From: Li Ming Date: Mon, 17 Mar 2025 07:01:24 +0000 (+0800) Subject: cxl/region: Fix the first aliased address miscalculation X-Git-Tag: v6.15-rc1~45^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aae0594a7053c60b82621136257c8b648c67b512;p=thirdparty%2Fkernel%2Flinux.git cxl/region: Fix the first aliased address miscalculation In extended linear cache(ELC) case, cxl_port_get_spa_cache_alias() helps to get the aliased address of a SPA, it considers the first address in CXL memory range is "region start + region cache size + 1", but it should be "region start + region cache size". So if a SPA is equal to "region start + region cache size", its aliased address should be "SPA - region cache size". Signed-off-by: Li Ming Reviewed-by: Alison Schofield Reviewed-by: Ira Weiny Link: https://patch.msgid.link/20250317070124.815028-1-ming.li@zohomail.com Signed-off-by: Dave Jiang --- diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 6d8bdb53f258c..c3f4dc244df77 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3460,7 +3460,7 @@ u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa) if (!p->cache_size) return ~0ULL; - if (spa > p->res->start + p->cache_size) + if (spa >= p->res->start + p->cache_size) return spa - p->cache_size; return spa + p->cache_size;