From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 57C9DA0526; Thu, 9 Jul 2020 07:14:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA5C61DA6E; Thu, 9 Jul 2020 07:14:03 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id BD9271D57F for ; Thu, 9 Jul 2020 07:14:01 +0200 (CEST) IronPort-SDR: UnuwpL2z+R7YNjDSht5ofInkW+79gl3BJ9r7yvGodGDSTfnOpmMv83/J8XL3uI+rq7nDC7/M6E tG+1g1X//2Gg== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="147014055" X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="147014055" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2020 22:13:57 -0700 IronPort-SDR: d+li3QHK01dBvfzeg5lSGVvZrKtd+p22PMgqvj3uWBQxs3oHU2dM/DwkPlXzWuAXEy2YBzy0dm DpeXZnMiQObA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="284023694" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga006.jf.intel.com with ESMTP; 08 Jul 2020 22:13:57 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 22:13:56 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 22:13:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VXqK+1kD35sGyWV1bD3zriLyY/vfy3ywBtZsdve26YQdwVEwQWG9b4qsh7l8RXXVsiuok8XABfowdiDqAGYG4FBy2UPH6hlhsLtcW20aFyRwdLFKbTSLMu+96nHrpBAWFdeAC/UOFHc2vY5YkyXuO3CiEf8TQ/QP/mfwyuiKBVbHXEcVo7UIRia5G1o7F6SqqfZQQUhVferJD2f1vt789m8i6Dl+ilbZFx5w5s7mvn29yndTlBhk7m9PQ2lIoxz89P6QDUpjLLxHkU50ndxK64yMyqyHE+wPGW9DhCAAHy0BsuE03Tjfxjt1QTgQukOlXsSISuoVKah46sdcRF2D1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ddF0Or70Yu3QblYTMAqMRDIbLEeY55U3o6RU3Hsy2fU=; b=czC9skqjCEPmK62FDiyg2DhRpAGEaiVaHH2KrXIhD36FGdTg5DWVZsge2M0CLe2KY6kbITNkJuaWU4GWZWLr255gG5fiFFCAFZ98fJbbzeJBycWy0d5Igu/HTTWh3VBo0KVeBxPHVm1TZ23eJ5qKnkvh73hcrhXHJN8nE9elFB1bTALj1ia2GvXZd36oz4vZw9s8tqoyAk0rUVSyW1HTUBL+YjKSU8ApBzVleuIG5r1ygb7VTKZI2X1mLJBOQUrhCTWgcuRyflmJQSSwR+OG9k7IzJxHJNCf9Va8DJQkHZgHhM/lFU1vtHtxyqdKI3nWAkPOE1ZYHWQb5J6/Waw9Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ddF0Or70Yu3QblYTMAqMRDIbLEeY55U3o6RU3Hsy2fU=; b=zpQa/TVWjqUZj0+WbLk6wUkRVr5XQ9qJSM9yknVvveffDJ7WLmlhFjQSITmql8DB/39VcRRsgmtqrCLxbAXlwuWmooMXtk1KtVgjX/DprkWleUSQvlyQ5oL0ujhaT+bzBEq0kON9dpDvAVCNBvIbyNGU8fYun0D2t3nPysUm1g8= Received: from SN6PR11MB2960.namprd11.prod.outlook.com (2603:10b6:805:d4::12) by SN6PR11MB3423.namprd11.prod.outlook.com (2603:10b6:805:db::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 05:13:54 +0000 Received: from SN6PR11MB2960.namprd11.prod.outlook.com ([fe80::20d6:bb89:9836:e68a]) by SN6PR11MB2960.namprd11.prod.outlook.com ([fe80::20d6:bb89:9836:e68a%7]) with mapi id 15.20.3174.022; Thu, 9 Jul 2020 05:13:54 +0000 From: "Zhang, AlvinX" To: "Xia, Chenbo" , "dev@dpdk.org" CC: David Marchand , Tal Shnaiderman , "Burakov, Anatoly" , "thomas@monjalon.net" Thread-Topic: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource Thread-Index: AQHWVQnn1RDxUua/TUiFOP0g9lYVRKj9tYuAgAD9q1A= Date: Thu, 9 Jul 2020 05:13:53 +0000 Message-ID: References: <20200708092435.9776-1-alvinx.zhang@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.46.46] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3d3be8dd-999b-44b2-267b-08d823c6dfea x-ms-traffictypediagnostic: SN6PR11MB3423: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JYJ1T3brUODyUD9ASJ4mrH8/4s0cD617q3GHSGIXH6zvAtvJ/Mml2FfMN1ZrAMggoKi7Moq6Z1HAx5tISzIysi07XT26vetceimTbJ1FS8LAEf+D02QdJKclZSB/jkqn3DLiY0Ya4YwGOgyG5umt/RvTge97HOjm2QjTECYF0d3athtQo+CZn0nKOOsv+/A3GWnmNsnB0LEbXFoNdliuVqFBYFn6w+K1MsgLvwgxlAdjme9oe/Hbc2Khw1TNMnjJcFcpWAE8Zu92zmmrl8EzAtt+rnwjn3XxoJFHfKsJqJwhKO2RN1gUNeKjXwuPdse6aJ03xRmHTNkXqonk5Mv0rATWtwuCBvyzXKjYEVFDT+3phSCd0Cq/INm16rTia9q68S1ZqgWclKRBpUXMWnV54A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2960.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(39860400002)(396003)(136003)(376002)(346002)(8936002)(4326008)(6506007)(53546011)(26005)(186003)(52536014)(7696005)(9686003)(86362001)(54906003)(66946007)(316002)(5660300002)(110136005)(8676002)(71200400001)(66446008)(64756008)(33656002)(83380400001)(55016002)(76116006)(2906002)(66556008)(478600001)(66476007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 9AdZblvWUpNs4kY5hpgeHNn1ufVoUdycs59+Ymbe6FOFKWD00d81LU1ha5RGew7GDgSVstOo8U4GUChCyHFinW1uZOUZO6Sym6xCqdoJyPerLekOO/TzDCzmIhEAfrU4Qk+Yk8x/fcU08QIwmwEHgSMU0tAgK2eblbmf/gV5psFb0HMIYiKSQ7EHIogSCQNLwbOA0/XDe3TM/1xPYtbqEJUtT8PCu3cm9YiIcMh68C5P/FW1BG570ZmemQUu+us3zBDYpbK0MHCxe025yj6svhScAMrgEshR3/5SpmFKlXvvNmH5LfQJA51ulyXZFm6iY7N6EU1nC7CxGZIM+ClxPawZvhXlDWSXS36kU7v1NbawsPZ/fwJ6rELATkH//KYBXJjcILf/T+NG2G7XR3/k8K1bdDp10dvYNQIHGCEcH/c= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2960.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d3be8dd-999b-44b2-267b-08d823c6dfea X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2020 05:13:53.8447 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Cc5pll1nvBkiGEFGZN2ZcDDKGXUo90LNLfMtYJqfgicqi4Fgib3u06mQLfkVmrG13fuVWxNQKV/u+g3B5sxRbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3423 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource 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" Hi Chenbo, Thanks your comments. > -----Original Message----- > From: Xia, Chenbo > Sent: Wednesday, July 8, 2020 9:58 PM > To: Zhang, AlvinX ; dev@dpdk.org > Cc: Xing, Beilei ; Guo, Jia ; D= avid > Marchand ; Tal Shnaiderman > ; Burakov, Anatoly ; > thomas@monjalon.net > Subject: RE: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource >=20 > Hi Alvin, >=20 > CC the maintainers. Comments below. >=20 > > -----Original Message----- > > From: dev On Behalf Of alvinx.zhang@intel.com > > Sent: Wednesday, July 8, 2020 5:25 PM > > To: dev@dpdk.org > > Cc: Xing, Beilei ; Guo, Jia > > Subject: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource > > > > From: Alvin Zhang > > > > When mapping a PCI BAR containing an MSI-X table, some devices do not > > need to actually map this BAR or only need to map part of them, which > > may cause the mapping to fail. Now some checks are added and a > > non-NULL initial value is set to the variable to avoid this situation. > > > > Fixes: 2fd3567e5425 ("pci: use OS generic memory mapping functions") > > Cc: talshn@mellanox.com > > > > Signed-off-by: Alvin Zhang > > --- > > drivers/bus/pci/linux/pci_vfio.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/bus/pci/linux/pci_vfio.c > > b/drivers/bus/pci/linux/pci_vfio.c > > index fdeb9a8..9143bfc 100644 > > --- a/drivers/bus/pci/linux/pci_vfio.c > > +++ b/drivers/bus/pci/linux/pci_vfio.c > > @@ -547,6 +547,14 @@ > > bar_index, > > memreg[0].offset, memreg[0].size, > > memreg[1].offset, memreg[1].size); > > + > > + if (memreg[0].size =3D=3D 0 && memreg[1].size =3D=3D 0) { > > + /* No need to map this BAR */ > > + RTE_LOG(DEBUG, EAL, "Skipping BAR%d\n", bar_index); > > + bar->size =3D 0; > > + bar->addr =3D 0; > > + return 0; > > + } >=20 > I'm not sure if this corner case will happen. If you confirmed it, Just i= gnore this. In theory, it is entirely possible if the misx-table size is equal to the b= ar size. >=20 > > } else { > > memreg[0].offset =3D bar->offset; > > memreg[0].size =3D bar->size; > > @@ -556,7 +564,9 @@ > > bar_addr =3D mmap(bar->addr, bar->size, 0, MAP_PRIVATE | > > MAP_ANONYMOUS | additional_flags, -1, 0); > > if (bar_addr !=3D MAP_FAILED) { > > - void *map_addr =3D NULL; > > + /* Set non NULL initial value for in case of no PCI mapping */ > > + void *map_addr =3D bar_addr; > > + >=20 > I see the issue that this patch wants to fix is based on an old kernel. > In older vfio-pci kernel module, MSI related reg cannot be mmaped in user= space > while in newer kernel it can be. That's why sometimes it cannot be reprod= uced > (https://bugs.dpdk.org/show_bug.cgi?id=3D503) >=20 > So under the condition of old kernel, there could be an example that Memr= eg 0 > has size 0 but Memreg 1 has non-zero size, which leads to Memreg 1 cannot= be > mmaped. Yes, it is. >=20 > So I'm fine with this part of code change. As this issue is blocking test= , we should > do fast confirm and review. >=20 > Thanks, > Chenbo >=20 > > if (memreg[0].size) { > > /* actual map of first part */ > > map_addr =3D pci_map_resource(bar_addr, vfio_dev_fd, > > -- > > 1.8.3.1