mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
virtio: unify config_changed handling
Replace duplicated code in all transports with a single wrapper in
virtio.c.
The only functional change is in virtio_mmio.c: if a buggy device sends
us an interrupt before driver is set, we previously returned IRQ_NONE,
now we return IRQ_HANDLED.
As this must not happen in practice, this does not look like a big deal.
See also commit 3fff0179e3
virtio-pci: do not oops on config change if driver not loaded.
for the original motivation behind the driver check.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
6fbc198cf6
commit
016c98c6fe
@ -462,16 +462,12 @@ static void mic_handle_config_change(struct mic_device_desc __iomem *d,
|
||||
struct mic_device_ctrl __iomem *dc
|
||||
= (void __iomem *)d + mic_aligned_desc_size(d);
|
||||
struct mic_vdev *mvdev = (struct mic_vdev *)ioread64(&dc->vdev);
|
||||
struct virtio_driver *drv;
|
||||
|
||||
if (ioread8(&dc->config_change) != MIC_VIRTIO_PARAM_CONFIG_CHANGED)
|
||||
return;
|
||||
|
||||
dev_dbg(mdrv->dev, "%s %d\n", __func__, __LINE__);
|
||||
drv = container_of(mvdev->vdev.dev.driver,
|
||||
struct virtio_driver, driver);
|
||||
if (drv->config_changed)
|
||||
drv->config_changed(&mvdev->vdev);
|
||||
virtio_config_changed(&mvdev->vdev);
|
||||
iowrite8(1, &dc->guest_ack);
|
||||
}
|
||||
|
||||
|
@ -406,15 +406,8 @@ static void kvm_extint_handler(struct ext_code ext_code,
|
||||
|
||||
switch (param) {
|
||||
case VIRTIO_PARAM_CONFIG_CHANGED:
|
||||
{
|
||||
struct virtio_driver *drv;
|
||||
drv = container_of(vq->vdev->dev.driver,
|
||||
struct virtio_driver, driver);
|
||||
if (drv->config_changed)
|
||||
drv->config_changed(vq->vdev);
|
||||
|
||||
virtio_config_changed(vq->vdev);
|
||||
break;
|
||||
}
|
||||
case VIRTIO_PARAM_DEV_ADD:
|
||||
schedule_work(&hotplug_work);
|
||||
break;
|
||||
|
@ -940,11 +940,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev,
|
||||
vring_interrupt(0, vq);
|
||||
}
|
||||
if (test_bit(0, &vcdev->indicators2)) {
|
||||
drv = container_of(vcdev->vdev.dev.driver,
|
||||
struct virtio_driver, driver);
|
||||
|
||||
if (drv && drv->config_changed)
|
||||
drv->config_changed(&vcdev->vdev);
|
||||
virtio_config_changed(&vcdev->vdev);
|
||||
clear_bit(0, &vcdev->indicators2);
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +239,15 @@ void unregister_virtio_device(struct virtio_device *dev)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(unregister_virtio_device);
|
||||
|
||||
void virtio_config_changed(struct virtio_device *dev)
|
||||
{
|
||||
struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
|
||||
|
||||
if (drv && drv->config_changed)
|
||||
drv->config_changed(dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(virtio_config_changed);
|
||||
|
||||
static int virtio_init(void)
|
||||
{
|
||||
if (bus_register(&virtio_bus) != 0)
|
||||
|
@ -234,8 +234,6 @@ static irqreturn_t vm_interrupt(int irq, void *opaque)
|
||||
{
|
||||
struct virtio_mmio_device *vm_dev = opaque;
|
||||
struct virtio_mmio_vq_info *info;
|
||||
struct virtio_driver *vdrv = container_of(vm_dev->vdev.dev.driver,
|
||||
struct virtio_driver, driver);
|
||||
unsigned long status;
|
||||
unsigned long flags;
|
||||
irqreturn_t ret = IRQ_NONE;
|
||||
@ -244,9 +242,8 @@ static irqreturn_t vm_interrupt(int irq, void *opaque)
|
||||
status = readl(vm_dev->base + VIRTIO_MMIO_INTERRUPT_STATUS);
|
||||
writel(status, vm_dev->base + VIRTIO_MMIO_INTERRUPT_ACK);
|
||||
|
||||
if (unlikely(status & VIRTIO_MMIO_INT_CONFIG)
|
||||
&& vdrv && vdrv->config_changed) {
|
||||
vdrv->config_changed(&vm_dev->vdev);
|
||||
if (unlikely(status & VIRTIO_MMIO_INT_CONFIG)) {
|
||||
virtio_config_changed(&vm_dev->vdev);
|
||||
ret = IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -211,12 +211,8 @@ static bool vp_notify(struct virtqueue *vq)
|
||||
static irqreturn_t vp_config_changed(int irq, void *opaque)
|
||||
{
|
||||
struct virtio_pci_device *vp_dev = opaque;
|
||||
struct virtio_driver *drv;
|
||||
drv = container_of(vp_dev->vdev.dev.driver,
|
||||
struct virtio_driver, driver);
|
||||
|
||||
if (drv && drv->config_changed)
|
||||
drv->config_changed(&vp_dev->vdev);
|
||||
virtio_config_changed(&vp_dev->vdev);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,8 @@ void unregister_virtio_device(struct virtio_device *dev);
|
||||
|
||||
void virtio_break_device(struct virtio_device *dev);
|
||||
|
||||
void virtio_config_changed(struct virtio_device *dev);
|
||||
|
||||
/**
|
||||
* virtio_driver - operations for a virtio I/O driver
|
||||
* @driver: underlying device driver (populate name and owner).
|
||||
|
Loading…
Reference in New Issue
Block a user