On 7/18/2026 2:02 AM, Lukas Wunner wrote:
> On Fri, Jul 17, 2026 at 05:27:04PM -0500, Terry Bowman wrote:
>> Add a u64 dsn field to struct pci_dev and populate it from pci_get_dsn()
>> during pci_init_capabilities() at probe time via pci_dsn_init(). Only
>> write dev->dsn when the read succeeds. The zero initial value from
>> pci_dev allocation already represents 'no DSN available.'
>
> The DSN is already cached on (natively handled) PCIe hotplug ports
> to detect device replacement during system sleep, see struct controller
> in drivers/pci/hotplug/pciehp.h.
>
> Please remove that member from struct controller, remove the two
> assignments to the member in pciehp_configure_device() and pcie_init()
> and change the comparison in pciehp_device_replaced() to use the new
> member in struct pci_dev. You can do this either as part of this patch
> or in a separate patch.
>
> Thanks,
>
> Lukas
Hi Lukas,
Thanks for reviewing. Is this the changes you want?
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index debc79b0adfb2..12ec050d8a0fb 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -90,7 +90,6 @@ extern int pciehp_poll_time;
*/
struct controller {
struct pcie_device *pcie;
- u64 dsn;
u32 slot_cap; /* capabilities and quirks */
unsigned int inband_presence_disabled:1;
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 4c62140a3cb44..c07957e0b37a8 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -587,7 +587,7 @@ bool pciehp_device_replaced(struct controller *ctrl)
reg != (pdev->subsystem_vendor | (pdev->subsystem_device << 16))))
return true;
- if (pci_get_dsn(pdev) != ctrl->dsn)
+ if (pci_get_dsn(pdev) != pdev->dsn)
return true;
return false;
@@ -1086,8 +1086,6 @@ struct controller *pcie_init(struct pcie_device *dev)
}
pdev = pci_get_slot(subordinate, PCI_DEVFN(0, 0));
- if (pdev)
- ctrl->dsn = pci_get_dsn(pdev);
pci_dev_put(pdev);
return ctrl;
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 65e50bee1a8c0..065e1f7c9a7bd 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -73,7 +73,6 @@ int pciehp_configure_device(struct controller *ctrl)
down_read_nested(&ctrl->reset_lock, ctrl->depth);
dev = pci_get_slot(parent, PCI_DEVFN(0, 0));
- ctrl->dsn = pci_get_dsn(dev);
pci_dev_put(dev);
out:
-Terry