From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <xiao.w.wang@intel.com>
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 815BBE5D
 for <dev@dpdk.org>; Mon, 18 Dec 2017 16:53:50 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga004.jf.intel.com ([10.7.209.38])
 by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 18 Dec 2017 07:53:49 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.45,422,1508828400"; d="scan'208";a="159791024"
Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204])
 by orsmga004.jf.intel.com with ESMTP; 18 Dec 2017 07:53:48 -0800
Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by
 FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS)
 id 14.3.319.2; Mon, 18 Dec 2017 07:53:39 -0800
Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by
 FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS)
 id 14.3.319.2; Mon, 18 Dec 2017 07:53:38 -0800
Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.159]) by
 SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002;
 Mon, 18 Dec 2017 23:53:37 +0800
From: "Wang, Xiao W" <xiao.w.wang@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
CC: "Yigit, Ferruh" <ferruh.yigit@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH] igb_uio: allow multi-process access
Thread-Index: AQHTcJDERXZz4GzGOEmIIDhNzAQk8aM+bLOAgArg3YA=
Date: Mon, 18 Dec 2017 15:53:36 +0000
Message-ID: <B7F2E978279D1D49A3034B7786DACF406F8040A4@SHSMSX101.ccr.corp.intel.com>
References: <1512784653-128951-1-git-send-email-xiao.w.wang@intel.com>
 <20171211173855.3eed4623@xeon-e3>
In-Reply-To: <20171211173855.3eed4623@xeon-e3>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ctpclassification: CTP_IC
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDAyZjEyM2EtMjU4My00ZWYxLTg1MGItOTI3Y2Y1ODE2MWM0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ5VnMwUjFLMHBzcXNwS1BOcWFLQVhBZHJnR29OdWhONHVjVU1HSU5SUE5qRWlzWHozMWlKQjBVRTdKeXZxNHlKIn0=
dlp-product: dlpe-windows
dlp-version: 11.0.0.116
dlp-reaction: no-action
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [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 <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 18 Dec 2017 15:53:50 -0000

Hi,

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Tuesday, December 12, 2017 9:39 AM
> To: Wang, Xiao W <xiao.w.wang@intel.com>
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] igb_uio: allow multi-process access
>=20
> On Fri,  8 Dec 2017 17:57:33 -0800
> Xiao Wang <xiao.w.wang@intel.com> wrote:
>=20
> > 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=
")
>=20
>=20
> Yes, this makes sense.
>=20
> >
> > Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> > ---
> >  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;
>=20
> Simple unsigned reference count is not SMP safe on all architectures.
> In kernel it is recommended to use refcount_t and associated API's.
> Note: refcount_t was introduced in last 2 years and some DPDK users
> still have ancient kernels.

I think atomic_t associated API will be enough, without worry about kernel =
version.

>=20
> >  };
> >
> >  static char *intr_mode;
> > @@ -336,6 +337,9 @@ struct rte_uio_pci_dev {
> >  	struct pci_dev *dev =3D udev->pdev;
> >  	int err;
> >
> > +	if (++(udev->ref_cnt) > 1)
> > +		return 0;
>=20
> Do not use (unnecessary) parenthesis. C precedence order is well defined.

Agree. Will change it in v2.

Thanks for your comments,
Xiao