public inbox for linux-cxl@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens
@ 2026-03-19 15:25 Dave Jiang
  2026-03-20  2:04 ` Alison Schofield
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dave Jiang @ 2026-03-19 15:25 UTC (permalink / raw)
  To: linux-cxl
  Cc: dan.j.williams, vishal.l.verma, ira.weiny, dave, jonathan.cameron,
	alison.schofield

When a PCI reset happens, the lock and enable flags of the CXL device
should be cleared to avoid stale state flags after reset. Add flag
clearing during cxl_reset_done() to clear the relevant endpoint
decoder flags for all decoders of the endpoint device.

Reported-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
v3:
- Rename cxl_decoder_clear_flags() to
  cxl_endpoint_decoder_clear_reset_flags() (Ben)
- Make the function single purpose rather than taking a flag. (Jonathan)
---
 drivers/cxl/cxl.h |  1 +
 drivers/cxl/pci.c | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index 9b947286eb9b..d09c84bcc015 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -333,6 +333,7 @@ int cxl_dport_map_rcd_linkcap(struct pci_dev *pdev, struct cxl_dport *dport);
 #define CXL_DECODER_F_LOCK  BIT(4)
 #define CXL_DECODER_F_ENABLE    BIT(5)
 #define CXL_DECODER_F_NORMALIZED_ADDRESSING BIT(6)
+#define CXL_DECODER_F_RESET_MASK (CXL_DECODER_F_ENABLE | CXL_DECODER_F_LOCK)
 
 enum cxl_decoder_type {
 	CXL_DECODER_DEVMEM = 2,
diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index fbb300a01830..84cff73b39e5 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -1030,6 +1030,19 @@ static void cxl_error_resume(struct pci_dev *pdev)
 		 dev->driver ? "successful" : "failed");
 }
 
+static int cxl_endpoint_decoder_clear_reset_flags(struct device *dev, void *data)
+{
+	struct cxl_endpoint_decoder *cxled;
+
+	if (!is_endpoint_decoder(dev))
+		return 0;
+
+	cxled = to_cxl_endpoint_decoder(dev);
+	cxled->cxld.flags &= ~CXL_DECODER_F_RESET_MASK;
+
+	return 0;
+}
+
 static void cxl_reset_done(struct pci_dev *pdev)
 {
 	struct cxl_dev_state *cxlds = pci_get_drvdata(pdev);
@@ -1045,6 +1058,9 @@ static void cxl_reset_done(struct pci_dev *pdev)
 	guard(device)(&cxlmd->dev);
 	if (cxlmd->endpoint &&
 	    cxl_endpoint_decoder_reset_detected(cxlmd->endpoint)) {
+		device_for_each_child(&cxlmd->endpoint->dev, NULL,
+				      cxl_endpoint_decoder_clear_reset_flags);
+
 		dev_crit(dev, "SBR happened without memory regions removal.\n");
 		dev_crit(dev, "System may be unstable if regions hosted system memory.\n");
 		add_taint(TAINT_USER, LOCKDEP_STILL_OK);

base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens
  2026-03-19 15:25 [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens Dave Jiang
@ 2026-03-20  2:04 ` Alison Schofield
  2026-03-20 14:33 ` Jonathan Cameron
  2026-03-20 16:27 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2026-03-20  2:04 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, dan.j.williams, vishal.l.verma, ira.weiny, dave,
	jonathan.cameron

On Thu, Mar 19, 2026 at 08:25:41AM -0700, Dave Jiang wrote:
> When a PCI reset happens, the lock and enable flags of the CXL device
> should be cleared to avoid stale state flags after reset. Add flag
> clearing during cxl_reset_done() to clear the relevant endpoint
> decoder flags for all decoders of the endpoint device.

LGTM still

> 
> Reported-by: Dan Williams <dan.j.williams@intel.com>
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens
  2026-03-19 15:25 [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens Dave Jiang
  2026-03-20  2:04 ` Alison Schofield
@ 2026-03-20 14:33 ` Jonathan Cameron
  2026-03-20 16:27 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-03-20 14:33 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, dan.j.williams, vishal.l.verma, ira.weiny, dave,
	alison.schofield

On Thu, 19 Mar 2026 08:25:41 -0700
Dave Jiang <dave.jiang@intel.com> wrote:

> When a PCI reset happens, the lock and enable flags of the CXL device
> should be cleared to avoid stale state flags after reset. Add flag
> clearing during cxl_reset_done() to clear the relevant endpoint
> decoder flags for all decoders of the endpoint device.
> 
> Reported-by: Dan Williams <dan.j.williams@intel.com>
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

Thanks for quick turnaround!  Major advantage for me being
rare case where I could still remember the context without having
to go reread the earlier threads :)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens
  2026-03-19 15:25 [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens Dave Jiang
  2026-03-20  2:04 ` Alison Schofield
  2026-03-20 14:33 ` Jonathan Cameron
@ 2026-03-20 16:27 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2026-03-20 16:27 UTC (permalink / raw)
  To: linux-cxl
  Cc: dan.j.williams, vishal.l.verma, ira.weiny, dave, jonathan.cameron,
	alison.schofield



On 3/19/26 8:25 AM, Dave Jiang wrote:
> When a PCI reset happens, the lock and enable flags of the CXL device
> should be cleared to avoid stale state flags after reset. Add flag
> clearing during cxl_reset_done() to clear the relevant endpoint
> decoder flags for all decoders of the endpoint device.
> 
> Reported-by: Dan Williams <dan.j.williams@intel.com>
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>

Applied to cxl/next
7974835aa9d5 ("cxl: Add endpoint decoder flags clear when PCI reset happens")

> ---
> v3:
> - Rename cxl_decoder_clear_flags() to
>   cxl_endpoint_decoder_clear_reset_flags() (Ben)
> - Make the function single purpose rather than taking a flag. (Jonathan)
> ---
>  drivers/cxl/cxl.h |  1 +
>  drivers/cxl/pci.c | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 9b947286eb9b..d09c84bcc015 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -333,6 +333,7 @@ int cxl_dport_map_rcd_linkcap(struct pci_dev *pdev, struct cxl_dport *dport);
>  #define CXL_DECODER_F_LOCK  BIT(4)
>  #define CXL_DECODER_F_ENABLE    BIT(5)
>  #define CXL_DECODER_F_NORMALIZED_ADDRESSING BIT(6)
> +#define CXL_DECODER_F_RESET_MASK (CXL_DECODER_F_ENABLE | CXL_DECODER_F_LOCK)
>  
>  enum cxl_decoder_type {
>  	CXL_DECODER_DEVMEM = 2,
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index fbb300a01830..84cff73b39e5 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -1030,6 +1030,19 @@ static void cxl_error_resume(struct pci_dev *pdev)
>  		 dev->driver ? "successful" : "failed");
>  }
>  
> +static int cxl_endpoint_decoder_clear_reset_flags(struct device *dev, void *data)
> +{
> +	struct cxl_endpoint_decoder *cxled;
> +
> +	if (!is_endpoint_decoder(dev))
> +		return 0;
> +
> +	cxled = to_cxl_endpoint_decoder(dev);
> +	cxled->cxld.flags &= ~CXL_DECODER_F_RESET_MASK;
> +
> +	return 0;
> +}
> +
>  static void cxl_reset_done(struct pci_dev *pdev)
>  {
>  	struct cxl_dev_state *cxlds = pci_get_drvdata(pdev);
> @@ -1045,6 +1058,9 @@ static void cxl_reset_done(struct pci_dev *pdev)
>  	guard(device)(&cxlmd->dev);
>  	if (cxlmd->endpoint &&
>  	    cxl_endpoint_decoder_reset_detected(cxlmd->endpoint)) {
> +		device_for_each_child(&cxlmd->endpoint->dev, NULL,
> +				      cxl_endpoint_decoder_clear_reset_flags);
> +
>  		dev_crit(dev, "SBR happened without memory regions removal.\n");
>  		dev_crit(dev, "System may be unstable if regions hosted system memory.\n");
>  		add_taint(TAINT_USER, LOCKDEP_STILL_OK);
> 
> base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-20 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 15:25 [PATCH v3] cxl: Add endpoint decoder flags clear when PCI reset happens Dave Jiang
2026-03-20  2:04 ` Alison Schofield
2026-03-20 14:33 ` Jonathan Cameron
2026-03-20 16:27 ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox