From: sashiko-bot@kernel.org
To: "Bert Karwatzki" <spasswolf@web.de>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT
Date: Mon, 27 Jul 2026 11:11:16 +0000 [thread overview]
Message-ID: <20260727111116.8D26C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727105059.75716-1-spasswolf@web.de>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Dropping the FPU guard inside dc_create_plane_state() and the error path of dc_create_stream_for_sink() corrupts callee-saved FPU registers on architectures like ARM64.
Pre-existing issues:
- [High] The patch addresses 'scheduling while atomic' bugs on PREEMPT_RT by wrapping memory allocations in FPU regions, but fails to apply the same fix to the symmetrical normal deallocation paths (dc_stream_free and dc_plane_state_free).
--
--- Patch [1]: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT ---
commit cf0d00c09a192f136eba5d73a1ff01aa518ca2f4
Author: Bert Karwatzki <spasswolf@web.de>
drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT
On PREEMPT_RT kernels kvzalloc_obj() can sleep because spin_lock is
converted to rt_mutex. dc_create_plane_state() can be called while
inside an FPU-guarded region, resuling in "scheduling while atomic"
errors on PREEMPT_RT kernels.
Link: https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
> index dbc12640b01c0..4ac835777b586 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
> @@ -233,8 +233,9 @@ struct dc_stream_state *dc_create_stream_for_sink(
>
> fail:
> if (stream) {
> - kfree(stream->update_scratch);
> - kfree(stream);
> + if (stream->update_scratch)
> + DC_RUN_WITH_PREEMPTION_ENABLED(kfree(stream->update_scratch));
> + DC_RUN_WITH_PREEMPTION_ENABLED(kfree(stream));
> }
>
> return NULL;
[Severity: High]
Could this cause floating-point data corruption on architectures like ARM64?
If this error path is reached while a DML algorithm is calling this as a
callback inside an FPU block, DC_RUN_WITH_PREEMPTION_ENABLED() terminates
the kernel FPU context.
When kernel_fpu_end() restores the user FPU state, won't the floating-point
variables held in callee-saved FPU registers be destroyed upon returning to
the DML caller?
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
> index 88e825a6582cb..d5c6427796b65 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
> @@ -85,8 +85,8 @@ uint8_t dc_plane_get_pipe_mask(struct dc_state *dc_state, const struct dc_plane
> ******************************************************************************/
> struct dc_plane_state *dc_create_plane_state(const struct dc *dc)
> {
> - struct dc_plane_state *plane_state = kvzalloc_obj(*plane_state,
> - GFP_ATOMIC);
> + struct dc_plane_state *plane_state;
> + DC_RUN_WITH_PREEMPTION_ENABLED(plane_state = kvzalloc_obj(*plane_state, GFP_ATOMIC));
[Severity: High]
Similar to the stream allocation above, does dropping the FPU guard here
corrupt callee-saved FPU registers?
When a DML algorithm calls dc_state_create_phantom_plane as a callback while
inside an FPU block, it calls dc_create_plane_state().
Dropping the FPU guard here allows the hardware FPU state to be overwritten,
which appears to destroy the caller's FPU context.
>
> if (NULL == plane_state)
> return NULL;
[Severity: High]
This isn't a bug introduced by this patch, but since you are addressing
'scheduling while atomic' bugs on PREEMPT_RT by wrapping memory allocations
in FPU regions, what about the symmetrical normal deallocation paths?
For example, dc_stream_free() and dc_plane_state_free() call kfree() and
kvfree() without FPU/preemption guards.
During bandwidth validation, dcn32_internal_validate_bw() executes inside an
FPU-guarded section (with preemption disabled) and can trigger these frees:
dcn32_internal_validate_bw()
dc_state_release_phantom_streams_and_planes()
// drops refcounts, leading to:
dc_stream_free()
kfree()
On PREEMPT_RT kernels, won't these free functions still attempt to acquire
sleeping locks (rt_mutex) and cause a scheduling while atomic crash?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727105059.75716-1-spasswolf@web.de?part=1
next prev parent reply other threads:[~2026-07-27 11:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 12:34 kernel panic during shutdown in v7.2-rc4 and next-20260722 with PREEMPT_RT Bert Karwatzki
2026-07-23 12:43 ` [Re] " Bert Karwatzki
2026-07-23 13:10 ` [Re] kernel panic during shutdown in v7.2-rc{3,4} " Bert Karwatzki
2026-07-23 13:23 ` Bert Karwatzki
2026-07-23 16:17 ` Bert Karwatzki
2026-07-23 22:51 ` [Re] kernel panic during shutdown in next-20260722 Bert Karwatzki
2026-07-24 15:08 ` Bert Karwatzki
2026-07-25 19:58 ` Bert Karwatzki
2026-07-25 23:16 ` Bert Karwatzki
2026-07-26 18:47 ` Bert Karwatzki
2026-07-26 22:52 ` Bert Karwatzki
2026-07-27 10:06 ` [Re] kernel panic during shutdown in v7.1+ with PREEMPT_RT Bert Karwatzki
2026-07-27 10:35 ` Ostrowski, Rafal
2026-07-27 10:50 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " Bert Karwatzki
2026-07-27 11:11 ` sashiko-bot [this message]
2026-07-28 0:51 ` mikhail.v.gavrilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727111116.8D26C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=spasswolf@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox