From patchwork Wed Mar 13 21:10:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160274 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14763610jad; Wed, 13 Mar 2019 14:10:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6LVmv3nTToEt49hoSaZjlcdpSx3yyBmjSIfnVOE7UWBGggI4l4Bv9FNW4N0IbO4awsH/+ X-Received: by 2002:a65:6203:: with SMTP id d3mr19119306pgv.109.1552511456158; Wed, 13 Mar 2019 14:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552511456; cv=none; d=google.com; s=arc-20160816; b=tQkviEttVM8D+4epBJxA3rXF/K4wAOYUcfZQ6SjGI9WuMaRShXtPDkD40ItOVAblgv KVU18ErPDcMndWOAWHWOO1F79E4x/zgZVJxCmjtYzMD8bWbZPN0Y2AOerLB24vOLndtB hBJgMO1vTuq2z6/vfvvK3ZlZuKUsOoTtMW2jaYtNgwfRZD5zQka8rChC2Y3RTM3ew5cy csHhHruf8fc/1RP0hB6hWIPPcPZ0jtr22J8yBBqk/5KvCpwdpFshupLqR2bxmvJZ9B2T xl6lrYJVn0di15xeiwLxOJ39R93ETIQbxWUNfS5o6Y4DFsoQEL5bDjilfJ5ozSRXgIaA ELiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=b8jCZHP3fesQKbEmOiYKhWtDGCaJBQJH+30R7u9DjHE=; b=HusoHUWr78xsY+0Ga8Q9elkTfWye13GK44XVE+sKE8oPhXgXgpJr1q5AE/EFbRFZhr XYmNl+5dSFWR+x41pLb/LTYpBdd4mGqCHmVsSjiIdwxXst9Fdu6Vd+MMGi8aWy4NDIpV zCtoR6DVWZvmPiApZ5hFxa1vRPknnbIuktIHD9coNyiqleER7+o0Yx5kOGMRHwvMMjSI dwkAFZip0sSgeqdTaezpjJGsZsoGzcEoFdHM2zjvJa2GZa+qWJsmA1+6uXFfLKXOFfoJ iBdd8ZnVKaumMbwSftJ6PRa2krYgi4/tl086fUZupay/+rKbJ8gK1r8jqmBiH5gHHfCA 58vw== 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 p8si11641321plk.257.2019.03.13.14.10.55; Wed, 13 Mar 2019 14:10:56 -0700 (PDT) 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 S1726717AbfCMVKz (ORCPT + 3 others); Wed, 13 Mar 2019 17:10:55 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:54921 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbfCMVKz (ORCPT ); Wed, 13 Mar 2019 17:10:55 -0400 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mw9Dg-1gnkgq23iW-00sAMA; Wed, 13 Mar 2019 22:10:44 +0100 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Greg Kroah-Hartman , Ioannis Valasakis , Hans Verkuil , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: media: davinci_vpfe: fix large stack usage with clang Date: Wed, 13 Mar 2019 22:10:29 +0100 Message-Id: <20190313211042.4131426-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:lkFtZ02KwH1msqPwqlwjI46jemgyHH4J05FGQBctqc9zB0J5Fpf ueQ1nCWMGBXusl6ENO51MeoDfU1x+klPcSsfb6ob4hotfYvu34ODl8XcmT69yLjtT7dz9nE Uyl35RDH2FXDUsQmxaLDtwDKXxaOMDcbOjXjR8IcAkGDUPArpWLW6A0V8JIzsezlsxa+jEl 2IdrDcKmAWOsex4E9LGfA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:pwev2Tadjn0=:kXoQG77WPUw0wtSKyiRJyx UBeXoUaPnJEfItRBtPix+6f4HYQyF/L5Mi3rEPaXkZDDPaVkwNsbC8hxKlVGbfWL2ycgdIIJ7 hascc3qSaM9r8J1e1Bx13GfrfSVQkM54TrYYxOfEVc3hdEgNak1s9tTdNh8wZz+3TdI1/jAYj byYmZJvpMcx1pNmKzvyypHZUQVdZWsmOVlyZ9YW7Oo0rbOFGEv/reNMO6p7b33YE4tIoetfAA 0r9oyLf/eN4chRMVDORNIt3sSznvvAf4s9LIDNMdBkspQ23L9DBRdbsTTArLfy97K6VPm3KER rUmAIZJP01U5ATPuNP09T7ARsty5/M5Zr9/Ut7ecayuI/VAJK7eQwiQwqr5fW5OyMhyo6GdAg PU3Lt7rCetSCVituhBCzNPP7TvpCzleXAgdUBmDgHKThRkyOSQmu25eg5oLGTIuqqfdLBAOxR /W2nNKhHatwe7A3WVSn0aKWJ1vaoX/syS0H0zZjyS0uW0+B5LoCFVH25pWte6n8ZYNSSLxUpX RZj6HCDPq8dSm8IHlBvq7I4EPSNasC9013H2nxXK972SuwHDN5O+GusAlbWGRtvBjGO4HH1Lm uKUrQH6r2gZ8Rwr9xtp9/Gzc27OJVGnqoWHV6gFdJKPKkXwRjwIjfLneG2aJMCMRL1zFsbJ9e DFkQxfKYBY7ll7bt6yWBJLKB961NcRRCtWJj20GrbBovImUx6VvZiJX4Wudq0ci6Nw/B8U4RN y15fgjUGpqVaDTgKd6S/hml8y9TKhYi67TsnCg== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org clang is unable to optimize the isif_ioctl() in the same way that gcc does, as it fails to prove that the local copy of the 'struct vpfe_isif_raw_config' argument is unnecessary: drivers/staging/media/davinci_vpfe/dm365_isif.c:622:13: error: stack frame size of 1344 bytes in function 'isif_ioctl' [-Werror,-Wframe-larger-than=] Marking it as 'const' while passing the data down clearly shows us that the copy is never modified, and we can skip copying it entirely, which reduces the stack usage to just eight bytes. Signed-off-by: Arnd Bergmann --- .../staging/media/davinci_vpfe/dm365_isif.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) -- 2.20.0 diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 0a6d038fcec9..46fd8184fc77 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -433,9 +433,9 @@ static int isif_get_params(struct v4l2_subdev *sd, void *params) return 0; } -static int isif_validate_df_csc_params(struct vpfe_isif_df_csc *df_csc) +static int isif_validate_df_csc_params(const struct vpfe_isif_df_csc *df_csc) { - struct vpfe_isif_color_space_conv *csc; + const struct vpfe_isif_color_space_conv *csc; int err = -EINVAL; int i; @@ -481,7 +481,7 @@ static int isif_validate_df_csc_params(struct vpfe_isif_df_csc *df_csc) #define DM365_ISIF_MAX_DFCMEM0 0x1fff #define DM365_ISIF_MAX_DFCMEM1 0x1fff -static int isif_validate_dfc_params(struct vpfe_isif_dfc *dfc) +static int isif_validate_dfc_params(const struct vpfe_isif_dfc *dfc) { int err = -EINVAL; int i; @@ -532,7 +532,7 @@ static int isif_validate_dfc_params(struct vpfe_isif_dfc *dfc) #define DM365_ISIF_MAX_CLVSV 0x1fff #define DM365_ISIF_MAX_HEIGHT_BLACK_REGION 0x1fff -static int isif_validate_bclamp_params(struct vpfe_isif_black_clamp *bclamp) +static int isif_validate_bclamp_params(const struct vpfe_isif_black_clamp *bclamp) { int err = -EINVAL; @@ -580,7 +580,7 @@ static int isif_validate_bclamp_params(struct vpfe_isif_black_clamp *bclamp) } static int -isif_validate_raw_params(struct vpfe_isif_raw_config *params) +isif_validate_raw_params(const struct vpfe_isif_raw_config *params) { int ret; @@ -593,20 +593,18 @@ isif_validate_raw_params(struct vpfe_isif_raw_config *params) return isif_validate_bclamp_params(¶ms->bclamp); } -static int isif_set_params(struct v4l2_subdev *sd, void *params) +static int isif_set_params(struct v4l2_subdev *sd, const struct vpfe_isif_raw_config *params) { struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); - struct vpfe_isif_raw_config isif_raw_params; int ret = -EINVAL; /* only raw module parameters can be set through the IOCTL */ if (isif->formats[ISIF_PAD_SINK].code != MEDIA_BUS_FMT_SGRBG12_1X12) return ret; - memcpy(&isif_raw_params, params, sizeof(isif_raw_params)); - if (!isif_validate_raw_params(&isif_raw_params)) { - memcpy(&isif->isif_cfg.bayer.config_params, &isif_raw_params, - sizeof(isif_raw_params)); + if (!isif_validate_raw_params(params)) { + memcpy(&isif->isif_cfg.bayer.config_params, params, + sizeof(*params)); ret = 0; } return ret;