]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cxl/core: Introduce a new helper cxl_resource_contains_addr()
authorLi Ming <ming.li@zohomail.com>
Fri, 11 Jul 2025 03:23:55 +0000 (11:23 +0800)
committerDave Jiang <dave.jiang@intel.com>
Fri, 11 Jul 2025 16:46:53 +0000 (09:46 -0700)
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 <alison.schofield@intel.com>
Signed-off-by: Li Ming <ming.li@zohomail.com>
Tested-by: Shiju Jose <shiju.jose@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20250711032357.127355-2-ming.li@zohomail.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/core.h
drivers/cxl/core/hdm.c

index 29b61828a8476349e8da37d3acde28a1dc9627c3..6b78b10da3e185782d626b65523f79a590cc0a67 100644 (file)
@@ -80,6 +80,7 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, u64 size);
 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled);
 resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled);
 resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled);
+bool cxl_resource_contains_addr(const struct resource *res, const resource_size_t addr);
 
 enum cxl_rcrb {
        CXL_RCRB_DOWNSTREAM,
index ab1007495f6b94bfd2067557e17ee1a9422cef24..088caa6b6f742229df1bb98d648fd99f7c374dee 100644 (file)
@@ -547,6 +547,13 @@ resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled)
        return base;
 }
 
+bool cxl_resource_contains_addr(const struct resource *res, const resource_size_t addr)
+{
+       struct resource _addr = DEFINE_RES_MEM(addr, 1);
+
+       return resource_contains(res, &_addr);
+}
+
 int cxl_dpa_free(struct cxl_endpoint_decoder *cxled)
 {
        struct cxl_port *port = cxled_to_port(cxled);