linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Albrecht Dreß" <albrecht.dress@arcor.de>
To: stephan@gatzka.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org
Subject: Re: MPC5200b jffs2 memcpy alignment problem
Date: Sat, 30 Jun 2012 22:09:43 +0200	[thread overview]
Message-ID: <1341086991.2252.0@antares> (raw)
In-Reply-To: <4FEF5098.8070602@gatzka.org> (from stephan@gatzka.org on Sat Jun 30 21:16:40 2012)

[-- Attachment #1: Type: text/plain, Size: 2223 bytes --]

Hi Stephan:

Am 30.06.12 21:16 schrieb(en) Stephan Gatzka:
> I have a problem running jffs2 on an MPC5200b board. I run kernel 3.4, but older kernels like 3.1.5 are also affected. Every time I mount jffs2, previously written content gets garbled.
> 
> The problem was nailed down to memcpy(&fd->name, rd->name, checkedlen); in jffs2_scan_dirent_node in fs/jffs2/scan.c.
[snip]
> 2. use memcpy_fromio in the jffs2 code. memcpy_fromio behaves exactly in the way I described above. This could be also a good solution because flash access via LocalPlus bus is clearly IO.

I don't recall who proposed this patch, but exactly this solution is around for a longer time (mayby you search archives...).  On my board, I have a flash chip attached to the LocalBus in 16-bit mode.  Based on 3.2.16, the patch is:

---8<----------------------------------------------------------------------------
--- linux-3.2.16-orig/fs/jffs2/scan.c   2012-04-23 00:31:32.000000000 +0200
+++ linux-3.2.16/fs/jffs2/scan.c        2012-04-27 13:23:06.000000000 +0200
@@ -509,7 +509,11 @@
                                         sumptr = kmalloc(sumlen, GFP_KERNEL);
                                         if (!sumptr)
                                                 return -ENOMEM;
+#ifdef CONFIG_PPC_MPC52xx
+                                       memcpy_fromio(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len);
+#else
                                         memcpy(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len);
+#endif
                                 }
                                 if (buf_len < sumlen) {
                                         /* Need to read more so that the entire summary node is present */
@@ -1039,7 +1043,11 @@
         if (!fd) {
                 return -ENOMEM;
         }
+#ifdef CONFIG_PPC_MPC52xx
+       memcpy_fromio(&fd->name, rd->name, checkedlen);
+#else
         memcpy(&fd->name, rd->name, checkedlen);
+#endif
         fd->name[checkedlen] = 0;

         crc = crc32(0, fd->name, rd->nsize);
---8<----------------------------------------------------------------------------

Works perfectly with it...

Hope this helps,
Albrecht.

[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

  reply	other threads:[~2012-06-30 20:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-30 19:16 MPC5200b jffs2 memcpy alignment problem Stephan Gatzka
2012-06-30 20:09 ` Albrecht Dreß [this message]
2012-07-01  6:47   ` Stephan Gatzka
2012-07-01 13:50     ` William F.
2012-07-02 10:21     ` Anatolij Gustschin
2012-07-02 16:41       ` Stephan Gatzka

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=1341086991.2252.0@antares \
    --to=albrecht.dress@arcor.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=stephan@gatzka.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;
as well as URLs for NNTP newsgroup(s).