<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/gpu/drm/vc4, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Merge tag 'drm-misc-fixes-2026-11-20' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes</title>
<updated>2026-11-20T21:38:38+00:00</updated>
<author>
<name>Dave Airlie</name>
<email>airlied@redhat.com</email>
</author>
<published>2026-11-20T21:37:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ce29b8f9fb606f87014c2d05483a3fef05a11f38'/>
<id>ce29b8f9fb606f87014c2d05483a3fef05a11f38</id>
<content type='text'>
Short summary of fixes pull:

core:
- syncobj: Limit allocations
- vblank: Resolve deadlock in timer

imagination:
- Use correct function for polling non-iomem

ivpu:
- Fix race condition in recovery

nouveau:
- Fix instmem io_mapping faults and slowdowns

omap:
- dss: Fix handling deferrals

qaic:
- Harden ioctl checks

rocket:
- Many fixes throughout driver

tilcdc:
- Fix drvdata in suspend/resume

vc4:
- Many fixes throughout driver

vmwgfx:
- Many fixes throughout driver

Signed-off-by: Dave Airlie &lt;airlied@redhat.com&gt;

From: Thomas Zimmermann &lt;tzimmermann@suse.de&gt;
Link: https://patch.msgid.link/20261120080903.GA18643@linux.fritz.box
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Short summary of fixes pull:

core:
- syncobj: Limit allocations
- vblank: Resolve deadlock in timer

imagination:
- Use correct function for polling non-iomem

ivpu:
- Fix race condition in recovery

nouveau:
- Fix instmem io_mapping faults and slowdowns

omap:
- dss: Fix handling deferrals

qaic:
- Harden ioctl checks

rocket:
- Many fixes throughout driver

tilcdc:
- Fix drvdata in suspend/resume

vc4:
- Many fixes throughout driver

vmwgfx:
- Many fixes throughout driver

Signed-off-by: Dave Airlie &lt;airlied@redhat.com&gt;

From: Thomas Zimmermann &lt;tzimmermann@suse.de&gt;
Link: https://patch.msgid.link/20261120080903.GA18643@linux.fritz.box
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Clear the slice caches before resetting a stalled GPU</title>
<updated>2026-11-19T13:40:54+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-18T21:47:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=af1cf92e8617a7f7aa24b415596cbf64b76a12e7'/>
<id>af1cf92e8617a7f7aa24b415596cbf64b76a12e7</id>
<content type='text'>
Starting shader code at varying offsets makes the GFXH-16 icache livelock
unlikely, but not impossible. When the livelock happens, the QPUs make no
progress and the hangcheck resets the GPU, losing the job.

When the hangcheck finds no progress, clear the slice instruction and
uniforms caches and check again before resetting. If the stall is a
livelock, clearing the caches can break it and let the job continue.

Drop round_jiffies_up() from the hangcheck timer, so checks run every
100 ms instead of at the next whole second. This shortens the screen
freeze before the caches are cleared. Long jobs are unaffected: while the
control lists advance, the hangcheck won't clear the caches or reset the
GPU.

Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-4-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Starting shader code at varying offsets makes the GFXH-16 icache livelock
unlikely, but not impossible. When the livelock happens, the QPUs make no
progress and the hangcheck resets the GPU, losing the job.

When the hangcheck finds no progress, clear the slice instruction and
uniforms caches and check again before resetting. If the stall is a
livelock, clearing the caches can break it and let the job continue.

Drop round_jiffies_up() from the hangcheck timer, so checks run every
100 ms instead of at the next whole second. This shortens the screen
freeze before the caches are cleared. Long jobs are unaffected: while the
control lists advance, the hangcheck won't clear the caches or reset the
GPU.

Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-4-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Start shader code at varying offsets in its BO</title>
<updated>2026-11-19T13:40:54+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-18T21:47:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c0e1ed41ad86cf5230d64dc5f2c6d2e3aeb59937'/>
<id>c0e1ed41ad86cf5230d64dc5f2c6d2e3aeb59937</id>
<content type='text'>
VC4 is affected by the HW erratum GFXH-16: the QPUs can get stuck in a
loop where instruction cache loads are evicted before they are used.

The QPUs of a slice share one instruction cache. Shader BOs are page
aligned and the code always starts at offset 0, so instructions at the
same position in different shaders end up mapping to the same cache sets.
When the four QPUs of a slice run four different shaders, their fills
evict each other, no instruction executes and the hangcheck resets the
GPU.

Place each shader's code at one of four offsets, 256 bytes apart, inside
its BO, and add the offset when relocating the shader record. Shader code
is position independent, as the validator only accepts relative branches.
The offsets are tracked per client, so shaders a given client creates in
sequence (which tend to run together) start in different sets.

Notice that this approach makes the livelock unlikely, but not impossible.
The next commit will address the remaining cases.

On a Raspberry Pi 3 running the issue's reproducer, GPU resets went from
dozens in an hour to none.

Cc: stable@vger.kernel.org
Fixes: 463873d57014 ("drm/vc4: Add an API for creating GPU shaders in GEM BOs.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-3-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
VC4 is affected by the HW erratum GFXH-16: the QPUs can get stuck in a
loop where instruction cache loads are evicted before they are used.

The QPUs of a slice share one instruction cache. Shader BOs are page
aligned and the code always starts at offset 0, so instructions at the
same position in different shaders end up mapping to the same cache sets.
When the four QPUs of a slice run four different shaders, their fills
evict each other, no instruction executes and the hangcheck resets the
GPU.

Place each shader's code at one of four offsets, 256 bytes apart, inside
its BO, and add the offset when relocating the shader record. Shader code
is position independent, as the validator only accepts relative branches.
The offsets are tracked per client, so shaders a given client creates in
sequence (which tend to run together) start in different sets.

Notice that this approach makes the livelock unlikely, but not impossible.
The next commit will address the remaining cases.

On a Raspberry Pi 3 running the issue's reproducer, GPU resets went from
dozens in an hour to none.

Cc: stable@vger.kernel.org
Fixes: 463873d57014 ("drm/vc4: Add an API for creating GPU shaders in GEM BOs.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-3-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Check for a validated shader before reading its thread mode</title>
<updated>2026-11-19T13:40:54+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-18T21:47:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=15da41dff1f66a389d238db60a1c19fa83582d07'/>
<id>15da41dff1f66a389d238db60a1c19fa83582d07</id>
<content type='text'>
validate_gl_shader_rec() reads the thread mode from the validated_shader
of the FS, VS and CS BOs before checking it for NULL. A shader record
pointing at a BO not created by DRM_IOCTL_VC4_CREATE_SHADER_BO has no
validated_shader, so userspace can trigger a NULL pointer dereference.

Check that every shader BO has a validated shader before using it.

Cc: stable@vger.kernel.org
Fixes: c778cc5df944 ("drm/vc4: Add fragment shader threading support")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-2-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
validate_gl_shader_rec() reads the thread mode from the validated_shader
of the FS, VS and CS BOs before checking it for NULL. A shader record
pointing at a BO not created by DRM_IOCTL_VC4_CREATE_SHADER_BO has no
validated_shader, so userspace can trigger a NULL pointer dereference.

Check that every shader BO has a validated shader before using it.

Cc: stable@vger.kernel.org
Fixes: c778cc5df944 ("drm/vc4: Add fragment shader threading support")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-2-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Fix off-by-one in the shader record BO handle check</title>
<updated>2026-11-19T13:40:54+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-18T21:47:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1fbbd14add401c70c178f0fa13016a3a53ef0de5'/>
<id>1fbbd14add401c70c178f0fa13016a3a53ef0de5</id>
<content type='text'>
validate_gl_shader_rec() accepts a shader BO handle equal to
exec-&gt;bo_count, reading one entry past the end of exec-&gt;bo[] and
using it as a GEM object.

Reject handles that aren't below exec-&gt;bo_count.

Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-1-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
validate_gl_shader_rec() accepts a shader BO handle equal to
exec-&gt;bo_count, reading one entry past the end of exec-&gt;bo[] and
using it as a GEM object.

Reject handles that aren't below exec-&gt;bo_count.

Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-1-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: dsi: Set the transfer result before completing the transfer</title>
<updated>2026-11-18T14:26:38+00:00</updated>
<author>
<name>Henry Zhang</name>
<email>henryzhang62@gmail.com</email>
</author>
<published>2026-10-28T16:45:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=80ac6d197218c3399d66674167a4d7c9051a25e2'/>
<id>80ac6d197218c3399d66674167a4d7c9051a25e2</id>
<content type='text'>
On an HSTX timeout the interrupt handler completes the transfer and
only then sets xfer_result to -ETIMEDOUT. The waiter, which may run on
another CPU, can wake up and read xfer_result in between, still 0 from
the start of the transfer, and report the timed-out transfer as a
success.

Set xfer_result first. complete() orders the store before the wake-up.

Fixes: 4078f5757144 ("drm/vc4: Add DSI driver")
Signed-off-by: Henry Zhang &lt;henryzhang62@gmail.com&gt;
Link: https://patch.msgid.link/20261028164539.3471833-2-henryzhang62@gmail.com
Reviewed-by: Maíra Canal &lt;mcanal@igalia.com&gt;
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On an HSTX timeout the interrupt handler completes the transfer and
only then sets xfer_result to -ETIMEDOUT. The waiter, which may run on
another CPU, can wake up and read xfer_result in between, still 0 from
the start of the transfer, and report the timed-out transfer as a
success.

Set xfer_result first. complete() orders the store before the wake-up.

Fixes: 4078f5757144 ("drm/vc4: Add DSI driver")
Signed-off-by: Henry Zhang &lt;henryzhang62@gmail.com&gt;
Link: https://patch.msgid.link/20261028164539.3471833-2-henryzhang62@gmail.com
Reviewed-by: Maíra Canal &lt;mcanal@igalia.com&gt;
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: dsi: Register the PHY clock provider with devm</title>
<updated>2026-11-18T13:37:34+00:00</updated>
<author>
<name>Henry Zhang</name>
<email>henryzhang62@gmail.com</email>
</author>
<published>2026-11-17T23:41:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=db9a489077cbe9217b7bc2b47ebf0fabc5f1a56f'/>
<id>db9a489077cbe9217b7bc2b47ebf0fabc5f1a56f</id>
<content type='text'>
vc4_dsi_init_phy_clocks() is called from the component bind. It
allocates the clock data with devm_kzalloc() and registers the clocks
with devm_clk_hw_register(), so both are released with the devres group
that the component framework opens for the bind, when the bind fails
later or the component is unbound. The OF clock provider that points at
that data is added with of_clk_add_hw_provider() and never removed:
after an unbind it stays registered with the freed data, and each new
bind adds another provider for the same node. A later lookup of one of
these clocks, such as &lt;&amp;dsi1 0&gt;, would call of_clk_hw_onecell_get() on
freed memory.

Use devm_of_clk_add_hw_provider(), so that the provider is removed with
the same devres group, before the clocks and their data.

Fixes: 4078f5757144 ("drm/vc4: Add DSI driver")
Signed-off-by: Henry Zhang &lt;henryzhang62@gmail.com&gt;
Reviewed-by: Maíra Canal &lt;mcanal@igalia.com&gt;
Link: https://patch.msgid.link/20261117234107.1298575-1-henryzhang62@gmail.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
vc4_dsi_init_phy_clocks() is called from the component bind. It
allocates the clock data with devm_kzalloc() and registers the clocks
with devm_clk_hw_register(), so both are released with the devres group
that the component framework opens for the bind, when the bind fails
later or the component is unbound. The OF clock provider that points at
that data is added with of_clk_add_hw_provider() and never removed:
after an unbind it stays registered with the freed data, and each new
bind adds another provider for the same node. A later lookup of one of
these clocks, such as &lt;&amp;dsi1 0&gt;, would call of_clk_hw_onecell_get() on
freed memory.

Use devm_of_clk_add_hw_provider(), so that the provider is removed with
the same devres group, before the clocks and their data.

Fixes: 4078f5757144 ("drm/vc4: Add DSI driver")
Signed-off-by: Henry Zhang &lt;henryzhang62@gmail.com&gt;
Reviewed-by: Maíra Canal &lt;mcanal@igalia.com&gt;
Link: https://patch.msgid.link/20261117234107.1298575-1-henryzhang62@gmail.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Look up the async page flip fence before committing the flip</title>
<updated>2026-11-17T20:13:37+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-14T19:16:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f9fc6da01a290609428d308033143f1d96ab658f'/>
<id>f9fc6da01a290609428d308033143f1d96ab658f</id>
<content type='text'>
vc4_async_page_flip_common() ignores dma_resv_get_singleton() failures.
By then the plane state already points at the new framebuffer, so the
flip is never completed. So, its state leaks, the vblank reference is
never dropped and the event is never sent.

Look up the fence before changing any state, so the error can be properly
returned to userspace.

Cc: stable@vger.kernel.org
Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-3-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
vc4_async_page_flip_common() ignores dma_resv_get_singleton() failures.
By then the plane state already points at the new framebuffer, so the
flip is never completed. So, its state leaks, the vblank reference is
never dropped and the event is never sent.

Look up the fence before changing any state, so the error can be properly
returned to userspace.

Cc: stable@vger.kernel.org
Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-3-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Complete async page flips from an ordered workqueue</title>
<updated>2026-11-17T20:13:37+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-14T19:16:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=12a321af56c436e299414d8c276457dcf387e0cf'/>
<id>12a321af56c436e299414d8c276457dcf387e0cf</id>
<content type='text'>
Async page flips complete from a dma_fence callback, which runs in the
fence signaling context: the VC4 render job IRQ handler on RPi 0-3 since
commit e8941ac97f28 ("drm/vc4: Remove BOs seqnos"), and the V3D IRQ
handler on RPi 4-5 since commit d19e00ee06a9 ("drm/vc4: crtc: Fix out of
order frames during asynchronous page flips").

Completing the flip may sleep: on RPi 0-3, vc4_bo_dec_usecnt() takes
bo-&gt;madv_lock, and on all platforms, dropping the last framebuffer
reference takes fb_lock and can free the BO. When running the kernel
with CONFIG_DEBUG_ATOMIC_SLEEP=y on RPi 3, this triggers the following
warning:

[ 2511.636319] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:623
[ 2511.636667] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/0
[ 2511.636681] preempt_count: 1000002, expected: 0
[ 2511.636689] RCU nest depth: 0, expected: 0
[ 2511.636698] locks held by swapper/0/0: 1, on CPU#0:
[ 2511.636711]  #0: ffff000037183198 (&amp;fence-&gt;inline_lock){-...}-{3:3}, at: dma_fence_signal+0x88/0xec
&lt;snip&gt;
[ 2511.636892] Hardware name: Raspberry Pi 3 Model B Plus Rev 1.3 (DT)
[ 2511.636899] Call trace:
&lt;snip&gt;
[ 2511.636991]  mutex_lock_nested+0x24/0x30
[ 2511.637002]  vc4_bo_dec_usecnt+0x40/0x124 [vc4]
[ 2511.637070]  vc4_async_page_flip_complete_with_cleanup+0xa0/0xc4 [vc4]
[ 2511.637102]  dma_fence_signal_timestamp_locked+0x118/0x290
[ 2511.637116]  dma_fence_signal+0x9c/0xec
[ 2511.637126]  vc4_irq_render_job_done+0x24/0x114 [vc4]
[ 2511.637158]  vc4_irq+0x16c/0x274 [vc4]

Make the fence callback only queue a work item on a per-CRTC ordered
workqueue and complete the flip from it. Flips with no fence or an already
signaled one still complete inline, but only after flushing that workqueue,
so they can't complete before earlier flips on the same CRTC whose fence
already signaled.

Cc: stable@vger.kernel.org
Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips")
Fixes: e8941ac97f28 ("drm/vc4: Remove BOs seqnos")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-2-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Async page flips complete from a dma_fence callback, which runs in the
fence signaling context: the VC4 render job IRQ handler on RPi 0-3 since
commit e8941ac97f28 ("drm/vc4: Remove BOs seqnos"), and the V3D IRQ
handler on RPi 4-5 since commit d19e00ee06a9 ("drm/vc4: crtc: Fix out of
order frames during asynchronous page flips").

Completing the flip may sleep: on RPi 0-3, vc4_bo_dec_usecnt() takes
bo-&gt;madv_lock, and on all platforms, dropping the last framebuffer
reference takes fb_lock and can free the BO. When running the kernel
with CONFIG_DEBUG_ATOMIC_SLEEP=y on RPi 3, this triggers the following
warning:

[ 2511.636319] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:623
[ 2511.636667] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/0
[ 2511.636681] preempt_count: 1000002, expected: 0
[ 2511.636689] RCU nest depth: 0, expected: 0
[ 2511.636698] locks held by swapper/0/0: 1, on CPU#0:
[ 2511.636711]  #0: ffff000037183198 (&amp;fence-&gt;inline_lock){-...}-{3:3}, at: dma_fence_signal+0x88/0xec
&lt;snip&gt;
[ 2511.636892] Hardware name: Raspberry Pi 3 Model B Plus Rev 1.3 (DT)
[ 2511.636899] Call trace:
&lt;snip&gt;
[ 2511.636991]  mutex_lock_nested+0x24/0x30
[ 2511.637002]  vc4_bo_dec_usecnt+0x40/0x124 [vc4]
[ 2511.637070]  vc4_async_page_flip_complete_with_cleanup+0xa0/0xc4 [vc4]
[ 2511.637102]  dma_fence_signal_timestamp_locked+0x118/0x290
[ 2511.637116]  dma_fence_signal+0x9c/0xec
[ 2511.637126]  vc4_irq_render_job_done+0x24/0x114 [vc4]
[ 2511.637158]  vc4_irq+0x16c/0x274 [vc4]

Make the fence callback only queue a work item on a per-CRTC ordered
workqueue and complete the flip from it. Flips with no fence or an already
signaled one still complete inline, but only after flushing that workqueue,
so they can't complete before earlier flips on the same CRTC whose fence
already signaled.

Cc: stable@vger.kernel.org
Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips")
Fixes: e8941ac97f28 ("drm/vc4: Remove BOs seqnos")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-2-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>drm/vc4: Drop BO usecnt before releasing the old FB</title>
<updated>2026-11-17T20:13:30+00:00</updated>
<author>
<name>Maíra Canal</name>
<email>mcanal@igalia.com</email>
</author>
<published>2026-11-14T19:16:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=43b85636ea0d33152bf16816b7601e785723596d'/>
<id>43b85636ea0d33152bf16816b7601e785723596d</id>
<content type='text'>
The async page flip completion drops the old FB reference before
decrementing its BO usecnt. If that was the last reference, the BO is
already freed or recycled into the BO cache when vc4_bo_dec_usecnt()
runs, leading to a use-after-free or a refcount underflow. For example,
while running glmark2-es2-drm in the Raspberry Pi 3, the following
warning appears:

[  459.078834] ------------[ cut here ]------------
[  459.078855] refcount_t: underflow; use-after-free.
[  459.078952] WARNING: lib/refcount.c:96 at refcount_dec_not_one+0xa0/0xa8, CPU#0: swapper/0/0
&lt;snip&gt;
[  459.079316] Call trace:
[  459.079323]  refcount_dec_not_one+0xa0/0xa8 (P)
[  459.079335]  vc4_bo_dec_usecnt+0x30/0x118 [vc4]
[  459.079371]  vc4_async_page_flip_complete_with_cleanup+0xa0/0xc4 [vc4]
[  459.079395]  dma_fence_signal_timestamp_locked+0xb0/0x12c
[  459.079408]  dma_fence_signal+0x3c/0x6c
[  459.079416]  vc4_irq_render_job_done+0x24/0xbc [vc4]
[  459.079440]  vc4_irq+0x120/0x138 [vc4]

This could happen when userspace removes the old FB and closes its GEM
handle while the flip is still pending.

Decrement the BO usecnt before releasing the old FB reference. Do this
by unifying the two fence callbacks and only decrementing the BO usecnt
in VC4_GEN_4.

Cc: stable@vger.kernel.org
Fixes: 4d12c36fb73b ("drm/vc4: crtc: Move the BO handling out of common page-flip callback")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-1-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The async page flip completion drops the old FB reference before
decrementing its BO usecnt. If that was the last reference, the BO is
already freed or recycled into the BO cache when vc4_bo_dec_usecnt()
runs, leading to a use-after-free or a refcount underflow. For example,
while running glmark2-es2-drm in the Raspberry Pi 3, the following
warning appears:

[  459.078834] ------------[ cut here ]------------
[  459.078855] refcount_t: underflow; use-after-free.
[  459.078952] WARNING: lib/refcount.c:96 at refcount_dec_not_one+0xa0/0xa8, CPU#0: swapper/0/0
&lt;snip&gt;
[  459.079316] Call trace:
[  459.079323]  refcount_dec_not_one+0xa0/0xa8 (P)
[  459.079335]  vc4_bo_dec_usecnt+0x30/0x118 [vc4]
[  459.079371]  vc4_async_page_flip_complete_with_cleanup+0xa0/0xc4 [vc4]
[  459.079395]  dma_fence_signal_timestamp_locked+0xb0/0x12c
[  459.079408]  dma_fence_signal+0x3c/0x6c
[  459.079416]  vc4_irq_render_job_done+0x24/0xbc [vc4]
[  459.079440]  vc4_irq+0x120/0x138 [vc4]

This could happen when userspace removes the old FB and closes its GEM
handle while the flip is still pending.

Decrement the BO usecnt before releasing the old FB reference. Do this
by unifying the two fence callbacks and only decrementing the BO usecnt
in VC4_GEN_4.

Cc: stable@vger.kernel.org
Fixes: 4d12c36fb73b ("drm/vc4: crtc: Move the BO handling out of common page-flip callback")
Reviewed-by: Iago Toral Quiroga &lt;itoral@igalia.com&gt;
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-1-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal &lt;mcanal@igalia.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
