Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cxl/region: Add helper to check Soft Reserved containment by CXL regions

Add a helper to determine whether a given Soft Reserved memory range is
fully contained within the committed CXL region.

This helper provides a primitive for policy decisions in subsequent
patches such as co-ordination with dax_hmem to determine whether CXL has
fully claimed ownership of Soft Reserved memory ranges.

Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://patch.msgid.link/20260322195343.206900-8-Smita.KoralahalliChannabasappa@amd.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by

Smita Koralahalli and committed by
Dave Jiang
8e65f99b 34f80bb9

+45
+30
drivers/cxl/core/region.c
··· 12 12 #include <linux/idr.h> 13 13 #include <linux/memory-tiers.h> 14 14 #include <linux/string_choices.h> 15 + #include <cxl/cxl.h> 15 16 #include <cxlmem.h> 16 17 #include <cxl.h> 17 18 #include "core.h" ··· 4173 4172 4174 4173 return devm_add_action_or_reset(dev, remove_debugfs, dentry); 4175 4174 } 4175 + 4176 + static int region_contains_resource(struct device *dev, void *data) 4177 + { 4178 + struct resource *res = data; 4179 + struct cxl_region *cxlr; 4180 + struct cxl_region_params *p; 4181 + 4182 + if (!is_cxl_region(dev)) 4183 + return 0; 4184 + 4185 + cxlr = to_cxl_region(dev); 4186 + p = &cxlr->params; 4187 + 4188 + if (p->state != CXL_CONFIG_COMMIT) 4189 + return 0; 4190 + 4191 + if (!p->res) 4192 + return 0; 4193 + 4194 + return resource_contains(p->res, res) ? 1 : 0; 4195 + } 4196 + 4197 + bool cxl_region_contains_resource(struct resource *res) 4198 + { 4199 + guard(rwsem_read)(&cxl_rwsem.region); 4200 + return bus_for_each_dev(&cxl_bus_type, NULL, res, 4201 + region_contains_resource) != 0; 4202 + } 4203 + EXPORT_SYMBOL_GPL(cxl_region_contains_resource); 4176 4204 4177 4205 static int cxl_region_can_probe(struct cxl_region *cxlr) 4178 4206 {
+15
include/cxl/cxl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* Copyright (c) 2026 Advanced Micro Devices, Inc. */ 3 + #ifndef _CXL_H_ 4 + #define _CXL_H_ 5 + 6 + #ifdef CONFIG_CXL_REGION 7 + bool cxl_region_contains_resource(struct resource *res); 8 + #else 9 + static inline bool cxl_region_contains_resource(struct resource *res) 10 + { 11 + return false; 12 + } 13 + #endif 14 + 15 + #endif /* _CXL_H_ */