Re: [PATCH v17 12/19] PCI/CXL: Add CXL Device Reset sequencing

From: Lucero Palau, Alejandro

Date: Wed Nov 11 2026 - 05:22:28 EST


On 05/11/2026 18:59, Srirangan Madhavan wrote:
Implement CXL Device Reset for eligible Type 2 devices: disable CXL.cache,
perform supported writeback, drain transactions, prepare the IOMMU,
initiate reset with Memory Clear enabled, and wait for completion.

Observe the 100 ms post-reset quiet period before polling Status2, and
treat an all-ones read as not ready. Wait for the timeout the device
advertises, up to 100 seconds, and access only Status2 until reset
completion, error or expiry, as CXL 4.0 section 9.7.3 requires. Control2
cleanup runs only afterwards. Treat Control2 command bits as
transient state, restore cache policy on exit, preserve the primary error,
and abort when IOMMU preparation fails.

Reuse Device DVSEC discovery from cache initialization and keep the
reset entry point declaration private to PCI core.

Signed-off-by: Srirangan Madhavan <smadhavan@xxxxxxxxxx>


Hi Srirangan,


A concern regarding IOMMU handling below. If it turns to be unfounded, you can add my review tag.


Thank you,

Alejandro


<snip>

+static int __cxl_reset_execute(struct pci_dev *pdev, int dvsec, u16 cap)
+{
+ int rc, rc2;
+
+ if (!pci_wait_for_pending_transaction(pdev)) {
+ pci_err(pdev, "timed out waiting for pending transactions\n");
+ return -ETIMEDOUT;
+ }
+
+ rc = pci_dev_reset_iommu_prepare(pdev);


I'm not sure if this is safe enough. I can see a situation where a Type2 device could not be using CXL.mem and CXL.cache but CXL.io. This would imply no CXL initialization from the Type2 driver but:


    1) Such a driver could be giving functionality without CXL

    2) The device belonging to an IOMMU domain which such functionality is using

    3) The HDM decoder range as a system resource is free.


If I am right, a CXL reset could happen, and although it should not be triggered by user space under these circumstances, the door is open ...


The solution would be, currently, to check for a  driver not bound to the device in an IOMMU enabled system. I say currently because CXL.cache will need extra work with IOMMU mapping which are not yet there.