From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Oleksandr Ocheretnyi <oocheret@cisco.com>
Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com,
p.yadav@ti.com, michael@walle.cc, richard@nod.at,
vigneshr@ti.com, broonie@kernel.org,
linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org,
mauro.lima@eclypsium.com, lee.jones@linaro.org,
linux-kernel@vger.kernel.org, xe-linux-external@cisco.com
Subject: Re: [PATCH v2] mtd: spi-nor: handle unsupported FSR opcodes properly
Date: Thu, 16 Jun 2022 15:33:31 +0300 [thread overview]
Message-ID: <YqsjGx54+Gd8Aws/@lahna> (raw)
In-Reply-To: <20220616121446.293408-1-oocheret@cisco.com>
On Thu, Jun 16, 2022 at 05:14:45AM -0700, Oleksandr Ocheretnyi wrote:
> Originally commit 094d3b9 ("mtd: spi-nor: Add USE_FSR flag for n25q*
> entries") and following one 8f93826 ("mtd: spi-nor: micron-st: convert
> USE_FSR to a manufacturer flag") enabled SPINOR_OP_RDFSR opcode handling
> ability, however some controller drivers still cannot handle it properly
> in the micron_st_nor_ready() call what breaks some mtd callbacks with
> next error logs:
>
> mtdblock: erase of region [address1, size1] on "BIOS" failed
> mtdblock: erase of region [address2, size2] on "BIOS" failed
>
> The Intel SPI controller does not support low level operations, like
> reading the flag status register (FSR). It only exposes a set of high
> level operations for software to use. For this reason check the return
> value of micron_st_nor_read_fsr() and if the operation was not
> supported, use the status register value only. This allows the chip to
> work even when attached to Intel SPI controller (there are such systems
> out there).
>
> Signed-off-by: Oleksandr Ocheretnyi <oocheret@cisco.com>
> Link: https://lore.kernel.org/lkml/YmZUCIE%2FND82BlNh@lahna/
> ---
> PATCH v2 updates PATCH v1 taking into account changes from
> https://lore.kernel.org/linux-mtd/20220506105158.43613-1-mika.westerberg@linux.intel.com
> to check -EOPNOTSUPP value from micron_st_nor_read_fsr() as well.
>
> drivers/mtd/spi-nor/micron-st.c | 12 ++++++++++--
> drivers/spi/spi-intel.c | 3 ++-
> 2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-st.c
> index a96f74e0f568..fd52e8feea44 100644
> --- a/drivers/mtd/spi-nor/micron-st.c
> +++ b/drivers/mtd/spi-nor/micron-st.c
> @@ -399,8 +399,16 @@ static int micron_st_nor_ready(struct spi_nor *nor)
> return sr_ready;
>
> ret = micron_st_nor_read_fsr(nor, nor->bouncebuf);
> - if (ret)
> - return ret;
> + if (ret < 0) {
> + /*
> + * Some controllers, such as Intel SPI, do not support low
> + * level operations such as reading the flag status
> + * register. They only expose small amount of high level
> + * operations to the software. If this is the case we use
> + * only the status register value.
> + */
> + return (ret == -ENOTSUPP || ret == -EOPNOTSUPP) ? sr_ready : ret;
The -EOPNOTSUPP here is not needed as you change the Intel SPI driver in
the below.
> + }
>
> if (nor->bouncebuf[0] & (FSR_E_ERR | FSR_P_ERR)) {
> if (nor->bouncebuf[0] & FSR_E_ERR)
> diff --git a/drivers/spi/spi-intel.c b/drivers/spi/spi-intel.c
> index 50f42983b950..f0313a718d1b 100644
> --- a/drivers/spi/spi-intel.c
> +++ b/drivers/spi/spi-intel.c
> @@ -352,7 +352,8 @@ static int intel_spi_hw_cycle(struct intel_spi *ispi, u8 opcode, size_t len)
> val |= HSFSTS_CTL_FCYCLE_RDSR;
> break;
> default:
> - return -EINVAL;
> + dev_dbg(ispi->dev, "%#x not supported\n", opcode);
> + return -ENOTSUPP;
> }
>
> if (len > INTEL_SPI_FIFO_SZ)
> --
> 2.27.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2022-06-16 12:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BYAPR11MB27570C5DC510D0F37FC106E4CDF69@BYAPR11MB2757.namprd11.prod.outlook.com>
2022-04-25 7:55 ` mtd: spi-nor: fatal issue during the mtd_erase() calls mika.westerberg
2022-06-10 19:15 ` [PATCH] mtd: spi-nor: handle unsupported FSR opcodes properly Oleksandr Ocheretnyi
2022-06-13 6:18 ` Mika Westerberg
[not found] ` <BYAPR11MB27570F2863F7BCDFE629B3DFCDAA9@BYAPR11MB2757.namprd11.prod.outlook.com>
2022-06-15 9:49 ` Mika Westerberg
2022-06-15 18:10 ` Michael Walle
2022-06-15 19:11 ` [PATCH v2] " Oleksandr Ocheretnyi
2022-06-15 19:25 ` Mark Brown
2022-06-16 5:31 ` Mika Westerberg
[not found] ` <BYAPR11MB2757B1146457E3860389F4D1CDAC9@BYAPR11MB2757.namprd11.prod.outlook.com>
2022-06-16 10:35 ` Mika Westerberg
2022-06-16 12:14 ` Oleksandr Ocheretnyi
2022-06-16 12:33 ` Mika Westerberg [this message]
[not found] ` <BYAPR11MB2757CEBE99C3A0861928CD43CDAC9@BYAPR11MB2757.namprd11.prod.outlook.com>
2022-06-16 12:59 ` Mika Westerberg
[not found] ` <BYAPR11MB2757BD90C63B9F6A31E0600ACDAC9@BYAPR11MB2757.namprd11.prod.outlook.com>
2022-06-17 5:04 ` Mika Westerberg
2022-07-19 9:12 ` Tudor.Ambarus
2022-06-16 5:29 ` [PATCH] " Mika Westerberg
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=YqsjGx54+Gd8Aws/@lahna \
--to=mika.westerberg@linux.intel.com \
--cc=broonie@kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=mauro.lima@eclypsium.com \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=oocheret@cisco.com \
--cc=p.yadav@ti.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
--cc=xe-linux-external@cisco.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).