* [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available
@ 2013-08-23 17:19 Neil Horman
2013-08-23 19:38 ` Rafael J. Wysocki
` (3 more replies)
0 siblings, 4 replies; 21+ messages in thread
From: Neil Horman @ 2013-08-23 17:19 UTC (permalink / raw)
To: linux-kernel; +Cc: Neil Horman, Len Brown, Rafael J. Wysocki, linux-acpi
Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed
slots for hotplug capabilites got reversed. While this isn't a big deal, it did
uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls
pci_acpi_scan_root before setting the osc flags for the device handle.
pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp()
to determine if a given slot has pcie hotplug capabilties, whcih checks the
devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set
until after pci_acpi_scan_root_completes, the acpi code never sees that pcie
slots are hotplug capable and configures them all to use acpi instead.
Fix is pretty simple, just defer the scan until after the osc flags have been
set on the device. Tested by myself and it seems to work well.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Len Brown <lenb@kernel.org>
CC: "Rafael J. Wysocki" <rjw@sisk.pl>
CC: linux-acpi@vger.kernel.org
---
drivers/acpi/pci_root.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 5917839..a2c2661 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -437,27 +437,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.
- */
-
- /*
- * 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) {
- dev_err(&device->dev,
- "Bus %04x:%02x not present in PCI namespace\n",
- root->segment, (unsigned int)root->secondary.start);
- result = -ENODEV;
- goto end;
- }
-
- /* Indicate support for various _OSC capabilities. */
if (pci_ext_cfg_avail())
flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
if (pcie_aspm_support_enabled()) {
@@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device,
"(_OSC support mask: 0x%02x)\n", flags);
}
+ /*
+ * TBD: Need PCI interface for enumeration/configuration of roots.
+ */
+
+ /*
+ * 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) {
+ dev_err(&device->dev,
+ "Bus %04x:%02x not present in PCI namespace\n",
+ root->segment, (unsigned int)root->secondary.start);
+ result = -ENODEV;
+ goto end;
+ }
+
pci_acpi_add_bus_pm_notifier(device, root->bus);
if (device->wakeup.flags.run_wake)
device_set_run_wake(root->bus->bridge, true);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 17:19 [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available Neil Horman @ 2013-08-23 19:38 ` Rafael J. Wysocki 2013-08-23 20:05 ` Neil Horman 2013-08-26 15:36 ` [PATCH v2] " Neil Horman ` (2 subsequent siblings) 3 siblings, 1 reply; 21+ messages in thread From: Rafael J. Wysocki @ 2013-08-23 19:38 UTC (permalink / raw) To: Neil Horman Cc: linux-kernel, Len Brown, linux-acpi, Bjorn Helgaas, Yinghai Lu, Linux PCI [CCs added] Please always send PCI-related material to linux-pci in the first place. The change that broke things for you was actually intentional: 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. so I think we'll need to clean up the ASMP initialization after all. On Friday, August 23, 2013 01:19:39 PM Neil Horman wrote: > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > pci_acpi_scan_root before setting the osc flags for the device handle. > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > to determine if a given slot has pcie hotplug capabilties, whcih checks the > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > slots are hotplug capable and configures them all to use acpi instead. > > Fix is pretty simple, just defer the scan until after the osc flags have been > set on the device. Tested by myself and it seems to work well. > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > CC: Len Brown <lenb@kernel.org> > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > CC: linux-acpi@vger.kernel.org > --- > drivers/acpi/pci_root.c | 41 ++++++++++++++++++++--------------------- > 1 file changed, 20 insertions(+), 21 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 5917839..a2c2661 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -437,27 +437,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. > - */ > - > - /* > - * 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) { > - dev_err(&device->dev, > - "Bus %04x:%02x not present in PCI namespace\n", > - root->segment, (unsigned int)root->secondary.start); > - result = -ENODEV; > - goto end; > - } > - > - /* Indicate support for various _OSC capabilities. */ > if (pci_ext_cfg_avail()) > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > if (pcie_aspm_support_enabled()) { > @@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device, > "(_OSC support mask: 0x%02x)\n", flags); > } > > + /* > + * TBD: Need PCI interface for enumeration/configuration of roots. > + */ > + > + /* > + * 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) { > + dev_err(&device->dev, > + "Bus %04x:%02x not present in PCI namespace\n", > + root->segment, (unsigned int)root->secondary.start); > + result = -ENODEV; > + goto end; > + } > + > pci_acpi_add_bus_pm_notifier(device, root->bus); > if (device->wakeup.flags.run_wake) > device_set_run_wake(root->bus->bridge, true); > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 19:38 ` Rafael J. Wysocki @ 2013-08-23 20:05 ` Neil Horman 2013-08-23 20:53 ` Rafael J. Wysocki 0 siblings, 1 reply; 21+ messages in thread From: Neil Horman @ 2013-08-23 20:05 UTC (permalink / raw) To: Rafael J. Wysocki Cc: linux-kernel, Len Brown, linux-acpi, Bjorn Helgaas, Yinghai Lu, Linux PCI On Fri, Aug 23, 2013 at 09:38:18PM +0200, Rafael J. Wysocki wrote: > [CCs added] > > Please always send PCI-related material to linux-pci in the first place. > Sorry, I ran get_maintainers and it seemed to think linux-acpi was sufficient. > The change that broke things for you was actually intentional: > > 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. > > so I think we'll need to clean up the ASMP initialization after all. > Crud. Reading over the revert commit, it seems like the problem boils down to the odering of checking aspm_disabled. It seems to me that the simple fix is to track the desire for acpi to disable aspm separately from the users desire to disable aspm (aspm_disabled). Then we just turn the points where we check the aspm_disabled into the appropriate or of two variables, except for pcie_asmp_sanity_check, which remains sensitive to just the user disable option. Or is there more to this? Neil > On Friday, August 23, 2013 01:19:39 PM Neil Horman wrote: > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > > pci_acpi_scan_root before setting the osc flags for the device handle. > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > > to determine if a given slot has pcie hotplug capabilties, whcih checks the > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > > slots are hotplug capable and configures them all to use acpi instead. > > > > Fix is pretty simple, just defer the scan until after the osc flags have been > > set on the device. Tested by myself and it seems to work well. > > > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > > CC: Len Brown <lenb@kernel.org> > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > > CC: linux-acpi@vger.kernel.org > > --- > > drivers/acpi/pci_root.c | 41 ++++++++++++++++++++--------------------- > > 1 file changed, 20 insertions(+), 21 deletions(-) > > > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > > index 5917839..a2c2661 100644 > > --- a/drivers/acpi/pci_root.c > > +++ b/drivers/acpi/pci_root.c > > @@ -437,27 +437,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. > > - */ > > - > > - /* > > - * 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) { > > - dev_err(&device->dev, > > - "Bus %04x:%02x not present in PCI namespace\n", > > - root->segment, (unsigned int)root->secondary.start); > > - result = -ENODEV; > > - goto end; > > - } > > - > > - /* Indicate support for various _OSC capabilities. */ > > if (pci_ext_cfg_avail()) > > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > > if (pcie_aspm_support_enabled()) { > > @@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device, > > "(_OSC support mask: 0x%02x)\n", flags); > > } > > > > + /* > > + * TBD: Need PCI interface for enumeration/configuration of roots. > > + */ > > + > > + /* > > + * 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) { > > + dev_err(&device->dev, > > + "Bus %04x:%02x not present in PCI namespace\n", > > + root->segment, (unsigned int)root->secondary.start); > > + result = -ENODEV; > > + goto end; > > + } > > + > > pci_acpi_add_bus_pm_notifier(device, root->bus); > > if (device->wakeup.flags.run_wake) > > device_set_run_wake(root->bus->bridge, true); > > > -- > I speak only for myself. > Rafael J. Wysocki, Intel Open Source Technology Center. > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 20:05 ` Neil Horman @ 2013-08-23 20:53 ` Rafael J. Wysocki 2013-08-23 20:46 ` Bjorn Helgaas 0 siblings, 1 reply; 21+ messages in thread From: Rafael J. Wysocki @ 2013-08-23 20:53 UTC (permalink / raw) To: Neil Horman, Bjorn Helgaas Cc: linux-kernel, Len Brown, linux-acpi, Yinghai Lu, Linux PCI On Friday, August 23, 2013 04:05:11 PM Neil Horman wrote: > On Fri, Aug 23, 2013 at 09:38:18PM +0200, Rafael J. Wysocki wrote: > > [CCs added] > > > > Please always send PCI-related material to linux-pci in the first place. > > > Sorry, I ran get_maintainers and it seemed to think linux-acpi was sufficient. > > > The change that broke things for you was actually intentional: > > > > 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. > > > > so I think we'll need to clean up the ASMP initialization after all. > > > Crud. Reading over the revert commit, it seems like the problem boils down to > the odering of checking aspm_disabled. It seems to me that the simple fix is to > track the desire for acpi to disable aspm separately from the users desire to > disable aspm (aspm_disabled). Then we just turn the points where we check the > aspm_disabled into the appropriate or of two variables, except for > pcie_asmp_sanity_check, which remains sensitive to just the user disable option. > > Or is there more to this? No, I think you're right. Bjorn, what do you think? Rafael > > On Friday, August 23, 2013 01:19:39 PM Neil Horman wrote: > > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > > > pci_acpi_scan_root before setting the osc flags for the device handle. > > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > > > to determine if a given slot has pcie hotplug capabilties, whcih checks the > > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > > > slots are hotplug capable and configures them all to use acpi instead. > > > > > > Fix is pretty simple, just defer the scan until after the osc flags have been > > > set on the device. Tested by myself and it seems to work well. > > > > > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > > > CC: Len Brown <lenb@kernel.org> > > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > > > CC: linux-acpi@vger.kernel.org > > > --- > > > drivers/acpi/pci_root.c | 41 ++++++++++++++++++++--------------------- > > > 1 file changed, 20 insertions(+), 21 deletions(-) > > > > > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > > > index 5917839..a2c2661 100644 > > > --- a/drivers/acpi/pci_root.c > > > +++ b/drivers/acpi/pci_root.c > > > @@ -437,27 +437,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. > > > - */ > > > - > > > - /* > > > - * 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) { > > > - dev_err(&device->dev, > > > - "Bus %04x:%02x not present in PCI namespace\n", > > > - root->segment, (unsigned int)root->secondary.start); > > > - result = -ENODEV; > > > - goto end; > > > - } > > > - > > > - /* Indicate support for various _OSC capabilities. */ > > > if (pci_ext_cfg_avail()) > > > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > > > if (pcie_aspm_support_enabled()) { > > > @@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device, > > > "(_OSC support mask: 0x%02x)\n", flags); > > > } > > > > > > + /* > > > + * TBD: Need PCI interface for enumeration/configuration of roots. > > > + */ > > > + > > > + /* > > > + * 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) { > > > + dev_err(&device->dev, > > > + "Bus %04x:%02x not present in PCI namespace\n", > > > + root->segment, (unsigned int)root->secondary.start); > > > + result = -ENODEV; > > > + goto end; > > > + } > > > + > > > pci_acpi_add_bus_pm_notifier(device, root->bus); > > > if (device->wakeup.flags.run_wake) > > > device_set_run_wake(root->bus->bridge, true); > > > > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 20:53 ` Rafael J. Wysocki @ 2013-08-23 20:46 ` Bjorn Helgaas 2013-08-23 21:40 ` Rafael J. Wysocki 0 siblings, 1 reply; 21+ messages in thread From: Bjorn Helgaas @ 2013-08-23 20:46 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Neil Horman, linux-kernel@vger.kernel.org, Len Brown, linux-acpi@vger.kernel.org, Yinghai Lu, Linux PCI On Fri, Aug 23, 2013 at 2:53 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote: > On Friday, August 23, 2013 04:05:11 PM Neil Horman wrote: >> On Fri, Aug 23, 2013 at 09:38:18PM +0200, Rafael J. Wysocki wrote: >> > [CCs added] >> > >> > Please always send PCI-related material to linux-pci in the first place. >> > >> Sorry, I ran get_maintainers and it seemed to think linux-acpi was sufficient. >> >> > The change that broke things for you was actually intentional: >> > >> > 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. >> > >> > so I think we'll need to clean up the ASMP initialization after all. >> > >> Crud. Reading over the revert commit, it seems like the problem boils down to >> the odering of checking aspm_disabled. It seems to me that the simple fix is to >> track the desire for acpi to disable aspm separately from the users desire to >> disable aspm (aspm_disabled). Then we just turn the points where we check the >> aspm_disabled into the appropriate or of two variables, except for >> pcie_asmp_sanity_check, which remains sensitive to just the user disable option. >> >> Or is there more to this? > > No, I think you're right. > > Bjorn, what do you think? My opinion is that the _OSC/ASPM state management is ridiculously complicated already, and this would make it slightly more complicated. That's why my preference would be to attempt a more radical cleanup and simplification instead of adding another wart. But if you want to merge a patch along the lines of what Neil proposes, I won't object. Bjorn >> > On Friday, August 23, 2013 01:19:39 PM Neil Horman wrote: >> > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed >> > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did >> > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls >> > > pci_acpi_scan_root before setting the osc flags for the device handle. >> > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() >> > > to determine if a given slot has pcie hotplug capabilties, whcih checks the >> > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set >> > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie >> > > slots are hotplug capable and configures them all to use acpi instead. >> > > >> > > Fix is pretty simple, just defer the scan until after the osc flags have been >> > > set on the device. Tested by myself and it seems to work well. >> > > >> > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> >> > > CC: Len Brown <lenb@kernel.org> >> > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> >> > > CC: linux-acpi@vger.kernel.org >> > > --- >> > > drivers/acpi/pci_root.c | 41 ++++++++++++++++++++--------------------- >> > > 1 file changed, 20 insertions(+), 21 deletions(-) >> > > >> > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c >> > > index 5917839..a2c2661 100644 >> > > --- a/drivers/acpi/pci_root.c >> > > +++ b/drivers/acpi/pci_root.c >> > > @@ -437,27 +437,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. >> > > - */ >> > > - >> > > - /* >> > > - * 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) { >> > > - dev_err(&device->dev, >> > > - "Bus %04x:%02x not present in PCI namespace\n", >> > > - root->segment, (unsigned int)root->secondary.start); >> > > - result = -ENODEV; >> > > - goto end; >> > > - } >> > > - >> > > - /* Indicate support for various _OSC capabilities. */ >> > > if (pci_ext_cfg_avail()) >> > > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; >> > > if (pcie_aspm_support_enabled()) { >> > > @@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device, >> > > "(_OSC support mask: 0x%02x)\n", flags); >> > > } >> > > >> > > + /* >> > > + * TBD: Need PCI interface for enumeration/configuration of roots. >> > > + */ >> > > + >> > > + /* >> > > + * 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) { >> > > + dev_err(&device->dev, >> > > + "Bus %04x:%02x not present in PCI namespace\n", >> > > + root->segment, (unsigned int)root->secondary.start); >> > > + result = -ENODEV; >> > > + goto end; >> > > + } >> > > + >> > > pci_acpi_add_bus_pm_notifier(device, root->bus); >> > > if (device->wakeup.flags.run_wake) >> > > device_set_run_wake(root->bus->bridge, true); >> > > >> > -- > I speak only for myself. > Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 20:46 ` Bjorn Helgaas @ 2013-08-23 21:40 ` Rafael J. Wysocki 2013-08-23 22:04 ` Bjorn Helgaas 0 siblings, 1 reply; 21+ messages in thread From: Rafael J. Wysocki @ 2013-08-23 21:40 UTC (permalink / raw) To: Bjorn Helgaas Cc: Neil Horman, linux-kernel@vger.kernel.org, Len Brown, linux-acpi@vger.kernel.org, Yinghai Lu, Linux PCI On Friday, August 23, 2013 02:46:23 PM Bjorn Helgaas wrote: > On Fri, Aug 23, 2013 at 2:53 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote: > > On Friday, August 23, 2013 04:05:11 PM Neil Horman wrote: > >> On Fri, Aug 23, 2013 at 09:38:18PM +0200, Rafael J. Wysocki wrote: > >> > [CCs added] > >> > > >> > Please always send PCI-related material to linux-pci in the first place. > >> > > >> Sorry, I ran get_maintainers and it seemed to think linux-acpi was sufficient. > >> > >> > The change that broke things for you was actually intentional: > >> > > >> > 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. > >> > > >> > so I think we'll need to clean up the ASMP initialization after all. > >> > > >> Crud. Reading over the revert commit, it seems like the problem boils down to > >> the odering of checking aspm_disabled. It seems to me that the simple fix is to > >> track the desire for acpi to disable aspm separately from the users desire to > >> disable aspm (aspm_disabled). Then we just turn the points where we check the > >> aspm_disabled into the appropriate or of two variables, except for > >> pcie_asmp_sanity_check, which remains sensitive to just the user disable option. > >> > >> Or is there more to this? > > > > No, I think you're right. > > > > Bjorn, what do you think? > > My opinion is that the _OSC/ASPM state management is ridiculously > complicated already, and this would make it slightly more complicated. > That's why my preference would be to attempt a more radical cleanup > and simplification instead of adding another wart. Well, do you have anything specific in mind? > But if you want to merge a patch along the lines of what Neil > proposes, I won't object. I'm not sure what to do really, so I'm asking. :-) Rafael > >> > On Friday, August 23, 2013 01:19:39 PM Neil Horman wrote: > >> > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > >> > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > >> > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > >> > > pci_acpi_scan_root before setting the osc flags for the device handle. > >> > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > >> > > to determine if a given slot has pcie hotplug capabilties, whcih checks the > >> > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > >> > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > >> > > slots are hotplug capable and configures them all to use acpi instead. > >> > > > >> > > Fix is pretty simple, just defer the scan until after the osc flags have been > >> > > set on the device. Tested by myself and it seems to work well. > >> > > > >> > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > >> > > CC: Len Brown <lenb@kernel.org> > >> > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > >> > > CC: linux-acpi@vger.kernel.org > >> > > --- > >> > > drivers/acpi/pci_root.c | 41 ++++++++++++++++++++--------------------- > >> > > 1 file changed, 20 insertions(+), 21 deletions(-) > >> > > > >> > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > >> > > index 5917839..a2c2661 100644 > >> > > --- a/drivers/acpi/pci_root.c > >> > > +++ b/drivers/acpi/pci_root.c > >> > > @@ -437,27 +437,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. > >> > > - */ > >> > > - > >> > > - /* > >> > > - * 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) { > >> > > - dev_err(&device->dev, > >> > > - "Bus %04x:%02x not present in PCI namespace\n", > >> > > - root->segment, (unsigned int)root->secondary.start); > >> > > - result = -ENODEV; > >> > > - goto end; > >> > > - } > >> > > - > >> > > - /* Indicate support for various _OSC capabilities. */ > >> > > if (pci_ext_cfg_avail()) > >> > > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > >> > > if (pcie_aspm_support_enabled()) { > >> > > @@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device, > >> > > "(_OSC support mask: 0x%02x)\n", flags); > >> > > } > >> > > > >> > > + /* > >> > > + * TBD: Need PCI interface for enumeration/configuration of roots. > >> > > + */ > >> > > + > >> > > + /* > >> > > + * 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) { > >> > > + dev_err(&device->dev, > >> > > + "Bus %04x:%02x not present in PCI namespace\n", > >> > > + root->segment, (unsigned int)root->secondary.start); > >> > > + result = -ENODEV; > >> > > + goto end; > >> > > + } > >> > > + > >> > > pci_acpi_add_bus_pm_notifier(device, root->bus); > >> > > if (device->wakeup.flags.run_wake) > >> > > device_set_run_wake(root->bus->bridge, true); > >> > > > >> > > -- > > I speak only for myself. > > Rafael J. Wysocki, Intel Open Source Technology Center. -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 21:40 ` Rafael J. Wysocki @ 2013-08-23 22:04 ` Bjorn Helgaas 2013-08-24 1:57 ` Neil Horman 0 siblings, 1 reply; 21+ messages in thread From: Bjorn Helgaas @ 2013-08-23 22:04 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Neil Horman, linux-kernel@vger.kernel.org, Len Brown, linux-acpi@vger.kernel.org, Yinghai Lu, Linux PCI On Fri, Aug 23, 2013 at 3:40 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote: > On Friday, August 23, 2013 02:46:23 PM Bjorn Helgaas wrote: >> On Fri, Aug 23, 2013 at 2:53 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote: >> > On Friday, August 23, 2013 04:05:11 PM Neil Horman wrote: >> >> On Fri, Aug 23, 2013 at 09:38:18PM +0200, Rafael J. Wysocki wrote: >> >> > [CCs added] >> >> > >> >> > Please always send PCI-related material to linux-pci in the first place. >> >> > >> >> Sorry, I ran get_maintainers and it seemed to think linux-acpi was sufficient. >> >> >> >> > The change that broke things for you was actually intentional: >> >> > >> >> > 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. >> >> > >> >> > so I think we'll need to clean up the ASMP initialization after all. >> >> > >> >> Crud. Reading over the revert commit, it seems like the problem boils down to >> >> the odering of checking aspm_disabled. It seems to me that the simple fix is to >> >> track the desire for acpi to disable aspm separately from the users desire to >> >> disable aspm (aspm_disabled). Then we just turn the points where we check the >> >> aspm_disabled into the appropriate or of two variables, except for >> >> pcie_asmp_sanity_check, which remains sensitive to just the user disable option. >> >> >> >> Or is there more to this? >> > >> > No, I think you're right. >> > >> > Bjorn, what do you think? >> >> My opinion is that the _OSC/ASPM state management is ridiculously >> complicated already, and this would make it slightly more complicated. >> That's why my preference would be to attempt a more radical cleanup >> and simplification instead of adding another wart. > > Well, do you have anything specific in mind? If I had a specific fix in mind, I would just post it, but I've never had time to work through it all. What I mean by complicated is that every time I have to look at ASPM, I have to start by trying to figure out the relationships between these variables: aspm_policy # default 0 (POLICY_DEFAULT) or POLICY_PERFORMANCE or POLICY_POWERSAVE depending on config aspm_disabled # default 0 aspm_force # default 0 aspm_support_enabled # default true plus the _OSC-related code in acpi_pci_root_add(), which honestly is a rat's nest. It sounds like Neil's fix (while probably correct) would tangle that nest a little more. But I guess it would make sense to see the actual patch and the justification (a regression fix, I suppose, but the details weren't clear to me) before deciding. >> >> > On Friday, August 23, 2013 01:19:39 PM Neil Horman wrote: >> >> > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed >> >> > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did >> >> > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls >> >> > > pci_acpi_scan_root before setting the osc flags for the device handle. >> >> > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() >> >> > > to determine if a given slot has pcie hotplug capabilties, whcih checks the >> >> > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set >> >> > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie >> >> > > slots are hotplug capable and configures them all to use acpi instead. >> >> > > >> >> > > Fix is pretty simple, just defer the scan until after the osc flags have been >> >> > > set on the device. Tested by myself and it seems to work well. >> >> > > >> >> > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> >> >> > > CC: Len Brown <lenb@kernel.org> >> >> > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> >> >> > > CC: linux-acpi@vger.kernel.org >> >> > > --- >> >> > > drivers/acpi/pci_root.c | 41 ++++++++++++++++++++--------------------- >> >> > > 1 file changed, 20 insertions(+), 21 deletions(-) >> >> > > >> >> > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c >> >> > > index 5917839..a2c2661 100644 >> >> > > --- a/drivers/acpi/pci_root.c >> >> > > +++ b/drivers/acpi/pci_root.c >> >> > > @@ -437,27 +437,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. >> >> > > - */ >> >> > > - >> >> > > - /* >> >> > > - * 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) { >> >> > > - dev_err(&device->dev, >> >> > > - "Bus %04x:%02x not present in PCI namespace\n", >> >> > > - root->segment, (unsigned int)root->secondary.start); >> >> > > - result = -ENODEV; >> >> > > - goto end; >> >> > > - } >> >> > > - >> >> > > - /* Indicate support for various _OSC capabilities. */ >> >> > > if (pci_ext_cfg_avail()) >> >> > > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; >> >> > > if (pcie_aspm_support_enabled()) { >> >> > > @@ -520,6 +499,26 @@ static int acpi_pci_root_add(struct acpi_device *device, >> >> > > "(_OSC support mask: 0x%02x)\n", flags); >> >> > > } >> >> > > >> >> > > + /* >> >> > > + * TBD: Need PCI interface for enumeration/configuration of roots. >> >> > > + */ >> >> > > + >> >> > > + /* >> >> > > + * 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) { >> >> > > + dev_err(&device->dev, >> >> > > + "Bus %04x:%02x not present in PCI namespace\n", >> >> > > + root->segment, (unsigned int)root->secondary.start); >> >> > > + result = -ENODEV; >> >> > > + goto end; >> >> > > + } >> >> > > + >> >> > > pci_acpi_add_bus_pm_notifier(device, root->bus); >> >> > > if (device->wakeup.flags.run_wake) >> >> > > device_set_run_wake(root->bus->bridge, true); >> >> > > >> >> >> > -- >> > I speak only for myself. >> > Rafael J. Wysocki, Intel Open Source Technology Center. > -- > I speak only for myself. > Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 22:04 ` Bjorn Helgaas @ 2013-08-24 1:57 ` Neil Horman 0 siblings, 0 replies; 21+ messages in thread From: Neil Horman @ 2013-08-24 1:57 UTC (permalink / raw) To: Bjorn Helgaas Cc: Rafael J. Wysocki, linux-kernel@vger.kernel.org, Len Brown, linux-acpi@vger.kernel.org, Yinghai Lu, Linux PCI On Fri, Aug 23, 2013 at 04:04:59PM -0600, Bjorn Helgaas wrote: > On Fri, Aug 23, 2013 at 3:40 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote: > > On Friday, August 23, 2013 02:46:23 PM Bjorn Helgaas wrote: > >> On Fri, Aug 23, 2013 at 2:53 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote: > >> > On Friday, August 23, 2013 04:05:11 PM Neil Horman wrote: > >> >> On Fri, Aug 23, 2013 at 09:38:18PM +0200, Rafael J. Wysocki wrote: > >> >> > [CCs added] > >> >> > > >> >> > Please always send PCI-related material to linux-pci in the first place. > >> >> > > >> >> Sorry, I ran get_maintainers and it seemed to think linux-acpi was sufficient. > >> >> > >> >> > The change that broke things for you was actually intentional: > >> >> > > >> >> > 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. > >> >> > > >> >> > so I think we'll need to clean up the ASMP initialization after all. > >> >> > > >> >> Crud. Reading over the revert commit, it seems like the problem boils down to > >> >> the odering of checking aspm_disabled. It seems to me that the simple fix is to > >> >> track the desire for acpi to disable aspm separately from the users desire to > >> >> disable aspm (aspm_disabled). Then we just turn the points where we check the > >> >> aspm_disabled into the appropriate or of two variables, except for > >> >> pcie_asmp_sanity_check, which remains sensitive to just the user disable option. > >> >> > >> >> Or is there more to this? > >> > > >> > No, I think you're right. > >> > > >> > Bjorn, what do you think? > >> > >> My opinion is that the _OSC/ASPM state management is ridiculously > >> complicated already, and this would make it slightly more complicated. > >> That's why my preference would be to attempt a more radical cleanup > >> and simplification instead of adding another wart. > > > > Well, do you have anything specific in mind? > > If I had a specific fix in mind, I would just post it, but I've never > had time to work through it all. What I mean by complicated is that > every time I have to look at ASPM, I have to start by trying to figure > out the relationships between these variables: > > aspm_policy # default 0 (POLICY_DEFAULT) > or POLICY_PERFORMANCE > or POLICY_POWERSAVE depending on config > aspm_disabled # default 0 > aspm_force # default 0 > aspm_support_enabled # default true > > plus the _OSC-related code in acpi_pci_root_add(), which honestly is a > rat's nest. > I agree, I've only looked at it for an hour, and it looks pretty hairy. > It sounds like Neil's fix (while probably correct) would tangle that > nest a little more. But I guess it would make sense to see the actual No argument, it would add complexity to something thats already very complex. That said, I think this needs to be fixed. Currently there are several systems that are reporting conflicts between ACPI and PCIE hotplug. While that means theres lots of griping, theres several people willing to test, so I think we have an opportunity to fix this. > patch and the justification (a regression fix, I suppose, but the > details weren't clear to me) before deciding. > Agreed. A larger cleanup would be preferable at this point, but I'm not sufficiently versed in the code to do that right now, so I'll try write an appropriate for this particular bug, and see what you think on monday. Regards Neil ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 17:19 [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available Neil Horman 2013-08-23 19:38 ` Rafael J. Wysocki @ 2013-08-26 15:36 ` Neil Horman 2013-08-26 15:38 ` Neil Horman 2013-08-26 15:39 ` [PATCH v3] " Neil Horman 2013-08-29 20:17 ` [PATCH v4] " Neil Horman 3 siblings, 1 reply; 21+ messages in thread From: Neil Horman @ 2013-08-26 15:36 UTC (permalink / raw) To: linux-kernel Cc: root, Neil Horman, Len Brown, Rafael J. Wysocki, Bjorn Helgaas, linux-acpi, linux-pci From: root <root@dhcp47-16.lab.bos.redhat.com> Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed slots for hotplug capabilites got reversed. While this isn't a big deal, it did uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls pci_acpi_scan_root before setting the osc flags for the device handle. pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() to determine if a given slot has pcie hotplug capabilties, whcih checks the devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set until after pci_acpi_scan_root_completes, the acpi code never sees that pcie slots are hotplug capable and configures them all to use acpi instead. Fix is pretty simple, just defer the scan until after the osc flags have been set on the device. Tested by myself and it seems to work well. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Len Brown <lenb@kernel.org> CC: "Rafael J. Wysocki" <rjw@sisk.pl> CC: Bjorn Helgaas <bhelgaas@google.com> CC: linux-acpi@vger.kernel.org CC: linux-pci@vger.kernel.org --- Change notes: v2) eferred the disabling of aspm until after the acpi scan of the pci bus is complete. This was done to allow proper handling of pcie 1.1 devices, as per: 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" As discussed previously in the thread the disable logic for aspm needs to be untangled and refactored, which is not something I'm sufficently versed in teh hotplug code to do right now, but this fixes the problem above, and prevents the problem that necessitated the revert without adding any visible complexity to the user, so I think its ok. --- drivers/acpi/pci_root.c | 54 +++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5917839..1e80a90 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, struct acpi_pci_root *root; u32 flags, base_flags; acpi_handle handle = device->handle; + bool no_aspm = false; root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); if (!root) @@ -437,27 +438,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. - */ - - /* - * 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) { - dev_err(&device->dev, - "Bus %04x:%02x not present in PCI namespace\n", - root->segment, (unsigned int)root->secondary.start); - result = -ENODEV; - goto end; - } - - /* Indicate support for various _OSC capabilities. */ if (pci_ext_cfg_avail()) flags |= OSC_EXT_PCI_CONFIG_SUPPORT; if (pcie_aspm_support_enabled()) { @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, acpi_format_exception(status), flags); dev_info(&device->dev, "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); - pcie_no_aspm(); + /* + * We want to disable aspm here, but aspm_disabled + * needs to remain in its state from boot so that we + * properly handle pcie 1.1 devices. So we set this + * flag here, to defer the action until after the acpi + * root scan + */ + no_aspm = true; } } else { dev_info(&device->dev, @@ -520,6 +507,29 @@ static int acpi_pci_root_add(struct acpi_device *device, "(_OSC support mask: 0x%02x)\n", flags); } + /* + * TBD: Need PCI interface for enumeration/configuration of roots. + */ + + /* + * 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) { + dev_err(&device->dev, + "Bus %04x:%02x not present in PCI namespace\n", + root->segment, (unsigned int)root->secondary.start); + result = -ENODEV; + goto end; + } + + if (no_aspm) + 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); -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v2] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-26 15:36 ` [PATCH v2] " Neil Horman @ 2013-08-26 15:38 ` Neil Horman 0 siblings, 0 replies; 21+ messages in thread From: Neil Horman @ 2013-08-26 15:38 UTC (permalink / raw) To: linux-kernel Cc: root, Len Brown, Rafael J. Wysocki, Bjorn Helgaas, linux-acpi, linux-pci On Mon, Aug 26, 2013 at 11:36:21AM -0400, Neil Horman wrote: > From: root <root@dhcp47-16.lab.bos.redhat.com> > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > pci_acpi_scan_root before setting the osc flags for the device handle. > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > to determine if a given slot has pcie hotplug capabilties, whcih checks the > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > slots are hotplug capable and configures them all to use acpi instead. > > Fix is pretty simple, just defer the scan until after the osc flags have been > set on the device. Tested by myself and it seems to work well. > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > CC: Len Brown <lenb@kernel.org> > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > CC: Bjorn Helgaas <bhelgaas@google.com> > CC: linux-acpi@vger.kernel.org > CC: linux-pci@vger.kernel.org > Sorry, self NAK on this, sorry, I forgot to fix up authorship from my development machine. I'll resend in a second. Neil ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 17:19 [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available Neil Horman 2013-08-23 19:38 ` Rafael J. Wysocki 2013-08-26 15:36 ` [PATCH v2] " Neil Horman @ 2013-08-26 15:39 ` Neil Horman 2013-08-27 21:34 ` Bjorn Helgaas 2013-08-29 17:47 ` Bjorn Helgaas 2013-08-29 20:17 ` [PATCH v4] " Neil Horman 3 siblings, 2 replies; 21+ messages in thread From: Neil Horman @ 2013-08-26 15:39 UTC (permalink / raw) To: linux-kernel Cc: Neil Horman, Len Brown, Rafael J. Wysocki, Bjorn Helgaas, linux-acpi, linux-pci Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed slots for hotplug capabilites got reversed. While this isn't a big deal, it did uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls pci_acpi_scan_root before setting the osc flags for the device handle. pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() to determine if a given slot has pcie hotplug capabilties, whcih checks the devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set until after pci_acpi_scan_root_completes, the acpi code never sees that pcie slots are hotplug capable and configures them all to use acpi instead. Fix is pretty simple, just defer the scan until after the osc flags have been set on the device. Tested by myself and it seems to work well. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Len Brown <lenb@kernel.org> CC: "Rafael J. Wysocki" <rjw@sisk.pl> CC: Bjorn Helgaas <bhelgaas@google.com> CC: linux-acpi@vger.kernel.org CC: linux-pci@vger.kernel.org --- Change notes: v2) eferred the disabling of aspm until after the acpi scan of the pci bus is complete. This was done to allow proper handling of pcie 1.1 devices, as per: 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" As discussed previously in the thread the disable logic for aspm needs to be untangled and refactored, which is not something I'm sufficently versed in teh hotplug code to do right now, but this fixes the problem above, and prevents the problem that necessitated the revert without adding any visible complexity to the user, so I think its ok. v3) Fixup stupid authorship error --- drivers/acpi/pci_root.c | 54 +++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5917839..1e80a90 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, struct acpi_pci_root *root; u32 flags, base_flags; acpi_handle handle = device->handle; + bool no_aspm = false; root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); if (!root) @@ -437,27 +438,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. - */ - - /* - * 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) { - dev_err(&device->dev, - "Bus %04x:%02x not present in PCI namespace\n", - root->segment, (unsigned int)root->secondary.start); - result = -ENODEV; - goto end; - } - - /* Indicate support for various _OSC capabilities. */ if (pci_ext_cfg_avail()) flags |= OSC_EXT_PCI_CONFIG_SUPPORT; if (pcie_aspm_support_enabled()) { @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, acpi_format_exception(status), flags); dev_info(&device->dev, "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); - pcie_no_aspm(); + /* + * We want to disable aspm here, but aspm_disabled + * needs to remain in its state from boot so that we + * properly handle pcie 1.1 devices. So we set this + * flag here, to defer the action until after the acpi + * root scan + */ + no_aspm = true; } } else { dev_info(&device->dev, @@ -520,6 +507,29 @@ static int acpi_pci_root_add(struct acpi_device *device, "(_OSC support mask: 0x%02x)\n", flags); } + /* + * TBD: Need PCI interface for enumeration/configuration of roots. + */ + + /* + * 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) { + dev_err(&device->dev, + "Bus %04x:%02x not present in PCI namespace\n", + root->segment, (unsigned int)root->secondary.start); + result = -ENODEV; + goto end; + } + + if (no_aspm) + 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); -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-26 15:39 ` [PATCH v3] " Neil Horman @ 2013-08-27 21:34 ` Bjorn Helgaas 2013-08-27 23:43 ` Neil Horman 2013-08-29 17:47 ` Bjorn Helgaas 1 sibling, 1 reply; 21+ messages in thread From: Bjorn Helgaas @ 2013-08-27 21:34 UTC (permalink / raw) To: Neil Horman Cc: linux-kernel@vger.kernel.org, Len Brown, Rafael J. Wysocki, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Stefan Seyfried [+cc Stefan] On Mon, Aug 26, 2013 at 9:39 AM, Neil Horman <nhorman@tuxdriver.com> wrote: > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > pci_acpi_scan_root before setting the osc flags for the device handle. > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > to determine if a given slot has pcie hotplug capabilties, whcih checks the > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > slots are hotplug capable and configures them all to use acpi instead. I'd like to make it more explicit what we're fixing. Apparently this is a regression between v3.9 and v3.10. Is this a fix for problems like https://bugzilla.kernel.org/show_bug.cgi?id=60736 ? That bug is that an ExpressCard slot doesn't work unless we boot with "acpiphp.disable=1". I think what happens there is that acpiphp claims the slot before we run _OSC, so pciehp doesn't claim it, even though _OSC did grant us control over native PCIe hotplug. > Fix is pretty simple, just defer the scan until after the osc flags have been > set on the device. Tested by myself and it seems to work well. > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > CC: Len Brown <lenb@kernel.org> > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > CC: Bjorn Helgaas <bhelgaas@google.com> > CC: linux-acpi@vger.kernel.org > CC: linux-pci@vger.kernel.org > > --- > Change notes: > v2) eferred the disabling of aspm until after the acpi scan of the pci bus is > complete. This was done to allow proper handling of pcie 1.1 devices, as per: > > 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" > > As discussed previously in the thread the disable logic for aspm needs to be > untangled and refactored, which is not something I'm sufficently versed in teh > hotplug code to do right now, but this fixes the problem above, and prevents the > problem that necessitated the revert without adding any visible complexity to > the user, so I think its ok. > > v3) Fixup stupid authorship error > --- > drivers/acpi/pci_root.c | 54 +++++++++++++++++++++++++++++-------------------- > 1 file changed, 32 insertions(+), 22 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 5917839..1e80a90 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > struct acpi_pci_root *root; > u32 flags, base_flags; > acpi_handle handle = device->handle; > + bool no_aspm = false; > > root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); > if (!root) > @@ -437,27 +438,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. > - */ > - > - /* > - * 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) { > - dev_err(&device->dev, > - "Bus %04x:%02x not present in PCI namespace\n", > - root->segment, (unsigned int)root->secondary.start); > - result = -ENODEV; > - goto end; > - } > - > - /* Indicate support for various _OSC capabilities. */ > if (pci_ext_cfg_avail()) > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > if (pcie_aspm_support_enabled()) { > @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, > acpi_format_exception(status), flags); > dev_info(&device->dev, > "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); > - pcie_no_aspm(); > + /* > + * We want to disable aspm here, but aspm_disabled > + * needs to remain in its state from boot so that we > + * properly handle pcie 1.1 devices. So we set this > + * flag here, to defer the action until after the acpi > + * root scan > + */ > + no_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -520,6 +507,29 @@ static int acpi_pci_root_add(struct acpi_device *device, > "(_OSC support mask: 0x%02x)\n", flags); > } > > + /* > + * TBD: Need PCI interface for enumeration/configuration of roots. > + */ > + > + /* > + * 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) { > + dev_err(&device->dev, > + "Bus %04x:%02x not present in PCI namespace\n", > + root->segment, (unsigned int)root->secondary.start); > + result = -ENODEV; > + goto end; > + } > + > + if (no_aspm) > + 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); > -- > 1.8.1.4 > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-27 21:34 ` Bjorn Helgaas @ 2013-08-27 23:43 ` Neil Horman 2013-08-28 13:04 ` Bjorn Helgaas 0 siblings, 1 reply; 21+ messages in thread From: Neil Horman @ 2013-08-27 23:43 UTC (permalink / raw) To: Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Len Brown, Rafael J. Wysocki, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Stefan Seyfried On Tue, Aug 27, 2013 at 03:34:11PM -0600, Bjorn Helgaas wrote: > [+cc Stefan] > > On Mon, Aug 26, 2013 at 9:39 AM, Neil Horman <nhorman@tuxdriver.com> wrote: > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > > pci_acpi_scan_root before setting the osc flags for the device handle. > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > > to determine if a given slot has pcie hotplug capabilties, whcih checks the > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > > slots are hotplug capable and configures them all to use acpi instead. > > I'd like to make it more explicit what we're fixing. Apparently this > is a regression between v3.9 and v3.10. > > Is this a fix for problems like > https://bugzilla.kernel.org/show_bug.cgi?id=60736 ? That bug is that > an ExpressCard slot doesn't work unless we boot with > "acpiphp.disable=1". I think what happens there is that acpiphp > claims the slot before we run _OSC, so pciehp doesn't claim it, even > though _OSC did grant us control over native PCIe hotplug. > Yes, that bug is precisely what I am trying to fix (although your wording above is inverted from the problem in the bug). What happens is that acpiphp claims the pcie ports, because acpiphp init runs first, and we haven't yet parsed _OSC, which would have told acpiphp to yield control to pciehp. The initial fix I proposed fixed this by parsing _OSC prior to running the acpiphp bus scan, but that reintroduced the problem of not handling pcie 1.1 aspm properly. That has been fixed in v2/v3 by deferring the setting of aspm_disable until after the bus scan. Shall I submit a v4 with an updated changelog? Best Neil ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-27 23:43 ` Neil Horman @ 2013-08-28 13:04 ` Bjorn Helgaas 2013-08-28 13:23 ` Neil Horman 0 siblings, 1 reply; 21+ messages in thread From: Bjorn Helgaas @ 2013-08-28 13:04 UTC (permalink / raw) To: Neil Horman Cc: linux-kernel@vger.kernel.org, Len Brown, Rafael J. Wysocki, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Stefan Seyfried On Tue, Aug 27, 2013 at 5:43 PM, Neil Horman <nhorman@tuxdriver.com> wrote: > On Tue, Aug 27, 2013 at 03:34:11PM -0600, Bjorn Helgaas wrote: >> [+cc Stefan] >> >> On Mon, Aug 26, 2013 at 9:39 AM, Neil Horman <nhorman@tuxdriver.com> wrote: >> > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed >> > slots for hotplug capabilites got reversed. While this isn't a big deal, it did >> > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls >> > pci_acpi_scan_root before setting the osc flags for the device handle. >> > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() >> > to determine if a given slot has pcie hotplug capabilties, whcih checks the >> > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set >> > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie >> > slots are hotplug capable and configures them all to use acpi instead. >> >> I'd like to make it more explicit what we're fixing. Apparently this >> is a regression between v3.9 and v3.10. >> >> Is this a fix for problems like >> https://bugzilla.kernel.org/show_bug.cgi?id=60736 ? That bug is that >> an ExpressCard slot doesn't work unless we boot with >> "acpiphp.disable=1". I think what happens there is that acpiphp >> claims the slot before we run _OSC, so pciehp doesn't claim it, even >> though _OSC did grant us control over native PCIe hotplug. >> > Yes, that bug is precisely what I am trying to fix (although your wording above is > inverted from the problem in the bug). What happens is that acpiphp claims the > pcie ports, because acpiphp init runs first, and we haven't yet parsed _OSC, > which would have told acpiphp to yield control to pciehp. The initial fix I > proposed fixed this by parsing _OSC prior to running the acpiphp bus scan, but > that reintroduced the problem of not handling pcie 1.1 aspm properly. That has > been fixed in v2/v3 by deferring the setting of aspm_disable until after the bus > scan. > > Shall I submit a v4 with an updated changelog? No need, I'll update the changelog and include the bugzilla reference and post it for your approval. Thanks! Bjorn ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-28 13:04 ` Bjorn Helgaas @ 2013-08-28 13:23 ` Neil Horman 0 siblings, 0 replies; 21+ messages in thread From: Neil Horman @ 2013-08-28 13:23 UTC (permalink / raw) To: Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Len Brown, Rafael J. Wysocki, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Stefan Seyfried On Wed, Aug 28, 2013 at 07:04:47AM -0600, Bjorn Helgaas wrote: > On Tue, Aug 27, 2013 at 5:43 PM, Neil Horman <nhorman@tuxdriver.com> wrote: > > On Tue, Aug 27, 2013 at 03:34:11PM -0600, Bjorn Helgaas wrote: > >> [+cc Stefan] > >> > >> On Mon, Aug 26, 2013 at 9:39 AM, Neil Horman <nhorman@tuxdriver.com> wrote: > >> > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > >> > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > >> > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > >> > pci_acpi_scan_root before setting the osc flags for the device handle. > >> > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > >> > to determine if a given slot has pcie hotplug capabilties, whcih checks the > >> > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > >> > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > >> > slots are hotplug capable and configures them all to use acpi instead. > >> > >> I'd like to make it more explicit what we're fixing. Apparently this > >> is a regression between v3.9 and v3.10. > >> > >> Is this a fix for problems like > >> https://bugzilla.kernel.org/show_bug.cgi?id=60736 ? That bug is that > >> an ExpressCard slot doesn't work unless we boot with > >> "acpiphp.disable=1". I think what happens there is that acpiphp > >> claims the slot before we run _OSC, so pciehp doesn't claim it, even > >> though _OSC did grant us control over native PCIe hotplug. > >> > > Yes, that bug is precisely what I am trying to fix (although your wording above is > > inverted from the problem in the bug). What happens is that acpiphp claims the > > pcie ports, because acpiphp init runs first, and we haven't yet parsed _OSC, > > which would have told acpiphp to yield control to pciehp. The initial fix I > > proposed fixed this by parsing _OSC prior to running the acpiphp bus scan, but > > that reintroduced the problem of not handling pcie 1.1 aspm properly. That has > > been fixed in v2/v3 by deferring the setting of aspm_disable until after the bus > > scan. > > > > Shall I submit a v4 with an updated changelog? > > No need, I'll update the changelog and include the bugzilla reference > and post it for your approval. Thanks! > > Bjorn > Great, thanks! Neil ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-26 15:39 ` [PATCH v3] " Neil Horman 2013-08-27 21:34 ` Bjorn Helgaas @ 2013-08-29 17:47 ` Bjorn Helgaas 2013-08-29 18:12 ` Neil Horman 1 sibling, 1 reply; 21+ messages in thread From: Bjorn Helgaas @ 2013-08-29 17:47 UTC (permalink / raw) To: Neil Horman Cc: linux-kernel, Len Brown, Rafael J. Wysocki, linux-acpi, linux-pci On Mon, Aug 26, 2013 at 11:39:13AM -0400, Neil Horman wrote: > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > pci_acpi_scan_root before setting the osc flags for the device handle. > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > to determine if a given slot has pcie hotplug capabilties, whcih checks the > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > slots are hotplug capable and configures them all to use acpi instead. > > Fix is pretty simple, just defer the scan until after the osc flags have been > set on the device. Tested by myself and it seems to work well. > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > CC: Len Brown <lenb@kernel.org> > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > CC: Bjorn Helgaas <bhelgaas@google.com> > CC: linux-acpi@vger.kernel.org > CC: linux-pci@vger.kernel.org > > --- > Change notes: > v2) eferred the disabling of aspm until after the acpi scan of the pci bus is > complete. This was done to allow proper handling of pcie 1.1 devices, as per: > > 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" > > As discussed previously in the thread the disable logic for aspm needs to be > untangled and refactored, which is not something I'm sufficently versed in teh > hotplug code to do right now, but this fixes the problem above, and prevents the > problem that necessitated the revert without adding any visible complexity to > the user, so I think its ok. > > v3) Fixup stupid authorship error > --- > drivers/acpi/pci_root.c | 54 +++++++++++++++++++++++++++++-------------------- > 1 file changed, 32 insertions(+), 22 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 5917839..1e80a90 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > struct acpi_pci_root *root; > u32 flags, base_flags; > acpi_handle handle = device->handle; > + bool no_aspm = false; > > root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); > if (!root) > @@ -437,27 +438,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. > - */ > - > - /* > - * 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) { > - dev_err(&device->dev, > - "Bus %04x:%02x not present in PCI namespace\n", > - root->segment, (unsigned int)root->secondary.start); > - result = -ENODEV; > - goto end; > - } > - > - /* Indicate support for various _OSC capabilities. */ > if (pci_ext_cfg_avail()) > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > if (pcie_aspm_support_enabled()) { > @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, > acpi_format_exception(status), flags); > dev_info(&device->dev, > "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); > - pcie_no_aspm(); > + /* > + * We want to disable aspm here, but aspm_disabled > + * needs to remain in its state from boot so that we > + * properly handle pcie 1.1 devices. So we set this > + * flag here, to defer the action until after the acpi > + * root scan > + */ > + no_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -520,6 +507,29 @@ static int acpi_pci_root_add(struct acpi_device *device, > "(_OSC support mask: 0x%02x)\n", flags); > } > > + /* > + * TBD: Need PCI interface for enumeration/configuration of roots. > + */ > + > + /* > + * 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) { > + dev_err(&device->dev, > + "Bus %04x:%02x not present in PCI namespace\n", > + root->segment, (unsigned int)root->secondary.start); > + result = -ENODEV; > + goto end; > + } > + > + if (no_aspm) > + 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); I think there are two problems with this patch: 1) There's another call of pcie_no_aspm() at line 454 (in the error path when acpi_pci_osc_support() fails), which happens before scanning the bus. I think this needs to be converted to "no_aspm = true" as you did for the one in the error path when acpi_pci_osc_control_set() fails. 2) You effectively moved the call of "pcie_clear_aspm(root->bus)" so it now happens before scanning the bus, which will cause a NULL pointer dereference if we take that path. I think we need something like the patch below on top of your v3 patch. Can you take a look and see if this makes sense, and if so, update your patch to include these or similar fixes? Here are my notes about where the ASPM and root->osc_control_set setting and testing happen. Before your patch: acpi_pci_root_add root = kzalloc # root->osc_control_set = 0 acpi_pci_osc_support # indicate OS support for segments root->bus = pci_acpi_scan_root # SCAN BUS pci_create_root_bus pcibios_add_bus acpi_pci_add_bus acpiphp_enumerate_slots acpi_walk_namespace(..., register_slot, ...) register_slot device_is_managed_by_native_pciehp <test root->osc_control_set> # root->osc_control_set == 0 return if OS has PCIe hotplug control (we never do) acpiphp_register_hotplug_slot (so we always do this) acpi_pci_osc_support # indicate OS support for MSI, ASPM, etc if (_osc_support() failed) pci_no_aspm acpi_pci_osc_control_set # request OS control of hotplug, PME, AER, etc root->osc_control_set = XX if (_osc_control_set() succeeded) { if (FADT NO_ASPM bit) pcie_clear_aspm list_for_each_entry(..., &bus->devices, ...) } else pcie_no_aspm # _osc_control_set() failed After your patch: acpi_pci_root_add root = kzalloc # root->osc_control_set = 0 acpi_pci_osc_support # indicate OS support for segments if (_osc_support() failed) pci_no_aspm # ** (1) before bus scan acpi_pci_osc_support # indicate OS support for MSI, ASPM, etc acpi_pci_osc_control_set # request OS control of hotplug, PME, AER, etc root->osc_control_set = XX if (_osc_control_set() succeeded) { if (FADT NO_ASPM bit) pcie_clear_aspm(root->bus) # ** (2) root->bus == NULL list_for_each_entry(..., &bus->devices, ...) } else no_aspm = true # _osc_control_set() failed root->bus = pci_acpi_scan_root # SCAN BUS pci_create_root_bus pcibios_add_bus acpi_pci_add_bus acpiphp_enumerate_slots acpi_walk_namespace(..., register_slot, ...) register_slot device_is_managed_by_native_pciehp <test root->osc_control_set> return if OS has PCIe hotplug control acpiphp_register_hotplug_slot if (no_aspm) pcie_no_aspm Bjorn diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index a37a372..a67853e 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -378,7 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, struct acpi_pci_root *root; u32 flags, base_flags; acpi_handle handle = device->handle; - bool no_aspm = false; + bool no_aspm = false, clear_aspm = false; root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); if (!root) @@ -451,7 +451,7 @@ static int acpi_pci_root_add(struct acpi_device *device, if (ACPI_FAILURE(status)) { dev_info(&device->dev, "ACPI _OSC support " "notification failed, disabling PCIe ASPM\n"); - pcie_no_aspm(); + no_aspm = true; flags = base_flags; } } @@ -483,7 +483,7 @@ static int acpi_pci_root_add(struct acpi_device *device, * We have ASPM control, but the FADT indicates * that it's unsupported. Clear it. */ - pcie_clear_aspm(root->bus); + clear_aspm = true; } } else { dev_info(&device->dev, @@ -527,6 +527,10 @@ static int acpi_pci_root_add(struct acpi_device *device, goto end; } + if (clear_aspm) { + dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); + pcie_clear_aspm(root->bus); + } if (no_aspm) pcie_no_aspm(); ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-29 17:47 ` Bjorn Helgaas @ 2013-08-29 18:12 ` Neil Horman 0 siblings, 0 replies; 21+ messages in thread From: Neil Horman @ 2013-08-29 18:12 UTC (permalink / raw) To: Bjorn Helgaas Cc: linux-kernel, Len Brown, Rafael J. Wysocki, linux-acpi, linux-pci On Thu, Aug 29, 2013 at 11:47:13AM -0600, Bjorn Helgaas wrote: > On Mon, Aug 26, 2013 at 11:39:13AM -0400, Neil Horman wrote: > > Somewhere between 3.9 and 3.10 it seems the order in which pcie and acpi probed > > slots for hotplug capabilites got reversed. While this isn't a big deal, it did > > uncover a bug in the ACPI bus setup path. Specifically, acpi_pci_root_add calls > > pci_acpi_scan_root before setting the osc flags for the device handle. > > pci_acpi_scan_root, among other things uses device_is_managed_by_native_pciehp() > > to determine if a given slot has pcie hotplug capabilties, whcih checks the > > devices OSC_PCI_EXPRESS_NATIVE_HP_CONTROL flag. Since that flag is not set > > until after pci_acpi_scan_root_completes, the acpi code never sees that pcie > > slots are hotplug capable and configures them all to use acpi instead. > > > > Fix is pretty simple, just defer the scan until after the osc flags have been > > set on the device. Tested by myself and it seems to work well. > > > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > > CC: Len Brown <lenb@kernel.org> > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > > CC: Bjorn Helgaas <bhelgaas@google.com> > > CC: linux-acpi@vger.kernel.org > > CC: linux-pci@vger.kernel.org > > > > --- > > Change notes: > > v2) eferred the disabling of aspm until after the acpi scan of the pci bus is > > complete. This was done to allow proper handling of pcie 1.1 devices, as per: > > > > 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" > > > > As discussed previously in the thread the disable logic for aspm needs to be > > untangled and refactored, which is not something I'm sufficently versed in teh > > hotplug code to do right now, but this fixes the problem above, and prevents the > > problem that necessitated the revert without adding any visible complexity to > > the user, so I think its ok. > > > > v3) Fixup stupid authorship error > > --- > > drivers/acpi/pci_root.c | 54 +++++++++++++++++++++++++++++-------------------- > > 1 file changed, 32 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > > index 5917839..1e80a90 100644 > > --- a/drivers/acpi/pci_root.c > > +++ b/drivers/acpi/pci_root.c > > @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > > struct acpi_pci_root *root; > > u32 flags, base_flags; > > acpi_handle handle = device->handle; > > + bool no_aspm = false; > > > > root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); > > if (!root) > > @@ -437,27 +438,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. > > - */ > > - > > - /* > > - * 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) { > > - dev_err(&device->dev, > > - "Bus %04x:%02x not present in PCI namespace\n", > > - root->segment, (unsigned int)root->secondary.start); > > - result = -ENODEV; > > - goto end; > > - } > > - > > - /* Indicate support for various _OSC capabilities. */ > > if (pci_ext_cfg_avail()) > > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > > if (pcie_aspm_support_enabled()) { > > @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, > > acpi_format_exception(status), flags); > > dev_info(&device->dev, > > "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); > > - pcie_no_aspm(); > > + /* > > + * We want to disable aspm here, but aspm_disabled > > + * needs to remain in its state from boot so that we > > + * properly handle pcie 1.1 devices. So we set this > > + * flag here, to defer the action until after the acpi > > + * root scan > > + */ > > + no_aspm = true; > > } > > } else { > > dev_info(&device->dev, > > @@ -520,6 +507,29 @@ static int acpi_pci_root_add(struct acpi_device *device, > > "(_OSC support mask: 0x%02x)\n", flags); > > } > > > > + /* > > + * TBD: Need PCI interface for enumeration/configuration of roots. > > + */ > > + > > + /* > > + * 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) { > > + dev_err(&device->dev, > > + "Bus %04x:%02x not present in PCI namespace\n", > > + root->segment, (unsigned int)root->secondary.start); > > + result = -ENODEV; > > + goto end; > > + } > > + > > + if (no_aspm) > > + 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); > > I think there are two problems with this patch: > > 1) There's another call of pcie_no_aspm() at line 454 (in the > error path when acpi_pci_osc_support() fails), which happens > before scanning the bus. I think this needs to be converted to > "no_aspm = true" as you did for the one in the error path when > acpi_pci_osc_control_set() fails. > I was wondering about that. I left it alone because this patch didn't introduce that condition (callingpcie_no_aspm at line 454). I thought perhaps there was something there I didn't completely understand, but yes, I agree, it seems like it should use the no_aspm just like the call I converted. > 2) You effectively moved the call of "pcie_clear_aspm(root->bus)" > so it now happens before scanning the bus, which will cause a > NULL pointer dereference if we take that path. > Yes, you're correct, and I missed that, we need to defer that call just like we do with pcie_no_aspm. > I think we need something like the patch below on top of your > v3 patch. Can you take a look and see if this makes sense, and > if so, update your patch to include these or similar fixes? > I agree, I'll send a v4 tomorrow, with these changes incorporated, and an updated changelog reflecting the exact problem we're solving here. Thanks! Neil > Here are my notes about where the ASPM and root->osc_control_set > setting and testing happen. > > Before your patch: > > acpi_pci_root_add > root = kzalloc # root->osc_control_set = 0 > acpi_pci_osc_support # indicate OS support for segments > root->bus = pci_acpi_scan_root # SCAN BUS > pci_create_root_bus > pcibios_add_bus > acpi_pci_add_bus > acpiphp_enumerate_slots > acpi_walk_namespace(..., register_slot, ...) > register_slot > device_is_managed_by_native_pciehp > <test root->osc_control_set> # root->osc_control_set == 0 > return if OS has PCIe hotplug control (we never do) > acpiphp_register_hotplug_slot (so we always do this) > acpi_pci_osc_support # indicate OS support for MSI, ASPM, etc > if (_osc_support() failed) > pci_no_aspm > acpi_pci_osc_control_set # request OS control of hotplug, PME, AER, etc > root->osc_control_set = XX > if (_osc_control_set() succeeded) { > if (FADT NO_ASPM bit) > pcie_clear_aspm > list_for_each_entry(..., &bus->devices, ...) > } else > pcie_no_aspm # _osc_control_set() failed > > After your patch: > > acpi_pci_root_add > root = kzalloc # root->osc_control_set = 0 > acpi_pci_osc_support # indicate OS support for segments > if (_osc_support() failed) > pci_no_aspm # ** (1) before bus scan > acpi_pci_osc_support # indicate OS support for MSI, ASPM, etc > acpi_pci_osc_control_set # request OS control of hotplug, PME, AER, etc > root->osc_control_set = XX > if (_osc_control_set() succeeded) { > if (FADT NO_ASPM bit) > pcie_clear_aspm(root->bus) # ** (2) root->bus == NULL > list_for_each_entry(..., &bus->devices, ...) > } else > no_aspm = true # _osc_control_set() failed > root->bus = pci_acpi_scan_root # SCAN BUS > pci_create_root_bus > pcibios_add_bus > acpi_pci_add_bus > acpiphp_enumerate_slots > acpi_walk_namespace(..., register_slot, ...) > register_slot > device_is_managed_by_native_pciehp > <test root->osc_control_set> > return if OS has PCIe hotplug control > acpiphp_register_hotplug_slot > if (no_aspm) > pcie_no_aspm > > > Bjorn > > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index a37a372..a67853e 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -378,7 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > struct acpi_pci_root *root; > u32 flags, base_flags; > acpi_handle handle = device->handle; > - bool no_aspm = false; > + bool no_aspm = false, clear_aspm = false; > > root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); > if (!root) > @@ -451,7 +451,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > if (ACPI_FAILURE(status)) { > dev_info(&device->dev, "ACPI _OSC support " > "notification failed, disabling PCIe ASPM\n"); > - pcie_no_aspm(); > + no_aspm = true; > flags = base_flags; > } > } > @@ -483,7 +483,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > * We have ASPM control, but the FADT indicates > * that it's unsupported. Clear it. > */ > - pcie_clear_aspm(root->bus); > + clear_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -527,6 +527,10 @@ static int acpi_pci_root_add(struct acpi_device *device, > goto end; > } > > + if (clear_aspm) { > + dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); > + pcie_clear_aspm(root->bus); > + } > if (no_aspm) > pcie_no_aspm(); > > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-23 17:19 [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available Neil Horman ` (2 preceding siblings ...) 2013-08-26 15:39 ` [PATCH v3] " Neil Horman @ 2013-08-29 20:17 ` Neil Horman 2013-08-29 20:46 ` Yinghai Lu 2013-08-29 23:40 ` Bjorn Helgaas 3 siblings, 2 replies; 21+ messages in thread From: Neil Horman @ 2013-08-29 20:17 UTC (permalink / raw) To: linux-kernel Cc: Neil Horman, Len Brown, Rafael J. Wysocki, linux-acpi, linux-pci This is a fix for: https://bugzilla.kernel.org/show_bug.cgi?id=60736 During the 3.8 devel cycle: 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 went in to allow us to query the pcie hotplug flags during the acpi bus scan. It however caused problems with the disabling of pcie aspm, and so: 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" Backed it out. This of course brought back the problem in which acpi took over hotplug ports that were meant to be controlled by pcie. This patch gives us both items. It lets us request _OSC control before scanning the pci root bus, but defers any disabling of aspm until after the scan is complete, allowing us to properly handle old pcie 1.1 devices aspm settings properly, as b8178f130e documents. Tested successfully by myself. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Len Brown <lenb@kernel.org> CC: "Rafael J. Wysocki" <rjw@sisk.pl> CC: linux-acpi@vger.kernel.org CC: linux-pci@vger.kernel.org --- drivers/acpi/pci_root.c | 62 ++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5917839..6110fd2 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, struct acpi_pci_root *root; u32 flags, base_flags; acpi_handle handle = device->handle; + bool no_aspm = false, clear_aspm = false; root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); if (!root) @@ -437,27 +438,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. - */ - - /* - * 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) { - dev_err(&device->dev, - "Bus %04x:%02x not present in PCI namespace\n", - root->segment, (unsigned int)root->secondary.start); - result = -ENODEV; - goto end; - } - - /* Indicate support for various _OSC capabilities. */ if (pci_ext_cfg_avail()) flags |= OSC_EXT_PCI_CONFIG_SUPPORT; if (pcie_aspm_support_enabled()) { @@ -471,7 +451,7 @@ static int acpi_pci_root_add(struct acpi_device *device, if (ACPI_FAILURE(status)) { dev_info(&device->dev, "ACPI _OSC support " "notification failed, disabling PCIe ASPM\n"); - pcie_no_aspm(); + no_aspm = true; flags = base_flags; } } @@ -503,7 +483,7 @@ static int acpi_pci_root_add(struct acpi_device *device, * We have ASPM control, but the FADT indicates * that it's unsupported. Clear it. */ - pcie_clear_aspm(root->bus); + clear_aspm = true; } } else { dev_info(&device->dev, @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, acpi_format_exception(status), flags); dev_info(&device->dev, "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); - pcie_no_aspm(); + /* + * We want to disable aspm here, but aspm_disabled + * needs to remain in its state from boot so that we + * properly handle pcie 1.1 devices. So we set this + * flag here, to defer the action until after the acpi + * root scan + */ + no_aspm = true; } } else { dev_info(&device->dev, @@ -520,6 +507,33 @@ static int acpi_pci_root_add(struct acpi_device *device, "(_OSC support mask: 0x%02x)\n", flags); } + /* + * TBD: Need PCI interface for enumeration/configuration of roots. + */ + + /* + * 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) { + dev_err(&device->dev, + "Bus %04x:%02x not present in PCI namespace\n", + root->segment, (unsigned int)root->secondary.start); + result = -ENODEV; + goto end; + } + + if (clear_aspm) { + dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); + pcie_clear_aspm(root->bus); + } + if (no_aspm) + 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); -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-29 20:17 ` [PATCH v4] " Neil Horman @ 2013-08-29 20:46 ` Yinghai Lu 2013-08-29 23:40 ` Bjorn Helgaas 1 sibling, 0 replies; 21+ messages in thread From: Yinghai Lu @ 2013-08-29 20:46 UTC (permalink / raw) To: Neil Horman Cc: Linux Kernel Mailing List, Len Brown, Rafael J. Wysocki, ACPI Devel Maling List, linux-pci@vger.kernel.org On Thu, Aug 29, 2013 at 1:17 PM, Neil Horman <nhorman@tuxdriver.com> wrote: > This is a fix for: > https://bugzilla.kernel.org/show_bug.cgi?id=60736 > > During the 3.8 devel cycle: > > 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 > > went in to allow us to query the pcie hotplug flags during the acpi bus scan. > It however caused problems with the disabling of pcie aspm, and so: > 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" > > Backed it out. This of course brought back the problem in which acpi took over > hotplug ports that were meant to be controlled by pcie. > > This patch gives us both items. It lets us request _OSC control before scanning > the pci root bus, but defers any disabling of aspm until after the scan is > complete, allowing us to properly handle old pcie 1.1 devices aspm settings > properly, as b8178f130e documents. > > Tested successfully by myself. > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > CC: Len Brown <lenb@kernel.org> > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > CC: linux-acpi@vger.kernel.org > CC: linux-pci@vger.kernel.org > --- > drivers/acpi/pci_root.c | 62 ++++++++++++++++++++++++++++++------------------- > 1 file changed, 38 insertions(+), 24 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 5917839..6110fd2 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > struct acpi_pci_root *root; > u32 flags, base_flags; > acpi_handle handle = device->handle; > + bool no_aspm = false, clear_aspm = false; > > root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); > if (!root) > @@ -437,27 +438,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. > - */ > - > - /* > - * 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) { > - dev_err(&device->dev, > - "Bus %04x:%02x not present in PCI namespace\n", > - root->segment, (unsigned int)root->secondary.start); > - result = -ENODEV; > - goto end; > - } > - > - /* Indicate support for various _OSC capabilities. */ > if (pci_ext_cfg_avail()) > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > if (pcie_aspm_support_enabled()) { > @@ -471,7 +451,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > if (ACPI_FAILURE(status)) { > dev_info(&device->dev, "ACPI _OSC support " > "notification failed, disabling PCIe ASPM\n"); > - pcie_no_aspm(); > + no_aspm = true; > flags = base_flags; > } > } > @@ -503,7 +483,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > * We have ASPM control, but the FADT indicates > * that it's unsupported. Clear it. > */ > - pcie_clear_aspm(root->bus); > + clear_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, > acpi_format_exception(status), flags); > dev_info(&device->dev, > "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); > - pcie_no_aspm(); > + /* > + * We want to disable aspm here, but aspm_disabled > + * needs to remain in its state from boot so that we > + * properly handle pcie 1.1 devices. So we set this > + * flag here, to defer the action until after the acpi > + * root scan > + */ > + no_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -520,6 +507,33 @@ static int acpi_pci_root_add(struct acpi_device *device, > "(_OSC support mask: 0x%02x)\n", flags); > } > > + /* > + * TBD: Need PCI interface for enumeration/configuration of roots. > + */ > + > + /* > + * 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) { > + dev_err(&device->dev, > + "Bus %04x:%02x not present in PCI namespace\n", > + root->segment, (unsigned int)root->secondary.start); > + result = -ENODEV; > + goto end; > + } > + > + if (clear_aspm) { > + dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); > + pcie_clear_aspm(root->bus); > + } > + if (no_aspm) > + 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); Also need to cc stable? Acked-by: Yinghai Lu <yinghai@kernel.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-29 20:17 ` [PATCH v4] " Neil Horman 2013-08-29 20:46 ` Yinghai Lu @ 2013-08-29 23:40 ` Bjorn Helgaas 2013-08-30 11:20 ` Neil Horman 1 sibling, 1 reply; 21+ messages in thread From: Bjorn Helgaas @ 2013-08-29 23:40 UTC (permalink / raw) To: Neil Horman Cc: linux-kernel, Len Brown, Rafael J. Wysocki, linux-acpi, linux-pci On Thu, Aug 29, 2013 at 04:17:05PM -0400, Neil Horman wrote: > This is a fix for: > https://bugzilla.kernel.org/show_bug.cgi?id=60736 > > During the 3.8 devel cycle: > > 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 > > went in to allow us to query the pcie hotplug flags during the acpi bus scan. > It however caused problems with the disabling of pcie aspm, and so: > 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" > > Backed it out. This of course brought back the problem in which acpi took over > hotplug ports that were meant to be controlled by pcie. > > This patch gives us both items. It lets us request _OSC control before scanning > the pci root bus, but defers any disabling of aspm until after the scan is > complete, allowing us to properly handle old pcie 1.1 devices aspm settings > properly, as b8178f130e documents. > > Tested successfully by myself. > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > CC: Len Brown <lenb@kernel.org> > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > CC: linux-acpi@vger.kernel.org > CC: linux-pci@vger.kernel.org I added Yinghai's ack and a stable tag and put this in pci/misc for v3.12. Thanks! I reworked the changelog because I think the actual cause of the regression was 3b63aaa70e, not the _OSC commits you mentioned: 8c33f51df4 ("PCI/ACPI: Request _OSC control before scanning PCI root bus") appeared in v3.8 and broke ASPM but not acpiphp. b8178f130e ('Revert "PCI/ACPI: Request _OSC control before scanning PCI root bus"') appeared in v3.9 and fixed ASPM, leaving acpiphp working. 3b63aaa70e ("PCI: acpiphp: Do not use ACPI PCI subdriver mechanism") appeared in v3.10, and I believe this is what actually broke acpiphp because it moved the acpiphp initialization earlier, into the bus scan. in v3.8: acpi_pci_root_add acpi_pci_osc_control_set # request OS control pci_acpi_scan_root # scan bus acpi_pci_root_start add_bridge # acpi_pci_driver .add method ... device_is_managed_by_native_pciehp # OK in v3.9: acpi_pci_root_add pci_acpi_scan_root # scan bus acpi_pci_osc_control_set # request OS control add_bridge # acpi_pci_driver .add method ... device_is_managed_by_native_pciehp # OK in v3.10: acpi_pci_root_add pci_acpi_scan_root # scan bus ... acpiphp_enumerate_slots ... device_is_managed_by_native_pciehp # PROBLEM acpi_pci_osc_control_set # request OS control So I added a stable tag for v3.10+ only. I'll ask Linus to merge it directly during the merge window for v3.12, and hopefully it will be backported to the v3.10 and v3.11 stable trees soon after that. Bjorn > --- > drivers/acpi/pci_root.c | 62 ++++++++++++++++++++++++++++++------------------- > 1 file changed, 38 insertions(+), 24 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 5917839..6110fd2 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > struct acpi_pci_root *root; > u32 flags, base_flags; > acpi_handle handle = device->handle; > + bool no_aspm = false, clear_aspm = false; > > root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); > if (!root) > @@ -437,27 +438,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. > - */ > - > - /* > - * 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) { > - dev_err(&device->dev, > - "Bus %04x:%02x not present in PCI namespace\n", > - root->segment, (unsigned int)root->secondary.start); > - result = -ENODEV; > - goto end; > - } > - > - /* Indicate support for various _OSC capabilities. */ > if (pci_ext_cfg_avail()) > flags |= OSC_EXT_PCI_CONFIG_SUPPORT; > if (pcie_aspm_support_enabled()) { > @@ -471,7 +451,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > if (ACPI_FAILURE(status)) { > dev_info(&device->dev, "ACPI _OSC support " > "notification failed, disabling PCIe ASPM\n"); > - pcie_no_aspm(); > + no_aspm = true; > flags = base_flags; > } > } > @@ -503,7 +483,7 @@ static int acpi_pci_root_add(struct acpi_device *device, > * We have ASPM control, but the FADT indicates > * that it's unsupported. Clear it. > */ > - pcie_clear_aspm(root->bus); > + clear_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device, > acpi_format_exception(status), flags); > dev_info(&device->dev, > "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); > - pcie_no_aspm(); > + /* > + * We want to disable aspm here, but aspm_disabled > + * needs to remain in its state from boot so that we > + * properly handle pcie 1.1 devices. So we set this > + * flag here, to defer the action until after the acpi > + * root scan > + */ > + no_aspm = true; > } > } else { > dev_info(&device->dev, > @@ -520,6 +507,33 @@ static int acpi_pci_root_add(struct acpi_device *device, > "(_OSC support mask: 0x%02x)\n", flags); > } > > + /* > + * TBD: Need PCI interface for enumeration/configuration of roots. > + */ > + > + /* > + * 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) { > + dev_err(&device->dev, > + "Bus %04x:%02x not present in PCI namespace\n", > + root->segment, (unsigned int)root->secondary.start); > + result = -ENODEV; > + goto end; > + } > + > + if (clear_aspm) { > + dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); > + pcie_clear_aspm(root->bus); > + } > + if (no_aspm) > + 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); > -- > 1.8.1.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available 2013-08-29 23:40 ` Bjorn Helgaas @ 2013-08-30 11:20 ` Neil Horman 0 siblings, 0 replies; 21+ messages in thread From: Neil Horman @ 2013-08-30 11:20 UTC (permalink / raw) To: Bjorn Helgaas Cc: linux-kernel, Len Brown, Rafael J. Wysocki, linux-acpi, linux-pci On Thu, Aug 29, 2013 at 05:40:52PM -0600, Bjorn Helgaas wrote: > On Thu, Aug 29, 2013 at 04:17:05PM -0400, Neil Horman wrote: > > This is a fix for: > > https://bugzilla.kernel.org/show_bug.cgi?id=60736 > > > > During the 3.8 devel cycle: > > > > 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 > > > > went in to allow us to query the pcie hotplug flags during the acpi bus scan. > > It however caused problems with the disabling of pcie aspm, and so: > > 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" > > > > Backed it out. This of course brought back the problem in which acpi took over > > hotplug ports that were meant to be controlled by pcie. > > > > This patch gives us both items. It lets us request _OSC control before scanning > > the pci root bus, but defers any disabling of aspm until after the scan is > > complete, allowing us to properly handle old pcie 1.1 devices aspm settings > > properly, as b8178f130e documents. > > > > Tested successfully by myself. > > > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com> > > CC: Len Brown <lenb@kernel.org> > > CC: "Rafael J. Wysocki" <rjw@sisk.pl> > > CC: linux-acpi@vger.kernel.org > > CC: linux-pci@vger.kernel.org > > I added Yinghai's ack and a stable tag and put this in pci/misc > for v3.12. Thanks! > > I reworked the changelog because I think the actual cause of the > regression was 3b63aaa70e, not the _OSC commits you mentioned: > > 8c33f51df4 ("PCI/ACPI: Request _OSC control before scanning PCI root bus") > appeared in v3.8 and broke ASPM but not acpiphp. > > b8178f130e ('Revert "PCI/ACPI: Request _OSC control before scanning PCI > root bus"') appeared in v3.9 and fixed ASPM, leaving acpiphp working. > > 3b63aaa70e ("PCI: acpiphp: Do not use ACPI PCI subdriver mechanism") > appeared in v3.10, and I believe this is what actually broke acpiphp > because it moved the acpiphp initialization earlier, into the bus scan. > > in v3.8: > acpi_pci_root_add > acpi_pci_osc_control_set # request OS control > pci_acpi_scan_root # scan bus > acpi_pci_root_start > add_bridge # acpi_pci_driver .add method > ... > device_is_managed_by_native_pciehp # OK > > in v3.9: > acpi_pci_root_add > pci_acpi_scan_root # scan bus > acpi_pci_osc_control_set # request OS control > add_bridge # acpi_pci_driver .add method > ... > device_is_managed_by_native_pciehp # OK > > in v3.10: > acpi_pci_root_add > pci_acpi_scan_root # scan bus > ... > acpiphp_enumerate_slots > ... > device_is_managed_by_native_pciehp # PROBLEM > acpi_pci_osc_control_set # request OS control > > So I added a stable tag for v3.10+ only. I'll ask Linus to merge it > directly during the merge window for v3.12, and hopefully it will be > backported to the v3.10 and v3.11 stable trees soon after that. > > Bjorn > Copy that, thanks! Neil ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2013-08-30 11:20 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-08-23 17:19 [PATCH] ACPI: Fix osc flag setup ordering to allow pcie hotplug use when available Neil Horman 2013-08-23 19:38 ` Rafael J. Wysocki 2013-08-23 20:05 ` Neil Horman 2013-08-23 20:53 ` Rafael J. Wysocki 2013-08-23 20:46 ` Bjorn Helgaas 2013-08-23 21:40 ` Rafael J. Wysocki 2013-08-23 22:04 ` Bjorn Helgaas 2013-08-24 1:57 ` Neil Horman 2013-08-26 15:36 ` [PATCH v2] " Neil Horman 2013-08-26 15:38 ` Neil Horman 2013-08-26 15:39 ` [PATCH v3] " Neil Horman 2013-08-27 21:34 ` Bjorn Helgaas 2013-08-27 23:43 ` Neil Horman 2013-08-28 13:04 ` Bjorn Helgaas 2013-08-28 13:23 ` Neil Horman 2013-08-29 17:47 ` Bjorn Helgaas 2013-08-29 18:12 ` Neil Horman 2013-08-29 20:17 ` [PATCH v4] " Neil Horman 2013-08-29 20:46 ` Yinghai Lu 2013-08-29 23:40 ` Bjorn Helgaas 2013-08-30 11:20 ` Neil Horman
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).