From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 629C7C43461 for ; Mon, 7 Sep 2020 07:34:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33F662145D for ; Mon, 7 Sep 2020 07:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbgIGHen (ORCPT ); Mon, 7 Sep 2020 03:34:43 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:51507 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727030AbgIGHeR (ORCPT ); Mon, 7 Sep 2020 03:34:17 -0400 Received: from localhost.localdomain (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 8B79F100003; Mon, 7 Sep 2020 07:34:13 +0000 (UTC) From: Miquel Raynal To: Arnd Bergmann , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Vincenzo Aliberti , Brian Norris Cc: Richard Fontana , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] mtd: lpddr: fix excessive stack usage with clang Date: Mon, 7 Sep 2020 09:34:12 +0200 Message-Id: <20200907073412.27402-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200505140136.263461-1-arnd@arndb.de> References: MIME-Version: 1.0 X-linux-mtd-patch-notification: thanks X-linux-mtd-patch-commit: 3e1b6469f8324bee5927b063e2aca30d3e56b907 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-05-05 at 14:01:16 UTC, Arnd Bergmann wrote: > Building lpddr2_nvm with clang can result in a giant stack usage > in one function: > > drivers/mtd/lpddr/lpddr2_nvm.c:399:12: error: stack frame size of 1144 bytes in function 'lpddr2_nvm_probe' [-Werror,-Wframe-larger-than=] > > The problem is that clang decides to build a copy of the mtd_info > structure on the stack and then do a memcpy() into the actual version. It > shouldn't really do it that way, but it's not strictly a bug either. > > As a workaround, use a static const version of the structure to assign > most of the members upfront and then only set the few members that > require runtime knowledge at probe time. > > Fixes: 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories") > Signed-off-by: Arnd Bergmann > Reviewed-by: Nathan Chancellor > Acked-by: Miquel Raynal Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks. Miquel