Re: [PATCH v16 14/18] PCI/CXL: Reject reset with unsafe function scope

From: Joshua Machauer

Date: Thu Nov 05 2026 - 09:42:30 EST


On Thu, Oct 29, 2026 at 02:56:59PM +0000, Srirangan Madhavan wrote:
> @@ -515,6 +515,9 @@ int cxl_reset_function(struct pci_dev *pdev, bool probe)
> !(ctrl & PCI_DVSEC_CXL_MEM_ENABLE))
> return -ENOTTY;
>
> + if (pdev->is_virtfn || pdev->multifunction || pci_num_vf(pdev))
> + return -ENOTTY;
> +
> if (probe)
> return 0;

[...]

> @@ -5026,6 +5026,9 @@ static int cxl_reset_bus_function(struct pci_dev *dev, bool probe)
> if (!dvsec)
> return -ENOTTY;
>
> + if (dev->is_virtfn || dev->multifunction || pci_num_vf(dev))
> + return -ENOTTY;
> +
> if (probe)
> return 0;

Could both checks go at the top of their functions, before the DVSEC
lookups? None of the three conditions depends on what the lookups
find.

pci_init_reset_methods() probes every reset method for every device
that is added, and enabling SR-IOV adds the VFs one after another.
Where the checks are now, each VF probe walks the extended
capabilities twice before it returns -ENOTTY: cxl_reset walks the
VF's own list for the CXL Device DVSEC, and cxl_bus walks the
upstream bridge's list for the CXL Port DVSEC. All VFs of a PF share
that bridge, so its walk repeats once per VF with the same result.

With the checks first, a VF returns -ENOTTY without a config read,
and the result for every device stays the same.

Thanks,
Joshua