* [PATCH] drm/amd/display: use kvzalloc to allocate struct dc
@ 2026-06-23 6:56 Honglei Huang
2026-06-23 14:08 ` Mario Limonciello
0 siblings, 1 reply; 2+ messages in thread
From: Honglei Huang @ 2026-06-23 6:56 UTC (permalink / raw)
To: harry.wentland, sunpeng.li, siqueira, Christian.Koenig,
Mario.Limonciello, amd-gfx
Cc: Alexander.Deucher, Ray.Huang, Honglei Huang
struct dc has grown large over time (most of it the two inlined
dc_scratch_space copies) and now sits close to the page allocator's 4 MiB
contiguous allocation limit. Its actual size is not fixed by the source
alone, it also depends on the compiler and the .configk, so it can
easily cross 4 MiB, e.g. with a newer GCC or a config change, and once it
does dc_create() fails.
dc_create() allocates it with kzalloc(). Once struct dc exceeds 4 MiB the
request is rounded up to order 11 (8 MiB), which is above MAX_PAGE_ORDER,
so the page allocator warns and returns NULL. dc_create() then fails, DM
init fails and amdgpu probe aborts with -EINVAL:
WARNING: mm/page_alloc.c:5197 at __alloc_frozen_pages_noprof+0x2f9/0x380
RSI: ...000b RBP: ...000b <- order = 11 (8 MiB)
__kmalloc_large_noprof+0x1e/0xc0
dc_create+0x38/0x660 [amdgpu]
amdgpu_dm_init+0x2d9/0x510 [amdgpu]
dm_hw_init+0x1b/0x90 [amdgpu]
amdgpu 0000:03:00.0: hw_init of IP block <dm> failed -22
amdgpu 0000:03:00.0: probe with driver amdgpu failed with error -22
struct dc is software only state, never DMAed and only kept as an opaque
pointer, so it needs no physically contiguous memory. Use kvzalloc()/
kvfree() so it falls back to vmalloc(), removing the dependency on
MAX_PAGE_ORDER. The underlying bloat of struct dc should be addressed
separately.
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index b3530fbf32f..65bd927435e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1507,7 +1507,7 @@ static void disable_vbios_mode_if_required(
struct dc *dc_create(const struct dc_init_data *init_params)
{
- struct dc *dc = kzalloc_obj(*dc);
+ struct dc *dc = kvzalloc_obj(*dc);
unsigned int full_pipe_count;
if (!dc)
@@ -1555,7 +1555,7 @@ struct dc *dc_create(const struct dc_init_data *init_params)
destruct_dc:
dc_destruct(dc);
- kfree(dc);
+ kvfree(dc);
return NULL;
}
@@ -1604,7 +1604,7 @@ void dc_deinit_callbacks(struct dc *dc)
void dc_destroy(struct dc **dc)
{
dc_destruct(*dc);
- kfree(*dc);
+ kvfree(*dc);
*dc = NULL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amd/display: use kvzalloc to allocate struct dc
2026-06-23 6:56 [PATCH] drm/amd/display: use kvzalloc to allocate struct dc Honglei Huang
@ 2026-06-23 14:08 ` Mario Limonciello
0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2026-06-23 14:08 UTC (permalink / raw)
To: Honglei Huang, harry.wentland, sunpeng.li, siqueira,
Christian.Koenig, amd-gfx
Cc: Alexander.Deucher, Ray.Huang
On 6/22/26 23:56, Honglei Huang wrote:
> struct dc has grown large over time (most of it the two inlined
> dc_scratch_space copies) and now sits close to the page allocator's 4 MiB
> contiguous allocation limit. Its actual size is not fixed by the source
> alone, it also depends on the compiler and the .configk, so it can
> easily cross 4 MiB, e.g. with a newer GCC or a config change, and once it
> does dc_create() fails.
>
> dc_create() allocates it with kzalloc(). Once struct dc exceeds 4 MiB the
> request is rounded up to order 11 (8 MiB), which is above MAX_PAGE_ORDER,
> so the page allocator warns and returns NULL. dc_create() then fails, DM
> init fails and amdgpu probe aborts with -EINVAL:
>
> WARNING: mm/page_alloc.c:5197 at __alloc_frozen_pages_noprof+0x2f9/0x380
> RSI: ...000b RBP: ...000b <- order = 11 (8 MiB)
> __kmalloc_large_noprof+0x1e/0xc0
> dc_create+0x38/0x660 [amdgpu]
> amdgpu_dm_init+0x2d9/0x510 [amdgpu]
> dm_hw_init+0x1b/0x90 [amdgpu]
> amdgpu 0000:03:00.0: hw_init of IP block <dm> failed -22
> amdgpu 0000:03:00.0: probe with driver amdgpu failed with error -22
>
> struct dc is software only state, never DMAed and only kept as an opaque
> pointer, so it needs no physically contiguous memory. Use kvzalloc()/
> kvfree() so it falls back to vmalloc(), removing the dependency on
> MAX_PAGE_ORDER. The underlying bloat of struct dc should be addressed
> separately.
>
Cc: stable@vger.kernel.org
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5406
> Signed-off-by: Honglei Huang <honghuan@amd.com>
> ---
> drivers/gpu/drm/amd/display/dc/core/dc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
> index b3530fbf32f..65bd927435e 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
> @@ -1507,7 +1507,7 @@ static void disable_vbios_mode_if_required(
>
> struct dc *dc_create(const struct dc_init_data *init_params)
> {
> - struct dc *dc = kzalloc_obj(*dc);
> + struct dc *dc = kvzalloc_obj(*dc);
> unsigned int full_pipe_count;
>
> if (!dc)
> @@ -1555,7 +1555,7 @@ struct dc *dc_create(const struct dc_init_data *init_params)
>
> destruct_dc:
> dc_destruct(dc);
> - kfree(dc);
> + kvfree(dc);
> return NULL;
> }
>
> @@ -1604,7 +1604,7 @@ void dc_deinit_callbacks(struct dc *dc)
> void dc_destroy(struct dc **dc)
> {
> dc_destruct(*dc);
> - kfree(*dc);
> + kvfree(*dc);
> *dc = NULL;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-23 14:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 6:56 [PATCH] drm/amd/display: use kvzalloc to allocate struct dc Honglei Huang
2026-06-23 14:08 ` Mario Limonciello
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.