Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp162220pxx; Wed, 28 Oct 2020 01:11:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlO2c1x73mOqKGTXceaJyMKddNQaSsUrx/LPS1snvkXtiwxmVO+dn+ZRT6JNtmUN4ZZgF1 X-Received: by 2002:a17:906:2dc7:: with SMTP id h7mr6656660eji.546.1603872683967; Wed, 28 Oct 2020 01:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872683; cv=none; d=google.com; s=arc-20160816; b=HjJ6NELtQpadwXb6SdoH4H8Y3mK4fubiWVKD/jVj3zbc6SoM1YYBzBadOqNDDFTADu zDQCv1B/iF5mL82WvZAa1LIMnWfU3W7+ahP3BWftLidXxM+N/DqIA/dXllw/Xof83IU4 lTAsiwC12lA7sIz83hdY8D2ZOLeEIC9a7CcU9I7JThhJBOijXsahwG2ak5FPHB7OmqJ+ ZaPIPOpvCl3BcSNK2ZxGMOJZ3Cmdebp0M3Hp8viBtbpcfmswMfw5gli6k0Y02R3IdkVx 0SVOUBqXwZU6UuzO5jEbQ1lEXl+YAQ9fiIi4T9+c19RjPIpx7dgLmC/yDLjUdbXK0JbE b/LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zf6D3IGpLSSeZJf+Wo1AI03AxSc+8LEvkUK1IMelHwI=; b=OEzf9lQaBjd8PhIW7sSCgkmVDGtzI0yRiLghJfCuTx++6R9kIVSDDY+dqN2CgOIwxM asM1Xkjad28pxIb/sAzTBBCi12nDlLvK6EhrNnbTlt6zGizXcb4rYIWQpqDZ5WIodlgi RgcnI4DH4ZAU5Jkw4Sd9JjJr0fs27odXtdzqlXJGm7yxLpb9cNG05Ugj10fUGaw28Y8k 7/rMSJe32fUKg1/yAhDWzO0SemOIYrgsPggq7Tm8GiroxeRRldxtGAjB1PEl1yrtxdvu MSwtvk+4w7cUfXvlExbjNLsKqxyZvUtbD11wAGMdTkOad+QhZ6JLFcEh4AcchBQa1LU1 T+vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nYdmOma7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si2741759edu.169.2020.10.28.01.11.01; Wed, 28 Oct 2020 01:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nYdmOma7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504412AbgJ0N7G (ORCPT + 99 others); Tue, 27 Oct 2020 09:59:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504289AbgJ0N7C (ORCPT ); Tue, 27 Oct 2020 09:59:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D7DF21D42; Tue, 27 Oct 2020 13:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807141; bh=oj5HLCgTap0UE8B9NbqNauRQX8CuLpo1hR0Pot0m9Jg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYdmOma7w78R3AJ1eFp8kpSlfwBt8YmQuYQ8IyvsgVvWYVFvW2hD1KS2ac3qYzXGv 0+zXryaQbyjILXtPZ6GIHLa6YJ2LWIYbZaXp/84ooyrtSf1kcRz/pvU/dg0AD+kcna JyOhF8wCLCeOUDDZaUpfbruQIt0u74P/78SmYBb0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Nathan Chancellor , Miquel Raynal , Sasha Levin Subject: [PATCH 4.4 056/112] mtd: lpddr: fix excessive stack usage with clang Date: Tue, 27 Oct 2020 14:49:26 +0100 Message-Id: <20201027134903.215575613@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit 3e1b6469f8324bee5927b063e2aca30d3e56b907 ] 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 Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20200505140136.263461-1-arnd@arndb.de Signed-off-by: Sasha Levin --- drivers/mtd/lpddr/lpddr2_nvm.c | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/lpddr/lpddr2_nvm.c b/drivers/mtd/lpddr/lpddr2_nvm.c index 2342277c9bcb0..5e36366d9b36d 100644 --- a/drivers/mtd/lpddr/lpddr2_nvm.c +++ b/drivers/mtd/lpddr/lpddr2_nvm.c @@ -408,6 +408,17 @@ static int lpddr2_nvm_lock(struct mtd_info *mtd, loff_t start_add, return lpddr2_nvm_do_block_op(mtd, start_add, len, LPDDR2_NVM_LOCK); } +static const struct mtd_info lpddr2_nvm_mtd_info = { + .type = MTD_RAM, + .writesize = 1, + .flags = (MTD_CAP_NVRAM | MTD_POWERUP_LOCK), + ._read = lpddr2_nvm_read, + ._write = lpddr2_nvm_write, + ._erase = lpddr2_nvm_erase, + ._unlock = lpddr2_nvm_unlock, + ._lock = lpddr2_nvm_lock, +}; + /* * lpddr2_nvm driver probe method */ @@ -448,6 +459,7 @@ static int lpddr2_nvm_probe(struct platform_device *pdev) .pfow_base = OW_BASE_ADDRESS, .fldrv_priv = pcm_data, }; + if (IS_ERR(map->virt)) return PTR_ERR(map->virt); @@ -459,22 +471,13 @@ static int lpddr2_nvm_probe(struct platform_device *pdev) return PTR_ERR(pcm_data->ctl_regs); /* Populate mtd_info data structure */ - *mtd = (struct mtd_info) { - .dev = { .parent = &pdev->dev }, - .name = pdev->dev.init_name, - .type = MTD_RAM, - .priv = map, - .size = resource_size(add_range), - .erasesize = ERASE_BLOCKSIZE * pcm_data->bus_width, - .writesize = 1, - .writebufsize = WRITE_BUFFSIZE * pcm_data->bus_width, - .flags = (MTD_CAP_NVRAM | MTD_POWERUP_LOCK), - ._read = lpddr2_nvm_read, - ._write = lpddr2_nvm_write, - ._erase = lpddr2_nvm_erase, - ._unlock = lpddr2_nvm_unlock, - ._lock = lpddr2_nvm_lock, - }; + *mtd = lpddr2_nvm_mtd_info; + mtd->dev.parent = &pdev->dev; + mtd->name = pdev->dev.init_name; + mtd->priv = map; + mtd->size = resource_size(add_range); + mtd->erasesize = ERASE_BLOCKSIZE * pcm_data->bus_width; + mtd->writebufsize = WRITE_BUFFSIZE * pcm_data->bus_width; /* Verify the presence of the device looking for PFOW string */ if (!lpddr2_nvm_pfow_present(map)) { -- 2.25.1