CONFIG_MTD_ROM and suspend-to-RAM
Hello,
I have a machine with a CFI flash using the physmap-flash mapping driver.
The problem after the failed detection (as reported earlier on the list[1]) is that if my kernel has CONFIG_MTD_ROM map_rom_probe() is called, which doesn't assign mtd->suspend and returns success.
Then when I do
echo mem > /sys/power/state
physmap_flash_suspend is called which does:
for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++) ret |= info->mtd[i]->suspend(info->mtd[i]); return ret;
Unsurprisingly this results in an Oops.
IMHO both functions should behave better. map_rom_probe should do some probing (not sure this is possible though) and physmap_flash_suspend should only call suspend if it's non-NULL. Moreover physmap_flash_suspend mangles the return value. I would prefer to break the loop after the first failure (and probably resume the already suspended parts). Moreover IIRC resume isn't called if suspend failed, so there might be some chips that stay suspended after a failing suspend.
I will come up with a patch addressing the physmap problems, but I don't know map_rom and don't have a chip for that, so I will leave that to someone else.
Best regards
Uwe
[1] http://thread.gmane.org/gmane.linux.drivers.mtd/22209
Signature · 3 lines
Uwe Kleine-König, Software Engineer Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
PATCH 1/1 physmap: only call suspend and resume callbacks if non-NULL
--- drivers/mtd/maps/physmap.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/mtd/maps/physmap.c +8 -4
@@ -202,8 +202,10 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t stateint ret =0 ;int i; -for (i =0 ; i <MAX_RESOURCES && info->mtd[i]; i++) - ret |= info->mtd[i]->suspend (info->mtd[i]); +for (i =0 ; i <MAX_RESOURCES && info->mtd[i]; i++) { +if (info->mtd[i]->suspend) + ret |= info->mtd[i]->suspend (info->mtd[i]); + }return ret; }
@@ -213,8 +215,10 @@ static int physmap_flash_resume(struct platform_device *dev)struct physmap_flash_info *info =platform_get_drvdata (dev);int i; -for (i =0 ; i <MAX_RESOURCES && info->mtd[i]; i++) - info->mtd[i]->resume (info->mtd[i]); +for (i =0 ; i <MAX_RESOURCES && info->mtd[i]; i++) { +if (info->mtd[i]->resume) + info->mtd[i]->resume (info->mtd[i]); + }return 0 ; }
Signature · 1 line
1.5.6.2
Re: [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL
drivers/mtd/maps/physmap.c static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
Quoted 10 lines · Uwe Kleine-König
Signed-off-by Uwe Kleine-König <[email protected]>--- drivers/mtd/maps/physmap.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)drivers/mtd/maps/physmap.c +0
-0@@ -202,8 +202,10 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
The same patch was submitted to this ML a while ago,
http://lists.infradead.org/pipermail/linux-mtd/2008-June/022023.html
It has not made it's way upstream, though ...
--
Robert
Re: [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL
Hello Robert,
Quoted 4 lines · Robert Jarzmik
The same patch was submitted to this ML a while ago,
http://lists.infradead.org/pipermail/linux-mtd/2008-June/022023.htmlIt has not made it's way upstream, though ...
Ah, OK. So please consider my mail as an additional Acked-by:
Thanks,
Uwe
Signature · 3 lines
Uwe Kleine-König, Software Engineer Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962