Skip to contentSkip to conversation

ASPM: Fix pcie devices with non-pcie children

PATCH In review Matthew Garrett 6 participants 9 messages Mar 27, 2012 – Mar 29, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASPM: Fix pcie devices with non-pcie children

Commit 4949be16822e92a18ea0cc1616319926628092ee changed the behaviour of pcie_aspm_sanity_check() to always return 0 if aspm is disabled, in order to avoid cases where we changed ASPM state on pre-PCIe 1.1 devices. This skipped the secondary function of pcie_aspm_sanity_check which was to avoid us enabling ASPM on devices that had non-PCIe children, causing us to hit a BUG_ON later on. Move the aspm_disabled check so we continue to honour that scenario.

---
 drivers/pci/pcie/aspm.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
drivers/pci/pcie/aspm.c +10 -3
index 86111d9..41e367b 100644
@@ -521,9 +521,6 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
 	int pos;
 	u32 reg32;
 
-	if (aspm_disabled)
-		return 0;
-
 	/*
 	 * Some functions in a slot might not all be PCIe functions,
 	 * very strange. Disable ASPM for the whole slot
@@ -532,6 +529,16 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
 		pos = pci_pcie_cap(child);
 		if (!pos)
 			return -EINVAL;
+
+		/*
+		 * If ASPM is disabled then we're not going to change
+		 * the BIOS state. It's safe to continue even if it's a
+		 * pre-1.1 device
+		 */
+
+		if (aspm_disabled)
+			continue;
+
 		/*
 		 * Disable ASPM for pre-1.1 PCIe device, we follow MS to use
 		 * RBER bit to determine if a function is 1.1 version device
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 35 lines · Matthew Garrett

Commit 4949be16822e92a18ea0cc1616319926628092ee changed the behaviour of pcie_aspm_sanity_check() to always return 0 if aspm is disabled, in order to avoid cases where we changed ASPM state on pre-PCIe 1.1 devices. This skipped the secondary function of pcie_aspm_sanity_check which was to avoid us enabling ASPM on devices that had non-PCIe children, causing us to hit a BUG_ON later on. Move the aspm_disabled check so we continue to honour that scenario.

---
  drivers/pci/pcie/aspm.c |   13 ++++++++++---
  1 files changed, 10 insertions(+), 3 deletions(-)
drivers/pci/pcie/aspm.c +3 -3
index 86111d9..41e367b 100644
@@ -521,9 +521,6 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
  	int pos;
  	u32 reg32;
 
-	if (aspm_disabled)
-		return 0;
-
  	/*
  	 * Some functions in a slot might not all be PCIe functions,
  	 * very strange. Disable ASPM for the whole slot
@@ -532,6 +529,16 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
  		pos = pci_pcie_cap(child);
  		if (!pos)
  			return -EINVAL;
+
+		/*
+		 * If ASPM is disabled then we're not going to change

drivers/pci/pcie/aspm.c static int pcie_aspm_sanity_check(struct pci_dev *pdev) · line 544

Quoted 10 lines
drivers/pci/pcie/aspm.c +7 -0
+		 * the BIOS state. It's safe to continue even if it's a
+		 * pre-1.1 device
+		 */
+
+		if (aspm_disabled)
+			continue;
+
  		/*
  		 * Disable ASPM for pre-1.1 PCIe device, we follow MS to use
  		 * RBER bit to determine if a function is 1.1 version device

We got a user who's now verified this fixes the BUG_ON() during boot,
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/961482/comments/51

.. so this does the trick. Thanks Matthew.

#2 lore raw
In reply to Matthew Garrett

Hi Matthew,

Quoted 7 lines · Matthew Garrett

Commit 4949be16822e92a18ea0cc1616319926628092ee changed the behaviour of pcie_aspm_sanity_check() to always return 0 if aspm is disabled, in order to avoid cases where we changed ASPM state on pre-PCIe 1.1 devices. This skipped the secondary function of pcie_aspm_sanity_check which was to avoid us enabling ASPM on devices that had non-PCIe children, causing us to hit a BUG_ON later on. Move the aspm_disabled check so we continue to honour that scenario.

janek (cc-ed) never experienced the BUG_ON. Instead, starting with v3.3 and v3.2.12 his hard disk using the pata_jmicron driver was not detected during boot-up, resulting in the message "gave up waiting for root device" and a failed boot.

Found in

Debian kernel 3.2.12-1
Debian kernel 3.3-1~experimental.1
Upstream 3.3
Linus's "master" as of 2012-03-28

Based on the thread [1] we blamed 4949be16822. janek tried the patch above on top of linus's "master". The result:

Quoted 1 line

Thanks. This patch fixes the problem.

In other words, this gets the pata_jmicron driver to enumerate its drives again, a positive effect that wasn't even advertised in the commit message. ;-) Thanks for writing it.

Sincerely,
Jonathan

[1] http://thread.gmane.org/gmane.linux.kernel/1271264/focus=1271785

#3 lore raw

PATCH RESEND 1/1 ASPM: Fix pcie devices with non-pcie children

In reply to Matthew Garrett

From: Matthew Garrett <[email protected]>
Date: Tue, 27 Mar 2012 10:17:41 -0400

Since 3.2.12 and 3.3, some systems are failing to boot with a BUG_ON. Some other systems using the pata_jmicron driver fail to boot because no disks are detected. Passing pcie_aspm=force on the kernel command line works around it.

The cause: commit 4949be16822e ("PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled") changed the behaviour of pcie_aspm_sanity_check() to always return 0 if aspm is disabled, in order to avoid cases where we changed ASPM state on pre-PCIe 1.1 devices. This skipped the secondary function of pcie_aspm_sanity_check which was to avoid us enabling ASPM on devices that had non-PCIe children, causing trouble later on. Move the aspm_disabled check so we continue to honour that scenario.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=42979 and

          http://bugs.debian.org/665420

[jn: with more symptoms in log message]

---
Hi Andrew,

This patch only appeared a couple of days ago[1], but it fixes a noticeable regression so I would like to make sure the patch becomes part of mainline and the 3.2.y- and 3.3.y-stable trees soon. Could you pick it up for linux-next until it makes its way to the PCI tree?

Regression was introduced between 3.3-rc7 and 3.3 and between 3.2.11 and 3.2.12. Prevents boot on affected machines, though there is a workaround. Details about the symptoms and fix are above.

Thanks,
Jonathan

[1] http://thread.gmane.org/gmane.linux.kernel.pci/14503

 drivers/pci/pcie/aspm.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/pci/pcie/aspm.c +10 -3
index 4bdef24cd412..b500840a143b 100644
@@ -508,9 +508,6 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
 	int pos;
 	u32 reg32;
 
-	if (aspm_disabled)
-		return 0;
-
 	/*
 	 * Some functions in a slot might not all be PCIe functions,
 	 * very strange. Disable ASPM for the whole slot
@@ -519,6 +516,16 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
 		pos = pci_pcie_cap(child);
 		if (!pos)
 			return -EINVAL;
+
+		/*
+		 * If ASPM is disabled then we're not going to change
+		 * the BIOS state. It's safe to continue even if it's a
+		 * pre-1.1 device
+		 */
+
+		if (aspm_disabled)
+			continue;
+
 		/*
 		 * Disable ASPM for pre-1.1 PCIe device, we follow MS to use
 		 * RBER bit to determine if a function is 1.1 version device
Signature · 1 line
1.7.10.rc1
#4 lore raw
Quoted 32 lines · On Thu, 29 Mar 2012 11:32:06 -0500 Jonathan Nieder <[email protected]> wrote:

From: Matthew Garrett <[email protected]>
Date: Tue, 27 Mar 2012 10:17:41 -0400

Since 3.2.12 and 3.3, some systems are failing to boot with a BUG_ON. Some other systems using the pata_jmicron driver fail to boot because no disks are detected. Passing pcie_aspm=force on the kernel command line works around it.

The cause: commit 4949be16822e ("PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled") changed the behaviour of pcie_aspm_sanity_check() to always return 0 if aspm is disabled, in order to avoid cases where we changed ASPM state on pre-PCIe 1.1 devices. This skipped the secondary function of pcie_aspm_sanity_check which was to avoid us enabling ASPM on devices that had non-PCIe children, causing trouble later on. Move the aspm_disabled check so we continue to honour that scenario.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=42979 and

          http://bugs.debian.org/665420

[jn: with more symptoms in log message]

---
Hi Andrew,

Quoted 8 lines

This patch only appeared a couple of days ago[1], but it fixes a noticeable regression so I would like to make sure the patch becomes part of mainline and the 3.2.y- and 3.3.y-stable trees soon. Could you pick it up for linux-next until it makes its way to the PCI tree?

Regression was introduced between 3.3-rc7 and 3.3 and between 3.2.11 and 3.2.12. Prevents boot on affected machines, though there is a workaround. Details about the symptoms and fix are above.

Just about the only person who wasn't copied on this email is, umm, the PCI maintainer!

#5 lore raw
Quoted 2 lines · Andrew Morton

Just about the only person who wasn't copied on this email is, umm, the PCI maintainer!

Jesse just handed that off to Bjorn…

Signature · 1 line
Matthew Garrett | [email protected]
#6 lore raw
Quoted 6 lines · On Thu, 29 Mar 2012 21:56:35 +0100 Matthew Garrett <[email protected]> wrote:
Quoted 2 lines · Andrew Morton

Just about the only person who wasn't copied on this email is, umm, the PCI maintainer!

Jesse just handed that off to Bjorn…

Oh. So he did. My search of MAINTAINERS turned up the probably wrong

T: git git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci.git

maintainer Acked-by
#7 lore raw
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Thu, 29 Mar 2012 21:56:35 +0100 Matthew Garrett <[email protected]> wrote:

On Thu, Mar 29, 2012 at 01:46:14PM -0700, Andrew Morton wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Just about the only person who wasn't copied on this email is, umm, the PCI maintainer!

Jesse just handed that off to Bjorn�

Oh. �So he did. � My search of MAINTAINERS turned up the probably wrong

T: � � �git git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci.git

Yep, I'll update MAINTAINERS as soon as I set up a kernel.org tree.

The patch itself looks fine to me, so in case anybody wants to pick it up earlier:

I do think that ASPM path is disappointingly hard to follow, which likely contributed to the bug in the first place. pcie_aspm_sanity_check() is a terrible name for something that returns 0/errno (which is treated as a bool meaning something like "do ASPM on this device"). And the idea that we save this blacklist information in the form of "link->aspm_enabled = ASPM_STATE_ALL" is weird.

But obviously, I'm ignorant of ASPM in general.

Bjorn

#8 lore raw
In reply to Andrew Morton
Quoted 4 lines · Andrew Morton
Quoted 2 lines · Jonathan Nieder

From: Matthew Garrett <[email protected]>
Date: Tue, 27 Mar 2012 10:17:41 -0400

[...]

Quoted 7 lines
Quoted 7 lines
           commit 4949be16822e ("PCI: ignore pre-1.1 ASPM quirking

when ASPM is disabled") changed the behaviour of pcie_aspm_sanity_check() to always return 0 if aspm is disabled, in order to avoid cases where we changed ASPM state on pre-PCIe 1.1 devices. This skipped the secondary function of pcie_aspm_sanity_check which was to avoid us enabling ASPM on devices that had non-PCIe children, causing trouble later on.

[...]

Quoted 2 lines
Quoted 2 lines

Could
you pick it up for linux-next until it makes its way to the PCI tree?

[...]

Quoted 2 lines

Just about the only person who wasn't copied on this email is, umm, the PCI maintainer!

Well spotted. Thanks for catching it.