[dpdk-dev] [PATCH v2] igb_uio: allow multi-process access

Xiao Wang xiao.w.wang at intel.com
Tue Dec 19 16:42:20 CET 2017


In some case, one device are accessed by different processes via
different BARs, so one uio device may be opened by more than one
process, for this case we just need to enable interrupt once, and
pci_clear_master only when the last process closed.

Fixes: 5f6ff30dc507 ("igb_uio: fix interrupt enablement after FLR in VM")

Signed-off-by: Xiao Wang <xiao.w.wang at intel.com>
---
v2:
- Make uio reference counter operation atomic.
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index a3a98c1..0c42cc4 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -45,6 +45,7 @@ struct rte_uio_pci_dev {
 	struct uio_info info;
 	struct pci_dev *pdev;
 	enum rte_intr_mode mode;
+	atomic_t refcnt;
 };
 
 static char *intr_mode;
@@ -336,6 +337,10 @@ struct rte_uio_pci_dev {
 	struct pci_dev *dev = udev->pdev;
 	int err;
 
+	atomic_inc(&udev->refcnt);
+	if (atomic_read(&udev->refcnt) > 1)
+		return 0;
+
 	/* set bus master, which was cleared by the reset function */
 	pci_set_master(dev);
 
@@ -354,6 +359,10 @@ struct rte_uio_pci_dev {
 	struct rte_uio_pci_dev *udev = info->priv;
 	struct pci_dev *dev = udev->pdev;
 
+	atomic_dec(&udev->refcnt);
+	if (atomic_read(&udev->refcnt) > 0)
+		return 0;
+
 	/* disable interrupts */
 	igbuio_pci_disable_interrupts(udev);
 
-- 
1.8.3.1



More information about the dev mailing list