linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [Bug 55211] pci_disable_link_state PCIE_LINK_STATE_L0S no longer disables ASPM for ath5k
       [not found] ` <20130317155023.5B2EB11FB81@bugzilla.kernel.org>
@ 2013-03-17 17:19   ` Yinghai Lu
  2013-03-18 17:37     ` [PATCH] PCI: Remove not needed check in disable aspm link Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-17 17:19 UTC (permalink / raw)
  To: bugzilla-daemon, Roman Yepishev, Bjorn Helgaas
  Cc: Taku Izumi, Linux Kernel Mailing List, linux-pci, NetDev

[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]

On Sun, Mar 17, 2013 at 8:50 AM,  <bugzilla-daemon@bugzilla.kernel.org> wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=55211

> --- Comment #9 from Roman Yepishev <roman.yepishev@gmail.com>  2013-03-17 15:50:23 ---
> Re-tested on two laptops - AOA150, ath5k device got ASPM disabled and on a
> Lenovo E420 I got ASPM disabled for iwlwifi-driven Intel Corporation Centrino
> Wireless-N 1000 [8086:0084].
>
> Also I found http://article.gmane.org/gmane.linux.kernel.pci/20640 where a
> question was raised why pci_disable_link_state stopped doing anything for
> iwlwifi devices too.
>

good.

Did you test first patch or second patch?

Please test second patch only on affected platforms.

old logic is quite strange, on boot path and hotplug path it have
different aspm_disabled setting.
as it could set aspm_disabled after pci root bus scanning.

Second patch will not restore to old logic, and just remove not needed
aspm_disabled checking
for disabling path.

So second patch is right fix, but it need more test.

Thanks

Yinghai

[-- Attachment #2: pci_acpi_osc_aspm_fix.patch --]
[-- Type: application/octet-stream, Size: 3533 bytes --]

Subject: [PATCH] PCI, ACPI: Delay pcie_no_aspm() calling

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pci_disable_link_state does not work anymore as acpi_disabled
is set before pci root bus scanning.
It will skip that in quirks and pcie_aspm_sanity_check.

Retore old logic just delay calling pcie_no_aspm() later.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Need it for 3.8 stable.

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Tested-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: stable@kernel.org

---
 drivers/acpi/pci_root.c |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -415,7 +415,9 @@ static int acpi_pci_root_add(struct acpi
 	struct acpi_pci_root *root;
 	struct acpi_pci_driver *driver;
 	u32 flags, base_flags;
-	bool is_osc_granted = false;
+	/* -1: not even tried, 0: tried but failed, 1: tried and succesful */
+	int osc_support_query_state = -1;
+	int osc_control_set_state = -1;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -488,11 +490,12 @@ static int acpi_pci_root_add(struct acpi
 	if (flags != base_flags) {
 		status = acpi_pci_osc_support(root, flags);
 		if (ACPI_FAILURE(status)) {
+			osc_support_query_state = 0;
 			dev_info(&device->dev, "ACPI _OSC support "
-				"notification failed, disabling PCIe ASPM\n");
-			pcie_no_aspm();
+				"notification failed, PCIe ASPM will be disabled\n");
 			flags = base_flags;
-		}
+		} else
+			osc_support_query_state = 1;
 	}
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
@@ -514,11 +517,11 @@ static int acpi_pci_root_add(struct acpi
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
 		if (ACPI_SUCCESS(status)) {
-			is_osc_granted = true;
+			osc_control_set_state = 1;
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
 		} else {
-			is_osc_granted = false;
+			osc_control_set_state = 0;
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
@@ -555,13 +558,16 @@ static int acpi_pci_root_add(struct acpi
 	}
 
 	/* ASPM setting */
-	if (is_osc_granted) {
+	if (osc_support_query_state == 0) {
+		dev_info(&device->dev, "ACPI _OSC support notification failed, PCIe ASPM disabled\n");
+		pcie_no_aspm();
+	}
+	if (osc_control_set_state == 1) {
 		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
 			pcie_clear_aspm(root->bus);
-	} else {
-		pr_info("ACPI _OSC control for PCIe not granted, "
-			"disabling ASPM\n");
-		pcie_no_aspm();
+	} else if (osc_control_set_state == 0) {
+			dev_info(&device->dev, "ACPI _OSC control not granted, PCIe ASPM disabled\n");
+			pcie_no_aspm();
 	}
 
 	pci_acpi_add_bus_pm_notifier(device, root->bus);

[-- Attachment #3: disable_aspm_remove_not_needed_check.patch --]
[-- Type: application/octet-stream, Size: 3040 bytes --]

Subject: [PATCH] PCI: Remove not needed check in disable aspm link

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pci_disable_link_state does not work anymore as acpi_disabled
is set before pci root bus scanning.
It will skip that in quirks and pcie_aspm_sanity_check.

Acctually we don't need to check aspm_disabled in disable link, as
we already have protection about link state following.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Need it for 3.8 stable.

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: stable@kernel.org

---
 drivers/pci/pcie/aspm.c |   21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

Index: linux-2.6/drivers/pci/pcie/aspm.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/aspm.c
+++ linux-2.6/drivers/pci/pcie/aspm.c
@@ -493,15 +493,6 @@ static int pcie_aspm_sanity_check(struct
 			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
 		 */
@@ -718,15 +709,11 @@ void pcie_aspm_powersave_config_link(str
  * pci_disable_link_state - disable pci device's link state, so the link will
  * never enter specific states
  */
-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
-				     bool force)
+static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 {
 	struct pci_dev *parent = pdev->bus->self;
 	struct pcie_link_state *link;
 
-	if (aspm_disabled && !force)
-		return;
-
 	if (!pci_is_pcie(pdev))
 		return;
 
@@ -757,13 +744,13 @@ static void __pci_disable_link_state(str
 
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, false, false);
+	__pci_disable_link_state(pdev, state, false);
 }
 EXPORT_SYMBOL(pci_disable_link_state_locked);
 
 void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, true, false);
+	__pci_disable_link_state(pdev, state, true);
 }
 EXPORT_SYMBOL(pci_disable_link_state);
 
@@ -781,7 +768,7 @@ void pcie_clear_aspm(struct pci_bus *bus
 		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
 					 PCIE_LINK_STATE_L1 |
 					 PCIE_LINK_STATE_CLKPM,
-					 false, true);
+					 false);
 	}
 }
 

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

* [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-17 17:19   ` [Bug 55211] pci_disable_link_state PCIE_LINK_STATE_L0S no longer disables ASPM for ath5k Yinghai Lu
@ 2013-03-18 17:37     ` Yinghai Lu
  2013-03-27 22:56       ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-18 17:37 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki
  Cc: linux-pci, linux-acpi, linux-kernel, Yinghai Lu, Taku Izumi,
	Kenji Kaneshige, stable

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pci_disable_link_state does not work anymore as acpi_disabled
is set before pci root bus scanning.
It will skip that in quirks and pcie_aspm_sanity_check.

We could revert to old logic, but that will make booting path and hotplug
path with different aspm_disabled again.

Acctually we don't need to check aspm_disabled in disable link, as
we already have protection about link state following.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Need it for 3.8 stable.

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Tested-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Cc: stable@kernel.org

---
 drivers/pci/pcie/aspm.c |   21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

Index: linux-2.6/drivers/pci/pcie/aspm.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/aspm.c
+++ linux-2.6/drivers/pci/pcie/aspm.c
@@ -493,15 +493,6 @@ static int pcie_aspm_sanity_check(struct
 			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
 		 */
@@ -718,15 +709,11 @@ void pcie_aspm_powersave_config_link(str
  * pci_disable_link_state - disable pci device's link state, so the link will
  * never enter specific states
  */
-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
-				     bool force)
+static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 {
 	struct pci_dev *parent = pdev->bus->self;
 	struct pcie_link_state *link;
 
-	if (aspm_disabled && !force)
-		return;
-
 	if (!pci_is_pcie(pdev))
 		return;
 
@@ -757,13 +744,13 @@ static void __pci_disable_link_state(str
 
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, false, false);
+	__pci_disable_link_state(pdev, state, false);
 }
 EXPORT_SYMBOL(pci_disable_link_state_locked);
 
 void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, true, false);
+	__pci_disable_link_state(pdev, state, true);
 }
 EXPORT_SYMBOL(pci_disable_link_state);
 
@@ -781,7 +768,7 @@ void pcie_clear_aspm(struct pci_bus *bus
 		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
 					 PCIE_LINK_STATE_L1 |
 					 PCIE_LINK_STATE_CLKPM,
-					 false, true);
+					 false);
 	}
 }
 

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-18 17:37     ` [PATCH] PCI: Remove not needed check in disable aspm link Yinghai Lu
@ 2013-03-27 22:56       ` Bjorn Helgaas
  2013-03-28  7:41         ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-03-27 22:56 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige, stable

On Mon, Mar 18, 2013 at 11:37 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> Roman reported ath5k does not work anymore on 3.8.
> Bisected to
> | commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
> | Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
> | Date:   Tue Oct 30 15:27:13 2012 +0900
> |
> |    PCI/ACPI: Request _OSC control before scanning PCI root bus
> |
> |    This patch moves up the code block to request _OSC control in order to
> |    separate ACPI work and PCI work in acpi_pci_root_add().
>
> It make pci_disable_link_state does not work anymore as acpi_disabled
> is set before pci root bus scanning.
> It will skip that in quirks and pcie_aspm_sanity_check.
>
> We could revert to old logic, but that will make booting path and hotplug
> path with different aspm_disabled again.
>
> Acctually we don't need to check aspm_disabled in disable link, as
> we already have protection about link state following.
>
> https://bugzilla.kernel.org/show_bug.cgi?id=55211
> http://article.gmane.org/gmane.linux.kernel.pci/20640
>
> Need it for 3.8 stable.
>
> Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
> Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
> Tested-by: Roman Yepishev <roman.yepishev@gmail.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
> Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
> Cc: stable@kernel.org
>
> ---
>  drivers/pci/pcie/aspm.c |   21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)
>
> Index: linux-2.6/drivers/pci/pcie/aspm.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pcie/aspm.c
> +++ linux-2.6/drivers/pci/pcie/aspm.c
> @@ -493,15 +493,6 @@ static int pcie_aspm_sanity_check(struct
>                         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
>                  */
> @@ -718,15 +709,11 @@ void pcie_aspm_powersave_config_link(str
>   * pci_disable_link_state - disable pci device's link state, so the link will
>   * never enter specific states
>   */
> -static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
> -                                    bool force)
> +static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
>  {
>         struct pci_dev *parent = pdev->bus->self;
>         struct pcie_link_state *link;
>
> -       if (aspm_disabled && !force)
> -               return;
> -
>         if (!pci_is_pcie(pdev))
>                 return;
>
> @@ -757,13 +744,13 @@ static void __pci_disable_link_state(str
>
>  void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
>  {
> -       __pci_disable_link_state(pdev, state, false, false);
> +       __pci_disable_link_state(pdev, state, false);
>  }
>  EXPORT_SYMBOL(pci_disable_link_state_locked);
>
>  void pci_disable_link_state(struct pci_dev *pdev, int state)
>  {
> -       __pci_disable_link_state(pdev, state, true, false);
> +       __pci_disable_link_state(pdev, state, true);
>  }
>  EXPORT_SYMBOL(pci_disable_link_state);
>
> @@ -781,7 +768,7 @@ void pcie_clear_aspm(struct pci_bus *bus
>                 __pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
>                                          PCIE_LINK_STATE_L1 |
>                                          PCIE_LINK_STATE_CLKPM,
> -                                        false, true);
> +                                        false);
>         }
>  }
>

This might fix the problem, but the code is still a mess.  In
acpi_pci_root_add(), why do we have the following?

    acpi_pci_root_add

      acpi_pci_osc_support
      if (flags != base_flags)
        pcie_no_aspm
      if (...)
        acpi_pci_osc_control_set
        if (ACPI_SUCCESS)
          is_osc_granted = true

      pci_acpi_scan_root

      if (is_osc_granted)
        if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
          pcie_clear_aspm
      else
        pcie_no_aspm

Why can't we set all the ASPM flags *first*, before calling
pci_acpi_scan_root()?  That way we could just do the correct ASPM
setup as we discover devices during enumeration, rather than trying to
fix things up afterwards.  I suspect pcie_clear_aspm() is broken
anyway, because it looks like it only touches one level of the
hierarchy, without recursively descending it.

But Taku went to some trouble in 8c33f51d to introduce is_osc_granted
to remember this until after pci_acpi_scan_root(), so presumably
there's some reason for this.  Do you remember why, Taku?

Bjorn

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-27 22:56       ` Bjorn Helgaas
@ 2013-03-28  7:41         ` Yinghai Lu
  2013-03-28 12:46           ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-28  7:41 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige, stable

On Wed, Mar 27, 2013 at 3:56 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>
> Why can't we set all the ASPM flags *first*, before calling
> pci_acpi_scan_root()?  That way we could just do the correct ASPM
> setup as we discover devices during enumeration, rather than trying to
> fix things up afterwards.  I suspect pcie_clear_aspm() is broken
> anyway, because it looks like it only touches one level of the
> hierarchy, without recursively descending it.

Yes, we can clean up aspm stop/clear up.
and that should be for 3.10 right?

But this patch should be safe for 3.9 and stable.

Thanks

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-28  7:41         ` Yinghai Lu
@ 2013-03-28 12:46           ` Bjorn Helgaas
  2013-03-28 20:21             ` Yinghai Lu
  2013-03-28 20:24             ` Yinghai Lu
  0 siblings, 2 replies; 38+ messages in thread
From: Bjorn Helgaas @ 2013-03-28 12:46 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige, stable

On Thu, Mar 28, 2013 at 1:41 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Wed, Mar 27, 2013 at 3:56 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>
>> Why can't we set all the ASPM flags *first*, before calling
>> pci_acpi_scan_root()?  That way we could just do the correct ASPM
>> setup as we discover devices during enumeration, rather than trying to
>> fix things up afterwards.  I suspect pcie_clear_aspm() is broken
>> anyway, because it looks like it only touches one level of the
>> hierarchy, without recursively descending it.
>
> Yes, we can clean up aspm stop/clear up.
> and that should be for 3.10 right?
>
> But this patch should be safe for 3.9 and stable.

This patch might be *safe*, but it (and the changelog) are completely
unintelligible.

The problem with applying an unintelligible stop-gap patch is that it
becomes forever part of the changelog, and it's a huge waste of time
to everybody who tries to understand the history later.  That's why I
think it's worth spending some time to make a good patch now.

Bjorn

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-28 12:46           ` Bjorn Helgaas
@ 2013-03-28 20:21             ` Yinghai Lu
  2013-03-28 20:24             ` Yinghai Lu
  1 sibling, 0 replies; 38+ messages in thread
From: Yinghai Lu @ 2013-03-28 20:21 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige, stable

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

On Thu, Mar 28, 2013 at 5:46 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:

> This patch might be *safe*, but it (and the changelog) are completely
> unintelligible.
>
> The problem with applying an unintelligible stop-gap patch is that it
> becomes forever part of the changelog, and it's a huge waste of time
> to everybody who tries to understand the history later.  That's why I
> think it's worth spending some time to make a good patch now.

Ok, Please check if attached is doing what you want.

Thanks

Yinghai

[-- Attachment #2: disable_aspm.patch --]
[-- Type: application/octet-stream, Size: 8303 bytes --]

Subject: [PATCH] PCI: Remove not needed check in disable aspm link

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pci_disable_link_state does not work anymore as acpi_disabled
is set before pci root bus scanning.
It will skip that in quirks and pcie_aspm_sanity_check.

We could revert to old logic, but that will make booting path and hotplug
path with different aspm_disabled again.

Acctually we don't need to check aspm_disabled in disable link, as
we already have protection about link state following.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Need it for 3.8 stable.

-v2: more cleanup
	1. remove aspm_support_enabled, as if it compiled in, support is there
		so even user pass aspm=off, link_state still get allocated,
		then we will have chance to disable aspm on devices from
		buggy setting of BIOS.
	2. move pcie_no_aspm() calling for fadt disabling before scanning
		requested by Bjorn.

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

---
 drivers/acpi/pci_root.c  |   25 +++++++++---------------
 drivers/pci/pcie/aspm.c  |   48 ++---------------------------------------------
 include/linux/pci-aspm.h |    4 ---
 include/linux/pci.h      |    2 -
 4 files changed, 14 insertions(+), 65 deletions(-)

Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -415,7 +415,6 @@ static int acpi_pci_root_add(struct acpi
 	struct acpi_pci_root *root;
 	struct acpi_pci_driver *driver;
 	u32 flags, base_flags;
-	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -494,6 +493,11 @@ static int acpi_pci_root_add(struct acpi
 			flags = base_flags;
 		}
 	}
+
+	/* ASPM setting */
+	if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+		pcie_no_aspm();
+
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -513,16 +517,17 @@ static int acpi_pci_root_add(struct acpi
 
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
-		if (ACPI_SUCCESS(status)) {
-			is_osc_granted = true;
+		if (ACPI_SUCCESS(status))
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
-		} else {
-			is_osc_granted = false;
+		else {
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
+			pr_info("ACPI _OSC control for PCIe not granted, "
+				"disabling ASPM\n");
+			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
@@ -554,16 +559,6 @@ static int acpi_pci_root_add(struct acpi
 		goto out_del_root;
 	}
 
-	/* ASPM setting */
-	if (is_osc_granted) {
-		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
-			pcie_clear_aspm(root->bus);
-	} else {
-		pr_info("ACPI _OSC control for PCIe not granted, "
-			"disabling ASPM\n");
-		pcie_no_aspm();
-	}
-
 	pci_acpi_add_bus_pm_notifier(device, root->bus);
 	if (device->wakeup.flags.run_wake)
 		device_set_run_wake(root->bus->bridge, true);
Index: linux-2.6/drivers/pci/pcie/aspm.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/aspm.c
+++ linux-2.6/drivers/pci/pcie/aspm.c
@@ -69,7 +69,6 @@ struct pcie_link_state {
 };
 
 static int aspm_disabled, aspm_force;
-static bool aspm_support_enabled = true;
 static DEFINE_MUTEX(aspm_lock);
 static LIST_HEAD(link_list);
 
@@ -493,15 +492,6 @@ static int pcie_aspm_sanity_check(struct
 			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
 		 */
@@ -556,9 +546,6 @@ void pcie_aspm_init_link_state(struct pc
 	struct pcie_link_state *link;
 	int blacklist = !!pcie_aspm_sanity_check(pdev);
 
-	if (!aspm_support_enabled)
-		return;
-
 	if (!pci_is_pcie(pdev) || pdev->link_state)
 		return;
 	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
@@ -718,15 +705,11 @@ void pcie_aspm_powersave_config_link(str
  * pci_disable_link_state - disable pci device's link state, so the link will
  * never enter specific states
  */
-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
-				     bool force)
+static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 {
 	struct pci_dev *parent = pdev->bus->self;
 	struct pcie_link_state *link;
 
-	if (aspm_disabled && !force)
-		return;
-
 	if (!pci_is_pcie(pdev))
 		return;
 
@@ -757,34 +740,16 @@ static void __pci_disable_link_state(str
 
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, false, false);
+	__pci_disable_link_state(pdev, state, false);
 }
 EXPORT_SYMBOL(pci_disable_link_state_locked);
 
 void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, true, false);
+	__pci_disable_link_state(pdev, state, true);
 }
 EXPORT_SYMBOL(pci_disable_link_state);
 
-void pcie_clear_aspm(struct pci_bus *bus)
-{
-	struct pci_dev *child;
-
-	if (aspm_force)
-		return;
-
-	/*
-	 * Clear any ASPM setup that the firmware has carried out on this bus
-	 */
-	list_for_each_entry(child, &bus->devices, bus_list) {
-		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
-					 PCIE_LINK_STATE_L1 |
-					 PCIE_LINK_STATE_CLKPM,
-					 false, true);
-	}
-}
-
 static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
 {
 	int i;
@@ -944,7 +909,6 @@ static int __init pcie_aspm_disable(char
 	if (!strcmp(str, "off")) {
 		aspm_policy = POLICY_DEFAULT;
 		aspm_disabled = 1;
-		aspm_support_enabled = false;
 		printk(KERN_INFO "PCIe ASPM is disabled\n");
 	} else if (!strcmp(str, "force")) {
 		aspm_force = 1;
@@ -980,9 +944,3 @@ int pcie_aspm_enabled(void)
        return !aspm_disabled;
 }
 EXPORT_SYMBOL(pcie_aspm_enabled);
-
-bool pcie_aspm_support_enabled(void)
-{
-	return aspm_support_enabled;
-}
-EXPORT_SYMBOL(pcie_aspm_support_enabled);
Index: linux-2.6/include/linux/pci-aspm.h
===================================================================
--- linux-2.6.orig/include/linux/pci-aspm.h
+++ linux-2.6/include/linux/pci-aspm.h
@@ -29,7 +29,6 @@ extern void pcie_aspm_pm_state_change(st
 extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
 extern void pci_disable_link_state(struct pci_dev *pdev, int state);
 extern void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
-extern void pcie_clear_aspm(struct pci_bus *bus);
 extern void pcie_no_aspm(void);
 #else
 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
@@ -47,9 +46,6 @@ static inline void pcie_aspm_powersave_c
 static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
 }
-static inline void pcie_clear_aspm(struct pci_bus *bus)
-{
-}
 static inline void pcie_no_aspm(void)
 {
 }
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1168,7 +1168,7 @@ static inline int pcie_aspm_enabled(void
 static inline bool pcie_aspm_support_enabled(void) { return false; }
 #else
 extern int pcie_aspm_enabled(void);
-extern bool pcie_aspm_support_enabled(void);
+static inline bool pcie_aspm_support_enabled(void) { return true; }
 #endif
 
 #ifdef CONFIG_PCIEAER

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-28 12:46           ` Bjorn Helgaas
  2013-03-28 20:21             ` Yinghai Lu
@ 2013-03-28 20:24             ` Yinghai Lu
  2013-03-28 20:24               ` Yinghai Lu
  1 sibling, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-28 20:24 UTC (permalink / raw)
  To: Bjorn Helgaas, Roman Yepishev
  Cc: Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige

resending with adding To Roman.

On Thu, Mar 28, 2013 at 5:46 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> This patch might be *safe*, but it (and the changelog) are completely
> unintelligible.
>
> The problem with applying an unintelligible stop-gap patch is that it
> becomes forever part of the changelog, and it's a huge waste of time
> to everybody who tries to understand the history later.  That's why I
> think it's worth spending some time to make a good patch now.

Please check if attached patch is doing what you want.

Thanks

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-28 20:24             ` Yinghai Lu
@ 2013-03-28 20:24               ` Yinghai Lu
  2013-03-29  3:22                 ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-28 20:24 UTC (permalink / raw)
  To: Bjorn Helgaas, Roman Yepishev
  Cc: Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

patch for Roman

On Thu, Mar 28, 2013 at 1:24 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> resending with adding To Roman.
>
> On Thu, Mar 28, 2013 at 5:46 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> This patch might be *safe*, but it (and the changelog) are completely
>> unintelligible.
>>
>> The problem with applying an unintelligible stop-gap patch is that it
>> becomes forever part of the changelog, and it's a huge waste of time
>> to everybody who tries to understand the history later.  That's why I
>> think it's worth spending some time to make a good patch now.
>
> Please check if attached patch is doing what you want.
>
> Thanks
>
> Yinghai

[-- Attachment #2: disable_aspm.patch --]
[-- Type: application/octet-stream, Size: 8303 bytes --]

Subject: [PATCH] PCI: Remove not needed check in disable aspm link

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pci_disable_link_state does not work anymore as acpi_disabled
is set before pci root bus scanning.
It will skip that in quirks and pcie_aspm_sanity_check.

We could revert to old logic, but that will make booting path and hotplug
path with different aspm_disabled again.

Acctually we don't need to check aspm_disabled in disable link, as
we already have protection about link state following.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Need it for 3.8 stable.

-v2: more cleanup
	1. remove aspm_support_enabled, as if it compiled in, support is there
		so even user pass aspm=off, link_state still get allocated,
		then we will have chance to disable aspm on devices from
		buggy setting of BIOS.
	2. move pcie_no_aspm() calling for fadt disabling before scanning
		requested by Bjorn.

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

---
 drivers/acpi/pci_root.c  |   25 +++++++++---------------
 drivers/pci/pcie/aspm.c  |   48 ++---------------------------------------------
 include/linux/pci-aspm.h |    4 ---
 include/linux/pci.h      |    2 -
 4 files changed, 14 insertions(+), 65 deletions(-)

Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -415,7 +415,6 @@ static int acpi_pci_root_add(struct acpi
 	struct acpi_pci_root *root;
 	struct acpi_pci_driver *driver;
 	u32 flags, base_flags;
-	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -494,6 +493,11 @@ static int acpi_pci_root_add(struct acpi
 			flags = base_flags;
 		}
 	}
+
+	/* ASPM setting */
+	if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+		pcie_no_aspm();
+
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -513,16 +517,17 @@ static int acpi_pci_root_add(struct acpi
 
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
-		if (ACPI_SUCCESS(status)) {
-			is_osc_granted = true;
+		if (ACPI_SUCCESS(status))
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
-		} else {
-			is_osc_granted = false;
+		else {
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
+			pr_info("ACPI _OSC control for PCIe not granted, "
+				"disabling ASPM\n");
+			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
@@ -554,16 +559,6 @@ static int acpi_pci_root_add(struct acpi
 		goto out_del_root;
 	}
 
-	/* ASPM setting */
-	if (is_osc_granted) {
-		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
-			pcie_clear_aspm(root->bus);
-	} else {
-		pr_info("ACPI _OSC control for PCIe not granted, "
-			"disabling ASPM\n");
-		pcie_no_aspm();
-	}
-
 	pci_acpi_add_bus_pm_notifier(device, root->bus);
 	if (device->wakeup.flags.run_wake)
 		device_set_run_wake(root->bus->bridge, true);
Index: linux-2.6/drivers/pci/pcie/aspm.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/aspm.c
+++ linux-2.6/drivers/pci/pcie/aspm.c
@@ -69,7 +69,6 @@ struct pcie_link_state {
 };
 
 static int aspm_disabled, aspm_force;
-static bool aspm_support_enabled = true;
 static DEFINE_MUTEX(aspm_lock);
 static LIST_HEAD(link_list);
 
@@ -493,15 +492,6 @@ static int pcie_aspm_sanity_check(struct
 			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
 		 */
@@ -556,9 +546,6 @@ void pcie_aspm_init_link_state(struct pc
 	struct pcie_link_state *link;
 	int blacklist = !!pcie_aspm_sanity_check(pdev);
 
-	if (!aspm_support_enabled)
-		return;
-
 	if (!pci_is_pcie(pdev) || pdev->link_state)
 		return;
 	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
@@ -718,15 +705,11 @@ void pcie_aspm_powersave_config_link(str
  * pci_disable_link_state - disable pci device's link state, so the link will
  * never enter specific states
  */
-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
-				     bool force)
+static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 {
 	struct pci_dev *parent = pdev->bus->self;
 	struct pcie_link_state *link;
 
-	if (aspm_disabled && !force)
-		return;
-
 	if (!pci_is_pcie(pdev))
 		return;
 
@@ -757,34 +740,16 @@ static void __pci_disable_link_state(str
 
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, false, false);
+	__pci_disable_link_state(pdev, state, false);
 }
 EXPORT_SYMBOL(pci_disable_link_state_locked);
 
 void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, true, false);
+	__pci_disable_link_state(pdev, state, true);
 }
 EXPORT_SYMBOL(pci_disable_link_state);
 
-void pcie_clear_aspm(struct pci_bus *bus)
-{
-	struct pci_dev *child;
-
-	if (aspm_force)
-		return;
-
-	/*
-	 * Clear any ASPM setup that the firmware has carried out on this bus
-	 */
-	list_for_each_entry(child, &bus->devices, bus_list) {
-		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
-					 PCIE_LINK_STATE_L1 |
-					 PCIE_LINK_STATE_CLKPM,
-					 false, true);
-	}
-}
-
 static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
 {
 	int i;
@@ -944,7 +909,6 @@ static int __init pcie_aspm_disable(char
 	if (!strcmp(str, "off")) {
 		aspm_policy = POLICY_DEFAULT;
 		aspm_disabled = 1;
-		aspm_support_enabled = false;
 		printk(KERN_INFO "PCIe ASPM is disabled\n");
 	} else if (!strcmp(str, "force")) {
 		aspm_force = 1;
@@ -980,9 +944,3 @@ int pcie_aspm_enabled(void)
        return !aspm_disabled;
 }
 EXPORT_SYMBOL(pcie_aspm_enabled);
-
-bool pcie_aspm_support_enabled(void)
-{
-	return aspm_support_enabled;
-}
-EXPORT_SYMBOL(pcie_aspm_support_enabled);
Index: linux-2.6/include/linux/pci-aspm.h
===================================================================
--- linux-2.6.orig/include/linux/pci-aspm.h
+++ linux-2.6/include/linux/pci-aspm.h
@@ -29,7 +29,6 @@ extern void pcie_aspm_pm_state_change(st
 extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
 extern void pci_disable_link_state(struct pci_dev *pdev, int state);
 extern void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
-extern void pcie_clear_aspm(struct pci_bus *bus);
 extern void pcie_no_aspm(void);
 #else
 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
@@ -47,9 +46,6 @@ static inline void pcie_aspm_powersave_c
 static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
 }
-static inline void pcie_clear_aspm(struct pci_bus *bus)
-{
-}
 static inline void pcie_no_aspm(void)
 {
 }
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1168,7 +1168,7 @@ static inline int pcie_aspm_enabled(void
 static inline bool pcie_aspm_support_enabled(void) { return false; }
 #else
 extern int pcie_aspm_enabled(void);
-extern bool pcie_aspm_support_enabled(void);
+static inline bool pcie_aspm_support_enabled(void) { return true; }
 #endif
 
 #ifdef CONFIG_PCIEAER

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-28 20:24               ` Yinghai Lu
@ 2013-03-29  3:22                 ` Bjorn Helgaas
       [not found]                   ` <CAE9FiQVu5QyxaKsYzzQoroQD=TvsziHzDOtoeg=FvhZ8HyN5yw@mail.gmail.com>
  2013-03-29 18:11                   ` Roman Yepishev
  0 siblings, 2 replies; 38+ messages in thread
From: Bjorn Helgaas @ 2013-03-29  3:22 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

[+cc Matthew]
[+cc e1000-devel@lists.sourceforge.net for suspected 82575/82598 regression]

On Thu, Mar 28, 2013 at 01:24:55PM -0700, Yinghai Lu wrote:
> patch for Roman
> 
> On Thu, Mar 28, 2013 at 1:24 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> > resending with adding To Roman.
> >
> > On Thu, Mar 28, 2013 at 5:46 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >> This patch might be *safe*, but it (and the changelog) are completely
> >> unintelligible.
> >>
> >> The problem with applying an unintelligible stop-gap patch is that it
> >> becomes forever part of the changelog, and it's a huge waste of time
> >> to everybody who tries to understand the history later.  That's why I
> >> think it's worth spending some time to make a good patch now.
> >
> > Please check if attached patch is doing what you want.

Patch inlined below for convenience.

> Subject: [PATCH] PCI: Remove not needed check in disable aspm link
> 
> Roman reported ath5k does not work anymore on 3.8.
> Bisected to
> | commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
> | Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
> | Date:   Tue Oct 30 15:27:13 2012 +0900
> |
> |    PCI/ACPI: Request _OSC control before scanning PCI root bus
> |
> |    This patch moves up the code block to request _OSC control in order to
> |    separate ACPI work and PCI work in acpi_pci_root_add().
> 
> It make pci_disable_link_state does not work anymore as acpi_disabled
> is set before pci root bus scanning.
> It will skip that in quirks and pcie_aspm_sanity_check.

I think this regression has nothing to do with pci_disable_link_state().

When aspm_disabled is set, pci_disable_link_state() doesn't do anything.

In both 3.7 and 3.8, aspm_disabled is set in acpi_pci_root_add() before
any driver probe routines are run, so it looks like calling
pci_disable_link_state() from a driver had no effect even in 3.7.  This
is a problem, of course, but not the one Roman is seeing, because ath5k
calls pci_disable_link_state() from the driver probe routine.

There are also PCI_FIXUP_FINAL quirks for 82575 and 82598 NICs that call
pci_disable_link_state().  In 3.7, these quirks are run before
aspm_disabled is set, but 8c33f51d moved the pcie_no_aspm() call up
before we start scanning the bus, so in 3.8, aspm_disabled is set
*before* we run them.  I think that means 8c33f51d broke all these
quirks.  That's also a problem, of course, but this isn't the one Roman
is seeing either.

I think the problem Roman is seeing happens when
pcie_aspm_init_link_state() calls pcie_aspm_sanity_check() during device
enumeration.  In 3.8, the fact that aspm_disabled is already set by the
time we get here means we skip the check for pre-1.1 PCIe devices, and
I think *this* is what Roman is seeing.

I suspect the following hunk of your patch is enough to fix things for
Roman:

> --- linux-2.6.orig/drivers/pci/pcie/aspm.c
> +++ linux-2.6/drivers/pci/pcie/aspm.c
> @@ -493,15 +492,6 @@ static int pcie_aspm_sanity_check(struct
>  			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
>  		 */

However, this test was added by Matthew in c9651e70, and I can't remove
it unless we have an explanation of why removing it will not reintroduce
the bug he was fixing.

This code is such a terrible mess that it's not surprising at all that
we have all these issues.  But there's too much to untangle in v3.9; all
we can hope for is to fix the regressions in v3.9 and clean it up later.

> We could revert to old logic, but that will make booting path and hotplug
> path with different aspm_disabled again.
> 
> Acctually we don't need to check aspm_disabled in disable link, as
> we already have protection about link state following.
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=55211
> http://article.gmane.org/gmane.linux.kernel.pci/20640
> 
> Need it for 3.8 stable.
> 
> -v2: more cleanup
> 	1. remove aspm_support_enabled, as if it compiled in, support is there
> 		so even user pass aspm=off, link_state still get allocated,
> 		then we will have chance to disable aspm on devices from
> 		buggy setting of BIOS.
> 	2. move pcie_no_aspm() calling for fadt disabling before scanning
> 		requested by Bjorn.
> 
> Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
> Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
> Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
> 
> ---
>  drivers/acpi/pci_root.c  |   25 +++++++++---------------
>  drivers/pci/pcie/aspm.c  |   48 ++---------------------------------------------
>  include/linux/pci-aspm.h |    4 ---
>  include/linux/pci.h      |    2 -
>  4 files changed, 14 insertions(+), 65 deletions(-)
> 
> Index: linux-2.6/drivers/acpi/pci_root.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/pci_root.c
> +++ linux-2.6/drivers/acpi/pci_root.c
> @@ -415,7 +415,6 @@ static int acpi_pci_root_add(struct acpi
>  	struct acpi_pci_root *root;
>  	struct acpi_pci_driver *driver;
>  	u32 flags, base_flags;
> -	bool is_osc_granted = false;
>  
>  	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
>  	if (!root)
> @@ -494,6 +493,11 @@ static int acpi_pci_root_add(struct acpi
>  			flags = base_flags;
>  		}
>  	}
> +
> +	/* ASPM setting */
> +	if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
> +		pcie_no_aspm();
> +
>  	if (!pcie_ports_disabled
>  	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
>  		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
> @@ -513,16 +517,17 @@ static int acpi_pci_root_add(struct acpi
>  
>  		status = acpi_pci_osc_control_set(device->handle, &flags,
>  				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
> -		if (ACPI_SUCCESS(status)) {
> -			is_osc_granted = true;
> +		if (ACPI_SUCCESS(status))
>  			dev_info(&device->dev,
>  				"ACPI _OSC control (0x%02x) granted\n", flags);
> -		} else {
> -			is_osc_granted = false;
> +		else {
>  			dev_info(&device->dev,
>  				"ACPI _OSC request failed (%s), "
>  				"returned control mask: 0x%02x\n",
>  				acpi_format_exception(status), flags);
> +			pr_info("ACPI _OSC control for PCIe not granted, "
> +				"disabling ASPM\n");
> +			pcie_no_aspm();
>  		}
>  	} else {
>  		dev_info(&device->dev,
> @@ -554,16 +559,6 @@ static int acpi_pci_root_add(struct acpi
>  		goto out_del_root;
>  	}
>  
> -	/* ASPM setting */
> -	if (is_osc_granted) {
> -		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
> -			pcie_clear_aspm(root->bus);
> -	} else {
> -		pr_info("ACPI _OSC control for PCIe not granted, "
> -			"disabling ASPM\n");
> -		pcie_no_aspm();
> -	}
> -
>  	pci_acpi_add_bus_pm_notifier(device, root->bus);
>  	if (device->wakeup.flags.run_wake)
>  		device_set_run_wake(root->bus->bridge, true);
> Index: linux-2.6/drivers/pci/pcie/aspm.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pcie/aspm.c
> +++ linux-2.6/drivers/pci/pcie/aspm.c
> @@ -69,7 +69,6 @@ struct pcie_link_state {
>  };
>  
>  static int aspm_disabled, aspm_force;
> -static bool aspm_support_enabled = true;
>  static DEFINE_MUTEX(aspm_lock);
>  static LIST_HEAD(link_list);
>  
> @@ -493,15 +492,6 @@ static int pcie_aspm_sanity_check(struct
>  			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
>  		 */
> @@ -556,9 +546,6 @@ void pcie_aspm_init_link_state(struct pc
>  	struct pcie_link_state *link;
>  	int blacklist = !!pcie_aspm_sanity_check(pdev);
>  
> -	if (!aspm_support_enabled)
> -		return;
> -
>  	if (!pci_is_pcie(pdev) || pdev->link_state)
>  		return;
>  	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
> @@ -718,15 +705,11 @@ void pcie_aspm_powersave_config_link(str
>   * pci_disable_link_state - disable pci device's link state, so the link will
>   * never enter specific states
>   */
> -static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
> -				     bool force)
> +static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
>  {
>  	struct pci_dev *parent = pdev->bus->self;
>  	struct pcie_link_state *link;
>  
> -	if (aspm_disabled && !force)
> -		return;
> -
>  	if (!pci_is_pcie(pdev))
>  		return;
>  
> @@ -757,34 +740,16 @@ static void __pci_disable_link_state(str
>  
>  void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
>  {
> -	__pci_disable_link_state(pdev, state, false, false);
> +	__pci_disable_link_state(pdev, state, false);
>  }
>  EXPORT_SYMBOL(pci_disable_link_state_locked);
>  
>  void pci_disable_link_state(struct pci_dev *pdev, int state)
>  {
> -	__pci_disable_link_state(pdev, state, true, false);
> +	__pci_disable_link_state(pdev, state, true);
>  }
>  EXPORT_SYMBOL(pci_disable_link_state);
>  
> -void pcie_clear_aspm(struct pci_bus *bus)
> -{
> -	struct pci_dev *child;
> -
> -	if (aspm_force)
> -		return;
> -
> -	/*
> -	 * Clear any ASPM setup that the firmware has carried out on this bus
> -	 */
> -	list_for_each_entry(child, &bus->devices, bus_list) {
> -		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
> -					 PCIE_LINK_STATE_L1 |
> -					 PCIE_LINK_STATE_CLKPM,
> -					 false, true);
> -	}
> -}
> -
>  static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
>  {
>  	int i;
> @@ -944,7 +909,6 @@ static int __init pcie_aspm_disable(char
>  	if (!strcmp(str, "off")) {
>  		aspm_policy = POLICY_DEFAULT;
>  		aspm_disabled = 1;
> -		aspm_support_enabled = false;
>  		printk(KERN_INFO "PCIe ASPM is disabled\n");
>  	} else if (!strcmp(str, "force")) {
>  		aspm_force = 1;
> @@ -980,9 +944,3 @@ int pcie_aspm_enabled(void)
>         return !aspm_disabled;
>  }
>  EXPORT_SYMBOL(pcie_aspm_enabled);
> -
> -bool pcie_aspm_support_enabled(void)
> -{
> -	return aspm_support_enabled;
> -}
> -EXPORT_SYMBOL(pcie_aspm_support_enabled);
> Index: linux-2.6/include/linux/pci-aspm.h
> ===================================================================
> --- linux-2.6.orig/include/linux/pci-aspm.h
> +++ linux-2.6/include/linux/pci-aspm.h
> @@ -29,7 +29,6 @@ extern void pcie_aspm_pm_state_change(st
>  extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
>  extern void pci_disable_link_state(struct pci_dev *pdev, int state);
>  extern void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
> -extern void pcie_clear_aspm(struct pci_bus *bus);
>  extern void pcie_no_aspm(void);
>  #else
>  static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
> @@ -47,9 +46,6 @@ static inline void pcie_aspm_powersave_c
>  static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
>  {
>  }
> -static inline void pcie_clear_aspm(struct pci_bus *bus)
> -{
> -}
>  static inline void pcie_no_aspm(void)
>  {
>  }
> Index: linux-2.6/include/linux/pci.h
> ===================================================================
> --- linux-2.6.orig/include/linux/pci.h
> +++ linux-2.6/include/linux/pci.h
> @@ -1168,7 +1168,7 @@ static inline int pcie_aspm_enabled(void
>  static inline bool pcie_aspm_support_enabled(void) { return false; }
>  #else
>  extern int pcie_aspm_enabled(void);
> -extern bool pcie_aspm_support_enabled(void);
> +static inline bool pcie_aspm_support_enabled(void) { return true; }
>  #endif
>  
>  #ifdef CONFIG_PCIEAER

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
       [not found]                   ` <CAE9FiQVu5QyxaKsYzzQoroQD=TvsziHzDOtoeg=FvhZ8HyN5yw@mail.gmail.com>
@ 2013-03-29 12:24                     ` Bjorn Helgaas
  2013-03-29 18:02                       ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-03-29 12:24 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Thu, Mar 28, 2013 at 11:59 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>
> On Thu, Mar 28, 2013 at 8:22 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>
>> [+cc Matthew]
>> [+cc e1000-devel@lists.sourceforge.net for suspected 82575/82598
>> regression]
>>
>> On Thu, Mar 28, 2013 at 01:24:55PM -0700, Yinghai Lu wrote:
>> > patch for Roman
>> >
>> > On Thu, Mar 28, 2013 at 1:24 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>> > > resending with adding To Roman.
>> > >
>> > > On Thu, Mar 28, 2013 at 5:46 AM, Bjorn Helgaas <bhelgaas@google.com>
>> > > wrote:
>> > >> This patch might be *safe*, but it (and the changelog) are completely
>> > >> unintelligible.
>> > >>
>> > >> The problem with applying an unintelligible stop-gap patch is that it
>> > >> becomes forever part of the changelog, and it's a huge waste of time
>> > >> to everybody who tries to understand the history later.  That's why I
>> > >> think it's worth spending some time to make a good patch now.
>> > >
>> > > Please check if attached patch is doing what you want.
>>
>> Patch inlined below for convenience.
>>
>> > Subject: [PATCH] PCI: Remove not needed check in disable aspm link
>> >
>> > Roman reported ath5k does not work anymore on 3.8.
>> > Bisected to
>> > | commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
>> > | Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
>> > | Date:   Tue Oct 30 15:27:13 2012 +0900
>> > |
>> > |    PCI/ACPI: Request _OSC control before scanning PCI root bus
>> > |
>> > |    This patch moves up the code block to request _OSC control in order
>> > to
>> > |    separate ACPI work and PCI work in acpi_pci_root_add().
>> >
>> > It make pci_disable_link_state does not work anymore as acpi_disabled
>> > is set before pci root bus scanning.
>> > It will skip that in quirks and pcie_aspm_sanity_check.
>>
>> I think this regression has nothing to do with pci_disable_link_state().
>>
>> When aspm_disabled is set, pci_disable_link_state() doesn't do anything.
>>
>> In both 3.7 and 3.8, aspm_disabled is set in acpi_pci_root_add() before
>> any driver probe routines are run, so it looks like calling
>> pci_disable_link_state() from a driver had no effect even in 3.7.  This
>> is a problem, of course, but not the one Roman is seeing, because ath5k
>> calls pci_disable_link_state() from the driver probe routine.
>>
>> There are also PCI_FIXUP_FINAL quirks for 82575 and 82598 NICs that call
>> pci_disable_link_state().  In 3.7, these quirks are run before
>> aspm_disabled is set, but 8c33f51d moved the pcie_no_aspm() call up
>> before we start scanning the bus, so in 3.8, aspm_disabled is set
>> *before* we run them.  I think that means 8c33f51d broke all these
>> quirks.  That's also a problem, of course, but this isn't the one Roman
>> is seeing either.
>>
>> I think the problem Roman is seeing happens when
>> pcie_aspm_init_link_state() calls pcie_aspm_sanity_check() during device
>> enumeration.  In 3.8, the fact that aspm_disabled is already set by the
>> time we get here means we skip the check for pre-1.1 PCIe devices, and
>> I think *this* is what Roman is seeing.
>>
>> I suspect the following hunk of your patch is enough to fix things for
>> Roman:
>>
>> > --- linux-2.6.orig/drivers/pci/pcie/aspm.c
>> > +++ linux-2.6/drivers/pci/pcie/aspm.c
>> > @@ -493,15 +492,6 @@ static int pcie_aspm_sanity_check(struct
>> >                       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
>> >                */
>>
>> However, this test was added by Matthew in c9651e70, and I can't remove
>> it unless we have an explanation of why removing it will not reintroduce
>> the bug he was fixing.
>>
>> This code is such a terrible mess that it's not surprising at all that
>> we have all these issues.  But there's too much to untangle in v3.9; all
>> we can hope for is to fix the regressions in v3.9 and clean it up later.
>
>
> v1 will fix quirks and pcie_aspm_sanity_check path.
> v2. will go further even user pass "aspm=off", those quirks and disable aspm
> in driver
> will still work, and also call pcie_no_aspm for disable aspm for FADT path
> early.
>
> So now you want half of v1, and not want to fix quirk path.
> Is my understanding right?

What I want is a patch that fixes the regression and doesn't break
anything else, along with a changelog that makes it obvious that we're
doing the right thing.  I don't know what that looks like yet.  None
of your patches so far is even close.

Half of your v1 patch (removing the pcie_aspm_sanity_check() test)
*might* be the right thing, but only if you can clearly explain why
that will not reintroduce the bug Matthew fixed with c9651e70.

I think we also need to fix the PCI_FIXUP_FINAL quirk regression, but
that's a separate issue and should be a separate patch.

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-29 12:24                     ` Bjorn Helgaas
@ 2013-03-29 18:02                       ` Yinghai Lu
  2013-03-29 18:04                         ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-29 18:02 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Fri, Mar 29, 2013 at 5:24 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>
> Half of your v1 patch (removing the pcie_aspm_sanity_check() test)
> *might* be the right thing, but only if you can clearly explain why
> that will not reintroduce the bug Matthew fixed with c9651e70.
>
> I think we also need to fix the PCI_FIXUP_FINAL quirk regression, but
> that's a separate issue and should be a separate patch.


First commit from Matthew
 0ae5eaf10     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
    Right now we won't touch ASPM state if ASPM is disabled, except in the case
    where we find a device that appears to be too old to reliably support ASPM.
    Right now we'll clear it in that case, which is almost certainly the wrong
    thing to do

Try to not touch pre-1.1 ASPM for all, and it causes lots of regression.

So second commit

cdb0f9a1ad2e ASPM: Fix pcie devices with non-pcie children
    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.

move the check aspm_disabled down.

but ath5 and etc (pre-1.1) really need to aspm_disable to change their
hw setting.

So the right solution would be dropping pcie_aspm_sanity_check()
change -in v2 should make all both happy, as quirk and disable that in
driver for ath5 are calling
pcie_disable_aspm_state explicitly.

In v2, we already removed pcie_clear_aspm() that is calling
pcie_disable_aspm_state.


Please check attached -v3.


Thanks

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-29 18:02                       ` Yinghai Lu
@ 2013-03-29 18:04                         ` Yinghai Lu
  2013-04-01 23:52                           ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-03-29 18:04 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]

attatched -v3 again

On Fri, Mar 29, 2013 at 11:02 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Mar 29, 2013 at 5:24 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>
>> Half of your v1 patch (removing the pcie_aspm_sanity_check() test)
>> *might* be the right thing, but only if you can clearly explain why
>> that will not reintroduce the bug Matthew fixed with c9651e70.
>>
>> I think we also need to fix the PCI_FIXUP_FINAL quirk regression, but
>> that's a separate issue and should be a separate patch.
>
>
> First commit from Matthew
>  0ae5eaf10     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
>     Right now we won't touch ASPM state if ASPM is disabled, except in the case
>     where we find a device that appears to be too old to reliably support ASPM.
>     Right now we'll clear it in that case, which is almost certainly the wrong
>     thing to do
>
> Try to not touch pre-1.1 ASPM for all, and it causes lots of regression.
>
> So second commit
>
> cdb0f9a1ad2e ASPM: Fix pcie devices with non-pcie children
>     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.
>
> move the check aspm_disabled down.
>
> but ath5 and etc (pre-1.1) really need to aspm_disable to change their
> hw setting.
>
> So the right solution would be dropping pcie_aspm_sanity_check()
> change -in v2 should make all both happy, as quirk and disable that in
> driver for ath5 are calling
> pcie_disable_aspm_state explicitly.
>
> In v2, we already removed pcie_clear_aspm() that is calling
> pcie_disable_aspm_state.
>
>
> Please check attached -v3.
>
>
> Thanks
>
> Yinghai

[-- Attachment #2: disable_aspm_3.patch --]
[-- Type: application/octet-stream, Size: 8221 bytes --]

Subject: [PATCH] PCI: Remove not needed check in disable aspm link

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pcie_aspm_sanity_check does not work anymore as acpi_disabled
is set before pci root bus scanning.

We could revert to old logic, but that will make booting path and hotplug
path with different aspm_disabled again.

Acctually we don't need to check aspm_disabled in pci_disable_link_state,
as we already have protection about link state checking.
and pci_disable_link_state will be only called explicted for quirk
and driver.

That will keep the logic in pcie_aspm_sanity_check() in commits:
 0ae5eaf10     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
 cdb0f9a1a     ASPM: Fix pcie devices with non-pcie children
still working, AKA still not touch pre-1.1 ASPM device.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Need it for 3.8 stable.

-v2: more cleanup
	1. remove aspm_support_enabled, as if it compiled in, support is there
		so even user pass aspm=off, link_state still get allocated,
		then we will have chance to disable aspm on devices from
		buggy setting of BIOS.
	2. move pcie_no_aspm() calling for fadt disabling before scanning
		requested by Bjorn.
-v3: remove change in pcie_aspm_sanity_check()

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

---
 drivers/acpi/pci_root.c  |   25 +++++++++---------------
 drivers/pci/pcie/aspm.c  |   48 ++---------------------------------------------
 include/linux/pci-aspm.h |    4 ---
 include/linux/pci.h      |    2 -
 4 files changed, 14 insertions(+), 65 deletions(-)

Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -415,7 +415,6 @@ static int acpi_pci_root_add(struct acpi
 	struct acpi_pci_root *root;
 	struct acpi_pci_driver *driver;
 	u32 flags, base_flags;
-	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -494,6 +493,11 @@ static int acpi_pci_root_add(struct acpi
 			flags = base_flags;
 		}
 	}
+
+	/* ASPM setting */
+	if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+		pcie_no_aspm();
+
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -513,16 +517,17 @@ static int acpi_pci_root_add(struct acpi
 
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
-		if (ACPI_SUCCESS(status)) {
-			is_osc_granted = true;
+		if (ACPI_SUCCESS(status))
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
-		} else {
-			is_osc_granted = false;
+		else {
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
+			pr_info("ACPI _OSC control for PCIe not granted, "
+				"disabling ASPM\n");
+			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
@@ -554,16 +559,6 @@ static int acpi_pci_root_add(struct acpi
 		goto out_del_root;
 	}
 
-	/* ASPM setting */
-	if (is_osc_granted) {
-		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
-			pcie_clear_aspm(root->bus);
-	} else {
-		pr_info("ACPI _OSC control for PCIe not granted, "
-			"disabling ASPM\n");
-		pcie_no_aspm();
-	}
-
 	pci_acpi_add_bus_pm_notifier(device, root->bus);
 	if (device->wakeup.flags.run_wake)
 		device_set_run_wake(root->bus->bridge, true);
Index: linux-2.6/drivers/pci/pcie/aspm.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/aspm.c
+++ linux-2.6/drivers/pci/pcie/aspm.c
@@ -69,7 +69,6 @@ struct pcie_link_state {
 };
 
 static int aspm_disabled, aspm_force;
-static bool aspm_support_enabled = true;
 static DEFINE_MUTEX(aspm_lock);
 static LIST_HEAD(link_list);
 
@@ -556,9 +546,6 @@ void pcie_aspm_init_link_state(struct pc
 	struct pcie_link_state *link;
 	int blacklist = !!pcie_aspm_sanity_check(pdev);
 
-	if (!aspm_support_enabled)
-		return;
-
 	if (!pci_is_pcie(pdev) || pdev->link_state)
 		return;
 	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
@@ -718,15 +705,11 @@ void pcie_aspm_powersave_config_link(str
  * pci_disable_link_state - disable pci device's link state, so the link will
  * never enter specific states
  */
-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
-				     bool force)
+static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 {
 	struct pci_dev *parent = pdev->bus->self;
 	struct pcie_link_state *link;
 
-	if (aspm_disabled && !force)
-		return;
-
 	if (!pci_is_pcie(pdev))
 		return;
 
@@ -757,34 +740,16 @@ static void __pci_disable_link_state(str
 
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, false, false);
+	__pci_disable_link_state(pdev, state, false);
 }
 EXPORT_SYMBOL(pci_disable_link_state_locked);
 
 void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, true, false);
+	__pci_disable_link_state(pdev, state, true);
 }
 EXPORT_SYMBOL(pci_disable_link_state);
 
-void pcie_clear_aspm(struct pci_bus *bus)
-{
-	struct pci_dev *child;
-
-	if (aspm_force)
-		return;
-
-	/*
-	 * Clear any ASPM setup that the firmware has carried out on this bus
-	 */
-	list_for_each_entry(child, &bus->devices, bus_list) {
-		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
-					 PCIE_LINK_STATE_L1 |
-					 PCIE_LINK_STATE_CLKPM,
-					 false, true);
-	}
-}
-
 static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
 {
 	int i;
@@ -944,7 +909,6 @@ static int __init pcie_aspm_disable(char
 	if (!strcmp(str, "off")) {
 		aspm_policy = POLICY_DEFAULT;
 		aspm_disabled = 1;
-		aspm_support_enabled = false;
 		printk(KERN_INFO "PCIe ASPM is disabled\n");
 	} else if (!strcmp(str, "force")) {
 		aspm_force = 1;
@@ -980,9 +944,3 @@ int pcie_aspm_enabled(void)
        return !aspm_disabled;
 }
 EXPORT_SYMBOL(pcie_aspm_enabled);
-
-bool pcie_aspm_support_enabled(void)
-{
-	return aspm_support_enabled;
-}
-EXPORT_SYMBOL(pcie_aspm_support_enabled);
Index: linux-2.6/include/linux/pci-aspm.h
===================================================================
--- linux-2.6.orig/include/linux/pci-aspm.h
+++ linux-2.6/include/linux/pci-aspm.h
@@ -29,7 +29,6 @@ extern void pcie_aspm_pm_state_change(st
 extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
 extern void pci_disable_link_state(struct pci_dev *pdev, int state);
 extern void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
-extern void pcie_clear_aspm(struct pci_bus *bus);
 extern void pcie_no_aspm(void);
 #else
 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
@@ -47,9 +46,6 @@ static inline void pcie_aspm_powersave_c
 static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
 }
-static inline void pcie_clear_aspm(struct pci_bus *bus)
-{
-}
 static inline void pcie_no_aspm(void)
 {
 }
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1168,7 +1168,7 @@ static inline int pcie_aspm_enabled(void
 static inline bool pcie_aspm_support_enabled(void) { return false; }
 #else
 extern int pcie_aspm_enabled(void);
-extern bool pcie_aspm_support_enabled(void);
+static inline bool pcie_aspm_support_enabled(void) { return true; }
 #endif
 
 #ifdef CONFIG_PCIEAER

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-29  3:22                 ` Bjorn Helgaas
       [not found]                   ` <CAE9FiQVu5QyxaKsYzzQoroQD=TvsziHzDOtoeg=FvhZ8HyN5yw@mail.gmail.com>
@ 2013-03-29 18:11                   ` Roman Yepishev
  1 sibling, 0 replies; 38+ messages in thread
From: Roman Yepishev @ 2013-03-29 18:11 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Fri, Mar 29, 2013 at 5:22 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> [+cc Matthew]
> [+cc e1000-devel@lists.sourceforge.net for suspected 82575/82598 regression]
>
> I think this regression has nothing to do with pci_disable_link_state().
>
> ...
>
> There are also PCI_FIXUP_FINAL quirks for 82575 and 82598 NICs that call
> pci_disable_link_state().  In 3.7, these quirks are run before
> aspm_disabled is set, but 8c33f51d moved the pcie_no_aspm() call up
> before we start scanning the bus, so in 3.8, aspm_disabled is set
> *before* we run them.  I think that means 8c33f51d broke all these
> quirks.  That's also a problem, of course, but this isn't the one Roman
> is seeing either.
I have to say that my iwlwifi device (Intel Corporation Centrino
Wireless-N 1000 [Condor Peak] [8086:0084] also appears to be affected
- it calls pci_disable_link_state too and in current 3.8 that does not
do anything. It looks like it affects something when the system is
resumed from suspend, but I was not able to confirm that yet (but
there's a thread about removing the code since it did not appear to
work - http://thread.gmane.org/gmane.linux.kernel.pci/20628/focus=20640)

> I think the problem Roman is seeing happens when
> pcie_aspm_init_link_state() calls pcie_aspm_sanity_check() during device
> enumeration.  In 3.8, the fact that aspm_disabled is already set by the
> time we get here means we skip the check for pre-1.1 PCIe devices, and
> I think *this* is what Roman is seeing.
>
> I suspect the following hunk of your patch is enough to fix things for
> Roman:
>
>> --- linux-2.6.orig/drivers/pci/pcie/aspm.c
>> +++ linux-2.6/drivers/pci/pcie/aspm.c
>> @@ -493,15 +492,6 @@ static int pcie_aspm_sanity_check(struct
>>                       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
>>                */
>
> However, this test was added by Matthew in c9651e70, and I can't remove
> it unless we have an explanation of why removing it will not reintroduce
> the bug he was fixing.
>
> This code is such a terrible mess that it's not surprising at all that
> we have all these issues.  But there's too much to untangle in v3.9; all
> we can hope for is to fix the regressions in v3.9 and clean it up later.
>
I have removed the check and indeed it allowed ASPM to become disabled
during the ath5k driver load.

--
Regards, Roman Yepishev

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-03-29 18:04                         ` Yinghai Lu
@ 2013-04-01 23:52                           ` Bjorn Helgaas
  2013-04-02  0:03                             ` Yinghai Lu
  2013-04-02  0:10                             ` Rafael J. Wysocki
  0 siblings, 2 replies; 38+ messages in thread
From: Bjorn Helgaas @ 2013-04-01 23:52 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Fri, Mar 29, 2013 at 11:04:48AM -0700, Yinghai Lu wrote:
> attatched -v3 again
> 
> On Fri, Mar 29, 2013 at 11:02 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> > On Fri, Mar 29, 2013 at 5:24 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >>
> >> Half of your v1 patch (removing the pcie_aspm_sanity_check() test)
> >> *might* be the right thing, but only if you can clearly explain why
> >> that will not reintroduce the bug Matthew fixed with c9651e70.
> >>
> >> I think we also need to fix the PCI_FIXUP_FINAL quirk regression, but
> >> that's a separate issue and should be a separate patch.
> >
> >
> > First commit from Matthew
> >  0ae5eaf10     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
> >     Right now we won't touch ASPM state if ASPM is disabled, except in the case
> >     where we find a device that appears to be too old to reliably support ASPM.
> >     Right now we'll clear it in that case, which is almost certainly the wrong
> >     thing to do
> >
> > Try to not touch pre-1.1 ASPM for all, and it causes lots of regression.
> >
> > So second commit
> >
> > cdb0f9a1ad2e ASPM: Fix pcie devices with non-pcie children
> >     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.
> >
> > move the check aspm_disabled down.
> >
> > but ath5 and etc (pre-1.1) really need to aspm_disable to change their
> > hw setting.
> >
> > So the right solution would be dropping pcie_aspm_sanity_check()
> > change -in v2 should make all both happy, as quirk and disable that in
> > driver for ath5 are calling
> > pcie_disable_aspm_state explicitly.
> >
> > In v2, we already removed pcie_clear_aspm() that is calling
> > pcie_disable_aspm_state.
> >
> >
> > Please check attached -v3.

It's getting late in the v3.9 cycle already, and while your v3 patch
probably fixes Roman's problem, I can't convince myself that it is
safe in general.

I think the safest thing to do at this point is to revert 8c33f51df
("PCI/ACPI: Request _OSC control before scanning PCI root bus") with a
patch like the one below.

That does mean the booting path and hotplug paths will be different (we set
aspm_disabled after boot but before hotplug), but it was that way for a
long time before 8c33f51df.  I think it's more important to fix this recent
ath5k regression than to fix a long-standing hotplug bug that nobody ever
complained about.

Obviously, I think we should fix the hotplug bug and clean up the ASPM
mess, too.  But we need to do that when we have more time to do it right
and test it.

Bjorn


commit 96e5d01cd536458435ef0678d9fa3dc542afb41f
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Mon Apr 1 15:47:39 2013 -0600

    Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
    
    This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
    
    Conflicts:
    	drivers/acpi/pci_root.c
    
    Reference: https://bugzilla.kernel.org/show_bug.cgi?id=55211
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 0ac546d..c740364 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -415,7 +415,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
 	struct acpi_pci_root *root;
 	struct acpi_pci_driver *driver;
 	u32 flags, base_flags;
-	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -476,6 +475,30 @@ static int acpi_pci_root_add(struct acpi_device *device,
 	flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
 	acpi_pci_osc_support(root, flags);
 
+	/*
+	 * TBD: Need PCI interface for enumeration/configuration of roots.
+	 */
+
+	mutex_lock(&acpi_pci_root_lock);
+	list_add_tail(&root->node, &acpi_pci_roots);
+	mutex_unlock(&acpi_pci_root_lock);
+
+	/*
+	 * Scan the Root Bridge
+	 * --------------------
+	 * Must do this prior to any attempt to bind the root device, as the
+	 * PCI namespace does not get created until this call is made (and
+	 * thus the root bridge's pci_dev does not exist).
+	 */
+	root->bus = pci_acpi_scan_root(root);
+	if (!root->bus) {
+		printk(KERN_ERR PREFIX
+			    "Bus %04x:%02x not present in PCI namespace\n",
+			    root->segment, (unsigned int)root->secondary.start);
+		result = -ENODEV;
+		goto out_del_root;
+	}
+
 	/* Indicate support for various _OSC capabilities. */
 	if (pci_ext_cfg_avail())
 		flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
@@ -494,6 +517,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
 			flags = base_flags;
 		}
 	}
+
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -514,54 +538,28 @@ static int acpi_pci_root_add(struct acpi_device *device,
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
 		if (ACPI_SUCCESS(status)) {
-			is_osc_granted = true;
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
+			if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
+				/*
+				 * We have ASPM control, but the FADT indicates
+				 * that it's unsupported. Clear it.
+				 */
+				pcie_clear_aspm(root->bus);
+			}
 		} else {
-			is_osc_granted = false;
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
+			pr_info("ACPI _OSC control for PCIe not granted, "
+				"disabling ASPM\n");
+			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
-			"Unable to request _OSC control "
-			"(_OSC support mask: 0x%02x)\n", flags);
-	}
-
-	/*
-	 * TBD: Need PCI interface for enumeration/configuration of roots.
-	 */
-
-	mutex_lock(&acpi_pci_root_lock);
-	list_add_tail(&root->node, &acpi_pci_roots);
-	mutex_unlock(&acpi_pci_root_lock);
-
-	/*
-	 * Scan the Root Bridge
-	 * --------------------
-	 * Must do this prior to any attempt to bind the root device, as the
-	 * PCI namespace does not get created until this call is made (and 
-	 * thus the root bridge's pci_dev does not exist).
-	 */
-	root->bus = pci_acpi_scan_root(root);
-	if (!root->bus) {
-		printk(KERN_ERR PREFIX
-			    "Bus %04x:%02x not present in PCI namespace\n",
-			    root->segment, (unsigned int)root->secondary.start);
-		result = -ENODEV;
-		goto out_del_root;
-	}
-
-	/* ASPM setting */
-	if (is_osc_granted) {
-		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
-			pcie_clear_aspm(root->bus);
-	} else {
-		pr_info("ACPI _OSC control for PCIe not granted, "
-			"disabling ASPM\n");
-		pcie_no_aspm();
+			 "Unable to request _OSC control "
+			 "(_OSC support mask: 0x%02x)\n", flags);
 	}
 
 	pci_acpi_add_bus_pm_notifier(device, root->bus);

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-04-01 23:52                           ` Bjorn Helgaas
@ 2013-04-02  0:03                             ` Yinghai Lu
  2013-04-02 20:10                               ` Bjorn Helgaas
  2013-04-02  0:10                             ` Rafael J. Wysocki
  1 sibling, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-04-02  0:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Mon, Apr 1, 2013 at 4:52 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Fri, Mar 29, 2013 at 11:04:48AM -0700, Yinghai Lu wrote:
>> attatched -v3 again
>>
>> > Please check attached -v3.
>
> It's getting late in the v3.9 cycle already, and while your v3 patch
> probably fixes Roman's problem, I can't convince myself that it is
> safe in general.
>
> I think the safest thing to do at this point is to revert 8c33f51df
> ("PCI/ACPI: Request _OSC control before scanning PCI root bus") with a
> patch like the one below.

Agreed.

>
> That does mean the booting path and hotplug paths will be different (we set
> aspm_disabled after boot but before hotplug), but it was that way for a
> long time before 8c33f51df.  I think it's more important to fix this recent
> ath5k regression than to fix a long-standing hotplug bug that nobody ever
> complained about.
>
> Obviously, I think we should fix the hotplug bug and clean up the ASPM
> mess, too.  But we need to do that when we have more time to do it right
> and test it.

Sure.

>
> Bjorn
>
>
> commit 96e5d01cd536458435ef0678d9fa3dc542afb41f
> Author: Bjorn Helgaas <bhelgaas@google.com>
> Date:   Mon Apr 1 15:47:39 2013 -0600
>
>     Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
>
>     This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
>
>     Conflicts:
>         drivers/acpi/pci_root.c
>
>     Reference: https://bugzilla.kernel.org/show_bug.cgi?id=55211
>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Acked-by: Yinghai Lu <yinghai@kernel.org>

stable need this reverting too.

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-04-01 23:52                           ` Bjorn Helgaas
  2013-04-02  0:03                             ` Yinghai Lu
@ 2013-04-02  0:10                             ` Rafael J. Wysocki
  1 sibling, 0 replies; 38+ messages in thread
From: Rafael J. Wysocki @ 2013-04-02  0:10 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Roman Yepishev, linux-pci, linux-acpi, linux-kernel,
	Taku Izumi, Kenji Kaneshige, Matthew Garrett, e1000-devel

On Monday, April 01, 2013 05:52:56 PM Bjorn Helgaas wrote:
> On Fri, Mar 29, 2013 at 11:04:48AM -0700, Yinghai Lu wrote:
> > attatched -v3 again
> > 
> > On Fri, Mar 29, 2013 at 11:02 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> > > On Fri, Mar 29, 2013 at 5:24 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > >>
> > >> Half of your v1 patch (removing the pcie_aspm_sanity_check() test)
> > >> *might* be the right thing, but only if you can clearly explain why
> > >> that will not reintroduce the bug Matthew fixed with c9651e70.
> > >>
> > >> I think we also need to fix the PCI_FIXUP_FINAL quirk regression, but
> > >> that's a separate issue and should be a separate patch.
> > >
> > >
> > > First commit from Matthew
> > >  0ae5eaf10     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
> > >     Right now we won't touch ASPM state if ASPM is disabled, except in the case
> > >     where we find a device that appears to be too old to reliably support ASPM.
> > >     Right now we'll clear it in that case, which is almost certainly the wrong
> > >     thing to do
> > >
> > > Try to not touch pre-1.1 ASPM for all, and it causes lots of regression.
> > >
> > > So second commit
> > >
> > > cdb0f9a1ad2e ASPM: Fix pcie devices with non-pcie children
> > >     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.
> > >
> > > move the check aspm_disabled down.
> > >
> > > but ath5 and etc (pre-1.1) really need to aspm_disable to change their
> > > hw setting.
> > >
> > > So the right solution would be dropping pcie_aspm_sanity_check()
> > > change -in v2 should make all both happy, as quirk and disable that in
> > > driver for ath5 are calling
> > > pcie_disable_aspm_state explicitly.
> > >
> > > In v2, we already removed pcie_clear_aspm() that is calling
> > > pcie_disable_aspm_state.
> > >
> > >
> > > Please check attached -v3.
> 
> It's getting late in the v3.9 cycle already, and while your v3 patch
> probably fixes Roman's problem, I can't convince myself that it is
> safe in general.
> 
> I think the safest thing to do at this point is to revert 8c33f51df
> ("PCI/ACPI: Request _OSC control before scanning PCI root bus") with a
> patch like the one below.
> 
> That does mean the booting path and hotplug paths will be different (we set
> aspm_disabled after boot but before hotplug), but it was that way for a
> long time before 8c33f51df.  I think it's more important to fix this recent
> ath5k regression than to fix a long-standing hotplug bug that nobody ever
> complained about.
> 
> Obviously, I think we should fix the hotplug bug and clean up the ASPM
> mess, too.  But we need to do that when we have more time to do it right
> and test it.
> 
> Bjorn
> 
> 
> commit 96e5d01cd536458435ef0678d9fa3dc542afb41f
> Author: Bjorn Helgaas <bhelgaas@google.com>
> Date:   Mon Apr 1 15:47:39 2013 -0600
> 
>     Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
>     
>     This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
>     
>     Conflicts:
>     	drivers/acpi/pci_root.c
>     
>     Reference: https://bugzilla.kernel.org/show_bug.cgi?id=55211
>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 0ac546d..c740364 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -415,7 +415,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
>  	struct acpi_pci_root *root;
>  	struct acpi_pci_driver *driver;
>  	u32 flags, base_flags;
> -	bool is_osc_granted = false;
>  
>  	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
>  	if (!root)
> @@ -476,6 +475,30 @@ static int acpi_pci_root_add(struct acpi_device *device,
>  	flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
>  	acpi_pci_osc_support(root, flags);
>  
> +	/*
> +	 * TBD: Need PCI interface for enumeration/configuration of roots.
> +	 */
> +
> +	mutex_lock(&acpi_pci_root_lock);
> +	list_add_tail(&root->node, &acpi_pci_roots);
> +	mutex_unlock(&acpi_pci_root_lock);
> +
> +	/*
> +	 * Scan the Root Bridge
> +	 * --------------------
> +	 * Must do this prior to any attempt to bind the root device, as the
> +	 * PCI namespace does not get created until this call is made (and
> +	 * thus the root bridge's pci_dev does not exist).
> +	 */
> +	root->bus = pci_acpi_scan_root(root);
> +	if (!root->bus) {
> +		printk(KERN_ERR PREFIX
> +			    "Bus %04x:%02x not present in PCI namespace\n",
> +			    root->segment, (unsigned int)root->secondary.start);
> +		result = -ENODEV;
> +		goto out_del_root;
> +	}
> +
>  	/* Indicate support for various _OSC capabilities. */
>  	if (pci_ext_cfg_avail())
>  		flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
> @@ -494,6 +517,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
>  			flags = base_flags;
>  		}
>  	}
> +
>  	if (!pcie_ports_disabled
>  	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
>  		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
> @@ -514,54 +538,28 @@ static int acpi_pci_root_add(struct acpi_device *device,
>  		status = acpi_pci_osc_control_set(device->handle, &flags,
>  				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
>  		if (ACPI_SUCCESS(status)) {
> -			is_osc_granted = true;
>  			dev_info(&device->dev,
>  				"ACPI _OSC control (0x%02x) granted\n", flags);
> +			if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
> +				/*
> +				 * We have ASPM control, but the FADT indicates
> +				 * that it's unsupported. Clear it.
> +				 */
> +				pcie_clear_aspm(root->bus);
> +			}
>  		} else {
> -			is_osc_granted = false;
>  			dev_info(&device->dev,
>  				"ACPI _OSC request failed (%s), "
>  				"returned control mask: 0x%02x\n",
>  				acpi_format_exception(status), flags);
> +			pr_info("ACPI _OSC control for PCIe not granted, "
> +				"disabling ASPM\n");
> +			pcie_no_aspm();
>  		}
>  	} else {
>  		dev_info(&device->dev,
> -			"Unable to request _OSC control "
> -			"(_OSC support mask: 0x%02x)\n", flags);
> -	}
> -
> -	/*
> -	 * TBD: Need PCI interface for enumeration/configuration of roots.
> -	 */
> -
> -	mutex_lock(&acpi_pci_root_lock);
> -	list_add_tail(&root->node, &acpi_pci_roots);
> -	mutex_unlock(&acpi_pci_root_lock);
> -
> -	/*
> -	 * Scan the Root Bridge
> -	 * --------------------
> -	 * Must do this prior to any attempt to bind the root device, as the
> -	 * PCI namespace does not get created until this call is made (and 
> -	 * thus the root bridge's pci_dev does not exist).
> -	 */
> -	root->bus = pci_acpi_scan_root(root);
> -	if (!root->bus) {
> -		printk(KERN_ERR PREFIX
> -			    "Bus %04x:%02x not present in PCI namespace\n",
> -			    root->segment, (unsigned int)root->secondary.start);
> -		result = -ENODEV;
> -		goto out_del_root;
> -	}
> -
> -	/* ASPM setting */
> -	if (is_osc_granted) {
> -		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
> -			pcie_clear_aspm(root->bus);
> -	} else {
> -		pr_info("ACPI _OSC control for PCIe not granted, "
> -			"disabling ASPM\n");
> -		pcie_no_aspm();
> +			 "Unable to request _OSC control "
> +			 "(_OSC support mask: 0x%02x)\n", flags);
>  	}
>  
>  	pci_acpi_add_bus_pm_notifier(device, root->bus);
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-04-02  0:03                             ` Yinghai Lu
@ 2013-04-02 20:10                               ` Bjorn Helgaas
  2013-06-12  6:20                                 ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-04-02 20:10 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Mon, Apr 1, 2013 at 6:03 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Mon, Apr 1, 2013 at 4:52 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Fri, Mar 29, 2013 at 11:04:48AM -0700, Yinghai Lu wrote:
>>> attatched -v3 again
>>>
>>> > Please check attached -v3.
>>
>> It's getting late in the v3.9 cycle already, and while your v3 patch
>> probably fixes Roman's problem, I can't convince myself that it is
>> safe in general.
>>
>> I think the safest thing to do at this point is to revert 8c33f51df
>> ("PCI/ACPI: Request _OSC control before scanning PCI root bus") with a
>> patch like the one below.
>
> Agreed.
>
>>
>> That does mean the booting path and hotplug paths will be different (we set
>> aspm_disabled after boot but before hotplug), but it was that way for a
>> long time before 8c33f51df.  I think it's more important to fix this recent
>> ath5k regression than to fix a long-standing hotplug bug that nobody ever
>> complained about.
>>
>> Obviously, I think we should fix the hotplug bug and clean up the ASPM
>> mess, too.  But we need to do that when we have more time to do it right
>> and test it.
>
> Sure.
>
>>
>> Bjorn
>>
>>
>> commit 96e5d01cd536458435ef0678d9fa3dc542afb41f
>> Author: Bjorn Helgaas <bhelgaas@google.com>
>> Date:   Mon Apr 1 15:47:39 2013 -0600
>>
>>     Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
>>
>>     This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
>>
>>     Conflicts:
>>         drivers/acpi/pci_root.c
>>
>>     Reference: https://bugzilla.kernel.org/show_bug.cgi?id=55211
>>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>
> Acked-by: Yinghai Lu <yinghai@kernel.org>
>
> stable need this reverting too.

I updated the changelog and added this to my for-linus branch, headed for v3.9.

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-04-02 20:10                               ` Bjorn Helgaas
@ 2013-06-12  6:20                                 ` Yinghai Lu
  2013-06-12 17:05                                   ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-12  6:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu
  Cc: Roman Yepishev, Rafael J. Wysocki, linux-pci, linux-acpi,
	linux-kernel, Taku Izumi, Kenji Kaneshige, Matthew Garrett,
	e1000-devel

On Tue, Apr 2, 2013 at 1:10 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Mon, Apr 1, 2013 at 6:03 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>>> commit 96e5d01cd536458435ef0678d9fa3dc542afb41f
>>> Author: Bjorn Helgaas <bhelgaas@google.com>
>>> Date:   Mon Apr 1 15:47:39 2013 -0600
>>>
>>>     Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
>>>
>>>     This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
>>>
>>>     Conflicts:
>>>         drivers/acpi/pci_root.c
>>>
>>>     Reference: https://bugzilla.kernel.org/show_bug.cgi?id=55211
>>>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>>
>> Acked-by: Yinghai Lu <yinghai@kernel.org>
>>
>> stable need this reverting too.
>
> I updated the changelog and added this to my for-linus branch, headed for v3.9.

We may need to revert this reverting for 3.10.

Today noticed that acpiphp jump in before pciehp on one setup.

current code from acpi_pci_root_add we have
  1. pci_acpi_scan_root
         ==> pci devices enumeration and bus scanning.
             ==> pci_alloc_child_bus
                 ==> pcibios_add_bus
                     ==> acpi_pci_add_bus
                         ==> acpiphp_enumerate_slots
                             ==> ...==> register_slot
                                  ==> device_is_managed_by_native_pciehp
                                        ==> check osc_set with
OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
   2. _OSC set request

so we always have acpiphp hotplug slot registered at first.

so either we need to
A. revert reverting about _OSC
B. move pcibios_add_bus down to pci_bus_add_devices()
    as acpiphp and apci pci slot driver are some kind of drivers for pci_bus
C. A+B

Thanks

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-12  6:20                                 ` Yinghai Lu
@ 2013-06-12 17:05                                   ` Bjorn Helgaas
  2013-06-12 19:41                                     ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-12 17:05 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Taku Izumi, Kenji Kaneshige,
	Matthew Garrett, e1000-devel

On Wed, Jun 12, 2013 at 12:20 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Apr 2, 2013 at 1:10 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Mon, Apr 1, 2013 at 6:03 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>>>> commit 96e5d01cd536458435ef0678d9fa3dc542afb41f
>>>> Author: Bjorn Helgaas <bhelgaas@google.com>
>>>> Date:   Mon Apr 1 15:47:39 2013 -0600
>>>>
>>>>     Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
>>>>
>>>>     This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
>>>>
>>>>     Conflicts:
>>>>         drivers/acpi/pci_root.c
>>>>
>>>>     Reference: https://bugzilla.kernel.org/show_bug.cgi?id=55211
>>>>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>>>
>>> Acked-by: Yinghai Lu <yinghai@kernel.org>
>>>
>>> stable need this reverting too.
>>
>> I updated the changelog and added this to my for-linus branch, headed for v3.9.
>
> We may need to revert this reverting for 3.10.
>
> Today noticed that acpiphp jump in before pciehp on one setup.
>
> current code from acpi_pci_root_add we have
>   1. pci_acpi_scan_root
>          ==> pci devices enumeration and bus scanning.
>              ==> pci_alloc_child_bus
>                  ==> pcibios_add_bus
>                      ==> acpi_pci_add_bus
>                          ==> acpiphp_enumerate_slots
>                              ==> ...==> register_slot
>                                   ==> device_is_managed_by_native_pciehp
>                                         ==> check osc_set with
> OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
>    2. _OSC set request
>
> so we always have acpiphp hotplug slot registered at first.
>
> so either we need to
> A. revert reverting about _OSC
> B. move pcibios_add_bus down to pci_bus_add_devices()
>     as acpiphp and apci pci slot driver are some kind of drivers for pci_bus
> C. A+B

It doesn't surprise me at all that there are problems in the _OSC code
and the acpiphp/pciehp interaction.  That whole area is a complete
disaster.  It'd really be nice if somebody stepped up and reworked it
so it makes sense.

But this report is useless to me.  I don't have time to work out what
the problem is and how it affects users and come up with a fix.

My advice is to simplify the path first, and worry about fixing the
bug afterwards.  We've already done several iterations of fiddling
with things, and I think all we're doing is playing "whack-a-mole" and
pushing the bugs around from one place to another.

Bjorn

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-12 17:05                                   ` Bjorn Helgaas
@ 2013-06-12 19:41                                     ` Yinghai Lu
  2013-06-13  3:50                                       ` Bjorn Helgaas
  2013-06-14 14:11                                       ` Bjorn Helgaas
  0 siblings, 2 replies; 38+ messages in thread
From: Yinghai Lu @ 2013-06-12 19:41 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 2038 bytes --]

On Wed, Jun 12, 2013 at 10:05 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> current code from acpi_pci_root_add we have
>>   1. pci_acpi_scan_root
>>          ==> pci devices enumeration and bus scanning.
>>              ==> pci_alloc_child_bus
>>                  ==> pcibios_add_bus
>>                      ==> acpi_pci_add_bus
>>                          ==> acpiphp_enumerate_slots
>>                              ==> ...==> register_slot
>>                                   ==> device_is_managed_by_native_pciehp
>>                                         ==> check osc_set with
>> OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
>>    2. _OSC set request
>>
>> so we always have acpiphp hotplug slot registered at first.
>>
>> so either we need to
>> A. revert reverting about _OSC
>> B. move pcibios_add_bus down to pci_bus_add_devices()
>>     as acpiphp and apci pci slot driver are some kind of drivers for pci_bus
>> C. A+B
>
> It doesn't surprise me at all that there are problems in the _OSC code
> and the acpiphp/pciehp interaction.  That whole area is a complete
> disaster.  It'd really be nice if somebody stepped up and reworked it
> so it makes sense.
>
> But this report is useless to me.  I don't have time to work out what
> the problem is and how it affects users and come up with a fix.

effects: without fix the problem, user can not use pcie native hotplug
if their system's firmware support acpihp and pciehp.
And make it worse, that acpiphp have to be built-in, so they have no
way to blacklist acpiphp in config.

>
> My advice is to simplify the path first, and worry about fixing the
> bug afterwards.  We've already done several iterations of fiddling
> with things, and I think all we're doing is playing "whack-a-mole" and
> pushing the bugs around from one place to another.

We need to address regression at first.
my suggestion is : revert the reverting and apply my -v3 version that will fix
regression that Roman Yepishev met.

please check attached two patches, hope it could save your some time.

Yinghai

[-- Attachment #2: revert_revert_osc_change_linus.patch --]
[-- Type: application/octet-stream, Size: 5303 bytes --]

Subject: [PATCH] ACPI, PCI: Revert reverting of "PCI/ACPI: Request _OSC control before scanning PCI root bus"

In
| commit b8178f130e25c1bdac1c33e0996f1ff6e20ec08e
| Author: Bjorn Helgaas <bhelgaas@google.com>
| Date:   Mon Apr 1 15:47:39 2013 -0600
|
|    Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
|
|    This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
for v3.9, "OSC set early" is reverted.

Now we have problem on v3.10, as it has
       - Remove ACPI PCI subdrivers (Jiang Liu, Myron Stowe)
       - Make acpiphp builtin only, not modular (Jiang Liu)
   acpiphp get registered with pcibios_add_bus very early.
We can not enable pcie native hotplug driver any more if system support
acpiphp and pciehp.

Calling path: in acpi_pci_root_add we have
1. pci_acpi_scan_root
     ==> pci devices enumeration and bus scanning.
       ==> pci_alloc_child_bus
         ==> pcibios_add_bus
           ==> acpi_pci_add_bus
             ==> acpiphp_enumerate_slots
               ==> ...==> register_slot
                 ==> device_is_managed_by_native_pciehp
                   ==> check osc_set with OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
2. _OSC set request
so we always have acpiphp hotplug slot registered at first, as OSC is
not set yet.

We need "OSC set early" before pci_apci_scan_root again.

The point: later aspm, pme, pciehp, aer support would rely on value in
root osc_support_set/osc_control_set.

For v3.10, let's put the "osc control set early" back,
as we have user in pci_acpi_scan_root.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e427dc5..207d773 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -382,6 +382,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
 	int result;
 	struct acpi_pci_root *root;
 	u32 flags, base_flags;
+	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -442,30 +443,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
 	flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
 	acpi_pci_osc_support(root, flags);
 
-	/*
-	 * TBD: Need PCI interface for enumeration/configuration of roots.
-	 */
-
-	mutex_lock(&acpi_pci_root_lock);
-	list_add_tail(&root->node, &acpi_pci_roots);
-	mutex_unlock(&acpi_pci_root_lock);
-
-	/*
-	 * Scan the Root Bridge
-	 * --------------------
-	 * Must do this prior to any attempt to bind the root device, as the
-	 * PCI namespace does not get created until this call is made (and
-	 * thus the root bridge's pci_dev does not exist).
-	 */
-	root->bus = pci_acpi_scan_root(root);
-	if (!root->bus) {
-		printk(KERN_ERR PREFIX
-			    "Bus %04x:%02x not present in PCI namespace\n",
-			    root->segment, (unsigned int)root->secondary.start);
-		result = -ENODEV;
-		goto out_del_root;
-	}
-
 	/* Indicate support for various _OSC capabilities. */
 	if (pci_ext_cfg_avail())
 		flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
@@ -484,7 +461,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
 			flags = base_flags;
 		}
 	}
-
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -505,28 +481,54 @@ static int acpi_pci_root_add(struct acpi_device *device,
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
 		if (ACPI_SUCCESS(status)) {
+			is_osc_granted = true;
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
-			if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
-				/*
-				 * We have ASPM control, but the FADT indicates
-				 * that it's unsupported. Clear it.
-				 */
-				pcie_clear_aspm(root->bus);
-			}
 		} else {
+			is_osc_granted = false;
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
-			pr_info("ACPI _OSC control for PCIe not granted, "
-				"disabling ASPM\n");
-			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
-			 "Unable to request _OSC control "
-			 "(_OSC support mask: 0x%02x)\n", flags);
+			"Unable to request _OSC control "
+			"(_OSC support mask: 0x%02x)\n", flags);
+	}
+
+	/*
+	 * TBD: Need PCI interface for enumeration/configuration of roots.
+	 */
+
+	mutex_lock(&acpi_pci_root_lock);
+	list_add_tail(&root->node, &acpi_pci_roots);
+	mutex_unlock(&acpi_pci_root_lock);
+
+	/*
+	 * Scan the Root Bridge
+	 * --------------------
+	 * Must do this prior to any attempt to bind the root device, as the
+	 * PCI namespace does not get created until this call is made (and 
+	 * thus the root bridge's pci_dev does not exist).
+	 */
+	root->bus = pci_acpi_scan_root(root);
+	if (!root->bus) {
+		printk(KERN_ERR PREFIX
+			    "Bus %04x:%02x not present in PCI namespace\n",
+			    root->segment, (unsigned int)root->secondary.start);
+		result = -ENODEV;
+		goto out_del_root;
+	}
+
+	/* ASPM setting */
+	if (is_osc_granted) {
+		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+			pcie_clear_aspm(root->bus);
+	} else {
+		pr_info("ACPI _OSC control for PCIe not granted, "
+			"disabling ASPM\n");
+		pcie_no_aspm();
 	}
 
 	pci_acpi_add_bus_pm_notifier(device, root->bus);

[-- Attachment #3: disable_aspm_3_linus.patch --]
[-- Type: application/octet-stream, Size: 8145 bytes --]

Subject: [PATCH] PCI: Remove not needed check in disable aspm link

Roman reported ath5k does not work anymore on 3.8.
Bisected to
| commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6
| Author: Taku Izumi <izumi.taku@jp.fujitsu.com>
| Date:   Tue Oct 30 15:27:13 2012 +0900
|
|    PCI/ACPI: Request _OSC control before scanning PCI root bus
|
|    This patch moves up the code block to request _OSC control in order to
|    separate ACPI work and PCI work in acpi_pci_root_add().

It make pcie_aspm_sanity_check does not work anymore as aspm_disabled
is set before pci root bus scanning.

Bjorn revert that for v3.9, and that will make booting path and hotplug
path with different aspm_disabled again.
For fixing acpiphp and pciehp loading, we need put that "osc set early"
again.

For regression that Roman had, acctually we don't need to check
aspm_disabled in pci_disable_link_state, as we already have
protection about link state checking.
And pci_disable_link_state will be called only for quirk and driver
directly.

That will keep the logic in pcie_aspm_sanity_check() in commits:
 0ae5eaf10     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
 cdb0f9a1a     ASPM: Fix pcie devices with non-pcie children
still working, AKA still not touch pre-1.1 ASPM device.

https://bugzilla.kernel.org/show_bug.cgi?id=55211
http://article.gmane.org/gmane.linux.kernel.pci/20640

Also remove aspm_support_enabled. if aspm is compiled in, even user pass
aspm=off, link_state still get allocated, then we will have chance to
disable aspm on devices from buggy setting of BIOS.

According Bjorn, move the FADT disabling handling early.

-v4: update changelog accordingly for v3.10

Reported-by: Roman Yepishev <roman.yepishev@gmail.com>
Bisected-by: Roman Yepishev <roman.yepishev@gmail.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

---
 drivers/acpi/pci_root.c  |   24 +++++++++---------------
 drivers/pci/pcie/aspm.c  |   39 +++------------------------------------
 include/linux/pci-aspm.h |    4 ----
 include/linux/pci.h      |    2 +-
 4 files changed, 13 insertions(+), 56 deletions(-)

Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -382,7 +382,6 @@ static int acpi_pci_root_add(struct acpi
 	int result;
 	struct acpi_pci_root *root;
 	u32 flags, base_flags;
-	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -461,6 +460,11 @@ static int acpi_pci_root_add(struct acpi
 			flags = base_flags;
 		}
 	}
+
+	/* ASPM setting */
+	if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+		pcie_no_aspm();
+
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -480,16 +484,16 @@ static int acpi_pci_root_add(struct acpi
 
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
-		if (ACPI_SUCCESS(status)) {
-			is_osc_granted = true;
+		if (ACPI_SUCCESS(status))
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
-		} else {
-			is_osc_granted = false;
+		else {
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
+			pr_info("ACPI _OSC control for PCIe not granted disabling ASPM\n");
+			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
@@ -521,16 +525,6 @@ static int acpi_pci_root_add(struct acpi
 		goto out_del_root;
 	}
 
-	/* ASPM setting */
-	if (is_osc_granted) {
-		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
-			pcie_clear_aspm(root->bus);
-	} else {
-		pr_info("ACPI _OSC control for PCIe not granted, "
-			"disabling ASPM\n");
-		pcie_no_aspm();
-	}
-
 	pci_acpi_add_bus_pm_notifier(device, root->bus);
 	if (device->wakeup.flags.run_wake)
 		device_set_run_wake(root->bus->bridge, true);
Index: linux-2.6/drivers/pci/pcie/aspm.c
===================================================================
--- linux-2.6.orig/drivers/pci/pcie/aspm.c
+++ linux-2.6/drivers/pci/pcie/aspm.c
@@ -69,7 +69,6 @@ struct pcie_link_state {
 };
 
 static int aspm_disabled, aspm_force;
-static bool aspm_support_enabled = true;
 static DEFINE_MUTEX(aspm_lock);
 static LIST_HEAD(link_list);
 
@@ -556,9 +555,6 @@ void pcie_aspm_init_link_state(struct pc
 	struct pcie_link_state *link;
 	int blacklist = !!pcie_aspm_sanity_check(pdev);
 
-	if (!aspm_support_enabled)
-		return;
-
 	if (!pci_is_pcie(pdev) || pdev->link_state)
 		return;
 	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
@@ -718,15 +714,11 @@ void pcie_aspm_powersave_config_link(str
  * pci_disable_link_state - disable pci device's link state, so the link will
  * never enter specific states
  */
-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
-				     bool force)
+static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
 {
 	struct pci_dev *parent = pdev->bus->self;
 	struct pcie_link_state *link;
 
-	if (aspm_disabled && !force)
-		return;
-
 	if (!pci_is_pcie(pdev))
 		return;
 
@@ -757,34 +749,16 @@ static void __pci_disable_link_state(str
 
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, false, false);
+	__pci_disable_link_state(pdev, state, false);
 }
 EXPORT_SYMBOL(pci_disable_link_state_locked);
 
 void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
-	__pci_disable_link_state(pdev, state, true, false);
+	__pci_disable_link_state(pdev, state, true);
 }
 EXPORT_SYMBOL(pci_disable_link_state);
 
-void pcie_clear_aspm(struct pci_bus *bus)
-{
-	struct pci_dev *child;
-
-	if (aspm_force)
-		return;
-
-	/*
-	 * Clear any ASPM setup that the firmware has carried out on this bus
-	 */
-	list_for_each_entry(child, &bus->devices, bus_list) {
-		__pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
-					 PCIE_LINK_STATE_L1 |
-					 PCIE_LINK_STATE_CLKPM,
-					 false, true);
-	}
-}
-
 static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
 {
 	int i;
@@ -944,7 +918,6 @@ static int __init pcie_aspm_disable(char
 	if (!strcmp(str, "off")) {
 		aspm_policy = POLICY_DEFAULT;
 		aspm_disabled = 1;
-		aspm_support_enabled = false;
 		printk(KERN_INFO "PCIe ASPM is disabled\n");
 	} else if (!strcmp(str, "force")) {
 		aspm_force = 1;
@@ -980,9 +953,3 @@ int pcie_aspm_enabled(void)
        return !aspm_disabled;
 }
 EXPORT_SYMBOL(pcie_aspm_enabled);
-
-bool pcie_aspm_support_enabled(void)
-{
-	return aspm_support_enabled;
-}
-EXPORT_SYMBOL(pcie_aspm_support_enabled);
Index: linux-2.6/include/linux/pci-aspm.h
===================================================================
--- linux-2.6.orig/include/linux/pci-aspm.h
+++ linux-2.6/include/linux/pci-aspm.h
@@ -29,7 +29,6 @@ void pcie_aspm_pm_state_change(struct pc
 void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
 void pci_disable_link_state(struct pci_dev *pdev, int state);
 void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
-void pcie_clear_aspm(struct pci_bus *bus);
 void pcie_no_aspm(void);
 #else
 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
@@ -47,9 +46,6 @@ static inline void pcie_aspm_powersave_c
 static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
 {
 }
-static inline void pcie_clear_aspm(struct pci_bus *bus)
-{
-}
 static inline void pcie_no_aspm(void)
 {
 }
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1186,7 +1186,7 @@ static inline int pcie_aspm_enabled(void
 static inline bool pcie_aspm_support_enabled(void) { return false; }
 #else
 int pcie_aspm_enabled(void);
-bool pcie_aspm_support_enabled(void);
+static inline bool pcie_aspm_support_enabled(void) { return true; }
 #endif
 
 #ifdef CONFIG_PCIEAER

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-12 19:41                                     ` Yinghai Lu
@ 2013-06-13  3:50                                       ` Bjorn Helgaas
  2013-06-13  4:11                                         ` Jiang Liu (Gerry)
  2013-06-13  5:47                                         ` Yinghai Lu
  2013-06-14 14:11                                       ` Bjorn Helgaas
  1 sibling, 2 replies; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-13  3:50 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Wed, Jun 12, 2013 at 1:41 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Wed, Jun 12, 2013 at 10:05 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> current code from acpi_pci_root_add we have
>>>   1. pci_acpi_scan_root
>>>          ==> pci devices enumeration and bus scanning.
>>>              ==> pci_alloc_child_bus
>>>                  ==> pcibios_add_bus
>>>                      ==> acpi_pci_add_bus
>>>                          ==> acpiphp_enumerate_slots
>>>                              ==> ...==> register_slot
>>>                                   ==> device_is_managed_by_native_pciehp
>>>                                         ==> check osc_set with
>>> OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
>>>    2. _OSC set request
>>>
>>> so we always have acpiphp hotplug slot registered at first.
>>>
>>> so either we need to
>>> A. revert reverting about _OSC
>>> B. move pcibios_add_bus down to pci_bus_add_devices()
>>>     as acpiphp and apci pci slot driver are some kind of drivers for pci_bus
>>> C. A+B
>>
>> It doesn't surprise me at all that there are problems in the _OSC code
>> and the acpiphp/pciehp interaction.  That whole area is a complete
>> disaster.  It'd really be nice if somebody stepped up and reworked it
>> so it makes sense.
>>
>> But this report is useless to me.  I don't have time to work out what
>> the problem is and how it affects users and come up with a fix.
>
> effects: without fix the problem, user can not use pcie native hotplug
> if their system's firmware support acpihp and pciehp.
> And make it worse, that acpiphp have to be built-in, so they have no
> way to blacklist acpiphp in config.
>
>>
>> My advice is to simplify the path first, and worry about fixing the
>> bug afterwards.  We've already done several iterations of fiddling
>> with things, and I think all we're doing is playing "whack-a-mole" and
>> pushing the bugs around from one place to another.
>
> We need to address regression at first.
> my suggestion is : revert the reverting and apply my -v3 version that will fix
> regression that Roman Yepishev met.
>
> please check attached two patches, hope it could save your some time.

OK, you're right.  It's not reasonable to do anything more than a
minimal fix when we're at -rc5.

Sigh.  I'll spend tomorrow trying to understand your patches and write
changelogs for you.

I think you're saying that in systems that support both acpiphp and
pciehp, we should be using pciehp, but we currently use acpiphp.  If
so, that's certainly a bug.  How serious is it?  Is it a disaster if
we use acpiphp until we can resolve this cleanly?  Are there a lot of
systems that claim to support acpiphp but it doesn't actually work?

Bjorn

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-13  3:50                                       ` Bjorn Helgaas
@ 2013-06-13  4:11                                         ` Jiang Liu (Gerry)
  2013-06-13 13:57                                           ` Bjorn Helgaas
  2013-06-13  5:47                                         ` Yinghai Lu
  1 sibling, 1 reply; 38+ messages in thread
From: Jiang Liu (Gerry) @ 2013-06-13  4:11 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

Hi Bjorn,
     I'm working on several acpiphp related bugfixes, and feel some
are materials for 3.10 too. Actually we have identified four bugs
related to dock station support on Sony VAIO VPCZ23A4R laptop.
I will try to send out patchset to address these bugs tonight.
Seems we really need to rethink about acpiphp and pciehp now.
Regards!
Gerry
On 2013/6/13 11:50, Bjorn Helgaas wrote:
> On Wed, Jun 12, 2013 at 1:41 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Wed, Jun 12, 2013 at 10:05 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>>> current code from acpi_pci_root_add we have
>>>>    1. pci_acpi_scan_root
>>>>           ==> pci devices enumeration and bus scanning.
>>>>               ==> pci_alloc_child_bus
>>>>                   ==> pcibios_add_bus
>>>>                       ==> acpi_pci_add_bus
>>>>                           ==> acpiphp_enumerate_slots
>>>>                               ==> ...==> register_slot
>>>>                                    ==> device_is_managed_by_native_pciehp
>>>>                                          ==> check osc_set with
>>>> OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
>>>>     2. _OSC set request
>>>>
>>>> so we always have acpiphp hotplug slot registered at first.
>>>>
>>>> so either we need to
>>>> A. revert reverting about _OSC
>>>> B. move pcibios_add_bus down to pci_bus_add_devices()
>>>>      as acpiphp and apci pci slot driver are some kind of drivers for pci_bus
>>>> C. A+B
>>>
>>> It doesn't surprise me at all that there are problems in the _OSC code
>>> and the acpiphp/pciehp interaction.  That whole area is a complete
>>> disaster.  It'd really be nice if somebody stepped up and reworked it
>>> so it makes sense.
>>>
>>> But this report is useless to me.  I don't have time to work out what
>>> the problem is and how it affects users and come up with a fix.
>>
>> effects: without fix the problem, user can not use pcie native hotplug
>> if their system's firmware support acpihp and pciehp.
>> And make it worse, that acpiphp have to be built-in, so they have no
>> way to blacklist acpiphp in config.
>>
>>>
>>> My advice is to simplify the path first, and worry about fixing the
>>> bug afterwards.  We've already done several iterations of fiddling
>>> with things, and I think all we're doing is playing "whack-a-mole" and
>>> pushing the bugs around from one place to another.
>>
>> We need to address regression at first.
>> my suggestion is : revert the reverting and apply my -v3 version that will fix
>> regression that Roman Yepishev met.
>>
>> please check attached two patches, hope it could save your some time.
>
> OK, you're right.  It's not reasonable to do anything more than a
> minimal fix when we're at -rc5.
>
> Sigh.  I'll spend tomorrow trying to understand your patches and write
> changelogs for you.
>
> I think you're saying that in systems that support both acpiphp and
> pciehp, we should be using pciehp, but we currently use acpiphp.  If
> so, that's certainly a bug.  How serious is it?  Is it a disaster if
> we use acpiphp until we can resolve this cleanly?  Are there a lot of
> systems that claim to support acpiphp but it doesn't actually work?
>
> Bjorn
>
> .
>



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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-13  3:50                                       ` Bjorn Helgaas
  2013-06-13  4:11                                         ` Jiang Liu (Gerry)
@ 2013-06-13  5:47                                         ` Yinghai Lu
  2013-06-13 12:04                                           ` Rafael J. Wysocki
  1 sibling, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-13  5:47 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Wed, Jun 12, 2013 at 8:50 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Wed, Jun 12, 2013 at 1:41 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>
> I think you're saying that in systems that support both acpiphp and
> pciehp, we should be using pciehp, but we currently use acpiphp.  If
> so, that's certainly a bug.  How serious is it?  Is it a disaster if
> we use acpiphp until we can resolve this cleanly?  Are there a lot of
> systems that claim to support acpiphp but it doesn't actually work?

No sure. To make acpiphp would need more expertise in bios.
Normally BIOS vendor would have half done work there, and will need
OEM or system vendor have someone to make it work ....
You would not want to read asl code in DSDT to help them out.
That is not something that we can control.

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-13  5:47                                         ` Yinghai Lu
@ 2013-06-13 12:04                                           ` Rafael J. Wysocki
  0 siblings, 0 replies; 38+ messages in thread
From: Rafael J. Wysocki @ 2013-06-13 12:04 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Roman Yepishev, linux-pci, linux-acpi,
	linux-kernel, Linus Torvalds, Andrew Morton, Greg Kroah-Hartman

On Wednesday, June 12, 2013 10:47:08 PM Yinghai Lu wrote:
> On Wed, Jun 12, 2013 at 8:50 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > On Wed, Jun 12, 2013 at 1:41 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> >
> > I think you're saying that in systems that support both acpiphp and
> > pciehp, we should be using pciehp, but we currently use acpiphp.  If
> > so, that's certainly a bug.  How serious is it?  Is it a disaster if
> > we use acpiphp until we can resolve this cleanly?  Are there a lot of
> > systems that claim to support acpiphp but it doesn't actually work?
> 
> No sure. To make acpiphp would need more expertise in bios.
> Normally BIOS vendor would have half done work there, and will need
> OEM or system vendor have someone to make it work ....
> You would not want to read asl code in DSDT to help them out.
> That is not something that we can control.

However, pciehp may simply not work by itself on those systems.

It's pretty much like saying "Oh, _CRS may be screwed up, so let's just ignore
it", which isn't overly smart.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-13  4:11                                         ` Jiang Liu (Gerry)
@ 2013-06-13 13:57                                           ` Bjorn Helgaas
  0 siblings, 0 replies; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-13 13:57 UTC (permalink / raw)
  To: Jiang Liu (Gerry)
  Cc: Yinghai Lu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Wed, Jun 12, 2013 at 10:11 PM, Jiang Liu (Gerry)
<jiang.liu@huawei.com> wrote:
> Hi Bjorn,
>     I'm working on several acpiphp related bugfixes, and feel some
> are materials for 3.10 too. Actually we have identified four bugs
> related to dock station support on Sony VAIO VPCZ23A4R laptop.
> I will try to send out patchset to address these bugs tonight.
> Seems we really need to rethink about acpiphp and pciehp now.

We certainly need more rework in acpiphp and pciehp.  But unless it's
an obvious fix for a serious regression, I'm doubtful about putting it
in 3.10.  rc6 is imminent and it's not the time to be putting
significant changes in.

I don't know the details of the dock issues, but you might not need to
be in a huge rush about them.

Bjorn

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-12 19:41                                     ` Yinghai Lu
  2013-06-13  3:50                                       ` Bjorn Helgaas
@ 2013-06-14 14:11                                       ` Bjorn Helgaas
  2013-06-14 16:17                                         ` Yinghai Lu
  1 sibling, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-14 14:11 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Wed, Jun 12, 2013 at 12:41:42PM -0700, Yinghai Lu wrote:
> On Wed, Jun 12, 2013 at 10:05 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >> current code from acpi_pci_root_add we have
> >>   1. pci_acpi_scan_root
> >>          ==> pci devices enumeration and bus scanning.
> >>              ==> pci_alloc_child_bus
> >>                  ==> pcibios_add_bus
> >>                      ==> acpi_pci_add_bus
> >>                          ==> acpiphp_enumerate_slots
> >>                              ==> ...==> register_slot
> >>                                   ==> device_is_managed_by_native_pciehp
> >>                                         ==> check osc_set with
> >> OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
> >>    2. _OSC set request
> >>
> >> so we always have acpiphp hotplug slot registered at first.
> >>
> >> so either we need to
> >> A. revert reverting about _OSC
> >> B. move pcibios_add_bus down to pci_bus_add_devices()
> >>     as acpiphp and apci pci slot driver are some kind of drivers for pci_bus
> >> C. A+B
> >
> > It doesn't surprise me at all that there are problems in the _OSC code
> > and the acpiphp/pciehp interaction.  That whole area is a complete
> > disaster.  It'd really be nice if somebody stepped up and reworked it
> > so it makes sense.
> >
> > But this report is useless to me.  I don't have time to work out what
> > the problem is and how it affects users and come up with a fix.
> 
> effects: without fix the problem, user can not use pcie native hotplug
> if their system's firmware support acpihp and pciehp.
> And make it worse, that acpiphp have to be built-in, so they have no
> way to blacklist acpiphp in config.
> 
> >
> > My advice is to simplify the path first, and worry about fixing the
> > bug afterwards.  We've already done several iterations of fiddling
> > with things, and I think all we're doing is playing "whack-a-mole" and
> > pushing the bugs around from one place to another.
> 
> We need to address regression at first.
> my suggestion is : revert the reverting and apply my -v3 version that will fix
> regression that Roman Yepishev met.
> 
> please check attached two patches, hope it could save your some time.

Here are some of my notes from trying to sort this out, in chronological
order:

    29594404 v3.7
      Bus scanned before requesting _OSC control
      pre-1.1 ath5k has ASPM disabled (works fine)

    8c33f51d "request _OSC control before scanning bus"

    19f949f5 v3.8
      _OSC control requested before scanning bus
      Now pre-1.1 ath5k has ASPM enabled and doesn't work
      https://bugzilla.kernel.org/show_bug.cgi?id=55211 opened

    b8178f13 "revert 'request _OSC control before scanning bus' (8c33f51d)"
      Bus now scanned before requesting _OSC control (as in v3.7)

    c1be5a5b v3.9
      pciehp claims slots first, even when both pciehp & acpiphp are
      built-in, because pciehp module_init precedes acpiphp module_init
      in link order

    6037a803 "Convert acpiphp to be builtin only"
      This also adds "acpiphp.disable" boot option

    3b63aaa7 "Do not use ACPI PCI subdriver mechanism"
      Now acpiphp claims slots first because we call
      acpiphp_enumerate_slots() from pcibios_add_bus() during PCI device
      enumeration.  This happens before pciehp, which still uses
      module_init.

    f722406f v3.10-rc1

    ........ "Revert reverting of 'request _OSC control before scanning bus' (b8178f13)"
      _OSC control requested before scanning bus (as in v3.8)
      pre-1.1 ath5k probably has ASPM enabled and doesn't work

    ........ "Remove not needed check in disable aspm link"
      Now pci_disable_link_state() unconditionally disables ASPM,
      even when BIOS hasn't given us ASPM control


1) The problem you're trying to fix is that when both acpiphp and
pciehp are supported for the same slot, acpiphp claims the slot first
and pciehp will not claim it.  I think this problem was introduced by
3b63aaa7, which was merged after v3.9.  Therefore, v3.9 should work
correctly, and this regression appeared in v3.10-rc1.

2) As you say, acpiphp cannot be a module, so the user would have to
rebuild the kernel to remove it.  However, 6037a803 *did* add a
"acpiphp.disable" boot option, so that should be a workaround that
allows pciehp to claim the slot.

3) I think your "revert reverting" patch gets us back to the same
situation we had after 8c33f51d, i.e., Roman's pre-1.1 ath5k device
will have ASPM enabled and won't work.  I don't want to leave the tree
in this broken state, even though you intend to fix it in the next
patch.  If you can reorder your patches so the ASPM fix is first, that
would be better.

4) Your "Remove not needed check in disable aspm link" patch makes
pci_disable_link_state() disable ASPM even when the OS doesn't have
permission to control ASPM.  I think this is a mistake.  I proposed a
similar change in [1], but Rafael and Matthew thought it was too
risky, and I agree.

Bjorn

[1] https://lkml.kernel.org/r/20130510225257.GA10847@google.com

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 14:11                                       ` Bjorn Helgaas
@ 2013-06-14 16:17                                         ` Yinghai Lu
  2013-06-14 16:33                                           ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-14 16:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Fri, Jun 14, 2013 at 7:11 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> Here are some of my notes from trying to sort this out, in chronological
> order:
>
>     29594404 v3.7
>       Bus scanned before requesting _OSC control
>       pre-1.1 ath5k has ASPM disabled (works fine)
>
>     8c33f51d "request _OSC control before scanning bus"
>
>     19f949f5 v3.8
>       _OSC control requested before scanning bus
>       Now pre-1.1 ath5k has ASPM enabled and doesn't work
>       https://bugzilla.kernel.org/show_bug.cgi?id=55211 opened
>
>     b8178f13 "revert 'request _OSC control before scanning bus' (8c33f51d)"
>       Bus now scanned before requesting _OSC control (as in v3.7)
>
>     c1be5a5b v3.9
>       pciehp claims slots first, even when both pciehp & acpiphp are
>       built-in, because pciehp module_init precedes acpiphp module_init
>       in link order
>
>     6037a803 "Convert acpiphp to be builtin only"
>       This also adds "acpiphp.disable" boot option
>
>     3b63aaa7 "Do not use ACPI PCI subdriver mechanism"
>       Now acpiphp claims slots first because we call
>       acpiphp_enumerate_slots() from pcibios_add_bus() during PCI device
>       enumeration.  This happens before pciehp, which still uses
>       module_init.
>
>     f722406f v3.10-rc1
>
>     ........ "Revert reverting of 'request _OSC control before scanning bus' (b8178f13)"
>       _OSC control requested before scanning bus (as in v3.8)
>       pre-1.1 ath5k probably has ASPM enabled and doesn't work
>
>     ........ "Remove not needed check in disable aspm link"
>       Now pci_disable_link_state() unconditionally disables ASPM,
>       even when BIOS hasn't given us ASPM control
>
>
> 1) The problem you're trying to fix is that when both acpiphp and
> pciehp are supported for the same slot, acpiphp claims the slot first
> and pciehp will not claim it.  I think this problem was introduced by
> 3b63aaa7, which was merged after v3.9.  Therefore, v3.9 should work
> correctly, and this regression appeared in v3.10-rc1.
>
> 2) As you say, acpiphp cannot be a module, so the user would have to
> rebuild the kernel to remove it.  However, 6037a803 *did* add a
> "acpiphp.disable" boot option, so that should be a workaround that
> allows pciehp to claim the slot.

How about the same system that some slots need to be handled by acpiphp
and some others need to be handled by pciehp ?

for example: laptop that have dock that will need acpiphp, and also have
pci express card that need pciehp.

>
> 3) I think your "revert reverting" patch gets us back to the same
> situation we had after 8c33f51d, i.e., Roman's pre-1.1 ath5k device
> will have ASPM enabled and won't work.  I don't want to leave the tree
> in this broken state, even though you intend to fix it in the next
> patch.  If you can reorder your patches so the ASPM fix is first, that
> would be better.

yes.

We could apply your patch in [1] at first, and revert the reverting.
and do not touch pcie_clear_aspm now.

>
> 4) Your "Remove not needed check in disable aspm link" patch makes
> pci_disable_link_state() disable ASPM even when the OS doesn't have
> permission to control ASPM.  I think this is a mistake.  I proposed a
> similar change in [1], but Rafael and Matthew thought it was too
> risky, and I agree.

before all those changes, and in current state:
quirk disable aspm is before _osc support and control are set.
aka in pci_acpi_scan_root will allocate all link state struct, and quirk
call pci_disable_link_state, and later will _osc support or control can
not be set, pcie_no_aspm is called, can will block all aspm operation.

That is risky too?, why booting path quirk could do that, but driver
and hot-add quirk path can not do that ?

or we can have another pci_disable_link_state always work on quirk path only?

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 16:17                                         ` Yinghai Lu
@ 2013-06-14 16:33                                           ` Bjorn Helgaas
  2013-06-14 16:57                                             ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-14 16:33 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Fri, Jun 14, 2013 at 10:17 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Jun 14, 2013 at 7:11 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> Here are some of my notes from trying to sort this out, in chronological
>> order:
>>
>>     29594404 v3.7
>>       Bus scanned before requesting _OSC control
>>       pre-1.1 ath5k has ASPM disabled (works fine)
>>
>>     8c33f51d "request _OSC control before scanning bus"
>>
>>     19f949f5 v3.8
>>       _OSC control requested before scanning bus
>>       Now pre-1.1 ath5k has ASPM enabled and doesn't work
>>       https://bugzilla.kernel.org/show_bug.cgi?id=55211 opened
>>
>>     b8178f13 "revert 'request _OSC control before scanning bus' (8c33f51d)"
>>       Bus now scanned before requesting _OSC control (as in v3.7)
>>
>>     c1be5a5b v3.9
>>       pciehp claims slots first, even when both pciehp & acpiphp are
>>       built-in, because pciehp module_init precedes acpiphp module_init
>>       in link order
>>
>>     6037a803 "Convert acpiphp to be builtin only"
>>       This also adds "acpiphp.disable" boot option
>>
>>     3b63aaa7 "Do not use ACPI PCI subdriver mechanism"
>>       Now acpiphp claims slots first because we call
>>       acpiphp_enumerate_slots() from pcibios_add_bus() during PCI device
>>       enumeration.  This happens before pciehp, which still uses
>>       module_init.
>>
>>     f722406f v3.10-rc1
>>
>>     ........ "Revert reverting of 'request _OSC control before scanning bus' (b8178f13)"
>>       _OSC control requested before scanning bus (as in v3.8)
>>       pre-1.1 ath5k probably has ASPM enabled and doesn't work
>>
>>     ........ "Remove not needed check in disable aspm link"
>>       Now pci_disable_link_state() unconditionally disables ASPM,
>>       even when BIOS hasn't given us ASPM control
>>
>>
>> 1) The problem you're trying to fix is that when both acpiphp and
>> pciehp are supported for the same slot, acpiphp claims the slot first
>> and pciehp will not claim it.  I think this problem was introduced by
>> 3b63aaa7, which was merged after v3.9.  Therefore, v3.9 should work
>> correctly, and this regression appeared in v3.10-rc1.
>>
>> 2) As you say, acpiphp cannot be a module, so the user would have to
>> rebuild the kernel to remove it.  However, 6037a803 *did* add a
>> "acpiphp.disable" boot option, so that should be a workaround that
>> allows pciehp to claim the slot.
>
> How about the same system that some slots need to be handled by acpiphp
> and some others need to be handled by pciehp ?
>
> for example: laptop that have dock that will need acpiphp, and also have
> pci express card that need pciehp.
>
>>
>> 3) I think your "revert reverting" patch gets us back to the same
>> situation we had after 8c33f51d, i.e., Roman's pre-1.1 ath5k device
>> will have ASPM enabled and won't work.  I don't want to leave the tree
>> in this broken state, even though you intend to fix it in the next
>> patch.  If you can reorder your patches so the ASPM fix is first, that
>> would be better.
>
> yes.
>
> We could apply your patch in [1] at first, and revert the reverting.
> and do not touch pcie_clear_aspm now.
>
>>
>> 4) Your "Remove not needed check in disable aspm link" patch makes
>> pci_disable_link_state() disable ASPM even when the OS doesn't have
>> permission to control ASPM.  I think this is a mistake.  I proposed a
>> similar change in [1], but Rafael and Matthew thought it was too
>> risky, and I agree.
>
> before all those changes, and in current state:
> quirk disable aspm is before _osc support and control are set.

Can you please refer to specific function names?  I can't read your mind.

You might be referring to quirk_disable_aspm_l0s().  This is a
pci_fixup_final quirk that calls pci_disable_link_state().  In the
current tree, we enumerate devices before requesting _OSC control.
However, pci_fixup_final quirks are not run until the
pci_apply_final_quirks() fs_initcall, which is after we request _OSC
control.

As far as I can tell, we never call pci_disable_link_state() before
calling pcie_no_aspm().

> aka in pci_acpi_scan_root will allocate all link state struct, and quirk
> call pci_disable_link_state, and later will _osc support or control can
> not be set, pcie_no_aspm is called, can will block all aspm operation.
>
> That is risky too?, why booting path quirk could do that, but driver
> and hot-add quirk path can not do that ?
>
> or we can have another pci_disable_link_state always work on quirk path only?
>
> Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 16:33                                           ` Bjorn Helgaas
@ 2013-06-14 16:57                                             ` Yinghai Lu
  2013-06-14 17:44                                               ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-14 16:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Fri, Jun 14, 2013 at 9:33 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Fri, Jun 14, 2013 at 10:17 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>
> Can you please refer to specific function names?  I can't read your mind.
>
> You might be referring to quirk_disable_aspm_l0s().  This is a
> pci_fixup_final quirk that calls pci_disable_link_state().  In the
> current tree, we enumerate devices before requesting _OSC control.
> However, pci_fixup_final quirks are not run until the
> pci_apply_final_quirks() fs_initcall, which is after we request _OSC
> control.
>
> As far as I can tell, we never call pci_disable_link_state() before
> calling pcie_no_aspm().

ok, you are right, that is not pci_disable_link_state.

It is pcie_aspm_init_link_state ==> pcie_aspm_sanity_check in booting path
that disable aspm.  It has  "if (aspm_disabled)" in it, and it cause
the difference.

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 16:57                                             ` Yinghai Lu
@ 2013-06-14 17:44                                               ` Bjorn Helgaas
  2013-06-14 18:26                                                 ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-14 17:44 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Fri, Jun 14, 2013 at 10:57 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Jun 14, 2013 at 9:33 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Fri, Jun 14, 2013 at 10:17 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>>
>> Can you please refer to specific function names?  I can't read your mind.
>>
>> You might be referring to quirk_disable_aspm_l0s().  This is a
>> pci_fixup_final quirk that calls pci_disable_link_state().  In the
>> current tree, we enumerate devices before requesting _OSC control.
>> However, pci_fixup_final quirks are not run until the
>> pci_apply_final_quirks() fs_initcall, which is after we request _OSC
>> control.
>>
>> As far as I can tell, we never call pci_disable_link_state() before
>> calling pcie_no_aspm().
>
> ok, you are right, that is not pci_disable_link_state.
>
> It is pcie_aspm_init_link_state ==> pcie_aspm_sanity_check in booting path
> that disable aspm.  It has  "if (aspm_disabled)" in it, and it cause
> the difference.

Yes, I agree, the pcie_aspm_init_link_state() path uses aspm_disabled
before we set it:

    acpi_pci_root_add
      pci_acpi_scan_root
        pci_scan_child_bus
          pci_scan_slot
            pcie_aspm_init_link_state
              pcie_aspm_sanity_check
                if (aspm_disabled)              # used before set
                  ...
      acpi_pci_osc_control_set
      pcie_no_aspm
        aspm_disabled = 1                       # set

That might mean we do some ASPM configuration during enumeration (in
pci_scan_slot()) even though the BIOS hasn't given us permission.  It
looks like we did that even in v3.7, since we did the enumeration
before the _OSC there as well.  That looks like a bug to me.

I don't think the fact that we have been doing ASPM config during
enumeration before _OSC is an argument for dropping the check in
pci_disable_link_state().

Bjorn

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 17:44                                               ` Bjorn Helgaas
@ 2013-06-14 18:26                                                 ` Yinghai Lu
  2013-06-14 21:26                                                   ` Bjorn Helgaas
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-14 18:26 UTC (permalink / raw)
  To: Bjorn Helgaas, Matthew Garrett
  Cc: Jiang Liu, Roman Yepishev, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman

On Fri, Jun 14, 2013 at 10:44 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Fri, Jun 14, 2013 at 10:57 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Fri, Jun 14, 2013 at 9:33 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> On Fri, Jun 14, 2013 at 10:17 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>>>
>>> Can you please refer to specific function names?  I can't read your mind.
>>>
>>> You might be referring to quirk_disable_aspm_l0s().  This is a
>>> pci_fixup_final quirk that calls pci_disable_link_state().  In the
>>> current tree, we enumerate devices before requesting _OSC control.
>>> However, pci_fixup_final quirks are not run until the
>>> pci_apply_final_quirks() fs_initcall, which is after we request _OSC
>>> control.
>>>
>>> As far as I can tell, we never call pci_disable_link_state() before
>>> calling pcie_no_aspm().
>>
>> ok, you are right, that is not pci_disable_link_state.
>>
>> It is pcie_aspm_init_link_state ==> pcie_aspm_sanity_check in booting path
>> that disable aspm.  It has  "if (aspm_disabled)" in it, and it cause
>> the difference.
>
> Yes, I agree, the pcie_aspm_init_link_state() path uses aspm_disabled
> before we set it:
>
>     acpi_pci_root_add
>       pci_acpi_scan_root
>         pci_scan_child_bus
>           pci_scan_slot
>             pcie_aspm_init_link_state
>               pcie_aspm_sanity_check
>                 if (aspm_disabled)              # used before set
>                   ...
>       acpi_pci_osc_control_set
>       pcie_no_aspm
>         aspm_disabled = 1                       # set
>
> That might mean we do some ASPM configuration during enumeration (in
> pci_scan_slot()) even though the BIOS hasn't given us permission.  It
> looks like we did that even in v3.7, since we did the enumeration
> before the _OSC there as well.  That looks like a bug to me.

agreed. that means commits from Matthew Garrett

commit 4949be16822e92a18ea0cc1616319926628092ee
Author: Matthew Garrett <mjg@redhat.com>
Date:   Tue Mar 6 13:41:49 2012 -0500

    PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled

commit c9651e70ad0aa499814817cbf3cc1d0b806ed3a1
Author: Matthew Garrett <mjg@redhat.com>
Date:   Tue Mar 27 10:17:41 2012 -0400

    ASPM: Fix pcie devices with non-pcie children

will only works when the user specify "aspm=off" in boot command line.

(Roman's should have problem when he boot current linus tree with
"aspm=off", as no one will disable aspm for the offending pci devices)

To close the hole that Matthew' commits miss, that we should move _OSC
support/control set ahead.

For Roman's system it will have to fail, as BIOS enable prep-1.1 pcie devices
aspm, and do not handle over control to OS, so os can not disable aspm link
state for it.

To workaround the problem in Roman's system, we can add pcie_aspm=force_off

so we will have
pcie_aspm=off
pcie_aspm=force
pcie_aspm=force_off

What a mess!

>
> I don't think the fact that we have been doing ASPM config during
> enumeration before _OSC is an argument for dropping the check in
> pci_disable_link_state().

Agreed.

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 18:26                                                 ` Yinghai Lu
@ 2013-06-14 21:26                                                   ` Bjorn Helgaas
  2013-06-14 21:30                                                     ` Matthew Garrett
  2013-06-14 22:17                                                     ` Yinghai Lu
  0 siblings, 2 replies; 38+ messages in thread
From: Bjorn Helgaas @ 2013-06-14 21:26 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Matthew Garrett, Jiang Liu, Roman Yepishev, Rafael J. Wysocki,
	linux-pci, linux-acpi, linux-kernel, Linus Torvalds,
	Andrew Morton, Greg Kroah-Hartman, Maxim Levitsky,
	Jussi Kivilinna

[+cc Maxim, Jussi]

On Fri, Jun 14, 2013 at 12:26 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Jun 14, 2013 at 10:44 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Fri, Jun 14, 2013 at 10:57 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>>> On Fri, Jun 14, 2013 at 9:33 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>>> On Fri, Jun 14, 2013 at 10:17 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>>>>
>>>> Can you please refer to specific function names?  I can't read your mind.
>>>>
>>>> You might be referring to quirk_disable_aspm_l0s().  This is a
>>>> pci_fixup_final quirk that calls pci_disable_link_state().  In the
>>>> current tree, we enumerate devices before requesting _OSC control.
>>>> However, pci_fixup_final quirks are not run until the
>>>> pci_apply_final_quirks() fs_initcall, which is after we request _OSC
>>>> control.
>>>>
>>>> As far as I can tell, we never call pci_disable_link_state() before
>>>> calling pcie_no_aspm().
>>>
>>> ok, you are right, that is not pci_disable_link_state.
>>>
>>> It is pcie_aspm_init_link_state ==> pcie_aspm_sanity_check in booting path
>>> that disable aspm.  It has  "if (aspm_disabled)" in it, and it cause
>>> the difference.
>>
>> Yes, I agree, the pcie_aspm_init_link_state() path uses aspm_disabled
>> before we set it:
>>
>>     acpi_pci_root_add
>>       pci_acpi_scan_root
>>         pci_scan_child_bus
>>           pci_scan_slot
>>             pcie_aspm_init_link_state
>>               pcie_aspm_sanity_check
>>                 if (aspm_disabled)              # used before set
>>                   ...
>>       acpi_pci_osc_control_set
>>       pcie_no_aspm
>>         aspm_disabled = 1                       # set
>>
>> That might mean we do some ASPM configuration during enumeration (in
>> pci_scan_slot()) even though the BIOS hasn't given us permission.  It
>> looks like we did that even in v3.7, since we did the enumeration
>> before the _OSC there as well.  That looks like a bug to me.
>
> agreed. that means commits from Matthew Garrett
>
> commit 4949be16822e92a18ea0cc1616319926628092ee
> Author: Matthew Garrett <mjg@redhat.com>
> Date:   Tue Mar 6 13:41:49 2012 -0500
>
>     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled
>
> commit c9651e70ad0aa499814817cbf3cc1d0b806ed3a1
> Author: Matthew Garrett <mjg@redhat.com>
> Date:   Tue Mar 27 10:17:41 2012 -0400
>
>     ASPM: Fix pcie devices with non-pcie children
>
> will only works when the user specify "aspm=off" in boot command line.
>
> (Roman's should have problem when he boot current linus tree with
> "aspm=off", as no one will disable aspm for the offending pci devices)
>
> To close the hole that Matthew' commits miss, that we should move _OSC
> support/control set ahead.
>
> For Roman's system it will have to fail, as BIOS enable prep-1.1 pcie devices
> aspm, and do not handle over control to OS, so os can not disable aspm link
> state for it.
>
> To workaround the problem in Roman's system, we can add pcie_aspm=force_off
>
> so we will have
> pcie_aspm=off
> pcie_aspm=force
> pcie_aspm=force_off
>
> What a mess!

Yeah, this is a huge mess.  It makes my head hurt.  I don't think it's
reasonable to add more flags because that will make my head hurt even
more.

If I understand correctly, on Roman's system (the Acer Aspire One
AOA150 netbook mentioned in
https://bugzilla.kernel.org/show_bug.cgi?id=55211):

  - The BIOS leaves ASPM enabled for the ath5k device (03:00.0)
  - The BIOS does not allow the OS to manage ASPM (via _OSC)
  - The ath5k device does not work correctly with ASPM enabled
  - The ath5k driver calls pci_disable_link_state(), but we do not
disable ASPM because we don't have permission from the BIOS

This is basically the case I investigated in bz 57331 [1], and my
conclusion was that Windows behaves the same way, i.e., Windows also
leaves ASPM enabled in this situation.

It would be interesting to know whether that device on Roman's machine
works under Windows and what the ASPM configuration there is.  When
Maxim added the pci_disable_link_state() to ath5k with 6ccf15a1, he
did say that the Windows driver disabled L0s [2], but I don't know
what machine that was or what its _OSC method said.

At the time of 6ccf15a1, Linux evaluated _OSC but did not call
pcie_no_aspm() when it failed, so the pci_disable_link_state() in
ath5k actually *did* disable ASPM.

I did find the Atheros Windows driver for the AOA150 on the Acer
website [3], and the .INF file has several interesting mentions of
ASPM, but I don't know what they mean.

Bjorn

[1] https://bugzilla.kernel.org/show_bug.cgi?id=57331#c5

[2] https://lists.ath5k.org/pipermail/ath5k-devel/2010-June/003842.html

[3] http://global-download.acer.com/GDFiles/Driver/Wireless%20LAN/WLAN_Atheros_7.6.0.224_XPx86_A.zip?acerid=633639843308102758&Step1=NETBOOK,%20CHROMEBOOK&Step2=ASPIRE%20ONE&Step3=AOA150&OS=ALL&LC=en&BC=ACER&SC=PA_6

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 21:26                                                   ` Bjorn Helgaas
@ 2013-06-14 21:30                                                     ` Matthew Garrett
  2013-06-14 22:17                                                     ` Yinghai Lu
  1 sibling, 0 replies; 38+ messages in thread
From: Matthew Garrett @ 2013-06-14 21:30 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Jiang Liu, Roman Yepishev, Rafael J. Wysocki,
	linux-pci, linux-acpi, linux-kernel, Linus Torvalds,
	Andrew Morton, Greg Kroah-Hartman, Maxim Levitsky,
	Jussi Kivilinna

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 576 bytes --]

On Fri, 2013-06-14 at 15:26 -0600, Bjorn Helgaas wrote:

> I did find the Atheros Windows driver for the AOA150 on the Acer
> website [3], and the .INF file has several interesting mentions of
> ASPM, but I don't know what they mean.

They're not the standard functions, so it's possible that the Windows
driver for this hardware disables ASPM via its own register writes.

-- 
Matthew Garrett | mjg59@srcf.ucam.org
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 21:26                                                   ` Bjorn Helgaas
  2013-06-14 21:30                                                     ` Matthew Garrett
@ 2013-06-14 22:17                                                     ` Yinghai Lu
  2013-06-14 22:27                                                       ` Matthew Garrett
  1 sibling, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-14 22:17 UTC (permalink / raw)
  To: Bjorn Helgaas, Roman Yepishev
  Cc: Matthew Garrett, Jiang Liu, Rafael J. Wysocki, linux-pci,
	linux-acpi, linux-kernel, Linus Torvalds, Andrew Morton,
	Greg Kroah-Hartman, Maxim Levitsky, Jussi Kivilinna

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

On Fri, Jun 14, 2013 at 2:26 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> [+cc Maxim, Jussi]
>
> Yeah, this is a huge mess.  It makes my head hurt.  I don't think it's
> reasonable to add more flags because that will make my head hurt even
> more.
>
> If I understand correctly, on Roman's system (the Acer Aspire One
> AOA150 netbook mentioned in
> https://bugzilla.kernel.org/show_bug.cgi?id=55211):
>
>   - The BIOS leaves ASPM enabled for the ath5k device (03:00.0)
>   - The BIOS does not allow the OS to manage ASPM (via _OSC)
>   - The ath5k device does not work correctly with ASPM enabled
>   - The ath5k driver calls pci_disable_link_state(), but we do not
> disable ASPM because we don't have permission from the BIOS

looks like Matthew Garrett path is causing problem:

 commit 4949be16822e92a18ea0cc1616319926628092ee
 Author: Matthew Garrett <mjg@redhat.com>
 Date:   Tue Mar 6 13:41:49 2012 -0500

     PCI: ignore pre-1.1 ASPM quirking when ASPM is disabled

 commit c9651e70ad0aa499814817cbf3cc1d0b806ed3a1
 Author: Matthew Garrett <mjg@redhat.com>
 Date:   Tue Mar 27 10:17:41 2012 -0400

     ASPM: Fix pcie devices with non-pcie children

after those two patches, it aspm_disabled is set, via _osc early,
pre-1.1 devices aspm register will be touched even aspm_force is not specified.

pcie_aspm_init_link_state will all the way to
 pcie_config_aspm_path ==> pcie_config_aspm_link

in that path, aspm_disabled is not checked nowhere.

BTW, when aspm is not disabled, even the link is allocated, because it is
black listed,  so it is never get touched.
Matthew's patch is not needed in any case.

I would suspect that that aspm enabling in Roman's system could set by that
path instead of BIOS.

Roman, can you please check two patches + linsus' tree on your system?

Thanks

Yinghai

[-- Attachment #2: revert_revert_osc_change_linus.patch --]
[-- Type: application/octet-stream, Size: 5303 bytes --]

Subject: [PATCH] ACPI, PCI: Revert reverting of "PCI/ACPI: Request _OSC control before scanning PCI root bus"

In
| commit b8178f130e25c1bdac1c33e0996f1ff6e20ec08e
| Author: Bjorn Helgaas <bhelgaas@google.com>
| Date:   Mon Apr 1 15:47:39 2013 -0600
|
|    Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"
|
|    This reverts commit 8c33f51df406e1a1f7fa4e9b244845b7ebd61fa6.
for v3.9, "OSC set early" is reverted.

Now we have problem on v3.10, as it has
       - Remove ACPI PCI subdrivers (Jiang Liu, Myron Stowe)
       - Make acpiphp builtin only, not modular (Jiang Liu)
   acpiphp get registered with pcibios_add_bus very early.
We can not enable pcie native hotplug driver any more if system support
acpiphp and pciehp.

Calling path: in acpi_pci_root_add we have
1. pci_acpi_scan_root
     ==> pci devices enumeration and bus scanning.
       ==> pci_alloc_child_bus
         ==> pcibios_add_bus
           ==> acpi_pci_add_bus
             ==> acpiphp_enumerate_slots
               ==> ...==> register_slot
                 ==> device_is_managed_by_native_pciehp
                   ==> check osc_set with OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
2. _OSC set request
so we always have acpiphp hotplug slot registered at first, as OSC is
not set yet.

We need "OSC set early" before pci_apci_scan_root again.

The point: later aspm, pme, pciehp, aer support would rely on value in
root osc_support_set/osc_control_set.

For v3.10, let's put the "osc control set early" back,
as we have user in pci_acpi_scan_root.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e427dc5..207d773 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -382,6 +382,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
 	int result;
 	struct acpi_pci_root *root;
 	u32 flags, base_flags;
+	bool is_osc_granted = false;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
 	if (!root)
@@ -442,30 +443,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
 	flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
 	acpi_pci_osc_support(root, flags);
 
-	/*
-	 * TBD: Need PCI interface for enumeration/configuration of roots.
-	 */
-
-	mutex_lock(&acpi_pci_root_lock);
-	list_add_tail(&root->node, &acpi_pci_roots);
-	mutex_unlock(&acpi_pci_root_lock);
-
-	/*
-	 * Scan the Root Bridge
-	 * --------------------
-	 * Must do this prior to any attempt to bind the root device, as the
-	 * PCI namespace does not get created until this call is made (and
-	 * thus the root bridge's pci_dev does not exist).
-	 */
-	root->bus = pci_acpi_scan_root(root);
-	if (!root->bus) {
-		printk(KERN_ERR PREFIX
-			    "Bus %04x:%02x not present in PCI namespace\n",
-			    root->segment, (unsigned int)root->secondary.start);
-		result = -ENODEV;
-		goto out_del_root;
-	}
-
 	/* Indicate support for various _OSC capabilities. */
 	if (pci_ext_cfg_avail())
 		flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
@@ -484,7 +461,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
 			flags = base_flags;
 		}
 	}
-
 	if (!pcie_ports_disabled
 	    && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
 		flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -505,28 +481,54 @@ static int acpi_pci_root_add(struct acpi_device *device,
 		status = acpi_pci_osc_control_set(device->handle, &flags,
 				       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
 		if (ACPI_SUCCESS(status)) {
+			is_osc_granted = true;
 			dev_info(&device->dev,
 				"ACPI _OSC control (0x%02x) granted\n", flags);
-			if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
-				/*
-				 * We have ASPM control, but the FADT indicates
-				 * that it's unsupported. Clear it.
-				 */
-				pcie_clear_aspm(root->bus);
-			}
 		} else {
+			is_osc_granted = false;
 			dev_info(&device->dev,
 				"ACPI _OSC request failed (%s), "
 				"returned control mask: 0x%02x\n",
 				acpi_format_exception(status), flags);
-			pr_info("ACPI _OSC control for PCIe not granted, "
-				"disabling ASPM\n");
-			pcie_no_aspm();
 		}
 	} else {
 		dev_info(&device->dev,
-			 "Unable to request _OSC control "
-			 "(_OSC support mask: 0x%02x)\n", flags);
+			"Unable to request _OSC control "
+			"(_OSC support mask: 0x%02x)\n", flags);
+	}
+
+	/*
+	 * TBD: Need PCI interface for enumeration/configuration of roots.
+	 */
+
+	mutex_lock(&acpi_pci_root_lock);
+	list_add_tail(&root->node, &acpi_pci_roots);
+	mutex_unlock(&acpi_pci_root_lock);
+
+	/*
+	 * Scan the Root Bridge
+	 * --------------------
+	 * Must do this prior to any attempt to bind the root device, as the
+	 * PCI namespace does not get created until this call is made (and 
+	 * thus the root bridge's pci_dev does not exist).
+	 */
+	root->bus = pci_acpi_scan_root(root);
+	if (!root->bus) {
+		printk(KERN_ERR PREFIX
+			    "Bus %04x:%02x not present in PCI namespace\n",
+			    root->segment, (unsigned int)root->secondary.start);
+		result = -ENODEV;
+		goto out_del_root;
+	}
+
+	/* ASPM setting */
+	if (is_osc_granted) {
+		if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+			pcie_clear_aspm(root->bus);
+	} else {
+		pr_info("ACPI _OSC control for PCIe not granted, "
+			"disabling ASPM\n");
+		pcie_no_aspm();
 	}
 
 	pci_acpi_add_bus_pm_notifier(device, root->bus);

[-- Attachment #3: revert_matthew_aspm_disabled.patch --]
[-- Type: application/octet-stream, Size: 583 bytes --]

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 403a443..b795b43 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -493,15 +493,6 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
 			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
 		 */

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 22:17                                                     ` Yinghai Lu
@ 2013-06-14 22:27                                                       ` Matthew Garrett
  2013-06-14 22:40                                                         ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Matthew Garrett @ 2013-06-14 22:27 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Roman Yepishev, Jiang Liu, Rafael J. Wysocki,
	linux-pci, linux-acpi, linux-kernel, Linus Torvalds,
	Andrew Morton, Greg Kroah-Hartman, Maxim Levitsky,
	Jussi Kivilinna

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 755 bytes --]

On Fri, 2013-06-14 at 15:17 -0700, Yinghai Lu wrote:

> after those two patches, it aspm_disabled is set, via _osc early,
> pre-1.1 devices aspm register will be touched even aspm_force is not specified.

I don't follow. We were previously automatically disabling ASPM on
pre-1.1 devices even if _OSC didn't give us control. I've confirmed that
this was the wrong thing for us to be doing, and my patch changed the
behaviour such that if the firmware enables ASPM on a pre-1.1 device and
refuses to give us control via _OSC we will leave ASPM enabled.

-- 
Matthew Garrett | mjg59@srcf.ucam.org
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 22:27                                                       ` Matthew Garrett
@ 2013-06-14 22:40                                                         ` Yinghai Lu
  2013-06-14 22:48                                                           ` Matthew Garrett
  0 siblings, 1 reply; 38+ messages in thread
From: Yinghai Lu @ 2013-06-14 22:40 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Bjorn Helgaas, Roman Yepishev, Jiang Liu, Rafael J. Wysocki,
	linux-pci, linux-acpi, linux-kernel, Linus Torvalds,
	Andrew Morton, Greg Kroah-Hartman, Maxim Levitsky,
	Jussi Kivilinna

On Fri, Jun 14, 2013 at 3:27 PM, Matthew Garrett
<matthew.garrett@nebula.com> wrote:
> On Fri, 2013-06-14 at 15:17 -0700, Yinghai Lu wrote:
>
>> after those two patches, it aspm_disabled is set, via _osc early,
>> pre-1.1 devices aspm register will be touched even aspm_force is not specified.
>
> I don't follow. We were previously automatically disabling ASPM on
> pre-1.1 devices even if _OSC didn't give us control.

I don't think so, we just moved _OSC support/control setting before pci scan
in 3.8 and revert that in v3.9.

> I've confirmed that
> this was the wrong thing for us to be doing, and my patch changed the
> behaviour such that if the firmware enables ASPM on a pre-1.1 device and
> refuses to give us control via _OSC we will leave ASPM enabled.

not sure, aspm_disabled should be false on booting path when that function
is called, if you don't pass aspm=off.

Yinghai

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 22:40                                                         ` Yinghai Lu
@ 2013-06-14 22:48                                                           ` Matthew Garrett
  2013-06-14 23:00                                                             ` Yinghai Lu
  0 siblings, 1 reply; 38+ messages in thread
From: Matthew Garrett @ 2013-06-14 22:48 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Roman Yepishev, Jiang Liu, Rafael J. Wysocki,
	linux-pci, linux-acpi, linux-kernel, Linus Torvalds,
	Andrew Morton, Greg Kroah-Hartman, Maxim Levitsky,
	Jussi Kivilinna

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 964 bytes --]

On Fri, 2013-06-14 at 15:40 -0700, Yinghai Lu wrote:
> On Fri, Jun 14, 2013 at 3:27 PM, Matthew Garrett
> <matthew.garrett@nebula.com> wrote:
> > On Fri, 2013-06-14 at 15:17 -0700, Yinghai Lu wrote:
> >
> >> after those two patches, it aspm_disabled is set, via _osc early,
> >> pre-1.1 devices aspm register will be touched even aspm_force is not specified.
> >
> > I don't follow. We were previously automatically disabling ASPM on
> > pre-1.1 devices even if _OSC didn't give us control.
> 
> I don't think so, we just moved _OSC support/control setting before pci scan
> in 3.8 and revert that in v3.9.

Right, sorry, I don't mean _OSC, I mean the FADT flag. We were
previously automatically disabling ASPM on pre-1.1 devices even if the
FADT flag was set.

-- 
Matthew Garrett | mjg59@srcf.ucam.org
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] PCI: Remove not needed check in disable aspm link
  2013-06-14 22:48                                                           ` Matthew Garrett
@ 2013-06-14 23:00                                                             ` Yinghai Lu
  0 siblings, 0 replies; 38+ messages in thread
From: Yinghai Lu @ 2013-06-14 23:00 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Bjorn Helgaas, Roman Yepishev, Jiang Liu, Rafael J. Wysocki,
	linux-pci, linux-acpi, linux-kernel, Linus Torvalds,
	Andrew Morton, Greg Kroah-Hartman, Maxim Levitsky,
	Jussi Kivilinna

On Fri, Jun 14, 2013 at 3:48 PM, Matthew Garrett
<matthew.garrett@nebula.com> wrote:
> On Fri, 2013-06-14 at 15:40 -0700, Yinghai Lu wrote:
>> On Fri, Jun 14, 2013 at 3:27 PM, Matthew Garrett
>> <matthew.garrett@nebula.com> wrote:
>> > On Fri, 2013-06-14 at 15:17 -0700, Yinghai Lu wrote:
>> >
>> >> after those two patches, it aspm_disabled is set, via _osc early,
>> >> pre-1.1 devices aspm register will be touched even aspm_force is not specified.
>> >
>> > I don't follow. We were previously automatically disabling ASPM on
>> > pre-1.1 devices even if _OSC didn't give us control.
>>
>> I don't think so, we just moved _OSC support/control setting before pci scan
>> in 3.8 and revert that in v3.9.
>
> Right, sorry, I don't mean _OSC, I mean the FADT flag. We were
> previously automatically disabling ASPM on pre-1.1 devices even if the
> FADT flag was set.

so in that case aspm_disabled, never get set.
booting path: pcie_aspm_init_link_state will not touch aspm on pre-1.1 devices.

late, FADT checking will cause pcie_clear_aspm() get called, it will
call __pci_disable_link_state, and because following line in
pcie_aspm_link()
        /* Nothing to do if the link is already in the requested state */
        state &= (link->aspm_capable & ~link->aspm_disable);
        if (link->aspm_enabled == state)
                return;
aspm in pre-1.1 devices still does not get touched.

Maybe I miss something.

Thanks

Yinghai

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

end of thread, other threads:[~2013-06-14 23:00 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-55211-13546@https.bugzilla.kernel.org/>
     [not found] ` <20130317155023.5B2EB11FB81@bugzilla.kernel.org>
2013-03-17 17:19   ` [Bug 55211] pci_disable_link_state PCIE_LINK_STATE_L0S no longer disables ASPM for ath5k Yinghai Lu
2013-03-18 17:37     ` [PATCH] PCI: Remove not needed check in disable aspm link Yinghai Lu
2013-03-27 22:56       ` Bjorn Helgaas
2013-03-28  7:41         ` Yinghai Lu
2013-03-28 12:46           ` Bjorn Helgaas
2013-03-28 20:21             ` Yinghai Lu
2013-03-28 20:24             ` Yinghai Lu
2013-03-28 20:24               ` Yinghai Lu
2013-03-29  3:22                 ` Bjorn Helgaas
     [not found]                   ` <CAE9FiQVu5QyxaKsYzzQoroQD=TvsziHzDOtoeg=FvhZ8HyN5yw@mail.gmail.com>
2013-03-29 12:24                     ` Bjorn Helgaas
2013-03-29 18:02                       ` Yinghai Lu
2013-03-29 18:04                         ` Yinghai Lu
2013-04-01 23:52                           ` Bjorn Helgaas
2013-04-02  0:03                             ` Yinghai Lu
2013-04-02 20:10                               ` Bjorn Helgaas
2013-06-12  6:20                                 ` Yinghai Lu
2013-06-12 17:05                                   ` Bjorn Helgaas
2013-06-12 19:41                                     ` Yinghai Lu
2013-06-13  3:50                                       ` Bjorn Helgaas
2013-06-13  4:11                                         ` Jiang Liu (Gerry)
2013-06-13 13:57                                           ` Bjorn Helgaas
2013-06-13  5:47                                         ` Yinghai Lu
2013-06-13 12:04                                           ` Rafael J. Wysocki
2013-06-14 14:11                                       ` Bjorn Helgaas
2013-06-14 16:17                                         ` Yinghai Lu
2013-06-14 16:33                                           ` Bjorn Helgaas
2013-06-14 16:57                                             ` Yinghai Lu
2013-06-14 17:44                                               ` Bjorn Helgaas
2013-06-14 18:26                                                 ` Yinghai Lu
2013-06-14 21:26                                                   ` Bjorn Helgaas
2013-06-14 21:30                                                     ` Matthew Garrett
2013-06-14 22:17                                                     ` Yinghai Lu
2013-06-14 22:27                                                       ` Matthew Garrett
2013-06-14 22:40                                                         ` Yinghai Lu
2013-06-14 22:48                                                           ` Matthew Garrett
2013-06-14 23:00                                                             ` Yinghai Lu
2013-04-02  0:10                             ` Rafael J. Wysocki
2013-03-29 18:11                   ` Roman Yepishev

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