ACPI / hotplug / PCI: Don't scan for non-hotplug bridges if slot is not bridge
PATCH v2 1/1 ACPI / hotplug / PCI: Don't scan for non-hotplug bridges if slot is not bridge
HP 6730b laptop has an ethernet NIC connected to one of the PCIe root ports. The root ports itself are native PCIe hotplug capable. Now, during boot after PCI devices are scanned the BIOS triggers ACPI bus check directly to the NIC:
[ 0.942239] ACPI: \_SB_.PCI0.RP06.NIC_: Bus check in hotplug_event()
It is not clear why it is sending bus check but regardless the ACPI hotplug notify handler calls enable_slot() directly (instead of going through acpiphp_check_bridge() as there is no bridge) which ends up handling special case for non-hotplug bridges with native PCIe hotplug. This results a crash of some kind but the reporter only sees black screen so it is hard to figure out the exact spot and what actually happens. Based on few fix proposals it was tracked to crash somewhere inside pci_assign_unassigned_bridge_resources().
In any case we should not really be in that special branch at all because the ACPI notify happened to a slot that is not a PCI bridge (it is just a regular PCI device).
Fix this so that we only go to that special branch if we are calling enable_slot() for a bridge (e.g the ACPI notification was for the bridge).
---
Changes from v1:
* Pass bool instead of a bridge pointer
drivers/pci/hotplug/acpiphp_glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +6 -5
@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)/** * enable_slot - enable, configure a slot * @slot: slot to be enabled +* @bridge: true if enable is for the whole bridge (not a single slot) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. */ -static void enable_slot (struct acpiphp_slot *slot) +static void enable_slot (struct acpiphp_slot *slot,bool bridge) {struct pci_dev *dev;struct pci_bus *bus = slot->bus;struct acpiphp_func *func; -if (bus->self &&hotplug_is_native (bus->self)) { +if (bridge && bus->self &&hotplug_is_native (bus->self)) {/* * If native hotplug is used, it will take care of hotplug * slot management and resource allocation for hotplug
@@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)trim_stale_devices (dev);/* configure all functions */ -enable_slot (slot); +enable_slot (slot, true); }else {disable_slot (slot); }
@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)if (bridge)acpiphp_check_bridge (bridge);else if (!(slot->flags &SLOT_IS_GOING_AWAY )) -enable_slot (slot); +enable_slot (slot, false);break ;
@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)/* configure all functions */ if (!(slot->flags &SLOT_ENABLED )) -enable_slot (slot); +enable_slot (slot, false);pci_unlock_rescan_remove ();return 0 ;
Signature · 1 line
2.18.0
Quoted 80 lines · Mika Westerberg
HP 6730b laptop has an ethernet NIC connected to one of the PCIe root ports. The root ports itself are native PCIe hotplug capable. Now, during boot after PCI devices are scanned the BIOS triggers ACPI bus check directly to the NIC:
[ 0.942239] ACPI: \_SB_.PCI0.RP06.NIC_: Bus check in hotplug_event()It is not clear why it is sending bus check but regardless the ACPI hotplug notify handler calls
enable_slot()directly (instead of going throughacpiphp_check_bridge()as there is no bridge) which ends up handling special case for non-hotplug bridges with native PCIe hotplug. This results a crash of some kind but the reporter only sees black screen so it is hard to figure out the exact spot and what actually happens. Based on few fix proposals it was tracked to crash somewhere insidepci_assign_unassigned_bridge_resources().In any case we should not really be in that special branch at all because the ACPI notify happened to a slot that is not a PCI bridge (it is just a regular PCI device).
Fix this so that we only go to that special branch if we are calling
enable_slot()for a bridge (e.g the ACPI notification was for the bridge).Fixes 84c8b58ed3ad ACPI / hotplug / PCI: Don't scan bridges managed by native hotplugReported-by Peter Anemone <[email protected]>Signed-off-by Mika Westerberg <[email protected]>---
Changes from v1:* Pass bool instead of a bridge pointer
drivers/pci/hotplug/acpiphp_glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpiphp_glue.c +5
-4@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)/** * enable_slot - enable, configure a slot * @slot: slot to be enabled +* @bridge: true if enable is for the whole bridge (not a single slot) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. */ -static void enable_slot (struct acpiphp_slot *slot) +static void enable_slot (struct acpiphp_slot *slot,bool bridge) {struct pci_dev *dev;struct pci_bus *bus = slot->bus;struct acpiphp_func *func; -if (bus->self &&hotplug_is_native (bus->self)) { +if (bridge && bus->self &&hotplug_is_native (bus->self)) {/* * If native hotplug is used, it will take care of hotplug * slot management and resource allocation for hotplug @@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)trim_stale_devices (dev);/* configure all functions */ -enable_slot (slot); +enable_slot (slot, true); }else {disable_slot (slot); }@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)if (bridge)acpiphp_check_bridge (bridge);else if (!(slot->flags &SLOT_IS_GOING_AWAY )) -enable_slot (slot); +enable_slot (slot, false);break ;
drivers/pci/hotplug/acpiphp_glue.c int acpiphp_enable_slot(struct acpiphp_slot *slot)
Quoted 9 lines
drivers/pci/hotplug/acpiphp_glue.c +1
-2@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)/* configure all functions */ if (!(slot->flags &SLOT_ENABLED )) -enable_slot (slot); +enable_slot (slot, false);pci_unlock_rescan_remove ();return 0 ; --
Rafael J. Wysocki
maintainerQuoted 89 lines · Rafael J. Wysocki
Quoted 86 lines · Mika Westerberg
HP 6730b laptop has an ethernet NIC connected to one of the PCIe root ports. The root ports itself are native PCIe hotplug capable. Now, during boot after PCI devices are scanned the BIOS triggers ACPI bus check directly to the NIC:
[ 0.942239] ACPI: \_SB_.PCI0.RP06.NIC_: Bus check in hotplug_event()It is not clear why it is sending bus check but regardless the ACPI hotplug notify handler calls
enable_slot()directly (instead of going throughacpiphp_check_bridge()as there is no bridge) which ends up handling special case for non-hotplug bridges with native PCIe hotplug. This results a crash of some kind but the reporter only sees black screen so it is hard to figure out the exact spot and what actually happens. Based on few fix proposals it was tracked to crash somewhere insidepci_assign_unassigned_bridge_resources().In any case we should not really be in that special branch at all because the ACPI notify happened to a slot that is not a PCI bridge (it is just a regular PCI device).
Fix this so that we only go to that special branch if we are calling
enable_slot()for a bridge (e.g the ACPI notification was for the bridge).Fixes 84c8b58ed3ad ACPI / hotplug / PCI: Don't scan bridges managed by native hotplugReported-by Peter Anemone <[email protected]>Signed-off-by Mika Westerberg <[email protected]>---
Changes from v1:* Pass bool instead of a bridge pointer
drivers/pci/hotplug/acpiphp_glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpiphp_glue.c +6
-5@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)/** * enable_slot - enable, configure a slot * @slot: slot to be enabled +* @bridge: true if enable is for the whole bridge (not a single slot) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. */ -static void enable_slot (struct acpiphp_slot *slot) +static void enable_slot (struct acpiphp_slot *slot,bool bridge) {struct pci_dev *dev;struct pci_bus *bus = slot->bus;struct acpiphp_func *func; -if (bus->self &&hotplug_is_native (bus->self)) { +if (bridge && bus->self &&hotplug_is_native (bus->self)) {/* * If native hotplug is used, it will take care of hotplug * slot management and resource allocation for hotplug @@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)trim_stale_devices (dev);/* configure all functions */ -enable_slot (slot); +enable_slot (slot, true); }else {disable_slot (slot); }@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)if (bridge)acpiphp_check_bridge (bridge);else if (!(slot->flags &SLOT_IS_GOING_AWAY )) -enable_slot (slot); +enable_slot (slot, false);break ;@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)/* configure all functions */ if (!(slot->flags &SLOT_ENABLED )) -enable_slot (slot); +enable_slot (slot, false);
Quoted 5 lines
drivers/pci/hotplug/acpiphp_glue.c int acpiphp_enable_slot(struct acpiphp_slot *slot)
Quoted 3 lines
drivers/pci/hotplug/acpiphp_glue.c +0
-1pci_unlock_rescan_remove ();return 0 ; --Reviewed-by Rafael J. Wysocki <[email protected]>
Bjorn, if you want me to take this one, please let me know.
Cheers,
Rafael
Quoted 20 lines · Mika Westerberg
HP 6730b laptop has an ethernet NIC connected to one of the PCIe root ports. The root ports itself are native PCIe hotplug capable. Now, during boot after PCI devices are scanned the BIOS triggers ACPI bus check directly to the NIC:
[ 0.942239] ACPI: \_SB_.PCI0.RP06.NIC_: Bus check in hotplug_event()It is not clear why it is sending bus check but regardless the ACPI hotplug notify handler calls
enable_slot()directly (instead of going throughacpiphp_check_bridge()as there is no bridge) which ends up handling special case for non-hotplug bridges with native PCIe hotplug. This results a crash of some kind but the reporter only sees black screen so it is hard to figure out the exact spot and what actually happens. Based on few fix proposals it was tracked to crash somewhere insidepci_assign_unassigned_bridge_resources().In any case we should not really be in that special branch at all because the ACPI notify happened to a slot that is not a PCI bridge (it is just a regular PCI device).
Quoted 7 lines
Fix this so that we only go to that special branch if we are calling
enable_slot()for a bridge (e.g the ACPI notification was for the bridge).Fixes 84c8b58ed3ad ACPI / hotplug / PCI: Don't scan bridges managed by native hotplugReported-by Peter Anemone <[email protected]>Signed-off-by Mika Westerberg <[email protected]>
Applied with Rafael's reviewed-by to pci/hotplug for v4.20, thanks!
Quoted 63 lines
---
Changes from v1:* Pass bool instead of a bridge pointer
drivers/pci/hotplug/acpiphp_glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpiphp_glue.c +6
-5@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)/** * enable_slot - enable, configure a slot * @slot: slot to be enabled +* @bridge: true if enable is for the whole bridge (not a single slot) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. */ -static void enable_slot (struct acpiphp_slot *slot) +static void enable_slot (struct acpiphp_slot *slot,bool bridge) {struct pci_dev *dev;struct pci_bus *bus = slot->bus;struct acpiphp_func *func; -if (bus->self &&hotplug_is_native (bus->self)) { +if (bridge && bus->self &&hotplug_is_native (bus->self)) {/* * If native hotplug is used, it will take care of hotplug * slot management and resource allocation for hotplug @@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)trim_stale_devices (dev);/* configure all functions */ -enable_slot (slot); +enable_slot (slot, true); }else {disable_slot (slot); }@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)if (bridge)acpiphp_check_bridge (bridge);else if (!(slot->flags &SLOT_IS_GOING_AWAY )) -enable_slot (slot); +enable_slot (slot, false);break ;@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)/* configure all functions */ if (!(slot->flags &SLOT_ENABLED )) -enable_slot (slot); +enable_slot (slot, false);pci_unlock_rescan_remove ();return 0 ;Signature · 1 line
2.18.0
I think this should also be applied to 4.18 and 4.19 as this fixes a boot hang. -Peter
Quoted 95 lines · Bjorn Helgaas
Quoted 20 lines · Mika Westerberg
HP 6730b laptop has an ethernet NIC connected to one of the PCIe root ports. The root ports itself are native PCIe hotplug capable. Now, during boot after PCI devices are scanned the BIOS triggers ACPI bus check directly to the NIC:
[ 0.942239] ACPI: \_SB_.PCI0.RP06.NIC_: Bus check in hotplug_event()It is not clear why it is sending bus check but regardless the ACPI hotplug notify handler calls
enable_slot()directly (instead of going throughacpiphp_check_bridge()as there is no bridge) which ends up handling special case for non-hotplug bridges with native PCIe hotplug. This results a crash of some kind but the reporter only sees black screen so it is hard to figure out the exact spot and what actually happens. Based on few fix proposals it was tracked to crash somewhere insidepci_assign_unassigned_bridge_resources().In any case we should not really be in that special branch at all because the ACPI notify happened to a slot that is not a PCI bridge (it is just a regular PCI device).
Quoted 7 lines
Fix this so that we only go to that special branch if we are calling
enable_slot()for a bridge (e.g the ACPI notification was for the bridge).Fixes 84c8b58ed3ad ACPI / hotplug / PCI: Don't scan bridges managed by native hotplugReported-by Peter Anemone <[email protected]>Signed-off-by Mika Westerberg <[email protected]>Applied with Rafael's reviewed-by to pci/hotplug for v4.20, thanks!
Quoted 63 lines
---
Changes from v1:* Pass bool instead of a bridge pointer
drivers/pci/hotplug/acpiphp_glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpiphp_glue.c +6
-6@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)/** * enable_slot - enable, configure a slot * @slot: slot to be enabled +* @bridge: true if enable is for the whole bridge (not a single slot) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. */ -static void enable_slot (struct acpiphp_slot *slot) +static void enable_slot (struct acpiphp_slot *slot,bool bridge) {struct pci_dev *dev;struct pci_bus *bus = slot->bus;struct acpiphp_func *func; -if (bus->self &&hotplug_is_native (bus->self)) { +if (bridge && bus->self &&hotplug_is_native (bus->self)) {/* * If native hotplug is used, it will take care of hotplug * slot management and resource allocation for hotplug @@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)trim_stale_devices (dev);/* configure all functions */ -enable_slot (slot); +enable_slot (slot, true); }else {disable_slot (slot); }@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)if (bridge)acpiphp_check_bridge (bridge);else if (!(slot->flags &SLOT_IS_GOING_AWAY )) -enable_slot (slot); +enable_slot (slot, false);break ;@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)/* configure all functions */ if (!(slot->flags &SLOT_ENABLED )) -enable_slot (slot); +enable_slot (slot, false);pci_unlock_rescan_remove ();return 0 ; --2.18.0
Quoted 2 lines · Peter Anemone
I think this should also be applied to 4.18 and 4.19 as this fixes a boot hang.
OK, I guess that makes sense. I added a stable tag for v4.18 and moved it to for-linus for v4.19. Thanks!
Quoted 96 lines · Bjorn Helgaas
Quoted 95 lines · Mika Westerberg
Quoted 20 lines
HP 6730b laptop has an ethernet NIC connected to one of the PCIe root ports. The root ports itself are native PCIe hotplug capable. Now, during boot after PCI devices are scanned the BIOS triggers ACPI bus check directly to the NIC:
[ 0.942239] ACPI: \_SB_.PCI0.RP06.NIC_: Bus check in hotplug_event()It is not clear why it is sending bus check but regardless the ACPI hotplug notify handler calls
enable_slot()directly (instead of going throughacpiphp_check_bridge()as there is no bridge) which ends up handling special case for non-hotplug bridges with native PCIe hotplug. This results a crash of some kind but the reporter only sees black screen so it is hard to figure out the exact spot and what actually happens. Based on few fix proposals it was tracked to crash somewhere insidepci_assign_unassigned_bridge_resources().In any case we should not really be in that special branch at all because the ACPI notify happened to a slot that is not a PCI bridge (it is just a regular PCI device).
Quoted 7 lines
Fix this so that we only go to that special branch if we are calling
enable_slot()for a bridge (e.g the ACPI notification was for the bridge).Fixes 84c8b58ed3ad ACPI / hotplug / PCI: Don't scan bridges managed by native hotplugReported-by Peter Anemone <[email protected]>Signed-off-by Mika Westerberg <[email protected]>Applied with Rafael's reviewed-by to pci/hotplug for v4.20, thanks!
Quoted 63 lines
---
Changes from v1:* Pass bool instead of a bridge pointer
drivers/pci/hotplug/acpiphp_glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpiphp_glue.c +6
-6@@ -457,17 +457,18 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)/** * enable_slot - enable, configure a slot * @slot: slot to be enabled +* @bridge: true if enable is for the whole bridge (not a single slot) * * This function should be called per *physical slot*, * not per each slot object in ACPI namespace. */ -static void enable_slot (struct acpiphp_slot *slot) +static void enable_slot (struct acpiphp_slot *slot,bool bridge) {struct pci_dev *dev;struct pci_bus *bus = slot->bus;struct acpiphp_func *func; -if (bus->self &&hotplug_is_native (bus->self)) { +if (bridge && bus->self &&hotplug_is_native (bus->self)) {/* * If native hotplug is used, it will take care of hotplug * slot management and resource allocation for hotplug @@ -701,7 +702,7 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)trim_stale_devices (dev);/* configure all functions */ -enable_slot (slot); +enable_slot (slot, true); }else {disable_slot (slot); }@@ -785,7 +786,7 @@ static void hotplug_event(u32 type, struct acpiphp_context *context)if (bridge)acpiphp_check_bridge (bridge);else if (!(slot->flags &SLOT_IS_GOING_AWAY )) -enable_slot (slot); +enable_slot (slot, false);break ;@@ -973,7 +974,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)/* configure all functions */ if (!(slot->flags &SLOT_ENABLED )) -enable_slot (slot); +enable_slot (slot, false);pci_unlock_rescan_remove ();return 0 ; --2.18.0