linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Add prep/unprep for spi_nor_resume
@ 2019-04-24 21:08 Han Xu
  2019-06-06  5:45 ` Tudor.Ambarus
  0 siblings, 1 reply; 3+ messages in thread
From: Han Xu @ 2019-04-24 21:08 UTC (permalink / raw)
  To: cyrille.pitchen, marek.vasut
  Cc: boris.brezillon, f.fainelli, kdasu.kdev, richard, linux-kernel,
	linux-mtd, dl-linux-imx, computersforpeace

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

Signed-off-by: Han Xu <han.xu@nxp.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 8 ++++++++
 include/linux/mtd/spi-nor.h   | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 73172d7f512b..f6491885fa4f 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -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)
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index b3d360b0ee3d..50cf71dd7e9e 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -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 {
-- 
2.17.1

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: Add prep/unprep for spi_nor_resume
  2019-04-24 21:08 [PATCH] mtd: spi-nor: Add prep/unprep for spi_nor_resume Han Xu
@ 2019-06-06  5:45 ` Tudor.Ambarus
  2019-06-06 22:33   ` [EXT] " Han Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Tudor.Ambarus @ 2019-06-06  5:45 UTC (permalink / raw)
  To: han.xu, cyrille.pitchen, marek.vasut
  Cc: boris.brezillon, f.fainelli, kdasu.kdev, richard, linux-kernel,
	linux-mtd, linux-imx, computersforpeace

Hi, Han,

On 04/25/2019 12:08 AM, Han Xu wrote:
> 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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [EXT] Re: [PATCH] mtd: spi-nor: Add prep/unprep for spi_nor_resume
  2019-06-06  5:45 ` Tudor.Ambarus
@ 2019-06-06 22:33   ` Han Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Han Xu @ 2019-06-06 22:33 UTC (permalink / raw)
  To: Tudor.Ambarus, cyrille.pitchen, marek.vasut
  Cc: boris.brezillon, f.fainelli, kdasu.kdev, richard, linux-kernel,
	linux-mtd, dl-linux-imx, computersforpeace



> -----Original Message-----
> From: Tudor.Ambarus@microchip.com <Tudor.Ambarus@microchip.com>
> Sent: Thursday, June 6, 2019 12:46 AM
> To: Han Xu <han.xu@nxp.com>; cyrille.pitchen@wedev4u.fr;
> marek.vasut@gmail.com
> Cc: boris.brezillon@free-electrons.com; f.fainelli@gmail.com;
> kdasu.kdev@gmail.com; richard@nod.at; linux-kernel@vger.kernel.org;
> linux-mtd@lists.infradead.org; dl-linux-imx <linux-imx@nxp.com>;
> computersforpeace@gmail.com
> Subject: [EXT] Re: [PATCH] mtd: spi-nor: Add prep/unprep for
> spi_nor_resume
> 
> Caution: EXT Email
> 
> Hi, Han,
> 
> On 04/25/2019 12:08 AM, Han Xu wrote:
> > 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?

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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-06 22:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 21:08 [PATCH] mtd: spi-nor: Add prep/unprep for spi_nor_resume Han Xu
2019-06-06  5:45 ` Tudor.Ambarus
2019-06-06 22:33   ` [EXT] " Han Xu

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).