From: <Tudor.Ambarus@microchip.com>
To: <vigneshr@ti.com>, <miquel.raynal@bootlin.com>, <richard@nod.at>
Cc: marek.vasut@gmail.com, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org, tmaimon77@gmail.com,
bbrezillon@kernel.org
Subject: Re: [PATCH v4 1/3] mtd: spi-nor: always use bounce buffer for register read/writes
Date: Mon, 5 Aug 2019 09:06:47 +0000 [thread overview]
Message-ID: <b125bf29-f1fd-6d33-4a7c-49cb94ef1488@microchip.com> (raw)
In-Reply-To: <20190801162229.28897-2-vigneshr@ti.com>
On 08/01/2019 07:22 PM, Vignesh Raghavendra wrote:
> External E-Mail
>
>
> spi-mem layer expects all buffers passed to it to be DMA'able. But
> spi-nor layer mostly allocates buffers on stack for reading/writing to
> registers and therefore are not DMA'able. Introduce bounce buffer to be
> used to read/write to registers. This ensures that buffer passed to
> spi-mem layer during register read/writes is DMA'able. With this change
> nor->cmd-buf is no longer used, so drop it.
>
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
>
> v4:
> Avoid memcpy during READID
>
> v3: new patch
>
> drivers/mtd/spi-nor/spi-nor.c | 70 ++++++++++++++++++++---------------
> include/linux/mtd/spi-nor.h | 7 +++-
> 2 files changed, 45 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 03cc788511d5..e02376e1127b 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
cut
> /**
> @@ -1404,9 +1401,11 @@ static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr)
> {
> int ret;
>
> + memcpy(nor->bouncebuf, sr_cr, 2);
I'm thinking out loud. This can be avoided by forcing all the callers to use
nor->bouncebuf. That would result in a:
static int write_sr(struct spi_nor *nor, size_t len)
write_sr_cr() can be removed. Memcopying 2 bytes is a small price to pay, we can
keep things as they are, to not be too invasive. But if you think that this idea
is worth it, tell.
> +
> write_enable(nor);
>
> - ret = nor->write_reg(nor, SPINOR_OP_WRSR, sr_cr, 2);
> + ret = nor->write_reg(nor, SPINOR_OP_WRSR, nor->bouncebuf, 2);
> if (ret < 0) {
> dev_err(nor->dev,
> "error while writing configuration register\n");
cut
> @@ -2177,9 +2176,10 @@ static const struct flash_info spi_nor_ids[] = {
> static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
> {
> int tmp;
> - u8 id[SPI_NOR_MAX_ID_LEN];
> + u8 *id;
> const struct flash_info *info;
>
> + id = nor->bouncebuf;
nit: do init at declaration.
Also, you missed a place in which you can use the bouncebuf, search by "read_reg(":
ret = nor->read_reg(nor, SPINOR_OP_XRDSR, &val, 1);
Cheers,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2019-08-05 9:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 16:22 [PATCH v4 0/3] Merge m25p80 into spi-nor Vignesh Raghavendra
2019-08-01 16:22 ` [PATCH v4 1/3] mtd: spi-nor: always use bounce buffer for register read/writes Vignesh Raghavendra
2019-08-05 9:06 ` Tudor.Ambarus [this message]
2019-08-05 10:38 ` Vignesh Raghavendra
2019-08-05 11:24 ` Tudor.Ambarus
2019-08-01 16:22 ` [PATCH v4 2/3] mtd: spi-nor: Move m25p80 code in spi-nor.c Vignesh Raghavendra
2019-08-05 10:25 ` Tudor.Ambarus
2019-08-05 11:10 ` Vignesh Raghavendra
2019-08-05 11:51 ` Tudor.Ambarus
2019-08-05 12:31 ` Vignesh Raghavendra
2019-08-01 16:22 ` [PATCH v4 3/3] mtd: spi-nor: Rework hwcaps selection for the spi-mem case Vignesh Raghavendra
2019-08-05 17:45 ` Tudor.Ambarus
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=b125bf29-f1fd-6d33-4a7c-49cb94ef1488@microchip.com \
--to=tudor.ambarus@microchip.com \
--cc=bbrezillon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=tmaimon77@gmail.com \
--cc=vigneshr@ti.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 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).