From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
stable@dpdk.org, Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 2/8] net/nfp: fix configuration BAR problem
Date: Fri, 19 Apr 2024 11:12:20 +0800 [thread overview]
Message-ID: <20240419031226.1191069-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240419031226.1191069-1-chaoyong.he@corigine.com>
All the configuration bars are sit in an array, and the initial logic
sort all the configuration BAR from small to large based on size and index,
which result all valid bars are behind the invalid bars.
But the BAR alloc logic search this array from the very beginning and
only try limited times (equal to the valid bars number).
It's ok for primary process because which has enough valid bars, and
finally it can find one to use.
But for secondary process and run with igb_uio driver, the valid bars
are very limit, and it can not find one, and the logic will fail.
Fix this by drop the sort logic, and search the bar array from the end
to begin.
Fixes: 1fbe51cd9c3a ("net/nfp: extend usage of BAR from 8 to 24")
Cc: stable@dpdk.org
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
drivers/net/nfp/nfpcore/nfp6000_pcie.c | 34 +++++++++-----------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/nfp/nfpcore/nfp6000_pcie.c
index a6fd89b6c8..ef1ffd6d01 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.c
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.c
@@ -263,19 +263,6 @@ nfp_bitsize_calc(uint64_t mask)
return bit_size;
}
-static int
-nfp_cmp_bars(const void *ptr_a,
- const void *ptr_b)
-{
- const struct nfp_bar *a = ptr_a;
- const struct nfp_bar *b = ptr_b;
-
- if (a->bitsize == b->bitsize)
- return a->index - b->index;
- else
- return a->bitsize - b->bitsize;
-}
-
static bool
nfp_bars_for_secondary(uint32_t index)
{
@@ -383,9 +370,6 @@ nfp_enable_bars(struct nfp_pcie_user *nfp)
if (nfp_bar_write(nfp, bar, barcfg_msix_general) < 0)
return -EIO;
- /* Sort bars by bit size - use the smallest possible first. */
- qsort(&nfp->bar[0], nfp->bars, sizeof(nfp->bar[0]), nfp_cmp_bars);
-
return 0;
}
@@ -466,16 +450,18 @@ find_matching_bar(struct nfp_pcie_user *nfp,
int width)
{
uint32_t n;
+ uint32_t index;
- for (n = 0; n < nfp->bars; n++) {
- struct nfp_bar *bar = &nfp->bar[n];
+ for (n = RTE_DIM(nfp->bar) ; n > 0; n--) {
+ index = n - 1;
+ struct nfp_bar *bar = &nfp->bar[index];
if (bar->lock)
continue;
if (matching_bar_exist(bar, target, action, token,
offset, size, width))
- return n;
+ return index;
}
return -1;
@@ -493,10 +479,12 @@ find_unused_bar_noblock(struct nfp_pcie_user *nfp,
{
int ret;
uint32_t n;
+ uint32_t index;
const struct nfp_bar *bar;
- for (n = 0; n < nfp->bars; n++) {
- bar = &nfp->bar[n];
+ for (n = RTE_DIM(nfp->bar); n > 0; n--) {
+ index = n - 1;
+ bar = &nfp->bar[index];
if (bar->bitsize == 0)
continue;
@@ -508,7 +496,7 @@ find_unused_bar_noblock(struct nfp_pcie_user *nfp,
continue;
if (!bar->lock)
- return n;
+ return index;
}
return -EAGAIN;
@@ -561,7 +549,7 @@ nfp_disable_bars(struct nfp_pcie_user *nfp)
uint32_t i;
struct nfp_bar *bar;
- for (i = 0; i < nfp->bars; i++) {
+ for (i = 0; i < RTE_DIM(nfp->bar); i++) {
bar = &nfp->bar[i];
if (bar->iomem != NULL) {
bar->iomem = NULL;
--
2.39.1
next prev parent reply other threads:[~2024-04-19 3:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240419031226.1191069-1-chaoyong.he@corigine.com>
2024-04-19 3:12 ` [PATCH 1/8] net/nfp: fix resource leak of secondary process Chaoyong He
2024-04-19 3:12 ` Chaoyong He [this message]
[not found] ` <20240419052349.1294696-1-chaoyong.he@corigine.com>
2024-04-19 5:23 ` [PATCH v2 " Chaoyong He
2024-04-19 5:23 ` [PATCH v2 2/8] net/nfp: fix configuration BAR problem Chaoyong He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240419031226.1191069-3-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).