All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Sanjay Tandel <sanjay.tandel@rockwellcollins.com>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>,
	Matt Weber <matthew.weber@rockwellcollins.com>,
	linux-mtd <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] map-ram chip driver: 16-bit block transfer
Date: Fri, 11 Aug 2017 21:42:56 +0200	[thread overview]
Message-ID: <CAK8P3a24mHdgqQoVJJ+DzSkudBQ-OH7zhoN9_vkDsNQv0jyryw@mail.gmail.com> (raw)
In-Reply-To: <CAB0kKmyMK_vWTtyKcn4Li__9Q9AanSTEqCzPBmCUJA5XH4YKaA@mail.gmail.com>

On Fri, Aug 11, 2017 at 7:57 PM, Sanjay Tandel
<sanjay.tandel@rockwellcollins.com> wrote:

>>>> +{
>>>> +     const unsigned char *t = to;
>>>> +
>>>> +     if (!(IS_ALIGNED((u32)from, sizeof(u16)))) {
>>>> +             from = (void __iomem *)ALIGN((u32)from, sizeof(u16))
>>>> +                                                     - sizeof(u16);
>>>> +             *(u8 *)t = (u8)((readw(from) & 0xff00) >> 8);
>>>> +             count--;
>>>> +             t++;
>>>> +             from += 2;
>>>> +     }
>>>> +     while (count >= 2) {
>>>> +             *(u16 *)t = readw(from);
>>>> +             count -= 2;
>>>> +             t += 2;
>>>> +             from += 2;
>>>> +     };
>>>> +     while (count > 0) {
>>>> +             *(u8 *)t = (u8)(readw(from) & 0x00ff);
>>>> +             count--;
>>>> +             t++;
>>>> +             from++;
>>>> +     }
>>>> +}
>>
>> This looks wrong on bit-endian kernels, which do a byte-swap
>> in readw. This is one of the few places that probably should use
>> __raw_readw().
>>
>
> Okay. will provide this change with fix-up patch.

On second thought, __raw_readw() can get combined into 32-bit
accesses on some architectures. If you want to be sure you use only
16-bit reads, then cpu_to_le32(readw_relaxed(from)) would be
the safer option.

      Arnd

  reply	other threads:[~2017-08-11 19:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 13:02 [PATCH] map-ram chip driver: 16-bit block transfer Matt Weber
2017-08-09 18:10 ` Boris Brezillon
2017-08-09 19:51   ` Arnd Bergmann
2017-08-11 17:57     ` Sanjay Tandel
2017-08-11 19:42       ` Arnd Bergmann [this message]
2017-08-11 16:50   ` Sanjay Tandel
2017-08-11 19:41     ` Arnd Bergmann
2017-08-11 21:03       ` Sanjay Tandel
2017-08-11 21:30         ` Arnd Bergmann
2017-08-11 23:42           ` Sanjay Tandel
2017-08-12 17:39             ` Boris Brezillon
2017-08-14  8:08               ` Arnd Bergmann
2017-08-14 16:33                 ` Sanjay Tandel
2017-08-29  2:23                 ` Matthew Weber
2017-08-29  7:12                   ` Boris Brezillon

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=CAK8P3a24mHdgqQoVJJ+DzSkudBQ-OH7zhoN9_vkDsNQv0jyryw@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=boris.brezillon@free-electrons.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matthew.weber@rockwellcollins.com \
    --cc=sanjay.tandel@rockwellcollins.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.