From patchwork Sat Dec 9 01:57:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Wang X-Patchwork-Id: 32048 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6A3637CFD; Sat, 9 Dec 2017 02:55:16 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 4F93B37B1 for ; Sat, 9 Dec 2017 02:55:14 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Dec 2017 17:55:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,380,1508828400"; d="scan'208";a="182656042" Received: from dpdk-xiao-1.sh.intel.com ([10.67.110.203]) by orsmga005.jf.intel.com with ESMTP; 08 Dec 2017 17:54:59 -0800 From: Xiao Wang To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Xiao Wang Date: Fri, 8 Dec 2017 17:57:33 -0800 Message-Id: <1512784653-128951-1-git-send-email-xiao.w.wang@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] igb_uio: allow multi-process access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 7 +++++++ 1 file changed, 7 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..c239d98 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; + uint32_t ref_cnt; }; static char *intr_mode; @@ -336,6 +337,9 @@ struct rte_uio_pci_dev { struct pci_dev *dev = udev->pdev; int err; + if (++(udev->ref_cnt) > 1) + return 0; + /* set bus master, which was cleared by the reset function */ pci_set_master(dev); @@ -354,6 +358,9 @@ struct rte_uio_pci_dev { struct rte_uio_pci_dev *udev = info->priv; struct pci_dev *dev = udev->pdev; + if (--(udev->ref_cnt) > 0) + return 0; + /* disable interrupts */ igbuio_pci_disable_interrupts(udev);