All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Srikanth Boyapally" <srikanth.boyapally@amd.com>,
	"Pratyush Yadav" <pratyush@kernel.org>,
	"Michael Walle" <mwalle@kernel.org>,
	"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org, michal.simek@amd.com, git@amd.com,
	"Sai Krishna Potthuri" <sai.krishna.potthuri@amd.com>
Subject: Re: [PATCH v2 2/2] mtd: spi-nor: Reset flash device on resume
Date: Tue, 01 Dec 2026 12:50:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-243311@kernel.org> (raw)
In-Reply-To: <20261201-ospi_reset_v2-v2-2-ceb06548d531@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mtd: spi-nor: spi_nor_resume() calls spi_nor_init() on 4-byte
  mode failure
--

commit 4cc851bee16e0903423a0be769db3ce9037e0647
Author: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>

mtd: spi-nor: Reset flash device on resume

This commit resets the SPI NOR flash via its hardware reset GPIO during
resume and restores 4-byte address mode if it was in use before calling
spi_nor_init().

> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 0e0960bc6f63f..0166f2b332469 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c

[ ... ]

> @@ -3188,6 +3191,24 @@ static void spi_nor_resume(struct mtd_info *mtd)
>  	struct device *dev = nor->dev;
>  	int ret;
>  
> +	/*
> +	 * Reset the flash to a known state before reinitializing it. The reset
> +	 * returns the flash to its power-on address mode, which is 3-byte
> +	 * addressing unless configured otherwise in non-volatile memory.
> +	 * Re-enter 4-byte address mode if it was in use, so that the flash
> +	 * matches the cached address mode used by spi_nor_init().
> +	 */
> +	if (nor->reset) {
> +		spi_nor_hw_reset(nor);
> +
> +		if (nor->params->addr_mode_nbytes == 4) {
> +			ret = spi_nor_set_4byte_addr_mode(nor, true);
> +			if (ret)
> +				dev_err(dev, "failed to enter 4-byte address mode: %d\n",
> +					ret);
> +		}
> +	}
> +
>  	/* re-initialize the nor chip */
>  	ret = spi_nor_init(nor);
>  	if (ret)

[Severity: Medium]
Should spi_nor_resume() return early when spi_nor_set_4byte_addr_mode()
fails?

When spi_nor_set_4byte_addr_mode() returns an error, the flash remains in
its power-on 3-byte address mode while nor->params->addr_mode_nbytes stays
4.  Falling through to spi_nor_init() will then issue volatile register
writes with 4-byte addresses (such as micron_st_nor_octal_dtr_en()),
causing the flash to treat the fourth address byte as data written to the
wrong configuration register.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-ospi_reset_v2-v2-0-ceb06548d531@amd.com?part=2

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

      reply	other threads:[~2026-12-01 12:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:38 [PATCH v2 0/2] mtd: spi-nor: Add flash reset support during resume Srikanth Boyapally
2026-12-01 12:38 ` Srikanth Boyapally
2026-12-01 12:38 ` [PATCH v2 1/2] mtd: spi-nor: Store GPIO info for resetting device " Srikanth Boyapally
2026-12-01 12:38   ` Srikanth Boyapally
2026-12-01 12:38 ` [PATCH v2 2/2] mtd: spi-nor: Reset flash device on resume Srikanth Boyapally
2026-12-01 12:38   ` Srikanth Boyapally
2026-12-01 12:50   ` sashiko-bot [this message]

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=sashiko-outbox-243311@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=git@amd.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=michal.simek@amd.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=sai.krishna.potthuri@amd.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=srikanth.boyapally@amd.com \
    --cc=takahiro.kuwano@infineon.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 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.