Hi Dan,

[snip]

+static int hmem_register_cxl_device(struct device *host, int target_nid,
+                                   const struct resource *res)
+{
+       if (region_intersects(res->start, resource_size(res), IORESOURCE_MEM,
+                             IORES_DESC_CXL) != REGION_DISJOINT)
+               return hmem_register_device(host, target_nid, res);
+
+       return 0;
+}
+
+static int soft_reserve_has_cxl_match(struct device *host, int target_nid,
+                                     const struct resource *res)
+{
+       if (region_intersects(res->start, resource_size(res), IORESOURCE_MEM,
+                             IORES_DESC_CXL) != REGION_DISJOINT) {
+               if (!cxl_region_contains_soft_reserve((struct resource *)res))
+                       return 1;
+       }
+
+       return 0;
+}
+
+static void process_defer_work(void *data)
+{
+       struct platform_device *pdev = data;
+       int rc;
+
+       /* relies on cxl_acpi and cxl_pci having had a chance to load */
+       wait_for_device_probe();
+
+       rc = walk_hmem_resources(&pdev->dev, soft_reserve_has_cxl_match);
+
+       if (!rc) {
+               dax_cxl_mode = DAX_CXL_MODE_DROP;
+               dev_dbg(&pdev->dev, "All Soft Reserved ranges claimed by 
CXL\n");
+       } else {
+               dax_cxl_mode = DAX_CXL_MODE_REGISTER;
+               dev_warn(&pdev->dev,
+                        "Soft Reserved not fully contained in CXL; using 
HMEM\n");
+       }
+
+       walk_hmem_resources(&pdev->dev, hmem_register_cxl_device);

I do not think we need to do 2 passes. Just do one
hmem_register_cxl_device() pass that skips a range when
cxl_region_contains_resource() has it covered, otherwise register an
hmem device.


Just want to make sure I'm not misreading this — are we dropping the
all or nothing ownership approach? In v6, if any SR range wasn't fully
covered by CXL, all CXL-intersecting ranges fell back to HMEM. With the
single-pass hmem_register_cxl_device() that skips individually covered ranges, we would be doing per range decisions..

[snip]

Thanks
Smita


Reply via email to