Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2586822lqb; Tue, 28 May 2024 04:53:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1WZ0mORRdK42m/NX///M8ekfC2+wyx1cX4PDcUEeg1U3Gds8OJLOYBYWd/R9BvcHNeOesengSr9aQTdCW0clDqYrHhKxr55jHw+xQbQ== X-Google-Smtp-Source: AGHT+IGaJKlRkKLr2BV/e+R9zVlbu9OFXgVy+c7mcjkNqxWqkqTAuiVuwwRh//Qx/Ttw4AtAETDx X-Received: by 2002:a05:620a:1023:b0:792:bbf3:3acf with SMTP id af79cd13be357-794ab09a00emr1283656085a.44.1716897218373; Tue, 28 May 2024 04:53:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716897218; cv=pass; d=google.com; s=arc-20160816; b=BVOfhi5FUPeE3Bp305HgZNXul/1dCywHJhdUCwVI6XPYSRU0DnGdzviKzOe6Dl5mnM ViiVrbNSN347o7ezE1PKx9Ez2LN2eQE61uJzEBNK6J5gOHj2577JSktcqO2gkzMtL+CS 6WKnIMMtos19HT3ZIWz7ErJAFfzF0N1AHFnuAu3xq+RAxjyjYE72aQ/xUFq75O7ga6Do Lz/JaqJzJlDVfYmnLKFXSht9lb6/dn67eFoc57C5v9cgFHizOaCItvEAE2NYLwGiYZaG sUECHy3wCBUy9GM6ivGAVh+75iAhAUB5OkM/kM2TVTi2IQDMLoWv9hVSg9slPdjdMo+s Oxsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jSL/YpKUNmGEkCEAhgauN2BiCCdlW4CHfzWqNU/BM6A=; fh=qFThZXroa1nNQKicNX/NzIlPMLpmToLevchUpb9c44c=; b=hqOCKvgWBXexd5NFTXocI+xzgogMLMAdWrlENIW7g5HUeMFw8buH5E68edJCjbATpu 2KrGskp6Z6xJJ2WL+QQVYPjM5ikg3TaFnT/lOxF4d7EwoEKzrm2aBkYtntT6ENlk2tcC RD/wBAKH0UH0jDEUM33HdwSIRBgpHLb14uMLqf4yUAUyusDPqyU6seKYUiuWLY1YomFU gXMo8dVE3vXSwe4gByo99VXceWUDC94tv4yuvAxtWAJ2I44Mi07KM8NwGQZuuDJIYnV7 Ldn4CzeBvEG6+yFVN4FOWbbiaDWaYgOgeaQxT9vT7PEYZvKAQaspIWBsUxeLRvjL76Cv rX3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZNC4Ir/e"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abd12cc9si971205285a.313.2024.05.28.04.53.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 04:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZNC4Ir/e"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3579B1C23182 for ; Tue, 28 May 2024 11:53:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF52316C86A; Tue, 28 May 2024 11:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZNC4Ir/e" 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 F15DA16C841 for ; Tue, 28 May 2024 11:53:12 +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=1716897193; cv=none; b=fayot+Of1xbW2ws0+KRrTYnCKtvYuXQg9ZPQfmWRc5AiQmpV+B2pHIlDdY6R1F8NDUI5yIFrZrZX7a7YIWzMFBd1je+rrheoAZ+F/2osZhClCBLEx2ilsdBotw2XEU32TSKClgAGd7g9bz5fW/gpYAIVh5mLPl5XW4TwgdvpIAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716897193; c=relaxed/simple; bh=bKf/VdtSEftKO+AsBfiSV+8sd0HFatxAnVyEq6Z9M4Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DxSqlJYnMJFRl9nt1XimqI6SycjCED5q3ee58TNnCZKC6b7f6roEQPhwYas+01hlWSdkly+CH5dbS06K3nbViHNwgDXKHa+IR9NV3N6Bms6j69iKMSlVTe1oMtqgzgzfeCDKbzLbW/5qC0Fo3Ns8fGcvSm0iXPsLRMQ7mMUuSYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZNC4Ir/e; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3F4CC3277B; Tue, 28 May 2024 11:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716897192; bh=bKf/VdtSEftKO+AsBfiSV+8sd0HFatxAnVyEq6Z9M4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZNC4Ir/ejdbgc2zVSO/0Euynl1TfeqW5N696yFBfT4dDcfip39yX6QPxJ00TUJkOs FMKCvdE/BRkbuMtBFRaiKCpJksPsttWGzlM3JWobwTb2rvWk/1IKoqk6VxuW0KQ3aH wucoYK4mgGr8xqlOaxB6Rb4wPz0tLLtwwmy6vkkne/5rGzBGs9V9UZUyYU5pd77DYj gzZYpDXDnw1+GiB3amV4PGKRV28a5qg2yZd0KNq+EDTUC0/xhSKJoxj5s4uBqBobP3 wB+KuFc7U6qxbgWHlLbcJ9ae7st066GhtOW8AisHRGtHtJ4Vmayq9f4hK2WO8EpnLL zH9c5MICNwbyQ== From: Arnd Bergmann To: Harry Wentland , Leo Li , Rodrigo Siqueira Cc: Arnd Bergmann , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Charlene Liu , Hamza Mahfooz , Nicholas Kazlauskas , Sung Joon Kim , Taimur Hassan , Fangzhi Zuo , Swapnil Patel , Qingqing Zhuo , Roman Li , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] drm/amd/display: Move 'struct scaler_data' off stack Date: Tue, 28 May 2024 13:51:21 +0200 Message-Id: <20240528115146.2870032-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240528115146.2870032-1-arnd@kernel.org> References: <20240528115146.2870032-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann The scaler_data structure is implicitly copied onto the stack twice by being returned from a function. This is usually a bad idea, but it was not flagged by the compiler until a recent addition that pushed it over the 1024 byte function stack limit: drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_translation_helper.c: In function 'populate_dml_plane_cfg_from_plane_state': drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_translation_helper.c:1075:1: error: the frame size of 1032 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Use an explicit kzalloc() and memcpy() instead here to keep it off the stack. Fixes: 00c391102abc ("drm/amd/display: Add misc DC changes for DCN401") Fixes: 7966f319c66d ("drm/amd/display: Introduce DML2") Signed-off-by: Arnd Bergmann --- .../display/dc/dml2/dml2_translation_helper.c | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c index 705985d3f407..c04ebf5434c9 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c @@ -927,7 +927,7 @@ static void populate_dml_surface_cfg_from_plane_state(enum dml_project_id dml2_p } } -static struct scaler_data get_scaler_data_for_plane(const struct dc_plane_state *in, struct dc_state *context) +static void get_scaler_data_for_plane(const struct dc_plane_state *in, struct dc_state *context, struct scaler_data *out) { int i; struct pipe_ctx *temp_pipe = &context->res_ctx.temp_pipe; @@ -948,7 +948,7 @@ static struct scaler_data get_scaler_data_for_plane(const struct dc_plane_state } ASSERT(i < MAX_PIPES); - return temp_pipe->plane_res.scl_data; + memcpy(out, &temp_pipe->plane_res.scl_data, sizeof(*out)); } static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned int location, const struct dc_stream_state *in) @@ -1007,27 +1007,31 @@ static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned static void populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st *out, unsigned int location, const struct dc_plane_state *in, struct dc_state *context) { - const struct scaler_data scaler_data = get_scaler_data_for_plane(in, context); + struct scaler_data *scaler_data = kzalloc(sizeof(*scaler_data), GFP_KERNEL); + if (!scaler_data) + return; + + get_scaler_data_for_plane(in, context, scaler_data); out->CursorBPP[location] = dml_cur_32bit; out->CursorWidth[location] = 256; out->GPUVMMinPageSizeKBytes[location] = 256; - out->ViewportWidth[location] = scaler_data.viewport.width; - out->ViewportHeight[location] = scaler_data.viewport.height; - out->ViewportWidthChroma[location] = scaler_data.viewport_c.width; - out->ViewportHeightChroma[location] = scaler_data.viewport_c.height; - out->ViewportXStart[location] = scaler_data.viewport.x; - out->ViewportYStart[location] = scaler_data.viewport.y; - out->ViewportXStartC[location] = scaler_data.viewport_c.x; - out->ViewportYStartC[location] = scaler_data.viewport_c.y; + out->ViewportWidth[location] = scaler_data->viewport.width; + out->ViewportHeight[location] = scaler_data->viewport.height; + out->ViewportWidthChroma[location] = scaler_data->viewport_c.width; + out->ViewportHeightChroma[location] = scaler_data->viewport_c.height; + out->ViewportXStart[location] = scaler_data->viewport.x; + out->ViewportYStart[location] = scaler_data->viewport.y; + out->ViewportXStartC[location] = scaler_data->viewport_c.x; + out->ViewportYStartC[location] = scaler_data->viewport_c.y; out->ViewportStationary[location] = false; - out->ScalerEnabled[location] = scaler_data.ratios.horz.value != dc_fixpt_one.value || - scaler_data.ratios.horz_c.value != dc_fixpt_one.value || - scaler_data.ratios.vert.value != dc_fixpt_one.value || - scaler_data.ratios.vert_c.value != dc_fixpt_one.value; + out->ScalerEnabled[location] = scaler_data->ratios.horz.value != dc_fixpt_one.value || + scaler_data->ratios.horz_c.value != dc_fixpt_one.value || + scaler_data->ratios.vert.value != dc_fixpt_one.value || + scaler_data->ratios.vert_c.value != dc_fixpt_one.value; /* Current driver code base uses LBBitPerPixel as 57. There is a discrepancy * from the HW/DML teams about this value. Initialize LBBitPerPixel with the @@ -1043,25 +1047,25 @@ static void populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st *out out->VRatioChroma[location] = 1; } else { /* Follow the original dml_wrapper.c code direction to fix scaling issues */ - out->HRatio[location] = (dml_float_t)scaler_data.ratios.horz.value / (1ULL << 32); - out->HRatioChroma[location] = (dml_float_t)scaler_data.ratios.horz_c.value / (1ULL << 32); - out->VRatio[location] = (dml_float_t)scaler_data.ratios.vert.value / (1ULL << 32); - out->VRatioChroma[location] = (dml_float_t)scaler_data.ratios.vert_c.value / (1ULL << 32); + out->HRatio[location] = (dml_float_t)scaler_data->ratios.horz.value / (1ULL << 32); + out->HRatioChroma[location] = (dml_float_t)scaler_data->ratios.horz_c.value / (1ULL << 32); + out->VRatio[location] = (dml_float_t)scaler_data->ratios.vert.value / (1ULL << 32); + out->VRatioChroma[location] = (dml_float_t)scaler_data->ratios.vert_c.value / (1ULL << 32); } - if (!scaler_data.taps.h_taps) { + if (!scaler_data->taps.h_taps) { out->HTaps[location] = 1; out->HTapsChroma[location] = 1; } else { - out->HTaps[location] = scaler_data.taps.h_taps; - out->HTapsChroma[location] = scaler_data.taps.h_taps_c; + out->HTaps[location] = scaler_data->taps.h_taps; + out->HTapsChroma[location] = scaler_data->taps.h_taps_c; } - if (!scaler_data.taps.v_taps) { + if (!scaler_data->taps.v_taps) { out->VTaps[location] = 1; out->VTapsChroma[location] = 1; } else { - out->VTaps[location] = scaler_data.taps.v_taps; - out->VTapsChroma[location] = scaler_data.taps.v_taps_c; + out->VTaps[location] = scaler_data->taps.v_taps; + out->VTapsChroma[location] = scaler_data->taps.v_taps_c; } out->SourceScan[location] = (enum dml_rotation_angle)in->rotation; @@ -1072,6 +1076,8 @@ static void populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st *out out->DynamicMetadataTransmittedBytes[location] = 0; out->NumberOfCursors[location] = 1; + + kfree(scaler_data); } static unsigned int map_stream_to_dml_display_cfg(const struct dml2_context *dml2, -- 2.39.2