From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D31E5A00C3; Sat, 6 Aug 2022 23:01:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7998B4067B; Sat, 6 Aug 2022 23:01:19 +0200 (CEST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mails.dpdk.org (Postfix) with ESMTP id E05D34021E for ; Sat, 6 Aug 2022 23:01:17 +0200 (CEST) Received: by mail-lf1-f47.google.com with SMTP id o2so445852lfb.1 for ; Sat, 06 Aug 2022 14:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc; bh=ESu4GHhleiqEpTKSRMmveZB7pTtUOmd62PAxOGCchOk=; b=ZJyv81oUrSmql7MtN+QcVlwx3uMJcSZHvt/IoSYTI1L4XCfrAIgtXtXfVMoEGS+Nhg QtY0bbZI6Wdl084wW6BOVlzs/Ypq+SPLVYasshykAwJwMHZ+SQf1hioclEUwJieW7+XD L0pRtrNVA8zahjhY/LYGEBNGb4gBBl09KfF7xLY76eIDETfWqBUmNmFJxFWBJ6aZKmvW wZZe1BnRQJ6q7QtNuOyFjYy0l6JzKBo9UXODnQcki+HB3uGymUanjLIx0R71viH3ONRS KiLjuToTofDYeY8apw1ZIDE+EQvAoW47YWXT5eFVLXdvRagGaFo9i/TMrp5DstNjJsza T1DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=ESu4GHhleiqEpTKSRMmveZB7pTtUOmd62PAxOGCchOk=; b=RwPYdOUjoAbwkI5NlqmXIcI5NThLNWMz8M7QrpglgC+Br1Y1/2J7nBXQi1eNhtAE6w +lh2hLEGEwesoVnUEOfAYvFLBlXZMkB2JtC/iiOtRgudD9VNObKbXDjiCNigAIJeUFhh QTEFhl23BiccI3+gTP9bpGhOsF9Zyf6wk8M7heoESOpCWRAUbmdB5mKt0m0kfSmeIFuf lPayARonFtmIQizPHs40fC7E21RSJRicN9wPoNfLkd+v+5WxVbUFtsGNAXZoOYBVF4gQ 1LsvTv+jcl3ZDWrQ6OOSWEBiMql2ybJ9HuHZrFfxzQx1Yn4JiQ9oMzk+2UEXs1t9YrsD VQRw== X-Gm-Message-State: ACgBeo0tqnnRjZb868rxJhP7y32yRtX+LtAu+OP4CAEtzUG+nkfIy95B VkNr4bwTRdnQqKFPZOuzrRA= X-Google-Smtp-Source: AA6agR4RaYxa0W3eLhQCOCEhsoJHA0TL3BDoUKYZ6pKIIh8jx14HUmvwkHaqub/IRbB9Xp14+iNauA== X-Received: by 2002:a05:6512:12cc:b0:48c:7bdc:734a with SMTP id p12-20020a05651212cc00b0048c7bdc734amr379199lfg.577.1659819677060; Sat, 06 Aug 2022 14:01:17 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id o6-20020ac24e86000000b0048b16cfecc3sm873488lfr.240.2022.08.06.14.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Aug 2022 14:01:16 -0700 (PDT) Date: Sun, 7 Aug 2022 00:01:13 +0300 From: Dmitry Kozlyuk To: Pallavi Kadam Cc: dev@dpdk.org, thomas@monjalon.net, ranjit.menon@intel.com, Narcisa.Vasile@microsoft.com, roretzla@linux.microsoft.com, qiao.liu@intel.com Subject: Re: [dpdk-kmods] windows/netuio: fix bar parsing Message-ID: <20220807000113.4f773581@sovereign> In-Reply-To: <20220802191058.1779-1-pallavi.kadam@intel.com> References: <20220802191058.1779-1-pallavi.kadam@intel.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 2022-08-02 12:10 (UTC-0700), Pallavi Kadam: > For certain PCIe devices, BAR values are not continuous. > This patch maps all the BARs and avoids skipping the next BAR addresses. > > Fixes: e28aabd88279 ("windows/netuio: introduce NetUIO kernel driver") > Cc: navasile@microsoft.com > > Signed-off-by: Qiao Liu > Signed-off-by: Pallavi Kadam > --- > windows/netuio/netuio_dev.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/windows/netuio/netuio_dev.c b/windows/netuio/netuio_dev.c > index b2deb10..e2cac3e 100644 > --- a/windows/netuio/netuio_dev.c > +++ b/windows/netuio/netuio_dev.c > @@ -172,6 +172,7 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R > ULONG next_descriptor = 0; > ULONG curr_bar = 0; > ULONG prev_bar = 0; > + BOOLEAN bar_done = FALSE; > > /* > * ResourcesTranslated report MMIO BARs in the correct order, but their > @@ -197,7 +198,8 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R > for (INT bar_index = 0; bar_index < PCI_MAX_BAR; bar_index++) { > prev_bar = curr_bar; > curr_bar = pci_config.u.type0.BaseAddresses[bar_index]; > - if (curr_bar == 0 || (prev_bar & PCI_TYPE_64BIT)) { > + if (curr_bar == 0 || ((prev_bar & PCI_TYPE_64BIT) && (bar_done))) { > + bar_done = FALSE; > continue; > } > > @@ -219,6 +221,7 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R > ctx->bar[bar_index].virt_addr = MmMapIoSpace(descriptor->u.Memory.Start, > descriptor->u.Memory.Length, > MmNonCached); > + bar_done = TRUE; > if (ctx->bar[bar_index].virt_addr == NULL) { > status = STATUS_INSUFFICIENT_RESOURCES; > goto end; Hi Pallavi, In the first place, it was wrong to always test `prev_bar & PCI_TYPE_64BIT` because only the first BAR slot of a 64-bit BAR contains flags. The current code has a state to track (curr_bar, prev_bar), and the fix is complicating it even more without solving the root cause. I suggest a simpler fix (not tested!) that eliminates both the incorrectness and the state to maintain: diff --git a/windows/netuio/netuio_dev.c b/windows/netuio/netuio_dev.c index d4662b6..8761d31 100644 --- a/windows/netuio/netuio_dev.c +++ b/windows/netuio/netuio_dev.c @@ -273,8 +273,6 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R PCM_PARTIAL_RESOURCE_DESCRIPTOR descriptor; ULONG next_descriptor = 0; - ULONG curr_bar = 0; - ULONG prev_bar = 0; /* * ResourcesTranslated report MMIO BARs in the correct order, but their @@ -298,9 +296,9 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R * searching for the next MMIO resource each time. */ for (INT bar_index = 0; bar_index < PCI_MAX_BAR; bar_index++) { - prev_bar = curr_bar; - curr_bar = pci_config.u.type0.BaseAddresses[bar_index]; - if (curr_bar == 0 || (prev_bar & PCI_TYPE_64BIT)) { + ULONG bar_value = pci_config.u.type0.BaseAddresses[bar_index]; + + if (bar_value == 0) { continue; } @@ -339,6 +337,11 @@ netuio_map_hw_resources(WDFDEVICE Device, WDFCMRESLIST Resources, WDFCMRESLIST R } ctx->dpdk_hw[bar_index].mem.size = ctx->bar[bar_index].size; + + // Skip the next BAR slot used by the current 64-bit address. + if (bar_value & PCI_TYPE_64BIT) { + bar_index++; + } } // for bar_index end_of_loop: