linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power states
@ 2025-03-05  9:02 Gautam Menghani
  2025-03-10  5:00 ` Vaibhav Jain
  2025-05-04  3:21 ` Madhavan Srinivasan
  0 siblings, 2 replies; 6+ messages in thread
From: Gautam Menghani @ 2025-03-05  9:02 UTC (permalink / raw)
  To: maddy, mpe, npiggin, christophe.leroy, naveen
  Cc: Gautam Menghani, linuxppc-dev, linux-kernel, vaibhav

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

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

2. Make sure console is not suspended (so that dmesg logs are visible)
	echo N > /sys/module/printk/parameters/console_suspend

3. 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")
Cc: stable@vger.kernel.org # v5.15+
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] 6+ messages in thread
* Re: [PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power states
@ 2025-04-22  4:50 Venkat
  0 siblings, 0 replies; 6+ messages in thread
From: Venkat @ 2025-04-22  4:50 UTC (permalink / raw)
  To: gautam
  Cc: christophe.leroy, LKML, linuxppc-dev, maddy, Michael Ellerman,
	naveen, npiggin, vaibhav, venkat88

Hello Gautam,

Makes sense to track this observation separately. I tried it on fedora41 with kernel, 6.11.4-301.fc41.ppc64le, and this warning is there also. 


Traces:

[  105.121663] ------------[ cut here ]------------
[  105.121664] WARNING: CPU: 0 PID: 16 at arch/powerpc/sysdev/xics/icp-hv.c:55 icp_hv_eoi+0xf8/0x120
[  105.121683] Modules linked in: bonding tls nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 rfkill nf_tables sunrpc ibmveth
[  105.121719] PM: suspend exit
[  105.121720]  pseries_rng vmx_crypto crct10dif_vpmsum fuse dm_multipath loop nfnetlink zram vsock_loopback vmw_vsock_virtio_transport_common vsock xfs ibmvscsi scsi_transport_srp crc32c_vpmsum scsi_dh_rdac scsi_dh_emc scsi_dh_alua
[  105.121790] CPU: 0 UID: 0 PID: 16 Comm: ksoftirqd/0 Not tainted 6.11.4-301.fc41.ppc64le #1
[  105.121800] Hardware name: IBM,8375-42A POWER9 (architected) 0x4e0202 0xf000005 of:IBM,FW950.A0 (VL950_144) hv:phyp pSeries
[  105.121808] NIP:  c0000000000d5068 LR: c0000000000d5064 CTR: c00000000011d810
[  105.121811] REGS: c000000004c87a20 TRAP: 0700   Not tainted  (6.11.4-301.fc41.ppc64le)
[  105.121821] MSR:  800000000282b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 44004202  XER: 00000010
[  105.121845] CFAR: c000000000246c2c IRQMASK: 1 
[  105.121845] GPR00: c0000000000d5064 c000000004c87cc0 c0000000021c0900 000000000000003f 
[  105.121845] GPR04: 00000000ffffdfff 00000000ffffdfff c000000004c87ab8 00000007f8e50000 
[  105.121845] GPR08: 0000000000000027 c0000007fc007190 0000000000000001 0000000044004202 
[  105.121845] GPR12: c00000000011d810 c000000003f40000 c0000000001bf378 c000000004f07640 
[  105.121845] GPR16: 0000000000000000 0000000004208040 c000000003d12a80 c000000003242e80 
[  105.121845] GPR20: 00000000ffffb375 000000000000000a c0000000031b6980 c0000000002532f0 
[  105.121845] GPR24: 0000000000000001 0000000000000000 0000000000000006 0000000000000002 
[  105.121845] GPR28: c0000007fc006898 0000000000000000 00000000050a0002 00000000050a0002 
[  105.121945] NIP [c0000000000d5068] icp_hv_eoi+0xf8/0x120
[  105.121953] LR [c0000000000d5064] icp_hv_eoi+0xf4/0x120
[  105.121961] Call Trace:
[  105.121965] [c000000004c87cc0] [c0000000000d5064] icp_hv_eoi+0xf4/0x120 (unreliable)
[  105.121976] [c000000004c87d40] [c000000000254eac] handle_fasteoi_irq+0x16c/0x350
[  105.121987] [c000000004c87d70] [c0000000002533b0] resend_irqs+0xc0/0x190
[  105.121997] [c000000004c87db0] [c00000000018b690] tasklet_action_common.isra.0+0x150/0x430
[  105.122007] [c000000004c87e20] [c00000000018aafc] handle_softirqs+0x17c/0x4f0
[  105.122017] [c000000004c87f10] [c00000000018aed8] run_ksoftirqd+0x68/0xb0
[  105.122025] [c000000004c87f30] [c0000000001ca460] smpboot_thread_fn+0x1e0/0x250
[  105.122036] [c000000004c87f90] [c0000000001bf4a4] kthread+0x134/0x140
[  105.122047] [c000000004c87fe0] [c00000000000ded8] start_kernel_thread+0x14/0x18
[  105.122056] Code: 48bc88c1 60000000 e9210068 4bffff9c 7c661b78 3c82ff40 3c62ff85 7fc5f378 3884ca50 38637628 48171b85 60000000 <0fe00000> 38210080 7be34622 e8010010 
[  105.122094] ---[ end trace 0000000000000000 ]—


Regards,
Venkat.

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

end of thread, other threads:[~2025-05-04  3:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05  9:02 [PATCH] powerpc/pseries/msi: Avoid reading PCI device registers in reduced power states Gautam Menghani
2025-03-10  5:00 ` Vaibhav Jain
2025-03-26 17:32   ` Venkat Rao Bagalkote
2025-04-21 11:50     ` Gautam Menghani
2025-05-04  3:21 ` Madhavan Srinivasan
  -- strict thread matches above, loose matches on Subject: below --
2025-04-22  4:50 Venkat

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).