[PATCH 1/3] nvme: Add warning for PST table memory allocation failure in nvme_configure_apst

From: Yaxiong Tian
Date: Wed Mar 26 2025 - 06:15:23 EST


From: Yaxiong Tian <tianyaxiong@xxxxxxxxxx>

Currently the function fails silently on PST table memory allocation failure.
Add warning messages to improve error visibility.

Signed-off-by: Yaxiong Tian <tianyaxiong@xxxxxxxxxx>
---
drivers/nvme/host/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c2d89fac86c5..fb0404fee551 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2678,8 +2678,10 @@ static int nvme_configure_apst(struct nvme_ctrl *ctrl)
}

table = kzalloc(sizeof(*table), GFP_KERNEL);
- if (!table)
+ if (!table) {
+ dev_warn(ctrl->device, "Failed to allocate pst table; not using APST\n");
return 0;
+ }

if (!ctrl->apst_enabled || ctrl->ps_max_latency_us == 0) {
/* Turn off APST. */
--
2.25.1