mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
virtio/virtio-pci: remove unused config change IRQ handler
The config change IRQ is not currently used. Remove it now and add it back when actually needed. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
5c835881b2
commit
63c147bfa4
@@ -108,10 +108,6 @@ virtio_pci_legacy_get_queue_len(FAR struct virtio_pci_device_s *vpdev,
|
||||
static int
|
||||
virtio_pci_legacy_create_virtqueue(FAR struct virtio_pci_device_s *vpdev,
|
||||
FAR struct virtqueue *vq);
|
||||
static int
|
||||
virtio_pci_legacy_config_vector(FAR struct virtio_pci_device_s *vpdev,
|
||||
bool enable);
|
||||
|
||||
static void
|
||||
virtio_pci_legacy_delete_virtqueue(FAR struct virtio_device *vdev,
|
||||
int index);
|
||||
@@ -152,7 +148,6 @@ static const struct virtio_dispatch g_virtio_pci_dispatch =
|
||||
static const struct virtio_pci_ops_s g_virtio_pci_legacy_ops =
|
||||
{
|
||||
virtio_pci_legacy_get_queue_len, /* get_queue_len */
|
||||
virtio_pci_legacy_config_vector, /* config_vector */
|
||||
virtio_pci_legacy_create_virtqueue, /* create_virtqueue */
|
||||
virtio_pci_legacy_delete_virtqueue, /* delete_virtqueue */
|
||||
};
|
||||
@@ -211,7 +206,7 @@ virtio_pci_legacy_create_virtqueue(FAR struct virtio_pci_device_s *vpdev,
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
pci_write_io_word(vpdev->dev,
|
||||
(uintptr_t)(vpdev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR),
|
||||
VIRTIO_PCI_INT_VQ);
|
||||
0);
|
||||
pci_read_io_word(vpdev->dev,
|
||||
(uintptr_t)(vpdev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR),
|
||||
&msix_vector);
|
||||
@@ -228,32 +223,6 @@ virtio_pci_legacy_create_virtqueue(FAR struct virtio_pci_device_s *vpdev,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_pci_legacy_config_vector
|
||||
****************************************************************************/
|
||||
|
||||
static int
|
||||
virtio_pci_legacy_config_vector(FAR struct virtio_pci_device_s *vpdev,
|
||||
bool enable)
|
||||
{
|
||||
uint16_t vector = enable ? 0 : VIRTIO_PCI_MSI_NO_VECTOR;
|
||||
uint16_t rvector;
|
||||
|
||||
pci_write_io_word(vpdev->dev,
|
||||
(uintptr_t)(vpdev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR),
|
||||
vector);
|
||||
pci_read_io_word(vpdev->dev,
|
||||
(uintptr_t)(vpdev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR),
|
||||
&rvector);
|
||||
|
||||
if (rvector != vector)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_pci_legacy_delete_virtqueue
|
||||
****************************************************************************/
|
||||
|
||||
@@ -161,9 +161,6 @@ static uint16_t
|
||||
virtio_pci_modern_get_queue_len(FAR struct virtio_pci_device_s *vpdev,
|
||||
int idx);
|
||||
static int
|
||||
virtio_pci_modern_config_vector(FAR struct virtio_pci_device_s *vpdev,
|
||||
bool enable);
|
||||
static int
|
||||
virtio_pci_modern_create_virtqueue(FAR struct virtio_pci_device_s *vpdev,
|
||||
FAR struct virtqueue *vq);
|
||||
static void
|
||||
@@ -206,7 +203,6 @@ static const struct virtio_dispatch g_virtio_pci_dispatch =
|
||||
static const struct virtio_pci_ops_s g_virtio_pci_modern_ops =
|
||||
{
|
||||
virtio_pci_modern_get_queue_len, /* get_queue_len */
|
||||
virtio_pci_modern_config_vector, /* config_vector */
|
||||
virtio_pci_modern_create_virtqueue, /* create_virtqueue */
|
||||
virtio_pci_modern_delete_virtqueue, /* delete_virtqueue */
|
||||
};
|
||||
@@ -344,8 +340,7 @@ virtio_pci_modern_create_virtqueue(FAR struct virtio_pci_device_s *vpdev,
|
||||
up_addrenv_va_to_pa(vq->vq_ring.used));
|
||||
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
pci_write_io_word(vpdev->dev, (uintptr_t)&cfg->queue_msix_vector,
|
||||
VIRTIO_PCI_INT_VQ);
|
||||
pci_write_io_word(vpdev->dev, (uintptr_t)&cfg->queue_msix_vector, 0);
|
||||
pci_read_io_word(vpdev->dev, (uintptr_t)&cfg->queue_msix_vector,
|
||||
&msix_vector);
|
||||
if (msix_vector == VIRTIO_PCI_MSI_NO_VECTOR)
|
||||
@@ -374,30 +369,6 @@ virtio_pci_modern_create_virtqueue(FAR struct virtio_pci_device_s *vpdev,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_pci_modern_config_vector
|
||||
****************************************************************************/
|
||||
|
||||
static int
|
||||
virtio_pci_modern_config_vector(FAR struct virtio_pci_device_s *vpdev,
|
||||
bool enable)
|
||||
{
|
||||
FAR struct virtio_pci_common_cfg_s *cfg = vpdev->common;
|
||||
uint16_t vector = enable ? 0 : VIRTIO_PCI_MSI_NO_VECTOR;
|
||||
uint16_t rvector;
|
||||
|
||||
pci_write_io_word(vpdev->dev, (uintptr_t)&cfg->config_msix_vector,
|
||||
vector);
|
||||
pci_read_io_word(vpdev->dev, (uintptr_t)&cfg->config_msix_vector,
|
||||
&rvector);
|
||||
if (rvector != vector)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_pci_modern_delete_virtqueue
|
||||
****************************************************************************/
|
||||
|
||||
+12
-39
@@ -120,18 +120,6 @@ static int virtio_pci_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_pci_config_changed
|
||||
****************************************************************************/
|
||||
|
||||
static int virtio_pci_config_changed(int irq, FAR void *context,
|
||||
FAR void *arg)
|
||||
{
|
||||
/* TODO: not support config changed notification */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#else
|
||||
/****************************************************************************
|
||||
* Name: virtio_pci_wdog
|
||||
@@ -226,27 +214,24 @@ static int virtio_pci_probe(FAR struct pci_device_s *dev)
|
||||
|
||||
/* Irq init */
|
||||
|
||||
ret = pci_alloc_irq(vpdev->dev, vpdev->irq, VIRTIO_PCI_INT_NUM);
|
||||
if (ret != VIRTIO_PCI_INT_NUM)
|
||||
ret = pci_alloc_irq(vpdev->dev, &vpdev->irq, 1);
|
||||
if (ret != 1)
|
||||
{
|
||||
vrterr("Failed to allocate MSI, ret=%d\n", ret);
|
||||
goto err_with_enable;
|
||||
}
|
||||
|
||||
vrtinfo("Interrupt mode: attaching MSI %d to %p, %d to %p\n",
|
||||
vpdev->irq[VIRTIO_PCI_INT_CFG], virtio_pci_config_changed,
|
||||
vpdev->irq[VIRTIO_PCI_INT_VQ], virtio_pci_interrupt);
|
||||
vrtinfo("Interrupt mode: attaching MSI %d to %p\n",
|
||||
vpdev->irq, virtio_pci_interrupt);
|
||||
|
||||
ret = pci_connect_irq(vpdev->dev, vpdev->irq, VIRTIO_PCI_INT_NUM);
|
||||
ret = pci_connect_irq(vpdev->dev, &vpdev->irq, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
vrterr("Failed to connect MSI %d\n", ret);
|
||||
goto err_with_irq;
|
||||
}
|
||||
|
||||
irq_attach(vpdev->irq[VIRTIO_PCI_INT_CFG],
|
||||
virtio_pci_config_changed, vpdev);
|
||||
irq_attach(vpdev->irq[VIRTIO_PCI_INT_VQ], virtio_pci_interrupt, vpdev);
|
||||
irq_attach(vpdev->irq, virtio_pci_interrupt, vpdev);
|
||||
#else
|
||||
vrtinfo("Polling mode\n");
|
||||
#endif
|
||||
@@ -265,10 +250,9 @@ static int virtio_pci_probe(FAR struct pci_device_s *dev)
|
||||
|
||||
err_with_attach:
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
irq_detach(vpdev->irq[VIRTIO_PCI_INT_CFG]);
|
||||
irq_detach(vpdev->irq[VIRTIO_PCI_INT_VQ]);
|
||||
irq_detach(vpdev->irq);
|
||||
err_with_irq:
|
||||
pci_release_irq(vpdev->dev, vpdev->irq, VIRTIO_PCI_INT_NUM);
|
||||
pci_release_irq(vpdev->dev, &vpdev->irq, 1);
|
||||
#endif
|
||||
err_with_enable:
|
||||
pci_clear_master(dev);
|
||||
@@ -289,9 +273,8 @@ static void virtio_pci_remove(FAR struct pci_device_s *dev)
|
||||
virtio_unregister_device(&vpdev->vdev);
|
||||
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
irq_detach(vpdev->irq[VIRTIO_PCI_INT_CFG]);
|
||||
irq_detach(vpdev->irq[VIRTIO_PCI_INT_VQ]);
|
||||
pci_release_irq(vpdev->dev, vpdev->irq, VIRTIO_PCI_INT_NUM);
|
||||
irq_detach(vpdev->irq);
|
||||
pci_release_irq(vpdev->dev, &vpdev->irq, 1);
|
||||
#endif
|
||||
|
||||
pci_clear_master(dev);
|
||||
@@ -407,15 +390,7 @@ int virtio_pci_create_virtqueues(FAR struct virtio_device *vdev,
|
||||
}
|
||||
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
ret = vpdev->ops->config_vector(vpdev, true);
|
||||
if (ret < 0)
|
||||
{
|
||||
vrterr("Config vector failed, vector=%u\n", ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
up_enable_irq(vpdev->irq[VIRTIO_PCI_INT_CFG]);
|
||||
up_enable_irq(vpdev->irq[VIRTIO_PCI_INT_VQ]);
|
||||
up_enable_irq(vpdev->irq);
|
||||
#else
|
||||
ret = wd_start(&vpdev->wdog, VIRTIO_PCI_WORK_DELAY, virtio_pci_wdog,
|
||||
(wdparm_t)vpdev);
|
||||
@@ -445,9 +420,7 @@ void virtio_pci_delete_virtqueues(FAR struct virtio_device *vdev)
|
||||
unsigned int i;
|
||||
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
up_disable_irq(vpdev->irq[VIRTIO_PCI_INT_CFG]);
|
||||
up_disable_irq(vpdev->irq[VIRTIO_PCI_INT_VQ]);
|
||||
vpdev->ops->config_vector(vpdev, false);
|
||||
up_disable_irq(vpdev->irq);
|
||||
#else
|
||||
wd_cancel(&vpdev->wdog);
|
||||
#endif
|
||||
|
||||
@@ -44,10 +44,6 @@
|
||||
|
||||
#define VIRTIO_PCI_MSI_NO_VECTOR 0xffff
|
||||
|
||||
#define VIRTIO_PCI_INT_CFG 0
|
||||
#define VIRTIO_PCI_INT_VQ 1
|
||||
#define VIRTIO_PCI_INT_NUM 2
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -69,8 +65,6 @@ struct virtio_pci_ops_s
|
||||
{
|
||||
CODE uint16_t (*get_queue_len)(FAR struct virtio_pci_device_s *vpdev,
|
||||
int idx);
|
||||
CODE int (*config_vector)(FAR struct virtio_pci_device_s *vpdev,
|
||||
bool enable);
|
||||
CODE int (*create_virtqueue)(FAR struct virtio_pci_device_s *vpdev,
|
||||
FAR struct virtqueue *vq);
|
||||
CODE void (*delete_virtqueue)(FAR struct virtio_device *vdev, int index);
|
||||
@@ -86,7 +80,7 @@ struct virtio_pci_device_s
|
||||
* virtqueue use this io.
|
||||
*/
|
||||
#if CONFIG_DRIVERS_VIRTIO_PCI_POLLING_PERIOD <= 0
|
||||
int irq[VIRTIO_PCI_INT_NUM];
|
||||
int irq;
|
||||
#else
|
||||
struct wdog_s wdog;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user