* pm-cpuidle-next:
cpuidle: support multiple drivers
cpuidle: prepare the cpuidle core to handle multiple drivers
cpuidle: move driver checking within the lock section
cpuidle: move driver's refcount to cpuidle
cpuidle: fixup device.h header in cpuidle.h
cpuidle / sysfs: move structure declaration into the sysfs.c file
cpuidle: Get typical recent sleep interval
cpuidle: Set residency to 0 if target Cstate not enter
cpuidle: Quickly notice prediction failure in general case
cpuidle: Quickly notice prediction failure for repeat mode
cpuidle / sysfs: move kobj initialization in the syfs file
cpuidle / sysfs: change function parameter
Daniel Lezcano [Wed, 31 Oct 2012 16:44:48 +0000 (16:44 +0000)]
cpuidle: support multiple drivers
With the tegra3 and the big.LITTLE [1] new architectures, several cpus
with different characteristics (latencies and states) can co-exists on the
system.
The cpuidle framework has the limitation of handling only identical cpus.
This patch removes this limitation by introducing the multiple driver support
for cpuidle.
This option is configurable at compile time and should be enabled for the
architectures mentioned above. So there is no impact for the other platforms
if the option is disabled. The option defaults to 'n'. Note the multiple drivers
support is also compatible with the existing drivers, even if just one driver is
needed, all the cpu will be tied to this driver using an extra small chunk of
processor memory.
The multiple driver support use a per-cpu driver pointer instead of a global
variable and the accessor to this variable are done from a cpu context.
In order to keep the compatibility with the existing drivers, the function
'cpuidle_register_driver' and 'cpuidle_unregister_driver' will register
the specified driver for all the cpus.
The semantic for the output of /sys/devices/system/cpu/cpuidle/current_driver
remains the same except the driver name will be related to the current cpu.
The /sys/devices/system/cpu/cpu[0-9]/cpuidle/driver/name files are added
allowing to read the per cpu driver name.
[1] http://lwn.net/Articles/481055/
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
* pm-cpufreq-next:
cpufreq: Remove unnecessary initialization of a local variable
cpufreq: Make sure target freq is within limits
cpufreq: Avoid calling cpufreq driver's target() routine if target_freq == policy->cur
cpufreq: Fix sparse warning by making local function static
cpufreq: Fix sparse warnings by updating cputime64_t to u64
cpufreq: governors: remove redundant code
cpufreq: return early from __cpufreq_driver_getavg()
cpufreq: fix jiffies/cputime mixup in conservative/ondemand governors
cpufreq: Improve debug prints
cpufreq: Move common part from governors to separate file, v2
cpufreq / core: Fix printing of governor and driver name
cpufreq / core: Fix typo in comment describing show_bios_limit()
* acpica-next: (26 commits)
ACPICA: Update version to 20121018
ACPICA: AcpiGetObjectInfo: Add support for ACPI 5 _SUB method
ACPICA: Update for 64-bit generation of recent error message changes
ACPICA: Fix externalize name to complete migration to ACPI_MOVE_NAME
ACPICA: Add starting offset parameter to common dump buffer routine
ACPICA: Deploy ACPI_MOVE_NAME across ACPICA source base
ACPICA: Update support for ACPI 5 MPST table
ACPICA: Enhance error reporting for invalid opcodes and bad ACPI_NAMEs
ACPICA: Add ACPI_MOVE_NAME macro to optimize 4-byte ACPI_NAME copies
ACPICA: AcpiExec: Improve algorithm for tracking memory leaks
ACPICA: Add debug print message for mutex objects that are force-released
ACPICA: Resource Mgr: Small fix for buffer size calculation
ACPICA: Remove extra spaces after periods in the Intel license
ACPICA: Remove extra spaces after periods within comments
ACPICA: Update local C library module comments for ASCII table
ACPICA: Fix for predefined name loop during ACPICA initialization
ACPICA: Fix some typos in comments
ACPICA: ACPICA core: Cleanup empty lines at file start and end
ACPICA: Audit/update for ACPICA return macros and debug depth counter
ACPICA: Fix unmerged acmacros.h divergences.
...
* acpi-next:
ACPI / memory-hotplug: add memory offline code to acpi_memory_device_remove()
ACPI / memory-hotplug: introduce a mutex lock to protect the list in acpi_memory_device
ACPI / memory-hotplug: call acpi_bus_trim() to remove memory device
ACPI: Add ACPI CPU hot-remove support
ACPI: Export functions for hot-remove
ACPI: Add user space interface for identification objects
ACPI: Add _UID support for ACPI devices.
ACPI: move acpi_no_s4_hw_signature() declaration into #ifdef CONFIG_HIBERNATION
ACPI / Sleep: add acpi_sleep=nonvs_s3 parameter
ACPI: Remove unused lockable in acpi_device_flags
ACPI: Fix stale pointer access to flags.lockable
ACPI: Fix a hard coding style when determining if a device is a container, v3
ACPI / x86: Add quirk for "CheckPoint P-20-00" to not use bridge _CRS_ info
ACPI / processor: prevent cpu from becoming online
ACPI: strict_strtoul() and printk() cleanup in acpi_pad
ACPI: dock: Remove redundant ACPI NS walk
ACPI / EC: Don't count a SCI interrupt as a false one
ACPI / EC: Add more debug info and trivial code cleanup
ACPI / EC: Cleanup the member name for spinlock/mutex in struct
Merge branch 'acpi-enumeration-next' into linux-next
* acpi-enumeration-next:
ACPI: Add support for platform bus type
ACPI / ia64: Export acpi_[un]register_gsi()
ACPI / x86: Export acpi_[un]register_gsi()
ACPI: Provide generic functions for matching ACPI device nodes
driver core / ACPI: Move ACPI support to core device and driver types
* pm-qos:
PM / QoS: Fix the return value of dev_pm_qos_update_request()
PM / ACPI: Take device PM QoS flags into account
PM / Domains: Check device PM QoS flags in pm_genpd_poweroff()
PM / QoS: Make it possible to expose PM QoS device flags to user space
PM / QoS: Introduce PM QoS device flags support
PM / QoS: Prepare struct dev_pm_qos_request for more request types
PM / QoS: Introduce request and constraint data types for PM QoS flags
PM / QoS: Prepare device structure for adding more constraint types
ACPI / memory-hotplug: add memory offline code to acpi_memory_device_remove()
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
In the 1st case, acpi_memory_disable_device() will be called.
In the 2nd case, acpi_memory_device_remove() will be called.
acpi_memory_device_remove() will also be called when we unbind the
memory device from the driver acpi_memhotplug or a driver initialization
fails.
acpi_memory_disable_device() has already implemented a code which
offlines memory and releases acpi_memory_info struct. But
acpi_memory_device_remove() has not implemented it yet.
So the patch move offlining memory and releasing acpi_memory_info struct
codes to a new function acpi_memory_remove_memory(). And it is used by both
acpi_memory_device_remove() and acpi_memory_disable_device().
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Wen Congyang [Fri, 2 Nov 2012 01:01:54 +0000 (02:01 +0100)]
ACPI / memory-hotplug: introduce a mutex lock to protect the list in acpi_memory_device
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
This 2 events may happen at the same time, so we may touch
acpi_memory_device.res_list at the same time. This patch
introduce a lock to protect this list.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PM: Provide ACPI PM callback routines for subsystems
Some bus types don't support power management natively, but generally
there may be device nodes in ACPI tables corresponding to the devices
whose bus types they are (under ACPI 5 those bus types may be SPI,
I2C and platform). If that is the case, standard ACPI power
management may be applied to those devices, although currently the
kernel has no means for that.
For this reason, provide a set of routines that may be used as power
management callbacks for such devices. This may be done in three
different ways.
(1) Device drivers handling the devices in question may run
acpi_dev_pm_attach() in their .probe() routines, which (on
success) will cause the devices to be added to the general ACPI
PM domain and ACPI power management will be used for them going
forward. Then, acpi_dev_pm_detach() may be used to remove the
devices from the general ACPI PM domain if ACPI power management
is not necessary for them any more.
(2) The devices' subsystems may use acpi_subsys_runtime_suspend(),
acpi_subsys_runtime_resume(), acpi_subsys_prepare(),
acpi_subsys_suspend_late(), acpi_subsys_resume_early() as their
power management callbacks in the same way as the general ACPI
PM domain does that.
(3) The devices' drivers may execute acpi_dev_suspend_late(),
acpi_dev_resume_early(), acpi_dev_runtime_suspend(),
acpi_dev_runtime_resume() from their power management callbacks
as appropriate, if that's absolutely necessary, but it is not
recommended to do that, because such drivers may not work
without ACPI support as a result.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PM: Move device PM functions related to sleep states
Introduce helper function returning the target sleep state of the
system and use it to move the remaining device power management
functions from sleep.c to device_pm.c.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PM: Provide device PM functions operating on struct acpi_device
If the caller of acpi_bus_set_power() already has a pointer to the
struct acpi_device object corresponding to the device in question, it
doesn't make sense for it to go through acpi_bus_get_device(), which
may be costly, because it involves acquiring the global ACPI
namespace mutex.
For this reason, export the function operating on struct acpi_device
objects used internally by acpi_bus_set_power(), so that it may be
called instead of acpi_bus_set_power() in the above case, and change
its name to acpi_device_set_power().
Additionally, introduce two inline wrappers for checking ACPI PM
capabilities of devices represented by struct acpi_device objects.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Two device wakeup management routines in device_pm.c and sleep.c,
acpi_pm_device_run_wake() and acpi_pm_device_sleep_wake(), take a
device pointer argument and use it to obtain the ACPI handle of the
corresponding ACPI namespace node. That handle is then used to get
the address of the struct acpi_device object corresponding to the
struct device passed as the argument.
Unfortunately, that last operation may be costly, because it involves
taking the global ACPI namespace mutex, so it shouldn't be carried
out too often. However, the callers of those routines usually call
them in a row with acpi_pm_device_sleep_state() which also takes that
mutex for the same reason, so it would be more efficient if they ran
acpi_bus_get_device() themselves to obtain a pointer to the struct
acpi_device object in question and then passed that pointer to the
appropriate PM routines.
To make that possible, split each of the PM routines mentioned above
in two parts, one taking a struct acpi_device pointer argument and
the other implementing the current interface for compatibility.
Additionally, change acpi_pm_device_run_wake() to actually return
an error code if there is an error while setting up runtime remote
wakeup for the device.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The ACPI function for setting up devices to do runtime remote
wakeup is now located in drivers/acpi/sleep.c, but
drivers/acpi/device_pm.c is a more logical place for it, so move it
there.
No functional changes should result from this modification.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PM: Move device power state selection routine to device_pm.c
The ACPI function for choosing device power state is now located
in drivers/acpi/sleep.c, but drivers/acpi/device_pm.c is a more
logical place for it, so move it there.
However, instead of moving the function entirely, move its core only
under a different name and with a different list of arguments, so
that it is more flexible, and leave a wrapper around it in the
original location.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PM: Move routines for adding/removing device wakeup notifiers
ACPI routines for adding and removing device wakeup notifiers are
currently defined in a PCI-specific file, but they will be necessary
for non-PCI devices too, so move them to a separate file under
drivers/acpi and rename them to indicate their ACPI origins.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Toshi Kani [Thu, 1 Nov 2012 14:42:13 +0000 (14:42 +0000)]
ACPI: Add ACPI CPU hot-remove support
Added support of CPU hot-remove via an ACPI eject notification.
It calls acpi_bus_hot_remove_device(), which shares the same code
path with the sysfs eject operation. acpi_os_hotplug_execute()
runs the hot-remove operation in kacpi_hotplug_wq and serializes
it between ACPI hot-remove and sysfs eject requests.
Lv Zheng [Tue, 30 Oct 2012 13:43:26 +0000 (14:43 +0100)]
ACPI: Add user space interface for identification objects
ACPI devices are glued with physical devices through _ADR object, ACPI
enumerated devices are identified with _UID object. Currently we can
observe _HID/_CID through sysfs interfaces (hid/modalias), but there's
no way for us to check _ADR/_UID from user space. This patch closes
this gap for ACPI developers and users.
[rjw: Modified the subject and changelog slightly.] Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Tue, 30 Oct 2012 13:41:07 +0000 (14:41 +0100)]
ACPI: Add _UID support for ACPI devices.
The _UID object is optional, but is required when the device has no
other way to report a persistent unique device ID.
This patch is required for ACPI 5.0 ACPI enumerated IP cores.
Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rui Zhang <rui.zhang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PM: Fix device PM kernedoc comments and #ifdefs
The kerneldoc comments for acpi_pm_device_sleep_state(),
acpi_pm_device_run_wake(), and acpi_pm_device_sleep_wake() are
outdated or otherwise inaccurate and/or don't follow the common
kerneldoc patterns, so fix them.
Additionally, notice that acpi_pm_device_run_wake() should be under
CONFIG_PM_RUNTIME rather than under CONFIG_PM_SLEEP, so fix that too.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Daniel Lezcano [Wed, 31 Oct 2012 16:44:47 +0000 (16:44 +0000)]
cpuidle: prepare the cpuidle core to handle multiple drivers
This patch is a preparation for the multiple cpuidle drivers support.
As the next patch will introduce the multiple drivers with the Kconfig
option and we want to keep the code clean and understandable, this patch
defines a set of functions for encapsulating some common parts and splits
what should be done under a lock from the rest.
[rjw: Modified the subject and changelog slightly.] Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Daniel Lezcano [Wed, 31 Oct 2012 16:44:46 +0000 (16:44 +0000)]
cpuidle: move driver checking within the lock section
The code is racy and the check with cpuidle_curr_driver should be
done under the lock.
I don't find a path in the different drivers where that could happen
because the arch specific drivers are written in such way it is not
possible to register a driver while it is unregistered, except maybe
in a very improbable case when "intel_idle" and "processor_idle" are
competing. One could unregister a driver, while the other one is
registering.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Daniel Lezcano [Wed, 31 Oct 2012 16:44:45 +0000 (16:44 +0000)]
cpuidle: move driver's refcount to cpuidle
We want to support different cpuidle drivers co-existing together.
In this case we should move the refcount to the cpuidle_driver
structure to handle several drivers at a time.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Jingoo Han [Wed, 31 Oct 2012 05:49:13 +0000 (05:49 +0000)]
cpufreq: Remove unnecessary initialization of a local variable
Remove an unnecessary initializer for the 'ret' variable in
__cpufreq_set_policy().
[rjw: Modified the subject and changelog slightly.] Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Yuanhan Liu [Fri, 26 Oct 2012 11:39:24 +0000 (13:39 +0200)]
ACPI: move acpi_no_s4_hw_signature() declaration into #ifdef CONFIG_HIBERNATION
acpi_no_s4_hw_signature is defined in #ifdef CONFIG_HIBERNATION block,
but the current code put the declaration in #ifdef CONFIG_PM_SLEEP block.
I happened to meet this issue when I turned off PM_SLEEP config manually:
arch/x86/kernel/acpi/sleep.c:100:4: error: implicit declaration of function ‘acpi_no_s4_hw_signature’ [-Werror=implicit-function-declaration]
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Reviewed-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The ACPI specificiation would like us to save NVS at hibernation time,
but makes no mention of saving NVS over S3. Not all versions of
Windows do this either, and it is clear that not all machines need NVS
saved/restored over S3. Allow the user to improve their suspend/resume
time by disabling the NVS save/restore at S3 time, but continue to do
the NVS save/restore for S4 as specified.
Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Toshi Kani [Fri, 26 Oct 2012 11:39:06 +0000 (13:39 +0200)]
ACPI: Remove unused lockable in acpi_device_flags
Removed lockable in struct acpi_device_flags since it is no
longer used by any code. acpi_bus_hot_remove_device() cannot
use this flag because acpi_bus_trim() frees up its acpi_device
object. Furthermore, the dock driver calls _LCK method without
using this lockable flag.
Signed-off-by: Toshi Kani <toshi.kani@hp.com> Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Toshi Kani [Fri, 26 Oct 2012 11:38:57 +0000 (13:38 +0200)]
ACPI: Fix stale pointer access to flags.lockable
During hot-remove, acpi_bus_hot_remove_device() calls ACPI _LCK
method when device->flags.lockable is set. However, this device
pointer is stale since the target acpi_device object has been
already kfree'd by acpi_bus_trim().
The flags.lockable indicates whether or not this ACPI object
implements _LCK method. Fix the stable pointer access by replacing
it with acpi_get_handle() to check if _LCK is implemented.
Signed-off-by: Toshi Kani <toshi.kani@hp.com> Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Feng Tang [Mon, 22 Oct 2012 23:31:14 +0000 (01:31 +0200)]
ACPI / x86: Add quirk for "CheckPoint P-20-00" to not use bridge _CRS_ info
This is to fix a regression https://bugzilla.kernel.org/show_bug.cgi?id=47981
The CheckPoint P-20-00 works ok before new machines (2008 and later) are
forced to use the bridge _CRS info by default in 2.6.34. Add this quirk
to restore its old way of working: not using bridge _CRS info.
Signed-off-by: Feng Tang <feng.tang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / processor: prevent cpu from becoming online
Even if acpi_processor_handle_eject() offlines cpu, there is a chance
to online the cpu after that. So the patch closes the window by using
get/put_online_cpus().
Why does the patch change _cpu_up() logic?
The patch cares the race of hot-remove cpu and _cpu_up(). If the patch
does not change it, there is the following race.
hot-remove cpu | _cpu_up()
------------------------------------- ------------------------------------
call acpi_processor_handle_eject() |
call cpu_down() |
call get_online_cpus() |
| call cpu_hotplug_begin() and stop here
call arch_unregister_cpu() |
call acpi_unmap_lsapic() |
call put_online_cpus() |
| start and continue _cpu_up()
return acpi_processor_remove() |
continue hot-remove the cpu |
So _cpu_up() can continue to itself. And hot-remove cpu can also continue
itself. If the patch changes _cpu_up() logic, the race disappears as below:
hot-remove cpu | _cpu_up()
-----------------------------------------------------------------------
call acpi_processor_handle_eject() |
call cpu_down() |
call get_online_cpus() |
| call cpu_hotplug_begin() and stop here
call arch_unregister_cpu() |
call acpi_unmap_lsapic() |
cpu's cpu_present is set |
to false by set_cpu_present()|
call put_online_cpus() |
| start _cpu_up()
| check cpu_present() and return -EINVAL
return acpi_processor_remove() |
continue hot-remove the cpu |
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Reviewed-by: Toshi Kani <toshi.kani@hp.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Josh [Mon, 22 Oct 2012 23:30:40 +0000 (01:30 +0200)]
ACPI: strict_strtoul() and printk() cleanup in acpi_pad
Replace a few calls to strict_strtoul() in acpi_pad.c with kstrtoul()
and use pr_warn() instead of printk() in the same file.
[rjw: Modified the subject and changelog.] Signed-off-by: Josh Taylor <joshua.taylor0@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Feng Tang [Mon, 22 Oct 2012 23:30:12 +0000 (01:30 +0200)]
ACPI / EC: Don't count a SCI interrupt as a false one
Currently when advance_transaction() is called in EC interrupt handler,
if there is nothing driver can do with the interrupt, it will be taken
as a false one.
But this is not always true, as there may be a SCI EC interrupt fired
during normal read/write operation, which should not be counted as a
false one. This patch fixes the problem.
Signed-off-by: Feng Tang <feng.tang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:28:38 +0000 (02:28 +0000)]
ACPICA: AcpiGetObjectInfo: Add support for ACPI 5 _SUB method
Now calls _SUB in addition to the other ID methods: _HID, _CID,
and _UID.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:28:27 +0000 (02:28 +0000)]
ACPICA: Update for 64-bit generation of recent error message changes
Fix for errors on printf changes on 64-bit platforms and gcc.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:28:19 +0000 (02:28 +0000)]
ACPICA: Fix externalize name to complete migration to ACPI_MOVE_NAME
Fix for name segment copy and validation.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:28:11 +0000 (02:28 +0000)]
ACPICA: Add starting offset parameter to common dump buffer routine
Rename the dump buffer routines. Offset parameter can specify the
buffer starting offset that is used when displaying each line of
the buffer.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:28:03 +0000 (02:28 +0000)]
ACPICA: Deploy ACPI_MOVE_NAME across ACPICA source base
Replaces instances of strncpy(...,4) for ACPI_NAMEs.
ACPI_MOVE_NAME optimizes these to a single 32-bit copy on machines
that support misaligned transfers.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:27:56 +0000 (02:27 +0000)]
ACPICA: Update support for ACPI 5 MPST table
Fixes some problems introduced by late changes to the table as it
was added to the ACPI 5.0 specification. Both the table compiler
and the disassembler and the main header support for the table.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:27:48 +0000 (02:27 +0000)]
ACPICA: Enhance error reporting for invalid opcodes and bad ACPI_NAMEs
For disassembler, dump the 48 bytes surrounding the invalid
opcode. Fix incorrect table offset reported for invalid opcodes.
Report original 32-bit value for bad ACPI_NAMEs.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:27:40 +0000 (02:27 +0000)]
ACPICA: Add ACPI_MOVE_NAME macro to optimize 4-byte ACPI_NAME copies
Resolves to a 32-bit move for the normal case, strncpy on machines
that do not support misaligned transfers.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:27:32 +0000 (02:27 +0000)]
ACPICA: AcpiExec: Improve algorithm for tracking memory leaks
Add some intelligence to the code that maintains the global
list of allocated memory. The list is now ordered by allocated
memory address, significantly improving performance. When running
AcpiExec on the ASLTS test suite, speed improvements of 3X to 5X
are seen, depending on the platform and/or the environment.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:27:24 +0000 (02:27 +0000)]
ACPICA: Add debug print message for mutex objects that are force-released
At control method termination, any currently acquired mutex
objects are force-released. Add a new message for each one that
is released.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Feng Tang [Wed, 31 Oct 2012 02:27:15 +0000 (02:27 +0000)]
ACPICA: Resource Mgr: Small fix for buffer size calculation
Fixes a one byte error in the output buffer calculation.
Feng Tang - ACPICA BZ 849:
https://www.acpica.org/bugzilla/show_bug.cgi?id=849
Signed-off-by: Feng Tang <feng.tang@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:27:04 +0000 (02:27 +0000)]
ACPICA: Remove extra spaces after periods in the Intel license
For consistency with the rest of the source code.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:26:55 +0000 (02:26 +0000)]
ACPICA: Remove extra spaces after periods within comments
This makes all comments consistent.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:26:47 +0000 (02:26 +0000)]
ACPICA: Update local C library module comments for ASCII table
Improve the commenting of the table.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Robert Moore [Wed, 31 Oct 2012 02:26:36 +0000 (02:26 +0000)]
ACPICA: Fix for predefined name loop during ACPICA initialization
If a name cannot be created, simply continue on to the next name.
Do not attempt to use the name, do not abort. With assistance
from Colin Ian King.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:26:23 +0000 (02:26 +0000)]
ACPICA: Fix some typos in comments
No functional changes. Some small fixes within commments. Colin
Ian King.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:26:11 +0000 (02:26 +0000)]
ACPICA: ACPICA core: Cleanup empty lines at file start and end
Maintenance for source code consistency.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:26:01 +0000 (02:26 +0000)]
ACPICA: Audit/update for ACPICA return macros and debug depth counter
1) Ensure that all functions that use the various TRACE macros
also use the appropriate ACPICA return macros.
2) Ensure that all normal return statements surround the return
expression (value) with parens.
Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Wed, 31 Oct 2012 02:25:52 +0000 (02:25 +0000)]
ACPICA: Fix unmerged acmacros.h divergences.
The 20121018 release depends on some unmerged acmaros.h fixes.
This patch includes the fixes made on acmaros.h that will not affect
the generated vmlinux binary.
This patch will not affect the generated vmlinux binary.
This will decrease 157 lines of 20120913 divergence.diff.
Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Wed, 31 Oct 2012 02:25:45 +0000 (02:25 +0000)]
ACPICA: Fix indent caused divergences.
New version of "indent" program will generate different outputs that
will lead to the divergences between the Linux and the ACPICA.
This patch fixes such divergences caused by the "indent" program.
The version of the "indent" used for this patch is "GNU indent 2.2.11".
This patch will not affect the generated vmlinux binary.
This will decrease 581 lines of 20120913 divergence.diff.
Signed-off-by: Robert Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Wed, 31 Oct 2012 02:25:36 +0000 (02:25 +0000)]
ACPICA: Fix AcpiSrc caused divergences.
There are definitions that can been converted into new styles by
the recent AcpiSrc while they remain the old styles in the Linux.
This patch fixes those definitions that will be converted by the
AcpiSrc.
This patch will not affect the generated vmlinux binary.
This will decrease 97 lines of 20120913 divergence.diff.
Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Wed, 31 Oct 2012 02:25:24 +0000 (02:25 +0000)]
ACPICA: Fix divergences of definition conflicts.
There are conflicts in the "acpi_device_id*" definitions between the
Linux and the ACPICA. The definitions of acpi_device_id* in ACPICA
have been changed to the "acpi_pnp_device_id*". This patch changes
the corresponding "acpica_device_id*" definitiions in the Linux.
This patch will not affect the generated vmlinx binary.
This will decrease 298 lines of 20120913 divergence.diff.
Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Wed, 31 Oct 2012 02:25:15 +0000 (02:25 +0000)]
ACPICA: Fix unmerged debugger divergences.
Debugger improvements in ACPICA are always ignored by ACPICA Linux
release. This will lead to divergences between Linux and ACPICA.
This patch fixes such unmerged debugger updates.
Following patches are included:
1. Fixed a couple compiler warnings for extra extern
Wed, 14 Mar 2007 21:12:19 +0000
2. Cleanup for internal Reference Object.
Wed, 27 Aug 2008 10:11:30 -0700
3. Debugger: Lock method args for multithread command.
Fri, 24 Apr 2009 12:28:49 -0700
4. Debugger: Add max count argument for Batch command.
Tue, 29 Sep 2009 12:31:58 -0700
5. Add new host interfaces for _OSI support.
Thu, 5 Aug 2010 14:18:28 -0700
6. Increase debugger buffer size for method return objects.
Wed, 17 Nov 2010 13:48:30 -0800
7. Debugger: Add command to display status of global handlers.
Tue, 25 Jan 2011 13:47:58 -0800
8. Debugger: Split large dbcmds.c file.
Wed, 26 Jan 2011 13:03:41 -0800
9. Debugger/AcpiExec: Add support to pass complex args to methods.
Tue, 17 May 2011 13:33:39 -0700
10.Debugger: Add Template command to dump resource templates.
Fri, 28 Oct 2011 14:18:51 -0700
11.Support for custom ACPICA build for ACPI 5.0 reduced hardware.
Wed, 1 Feb 2012 13:18:17 -0800
12.Debugger: Improve command help support.
Wed, 15 Feb 2012 07:59:26 -0800
13.Update ACPI_HW_DEPENDENT* macro invocations.
Wed, 15 Feb 2012 08:14:08 -0800
14.Debugger: Rename function to simplify source code conversion.
Wed, 13 Jun 2012 14:23:06 -0700
15.Debugger: Enhance "Tables" and "Unload" commands.
Fri, 29 Jun 2012 13:10:58 -0700
16.Debugger: update prototype for AcpiDbSleep function.
Fri, 17 Aug 2012 13:43:02 -0700
This patch will not affect the generated vmlinx binary.
This will decrease 264 lines of 20120913 divergence.diff.
Signed-off-by: Robert Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Lv Zheng [Wed, 31 Oct 2012 02:25:05 +0000 (02:25 +0000)]
ACPICA: Fix unmerged utility divergences.
Utility improvements in ACPICA are partial ignored by ACPICA Linux
release. This will lead to divergences between Linux and ACPICA.
This patch ports the entire "utility" into Linux and makes them
igored in the compilation stage by "ACPI_FUTURE_USAGE".
The following "Utility" files have been ported into the Linux:
drivers/acpi/uttrack.c
drivers/acpi/utcache.c
drivers/acpi/utids.c
This patch will not affect the generated vmlinx binary.
This will decrease 274 lines of 20120913 divergence.diff.
Signed-off-by: Robert Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Bob Moore [Wed, 31 Oct 2012 02:24:51 +0000 (02:24 +0000)]
Cleanup of invalid ACPI name handling and repair
Implemented a change/cleanup for the handling of invalid ACPI names.
Names are now validated and repaired only when
1) entering a new name into the namespace and
2) disassembling a named AML opcode. A warning is only displayed in
debug mode or when the interpreter is in "strict" mode, since some
working machines do in fact contain invalid ACPI names.
Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Mika Westerberg [Wed, 31 Oct 2012 21:45:02 +0000 (22:45 +0100)]
ACPI: Add support for platform bus type
With ACPI 5 it is now possible to enumerate traditional SoC
peripherals, like serial bus controllers and slave devices behind
them. These devices are typically based on IP-blocks used in many
existing SoC platforms and platform drivers for them may already
be present in the kernel tree.
To make driver "porting" more straightforward, add ACPI support to
the platform bus type. Instead of writing ACPI "glue" drivers for
the existing platform drivers, register the platform bus type with
ACPI to create platform device objects for the drivers and bind the
corresponding ACPI handles to those platform devices.
This should allow us to reuse the existing platform drivers for the
devices in question with the minimum amount of modifications.
This changeset is based on Mika Westerberg's and Mathias Nyman's
work.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Mika Westerberg [Wed, 31 Oct 2012 21:44:55 +0000 (22:44 +0100)]
ACPI / ia64: Export acpi_[un]register_gsi()
These functions might be called from modules as well so make sure
they are exported.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Andy Shevchenko [Wed, 31 Oct 2012 21:44:48 +0000 (22:44 +0100)]
ACPI / x86: Export acpi_[un]register_gsi()
These functions might be called from modules as well so make sure
they are exported.
In addition, implement empty version of acpi_unregister_gsi() and
remove the one from pci_irq.c.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Mika Westerberg [Wed, 31 Oct 2012 21:44:41 +0000 (22:44 +0100)]
ACPI: Provide generic functions for matching ACPI device nodes
Introduce function acpi_match_device() allowing callers to match
struct device objects with populated acpi_handle fields against
arrays of ACPI device IDs. Also introduce function
acpi_driver_match_device() using acpi_match_device() internally and
allowing callers to match a struct device object against an array of
ACPI device IDs provided by a device driver.
Additionally, introduce macro ACPI_PTR() that may be used by device
drivers to escape pointers to data structures whose definitions
depend on CONFIG_ACPI.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Mika Westerberg [Wed, 31 Oct 2012 21:44:33 +0000 (22:44 +0100)]
driver core / ACPI: Move ACPI support to core device and driver types
With ACPI 5 we are starting to see devices that don't natively support
discovery but can be enumerated with the help of the ACPI namespace.
Typically, these devices can be represented in the Linux device driver
model as platform devices or some serial bus devices, like SPI or I2C
devices.
Since we want to re-use existing drivers for those devices, we need a
way for drivers to specify the ACPI IDs of supported devices, so that
they can be matched against device nodes in the ACPI namespace. To
this end, it is sufficient to add a pointer to an array of supported
ACPI device IDs, that can be provided by the driver, to struct device.
Moreover, things like ACPI power management need to have access to
the ACPI handle of each supported device, because that handle is used
to invoke AML methods associated with the corresponding ACPI device
node. The ACPI handles of devices are now stored in the archdata
member structure of struct device whose definition depends on the
architecture and includes the ACPI handle only on x86 and ia64. Since
the pointer to an array of supported ACPI IDs is added to struct
device_driver in an architecture-independent way, it is logical to
move the ACPI handle from archdata to struct device itself at the same
time. This also makes code more straightforward in some places and
follows the example of Device Trees that have a poiter to struct
device_node in there too.
This changeset is based on Mika Westerberg's work.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Nishanth Menon [Thu, 25 Oct 2012 23:50:43 +0000 (01:50 +0200)]
PM / devfreq: fix sscanf handling for writable sysfs entries
sscanf returns 0 when an invalid parameter like:
echo -n "a">min_freq
is attempted. Returning back the return result(0) will
cause the command not to return back to command
prompt.
Instead, just return -EINVAL when sscanf does not
return 1.
This is done for min_freq, max_freq and polling_interval
Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Nishanth Menon [Thu, 25 Oct 2012 23:50:35 +0000 (01:50 +0200)]
PM / devfreq: kernel-doc typo corrections
Parameter documentation needs a ':' for scripts/kernel-doc
to parse properly.
Minor fixes for ones warned by:
./scripts/kernel-doc -text drivers/devfreq/devfreq.c>/dev/null
Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: Randy Dunlap <rdunlap@xenotime.net> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Rajagopal Venkat [Thu, 25 Oct 2012 23:50:26 +0000 (01:50 +0200)]
PM / devfreq: Add current freq callback in device profile
Devfreq returns governor predicted frequency as current frequency
via sysfs interface. But device may not support all frequencies
that governor predicts. So add a callback in device profile to get
current freq from driver. Also add a new sysfs node to expose
governor predicted next target frequency.
Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Rajagopal Venkat [Thu, 25 Oct 2012 23:50:18 +0000 (01:50 +0200)]
PM / devfreq: Add suspend and resume apis
Add devfreq suspend/resume apis for devfreq users. This patch
supports suspend and resume of devfreq load monitoring, required
for devices which can idle.
Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Rajagopal Venkat [Thu, 25 Oct 2012 23:50:09 +0000 (01:50 +0200)]
PM / devfreq: Core updates to support devices which can idle
Prepare devfreq core framework to support devices which
can idle. When device idleness is detected perhaps through
runtime-pm, need some mechanism to suspend devfreq load
monitoring and resume back when device is online. Present
code continues monitoring unless device is removed from
devfreq core.
This patch introduces following design changes,
- use per device work instead of global work to monitor device
load. This enables suspend/resume of device devfreq and
reduces monitoring code complexity.
- decouple delayed work based load monitoring logic from core
by introducing helpers functions to be used by governors. This
provides flexibility for governors either to use delayed work
based monitoring functions or to implement their own mechanism.
- devfreq core interacts with governors via events to perform
specific actions. These events include start/stop devfreq.
This sets ground for adding suspend/resume events.
The devfreq apis are not modified and are kept intact.
Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Daniel Lezcano [Wed, 31 Oct 2012 00:09:02 +0000 (01:09 +0100)]
cpuidle: fixup device.h header in cpuidle.h
The "struct device" is only used in sysfs.c.
The other .c files including the private header "cpuidle.h"
do not need to pull the entire headers tree from there as they
don't manipulate the "struct device".
This patch fixes this by moving the header inclusion to sysfs.c
and adding a forward declaration for the struct device.
The number of lines generated by the preprocesor:
Without this patch : 17269 loc
With this patch : 16446 loc
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Daniel Lezcano [Wed, 31 Oct 2012 00:05:16 +0000 (01:05 +0100)]
cpuidle / sysfs: move structure declaration into the sysfs.c file
The structure cpuidle_state_kobj is not used anywhere except
in the sysfs.c file. The definition of this structure is not
needed in the cpuidle header file. This patch moves it to the
sysfs.c file in order to encapsulate the code a bit more.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Youquan Song [Fri, 26 Oct 2012 10:27:07 +0000 (12:27 +0200)]
cpuidle: Get typical recent sleep interval
The function detect_repeating_patterns was not very useful for
workloads with alternating long and short pauses, for example
virtual machines handling network requests for each other (say
a web and database server).
Instead, try to find a recent sleep interval that is somewhere
between the median and the mode sleep time, by discarding outliers
to the up side and recalculating the average and standard deviation
until that is no longer required.
This should do something sane with a sleep interval series like:
200 180 210 10000 30 1000 170 200
The current code would simply discard such a series, while the
new code will guess a typical sleep interval just shy of 200.
The original patch come from Rik van Riel <riel@redhat.com>.
Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Youquan Song <youquan.song@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Youquan Song [Fri, 26 Oct 2012 10:26:59 +0000 (12:26 +0200)]
cpuidle: Set residency to 0 if target Cstate not enter
When cpuidle governor choose a C-state to enter for idle CPU, but it notice that
there is tasks request to be executed. So the idle CPU will not really enter
the target C-state and go to run task.
In this situation, it will use the residency of previous really entered target
C-states. Obviously, it is not reasonable.
So, this patch fix it by set the target C-state residency to 0.
Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Youquan Song <youquan.song@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Youquan Song [Fri, 26 Oct 2012 10:26:50 +0000 (12:26 +0200)]
cpuidle: Quickly notice prediction failure in general case
The prediction for future is difficult and when the cpuidle governor prediction
fails and govenor possibly choose the shallower C-state than it should. How to
quickly notice and find the failure becomes important for power saving.
The patch extends to general case that prediction logic get a small predicted
residency, so it choose a shallow C-state though the expected residency is large
. Once the prediction will be fail, the CPU will keep staying at shallow C-state
for a long time. Acutally, the CPU has change enter into deep C-state.
So when the expected residency is long enough but governor choose a shallow
C-state, an timer will be added in order to monitor if the prediction failure.
When C-state is waken up prior to the adding timer, the timer will be cancelled
initiatively. When the timer is triggered and menu governor will quickly notice
prediction failure and re-evaluates deeper C-states possibility.
Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Youquan Song <youquan.song@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Youquan Song [Fri, 26 Oct 2012 10:26:41 +0000 (12:26 +0200)]
cpuidle: Quickly notice prediction failure for repeat mode
The prediction for future is difficult and when the cpuidle governor prediction
fails and govenor possibly choose the shallower C-state than it should. How to
quickly notice and find the failure becomes important for power saving.
cpuidle menu governor has a method to predict the repeat pattern if there are 8
C-states residency which are continuous and the same or very close, so it will
predict the next C-states residency will keep same residency time.
There is a real case that turbostat utility (tools/power/x86/turbostat)
at kernel 3.3 or early. turbostat utility will read 10 registers one by one at
Sandybridge, so it will generate 10 IPIs to wake up idle CPUs. So cpuidle menu
governor will predict it is repeat mode and there is another IPI wake up idle
CPU soon, so it keeps idle CPU stay at C1 state even though CPU is totally
idle. However, in the turbostat, following 10 registers reading is sleep 5
seconds by default, so the idle CPU will keep at C1 for a long time though it is
idle until break event occurs.
In a idle Sandybridge system, run "./turbostat -v", we will notice that deep
C-state dangles between "70% ~ 99%". After patched the kernel, we will notice
deep C-state stays at >99.98%.
In the patch, a timer is added when menu governor detects a repeat mode and
choose a shallow C-state. The timer is set to a time out value that greater
than predicted time, and we conclude repeat mode prediction failure if timer is
triggered. When repeat mode happens as expected, the timer is not triggered
and CPU waken up from C-states and it will cancel the timer initiatively.
When repeat mode does not happen, the timer will be time out and menu governor
will quickly notice that the repeat mode prediction fails and then re-evaluates
deeper C-states possibility.
Below is another case which will clearly show the patch much benefit:
for (i = 0; i < thread_num; i++)
pthread_join(pt[i], NULL);
exit(0);
}
Get powertop V2 from git://github.com/fenrus75/powertop, build powertop.
After build the above test application, then run it.
Test plaform can be Intel Sandybridge or other recent platforms.
#./idle_predict -l 10 &
#./powertop
We will find that deep C-state will dangle between 40%~100% and much time spent
on C1 state. It is because menu governor wrongly predict that repeat mode
is kept, so it will choose the C1 shallow C-state even though it has chance to
sleep 1 second in deep C-state.
While after patched the kernel, we find that deep C-state will keep >99.6%.
Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Youquan Song <youquan.song@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Daniel Lezcano [Fri, 26 Oct 2012 10:26:24 +0000 (12:26 +0200)]
cpuidle / sysfs: change function parameter
The function needs the cpuidle_device which is initially passed to the
caller.
The current code gets the struct device from the struct cpuidle_device,
pass it the cpuidle_add_sysfs function. This function calls
per_cpu(cpuidle_devices, cpu) to get the cpuidle_device.
This patch pass the cpuidle_device instead and simplify the code.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar [Thu, 25 Oct 2012 22:51:21 +0000 (00:51 +0200)]
cpufreq: Fix sparse warnings by updating cputime64_t to u64
There were few sparse warnings due to mismatch of type on function arguments.
Two types were used u64 and cputime64_t. Both are actually u64, so use u64 only.
Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar [Thu, 25 Oct 2012 22:47:42 +0000 (00:47 +0200)]
cpufreq: governors: remove redundant code
Initially ondemand governor was written and then using its code conservative
governor is written. It used a lot of code from ondemand governor, but copy of
code was created instead of using the same routines from both governors. Which
increased code redundancy, which is difficult to manage.
This patch is an attempt to move common part of both the governors to
cpufreq_governor.c file to come over above mentioned issues.
This shouldn't change anything from functionality point of view.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Andreas Schwab [Wed, 24 Oct 2012 20:16:34 +0000 (22:16 +0200)]
cpufreq: fix jiffies/cputime mixup in conservative/ondemand governors
The function get_cpu_idle_time_jiffy in both the conservative and
ondemand governors use jiffies_to_usecs to convert a cputime value to
usecs which gives the wrong value on architectures where cputime and
jiffies use different units. Only matters if NO_HZ is disabled, since
otherwise get_cpu_idle_time_us should already return a valid value, and
get_cpu_idle_time_jiffy isn't actually called.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
viresh kumar [Mon, 22 Oct 2012 23:28:05 +0000 (01:28 +0200)]
cpufreq: Move common part from governors to separate file, v2
Multiple cpufreq governers have defined similar get_cpu_idle_time_***()
routines. These routines must be moved to some common place, so that all
governors can use them.
So moving them to cpufreq_governor.c, which seems to be a better place for
keeping these routines.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
viresh kumar [Mon, 22 Oct 2012 23:23:43 +0000 (01:23 +0200)]
cpufreq / core: Fix printing of governor and driver name
Arrays for governer and driver name are of size CPUFREQ_NAME_LEN or 16.
i.e. 15 bytes for name and 1 for trailing '\0'.
When cpufreq driver print these names (for sysfs), it includes '\n' or ' ' in
the fmt string and still passes length as CPUFREQ_NAME_LEN. If the driver or
governor names are using all 15 fields allocated to them, then the trailing '\n'
or ' ' will never be printed. And so commands like:
PM / QoS: Fix the return value of dev_pm_qos_update_request()
Commit e39473d (PM / QoS: Make it possible to expose PM QoS device
flags to user space) introduced __dev_pm_qos_update_request() to be
called internally by dev_pm_qos_update_request(), but forgot to make
the latter actually use the return value of the former. Fix this
mistake.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>