* [ndctl PATCH] cxl/list: apply bus and port filters to anonymous memdevs
@ 2026-04-11 1:13 Alison Schofield
0 siblings, 0 replies; only message in thread
From: Alison Schofield @ 2026-04-11 1:13 UTC (permalink / raw)
To: nvdimm, linux-cxl; +Cc: Alison Schofield, Dave Jiang
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-11 1:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11 1:13 [ndctl PATCH] cxl/list: apply bus and port filters to anonymous memdevs Alison Schofield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox