Skip to content

Commit 5b6031c

Browse files
MingLi-4davejiang
authored andcommitted
cxl/core: Introduce a new helper cxl_resource_contains_addr()
In CXL subsystem, many functions need to check an address availability by checking if the resource range contains the address. Providing a new helper function cxl_resource_contains_addr() to check if the resource range contains the input address. Suggested-by: Alison Schofield <[email protected]> Signed-off-by: Li Ming <[email protected]> Tested-by: Shiju Jose <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent ac0fe6a commit 5b6031c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/cxl/core/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, u64 size);
8080
int cxl_dpa_free(struct cxl_endpoint_decoder *cxled);
8181
resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
8282
resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
83+
bool cxl_resource_contains_addr(const struct resource *res, const resource_size_t addr);
8384

8485
enum cxl_rcrb {
8586
CXL_RCRB_DOWNSTREAM,

drivers/cxl/core/hdm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,13 @@ resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled)
547547
return base;
548548
}
549549

550+
bool cxl_resource_contains_addr(const struct resource *res, const resource_size_t addr)
551+
{
552+
struct resource _addr = DEFINE_RES_MEM(addr, 1);
553+
554+
return resource_contains(res, &_addr);
555+
}
556+
550557
int cxl_dpa_free(struct cxl_endpoint_decoder *cxled)
551558
{
552559
struct cxl_port *port = cxled_to_port(cxled);

0 commit comments

Comments
 (0)