Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1315490 > unrolled thread
| Started by | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| First post | 2016-01-23 04:00 +0100 |
| Last post | 2016-01-23 22:00 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support Brian Norris <computersforpeace@gmail.com> - 2016-01-23 04:00 +0100
Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-23 09:20 +0100
Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support Brian Norris <computersforpeace@gmail.com> - 2016-01-23 22:00 +0100
| From | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| Date | 2016-01-23 04:00 +0100 |
| Subject | Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support |
| Message-ID | <qTWAG-4Dh-1@gated-at.bofh.it> |
All three look good, so pushed to l2-mtd.git/next. One comment below:
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.
> +
> + 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 <computersforpeace@gmail.com>
Date: Fri, 22 Jan 2016 18:54:02 -0800
Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper
Suggested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
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);
if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds))
mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds);
--
2.7.0.rc3.207.g0ac5344
[toc] | [next] | [standalone]
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Date | 2016-01-23 09:20 +0100 |
| Message-ID | <qU1Am-8nr-11@gated-at.bofh.it> |
| In reply to | #1315490 |
Hi Brian,
On Fri, 22 Jan 2016 18:57:13 -0800
Brian Norris <computersforpeace@gmail.com> 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 <computersforpeace@gmail.com>
> Date: Fri, 22 Jan 2016 18:54:02 -0800
> Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper
>
> Suggested-by: Richard Weinberger <richard@nod.at>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> 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
[toc] | [prev] | [next] | [standalone]
| From | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| Date | 2016-01-23 22:00 +0100 |
| Message-ID | <qUdrP-8sv-5@gated-at.bofh.it> |
| In reply to | #1315540 |
On Sat, Jan 23, 2016 at 09:18:44AM +0100, Boris Brezillon wrote:
> On Fri, 22 Jan 2016 18:57:13 -0800
> Brian Norris <computersforpeace@gmail.com> wrote:
> >
> > From: Brian Norris <computersforpeace@gmail.com>
> > Date: Fri, 22 Jan 2016 18:54:02 -0800
> > Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper
> >
> > Suggested-by: Richard Weinberger <richard@nod.at>
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Applied.
> > ---
> > 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.
drivers/mtd/nand/ assumes power-of-2 dimensions for many things, so
probably.
> 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.
Perhaps.
Brian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web