Skip to contentSkip to conversation

mtd: spi-nor: Add prep/unprep for spi_nor_resume

PATCH In review Han Xu 2 participants 3 messages Apr 24, 2019 – Jun 6, 2019

Subsystems (2)
lore
Share & tools
lore

Han Xu

author
#0 lore raw

PATCH 1/1 mtd: spi-nor: Add prep/unprep for spi_nor_resume

In the new implemented spi_nor_resume function, the spi_nor_init() should be braced by prep/unprep functions._

---
 drivers/mtd/spi-nor/spi-nor.c | 8 ++++++++
 include/linux/mtd/spi-nor.h   | 1 +
 2 files changed, 9 insertions(+)
drivers/mtd/spi-nor/spi-nor.c +8 -0
index 73172d7f512b..f6491885fa4f 100644
@@ -3956,10 +3956,18 @@ static void spi_nor_resume(struct mtd_info *mtd)
 	struct device *dev = nor->dev;
 	int ret;
 
+	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_RESUME);
+	if (ret) {
+		dev_err(dev, "prepare() failed\n");
+		return;
+	}
+
 	/* re-initialize the nor chip */
 	ret = spi_nor_init(nor);
 	if (ret)
 		dev_err(dev, "resume() failed\n");
+
+	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_RESUME);
 }
 
 void spi_nor_restore(struct spi_nor *nor)
include/linux/mtd/spi-nor.h +1 -0
index b3d360b0ee3d..50cf71dd7e9e 100644
@@ -231,6 +231,7 @@ enum spi_nor_ops {
 	SPI_NOR_OPS_ERASE,
 	SPI_NOR_OPS_LOCK,
 	SPI_NOR_OPS_UNLOCK,
+	SPI_NOR_OPS_RESUME,
 };
 
 enum spi_nor_option_flags {
Signature · 1 line
2.17.1
#1 lore raw

Hi, Han,

Quoted 6 lines · Han Xu

External E-Mail

In the new implemented spi_nor_resume function, the spi_nor_init() should be braced by prep/unprep functions._

Would you please explain why this is needed? Have you tried a suspend/resume cycle while a write was in progress and it failed?

Thanks,
ta

author
#2 lore raw
Quoted 22 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Thursday, June 6, 2019 12:46 AM
To: Han Xu <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH] mtd: spi-nor: Add prep/unprep for spi_nor_resume

Caution: EXT Email

Hi, Han,

Quoted 3 lines · Han Xu

External E-Mail

Quoted 6 lines
Quoted 3 lines

In the new implemented spi_nor_resume function, the spi_nor_init() should be braced by prep/unprep functions._

Would you please explain why this is needed? Have you tried a suspend/resume cycle while a write was in progress and it failed?

Same as all other functions that hooked up with mtd ops, such as _read/_write/_lock/_unlock, the _resume function also need to call the lower level controller's prep/unprep functions to properly handle runtime pm and mutex.

I didn't try suspend/resume during writing, but found accessing registers without enabling clock when system resumed.

Quoted 3 lines

Thanks,
ta