Skip to content

Commit 98ceb1a

Browse files
Robert Richterdavejiang
authored andcommitted
cxl/region: Store HPA range in struct cxl_region
Each region has a known host physical address (HPA) range it is assigned to. Endpoint decoders assigned to a region share the same HPA range. The region's address range is the system's physical address (SPA) range. Endpoint decoders in systems that need address translation use HPAs which are not SPAs. To make the SPA range accessible to the endpoint decoders, store and track the region's SPA range in struct cxl_region. Introduce the @hpa_range member to the struct. Now, the SPA range of an endpoint decoder can be determined based on its assigned region. Patch is a prerequisite to implement address translation which uses struct cxl_region to store all relevant region and interleaving parameters. Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gregory Price <gourry@gourry.net> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Signed-off-by: Robert Richter <rrichter@amd.com> Link: https://patch.msgid.link/20260114164837.1076338-4-rrichter@amd.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 4fe8227 commit 98ceb1a

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/cxl/core/region.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
664664
return PTR_ERR(res);
665665
}
666666

667+
cxlr->hpa_range = DEFINE_RANGE(res->start, res->end);
668+
667669
p->res = res;
668670
p->state = CXL_CONFIG_INTERLEAVE_ACTIVE;
669671

@@ -700,6 +702,8 @@ static int free_hpa(struct cxl_region *cxlr)
700702
if (p->state >= CXL_CONFIG_ACTIVE)
701703
return -EBUSY;
702704

705+
cxlr->hpa_range = DEFINE_RANGE(0, -1);
706+
703707
cxl_region_iomem_release(cxlr);
704708
p->state = CXL_CONFIG_IDLE;
705709
return 0;
@@ -2453,6 +2457,8 @@ static void unregister_region(void *_cxlr)
24532457
for (i = 0; i < p->interleave_ways; i++)
24542458
detach_target(cxlr, i);
24552459

2460+
cxlr->hpa_range = DEFINE_RANGE(0, -1);
2461+
24562462
cxl_region_iomem_release(cxlr);
24572463
put_device(&cxlr->dev);
24582464
}
@@ -3579,6 +3585,7 @@ static int __construct_region(struct cxl_region *cxlr,
35793585
}
35803586

35813587
set_bit(CXL_REGION_F_AUTO, &cxlr->flags);
3588+
cxlr->hpa_range = *hpa_range;
35823589

35833590
res = kmalloc(sizeof(*res), GFP_KERNEL);
35843591
if (!res)

drivers/cxl/cxl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ enum cxl_partition_mode {
530530
* @dev: This region's device
531531
* @id: This region's id. Id is globally unique across all regions
532532
* @cxlrd: Region's root decoder
533+
* @hpa_range: Address range occupied by the region
533534
* @mode: Operational mode of the mapped capacity
534535
* @type: Endpoint decoder target type
535536
* @cxl_nvb: nvdimm bridge for coordinating @cxlr_pmem setup / shutdown
@@ -544,6 +545,7 @@ struct cxl_region {
544545
struct device dev;
545546
int id;
546547
struct cxl_root_decoder *cxlrd;
548+
struct range hpa_range;
547549
enum cxl_partition_mode mode;
548550
enum cxl_decoder_type type;
549551
struct cxl_nvdimm_bridge *cxl_nvb;

0 commit comments

Comments
 (0)