summaryrefslogtreecommitdiff
path: root/drivers/net/virtio/virtio_pci.c
diff options
context:
space:
mode:
authorJianfeng Tan <jianfeng.tan@intel.com>2016-05-09 09:35:57 -0700
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-05-10 10:57:10 -0700
commit62a785a68ebf710eba22b70b46a970a4e4e1cec7 (patch)
tree839e4f6bf37e049d1ff6dde57177c1d8727a317a /drivers/net/virtio/virtio_pci.c
parente928fd0bb0118387f04811970b11504b199b5ed1 (diff)
downloaddpdk-next-eventdev-62a785a68ebf710eba22b70b46a970a4e4e1cec7.zip
dpdk-next-eventdev-62a785a68ebf710eba22b70b46a970a4e4e1cec7.tar.gz
dpdk-next-eventdev-62a785a68ebf710eba22b70b46a970a4e4e1cec7.tar.xz
virtio: fix overwritten driver flags
The "drv_flags" is set with device as the input, which means different device (say, modern vs legacy) could end up with a different value. And the fact that "drv_flags" is shared by all devices means that every time we add a new device, it simply overwrites the value configured from the last device. Therefore, when two virtio devices have different flags, it may lead to wrong result, such as virtio would set irq config when it's not supported. Making the flag per device (using "dev->data->dev_flags") could let us have different value for each device, which would avoid the above issue. Fixes: da978dfdc43 ("virtio: use port IO to get PCI resource") Reported-by: David Marchand <david.marchand@6wind.com> Suggested-by: David Marchand <david.marchand@6wind.com> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> Acked-by: David Marchand <david.marchand@6wind.com> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Diffstat (limited to 'drivers/net/virtio/virtio_pci.c')
-rw-r--r--drivers/net/virtio/virtio_pci.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index c007959..9cdca06 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -199,15 +199,15 @@ legacy_virtio_has_msix(const struct rte_pci_addr *loc __rte_unused)
static int
legacy_virtio_resource_init(struct rte_pci_device *pci_dev,
- struct virtio_hw *hw)
+ struct virtio_hw *hw, uint32_t *dev_flags)
{
if (rte_eal_pci_ioport_map(pci_dev, 0, &hw->io) < 0)
return -1;
if (pci_dev->intr_handle.type != RTE_INTR_HANDLE_UNKNOWN)
- pci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;
+ *dev_flags |= RTE_ETH_DEV_INTR_LSC;
else
- pci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
+ *dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
return 0;
}
@@ -630,7 +630,8 @@ next:
* Return 0 on success.
*/
int
-vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
+vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw,
+ uint32_t *dev_flags)
{
hw->dev = dev;
@@ -643,12 +644,12 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
PMD_INIT_LOG(INFO, "modern virtio pci detected.");
hw->vtpci_ops = &modern_ops;
hw->modern = 1;
- dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;
+ *dev_flags |= RTE_ETH_DEV_INTR_LSC;
return 0;
}
PMD_INIT_LOG(INFO, "trying with legacy virtio pci.");
- if (legacy_virtio_resource_init(dev, hw) < 0) {
+ if (legacy_virtio_resource_init(dev, hw, dev_flags) < 0) {
if (dev->kdrv == RTE_KDRV_UNKNOWN &&
dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) {
PMD_INIT_LOG(INFO,