Re: [PATCH v1 00/20] cxl: Address translation support, part 2: Region code rework
From: Dave Jiang
Date: Mon Jul 21 2025 - 17:00:04 EST
On 7/15/25 12:11 PM, Robert Richter wrote:
> This series is the second part of adding support for CXL address
> translation. It adds another rework of region code to address
> implementation changes or conflicts of current address translation
> code with cxl/next, esp. the introduction of support of extended
> linear caching.
>
> Following parts are currently planned, worked on or finished:
>
> Part 1: Cleanups and refactoring
> Upstream: 68d8b4f399e7 ("Merge branch 'for-6.16/cxl-cleanups' into cxl-for-next")
>
> Part 2: Region code rework
> This initial patch series.
>
> Part 3: Extended linear cache rework
> Not yet posted.
>
> Part 4: Generic support and AMD Zen5 platform enablement.
> Not yet posted. (Earlier version posted as part 2, v2: Generic support
> and AMD Zen5 platform enablement. [1])
Hi Robert, this is A LOT of refactoring and we are not anywhere near the actual translation implementation. Before we proceed further, can you please send out a documentation patch and describe the ZEN5 translation needs for docs/driver-api/cxl/conventions.rst similar to what Fabio is doing for LMH [1]? Thank you!
[1]: https://lore.kernel.org/linux-cxl/687ea20d2e508_34e0f2941@iweiny-mobl.notmuch/T/#t
DJ
>
> The general changes in the implementation compared to [1] are in
> particular to use the attached region of an endpoint decoder to host
> the HPA range and interleaving configuration parameters. That is, the
> region's root decoder and HPA range are added as members @cxlrd and
> @hpa_range to struct cxl_region. Both are introduced to keep track of
> the region's SPA address range and the interleaving configuration.
> Those parameters are the same for all endpoint decoders that share the
> same interleaving setup.
>
> The implementation must ensure that the endpoint decoder's region
> parameters are always valid. All parameters must be determined first
> and then a check must be performed if a region with identical
> parameters already exists. A split of region creation and registration
> is required as the region may not become active and may need to be
> replaced by an already existing region. Several high-level functions
> are introduced (create_region(), setup_region(), register_region(),
> cxl_endpoint_get_region(), cxl_region_find_duplicate()). Most of it is
> implemented in cxl_add_to_region().
>
> Finally, this series adds a lot of simplification and improves error
> handling and code readability.
>
> [1] https://lore.kernel.org/all/20250218132356.1809075-1-rrichter@xxxxxxx/
>
> Robert Richter (20):
> cxl/region: Move helper functions closer to their users
> cxl/region: Store root decoder in struct cxl_region
> cxl/region: Remove region id handling from cxl_region_alloc()
> cxl/region: Add region registration code to new function
> register_region()
> cxl/region: Separate cxl_region_alloc() from devm_cxl_add_region()
> cxl/region: Remove dev_err() from cxl_find_root_decoder()
> cxl/region: Add new function cxl_endpoint_get_region() to simplify
> cxl_add_to_region()
> cxl/region: Rework memregion id allocation and move it to
> register_region()
> cxl/region: Change __construct_region() to use it as a tail function
> call
> cxl/region: Remove __construct_region()
> cxl/region: Separate auto-generated region cration code path
> cxl/region: Remove region creation code from construct_region()
> cxl/region: Move devm_cxl_add_region() out of create_region()
> cxl/region: Prepare removal of @cxlrd argument from create_region()
> cxl/region: Prepare removal of @cxled argument from construct_region()
> cxl/region: Introduce @hpa_range to struct cxl_region
> cxl/region: Remove create_region() call from construct_region()
> cxl/region: Determine root decoder in create_region()
> cxl/region: Add function to find a region's duplicate
> cxl/region: Early check region's interleaving configuration
>
> drivers/cxl/core/region.c | 514 +++++++++++++++++++++++---------------
> drivers/cxl/cxl.h | 4 +
> 2 files changed, 315 insertions(+), 203 deletions(-)
>
>
> base-commit: 12b3d697c812aaf356e82d9e1f351fbb2ea97500