linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: Export FADT pm_profile integer value to userspace
@ 2011-11-04  2:33 Thomas Renninger
  2011-11-04 22:25 ` Rafael J. Wysocki
       [not found] ` <201111042325.48583.rjw@sisk.pl>
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Renninger @ 2011-11-04  2:33 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-pm

There are a lot userspace approaches to detect the usage of the
platform (laptop, workstation, server, ...) and adjust kernel tunables
accordingly (io/process scheduler, power management, ...).

These approaches need constant maintaining and are ugly to implement
(detect PCMCIA controller -> laptop,
does not work on recent systems anymore, ...)
On ACPI systems there is an easy and reliable way (if implemented
in BIOS and most recent platforms have this value set).
-> export it to userspace.

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: lenb@kernel.org
---
 Documentation/ABI/stable/sysfs-acpi-pmprofile |   22 ++++++++++++++++++++++
 drivers/acpi/sysfs.c                          |   14 +++++++++++++-
 2 files changed, 35 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-acpi-pmprofile

diff --git a/Documentation/ABI/stable/sysfs-acpi-pmprofile b/Documentation/ABI/stable/sysfs-acpi-pmprofile
new file mode 100644
index 0000000..964c7a8
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-acpi-pmprofile
@@ -0,0 +1,22 @@
+What: 		/sys/firmware/acpi/pm_profile
+Date:		03-Nov-2011
+KernelVersion:	v3.2
+Contact:	linux-acpi@vger.kernel.org
+Description: 	The ACPI pm_profile sysfs interface exports the platform
+		power management (and performance) requirement expectations
+		as provided by BIOS. The integer value is directly passed as
+		retrieved from the FADT ACPI table.
+Values:         For possible values see ACPI specification:
+		5.2.9 Fixed ACPI Description Table (FADT)
+		Field: Preferred_PM_Profile
+
+		Currently these values are defined by spec:
+		0 Unspecified
+		1 Desktop
+		2 Mobile
+		3 Workstation
+		4 Enterprise Server
+		5 SOHO Server
+		6 Appliance PC
+		7 Performance Server
+		>7 Reserved
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index c538d0e..9f66181 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -706,11 +706,23 @@ static void __exit interrupt_stats_exit(void)
 	return;
 }
 
+static ssize_t
+acpi_show_profile(struct device *dev, struct device_attribute *attr,
+		  char *buf)
+{
+	return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile);
+}
+
+static const struct device_attribute pm_profile_attr =
+	__ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL);
+
 int __init acpi_sysfs_init(void)
 {
 	int result;
 
 	result = acpi_tables_sysfs_init();
-
+	if (result)
+		return result;
+	result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr);
 	return result;
 }
-- 
1.7.6.1

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

* Re: [PATCH] ACPI: Export FADT pm_profile integer value to userspace
  2011-11-04  2:33 [PATCH] ACPI: Export FADT pm_profile integer value to userspace Thomas Renninger
@ 2011-11-04 22:25 ` Rafael J. Wysocki
       [not found] ` <201111042325.48583.rjw@sisk.pl>
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2011-11-04 22:25 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: linux-acpi, linux-pm, Len Brown (Intel)

On Friday, November 04, 2011, Thomas Renninger wrote:
> There are a lot userspace approaches to detect the usage of the
> platform (laptop, workstation, server, ...) and adjust kernel tunables
> accordingly (io/process scheduler, power management, ...).
> 
> These approaches need constant maintaining and are ugly to implement
> (detect PCMCIA controller -> laptop,
> does not work on recent systems anymore, ...)
> On ACPI systems there is an easy and reliable way (if implemented
> in BIOS and most recent platforms have this value set).
> -> export it to userspace.
> 
> Signed-off-by: Thomas Renninger <trenn@suse.de>
> CC: lenb@kernel.org

This is for Len, I guess?

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>

Thanks,
Rafael


> ---
>  Documentation/ABI/stable/sysfs-acpi-pmprofile |   22 ++++++++++++++++++++++
>  drivers/acpi/sysfs.c                          |   14 +++++++++++++-
>  2 files changed, 35 insertions(+), 1 deletions(-)
>  create mode 100644 Documentation/ABI/stable/sysfs-acpi-pmprofile
> 
> diff --git a/Documentation/ABI/stable/sysfs-acpi-pmprofile b/Documentation/ABI/stable/sysfs-acpi-pmprofile
> new file mode 100644
> index 0000000..964c7a8
> --- /dev/null
> +++ b/Documentation/ABI/stable/sysfs-acpi-pmprofile
> @@ -0,0 +1,22 @@
> +What: 		/sys/firmware/acpi/pm_profile
> +Date:		03-Nov-2011
> +KernelVersion:	v3.2
> +Contact:	linux-acpi@vger.kernel.org
> +Description: 	The ACPI pm_profile sysfs interface exports the platform
> +		power management (and performance) requirement expectations
> +		as provided by BIOS. The integer value is directly passed as
> +		retrieved from the FADT ACPI table.
> +Values:         For possible values see ACPI specification:
> +		5.2.9 Fixed ACPI Description Table (FADT)
> +		Field: Preferred_PM_Profile
> +
> +		Currently these values are defined by spec:
> +		0 Unspecified
> +		1 Desktop
> +		2 Mobile
> +		3 Workstation
> +		4 Enterprise Server
> +		5 SOHO Server
> +		6 Appliance PC
> +		7 Performance Server
> +		>7 Reserved
> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
> index c538d0e..9f66181 100644
> --- a/drivers/acpi/sysfs.c
> +++ b/drivers/acpi/sysfs.c
> @@ -706,11 +706,23 @@ static void __exit interrupt_stats_exit(void)
>  	return;
>  }
>  
> +static ssize_t
> +acpi_show_profile(struct device *dev, struct device_attribute *attr,
> +		  char *buf)
> +{
> +	return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile);
> +}
> +
> +static const struct device_attribute pm_profile_attr =
> +	__ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL);
> +
>  int __init acpi_sysfs_init(void)
>  {
>  	int result;
>  
>  	result = acpi_tables_sysfs_init();
> -
> +	if (result)
> +		return result;
> +	result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr);
>  	return result;
>  }
> 

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

* Re: [PATCH] ACPI: Export FADT pm_profile integer value to userspace
       [not found] ` <201111042325.48583.rjw@sisk.pl>
@ 2011-11-07  1:50   ` Len Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Len Brown @ 2011-11-07  1:50 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-acpi, linux-pm, Len Brown (Intel)

I guess in theory one could parse the FADT from user-space,
as it is already exported in /sys/firmware/acpi/tables/
but this is certainly more user-friendly -- say
to a shell script etc.

applied.

thanks,
Len Brown, Intel Open Source Technology Center

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

end of thread, other threads:[~2011-11-07  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-04  2:33 [PATCH] ACPI: Export FADT pm_profile integer value to userspace Thomas Renninger
2011-11-04 22:25 ` Rafael J. Wysocki
     [not found] ` <201111042325.48583.rjw@sisk.pl>
2011-11-07  1:50   ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).