Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Srirangan Madhavan" <smadhavan@nvidia.com>
Cc: linux-pci@vger.kernel.org, linux-cxl@vger.kernel.org
Subject: Re: [PATCH v9 11/11] PCI/CXL: Restore HDM state after CXL bus reset
Date: Thu, 09 Jul 2026 01:20:22 +0000	[thread overview]
Message-ID: <20260709012023.24DCA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709010304.680422-12-smadhavan@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] HDM decoder restoration is performed before the PCI device's BARs are restored, causing MMIO writes to be dropped by the hardware or triggering Unsupported Requests.
--

--- Patch [11]: [PATCH v9 11/11] PCI/CXL: Restore HDM state after CXL bus reset ---
commit 4e02f0f18a7abbebc3cc9b8384269906531ad726
Author: Srirangan Madhavan <smadhavan@nvidia.com>

PCI/CXL: Restore HDM state after CXL bus reset

This commit restores cached HDM state after a successful CXL bus reset while
the IOMMU reset block remains active. It introduces a helper to restore the
state and calls it directly from the PCI reset path.

> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index ef25ba5f7fe95..b394704950a5f 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5004,6 +5004,9 @@ static int cxl_reset_bus_function(struct pci_dev *dev, bool probe)
>  		pci_write_config_word(bridge, dvsec + PCI_DVSEC_CXL_PORT_CTL,
>  				      reg);
>  
> +	if (!rc)
> +		rc = cxl_restore_hdm_after_pci_reset(dev);
> +

[Severity: High]
Is it safe to restore the HDM decoders here before the PCI state (including
BARs) has been restored?

When pci_reset_bus_function() is called earlier in this function, the
hardware reset clears the device's BARs to 0. The caller of the reset
function typically restores the saved PCI state after this returns.

However, cxl_restore_hdm_after_pci_reset() calls cxl_restore_hdm(), which
enables memory decoding and writes to the cached BAR address:

drivers/cxl/core/reset.c:cxl_restore_hdm() {
    ...
    rc = cxl_hdm_enable_mem(pdev, &command, &restore_command);
    ...
    writel(global_ctrl, hdm + CXL_HDM_DECODER_CTRL_OFFSET);
    ...
}

Because the hardware BARs are still 0 at this point, will enabling
PCI_COMMAND_MEMORY cause the device to incorrectly claim physical address 0?

Furthermore, will the MMIO writes to the cached BAR address result in PCIe
Unsupported Requests (Master Aborts) since the hardware isn't actually
decoding the cached address yet?

>  	pci_dev_reset_iommu_done(dev);
>  	return rc;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709010304.680422-1-smadhavan@nvidia.com?part=11

      reply	other threads:[~2026-07-09  1:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  1:02 [PATCH v9 00/11] PCI/CXL: Add CXL reset support for Type 2 devices Srirangan Madhavan
2026-07-09  1:02 ` [PATCH v9 01/11] cxl: Split decoder programming into a reusable helper Srirangan Madhavan
2026-07-09  1:14   ` sashiko-bot
2026-07-09  1:02 ` [PATCH v9 02/11] cxl: Cache decoder settings on PCI devices Srirangan Madhavan
2026-07-09  1:16   ` sashiko-bot
2026-07-09  1:02 ` [PATCH v9 03/11] cxl: Share HDM decoder decode logic Srirangan Madhavan
2026-07-09  1:18   ` sashiko-bot
2026-07-09  1:02 ` [PATCH v9 04/11] cxl: Cache endpoint decoder settings during PCI enumeration Srirangan Madhavan
2026-07-09  1:17   ` sashiko-bot
2026-07-09  3:30   ` Alison Schofield
2026-07-10  0:48   ` Dan Williams (nvidia)
2026-07-09  1:02 ` [PATCH v9 05/11] cxl: Add CXL Device Reset helper Srirangan Madhavan
2026-07-09  1:15   ` sashiko-bot
2026-07-09  1:02 ` [PATCH v9 06/11] cxl: Validate HDM ranges before CXL reset Srirangan Madhavan
2026-07-09  1:28   ` sashiko-bot
2026-07-09  1:03 ` [PATCH v9 07/11] PCI/CXL: Discover the CXL reset scope Srirangan Madhavan
2026-07-09  1:24   ` sashiko-bot
2026-07-10  1:00   ` Dan Williams (nvidia)
2026-07-09  1:03 ` [PATCH v9 08/11] cxl: Restore CXL HDM state after PCI reset Srirangan Madhavan
2026-07-09  1:17   ` sashiko-bot
2026-07-09  1:03 ` [PATCH v9 09/11] PCI/CXL: Expose CXL Reset as a PCI reset method Srirangan Madhavan
2026-07-09  1:27   ` sashiko-bot
2026-07-09  1:03 ` [PATCH v9 10/11] Documentation/ABI: Document CXL Reset " Srirangan Madhavan
2026-07-09  1:05   ` sashiko-bot
2026-07-09  1:03 ` [PATCH v9 11/11] PCI/CXL: Restore HDM state after CXL bus reset Srirangan Madhavan
2026-07-09  1:20   ` sashiko-bot [this message]

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=20260709012023.24DCA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=smadhavan@nvidia.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