From: Li Ming <ming.li@zohomail.com>
To: dave@stgolabs.net, jonathan.cameron@huawei.com,
dave.jiang@intel.com, alison.schofield@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com, shiju.jose@huawei.com
Cc: andriy.shevchenko@linux.intel.com, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org, Li Ming <ming.li@zohomail.com>
Subject: [PATCH v3 1/3] cxl/core: Introduce a new helper resource_contains_addr()
Date: Tue, 8 Jul 2025 13:15:34 +0800 [thread overview]
Message-ID: <20250708051536.92119-2-ming.li@zohomail.com> (raw)
In-Reply-To: <20250708051536.92119-1-ming.li@zohomail.com>
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 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>
---
drivers/cxl/core/core.h | 1 +
drivers/cxl/core/hdm.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
index 29b61828a847..3798e9047175 100644
--- a/drivers/cxl/core/core.h
+++ b/drivers/cxl/core/core.h
@@ -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 resource_contains_addr(const struct resource *res, const resource_size_t addr);
enum cxl_rcrb {
CXL_RCRB_DOWNSTREAM,
diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index ab1007495f6b..701a6a3baa6a 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -547,6 +547,14 @@ resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled)
return base;
}
+bool resource_contains_addr(const struct resource *res, const resource_size_t addr)
+{
+ if (res->flags & IORESOURCE_MEM)
+ return res->start <= addr && addr <= res->end;
+
+ return false;
+}
+
int cxl_dpa_free(struct cxl_endpoint_decoder *cxled)
{
struct cxl_port *port = cxled_to_port(cxled);
--
2.34.1
next prev parent reply other threads:[~2025-07-08 5:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 5:15 [PATCH v3 0/3] Fix wrong dpa checking in PPR operation Li Ming
2025-07-08 5:15 ` Li Ming [this message]
2025-07-08 13:20 ` [PATCH v3 1/3] cxl/core: Introduce a new helper resource_contains_addr() Andy Shevchenko
2025-07-09 3:45 ` Li Ming
2025-07-09 1:24 ` Alison Schofield
2025-07-08 5:15 ` [PATCH v3 2/3] cxl/edac: Fix wrong dpa checking for PPR operation Li Ming
2025-07-08 23:11 ` Dave Jiang
2025-07-09 1:42 ` Alison Schofield
2025-07-09 7:13 ` Li Ming
2025-07-08 5:15 ` [PATCH v3 3/3] cxl/core: Using resource_contains_addr() to check address availability Li Ming
2025-07-08 23:11 ` Dave Jiang
2025-07-09 1:37 ` Alison Schofield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250708051536.92119-2-ming.li@zohomail.com \
--to=ming.li@zohomail.com \
--cc=alison.schofield@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shiju.jose@huawei.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®