All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kelly Anderson <kelly@silka.with-linux.com>
To: linux-mtd@lists.infradead.org
Subject: Mtd alignment bug affecting 1.4.X including current git
Date: Mon, 28 Mar 2011 07:48:33 -0600	[thread overview]
Message-ID: <4D9091B1.80002@silka.with-linux.com> (raw)

Hello,

Hey there's a problem with mtd-utils starting with commit 
5dd7d09648bd4c1c87e7c155b960e500925571db
Versions starting with 1.4.X fail.
A SheevaPlug user report the problem, so I git bisected it.
The output from flash_eraseall is at the bottom (the alignments are all 
off by 2).
I looked at the problem and found (in current git) that it's passing 
"offset + clmpos".
I'm pretty sure that clmpos is 2 in this case.  mtd_write_oob is passing 
this to do_oob_op
as "start". do_oob_op is verifying alignment, but it's off by 2 so it fails.
It should be relatively easy to fix.  You probably need to check all of 
the calls to mtd_write_oob
and mtd_read_oob for proper behaviour.  If you create a patch I'll test 
it for you.

flash_erase.c:275
         if (isNAND) {
             if (mtd_write_oob(mtd_desc, &mtd, fd, offset + clmpos, 
clmlen, &cleanmarker) != 0) {
                 sys_errmsg("%s: MTD writeoob failure", mtd_device);
                 continue;
             }
         } else {


libmtd.c:1166
int mtd_write_oob(libmtd_t desc, const struct mtd_dev_info *mtd, int fd,
           uint64_t start, uint64_t length, void *data)
{
     return do_oob_op(desc, mtd, fd, start, length, data,
              MEMWRITEOOB64, MEMWRITEOOB);
}

libmtd.c:1105
     if (start % mtd->min_io_size) {
         errmsg("unaligned address %llu, mtd%d page size is %d",
                (unsigned long long)start, mtd->mtd_num,
                mtd->min_io_size);
         errno = EINVAL;
         return -1;
     }


5dd7d09648bd4c1c87e7c155b960e500925571db is the first bad commit
commit 5dd7d09648bd4c1c87e7c155b960e500925571db
Author: Kevin Cernekee <cernekee@gmail.com>
Date:   Fri Jul 23 17:46:15 2010 -0700

     mtd: change flash_eraseall to use libmtd-wrapped ioctls

     ERASE/ERASE64 were tested on 2.6.18 and 2.6.31. OOB is untested.

     Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
     Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

:100644 100644 e6f8d50ea41ff99260ef2528e50866380675d866 
a2a6b0a28ed5e6053c41524f3de686e81fdd5afa M      flash_eraseall.c


Erasing 128 Kibyte @ 0 --  0 % complete.libmtd: error!: unaligned 
address 2, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 20000 --  3 % complete.libmtd: error!: unaligned 
address 131074, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 40000 --  6 % complete.libmtd: error!: unaligned 
address 262146, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 60000 --  9 % complete.libmtd: error!: unaligned 
address 393218, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 80000 -- 12 % complete.libmtd: error!: unaligned 
address 524290, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ a0000 -- 15 % complete.libmtd: error!: unaligned 
address 655362, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ c0000 -- 18 % complete.libmtd: error!: unaligned 
address 786434, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ e0000 -- 21 % complete.libmtd: error!: unaligned 
address 917506, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 100000 -- 25 % complete.libmtd: error!: unaligned 
address 1048578, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 120000 -- 28 % complete.libmtd: error!: unaligned 
address 1179650, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 140000 -- 31 % complete.libmtd: error!: unaligned 
address 1310722, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 160000 -- 34 % complete.libmtd: error!: unaligned 
address 1441794, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 180000 -- 37 % complete.libmtd: error!: unaligned 
address 1572866, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 1a0000 -- 40 % complete.libmtd: error!: unaligned 
address 1703938, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 1c0000 -- 43 % complete.libmtd: error!: unaligned 
address 1835010, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 1e0000 -- 46 % complete.libmtd: error!: unaligned 
address 1966082, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 200000 -- 50 % complete.libmtd: error!: unaligned 
address 2097154, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 220000 -- 53 % complete.libmtd: error!: unaligned 
address 2228226, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 240000 -- 56 % complete.libmtd: error!: unaligned 
address 2359298, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 260000 -- 59 % complete.libmtd: error!: unaligned 
address 2490370, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 280000 -- 62 % complete.libmtd: error!: unaligned 
address 2621442, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 2a0000 -- 65 % complete.libmtd: error!: unaligned 
address 2752514, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 2c0000 -- 68 % complete.libmtd: error!: unaligned 
address 2883586, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 2e0000 -- 71 % complete.libmtd: error!: unaligned 
address 3014658, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 300000 -- 75 % complete.libmtd: error!: unaligned 
address 3145730, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 320000 -- 78 % complete.libmtd: error!: unaligned 
address 3276802, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 340000 -- 81 % complete.libmtd: error!: unaligned 
address 3407874, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 360000 -- 84 % complete.libmtd: error!: unaligned 
address 3538946, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 380000 -- 87 % complete.libmtd: error!: unaligned 
address 3670018, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 3a0000 -- 90 % complete.libmtd: error!: unaligned 
address 3801090, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 3c0000 -- 93 % complete.libmtd: error!: unaligned 
address 3932162, mtd0 page size is 2048

/usr/sbin/flash_eraseall: /dev/mtd0: MTD writeoob failure: Invalid argument
Erasing 128 Kibyte @ 3e0000 -- 96 % complete.libmtd: error!: unaligned 
address 4063234, mtd0 page size is 2048

             reply	other threads:[~2011-03-28 13:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28 13:48 Kelly Anderson [this message]
2011-04-01  8:11 ` Mtd alignment bug affecting 1.4.X including current git Artem Bityutskiy
2011-04-01  8:33   ` Kelly Anderson
2011-04-01  8:16 ` Artem Bityutskiy
2011-04-01  9:02   ` Kelly Anderson
2011-04-01 16:26     ` Artem Bityutskiy

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=4D9091B1.80002@silka.with-linux.com \
    --to=kelly@silka.with-linux.com \
    --cc=linux-mtd@lists.infradead.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.