Save and restore the DPC Control register through the per-device saved capability store instead of a private pci_cap_saved_state buffer.
Key the save and restore paths off pdev->dpc_cap rather than pci_is_pcie(). The presence of the save buffer used to stand in for the presence of the capability, which the store cannot do because it is addressed by configuration space offset. No functional change intended. Assisted-by: LLM Signed-off-by: David Matlack <[email protected]> --- drivers/pci/pcie/dpc.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index b7f79266f66d..6f40cf2c712c 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -45,34 +45,18 @@ static const char * const rp_pio_error_string[] = { void pci_save_dpc_state(struct pci_dev *dev) { - struct pci_cap_saved_state *save_state; - u16 *cap; - - if (!pci_is_pcie(dev)) - return; - - save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_DPC); - if (!save_state) + if (!dev->dpc_cap) return; - cap = (u16 *)&save_state->cap.data[0]; - pci_read_config_word(dev, dev->dpc_cap + PCI_EXP_DPC_CTL, cap); + pci_save_cap_word(dev, dev->dpc_cap + PCI_EXP_DPC_CTL); } void pci_restore_dpc_state(struct pci_dev *dev) { - struct pci_cap_saved_state *save_state; - u16 *cap; - - if (!pci_is_pcie(dev)) - return; - - save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_DPC); - if (!save_state) + if (!dev->dpc_cap) return; - cap = (u16 *)&save_state->cap.data[0]; - pci_write_config_word(dev, dev->dpc_cap + PCI_EXP_DPC_CTL, *cap); + pci_restore_cap_word(dev, dev->dpc_cap + PCI_EXP_DPC_CTL); } static DECLARE_WAIT_QUEUE_HEAD(dpc_completed_waitqueue); @@ -408,8 +392,8 @@ void pci_dpc_init(struct pci_dev *pdev) if (!pdev->dpc_cap) return; - if (pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_DPC, sizeof(u16))) - pci_err(pdev, "unable to allocate suspend buffer for DPC\n"); + if (pci_reserve_saved_cap(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, sizeof(u16))) + pci_err(pdev, "unable to reserve DPC save state\n"); pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CAP, &cap); if (!(cap & PCI_EXP_DPC_CAP_RP_EXT)) -- 2.56.0.rc1.315.gc6ed9934b7-goog
