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 4F62FA04C0; Fri, 25 Sep 2020 13:49:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4796C1E90C; Fri, 25 Sep 2020 13:49:00 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 1C7011E882 for ; Fri, 25 Sep 2020 13:48:58 +0200 (CEST) IronPort-SDR: qJySFFcPiUvfSDRz4MpGk4LkkhjHoSyi7aznYTeBCHsXFc3v/P3o1j8lGbMze4CCj01ciD+mp5 gPtcqLhtG2xw== X-IronPort-AV: E=McAfee;i="6000,8403,9754"; a="179586136" X-IronPort-AV: E=Sophos;i="5.77,301,1596524400"; d="scan'208";a="179586136" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 04:48:58 -0700 IronPort-SDR: 6TsPAG7oY5rraINYA6l4A+hUVDHWZIGx9UyKSYfbqvGJcnoBKKe5B2+F8uVGd4Lux8ZcyM5yuq BOy+wsK3QSgg== X-IronPort-AV: E=Sophos;i="5.77,301,1596524400"; d="scan'208";a="310782330" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.228.71]) ([10.213.228.71]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 04:48:56 -0700 To: Hyong Youb Kim , Ferruh Yigit , David Marchand , Thomas Monjalon Cc: dev@dpdk.org, John Daley References: <20200925021435.16114-1-hyonkim@cisco.com> From: "Burakov, Anatoly" Message-ID: <65af599a-e5e1-a01c-1b83-6f22a680abaa@intel.com> Date: Fri, 25 Sep 2020 12:48:54 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200925021435.16114-1-hyonkim@cisco.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] bus/pci: fix mapping BAR containing MSI-X table 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" On 25-Sep-20 3:14 AM, Hyong Youb Kim wrote: > When the BAR contains MSI-X table, pci_vfio_mmap_bar() tries to skip > the table and map the rest. "map around it" is the phrase used in the > source. The function splits the BAR into two regions: the region > before the table (first part or memreg[0]) and the region after the > table (second part or memreg[1]). > > For hardware that has MSI-X vector table offset 0, the first part does > not exist (memreg[0].size == 0). > > Capabilities: [60] MSI-X: Enable- Count=48 Masked- > Vector table: BAR=2 offset=00000000 > PBA: BAR=2 offset=00001000 > > The mapping part of the function maps the first part, if it > exists. Then, it maps the second part, if it exists and "if mapping the > first part succeeded". > > The recent change that replaces MAP_FAILED with NULL breaks the "if > mapping the first part succeeded" condition (1) in the snippet below. > > void *map_addr = NULL; > if (memreg[0].size) { > /* actual map of first part */ > map_addr = pci_map_resource(...); > } > > /* if there's a second part, try to map it */ > if (map_addr != NULL // -- (1) > && memreg[1].offset && memreg[1].size) { > [...] > } > > if (map_addr == NULL) { > RTE_LOG(ERR, EAL, "Failed to map pci BAR%d\n", > bar_index); > return -1; > } > > When the first part does not exist, (1) sees map_addr is still NULL, > and the function fails. This behavior is a regression and fails > probing hardware with vector table offset 0. > > Previously, (1) was "map_addr != MAP_FAILED", which meant > pci_map_resource() was actually attempted and failed. So, expand (1) > to check if the first part exists as well, to match the semantics of > MAP_FAILED. > > Bugzilla ID: 539 > Fixes: e200535c1ca3 ("mem: drop mapping API workaround") > > Signed-off-by: Hyong Youb Kim > --- LGTM Acked-by: Anatoly Burakov -- Thanks, Anatoly