Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: Update saved Max Read Request Size in pcie_set_readrq()
@ 2026-10-13 19:53 Niklas Cassel
  2026-10-13 20:05 ` sashiko-bot
  2026-10-14  2:21 ` Shawn Lin
  0 siblings, 2 replies; 4+ messages in thread
From: Niklas Cassel @ 2026-10-13 19:53 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Niklas Cassel, Shawn Lin, linux-pci

pcie_set_readrq() changes the Max Read Request Size (MRRS) in the Device
Control register but leaves the copy saved by pci_save_state() alone, so
a pci_restore_state() that is not preceded by pci_save_state() puts back
the old value.

Since commit a2f1e22390ac ("PCI/ERR: Ensure error recoverability at all
times"), the PCI core saves the state of a device when the device is
added, before a driver is bound.  The MRRS is usually set after that, by
the driver or by an enable fixup, some of which limit the MRRS to what
the hardware can handle, e.g. quirk_brcm_5719_limit_mrrs() and the
keystone and Loongson fixups.  Unless the state is saved again, a
pci_restore_state() after a reset, e.g. in the driver's ->slot_reset()
during error recovery, puts back the MRRS that the device had when it
was added.

Update the saved copy of Device Control when pcie_set_readrq() changes
the MRRS, like pcie_set_mps() does for the Max Payload Size.

Suggested-by: Shawn Lin <shawn.lin@rock-chips.com>
Assisted-by: LLM
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
 drivers/pci/pci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5b126cd342ca..30a583aeea65 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5944,8 +5944,12 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
 
 	ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
 						  PCI_EXP_DEVCTL_READRQ, v);
+	if (ret)
+		return pcibios_err_to_errno(ret);
 
-	return pcibios_err_to_errno(ret);
+	pcie_update_saved_devctl(dev, PCI_EXP_DEVCTL_READRQ, v);
+
+	return 0;
 }
 EXPORT_SYMBOL(pcie_set_readrq);
 

base-commit: 581cf67cb6f66eabc6bcd7f61dd64b2559270507
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-14  2:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 19:53 [PATCH] PCI: Update saved Max Read Request Size in pcie_set_readrq() Niklas Cassel
2026-10-13 20:05 ` sashiko-bot
2026-10-13 21:00   ` Niklas Cassel
2026-10-14  2:21 ` Shawn Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox