From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751927AbcAWISx (ORCPT ); Sat, 23 Jan 2016 03:18:53 -0500 Received: from down.free-electrons.com ([37.187.137.238]:59829 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751395AbcAWISr (ORCPT ); Sat, 23 Jan 2016 03:18:47 -0500 Date: Sat, 23 Jan 2016 09:18:44 +0100 From: Boris Brezillon To: Brian Norris Cc: David Woodhouse , linux-mtd@lists.infradead.org, Maxime Ripard , Chen-Yu Tsai , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Richard Weinberger Subject: Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support Message-ID: <20160123091844.4826ffe6@bbrezillon> In-Reply-To: <20160123025713.GA90611@google.com> References: <1449054067-16751-1-git-send-email-boris.brezillon@free-electrons.com> <1449054067-16751-4-git-send-email-boris.brezillon@free-electrons.com> <20160123025713.GA90611@google.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.27; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Brian, On Fri, 22 Jan 2016 18:57:13 -0800 Brian Norris wrote: > All three look good, so pushed to l2-mtd.git/next. One comment below: Thanks. > > On Wed, Dec 02, 2015 at 12:01:07PM +0100, Boris Brezillon wrote: > > ... > > > +static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) > > +{ > > + const u16 *seeds = sunxi_nfc_randomizer_page_seeds; > > + int mod = mtd->erasesize / mtd->writesize; > > Richard suggested you use the mtd.h helper here. Patch below. Yep, I forgot to do this change. > > > + > > + if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds)) > > + mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds); > > + > > + if (ecc) { > > + if (mtd->ecc_step_size == 512) > > + seeds = sunxi_nfc_randomizer_ecc512_seeds; > > + else > > + seeds = sunxi_nfc_randomizer_ecc1024_seeds; > > + } > > + > > + return seeds[page % mod]; > > +} > > From: Brian Norris > Date: Fri, 22 Jan 2016 18:54:02 -0800 > Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper > > Suggested-by: Richard Weinberger > Signed-off-by: Brian Norris Acked-by: Boris Brezillon > --- > drivers/mtd/nand/sunxi_nand.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c > index 5f700719d5c2..b5ea6b312df0 100644 > --- a/drivers/mtd/nand/sunxi_nand.c > +++ b/drivers/mtd/nand/sunxi_nand.c > @@ -624,7 +624,7 @@ static u16 sunxi_nfc_randomizer_step(u16 state, int count) > static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) > { > const u16 *seeds = sunxi_nfc_randomizer_page_seeds; > - int mod = mtd->erasesize / mtd->writesize; > + int mod = mtd_div_by_ws(mtd->erasesize, mtd); Just a comment (which should not prevent you from applying this patch). Isn't it a bit overkill to cast the erasesize to a 64 bit value, and then do a do_div on it. Shouldn't happen often though, because ->writesize_shift should be != 0 in most (all?) cases. Another related remark: with the MLC/paired pages stuff I'll have to retrieve this information (number of write units per erase block) quite often, so maybe we should have a field (and/or an helper) for that. Thanks, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: boris.brezillon@free-electrons.com (Boris Brezillon) Date: Sat, 23 Jan 2016 09:18:44 +0100 Subject: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support In-Reply-To: <20160123025713.GA90611@google.com> References: <1449054067-16751-1-git-send-email-boris.brezillon@free-electrons.com> <1449054067-16751-4-git-send-email-boris.brezillon@free-electrons.com> <20160123025713.GA90611@google.com> Message-ID: <20160123091844.4826ffe6@bbrezillon> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Brian, On Fri, 22 Jan 2016 18:57:13 -0800 Brian Norris wrote: > All three look good, so pushed to l2-mtd.git/next. One comment below: Thanks. > > On Wed, Dec 02, 2015 at 12:01:07PM +0100, Boris Brezillon wrote: > > ... > > > +static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) > > +{ > > + const u16 *seeds = sunxi_nfc_randomizer_page_seeds; > > + int mod = mtd->erasesize / mtd->writesize; > > Richard suggested you use the mtd.h helper here. Patch below. Yep, I forgot to do this change. > > > + > > + if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds)) > > + mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds); > > + > > + if (ecc) { > > + if (mtd->ecc_step_size == 512) > > + seeds = sunxi_nfc_randomizer_ecc512_seeds; > > + else > > + seeds = sunxi_nfc_randomizer_ecc1024_seeds; > > + } > > + > > + return seeds[page % mod]; > > +} > > From: Brian Norris > Date: Fri, 22 Jan 2016 18:54:02 -0800 > Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper > > Suggested-by: Richard Weinberger > Signed-off-by: Brian Norris Acked-by: Boris Brezillon > --- > drivers/mtd/nand/sunxi_nand.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c > index 5f700719d5c2..b5ea6b312df0 100644 > --- a/drivers/mtd/nand/sunxi_nand.c > +++ b/drivers/mtd/nand/sunxi_nand.c > @@ -624,7 +624,7 @@ static u16 sunxi_nfc_randomizer_step(u16 state, int count) > static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc) > { > const u16 *seeds = sunxi_nfc_randomizer_page_seeds; > - int mod = mtd->erasesize / mtd->writesize; > + int mod = mtd_div_by_ws(mtd->erasesize, mtd); Just a comment (which should not prevent you from applying this patch). Isn't it a bit overkill to cast the erasesize to a 64 bit value, and then do a do_div on it. Shouldn't happen often though, because ->writesize_shift should be != 0 in most (all?) cases. Another related remark: with the MLC/paired pages stuff I'll have to retrieve this information (number of write units per erase block) quite often, so maybe we should have a field (and/or an helper) for that. Thanks, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com