From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 1891B1DBF for ; Tue, 19 Dec 2017 10:05:04 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2017 01:05:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,425,1508828400"; d="scan'208";a="19472629" Received: from deepin-15.sh.intel.com (HELO debian-xvivbkq) ([10.67.104.165]) by orsmga002.jf.intel.com with ESMTP; 19 Dec 2017 01:05:02 -0800 Date: Tue, 19 Dec 2017 17:04:34 +0800 From: Tiwei Bie To: Xiao Wang Cc: ferruh.yigit@intel.com, dev@dpdk.org, stephen@networkplumber.org Message-ID: <20171219090433.3jymojar7of3mkdm@debian-xvivbkq> References: <1512784653-128951-1-git-send-email-xiao.w.wang@intel.com> <1513698140-92837-1-git-send-email-xiao.w.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1513698140-92837-1-git-send-email-xiao.w.wang@intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Subject: Re: [dpdk-dev] [PATCH v2] 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: , X-List-Received-Date: Tue, 19 Dec 2017 09:05:05 -0000 Hi, On Tue, Dec 19, 2017 at 07:42:20AM -0800, Xiao Wang wrote: > @@ -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) The "inc and read" should be atomic. Otherwise below sequence may happen: P1: atomic_inc(&udev->refcnt); P2: atomic_inc(&udev->refcnt); P1: if (atomic_read(&udev->refcnt) > 1) P2: 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; Ditto. Best regards, Tiwei Bie > + > /* disable interrupts */ > igbuio_pci_disable_interrupts(udev); > > -- > 1.8.3.1 >