Commit c5d8c0cae4af7d78823d32fcd1c458ee1a1b5489

Authored by Kishore Kadiyala
Committed by David Woodhouse
1 parent 61cc8276fa

mtd: omap: fix subpage ecc issue with prefetch

When reading/writing a subpage (When HW ECC is not available/enabled)
for number of bytes not aligned to 4, the mis-aligned bytes are handled
first (by cpu copy method) before enabling the Prefetch engine to/from
'p'(start of buffer 'buf'). Then it reads/writes rest of the bytes with
the help of Prefetch engine, if available, or again using cpu copy method.
Currently, reading/writing of rest of bytes, is not done correctly since
its trying to read/write again to/from begining of buffer 'buf',
overwriting the mis-aligned bytes.

Read & write using prefetch engine got broken in commit '2c01946c'.
We never hit a scenario of not getting 'gpmc_prefetch_enable' call
success. So, problem did not get caught up.

Signed-off-by: Kishore Kadiyala <kishore.kadiyala@ti.com>
Signed-off-by: Vimal Singh <vimal.newwork@gmail.com>
Reported-by: Bryan DE FARIA <bdefaria@adeneo-embedded.com>
Cc: stable@kernel.org [2.6.35+]
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Showing 1 changed file with 5 additions and 7 deletions Side-by-side Diff

drivers/mtd/nand/omap2.c
... ... @@ -263,11 +263,10 @@
263 263 if (ret) {
264 264 /* PFPW engine is busy, use cpu copy method */
265 265 if (info->nand.options & NAND_BUSWIDTH_16)
266   - omap_read_buf16(mtd, buf, len);
  266 + omap_read_buf16(mtd, (u_char *)p, len);
267 267 else
268   - omap_read_buf8(mtd, buf, len);
  268 + omap_read_buf8(mtd, (u_char *)p, len);
269 269 } else {
270   - p = (u32 *) buf;
271 270 do {
272 271 r_count = gpmc_read_status(GPMC_PREFETCH_FIFO_CNT);
273 272 r_count = r_count >> 2;
... ... @@ -293,7 +292,7 @@
293 292 struct omap_nand_info, mtd);
294 293 uint32_t w_count = 0;
295 294 int i = 0, ret = 0;
296   - u16 *p;
  295 + u16 *p = (u16 *)buf;
297 296 unsigned long tim, limit;
298 297  
299 298 /* take care of subpage writes */
300 299  
301 300  
... ... @@ -309,11 +308,10 @@
309 308 if (ret) {
310 309 /* PFPW engine is busy, use cpu copy method */
311 310 if (info->nand.options & NAND_BUSWIDTH_16)
312   - omap_write_buf16(mtd, buf, len);
  311 + omap_write_buf16(mtd, (u_char *)p, len);
313 312 else
314   - omap_write_buf8(mtd, buf, len);
  313 + omap_write_buf8(mtd, (u_char *)p, len);
315 314 } else {
316   - p = (u16 *) buf;
317 315 while (len) {
318 316 w_count = gpmc_read_status(GPMC_PREFETCH_FIFO_CNT);
319 317 w_count = w_count >> 1;