Re: [PATCH v17 12/19] PCI/CXL: Add CXL Device Reset sequencing
From: Srirangan Madhavan
Date: Fri Nov 20 2026 - 18:14:54 EST
On 11/11/26 2:12 AM, Lucero Palau, Alejandro wrote:
External email: Use caution opening links or attachments
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.
Hi Alejandro,
Thanks for the review.
I don't think I can add a bound-driver check in this series. For VFIO
passthrough, vfio-pci is always the bound driver at every reset VFIO
starts, and VFIO needs an IOMMU outside no-IOMMU mode, so the check would
always fire. VFIO resets through the PCI reset methods, so a refusal would
make every reset of a Type 2 device fail or fall back to FLR, which isn't
what passthrough needs. Manish describes the vfio-cxl side in his reply
to patch 15 of the v6 series:
https://lore.kernel.org/linux-cxl/20261016161839.2765592-1-mhonap@xxxxxxxxxx/
I guess the same exposure also exists for FLR and the other methods, which go through the same pci_dev_reset_iommu_prepare()?
For now, the reset file is root-only, and a CXL.io-only device doesn't reach cxl_reset: cxl_reset_function() needs CXL.cache and CXL.mem enabled, otherwise it returns -ENOTTY and the normal methods are used.
If this is okay, can we revisit the point once vfio-cxl's reset model is settled and the CXL.cache IOMMU side lands as you mentioned?
--
Regards,
Srirangan