* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT [not found] <20260727105059.75716-1-spasswolf@web.de> @ 2026-07-28 0:51 ` mikhail.v.gavrilov 2026-07-29 12:35 ` Bert Karwatzki 0 siblings, 1 reply; 11+ messages in thread From: mikhail.v.gavrilov @ 2026-07-28 0:51 UTC (permalink / raw) To: Bert Karwatzki, linux-kernel Cc: linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner On Mon, 2026-07-27 at 12:50 +0200, Bert Karwatzki wrote: > 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. > Fix this by calling kvzalloc_obj() with > DC_RUN_WITH_PREEMPTION_ENABLED(). > Also fix the error path in dc_create_stream_for_sink(). > > Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC > - Part 1") > Link: > https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ > > Signed-off-by: Bert Karwatzki <spasswolf@web.de> > --- > drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 5 +++-- > drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 4 ++-- > 2 files changed, 5 insertions(+), 4 deletions(-) > > 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 dbc12640b01c..4ac835777b58 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; > 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 88e825a6582c..d5c6427796b6 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)); > > if (NULL == plane_state) > return NULL; Hi Bert, You may not be aware that the same allocation is already wrapped once, at the dcn32 call site: 183182235f6d ("drm/amd/display: Wrap DCN32 phantom-plane allocation in DC_RUN_WITH_PREEMPTION_ENABLED") That one only covers the dcn32 DML1 path, while your trace goes through dcn401_validate_bandwidth() and dml21 - so wrapping the call site could never have caught your case. Which is a good argument for guarding the allocation in the callee, as you do: dc_create_plane_state() is reached from every DCN and both DML generations. On dcn32 the two wraps now nest. That is harmless, because DC_RUN_WITH_PREEMPTION_ENABLED() is conditional on dc_is_fp_enabled(): once the outer instance has left the FPU region, the inner one expands to a plain call. But it does make the dcn32 wrap redundant, and I think it should be dropped in a follow-up now that the allocation is guarded in the callee. One thing that may be worth adjusting in the commit message: this is not only a PREEMPT_RT problem. 183182235f6d was needed on a plain non- RT x86 kernel. There DC_FP_START() takes fpregs_lock(), which disables local softirqs, and dc_plane_state is around 335 KiB, so kvzalloc_obj() falls through to the vmalloc path and hits BUG_ON(in_interrupt()). So on RT any allocation inside the FPU region is illegal, while on non-RT it is specifically the large ones - two failure modes, one root cause. About the FPU register question raised by the review bot: as far as I can see it applies to every existing user of DC_RUN_WITH_PREEMPTION_ENABLED(), 183182235f6d included, so it looks like a property of the macro rather than something your patch introduces. An answer from AMD on that would be useful either way. I have dcn32 hardware here (RX 7900 XTX) and can test the patch on non-RT if that helps. -- Thanks, Mikhail ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT 2026-07-28 0:51 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT mikhail.v.gavrilov @ 2026-07-29 12:35 ` Bert Karwatzki 2026-07-29 14:39 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Mikhail Gavrilov 0 siblings, 1 reply; 11+ messages in thread From: Bert Karwatzki @ 2026-07-29 12:35 UTC (permalink / raw) To: mikhail.v.gavrilov@gmail.com, linux-kernel Cc: linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner, spasswolf Am Dienstag, dem 28.07.2026 um 05:51 +0500 schrieb mikhail.v.gavrilov@gmail.com: > On Mon, 2026-07-27 at 12:50 +0200, Bert Karwatzki wrote: > > 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. > > Fix this by calling kvzalloc_obj() with > > DC_RUN_WITH_PREEMPTION_ENABLED(). > > Also fix the error path in dc_create_stream_for_sink(). > > > > Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC > > - Part 1") > > Link: > > https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ > > > > Signed-off-by: Bert Karwatzki <spasswolf@web.de> > > --- > > drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 5 +++-- > > drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 4 ++-- > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > 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 dbc12640b01c..4ac835777b58 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; > > 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 88e825a6582c..d5c6427796b6 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)); > > > > if (NULL == plane_state) > > return NULL; > > Hi Bert, > > You may not be aware that the same allocation is already wrapped once, > at the dcn32 call site: > > 183182235f6d ("drm/amd/display: Wrap DCN32 phantom-plane allocation > in DC_RUN_WITH_PREEMPTION_ENABLED") > > That one only covers the dcn32 DML1 path, while your trace goes through > dcn401_validate_bandwidth() and dml21 - so wrapping the call site could > never have caught your case. Which is a good argument for guarding the > allocation in the callee, as you do: dc_create_plane_state() is reached > from every DCN and both DML generations. I did try a different approach, using DC_RUN_WITH_PREEMPTION_ENABLED further upward in the calltrace (This would have the slight benefit of more code running with preemption enabled). This does not work because dml21_utils.c is compiled as a _LINUX_FPU_COMPILATION_UNIT, so DC_RUN_WITH_PREEMPTION_ENABLED does nothing. (see drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h) diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/dml21_utils.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/dml21_utils.c index 835fece1d46a..8c92deded8cd 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/dml21_utils.c +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/dml21_utils.c @@ -286,7 +286,8 @@ static struct dc_plane_state *dml21_add_phantom_plane(struct dml2_context *dml_c (void)plane_programming; struct dc_plane_state *phantom_plane; - phantom_plane = dml_ctx->config.svp_pstate.callbacks.create_phantom_plane(dc, context, main_plane); + DC_RUN_WITH_PREEMPTION_ENABLED(phantom_plane + = dml_ctx->config.svp_pstate.callbacks.create_phantom_plane(dc, context, main_plane)); if (!phantom_plane) return NULL; diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c index 4543a60a0683..464bab9fc13b 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c @@ -769,10 +769,11 @@ static void enable_phantom_plane(struct dml2_context *ctx, if (curr_pipe->top_pipe && curr_pipe->top_pipe->plane_state == curr_pipe->plane_state) { phantom_plane = prev_phantom_plane; } else { - phantom_plane = ctx->config.svp_pstate.callbacks.create_phantom_plane( + DC_RUN_WITH_PREEMPTION_ENABLED(phantom_plane = + ctx->config.svp_pstate.callbacks.create_phantom_plane( ctx->config.svp_pstate.callbacks.dc, state, - curr_pipe->plane_state); + curr_pipe->plane_state)); if (!phantom_plane) return; } Bert Karwatzki ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} with PREEMPT_RT 2026-07-29 12:35 ` Bert Karwatzki @ 2026-07-29 14:39 ` Mikhail Gavrilov 2026-07-29 17:46 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " Bert Karwatzki 0 siblings, 1 reply; 11+ messages in thread From: Mikhail Gavrilov @ 2026-07-29 14:39 UTC (permalink / raw) To: Bert Karwatzki Cc: linux-kernel, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner On Wed, Jul 29, 2026 at 5:36 PM Bert Karwatzki <spasswolf@web.de> wrote: > > I did try a different approach, using DC_RUN_WITH_PREEMPTION_ENABLED further > upward in the calltrace (This would have the slight benefit of more code > running with preemption enabled). This does not work because dml21_utils.c is compiled > as a _LINUX_FPU_COMPILATION_UNIT, so DC_RUN_WITH_PREEMPTION_ENABLED does nothing. Confirmed, and the chain is worth spelling out because it is not obvious from the call site: Makefile:1127: CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT dc/dml2_0/Makefile: applies $(CC_FLAGS_FPU) to every object under dc/dml2_0/ ("Add FPU flags to all dml2 files by default") so both files you tried are built with -D_LINUX_FPU_COMPILATION_UNIT, and in that branch of dc_fpu.h the macro is: #define DC_RUN_WITH_PREEMPTION_ENABLED(code) code What I think is the real problem here: in the same branch DC_FP_START() and DC_FP_END() are defined as BUILD_BUG(), so misusing those inside an FPU compilation unit fails the build. DC_RUN_WITH_PREEMPTION_ENABLED() silently degrades to a plain call instead. It compiles cleanly, looks correct on review, and does nothing - which is exactly the trap you just walked into. Making it BUILD_BUG() as well would turn that into a compile error. I can send that as a separate patch if AMD agrees it is the right direction. This also explains the asymmetry with 183182235f6d: dc/resource/dcn32/ does not get the FPU flags, so the call-site wrap there expands to the real thing, while the equivalent wrap in the dml21 path would have been a no-op. Another reason to guard the allocation in the callee, as your patch does. -- Thanks, Mikhail ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT 2026-07-29 14:39 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Mikhail Gavrilov @ 2026-07-29 17:46 ` Bert Karwatzki 2026-08-01 7:17 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki 0 siblings, 1 reply; 11+ messages in thread From: Bert Karwatzki @ 2026-07-29 17:46 UTC (permalink / raw) To: Mikhail Gavrilov Cc: linux-kernel, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner, spasswwolf Am Dienstag, dem 28.07.2026 um 05:51 +0500 schrieb mikhail.v.gavrilov@gmail.com: > One thing that may be worth adjusting in the commit message: this is > not only a PREEMPT_RT problem. 183182235f6d was needed on a plain non- > RT x86 kernel. There DC_FP_START() takes fpregs_lock(), which disables > local softirqs, and dc_plane_state is around 335 KiB, so kvzalloc_obj() > falls through to the vmalloc path and hits BUG_ON(in_interrupt()). So > on RT any allocation inside the FPU region is illegal, while on non-RT > it is specifically the large ones - two failure modes, one root cause. I think this was true when commit 183182235f6d ("drm/amd/display: Wrap DCN32 phantom-plane allocation in DC_RUN_WITH_PREEMPTION_ENABLED") was commited, but commit 04aa71da5f35 ("mm/vmalloc: do not trigger BUG() on BH disabled context") changed the BUG_ON() in __get_vm_area_node(): diff --git a/mm/vmalloc.c b/mm/vmalloc.c index c31a8615a832..bb6ae08d18f5 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3203,7 +3203,7 @@ struct vm_struct *__get_vm_area_node(unsigned long size, struct vm_struct *area; unsigned long requested_size = size; - BUG_ON(in_interrupt()); + BUG_ON(in_nmi() || in_hardirq()); size = ALIGN(size, 1ul << shift); if (unlikely(!size)) return NULL; so on non-PREEMPT_RT kernels DC_RUN_WITH_PREEMPTION_ENABLED is no longer required for DCN32 phantom-plane allocation. Bert Karwatzki ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} with PREEMPT_RT 2026-07-29 17:46 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " Bert Karwatzki @ 2026-08-01 7:17 ` Bert Karwatzki 2026-08-01 10:17 ` Mikhail Gavrilov ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Bert Karwatzki @ 2026-08-01 7:17 UTC (permalink / raw) To: linux-kernel Cc: Bert Karwatzki, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Mikhail Gavrilov, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner 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. Fix this by calling kvzalloc_obj() with DC_RUN_WITH_PREEMPTION_ENABLED(). Also fix the error path in dc_create_stream_for_sink(). Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC - Part 1") Link: https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ Signed-off-by: Bert Karwatzki <spasswolf@web.de> --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 cdcf140bc1bb..accad9e20e88 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -229,7 +229,7 @@ struct dc_stream_state *dc_create_stream_for_sink( fail: if (stream) - kfree(stream); + DC_RUN_WITH_PREEMPTION_ENABLED(kfree(stream)); return NULL; } 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 88e825a6582c..d5c6427796b6 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)); if (NULL == plane_state) return NULL; -- 2.53.0 Rebased to next-20260729+. In these version the allocation of update_scratch has been removed from dc_create_stream_for_sink(). Bert Karwatzki ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} with PREEMPT_RT 2026-08-01 7:17 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki @ 2026-08-01 10:17 ` Mikhail Gavrilov 2026-08-07 12:58 ` Bert Karwatzki 2026-08-06 3:47 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " kernel test robot 2026-08-06 4:29 ` kernel test robot 2 siblings, 1 reply; 11+ messages in thread From: Mikhail Gavrilov @ 2026-08-01 10:17 UTC (permalink / raw) To: Bert Karwatzki Cc: linux-kernel, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner On Sat, Aug 1, 2026 at 12:17 PM Bert Karwatzki <spasswolf@web.de> wrote: > > 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. > Fix this by calling kvzalloc_obj() with DC_RUN_WITH_PREEMPTION_ENABLED(). > Also fix the error path in dc_create_stream_for_sink(). > > Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC - Part 1") > Link: https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ > > Signed-off-by: Bert Karwatzki <spasswolf@web.de> > --- > drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- > drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > 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 cdcf140bc1bb..accad9e20e88 100644 > --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c > @@ -229,7 +229,7 @@ struct dc_stream_state *dc_create_stream_for_sink( > > fail: > if (stream) > - kfree(stream); > + DC_RUN_WITH_PREEMPTION_ENABLED(kfree(stream)); > > return NULL; > } > 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 88e825a6582c..d5c6427796b6 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)); This hunk breaks the build when CONFIG_DRM_AMD_DC_FP=n. dc_surface.c gets DC_RUN_WITH_PREEMPTION_ENABLED only indirectly, via dc.h -> dc_types.h -> os_types.h, and there the include is guarded: #if defined(CONFIG_DRM_AMD_DC_FP) #include "amdgpu_dm/dc_fpu.h" #endif With DC_FP=n nothing defines the macro in that file. dc_stream.c is not affected because it includes dc_fpu.h directly. This is not only exotic architectures: DRM_AMD_DC has select DRM_AMD_DC_FP if ARCH_HAS_KERNEL_FPU_SUPPORT && \ !(CC_IS_CLANG && (ARM64 || LOONGARCH || RISCV)) so an arm64 clang build is enough. On amd-staging-drm-next with your patch applied: $ make LLVM=1 ARCH=arm64 allmodconfig $ make LLVM=1 ARCH=arm64 drivers/gpu/drm/amd/amdgpu/ dc_surface.c:89:2: error: call to undeclared function 'DC_RUN_WITH_PREEMPTION_ENABLED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 89 | DC_RUN_WITH_PREEMPTION_ENABLED(plane_state = kvzalloc_obj(*plane_state, GFP_ATOMIC)); A plain x86_64 build (DC_FP=y) is clean, which is presumably why it did not show up for you. Adding #include "dc_fpu.h" to dc_surface.c fixes it, and matches what dc_stream.c already does. Please do not copy the local fallback that sits below that include in dc_stream.c: #if !defined(DC_RUN_WITH_PREEMPTION_ENABLED) #define DC_RUN_WITH_PREEMPTION_ENABLED(code) code #endif It is dead code there - dc_fpu.h defines the macro in every branch - and in a new file it would compile cleanly while quietly doing nothing. One unrelated note: you kept Cc: stable # v7.1, but this version is rebased onto next-20260729, where the update_scratch allocation is gone from dc_create_stream_for_sink(). It does not apply to current mainline either, so older trees will need a separate backport - worth saying so in the commit message. With the include added I can give this a Tested-by on dcn32 (RX 7900 XTX), which exercises the DML1 phantom-plane path rather than the dml21 one you hit. -- Best Regards, Mikhail Gavrilov. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} with PREEMPT_RT 2026-08-01 10:17 ` Mikhail Gavrilov @ 2026-08-07 12:58 ` Bert Karwatzki 0 siblings, 0 replies; 11+ messages in thread From: Bert Karwatzki @ 2026-08-07 12:58 UTC (permalink / raw) To: linux-kernel Cc: Bert Karwatzki, linux-next, linux-rt-devel, amd-gfx, Mikhail Gavrilov, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner 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. Fix this by calling kvzalloc_obj() with DC_RUN_WITH_PREEMPTION_ENABLED(). Also fix the error path in dc_create_stream_for_sink(). Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC - Part 1") Link: https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ Signed-off-by: Bert Karwatzki <spasswolf@web.de> --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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 cdcf140bc1bb..accad9e20e88 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -229,7 +229,7 @@ struct dc_stream_state *dc_create_stream_for_sink( fail: if (stream) - kfree(stream); + DC_RUN_WITH_PREEMPTION_ENABLED(kfree(stream)); return NULL; } 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 88e825a6582c..f4eb021711cb 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c @@ -33,6 +33,7 @@ #include "dpp.h" #include "dc_plane_priv.h" +#include "dc_fpu.h" /******************************************************************************* * Private functions @@ -85,8 +86,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)); if (NULL == plane_state) return NULL; -- 2.55.0 Added compile fix (by Mikhail Gavrilov) for CONFIG_DRM_AMD_DC_FP=n to the patch for linux-next. Compile tested with arm64/clang on debian sid. Bert Karwatzki ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT 2026-08-01 7:17 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki 2026-08-01 10:17 ` Mikhail Gavrilov @ 2026-08-06 3:47 ` kernel test robot 2026-08-06 4:29 ` kernel test robot 2 siblings, 0 replies; 11+ messages in thread From: kernel test robot @ 2026-08-06 3:47 UTC (permalink / raw) To: Bert Karwatzki, linux-kernel Cc: llvm, oe-kbuild-all, Bert Karwatzki, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Mikhail Gavrilov, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner Hi Bert, kernel test robot noticed the following build errors: [auto build test ERROR on next-20260804] [cannot apply to drm-misc/drm-misc-next linus/master v7.2-rc6 v7.2-rc5 v7.2-rc4 v7.2-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Bert-Karwatzki/drm-amd-display-fix-usage-of-DC_FPU_-BEGIN-END-with-PREEMPT_RT/20260805-170330 base: next-20260804 patch link: https://lore.kernel.org/r/20260801071724.12998-1-spasswolf%40web.de patch subject: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260806/202608061154.QtrglsMo-lkp@intel.com/config) compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project bacfe2950f8218268fcc0a8765644ea0c15f0360) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260806/202608061154.QtrglsMo-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202608061154.QtrglsMo-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_surface.c:89:2: error: call to undeclared function 'DC_RUN_WITH_PREEMPTION_ENABLED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 89 | DC_RUN_WITH_PREEMPTION_ENABLED(plane_state = kvzalloc_obj(*plane_state, GFP_ATOMIC)); | ^ 1 error generated. vim +/DC_RUN_WITH_PREEMPTION_ENABLED +89 drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_surface.c 82 83 /******************************************************************************* 84 * Public functions 85 ******************************************************************************/ 86 struct dc_plane_state *dc_create_plane_state(const struct dc *dc) 87 { 88 struct dc_plane_state *plane_state; > 89 DC_RUN_WITH_PREEMPTION_ENABLED(plane_state = kvzalloc_obj(*plane_state, GFP_ATOMIC)); 90 91 if (NULL == plane_state) 92 return NULL; 93 94 kref_init(&plane_state->refcount); 95 dc_plane_construct(dc->ctx, plane_state); 96 97 return plane_state; 98 } 99 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT 2026-08-01 7:17 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki 2026-08-01 10:17 ` Mikhail Gavrilov 2026-08-06 3:47 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " kernel test robot @ 2026-08-06 4:29 ` kernel test robot 2026-08-07 12:49 ` [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki 2 siblings, 1 reply; 11+ messages in thread From: kernel test robot @ 2026-08-06 4:29 UTC (permalink / raw) To: Bert Karwatzki, linux-kernel Cc: oe-kbuild-all, Bert Karwatzki, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Mikhail Gavrilov, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner Hi Bert, kernel test robot noticed the following build errors: [auto build test ERROR on next-20260804] [cannot apply to drm-misc/drm-misc-next linus/master v7.2-rc6 v7.2-rc5 v7.2-rc4 v7.2-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Bert-Karwatzki/drm-amd-display-fix-usage-of-DC_FPU_-BEGIN-END-with-PREEMPT_RT/20260805-170330 base: next-20260804 patch link: https://lore.kernel.org/r/20260801071724.12998-1-spasswolf%40web.de patch subject: [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20260806/202608061233.eufnR5Qm-lkp@intel.com/config) compiler: alpha-linux-gcc (GCC) 16.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260806/202608061233.eufnR5Qm-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202608061233.eufnR5Qm-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_surface.c: In function 'dc_create_plane_state': >> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_surface.c:89:9: error: implicit declaration of function 'DC_RUN_WITH_PREEMPTION_ENABLED' [-Wimplicit-function-declaration] 89 | DC_RUN_WITH_PREEMPTION_ENABLED(plane_state = kvzalloc_obj(*plane_state, GFP_ATOMIC)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/DC_RUN_WITH_PREEMPTION_ENABLED +89 drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_surface.c 82 83 /******************************************************************************* 84 * Public functions 85 ******************************************************************************/ 86 struct dc_plane_state *dc_create_plane_state(const struct dc *dc) 87 { 88 struct dc_plane_state *plane_state; > 89 DC_RUN_WITH_PREEMPTION_ENABLED(plane_state = kvzalloc_obj(*plane_state, GFP_ATOMIC)); 90 91 if (NULL == plane_state) 92 return NULL; 93 94 kref_init(&plane_state->refcount); 95 dc_plane_construct(dc->ctx, plane_state); 96 97 return plane_state; 98 } 99 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} with PREEMPT_RT 2026-08-06 4:29 ` kernel test robot @ 2026-08-07 12:49 ` Bert Karwatzki 2026-08-07 14:00 ` [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " Greg KH 0 siblings, 1 reply; 11+ messages in thread From: Bert Karwatzki @ 2026-08-07 12:49 UTC (permalink / raw) To: linux-kernel Cc: Bert Karwatzki, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Mikhail Gavrilov, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner 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. Fix this by calling kvzalloc_obj() with DC_RUN_WITH_PREEMPTION_ENABLED(). Also fix the error path in dc_create_stream_for_sink(). Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC - Part 1") Link: https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ Signed-off-by: Bert Karwatzki <spasswolf@web.de> --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 5 +++-- drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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 7666cdc78f4e..a5a304a3f802 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; 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 72845fc788f3..04982673ffbc 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c @@ -33,6 +33,7 @@ #include "dpp.h" #include "dc_plane_priv.h" +#include "dc_fpu.h" /******************************************************************************* * Private functions @@ -86,8 +87,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)); if (NULL == plane_state) return NULL; -- 2.55.0 Fix for stable with the old error handling in dc_create_stream_for_sink() and compile fix form arm64/clang. Bert Karwatzki ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT 2026-08-07 12:49 ` [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki @ 2026-08-07 14:00 ` Greg KH 0 siblings, 0 replies; 11+ messages in thread From: Greg KH @ 2026-08-07 14:00 UTC (permalink / raw) To: Bert Karwatzki Cc: linux-kernel, linux-next, linux-rt-devel, amd-gfx, # = v7 . 1, Mikhail Gavrilov, Alex Deucher, Rafal Ostrowski, Mario Limonciello, Sebastian Andrzej Siewior, Thomas Gleixner On Fri, Aug 07, 2026 at 02:49:42PM +0200, Bert Karwatzki wrote: > 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. > Fix this by calling kvzalloc_obj() with DC_RUN_WITH_PREEMPTION_ENABLED(). > Also fix the error path in dc_create_stream_for_sink(). > > Fixes: 3539437f354b ("drm/amd/display: Move FPU Guards From DML To DC - Part 1") > Link: https://lore.kernel.org/lkml/20260723123449.6494-1-spasswolf@web.de/ > Signed-off-by: Bert Karwatzki <spasswolf@web.de> > --- > drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 5 +++-- > drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 5 +++-- > 2 files changed, 6 insertions(+), 4 deletions(-) > > 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 7666cdc78f4e..a5a304a3f802 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; > 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 72845fc788f3..04982673ffbc 100644 > --- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c > @@ -33,6 +33,7 @@ > #include "dpp.h" > > #include "dc_plane_priv.h" > +#include "dc_fpu.h" > > /******************************************************************************* > * Private functions > @@ -86,8 +87,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)); > > if (NULL == plane_state) > return NULL; > -- > 2.55.0 > > Fix for stable with the old error handling in > dc_create_stream_for_sink() and compile fix form arm64/clang. > > Bert Karwatzki > <formletter> This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. </formletter> ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-08-10 6:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260727105059.75716-1-spasswolf@web.de>
2026-07-28 0:51 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} with PREEMPT_RT mikhail.v.gavrilov
2026-07-29 12:35 ` Bert Karwatzki
2026-07-29 14:39 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Mikhail Gavrilov
2026-07-29 17:46 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " Bert Karwatzki
2026-08-01 7:17 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki
2026-08-01 10:17 ` Mikhail Gavrilov
2026-08-07 12:58 ` Bert Karwatzki
2026-08-06 3:47 ` [PATCH] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " kernel test robot
2026-08-06 4:29 ` kernel test robot
2026-08-07 12:49 ` [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN, END} " Bert Karwatzki
2026-08-07 14:00 ` [PATCH v7.2-rc6] drm/amd/display: fix usage of DC_FPU_{BEGIN,END} " Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox