Skip to content

Rework pciehp event handling & add runtime PM

Lukas Wunner linux-pci linux-s390 lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest32 patches 33 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/32PCI: hotplug: Don't leak pci_slot on registration failuredrivers/pci/hotplug/pci_hotplug_core.c+9 -00 replies
2/32PCI: pciehp: Fix UAF on unplugdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_hpc.c+9 -30 replies
3/32PCI: pciehp: Fix deadlock on unplugdrivers/pci/hotplug/pciehp_pci.c+26 -123 replies
4/32PCI: pciehp: Fix unprotected list iteration in IRQ handlerdrivers/pci/hotplug/pciehp_hpc.c+3 -100 replies
5/32PCI: pciehp: Drop unnecessary NULL pointer checkdrivers/pci/hotplug/pciehp_ctrl.c+0 -30 replies
6/32PCI: pciehp: Declare pciehp_unconfigure_device() voiddrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_ctrl.c drivers/pci/hotplug/pciehp_pci.c+7 -120 replies
7/32PCI: pciehp: Document struct slot and struct controllerdrivers/pci/hotplug/pciehp.h+44 -40 replies
8/32genirq: Synchronize only with single thread on free_irq()kernel/irq/manage.c+14 -75 replies
9/32PCI: pciehp: Convert to threaded IRQdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_hpc.c+41 -322 replies
10/32PCI: pciehp: Convert to threaded pollingdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_hpc.c+34 -370 replies
11/32PCI: pciehp: Stop blinking on slot enable failuredrivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_ctrl.c+42 -380 replies
12/32PCI: pciehp: Handle events synchronouslydrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_ctrl.c drivers/pci/hotplug/pciehp_hpc.c+67 -1580 replies
13/32PCI: pciehp: Drop slot workqueuedrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_ctrl.c +1 more+2 -170 replies
14/32PCI: hotplug: Demidlayer registration with the coredrivers/pci/hotplug/acpiphp_core.c drivers/pci/hotplug/cpci_hotplug_core.c drivers/pci/hotplug/cpqphp_core.c +14 more+171 -1913 replies
15/32PCI: pciehp: Publish to user space last on probedrivers/pci/hotplug/pciehp_core.c+15 -50 replies
16/32PCI: pciehp: Track enable/disable statusdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_ctrl.c drivers/pci/hotplug/pciehp_hpc.c+35 -130 replies
17/32PCI: pciehp: Enable/disable exclusively from IRQ threaddrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_ctrl.c +1 more+93 -601 reply
18/32PCI: pciehp: Drop enable/disable lockdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_ctrl.c drivers/pci/hotplug/pciehp_hpc.c+0 -150 replies
19/32PCI: pciehp: Declare pciehp_enable/disable_slot() staticdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_ctrl.c+5 -40 replies
20/32PCI: pciehp: Tolerate initially unstable linkdrivers/pci/hotplug/pciehp_hpc.c+5 -00 replies
21/32PCI: pciehp: Become resilient to missed eventsdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_ctrl.c drivers/pci/hotplug/pciehp_hpc.c+40 -530 replies
22/32PCI: pciehp: Always enable occupied slot on probedrivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_hpc.c+6 -150 replies
23/32PCI: pciehp: Avoid slot access during resetdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_hpc.c+14 -73 replies
24/32PCI: portdrv: Deduplicate PM callback iteratordrivers/pci/pcie/portdrv_core.c+12 -180 replies
25/32PCI: pciehp: Clear spurious events earlier on resumedrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_hpc.c +3 more+30 -160 replies
26/32PCI: pciehp: Obey compulsory command delay after resumedrivers/pci/hotplug/pciehp_core.c+4 -00 replies
27/32PCI: pciehp: Support interrupts sent from D3hotdrivers/pci/hotplug/pciehp.h drivers/pci/hotplug/pciehp_hpc.c+48 -21 reply
28/32PCI: pciehp: Resume to D0 on enable/disabledrivers/pci/hotplug/pciehp_ctrl.c+6 -00 replies
29/32PCI: pciehp: Resume parent to D0 on config space accessdrivers/pci/hotplug/pciehp_core.c drivers/pci/hotplug/pciehp_hpc.c+21 -00 replies
30/32PCI: sysfs: Resume to D0 on function resetdrivers/pci/pci-sysfs.c+2 -00 replies
31/32PCI: Whitelist native hotplug ports for runtime D3drivers/pci/pci.c+10 -50 replies
32/32PCI: Whitelist Thunderbolt ports for runtime D3drivers/pci/pci.c+5 -15 replies

Reviews trailers per patch

2 of 32 patches have a Reviewed-by or Acked-by.

PatchMika WesterbergAndy Shevchenko
1/32
2/32
3/32
4/32
5/32
6/32
7/32
8/32
9/32
10/32
11/32
12/32
13/32
14/32A-b A-b
15/32
16/32
17/32
18/32
19/32
20/32
21/32
22/32
23/32
24/32
25/32
26/32
27/32
28/32
29/32
30/32
31/32
32/32R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/32] Rework pciehp event handling & add runtime PM

Rework pciehp to use modern, threaded IRQ handling. The slot is powered on and off synchronously in the IRQ thread, no indirection via a work queue anymore.

When the slot is enabled/disabled by the user via sysfs or an Attention Button press, a request is sent to the IRQ thread. The IRQ thread is thus the sole entity enabling/disabling the slot.

The IRQ thread can cope with missed events, e.g. if a card is inserted and immediately pulled out before the IRQ thread had a chance to react. It also tolerates an initially unstable link as observed in the wild by Stefan Roese.

Finally, runtime PM support is added. This was the original motivation of the series because runtime suspending hotplug ports is needed to power down Thunderbolt controllers on idle, which saves ~1.5W per controller. Runtime resuming ports takes tenths of milliseconds during which events may be missed, this in turn necessitated the event handling rework.

I've pushed the series to GitHub to ease reviewing/fetching:
https://github.com/l1k/linux/commits/pciehp_runpm_v2

Please review and test.

Thanks,

Lukas

Lukas Wunner (32):
PCI: hotplug: Don't leak pci_slot on registration failure
PCI: pciehp: Fix UAF on unplug
PCI: pciehp: Fix deadlock on unplug
PCI: pciehp: Fix unprotected list iteration in IRQ handler
PCI: pciehp: Drop unnecessary NULL pointer check
PCI: pciehp: Declare pciehp_unconfigure_device() void
PCI: pciehp: Document struct slot and struct controller
genirq: Synchronize only with single thread on free_irq()
PCI: pciehp: Convert to threaded IRQ
PCI: pciehp: Convert to threaded polling
PCI: pciehp: Stop blinking on slot enable failure
PCI: pciehp: Handle events synchronously
PCI: pciehp: Drop slot workqueue
PCI: hotplug: Demidlayer registration with the core
PCI: pciehp: Publish to user space last on probe
PCI: pciehp: Track enable/disable status
PCI: pciehp: Enable/disable exclusively from IRQ thread
PCI: pciehp: Drop enable/disable lock
PCI: pciehp: Declare pciehp_enable/disable_slot() static
PCI: pciehp: Tolerate initially unstable link
PCI: pciehp: Become resilient to missed events
PCI: pciehp: Always enable occupied slot on probe
PCI: pciehp: Avoid slot access during reset
PCI: portdrv: Deduplicate PM callback iterator
PCI: pciehp: Clear spurious events earlier on resume
PCI: pciehp: Obey compulsory command delay after resume
PCI: pciehp: Support interrupts sent from D3hot
PCI: pciehp: Resume to D0 on enable/disable
PCI: pciehp: Resume parent to D0 on config space access
PCI: sysfs: Resume to D0 on function reset
PCI: Whitelist native hotplug ports for runtime D3
PCI: Whitelist Thunderbolt ports for runtime D3

 drivers/pci/hotplug/acpiphp_core.c      |  22 +-
 drivers/pci/hotplug/cpci_hotplug_core.c |  14 +-
 drivers/pci/hotplug/cpqphp_core.c       |  16 +-
 drivers/pci/hotplug/ibmphp_core.c       |  15 +-
 drivers/pci/hotplug/ibmphp_ebda.c       |  20 --
 drivers/pci/hotplug/pci_hotplug_core.c  | 134 +++++++--
 drivers/pci/hotplug/pciehp.h            | 117 ++++++--
 drivers/pci/hotplug/pciehp_core.c       | 104 ++++---
 drivers/pci/hotplug/pciehp_ctrl.c       | 352 ++++++++++--------------
 drivers/pci/hotplug/pciehp_hpc.c        | 261 ++++++++++--------
 drivers/pci/hotplug/pciehp_pci.c        |  42 ++-
 drivers/pci/hotplug/pcihp_skeleton.c    |  16 +-
 drivers/pci/hotplug/pnv_php.c           |   5 +-
 drivers/pci/hotplug/rpaphp_core.c       |   2 +-
 drivers/pci/hotplug/rpaphp_slot.c       |  13 +-
 drivers/pci/hotplug/s390_pci_hpc.c      |  13 +-
 drivers/pci/hotplug/sgi_hotplug.c       |   9 +-
 drivers/pci/hotplug/shpchp_core.c       |  20 +-
 drivers/pci/pci-sysfs.c                 |   2 +
 drivers/pci/pci.c                       |  21 +-
 drivers/pci/pcie/portdrv.h              |   2 +
 drivers/pci/pcie/portdrv_core.c         |  30 +-
 drivers/pci/pcie/portdrv_pci.c          |   2 +
 drivers/platform/x86/asus-wmi.c         |  12 +-
 drivers/platform/x86/eeepc-laptop.c     |  12 +-
 include/linux/pci_hotplug.h             |  15 +-
 kernel/irq/manage.c                     |  21 +-
 27 files changed, 687 insertions(+), 605 deletions(-)
Signature · 1 line
2.17.1