[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <de625425-bc2c-4fe8-850a-2196946ce9d8@intel.com>
Date: Wed, 15 Oct 2025 08:38:29 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Vishal Aslot <vaslot@...dia.com>, Davidlohr Bueso <dave@...olabs.net>,
Jonathan Cameron <jonathan.cameron@...wei.com>,
Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>,
Dan Williams <dan.j.williams@...el.com>, Li Ming <ming.li@...omail.com>,
Peter Zijlstra <peterz@...radead.org>,
"open list:COMPUTE EXPRESS LINK (CXL)" <linux-cxl@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 1/2] cxl_test: enable zero sized decoders under hb0
On 10/14/25 7:40 PM, Vishal Aslot wrote:
> The cxl core in linux updated to supported committed
> decoders of zero size, because this is allowed by
> the CXL spec.
>
> This patch updates cxl_test to enable decoders 1 and 2
> in the host-bridge 0 port, in a switch uport under hb0,
> and the endpoints ports with size zero simulating
> committed zero sized decoders.
Hi Vishal, first of all, really appreciate you doing this. If there's another rev of the series, let's reorder and the test patch should go after the implementation patch.
Can you add a little more in the commit log on how this is tested? i.e. this code is exercised in cxl-topology.sh unit test or something else etc etc.
>
> Signed-off-by: Vishal Aslot <vaslot@...dia.com>
> ---
> tools/testing/cxl/test/cxl.c | 96 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 94 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 2d135ca533d0..cb18ee41a7cf 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -719,6 +719,45 @@ static void default_mock_decoder(struct cxl_decoder *cxld)
> cxld->reset = mock_decoder_reset;
> }
>
> +static void size_zero_mock_decoder_ep(struct cxl_decoder *cxld, u64 base)
> +{
> + struct cxl_endpoint_decoder *cxled;
> +
> + cxled = to_cxl_endpoint_decoder(&cxld->dev);
> + cxld->hpa_range = (struct range){
> + .start = base,
> + .end = base - 1, /* Size 0 */
> + };
> +
> + cxld->interleave_ways = 2;
> + cxld->interleave_granularity = 4096;
> + cxld->target_type = CXL_DECODER_HOSTONLYMEM;
> + cxld->flags = CXL_DECODER_F_ENABLE;
> + cxled->state = CXL_DECODER_STATE_AUTO;
> + cxld->commit = mock_decoder_commit;
> + cxld->reset = mock_decoder_reset;
> +}
> +
> +static void size_zero_mock_decoder_sw(struct device *dev, u64 base, int i)
> +{
> + struct cxl_switch_decoder *cxlsd;
> + struct cxl_decoder *cxld;
> +
> + cxlsd = to_cxl_switch_decoder(dev);
> + cxld = &cxlsd->cxld;
> + cxld->flags = CXL_DECODER_F_ENABLE;
> + cxld->target_type = CXL_DECODER_HOSTONLYMEM;
> + if (i == 0)
> + cxld->interleave_ways = 2;
> + else
> + cxld->interleave_ways = 1;
> + cxld->interleave_granularity = 4096;
> + cxld->hpa_range = (struct range) {
> + .start = base,
> + .end = base - 1, /* Size 0 */
> + };
> +}
> +
> static int first_decoder(struct device *dev, const void *data)
> {
> struct cxl_decoder *cxld;
> @@ -731,6 +770,30 @@ static int first_decoder(struct device *dev, const void *data)
> return 0;
> }
>
> +static int second_decoder(struct device *dev, const void *data)
> +{
> + struct cxl_decoder *cxld;
> +
> + if (!is_switch_decoder(dev))
> + return 0;
> + cxld = to_cxl_decoder(dev);
> + if (cxld->id == 1)
> + return 1;
> + return 0;
> +}
> +
> +static int third_decoder(struct device *dev, const void *data)
> +{
> + struct cxl_decoder *cxld;
> +
> + if (!is_switch_decoder(dev))
> + return 0;
> + cxld = to_cxl_decoder(dev);
> + if (cxld->id == 2)
> + return 1;
> + return 0;
> +}
> +
> static void mock_init_hdm_decoder(struct cxl_decoder *cxld)
> {
> struct acpi_cedt_cfmws *window = mock_cfmws[0];
> @@ -743,7 +806,7 @@ static void mock_init_hdm_decoder(struct cxl_decoder *cxld)
> struct cxl_dport *dport;
> struct device *dev;
> bool hb0 = false;
> - u64 base;
> + u64 base = window->base_hpa;
> int i;
>
> if (is_endpoint_decoder(&cxld->dev)) {
> @@ -767,6 +830,20 @@ static void mock_init_hdm_decoder(struct cxl_decoder *cxld)
> port = cxled_to_port(cxled);
> }
>
> + /*
> + * Decoders 1 and 2 of the endpoint under host bridge 0 should be enabled as zero-sized.
> + * It would be even better to make sure that the parent switch uport decoder was
> + * also enabled before enabling the size zero decoders but there is no harm in doing it
> + * anyway.
> + */
> + if (hb0 && (cxld->id == 1 || cxld->id == 2)) {
> + port = to_cxl_port(cxld->dev.parent);
> + size_zero_mock_decoder_ep(cxld, base);
> + /* Commit the zero-sized decoder */
> + port->commit_end = cxld->id;
> + return;
> + }
> +
> /*
> * The first decoder on the first 2 devices on the first switch
> * attached to host-bridge0 mock a fake / static RAM region. All
> @@ -780,7 +857,6 @@ static void mock_init_hdm_decoder(struct cxl_decoder *cxld)
> return;
> }
>
> - base = window->base_hpa;
> cxld->hpa_range = (struct range) {
> .start = base,
> .end = base + size - 1,
> @@ -844,6 +920,22 @@ static void mock_init_hdm_decoder(struct cxl_decoder *cxld)
> .end = base + size - 1,
> };
> put_device(dev);
> +
> + /* Enable the next two decoders also and make them zero sized */
s/decoders/switch decoders/
> + dev = device_find_child(&iter->dev, NULL, second_decoder);
Maybe just pass in the index as the data parameter and then you can just use match_decoder_by_index instead of static code second and third.
DJ
> + WARN_ON(!dev);
> + if (dev) {
> + size_zero_mock_decoder_sw(dev, base, i);
> + iter->commit_end = 1;
> + put_device(dev);
> + }
> + dev = device_find_child(&iter->dev, NULL, third_decoder);
> + WARN_ON(!dev);
> + if (dev) {
> + size_zero_mock_decoder_sw(dev, base, i);
> + iter->commit_end = 2;
> + put_device(dev);
> + }
> }
> }
>
Powered by blists - more mailing lists