Linux Power Management development
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>,
	<linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<nvdimm@lists.linux.dev>, <linux-fsdevel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	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>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Yazen Ghannam <yazen.ghannam@amd.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	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>,
	Yao Xingtao <yaoxt.fnst@fujitsu.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Greg Kroah-Hartman <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>,
	Zhijian Li <lizhijian@fujitsu.com>,
	Borislav Petkov <bp@alien8.de>,
	Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>,
	Tomasz Wolski <tomasz.wolski@fujitsu.com>
Subject: Re: [PATCH v6 3/9] cxl/region: Skip decoder reset on detach for autodiscovered regions
Date: Wed, 11 Mar 2026 14:37:46 -0700	[thread overview]
Message-ID: <69b1e0aacb9d0_2132100c5@dwillia2-mobl4.notmuch> (raw)
In-Reply-To: <20260210064501.157591-4-Smita.KoralahalliChannabasappa@amd.com>

Smita Koralahalli wrote:
> __cxl_decoder_detach() currently resets decoder programming whenever a
> region is detached if cxl_config_state is beyond CXL_CONFIG_ACTIVE. For
> autodiscovered regions, this can incorrectly tear down decoder state
> that may be relied upon by other consumers or by subsequent ownership
> decisions.
> 
> Skip cxl_region_decode_reset() during detach when CXL_REGION_F_AUTO is
> set.
> 
> 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: Alejandro Lucero <alucerop@amd.com>
> ---
>  drivers/cxl/core/region.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index ae899f68551f..45ee598daf95 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2178,7 +2178,9 @@ __cxl_decoder_detach(struct cxl_region *cxlr,
>  		cxled->part = -1;
>  
>  	if (p->state > CXL_CONFIG_ACTIVE) {
> -		cxl_region_decode_reset(cxlr, p->interleave_ways);
> +		if (!test_bit(CXL_REGION_F_AUTO, &cxlr->flags))
> +			cxl_region_decode_reset(cxlr, p->interleave_ways);
> +
>  		p->state = CXL_CONFIG_ACTIVE;

tl;dr: I do not think we need this, I do think we need to clarify to
users what enable/disable and/or hot remove violence is handled and not
handled by the CXL core.

So this looks deceptively simple, but I think it is incomplete or at
least adds to the current confusion. A couple points to consider:

1/ There is no corresponding clear_bit(CXL_REGION_F_AUTO, ...) anywhere in
the driver. Yes, admin can still force cxl_region_decode_reset() via
commit_store() path, but admin can not force
cxl_region_teardown_targets() in the __cxl_decoder_detach() path. I do
not like that this causes us to end up with 2 separate considerations
for when __cxl_decoder_detach() skips cleanup actions
(cxl_region_teardown_targets() and cxl_region_decode_reset()). See
below, I think the cxl_region_teardown_targets() check is probably
bogus.

At a minimum I think commit_store() should clear CXL_REGION_F_AUTO on
decommit such that cleaning up decoders and targets later proceeds as
expected.

2/ The hard part about CXL region cleanup is that it needs to be prepared
for:

 a/ user manually removes the region via sysfs

 b/ user manually disables cxl_port, cxl_mem, or cxl_acpi causing the
    endpoint port to be removed

 c/ user physically removes the memdev causing the endpoint port to be
    removed (CXL core can not tell the difference with 2b/ it just sees
    cxl_mem_driver::remove() operation invocation)

 d/ setup action fails and region setup is unwound
 
The cxl_region_decode_reset() is in __cxl_decoder_detach() because of
2b/ and 2c/. No other chance to cleanup the decode topology once the
endpoint decoders are on their way out of the system.

In this case though the patch was generated back when we were committed
to cleaning up failed to assemble regions, a new 2d/ case, right?
However, in that case the decoder is not leaving the system. The
questions that arrive from that analysis are:

* Is this patch still needed now that there is no auto-cleanup?

* If this patch is still needed is it better to skip
  cxl_region_decode_reset() based on the 'enum cxl_detach_mode' rather
  than the CXL_REGION_F_AUTO flag? I.e. skip reset in the 2d/ case, or
  some other new general flag that says "please preserve hardware
  configuration".

* Should cxl_region_teardown_targets() also be caring about the
  cxl_detach_mode rather than the auto flag? I actually think the
  CXL_REGION_F_AUTO check in cxl_region_teardown_targets() is misplaced
  and it was confusing "teardown targets" with "decode reset".

All of this wants some documentation to tell users that the rule is
"Hey, after any endpoint decoder has been seen by the CXL core, if you
remove that endpoint decoder by removing or disabling any of cxl_acpi,
cxl_mem, or cxl_port the CXL core *will* violently destroy the decode
configuration". Then think about whether this needs a way to specify
"skip decoder teardown" to disambiguate "the decoder is disappearing
logically, but not physically, keep its configuration". That allows
turning any manual configuration into an auto-configuration and has an
explicit rule for all regions rather than the current "auto regions are
special" policy.

It is helpful that violence has been the default so far. So it allows to
introduce a decoder shutdown policy toggle where CXL_REGION_F_AUTO flags
decoders as "preserve" by default. Region decommit clears that flag,
and/or userspace can toggle that per endpoint decoder flag to determine
what happens when decoders leave the system. That probably also wants
some lockdown interaction such that root can not force unplug memory by
unbinding a driver.

  parent reply	other threads:[~2026-03-11 21:37 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10  6:44 [PATCH v6 0/9] dax/hmem, cxl: Coordinate Soft Reserved handling with CXL and HMEM Smita Koralahalli
2026-02-10  6:44 ` [PATCH v6 1/9] dax/hmem: Request cxl_acpi and cxl_pci before walking Soft Reserved ranges Smita Koralahalli
2026-02-19  3:22   ` Alison Schofield
2026-02-10  6:44 ` [PATCH v6 2/9] dax/hmem: Gate Soft Reserved deferral on DEV_DAX_CXL Smita Koralahalli
2026-02-19  3:23   ` Alison Schofield
2026-02-10  6:44 ` [PATCH v6 3/9] cxl/region: Skip decoder reset on detach for autodiscovered regions Smita Koralahalli
2026-02-19  3:44   ` Alison Schofield
2026-02-20 20:35     ` Koralahalli Channabasappa, Smita
2026-03-11 21:37   ` Dan Williams [this message]
2026-03-12 19:53     ` Dan Williams
2026-03-12 21:28       ` Koralahalli Channabasappa, Smita
2026-03-13 12:54       ` Alejandro Lucero Palau
2026-03-17  2:14         ` Dan Williams
2026-03-18  7:33           ` Alejandro Lucero Palau
2026-03-18 21:49             ` Dave Jiang
2026-03-18 21:27     ` Alison Schofield
2026-03-24 14:06       ` Alejandro Lucero Palau
2026-03-24 19:46       ` Dan Williams
2026-03-24 22:23         ` Alejandro Lucero Palau
2026-03-25  1:51         ` Alison Schofield
2026-02-10  6:44 ` [PATCH v6 4/9] dax/cxl, hmem: Initialize hmem early and defer dax_cxl binding Smita Koralahalli
2026-02-18 15:54   ` Dave Jiang
2026-03-09 14:31   ` Jonathan Cameron
2026-02-10  6:44 ` [PATCH v6 5/9] dax: Track all dax_region allocations under a global resource tree Smita Koralahalli
2026-02-18 16:04   ` Dave Jiang
2026-03-09 14:37   ` Jonathan Cameron
2026-03-12 21:30     ` Koralahalli Channabasappa, Smita
2026-03-12  0:27   ` Dan Williams
2026-03-12 21:31     ` Koralahalli Channabasappa, Smita
2026-02-10  6:44 ` [PATCH v6 6/9] cxl/region: Add helper to check Soft Reserved containment by CXL regions Smita Koralahalli
2026-03-12  0:29   ` Dan Williams
2026-02-10  6:44 ` [PATCH v6 7/9] dax: Add deferred-work helpers for dax_hmem and dax_cxl coordination Smita Koralahalli
2026-02-18 17:52   ` Dave Jiang
2026-02-20  0:02     ` Koralahalli Channabasappa, Smita
2026-02-20 15:55       ` Dave Jiang
2026-03-09 14:49   ` Jonathan Cameron
2026-02-10  6:45 ` [PATCH v6 8/9] dax/hmem, cxl: Defer and resolve ownership of Soft Reserved memory ranges Smita Koralahalli
2026-02-18 18:05   ` Dave Jiang
2026-02-20 19:54     ` Koralahalli Channabasappa, Smita
2026-02-20 10:14   ` Alejandro Lucero Palau
2026-03-12  2:28   ` Dan Williams
2026-03-13 18:41     ` Koralahalli Channabasappa, Smita
2026-03-17  2:36       ` Dan Williams
2026-03-16 22:26     ` Koralahalli Channabasappa, Smita
2026-03-17  2:42       ` Dan Williams
2026-02-10  6:45 ` [PATCH v6 9/9] dax/hmem: Reintroduce Soft Reserved ranges back into the iomem tree Smita Koralahalli
2026-02-10 19:16 ` [PATCH v6 0/9] dax/hmem, cxl: Coordinate Soft Reserved handling with CXL and HMEM Alison Schofield
2026-02-10 19:49   ` Koralahalli Channabasappa, Smita
2026-02-12  6:38     ` Alison Schofield
2026-02-20 21:00       ` Koralahalli Channabasappa, Smita
2026-02-12 14:44   ` Tomasz Wolski
2026-02-12 21:18     ` Alison Schofield
2026-02-13  7:47       ` Yasunori Goto (Fujitsu)
2026-02-13 17:31         ` Alison Schofield
2026-02-16  5:15           ` Yasunori Goto (Fujitsu)
2026-02-12 20:02 ` [sos-linux-dev] " Koralahalli Channabasappa, Smita
2026-02-13 14:04 ` Gregory Price
2026-02-20 20:47   ` Koralahalli Channabasappa, Smita
2026-02-20  9:45 ` Tomasz Wolski
2026-02-20 21:19   ` Koralahalli Channabasappa, Smita
2026-02-22 23:17     ` Tomasz Wolski

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=69b1e0aacb9d0_2132100c5@dwillia2-mobl4.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=Smita.KoralahalliChannabasappa@amd.com \
    --cc=alison.schofield@intel.com \
    --cc=ardb@kernel.org \
    --cc=benjamin.cheatham@amd.com \
    --cc=bp@alien8.de \
    --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=lizhijian@fujitsu.com \
    --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=tomasz.wolski@fujitsu.com \
    --cc=vishal.l.verma@intel.com \
    --cc=willy@infradead.org \
    --cc=yaoxt.fnst@fujitsu.com \
    --cc=yazen.ghannam@amd.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