Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2725847imb; Mon, 4 Mar 2019 12:28:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyeXiHU3mDUqGojkV+y5CKDKHym6JAeWGE4aJLua1uGYDYMReWLPVjxTjQfzcFR1M/ZKB72 X-Received: by 2002:a17:902:8346:: with SMTP id z6mr22660868pln.74.1551731335605; Mon, 04 Mar 2019 12:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551731335; cv=none; d=google.com; s=arc-20160816; b=njEaRe6nwn9gju2dC4RqHUhZ63CIguHFAyDSg/3IAy2luydgIUzs4elzV8xGbt9lsN SApVCsMX9wVlBUc4vbGx2BzLMjJr4C3RHuBXlskEI1pFoXFgH5JwzOA8cCI6y6NEeDgn mWS2ROFBuw6PEMBkvMg5GgQ37kUsoZF6v5jW65+IIo0siCU58S1NNjUUFpmkRYEOOca5 7QMfIAco/urg1DIc28LUDz33raGciCNLQeb9TdHDFMDrgRoNVe0DBD+7Ftfdr6/s0ELz jJMBByNvOTPglsvjX21rdYzzMqSlz1+kJcmjhXVzLHPtNh6WAN1poRpRZ3Q5auWbReYl Kl7A== 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=BF8pjJTJQ5Vrm6ELZsfPbEyLHI3Y7NspIa2vOwH7/VI=; b=y37P5OGlAvs26FgJpfS3SRTxAhFfbFTdeKi9LMmcNaoKCWTgmGLC5BfylCAI0MX9rk aK/L0nAubB7y/8b13vAIZKYLBmL4qRRPvKfVmEOyu2cP/z3yvFJkP59cPiCQAcSIKWru EXBn1nLCgoobKj5DfARD6FShIxOHHtTiPHYehsen6fDSapziqUuOvFya94xls9L470RY FpcXBcwzrYLg6xmwoBp/kwpFglHYeNIvUrPbpy7s5FDqO9gaOy6nZyQ+u0u9nSLhuvhk 8iJWZPa8gkquM0L2c1QSUrXTIuRPC/JuFH0dfKVOmMd4+TjX/ytIFyE9/tyzHgNpXP2+ eYNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 c6si5954097pgd.106.2019.03.04.12.28.40; Mon, 04 Mar 2019 12:28:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbfCDU2N (ORCPT + 99 others); Mon, 4 Mar 2019 15:28:13 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:33865 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbfCDU2N (ORCPT ); Mon, 4 Mar 2019 15:28:13 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MJWgK-1ghANs1Xuy-00JrRZ; Mon, 04 Mar 2019 21:28:00 +0100 From: Arnd Bergmann To: Sakari Ailus , Mauro Carvalho Chehab , Greg Kroah-Hartman Cc: Arnd Bergmann , Yong Zhi , Bingbu Cao , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: staging/intel-ipu3: reduce kernel stack usage Date: Mon, 4 Mar 2019 21:27:40 +0100 Message-Id: <20190304202758.1802417-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K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vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The imgu_css_queue structure is too large to be put on the kernel stack, as we can see in 32-bit builds: drivers/staging/media/ipu3/ipu3-css.c: In function 'imgu_css_fmt_try': drivers/staging/media/ipu3/ipu3-css.c:1863:1: error: the frame size of 1172 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] By dynamically allocating this array, the stack usage goes down to an acceptable 140 bytes for the same x86-32 configuration. Fixes: f5f2e4273518 ("media: staging/intel-ipu3: Add css pipeline programming") Signed-off-by: Arnd Bergmann --- drivers/staging/media/ipu3/ipu3-css.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c index 15ab77e4b766..664c14b7a518 100644 --- a/drivers/staging/media/ipu3/ipu3-css.c +++ b/drivers/staging/media/ipu3/ipu3-css.c @@ -3,6 +3,7 @@ #include #include +#include #include "ipu3-css.h" #include "ipu3-css-fw.h" @@ -1744,7 +1745,7 @@ int imgu_css_fmt_try(struct imgu_css *css, struct v4l2_rect *const bds = &r[IPU3_CSS_RECT_BDS]; struct v4l2_rect *const env = &r[IPU3_CSS_RECT_ENVELOPE]; struct v4l2_rect *const gdc = &r[IPU3_CSS_RECT_GDC]; - struct imgu_css_queue q[IPU3_CSS_QUEUES]; + struct imgu_css_queue *q = kcalloc(IPU3_CSS_QUEUES, sizeof(struct imgu_css_queue), GFP_KERNEL); struct v4l2_pix_format_mplane *const in = &q[IPU3_CSS_QUEUE_IN].fmt.mpix; struct v4l2_pix_format_mplane *const out = @@ -1753,6 +1754,11 @@ int imgu_css_fmt_try(struct imgu_css *css, &q[IPU3_CSS_QUEUE_VF].fmt.mpix; int i, s, ret; + if (!q) { + ret = -ENOMEM; + goto out; + } + /* Adjust all formats, get statistics buffer sizes and formats */ for (i = 0; i < IPU3_CSS_QUEUES; i++) { if (fmts[i]) @@ -1766,7 +1772,8 @@ int imgu_css_fmt_try(struct imgu_css *css, IPU3_CSS_QUEUE_TO_FLAGS(i))) { dev_notice(css->dev, "can not initialize queue %s\n", qnames[i]); - return -EINVAL; + ret = -EINVAL; + goto out; } } for (i = 0; i < IPU3_CSS_RECTS; i++) { @@ -1788,7 +1795,8 @@ int imgu_css_fmt_try(struct imgu_css *css, if (!imgu_css_queue_enabled(&q[IPU3_CSS_QUEUE_IN]) || !imgu_css_queue_enabled(&q[IPU3_CSS_QUEUE_OUT])) { dev_warn(css->dev, "required queues are disabled\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } if (!imgu_css_queue_enabled(&q[IPU3_CSS_QUEUE_OUT])) { @@ -1829,7 +1837,8 @@ int imgu_css_fmt_try(struct imgu_css *css, ret = imgu_css_find_binary(css, pipe, q, r); if (ret < 0) { dev_err(css->dev, "failed to find suitable binary\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } css->pipes[pipe].bindex = ret; @@ -1843,7 +1852,8 @@ int imgu_css_fmt_try(struct imgu_css *css, IPU3_CSS_QUEUE_TO_FLAGS(i))) { dev_err(css->dev, "final resolution adjustment failed\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } *fmts[i] = q[i].fmt.mpix; } @@ -1859,7 +1869,10 @@ int imgu_css_fmt_try(struct imgu_css *css, bds->width, bds->height, gdc->width, gdc->height, out->width, out->height, vf->width, vf->height); - return 0; + ret = 0; +out: + kfree(q); + return ret; } int imgu_css_fmt_set(struct imgu_css *css, -- 2.20.0