Message ID | c797dc5e9248498918916a6eeedaa25de2196e8c.1669154149.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2460876wrr; Tue, 22 Nov 2022 14:06:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf6DfeOvW7n7OsXIoiZOBgKg5U6E41y7j5GU1Qymk6jsXbCK8DiwLAfGUNevOyBdwr8mFVor X-Received: by 2002:a62:1cd4:0:b0:56b:deea:72e9 with SMTP id c203-20020a621cd4000000b0056bdeea72e9mr27151532pfc.47.1669154798122; Tue, 22 Nov 2022 14:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669154798; cv=none; d=google.com; s=arc-20160816; b=m3obP/JYj4dE+ProNd23OPg3YREDYaur7p7wh7QCLD1Y9pmIpax8gcUiO18zvQPEAX mSIpGCOLRXzeoIafwePxypJuAPqYEuh5BG6f2PsoD7tHoSSSNsOYeUQcOUxSAKs1hQ+9 etoxBmYi/oIF4H9LvoSPvcMRZ4t+bwl60rc6WBuFYQtwvlkWqjFpr4kq/fq1fCNj/0Hi bA8xlrZotjyKNfm/8l43wyXhzPiF76auis0y5vPgnIOBp9XzGuf4OwuSEUZpvBPIc4Cs CfGvV762No+vLFacA04PzlLMHb746wFgsmYjy9aV0piMUlZ02XifD1AYMKfmIPpo7gk0 d7yQ== 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 :message-id:date:subject:cc:to:from; bh=824SFzJcvTB2JbHC1JCtx94TdATQoRAOhQZkIVf2p1A=; b=lb24z2O+7CYLzwsiiy04NXEJ5KFL+Uro+XhZNyHjEPix/vgILD5z2c5qEHrK4d3lMo RRD3oyOzMUxAbMvsSZXUvGHs3QPbQiOmVcMgeDNHuaSe7co13Q6nBF0JO86gzKUhXCBA H0Ro21n15+ijPGgEl0+TnQqsHy8pguUfuSrB5hqyDv3OIFPnDDzwum7Yekvtq4in9eFk KfZc2Cf+Yq07Xo3vH6IaVQBZOYKY4qQ3HHYzxl6Ph2IFib4X9oIn+ltEB+CCCxIYBBDU V3wUxj40ztLO/YoA5UnWd5kQEGeF4lLvbgc6gKpmBaACyver0ceDDNL1F301Svs/4Xsi ZTXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j191-20020a6380c8000000b004774a855375si10195723pgd.351.2022.11.22.14.06.24; Tue, 22 Nov 2022 14:06:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234767AbiKVV4a (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 16:56:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231174AbiKVV42 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 16:56:28 -0500 Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270E2C6BC3 for <linux-kernel@vger.kernel.org>; Tue, 22 Nov 2022 13:56:28 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id xbFdoaYQDOAzAxbFdon0TP; Tue, 22 Nov 2022 22:56:26 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 22 Nov 2022 22:56:26 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Corentin Labbe <clabbe@baylibre.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-crypto@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH] crypto: amlogic - Save a few bytes of memory Date: Tue, 22 Nov 2022 22:56:19 +0100 Message-Id: <c797dc5e9248498918916a6eeedaa25de2196e8c.1669154149.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750235661606378532?= X-GMAIL-MSGID: =?utf-8?q?1750235661606378532?= |
Series |
crypto: amlogic - Save a few bytes of memory
|
|
Commit Message
Christophe JAILLET
Nov. 22, 2022, 9:56 p.m. UTC
There is no real point in allocating dedicated memory for the irqs array.
MAXFLOW is only 2, so it is easier to allocated the needed space
directly within the 'meson_dev' structure.
This saves some memory allocation and avoids an indirection when using the
irqs array.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/crypto/amlogic/amlogic-gxl-core.c | 1 -
drivers/crypto/amlogic/amlogic-gxl.h | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
Comments
On Tue, Nov 22, 2022 at 10:57 PM Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > > There is no real point in allocating dedicated memory for the irqs array. > MAXFLOW is only 2, so it is easier to allocated the needed space > directly within the 'meson_dev' structure. > > This saves some memory allocation and avoids an indirection when using the > irqs array. ..and it even fixes a missing devm_kcalloc error check Personally I prefer this approach over a patch that was sent earlier today: [0] Corentin, Christophe, what do you think? Best regards, Martin [0] https://lore.kernel.org/linux-crypto/0df30bbf-3b7e-ed20-e316-41192bf3cc2b@linaro.org/T/#m6a45b44206c282f106d379b01d19027823c5d79b
Le 22/11/2022 à 23:02, Martin Blumenstingl a écrit : > On Tue, Nov 22, 2022 at 10:57 PM Christophe JAILLET > <christophe.jaillet@wanadoo.fr> wrote: >> >> There is no real point in allocating dedicated memory for the irqs array. >> MAXFLOW is only 2, so it is easier to allocated the needed space >> directly within the 'meson_dev' structure. >> >> This saves some memory allocation and avoids an indirection when using the >> irqs array. > ..and it even fixes a missing devm_kcalloc error check > > Personally I prefer this approach over a patch that was sent earlier today: [0] Funny. A file untouched for about 18 months and 2 patches around the same line, ... the same day! > Corentin, Christophe, what do you think? Obviously, mine is better :) More seriously, I think it is mostly a mater of taste and that both are fine. Neither one will make a real difference IRL. I guess that memory allocation failure in probe are unlikely and saving 64 bytes (40 for devm_ + 2 x 4 = 48, rounded to 64 bytes) won't make any real difference. Up to you. CJ > > > Best regards, > Martin > > > [0] https://lore.kernel.org/linux-crypto/0df30bbf-3b7e-ed20-e316-41192bf3cc2b@linaro.org/T/#m6a45b44206c282f106d379b01d19027823c5d79b >
Le 22/11/2022 à 23:02, Martin Blumenstingl a écrit : > On Tue, Nov 22, 2022 at 10:57 PM Christophe JAILLET > <christophe.jaillet@wanadoo.fr> wrote: >> >> There is no real point in allocating dedicated memory for the irqs array. >> MAXFLOW is only 2, so it is easier to allocated the needed space >> directly within the 'meson_dev' structure. >> >> This saves some memory allocation and avoids an indirection when using the >> irqs array. > ..and it even fixes a missing devm_kcalloc error check > > Personally I prefer this approach over a patch that was sent earlier today: [0] > Corentin, Christophe, what do you think? > > > Best regards, > Martin > > > [0] https://lore.kernel.org/linux-crypto/0df30bbf-3b7e-ed20-e316-41192bf3cc2b@linaro.org/T/#m6a45b44206c282f106d379b01d19027823c5d79b > Unrelated, but I think that meson_irq_handler() needs a small ajustement to avoid printing a spurious message if readl() returns 0. Maybe something like that?: @@ -33,9 +33,10 @@ static irqreturn_t meson_irq_handler(int irq, void *data) writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); mc->chanlist[flow].status = 1; complete(&mc->chanlist[flow].complete); - return IRQ_HANDLED; + } else { + dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); } - dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); + return IRQ_HANDLED; } } CJ
> -----Original Message----- > From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Sent: Tuesday, November 22, 2022 4:37 PM > Subject: Re: [PATCH] crypto: amlogic - Save a few bytes of memory ... > Unrelated, but I think that meson_irq_handler() needs a small ajustement > to avoid printing a spurious message if readl() returns 0. > > Maybe something like that?: > > @@ -33,9 +33,10 @@ static irqreturn_t meson_irq_handler(int irq, void > *data) > writel_relaxed(0xF, mc->base + ((0x4 + flow) << 2)); > mc->chanlist[flow].status = 1; > complete(&mc->chanlist[flow].complete); > - return IRQ_HANDLED; > + } else { > + dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); > } > - dev_err(mc->dev, "%s %d Got irq for flow %d but ctrl is empty\n", __func__, irq, flow); > + return IRQ_HANDLED; > } > } You might want to reconsider allowing this irq handler to do any prints. 80 characters take 5 ms to print on a 115 kbps serial port, which can lead to RCU stalls, soft lockups, etc. If kept, dev_err_ratelimited would be a little safer. In some systems "spurious interrupts" are routine and are not really a problem unless you overreact to them.
On Tue, Nov 22, 2022 at 10:56:19PM +0100, Christophe JAILLET wrote: > There is no real point in allocating dedicated memory for the irqs array. > MAXFLOW is only 2, so it is easier to allocated the needed space > directly within the 'meson_dev' structure. > > This saves some memory allocation and avoids an indirection when using the > irqs array. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/crypto/amlogic/amlogic-gxl-core.c | 1 - > drivers/crypto/amlogic/amlogic-gxl.h | 2 +- > 2 files changed, 1 insertion(+), 2 deletions(-) Patch applied. Thanks.
diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c index 6e7ae896717c..937187027ad5 100644 --- a/drivers/crypto/amlogic/amlogic-gxl-core.c +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c @@ -237,7 +237,6 @@ static int meson_crypto_probe(struct platform_device *pdev) return err; } - mc->irqs = devm_kcalloc(mc->dev, MAXFLOW, sizeof(int), GFP_KERNEL); for (i = 0; i < MAXFLOW; i++) { mc->irqs[i] = platform_get_irq(pdev, i); if (mc->irqs[i] < 0) diff --git a/drivers/crypto/amlogic/amlogic-gxl.h b/drivers/crypto/amlogic/amlogic-gxl.h index dc0f142324a3..8c0746a1d6d4 100644 --- a/drivers/crypto/amlogic/amlogic-gxl.h +++ b/drivers/crypto/amlogic/amlogic-gxl.h @@ -95,7 +95,7 @@ struct meson_dev { struct device *dev; struct meson_flow *chanlist; atomic_t flow; - int *irqs; + int irqs[MAXFLOW]; #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG struct dentry *dbgfs_dir; #endif