Re: [PATCH 4/7] drm/bridge: lock the encoder chain in scoped for_each loops

From: Luca Ceresoli
Date: Thu Oct 02 2025 - 11:34:05 EST


Hello,

On Tue, 30 Sep 2025 14:16:23 +0800
kernel test robot <oliver.sang@xxxxxxxxx> wrote:

> [ 674.477504][ C1] watchdog: BUG: soft lockup - CPU#1 stuck for 626s! [swapper/0:1]
> [ 674.477539][ C1] CPU#1 Utilization every 96s during lockup:
> [ 674.477543][ C1] #1: 100% system, 1% softirq, 1% hardirq, 0% idle
> [ 674.477549][ C1] #2: 100% system, 1% softirq, 1% hardirq, 0% idle
> [ 674.477553][ C1] #3: 100% system, 0% softirq, 1% hardirq, 0% idle
> [ 674.477557][ C1] #4: 100% system, 1% softirq, 1% hardirq, 0% idle
> [ 674.477561][ C1] #5: 100% system, 1% softirq, 1% hardirq, 0% idle
...
> [ 674.477713][ C1] drm_atomic_add_encoder_bridges (drivers/gpu/drm/drm_atomic.c:1319 (discriminator 1025))

The one reported is an actual bug, causing an infinite loop when the
encoder bridge chain is empty. Took a while to reproduce and debug, but
the fix is very simple:

#define drm_for_each_bridge_in_chain_scoped(encoder, bridge) \
for (struct drm_bridge *bridge __free(drm_bridge_encoder_chain_unlock) = \
- list_first_entry(&drm_encoder_chain_lock(encoder)->bridge_chain, \
+ list_first_entry_or_null(&drm_encoder_chain_lock(encoder)->bridge_chain, \

Fix queued for v2.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com