public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Stephan Gatzka <stephan@gatzka.org>
To: linux-mtd@lists.infradead.org, linuxppc-dev@lists.ozlabs.org
Subject: MPC5200b jffs2 memcpy alignment problem
Date: Sat, 30 Jun 2012 21:16:40 +0200	[thread overview]
Message-ID: <4FEF5098.8070602@gatzka.org> (raw)

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

Hello!

First of all, please apologize my cross posting.

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.

This is a copy directly from the mapped flash.

memcpy from copy_32.S only ensures that the 32 bit stores to the 
destination ptr are aligned. And that's the problem with the MPC5200b 
because the user manual (Chapter 9.2, LocalPlus bus features) clearly 
states that unaligned access is not supported. But the code above 
results in unaligned loads from the LocalPlus bus.

I think there are two possible solutions:

1. Rewrite memcpy this way: Only if both src and dst are 32 bit aligned, 
use 32 bit load/store to copy, otherwise use byte load/store 
instructions. (btw. is there a reason for not to use the load multiple 
and store multiple instructions in memcpy?) This might be the best way 
to do because in my opinion the semantics of memcpy put no restrictions 
on the alignment of src and dst.

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.

What is your opinion where to fix this problem?

Regards,

Stephan


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4931 bytes --]

             reply	other threads:[~2012-06-30 19:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-30 19:16 Stephan Gatzka [this message]
2012-06-30 20:09 ` MPC5200b jffs2 memcpy alignment problem Albrecht Dreß
2012-07-01  6:47   ` Stephan Gatzka
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=4FEF5098.8070602@gatzka.org \
    --to=stephan@gatzka.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.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