All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Baruch Siach <baruch@tkos.co.il>
Cc: Shawn Guo <shawn.guo@linaro.org>,
	linux-mtd@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Sascha Hauer <sha@pengutronix.de>
Subject: Re: [PATCH 3/4] mtd: mxc_nand: fix truncate of unaligned oob copying
Date: Mon, 27 Apr 2015 08:56:57 +0200	[thread overview]
Message-ID: <20150427065657.GD19431@pengutronix.de> (raw)
In-Reply-To: <20150427044618.GS2258@tarshish>

Hello Baruch,

On Mon, Apr 27, 2015 at 07:46:18AM +0300, Baruch Siach wrote:
> On Sun, Apr 26, 2015 at 09:52:11PM +0200, Uwe Kleine-König wrote:
> > On Sun, Apr 26, 2015 at 11:16:50AM +0300, Baruch Siach wrote:
> > > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > > index c650f0950b20..c05f5e8fef17 100644
> > > --- a/drivers/mtd/nand/mxc_nand.c
> > > +++ b/drivers/mtd/nand/mxc_nand.c
> > > @@ -840,22 +840,22 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
> > >  		for (i = 0; i < num_chunks - 1; i++)
> > >  			memcpy32_fromio(d + i * oob_chunk_size,
> > >  					s + i * sparebuf_size,
> > > -					oob_chunk_size);
> > > +					ALIGN(oob_chunk_size, 4));
> > If oob_chunk_size isn't 32-bit-aligned, d + i * oob_chunk_size isn't
> > either for uneven i. That's not nice. I suggest to use memcpy16_fromio.
> 
> memcpy32_fromio() was introduced by Sascha in 096bcc231fd2 (mtd: mxc_nand: use 
> 32bit copy functions, 2012-05-29), replacing memcpy_fromio() to force 32bit io 
> access. Are you sure the hypothetical memcpy16_fromio() would work?
according to the reference manual you can use 16-bit or 32-bit accesses.
And giving that in some cases the amount of valid data (in bytes) is ≡ 2
(mod 4) 16-bit access seem to be the obvious thing. Also Sascha only
wrote about byte accesses being problematic in 096bcc231fd2. So I'm
expecting that 16-bit operators should be fine.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

WARNING: multiple messages have this Message-ID (diff)
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] mtd: mxc_nand: fix truncate of unaligned oob copying
Date: Mon, 27 Apr 2015 08:56:57 +0200	[thread overview]
Message-ID: <20150427065657.GD19431@pengutronix.de> (raw)
In-Reply-To: <20150427044618.GS2258@tarshish>

Hello Baruch,

On Mon, Apr 27, 2015 at 07:46:18AM +0300, Baruch Siach wrote:
> On Sun, Apr 26, 2015 at 09:52:11PM +0200, Uwe Kleine-K?nig wrote:
> > On Sun, Apr 26, 2015 at 11:16:50AM +0300, Baruch Siach wrote:
> > > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > > index c650f0950b20..c05f5e8fef17 100644
> > > --- a/drivers/mtd/nand/mxc_nand.c
> > > +++ b/drivers/mtd/nand/mxc_nand.c
> > > @@ -840,22 +840,22 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
> > >  		for (i = 0; i < num_chunks - 1; i++)
> > >  			memcpy32_fromio(d + i * oob_chunk_size,
> > >  					s + i * sparebuf_size,
> > > -					oob_chunk_size);
> > > +					ALIGN(oob_chunk_size, 4));
> > If oob_chunk_size isn't 32-bit-aligned, d + i * oob_chunk_size isn't
> > either for uneven i. That's not nice. I suggest to use memcpy16_fromio.
> 
> memcpy32_fromio() was introduced by Sascha in 096bcc231fd2 (mtd: mxc_nand: use 
> 32bit copy functions, 2012-05-29), replacing memcpy_fromio() to force 32bit io 
> access. Are you sure the hypothetical memcpy16_fromio() would work?
according to the reference manual you can use 16-bit or 32-bit accesses.
And giving that in some cases the amount of valid data (in bytes) is ? 2
(mod 4) 16-bit access seem to be the obvious thing. Also Sascha only
wrote about byte accesses being problematic in 096bcc231fd2. So I'm
expecting that 16-bit operators should be fine.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2015-04-27  6:57 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-26  8:16 [PATCH 0/4] mtd: mxc_nand: fix 8 bit ECC and large oob Baruch Siach
2015-04-26  8:16 ` Baruch Siach
2015-04-26  8:16 ` [PATCH 1/4] mtd: nand: mxc_nand: cleanup copy_spare function Baruch Siach
2015-04-26  8:16   ` Baruch Siach
2015-04-26  8:16 ` [PATCH 2/4] mtd: mxc_nand: limit the size of used oob Baruch Siach
2015-04-26  8:16   ` Baruch Siach
2015-04-26 20:07   ` Uwe Kleine-König
2015-04-26 20:07     ` Uwe Kleine-König
2015-04-27  4:39     ` Baruch Siach
2015-04-27  4:39       ` Baruch Siach
2015-04-27  7:12       ` Uwe Kleine-König
2015-04-27  7:12         ` Uwe Kleine-König
2015-04-27  7:20         ` Baruch Siach
2015-04-27  7:20           ` Baruch Siach
2015-04-27  7:50           ` Uwe Kleine-König
2015-04-27  7:50             ` Uwe Kleine-König
2015-04-27 11:43             ` Baruch Siach
2015-04-27 11:43               ` Baruch Siach
2015-04-27 19:31               ` Uwe Kleine-König
2015-04-27 19:31                 ` Uwe Kleine-König
2015-04-29  6:18                 ` Baruch Siach
2015-04-29  6:18                   ` Baruch Siach
2015-04-29  6:35                   ` Uwe Kleine-König
2015-04-29  6:35                     ` Uwe Kleine-König
2015-04-30 15:20                     ` Fabio Estevam
2015-04-30 15:20                       ` Fabio Estevam
2015-05-03  7:55                       ` Baruch Siach
2015-05-03  7:55                         ` Baruch Siach
2015-04-26  8:16 ` [PATCH 3/4] mtd: mxc_nand: fix truncate of unaligned oob copying Baruch Siach
2015-04-26  8:16   ` Baruch Siach
2015-04-26 19:52   ` Uwe Kleine-König
2015-04-26 19:52     ` Uwe Kleine-König
2015-04-27  4:46     ` Baruch Siach
2015-04-27  4:46       ` Baruch Siach
2015-04-27  6:56       ` Uwe Kleine-König [this message]
2015-04-27  6:56         ` Uwe Kleine-König
2015-04-26  8:16 ` [PATCH 4/4] mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC Baruch Siach
2015-04-26  8:16   ` Baruch Siach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150427065657.GD19431@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=baruch@tkos.co.il \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=sha@pengutronix.de \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.