Skip to contentSkip to conversation

ACPI / hotplug / PCI: Consolidation of handling notifications (in progress)

RFC PATCH In review Rafael J. Wysocki 6 participants 135 messages Jul 9, 2013 – Sep 9, 2013 Page 2 of 2

Subsystems (2)
lore
Share & tools
lore
Tested-by
#115 lore raw

Re: [PATCH 0/2] Re: Excess dmesg output from ACPIPHP on boot

In reply to Rafael J. Wysocki
Quoted 123 lines · Rafael J. Wysocki
Quoted 122 lines · Rafael J. Wysocki
Quoted 120 lines · Alex Williamson
Quoted 109 lines · Rafael J. Wysocki
Quoted 108 lines · Alex Williamson
Quoted 106 lines · Rafael J. Wysocki
Quoted 1 line · Rafael J. Wysocki

On Thursday, September 05, 2013 08:21:41 AM Alex Williamson wrote:

[...]

Quoted 85 lines
Quoted 41 lines
Quoted 41 lines
[   18.288122] pci 0000:00:00.0: no hotplug settings from platform
[   18.288127] pcieport 0000:00:01.0: no hotplug settings from platform
[   18.288142] pci 0000:01:00.0: no hotplug settings from platform
[   18.288157] pci 0000:01:00.1: no hotplug settings from platform
[   18.288162] pcieport 0000:00:03.0: no hotplug settings from platform
[   18.288176] pci 0000:02:00.0: no hotplug settings from platform
[   18.288190] pci 0000:02:00.1: no hotplug settings from platform
[   18.288195] pcieport 0000:00:07.0: no hotplug settings from platform
[   18.288209] pci 0000:03:00.0: no hotplug settings from platform
[   18.288224] pci 0000:03:00.1: no hotplug settings from platform
[   18.288228] pci 0000:00:14.0: no hotplug settings from platform
[   18.288233] pci 0000:00:14.1: no hotplug settings from platform
[   18.288237] pci 0000:00:14.2: no hotplug settings from platform
[   18.288242] pci 0000:00:16.0: no hotplug settings from platform
[   18.288247] pci 0000:00:16.1: no hotplug settings from platform
[   18.288251] pci 0000:00:16.2: no hotplug settings from platform
[   18.288256] pci 0000:00:16.3: no hotplug settings from platform
[   18.288260] pci 0000:00:16.4: no hotplug settings from platform
[   18.288265] pci 0000:00:16.5: no hotplug settings from platform
[   18.288269] pci 0000:00:16.6: no hotplug settings from platform
[   18.288274] pci 0000:00:16.7: no hotplug settings from platform
[   18.288278] pci 0000:00:1a.0: no hotplug settings from platform
[   18.288279] pci 0000:00:1a.0: using default PCI settings
[   18.288292] pci 0000:00:1a.1: no hotplug settings from platform
[   18.288293] pci 0000:00:1a.1: using default PCI settings
[   18.288307] ehci-pci 0000:00:1a.7: no hotplug settings from platform
[   18.288308] ehci-pci 0000:00:1a.7: using default PCI settings
[   18.288322] pci 0000:00:1b.0: no hotplug settings from platform
[   18.288327] pcieport 0000:00:1c.0: no hotplug settings from platform
[   18.288332] pcieport 0000:00:1c.4: no hotplug settings from platform
[   18.288344] pci 0000:05:00.0: no hotplug settings from platform
[   18.288349] pci 0000:00:1d.0: no hotplug settings from platform
[   18.288350] pci 0000:00:1d.0: using default PCI settings
[   18.288360] pci 0000:00:1d.1: no hotplug settings from platform
[   18.288361] pci 0000:00:1d.1: using default PCI settings
[   18.288374] pci 0000:00:1d.2: no hotplug settings from platform
[   18.288374] pci 0000:00:1d.2: using default PCI settings
[   18.288387] pci 0000:00:1d.3: no hotplug settings from platform
[   18.288387] pci 0000:00:1d.3: using default PCI settings
Quoted 2 lines
Quoted 2 lines

The boot is noticeably slower. What's going to happen on systems that actually have a significant I/O topology vs my little workstation?

That depends on how many bus check/device check events they generate on boot.

My test machines don't generate them during boot at all (even the one with a Thunderbolt connector), so I don't see the messages in question during boot on any of them. Mika doesn't see them either I suppose, or he would have told me about that before.

And let's just make it clear that it is not usual or even OK to generate bus checks or device checks during boot like this. And since the changes in question have been in linux-next since right after the 3.11 merge window, I think that someone would have complained already had that been a common issue.

Of course, we need to deal with that somehow nevertheless. :-)

Quoted 14 lines

Just to give you an idea:

CONFIG_HOTPLUG_PCI_ACPI=y

$ dmesg | wc
  5697  49935 384368
$ dmesg | tail --lines=1
[   53.137123] Ebtables v2.0 registered

-- vs --

# CONFIG_HOTPLUG_PCI_ACPI is not set

Quoted 8 lines
$ dmesg | wc
 1053  9176 71652

$dmesg | tail --lines=1

[   28.917220] Ebtables v2.0 registered

So it spews out 5x more output with acpiphp enabled and takes and extra 24s to boot (nearly 2x). Not good.

The "no hotplug settings from platform" message is from pci_configure_slot(). I think the messages you're seeing are from the call to it in acpiphp_set_hpp_values() which is called by enable_slot().

Quoted 7 lines

There, I think, we can simply check the return value of pci_scan_slot() and if that is 0 (no new devices), we can just skip everything under the call to __pci_bus_assign_resources().

However, we can't skip the scanning of bridges, if any, because there may be new devices below them and I guess that's what takes so much time on your machine.

OK, one piece is missing. We may need to evaluate _OSC after handling each event to let the platform know the status.

Can you please check if the appended patch makes any difference (with the previous fix applied, of course)?

If fact, it is two patches combined. One of them optimizes enable_slot() slightly and the other adds the missing _OSC evaluation.

Quoted 8 lines
Quoted 4 lines

Better, still double the output:

$ dmesg | wc
   2169   19047  152710

I see.

What about the timing?

~40s below vs ~29s for acpiphp config'd out above.

Quoted 8 lines
Quoted 3 lines

Well, that's better than before.

I'll prepare "official" patches with the last changes then too.

The patches follow as [1/2] and [2/2]. The change in enable_slot() is literally the same, but the _OST patch is somewhat different, although the changes mostly affect the eject code path and the notifies that we don't actually handle, so they should not matter on your machine.

#116 lore raw

Re: [PATCH 0/2] Re: Excess dmesg output from ACPIPHP on boot

Quoted 126 lines · Alex Williamson
Quoted 125 lines · Rafael J. Wysocki
Quoted 124 lines · Rafael J. Wysocki
Quoted 112 lines · Alex Williamson
Quoted 111 lines · Rafael J. Wysocki
Quoted 110 lines · Alex Williamson
Quoted 98 lines · Rafael J. Wysocki
Quoted 1 line · Rafael J. Wysocki

On Thursday, September 05, 2013 08:21:41 AM Alex Williamson wrote:

[...]

Quoted 85 lines
Quoted 41 lines
Quoted 41 lines
[   18.288122] pci 0000:00:00.0: no hotplug settings from platform
[   18.288127] pcieport 0000:00:01.0: no hotplug settings from platform
[   18.288142] pci 0000:01:00.0: no hotplug settings from platform
[   18.288157] pci 0000:01:00.1: no hotplug settings from platform
[   18.288162] pcieport 0000:00:03.0: no hotplug settings from platform
[   18.288176] pci 0000:02:00.0: no hotplug settings from platform
[   18.288190] pci 0000:02:00.1: no hotplug settings from platform
[   18.288195] pcieport 0000:00:07.0: no hotplug settings from platform
[   18.288209] pci 0000:03:00.0: no hotplug settings from platform
[   18.288224] pci 0000:03:00.1: no hotplug settings from platform
[   18.288228] pci 0000:00:14.0: no hotplug settings from platform
[   18.288233] pci 0000:00:14.1: no hotplug settings from platform
[   18.288237] pci 0000:00:14.2: no hotplug settings from platform
[   18.288242] pci 0000:00:16.0: no hotplug settings from platform
[   18.288247] pci 0000:00:16.1: no hotplug settings from platform
[   18.288251] pci 0000:00:16.2: no hotplug settings from platform
[   18.288256] pci 0000:00:16.3: no hotplug settings from platform
[   18.288260] pci 0000:00:16.4: no hotplug settings from platform
[   18.288265] pci 0000:00:16.5: no hotplug settings from platform
[   18.288269] pci 0000:00:16.6: no hotplug settings from platform
[   18.288274] pci 0000:00:16.7: no hotplug settings from platform
[   18.288278] pci 0000:00:1a.0: no hotplug settings from platform
[   18.288279] pci 0000:00:1a.0: using default PCI settings
[   18.288292] pci 0000:00:1a.1: no hotplug settings from platform
[   18.288293] pci 0000:00:1a.1: using default PCI settings
[   18.288307] ehci-pci 0000:00:1a.7: no hotplug settings from platform
[   18.288308] ehci-pci 0000:00:1a.7: using default PCI settings
[   18.288322] pci 0000:00:1b.0: no hotplug settings from platform
[   18.288327] pcieport 0000:00:1c.0: no hotplug settings from platform
[   18.288332] pcieport 0000:00:1c.4: no hotplug settings from platform
[   18.288344] pci 0000:05:00.0: no hotplug settings from platform
[   18.288349] pci 0000:00:1d.0: no hotplug settings from platform
[   18.288350] pci 0000:00:1d.0: using default PCI settings
[   18.288360] pci 0000:00:1d.1: no hotplug settings from platform
[   18.288361] pci 0000:00:1d.1: using default PCI settings
[   18.288374] pci 0000:00:1d.2: no hotplug settings from platform
[   18.288374] pci 0000:00:1d.2: using default PCI settings
[   18.288387] pci 0000:00:1d.3: no hotplug settings from platform
[   18.288387] pci 0000:00:1d.3: using default PCI settings
Quoted 2 lines
Quoted 2 lines

The boot is noticeably slower. What's going to happen on systems that actually have a significant I/O topology vs my little workstation?

That depends on how many bus check/device check events they generate on boot.

My test machines don't generate them during boot at all (even the one with a Thunderbolt connector), so I don't see the messages in question during boot on any of them. Mika doesn't see them either I suppose, or he would have told me about that before.

And let's just make it clear that it is not usual or even OK to generate bus checks or device checks during boot like this. And since the changes in question have been in linux-next since right after the 3.11 merge window, I think that someone would have complained already had that been a common issue.

Of course, we need to deal with that somehow nevertheless. :-)

Quoted 14 lines

Just to give you an idea:

CONFIG_HOTPLUG_PCI_ACPI=y

$ dmesg | wc
  5697  49935 384368
$ dmesg | tail --lines=1
[   53.137123] Ebtables v2.0 registered

-- vs --

# CONFIG_HOTPLUG_PCI_ACPI is not set

Quoted 8 lines
$ dmesg | wc
 1053  9176 71652

$dmesg | tail --lines=1

[   28.917220] Ebtables v2.0 registered

So it spews out 5x more output with acpiphp enabled and takes and extra 24s to boot (nearly 2x). Not good.

The "no hotplug settings from platform" message is from pci_configure_slot(). I think the messages you're seeing are from the call to it in acpiphp_set_hpp_values() which is called by enable_slot().

Quoted 7 lines

There, I think, we can simply check the return value of pci_scan_slot() and if that is 0 (no new devices), we can just skip everything under the call to __pci_bus_assign_resources().

However, we can't skip the scanning of bridges, if any, because there may be new devices below them and I guess that's what takes so much time on your machine.

Quoted 8 lines

OK, one piece is missing. We may need to evaluate _OSC after handling each event to let the platform know the status.

Can you please check if the appended patch makes any difference (with the previous fix applied, of course)?

If fact, it is two patches combined. One of them optimizes enable_slot() slightly and the other adds the missing _OSC evaluation.

Better, still double the output:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
$ dmesg | wc
   2169   19047  152710

I see.

What about the timing?

~40s below vs ~29s for acpiphp config'd out above.

Well, that's better than before.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I'll prepare "official" patches with the last changes then too.

The patches follow as [1/2] and [2/2]. The change in enable_slot() is literally the same, but the _OST patch is somewhat different, although the changes mostly affect the eject code path and the notifies that we don't actually handle, so they should not matter on your machine.

Thanks!

#117 lore raw

Re: [PATCH 25/30] ACPI / hotplug / PCI: Check for new devices on enabled slots

In reply to Alex Williamson

2013/9/5 Alex Williamson <[email protected]>:

Quoted 96 lines · Rafael J. Wysocki
Quoted 58 lines · Alex Williamson
Quoted 48 lines · Rafael J. Wysocki
Quoted 40 lines · Alex Williamson
Quoted 39 lines · Rafael J. Wysocki
Quoted 37 lines

From: Rafael J. Wysocki <[email protected]>

The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not ACPI_STA_ALL.

This behavior is not sufficient to handle the Thunderbolt daisy chaining case properly, however, because in that case the bus behind the already enabled slot needs to be rescanned for new devices.

For this reason, modify acpiphp_check_bridge() so that slots are disabled and stopped if they are not in the ACPI_STA_ALL state.

For slots in the ACPI_STA_ALL state, devices behind them that don't respond are trimmed using a new function, trim_stale_devices(), introduced specifically for this purpose. That function walks the given bus and checks each device on it. If the device doesn't respond, it is assumed to be gone and is removed.

Once all of the stale devices directy behind the slot have been removed, acpiphp_check_bridge() will start looking for new devices that might have appeared on the given bus. It will do that even if the slot is already enabled (SLOT_ENABLED is set for it).

In addition to that, make the bus check notification ignore SLOT_ENABLED and go for enable_device() directly if bridge is NULL, so that devices behind the slot are re-enumerated in that case too.

This change is based on earlier patches from Kirill A Shutemov and Mika Westerberg.

---

Quoted 6 lines
Quoted 2 lines

FYI, git bisect landed on this patch as the cause of my serial console dying on current upstream. Further debugging to come... Thanks,

Well, sorry about that.

What exactly do you mean by "dying"?

Quoted 8 lines

Sorry, I was hoping to have more details quickly, but it's been a pain to debug. By dying I mean serial console output suddenly stops during kernel boot and nothing more comes out of it until after the system is rebooted. The problem happens when acpiphp_check_bridge() calls enable_slot(). The serial console dies somewhere down in acpiphp_bus_trim(). I think this is happening on the 00:1f ISA bridge, so there's a good chance the serial ports are described as somewhere under there.

Quoted 6 lines

Can you please check if that is the acpiphp_bus_trim() called by acpiphp_bus_add() or the other one called from trim_stale_devices()?

Just add a dump_stack() or WARN_ON(1) to trim_stale_devices() next to the acpiphp_bus_trim() call and see if that triggers. I *think* it's the one in acpiphp_bus_add(), but it won't hurt to verify that.

Here's the call path:

[   16.120824]  [<ffffffff81627e6c>] dump_stack+0x55/0x76
[   16.125979]  [<ffffffff8162132e>] enable_slot+0x4ee/0x5e0
[   16.131396]  [<ffffffff813418fb>] ? trim_stale_devices+0x5b/0xf0
[   16.137420]  [<ffffffff81341b35>] acpiphp_check_bridge+0xd5/0x110
[   16.143531]  [<ffffffff81342acb>] hotplug_event+0x16b/0x260
[   16.149115]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.155136]  [<ffffffff81342bf0>] hotplug_event_work+0x30/0x70
[   16.160978]  [<ffffffff81072d3b>] process_one_work+0x1eb/0x540
[   16.166819]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.172836]  [<ffffffff8107353c>] worker_thread+0x11c/0x370
[   16.178426]  [<ffffffff81073420>] ? rescuer_thread+0x350/0x350
[   16.184276]  [<ffffffff8107b0ea>] kthread+0xea/0xf0
[   16.189165]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160
[   16.195700]  [<ffffffff816395dc>] ret_from_fork+0x7c/0xb0
[   16.201109]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160

The actual death of the serial console occurs in acpi_device_set_power() called from:

enable_slot()
acpiphp_bus_add()
acpiphp_bus_trim()
acpi_bus_trim()
acpi_walk_namespace()
acpi_bus_remove()
acpi_device_unregister()
acpi_device_set_power()

Quoted 4 lines

I can't seem to get a path from the acpi devices in question there, so I have no idea what's getting trimmed here. It worries me quite a bit by introducing this trimming that apparently wasn't happening before though. Thanks,

Hi Alex:
Could you apply the following patch and bootup with kernel param
"acpiphp.acpiphp_debug=1"?
I guess the patch can make serial port alive. It will not
be put into D3cold
during trimming. But I don't know why it doesn't work after being put back to D0.
So please attach output of acpidump and the dmesg if it can work. Thanks.

drivers/acpi/scan.c +0 -0
index e763651..359b23d 100644
@@ -1110,7 +1110,7 @@ static void acpi_device_unregister(struct

acpi_device *device)
* power resources the device depends on and turn off the ones that have
* no more references.
*/
- acpi_device_set_power(device, ACPI_STATE_D3_COLD);

+       //acpi_device_set_power(device, ACPI_STATE_D3_COLD);
        device->handle = NULL;
        put_device(&device->dev);

}

Quoted 7 lines

Alex

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards
Tianyu Lan
#118 lore raw

Re: [PATCH 25/30] ACPI / hotplug / PCI: Check for new devices on enabled slots

Quoted 102 lines · Lan Tianyu

2013/9/5 Alex Williamson <[email protected]>:

Quoted 96 lines · Rafael J. Wysocki
Quoted 58 lines · Alex Williamson
Quoted 48 lines · Rafael J. Wysocki
Quoted 40 lines · Alex Williamson
Quoted 39 lines · Rafael J. Wysocki
Quoted 37 lines

From: Rafael J. Wysocki <[email protected]>

The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not ACPI_STA_ALL.

This behavior is not sufficient to handle the Thunderbolt daisy chaining case properly, however, because in that case the bus behind the already enabled slot needs to be rescanned for new devices.

For this reason, modify acpiphp_check_bridge() so that slots are disabled and stopped if they are not in the ACPI_STA_ALL state.

For slots in the ACPI_STA_ALL state, devices behind them that don't respond are trimmed using a new function, trim_stale_devices(), introduced specifically for this purpose. That function walks the given bus and checks each device on it. If the device doesn't respond, it is assumed to be gone and is removed.

Once all of the stale devices directy behind the slot have been removed, acpiphp_check_bridge() will start looking for new devices that might have appeared on the given bus. It will do that even if the slot is already enabled (SLOT_ENABLED is set for it).

In addition to that, make the bus check notification ignore SLOT_ENABLED and go for enable_device() directly if bridge is NULL, so that devices behind the slot are re-enumerated in that case too.

This change is based on earlier patches from Kirill A Shutemov and Mika Westerberg.

---

Quoted 6 lines
Quoted 2 lines

FYI, git bisect landed on this patch as the cause of my serial console dying on current upstream. Further debugging to come... Thanks,

Well, sorry about that.

What exactly do you mean by "dying"?

Quoted 8 lines

Sorry, I was hoping to have more details quickly, but it's been a pain to debug. By dying I mean serial console output suddenly stops during kernel boot and nothing more comes out of it until after the system is rebooted. The problem happens when acpiphp_check_bridge() calls enable_slot(). The serial console dies somewhere down in acpiphp_bus_trim(). I think this is happening on the 00:1f ISA bridge, so there's a good chance the serial ports are described as somewhere under there.

Quoted 6 lines

Can you please check if that is the acpiphp_bus_trim() called by acpiphp_bus_add() or the other one called from trim_stale_devices()?

Just add a dump_stack() or WARN_ON(1) to trim_stale_devices() next to the acpiphp_bus_trim() call and see if that triggers. I *think* it's the one in acpiphp_bus_add(), but it won't hurt to verify that.

Here's the call path:

[   16.120824]  [<ffffffff81627e6c>] dump_stack+0x55/0x76
[   16.125979]  [<ffffffff8162132e>] enable_slot+0x4ee/0x5e0
[   16.131396]  [<ffffffff813418fb>] ? trim_stale_devices+0x5b/0xf0
[   16.137420]  [<ffffffff81341b35>] acpiphp_check_bridge+0xd5/0x110
[   16.143531]  [<ffffffff81342acb>] hotplug_event+0x16b/0x260
[   16.149115]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.155136]  [<ffffffff81342bf0>] hotplug_event_work+0x30/0x70
[   16.160978]  [<ffffffff81072d3b>] process_one_work+0x1eb/0x540
[   16.166819]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.172836]  [<ffffffff8107353c>] worker_thread+0x11c/0x370
[   16.178426]  [<ffffffff81073420>] ? rescuer_thread+0x350/0x350
[   16.184276]  [<ffffffff8107b0ea>] kthread+0xea/0xf0
[   16.189165]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160
[   16.195700]  [<ffffffff816395dc>] ret_from_fork+0x7c/0xb0
[   16.201109]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160

The actual death of the serial console occurs in acpi_device_set_power() called from:

enable_slot()
acpiphp_bus_add()
acpiphp_bus_trim()
acpi_bus_trim()
acpi_walk_namespace()
acpi_bus_remove()
acpi_device_unregister()
acpi_device_set_power()

Quoted 4 lines

I can't seem to get a path from the acpi devices in question there, so I have no idea what's getting trimmed here. It worries me quite a bit by introducing this trimming that apparently wasn't happening before though. Thanks,

Quoted 7 lines

Hi Alex:
Could you apply the following patch and bootup with kernel param
"acpiphp.acpiphp_debug=1"?
I guess the patch can make serial port alive. It will not
be put into D3cold
during trimming. But I don't know why it doesn't work after being put back to D0.

Do we actually put it into D0 in acpi_bus_scan()? I don't think so.

Quoted 15 lines

So please attach output of acpidump and the dmesg if it can work. Thanks.

drivers/acpi/scan.c +1 -1
index e763651..359b23d 100644
@@ -1110,7 +1110,7 @@ static void acpi_device_unregister(struct
 acpi_device *device)
         * power resources the device depends on and turn off the ones that have
         * no more references.
         */
-       acpi_device_set_power(device, ACPI_STATE_D3_COLD);
+       //acpi_device_set_power(device, ACPI_STATE_D3_COLD);
        device->handle = NULL;
        put_device(&device->dev);
Quoted 1 line

}

I don't think we should do the trimming in acpiphp_bus_add() at all.

Thanks,
Rafael

#119 lore raw

Re: [PATCH 25/30] ACPI / hotplug / PCI: Check for new devices on enabled slots

2013/9/5 Rafael J. Wysocki <[email protected]>:

Quoted 111 lines · Lan Tianyu
Quoted 102 lines

2013/9/5 Alex Williamson <[email protected]>:

Quoted 96 lines · Rafael J. Wysocki
Quoted 58 lines · Alex Williamson
Quoted 48 lines · Rafael J. Wysocki
Quoted 40 lines · Alex Williamson
Quoted 39 lines · Rafael J. Wysocki
Quoted 37 lines

From: Rafael J. Wysocki <[email protected]>

The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not ACPI_STA_ALL.

This behavior is not sufficient to handle the Thunderbolt daisy chaining case properly, however, because in that case the bus behind the already enabled slot needs to be rescanned for new devices.

For this reason, modify acpiphp_check_bridge() so that slots are disabled and stopped if they are not in the ACPI_STA_ALL state.

For slots in the ACPI_STA_ALL state, devices behind them that don't respond are trimmed using a new function, trim_stale_devices(), introduced specifically for this purpose. That function walks the given bus and checks each device on it. If the device doesn't respond, it is assumed to be gone and is removed.

Once all of the stale devices directy behind the slot have been removed, acpiphp_check_bridge() will start looking for new devices that might have appeared on the given bus. It will do that even if the slot is already enabled (SLOT_ENABLED is set for it).

In addition to that, make the bus check notification ignore SLOT_ENABLED and go for enable_device() directly if bridge is NULL, so that devices behind the slot are re-enumerated in that case too.

This change is based on earlier patches from Kirill A Shutemov and Mika Westerberg.

---

Quoted 6 lines
Quoted 2 lines

FYI, git bisect landed on this patch as the cause of my serial console dying on current upstream. Further debugging to come... Thanks,

Well, sorry about that.

What exactly do you mean by "dying"?

Quoted 8 lines

Sorry, I was hoping to have more details quickly, but it's been a pain to debug. By dying I mean serial console output suddenly stops during kernel boot and nothing more comes out of it until after the system is rebooted. The problem happens when acpiphp_check_bridge() calls enable_slot(). The serial console dies somewhere down in acpiphp_bus_trim(). I think this is happening on the 00:1f ISA bridge, so there's a good chance the serial ports are described as somewhere under there.

Quoted 6 lines

Can you please check if that is the acpiphp_bus_trim() called by acpiphp_bus_add() or the other one called from trim_stale_devices()?

Just add a dump_stack() or WARN_ON(1) to trim_stale_devices() next to the acpiphp_bus_trim() call and see if that triggers. I *think* it's the one in acpiphp_bus_add(), but it won't hurt to verify that.

Here's the call path:

[   16.120824]  [<ffffffff81627e6c>] dump_stack+0x55/0x76
[   16.125979]  [<ffffffff8162132e>] enable_slot+0x4ee/0x5e0
[   16.131396]  [<ffffffff813418fb>] ? trim_stale_devices+0x5b/0xf0
[   16.137420]  [<ffffffff81341b35>] acpiphp_check_bridge+0xd5/0x110
[   16.143531]  [<ffffffff81342acb>] hotplug_event+0x16b/0x260
[   16.149115]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.155136]  [<ffffffff81342bf0>] hotplug_event_work+0x30/0x70
[   16.160978]  [<ffffffff81072d3b>] process_one_work+0x1eb/0x540
[   16.166819]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.172836]  [<ffffffff8107353c>] worker_thread+0x11c/0x370
[   16.178426]  [<ffffffff81073420>] ? rescuer_thread+0x350/0x350
[   16.184276]  [<ffffffff8107b0ea>] kthread+0xea/0xf0
[   16.189165]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160
[   16.195700]  [<ffffffff816395dc>] ret_from_fork+0x7c/0xb0
[   16.201109]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160

The actual death of the serial console occurs in acpi_device_set_power() called from:

enable_slot()
acpiphp_bus_add()
acpiphp_bus_trim()
acpi_bus_trim()
acpi_walk_namespace()
acpi_bus_remove()
acpi_device_unregister()
acpi_device_set_power()

Quoted 4 lines

I can't seem to get a path from the acpi devices in question there, so I have no idea what's getting trimmed here. It worries me quite a bit by introducing this trimming that apparently wasn't happening before though. Thanks,

Quoted 7 lines

Hi Alex:
Could you apply the following patch and bootup with kernel param
"acpiphp.acpiphp_debug=1"?
I guess the patch can make serial port alive. It will not
be put into D3cold
during trimming. But I don't know why it doesn't work after being put back to D0.

Quoted 2 lines

Do we actually put it into D0 in acpi_bus_scan()? I don't think so.

Hi Rafael:
I mean the code in the acpiphp_bus_add(). After trimming and acpi
bus scan handle, the device will be put back to D0 if acpi_bus_get_device() return acpi device. So I thought the serial port is put back to D0.

Quoted 18 lines
Quoted 15 lines

So please attach output of acpidump and the dmesg if it can work. Thanks.

drivers/acpi/scan.c +1 -1
index e763651..359b23d 100644
@@ -1110,7 +1110,7 @@ static void acpi_device_unregister(struct
 acpi_device *device)
         * power resources the device depends on and turn off the ones that have
         * no more references.
         */
-       acpi_device_set_power(device, ACPI_STATE_D3_COLD);
+       //acpi_device_set_power(device, ACPI_STATE_D3_COLD);
        device->handle = NULL;
        put_device(&device->dev);
Quoted 1 line

}

I don't think we should do the trimming in acpiphp_bus_add() at all.

Yes, I agree.

Quoted 4 lines

Thanks,
Rafael

Signature · 2 lines
Best regards
Tianyu Lan
#120 lore raw

Re: [PATCH 25/30] ACPI / hotplug / PCI: Check for new devices on enabled slots

Quoted 112 lines · Lan Tianyu

2013/9/5 Rafael J. Wysocki <[email protected]>:

Quoted 111 lines · Lan Tianyu
Quoted 109 lines

2013/9/5 Alex Williamson <[email protected]>:

Quoted 96 lines · Rafael J. Wysocki
Quoted 58 lines · Alex Williamson
Quoted 48 lines · Rafael J. Wysocki
Quoted 40 lines · Alex Williamson
Quoted 39 lines · Rafael J. Wysocki
Quoted 37 lines

From: Rafael J. Wysocki <[email protected]>

The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not ACPI_STA_ALL.

This behavior is not sufficient to handle the Thunderbolt daisy chaining case properly, however, because in that case the bus behind the already enabled slot needs to be rescanned for new devices.

For this reason, modify acpiphp_check_bridge() so that slots are disabled and stopped if they are not in the ACPI_STA_ALL state.

For slots in the ACPI_STA_ALL state, devices behind them that don't respond are trimmed using a new function, trim_stale_devices(), introduced specifically for this purpose. That function walks the given bus and checks each device on it. If the device doesn't respond, it is assumed to be gone and is removed.

Once all of the stale devices directy behind the slot have been removed, acpiphp_check_bridge() will start looking for new devices that might have appeared on the given bus. It will do that even if the slot is already enabled (SLOT_ENABLED is set for it).

In addition to that, make the bus check notification ignore SLOT_ENABLED and go for enable_device() directly if bridge is NULL, so that devices behind the slot are re-enumerated in that case too.

This change is based on earlier patches from Kirill A Shutemov and Mika Westerberg.

---

Quoted 6 lines
Quoted 2 lines

FYI, git bisect landed on this patch as the cause of my serial console dying on current upstream. Further debugging to come... Thanks,

Well, sorry about that.

What exactly do you mean by "dying"?

Quoted 8 lines

Sorry, I was hoping to have more details quickly, but it's been a pain to debug. By dying I mean serial console output suddenly stops during kernel boot and nothing more comes out of it until after the system is rebooted. The problem happens when acpiphp_check_bridge() calls enable_slot(). The serial console dies somewhere down in acpiphp_bus_trim(). I think this is happening on the 00:1f ISA bridge, so there's a good chance the serial ports are described as somewhere under there.

Quoted 6 lines

Can you please check if that is the acpiphp_bus_trim() called by acpiphp_bus_add() or the other one called from trim_stale_devices()?

Just add a dump_stack() or WARN_ON(1) to trim_stale_devices() next to the acpiphp_bus_trim() call and see if that triggers. I *think* it's the one in acpiphp_bus_add(), but it won't hurt to verify that.

Here's the call path:

[   16.120824]  [<ffffffff81627e6c>] dump_stack+0x55/0x76
[   16.125979]  [<ffffffff8162132e>] enable_slot+0x4ee/0x5e0
[   16.131396]  [<ffffffff813418fb>] ? trim_stale_devices+0x5b/0xf0
[   16.137420]  [<ffffffff81341b35>] acpiphp_check_bridge+0xd5/0x110
[   16.143531]  [<ffffffff81342acb>] hotplug_event+0x16b/0x260
[   16.149115]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.155136]  [<ffffffff81342bf0>] hotplug_event_work+0x30/0x70
[   16.160978]  [<ffffffff81072d3b>] process_one_work+0x1eb/0x540
[   16.166819]  [<ffffffff81072cd9>] ? process_one_work+0x189/0x540
[   16.172836]  [<ffffffff8107353c>] worker_thread+0x11c/0x370
[   16.178426]  [<ffffffff81073420>] ? rescuer_thread+0x350/0x350
[   16.184276]  [<ffffffff8107b0ea>] kthread+0xea/0xf0
[   16.189165]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160
[   16.195700]  [<ffffffff816395dc>] ret_from_fork+0x7c/0xb0
[   16.201109]  [<ffffffff8107b000>] ? kthread_create_on_node+0x160/0x160

The actual death of the serial console occurs in acpi_device_set_power() called from:

enable_slot()
acpiphp_bus_add()
acpiphp_bus_trim()
acpi_bus_trim()
acpi_walk_namespace()
acpi_bus_remove()
acpi_device_unregister()
acpi_device_set_power()

Quoted 4 lines

I can't seem to get a path from the acpi devices in question there, so I have no idea what's getting trimmed here. It worries me quite a bit by introducing this trimming that apparently wasn't happening before though. Thanks,

Hi Alex:
Could you apply the following patch and bootup with kernel param
"acpiphp.acpiphp_debug=1"?
I guess the patch can make serial port alive. It will not
be put into D3cold
during trimming. But I don't know why it doesn't work after being put back to D0.

Quoted 7 lines
Quoted 2 lines

Do we actually put it into D0 in acpi_bus_scan()? I don't think so.

Hi Rafael:
I mean the code in the acpiphp_bus_add(). After trimming and acpi
bus scan handle, the device will be put back to D0 if acpi_bus_get_device() return acpi device. So I thought the serial port is put back to D0.

*The* device corresponding to handle will be put into D0. Any devices below it whose ACPI device objects may also be added by acpi_bus_scan() - not necessarily.

Thanks,
Rafael

#121 lore raw

PATCH 26/30 ACPI / hotplug / PCI: Get rid of unused constants in acpiphp.h

In reply to Rafael J. Wysocki

From: Mika Westerberg <[email protected]>

Drop some unused symbols from acpiphp.h and redefine SLOT_ENABLED (which is the only slot flag now) as 1.

[rjw: Redefinition of SLOT_ENABLED, changelog]

---
drivers/pci/hotplug/acpiphp.h | 4 ----

 drivers/pci/hotplug/acpiphp.h |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pci/hotplug/acpiphp.h +1 -5
Index: linux-pm/drivers/pci/hotplug/acpiphp.h
===================================================================
@@ -154,16 +154,12 @@ struct acpiphp_attention_info
 	struct module *owner;
 };
 
-/* PCI bus bridge HID */
-#define ACPI_PCI_HOST_HID		"PNP0A03"
-
 /* ACPI _STA method value (ignore bit 4; battery present) */
 #define ACPI_STA_ALL			(0x0000000f)
 
 /* slot flags */
 
-#define SLOT_ENABLED		(0x00000002)
-#define SLOT_MULTIFUNCTION	(0x00000004)
+#define SLOT_ENABLED		(0x00000001)
 
 /* function flags */
 
#122 lore raw

PATCH 27/30 ACPI / hotplug / PCI: Sanitize acpiphp_get_(latch)|(adapter)_status()

In reply to Rafael J. Wysocki

From: Mika Westerberg <[email protected]>

There is no need for a temporary variable and all the tricks with ternary operators in acpiphp_get_(latch)|(adapter)_status(). Change those functions to be a bit more straightforward.

---
 drivers/pci/hotplug/acpiphp_glue.c |   12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +2 -10
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -1107,11 +1107,7 @@ u8 acpiphp_get_power_status(struct acpip
  */
 u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
 {
-	unsigned int sta;
-
-	sta = get_slot_status(slot);
-
-	return (sta & ACPI_STA_DEVICE_UI) ? 0 : 1;
+	return !(get_slot_status(slot) & ACPI_STA_DEVICE_UI);
 }
 
 
@@ -1121,9 +1117,5 @@ u8 acpiphp_get_latch_status(struct acpip
  */
 u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot)
 {
-	unsigned int sta;
-
-	sta = get_slot_status(slot);
-
-	return (sta == 0) ? 0 : 1;
+	return !!get_slot_status(slot);
 }
#123 lore raw

PATCH 28/30 ACPI / hotplug / PCI: Redefine enable_device() and disable_device()

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Notice that functions enable_device() and disable_device() cannot fail and their return values are ignored in the majority of places, so redefine them as void and use the opportunity to change their names to enable_slot() and disable_slot(), respectively, which much better reflects what they do.

---
 drivers/pci/hotplug/acpiphp_glue.c |   33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +12 -21
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -532,13 +532,13 @@ static void check_hotplug_bridge(struct
 }
 
 /**
- * enable_device - enable, configure a slot
+ * enable_slot - enable, configure a slot
  * @slot: slot to be enabled
  *
  * This function should be called per *physical slot*,
  * not per each slot object in ACPI namespace.
  */
-static int __ref enable_device(struct acpiphp_slot *slot)
+static void __ref enable_slot(struct acpiphp_slot *slot)
 {
 	struct pci_dev *dev;
 	struct pci_bus *bus = slot->bus;
@@ -556,6 +556,7 @@ static int __ref enable_device(struct ac
 		list_for_each_entry(dev, &bus->devices, bus_list) {
 			if (PCI_SLOT(dev->devfn) != slot->device)
 				continue;
+
 			if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
 			    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
 				max = pci_scan_bridge(bus, dev, max, pass);
@@ -594,8 +595,6 @@ static int __ref enable_device(struct ac
 			continue;
 		}
 	}
-
-	return 0;
 }
 
 /* return first device in slot, acquiring a reference on it */
@@ -617,16 +616,16 @@ static struct pci_dev *dev_in_slot(struc
 }
 
 /**
- * disable_device - disable a slot
+ * disable_slot - disable a slot
  * @slot: ACPI PHP slot
  */
-static int disable_device(struct acpiphp_slot *slot)
+static void disable_slot(struct acpiphp_slot *slot)
 {
 	struct acpiphp_func *func;
 	struct pci_dev *pdev;
 
 	/*
-	 * enable_device() enumerates all functions in this device via
+	 * enable_slot() enumerates all functions in this device via
 	 * pci_scan_slot(), whether they have associated ACPI hotplug
 	 * methods (_EJ0, etc.) or not.  Therefore, we remove all functions
 	 * here.
@@ -640,8 +639,6 @@ static int disable_device(struct acpiphp
 		acpiphp_bus_trim(func_to_handle(func));
 
 	slot->flags &= (~SLOT_ENABLED);
-
-	return 0;
 }
 
 
@@ -751,9 +748,9 @@ static void acpiphp_check_bridge(struct
 					trim_stale_devices(dev);
 
 			/* configure all functions */
-			enable_device(slot);
+			enable_slot(slot);
 		} else {
-			disable_device(slot);
+			disable_slot(slot);
 		}
 		mutex_unlock(&slot->crit_sect);
 	}
@@ -860,7 +857,7 @@ static void hotplug_event(acpi_handle ha
 			struct acpiphp_slot *slot = func->slot;
 
 			mutex_lock(&slot->crit_sect);
-			enable_device(slot);
+			enable_slot(slot);
 			mutex_unlock(&slot->crit_sect);
 		}
 		break;
@@ -1047,16 +1044,13 @@ void acpiphp_remove_slots(struct pci_bus
  */
 int acpiphp_enable_slot(struct acpiphp_slot *slot)
 {
-	int retval = 0;
-
 	mutex_lock(&slot->crit_sect);
-
 	/* configure all functions */
 	if (!(slot->flags & SLOT_ENABLED))
-		retval = enable_device(slot);
+		enable_slot(slot);
 
 	mutex_unlock(&slot->crit_sect);
-	return retval;
+	return 0;
 }
 
 /**
@@ -1071,9 +1065,7 @@ int acpiphp_disable_and_eject_slot(struc
 	mutex_lock(&slot->crit_sect);
 
 	/* unconfigure all functions */
-	retval = disable_device(slot);
-	if (retval)
-		goto err_exit;
+	disable_slot(slot);
 
 	list_for_each_entry(func, &slot->funcs, sibling)
 		if (func->flags & FUNC_HAS_EJ0) {
@@ -1085,7 +1077,6 @@ int acpiphp_disable_and_eject_slot(struc
 			break;
 		}
 
- err_exit:
 	mutex_unlock(&slot->crit_sect);
 	return retval;
 }
#124 lore raw

PATCH 29/30 ACPI / hotplug / PCI: Clean up bridge_mutex usage

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Do not acquire bridge_mutex around the addition of a slot to its bridge's list of slots and arount the addition of a function to its slot's list of functions, because that doesn't help anything right now (those lists are walked without any locking anyway).

However, acquire bridge_mutex around the list walk in acpiphp_remove_slots() and use list_for_each_entry() there, because we terminate the walk as soon as we find the first matching entry. This prevents that list walk from colliding with bridge addition and removal.

---
 drivers/pci/hotplug/acpiphp_glue.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +7 -7
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -323,9 +323,7 @@ static acpi_status register_slot(acpi_ha
 	INIT_LIST_HEAD(&slot->funcs);
 	mutex_init(&slot->crit_sect);
 
-	mutex_lock(&bridge_mutex);
 	list_add_tail(&slot->node, &bridge->slots);
-	mutex_unlock(&bridge_mutex);
 
 	/* Register slots for ejectable funtions only. */
 	if (acpi_pci_check_ejectable(pbus, handle)  || is_dock_device(handle)) {
@@ -355,9 +353,7 @@ static acpi_status register_slot(acpi_ha
 
  slot_found:
 	newfunc->slot = slot;
-	mutex_lock(&bridge_mutex);
 	list_add_tail(&newfunc->sibling, &slot->funcs);
-	mutex_unlock(&bridge_mutex);
 
 	if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
 				       &val, 60*1000))
@@ -1025,17 +1021,21 @@ void acpiphp_enumerate_slots(struct pci_
 /* Destroy hotplug slots associated with the PCI bus */
 void acpiphp_remove_slots(struct pci_bus *bus)
 {
-	struct acpiphp_bridge *bridge, *tmp;
+	struct acpiphp_bridge *bridge;
 
 	if (acpiphp_disabled)
 		return;
 
-	list_for_each_entry_safe(bridge, tmp, &bridge_list, list)
+	mutex_lock(&bridge_mutex);
+	list_for_each_entry(bridge, &bridge_list, list)
 		if (bridge->pci_bus == bus) {
+			mutex_unlock(&bridge_mutex);
 			cleanup_bridge(bridge);
 			put_bridge(bridge);
-			break;
+			return;
 		}
+
+	mutex_unlock(&bridge_mutex);
 }
 
 /**
#125 lore raw

PATCH 30/30 ACPI / hotplug / PCI: Get rid of check_sub_bridges()

In reply to Rafael J. Wysocki

From: Mika Westerberg <[email protected]>

Now that acpiphp_check_bridge() always enumerates devices behind the bridge, there is no need to do that for each sub-bridge anymore like it is done in the current ACPI-based PCI hotplug (ACPIPHP) code.

Given this we don't need check_sub_bridges() anymore, so drop that function completely.

This also simplifies the ACPIPHP code a bit.

---
 drivers/pci/hotplug/acpiphp_glue.c |   25 -------------------------
 1 file changed, 25 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +0 -25
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -788,25 +788,6 @@ static void acpiphp_sanitize_bus(struct
  * ACPI event handlers
  */
 
-static acpi_status
-check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
-{
-	struct acpiphp_bridge *bridge;
-	char objname[64];
-	struct acpi_buffer buffer = { .length = sizeof(objname),
-				      .pointer = objname };
-
-	bridge = acpiphp_handle_to_bridge(handle);
-	if (bridge) {
-		acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-		dbg("%s: re-enumerating slots under %s\n",
-			__func__, objname);
-		acpiphp_check_bridge(bridge);
-		put_bridge(bridge);
-	}
-	return AE_OK ;
-}
-
 void acpiphp_check_host_bridge(acpi_handle handle)
 {
 	struct acpiphp_bridge *bridge;
@@ -816,9 +797,6 @@ void acpiphp_check_host_bridge(acpi_hand
 		acpiphp_check_bridge(bridge);
 		put_bridge(bridge);
 	}
-
-	acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
-		ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL);
 }
 
 static void hotplug_event(acpi_handle handle, u32 type, void *data)
@@ -846,9 +824,6 @@ static void hotplug_event(acpi_handle ha
 		dbg("%s: re-enumerating slots under %s\n", __func__, objname);
 		if (bridge) {
 			acpiphp_check_bridge(bridge);
-			acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
-					    ACPI_UINT32_MAX, check_sub_bridges,
-					    NULL, NULL, NULL);
 		} else {
 			struct acpiphp_slot *slot = func->slot;
 
#126 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

In reply to Rafael J. Wysocki
Quoted 82 lines · Rafael J. Wysocki

Hi All,

Now the series has been rebased on top of current linux-pm.git/linux-next and tested on two systems with Thunderbolt. Some changes have been made too. ->

Quoted 26 lines · Rafael J. Wysocki

Hi,

I've made some progress with my ACPIPHP rework since I posted the series last time and here goes an update.

First off, the previous series was somewhat racy, which should be fixed now. Apart from this there's quite some new material on top of the patches I posted last time (or rather on top of their new versions) and I integrated the Thunderbolt series from Mika with that. As a result,

https://patchwork.kernel.org/patch/2817341/

is required to be applied.

Still untested, still based on 3.10 with ACPI+PM 3.11 material merged on top, but this time I don't have any plans to add more patches to the series for the time being. Also 3.11-rc1 should be out in a couple of days, so I'll be able to integrate this work with the previous cleanups series from Gerry and myself on top of it.

I did my best not to change too much at a time and some steps add stuff that is removed by the subsequent ones, so hopefully it is bisectable.

If anyone finds something questionable or outright bogus in these patches, please let me know before it's too late. ;-)

Quoted 16 lines

[ 1/30] Make bus registration and unregistration symmetric. [Resend]
[ 2/30] Consolidate acpiphp_enumerate_slots(). [Resend]
[ 3/30] Fix error code path in register_slot(). [Resend]
[ 4/30] Introduce hotplug context objects for ACPI device objects corresponding
to PCI hotplug devices. [Update]
[ 5/30] Unified notify handler for hotplug events. [Update]
[ 6/30] Drop acpiphp_handle_to_bridge() and use context objects instead of it. [Update] [ 7/30] Pass entire hotplug context objects (instead of their fields
individually) to event handling work functions. [Update]
[ 8/30] Merge hotplug event handling functions. [Update]
[ 9/30] Drop func field from struct acpiphp_bridge.
[10/30] Refactor slot allocation code in register_slot().
[11/30] Make acpiphp_enumerate_slots() to register all devices on the given bus
and install the notification handler for all of them.
[12/30] Drop sun field from struct acpiphp_slot.
[13/30] Use common slot count variable in register_slot().

-> The one above has been dropped, because it might cause regressions to appear on some systems, but that's not a big deal.

The numbering of the patches below has changed as a result, so the next one is [13/30] now and so on.

Quoted 11 lines

[14/30] Drop flags field from struct acpiphp_bridge.
[15/30] Embed function structure into struct acpiphp_context. [16/30] Drop handle field from struct acpiphp_func.
[17/30] Drop handle field from struct acpiphp_bridge.
[18/30] Store parent bridge pointer in function objects and bus pointer in slot
objects.
[19/30] Rework ACPI namespace scanning and trimming routines. [20/30] Drop redundant checks from check_hotplug_bridge().
[21/30] Consolidate slot disabling and ejecting
[22/30] Do not queue up event handling work items for non-hotplug events. [23/30] Do not execute _PS0 and _PS3 directly.

This one was fixed after Mika had reported a problem with it.

Quoted 3 lines

[24/30] Do not check SLOT_ENABLED in enable_device(). [Thunderbolt series] [25/30] Allow slots without new devices to be rescanned. [Thunderbolt series] [26/30] Check for new devices on enabled slots. [Thunderbolt series, TBD]

This one was reworked to use acpi_bus_trim() on ACPI device objects corresponding to PCI devices being removed (it also uses _STA to check the status of those devices if available).

Quoted 4 lines

[27/30] Get rid of unused constands in acpiphp.h. [Thunderbolt series] [28/30] Sanitize acpiphp_get_(latch)|(adapter)_status(). [Thunderbolt series] [29/30] Redefine enable_device() and disable_device() (rename and change to void). [30/30] Clean up the usage of bridge_mutex.

Quoted 8 lines

The one above is [29/30] now and we have added one more patch:

[30/30] Drop check_sub_bridges() which isn't necessary any more.

The updated patches follow.

If you don't hate this stuff, I'll put it into linux-next over the weekend for further testing.

pm/linux-next with those patches breaks acpi root bus hotplug. it is kvm guest:

10:~ # echo "PCI0 3" > /sys/kernel/debug/acpi/sci_notify

[   92.549508] ACPI: ACPI device name is <PCI0>, event code is <3>
[   92.552433] ACPI: Notify event is queued
10:~ # [   92.554279] ACPI: \_SB_.PCI0: Device eject notify on
_handle_hotplug_event_root
[   92.677696] ACPI: Device 0000:00:03.0 -x-> \_SB_.PCI0.S03_
[   92.679229] ACPI: Device 0000:00:02.0 -x-> \_SB_.PCI0.VGA_
[   92.680684] ACPI: Device 0000:00:01.3 -x-> \_SB_.PCI0.PX13
[   92.682235] ata1.00: disabled
[   92.689000] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   92.690399] sd 0:0:0:0: [sda]
[   92.691133] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[   92.693151] sd 0:0:0:0: [sda] Stopping disk
[   92.694682] sd 0:0:0:0: [sda] START_STOP FAILED
[   92.696749] sd 0:0:0:0: [sda]
[   92.698157] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[   92.702852] ata2.00: disabled
[   92.711550] ACPI: Device 0000:00:01.0 -x-> \_SB_.PCI0.ISA_
[   92.713208] ACPI: Device pci0000:00 -x-> \_SB_.PCI0
[   92.713226]   acpi_pci_iommu_remove is called for \_SB_.PCI0 ffff88007ab3f1e0
[   92.713274]   acpi_pci_ioapic_remove is called for \_SB_.PCI0
ffff88007ab3f1e0
[   92.713345] pci 0000:00:00.0: freeing pci_dev info
[   92.713363] pci 0000:00:01.0: freeing pci_dev info
[   92.713366] pci 0000:00:01.1: freeing pci_dev info
[   92.713376] pci 0000:00:01.3: freeing pci_dev info
[   92.713380] pci 0000:00:02.0: freeing pci_dev info
[   92.713384] pci 0000:00:03.0: freeing pci_dev info
[   92.713396] pci_bus 0000:00: busn_res: [bus 00-ff] is released
[   92.713441] BUG: unable to handle kernel NULL pointer dereference
at           (null)
[   92.713446] IP: [<ffffffff81557910>]
acpiphp_unregister_hotplug_slot+0x20/0x60
[   92.713448] PGD 0
[   92.713449] Oops: 0000 [#1] SMP
[   92.713451] Modules linked in:
[   92.713453] CPU: 0 PID: 1042 Comm: kworker/0:1 Not tainted
3.11.0-rc2-yh-00277-gaaf9c19-dirty #1818
[   92.713454] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[   92.713458] Workqueue: kacpi_hotplug acpi_os_execute_deferred
[   92.713459] task: ffff88007a0ecb40 ti: ffff88007a72a000 task.ti:
ffff88007a72a000
[   92.713461] RIP: 0010:[<ffffffff81557910>]  [<ffffffff81557910>]
acpiphp_unregister_hotplug_slot+0x20/0x60
[   92.713462] RSP: 0018:ffff88007a72bb28  EFLAGS: 00010296
[   92.713463] RAX: ffff88007a774e18 RBX: 0000000000000000 RCX: 0000000000000004
[   92.713463] RDX: ffffffff822ab080 RSI: ffffffff8284eaef RDI: ffffffff8284eb13
[   92.713464] RBP: ffff88007a72bb38 R08: 0000000000000000 R09: 0000000000000000
[   92.713465] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88007a774e18
[   92.713465] R13: ffff88007a774e00 R14: ffff88007a148f70 R15: ffff88007a774e08
[   92.713466] FS:  0000000000000000(0000) GS:ffff88007b800000(0000)
knlGS:0000000000000000
[   92.713467] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[   92.713470] CR2: 0000000000000000 CR3: 00000000794fc000 CR4: 00000000000006f0
[   92.713474] Stack:
[   92.713476]  ffff88007a148f70 ffff88007ab43cd0 ffff88007a72bb88
ffffffff81557ae0
[   92.713478]  ffff88007a72bb78 ffff88007a148f60 ffffffff8153574e
ffff88007a148f60
[   92.713479]  ffff88007a07d000 ffff88007a07d028 ffff88007a07d800
ffff88007a325298
[   92.713480] Call Trace:
[   92.713482]  [<ffffffff81557ae0>] cleanup_bridge+0x80/0xf0
[   92.713485]  [<ffffffff8153574e>] ? pci_remove_bus+0x3e/0x60
[   92.713487]  [<ffffffff81558b1d>] acpiphp_remove_slots+0x5d/0xa0
[   92.713489]  [<ffffffff8155d48a>] acpi_pci_remove_bus+0x2a/0x40
[   92.713493]  [<ffffffff81f7bf9e>] pcibios_remove_bus+0xe/0x10
[   92.713494]  [<ffffffff81535756>] pci_remove_bus+0x46/0x60
[   92.713496]  [<ffffffff81535900>] pci_remove_root_bus+0x50/0xa0
[   92.713499]  [<ffffffff81595596>] acpi_pci_root_remove+0x52/0x5f
[   92.713501]  [<ffffffff81590a0f>] acpi_bus_device_detach+0x3d/0x5e
[   92.713503]  [<ffffffff81590a72>] acpi_bus_trim+0x42/0x7a
[   92.713505]  [<ffffffff8159104e>] acpi_scan_hot_remove+0x194/0x23b
[   92.713507]  [<ffffffff815911f4>] acpi_bus_hot_remove_device+0x2f/0x66
[   92.713509]  [<ffffffff8158b60b>] acpi_os_execute_deferred+0x25/0x32
[   92.713513]  [<ffffffff810b7ffb>] process_one_work+0x28b/0x490
[   92.713515]  [<ffffffff810b7f72>] ? process_one_work+0x202/0x490
[   92.713517]  [<ffffffff810b94ce>] worker_thread+0x21e/0x370
[   92.713521]  [<ffffffff810fdafd>] ? trace_hardirqs_on+0xd/0x10
[   92.713523]  [<ffffffff810b92b0>] ? manage_workers.isra.18+0x330/0x330
[   92.713526]  [<ffffffff810c0aa8>] kthread+0xe8/0xf0
[   92.713528]  [<ffffffff810c09c0>] ? __init_kthread_worker+0x70/0x70
[   92.713531]  [<ffffffff820d991c>] ret_from_fork+0x7c/0xb0
[   92.713533]  [<ffffffff810c09c0>] ? __init_kthread_worker+0x70/0x70
[   92.713549] Code: 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00
55 48 c7 c6 ef ea 84 82 48 89 e5 53 48 83 ec 08 48 8b 5f 28 48 c7 c7
13 eb 84 82 <48> 8b 03 48 8b 40 30 48 8b 50 28 31 c0 e8 f7 dd b5 00 48
8b 3b
[   92.713551] RIP  [<ffffffff81557910>]
acpiphp_unregister_hotplug_slot+0x20/0x60
[   92.713552]  RSP <ffff88007a72bb28>
[   92.713552] CR2: 0000000000000000
[   92.713554] ---[ end trace 9e3bba504fb5e5d4 ]---
[   92.713589] BUG: unable to handle kernel paging request at ffffffffffffff98
[   92.713591] IP: [<ffffffff810c0e30>] kthread_data+0x10/0x20
[   92.713593] PGD 2a15067 PUD 2a17067 PMD 0
[   92.713594] Oops: 0000 [#2] SMP
[   92.713595] Modules linked in:
[   92.713596] CPU: 0 PID: 1042 Comm: kworker/0:1 Tainted: G      D
  3.11.0-rc2-yh-00277-gaaf9c19-dirty #1818
[   92.713597] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[   92.713604] task: ffff88007a0ecb40 ti: ffff88007a72a000 task.ti:
ffff88007a72a000
[   92.713606] RIP: 0010:[<ffffffff810c0e30>]  [<ffffffff810c0e30>]
kthread_data+0x10/0x20
[   92.713607] RSP: 0018:ffff88007a72b648  EFLAGS: 00010092
[   92.713607] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000008
[   92.713608] RDX: 0000000000000006 RSI: 0000000000000000 RDI: ffff88007a0ecb40
[   92.713608] RBP: ffff88007a72b648 R08: ffff88007a0ecbb0 R09: 0000000000000000
[   92.713609] R10: 0000000000000000 R11: 000000159620c258 R12: ffff88007b9d3e80
[   92.713610] R13: 0000000000000000 R14: 0000000000000001 R15: ffff88007a0ecb40
[   92.713611] FS:  0000000000000000(0000) GS:ffff88007b800000(0000)
knlGS:0000000000000000
[   92.713612] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[   92.713615] CR2: 0000000000000028 CR3: 00000000794fc000 CR4: 00000000000006f0
[   92.713618] Stack:
[   92.713620]  ffff88007a72b668 ffffffff810b9a15 ffff88007a72b668
ffff88007a0ed168
[   92.713621]  ffff88007a72b788 ffffffff820ce2f4 ffff88007a72b6c8
ffff88007a72bfd8
[   92.713623]  ffff88007a72bfd8 0000000000004000 ffff88007a0ecb40
ffff88007a0ecb40
[   92.713623] Call Trace:
[   92.713625]  [<ffffffff810b9a15>] wq_worker_sleeping+0x15/0xa0
[   92.713627]  [<ffffffff820ce2f4>] __schedule+0x154/0xa60
[   92.713629]  [<ffffffff810fdafd>] ? trace_hardirqs_on+0xd/0x10
[   92.713632]  [<ffffffff814e540a>] ? put_io_context+0x9a/0xb0
[   92.713633]  [<ffffffff814e547b>] ? put_io_context_active+0x5b/0xd0
[   92.713635]  [<ffffffff820cecfd>] schedule+0x5d/0x60
[   92.713638]  [<ffffffff8109def5>] do_exit+0x935/0x990
[   92.713640]  [<ffffffff820d20e8>] oops_end+0xc8/0xe0
[   92.713643]  [<ffffffff820b4fbc>] no_context+0x261/0x28c
[   92.713645]  [<ffffffff820b51ac>] __bad_area_nosemaphore+0x1c5/0x1e4
[   92.713646]  [<ffffffff820b51de>] bad_area_nosemaphore+0x13/0x15
[   92.713649]  [<ffffffff820d505e>] __do_page_fault+0x4be/0x550
[   92.713651]  [<ffffffff810d41e5>] ? sched_clock_local+0x25/0xa0
[   92.713653]  [<ffffffff810f9fc8>] ? trace_hardirqs_off_caller+0x28/0x160
[   92.713655]  [<ffffffff810fd876>] ? mark_held_locks+0x136/0x150
[   92.713657]  [<ffffffff810c673b>] ? up+0x4b/0x60
[   92.713659]  [<ffffffff820d5127>] do_page_fault+0x37/0x60
[   92.713660]  [<ffffffff820d128c>] ? restore_args+0x30/0x30
[   92.713662]  [<ffffffff820d1462>] page_fault+0x22/0x30
[   92.713664]  [<ffffffff81557910>] ? acpiphp_unregister_hotplug_slot+0x20/0x60
[   92.713667]  [<ffffffff81557ae0>] cleanup_bridge+0x80/0xf0
[   92.713669]  [<ffffffff8153574e>] ? pci_remove_bus+0x3e/0x60
[   92.713671]  [<ffffffff81558b1d>] acpiphp_remove_slots+0x5d/0xa0
[   92.713673]  [<ffffffff8155d48a>] acpi_pci_remove_bus+0x2a/0x40
[   92.713676]  [<ffffffff81f7bf9e>] pcibios_remove_bus+0xe/0x10
[   92.713678]  [<ffffffff81535756>] pci_remove_bus+0x46/0x60
[   92.713681]  [<ffffffff81535900>] pci_remove_root_bus+0x50/0xa0
[   92.713683]  [<ffffffff81595596>] acpi_pci_root_remove+0x52/0x5f
[   92.713685]  [<ffffffff81590a0f>] acpi_bus_device_detach+0x3d/0x5e
[   92.713687]  [<ffffffff81590a72>] acpi_bus_trim+0x42/0x7a
[   92.713690]  [<ffffffff8159104e>] acpi_scan_hot_remove+0x194/0x23b
[   92.713692]  [<ffffffff815911f4>] acpi_bus_hot_remove_device+0x2f/0x66
[   92.713695]  [<ffffffff8158b60b>] acpi_os_execute_deferred+0x25/0x32
[   92.713697]  [<ffffffff810b7ffb>] process_one_work+0x28b/0x490
[   92.713699]  [<ffffffff810b7f72>] ? process_one_work+0x202/0x490
[   92.713701]  [<ffffffff810b94ce>] worker_thread+0x21e/0x370
[   92.713704]  [<ffffffff810fdafd>] ? trace_hardirqs_on+0xd/0x10
[   92.713706]  [<ffffffff810b92b0>] ? manage_workers.isra.18+0x330/0x330
[   92.713708]  [<ffffffff810c0aa8>] kthread+0xe8/0xf0
[   92.713710]  [<ffffffff810c09c0>] ? __init_kthread_worker+0x70/0x70
[   92.713712]  [<ffffffff820d991c>] ret_from_fork+0x7c/0xb0
[   92.713713]  [<ffffffff810c09c0>] ? __init_kthread_worker+0x70/0x70
[   92.713728] Code: 00 48 89 e5 5d 48 8b 40 88 48 c1 e8 02 83 e0 01
c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 8b 87 70 05 00 00
55 48 89 e5 <48> 8b 40 98 5d c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44
00 00
[   92.713730] RIP  [<ffffffff810c0e30>] kthread_data+0x10/0x20
[   92.713730]  RSP <ffff88007a72b648>
[   92.713731] CR2: ffffffffffffff98
[   92.713732] ---[ end trace 9e3bba504fb5e5d5 ]---
[   92.713732] Fixing recursive fault but reboot is needed!
#127 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

Quoted 127 lines · Yinghai Lu
Quoted 82 lines · Rafael J. Wysocki

Hi All,

Now the series has been rebased on top of current linux-pm.git/linux-next and tested on two systems with Thunderbolt. Some changes have been made too. ->

Quoted 26 lines · Rafael J. Wysocki

Hi,

I've made some progress with my ACPIPHP rework since I posted the series last time and here goes an update.

First off, the previous series was somewhat racy, which should be fixed now. Apart from this there's quite some new material on top of the patches I posted last time (or rather on top of their new versions) and I integrated the Thunderbolt series from Mika with that. As a result,

https://patchwork.kernel.org/patch/2817341/

is required to be applied.

Still untested, still based on 3.10 with ACPI+PM 3.11 material merged on top, but this time I don't have any plans to add more patches to the series for the time being. Also 3.11-rc1 should be out in a couple of days, so I'll be able to integrate this work with the previous cleanups series from Gerry and myself on top of it.

I did my best not to change too much at a time and some steps add stuff that is removed by the subsequent ones, so hopefully it is bisectable.

If anyone finds something questionable or outright bogus in these patches, please let me know before it's too late. ;-)

Quoted 16 lines

[ 1/30] Make bus registration and unregistration symmetric. [Resend]
[ 2/30] Consolidate acpiphp_enumerate_slots(). [Resend]
[ 3/30] Fix error code path in register_slot(). [Resend]
[ 4/30] Introduce hotplug context objects for ACPI device objects corresponding
to PCI hotplug devices. [Update]
[ 5/30] Unified notify handler for hotplug events. [Update]
[ 6/30] Drop acpiphp_handle_to_bridge() and use context objects instead of it. [Update] [ 7/30] Pass entire hotplug context objects (instead of their fields
individually) to event handling work functions. [Update]
[ 8/30] Merge hotplug event handling functions. [Update]
[ 9/30] Drop func field from struct acpiphp_bridge.
[10/30] Refactor slot allocation code in register_slot().
[11/30] Make acpiphp_enumerate_slots() to register all devices on the given bus
and install the notification handler for all of them.
[12/30] Drop sun field from struct acpiphp_slot.
[13/30] Use common slot count variable in register_slot().

-> The one above has been dropped, because it might cause regressions to appear on some systems, but that's not a big deal.

The numbering of the patches below has changed as a result, so the next one is [13/30] now and so on.

Quoted 11 lines

[14/30] Drop flags field from struct acpiphp_bridge.
[15/30] Embed function structure into struct acpiphp_context. [16/30] Drop handle field from struct acpiphp_func.
[17/30] Drop handle field from struct acpiphp_bridge.
[18/30] Store parent bridge pointer in function objects and bus pointer in slot
objects.
[19/30] Rework ACPI namespace scanning and trimming routines. [20/30] Drop redundant checks from check_hotplug_bridge().
[21/30] Consolidate slot disabling and ejecting
[22/30] Do not queue up event handling work items for non-hotplug events. [23/30] Do not execute _PS0 and _PS3 directly.

This one was fixed after Mika had reported a problem with it.

Quoted 3 lines

[24/30] Do not check SLOT_ENABLED in enable_device(). [Thunderbolt series] [25/30] Allow slots without new devices to be rescanned. [Thunderbolt series] [26/30] Check for new devices on enabled slots. [Thunderbolt series, TBD]

This one was reworked to use acpi_bus_trim() on ACPI device objects corresponding to PCI devices being removed (it also uses _STA to check the status of those devices if available).

Quoted 4 lines

[27/30] Get rid of unused constands in acpiphp.h. [Thunderbolt series] [28/30] Sanitize acpiphp_get_(latch)|(adapter)_status(). [Thunderbolt series] [29/30] Redefine enable_device() and disable_device() (rename and change to void). [30/30] Clean up the usage of bridge_mutex.

Quoted 8 lines

The one above is [29/30] now and we have added one more patch:

[30/30] Drop check_sub_bridges() which isn't necessary any more.

The updated patches follow.

If you don't hate this stuff, I'll put it into linux-next over the weekend for further testing.

pm/linux-next with those patches breaks acpi root bus hotplug. it is kvm guest:

10:~ # echo "PCI0 3" > /sys/kernel/debug/acpi/sci_notify

[   92.549508] ACPI: ACPI device name is <PCI0>, event code is <3>
[   92.552433] ACPI: Notify event is queued
10:~ # [   92.554279] ACPI: \_SB_.PCI0: Device eject notify on
_handle_hotplug_event_root
[   92.677696] ACPI: Device 0000:00:03.0 -x-> \_SB_.PCI0.S03_
[   92.679229] ACPI: Device 0000:00:02.0 -x-> \_SB_.PCI0.VGA_
[   92.680684] ACPI: Device 0000:00:01.3 -x-> \_SB_.PCI0.PX13
[   92.682235] ata1.00: disabled
[   92.689000] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   92.690399] sd 0:0:0:0: [sda]
[   92.691133] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[   92.693151] sd 0:0:0:0: [sda] Stopping disk
[   92.694682] sd 0:0:0:0: [sda] START_STOP FAILED
[   92.696749] sd 0:0:0:0: [sda]
[   92.698157] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[   92.702852] ata2.00: disabled
[   92.711550] ACPI: Device 0000:00:01.0 -x-> \_SB_.PCI0.ISA_
[   92.713208] ACPI: Device pci0000:00 -x-> \_SB_.PCI0
[   92.713226]   acpi_pci_iommu_remove is called for \_SB_.PCI0 ffff88007ab3f1e0
[   92.713274]   acpi_pci_ioapic_remove is called for \_SB_.PCI0
ffff88007ab3f1e0
[   92.713345] pci 0000:00:00.0: freeing pci_dev info
[   92.713363] pci 0000:00:01.0: freeing pci_dev info
[   92.713366] pci 0000:00:01.1: freeing pci_dev info
[   92.713376] pci 0000:00:01.3: freeing pci_dev info
[   92.713380] pci 0000:00:02.0: freeing pci_dev info
[   92.713384] pci 0000:00:03.0: freeing pci_dev info
[   92.713396] pci_bus 0000:00: busn_res: [bus 00-ff] is released
[   92.713441] BUG: unable to handle kernel NULL pointer dereference
at           (null)
[   92.713446] IP: [<ffffffff81557910>]
Quoted 1 line

acpiphp_unregister_hotplug_slot+0x20/0x60

Ugh, stupid bug, sorry about it. We try to unregister something that may have not been registered.

Can you please check if the appended patch helps (on top of linux-pm.git/linux-next)?

Rafael

---
 drivers/pci/hotplug/acpiphp_glue.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/hotplug/acpiphp_glue.c +3 -1
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -340,6 +340,7 @@ static acpi_status register_slot(acpi_ha
 
 		retval = acpiphp_register_hotplug_slot(slot, sun);
 		if (retval) {
+			slot->slot = NULL;
 			bridge->nr_slots--;
 			if (retval == -EBUSY)
 				warn("Slot %llu already registered by another "
@@ -429,7 +430,8 @@ static void cleanup_bridge(struct acpiph
 					err("failed to remove notify handler\n");
 			}
 		}
-		acpiphp_unregister_hotplug_slot(slot);
+		if (slot->slot)
+			acpiphp_unregister_hotplug_slot(slot);
 	}
 
 	mutex_lock(&bridge_mutex);
#128 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

Quoted 28 lines · Rafael J. Wysocki

Ugh, stupid bug, sorry about it. We try to unregister something that may have not been registered.

Can you please check if the appended patch helps (on top of linux-pm.git/linux-next)?

Rafael

---
 drivers/pci/hotplug/acpiphp_glue.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================

drivers/pci/hotplug/acpiphp_glue.c +1 -0
@@ -340,6 +340,7 @@ static acpi_status register_slot(acpi_ha
 
                retval = acpiphp_register_hotplug_slot(slot, sun);
                if (retval) {
+                       slot->slot = NULL;
                        bridge->nr_slots--;
                        if (retval == -EBUSY)
                                warn("Slot %llu already registered by another "

drivers/pci/hotplug/acpiphp_glue.c static void cleanup_bridge(struct acpiph · line 437

Quoted 9 lines
drivers/pci/hotplug/acpiphp_glue.c +2 -1
@@ -429,7 +430,8 @@ static void cleanup_bridge(struct acpiph
                                        err("failed to remove notify handler\n");
                        }
                }
-               acpiphp_unregister_hotplug_slot(slot);
+               if (slot->slot)
+                       acpiphp_unregister_hotplug_slot(slot);
        }
 
        mutex_lock(&bridge_mutex);

yes, that fixes the problem. Thanks

10:~ # echo "PCI0 3" > /sys/kernel/debug/acpi/sci_notify

[  102.231645] ACPI: ACPI device name is <PCI0>, event code is <3>
[  102.233189] ACPI: Notify event is queued
[  102.234326] ACPI: \_SB_.PCI0: Device eject notify on
_handle_hotplug_event_root
10:~ # [  102.357749] ACPI: Device 0000:00:03.0 -x-> \_SB_.PCI0.S03_
[  102.359902] ACPI: Device 0000:00:02.0 -x-> \_SB_.PCI0.VGA_
[  102.362188] ACPI: Device 0000:00:01.3 -x-> \_SB_.PCI0.PX13
[  102.364752] ata1.00: disabled
[  102.372154] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  102.374523] sd 0:0:0:0: [sda]
[  102.375759] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[  102.378173] sd 0:0:0:0: [sda] Stopping disk
[  102.380248] sd 0:0:0:0: [sda] START_STOP FAILED
[  102.381983] sd 0:0:0:0: [sda]
[  102.383167] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[  102.387588] ata2.00: disabled
[  102.395254] ACPI: Device 0000:00:01.0 -x-> \_SB_.PCI0.ISA_
[  102.396943] ACPI: Device pci0000:00 -x-> \_SB_.PCI0
[  102.398162]   acpi_pci_iommu_remove is called for \_SB_.PCI0 ffff88007ab3f1e0
[  102.400253]   acpi_pci_ioapic_remove is called for \_SB_.PCI0
ffff88007ab3f1e0
[  102.402176] pci 0000:00:00.0: freeing pci_dev info
[  102.404247] pci 0000:00:01.0: freeing pci_dev info
[  102.406611] pci 0000:00:01.1: freeing pci_dev info
[  102.408401] pci 0000:00:01.3: freeing pci_dev info
[  102.410276] pci 0000:00:02.0: freeing pci_dev info
[  102.411378] pci 0000:00:03.0: freeing pci_dev info
[  102.412485] pci_bus 0000:00: busn_res: [bus 00-ff] is released
[  102.413945] acpiphp: Slot [3] unregistered
[  102.415189] pci_hotplug: pci_hp_deregister: Removed slot 3 from the list
[  102.418224] acpiphp: release_slot - physical_slot = 3
[  102.420439] pci_bus 0000:00: dev 03, dec refcount to 1
[  102.422689] acpiphp: Slot [4] unregistered
[  102.424592] pci_hotplug: pci_hp_deregister: Removed slot 4 from the list
[  102.427484] acpiphp: release_slot - physical_slot = 4
[  102.429679] pci_bus 0000:00: dev 04, dec refcount to 1
[  102.431492] acpiphp: Slot [5] unregistered
[  102.433169] pci_hotplug: pci_hp_deregister: Removed slot 5 from the list
[  102.435486] acpiphp: release_slot - physical_slot = 5
[  102.436963] pci_bus 0000:00: dev 05, dec refcount to 1
[  102.438140] acpiphp: Slot [6] unregistered
[  102.439116] pci_hotplug: pci_hp_deregister: Removed slot 6 from the list
[  102.440922] acpiphp: release_slot - physical_slot = 6
[  102.442079] pci_bus 0000:00: dev 06, dec refcount to 1
[  102.443280] acpiphp: Slot [7] unregistered
[  102.444286] pci_hotplug: pci_hp_deregister: Removed slot 7 from the list
[  102.445840] acpiphp: release_slot - physical_slot = 7
[  102.447024] pci_bus 0000:00: dev 07, dec refcount to 1
[  102.448272] acpiphp: Slot [8] unregistered
[  102.449236] pci_hotplug: pci_hp_deregister: Removed slot 8 from the list
[  102.450770] acpiphp: release_slot - physical_slot = 8
[  102.451632] pci_bus 0000:00: dev 08, dec refcount to 1
[  102.452870] acpiphp: Slot [9] unregistered
[  102.453848] pci_hotplug: pci_hp_deregister: Removed slot 9 from the list
[  102.455400] acpiphp: release_slot - physical_slot = 9
[  102.456594] pci_bus 0000:00: dev 09, dec refcount to 1
[  102.457557] acpiphp: Slot [10] unregistered
[  102.458542] pci_hotplug: pci_hp_deregister: Removed slot 10 from the list
[  102.460124] acpiphp: release_slot - physical_slot = 10
[  102.461295] pci_bus 0000:00: dev 0a, dec refcount to 1
[  102.462482] acpiphp: Slot [11] unregistered
[  102.463464] pci_hotplug: pci_hp_deregister: Removed slot 11 from the list
[  102.465046] acpiphp: release_slot - physical_slot = 11
[  102.467024] pci_bus 0000:00: dev 0b, dec refcount to 1
[  102.468199] acpiphp: Slot [12] unregistered
[  102.469210] pci_hotplug: pci_hp_deregister: Removed slot 12 from the list
[  102.470798] acpiphp: release_slot - physical_slot = 12
[  102.471992] pci_bus 0000:00: dev 0c, dec refcount to 1
[  102.473239] acpiphp: Slot [13] unregistered
[  102.473959] pci_hotplug: pci_hp_deregister: Removed slot 13 from the list
[  102.475545] acpiphp: release_slot - physical_slot = 13
[  102.476516] pci_bus 0000:00: dev 0d, dec refcount to 1
[  102.477740] acpiphp: Slot [14] unregistered
[  102.478733] pci_hotplug: pci_hp_deregister: Removed slot 14 from the list
[  102.480319] acpiphp: release_slot - physical_slot = 14
[  102.481296] pci_bus 0000:00: dev 0e, dec refcount to 1
[  102.481947] acpiphp: Slot [15] unregistered
[  102.482888] pci_hotplug: pci_hp_deregister: Removed slot 15 from the list
[  102.484555] acpiphp: release_slot - physical_slot = 15
[  102.485806] pci_bus 0000:00: dev 0f, dec refcount to 1
[  102.486808] acpiphp: Slot [16] unregistered
[  102.487652] pci_hotplug: pci_hp_deregister: Removed slot 16 from the list
[  102.488986] acpiphp: release_slot - physical_slot = 16
[  102.489996] pci_bus 0000:00: dev 10, dec refcount to 1
[  102.491100] acpiphp: Slot [17] unregistered
[  102.492054] pci_hotplug: pci_hp_deregister: Removed slot 17 from the list
[  102.493572] acpiphp: release_slot - physical_slot = 17
[  102.494444] pci_bus 0000:00: dev 11, dec refcount to 1
[  102.495266] acpiphp: Slot [18] unregistered
[  102.495966] pci_hotplug: pci_hp_deregister: Removed slot 18 from the list
[  102.497083] acpiphp: release_slot - physical_slot = 18
[  102.497921] pci_bus 0000:00: dev 12, dec refcount to 1
[  102.498770] acpiphp: Slot [19] unregistered
[  102.499474] pci_hotplug: pci_hp_deregister: Removed slot 19 from the list
[  102.500764] acpiphp: release_slot - physical_slot = 19
[  102.501873] pci_bus 0000:00: dev 13, dec refcount to 1
[  102.502966] acpiphp: Slot [20] unregistered
[  102.503824] pci_hotplug: pci_hp_deregister: Removed slot 20 from the list
[  102.504770] acpiphp: release_slot - physical_slot = 20
[  102.505608] pci_bus 0000:00: dev 14, dec refcount to 1
[  102.506456] acpiphp: Slot [21] unregistered
[  102.507146] pci_hotplug: pci_hp_deregister: Removed slot 21 from the list
[  102.508269] acpiphp: release_slot - physical_slot = 21
[  102.508981] pci_bus 0000:00: dev 15, dec refcount to 1
[  102.509815] acpiphp: Slot [22] unregistered
[  102.510668] pci_hotplug: pci_hp_deregister: Removed slot 22 from the list
[  102.511955] acpiphp: release_slot - physical_slot = 22
[  102.512980] pci_bus 0000:00: dev 16, dec refcount to 1
[  102.514040] acpiphp: Slot [23] unregistered
[  102.514621] pci_hotplug: pci_hp_deregister: Removed slot 23 from the list
[  102.515446] acpiphp: release_slot - physical_slot = 23
[  102.516101] pci_bus 0000:00: dev 17, dec refcount to 1
[  102.516752] acpiphp: Slot [24] unregistered
[  102.517370] pci_hotplug: pci_hp_deregister: Removed slot 24 from the list
[  102.518210] acpiphp: release_slot - physical_slot = 24
[  102.518841] pci_bus 0000:00: dev 18, dec refcount to 1
[  102.519500] acpiphp: Slot [25] unregistered
[  102.520146] pci_hotplug: pci_hp_deregister: Removed slot 25 from the list
[  102.520995] acpiphp: release_slot - physical_slot = 25
[  102.522445] pci_bus 0000:00: dev 19, dec refcount to 1
[  102.523463] acpiphp: Slot [26] unregistered
[  102.524335] pci_hotplug: pci_hp_deregister: Removed slot 26 from the list
[  102.525597] acpiphp: release_slot - physical_slot = 26
[  102.526599] pci_bus 0000:00: dev 1a, dec refcount to 1
[  102.527636] acpiphp: Slot [27] unregistered
[  102.528483] pci_hotplug: pci_hp_deregister: Removed slot 27 from the list
[  102.529812] acpiphp: release_slot - physical_slot = 27
[  102.530872] pci_bus 0000:00: dev 1b, dec refcount to 1
[  102.531988] acpiphp: Slot [28] unregistered
[  102.532775] pci_hotplug: pci_hp_deregister: Removed slot 28 from the list
[  102.534200] acpiphp: release_slot - physical_slot = 28
[  102.535038] pci_bus 0000:00: dev 1c, dec refcount to 1
[  102.535727] acpiphp: Slot [29] unregistered
[  102.536328] pci_hotplug: pci_hp_deregister: Removed slot 29 from the list
[  102.537213] acpiphp: release_slot - physical_slot = 29
[  102.537886] pci_bus 0000:00: dev 1d, dec refcount to 1
[  102.539560] acpiphp: Slot [30] unregistered
[  102.541427] pci_hotplug: pci_hp_deregister: Removed slot 30 from the list
[  102.544245] acpiphp: release_slot - physical_slot = 30
[  102.545431] pci_bus 0000:00: dev 1e, dec refcount to 1
[  102.546647] acpiphp: Slot [31] unregistered
[  102.547643] pci_hotplug: pci_hp_deregister: Removed slot 31 from the list
[  102.549290] acpiphp: release_slot - physical_slot = 31
[  102.550510] pci_bus 0000:00: dev 1f, dec refcount to 1
[  102.551810] pci_bus 0000:00: dev 1f, dec refcount to 0
[  102.552861] pci_bus 0000:00: dev 1f, released physical slot 31
[  102.554226] pci_bus 0000:00: dev 1e, dec refcount to 0
[  102.555448] pci_bus 0000:00: dev 1e, released physical slot 30
[  102.556836] pci_bus 0000:00: dev 1d, dec refcount to 0
[  102.558061] pci_bus 0000:00: dev 1d, released physical slot 29
[  102.559420] pci_bus 0000:00: dev 1c, dec refcount to 0
[  102.560662] pci_bus 0000:00: dev 1c, released physical slot 28
[  102.562016] pci_bus 0000:00: dev 1b, dec refcount to 0
[  102.563218] pci_bus 0000:00: dev 1b, released physical slot 27
[  102.564556] pci_bus 0000:00: dev 1a, dec refcount to 0
[  102.565767] pci_bus 0000:00: dev 1a, released physical slot 26
[  102.567132] pci_bus 0000:00: dev 19, dec refcount to 0
[  102.568366] pci_bus 0000:00: dev 19, released physical slot 25
[  102.569631] pci_bus 0000:00: dev 18, dec refcount to 0
[  102.570826] pci_bus 0000:00: dev 18, released physical slot 24
[  102.572194] pci_bus 0000:00: dev 17, dec refcount to 0
[  102.573407] pci_bus 0000:00: dev 17, released physical slot 23
[  102.574741] pci_bus 0000:00: dev 16, dec refcount to 0
[  102.575960] pci_bus 0000:00: dev 16, released physical slot 22
[  102.577334] pci_bus 0000:00: dev 15, dec refcount to 0
[  102.578548] pci_bus 0000:00: dev 15, released physical slot 21
[  102.579894] pci_bus 0000:00: dev 14, dec refcount to 0
[  102.581141] pci_bus 0000:00: dev 14, released physical slot 20
[  102.582506] pci_bus 0000:00: dev 13, dec refcount to 0
[  102.583722] pci_bus 0000:00: dev 13, released physical slot 19
[  102.585111] pci_bus 0000:00: dev 12, dec refcount to 0
[  102.586328] pci_bus 0000:00: dev 12, released physical slot 18
[  102.587688] pci_bus 0000:00: dev 11, dec refcount to 0
[  102.588915] pci_bus 0000:00: dev 11, released physical slot 17
[  102.590281] pci_bus 0000:00: dev 10, dec refcount to 0
[  102.591485] pci_bus 0000:00: dev 10, released physical slot 16
[  102.592854] pci_bus 0000:00: dev 0f, dec refcount to 0
[  102.594066] pci_bus 0000:00: dev 0f, released physical slot 15
[  102.595417] pci_bus 0000:00: dev 0e, dec refcount to 0
[  102.596635] pci_bus 0000:00: dev 0e, released physical slot 14
[  102.598010] pci_bus 0000:00: dev 0d, dec refcount to 0
[  102.599210] pci_bus 0000:00: dev 0d, released physical slot 13
[  102.600595] pci_bus 0000:00: dev 0c, dec refcount to 0
[  102.601794] pci_bus 0000:00: dev 0c, released physical slot 12
[  102.603143] pci_bus 0000:00: dev 0b, dec refcount to 0
[  102.604362] pci_bus 0000:00: dev 0b, released physical slot 11
[  102.605700] pci_bus 0000:00: dev 0a, dec refcount to 0
[  102.606904] pci_bus 0000:00: dev 0a, released physical slot 10
[  102.608313] pci_bus 0000:00: dev 09, dec refcount to 0
[  102.609539] pci_bus 0000:00: dev 09, released physical slot 9
[  102.610879] pci_bus 0000:00: dev 08, dec refcount to 0
[  102.612117] pci_bus 0000:00: dev 08, released physical slot 8
[  102.613452] pci_bus 0000:00: dev 07, dec refcount to 0
[  102.614664] pci_bus 0000:00: dev 07, released physical slot 7
[  102.615992] pci_bus 0000:00: dev 06, dec refcount to 0
[  102.617221] pci_bus 0000:00: dev 06, released physical slot 6
[  102.618554] pci_bus 0000:00: dev 05, dec refcount to 0
[  102.619758] pci_bus 0000:00: dev 05, released physical slot 5
[  102.621116] pci_bus 0000:00: dev 04, dec refcount to 0
[  102.622320] pci_bus 0000:00: dev 04, released physical slot 4
[  102.623656] pci_bus 0000:00: dev 03, dec refcount to 0
[  102.624887] pci_bus 0000:00: dev 03, released physical slot 3
[  102.626239] pci_bus 0000:00: dev 02, dec refcount to 0
[  102.627445] pci_bus 0000:00: dev 02, released physical slot 2
[  102.628805] pci_bus 0000:00: dev 01, dec refcount to 0
[  102.629589] pci_bus 0000:00: dev 01, released physical slot 1
[  102.630631] pci_bus 0000:00: freeing pci_bus info
[  102.631369] pci_host_bridge pci0000:00: freeing pci_host_bridge info
[  102.633091] ACPI: Device does not support D3cold
[  102.633915] ACPI: Device does not support D3cold
[  102.635221] ACPI: Device does not support D3cold
[  102.636103] ACPI: Device does not support D3cold
[  102.636902] ACPI: Device does not support D3cold
[  102.637685] ACPI: Device does not support D3cold
[  102.638467] ACPI: Device does not support D3cold
[  102.639631] ACPI: Device does not support D3cold
[  102.640472] ACPI: Device does not support D3cold
[  102.641310] ACPI: Device does not support D3cold
[  102.642105] ACPI: Device does not support D3cold
[  102.642928] ACPI: Device does not support D3cold
[  102.643725] ACPI: Device does not support D3cold
[  102.644544] ACPI: Device does not support D3cold
[  102.645344] ACPI: Device does not support D3cold
[  102.646126] ACPI: Device does not support D3cold
[  102.646902] ACPI: Device does not support D3cold
[  102.647677] ACPI: Device does not support D3cold
[  102.648485] ACPI: Device does not support D3cold
[  102.649269] ACPI: Device does not support D3cold
[  102.650065] ACPI: Device does not support D3cold
[  102.650822] ACPI: Device does not support D3cold
[  102.652483] ACPI: Device does not support D3cold
[  102.654157] ACPI: Device does not support D3cold
[  102.655803] ACPI: Device does not support D3cold
[  102.657419] ACPI: Device does not support D3cold
[  102.658528] ACPI: Device does not support D3cold
[  102.659255] ACPI: Device does not support D3cold
[  102.659973] ACPI: Device does not support D3cold
[  102.661807] ACPI: Device does not support D3cold
[  102.661925] ACPI: Device does not support D3cold
[  102.662047] ACPI: Device does not support D3cold
[  102.662148] ACPI: Device does not support D3cold
[  102.662258] ACPI: Device does not support D3cold
[  102.662374] ACPI: Device does not support D3cold
[  102.662486] ACPI: Device does not support D3cold
[  102.662597] ACPI: Device does not support D3cold
[  102.662711] ACPI: Device does not support D3cold
[  102.662814] ACPI: Device does not support D3cold
[  102.662918] ACPI: Device does not support D3cold
[  102.663019] ACPI: Device does not support D3cold
[  102.663039] ACPI: \_SB_.PCI0: No _EJ0 support for device
#129 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

Quoted 36 lines · Yinghai Lu
Quoted 35 lines · Rafael J. Wysocki

Ugh, stupid bug, sorry about it. We try to unregister something that may have not been registered.

Can you please check if the appended patch helps (on top of linux-pm.git/linux-next)?

Rafael

---
 drivers/pci/hotplug/acpiphp_glue.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================

drivers/pci/hotplug/acpiphp_glue.c +3 -1
@@ -340,6 +340,7 @@ static acpi_status register_slot(acpi_ha
 
                retval = acpiphp_register_hotplug_slot(slot, sun);
                if (retval) {
+                       slot->slot = NULL;
                        bridge->nr_slots--;
                        if (retval == -EBUSY)
                                warn("Slot %llu already registered by another "
@@ -429,7 +430,8 @@ static void cleanup_bridge(struct acpiph
                                        err("failed to remove notify handler\n");
                        }
                }
-               acpiphp_unregister_hotplug_slot(slot);
+               if (slot->slot)
+                       acpiphp_unregister_hotplug_slot(slot);
        }
 
Quoted 4 lines

drivers/pci/hotplug/acpiphp_glue.c static void cleanup_bridge(struct acpiph · line 437

Quoted 2 lines
drivers/pci/hotplug/acpiphp_glue.c +0 -0
        mutex_lock(&bridge_mutex);

yes, that fixes the problem. Thanks

Great, thanks for testing!

I'm adding this to the series (after commit 7342798):

---
From: Rafael J. Wysocki <[email protected]>
Subject: ACPI / hotplug / PCI: Fix NULL pointer dereference in cleanup_bridge()

After commit bbd34fc (ACPI / hotplug / PCI: Register all devices under the given bridge) register_slot() is called for all PCI devices under a given bridge that have corresponding objects in the ACPI namespace, but it calls acpiphp_register_hotplug_slot() only for devices satisfying specific criteria. Still, cleanup_bridge() calls acpiphp_unregister_hotplug_slot() for all objects created by register_slot(), although it should only call it for the ones that acpiphp_register_hotplug_slot() has been called for (successfully). This causes a NULL pointer to be dereferenced by the acpiphp_unregister_hotplug_slot() executed by cleanup_bridge() if the object it is called for has not been passed to acpiphp_register_hotplug_slot().

To fix this problem, check if the 'slot' field of the object passed to acpiphp_unregister_hotplug_slot() in cleanup_bridge() is not NULL, which only is the case if acpiphp_register_hotplug_slot() has been executed for that object. In addition to that, make register_slot() reset the 'slot' field to NULL if acpiphp_register_hotplug_slot() has failed for the given object to prevent stale pointers from being used by acpiphp_unregister_hotplug_slot().

---
 drivers/pci/hotplug/acpiphp_glue.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/hotplug/acpiphp_glue.c +3 -1
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -340,6 +340,7 @@ static acpi_status register_slot(acpi_ha
 
 		retval = acpiphp_register_hotplug_slot(slot, sun);
 		if (retval) {
+			slot->slot = NULL;
 			bridge->nr_slots--;
 			if (retval == -EBUSY)
 				warn("Slot %llu already registered by another "
@@ -429,7 +430,8 @@ static void cleanup_bridge(struct acpiph
 					err("failed to remove notify handler\n");
 			}
 		}
-		acpiphp_unregister_hotplug_slot(slot);
+		if (slot->slot)
+			acpiphp_unregister_hotplug_slot(slot);
 	}
 
 	mutex_lock(&bridge_mutex);
#130 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

In reply to Yinghai Lu
Quoted 1 line · Yinghai Lu

On Tue, Jul 23, 2013 at 2:39 PM, Rafael J. Wysocki <[email protected]> wrote:

[...]

Quoted 1 line
[  102.631369] pci_host_bridge pci0000:00: freeing pci_host_bridge info

By the way this looks fishy:

Quoted 33 lines
[  102.633091] ACPI: Device does not support D3cold
[  102.633915] ACPI: Device does not support D3cold
[  102.635221] ACPI: Device does not support D3cold
[  102.636103] ACPI: Device does not support D3cold
[  102.636902] ACPI: Device does not support D3cold
[  102.637685] ACPI: Device does not support D3cold
[  102.638467] ACPI: Device does not support D3cold
[  102.639631] ACPI: Device does not support D3cold
[  102.640472] ACPI: Device does not support D3cold
[  102.641310] ACPI: Device does not support D3cold
[  102.642105] ACPI: Device does not support D3cold
[  102.642928] ACPI: Device does not support D3cold
[  102.643725] ACPI: Device does not support D3cold
[  102.644544] ACPI: Device does not support D3cold
[  102.645344] ACPI: Device does not support D3cold
[  102.646126] ACPI: Device does not support D3cold
[  102.646902] ACPI: Device does not support D3cold
[  102.647677] ACPI: Device does not support D3cold
[  102.648485] ACPI: Device does not support D3cold
[  102.649269] ACPI: Device does not support D3cold
[  102.650065] ACPI: Device does not support D3cold
[  102.650822] ACPI: Device does not support D3cold
[  102.652483] ACPI: Device does not support D3cold
[  102.654157] ACPI: Device does not support D3cold
[  102.655803] ACPI: Device does not support D3cold
[  102.657419] ACPI: Device does not support D3cold
[  102.658528] ACPI: Device does not support D3cold
[  102.659255] ACPI: Device does not support D3cold
[  102.659973] ACPI: Device does not support D3cold
[  102.661807] ACPI: Device does not support D3cold
[  102.661925] ACPI: Device does not support D3cold
[  102.662047] ACPI: Device does not support D3cold
[  102.662148] ACPI: Device does not support D3cold
Quoted 8 lines
[  102.662258] ACPI: Device does not support D3cold
[  102.662374] ACPI: Device does not support D3cold
[  102.662486] ACPI: Device does not support D3cold
[  102.662597] ACPI: Device does not support D3cold
[  102.662711] ACPI: Device does not support D3cold
[  102.662814] ACPI: Device does not support D3cold
[  102.662918] ACPI: Device does not support D3cold
[  102.663019] ACPI: Device does not support D3cold

Can you please check if it goes away with the patch below applied?

Quoted 1 line
[  102.663039] ACPI: \_SB_.PCI0: No _EJ0 support for device
---
 drivers/acpi/device_pm.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/device_pm.c +2 -1
Index: linux-pm/drivers/acpi/device_pm.c
===================================================================
@@ -159,7 +159,8 @@ int acpi_device_set_power(struct acpi_de
 	int result = 0;
 	bool cut_power = false;
 
-	if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
+	if (!device || !device->flags.power_manageable
+	    || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
 		return -EINVAL;
 
 	/* Make sure this is a valid target state */
maintainer
#131 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

Quoted 10 lines · Rafael J. Wysocki
Quoted 1 line · Yinghai Lu

On Tue, Jul 23, 2013 at 2:39 PM, Rafael J. Wysocki <[email protected]> wrote:

[...]

Quoted 1 line
[  102.631369] pci_host_bridge pci0000:00: freeing pci_host_bridge info

By the way this looks fishy:

Quoted 1 line
[  102.633091] ACPI: Device does not support D3cold

This and other printks in that function don't give any clue what device is involved, even though we have an acpi_device pointer. It'd be nice to fix that, too.

#132 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

Quoted 8 lines · Bjorn Helgaas
Quoted 7 lines · Rafael J. Wysocki
Quoted 1 line · Yinghai Lu

On Tue, Jul 23, 2013 at 2:39 PM, Rafael J. Wysocki <[email protected]> wrote:

[...]

Quoted 1 line
[  102.631369] pci_host_bridge pci0000:00: freeing pci_host_bridge info
Quoted 7 lines
Quoted 3 lines

By the way this looks fishy:

Quoted 1 line
[  102.633091] ACPI: Device does not support D3cold

This and other printks in that function don't give any clue what device is involved, even though we have an acpi_device pointer. It'd be nice to fix that, too.

As it turns out, I have that patch ready as well. Appended for completeness.

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>
Subject: ACPI / PM: Make messages in acpi_device_set_power() print device name

Modify acpi_device_set_power() so that diagnostic messages printed by it to the kernel log always contain the name of the device to make it possible to identify the device if need be. Also replace printk(KERN_WARNING ) with dev_warn() everywhere in that function.

---
 drivers/acpi/device_pm.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/acpi/device_pm.c +10 -12
Index: linux-pm/drivers/acpi/device_pm.c
===================================================================
@@ -166,20 +166,20 @@ int acpi_device_set_power(struct acpi_de
 	/* Make sure this is a valid target state */
 
 	if (state == device->power.state) {
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at %s\n",
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] already in %s\n",
+				  device->pnp.bus_id,
 				  acpi_power_state_string(state)));
 		return 0;
 	}
 
 	if (!device->power.states[state].flags.valid) {
-		printk(KERN_WARNING PREFIX "Device does not support %s\n",
-		       acpi_power_state_string(state));
+		dev_warn(&device->dev, "Power state %s not supported\n",
+			 acpi_power_state_string(state));
 		return -ENODEV;
 	}
 	if (device->parent && (state < device->parent->power.state)) {
-		printk(KERN_WARNING PREFIX
-			      "Cannot set device to a higher-powered"
-			      " state than parent\n");
+		dev_warn(&device->dev, "Cannot transition to a higher-powered "
+			 "state than parent\n");
 		return -ENODEV;
 	}
 
@@ -192,8 +192,8 @@ int acpi_device_set_power(struct acpi_de
 
 	if (state < device->power.state && state != ACPI_STATE_D0
 	    && device->power.state >= ACPI_STATE_D3_HOT) {
-		printk(KERN_WARNING PREFIX
-			"Cannot transition to non-D0 state from D3\n");
+		dev_warn(&device->dev,
+			 "Cannot transition to non-D0 state from D3\n");
 		return -ENODEV;
 	}
 
@@ -220,10 +220,8 @@ int acpi_device_set_power(struct acpi_de
 
  end:
 	if (result) {
-		printk(KERN_WARNING PREFIX
-			      "Device [%s] failed to transition to %s\n",
-			      device->pnp.bus_id,
-			      acpi_power_state_string(state));
+		dev_warn(&device->dev, "Failed to change power state to %s\n",
+			 acpi_power_state_string(state));
 	} else {
 		device->power.state = state;
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
#133 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

In reply to Rafael J. Wysocki
Quoted 66 lines · Rafael J. Wysocki
Quoted 1 line · Yinghai Lu

On Tue, Jul 23, 2013 at 2:39 PM, Rafael J. Wysocki <[email protected]> wrote:

[...]

Quoted 1 line
[  102.631369] pci_host_bridge pci0000:00: freeing pci_host_bridge info

By the way this looks fishy:

Quoted 33 lines
[  102.633091] ACPI: Device does not support D3cold
[  102.633915] ACPI: Device does not support D3cold
[  102.635221] ACPI: Device does not support D3cold
[  102.636103] ACPI: Device does not support D3cold
[  102.636902] ACPI: Device does not support D3cold
[  102.637685] ACPI: Device does not support D3cold
[  102.638467] ACPI: Device does not support D3cold
[  102.639631] ACPI: Device does not support D3cold
[  102.640472] ACPI: Device does not support D3cold
[  102.641310] ACPI: Device does not support D3cold
[  102.642105] ACPI: Device does not support D3cold
[  102.642928] ACPI: Device does not support D3cold
[  102.643725] ACPI: Device does not support D3cold
[  102.644544] ACPI: Device does not support D3cold
[  102.645344] ACPI: Device does not support D3cold
[  102.646126] ACPI: Device does not support D3cold
[  102.646902] ACPI: Device does not support D3cold
[  102.647677] ACPI: Device does not support D3cold
[  102.648485] ACPI: Device does not support D3cold
[  102.649269] ACPI: Device does not support D3cold
[  102.650065] ACPI: Device does not support D3cold
[  102.650822] ACPI: Device does not support D3cold
[  102.652483] ACPI: Device does not support D3cold
[  102.654157] ACPI: Device does not support D3cold
[  102.655803] ACPI: Device does not support D3cold
[  102.657419] ACPI: Device does not support D3cold
[  102.658528] ACPI: Device does not support D3cold
[  102.659255] ACPI: Device does not support D3cold
[  102.659973] ACPI: Device does not support D3cold
[  102.661807] ACPI: Device does not support D3cold
[  102.661925] ACPI: Device does not support D3cold
[  102.662047] ACPI: Device does not support D3cold
[  102.662148] ACPI: Device does not support D3cold
Quoted 8 lines
[  102.662258] ACPI: Device does not support D3cold
[  102.662374] ACPI: Device does not support D3cold
[  102.662486] ACPI: Device does not support D3cold
[  102.662597] ACPI: Device does not support D3cold
[  102.662711] ACPI: Device does not support D3cold
[  102.662814] ACPI: Device does not support D3cold
[  102.662918] ACPI: Device does not support D3cold
[  102.663019] ACPI: Device does not support D3cold

Can you please check if it goes away with the patch below applied?

Quoted 1 line
[  102.663039] ACPI: \_SB_.PCI0: No _EJ0 support for device
---
 drivers/acpi/device_pm.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/device_pm.c
===================================================================

drivers/acpi/device_pm.c int acpi_device_set_power(struct acpi_de · line 166

Quoted 9 lines
drivers/acpi/device_pm.c +2 -1
@@ -159,7 +159,8 @@ int acpi_device_set_power(struct acpi_de
        int result = 0;
        bool cut_power = false;
 
-       if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
+       if (!device || !device->flags.power_manageable
+           || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
                return -EINVAL;
 
        /* Make sure this is a valid target state */

yes, with this change, those print out are gone.

Thanks

Yinghai

#134 lore raw

Re: [PATCH 0/30] ACPI / hotplug / PCI: Major rework + Thunderbolt workarounds

Quoted 74 lines · Yinghai Lu
Quoted 73 lines · Rafael J. Wysocki
Quoted 1 line · Yinghai Lu

On Tue, Jul 23, 2013 at 2:39 PM, Rafael J. Wysocki <[email protected]> wrote:

[...]

Quoted 1 line
[  102.631369] pci_host_bridge pci0000:00: freeing pci_host_bridge info

By the way this looks fishy:

Quoted 33 lines
[  102.633091] ACPI: Device does not support D3cold
[  102.633915] ACPI: Device does not support D3cold
[  102.635221] ACPI: Device does not support D3cold
[  102.636103] ACPI: Device does not support D3cold
[  102.636902] ACPI: Device does not support D3cold
[  102.637685] ACPI: Device does not support D3cold
[  102.638467] ACPI: Device does not support D3cold
[  102.639631] ACPI: Device does not support D3cold
[  102.640472] ACPI: Device does not support D3cold
[  102.641310] ACPI: Device does not support D3cold
[  102.642105] ACPI: Device does not support D3cold
[  102.642928] ACPI: Device does not support D3cold
[  102.643725] ACPI: Device does not support D3cold
[  102.644544] ACPI: Device does not support D3cold
[  102.645344] ACPI: Device does not support D3cold
[  102.646126] ACPI: Device does not support D3cold
[  102.646902] ACPI: Device does not support D3cold
[  102.647677] ACPI: Device does not support D3cold
[  102.648485] ACPI: Device does not support D3cold
[  102.649269] ACPI: Device does not support D3cold
[  102.650065] ACPI: Device does not support D3cold
[  102.650822] ACPI: Device does not support D3cold
[  102.652483] ACPI: Device does not support D3cold
[  102.654157] ACPI: Device does not support D3cold
[  102.655803] ACPI: Device does not support D3cold
[  102.657419] ACPI: Device does not support D3cold
[  102.658528] ACPI: Device does not support D3cold
[  102.659255] ACPI: Device does not support D3cold
[  102.659973] ACPI: Device does not support D3cold
[  102.661807] ACPI: Device does not support D3cold
[  102.661925] ACPI: Device does not support D3cold
[  102.662047] ACPI: Device does not support D3cold
[  102.662148] ACPI: Device does not support D3cold
Quoted 8 lines
[  102.662258] ACPI: Device does not support D3cold
[  102.662374] ACPI: Device does not support D3cold
[  102.662486] ACPI: Device does not support D3cold
[  102.662597] ACPI: Device does not support D3cold
[  102.662711] ACPI: Device does not support D3cold
[  102.662814] ACPI: Device does not support D3cold
[  102.662918] ACPI: Device does not support D3cold
[  102.663019] ACPI: Device does not support D3cold

Can you please check if it goes away with the patch below applied?

Quoted 1 line
[  102.663039] ACPI: \_SB_.PCI0: No _EJ0 support for device
---
 drivers/acpi/device_pm.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/device_pm.c
===================================================================

drivers/acpi/device_pm.c +2 -1
@@ -159,7 +159,8 @@ int acpi_device_set_power(struct acpi_de
        int result = 0;
        bool cut_power = false;
 
-       if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
+       if (!device || !device->flags.power_manageable
+           || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
                return -EINVAL;
 
Quoted 4 lines

drivers/acpi/device_pm.c int acpi_device_set_power(struct acpi_de · line 166

Quoted 2 lines
drivers/acpi/device_pm.c +0 -0
        /* Make sure this is a valid target state */

yes, with this change, those print out are gone.

Cool, thanks!

Rafael