public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* CONFIG_MTD_ROM and suspend-to-RAM
@ 2008-07-15 13:03 Uwe Kleine-König
  2008-07-15 13:14 ` [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2008-07-15 13:03 UTC (permalink / raw)
  To: linux-mtd; +Cc: Lennert, Stefan Roese, David Woodhouse, Buytenhek

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

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

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

* [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL
  2008-07-15 13:03 CONFIG_MTD_ROM and suspend-to-RAM Uwe Kleine-König
@ 2008-07-15 13:14 ` Uwe Kleine-König
  2008-07-17 10:24   ` Robert Jarzmik
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2008-07-15 13:14 UTC (permalink / raw)
  To: linux-mtd

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
---
 drivers/mtd/maps/physmap.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 183255f..f04061f 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -202,8 +202,10 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
 	int 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;
 }
-- 
1.5.6.2

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

* Re: [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL
  2008-07-15 13:14 ` [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL Uwe Kleine-König
@ 2008-07-17 10:24   ` Robert Jarzmik
  2008-07-17 11:29     ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Jarzmik @ 2008-07-17 10:24 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-mtd

Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com> writes:

> Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
> ---
>  drivers/mtd/maps/physmap.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
> index 183255f..f04061f 100644
> --- a/drivers/mtd/maps/physmap.c
> +++ b/drivers/mtd/maps/physmap.c
> @@ -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

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

* Re: [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL
  2008-07-17 10:24   ` Robert Jarzmik
@ 2008-07-17 11:29     ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2008-07-17 11:29 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: linux-mtd

Hello Robert,

Robert Jarzmik wrote:
> 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 ...
Ah, OK.  So please consider my mail as an additional Acked-by:

Thanks,
Uwe

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

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

end of thread, other threads:[~2008-07-17 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-15 13:03 CONFIG_MTD_ROM and suspend-to-RAM Uwe Kleine-König
2008-07-15 13:14 ` [PATCH] [MTD] physmap: only call suspend and resume callbacks if non-NULL Uwe Kleine-König
2008-07-17 10:24   ` Robert Jarzmik
2008-07-17 11:29     ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox