From: Florian Schirmer <jolt@tuxbox.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Subject: Re: JFFS2 corruption
Date: Sun, 8 Feb 2004 18:02:42 +0100 [thread overview]
Message-ID: <200402081802.42325.jolt@tuxbox.org> (raw)
In-Reply-To: <1076241213.12587.240.camel@imladris.demon.co.uk>
[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]
Hi,
> Interesting. That would be a problem in map_copy_from(), which is either
> just memcpy_fromio() or a function provided by your map driver,
> depending on whether you have CONFIG_MTD_COMPLEX_MAPPINGS enabled.
>
> Can you check what memcpy_fromio() does directly? Try changing the
> definition of map_copy_from() in include/linux/mtd/map.h or
> drivers/mtd/maps/map_funcs.c or your map driver (depending on your
> configuration) to copy a byte at a time, and see if that fixes it.
Yeah. You're absolutely right. I should have checked cmdset2 before claiming
it is broken.
memcopy_fromio is memcpy on MIPS. I've checked the memcpy implementation in
arch/mips/lib/memcpy.S and it is using byte transfers for remaining byte
transfers. So i expect at least the MIPS and SH plattform to be broken for
non buswidth==1 setups. Haven't checked other archs yet.
I'm wondering what assumptions can be made about memcpy's access patterns?
Looks like nobody even guarantees a specific access type. But we need to make
sure every access to the flash matches the bus width, don't we?
My proposed solution would be to handle remaining transfers in
maps.h/map_funcs.c already. So that the arch code only has to handle full
transfers. See attached patch. I've to admit that its very hard/impossible to
detect the remaining byte size. BITS_PER_LONG / 2 seems at least the best
guess we can make. This will handle SH, MIPS32 and MIPS64 just fine.
> The '%zd' modifier is the correct way to print a size_t; the old %Z was
> a gcc-ism. It's supported by the 2.6 and I thought also the current 2.4
> kernels; what kernel are you using, precisely? It's a trivial patch to
> add it.
I'm still using what was provided by Broadcom/Linksys (2.4.20). So dont worry
about that. I've ported the Broadcom code over to current 2.4.x but went back
to 2.4.20 due to the jffs2 corruption.
Regards,
Florian
[-- Attachment #2: mtd-memcpy.diff --]
[-- Type: text/x-diff, Size: 1113 bytes --]
--- linux-bcm/include/linux/mtd/map.h-old 2003-05-28 14:42:22.000000000 +0200
+++ linux-bcm/include/linux/mtd/map.h 2004-02-08 17:43:55.398928752 +0100
@@ -156,7 +156,30 @@ static inline void map_write64(struct ma
static inline void map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
- memcpy_fromio(to, map->virt + from, len);
+#define MTD_ALIGN (4 - 1)
+//#define MTD_ALIGN ((BITS_PER_LONG / 2) - 1)
+ u64 buf;
+ ssize_t transfer;
+ ssize_t done = (map->buswidth == 1) ? len : (len & ~MTD_ALIGN);
+ memcpy_fromio(to, map->virt + from, done);
+ while (done < len) {
+ switch(map->buswidth) {
+ case 2:
+ buf = map_read16(map, from + done);
+ break;
+ case 4:
+ buf = map_read32(map, from + done);
+ break;
+ case 8:
+ buf = map_read64(map, from + done);
+ break;
+ }
+ transfer = len - done;
+ if (transfer > map->buswidth)
+ transfer = map->buswidth;
+ memcpy((void *)((unsigned long)to + done), &buf, transfer);
+ done += transfer;
+ }
}
static inline void map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
next prev parent reply other threads:[~2004-02-08 17:02 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-05 13:15 JFFS2 corruption Florian Schirmer
2004-02-08 10:37 ` David Woodhouse
2004-02-08 11:38 ` Florian Schirmer
2004-02-08 11:53 ` David Woodhouse
2004-02-08 17:02 ` Florian Schirmer [this message]
2004-02-08 17:13 ` David Woodhouse
2004-02-08 11:28 ` David Woodhouse
-- strict thread matches above, loose matches on Subject: below --
2004-02-19 16:48 JFFS2 Corruption simon
2004-02-23 11:07 ` simon
2004-02-24 9:48 ` simon
2004-02-24 12:00 ` David Woodhouse
2004-02-24 12:54 ` Simon Haynes
2004-02-24 13:04 ` Simon Haynes
2004-02-24 13:40 ` Simon Haynes
2004-02-24 14:22 ` David Woodhouse
2004-02-24 14:25 ` Simon Haynes
2004-02-24 14:56 ` David Woodhouse
2004-02-24 14:58 ` Simon Haynes
2004-02-24 15:35 ` David Woodhouse
2004-02-24 15:47 ` Simon Haynes
2004-02-24 16:14 ` David Woodhouse
2004-02-24 16:17 ` Simon Haynes
2004-02-24 16:51 ` David Woodhouse
2004-02-24 17:05 ` Simon Haynes
2004-02-24 18:05 ` David Woodhouse
2004-02-24 18:04 ` Simon Haynes
2004-02-25 9:49 ` simon
2004-02-25 10:25 ` David Woodhouse
2004-02-26 11:08 ` Simon Haynes
2004-02-26 11:55 ` David Woodhouse
2004-03-03 15:31 ` David Woodhouse
2004-03-08 15:10 ` Simon Haynes
2004-03-09 15:33 ` Simon Haynes
2004-03-16 16:14 ` David Woodhouse
2004-03-19 10:37 ` Simon Haynes
2004-03-19 11:11 ` David Woodhouse
2004-02-24 17:12 ` Simon Haynes
2004-02-24 16:55 ` David Woodhouse
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=200402081802.42325.jolt@tuxbox.org \
--to=jolt@tuxbox.org \
--cc=dwmw2@infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox