diff options
| author | Alexey Sukhoguzov <sap@eseipi.net> | 2024-10-30 11:03:30 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2026-01-09 20:32:49 +0000 |
| commit | a24932dcec45ca68fa5ca2f49bbf0df539cfd710 (patch) | |
| tree | 83a9dbe9355a1731bf67e7fd1cf4b55df3e19095 | |
| parent | 4c18ec0e75e1f2ca99e587d749a9191513e63a29 (diff) | |
| -rw-r--r-- | share/man/man4/nvme.4 | 9 | ||||
| -rw-r--r-- | sys/dev/nvme/nvme_ctrlr.c | 36 |
2 files changed, 45 insertions, 0 deletions
diff --git a/share/man/man4/nvme.4 b/share/man/man4/nvme.4 index dcd2ec86f5fa..d24ffc07ef9e 100644 --- a/share/man/man4/nvme.4 +++ b/share/man/man4/nvme.4 @@ -128,6 +128,15 @@ hw.nvme.hmb_max .Pp The default value is 5% of physical memory size per device. .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 .Xr nvd 4 driver is used to provide a disk driver to the system by default. diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index 7e1a3f02f326..2c13dac96342 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -782,6 +782,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 nvme_ctrlr_configure_int_coalescing(struct nvme_controller *ctrlr) { ctrlr->int_coal_time = 0; @@ -1047,6 +1082,7 @@ nvme_ctrlr_start(void *ctrlr_arg, bool resetting) } nvme_ctrlr_configure_aer(ctrlr); + nvme_ctrlr_configure_apst(ctrlr); nvme_ctrlr_configure_int_coalescing(ctrlr); for (i = 0; i < ctrlr->num_io_queues; i++) |
