Patchwork [2/2] powerpc: Add power management support to VIO bus

login
register
mail settings
Submitter Brian King
Date May 7, 2010, 6:58 p.m.
Message ID <201005071158.o47BwxPT013700@d03av03.boulder.ibm.com>
Download mbox | patch
Permalink /patch/51946/
State Superseded
Headers show

Comments

Brian King - May 7, 2010, 6:58 p.m.
Adds support for suspend/resume for VIO devices. This is needed for
support for HMC initiated hibernation.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 arch/powerpc/kernel/vio.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
Michael Ellerman - May 10, 2010, 2:35 a.m.
On Fri, 2010-05-07 at 13:58 -0500, Brian King wrote:
> Adds support for suspend/resume for VIO devices. This is needed for
> support for HMC initiated hibernation.
> 
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> ---
> 
>  arch/powerpc/kernel/vio.c |   24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff -puN arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm arch/powerpc/kernel/vio.c
> --- linux-2.6/arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm	2010-05-07 13:49:16.000000000 -0500
> +++ linux-2.6-bjking1/arch/powerpc/kernel/vio.c	2010-05-07 13:49:16.000000000 -0500
> @@ -1358,6 +1358,29 @@ static int vio_hotplug(struct device *de
>  	return 0;
>  }
>  
> +static int vio_pm_suspend(struct device *dev)
> +{
> +	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
> +
> +	if (pm && pm->suspend)
> +		return pm->suspend(dev);
> +	return 0;
> +}
> +
> +static int vio_pm_resume(struct device *dev)
> +{
> +	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
> +
> +	if (pm && pm->resume)
> +		return pm->resume(dev);
> +	return 0;
> +}
> +
> +const struct dev_pm_ops vio_dev_pm_ops = {
> +	.suspend = vio_pm_suspend,
> +	.resume = vio_pm_resume,
> +};

That just looks like boiler plate, is there not a generic version
somewhere?

cheers
Brian King - May 10, 2010, 1:40 p.m.
On 05/09/2010 09:35 PM, Michael Ellerman wrote:
> On Fri, 2010-05-07 at 13:58 -0500, Brian King wrote:
>> Adds support for suspend/resume for VIO devices. This is needed for
>> support for HMC initiated hibernation.
>>
>> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
>> ---
>>
>>  arch/powerpc/kernel/vio.c |   24 ++++++++++++++++++++++++
>>  1 file changed, 24 insertions(+)
>>
>> diff -puN arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm arch/powerpc/kernel/vio.c
>> --- linux-2.6/arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm	2010-05-07 13:49:16.000000000 -0500
>> +++ linux-2.6-bjking1/arch/powerpc/kernel/vio.c	2010-05-07 13:49:16.000000000 -0500
>> @@ -1358,6 +1358,29 @@ static int vio_hotplug(struct device *de
>>  	return 0;
>>  }
>>  
>> +static int vio_pm_suspend(struct device *dev)
>> +{
>> +	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
>> +
>> +	if (pm && pm->suspend)
>> +		return pm->suspend(dev);
>> +	return 0;
>> +}
>> +
>> +static int vio_pm_resume(struct device *dev)
>> +{
>> +	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
>> +
>> +	if (pm && pm->resume)
>> +		return pm->resume(dev);
>> +	return 0;
>> +}
>> +
>> +const struct dev_pm_ops vio_dev_pm_ops = {
>> +	.suspend = vio_pm_suspend,
>> +	.resume = vio_pm_resume,
>> +};
> 
> That just looks like boiler plate, is there not a generic version
> somewhere?

Looks there is. I'll update the patch to use the generic helpers.

Thanks,

Brian

Patch

diff -puN arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm arch/powerpc/kernel/vio.c
--- linux-2.6/arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm	2010-05-07 13:49:16.000000000 -0500
+++ linux-2.6-bjking1/arch/powerpc/kernel/vio.c	2010-05-07 13:49:16.000000000 -0500
@@ -1358,6 +1358,29 @@  static int vio_hotplug(struct device *de
 	return 0;
 }
 
+static int vio_pm_suspend(struct device *dev)
+{
+	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
+
+	if (pm && pm->suspend)
+		return pm->suspend(dev);
+	return 0;
+}
+
+static int vio_pm_resume(struct device *dev)
+{
+	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
+
+	if (pm && pm->resume)
+		return pm->resume(dev);
+	return 0;
+}
+
+const struct dev_pm_ops vio_dev_pm_ops = {
+	.suspend = vio_pm_suspend,
+	.resume = vio_pm_resume,
+};
+
 static struct bus_type vio_bus_type = {
 	.name = "vio",
 	.dev_attrs = vio_dev_attrs,
@@ -1365,6 +1388,7 @@  static struct bus_type vio_bus_type = {
 	.match = vio_bus_match,
 	.probe = vio_bus_probe,
 	.remove = vio_bus_remove,
+	.pm = &vio_dev_pm_ops,
 };
 
 /**