* [RFC PATCH] cxl/region: Calculate peer distance only for reused targets
@ 2026-10-15 9:40 Richard Cheng
0 siblings, 0 replies; only message in thread
From: Richard Cheng @ 2026-10-15 9:40 UTC (permalink / raw)
To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma
Cc: iweiny, ming.li, icheng, gourry, rrichter, linux-cxl, linux-kernel
This patch depends on Alison Schofield's v3 "cxl/region: Refactor
cxl_port_setup_targets()" series [1], this is inspired from that serie
as well, since her serie contains no functional change, I pull this one
out as a standalone patch.
cxl_switch_port_setup_targets() calculates peer distance before
searching the existing targets. When the endpoint needs a new target,
the calculated distance is never used.
Move cxl_port_peer_distance() into the matching-target branch,
immediately before check_last_peer(). This avoids unnecessary ancestor
walks and per-port region lookups when adding distinct targets.
[1]:
https://lore.kernel.org/linux-cxl/cover.1791860305.git.alison.schofield@intel.com/
Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
I don't have available HW for multi-way interleaving setup, so I can't
exercise the case optimized here. I would appreciate if someone is
williing to validate the actual benefit of this.
Best regards,
Richard Cheng.
---
drivers/cxl/core/region.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 50f4830c225d..efd173c57dad 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1666,10 +1666,10 @@ static int cxl_switch_port_setup_targets(struct cxl_port *port, struct cxl_regio
cxlsd = to_cxl_switch_decoder(&cxld->dev);
if (cxl_rr->nr_targets_set) {
- int distance = cxl_port_peer_distance(port, cxlr);
-
for (int i = 0; i < cxl_rr->nr_targets_set; i++)
if (ep->dport == cxlsd->target[i]) {
+ int distance = cxl_port_peer_distance(port, cxlr);
+
rc = check_last_peer(cxled, ep, cxl_rr,
distance);
if (rc)
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-15 9:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 9:40 [RFC PATCH] cxl/region: Calculate peer distance only for reused targets Richard Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®