From: Eric Nelson <eric.nelson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] MMC and buffer alignment question
Date: Wed, 19 Mar 2014 11:18:02 -0700 [thread overview]
Message-ID: <5329DF5A.7090604@boundarydevices.com> (raw)
In-Reply-To: <5329D685.80402@tqsc.de>
Hi Markus and Wolfgang,
On 03/19/2014 10:40 AM, Markus Niebel wrote:
> Am 19.03.2014 15:44, wrote Wolfgang Denk:
>> Dear Eric Nelson,
>>
>> In message <5329A80B.9020908@boundarydevices.com> you wrote:
>>>
>>>> short question to the usage of the mmc command (and also the mmc
>>>> driver API): is it intended that mmc read / write may fail when the
>>>> supplied address in RAM is not aligned?
>>>
>>> If not intended, it is known.
>>
>> I consider this a known bug.
>>
>>>> ARMV7 will give output like this:
>>>>
>>>> U-Boot > mmc read 12000002 44 44
>>>>
>>> Why would you want to do this?
>>
>> For example, BMP images require loading on a +2 aligned address due to
>> their stupid header format. I ran into this before myself: it is
>> impossible to match both the alignment reuqirements of the bmp command
>> and the mmc read command at the same time. One must manually copy the
>> memory ragen again. This is a plain, stupid bug.
>>
>
> Exactly here it popped up ...
>
It seems to me that if you're resorting to using un-formatted
storage space to store a broken data structure (the BMP header),
you could just write it at an offset +2.
The BMP support is pretty difficult to use anyway (only supports
BMPV3 headers), so asking the user to know about the offset doesn't
seem onerous.
Also note that the patch I submitted recently handles the case
for gzipped files for those using cfb_console.
>>>> Special commands inside the mmc drivers and in env_mmc implement the
>>>> alignment magic. Shouldn't the mmc do the magic (and if neccesarry
>>>> provide help using temp buffers if needed) so that all users outside can
>>>> read / write without caring for special cases?
>>>
>>> Is there a use case here? There are plenty of memory addresses that
>>> won't work with commands like "mmc read".
>>
>
> env_mmc needs to care for cache aligned buffers - This was fixed some time ago
> for the redundant env case
>
>> "mmc read" and "mmc write" are operations that work on character
>> buffers, like all other file IO ops. These should not require any
>> specific alignment.
>>
>>> Is it worth **any** code to try and catch them?
>>
>> Definitely yes.
>>
IMHO, this seems like overkill. Should we also prevent over-writing
the stack or heap?
>
> So just as an idea - we could use a bounce buffer for mmc_bwrite / mmc_bread for the
> unaligned case. Is definitely slow but should work.
>
Note that "sata read/write" and "usb read/write" have the same issues.
Regards,
Eric
next prev parent reply other threads:[~2014-03-19 18:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 14:16 [U-Boot] MMC and buffer alignment question Markus Niebel
2014-03-19 14:22 ` Eric Nelson
2014-03-19 14:44 ` Wolfgang Denk
2014-03-19 17:40 ` Markus Niebel
2014-03-19 18:18 ` Eric Nelson [this message]
2014-03-19 19:17 ` Wolfgang Denk
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=5329DF5A.7090604@boundarydevices.com \
--to=eric.nelson@boundarydevices.com \
--cc=u-boot@lists.denx.de \
/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.