]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
nvme: Enable autonomous power state transitions
authorAndy Lutomirski <luto@kernel.org>
Thu, 16 Mar 2017 06:09:24 +0000 (14:09 +0800)
committerTim Gardner <tim.gardner@canonical.com>
Thu, 16 Mar 2017 15:28:42 +0000 (10:28 -0500)
commit441d14c0e39c69e5d91c4d1d7bb0ead351d7da7c
treee90a2aa71e50655e9dfefe8ef348d10dd04e7539
parent225a9366b4db6c4501b54421afad585f8455f4d1
nvme: Enable autonomous power state transitions

BugLink: https://bugs.launchpad.net/bugs/1664602
NVMe devices can advertise multiple power states.  These states can
be either "operational" (the device is fully functional but possibly
slow) or "non-operational" (the device is asleep until woken up).
Some devices can automatically enter a non-operational state when
idle for a specified amount of time and then automatically wake back
up when needed.

The hardware configuration is a table.  For each state, an entry in
the table indicates the next deeper non-operational state, if any,
to autonomously transition to and the idle time required before
transitioning.

This patch teaches the driver to program APST so that each successive
non-operational state will be entered after an idle time equal to 100%
of the total latency (entry plus exit) associated with that state.
The maximum acceptable latency is controlled using dev_pm_qos
(e.g. power/pm_qos_latency_tolerance_us in sysfs); non-operational
states with total latency greater than this value will not be used.
As a special case, setting the latency tolerance to 0 will disable
APST entirely.  On hardware without APST support, the sysfs file will
not be exposed.

The latency tolerance for newly-probed devices is set by the module
parameter nvme_core.default_ps_max_latency_us.

In theory, the device can expose "default" APST table, but this
doesn't seem to function correctly on my device (Samsung 950), nor
does it seem particularly useful.  There is also an optional
mechanism by which a configuration can be "saved" so it will be
automatically loaded on reset.  This can be configured from
userspace, but it doesn't seem useful to support in the driver.

On my laptop, enabling APST seems to save nearly 1W.

The hardware tables can be decoded in userspace with nvme-cli.
'nvme id-ctrl /dev/nvmeN' will show the power state table and
'nvme get-feature -f 0x0c -H /dev/nvme0' will show the current APST
configuration.

This feature is quirked off on a known-buggy Samsung device.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit c5552fde102fcc3f2cf9e502b8ac90e3500d8fdf)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h
include/linux/nvme.h