Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,27 @@ acpi_status acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler handler)

void acpi_os_sleep(u64 ms)
{
msleep(ms);
u64 usec = ms * USEC_PER_MSEC, delta_us = 50;

/*
* Use a hrtimer because the timer wheel timers are optimized for
* cancelation before they expire and this timer is not going to be
* canceled.
*
* Set the delta between the requested sleep time and the effective
* deadline to at least 50 us in case there is an opportunity for timer
* coalescing.
*
* Moreover, longer sleeps can be assumed to need somewhat less timer
* precision, so sacrifice some of it for making the timer a more likely
* candidate for coalescing by setting the delta to 1% of the sleep time
* if it is above 5 ms (this value is chosen so that the delta is a
* continuous function of the sleep time).
*/
if (ms > 5)
delta_us = (USEC_PER_MSEC / 100) * ms;

usleep_range(usec, usec + delta_us);
}

void acpi_os_stall(u32 us)
Expand Down
Loading