Subject: Re: [PATCH v9 22/27] cxl: allow region creation by type2 drivers

From: Jonathan Cameron <[email-masked]>
Date: Thu, 2 Jan 2025 15:22:43 +0000

On Mon, 30 Dec 2024 21:44:40 +0000
[email-masked] wrote:

> From: Alejandro Lucero <[email-masked]>
> 
> Creating a CXL region requires userspace intervention through the cxl
> sysfs files. Type2 support should allow accelerator drivers to create
> such cxl region from kernel code.
> 
> Adding that functionality and integrating it with current support for
> memory expanders.
> 
> Based on https://lore.kernel.org/linux-cxl/[email-masked]/
> 
> Signed-off-by: Alejandro Lucero <[email-masked]>
> Co-developed-by: Dan Williams <[email-masked]>
> Reviewed-by: Zhi Wang <[email-masked]>

Trivial comment inline. Either way
Reviewed-by: Jonathan Cameron <[email-masked]>

> ---
>  drivers/cxl/core/region.c | 145 ++++++++++++++++++++++++++++++++++----
>  drivers/cxl/cxlmem.h      |   2 +
>  drivers/cxl/port.c        |   5 +-
>  include/cxl/cxl.h         |   4 ++
>  4 files changed, 141 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 1b1d45c44b52..a2b92162edbd 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2270,6 +2270,18 @@ static int cxl_region_detach(struct cxl_endpoint_decoder *cxled)
>  	return rc;
>  }
>  
> +int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled)
> +{
> +	int rc;
> +
> +	down_write(&cxl_region_rwsem);

Could use a guard here so you can return directly.

> +	cxled->mode = CXL_DECODER_DEAD;
> +	rc = cxl_region_detach(cxled);
> +	up_write(&cxl_region_rwsem);
> +	return rc;
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_accel_region_detach, "CXL");