* [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO
@ 2026-03-10 4:24 Calvin Owens
2026-03-10 5:54 ` Calvin Owens
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Calvin Owens @ 2026-03-10 4:24 UTC (permalink / raw)
To: linux-kernel
Cc: dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung,
Dan Wheeler, Alex Deucher, Harry Wentland, Leo Li,
Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter,
llvm
Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP
footer size") introduced a use of an uninitialized stack variable
in dm_dmub_sw_init() (region_params.bss_data_size).
Interestingly, this seems to cause no issue on normal kernels. But when
full LTO is enabled, it causes the compiler to "optimize" out huge
swaths of amdgpu initialization code, and the driver is unusable:
amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00
amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5
amdgpu 0000:03:00.0: amdgpu_device_ip_init failed
amdgpu 0000:03:00.0: Fatal error during GPU init
It surprises me that neither gcc nor clang emit a warning about this: I
only found it by bisecting the LTO breakage.
Fix by using the old value for region_params.bss_data_size in place of
the uninitialized reference, which makes amdgpu work with LTO again.
Fixes: e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size")
Signed-off-by: Calvin Owens <calvin@wbinvd.org>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b3d6f2cd8ab6..e69e61163ae9 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2554,7 +2554,7 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)
fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data +
le32_to_cpu(hdr->header.ucode_array_offset_bytes) +
PSP_HEADER_BYTES_256;
- fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data +
+ fw_meta_info_params.fw_bss_data = le32_to_cpu(hdr->bss_data_bytes) ? adev->dm.dmub_fw->data +
le32_to_cpu(hdr->header.ucode_array_offset_bytes) +
le32_to_cpu(hdr->inst_const_bytes) : NULL;
fw_meta_info_params.custom_psp_footer_size = 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO 2026-03-10 4:24 [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO Calvin Owens @ 2026-03-10 5:54 ` Calvin Owens 2026-03-12 8:02 ` Nathan Chancellor 2026-03-12 17:13 ` [PATCH v2] drm/amd/display: Fix uninitialized variable use " Calvin Owens 2 siblings, 0 replies; 7+ messages in thread From: Calvin Owens @ 2026-03-10 5:54 UTC (permalink / raw) To: linux-kernel Cc: dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung, Dan Wheeler, Alex Deucher, Harry Wentland, Leo Li, Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter, llvm On Monday 03/09 at 21:24 -0700, Calvin Owens wrote: > Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP > footer size") introduced a use of an uninitialized stack variable > in dm_dmub_sw_init() (region_params.bss_data_size). > > Interestingly, this seems to cause no issue on normal kernels. But when > full LTO is enabled, it causes the compiler to "optimize" out huge > swaths of amdgpu initialization code, and the driver is unusable: > > amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00 > amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5 > amdgpu 0000:03:00.0: amdgpu_device_ip_init failed > amdgpu 0000:03:00.0: Fatal error during GPU init In case anybody wants to poke around, I uploaded the binaries here: https://github.com/jcalvinowens/lkml-debug/releases/tag/000001 You can see in the diff of the disassembly that the "missing" piece of dm_sw_init() reappeared after reverting e1b38572: https://github.com/jcalvinowens/lkml-debug/blob/main/amdgpu-lto/not-working-to-working.diff This is my bisect log: bad: [1f318b96cc84d7c2ab792fcc0bfd42a7ca890681] Linux 7.0-rc3 good: [05f7e89ab9731565d8a62e3b5d1ec206485eeb0b] Linux 6.19 bad: [1c2b4a4c2bcb950f182eeeb33d94b565607608cf] Merge tag 'pci-v7.0-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci good: [6589b3d76db2d6adbf8f2084c303fb24252a0dc6] Merge tag 'soc-dt-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc bad: [a60f627cf4ab474aebf15f62c55eadabab9780da] Merge tag 'amd-drm-next-6.20-2026-01-30' of https://gitlab.freedesktop.org/agd5f/linux into drm-next good: [83675851547e835c15252c601f41acf269c351d9] drm/xe: Cleanup unused header includes bad: [71573db5ad74b2087a4688cd1dda73ff082620f6] drm/amd/display: switch to drm_dbg_ macros instead of DRM_DEBUG_ variants bad: [3235a5b72317be613b69e22c3b2c9f2bec546253] drm/amdgpu: Update MES VM_CNTX_CNTL for XNACK off for GFX 12.1 bad: [e1b73b64271d706079370b58b81292dafd373163] amdkfd: remove DIQ support good: [2634ef1b8c00207dde5101e926241957aa5652b8] drm/amdkfd: Fix PTE clearing during SVM unmap on GFX 12.1 bad: [af441be8b75deb93ded51c54b9a2ba1e048b1c91] drm/amdgpu: add support for sdma v7_1 good: [69249b477b95f91e56bb19ec53707253899458c4] drm/amd/display: Move dml2_validate to the non-FPU dml2_wrapper bad: [ec62b7ded978957ec74add4c1feccc986e2baeef] drm/amdkfd: Uninitialized and Unused variables good: [c7062be3380cb20c8b1c4a935a13f1848ead0719] drm/amd/display: Correct DSC padding accounting bad: [d28e92093ceffb424b9b0e36bbd391c83b1cfe78] drm/amd/display: [FW Promotion] Release 0.1.37.0 bad: [e1b385726f7f7fc75b6cd3c2216430de8a625a2d] drm/amd/display: Add additional checks for PSP footer size first bad commit: [e1b385726f7f7fc75b6cd3c2216430de8a625a2d] drm/amd/display: Add additional checks for PSP footer size Thanks, Calvin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO 2026-03-10 4:24 [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO Calvin Owens 2026-03-10 5:54 ` Calvin Owens @ 2026-03-12 8:02 ` Nathan Chancellor 2026-03-12 16:15 ` Calvin Owens 2026-03-12 17:13 ` [PATCH v2] drm/amd/display: Fix uninitialized variable use " Calvin Owens 2 siblings, 1 reply; 7+ messages in thread From: Nathan Chancellor @ 2026-03-12 8:02 UTC (permalink / raw) To: Calvin Owens Cc: linux-kernel, dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung, Dan Wheeler, Alex Deucher, Harry Wentland, Leo Li, Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter, llvm Hi Calvin, On Mon, Mar 09, 2026 at 09:24:57PM -0700, Calvin Owens wrote: > Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP > footer size") introduced a use of an uninitialized stack variable > in dm_dmub_sw_init() (region_params.bss_data_size). > > Interestingly, this seems to cause no issue on normal kernels. But when > full LTO is enabled, it causes the compiler to "optimize" out huge > swaths of amdgpu initialization code, and the driver is unusable: Yeah, this appears to be a very unfortunate case of "clang encountered known undefined behavior and stopped code generation", which we would like to avoid but figuring out a proper upstreamable solution is hard. The most recent attempt: https://github.com/llvm/llvm-project/pull/146791 My guess is that LTO allows inlining of dmub_srv_get_fw_meta_info_from_raw_fw() into dm_dmub_sw_init(), at which point it can see that the result of accessing an uninitialized region_params.bss_data_size will be used through fw_meta_info_params.fw_bss_data and gives up generating the rest of the function. > amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00 > amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5 > amdgpu 0000:03:00.0: amdgpu_device_ip_init failed > amdgpu 0000:03:00.0: Fatal error during GPU init > > It surprises me that neither gcc nor clang emit a warning about this: I > only found it by bisecting the LTO breakage. gcc's -Wmaybe-uninitialized is disabled by default for the kernel but even enabling it with KCFLAGS does not show an instance here, which I find quite surprising... for clang, it is harder because the warning happens early in the frontend where it might not be able to track a value that well. > Fix by using the old value for region_params.bss_data_size in place of > the uninitialized reference, which makes amdgpu work with LTO again. > > Fixes: e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size") > Signed-off-by: Calvin Owens <calvin@wbinvd.org> > --- > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index b3d6f2cd8ab6..e69e61163ae9 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -2554,7 +2554,7 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) > fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data + > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > PSP_HEADER_BYTES_256; > - fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data + > + fw_meta_info_params.fw_bss_data = le32_to_cpu(hdr->bss_data_bytes) ? adev->dm.dmub_fw->data + Maybe it would be better to use fw_meta_info_params.bss_data_size instead of le32_to_cpu(hdr->bss_data_bytes)? Obviously it is the same value but it would result in a smaller change. It seems likely that this was just a copy and paste failure. > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > le32_to_cpu(hdr->inst_const_bytes) : NULL; > fw_meta_info_params.custom_psp_footer_size = 0; > -- > 2.47.3 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO 2026-03-12 8:02 ` Nathan Chancellor @ 2026-03-12 16:15 ` Calvin Owens 0 siblings, 0 replies; 7+ messages in thread From: Calvin Owens @ 2026-03-12 16:15 UTC (permalink / raw) To: Nathan Chancellor Cc: linux-kernel, dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung, Dan Wheeler, Alex Deucher, Harry Wentland, Leo Li, Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter, llvm On Thursday 03/12 at 01:02 -0700, Nathan Chancellor wrote: > Hi Calvin, > > On Mon, Mar 09, 2026 at 09:24:57PM -0700, Calvin Owens wrote: > > Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP > > footer size") introduced a use of an uninitialized stack variable > > in dm_dmub_sw_init() (region_params.bss_data_size). > > > > Interestingly, this seems to cause no issue on normal kernels. But when > > full LTO is enabled, it causes the compiler to "optimize" out huge > > swaths of amdgpu initialization code, and the driver is unusable: > > Yeah, this appears to be a very unfortunate case of "clang encountered known > undefined behavior and stopped code generation", which we would like to > avoid but figuring out a proper upstreamable solution is hard. The most > recent attempt: > > https://github.com/llvm/llvm-project/pull/146791 > > My guess is that LTO allows inlining of > dmub_srv_get_fw_meta_info_from_raw_fw() into dm_dmub_sw_init(), at which > point it can see that the result of accessing an uninitialized > region_params.bss_data_size will be used through > fw_meta_info_params.fw_bss_data and gives up generating the rest of the > function. Thanks for looking Nathan. I'll keep an eye on that and see if it's able to catch this example. I've tried to come up with a minimal reproducer, but I haven't had any luck yet (so far I always get the warning), would that be helpful at all? I put the full W=2 output for the one file here in case anyone else wants to look: https://github.com/jcalvinowens/lkml-debug/blob/main/amdgpu-lto/gcc-warns.txt https://github.com/jcalvinowens/lkml-debug/blob/main/amdgpu-lto/llvm-warns.txt Somehow 'make drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.o' doesn't work, I want to look at that later because it was mildly annoying while digging into this. > > amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00 > > amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5 > > amdgpu 0000:03:00.0: amdgpu_device_ip_init failed > > amdgpu 0000:03:00.0: Fatal error during GPU init > > > > It surprises me that neither gcc nor clang emit a warning about this: I > > only found it by bisecting the LTO breakage. > > gcc's -Wmaybe-uninitialized is disabled by default for the kernel but > even enabling it with KCFLAGS does not show an instance here, which I > find quite surprising... for clang, it is harder because the warning > happens early in the frontend where it might not be able to track a > value that well. GCC does flag what seems to me to be a real but benign warning about an ERR_PTR check that doesn't handle NULL in the same file: https://lore.kernel.org/lkml/6aaf2cf4bd19363a85f35e649685d7bdae400253.1773157137.git.calvin@wbinvd.org/ I'm also trying to find a minimal reproducer for GCC, no luck yet. > > Fix by using the old value for region_params.bss_data_size in place of > > the uninitialized reference, which makes amdgpu work with LTO again. > > > > Fixes: e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size") > > Signed-off-by: Calvin Owens <calvin@wbinvd.org> > > --- > > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > > index b3d6f2cd8ab6..e69e61163ae9 100644 > > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > > @@ -2554,7 +2554,7 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) > > fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data + > > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > > PSP_HEADER_BYTES_256; > > - fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data + > > + fw_meta_info_params.fw_bss_data = le32_to_cpu(hdr->bss_data_bytes) ? adev->dm.dmub_fw->data + > > Maybe it would be better to use fw_meta_info_params.bss_data_size > instead of le32_to_cpu(hdr->bss_data_bytes)? Obviously it is the same > value but it would result in a smaller change. It seems likely that this > was just a copy and paste failure. Agreed. That ends up being almost self evidently correct if I force git to add an extra context line with the assignment, I always forget I can do that: diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index b3d6f2cd8ab6..0d1c772ef713 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2553,9 +2553,9 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) fw_meta_info_params.bss_data_size = le32_to_cpu(hdr->bss_data_bytes); fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes) + PSP_HEADER_BYTES_256; - fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data + + fw_meta_info_params.fw_bss_data = fw_meta_info_params.bss_data_size ? adev->dm.dmub_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes) + le32_to_cpu(hdr->inst_const_bytes) : NULL; fw_meta_info_params.custom_psp_footer_size = 0; I'll send a v2 in a little bit. Thanks, Calvin > > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > > le32_to_cpu(hdr->inst_const_bytes) : NULL; > > fw_meta_info_params.custom_psp_footer_size = 0; > > -- > > 2.47.3 > > ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2] drm/amd/display: Fix uninitialized variable use which breaks full LTO 2026-03-10 4:24 [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO Calvin Owens 2026-03-10 5:54 ` Calvin Owens 2026-03-12 8:02 ` Nathan Chancellor @ 2026-03-12 17:13 ` Calvin Owens 2026-03-12 20:31 ` Harry Wentland 2026-03-12 20:37 ` Nathan Chancellor 2 siblings, 2 replies; 7+ messages in thread From: Calvin Owens @ 2026-03-12 17:13 UTC (permalink / raw) To: linux-kernel Cc: dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung, Dan Wheeler, Alex Deucher, Harry Wentland, Leo Li, Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter, llvm Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size") introduced a use of an uninitialized stack variable in dm_dmub_sw_init() (region_params.bss_data_size). Interestingly, this seems to cause no issue on normal kernels. But when full LTO is enabled, it causes the compiler to "optimize" out huge swaths of amdgpu initialization code, and the driver is unusable: amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00 amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5 amdgpu 0000:03:00.0: amdgpu_device_ip_init failed amdgpu 0000:03:00.0: Fatal error during GPU init It surprises me that neither gcc nor clang emit a warning about this: I only found it by bisecting the LTO breakage. Fix by using the bss_data_size field from fw_meta_info_params, as was presumably intended. Fixes: e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size") Signed-off-by: Calvin Owens <calvin@wbinvd.org> --- Changes in v2: * Use fw_meta_info_params.bss_data_size instead of repeating the load from the payload header field [Nathan] drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index b3d6f2cd8ab6..0d1c772ef713 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2553,9 +2553,9 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) fw_meta_info_params.bss_data_size = le32_to_cpu(hdr->bss_data_bytes); fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes) + PSP_HEADER_BYTES_256; - fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data + + fw_meta_info_params.fw_bss_data = fw_meta_info_params.bss_data_size ? adev->dm.dmub_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes) + le32_to_cpu(hdr->inst_const_bytes) : NULL; fw_meta_info_params.custom_psp_footer_size = 0; -- 2.47.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/amd/display: Fix uninitialized variable use which breaks full LTO 2026-03-12 17:13 ` [PATCH v2] drm/amd/display: Fix uninitialized variable use " Calvin Owens @ 2026-03-12 20:31 ` Harry Wentland 2026-03-12 20:37 ` Nathan Chancellor 1 sibling, 0 replies; 7+ messages in thread From: Harry Wentland @ 2026-03-12 20:31 UTC (permalink / raw) To: Calvin Owens, linux-kernel Cc: dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung, Dan Wheeler, Alex Deucher, Leo Li, Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter, llvm On 2026-03-12 13:13, Calvin Owens wrote: > Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP > footer size") introduced a use of an uninitialized stack variable > in dm_dmub_sw_init() (region_params.bss_data_size). > > Interestingly, this seems to cause no issue on normal kernels. But when > full LTO is enabled, it causes the compiler to "optimize" out huge > swaths of amdgpu initialization code, and the driver is unusable: > > amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00 > amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5 > amdgpu 0000:03:00.0: amdgpu_device_ip_init failed > amdgpu 0000:03:00.0: Fatal error during GPU init > > It surprises me that neither gcc nor clang emit a warning about this: I > only found it by bisecting the LTO breakage. > > Fix by using the bss_data_size field from fw_meta_info_params, as was > presumably intended. > > Fixes: e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size") > Signed-off-by: Calvin Owens <calvin@wbinvd.org> Reviewed-by: Harry Wentland <harry.wentland@amd.com> Harry > --- > Changes in v2: > * Use fw_meta_info_params.bss_data_size instead of repeating the load > from the payload header field [Nathan] > > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index b3d6f2cd8ab6..0d1c772ef713 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -2553,9 +2553,9 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) > fw_meta_info_params.bss_data_size = le32_to_cpu(hdr->bss_data_bytes); > fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data + > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > PSP_HEADER_BYTES_256; > - fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data + > + fw_meta_info_params.fw_bss_data = fw_meta_info_params.bss_data_size ? adev->dm.dmub_fw->data + > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > le32_to_cpu(hdr->inst_const_bytes) : NULL; > fw_meta_info_params.custom_psp_footer_size = 0; > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] drm/amd/display: Fix uninitialized variable use which breaks full LTO 2026-03-12 17:13 ` [PATCH v2] drm/amd/display: Fix uninitialized variable use " Calvin Owens 2026-03-12 20:31 ` Harry Wentland @ 2026-03-12 20:37 ` Nathan Chancellor 1 sibling, 0 replies; 7+ messages in thread From: Nathan Chancellor @ 2026-03-12 20:37 UTC (permalink / raw) To: Calvin Owens Cc: linux-kernel, dri-devel, amd-gfx, Charlene Liu, Ovidiu Bunea, Alex Hung, Dan Wheeler, Alex Deucher, Harry Wentland, Leo Li, Rodrigo Siqueira, Christian Koenig, David Airlie, Simona Vetter, llvm On Thu, Mar 12, 2026 at 10:13:34AM -0700, Calvin Owens wrote: > Commit e1b385726f7f ("drm/amd/display: Add additional checks for PSP > footer size") introduced a use of an uninitialized stack variable > in dm_dmub_sw_init() (region_params.bss_data_size). > > Interestingly, this seems to cause no issue on normal kernels. But when > full LTO is enabled, it causes the compiler to "optimize" out huge > swaths of amdgpu initialization code, and the driver is unusable: > > amdgpu 0000:03:00.0: [drm] Loading DMUB firmware via PSP: version=0x07002F00 > amdgpu 0000:03:00.0: sw_init of IP block <dm> failed 5 > amdgpu 0000:03:00.0: amdgpu_device_ip_init failed > amdgpu 0000:03:00.0: Fatal error during GPU init > > It surprises me that neither gcc nor clang emit a warning about this: I > only found it by bisecting the LTO breakage. > > Fix by using the bss_data_size field from fw_meta_info_params, as was > presumably intended. > > Fixes: e1b385726f7f ("drm/amd/display: Add additional checks for PSP footer size") > Signed-off-by: Calvin Owens <calvin@wbinvd.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> > --- > Changes in v2: > * Use fw_meta_info_params.bss_data_size instead of repeating the load > from the payload header field [Nathan] > > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index b3d6f2cd8ab6..0d1c772ef713 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -2553,9 +2553,9 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) > fw_meta_info_params.bss_data_size = le32_to_cpu(hdr->bss_data_bytes); > fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data + > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > PSP_HEADER_BYTES_256; > - fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data + > + fw_meta_info_params.fw_bss_data = fw_meta_info_params.bss_data_size ? adev->dm.dmub_fw->data + > le32_to_cpu(hdr->header.ucode_array_offset_bytes) + > le32_to_cpu(hdr->inst_const_bytes) : NULL; > fw_meta_info_params.custom_psp_footer_size = 0; > > -- > 2.47.3 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-12 20:37 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-10 4:24 [REGRESSION][PATCH] drm/amd/display: Fix uninitialized variable which breaks full LTO Calvin Owens 2026-03-10 5:54 ` Calvin Owens 2026-03-12 8:02 ` Nathan Chancellor 2026-03-12 16:15 ` Calvin Owens 2026-03-12 17:13 ` [PATCH v2] drm/amd/display: Fix uninitialized variable use " Calvin Owens 2026-03-12 20:31 ` Harry Wentland 2026-03-12 20:37 ` Nathan Chancellor
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox