Linux CXL
 help / color / mirror / Atom feed
* [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation
@ 2025-03-17  7:01 Li Ming
  2025-03-17 17:59 ` Alison Schofield
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Li Ming @ 2025-03-17  7:01 UTC (permalink / raw)
  To: dave, jonathan.cameron, dave.jiang, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel, Li Ming

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>
---
 drivers/cxl/core/region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 6d8bdb53f258..c3f4dc244df7 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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation
  2025-03-17  7:01 [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation Li Ming
@ 2025-03-17 17:59 ` Alison Schofield
  2025-03-20 18:26 ` Ira Weiny
  2025-03-20 22:09 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2025-03-17 17:59 UTC (permalink / raw)
  To: Li Ming
  Cc: dave, jonathan.cameron, dave.jiang, vishal.l.verma, ira.weiny,
	dan.j.williams, linux-cxl, linux-kernel

On Mon, Mar 17, 2025 at 03:01:24PM +0800, Li Ming wrote:
> 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".

Nice catch Ming!

Reviewed-by: Alison Schofield <alison.schofield@intel.com>

> 
> Signed-off-by: Li Ming <ming.li@zohomail.com>
> ---
>  drivers/cxl/core/region.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 6d8bdb53f258..c3f4dc244df7 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;
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation
  2025-03-17  7:01 [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation Li Ming
  2025-03-17 17:59 ` Alison Schofield
@ 2025-03-20 18:26 ` Ira Weiny
  2025-03-20 22:09 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Ira Weiny @ 2025-03-20 18:26 UTC (permalink / raw)
  To: Li Ming, dave, jonathan.cameron, dave.jiang, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel, Li Ming

Li Ming wrote:
> 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: Ira Weiny <ira.weiny@intel.com>

[snip]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation
  2025-03-17  7:01 [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation Li Ming
  2025-03-17 17:59 ` Alison Schofield
  2025-03-20 18:26 ` Ira Weiny
@ 2025-03-20 22:09 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2025-03-20 22:09 UTC (permalink / raw)
  To: Li Ming, dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel



On 3/17/25 12:01 AM, Li Ming wrote:
> 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>

Applied to cxl/next

> ---
>  drivers/cxl/core/region.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 6d8bdb53f258..c3f4dc244df7 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;


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-20 22:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17  7:01 [PATCH 1/1] cxl/region: Fix the first aliased address miscalculation Li Ming
2025-03-17 17:59 ` Alison Schofield
2025-03-20 18:26 ` Ira Weiny
2025-03-20 22:09 ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox