Skip to content

fixup usage of non-raw spinlocks in irqchips

Julia Cartwright cocci linux-alpha linux-gpio linux-rt-users linuxppc-dev lkml 2 versions – Applied

Status from this message: Applied, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 16 repliesApplied
  2. v119 patches 25 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/9Coccinelle: locks: identify callers of spin_lock{,_irq,_irqsave}() in irqchip implementationsscripts/coccinelle/locks/irq_chip_raw_spinlock.cocci+96 -03 replies
2/9alpha: marvel: make use of raw_spinlock variantsarch/alpha/include/asm/core_marvel.h arch/alpha/kernel/core_marvel.c arch/alpha/kernel/sys_marvel.c+8 -80 replies
3/9powerpc: mpc52xx_gpt: make use of raw_spinlock variantsarch/powerpc/platforms/52xx/mpc52xx_gpt.c+26 -261 reply
4/9mfd: asic3: make use of raw_spinlock variantsdrivers/mfd/asic3.c+28 -281 reply
5/9mfd: t7l66xb: make use of raw_spinlock variantsdrivers/mfd/t7l66xb.c+10 -101 reply
6/9mfd: tc6393xb: make use of raw_spinlock variantsdrivers/mfd/tc6393xb.c+26 -261 reply
7/9gpio: 104-idi-48: make use of raw_spinlock variantsdrivers/gpio/gpio-104-idi-48.c+10 -85 replies
8/9gpio: 104-idio-16: make use of raw_spinlock variantsdrivers/gpio/gpio-104-idio-16.c+12 -122 replies
9/9gpio: pci-idio-16: make use of raw_spinlock variantsdrivers/gpio/gpio-pci-idio-16.c+14 -142 replies

Reviews trailers per patch

4 of 9 patches have a Reviewed-by or Acked-by.

PatchLee JonesJulia LawallWilliam Breathitt Gray
1/9A-b
2/9
3/9
4/9Acked-for-MFD-by
5/9Acked-for-MFD-by
6/9Acked-for-MFD-by
7/9A-b
8/9A-b
9/9A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/9] fixup usage of non-raw spinlocks in irqchips

Changes since v1[1]:
- Dropped already applied patches in pinctrl, gpio, and mux trees.
- Gained three new patches destined for gpio tree, due to loosening constraints in the semantic patch.

The following patchset introduces a new coccinelle patch, irq_chip_raw_spinlock.cocci, which is used to identify irq_chip implementors which acquire/release non-raw spinlocks, and in addition, a set of generated patches for most cases identified.

On mainline builds, there exists no functional difference between raw_spinlock_t and spinlock_t. However, w/ PREEMPT_RT, the spinlock_t will cause the calling thread to sleep when the lock is contended. Because sleeping is illegal in hardirq context, and because the irqchip callbacks are invoked in hardirq context, irqchip implementations must not use spin_lock_t for synchronization.

Patches build tested only. All patches are independent of one another and can be applied to the relevant trees.

Some notes:

- In order to ensure that latency problems are not introduced for realtime kernels, the generated patches need to be hand audited to ensure that raw-spinlock protected regions are bounded and minimal. I've done a quick audit for each of the modified drivers in this series, but please check my work.

- There are a couple of matches which will require further intervention to fully fix. Namely the Intel LPE Audio driver:

drivers/gpu/drm/i915/intel_lpe_audio.c:169:30-38: Use of non-raw spinlock is illegal in this context (struct drm_i915_private::irq_lock)

and the adi2 pinctrl driver:

drivers/pinctrl/pinctrl-adi2.c:308:26-30: Use of non-raw spinlock is illegal in this context (struct gpio_port::lock)

- This semantic patch is not comprehensive, there are other equally broken usecases which are not properly identified yet, such as the use of a single global spinlock_t declared via DEFINE_SPINLOCK() (found in arch/alpha, and perhaps elsewhere).

An additional currently unhandled case is the irq_chip_generic callbacks.

Julia

[1]: http://lkml.kernel.org/r/cover.1489015238.git.julia at ni.com

Cc: Thomas Gleixner <[email protected]>
Cc: Sebastian Andrzej Siewior <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Julia Lawall <[email protected]>
Cc: Gilles Muller <[email protected]>
Cc: Nicolas Palix <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: cocci at systeme.lip6.fr
--------------
Julia Cartwright (9):
Coccinelle: locks: identify callers of spin_lock{,_irq,_irqsave}() in
irqchip implementations
alpha: marvel: make use of raw_spinlock variants
powerpc: mpc52xx_gpt: make use of raw_spinlock variants
mfd: asic3: make use of raw_spinlock variants
mfd: t7l66xb: make use of raw_spinlock variants
mfd: tc6393xb: make use of raw_spinlock variants
gpio: 104-idi-48: make use of raw_spinlock variants
gpio: 104-idio-16: make use of raw_spinlock variants
gpio: pci-idio-16: make use of raw_spinlock variants

 arch/alpha/include/asm/core_marvel.h               |  2 +-
 arch/alpha/kernel/core_marvel.c                    |  2 +-
 arch/alpha/kernel/sys_marvel.c                     | 12 +--
 arch/powerpc/platforms/52xx/mpc52xx_gpt.c          | 52 ++++++------
 drivers/gpio/gpio-104-idi-48.c                     | 18 ++--
 drivers/gpio/gpio-104-idio-16.c                    | 24 +++---
 drivers/gpio/gpio-pci-idio-16.c                    | 28 +++----
 drivers/mfd/asic3.c                                | 56 ++++++-------
 drivers/mfd/t7l66xb.c                              | 20 ++---
 drivers/mfd/tc6393xb.c                             | 52 ++++++------
 .../coccinelle/locks/irq_chip_raw_spinlock.cocci   | 96 ++++++++++++++++++++++
 11 files changed, 230 insertions(+), 132 deletions(-)
 create mode 100644 scripts/coccinelle/locks/irq_chip_raw_spinlock.cocci
Signature · 1 line
2.12.0