From patchwork Wed Jan 8 13:51:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 182756 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp3121516ile; Sun, 12 Jan 2020 08:05:06 -0800 (PST) X-Google-Smtp-Source: APXvYqz1R7IyoZp59IOmzkqRT8YASvEyojXcd1gzA141GytlGXjgbktb1M65sqsAtpubl0Zbm9Rv X-Received: by 2002:a63:289:: with SMTP id 131mr16713096pgc.149.1578845106531; Sun, 12 Jan 2020 08:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578845106; cv=none; d=google.com; s=arc-20160816; b=bLd/WG3uS1r5wQ04MctbAkJCV1ZQAvOvG1zU0zCIIlRhgnNyJ88rNG/k0bLtajcTgx +ifxvIotJCDuAzcUcBEhBkkO0+3WPvdkZ4IOtNtUsxR1FrxndH9YYoCzJseqh1fGzcnl mCH+CwoAdsraRmtPsbKHKYfDT0EOqQPvdR1pw74z6R/pDoYfaJf+IDy2dTOtK8TFxHLv 2H0kwbYg01RMQ10SeBn/3WMf7L7XqwC/FHI96WhZ7/n6AEKhKAC6zC9Tb9v6/ZTACrAb OCpNr5/AhKXa1EhMnZvwneP4pKyuLIuj7mgy/NRpZQovHk7/a93XaKebzkte/lKlrMvW FVFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :delivered-to; bh=nMcAfyj8D7RLNa4iB131BKl9xU6WpUQ+57+hdj+rpbs=; b=uoDuGa5J/M9M6rbW3JfGt0CfGqvKAf+RIQs6Qe2g/m5urEMPhsPWHBlhtWGWWnwUzi VYHRO6CPN/Z4Hjw5UcCRSirD1jLpNEVl/urPRVj2J4ajrX3HEnjQxAlQYZpwjoGr5HkV e1oOiTUxgxE/Kk68nDvFIzRcRiCS1GSIsvxx0BePbyT6TCGlw5nK42YaPWrrzD/p1mb+ rvWjLXEZg+cc7kmmroWV6M0bD7KxvlcVzoKEUXhDvevHXAAEf/gcE/+ERnMrUT/lKIwP oFKBe6B1XPihCcBGpktHqwZ9s1WGOCka7oZiOve3syJpxFivetzZr0hDtVX6bTFShtwm Zqew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 41si9499432ple.230.2020.01.12.08.05.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 08:05:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 604D66E2EC; Wed, 8 Jan 2020 13:56:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 314 seconds by postgrey-1.36 at gabe; Wed, 08 Jan 2020 13:56:48 UTC Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D6B16E2EC for ; Wed, 8 Jan 2020 13:56:48 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1M1HmG-1irvZ64Bre-002q6O; Wed, 08 Jan 2020 14:51:19 +0100 From: Arnd Bergmann To: Thierry Reding , David Airlie , Daniel Vetter Subject: [PATCH] [v2] drm: panel: fix excessive stack usage in td028ttec1_prepare Date: Wed, 8 Jan 2020 14:51:05 +0100 Message-Id: <20200108135116.3687988-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:tKeoXcUsVKacqijm/XBhh86H/1egpokkSRB3oJsHcu9HgP2Y928 1GSfviPvOtLi8YZQaeX23+XqClPiJrywRCkJJRGjf8vAfQfiopAva7YFo0tnacKJDhyia6v nYYGyu/22VW3xwc/I5Kcaf1stwZOTbn9Uk/fdCdpa1CSzmYXbgEVMI+3dfKJEF4pjqd14+w b59uP2AOjmLkOyP7/qYkg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:rP9NgrqvnYc=:2+J0J2APKPEoDIVOqsFq5g 4lsM4D/YW2vmYAHacrCc9Y2cPHGVbkhgf5IsF0oxrmmIfb89ObfFjXcP8lHGfhzA7/vFV7ubB DakuJyoOpBnJ+MBG6Qg3w8Q9js5yndpBbB+PqaxBjd35XPkWy19HKlhAqknpOQoozQTUIUNMs OEDOaUm7d9JxlhFu2PxAO0po/07MrOa9z8OOghLGjrEMBN45T+ZhUEMz9E69xihELY/l2EWxI lw7AoFO3u3QltJQpWSSf2ldaF0uHr613npVqNPoyoU8POhEElyRizgEK1U0T2J6IKtR+IOdUc yiL76TD4AS081iWXgLx9BroZG+tXXLJFTmprDky6JYoiy+1Rk9W5bkYVNAmRl1IDofZwCor3j JbschIZsd+C7/j9hGHRJl2WVIZ9Z+4S2o91VGbsDZzABKMNhU0TTe5Bh09bFULQq7khP8Ww04 hcBLQ6213mBQ78qP+H2ZKIwkc4FU1crv/DTPAJs9PIG83cM75YAtnP89uW4GaoqenagzTUTsm DGvxFmbdmP3mXe8NXhjUTaz0MSknRdpg0kfsK50qfHWY3toJ6hCmErA4vBcNhS1EKUDa71JSt Ln7+RW8+8r0ZWIK22NIbs9E1WE20w4mTjjsXlEdQ7JzNj5Wl2Lrbe2ZTb83jOzVTNa7kfmLSZ iaJPKgA9wE6hSWViNl/+FaJqESfT/zrFxvdx+wDp4nlkM3bLfEncsEcu/1YKvhxkqQz6zYV9k ZWtiWvAM7W3TJPQUv1NnvxeLnO5goXCIs6xoH76JT9wnaulohMoOkvP/wbfL2v8AQu40HjZ9h eexqRbdH4Ajr41EcqukK35QQBtgnW7AUAFjXJRnzDOen5a7DT9yvrJs+ly6uE1NsbCknaRVM2 hBQlmsp/7PQwUu2WqEdw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Natalenko , Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , Laurent Pinchart , Boris Brezillon , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" With gcc -O3 in combination with the structleak plug, the compiler can inline very aggressively, leading to rather large stack usage: drivers/gpu/drm/panel/panel-tpo-td028ttec1.c: In function 'td028ttec1_prepare': drivers/gpu/drm/panel/panel-tpo-td028ttec1.c:233:1: error: the frame size of 2768 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] } Marking jbt_reg_write_*() as noinline avoids the case where multiple instances of this function get inlined into the same stack frame and each one adds a copy of 'tx_buf'. The compiler is clearly making some bad decisions here, but I did not open a new bug report as this only happens in combination with the structleak plugin. Link: https://lore.kernel.org/lkml/CAK8P3a3jAnFZA3GFRtdYdg1-i-oih3pOQzkkrK-X3BGsFrMiZQ@mail.gmail.com/ Fixes: mmtom ("init/Kconfig: enable -O3 for all arches") Signed-off-by: Arnd Bergmann --- v2: - mark all three functions as noinlien - add code comment - add link to more detailed analysis --- drivers/gpu/drm/panel/panel-tpo-td028ttec1.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.20.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c b/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c index cf29405a2dbe..5034db8b55de 100644 --- a/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c +++ b/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c @@ -86,7 +86,12 @@ struct td028ttec1_panel { #define to_td028ttec1_device(p) container_of(p, struct td028ttec1_panel, panel) -static int jbt_ret_write_0(struct td028ttec1_panel *lcd, u8 reg, int *err) +/* + * noinline_for_stack so we don't get multiple copies of tx_buf + * on the stack in case of gcc-plugin-structleak + */ +static int noinline_for_stack +jbt_ret_write_0(struct td028ttec1_panel *lcd, u8 reg, int *err) { struct spi_device *spi = lcd->spi; u16 tx_buf = JBT_COMMAND | reg; @@ -105,7 +110,8 @@ static int jbt_ret_write_0(struct td028ttec1_panel *lcd, u8 reg, int *err) return ret; } -static int jbt_reg_write_1(struct td028ttec1_panel *lcd, +static int noinline_for_stack +jbt_reg_write_1(struct td028ttec1_panel *lcd, u8 reg, u8 data, int *err) { struct spi_device *spi = lcd->spi; @@ -128,7 +134,8 @@ static int jbt_reg_write_1(struct td028ttec1_panel *lcd, return ret; } -static int jbt_reg_write_2(struct td028ttec1_panel *lcd, +static int noinline_for_stack +jbt_reg_write_2(struct td028ttec1_panel *lcd, u8 reg, u16 data, int *err) { struct spi_device *spi = lcd->spi;