diff mbox series

[2/4] cxl/list: Filter root decoders by region

Message ID 168236638318.1027628.17234728660914767074.stgit@dwillia2-xfh.jf.intel.com
State Accepted
Commit 228cbe0f2401766298047f405b2354835ec11aa6
Headers show
Series cxl list and test fixes | expand

Commit Message

Dan Williams April 24, 2023, 7:59 p.m. UTC
Arrange for util_cxl_decoder_filter_by_region() to consider that root
decoders host multiple regions, unlike switch and endpoint decoders that
have a 1:1 relationship.

Before: (list the root decoders hosting region4 and region9)
    # cxl list -Du -d root -r 4,9
      Warning: no matching devices found

    [
    ]

After:
    # cxl list -Du -d root -r 4,9
    [
      {
        "decoder":"decoder3.0",
        "resource":"0xf010000000",
        "size":"1024.00 MiB (1073.74 MB)",
        "interleave_ways":1,
        "max_available_extent":"512.00 MiB (536.87 MB)",
        "volatile_capable":true,
        "nr_targets":1
      },
      {
        "decoder":"decoder3.5",
        "resource":"0xf1d0000000",
        "size":"256.00 MiB (268.44 MB)",
        "interleave_ways":1,
        "accelmem_capable":true,
        "nr_targets":1
      }
    ]

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 cxl/filter.c |    6 ++++++
 1 file changed, 6 insertions(+)

Comments

Dave Jiang April 28, 2023, 4:03 p.m. UTC | #1
On 4/24/23 12:59 PM, Dan Williams wrote:
> Arrange for util_cxl_decoder_filter_by_region() to consider that root
> decoders host multiple regions, unlike switch and endpoint decoders that
> have a 1:1 relationship.
> 
> Before: (list the root decoders hosting region4 and region9)
>      # cxl list -Du -d root -r 4,9
>        Warning: no matching devices found
> 
>      [
>      ]
> 
> After:
>      # cxl list -Du -d root -r 4,9
>      [
>        {
>          "decoder":"decoder3.0",
>          "resource":"0xf010000000",
>          "size":"1024.00 MiB (1073.74 MB)",
>          "interleave_ways":1,
>          "max_available_extent":"512.00 MiB (536.87 MB)",
>          "volatile_capable":true,
>          "nr_targets":1
>        },
>        {
>          "decoder":"decoder3.5",
>          "resource":"0xf1d0000000",
>          "size":"256.00 MiB (268.44 MB)",
>          "interleave_ways":1,
>          "accelmem_capable":true,
>          "nr_targets":1
>        }
>      ]
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

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

> ---
>   cxl/filter.c |    6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/cxl/filter.c b/cxl/filter.c
> index 90b13be79d9c..6e8d42165205 100644
> --- a/cxl/filter.c
> +++ b/cxl/filter.c
> @@ -661,6 +661,12 @@ util_cxl_decoder_filter_by_region(struct cxl_decoder *decoder,
>   	if (!__ident)
>   		return decoder;
>   
> +	/* root decoders filter by children */
> +	cxl_region_foreach(decoder, region)
> +		if (util_cxl_region_filter(region, __ident))
> +			return decoder;
> +
> +	/* switch and endpoint decoders have a 1:1 association with a region */
>   	region = cxl_decoder_get_region(decoder);
>   	if (!region)
>   		return NULL;
> 
>
diff mbox series

Patch

diff --git a/cxl/filter.c b/cxl/filter.c
index 90b13be79d9c..6e8d42165205 100644
--- a/cxl/filter.c
+++ b/cxl/filter.c
@@ -661,6 +661,12 @@  util_cxl_decoder_filter_by_region(struct cxl_decoder *decoder,
 	if (!__ident)
 		return decoder;
 
+	/* root decoders filter by children */
+	cxl_region_foreach(decoder, region)
+		if (util_cxl_region_filter(region, __ident))
+			return decoder;
+
+	/* switch and endpoint decoders have a 1:1 association with a region */
 	region = cxl_decoder_get_region(decoder);
 	if (!region)
 		return NULL;