From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Jiang, Dave" <dave.jiang@intel.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Cc: "Schofield, Alison" <alison.schofield@intel.com>
Subject: Re: [NDCTL PATCH] cxl: Change cxl-topology.sh assumption on host bridge validation
Date: Thu, 8 May 2025 06:48:16 +0000 [thread overview]
Message-ID: <ffac09c7154f4c4bc9dff6524a02d8a707ad8b0c.camel@intel.com> (raw)
In-Reply-To: <20250507164618.635320-1-dave.jiang@intel.com>
On Wed, 2025-05-07 at 09:46 -0700, Dave Jiang wrote:
> Current host bridge validation in cxl-topology.sh assumes that the
> decoder enumeration is in order and therefore the port numbers can
> be used as a sorting key. With delayed port enumeration, this
> assumption is no longer true. Change the sorting to by number
> of children ports for each host bridge as the test code expects
> the first 2 host bridges to have 2 children and the third to only
> have 1.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> test/cxl-topology.sh | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/test/cxl-topology.sh b/test/cxl-topology.sh
> index 90b9c98273db..41d6f052394d 100644
> --- a/test/cxl-topology.sh
> +++ b/test/cxl-topology.sh
> @@ -37,15 +37,16 @@ root=$(jq -r ".[] | .bus" <<< $json)
>
>
> # validate 2 or 3 host bridges under a root port
> -port_sort="sort_by(.port | .[4:] | tonumber)"
> json=$($CXL list -b cxl_test -BP)
> count=$(jq ".[] | .[\"ports:$root\"] | length" <<< $json)
> ((count == 2)) || ((count == 3)) || err "$LINENO"
> bridges=$count
>
> -bridge[0]=$(jq -r ".[] | .[\"ports:$root\"] | $port_sort | .[0].port" <<< $json)
> -bridge[1]=$(jq -r ".[] | .[\"ports:$root\"] | $port_sort | .[1].port" <<< $json)
> -((bridges > 2)) && bridge[2]=$(jq -r ".[] | .[\"ports:$root\"] | $port_sort | .[2].port" <<< $json)
> +bridge[0]=$(jq -r --arg key "$root" '.[] | select(has("ports:" + $key)) | .["ports:" + $key] | map({full: ., length: (.["ports:" + .port] | length)}) | sort_by(-.length) | map(.full) | .[0].port' <<< "$json")
> +
> +bridge[1]=$(jq -r --arg key "$root" '.[] | select(has("ports:" + $key)) | .["ports:" + $key] | map({full: ., length: (.["ports:" + .port] | length)}) | sort_by(-.length) | map(.full) | .[1].port' <<< "$json")
> +
> +((bridges > 2)) && bridge[2]=$(jq -r --arg key "$root" '.[] | select(has("ports:" + $key)) | .["ports:" + $key] | map({full: ., length: (.["ports:" + .port] | length)}) | sort_by(-.length) | map(.full) | .[2].port' <<< "$json")
>
The jq filtering looks reasonable, but the long lines are definitely a
bit unsightly, not to mention hard to follow/edit in the future.
How about this incremental patch (It passes the test for me with the
delayed port enumeration series):
-->8--
From 996610fac0a751acc5d68a56ff7d6746348a80c4 Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.verma@intel.com>
Date: Thu, 8 May 2025 00:46:27 -0600
Subject: [ndctl PATCH] test: Cleanup long lines in cxl-topology.sh
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
test/cxl-topology.sh | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/test/cxl-topology.sh b/test/cxl-topology.sh
index f4ba7374..b68cb8b2 100644
--- a/test/cxl-topology.sh
+++ b/test/cxl-topology.sh
@@ -42,11 +42,32 @@ count=$(jq ".[] | .[\"ports:$root\"] | length" <<< $json)
((count == 2)) || ((count == 3)) || err "$LINENO"
bridges=$count
-bridge[0]=$(jq -r --arg key "$root" '.[] | select(has("ports:" + $key)) | .["ports:" + $key] | map({full: ., length: (.["ports:" + .port] | length)}) | sort_by(-.length) | map(.full) | .[0].port' <<< "$json")
+bridge_filter()
+{
+ local br_num="$1"
-bridge[1]=$(jq -r --arg key "$root" '.[] | select(has("ports:" + $key)) | .["ports:" + $key] | map({full: ., length: (.["ports:" + .port] | length)}) | sort_by(-.length) | map(.full) | .[1].port' <<< "$json")
+ jq -r \
+ --arg key "$root" \
+ --argjson br_num "$br_num" \
+ '.[] |
+ select(has("ports:" + $key)) |
+ .["ports:" + $key] |
+ map(
+ {
+ full: .,
+ length: (.["ports:" + .port] | length)
+ }
+ ) |
+ sort_by(-.length) |
+ map(.full) |
+ .[$br_num].port'
+}
-((bridges > 2)) && bridge[2]=$(jq -r --arg key "$root" '.[] | select(has("ports:" + $key)) | .["ports:" + $key] | map({full: ., length: (.["ports:" + .port] | length)}) | sort_by(-.length) | map(.full) | .[2].port' <<< "$json")
+# $count has already been sanitized for acceptable values, so
+# just collect $count bridges here.
+for i in $(seq 0 $((count - 1))); do
+ bridge[$i]="$(bridge_filter "$i" <<< "$json")"
+done
# validate root ports per host bridge
check_host_bridge()
base-commit: 92d5203077553bfc9f7bf1c219563db0fc28e660
prerequisite-patch-id: f17261693e3ac38880b7701a94a469bb513b4078
--
2.49.0
next prev parent reply other threads:[~2025-05-08 6:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 16:46 [NDCTL PATCH] cxl: Change cxl-topology.sh assumption on host bridge validation Dave Jiang
2025-05-08 6:48 ` Verma, Vishal L [this message]
2025-05-08 19:03 ` Dave Jiang
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=ffac09c7154f4c4bc9dff6524a02d8a707ad8b0c.camel@intel.com \
--to=vishal.l.verma@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.