All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Daniel Golle <daniel@makrotopia.org>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Mason Yang <masonccyang@mxic.com.tw>,
	Jianhui Zhao <zhaojh329@gmail.com>
Subject: Re: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
Date: Mon, 30 Jan 2023 17:05:24 +0100	[thread overview]
Message-ID: <20230130170524.295c27af@xps-13> (raw)
In-Reply-To: <Y8i85zM0u4XdM46z@makrotopia.org>

Hi Daniel,

daniel@makrotopia.org wrote on Thu, 19 Jan 2023 03:45:43 +0000:

> The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
> read the eccsr, hence the buffer should not be on stack. Since commit
> 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
> the kernel emmits a warning and blocks such operations.
> 
> Use the scratch buffer to get eccsr instead of trying to directly read
> into a stack-allocated variable.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---

Looks like my scripts did not properly sent the "applied" e-mail, so
here it is, I applied this patch to nand/next.

>  drivers/mtd/nand/spi/macronix.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index dce835132a1e2..722a9738ba370 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
>  		 * in order to avoid forcing the wear-leveling layer to move
>  		 * data around if it's not necessary.
>  		 */
> -		if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
> +		if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
>  			return nanddev_get_ecc_conf(nand)->strength;
>  
> +		eccsr = *spinand->scratchbuf;
>  		if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
>  			    !eccsr))
>  			return nanddev_get_ecc_conf(nand)->strength;


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Daniel Golle <daniel@makrotopia.org>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Mason Yang <masonccyang@mxic.com.tw>,
	Jianhui Zhao <zhaojh329@gmail.com>
Subject: Re: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation
Date: Mon, 30 Jan 2023 17:05:24 +0100	[thread overview]
Message-ID: <20230130170524.295c27af@xps-13> (raw)
In-Reply-To: <Y8i85zM0u4XdM46z@makrotopia.org>

Hi Daniel,

daniel@makrotopia.org wrote on Thu, 19 Jan 2023 03:45:43 +0000:

> The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to
> read the eccsr, hence the buffer should not be on stack. Since commit
> 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param")
> the kernel emmits a warning and blocks such operations.
> 
> Use the scratch buffer to get eccsr instead of trying to directly read
> into a stack-allocated variable.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---

Looks like my scripts did not properly sent the "applied" e-mail, so
here it is, I applied this patch to nand/next.

>  drivers/mtd/nand/spi/macronix.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index dce835132a1e2..722a9738ba370 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
>  		 * in order to avoid forcing the wear-leveling layer to move
>  		 * data around if it's not necessary.
>  		 */
> -		if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr))
> +		if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf))
>  			return nanddev_get_ecc_conf(nand)->strength;
>  
> +		eccsr = *spinand->scratchbuf;
>  		if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength ||
>  			    !eccsr))
>  			return nanddev_get_ecc_conf(nand)->strength;


Thanks,
Miquèl

  parent reply	other threads:[~2023-01-30 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  3:45 [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation Daniel Golle
2023-01-19  3:45 ` Daniel Golle
2023-01-20  4:30 ` Dhruva Gole
2023-01-20  4:30   ` Dhruva Gole
2023-01-30 16:05 ` Miquel Raynal [this message]
2023-01-30 16:05   ` Miquel Raynal

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=20230130170524.295c27af@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=daniel@makrotopia.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=masonccyang@mxic.com.tw \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=zhaojh329@gmail.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.