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 98FD8A0526; Thu, 9 Jul 2020 04:25:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E9CA11DBC6; Thu, 9 Jul 2020 04:25:47 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id EC4B51D8D1 for ; Thu, 9 Jul 2020 04:25:45 +0200 (CEST) IronPort-SDR: Cery14g+2HxrqHpceqPhlNiYko7Tq/tv89TFmCMJV/5wjv0goQtffm/uj4EGNcqA0YRnsRzpam PXO2B40sXANw== X-IronPort-AV: E=McAfee;i="6000,8403,9676"; a="147002465" X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="147002465" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2020 19:25:44 -0700 IronPort-SDR: hmt4p57hmUlszWCfLczsu00dB8ftyuPL2xw0XoXpWtwdiC0O4jN3ZszjUj02wKo6UX8pTz3dAX x81jx38A28mw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,330,1589266800"; d="scan'208";a="457727694" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 08 Jul 2020 19:25:44 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 19:25:44 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 19:25:43 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.52) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 8 Jul 2020 19:25:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bZXENwosWMN2Jlz8Ew+sEy2fUphMaEQuKP7vDvkedcdP2dzpLuBeu1yAroOIGUSMVBC2Tw8c/vX4IBIva0edQEl6Yajfm++SDE8AEn1BYXebL4LgWBK++B0xHFZJPqiKTGgpzm6ySTpiW0mcd0EdGj0vVeHdn7fmK4WPNovkE5mjn7bYH9mC0TUDSa5YgpKyMXTvAGr+SaAB6mDuBA4+yTRu2Rl2i9wCyKBGMXC1MLXUZVZY84Bc5MNkbgl9ZrnrjjTVEnVD6+9dNHqLqh+tUqGRUSUQy/gQWQFBximPLH58Wp0cOP0+bbmH62ioQJziHfAuEem9vZdAAj+HzQH/EQ== 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=1kGPTuqW/IutCfRdzqTpwPQ22hN969aTLRUi717tVCg=; b=NasMoew5VL9p6kZ4K0HoLhJU6nfT8soR5uC6/jbbVvyYfqOXr9BN9YecMQ7W0ko8G2v4E3QpyfjKVcs9dH8+k8FFTs/Uzn0GFJibkBr03IeJrgc+dHsscT8tRqzeytrNOY8cmyfXp3eAKdfc9Sp2FMfeZcMsyFtHiu2t8WxMfOEOVLpjMIrLIctFrSPC4keTIP9zUn/n4VL4X4fxi63SV7yszFiTgKoHUdvAI4Cnsc64PzP+2Lv4f1Gi+GfFqFZM2i9mKxf07XSoNQpTSbV7lwgKJzrLUluSLD6DBoX6xey5tKOpXhV3SD+CeHzM/eI5+ERi/RysndkcNwfdaskkfA== 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=1kGPTuqW/IutCfRdzqTpwPQ22hN969aTLRUi717tVCg=; b=VcGRDaG2oR3bnrxoxQCW0JatuivEaPbDPNSvk3v7/JwgJwvBEnb7MhD8pRS5nMIGAV74pRMlGIDpktr9roovj3IIXudqppc8J/zpF5paHvXBrMfqni1SFpxQEq7Zco1KpC9QL4teQSlDkJHaAjXNvOvb6n6E8LIr+EZD/HcYCZs= Received: from MWHPR1101MB2254.namprd11.prod.outlook.com (2603:10b6:301:58::11) by MWHPR11MB1807.namprd11.prod.outlook.com (2603:10b6:300:112::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Thu, 9 Jul 2020 02:25:41 +0000 Received: from MWHPR1101MB2254.namprd11.prod.outlook.com ([fe80::f192:356f:89f:c71f]) by MWHPR1101MB2254.namprd11.prod.outlook.com ([fe80::f192:356f:89f:c71f%9]) with mapi id 15.20.3174.022; Thu, 9 Jul 2020 02:25:41 +0000 From: "Xiao, QimaiX" To: "Zhang, AlvinX" , "dev@dpdk.org" CC: "Xing, Beilei" , "Guo, Jia" Thread-Topic: [dpdk-dev] [PATCH] bus/pci: fix mmap PCI resource Thread-Index: AQHWVQn1Kv3hVKap6kmUnzcuDo7yvqj+hfTA Date: Thu, 9 Jul 2020 02:25:41 +0000 Message-ID: References: <20200708092435.9776-1-alvinx.zhang@intel.com> In-Reply-To: <20200708092435.9776-1-alvinx.zhang@intel.com> 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: ea114845-641f-4d8f-7b65-08d823af605d x-ms-traffictypediagnostic: MWHPR11MB1807: 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:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7EjllpnZw59HQpfxSKdHXXUhxbtFSliXw6rGfW/VRQ0u/EVsB1SDgWP26wvYIo5Ct/SkQdsOuRpZEqzpzyLmLSGaOEj7j/90lpN8vZqAy+apiDGZorKWavFyF2cUzZp+aUgTNdPVIlFN6D62hk0E8CVoE5YCbEL11G9JW0x9jyY/UdPrTH00Tl+oiy3cxtmdqs982TissoiP+4nLew1iODw5XGLkzVwdxwl6dFEabq1RanDbp0iG9e3zzXxj67hy2fd8wtP3ocC3bHYCiKmAdCoPj8xaZekkeP8hOltiXM1++3T+VbdJ0rB98chbyy7JOLE2XOjKOwNx5Y2+Px7hbg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1101MB2254.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(7696005)(107886003)(26005)(66446008)(66476007)(83380400001)(186003)(64756008)(53546011)(316002)(55016002)(76116006)(6506007)(4326008)(66946007)(66556008)(110136005)(478600001)(86362001)(8936002)(9686003)(54906003)(52536014)(5660300002)(71200400001)(2906002)(33656002)(8676002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: CVDwEFYU3rr6mXJ8HO5HEsHddnsrJtuR37s756QdsiJOUVgVg7Eqq2dwTFA0NsS/16FjKQb1klW0P7THY15mj//7tYwbJPHHYQK92e/pm3B6i8N50/x+mdxpmiuIahSicHrlrGzF5QBstVrIQsX4Oj5HvayMJme5uVd8avJZup91fC+7PRxgizAqwjeUqHSbC8EXgWK2IIH1qLJU+SpO62rWfnb7YxwYTZa7wspcypT51H4gIwvZ5ev3KOh3NeLR27+r+0lU9+4fUUzO0JJkgqHje+lTAY7pOfU+xyzvTze4wfjW/tg9f4qyyQ7BGURV6wOKYMjYaNff/P+tPJbsq75gHHfn+aHiMhH/7A9j8wXxpaVbhF6D7DEq+YYIGgS97ZSHS117pWcH+9/jQxbX6xvyZuhu0jiblSOA0qe9T4NmYLYZf2MyI2CqlkGF+geZa4sWXF2+atBbdfl2e4bqBrk+7QOprZz5GF7LdhMWKGM= 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: MWHPR1101MB2254.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea114845-641f-4d8f-7b65-08d823af605d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2020 02:25:41.4543 (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: Y+pDEfJQudEFsOjqtfARBwKARFE3VYxAi8Yai5Q+sU4WeA6weLmrLjhJxpPmJbmdUslNVkAdejPcFYRR3fkyaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1807 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" Tested-by: Xiao Qimai Regards, Xiao Qimai > -----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 >=20 > From: Alvin Zhang >=20 > 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 initi= al > value is set to the variable to avoid this situation. >=20 > Fixes: 2fd3567e5425 ("pci: use OS generic memory mapping functions") > Cc: talshn@mellanox.com >=20 > Signed-off-by: Alvin Zhang > --- > drivers/bus/pci/linux/pci_vfio.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) >=20 > 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; > + } > } 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; > + > if (memreg[0].size) { > /* actual map of first part */ > map_addr =3D pci_map_resource(bar_addr, > vfio_dev_fd, > -- > 1.8.3.1