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 647A9A0526; Thu, 9 Jul 2020 07:21:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 38B0B1DA6E; Thu, 9 Jul 2020 07:21:24 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 491341D9D4 for ; Thu, 9 Jul 2020 07:21:22 +0200 (CEST) IronPort-SDR: uVVZg5McqgcBn8l1zKcaEACGMYgLq3/YX2PJ9K9joNEOzrZQm5ZKcWsCPoCi8U08LneXY8sZpe 1jPrg+m87eVw== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="166036983" X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="166036983" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2020 22:21:21 -0700 IronPort-SDR: fsdofnxMowc5dLzOg/si4pHXLt3tY3lNQUilukulQuvM8tFJzquhrno85L1blfJr3tZG1JUrrT k4+JtDqLIinw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="268659451" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 08 Jul 2020 22:21:21 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 22:21:21 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 22:21:20 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 22:21:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b80SD2QKBaBQmJ5jjmEBrcFqcIJ32iP6C3ixPiFFbU5uQUzd1tgSiFI/rMt+WL+HLQp4yMy/h3eRhildFxlGLB0zDgquLDPz0q2xdSk7NwkPh5wCboRDrduQhfNbb+1B3p7TXAN8zccfuuyZhE4iJTYdKzCmhUNGermy0jR3VqxSaq+vI6Sn8zrZpL9omv+PBn1llfglZq9SS86x14qZlMpHf2pTcimQ9DPTY1tEq9jlm0s4C9TrHDzITZW+SYAwtSdtEr260kXYBAbDyuWcFsEr62DMFsSNOLnEnA80Em5B2JZsTupF6i7X6VaEYBh2DotdXZtG2S+GpCpIYhVekg== 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=6Lcur2E1FLF+6p0gRBTOuTQ36In5DbPm5Rx33fHPu7I=; b=SlAJUO00Bm5T/on61ZexoV+xtGvY5rLtlxmVjoQEbnlhl1b/yu3/maKdigqbOeDm9Lp3UTE/lneFaECnImk6OTRlQFuUq2SylaI3u9zzmpVPAjzZltdxsqqJgX6pqK/8j6LNvPkJaWSspzu+5BhrahB7+7TW6Lymrm6TL/pm0QXo7VocgYmPOMvLwxe03lQHw/p4Z4+Z30UhnNdLSc892ENMlAW2o5DRuTQq7wfHE3vBEJ+ctJUMYuq9GhqdWNSZrWEag7g8lHyfdbOf/OD2D5qCx6jfjckjYq+feNLu3dZGchBR4sepayPG7BugqyK6/lMsyTrWSWD+Tiez6wTUOw== 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=6Lcur2E1FLF+6p0gRBTOuTQ36In5DbPm5Rx33fHPu7I=; b=MCKkbvQqlgVslDBtnIi9qPdADIcVyqCSRyjCO9U84AUWd7uskn2ZSQdjAsDYVlSa0vz4/E9W8uPwRAl0ScPqIgd8qjpe3EDi3cp+9lCAgiJrvaHPmU05rXBw4aOc/biURb+4AnJn7FqwxDwLS8oQSGeEbC3/csbiLB3is8CmBCc= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3869.namprd11.prod.outlook.com (2603:10b6:208:138::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Thu, 9 Jul 2020 05:21:18 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e%7]) with mapi id 15.20.3153.031; Thu, 9 Jul 2020 05:21:18 +0000 From: "Xia, Chenbo" To: "Zhang, AlvinX" , "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: AQHWVQny4OL7AABPaUCG1PWCsxlEOaj9sExQgAEFGYCAAAFVAA== Date: Thu, 9 Jul 2020 05:21:18 +0000 Message-ID: References: <20200708092435.9776-1-alvinx.zhang@intel.com> In-Reply-To: Accept-Language: zh-CN, 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.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af2e02a2-189e-4d6a-cbf1-08d823c7e8d7 x-ms-traffictypediagnostic: MN2PR11MB3869: 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-forefront-prvs: 04599F3534 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Hd66JOopQyI/lg9TqRLxUL+qZOION63izNhHWuY+8HGTwAUhij9Na0OtlNSfuivLbu+1r4NrwVH4hQPm8vZSQLNmUAKML+11PMy9XEKy/rDNRHDrUWlBotk9e9hfVBhqXWqyb6EzPfBSUx6AKXvxWETpnLo2B2BJpoHcj1HRpwex23+SsM68RLIOIg3hMpu10+esakIcbNBp8lmx/FZnS3h6zcLeOPi4E92UJf0ZxgowfGyFtVGTa/BA1J16M97b9vMiLvx27OSqcXRCgqy6TgGqtEzR6bPrr8K8ZggG8I4kULAv3YOjIFt4LuihXi/aNlaF8cx/ZZVrtCjWR9zSbdxVWxeW6aiPzpXT1BlhuHNPO8XzxdaTNOPeFpADZzpU9tlvVk5W+oT2EfLmBTdjZA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB4063.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(376002)(396003)(136003)(366004)(346002)(76116006)(7696005)(9686003)(53546011)(55016002)(110136005)(54906003)(6506007)(4326008)(33656002)(71200400001)(2906002)(478600001)(26005)(316002)(5660300002)(186003)(52536014)(83380400001)(66476007)(66446008)(66556008)(64756008)(66946007)(86362001)(8676002)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: lpl9b2hRQJ6L//PN5JUoyh9uG6MMiKNfT6JZdh7VwP6hRXFtk1Bc9YbOVfzXxQxz0jA240HP7DucRVHKhMoc/93/UXFTzOw45pheQlCjuxD2WJ/21MD3uvMuaAgP4lO6KaXi4N22jFKZ7wCBqnzrLLFQdd++vvzB7B8Lj6KAgjpAELWQ3727LgYmRGqZPOp2Z4pzrVPl4FsCWnuRs9P/jUGz3pS1iTMeXBWf/B0uRLB+46hJlMpgWOoni1+JfMubog+HQBJEVHWPw3LBSwvTGyTluKZg9aWdbRdbe+RPy6buDO2jL1UUlBatMOMIW+0/mfFUE+y4oCzPCEe/gwGET3pr3Zq0OeI3bTqgxLfzsf6MEIbds890i/USXnQw1LBWeIlUY3+XBEMrFPa2UzNKf491ae+fD+AHfiUASNvQpN06OJ09Alio+5gXyTAG2QsEFm4QBOwNUXcgF1jtf2kaB7nmX93pQ4Z/+rwORYnHEtqKtlOO9QfvgkA5Rg9MsY0H 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: MN2PR11MB4063.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: af2e02a2-189e-4d6a-cbf1-08d823c7e8d7 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2020 05:21:18.3956 (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: hQGmDeSUSDXIV3tIrRO0Q2TJSD4juzdoUU965lSSAf7cwlYbYe4Fy0jixhJMN1UGXOi1R+9BnGT1yBET/+3njQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3869 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" > -----Original Message----- > From: Zhang, AlvinX > Sent: Thursday, July 9, 2020 1:14 PM > To: Xia, Chenbo ; dev@dpdk.org > Cc: David Marchand ; Tal Shnaiderman > ; Burakov, Anatoly ; > thomas@monjalon.net > Subject: RE: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource >=20 > Hi Chenbo, >=20 > Thanks your comments. >=20 > > -----Original Message----- > > From: Xia, Chenbo > > Sent: Wednesday, July 8, 2020 9:58 PM > > To: Zhang, AlvinX ; dev@dpdk.org > > Cc: Xing, Beilei ; Guo, Jia > > ; David Marchand ; Tal > > Shnaiderman ; Burakov, Anatoly > > ; thomas@monjalon.net > > Subject: RE: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource > > > > Hi Alvin, > > > > CC the maintainers. Comments below. > > > > > -----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; > > > + } > > > > I'm not sure if this corner case will happen. If you confirmed it, Just= ignore this. >=20 > In theory, it is entirely possible if the misx-table size is equal to the= bar 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; > > > + > > > > 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 > > userspace while in newer kernel it can be. That's why sometimes it > > cannot be reproduced > > (https://bugs.dpdk.org/show_bug.cgi?id=3D503) > > > > So under the condition of old kernel, there could be an example that > > Memreg 0 has size 0 but Memreg 1 has non-zero size, which leads to > > Memreg 1 cannot be mmaped. >=20 > 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. > > > > Thanks, > > Chenbo > > > > > if (memreg[0].size) { > > > /* actual map of first part */ > > > map_addr =3D pci_map_resource(bar_addr, vfio_dev_fd, > > > -- > > > 1.8.3.1 Acked-by: Chenbo Xia