From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH] igb_uio: allow multi-process access Date: Thu, 8 Mar 2018 13:17:00 -0800 Message-ID: <20180308131700.1569797c@xeon-e3> References: <1512784653-128951-1-git-send-email-xiao.w.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: ferruh.yigit@intel.com, dev@dpdk.org To: Xiao Wang Return-path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id B9CA42C01 for ; Thu, 8 Mar 2018 22:17:03 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id j2so417817pff.10 for ; Thu, 08 Mar 2018 13:17:03 -0800 (PST) In-Reply-To: <1512784653-128951-1-git-send-email-xiao.w.wang@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, 8 Dec 2017 17:57:33 -0800 Xiao Wang wrote: > 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) Minor nit: Parenthesis is unnecessary here. > + 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); > You might consider using new reference counting (refcnt_t) in kernel which protects against accidental under/overflow.