From: Dave Jiang <dave.jiang@intel.com>
To: Alejandro Lucero Palau <alucerop@amd.com>, linux-cxl@vger.kernel.org
Cc: dave@stgolabs.net, jic23@kernel.org, alison.schofield@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com, djbw@kernel.org
Subject: Re: [PATCH 7/7] cxl: Fix double unregistration of CXL regions for type2 devices
Date: Thu, 23 Apr 2026 07:36:17 -0700 [thread overview]
Message-ID: <0a2b55cf-7df4-42e9-86b9-c5422a802085@intel.com> (raw)
In-Reply-To: <e0806e00-f727-4399-ab40-f10fbf881662@amd.com>
On 4/23/26 12:10 AM, Alejandro Lucero Palau wrote:
>
> On 4/23/26 00:02, Dave Jiang wrote:
>> For a type2 device cxl_memdev_attach_region() is provided as the callback
>> to devm_cxl_add_memdev() call. In cxl_memdev_attach_region() a devm
>> action cxl_endpoint_region_autoremove() is registered to remove the
>> region when the device is removed. And this action calls
>> unregister_region() on trigger.
>>
>> When the endpoint port driver is probed, discover_region() is called
>> to register a region. The call tree becomes discover_region() ->
>> cxl_add_to_region() -> construct_region() -> __create_region() ->
>> devm_cxl_add_region(). In devm_cxl_add_region(), unregister_region()
>> is also added as a devm action.
>>
>> When removing the cxl_test module, the platform devices are removed
>> and that triggers the endpoint driver removal and calling of
>> unregister_region(). And then when the mock type2 device driver is being
>> removed, the devm action of unregister_region() is called again, which
>> causes a kernel warning about double unregistration of the same region.
>> Add a check to see if the devm action is already removed before calling
>> unregister_region() for cxl_endpoint_region_autoremove().
>>
>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>>
>> ---
>> - Need to add a fixes tag when the patch commit that introduces
>> cxl_endpoint_region_autoremove() is stable.
>> ---
>> drivers/cxl/core/region.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>> index 61a3efdbf3c9..1a7c0895bb88 100644
>> --- a/drivers/cxl/core/region.c
>> +++ b/drivers/cxl/core/region.c
>> @@ -4296,7 +4296,8 @@ static void cxl_endpoint_region_autoremove(void *_cxlr)
>> struct cxl_root_decoder *cxlrd = cxlr->cxlrd;
>> struct cxl_port *port = cxlrd_to_port(cxlrd);
>> - devm_release_action(port->uport_dev, unregister_region, cxlr);
>> + if (!devm_remove_action_nowarn(port->uport_dev, unregister_region, cxlr))
>> + unregister_region(cxlr);
>> }
>> /*
>
>
> Hi Dave,
>
>
> Yes, I saw that problem and reported to Dan:
>
>
> https://lore.kernel.org/linux-cxl/20260403210050.1058650-1-dan.j.williams@intel.com/T/#m467dc88199645865a05b5fef858a67f3a608895b
>
>
> I thought about adding similar check in my impending v26 but I ended up changing the linking of the created region from the root port to the endpoint device only. This avoids the problem you report for the cases of removing cxl_acpi before accelerator driver or cxl_mem unbinding the accelerator memdev.
>
>
> You will see that later today within v26.
>
Thanks. This series will adapt to whatever the final resulting version we merge upstream.
>
> Thank you.
>
next prev parent reply other threads:[~2026-04-23 14:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 23:02 [PATCH 0/7] cxl: Add CXL type2 accelerator support for cxl_test Dave Jiang
2026-04-22 23:02 ` [PATCH 1/7] cxl/test: Refactor mock_init_hdm_decoder() to prep for type2 decoder Dave Jiang
2026-04-22 23:02 ` [PATCH 2/7] cxl/test: Add type2 support for mock CFMWS0 Dave Jiang
2026-04-22 23:02 ` [PATCH 3/7] cxl/test: Refactor platform device enumerations Dave Jiang
2026-04-22 23:02 ` [PATCH 4/7] cxl/test: Add hierarchy enumeration support for type2 device Dave Jiang
2026-04-22 23:02 ` [PATCH 5/7] cxl/test: Fixup hdm init for auto region to support type2 Dave Jiang
2026-04-22 23:02 ` [PATCH 6/7] cxl/test: Add cxl_test accelerator driver Dave Jiang
2026-04-22 23:02 ` [PATCH 7/7] cxl: Fix double unregistration of CXL regions for type2 devices Dave Jiang
2026-04-23 7:10 ` Alejandro Lucero Palau
2026-04-23 14:36 ` Dave Jiang [this message]
2026-04-29 23:45 ` Dan Williams (nvidia)
2026-04-23 7:16 ` [PATCH 0/7] cxl: Add CXL type2 accelerator support for cxl_test Alejandro Lucero Palau
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=0a2b55cf-7df4-42e9-86b9-c5422a802085@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=alucerop@amd.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=ira.weiny@intel.com \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--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