From: Yuanhan Liu Date: Thu, 12 Jan 2017 05:37:00 +0000 (+0800) Subject: net/virtio: do not store PCI device pointer at shared memory X-Git-Tag: spdx-start~5164 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9470427c88e1;p=dpdk.git net/virtio: do not store PCI device pointer at shared memory hw->dev, a pointer to pci_dev, was actually not used, until the refactor of decouping from PCI device. This would somehow break the multiple process again, since "hw" is stored at shared memory, while "pci_dev" is not: the primary and secondary process could have different address for it, while just one value is allowed. Thus we should not store it to "hw", instead, we could retrieve it from the "eth_dev->device" field. Fixes: ae34410a8a8a ("ethdev: move info filling of PCI into drivers") Fixes: eac901ce29be ("ethdev: decouple from PCI device") Signed-off-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index dfd7e9f2a2..0a76cce21e 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -489,7 +489,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx) * virtual address. And we need properly set _offset_, please see * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information. */ - if (hw->dev) + if (!hw->virtio_user_dev) vq->offset = offsetof(struct rte_mbuf, buf_physaddr); else { vq->vq_ring_mem = (uintptr_t)mz->addr; @@ -1194,7 +1194,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) struct virtio_hw *hw = eth_dev->data->dev_private; struct virtio_net_config *config; struct virtio_net_config local_config; - struct rte_pci_device *pci_dev = hw->dev; + struct rte_pci_device *pci_dev = NULL; int ret; /* Reset the device although not necessary at startup */ @@ -1214,7 +1214,8 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) else eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; - if (pci_dev) { + if (eth_dev->device) { + pci_dev = RTE_DEV_TO_PCI(eth_dev->device); rte_eth_copy_pci_info(eth_dev, pci_dev); eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE; } @@ -1408,8 +1409,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) { - struct virtio_hw *hw = eth_dev->data->dev_private; - PMD_INIT_FUNC_TRACE(); if (rte_eal_process_type() == RTE_PROC_SECONDARY) @@ -1430,8 +1429,8 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) rte_intr_callback_unregister(eth_dev->intr_handle, virtio_interrupt_handler, eth_dev); - if (hw->dev) - rte_eal_pci_unmap_device(hw->dev); + if (eth_dev->device) + rte_eal_pci_unmap_device(RTE_DEV_TO_PCI(eth_dev->device)); PMD_INIT_LOG(DEBUG, "dev_uninit completed"); @@ -1689,7 +1688,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint64_t tso_mask; struct virtio_hw *hw = dev->data->dev_private; - dev_info->pci_dev = hw->dev; + dev_info->pci_dev = dev->device ? RTE_DEV_TO_PCI(dev->device) : NULL; dev_info->max_rx_queues = RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES); dev_info->max_tx_queues = diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 8d5355c75e..34ca01b23f 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -731,8 +731,6 @@ int vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw, uint32_t *dev_flags) { - hw->dev = dev; - /* * Try if we can succeed reading virtio pci caps, which exists * only on modern pci device. If failed, we fallback to legacy diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index 511a1c8794..4235beff10 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -258,7 +258,6 @@ struct virtio_hw { uint32_t notify_off_multiplier; uint8_t *isr; uint16_t *notify_base; - struct rte_pci_device *dev; struct virtio_pci_common_cfg *common_cfg; struct virtio_net_config *dev_cfg; void *virtio_user_dev;