From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54D5037DE84; Thu, 12 Mar 2026 20:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773347866; cv=none; b=BaGRprIhxB5ANEMcGpjTFTCqqvc7jHoT5LYM9FYDbdhC87vqWemcNhSm3vHa8PDbZXS9XBKXZuXuo6HHFe3uH9sMMWDJXc6jGbXVoXEQXFJytaPQSvOR6+REYSNhoSx0O9WJgXZ8i08vJM0/eXGEhct42Bn/n64XYAQIVV5fMvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773347866; c=relaxed/simple; bh=Hlj3wUVDqV3lGFj/UpEgAg7uNK/MNg5jI7SSa9ZuiSI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KQOF/LRlI2R/+XMb08LF2D43gfmVuRRIKcpTd/YmInsqynOoE7NWoB3u92Eym7RjvuWN/iVWHTtG72sdD4SQiV6LVp9g6zMAYb8pf/OJaeU517IfPyU/hVVb5nQ3y9tDXoeAiLSlRsM0IfWWjf+SKl7DCGX71jTcc5KgltIIcQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C/QLezoJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C/QLezoJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA7CC4CEF7; Thu, 12 Mar 2026 20:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773347866; bh=Hlj3wUVDqV3lGFj/UpEgAg7uNK/MNg5jI7SSa9ZuiSI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C/QLezoJFTZ2W1UxtqdQN5LK1EmIN7m6I0wcGmma+62apeVCvv6OTk8lUKDGL9Bck SKtnnR1IeNSiM4EoGP43LJ4XmGA9laBiUxLUl3a0vYozZtSUyfotxBycyYLq1pTKrA sceSRw3irBaavRL6Nb6Ut9H8v6XADlw1FEmMrdgAXHRwtgoo+NRsY1TdTWkOgYX/Sf X153gd+D+ZnSA02cvaPWrLunOnHMqfkQaGnT/3jvubTyanCyFBUa/kbSS/GaCft+Ua Ztr0K958uKpOlUYe3bLsvCPDteIR8aJbKle7G7BBINtEkDbXFNvsoYLZ2wFMbmAdlz jljSLSlzkgQ4g== Date: Thu, 12 Mar 2026 13:37:40 -0700 From: Nathan Chancellor To: Calvin Owens Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Charlene Liu , Ovidiu Bunea , Alex Hung , Dan Wheeler , Alex Deucher , Harry Wentland , Leo Li , Rodrigo Siqueira , Christian Koenig , David Airlie , Simona Vetter , llvm@lists.linux.dev Subject: Re: [PATCH v2] drm/amd/display: Fix uninitialized variable use which breaks full LTO Message-ID: <20260312203740.GA2747807@ax162> References: Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 Reviewed-by: Nathan Chancellor > --- > 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 > >