All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
@ 2009-03-30 17:31 Witold Szczeponik
  2009-03-31  1:45 ` yakui_zhao
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Witold Szczeponik @ 2009-03-30 17:31 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-kernel, bjorn.helgaas, abelay, rjw

Subject: Enable PNPACPI _PSx Support, v3


(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)

This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled.  The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)

Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)

The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used.  Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)

The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly.  Comments welcome! :-)

No regressions were observed on hardware that does not require
this patch.

The patch is applied against 2.6.27.x.


Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>


Index: linux/drivers/pnp/pnpacpi/core.c
===================================================================
--- linux.orig/drivers/pnp/pnpacpi/core.c
+++ linux/drivers/pnp/pnpacpi/core.c
@@ -84,7 +84,6 @@ static int pnpacpi_set_resources(struct
  	acpi_handle handle = dev->data;
  	struct acpi_buffer buffer;
  	int ret;
-	acpi_status status;

  	dev_dbg(&dev->dev, "set resources\n");
  	ret = pnpacpi_build_resource_template(dev, &buffer);
@@ -95,21 +94,30 @@ static int pnpacpi_set_resources(struct
  		kfree(buffer.pointer);
  		return ret;
  	}
-	status = acpi_set_current_resources(handle, &buffer);
-	if (ACPI_FAILURE(status))
+	if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
  		ret = -EINVAL;
+	else if (acpi_bus_power_manageable(handle))
+		ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
  	kfree(buffer.pointer);
  	return ret;
  }

  static int pnpacpi_disable_resources(struct pnp_dev *dev)
  {
-	acpi_status status;
+	acpi_handle handle = dev->data;
+	int ret;

+	dev_dbg(&dev->dev, "disable resources\n");
  	/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
-	status = acpi_evaluate_object((acpi_handle) dev->data,
-				      "_DIS", NULL, NULL);
-	return ACPI_FAILURE(status) ? -ENODEV : 0;
+	ret = 0;
+	if (acpi_bus_power_manageable(handle)) {
+		ret = acpi_bus_set_power(handle, ACPI_STATE_D3);
+		if (ret)
+			return ret;
+	}
+	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
+		ret = -ENODEV;
+	return ret;
  }

  #ifdef CONFIG_ACPI_SLEEP

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

* Re: [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-03-30 17:31 [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3 Witold Szczeponik
@ 2009-03-31  1:45 ` yakui_zhao
  2009-03-31 20:37   ` Witold Szczeponik
  2009-03-31 10:19 ` Henrique de Moraes Holschuh
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: yakui_zhao @ 2009-03-31  1:45 UTC (permalink / raw)
  To: Witold Szczeponik; +Cc: linux-acpi, linux-kernel, bjorn.helgaas, abelay, rjw

On Tue, 2009-03-31 at 01:31 +0800, Witold Szczeponik wrote:
> Subject: Enable PNPACPI _PSx Support, v3
> 
    Very good patch.
    Do you have the hardware on which the dedicated power source is
required by the serial port(PnP device) in your hand?

When the Pnp ACPI device is started, it should be changed to D0 state if
there exists the _PSX object or the power resource is required. 
When it is disabled, it should be changed to D3 state.

   acked-by: Zhao Yakui <yakui.zhao@intel.com>

Thanks.
> 
> (This is an update to the patch presented earlier in
> http://lkml.org/lkml/2008/12/8/284, with new error handling.)
> 
> This patch sets the power of PnP ACPI devices to D0 when they
> are activated and to D3 when they are disabled.  The latter is
> in correspondence with the ACPI 3.0 specification, whereas the
> former is added in order to be able to power up a device after
> it has been previously disabled (or when booting up a system).
> (As a consequence, the patch makes the PnP ACPI code more ACPI
> compliant.)
> 
> Section 6.2.2 of the ACPI Specification (at least versions 1.0b
> and 3.0a) states: "Prior to running this control method [_DIS],
> the OS[PM] will have already put the device in the D3 state."
> Unfortunately, there is no clear statement as to when to put
> a device in the D0 state. :-( Therefore, the patch executes the
> method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
> device is disabled, _SRS enables the device at the specified
> resources." (From the ACPI 3.0a Specification.)
> 
> The patch fixes a problem with some IBM ThinkPads (at least the
> 600E and the 600X) where the serial ports have a dedicated
> power source that needs to be brought up before the serial port
> can be used.  Without this patch, the serial port is enabled
> but has no power. (In the past, the tpctl utility had to be
> utilized to turn on the power, but support for this feature
> stopped with version 5.9 as it did not support the more recent
> kernel versions.)
> 
> The error handlers that handle any errors that can occur during
> the power up/power down phases return the error codes to the
> caller directly.  Comments welcome! :-)
> 
> No regressions were observed on hardware that does not require
> this patch.
> 
> The patch is applied against 2.6.27.x.
> 
> 
> Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
> 
> 
> Index: linux/drivers/pnp/pnpacpi/core.c
> ===================================================================
> --- linux.orig/drivers/pnp/pnpacpi/core.c
> +++ linux/drivers/pnp/pnpacpi/core.c
> @@ -84,7 +84,6 @@ static int pnpacpi_set_resources(struct
>   	acpi_handle handle = dev->data;
>   	struct acpi_buffer buffer;
>   	int ret;
> -	acpi_status status;
> 
>   	dev_dbg(&dev->dev, "set resources\n");
>   	ret = pnpacpi_build_resource_template(dev, &buffer);
> @@ -95,21 +94,30 @@ static int pnpacpi_set_resources(struct
>   		kfree(buffer.pointer);
>   		return ret;
>   	}
> -	status = acpi_set_current_resources(handle, &buffer);
> -	if (ACPI_FAILURE(status))
> +	if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
>   		ret = -EINVAL;
> +	else if (acpi_bus_power_manageable(handle))
> +		ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
How about changing the power state before calling _SRS object?
>   	kfree(buffer.pointer);
>   	return ret;
>   }
> 
>   static int pnpacpi_disable_resources(struct pnp_dev *dev)
>   {
> -	acpi_status status;
> +	acpi_handle handle = dev->data;
> +	int ret;
> 
> +	dev_dbg(&dev->dev, "disable resources\n");
>   	/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
> -	status = acpi_evaluate_object((acpi_handle) dev->data,
> -				      "_DIS", NULL, NULL);
> -	return ACPI_FAILURE(status) ? -ENODEV : 0;
> +	ret = 0;
> +	if (acpi_bus_power_manageable(handle)) {
> +		ret = acpi_bus_set_power(handle, ACPI_STATE_D3);
> +		if (ret)
> +			return ret;
> +	}
> +	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
> +		ret = -ENODEV;
> +	return ret;
>   }
> 
>   #ifdef CONFIG_ACPI_SLEEP
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-03-30 17:31 [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3 Witold Szczeponik
  2009-03-31  1:45 ` yakui_zhao
@ 2009-03-31 10:19 ` Henrique de Moraes Holschuh
  2009-04-04  1:32 ` Len Brown
       [not found] ` <200904021510.37517.trenn@suse.de>
  3 siblings, 0 replies; 9+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-03-31 10:19 UTC (permalink / raw)
  To: Witold Szczeponik; +Cc: linux-acpi, linux-kernel, bjorn.helgaas, abelay, rjw

This issue is also related to
http://bugzilla.kernel.org/show_bug.cgi?id=12748

Thanks for fixing the PNPACPI side of things :-)

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-03-31  1:45 ` yakui_zhao
@ 2009-03-31 20:37   ` Witold Szczeponik
  0 siblings, 0 replies; 9+ messages in thread
From: Witold Szczeponik @ 2009-03-31 20:37 UTC (permalink / raw)
  To: yakui_zhao; +Cc: linux-acpi, linux-kernel, bjorn.helgaas, abelay, rjw

yakui_zhao wrote:

>     Very good patch.
>     Do you have the hardware on which the dedicated power source is
> required by the serial port(PnP device) in your hand?
> 

Yes, I have an IBM ThinkPad 600E. I need this patch in order to
be able receive accurate time using a DCF77 receiver attached
to the serial port.

[snip]

>> -	if (ACPI_FAILURE(status))
>> +	if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
>>   		ret = -EINVAL;
>> +	else if (acpi_bus_power_manageable(handle))
>> +		ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
> How about changing the power state before calling _SRS object?

I recall reading something in the ACPI spec that says that the power
needs to be set after the device was enabled.  But the main driver
for this order (_SRS followed by _PS0) is the symmetry to the required
_PS3 followed by _DIS (according to the spec).

[snip]

--- Witold

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

* Re: [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-03-30 17:31 [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3 Witold Szczeponik
  2009-03-31  1:45 ` yakui_zhao
  2009-03-31 10:19 ` Henrique de Moraes Holschuh
@ 2009-04-04  1:32 ` Len Brown
  2009-04-04  1:49   ` Len Brown
       [not found] ` <200904021510.37517.trenn@suse.de>
  3 siblings, 1 reply; 9+ messages in thread
From: Len Brown @ 2009-04-04  1:32 UTC (permalink / raw)
  To: Witold Szczeponik; +Cc: linux-acpi, linux-kernel, bjorn.helgaas, abelay, rjw

applied

thanks,
Len Brown, Intel Open Source Technology Center


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

* Re: [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-04-04  1:32 ` Len Brown
@ 2009-04-04  1:49   ` Len Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Len Brown @ 2009-04-04  1:49 UTC (permalink / raw)
  To: Witold Szczeponik
  Cc: linux-acpi, Linux Kernel Mailing List, bjorn.helgaas, abelay,
	Rafael J. Wysocki

>From 6328a57401dc5f5cf9931738eb7268fcd8058c49 Mon Sep 17 00:00:00 2001
From: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Date: Mon, 30 Mar 2009 19:31:06 +0200
Subject: [PATCH] Enable PNPACPI _PSx Support, v3
X-Patchwork-Hint: ignore

(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)

This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled.  The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)

Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)

The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used.  Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)

The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly.  Comments welcome! :-)

No regressions were observed on hardware that does not require
this patch.

The patch is applied against 2.6.27.x.

Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---

(not immediately clear what tree the orginal patch
was based on top of, but here is what I checked-in
on top of 2.6.29 -Len)

 drivers/pnp/pnpacpi/core.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 2834846..9a3a682 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -83,7 +83,6 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
 	acpi_handle handle = dev->data;
 	struct acpi_buffer buffer;
 	int ret;
-	acpi_status status;
 
 	pnp_dbg(&dev->dev, "set resources\n");
 	ret = pnpacpi_build_resource_template(dev, &buffer);
@@ -94,21 +93,31 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
 		kfree(buffer.pointer);
 		return ret;
 	}
-	status = acpi_set_current_resources(handle, &buffer);
-	if (ACPI_FAILURE(status))
+	if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
 		ret = -EINVAL;
+	else if (acpi_bus_power_manageable(handle))
+		ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
 	kfree(buffer.pointer);
 	return ret;
 }
 
 static int pnpacpi_disable_resources(struct pnp_dev *dev)
 {
-	acpi_status status;
+	acpi_handle handle = dev->data;
+	int ret;
+
+	dev_dbg(&dev->dev, "disable resources\n");
 
 	/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
-	status = acpi_evaluate_object((acpi_handle) dev->data,
-				      "_DIS", NULL, NULL);
-	return ACPI_FAILURE(status) ? -ENODEV : 0;
+	ret = 0;
+	if (acpi_bus_power_manageable(handle)) {
+		ret = acpi_bus_set_power(handle, ACPI_STATE_D3);
+		if (ret)
+			return ret;
+	}
+	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
+		ret = -ENODEV;
+	return ret;
 }
 
 #ifdef CONFIG_ACPI_SLEEP
-- 
1.6.2.2.404.ge96f3


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

* Re: [stable] [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
       [not found] ` <200904021510.37517.trenn@suse.de>
@ 2009-06-30 23:03   ` Greg KH
  2009-07-07 20:06     ` Witold Szczeponik
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2009-06-30 23:03 UTC (permalink / raw)
  To: Thomas Renninger
  Cc: Witold Szczeponik, stable, rjw, linux-acpi, linux-kernel, abelay,
	bjorn.helgaas

On Thu, Apr 02, 2009 at 03:10:36PM +0200, Thomas Renninger wrote:
> Hi,
> 
> I remember a bug (serial device not working)
> related to serial and docking on Lenovo.
> I wonder whether this could be related to this fix.
> 
> This one also looks worth adding to stable kernel, at least
> after 2.6.30 does not show regressions for a while.
> 
> On Monday 30 March 2009 19:31:06 Witold Szczeponik wrote:
> > Subject: Enable PNPACPI _PSx Support, v3
> > 
> > 
> > (This is an update to the patch presented earlier in
> > http://lkml.org/lkml/2008/12/8/284, with new error handling.)
> > 
> > This patch sets the power of PnP ACPI devices to D0 when they
> > are activated and to D3 when they are disabled.  The latter is
> > in correspondence with the ACPI 3.0 specification, whereas the
> > former is added in order to be able to power up a device after
> > it has been previously disabled (or when booting up a system).
> > (As a consequence, the patch makes the PnP ACPI code more ACPI
> > compliant.)
> > 
> > Section 6.2.2 of the ACPI Specification (at least versions 1.0b
> > and 3.0a) states: "Prior to running this control method [_DIS],
> > the OS[PM] will have already put the device in the D3 state."
> > Unfortunately, there is no clear statement as to when to put
> > a device in the D0 state. :-( Therefore, the patch executes the
> > method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
> > device is disabled, _SRS enables the device at the specified
> > resources." (From the ACPI 3.0a Specification.)
> > 
> > The patch fixes a problem with some IBM ThinkPads (at least the
> > 600E and the 600X) where the serial ports have a dedicated
> > power source that needs to be brought up before the serial port
> > can be used.  Without this patch, the serial port is enabled
> > but has no power. (In the past, the tpctl utility had to be
> > utilized to turn on the power, but support for this feature
> > stopped with version 5.9 as it did not support the more recent
> > kernel versions.)
> > 
> > The error handlers that handle any errors that can occur during
> > the power up/power down phases return the error codes to the
> > caller directly.  Comments welcome! :-)
> > 
> > No regressions were observed on hardware that does not require
> > this patch.
> > 
> > The patch is applied against 2.6.27.x.
> > 
> > 
> > Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
> CC: stable@kernel.org
> ...

What specific git commit id in Linus's tree is this?

thanks,

greg k-h

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

* Re: [stable] [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-06-30 23:03   ` [stable] " Greg KH
@ 2009-07-07 20:06     ` Witold Szczeponik
  2009-07-28 19:15       ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Witold Szczeponik @ 2009-07-07 20:06 UTC (permalink / raw)
  To: Greg KH
  Cc: Thomas Renninger, stable, rjw, linux-acpi, linux-kernel, abelay,
	bjorn.helgaas

Greg KH wrote:

[snip]

> 
> What specific git commit id in Linus's tree is this?
> 
> thanks,
> 
> greg k-h
> 

Hi Greg,

the git commit id of this patch would be 
6328a57401dc5f5cf9931738eb7268fcd8058c49, but the patch triggered a 
regression which is described in 
http://bugzilla.kernel.org/show_bug.cgi?id=13243 and which was fixed in 
19bde778c1fd2574cc020a618d7d576f260271ca.

Hope this helps.


--- Witold

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

* Re: [stable] [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3
  2009-07-07 20:06     ` Witold Szczeponik
@ 2009-07-28 19:15       ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2009-07-28 19:15 UTC (permalink / raw)
  To: Witold Szczeponik
  Cc: Thomas Renninger, stable, rjw, linux-acpi, linux-kernel, abelay,
	bjorn.helgaas

On Tue, Jul 07, 2009 at 10:06:41PM +0200, Witold Szczeponik wrote:
> Greg KH wrote:
> 
> [snip]
> 
> > 
> > What specific git commit id in Linus's tree is this?
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Hi Greg,
> 
> the git commit id of this patch would be 
> 6328a57401dc5f5cf9931738eb7268fcd8058c49, but the patch triggered a 
> regression which is described in 
> http://bugzilla.kernel.org/show_bug.cgi?id=13243 and which was fixed in 
> 19bde778c1fd2574cc020a618d7d576f260271ca.

Ok, I've queued up both of these for the next .27 stable release.

thanks,

greg k-h

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

end of thread, other threads:[~2009-07-28 19:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-30 17:31 [PATCH] PNPACPI: Enable PNPACPI _PSx Support, v3 Witold Szczeponik
2009-03-31  1:45 ` yakui_zhao
2009-03-31 20:37   ` Witold Szczeponik
2009-03-31 10:19 ` Henrique de Moraes Holschuh
2009-04-04  1:32 ` Len Brown
2009-04-04  1:49   ` Len Brown
     [not found] ` <200904021510.37517.trenn@suse.de>
2009-06-30 23:03   ` [stable] " Greg KH
2009-07-07 20:06     ` Witold Szczeponik
2009-07-28 19:15       ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.