linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power state
@ 2025-02-06 10:09 Gautam Menghani
  2025-02-17  5:07 ` Gautam Menghani
  0 siblings, 1 reply; 2+ messages in thread
From: Gautam Menghani @ 2025-02-06 10:09 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, naveen, maddy, clg, brking,
	vaibhav
  Cc: Gautam Menghani, linuxppc-dev, linux-kernel

When a system is being suspended to RAM, the PCI devices are also
suspended and the code ends up calling pseries_msi_compose_msg() and this
triggers the BUG_ON() in __pci_read_msi_msg() because the device at that
point is in reduced power state. In reduced power state, the memory
mapped registers of the device are not accessible.

To replicate the bug:
1. Make sure deep sleep is selected
	# cat /sys/power/mem_sleep
	s2idle [deep]

2. Suspend the system
	echo mem > /sys/power/state

To fix this behaviour, read the cached msi message of the device when the
device is not in PCI_D0 power state instead of touching the hardware.

Fixes: a5f3d2c17b07 ("powerpc/pseries/pci: Add MSI domains")
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
 arch/powerpc/platforms/pseries/msi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index fdc2f7f38dc9..458d95c8c755 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -525,7 +525,12 @@ static struct msi_domain_info pseries_msi_domain_info = {
 
 static void pseries_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
 {
-	__pci_read_msi_msg(irq_data_get_msi_desc(data), msg);
+	struct pci_dev *dev = msi_desc_to_pci_dev(irq_data_get_msi_desc(data));
+
+	if (dev->current_state == PCI_D0)
+		__pci_read_msi_msg(irq_data_get_msi_desc(data), msg);
+	else
+		get_cached_msi_msg(data->irq, msg);
 }
 
 static struct irq_chip pseries_msi_irq_chip = {
-- 
2.47.0



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

* Re: [RFC PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power state
  2025-02-06 10:09 [RFC PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power state Gautam Menghani
@ 2025-02-17  5:07 ` Gautam Menghani
  0 siblings, 0 replies; 2+ messages in thread
From: Gautam Menghani @ 2025-02-17  5:07 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, naveen, maddy, clg, brking,
	vaibhav
  Cc: linuxppc-dev, linux-kernel

Hello,
Please review this patch and let me know if there are any issues with
the same.

Thanks,
Gautam


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

end of thread, other threads:[~2025-02-17  5:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-06 10:09 [RFC PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power state Gautam Menghani
2025-02-17  5:07 ` Gautam Menghani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).