Re: [PATCH v7 7/7] dax/hmem: Reintroduce Soft Reserved ranges back into the iomem tree

Koralahalli Channabasappa, Smita
2026-03-20T17:00:21Z

On 3/19/2026 7:35 AM, Jonathan Cameron wrote:
> On Thu, 19 Mar 2026 01:15:00 +0000
> Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> wrote:
>
>> Reworked from a patch by Alison Schofield <alison.schofield@intel.com>
>>
>> Reintroduce Soft Reserved range into the iomem_resource tree for HMEM
>> to consume.
>>
>> This restores visibility in /proc/iomem for ranges actively in use, while
>> avoiding the early-boot conflicts that occurred when Soft Reserved was
>> published into iomem before CXL window and region discovery.
>>
>> Link: https://lore.kernel.org/linux-cxl/29312c0765224ae76862d59a17748c8188fb95f1.1692638817.git.alison.schofield@intel.com/
>> Co-developed-by: Alison Schofield <alison.schofield@intel.com>
>> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
>> Co-developed-by: Zhijian Li <lizhijian@fujitsu.com>
>> Signed-off-by: Zhijian Li <lizhijian@fujitsu.com>
>> Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
>> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
>> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
> One minor update needed as kmalloc_obj() has shown up in meantime.
>
> Thanks
>
> Jonathan
>> ---
>> drivers/dax/hmem/hmem.c | 32 +++++++++++++++++++++++++++++++-
>> 1 file changed, 31 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
>> index 8c574123bd3b..15e462589b92 100644
>> --- a/drivers/dax/hmem/hmem.c
>> +++ b/drivers/dax/hmem/hmem.c
>> @@ -72,6 +72,34 @@ void dax_hmem_flush_work(void)
>> }
>> EXPORT_SYMBOL_GPL(dax_hmem_flush_work);
>>
>> +static void remove_soft_reserved(void *r)
>> +{
>> + remove_resource(r);
>> + kfree(r);
>> +}
>> +
>> +static int add_soft_reserve_into_iomem(struct device *host,
>> + const struct resource *res)
>> +{
>> + int rc;
>> +
>> + struct resource *soft __free(kfree) =
>> + kmalloc(sizeof(*res), GFP_KERNEL);
>
> Update to
>
> struct resource *soft __free(kfree) = kmalloc_obj(*soft);
>
> Got added in 7.0 with lots of call sites updated via scripting.
>
> Not sure why this had sizeof(*res) rather than sizeof(*soft).
> Same type but should have been soft! If nothing else that would
> probably have broken the scripts looking for where we should
> be using kmalloc_obj().

Okay I will update it. sizeof(*res) was a typo from my end. Sorry.
Will change to kmalloc_obj().

Thanks
Smita
>
>
>
>> + if (!soft)
>> + return -ENOMEM;
>> +
>> + *soft = DEFINE_RES_NAMED_DESC(res->start, (res->end - res->start + 1),
>> + "Soft Reserved", IORESOURCE_MEM,
>> + IORES_DESC_SOFT_RESERVED);
>> +
>> + rc = insert_resource(&iomem_resource, soft);
>> + if (rc)
>> + return rc;
>> +
>> + return devm_add_action_or_reset(host, remove_soft_reserved,
>> + no_free_ptr(soft));
>> +}
>> +
>> static int hmem_register_device(struct device *host, int target_nid,
>> const struct resource *res)
>> {
>> @@ -94,7 +122,9 @@ static int hmem_register_device(struct device *host, int target_nid,
>> if (rc != REGION_INTERSECTS)
>> return 0;
>>
>> - /* TODO: Add Soft-Reserved memory back to iomem */
>> + rc = add_soft_reserve_into_iomem(host, res);
>> + if (rc)
>> + return rc;
>>
>> id = memregion_alloc(GFP_KERNEL);
>> if (id < 0) {
>