Commit bbaba479 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Michael S. Tsirkin

virtio: provide a method to get the IRQ affinity mask for a virtqueue

This basically passed up the pci_irq_get_affinity information through
virtio through an optional get_vq_affinity method.  It is only implemented
by the PCI backend for now, and only when we use per-virtqueue IRQs.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent fb5e31d9
...@@ -361,6 +361,17 @@ int vp_set_vq_affinity(struct virtqueue *vq, int cpu) ...@@ -361,6 +361,17 @@ int vp_set_vq_affinity(struct virtqueue *vq, int cpu)
return 0; return 0;
} }
const struct cpumask *vp_get_vq_affinity(struct virtio_device *vdev, int index)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
unsigned int *map = vp_dev->msix_vector_map;
if (!map || map[index] == VIRTIO_MSI_NO_VECTOR)
return NULL;
return pci_irq_get_affinity(vp_dev->pci_dev, map[index]);
}
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int virtio_pci_freeze(struct device *dev) static int virtio_pci_freeze(struct device *dev)
{ {
......
...@@ -108,6 +108,8 @@ const char *vp_bus_name(struct virtio_device *vdev); ...@@ -108,6 +108,8 @@ const char *vp_bus_name(struct virtio_device *vdev);
*/ */
int vp_set_vq_affinity(struct virtqueue *vq, int cpu); int vp_set_vq_affinity(struct virtqueue *vq, int cpu);
const struct cpumask *vp_get_vq_affinity(struct virtio_device *vdev, int index);
#if IS_ENABLED(CONFIG_VIRTIO_PCI_LEGACY) #if IS_ENABLED(CONFIG_VIRTIO_PCI_LEGACY)
int virtio_pci_legacy_probe(struct virtio_pci_device *); int virtio_pci_legacy_probe(struct virtio_pci_device *);
void virtio_pci_legacy_remove(struct virtio_pci_device *); void virtio_pci_legacy_remove(struct virtio_pci_device *);
......
...@@ -190,6 +190,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = { ...@@ -190,6 +190,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
.finalize_features = vp_finalize_features, .finalize_features = vp_finalize_features,
.bus_name = vp_bus_name, .bus_name = vp_bus_name,
.set_vq_affinity = vp_set_vq_affinity, .set_vq_affinity = vp_set_vq_affinity,
.get_vq_affinity = vp_get_vq_affinity,
}; };
/* the PCI probing function */ /* the PCI probing function */
......
...@@ -437,6 +437,7 @@ static const struct virtio_config_ops virtio_pci_config_nodev_ops = { ...@@ -437,6 +437,7 @@ static const struct virtio_config_ops virtio_pci_config_nodev_ops = {
.finalize_features = vp_finalize_features, .finalize_features = vp_finalize_features,
.bus_name = vp_bus_name, .bus_name = vp_bus_name,
.set_vq_affinity = vp_set_vq_affinity, .set_vq_affinity = vp_set_vq_affinity,
.get_vq_affinity = vp_get_vq_affinity,
}; };
static const struct virtio_config_ops virtio_pci_config_ops = { static const struct virtio_config_ops virtio_pci_config_ops = {
...@@ -452,6 +453,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = { ...@@ -452,6 +453,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
.finalize_features = vp_finalize_features, .finalize_features = vp_finalize_features,
.bus_name = vp_bus_name, .bus_name = vp_bus_name,
.set_vq_affinity = vp_set_vq_affinity, .set_vq_affinity = vp_set_vq_affinity,
.get_vq_affinity = vp_get_vq_affinity,
}; };
/** /**
......
...@@ -58,6 +58,7 @@ struct irq_affinity; ...@@ -58,6 +58,7 @@ struct irq_affinity;
* This returns a pointer to the bus name a la pci_name from which * This returns a pointer to the bus name a la pci_name from which
* the caller can then copy. * the caller can then copy.
* @set_vq_affinity: set the affinity for a virtqueue. * @set_vq_affinity: set the affinity for a virtqueue.
* @get_vq_affinity: get the affinity for a virtqueue (optional).
*/ */
typedef void vq_callback_t(struct virtqueue *); typedef void vq_callback_t(struct virtqueue *);
struct virtio_config_ops { struct virtio_config_ops {
...@@ -77,6 +78,8 @@ struct virtio_config_ops { ...@@ -77,6 +78,8 @@ struct virtio_config_ops {
int (*finalize_features)(struct virtio_device *vdev); int (*finalize_features)(struct virtio_device *vdev);
const char *(*bus_name)(struct virtio_device *vdev); const char *(*bus_name)(struct virtio_device *vdev);
int (*set_vq_affinity)(struct virtqueue *vq, int cpu); int (*set_vq_affinity)(struct virtqueue *vq, int cpu);
const struct cpumask *(*get_vq_affinity)(struct virtio_device *vdev,
int index);
}; };
/* If driver didn't advertise the feature, it will never appear. */ /* If driver didn't advertise the feature, it will never appear. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment