mtd/nand: fix multi-chip suspend problem
Subsystems (2)
PATCH 4/4 mtd/nand: fix multi-chip suspend problem
From: Li Yang <[email protected]>
Symptom:device_suspend(): mtd_cls_suspend+0x0/0x58 returns -11
PM: Device mtd14 failed to suspend: error -11
PM: Some devices failed to suspend
This patch enables other chips to be suspended if the active chip of the controller has been suspended.
---
drivers/mtd/nand/nand_base.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problem +10 -4
@@ -697,10 +697,16 @@ nand_get_device(struct nand_chip *chip,spin_unlock (lock);return 0 ; } -if (new_state ==FL_PM_SUSPENDED ) { -spin_unlock (lock); -return (chip->state ==FL_PM_SUSPENDED ) ?0 : -EAGAIN ; - } +if (new_state ==FL_PM_SUSPENDED ) +if (chip->controller->active->state ==FL_PM_SUSPENDED ) { + chip->state =FL_PM_SUSPENDED ; +spin_unlock (lock); +return 0 ; + }else { +spin_unlock (lock); +return -EAGAIN ; + } +set_current_state (TASK_UNINTERRUPTIBLE );add_wait_queue (wq, &wait);spin_unlock (lock);
_
Quoted 32 lines · On Tue, 2009-11-17 at 14:45 -0800, [email protected] wrote:
From: Li Yang <[email protected]>
Symptom:
device_suspend():mtd_cls_suspend+0x0/0x58returns -11
PM: Device mtd14 failed to suspend: error -11
PM: Some devices failed to suspendThis patch enables other chips to be suspended if the active chip of the controller has been suspended.
Signed-off-by Jin Qing <[email protected]>Signed-off-by Li Yang <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
drivers/mtd/nand/nand_base.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)diff -puN
drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problemdrivers/mtd/nand/nand_base.cdrivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problem +3
-4@@ -697,10 +697,16 @@ nand_get_device(struct nand_chip *chip,spin_unlock (lock);return 0 ; } -if (new_state ==FL_PM_SUSPENDED ) { -spin_unlock (lock); -return (chip->state ==FL_PM_SUSPENDED ) ?0 : -EAGAIN ; - } +if (new_state ==FL_PM_SUSPENDED ) +if (chip->controller->active->state ==FL_PM_SUSPENDED ) { + chip->state =FL_PM_SUSPENDED ;
drivers/mtd/nand/nand_base.c nand_get_device(struct nand_chip *chip, · line 712
Quoted 10 lines
drivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problem +7
-0+spin_unlock (lock); +return 0 ; + }else { +spin_unlock (lock); +return -EAGAIN ; + } +set_current_state (TASK_UNINTERRUPTIBLE );add_wait_queue (wq, &wait);spin_unlock (lock);
This patch casing the following gcc warning:
drivers/mtd/nand/nand_base.c: In function ‘nand_get_device’:drivers/mtd/nand/nand_base.c:700: warning: suggest explicit braces to avoid ambiguous ‘else’
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Ubiformat --erase-counter not always used
Hello Artem,
This is not a bug report, just an observation on ubiformat. It only seems to take the --erase-counter parameter in certain situations. If you have alien data it seems to take it. If the blocks are FF erased or previously formatted correctly it seems to ignore the --erase-counter argument, even though it says it is using it (see below).
Should we add something in the online help or documentation to explain this better and maybe say in the ubiformat tool itself when the switch is getting used or ignored and why?
# ./ubiformat /dev/mtd4 -n --erase-counter=1234 -v -y ubiformat: mtd4 (NAND), size 2097152 bytes (2.0 MiB), 524288 eraseblocks of 524288 bytes (512.0 KiB), min. I/O size 4096 bytes libscan: start scanning eraseblocks 0-4 libscan: scanning eraseblock 0: alien libscan: scanning eraseblock 1: alien libscan: scanning eraseblock 2: alien libscan: scanning eraseblock 3: alien libscan: finished, mean EC 0, 0 OK, 0 corrupted, 0 empty, 4 alien, bad 0 ubiformat: warning!: 4 of 4 eraseblocks contain non-ubifs data ubiformat: use erase counter 1234 for all eraseblocks ubiformat: eraseblock 0: erase, write EC 1234 ubiformat: eraseblock 1: erase, write EC 1234 ubiformat: eraseblock 2: erase, write EC 1234 ubiformat: eraseblock 3: erase, write EC 1234 192.168.1.105 # ./ubiformat /dev/mtd4 -n --erase-counter=5432 -v -y ubiformat: mtd4 (NAND), size 2097152 bytes (2.0 MiB), 524288 eraseblocks of 524288 bytes (512.0 KiB), min. I/O size 4096 bytes libscan: start scanning eraseblocks 0-4 libscan: scanning eraseblock 0: OK, erase counter 1234 libscan: scanning eraseblock 1: OK, erase counter 1234 libscan: scanning eraseblock 2: OK, erase counter 1234 libscan: scanning eraseblock 3: OK, erase counter 1234 libscan: finished, mean EC 1234, 4 OK, 0 corrupted, 0 empty, 0 alien, bad 0 ubiformat: 4 eraseblocks have valid erase counter, mean value is 1234 ubiformat: use erase counter 5432 for all eraseblocks <------------------ Didn't take this value ubiformat: eraseblock 0: erase, write EC 1235 ubiformat: eraseblock 1: erase, write EC 1235 ubiformat: eraseblock 2: erase, write EC 1235 ubiformat: eraseblock 3: erase, write EC 1235
Thanks.
Regards,
Darwin
Re: Ubiformat --erase-counter not always used
Quoted 26 lines · Darwin Rambo
Hello Artem,
This is not a bug report, just an observation on ubiformat. It only seems to take the --erase-counter parameter in certain situations. If you have alien data it seems to take it. If the blocks are FF erased or previously formatted correctly it seems to ignore the --erase-counter argument, even though it says it is using it (see below).
Should we add something in the online help or documentation to explain this better and maybe say in the ubiformat tool itself when the switch is getting used or ignored and why?
# ./ubiformat /dev/mtd4 -n --erase-counter=1234 -v -y ubiformat: mtd4 (NAND), size 2097152 bytes (2.0 MiB), 524288 eraseblocks of 524288 bytes (512.0 KiB), min. I/O size 4096 bytes libscan: start scanning eraseblocks 0-4 libscan: scanning eraseblock 0: alien libscan: scanning eraseblock 1: alien libscan: scanning eraseblock 2: alien libscan: scanning eraseblock 3: alien libscan: finished, mean EC 0, 0 OK, 0 corrupted, 0 empty, 4 alien, bad 0 ubiformat: warning!: 4 of 4 eraseblocks contain non-ubifs data ubiformat: use erase counter 1234 for all eraseblocks ubiformat: eraseblock 0: erase, write EC 1234 ubiformat: eraseblock 1: erase, write EC 1234 ubiformat: eraseblock 2: erase, write EC 1234 ubiformat: eraseblock 3: erase, write EC 1234 192.168.1.105 # ./ubiformat /dev/mtd4 -n --erase-counter=5432 -v -y ubiformat: mtd4 (NAND), size 2097152 bytes (2.0 MiB), 524288 eraseblocks of 524288 bytes (512.0 KiB), min. I/O size 4096 bytes libscan: start scanning eraseblocks 0-4 libscan: scanning eraseblock 0: OK, erase counter 1234 libscan: scanning eraseblock 1: OK, erase counter 1234 libscan: scanning eraseblock 2: OK, erase counter 1234
Quoted 8 lines
libscan: scanning eraseblock 3: OK, erase counter 1234 libscan: finished, mean EC 1234, 4 OK, 0 corrupted, 0 empty, 0 alien, bad 0 ubiformat: 4 eraseblocks have valid erase counter, mean value is 1234 ubiformat: use erase counter 5432 for all eraseblocks <------------------ Didn't take this value ubiformat: eraseblock 0: erase, write EC 1235 ubiformat: eraseblock 1: erase, write EC 1235 ubiformat: eraseblock 2: erase, write EC 1235 ubiformat: eraseblock 3: erase, write EC 1235
Looks like a bug to me. I think it should take the EC you ask it in all cases. I'll look at this when I have a bit more time, thanks for the report.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: Ubiformat --erase-counter not always used
In reply to Darwin RamboQuoted 5 lines · Darwin Rambo
Hello Artem,
This is not a bug report, just an observation on ubiformat. It only seems to take the --erase-counter parameter in certain situations. If you have alien data it seems to take it. If the blocks are FF erased or previously formatted correctly it seems to ignore the --erase-counter argument, even though it says it is using it (see below).
Should we add something in the online help or documentation to explain this better and maybe say in the ubiformat tool itself when the switch is getting used or ignored and why?
Should be fixed in the mtd-utils repository now, thanks.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Quoted 46 lines · On Mon, 23 Nov 2009 17:19:04 +0200 Artem Bityutskiy <[email protected]> wrote:
Quoted 32 lines · On Tue, 2009-11-17 at 14:45 -0800, [email protected] wrote:
From: Li Yang <[email protected]>
Symptom:
device_suspend():mtd_cls_suspend+0x0/0x58returns -11
PM: Device mtd14 failed to suspend: error -11
PM: Some devices failed to suspendThis patch enables other chips to be suspended if the active chip of the controller has been suspended.
Signed-off-by Jin Qing <[email protected]>Signed-off-by Li Yang <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
drivers/mtd/nand/nand_base.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)diff -puN
drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problemdrivers/mtd/nand/nand_base.cdrivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problem +3
-4@@ -697,10 +697,16 @@ nand_get_device(struct nand_chip *chip,spin_unlock (lock);return 0 ; } -if (new_state ==FL_PM_SUSPENDED ) { -spin_unlock (lock); -return (chip->state ==FL_PM_SUSPENDED ) ?0 : -EAGAIN ; - } +if (new_state ==FL_PM_SUSPENDED ) +if (chip->controller->active->state ==FL_PM_SUSPENDED ) { + chip->state =FL_PM_SUSPENDED ;drivers/mtd/nand/nand_base.c nand_get_device(struct nand_chip *chip, · line 712
Quoted 10 lines
drivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problem +7
-0+spin_unlock (lock); +return 0 ; + }else { +spin_unlock (lock); +return -EAGAIN ; + } +set_current_state (TASK_UNINTERRUPTIBLE );add_wait_queue (wq, &wait);spin_unlock (lock);This patch casing the following gcc warning:
Quoted 4 lines
drivers/mtd/nand/nand_base.c: In function___nand_get_device___:drivers/mtd/nand/nand_base.c:700: warning: suggest explicit braces to avoid ambiguous___else___
Stupid gcc.
drivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-fix-multi-chip-suspend-problem-fix +2 -2
@@ -697,7 +697,7 @@ nand_get_device(struct nand_chip *chip,spin_unlock (lock);return 0 ; } -if (new_state ==FL_PM_SUSPENDED ) +if (new_state ==FL_PM_SUSPENDED ) {if (chip->controller->active->state ==FL_PM_SUSPENDED ) { chip->state =FL_PM_SUSPENDED ;spin_unlock (lock);
@@ -706,7 +706,7 @@ nand_get_device(struct nand_chip *chip,spin_unlock (lock);return -EAGAIN ; } - + }set_current_state (TASK_UNINTERRUPTIBLE );add_wait_queue (wq, &wait);spin_unlock (lock);
_