Linux CXL
 help / color / mirror / Atom feed
* [PATCH v1 0/3] cxl region changes for Type2 support
@ 2026-02-24 15:26 alejandro.lucero-palau
  2026-02-24 15:26 ` [PATCH v1 1/3] cxl: Make region type based on endpoint type alejandro.lucero-palau
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: alejandro.lucero-palau @ 2026-02-24 15:26 UTC (permalink / raw)
  To: linux-cxl, dan.j.williams, dave.jiang; +Cc: Alejandro Lucero

From: Alejandro Lucero <alucerop@amd.com>

In preparation for Type2 devices/drivers support, these next patches
adapt the cxl region code for required Type2 functionality preserving
current functionality.

Alejandro Lucero (3):
  cxl: Make region type based on endpoint type
  cxl/region: Factor out interleave ways setup
  cxl/region: Factor out interleave granularity setup

 drivers/cxl/core/region.c | 87 +++++++++++++++++++++++++--------------
 1 file changed, 56 insertions(+), 31 deletions(-)


base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
-- 
2.34.1


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

* [PATCH v1 1/3] cxl: Make region type based on endpoint type
  2026-02-24 15:26 [PATCH v1 0/3] cxl region changes for Type2 support alejandro.lucero-palau
@ 2026-02-24 15:26 ` alejandro.lucero-palau
  2026-02-24 16:04   ` Gregory Price
  2026-02-24 15:26 ` [PATCH v1 2/3] cxl/region: Factor out interleave ways setup alejandro.lucero-palau
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: alejandro.lucero-palau @ 2026-02-24 15:26 UTC (permalink / raw)
  To: linux-cxl, dan.j.williams, dave.jiang
  Cc: Alejandro Lucero, Zhi Wang, Jonathan Cameron, Ben Cheatham,
	Alison Schofield, Davidlohr Bueso

From: Alejandro Lucero <alucerop@amd.com>

Current code is expecting Type3 or CXL_DECODER_HOSTONLYMEM devices only.
Support for Type2 implies region type needs to be based on the endpoint
type HDM-D[B] instead.

Signed-off-by: Alejandro Lucero <alucerop@amd.com>
Reviewed-by: Zhi Wang <zhiw@nvidia.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Davidlohr Bueso <daves@stgolabs.net>
---
 drivers/cxl/core/region.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index fec37af1dfbf..cac33c99fe6a 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2650,7 +2650,8 @@ static ssize_t create_ram_region_show(struct device *dev,
 }
 
 static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
-					  enum cxl_partition_mode mode, int id)
+					  enum cxl_partition_mode mode, int id,
+					  enum cxl_decoder_type target_type)
 {
 	int rc;
 
@@ -2672,7 +2673,7 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
 		return ERR_PTR(-EBUSY);
 	}
 
-	return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_HOSTONLYMEM);
+	return devm_cxl_add_region(cxlrd, id, mode, target_type);
 }
 
 static ssize_t create_region_store(struct device *dev, const char *buf,
@@ -2686,7 +2687,7 @@ static ssize_t create_region_store(struct device *dev, const char *buf,
 	if (rc != 1)
 		return -EINVAL;
 
-	cxlr = __create_region(cxlrd, mode, id);
+	cxlr = __create_region(cxlrd, mode, id, CXL_DECODER_HOSTONLYMEM);
 	if (IS_ERR(cxlr))
 		return PTR_ERR(cxlr);
 
@@ -3902,7 +3903,8 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
 
 	do {
 		cxlr = __create_region(cxlrd, cxlds->part[part].mode,
-				       atomic_read(&cxlrd->region_id));
+				       atomic_read(&cxlrd->region_id),
+				       cxled->cxld.target_type);
 	} while (IS_ERR(cxlr) && PTR_ERR(cxlr) == -EBUSY);
 
 	if (IS_ERR(cxlr)) {
-- 
2.34.1


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

* [PATCH v1 2/3] cxl/region: Factor out interleave ways setup
  2026-02-24 15:26 [PATCH v1 0/3] cxl region changes for Type2 support alejandro.lucero-palau
  2026-02-24 15:26 ` [PATCH v1 1/3] cxl: Make region type based on endpoint type alejandro.lucero-palau
@ 2026-02-24 15:26 ` alejandro.lucero-palau
  2026-02-24 15:54   ` Dave Jiang
  2026-02-24 16:05   ` Gregory Price
  2026-02-24 15:26 ` [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup alejandro.lucero-palau
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: alejandro.lucero-palau @ 2026-02-24 15:26 UTC (permalink / raw)
  To: linux-cxl, dan.j.williams, dave.jiang; +Cc: Alejandro Lucero

From: Alejandro Lucero <alucerop@amd.com>

Region creation based on Type3 devices is triggered from user space
allowing memory combination through interleaving.

In preparation for kernel driven region creation, that is Type2 drivers
triggering region creation backed with its advertised CXL memory, factor
out a common helper from the user-sysfs region setup for interleave ways.

Signed-off-by: Alejandro Lucero <alucerop@amd.com>
---
 drivers/cxl/core/region.c | 41 +++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index cac33c99fe6a..3ef4ccf1c92b 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -485,22 +485,14 @@ static ssize_t interleave_ways_show(struct device *dev,
 
 static const struct attribute_group *get_cxl_region_target_group(void);
 
-static ssize_t interleave_ways_store(struct device *dev,
-				     struct device_attribute *attr,
-				     const char *buf, size_t len)
+static int set_interleave_ways(struct cxl_region *cxlr, int val)
 {
-	struct cxl_region *cxlr = to_cxl_region(dev);
 	struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
 	struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld;
 	struct cxl_region_params *p = &cxlr->params;
-	unsigned int val, save;
-	int rc;
+	int save, rc;
 	u8 iw;
 
-	rc = kstrtouint(buf, 0, &val);
-	if (rc)
-		return rc;
-
 	rc = ways_to_eiw(val, &iw);
 	if (rc)
 		return rc;
@@ -515,9 +507,7 @@ static ssize_t interleave_ways_store(struct device *dev,
 		return -EINVAL;
 	}
 
-	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
-	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
-		return rc;
+	lockdep_assert_held_write(&cxl_rwsem.region);
 
 	if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE)
 		return -EBUSY;
@@ -525,10 +515,31 @@ static ssize_t interleave_ways_store(struct device *dev,
 	save = p->interleave_ways;
 	p->interleave_ways = val;
 	rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group());
-	if (rc) {
+	if (rc)
 		p->interleave_ways = save;
+
+	return rc;
+}
+
+static ssize_t interleave_ways_store(struct device *dev,
+				     struct device_attribute *attr,
+				     const char *buf, size_t len)
+{
+	struct cxl_region *cxlr = to_cxl_region(dev);
+	unsigned int val;
+	int rc;
+
+	rc = kstrtouint(buf, 0, &val);
+	if (rc)
+		return rc;
+
+	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
+	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
+		return rc;
+
+	rc = set_interleave_ways(cxlr, val);
+	if (rc)
 		return rc;
-	}
 
 	return len;
 }
-- 
2.34.1


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

* [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup
  2026-02-24 15:26 [PATCH v1 0/3] cxl region changes for Type2 support alejandro.lucero-palau
  2026-02-24 15:26 ` [PATCH v1 1/3] cxl: Make region type based on endpoint type alejandro.lucero-palau
  2026-02-24 15:26 ` [PATCH v1 2/3] cxl/region: Factor out interleave ways setup alejandro.lucero-palau
@ 2026-02-24 15:26 ` alejandro.lucero-palau
  2026-02-24 16:06   ` Gregory Price
  2026-02-24 16:13   ` Dave Jiang
  2026-02-24 15:39 ` [PATCH v1 0/3] cxl region changes for Type2 support Dave Jiang
  2026-02-24 16:06 ` Gregory Price
  4 siblings, 2 replies; 13+ messages in thread
From: alejandro.lucero-palau @ 2026-02-24 15:26 UTC (permalink / raw)
  To: linux-cxl, dan.j.williams, dave.jiang; +Cc: Alejandro Lucero

From: Alejandro Lucero <alucerop@amd.com>

Region creation based on Type3 devices is triggered from user space
allowing memory combination through interleaving.

In preparation for kernel driven region creation, that is Type2 drivers
triggering region creation backed with its advertised CXL memory, factor
out a common helper from the user-sysfs region setup forinterleave
granularity.

Signed-off-by: Alejandro Lucero <alucerop@amd.com>
---
 drivers/cxl/core/region.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 3ef4ccf1c92b..aed3733490a1 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -559,21 +559,14 @@ static ssize_t interleave_granularity_show(struct device *dev,
 	return sysfs_emit(buf, "%d\n", p->interleave_granularity);
 }
 
-static ssize_t interleave_granularity_store(struct device *dev,
-					    struct device_attribute *attr,
-					    const char *buf, size_t len)
+static int set_interleave_granularity(struct cxl_region *cxlr, int val)
 {
-	struct cxl_region *cxlr = to_cxl_region(dev);
 	struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
 	struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld;
 	struct cxl_region_params *p = &cxlr->params;
-	int rc, val;
+	int rc;
 	u16 ig;
 
-	rc = kstrtoint(buf, 0, &val);
-	if (rc)
-		return rc;
-
 	rc = granularity_to_eig(val, &ig);
 	if (rc)
 		return rc;
@@ -589,14 +582,33 @@ static ssize_t interleave_granularity_store(struct device *dev,
 	if (cxld->interleave_ways > 1 && val != cxld->interleave_granularity)
 		return -EINVAL;
 
-	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
-	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
-		return rc;
+	lockdep_assert_held_write(&cxl_rwsem.region);
 
 	if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE)
 		return -EBUSY;
 
 	p->interleave_granularity = val;
+	return 0;
+}
+
+static ssize_t interleave_granularity_store(struct device *dev,
+					    struct device_attribute *attr,
+					    const char *buf, size_t len)
+{
+	struct cxl_region *cxlr = to_cxl_region(dev);
+	int rc, val;
+
+	rc = kstrtoint(buf, 0, &val);
+	if (rc)
+		return rc;
+
+	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
+	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
+		return rc;
+
+	rc = set_interleave_granularity(cxlr, val);
+	if (rc)
+		return rc;
 
 	return len;
 }
-- 
2.34.1


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

* Re: [PATCH v1 0/3] cxl region changes for Type2 support
  2026-02-24 15:26 [PATCH v1 0/3] cxl region changes for Type2 support alejandro.lucero-palau
                   ` (2 preceding siblings ...)
  2026-02-24 15:26 ` [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup alejandro.lucero-palau
@ 2026-02-24 15:39 ` Dave Jiang
  2026-02-24 16:20   ` Alejandro Lucero Palau
  2026-02-24 16:06 ` Gregory Price
  4 siblings, 1 reply; 13+ messages in thread
From: Dave Jiang @ 2026-02-24 15:39 UTC (permalink / raw)
  To: alejandro.lucero-palau, linux-cxl, dan.j.williams; +Cc: Alejandro Lucero



On 2/24/26 8:26 AM, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> In preparation for Type2 devices/drivers support, these next patches
> adapt the cxl region code for required Type2 functionality preserving
> current functionality.
> 
> Alejandro Lucero (3):
>   cxl: Make region type based on endpoint type
>   cxl/region: Factor out interleave ways setup
>   cxl/region: Factor out interleave granularity setup
> 
>  drivers/cxl/core/region.c | 87 +++++++++++++++++++++++++--------------
>  1 file changed, 56 insertions(+), 31 deletions(-)
> 
> 
> base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f

Does this set depends on the preparation set [1] or is independent?

[1]: https://lore.kernel.org/linux-cxl/20260223142633.2994082-1-alejandro.lucero-palau@amd.com/T/#t

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

* Re: [PATCH v1 2/3] cxl/region: Factor out interleave ways setup
  2026-02-24 15:26 ` [PATCH v1 2/3] cxl/region: Factor out interleave ways setup alejandro.lucero-palau
@ 2026-02-24 15:54   ` Dave Jiang
  2026-02-24 16:21     ` Alejandro Lucero Palau
  2026-02-24 16:05   ` Gregory Price
  1 sibling, 1 reply; 13+ messages in thread
From: Dave Jiang @ 2026-02-24 15:54 UTC (permalink / raw)
  To: alejandro.lucero-palau, linux-cxl, dan.j.williams; +Cc: Alejandro Lucero



On 2/24/26 8:26 AM, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> Region creation based on Type3 devices is triggered from user space

s/is/can be/

Since there's also auto region creation.

> allowing memory combination through interleaving.
> 
> In preparation for kernel driven region creation, that is Type2 drivers
> triggering region creation backed with its advertised CXL memory, factor
> out a common helper from the user-sysfs region setup for interleave ways.
> 
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  drivers/cxl/core/region.c | 41 +++++++++++++++++++++++++--------------
>  1 file changed, 26 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index cac33c99fe6a..3ef4ccf1c92b 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -485,22 +485,14 @@ static ssize_t interleave_ways_show(struct device *dev,
>  
>  static const struct attribute_group *get_cxl_region_target_group(void);
>  
> -static ssize_t interleave_ways_store(struct device *dev,
> -				     struct device_attribute *attr,
> -				     const char *buf, size_t len)
> +static int set_interleave_ways(struct cxl_region *cxlr, int val)
>  {
> -	struct cxl_region *cxlr = to_cxl_region(dev);
>  	struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
>  	struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld;
>  	struct cxl_region_params *p = &cxlr->params;
> -	unsigned int val, save;
> -	int rc;
> +	int save, rc;
>  	u8 iw;
>  
> -	rc = kstrtouint(buf, 0, &val);
> -	if (rc)
> -		return rc;
> -
>  	rc = ways_to_eiw(val, &iw);
>  	if (rc)
>  		return rc;
> @@ -515,9 +507,7 @@ static ssize_t interleave_ways_store(struct device *dev,
>  		return -EINVAL;
>  	}
>  
> -	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
> -	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
> -		return rc;
> +	lockdep_assert_held_write(&cxl_rwsem.region);
>  
>  	if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE)
>  		return -EBUSY;
> @@ -525,10 +515,31 @@ static ssize_t interleave_ways_store(struct device *dev,
>  	save = p->interleave_ways;
>  	p->interleave_ways = val;
>  	rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group());
> -	if (rc) {
> +	if (rc)
>  		p->interleave_ways = save;
> +
> +	return rc;
> +}
> +
> +static ssize_t interleave_ways_store(struct device *dev,
> +				     struct device_attribute *attr,
> +				     const char *buf, size_t len)
> +{
> +	struct cxl_region *cxlr = to_cxl_region(dev);
> +	unsigned int val;
> +	int rc;
> +
> +	rc = kstrtouint(buf, 0, &val);
> +	if (rc)
> +		return rc;
> +
> +	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
> +	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
> +		return rc;
> +
> +	rc = set_interleave_ways(cxlr, val);
> +	if (rc)
>  		return rc;
> -	}
>  
>  	return len;
>  }


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

* Re: [PATCH v1 1/3] cxl: Make region type based on endpoint type
  2026-02-24 15:26 ` [PATCH v1 1/3] cxl: Make region type based on endpoint type alejandro.lucero-palau
@ 2026-02-24 16:04   ` Gregory Price
  0 siblings, 0 replies; 13+ messages in thread
From: Gregory Price @ 2026-02-24 16:04 UTC (permalink / raw)
  To: alejandro.lucero-palau
  Cc: linux-cxl, dan.j.williams, dave.jiang, Alejandro Lucero, Zhi Wang,
	Jonathan Cameron, Ben Cheatham, Alison Schofield, Davidlohr Bueso

On Tue, Feb 24, 2026 at 03:26:43PM +0000, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> Current code is expecting Type3 or CXL_DECODER_HOSTONLYMEM devices only.
> Support for Type2 implies region type needs to be based on the endpoint
> type HDM-D[B] instead.
> 
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
> Reviewed-by: Zhi Wang <zhiw@nvidia.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> Reviewed-by: Davidlohr Bueso <daves@stgolabs.net>


Reviewed-by: Gregory Price <gourry@gourry.net>

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

* Re: [PATCH v1 2/3] cxl/region: Factor out interleave ways setup
  2026-02-24 15:26 ` [PATCH v1 2/3] cxl/region: Factor out interleave ways setup alejandro.lucero-palau
  2026-02-24 15:54   ` Dave Jiang
@ 2026-02-24 16:05   ` Gregory Price
  1 sibling, 0 replies; 13+ messages in thread
From: Gregory Price @ 2026-02-24 16:05 UTC (permalink / raw)
  To: alejandro.lucero-palau
  Cc: linux-cxl, dan.j.williams, dave.jiang, Alejandro Lucero

On Tue, Feb 24, 2026 at 03:26:44PM +0000, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> Region creation based on Type3 devices is triggered from user space
> allowing memory combination through interleaving.
> 
> In preparation for kernel driven region creation, that is Type2 drivers
> triggering region creation backed with its advertised CXL memory, factor
> out a common helper from the user-sysfs region setup for interleave ways.
> 
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>

Reviewed-by: Gregory Price <gourry@gourry.net>

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

* Re: [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup
  2026-02-24 15:26 ` [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup alejandro.lucero-palau
@ 2026-02-24 16:06   ` Gregory Price
  2026-02-24 16:13   ` Dave Jiang
  1 sibling, 0 replies; 13+ messages in thread
From: Gregory Price @ 2026-02-24 16:06 UTC (permalink / raw)
  To: alejandro.lucero-palau
  Cc: linux-cxl, dan.j.williams, dave.jiang, Alejandro Lucero

On Tue, Feb 24, 2026 at 03:26:45PM +0000, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> Region creation based on Type3 devices is triggered from user space
> allowing memory combination through interleaving.
> 
> In preparation for kernel driven region creation, that is Type2 drivers
> triggering region creation backed with its advertised CXL memory, factor
> out a common helper from the user-sysfs region setup forinterleave
> granularity.
> 
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>

Reviewed-by: Gregory Price <gourry@gourry.net>

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

* Re: [PATCH v1 0/3] cxl region changes for Type2 support
  2026-02-24 15:26 [PATCH v1 0/3] cxl region changes for Type2 support alejandro.lucero-palau
                   ` (3 preceding siblings ...)
  2026-02-24 15:39 ` [PATCH v1 0/3] cxl region changes for Type2 support Dave Jiang
@ 2026-02-24 16:06 ` Gregory Price
  4 siblings, 0 replies; 13+ messages in thread
From: Gregory Price @ 2026-02-24 16:06 UTC (permalink / raw)
  To: alejandro.lucero-palau
  Cc: linux-cxl, dan.j.williams, dave.jiang, Alejandro Lucero

On Tue, Feb 24, 2026 at 03:26:42PM +0000, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> In preparation for Type2 devices/drivers support, these next patches
> adapt the cxl region code for required Type2 functionality preserving
> current functionality.
> 
> Alejandro Lucero (3):
>   cxl: Make region type based on endpoint type
>   cxl/region: Factor out interleave ways setup
>   cxl/region: Factor out interleave granularity setup
> 
>  drivers/cxl/core/region.c | 87 +++++++++++++++++++++++++--------------
>  1 file changed, 56 insertions(+), 31 deletions(-)
> 

I've been testing with these for a while - the additional lockdep is a
nice addition.  So for series

Tested-by: Gregory Price <gourry@gourry.net>


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

* Re: [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup
  2026-02-24 15:26 ` [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup alejandro.lucero-palau
  2026-02-24 16:06   ` Gregory Price
@ 2026-02-24 16:13   ` Dave Jiang
  1 sibling, 0 replies; 13+ messages in thread
From: Dave Jiang @ 2026-02-24 16:13 UTC (permalink / raw)
  To: alejandro.lucero-palau, linux-cxl, dan.j.williams; +Cc: Alejandro Lucero



On 2/24/26 8:26 AM, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
> 
> Region creation based on Type3 devices is triggered from user space

same comment here as for 2/3.

> allowing memory combination through interleaving.
> 
> In preparation for kernel driven region creation, that is Type2 drivers
> triggering region creation backed with its advertised CXL memory, factor
> out a common helper from the user-sysfs region setup forinterleave
> granularity.
> 
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>


> ---
>  drivers/cxl/core/region.c | 36 ++++++++++++++++++++++++------------
>  1 file changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 3ef4ccf1c92b..aed3733490a1 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -559,21 +559,14 @@ static ssize_t interleave_granularity_show(struct device *dev,
>  	return sysfs_emit(buf, "%d\n", p->interleave_granularity);
>  }
>  
> -static ssize_t interleave_granularity_store(struct device *dev,
> -					    struct device_attribute *attr,
> -					    const char *buf, size_t len)
> +static int set_interleave_granularity(struct cxl_region *cxlr, int val)
>  {
> -	struct cxl_region *cxlr = to_cxl_region(dev);
>  	struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
>  	struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld;
>  	struct cxl_region_params *p = &cxlr->params;
> -	int rc, val;
> +	int rc;
>  	u16 ig;
>  
> -	rc = kstrtoint(buf, 0, &val);
> -	if (rc)
> -		return rc;
> -
>  	rc = granularity_to_eig(val, &ig);
>  	if (rc)
>  		return rc;
> @@ -589,14 +582,33 @@ static ssize_t interleave_granularity_store(struct device *dev,
>  	if (cxld->interleave_ways > 1 && val != cxld->interleave_granularity)
>  		return -EINVAL;
>  
> -	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
> -	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
> -		return rc;
> +	lockdep_assert_held_write(&cxl_rwsem.region);
>  
>  	if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE)
>  		return -EBUSY;
>  
>  	p->interleave_granularity = val;
> +	return 0;
> +}
> +
> +static ssize_t interleave_granularity_store(struct device *dev,
> +					    struct device_attribute *attr,
> +					    const char *buf, size_t len)
> +{
> +	struct cxl_region *cxlr = to_cxl_region(dev);
> +	int rc, val;
> +
> +	rc = kstrtoint(buf, 0, &val);
> +	if (rc)
> +		return rc;
> +
> +	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
> +	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
> +		return rc;
> +
> +	rc = set_interleave_granularity(cxlr, val);
> +	if (rc)
> +		return rc;
>  
>  	return len;
>  }


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

* Re: [PATCH v1 0/3] cxl region changes for Type2 support
  2026-02-24 15:39 ` [PATCH v1 0/3] cxl region changes for Type2 support Dave Jiang
@ 2026-02-24 16:20   ` Alejandro Lucero Palau
  0 siblings, 0 replies; 13+ messages in thread
From: Alejandro Lucero Palau @ 2026-02-24 16:20 UTC (permalink / raw)
  To: Dave Jiang, alejandro.lucero-palau, linux-cxl, dan.j.williams


On 2/24/26 15:39, Dave Jiang wrote:
>
> On 2/24/26 8:26 AM, alejandro.lucero-palau@amd.com wrote:
>> From: Alejandro Lucero <alucerop@amd.com>
>>
>> In preparation for Type2 devices/drivers support, these next patches
>> adapt the cxl region code for required Type2 functionality preserving
>> current functionality.
>>
>> Alejandro Lucero (3):
>>    cxl: Make region type based on endpoint type
>>    cxl/region: Factor out interleave ways setup
>>    cxl/region: Factor out interleave granularity setup
>>
>>   drivers/cxl/core/region.c | 87 +++++++++++++++++++++++++--------------
>>   1 file changed, 56 insertions(+), 31 deletions(-)
>>
>>
>> base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
> Does this set depends on the preparation set [1] or is independent?


Hi Dave,


It is independent, but it applies cleanly on top of the previous ones as 
core/region.c is not modified by the other.


Thank you


> [1]: https://lore.kernel.org/linux-cxl/20260223142633.2994082-1-alejandro.lucero-palau@amd.com/T/#t

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

* Re: [PATCH v1 2/3] cxl/region: Factor out interleave ways setup
  2026-02-24 15:54   ` Dave Jiang
@ 2026-02-24 16:21     ` Alejandro Lucero Palau
  0 siblings, 0 replies; 13+ messages in thread
From: Alejandro Lucero Palau @ 2026-02-24 16:21 UTC (permalink / raw)
  To: Dave Jiang, alejandro.lucero-palau, linux-cxl, dan.j.williams


On 2/24/26 15:54, Dave Jiang wrote:
>
> On 2/24/26 8:26 AM, alejandro.lucero-palau@amd.com wrote:
>> From: Alejandro Lucero <alucerop@amd.com>
>>
>> Region creation based on Type3 devices is triggered from user space
> s/is/can be/
>
> Since there's also auto region creation.


Ok. I will send a v2.


>> allowing memory combination through interleaving.
>>
>> In preparation for kernel driven region creation, that is Type2 drivers
>> triggering region creation backed with its advertised CXL memory, factor
>> out a common helper from the user-sysfs region setup for interleave ways.
>>
>> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>


Thank you

>> ---
>>   drivers/cxl/core/region.c | 41 +++++++++++++++++++++++++--------------
>>   1 file changed, 26 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>> index cac33c99fe6a..3ef4ccf1c92b 100644
>> --- a/drivers/cxl/core/region.c
>> +++ b/drivers/cxl/core/region.c
>> @@ -485,22 +485,14 @@ static ssize_t interleave_ways_show(struct device *dev,
>>   
>>   static const struct attribute_group *get_cxl_region_target_group(void);
>>   
>> -static ssize_t interleave_ways_store(struct device *dev,
>> -				     struct device_attribute *attr,
>> -				     const char *buf, size_t len)
>> +static int set_interleave_ways(struct cxl_region *cxlr, int val)
>>   {
>> -	struct cxl_region *cxlr = to_cxl_region(dev);
>>   	struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
>>   	struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld;
>>   	struct cxl_region_params *p = &cxlr->params;
>> -	unsigned int val, save;
>> -	int rc;
>> +	int save, rc;
>>   	u8 iw;
>>   
>> -	rc = kstrtouint(buf, 0, &val);
>> -	if (rc)
>> -		return rc;
>> -
>>   	rc = ways_to_eiw(val, &iw);
>>   	if (rc)
>>   		return rc;
>> @@ -515,9 +507,7 @@ static ssize_t interleave_ways_store(struct device *dev,
>>   		return -EINVAL;
>>   	}
>>   
>> -	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
>> -	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
>> -		return rc;
>> +	lockdep_assert_held_write(&cxl_rwsem.region);
>>   
>>   	if (p->state >= CXL_CONFIG_INTERLEAVE_ACTIVE)
>>   		return -EBUSY;
>> @@ -525,10 +515,31 @@ static ssize_t interleave_ways_store(struct device *dev,
>>   	save = p->interleave_ways;
>>   	p->interleave_ways = val;
>>   	rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group());
>> -	if (rc) {
>> +	if (rc)
>>   		p->interleave_ways = save;
>> +
>> +	return rc;
>> +}
>> +
>> +static ssize_t interleave_ways_store(struct device *dev,
>> +				     struct device_attribute *attr,
>> +				     const char *buf, size_t len)
>> +{
>> +	struct cxl_region *cxlr = to_cxl_region(dev);
>> +	unsigned int val;
>> +	int rc;
>> +
>> +	rc = kstrtouint(buf, 0, &val);
>> +	if (rc)
>> +		return rc;
>> +
>> +	ACQUIRE(rwsem_write_kill, rwsem)(&cxl_rwsem.region);
>> +	if ((rc = ACQUIRE_ERR(rwsem_write_kill, &rwsem)))
>> +		return rc;
>> +
>> +	rc = set_interleave_ways(cxlr, val);
>> +	if (rc)
>>   		return rc;
>> -	}
>>   
>>   	return len;
>>   }

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

end of thread, other threads:[~2026-02-24 16:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 15:26 [PATCH v1 0/3] cxl region changes for Type2 support alejandro.lucero-palau
2026-02-24 15:26 ` [PATCH v1 1/3] cxl: Make region type based on endpoint type alejandro.lucero-palau
2026-02-24 16:04   ` Gregory Price
2026-02-24 15:26 ` [PATCH v1 2/3] cxl/region: Factor out interleave ways setup alejandro.lucero-palau
2026-02-24 15:54   ` Dave Jiang
2026-02-24 16:21     ` Alejandro Lucero Palau
2026-02-24 16:05   ` Gregory Price
2026-02-24 15:26 ` [PATCH v1 3/3] cxl/region: Factor out interleave granularity setup alejandro.lucero-palau
2026-02-24 16:06   ` Gregory Price
2026-02-24 16:13   ` Dave Jiang
2026-02-24 15:39 ` [PATCH v1 0/3] cxl region changes for Type2 support Dave Jiang
2026-02-24 16:20   ` Alejandro Lucero Palau
2026-02-24 16:06 ` Gregory Price

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