Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <dave@stgolabs.net>,
	<alison.schofield@intel.com>, <vishal.l.verma@intel.com>,
	<ira.weiny@intel.com>, <dan.j.williams@intel.com>
Subject: Re: [PATCH v2] cxl: Remove core/acpi.c and cxl core dependency on ACPI
Date: Tue, 10 Jun 2025 10:35:04 +0100	[thread overview]
Message-ID: <20250610103504.00004316@huawei.com> (raw)
In-Reply-To: <20250610000237.2929667-2-dave.jiang@intel.com>

On Mon, 9 Jun 2025 17:02:37 -0700
Dave Jiang <dave.jiang@intel.com> wrote:

> It was a mistake to introduce core/acpi.c and putting ACPI dependency on
> cxl_core when adding the extended linear cache support. Add a callback
> in the cxl_root_decoder to retrieve the extended linear cache size from
> ACPI via the cxl_acpi driver.
> 
> In order to deal with cxl_test, a device parameter had to be introduced
> to the hmat_get_extended_linear_cache_size() call in order to help with
> the mock wrapped function from ACPI. Even though the 'struct device' is
> not used by the actual hmat_get_extended_linear_cache_size() function.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> v2:
> - Remove introduction of 'struct device' parameter to
>   hmat_get_extended_linear_cache_size().
> - Drop comment on flex array (Jonathan)
> - Rename cxl_rcd_ops to cxl_rd_ops for 'root decoder ops' (Fabio)
There is a lot of indirection going on in here, but I think I understand
why it is all there.  A few comments inline. The device reference one
just passes what I'm comfortable assuming you will just fix it up though
so I'll wait for v3 for tags.

J

> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 8a5815ca870d..3f6780179752 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -470,6 +470,43 @@ struct cxl_cedt_context {
>  	struct device *dev;
>  };
>  
> +static int match_root_decoder_by_range(struct device *dev, const void *data)
> +{
> +	const struct range *r1, *r2 = data;

I'm fussy about this, but I'd not mix a non assigned and assigned declaration
in one line.  (Trivial comment though so ignore if you like)

> +	struct cxl_root_decoder *cxlrd;
> +
> +	if (!is_root_decoder(dev))
> +		return 0;
> +
> +	cxlrd = to_cxl_root_decoder(dev);
> +	r1 = &cxlrd->cxlsd.cxld.hpa_range;
> +	return range_contains(r1, r2);
> +}
> +
> +static int mock_hmat_get_extended_linear_cache_size(struct resource *backing_res,
> +						    int nid, resource_size_t *size)
> +{
> +	struct range backing_range = {
> +		.start = backing_res->start,
> +		.end = backing_res->end,
> +	};
> +	struct cxl_decoder *cxld;
> +	struct cxl_port *port;
> +	struct device *dev;
> +
> +	dev = bus_find_device(&cxl_bus_type, NULL, &backing_range,
> +			      match_root_decoder_by_range);

This grabs a reference to the device.  Do we need a put_device()
somewhere?

> +	if (!dev)
> +		return -ENODEV;
> +
> +	cxld = to_cxl_decoder(dev);
> +	port = to_cxl_port(cxld->dev.parent);
> +	if (is_mock_dev(port->uport_dev))
> +		return -EOPNOTSUPP;
> +
> +	return hmat_get_extended_linear_cache_size(backing_res, nid, size);
> +}
> +
>  static int mock_acpi_table_parse_cedt(enum acpi_cedt_type id,
>  				      acpi_tbl_entry_handler_arg handler_arg,
>  				      void *arg)
> @@ -1040,6 +1077,8 @@ static struct cxl_mock_ops cxl_mock_ops = {
>  	.devm_cxl_enumerate_decoders = mock_cxl_enumerate_decoders,
>  	.cxl_endpoint_parse_cdat = mock_cxl_endpoint_parse_cdat,
>  	.list = LIST_HEAD_INIT(cxl_mock_ops.list),
> +	.hmat_get_extended_linear_cache_size =
> +		mock_hmat_get_extended_linear_cache_size,
>  };

Why is list set last in here?  It's first in the structure
and we now end up with the callbacks not next to each other which looks
weird.  Maybe move the LIST_HEAD_INIT() up, or if not move the new
callback setting up one line to next to parse_cdat.




  reply	other threads:[~2025-06-10  9:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10  0:02 [PATCH] cxl: Remove core/acpi.c and cxl core dependency on ACPI Dave Jiang
2025-06-10  0:02 ` [PATCH v2] " Dave Jiang
2025-06-10  9:35   ` Jonathan Cameron [this message]
2025-06-10 17:22     ` Dave Jiang
2025-06-10  0:03 ` [PATCH] " Dave Jiang
     [not found] <20250715185737.5d9c75e4@canb.auug.org.au>
2025-07-15 10:40 ` [PATCH v2] " Robert Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250610103504.00004316@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox