From patchwork Mon Dec 11 12:06:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 121382 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2704237qgn; Mon, 11 Dec 2017 04:06:22 -0800 (PST) X-Google-Smtp-Source: ACJfBot5w86WRtZVCwrOtsvJmkNkPM8t2zJPS/bBlouXJsAdbyeE06uhQRNlbCLSo/bwzPfwvThH X-Received: by 10.99.107.197 with SMTP id g188mr127030pgc.295.1512993982127; Mon, 11 Dec 2017 04:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512993982; cv=none; d=google.com; s=arc-20160816; b=rnv9NLqqwEnGfz/TiynTPWDRGQv/RHCehwHPcVDImmBS/+kMgVeGc4bBcukGYqqaRc DPfDtbuD+KfyWe2yoyr68XrA6Rj0GD71Qo7s0DDcK5TLU6neIIJvth5adlHIOYnbHo8h 78kPdzR1X5a1ji/VAM72JaiHrJO6/GrWXR7qsbGsQSF7lIJ49KXiKPG++R+++DRE444l Zbo+SGxquXCMX3wAacQc4ox0DbYfsBW6i/KdQU+yRoLxjYHty2ngNFDEgotIuFJmpGSB XgYDF6GiZwUDlDpF8y/hyiJxtn9bhZeOYy9WI8ClGpyjaRLRy1aRwXaqeNLNMEiaj7gB wLSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=KE8BybFf+gWpoT/B/kfp5hAKwPX0xnojHvhzpLEuTwU=; b=KPiTUX94rXyvJrg8ii/WpChdtJE8gaUwUBzIh7tIvIo+QHgUA6ORWK9Nw+98PPMTFr p6Szq8MhVxRF3AkAXaKijaqHcyLpZP79Sa67XdL0wpijgcvuY2/9emyaFn0vyvN+sm+r d2Jdg+8zz8ENf75lZ3v9nu7cHlOJ2gRacVsVc2Uxlqt2U0jX532wCX3DbfiXiX8kRMhT 4qWP7tEV+WKjkuk0l9DmWbxw8kE5Fq+eJHRhfDknW2L66+W6bpIKdN0qOOq0sOzP6Xe1 nGkPsmKLwMkrixITt2EHYQeSdTZqoLEpjeOED9hOkkge6Kmv0cdu2bKAXQdMInszfL9C XsSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si10858257pfj.235.2017.12.11.04.06.22; Mon, 11 Dec 2017 04:06:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752685AbdLKMGU (ORCPT + 4 others); Mon, 11 Dec 2017 07:06:20 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:56953 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281AbdLKMGS (ORCPT ); Mon, 11 Dec 2017 07:06:18 -0500 Received: from wuerfel.lan ([149.172.96.106]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0MYYMv-1ebir62oqX-00V75K; Mon, 11 Dec 2017 13:06:13 +0100 From: Arnd Bergmann To: Michael Krufky , Mauro Carvalho Chehab Cc: Arnd Bergmann , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] tuners: tda8290: reduce stack usage with kasan Date: Mon, 11 Dec 2017 13:06:04 +0100 Message-Id: <20171211120612.3775893-1-arnd@arndb.de> X-Mailer: git-send-email 2.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== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org With CONFIG_KASAN enabled, we get a relatively large stack frame in one function drivers/media/tuners/tda8290.c: In function 'tda8290_set_params': drivers/media/tuners/tda8290.c:310:1: warning: the frame size of 1520 bytes is larger than 1024 bytes [-Wframe-larger-than=] With CONFIG_KASAN_EXTRA this goes up to drivers/media/tuners/tda8290.c: In function 'tda8290_set_params': drivers/media/tuners/tda8290.c:310:1: error: the frame size of 3200 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] We can significantly reduce this by marking local arrays as 'static const', and this should result in better compiled code for everyone. I have another patch for the same symptom to patch tuner_i2c_xfer_*, and we actually want both of them. Signed-off-by: Arnd Bergmann --- drivers/media/tuners/tda8290.c | 76 ++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 37 deletions(-) -- 2.9.0 Reviewed-by: Michael Ira Krufky diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c index a59c567c55d6..19854221b72d 100644 --- a/drivers/media/tuners/tda8290.c +++ b/drivers/media/tuners/tda8290.c @@ -63,8 +63,8 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe, int close) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char enable[2] = { 0x21, 0xC0 }; - unsigned char disable[2] = { 0x21, 0x00 }; + static unsigned char enable[2] = { 0x21, 0xC0 }; + static unsigned char disable[2] = { 0x21, 0x00 }; unsigned char *msg; if (close) { @@ -84,9 +84,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char enable[2] = { 0x45, 0xc1 }; - unsigned char disable[2] = { 0x46, 0x00 }; - unsigned char buf[3] = { 0x45, 0x01, 0x00 }; + static unsigned char enable[2] = { 0x45, 0xc1 }; + static unsigned char disable[2] = { 0x46, 0x00 }; + static unsigned char buf[3] = { 0x45, 0x01, 0x00 }; unsigned char *msg; if (close) { @@ -178,24 +178,24 @@ static void tda8290_set_params(struct dvb_frontend *fe, { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char soft_reset[] = { 0x00, 0x00 }; + static unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; - unsigned char expert_mode[] = { 0x01, 0x80 }; - unsigned char agc_out_on[] = { 0x02, 0x00 }; - unsigned char gainset_off[] = { 0x28, 0x14 }; - unsigned char if_agc_spd[] = { 0x0f, 0x88 }; - unsigned char adc_head_6[] = { 0x05, 0x04 }; - unsigned char adc_head_9[] = { 0x05, 0x02 }; - unsigned char adc_head_12[] = { 0x05, 0x01 }; - unsigned char pll_bw_nom[] = { 0x0d, 0x47 }; - unsigned char pll_bw_low[] = { 0x0d, 0x27 }; - unsigned char gainset_2[] = { 0x28, 0x64 }; - unsigned char agc_rst_on[] = { 0x0e, 0x0b }; - unsigned char agc_rst_off[] = { 0x0e, 0x09 }; - unsigned char if_agc_set[] = { 0x0f, 0x81 }; - unsigned char addr_adc_sat = 0x1a; - unsigned char addr_agc_stat = 0x1d; - unsigned char addr_pll_stat = 0x1b; + static unsigned char expert_mode[] = { 0x01, 0x80 }; + static unsigned char agc_out_on[] = { 0x02, 0x00 }; + static unsigned char gainset_off[] = { 0x28, 0x14 }; + static unsigned char if_agc_spd[] = { 0x0f, 0x88 }; + static unsigned char adc_head_6[] = { 0x05, 0x04 }; + static unsigned char adc_head_9[] = { 0x05, 0x02 }; + static unsigned char adc_head_12[] = { 0x05, 0x01 }; + static unsigned char pll_bw_nom[] = { 0x0d, 0x47 }; + static unsigned char pll_bw_low[] = { 0x0d, 0x27 }; + static unsigned char gainset_2[] = { 0x28, 0x64 }; + static unsigned char agc_rst_on[] = { 0x0e, 0x0b }; + static unsigned char agc_rst_off[] = { 0x0e, 0x09 }; + static unsigned char if_agc_set[] = { 0x0f, 0x81 }; + static unsigned char addr_adc_sat = 0x1a; + static unsigned char addr_agc_stat = 0x1d; + static unsigned char addr_pll_stat = 0x1b; unsigned char adc_sat, agc_stat, pll_stat; int i; @@ -468,9 +468,9 @@ static void tda8290_standby(struct dvb_frontend *fe) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char cb1[] = { 0x30, 0xD0 }; - unsigned char tda8290_standby[] = { 0x00, 0x02 }; - unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; + static unsigned char cb1[] = { 0x30, 0xD0 }; + static unsigned char tda8290_standby[] = { 0x00, 0x02 }; + static unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; if (fe->ops.analog_ops.i2c_gate_ctrl) @@ -495,9 +495,9 @@ static void tda8290_init_if(struct dvb_frontend *fe) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char set_VS[] = { 0x30, 0x6F }; - unsigned char set_GP00_CF[] = { 0x20, 0x01 }; - unsigned char set_GP01_CF[] = { 0x20, 0x0B }; + static unsigned char set_VS[] = { 0x30, 0x6F }; + static unsigned char set_GP00_CF[] = { 0x20, 0x01 }; + static unsigned char set_GP01_CF[] = { 0x20, 0x0B }; if ((priv->cfg.config == TDA8290_LNA_GP0_HIGH_ON) || (priv->cfg.config == TDA8290_LNA_GP0_HIGH_OFF)) @@ -539,10 +539,12 @@ static void tda8295_init_if(struct dvb_frontend *fe) static void tda8290_init_tuner(struct dvb_frontend *fe) { struct tda8290_priv *priv = fe->analog_demod_priv; - unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, - 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; - unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, - 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; + static unsigned char tda8275_init[] = + { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, + 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; + static unsigned char tda8275a_init[] = + { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, + 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=tda8275_init, .len = 14}; if (priv->ver & TDA8275A) @@ -834,11 +836,11 @@ int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr) .addr = i2c_addr, }; - unsigned char soft_reset[] = { 0x00, 0x00 }; - unsigned char easy_mode_b[] = { 0x01, 0x02 }; - unsigned char easy_mode_g[] = { 0x01, 0x04 }; - unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 }; - unsigned char addr_dto_lsb = 0x07; + static unsigned char soft_reset[] = { 0x00, 0x00 }; + static unsigned char easy_mode_b[] = { 0x01, 0x02 }; + static unsigned char easy_mode_g[] = { 0x01, 0x04 }; + static unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 }; + static unsigned char addr_dto_lsb = 0x07; unsigned char data; #define PROBE_BUFFER_SIZE 8 unsigned char buf[PROBE_BUFFER_SIZE];