From: "Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com>
To: "Koralahalli Channabasappa,
Smita" <Smita.KoralahalliChannabasappa@amd.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@kernel.org>,
Li Ming <ming.li@zohomail.com>,
Jeff Johnson <jeff.johnson@oss.qualcomm.com>,
Ying Huang <huang.ying.caritas@gmail.com>,
"Xingtao Yao (Fujitsu)" <yaoxt.fnst@fujitsu.com>,
Peter Zijlstra <peterz@infradead.org>,
Greg KH <gregkh@linuxfoundation.org>,
Nathan Fontenot <nathan.fontenot@amd.com>,
Terry Bowman <terry.bowman@amd.com>,
Robert Richter <rrichter@amd.com>,
Benjamin Cheatham <benjamin.cheatham@amd.com>,
PradeepVineshReddy Kodamati <PradeepVineshReddy.Kodamati@amd.com>
Subject: Re: [PATCH v4 7/7] cxl/dax: Defer DAX consumption of SOFT RESERVED resources until after CXL region creation
Date: Thu, 10 Jul 2025 08:18:05 +0000 [thread overview]
Message-ID: <10e044b9-f126-47d5-86a3-b5b0fcc0bc14@fujitsu.com> (raw)
In-Reply-To: <a4860c1e-e6ec-4f5a-a039-bb2066740523@amd.com>
On 10/07/2025 12:22, Koralahalli Channabasappa, Smita wrote:
>>
>> what is the impact if one consumes all SOFT RESERVED resources?
>>
>> Since `hmem_register_device()` only creates HMEM devices for ranges
>> *without* `IORES_DESC_CXL` which could be marked in cxl_acpi , cxl_core/cxl_dax
>> should still create regions and DAX devices without conflicts.
>
> You're correct that hmem_register_device() includes a check to skip
> regions overlapping with IORES_DESC_CXL. However, this check only works if the CXL region driver has already inserted those regions into iomem_resource.
IIUC, this relies on the the root decoder resource(CFMW) has be already inserted iomem_resource which is currently done in cxl_acpi
This also can be resolved by the modules loading dependence chain.
something like this:
#if IS_MODULE(CONFIG_CXL_ACPI)
MODULE_SOFTDEP("pre: cxl_acpi");
#endif
> If dax_hmem_platform_probe() runs too early (before CXL region probing), that check fails to detect overlaps — leading to erroneous registration.
>
> This is what I think. I may be wrong. Also, Alison/Dan comment here: "New approach is to not have the CXL intersecting soft reserved
> resources in iomem_resource tree."..
I think his point was the latter sentence.
"Only move them there if CXL region assembly fails and we want to make them availabe to DAX directly."
which in my understanding was remove the 'soft reserved' in the next region creating.
>
> https://lore.kernel.org/linux-cxl/ZPdoduf5IckVWQVD@aschofie-mobl2/
>
>>
>>> To resolve this, defer the DAX driver's resource consumption if the
>>> cxl_acpi driver is enabled. The DAX HMEM initialization skips walking the
>>> iomem resource tree in this case. After CXL region creation completes,
>>> any remaining SOFT RESERVED resources are explicitly registered with the
>>> DAX driver by the CXL driver.
>>
>> Conversely, with this patch applied, `cxl_region_softreserv_update()` attempts
>> to register new HMEM devices. This may cause duplicate registrations for the
>> same range (e.g., 0x180000000-0x1ffffffff), triggering warnings like:
>>
>> [ 14.984108] kmem dax4.0: mapping0: 0x180000000-0x1ffffffff could not reserve region
>> [ 14.987204] kmem dax4.0: probe with driver kmem failed with error -16
>>
>> Because the HMAT initialization already registered these sub-ranges:
>> 180000000-1bfffffff
>> 1c0000000-1ffffffff
>>
>>
>> If I'm missing something, please correct me.
>
> Yeah, this bug is due to a double invocation of hmem_register_device() once from cxl_softreserv_mem_register() and once from dax_hmem_platform_probe().
>
> When CONFIG_CXL_ACPI=y, walk_iomem_res_desc() is skipped in hmem_init(),
> so I expected hmem_active to remain empty. However, I missed the detail that the ACPI HMAT parser (drivers/acpi/numa/hmat.c) calls hmem_register_resource(), which populates hmem_active via __hmem_register_resource().
>
> Case 1 (No bug): If dax_hmem_platform_probe() runs when hmem_active is still empty.
>
> walk_hmem_resources() walks nothing — it's effectively a no-op.
>
> Later, cxl_softreserv_mem_register() is invoked to register leftover soft-reserved regions via hmem_register_device().
>
> Only one registration occurs, no conflict.
>
> Case 2: If dax_hmem_platform_probe() runs after hmem_active is populated by hmat_register_target_devices() (via hmem_register_resource()):
>
> walk_hmem_resources() iterates those regions. It invokes hmem_register_device(). Later, cxl_region driver does the same again.
>
> This results in duplicate instances for the same physical range and second call fails like below:
>
> [ 14.984108] kmem dax4.0: mapping0: 0x180000000-0x1ffffffff could not reserve region
> [ 14.987204] kmem dax4.0: probe with driver kmem failed with error -16
>
> Below, did the job to fix the above bug for me and I did incorporate this in v5.
Actually, I don't think it's a real problem, current code can tolerate such duplicating registration. so I'm fine to just turn it to dev_debug from dev_warn.
>
> static int dax_hmem_platform_probe(struct platform_device *pdev)
> {
> + if (IS_ENABLED(CONFIG_CXL_ACPI))
> + return 0;
>
> dax_hmem_pdev = pdev;
> return walk_hmem_resources(hmem_register_device);
> }
>
> Let me know if my thought process is right. I would appreciate any additional feedback or suggestions.
>
> Meanwhile, I should also mention that my approach fails, if cxl_acpi finishes probing before dax_hmem is even loaded, it attempts to call into unresolved dax_hmem symbols, causing probe failures. Particularly when CXL_BUS=y and DEV_DAX_HMEM=m.
>
> ld: vmlinux.o: in function `cxl_softreserv_mem_register':
> region.c:(.text+0xc15160): undefined reference to `hmem_register_device'
> make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1
>
> I spent some time exploring possible fixes for this symbol dependency issue, which delayed my v5 submission. I would welcome any ideas..
>
> In the meantime, I noticed your new patchset that introduces a different approach for resolving resource conflicts between CMFW and Soft Reserved regions. I will take a closer look at that.
Thanks in advance.
(I am uncertain whether such an approach has ever been proposed previously.)
>
> Thanks
> Smita
>
next prev parent reply other threads:[~2025-07-10 8:19 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 22:19 [PATCH v4 0/7] Add managed SOFT RESERVE resource handling Smita Koralahalli
2025-06-03 22:19 ` [PATCH v4 1/7] cxl/region: Avoid null pointer dereference in is_cxl_region() Smita Koralahalli
2025-06-03 23:49 ` Dave Jiang
2025-06-04 19:56 ` Nathan Fontenot
2025-06-25 15:23 ` Robert Richter
2025-06-03 22:19 ` [PATCH v4 2/7] cxl/core: Remove CONFIG_CXL_SUSPEND and always build suspend.o Smita Koralahalli
2025-06-09 11:02 ` Jonathan Cameron
2025-06-09 23:25 ` Koralahalli Channabasappa, Smita
2025-06-10 9:38 ` Jonathan Cameron
2025-06-03 22:19 ` [PATCH v4 3/7] cxl/pci: Add pci_loaded tracking to mark PCI driver readiness Smita Koralahalli
2025-06-04 9:29 ` Zhijian Li (Fujitsu)
2025-06-03 22:19 ` [PATCH v4 4/7] cxl/acpi: Add background worker to wait for cxl_pci and cxl_mem probe Smita Koralahalli
2025-06-03 23:45 ` Dave Jiang
2025-06-04 18:31 ` Koralahalli Channabasappa, Smita
2025-06-04 9:40 ` Zhijian Li (Fujitsu)
2025-06-04 14:35 ` Dave Jiang
2025-06-05 2:18 ` Zhijian Li (Fujitsu)
2025-06-03 22:19 ` [PATCH v4 5/7] cxl/region: Introduce SOFT RESERVED resource removal on region teardown Smita Koralahalli
2025-06-06 4:16 ` Zhijian Li (Fujitsu)
2025-06-06 17:53 ` Koralahalli Channabasappa, Smita
2025-06-09 12:54 ` Jonathan Cameron
2025-06-10 1:25 ` Koralahalli Channabasappa, Smita
2025-06-10 9:37 ` Jonathan Cameron
2025-06-25 15:20 ` Robert Richter
2025-07-09 1:14 ` Alison Schofield
2025-06-03 22:19 ` [PATCH v4 6/7] dax/hmem: Save the DAX HMEM platform device pointer Smita Koralahalli
2025-06-05 16:54 ` Dave Jiang
2025-06-06 8:11 ` Zhijian Li (Fujitsu)
2025-06-06 20:09 ` Nathan Fontenot
2025-06-03 22:19 ` [PATCH v4 7/7] cxl/dax: Defer DAX consumption of SOFT RESERVED resources until after CXL region creation Smita Koralahalli
2025-06-09 13:01 ` Jonathan Cameron
2025-06-13 2:12 ` Zhijian Li (Fujitsu)
2025-07-10 4:22 ` Koralahalli Channabasappa, Smita
2025-07-10 8:18 ` Zhijian Li (Fujitsu) [this message]
2025-07-15 16:27 ` Alison Schofield
2025-07-15 18:19 ` Koralahalli Channabasappa, Smita
2025-07-15 18:45 ` Alison Schofield
2025-06-04 8:43 ` [PATCH v4 0/7] Add managed SOFT RESERVE resource handling Zhijian Li (Fujitsu)
2025-06-04 18:59 ` Koralahalli Channabasappa, Smita
2025-06-16 1:00 ` Zhijian Li (Fujitsu)
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=10e044b9-f126-47d5-86a3-b5b0fcc0bc14@fujitsu.com \
--to=lizhijian@fujitsu.com \
--cc=PradeepVineshReddy.Kodamati@amd.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=alison.schofield@intel.com \
--cc=benjamin.cheatham@amd.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=gregkh@linuxfoundation.org \
--cc=huang.ying.caritas@gmail.com \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=jonathan.cameron@huawei.com \
--cc=len.brown@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=nathan.fontenot@amd.com \
--cc=nvdimm@lists.linux.dev \
--cc=pavel@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rrichter@amd.com \
--cc=terry.bowman@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
--cc=yaoxt.fnst@fujitsu.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®