public inbox for nvdimm@lists.linux.dev
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Cc: Alison Schofield <alison.schofield@intel.com>,
	Dave Jiang <dave.jiang@intel.com>
Subject: [ndctl PATCH] cxl/list: apply bus and port filters to anonymous memdevs
Date: Fri, 10 Apr 2026 18:13:56 -0700	[thread overview]
Message-ID: <20260411011358.3133190-1-alison.schofield@intel.com> (raw)

Anonymous memdevs are disabled memdevs that do not nest in the
topology output and are reported separately in the "anon memdevs"
array.

A user reports that cxl list -M -i with a port filter may return
anonymous memdevs that are not part of the selected port. In this
case, QEMU-defined disabled memdevs were returned in a query of a
cxl_test bus port.

The issue has two parts. First, util_cxl_memdev_filter_by_port() does 
not properly constrain bus-filtered queries. It treats the bus name
as a port identifier, allowing memdevs from other buses to match.

Second, cxl_filter_walk() collects anonymous memdevs in a global
pre-pass without applying decoder, bus, or port filters, so disabled
memdevs outside the requested scope are included.

Update util_cxl_memdev_filter_by_port() to limit the search to the
selected bus and match ports only within that bus. Apply decoder and
bus/port filtering to anonymous memdevs so they follow the same rules
as other memdev listings.

Found with CXL unit test cxl-topology.sh

Reported-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 cxl/filter.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/cxl/filter.c b/cxl/filter.c
index 8c7dc6e31701..5d634d3b2512 100644
--- a/cxl/filter.c
+++ b/cxl/filter.c
@@ -615,12 +615,12 @@ util_cxl_memdev_filter_by_port(struct cxl_memdev *memdev, const char *bus_ident,
 		struct cxl_port *port, *top;
 
 		port = cxl_bus_get_port(bus);
-		if (util_cxl_bus_filter(bus, bus_ident))
-			if (__memdev_filter_by_port(memdev, port,
-						    cxl_bus_get_devname(bus)))
-				return memdev;
+
+		if (!util_cxl_bus_filter(bus, bus_ident))
+			continue;
 		if (__memdev_filter_by_port(memdev, port, port_ident))
-				return memdev;
+			return memdev;
+
 		top = port;
 		cxl_port_foreach_all(top, port)
 			if (__memdev_filter_by_port(memdev, port, port_ident))
@@ -1125,6 +1125,12 @@ struct json_object *cxl_filter_walk(struct cxl_ctx *ctx,
 		if (!util_cxl_memdev_filter(memdev, p->memdev_filter,
 					    p->serial_filter))
 			continue;
+		if (!util_cxl_memdev_filter_by_decoder(memdev,
+						       p->decoder_filter))
+			continue;
+		if (!util_cxl_memdev_filter_by_port(memdev, p->bus_filter,
+						    p->port_filter))
+			continue;
 		if (cxl_memdev_is_enabled(memdev))
 			continue;
 		if (!p->idle)
-- 
2.37.3


                 reply	other threads:[~2026-04-11  1:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260411011358.3133190-1-alison.schofield@intel.com \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox