Skip to content

Commit 1271d02

Browse files
committed
Reverting 456d8aa to avoid kernel panics in 6.1.94
For certain pci tree structures involving pci devices with sibling functions we can get a nullptr dereference when the link state goes down due to this change. Fixing: sonic-net/sonic-buildimage#20901 Reverting: torvalds/linux@456d8aa Upstream Discussion: https://lore.kernel.org/linux-pci/20240801171103.GA107989@bhelgaas/T/#t
1 parent c281fc9 commit 1271d02

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Nathan Wolfe <[email protected]>
3+
Date: Tue, 8 Oct 2024 11:57:26 -0700
4+
Subject: [PATCH] revert 456d8aa to fix pcie_aspm_exit_link_status
5+
6+
https://github.com/torvalds/linux/commit/456d8aa37d0f56fc9e985e812496e861dcd6f2f2
7+
---
8+
drivers/pci/pcie/aspm.c | 21 +++++++++------------
9+
1 file changed, 9 insertions(+), 12 deletions(-)
10+
11+
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
12+
index cf4acea66..188517c5a 100644
13+
--- a/drivers/pci/pcie/aspm.c
14+
+++ b/drivers/pci/pcie/aspm.c
15+
@@ -1025,24 +1025,21 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
16+
17+
down_read(&pci_bus_sem);
18+
mutex_lock(&aspm_lock);
19+
+ /*
20+
+ * All PCIe functions are in one slot, remove one function will remove
21+
+ * the whole slot, so just wait until we are the last function left.
22+
+ */
23+
+ if (!list_empty(&parent->subordinate->devices))
24+
+ goto out;
25+
26+
link = parent->link_state;
27+
root = link->root;
28+
parent_link = link->parent;
29+
30+
- /*
31+
- * link->downstream is a pointer to the pci_dev of function 0. If
32+
- * we remove that function, the pci_dev is about to be deallocated,
33+
- * so we can't use link->downstream again. Free the link state to
34+
- * avoid this.
35+
- *
36+
- * If we're removing a non-0 function, it's possible we could
37+
- * retain the link state, but PCIe r6.0, sec 7.5.3.7, recommends
38+
- * programming the same ASPM Control value for all functions of
39+
- * multi-function devices, so disable ASPM for all of them.
40+
- */
41+
+ /* All functions are removed, so just disable ASPM for the link */
42+
pcie_config_aspm_link(link, 0);
43+
list_del(&link->sibling);
44+
+ /* Clock PM is for endpoint device */
45+
free_link_state(link);
46+
47+
/* Recheck latencies and configure upstream links */
48+
@@ -1050,7 +1047,7 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
49+
pcie_update_aspm_capable(root);
50+
pcie_config_aspm_path(parent_link);
51+
}
52+
-
53+
+out:
54+
mutex_unlock(&aspm_lock);
55+
up_read(&pci_bus_sem);
56+
}

patch/series

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ cisco-npu-disable-other-bars.patch
223223
# Micas patches
224224
0001-fix-os-crash-caused-by-optoe-when-class-switch.patch
225225

226+
# Fix to avoid kernel panic on Kernel 6.1.94
227+
# https://github.com/sonic-net/sonic-buildimage/issues/20901
228+
revert-456d8aa-to-fix-pcie_aspm_exit_link_status.patch
229+
226230
#
227231
#
228232
############################################################

0 commit comments

Comments
 (0)