]> www.infradead.org Git - nvme.git/commitdiff
cxl/region: Fix the first aliased address miscalculation
authorLi Ming <ming.li@zohomail.com>
Mon, 17 Mar 2025 07:01:24 +0000 (15:01 +0800)
committerDave Jiang <dave.jiang@intel.com>
Thu, 20 Mar 2025 18:28:45 +0000 (11:28 -0700)
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 <ming.li@zohomail.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://patch.msgid.link/20250317070124.815028-1-ming.li@zohomail.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/region.c

index 6d8bdb53f258c96ea12fd4a0d2ad67f46d719f09..c3f4dc244df77bb7bd48d3828ceece0c7cb2e3f2 100644 (file)
@@ -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;