From: Andrey Volkov <avolkov@varma-el.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sylvain Munaut <tnt@246tNt.com>,
Paul Mackerras <paulus@samba.org>,
Linuxppc-embedded <Linuxppc-embedded@ozlabs.org>
Subject: Re: MPC5200 + LocalPlus Bus + memcpy
Date: Thu, 6 Apr 2006 18:21:44 +0400 [thread overview]
Message-ID: <583603349.20060406182144@varma-el.com> (raw)
In-Reply-To: <20060405113825.GA9110@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]
Hello, Sascha.
On Wednesday, April 5, 2006, Sascha Hauer wrote:
> Hi all,
> I try to use jffs2 on a flash device connected to the mpc5200
> LocalPlus Bus. This bus does not allow misaligned accesses.
> The jffs2 code uses memcpy to copy from a word aligned address to an
> odd address. The ppc memcpy implementation first copies three bytes to get
> the target address word aligned, but then the source address is on an
> odd address. The following word accesses on this unaligned address fail
> badly.
Invalid crc on 'name' field ;)?
> I have fixed my problem by modifying the physmap mtd driver, but some
> day someone wants to connect SRAM to the LocalPlus Bus and I guess he
> will expect memcpy to work.
Heh, I'll have same problem. Patch (dirty hack)
attached (vs head of vanilla 2.6. tree)
> (BTW the arm implementation of memcpy seems to work around this problem)
Wrong, memcpy to/from SDRAM _may_ be unaligned, only
memcpy_fromio/memcpy_toio _must_ be aligned to even addresses.
P.S.
Paul, Sylvain, any suggestions to fix it?
AFAIK, memcpy_to/from_io must be it string.s, isn't it?
P.P.S Sacha if you start to write mscan driver, then please wait a
week, I planned to send my work to can-socket at next Friday.
--
Regards,
Andrey Volkov
[-- Attachment #2: mpc52xx_LPB_jffs2_hack.diff --]
[-- Type: application/octet-stream, Size: 1493 bytes --]
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index cf55b22..3bf61d6 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -831,7 +831,7 @@ static int jffs2_scan_dirent_node(struct
if (!fd) {
return -ENOMEM;
}
- memcpy(&fd->name, rd->name, rd->nsize);
+ memcpy_fromio(&fd->name, rd->name, rd->nsize);
fd->name[rd->nsize] = 0;
crc = crc32(0, fd->name, rd->nsize);
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index b919d8f..c2f173a 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -354,6 +354,29 @@ extern void _outsl_ns(volatile u32 __iom
#define memset_io(a,b,c) memset((void *)(a),(b),(c))
#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
+#elif defined (CONFIG_PPC_MPC52xx)
+static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
+{
+ volatile u8 __iomem *addr_u8 = addr;
+ for(;count>0;count--)
+ *addr_u8++ = val;
+}
+
+static inline void memcpy_fromio(void *dst,const volatile void __iomem *src, int count)
+{
+ const volatile u8 __iomem *src_u8 = src;
+ u8 *dst_u8 = dst;
+ for(;count>0;count--)
+ *dst_u8++ = *src_u8++;
+}
+
+static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
+{
+ const u8 *src_u8 = src;
+ volatile u8 __iomem *dst_u8 = dst;
+ for(;count>0;count--)
+ *dst_u8++ = *src_u8++;
+}
#else
static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
{
next prev parent reply other threads:[~2006-04-06 14:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-05 11:38 MPC5200 + LocalPlus Bus + memcpy Sascha Hauer
2006-04-06 14:21 ` Andrey Volkov [this message]
2006-04-07 7:37 ` Sascha Hauer
2006-04-07 8:57 ` Re[2]: " Andrey Volkov
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=583603349.20060406182144@varma-el.com \
--to=avolkov@varma-el.com \
--cc=Linuxppc-embedded@ozlabs.org \
--cc=paulus@samba.org \
--cc=s.hauer@pengutronix.de \
--cc=tnt@246tNt.com \
/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.