From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id B337E1B1B9 for ; Wed, 24 Jan 2018 16:41:04 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 66023226C8; Wed, 24 Jan 2018 10:41:04 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:41:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=7E9z6HHcEVyHJhSpJ fU4ZZsbRR1qKeCW1ngwCwlxkEc=; b=Z/rPKuK6rJgNpFaHnnyx6KokF0dKP0Qo0 SMU5hfW19fd62zmx0vg+xfN8gdpEMhMesdFEqoyBRC98Pykom0/yCdfvHxOSOjQp mSc+PQdGfd8drvm+uPPn4/B2wfhH9yv5VlQHIXDZoIt/pLPFUgswjtJCAg2MSzLq 2iY3vJbw3EAwCLYp7duQfal4uuF/zNsEIa7oF2M01yJyUrc8mvN+GADnYKXiHA8K GT/njMabceKsZP9z27wu2yXHjm75DDedDdJyjXD6zMS/lBAXUhEXIIGYQ8/onf+1 wTvFXtmP0rRnN4j17Ye7i0vipwihhSHmzYGM00Ggt2GDFg3zZO6rw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=7E9z6HHcEVyHJhSpJfU4ZZsbRR1qKeCW1ngwCwlxkEc=; b=iB8EH35R q+KD7niaiv4A4lSVcBhFc1jspdvq3IEOrDz4xyUgoczmpLefPaoutUm9GgsD/3pD +aTgyaSMCaHww4syJnRef0lsCqbibGAE+mLPTnFrXdtWjc3Z2yq9ckdBvomSS7ie lvtHoy7V8VnIPa3tPRKtZXnpEpQZPnIrpLsv+FZ5NCKGtZvrCPs0RXBt7vjGJncE 7kjw5lTtgKhtOAfzNMKRXshTBHtELmfV8Dfkwj1RDn5/1JY0cgLlF2qYGGtdjoBh baXcO2rlEzMVSrd8ZGaaQGFTLx9E0Gm6n69qX/L0wDIknADLOmyidwbc9ZRPkl8e 7XV65JXMdtkZ5g== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 490907E1A2; Wed, 24 Jan 2018 10:41:01 -0500 (EST) From: Yuanhan Liu To: Xiao Wang Cc: Ferruh Yigit , dpdk stable Date: Wed, 24 Jan 2018 23:33:04 +0800 Message-Id: <1516808026-25523-116-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'igb_uio: allow multi-process access' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:41:05 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From caedec7911c6f04ceb41a777ca3665b8df44e329 Mon Sep 17 00:00:00 2001 From: Xiao Wang Date: Mon, 1 Jan 2018 14:00:10 -0800 Subject: [PATCH] igb_uio: allow multi-process access [ upstream commit 19685d5aa79c2f86486b0afee6db4c7a280ea7b3 ] 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 Acked-by: Ferruh Yigit --- lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 18 ++++++++++++++++++ 1 file changed, 18 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..1826adb 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -45,6 +45,8 @@ struct rte_uio_pci_dev { struct uio_info info; struct pci_dev *pdev; enum rte_intr_mode mode; + struct mutex lock; + int refcnt; }; static char *intr_mode; @@ -336,11 +338,18 @@ igbuio_pci_open(struct uio_info *info, struct inode *inode) struct pci_dev *dev = udev->pdev; int err; + mutex_lock(&udev->lock); + if (++udev->refcnt > 1) { + mutex_unlock(&udev->lock); + return 0; + } + /* set bus master, which was cleared by the reset function */ pci_set_master(dev); /* enable interrupts */ err = igbuio_pci_enable_interrupts(udev); + mutex_unlock(&udev->lock); if (err) { dev_err(&dev->dev, "Enable interrupt fails\n"); return err; @@ -354,12 +363,19 @@ igbuio_pci_release(struct uio_info *info, struct inode *inode) struct rte_uio_pci_dev *udev = info->priv; struct pci_dev *dev = udev->pdev; + mutex_lock(&udev->lock); + if (--udev->refcnt > 0) { + mutex_unlock(&udev->lock); + return 0; + } + /* disable interrupts */ igbuio_pci_disable_interrupts(udev); /* stop the device from further DMA */ pci_clear_master(dev); + mutex_unlock(&udev->lock); return 0; } @@ -480,6 +496,7 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) if (!udev) return -ENOMEM; + mutex_init(&udev->lock); /* * enable device: ask low-level code to enable I/O and * memory @@ -570,6 +587,7 @@ igbuio_pci_remove(struct pci_dev *dev) { struct rte_uio_pci_dev *udev = pci_get_drvdata(dev); + mutex_destroy(&udev->lock); sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); uio_unregister_device(&udev->info); igbuio_pci_release_iomem(&udev->info); -- 2.7.4