Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2857300imb; Mon, 4 Mar 2019 16:26:33 -0800 (PST) X-Google-Smtp-Source: APXvYqz1S2ZX9LVRpTD/EYQN3GSDg06ZoHWtqhW73RuAYNllJmJ7+HQUQOOXtdo6ijWhKumxHdzT X-Received: by 2002:a63:4607:: with SMTP id t7mr5477305pga.306.1551745593740; Mon, 04 Mar 2019 16:26:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551745593; cv=none; d=google.com; s=arc-20160816; b=m9l0+Fm73H8s8SX12XJxE4q9vA294jayS+6uAFV+vhMVPAFOxmhff514U0Hyi3xuQA rxg6CtFiVYtUxOqrVKRMeDouAE5OMeUq/LkIQ5WvwSM4w5rFDcOiQu63IsU+TKx12+t7 4QqFS1kP/ZwzXnRn7RSk+wxLk2HrbIDF+VFjxxCAnfM2wIfkM7WjdoGeEibfUyDv9mtB Il6ma1Qpq52r6b6nsDe5kT3/vCZeC4ymdUt+G0Va2L6gjg5+TU5Zcm/0Qw8G7v+4VPqZ LBZEqAv6NoQDtBrJZoDGhgNQ9cwlpSyqShdAR0lXJ2lWBYfiurMUkV5Yx6wpLwrmdFBC shsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=p0MjH9jA34yCMnxfsyW7fOjh3tgS31S5tj+iEjfXMG0=; b=A9e5xImQDDHkLO+SMkaiHS7zMXzX9gppSdM7Idr8CzC9eKAWyeMN5+M5E6ZyeUTvY7 yvG0oCjco0rx0eHAK10qH2i9H6pusP4lSS9k8LCx9hcuHpUBUzMCgDvUt/4V8K/y5qzP Bg9GJAwcMVzORunfvfiG6Eq5lxI965A4sallVYzqUIpxXiFvQrLj+wnhO6D+/uc8YG4R 6HXLxGWuqiAwok5xODIUdzVNhpTlnhysebl+5wiRATF7eySXKjk8G7Xue6OTRKkWBisd DE4xYk8a+aorm/Iu45T6kLXF15qy+59StZnRaoWN4Ncwk0w9vHmHcksPirJmv8BuWIJw E+vQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w185si6211874pgd.495.2019.03.04.16.26.18; Mon, 04 Mar 2019 16:26:33 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbfCEAZx convert rfc822-to-8bit (ORCPT + 99 others); Mon, 4 Mar 2019 19:25:53 -0500 Received: from mga04.intel.com ([192.55.52.120]:58216 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbfCEAZw (ORCPT ); Mon, 4 Mar 2019 19:25:52 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 16:25:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,441,1544515200"; d="scan'208";a="148586669" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 04 Mar 2019 16:25:52 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 4 Mar 2019 16:25:51 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 4 Mar 2019 16:25:51 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.74]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.26]) with mapi id 14.03.0415.000; Tue, 5 Mar 2019 08:25:19 +0800 From: "Cao, Bingbu" To: Arnd Bergmann , Sakari Ailus , Mauro Carvalho Chehab , Greg Kroah-Hartman CC: "Zhi, Yong" , "linux-media@vger.kernel.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] media: staging/intel-ipu3: reduce kernel stack usage Thread-Topic: [PATCH] media: staging/intel-ipu3: reduce kernel stack usage Thread-Index: AQHU0sjI/9ys7oMm70KxNpya8bdOOaX8LDeg Date: Tue, 5 Mar 2019 00:25:18 +0000 Message-ID: References: <20190304202758.1802417-1-arnd@arndb.de> In-Reply-To: <20190304202758.1802417-1-arnd@arndb.de> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzM2ZjM5Y2ItNmNhOC00ZTFmLWFmMGQtMzUwOTZkMzUyZDcyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVVBTMHBvVGdaN1F4ZVpxM0JBRWxDeGcwR1l4VmVzczNoOVQ3MGI4K2lMeDZ2eTdVVnMzMXdzVEYrVTQ2bkd2SiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __________________________ BRs, Cao, Bingbu > -----Original Message----- > From: Arnd Bergmann [mailto:arnd@arndb.de] > Sent: Tuesday, March 5, 2019 4:28 AM > To: Sakari Ailus ; Mauro Carvalho Chehab > ; Greg Kroah-Hartman > Cc: Arnd Bergmann ; Zhi, Yong ; Cao, > Bingbu ; linux-media@vger.kernel.org; > devel@driverdev.osuosl.org; linux-kernel@vger.kernel.org > Subject: [PATCH] media: staging/intel-ipu3: reduce kernel stack usage > > 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); Could you use the devm_kcalloc()? > 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; > + } [Cao, Bingbu] The goto here is wrong, you can just report an error, and I prefer it is next to the alloc. > + > /* 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