All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	stable@vger.kernel.org, linux-sunxi@googlegroups.com
Subject: Re: [PATCH v4] mtd: nand: sunxi: fix OOB handling in ->write_xxx() functions
Date: Mon, 14 Sep 2015 10:59:02 +0200	[thread overview]
Message-ID: <1472478.qiY0UY0ao8@wuerfel> (raw)
In-Reply-To: <1442220063-7520-1-git-send-email-boris.brezillon@free-electrons.com>

On Monday 14 September 2015 10:41:03 Boris Brezillon wrote:
>                 /* Fill OOB data in */
> -               if (oob_required) {
> -                       tmp = 0xffffffff;
> -                       memcpy_toio(nfc->regs + NFC_REG_USER_DATA_BASE, &tmp,
> -                                   4);
> -               } else {
> -                       memcpy_toio(nfc->regs + NFC_REG_USER_DATA_BASE,
> -                                   chip->oob_poi + offset - mtd->writesize,
> -                                   4);
> -               }
> +               writel(NFC_BUF_TO_USER_DATA(chip->oob_poi +
> +                                           layout->oobfree[i].offset),
> +                      nfc->regs + NFC_REG_USER_DATA_BASE);

This looks like you are changing the endianess of the data that gets written.
Is that intentional?

memcpy_toio() uses the same endianess for source and destination, while writel()
assumes that the destination is a little-endian register, and that could break
if the kernel is built to run as big-endian. I also see that sunxi_nfc_write_buf()
uses memcpy_toio() for writing the actual data, and you are not changing that.

If all hardware can do 32-bit accesses here and the size is guaranteed to be a
multiple of four bytes, you can probably improve performance by using a
__raw_writel() loop there. Using __raw_writel() in general is almost always
a bug, but here it actually makes sense. See also the powerpc implementation
of _memcpy_toio().

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4] mtd: nand: sunxi: fix OOB handling in ->write_xxx() functions
Date: Mon, 14 Sep 2015 10:59:02 +0200	[thread overview]
Message-ID: <1472478.qiY0UY0ao8@wuerfel> (raw)
In-Reply-To: <1442220063-7520-1-git-send-email-boris.brezillon@free-electrons.com>

On Monday 14 September 2015 10:41:03 Boris Brezillon wrote:
>                 /* Fill OOB data in */
> -               if (oob_required) {
> -                       tmp = 0xffffffff;
> -                       memcpy_toio(nfc->regs + NFC_REG_USER_DATA_BASE, &tmp,
> -                                   4);
> -               } else {
> -                       memcpy_toio(nfc->regs + NFC_REG_USER_DATA_BASE,
> -                                   chip->oob_poi + offset - mtd->writesize,
> -                                   4);
> -               }
> +               writel(NFC_BUF_TO_USER_DATA(chip->oob_poi +
> +                                           layout->oobfree[i].offset),
> +                      nfc->regs + NFC_REG_USER_DATA_BASE);

This looks like you are changing the endianess of the data that gets written.
Is that intentional?

memcpy_toio() uses the same endianess for source and destination, while writel()
assumes that the destination is a little-endian register, and that could break
if the kernel is built to run as big-endian. I also see that sunxi_nfc_write_buf()
uses memcpy_toio() for writing the actual data, and you are not changing that.

If all hardware can do 32-bit accesses here and the size is guaranteed to be a
multiple of four bytes, you can probably improve performance by using a
__raw_writel() loop there. Using __raw_writel() in general is almost always
a bug, but here it actually makes sense. See also the powerpc implementation
of _memcpy_toio().

	Arnd

  reply	other threads:[~2015-09-14  8:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14  8:41 [PATCH v4] mtd: nand: sunxi: fix OOB handling in ->write_xxx() functions Boris Brezillon
2015-09-14  8:41 ` Boris Brezillon
2015-09-14  8:59 ` Arnd Bergmann [this message]
2015-09-14  8:59   ` Arnd Bergmann
2015-09-14  9:41   ` Boris Brezillon
2015-09-14  9:41     ` Boris Brezillon
2015-09-14 11:49     ` Arnd Bergmann
2015-09-14 11:49       ` Arnd Bergmann
2015-09-14 12:36       ` Arnd Bergmann
2015-09-14 12:36         ` Arnd Bergmann
2015-09-14 17:02 ` Brian Norris
2015-09-14 17:02   ` Brian Norris
2015-09-21 20:43   ` Brian Norris
2015-09-21 20:43     ` Brian Norris

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=1472478.qiY0UY0ao8@wuerfel \
    --to=arnd@arndb.de \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=stable@vger.kernel.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 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.