linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Tudor.Ambarus@microchip.com>
To: <boris.brezillon@bootlin.com>, <marek.vasut@gmail.com>,
	<dwmw2@infradead.org>, <computersforpeace@gmail.com>,
	<richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<yogeshnarayan.gaur@nxp.com>, <cyrille.pitchen@wedev4u.fr>,
	<Tudor.Ambarus@microchip.com>
Subject: [PATCH v2 1/5] mtd: spi-nor: don't drop sfdp data if optional parsers fail
Date: Fri, 9 Nov 2018 16:56:48 +0000	[thread overview]
Message-ID: <20181109165644.30534-2-tudor.ambarus@microchip.com> (raw)
In-Reply-To: <20181109165644.30534-1-tudor.ambarus@microchip.com>

JESD216C states that just the Basic Flash Parameter Table is mandatory.
Already defined (or future) additional parameter headers and tables are
optional.

Don't drop already collected sfdp data in case an optional table
parser fails. In case of failing, each optional parser is responsible
to roll back to the previously known spi_nor data.

Fixes: b038e8e3be72 ("mtd: spi-nor: parse SFDP Sector Map Parameter Table")
Reported-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com>
Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
v2: update Fixes tag to point to correct commit

 drivers/mtd/spi-nor/spi-nor.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 4a96ee719e5a..2cdf96013689 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -3130,7 +3130,7 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
 	if (err)
 		goto exit;
 
-	/* Parse other parameter headers. */
+	/* Parse optional parameter tables. */
 	for (i = 0; i < header.nph; i++) {
 		param_header = &param_headers[i];
 
@@ -3143,8 +3143,17 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
 			break;
 		}
 
-		if (err)
-			goto exit;
+		if (err) {
+			dev_warn(dev, "Failed to parse optional parameter table: %04x\n",
+				 SFDP_PARAM_HEADER_ID(param_header));
+			/*
+			 * Let's not drop all information we extracted so far
+			 * if optional table parsers fail. In case of failing,
+			 * each optional parser is responsible to roll back to
+			 * the previously known spi_nor data.
+			 */
+			err = 0;
+		}
 	}
 
 exit:
-- 
2.9.4


  reply	other threads:[~2018-11-09 16:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09 16:56 [PATCH v2 0/5] mtd: spi-nor: fixes found when debugging smpt Tudor.Ambarus
2018-11-09 16:56 ` Tudor.Ambarus [this message]
2018-11-13  6:29   ` [PATCH v2 1/5] mtd: spi-nor: don't drop sfdp data if optional parsers fail Yogesh Narayan Gaur
2018-11-15 13:25   ` [v2,1/5] " Boris Brezillon
2018-11-09 16:56 ` [PATCH v2 2/5] mtd: spi-nor: fix iteration over smpt array Tudor.Ambarus
2018-11-15 13:25   ` [v2,2/5] " Boris Brezillon
2018-11-09 16:56 ` [PATCH v2 3/5] mtd: spi-nor: don't overwrite errno in spi_nor_get_map_in_use() Tudor.Ambarus
2018-11-15 13:25   ` [v2, " Boris Brezillon
2018-11-09 16:56 ` [PATCH v2 4/5] mtd: spi_nor: pass DMA-able buffer to spi_nor_read_raw() Tudor.Ambarus
2018-11-15 13:25   ` [v2,4/5] " Boris Brezillon
2018-11-09 16:56 ` [PATCH v2 5/5] mtd: spi-nor: remove unneeded smpt zeroization Tudor.Ambarus
2018-11-15 13:38   ` [v2,5/5] " Boris Brezillon

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=20181109165644.30534-2-tudor.ambarus@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=yogeshnarayan.gaur@nxp.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).