Skip to contentSkip to conversation

au1xmmc: dev_pm_ops conversion

PATCH In review Manuel Lauss 5 participants 13 messages Jul 22, 2009 – Jul 26, 2009

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

PATCH v2 1/1 au1xmmc: dev_pm_ops conversion

---
V1->V2: don't remove CONFIG_PM

 drivers/mmc/host/au1xmmc.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
drivers/mmc/host/au1xmmc.c +15 -9
index d3f5561..2d4e20f 100644
@@ -1132,12 +1132,12 @@ static int __devexit au1xmmc_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM
-static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state)
+static int au1xmmc_suspend(struct device *dev)
 {
-	struct au1xmmc_host *host = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host = dev_get_drvdata(dev);
 	int ret;
 
-	ret = mmc_suspend_host(host->mmc, state);
+	ret = mmc_suspend_host(host->mmc, PMSG_SUSPEND);
 	if (ret)
 		return ret;
 
@@ -1150,27 +1150,33 @@ static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state)
 	return 0;
 }
 
-static int au1xmmc_resume(struct platform_device *pdev)
+static int au1xmmc_resume(struct device *dev)
 {
-	struct au1xmmc_host *host = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host = dev_get_drvdata(dev);
 
 	au1xmmc_reset_controller(host);
 
 	return mmc_resume_host(host->mmc);
 }
+
+static struct dev_pm_ops au1xmmc_pmops = {
+	.resume		= au1xmmc_resume,
+	.suspend	= au1xmmc_suspend,
+};
+
+#define AU1XMMC_PMOPS &au1xmmc_pmops
+
 #else
-#define au1xmmc_suspend NULL
-#define au1xmmc_resume NULL
+#define AU1XMMC_PMOPS NULL
 #endif
 
 static struct platform_driver au1xmmc_driver = {
 	.probe         = au1xmmc_probe,
 	.remove        = au1xmmc_remove,
-	.suspend       = au1xmmc_suspend,
-	.resume        = au1xmmc_resume,
 	.driver        = {
 		.name  = DRIVER_NAME,
 		.owner = THIS_MODULE,
+		.pm    = AU1XMMC_PMOPS,
 	},
 };
 
Signature · 1 line
1.6.3.3
#1 lore raw

Hi Manuel,

drivers/mmc/host/au1xmmc.c static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) · line 1166

Quoted 9 lines · Manuel Lauss
drivers/mmc/host/au1xmmc.c +6 -0
+
+static struct dev_pm_ops au1xmmc_pmops = {
+	.resume		= au1xmmc_resume,
+	.suspend	= au1xmmc_suspend,
+};
+

Was suspend to disk tested? It requires freeze()/thaw().

Signature · 1 line
Dmitry
#2 lore raw
Quoted 6 lines · Dmitry Torokhov

Hi Manuel,

Quoted 3 lines · Manuel Lauss
Quoted 8 lines

drivers/mmc/host/au1xmmc.c static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) · line 1166

Quoted 6 lines
drivers/mmc/host/au1xmmc.c +6 -0
+
+static struct dev_pm_ops au1xmmc_pmops = {
+     .resume         = au1xmmc_resume,
+     .suspend        = au1xmmc_suspend,
+};
+

Was suspend to disk tested? It requires freeze()/thaw().

No, only suspend-to-ram, but that's good to know. Currently for me only STR is important (and testable), I'll have to check wheter STD works on MIPS with my test hardware.

Thank you!
Manuel Lauss

#3 lore raw
In reply to Dmitry Torokhov
Quoted 4 lines · Dmitry Torokhov
Quoted 3 lines · Manuel Lauss
Quoted 8 lines

drivers/mmc/host/au1xmmc.c static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) · line 1166

Quoted 6 lines
drivers/mmc/host/au1xmmc.c +6 -0
+
+static struct dev_pm_ops au1xmmc_pmops = {
+	.resume		= au1xmmc_resume,
+	.suspend	= au1xmmc_suspend,
+};
+

Was suspend to disk tested? It requires freeze()/thaw().

Is that a regression introduced by this patch then? If so, many more of the recent dev_pm_ops conversion patches would need to be revisited.

#4 lore raw
Quoted 14 lines · Frans Pop
Quoted 4 lines · Dmitry Torokhov
Quoted 3 lines · Manuel Lauss
Quoted 8 lines

drivers/mmc/host/au1xmmc.c static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) · line 1166

Quoted 6 lines
drivers/mmc/host/au1xmmc.c +6 -0
+
+static struct dev_pm_ops au1xmmc_pmops = {
+	.resume		= au1xmmc_resume,
+	.suspend	= au1xmmc_suspend,
+};
+

Was suspend to disk tested? It requires freeze()/thaw().

Quoted 2 lines

Is that a regression introduced by this patch then? If so, many more of the recent dev_pm_ops conversion patches would need to be revisited.

Yes, as far as I understand they would. Let's ask Rafael to confirm...

Signature · 1 line
Dmitry
#5 lore raw
Quoted 15 lines · Dmitry Torokhov
Quoted 14 lines · Frans Pop
Quoted 12 lines · Dmitry Torokhov

drivers/mmc/host/au1xmmc.c static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) · line 1166

Quoted 9 lines · Manuel Lauss
drivers/mmc/host/au1xmmc.c +6 -0
+
+static struct dev_pm_ops au1xmmc_pmops = {
+	.resume		= au1xmmc_resume,
+	.suspend	= au1xmmc_suspend,
+};
+

Was suspend to disk tested? It requires freeze()/thaw().

Quoted 4 lines
Quoted 2 lines

Is that a regression introduced by this patch then? If so, many more of the recent dev_pm_ops conversion patches would need to be revisited.

Yes, as far as I understand they would. Let's ask Rafael to confirm...

Yes, they would. In general, you'd probably want to do something like this:

static struct dev_pm_ops au1xmmc_pmops = {
	.resume		= au1xmmc_resume,
	.suspend		= au1xmmc_suspend,
	.freeze		= au1xmmc_resume,
	.thaw		= au1xmmc_suspend,
	.restore		= au1xmmc_resume,
	.poweroff	= au1xmmc_suspend,
};

but in this particular case it's probably better to define separate callbacks for .freeze() and .thaw() at least.

During hibernation we call .freeze() and .thaw() before and after creating the image, respectively, and then .poweroff() is called right after the image has been saved. During resume .freeze() is called after the image has been loaded and before the control goes to the image kernel, which then calls .restore().

HTH

I see I forgot about that myself. I'll fix up the floppy and hp-wmi patches.

Best,
Rafael

#6 lore raw
Quoted 18 lines · Rafael J. Wysocki
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Was suspend to disk tested? It requires freeze()/thaw().

Is that a regression introduced by this patch then? If so, many more of the recent dev_pm_ops conversion patches would need to be revisited.

Yes, they would.  In general, you'd probably want to do something like this:

static struct dev_pm_ops au1xmmc_pmops = { .resume         = au1xmmc_resume, .suspend                = au1xmmc_suspend, .freeze         = au1xmmc_resume, .thaw           = au1xmmc_suspend, .restore                = au1xmmc_resume, .poweroff       = au1xmmc_suspend, };

Quoted 8 lines

but in this particular case it's probably better to define separate callbacks for .freeze() and .thaw() at least.

During hibernation we call .freeze() and .thaw() before and after creating the image, respectively, and then .poweroff() is called right after the image has been saved.  During resume .freeze() is called after the image has been loaded and before the control goes to the image kernel, which then calls .restore().

Yes, I see that in drivers/base/platform.c (legacy) .suspend resp. .resume also got called for those cases?
Ouch :-(

I've added others who've submitted dev_pm_ops patches in CC.

Quoted 1 line

I'll fix up the floppy and hp-wmi patches.

Note that those are already in mainline, as is pcspkr.

Thanks,
FJP

#7 lore raw
Quoted 3 lines · you
Quoted 1 line

I'll fix up the floppy and hp-wmi patches.

Note that those are already in mainline, as is pcspkr.

Here's an overview of commits (that I could find) already in mainline that look to have gotten it wrong:

6daa79b3  drivers/serial/sh-sci.c	(Paul Mundt)
2dbc8a23  drivers/video/hitfb.c		(Paul Mundt)
35db715b  drivers/input/misc/pcspkr.c	(/me)
2702403c  drivers/platform/x86/hp-wmi.c	(/me)
142a735b  drivers/block/floppy.c	(/me)
#8 lore raw
Quoted 5 lines · Frans Pop
Quoted 3 lines · you
Quoted 1 line

I'll fix up the floppy and hp-wmi patches.

Note that those are already in mainline, as is pcspkr.

Quoted 8 lines

Here's an overview of commits (that I could find) already in mainline that look to have gotten it wrong:

6daa79b3  drivers/serial/sh-sci.c	(Paul Mundt)
2dbc8a23  drivers/video/hitfb.c		(Paul Mundt)
35db715b  drivers/input/misc/pcspkr.c	(/me)
2702403c  drivers/platform/x86/hp-wmi.c	(/me)
142a735b  drivers/block/floppy.c	(/me)

Are you sure they're all in mainline?

The last change in mainline floppy.c happened on Jun 30 and I have the last two (fixed up already) in my linux-next branch.

Best,
Rafael

#9 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Frans Pop
Quoted 3 lines · you
Quoted 1 line

I'll fix up the floppy and hp-wmi patches.

Note that those are already in mainline, as is pcspkr.

Here's an overview of commits (that I could find) already in mainline that look to have gotten it wrong:

Quoted 7 lines
Quoted 5 lines
6daa79b3  drivers/serial/sh-sci.c	(Paul Mundt)
2dbc8a23  drivers/video/hitfb.c		(Paul Mundt)
35db715b  drivers/input/misc/pcspkr.c	(/me)
2702403c  drivers/platform/x86/hp-wmi.c	(/me)
142a735b  drivers/block/floppy.c	(/me)

Are you sure they're all in mainline?

Ugh, you're right. Only the first three are.

For the last two I was confused by the mails from akm that he'd dropped them from his queue. I'd not realized that was because you took them.

#10 lore raw
In reply to Frans Pop
Quoted 32 lines · Frans Pop
Quoted 18 lines · Rafael J. Wysocki
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Was suspend to disk tested? It requires freeze()/thaw().

Is that a regression introduced by this patch then? If so, many more of the recent dev_pm_ops conversion patches would need to be revisited.

Yes, they would. In general, you'd probably want to do something like this:

static struct dev_pm_ops au1xmmc_pmops = {
.resume = au1xmmc_resume,
.suspend = au1xmmc_suspend,
.freeze = au1xmmc_resume,
.thaw = au1xmmc_suspend,
.restore = au1xmmc_resume,
.poweroff = au1xmmc_suspend,
};

Quoted 8 lines

but in this particular case it's probably better to define separate callbacks for .freeze() and .thaw() at least.

During hibernation we call .freeze() and .thaw() before and after creating the image, respectively, and then .poweroff() is called right after the image has been saved. During resume .freeze() is called after the image has been loaded and before the control goes to the image kernel, which then calls .restore().

Yes, I see that in drivers/base/platform.c (legacy) .suspend resp. .resume also got called for those cases?
Ouch :-(

Quoted 6 lines

I've added others who've submitted dev_pm_ops patches in CC.

Quoted 1 line

I'll fix up the floppy and hp-wmi patches.

Note that those are already in mainline, as is pcspkr.

Pcspkr should be fine as is since we just want to shut it off and with s2d it will happen automatically when we power down.

Signature · 1 line
Dmitry
#11 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

Yes, they would. In general, you'd probably want to do something like this:

static struct dev_pm_ops au1xmmc_pmops = {
	.resume		= au1xmmc_resume,
	.suspend		= au1xmmc_suspend,
	.freeze		= au1xmmc_resume,
	.thaw		= au1xmmc_suspend,

I'd have expected freeze and thaw to be the other way around here?

#12 lore raw
Quoted 11 lines · Mark Brown
Quoted 7 lines · Rafael J. Wysocki

Yes, they would. In general, you'd probably want to do something like this:

static struct dev_pm_ops au1xmmc_pmops = {
	.resume		= au1xmmc_resume,
	.suspend		= au1xmmc_suspend,
	.freeze		= au1xmmc_resume,
	.thaw		= au1xmmc_suspend,

I'd have expected freeze and thaw to be the other way around here?

Sure, sorry.

.suspend() corresponds to .freeze() and .poweroff(), while .resume() corresponds to .thaw() and .restore().

Best,
Rafael