Skip to contentSkip to conversation

mtd: nand: fix shutdown/reboot for multi-chip systems

PATCH Applied Brian Norris 3 participants 4 messages Nov 10, 2015 – Nov 16, 2015

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

PATCH 1/1 mtd: nand: fix shutdown/reboot for multi-chip systems

If multiple NAND chips are registered to the same controller, then when rebooting the system, the first one will grab the controller lock, while the second will wait forever for the first one to release it. i.e., a classic deadlock.

This problem was solved for a similar case (suspend/resume) back in commit 6b0d9a841249 ("mtd: nand: fix multi-chip suspend problem"), and the shutdown state really isn't much different for us, so rather than adding a new special case to nand_get_device(), we can just overload the FL_PM_SUSPENDED state.

Now, multiple chips can "get" the same controller lock (preventing further I/O), while we still allow other chips to pass through nand_shutdown().

Original report:
http://thread.gmane.org/gmane.linux.drivers.mtd/59726
http://lists.infradead.org/pipermail/linux-mtd/2015-July/059992.html

Fixes 72ea403669c7 ("mtd: nand: added nand_shutdown")
Cc Scott Branden <[email protected]>
Cc Andrew E. Mileski <[email protected]>

---
I only compile-tested

If we get proper tests, this is probably 4.4 material

 drivers/mtd/nand/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +1 -1
index cc74142938b0..ece544efccc3 100644
@@ -3110,7 +3110,7 @@ static void nand_resume(struct mtd_info *mtd)
  */
 static void nand_shutdown(struct mtd_info *mtd)
 {
-	nand_get_device(mtd, FL_SHUTDOWN);
+	nand_get_device(mtd, FL_PM_SUSPENDED);
 }
 
 /* Set default functions */
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
Acked-by on v1 1/1
#1 lore raw
Quoted 24 lines · Brian Norris

If multiple NAND chips are registered to the same controller, then when rebooting the system, the first one will grab the controller lock, while the second will wait forever for the first one to release it. i.e., a classic deadlock.

This problem was solved for a similar case (suspend/resume) back in commit 6b0d9a841249 ("mtd: nand: fix multi-chip suspend problem"), and the shutdown state really isn't much different for us, so rather than adding a new special case to nand_get_device(), we can just overload the FL_PM_SUSPENDED state.

Now, multiple chips can "get" the same controller lock (preventing further I/O), while we still allow other chips to pass through nand_shutdown().

Original report:
http://thread.gmane.org/gmane.linux.drivers.mtd/59726
http://lists.infradead.org/pipermail/linux-mtd/2015-July/059992.html

Fixes 72ea403669c7 ("mtd: nand: added nand_shutdown")
Cc Scott Branden <[email protected]>
Cc Andrew E. Mileski <[email protected]>
Quoted 4 lines

---
I only compile-tested

If we get proper tests, this is probably 4.4 material

I reviewed the code in nand_get_device and it looks sane whether FL_SHUTDOWN or PL_PM_SUSPENDED is called.

Quoted 18 lines
  drivers/mtd/nand/nand_base.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +1 -1
index cc74142938b0..ece544efccc3 100644
@@ -3110,7 +3110,7 @@ static void nand_resume(struct mtd_info *mtd)
   */
  static void nand_shutdown(struct mtd_info *mtd)
  {
-	nand_get_device(mtd, FL_SHUTDOWN);
+	nand_get_device(mtd, FL_PM_SUSPENDED);
  }
 
  /* Set default functions */
Reviewed-by on v1 1/1
#2 lore raw
In reply to Brian Norris
Quoted 19 lines · On Mon, 9 Nov 2015 16:37:28 -0800 Brian Norris <[email protected]>…

If multiple NAND chips are registered to the same controller, then when rebooting the system, the first one will grab the controller lock, while the second will wait forever for the first one to release it. i.e., a classic deadlock.

This problem was solved for a similar case (suspend/resume) back in commit 6b0d9a841249 ("mtd: nand: fix multi-chip suspend problem"), and the shutdown state really isn't much different for us, so rather than adding a new special case to nand_get_device(), we can just overload the FL_PM_SUSPENDED state.

Now, multiple chips can "get" the same controller lock (preventing further I/O), while we still allow other chips to pass through nand_shutdown().

Original report:
http://thread.gmane.org/gmane.linux.drivers.mtd/59726
http://lists.infradead.org/pipermail/linux-mtd/2015-July/059992.html

Quoted 5 lines
Fixes 72ea403669c7 ("mtd: nand: added nand_shutdown")
Cc Scott Branden <[email protected]>
Cc Andrew E. Mileski <[email protected]>
Quoted 21 lines

---
I only compile-tested

If we get proper tests, this is probably 4.4 material

 drivers/mtd/nand/nand_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +1 -1
index cc74142938b0..ece544efccc3 100644
@@ -3110,7 +3110,7 @@ static void nand_resume(struct mtd_info *mtd)
  */
 static void nand_shutdown(struct mtd_info *mtd)
 {
-	nand_get_device(mtd, FL_SHUTDOWN);
+	nand_get_device(mtd, FL_PM_SUSPENDED);
 }
 
 /* Set default functions */
Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author Applied
#3 lore raw
In reply to Brian Norris
Quoted 19 lines · Brian Norris

If multiple NAND chips are registered to the same controller, then when rebooting the system, the first one will grab the controller lock, while the second will wait forever for the first one to release it. i.e., a classic deadlock.

This problem was solved for a similar case (suspend/resume) back in commit 6b0d9a841249 ("mtd: nand: fix multi-chip suspend problem"), and the shutdown state really isn't much different for us, so rather than adding a new special case to nand_get_device(), we can just overload the FL_PM_SUSPENDED state.

Now, multiple chips can "get" the same controller lock (preventing further I/O), while we still allow other chips to pass through nand_shutdown().

Original report:
http://thread.gmane.org/gmane.linux.drivers.mtd/59726
http://lists.infradead.org/pipermail/linux-mtd/2015-July/059992.html

Quoted 5 lines
Fixes 72ea403669c7 ("mtd: nand: added nand_shutdown")
Cc Scott Branden <[email protected]>
Cc Andrew E. Mileski <[email protected]>

Pushed to linux-mtd.git