Skip to content

Commit d6d1ad3

Browse files
Akhil P Oommenrobclark
authored andcommitted
drm/msm/a6xx: Fix excessive stack usage
Clang-19 and above sometimes end up with multiple copies of the large a6xx_hfi_msg_bw_table structure on the stack. The problem is that a6xx_hfi_send_bw_table() calls a number of device specific functions to fill the structure, but these create another copy of the structure on the stack which gets copied to the first. If the functions get inlined, that busts the warning limit: drivers/gpu/drm/msm/adreno/a6xx_hfi.c:631:12: error: stack frame size (1032) exceeds limit (1024) in 'a6xx_hfi_send_bw_table' [-Werror,-Wframe-larger-than] Fix this by kmalloc-ating struct a6xx_hfi_msg_bw_table instead of using the stack. Also, use this opportunity to skip re-initializing this table to optimize gpu wake up latency. Cc: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Akhil P Oommen <quic_akhilpo@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/621814/ Signed-off-by: Rob Clark <robdclark@chromium.org>
1 parent 8f32ddd commit d6d1ad3

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

drivers/gpu/drm/msm/adreno/a6xx_gmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct a6xx_gmu {
9999
struct completion pd_gate;
100100

101101
struct qmp *qmp;
102+
struct a6xx_hfi_msg_bw_table *bw_table;
102103
};
103104

104105
static inline u32 gmu_read(struct a6xx_gmu *gmu, u32 offset)

drivers/gpu/drm/msm/adreno/a6xx_hfi.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -661,34 +661,44 @@ static void a6xx_build_bw_table(struct a6xx_hfi_msg_bw_table *msg)
661661

662662
static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu)
663663
{
664-
struct a6xx_hfi_msg_bw_table msg = { 0 };
664+
struct a6xx_hfi_msg_bw_table *msg;
665665
struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu);
666666
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
667667

668+
if (gmu->bw_table)
669+
goto send;
670+
671+
msg = devm_kzalloc(gmu->dev, sizeof(*msg), GFP_KERNEL);
672+
if (!msg)
673+
return -ENOMEM;
674+
668675
if (adreno_is_a618(adreno_gpu))
669-
a618_build_bw_table(&msg);
676+
a618_build_bw_table(msg);
670677
else if (adreno_is_a619(adreno_gpu))
671-
a619_build_bw_table(&msg);
678+
a619_build_bw_table(msg);
672679
else if (adreno_is_a640_family(adreno_gpu))
673-
a640_build_bw_table(&msg);
680+
a640_build_bw_table(msg);
674681
else if (adreno_is_a650(adreno_gpu))
675-
a650_build_bw_table(&msg);
682+
a650_build_bw_table(msg);
676683
else if (adreno_is_7c3(adreno_gpu))
677-
adreno_7c3_build_bw_table(&msg);
684+
adreno_7c3_build_bw_table(msg);
678685
else if (adreno_is_a660(adreno_gpu))
679-
a660_build_bw_table(&msg);
686+
a660_build_bw_table(msg);
680687
else if (adreno_is_a663(adreno_gpu))
681-
a663_build_bw_table(&msg);
688+
a663_build_bw_table(msg);
682689
else if (adreno_is_a690(adreno_gpu))
683-
a690_build_bw_table(&msg);
690+
a690_build_bw_table(msg);
684691
else if (adreno_is_a730(adreno_gpu))
685-
a730_build_bw_table(&msg);
692+
a730_build_bw_table(msg);
686693
else if (adreno_is_a740_family(adreno_gpu))
687-
a740_build_bw_table(&msg);
694+
a740_build_bw_table(msg);
688695
else
689-
a6xx_build_bw_table(&msg);
696+
a6xx_build_bw_table(msg);
697+
698+
gmu->bw_table = msg;
690699

691-
return a6xx_hfi_send_msg(gmu, HFI_H2F_MSG_BW_TABLE, &msg, sizeof(msg),
700+
send:
701+
return a6xx_hfi_send_msg(gmu, HFI_H2F_MSG_BW_TABLE, gmu->bw_table, sizeof(*(gmu->bw_table)),
692702
NULL, 0);
693703
}
694704

0 commit comments

Comments
 (0)