aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2013-05-23 03:27:46 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-27 15:38:15 -0400
commit10619066a353f27fe3700a448fa2b21643687840 (patch)
treef78d6f192c720fb1675ea93a1412dcea89a03b58 /drivers/acpi
parenteff9a4b62b14cf0d9913e3caf1f26f8b7a6105c9 (diff)
ACPI: implement acpi_os_get_timer() according the spec
ACPI Timer() opcode should return monotonically increasing clock with 100ns granularity according the ACPI 5.0 spec. Testing the current Timer() implementation with following ASL code (and an additional debug print in acpi_os_sleep() to get the sleep times dumped out to dmesg): // Test: 10ms Store(Timer, Local1) Sleep(10) Divide(Subtract(Timer, Local1), 10000,, Local1) Sleep(Local1) // Test: 200ms Store(Timer, Local1) Sleep(200) Divide(Subtract(Timer, Local1), 10000,, Local1) Sleep(Local1) // Test 1300ms Store(Timer, Local1) Sleep(1300) Divide(Subtract(Timer, Local1), 10000,, Local1) Sleep(Local1) The second sleep value is calculated using Timer(). If the implementation is good enough we should be able to get the second value pretty close to the first. However, the current Timer() gives pretty bad sleep times: [ 11.488100] ACPI: acpi_os_get_timer() TBD [ 11.492150] ACPI: Sleep(10) [ 11.502993] ACPI: Sleep(0) [ 11.506315] ACPI: Sleep(200) [ 11.706237] ACPI: Sleep(0) [ 11.709550] ACPI: Sleep(1300) [ 13.008929] ACPI: Sleep(0) Fix this with the help of ktime_get(). Once the fix is applied and run against the same ASL code we get: [ 11.486786] ACPI: Sleep(10) [ 11.499029] ACPI: Sleep(12) [ 11.512350] ACPI: Sleep(200) [ 11.712282] ACPI: Sleep(200) [ 11.912170] ACPI: Sleep(1300) [ 13.211577] ACPI: Sleep(1300) That is much more closer to the values we expected. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/osl.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index e72186340fec..c29076909efe 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -835,19 +835,9 @@ void acpi_os_stall(u32 us)
835 */ 835 */
836u64 acpi_os_get_timer(void) 836u64 acpi_os_get_timer(void)
837{ 837{
838 static u64 t; 838 u64 time_ns = ktime_to_ns(ktime_get());
839 839 do_div(time_ns, 100);
840#ifdef CONFIG_HPET 840 return time_ns;
841 /* TBD: use HPET if available */
842#endif
843
844#ifdef CONFIG_X86_PM_TIMER
845 /* TBD: default to PM timer if HPET was not available */
846#endif
847 if (!t)
848 printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n");
849
850 return ++t;
851} 841}
852 842
853acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) 843acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)