Linux CXL
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jic23@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dan Williams <djbw@kernel.org>, Ira Weiny <iweiny@kernel.org>,
	Li Ming <ming.li@zohomail.com>
Cc: linux-cxl@vger.kernel.org
Subject: [PATCH v3 2/2] cxl/port: Fix uninitialized coordinates reported for RCDs
Date: Wed, 12 Aug 2026 16:30:35 +0800	[thread overview]
Message-ID: <20260812083035.372308-3-kanie@linux.alibaba.com> (raw)
In-Reply-To: <20260812083035.372308-1-kanie@linux.alibaba.com>

cxl_endpoint_get_perf_coordinates() walks the CXL path and copies the
accumulated numbers into the caller's array with set_access_coordinates()
just before it returns. For a Restricted CXL Device it never gets that far:
RCH topologies are covered by HMAT and cannot be hotplugged, so the walk is
skipped and the function returns 0 with the output array untouched. Every
caller is told the coordinates are valid while nothing was written to them.

Its only consumer, cxl_port_perf_data_calculate(), keeps the array on the
stack and does not pre-zero it, and endpoint CDAT parsing is not gated on
the topology: cxl_endpoint_port_probe() calls read_cdat_data() and
cxl_endpoint_parse_cdat() for every endpoint port, RCD included. So an RCD
that exposes a CDAT combines stack residue with the values from its DSMAS
entries.

The residue does not stay in the driver. __cxl_coordinates_combine() sums
the latencies unconditionally and takes the minimum of the bandwidths when
both are non-zero, so it lands in dent->coord, which selects a QoS class
through cxl_root->ops.qos_class() and is copied into the memdev's
cxl_dpa_perf, where cxl_memdev_update_perf() publishes it through the
memdev's access coordinate sysfs attributes.

Clear the output on the RCD path so the function honours its contract for
every caller. Zeroing at the single caller instead would leave the exported
helper free to report success without writing anything, which the next
caller would have to know about; and zero is the value this code already
uses for "not reported", so an RCD now reads back as unknown rather than as
plausible numbers.

Fixes: 5d211c709059 ("cxl: Fix cxl_endpoint_get_perf_coordinate() support for RCH")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/cxl/core/port.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 625e4aa427db..fea43a92744c 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -2394,8 +2394,10 @@ int cxl_endpoint_get_perf_coordinates(struct cxl_port *port,
 	 * Skip calculation for RCD. Expectation is HMAT already covers RCD case
 	 * since RCH does not support hotplug.
 	 */
-	if (cxlmd->cxlds->rcd)
+	if (cxlmd->cxlds->rcd) {
+		memset(coord, 0, sizeof(*coord) * ACCESS_COORDINATE_MAX);
 		return 0;
+	}
 
 	/*
 	 * Exit the loop when the parent port of the current iter port is cxl
-- 
2.43.7


  parent reply	other threads:[~2026-08-12  8:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12  8:30 [PATCH v3 0/2] cxl: Fix uninitialized access coordinates Guixin Liu
2026-08-12  8:30 ` [PATCH v3 1/2] cxl/cdat: Fix uninitialized stack use in bandwidth gathering Guixin Liu
2026-08-12  8:44   ` sashiko-bot
2026-08-12  9:08     ` Guixin Liu
2026-08-12  8:30 ` Guixin Liu [this message]
2026-08-12  9:48 ` [PATCH v3 0/2] cxl: Fix uninitialized access coordinates Richard Cheng

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=20260812083035.372308-3-kanie@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=djbw@kernel.org \
    --cc=iweiny@kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=vishal.l.verma@intel.com \
    /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