From 84baf1725dc532d9746df2d216c1921154767109 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 4 Oct 2016 13:51:40 -0700 Subject: ACPI / fan: Fix error reading cur_state On some platforms with ACPI4 variable speed fan, reading cur_state from cooling device returns "invalid value" error. This confuses user space applications. This issue occurs as the current driver doesn't take account of "FineGrainControl" from _FIF(Fan Information). When the "FineGrainControl" is set, _FSL(FSL Set Level) takes argument as a percent, which doesn't have to match from any control value from _FPS(Fan Performance States). It is also possible that the Fan is not actually running at the requested speed returning a lower speed. On some platforms the BIOS is setting fan speed to a level during boot, which will not have an exact match to _FPS control values. The current implementation will treat this level as invalid value. The simple change is to atleast return state corresponding to a maximum control value in the _FPS compared to the current level. Signed-off-by: Srinivas Pandruvada Signed-off-by: Rafael J. Wysocki --- drivers/acpi/fan.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 384cfc3083e1..6cf4988206f2 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -129,8 +129,18 @@ static int fan_get_state_acpi4(struct acpi_device *device, unsigned long *state) control = obj->package.elements[1].integer.value; for (i = 0; i < fan->fps_count; i++) { - if (control == fan->fps[i].control) + /* + * When Fine Grain Control is set, return the state + * corresponding to maximum fan->fps[i].control + * value compared to the current speed. Here the + * fan->fps[] is sorted array with increasing speed. + */ + if (fan->fif.fine_grain_ctrl && control < fan->fps[i].control) { + i = (i > 0) ? i - 1 : 0; break; + } else if (control == fan->fps[i].control) { + break; + } } if (i == fan->fps_count) { dev_dbg(&device->dev, "Invalid control value returned\n"); -- cgit v1.2.3 From eab05ec38073f72389386f4a77fb58c06e246a4c Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 5 Oct 2016 10:33:16 -0700 Subject: ACPI / EC: Fix unused function warning when CONFIG_PM_SLEEP=n Signed-off-by: Eric Biggers Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 680531062160..48e19d013170 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -526,6 +526,7 @@ static void acpi_ec_enable_event(struct acpi_ec *ec) acpi_ec_clear(ec); } +#ifdef CONFIG_PM_SLEEP static bool acpi_ec_query_flushed(struct acpi_ec *ec) { bool flushed; @@ -557,6 +558,7 @@ static void acpi_ec_disable_event(struct acpi_ec *ec) spin_unlock_irqrestore(&ec->lock, flags); __acpi_ec_flush_event(ec); } +#endif /* CONFIG_PM_SLEEP */ static bool acpi_ec_guard_event(struct acpi_ec *ec) { -- cgit v1.2.3 From e311404f7925f6879817ebf471651c0bb5935604 Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Wed, 12 Oct 2016 13:11:45 +0200 Subject: ACPI / PAD: don't register acpi_pad driver if running as Xen dom0 When running as Xen dom0 a special processor_aggregator driver is needed. Don't register the standard driver in this case. Without that check an error message: "Error: Driver 'processor_aggregator' is already registered, aborting..." will be displayed. Signed-off-by: Juergen Gross [ rjw: Minor fixups ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_pad.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 8ea8211b2d58..eb76a4c10dbf 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -26,6 +26,7 @@ #include #include #include +#include #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" @@ -477,6 +478,10 @@ static struct acpi_driver acpi_pad_driver = { static int __init acpi_pad_init(void) { + /* Xen ACPI PAD is used when running as Xen Dom0. */ + if (xen_initial_domain()) + return -ENODEV; + power_saving_mwait_init(); if (power_saving_mwait_eax == 0) return -EINVAL; -- cgit v1.2.3 From abc4b9a53ea8153e0e028762b22cb213685c52e3 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 12 Oct 2016 11:50:34 -0700 Subject: acpi_os_vprintf: Use printk_get_level() to avoid unnecessary KERN_CONT acpi_os_vprintf currently always uses a KERN_CONT prefix which may be followed immediately by a proper KERN_. Check if the buffer already has a KERN_ at the start of the buffer and avoid the unnecessary KERN_CONT. Signed-off-by: Joe Perches Signed-off-by: Rafael J. Wysocki --- drivers/acpi/osl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 4305ee9db4b2..416953a42510 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -162,11 +162,18 @@ void acpi_os_vprintf(const char *fmt, va_list args) if (acpi_in_debugger) { kdb_printf("%s", buffer); } else { - printk(KERN_CONT "%s", buffer); + if (printk_get_level(buffer)) + printk("%s", buffer); + else + printk(KERN_CONT "%s", buffer); } #else - if (acpi_debugger_write_log(buffer) < 0) - printk(KERN_CONT "%s", buffer); + if (acpi_debugger_write_log(buffer) < 0) { + if (printk_get_level(buffer)) + printk("%s", buffer); + else + printk(KERN_CONT "%s", buffer); + } #endif } -- cgit v1.2.3