Skip to contentSkip to conversation

mtd: rawnand: gpmi: Suspend/resume fixes

PATCH Applied Esben Haabendal 3 participants 7 messages Jan 17, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover mtd: rawnand: gpmi: Suspend/resume fixes

This fixes a couple of suspend/resume problems in gpmi-nand driver, introduced in 5.3 with the implementation of exec_op for gpmi-nand driver.

Changes since v1:
- Fixed bug in gpmi_init() causing runtime pm becoming disabled
- Added Fixes tags and cc to stable
- Rebased to v5.5-rc6

Esben Haabendal (2):
mtd: rawnand: gpmi: Fix suspend/resume problem
mtd: rawnand: gpmi: Restore nfc timing setup after suspend/resume

 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 6 lines
2.25.0


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

PATCH v2 1/2 mtd: rawnand: gpmi: Fix suspend/resume problem

On system resume, the gpmi clock must be enabled before accessing gpmi block. Without this, resume causes something like

[  661.348790] gpmi_reset_block(5cbb0f7e): module reset timeout
[  661.348889] gpmi-nand 1806000.gpmi-nand: Error setting GPMI : -110
[  661.348928] PM: dpm_run_callback(): platform_pm_resume+0x0/0x44 returns -110
[  661.348961] PM: Device 1806000.gpmi-nand failed to resume: error -110
Fixes ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +6 -1
index 334fe3130285..879df8402446 100644
@@ -148,6 +148,10 @@ static int gpmi_init(struct gpmi_nand_data *this)
 	struct resources *r = &this->resources;
 	int ret;
 
+	ret = pm_runtime_get_sync(this->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = gpmi_reset_block(r->gpmi_regs, false);
 	if (ret)
 		goto err_out;
@@ -179,8 +183,9 @@ static int gpmi_init(struct gpmi_nand_data *this)
 	 */
 	writel(BM_GPMI_CTRL1_DECOUPLE_CS, r->gpmi_regs + HW_GPMI_CTRL1_SET);
 
-	return 0;
 err_out:
+	pm_runtime_mark_last_busy(this->dev);
+	pm_runtime_put_autosuspend(this->dev);
 	return ret;
 }
 
Signature · 1 line
2.25.0
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] mtd: rawnand: gpmi: Fix suspend/resume problem

Quoted 32 lines · Esben Haabendal

On system resume, the gpmi clock must be enabled before accessing gpmi block. Without this, resume causes something like

[  661.348790] gpmi_reset_block(5cbb0f7e): module reset timeout
[  661.348889] gpmi-nand 1806000.gpmi-nand: Error setting GPMI : -110
[  661.348928] PM: dpm_run_callback(): platform_pm_resume+0x0/0x44 returns -110
[  661.348961] PM: Device 1806000.gpmi-nand failed to resume: error -110
Fixes ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +4 -0
index 334fe3130285..879df8402446 100644
@@ -148,6 +148,10 @@ static int gpmi_init(struct gpmi_nand_data *this)
        struct resources *r = &this->resources;
        int ret;
 
+       ret = pm_runtime_get_sync(this->dev);
+       if (ret < 0)
+               return ret;
+
        ret = gpmi_reset_block(r->gpmi_regs, false);
        if (ret)
                goto err_out;

drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c static int gpmi_init(struct gpmi_nand_data *this) · line 191

Quoted 10 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +2 -1
@@ -179,8 +183,9 @@ static int gpmi_init(struct gpmi_nand_data *this)
         */
        writel(BM_GPMI_CTRL1_DECOUPLE_CS, r->gpmi_regs + HW_GPMI_CTRL1_SET);
 
-       return 0;
 err_out:
+       pm_runtime_mark_last_busy(this->dev);
+       pm_runtime_put_autosuspend(this->dev);
        return ret;
 }
 
Quoted 7 lines

--
2.25.0

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

Signature · 3 lines
Sincerely,

Han XU
maintainer Applied
#3 lore raw

Re: [PATCH v2 1/2] mtd: rawnand: gpmi: Fix suspend/resume problem

In reply to Esben Haabendal
Quoted 8 lines · Esben Haabendal

On system resume, the gpmi clock must be enabled before accessing gpmi block. Without this, resume causes something like

[  661.348790] gpmi_reset_block(5cbb0f7e): module reset timeout
[  661.348889] gpmi-nand 1806000.gpmi-nand: Error setting GPMI : -110
[  661.348928] PM: dpm_run_callback(): platform_pm_resume+0x0/0x44 returns -110
[  661.348961] PM: Device 1806000.gpmi-nand failed to resume: error -110
Quoted 4 lines
Fixes ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

#4 lore raw

PATCH v2 2/2 mtd: rawnand: gpmi: Restore nfc timing setup after suspend/resume

In reply to Esben Haabendal

As we reset the GPMI block at resume, the timing parameters setup by a previous exec_op is lost. Rewriting GPMI timing registers on first exec_op after resume fixes the problem.

Fixes ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +4 -0
index 879df8402446..b9d5d55a5edb 100644
@@ -2727,6 +2727,10 @@ static int gpmi_pm_resume(struct device *dev)
 		return ret;
 	}
 
+	/* Set flag to get timing setup restored for next exec_op */
+	if (this->hw.clk_rate)
+		this->hw.must_apply_timings = true;
+
 	/* re-init the BCH registers */
 	ret = bch_set_geometry(this);
 	if (ret) {
Signature · 1 line
2.25.0
Acked-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] mtd: rawnand: gpmi: Restore nfc timing setup after suspend/resume

Quoted 17 lines · Esben Haabendal

As we reset the GPMI block at resume, the timing parameters setup by a previous exec_op is lost. Rewriting GPMI timing registers on first exec_op after resume fixes the problem.

Fixes ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +0 -0
index 879df8402446..b9d5d55a5edb 100644

drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c static int gpmi_pm_resume(struct device *dev) · line 2733

Quoted 7 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +4 -0
@@ -2727,6 +2727,10 @@ static int gpmi_pm_resume(struct device *dev)
                return ret;
        }
 
+       /* Set flag to get timing setup restored for next exec_op */
+       if (this->hw.clk_rate)
+               this->hw.must_apply_timings = true;
+
Quoted 10 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +0 -1
        /* re-init the BCH registers */
        ret = bch_set_geometry(this);
        if (ret) {
--

2.25.0

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

Signature · 3 lines
Sincerely,

Han XU
maintainer Applied
#6 lore raw

Re: [PATCH v2 2/2] mtd: rawnand: gpmi: Restore nfc timing setup after suspend/resume

In reply to Esben Haabendal
Quoted 8 lines · Esben Haabendal

As we reset the GPMI block at resume, the timing parameters setup by a previous exec_op is lost. Rewriting GPMI timing registers on first exec_op after resume fixes the problem.

Fixes ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel