Skip to content

Commit 5e0062d

Browse files
committed
read from DAOS_NVME_POWER_MGMT env
Signed-off-by: Tom Nabarro <[email protected]>
1 parent 667181c commit 5e0062d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bio/bio_device.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ set_power_mgmt_completion(struct spdk_bdev_io *bdev_io, bool success, void *cb_a
10801080
D_ERROR("Set power management failed for device %s, NVMe status code/type: %d/%d\n",
10811081
d_bdev->bb_name, sc, sct);
10821082
} else {
1083-
D_INFO("Power management set to 0x1 for device %s\n", d_bdev->bb_name);
1083+
D_INFO("Power management value set on device %s\n", d_bdev->bb_name);
10841084
}
10851085

10861086
spdk_bdev_free_io(bdev_io);
@@ -1091,12 +1091,23 @@ bio_set_power_mgmt(struct bio_bdev *d_bdev, struct spdk_io_channel *channel)
10911091
{
10921092
struct spdk_bdev *bdev;
10931093
struct spdk_nvme_cmd cmd;
1094+
uint32_t pwr_val = UINT32_MAX;
10941095
int rc;
10951096

10961097
D_ASSERT(d_bdev != NULL);
10971098
D_ASSERT(d_bdev->bb_desc != NULL);
10981099
D_ASSERT(channel != NULL);
10991100

1101+
rc = d_getenv_uint("DAOS_NVME_POWER_MGMT", &pwr_val);
1102+
if (rc == -DER_NONEXIST) {
1103+
return 0;
1104+
} else if (rc != 0) {
1105+
D_ERROR("DAOS_NVME_POWER_MGMT env value invalid, skipping set power management\n");
1106+
return -DER_INVAL;
1107+
}
1108+
1109+
D_INFO("New NVMe power management setting is %u\n", pwr_val);
1110+
11001111
bdev = spdk_bdev_desc_get_bdev(d_bdev->bb_desc);
11011112
if (bdev == NULL) {
11021113
D_ERROR("No bdev associated with device descriptor\n");
@@ -1117,7 +1128,7 @@ bio_set_power_mgmt(struct bio_bdev *d_bdev, struct spdk_io_channel *channel)
11171128
memset(&cmd, 0, sizeof(cmd));
11181129
cmd.opc = SPDK_NVME_OPC_SET_FEATURES;
11191130
cmd.cdw10 = SPDK_NVME_FEAT_POWER_MANAGEMENT;
1120-
cmd.cdw11 = 0x1;
1131+
cmd.cdw11 = pwr_val;
11211132

11221133
rc = spdk_bdev_nvme_admin_passthru(d_bdev->bb_desc, channel, &cmd, NULL, 0,
11231134
set_power_mgmt_completion, d_bdev);

0 commit comments

Comments
 (0)