nvme: Support Autonomous Power State Transition (APST)
APST is an optional NVMe power-saving feature that allows devices to autonomously enter higher non-operational power states after a certain amount of idle time, reducing the controller's overall power consumption. Signed-off-by: Alexey Sukhoguzov <sap@eseipi.net> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1444
This commit is contained in:
committed by
Warner Losh
parent
4c18ec0e75
commit
a24932dcec
@@ -128,6 +128,15 @@ hw.nvme.hmb_max
|
|||||||
.Pp
|
.Pp
|
||||||
The default value is 5% of physical memory size per device.
|
The default value is 5% of physical memory size per device.
|
||||||
.Pp
|
.Pp
|
||||||
|
To enable Autonomous Power State Transition (APST), set the following
|
||||||
|
tunable value in
|
||||||
|
.Xr loader.conf 5 :
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
hw.nvme.apst_enable=1
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
The default vendor-provided settings, if any, will be applied.
|
||||||
|
.Pp
|
||||||
The
|
The
|
||||||
.Xr nvd 4
|
.Xr nvd 4
|
||||||
driver is used to provide a disk driver to the system by default.
|
driver is used to provide a disk driver to the system by default.
|
||||||
|
|||||||
@@ -781,6 +781,41 @@ nvme_ctrlr_configure_aer(struct nvme_controller *ctrlr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nvme_ctrlr_configure_apst(struct nvme_controller *ctrlr)
|
||||||
|
{
|
||||||
|
struct nvme_completion_poll_status status;
|
||||||
|
uint64_t *data;
|
||||||
|
int data_size;
|
||||||
|
bool enable, error = true;
|
||||||
|
|
||||||
|
if (TUNABLE_BOOL_FETCH("hw.nvme.apst_enable", &enable) == 0 ||
|
||||||
|
ctrlr->cdata.apsta == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
data_size = 32 * sizeof(*data);
|
||||||
|
data = malloc(data_size, M_NVME, M_WAITOK | M_ZERO);
|
||||||
|
|
||||||
|
status.done = 0;
|
||||||
|
nvme_ctrlr_cmd_get_feature(ctrlr,
|
||||||
|
NVME_FEAT_AUTONOMOUS_POWER_STATE_TRANSITION, 0,
|
||||||
|
data, data_size, nvme_completion_poll_cb, &status);
|
||||||
|
nvme_completion_poll(&status);
|
||||||
|
if (nvme_completion_is_error(&status.cpl))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
status.done = 0;
|
||||||
|
nvme_ctrlr_cmd_set_feature(ctrlr,
|
||||||
|
NVME_FEAT_AUTONOMOUS_POWER_STATE_TRANSITION, enable, 0, 0,
|
||||||
|
0, 0, data, data_size, nvme_completion_poll_cb, &status);
|
||||||
|
nvme_completion_poll(&status);
|
||||||
|
error = nvme_completion_is_error(&status.cpl);
|
||||||
|
out:
|
||||||
|
if (error && bootverbose)
|
||||||
|
nvme_printf(ctrlr, "failed to configure APST\n");
|
||||||
|
free(data, M_NVME);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nvme_ctrlr_configure_int_coalescing(struct nvme_controller *ctrlr)
|
nvme_ctrlr_configure_int_coalescing(struct nvme_controller *ctrlr)
|
||||||
{
|
{
|
||||||
@@ -1047,6 +1082,7 @@ nvme_ctrlr_start(void *ctrlr_arg, bool resetting)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nvme_ctrlr_configure_aer(ctrlr);
|
nvme_ctrlr_configure_aer(ctrlr);
|
||||||
|
nvme_ctrlr_configure_apst(ctrlr);
|
||||||
nvme_ctrlr_configure_int_coalescing(ctrlr);
|
nvme_ctrlr_configure_int_coalescing(ctrlr);
|
||||||
|
|
||||||
for (i = 0; i < ctrlr->num_io_queues; i++)
|
for (i = 0; i < ctrlr->num_io_queues; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user