[PATCH V2 1/2] nvme: Include AEN CQE.DW1 in NVME_AEN uevents

clay.mayers at kioxia.com clay.mayers at kioxia.com
Thu Sep 29 15:39:54 PDT 2022


From: Clay Mayers <clay.mayers at kioxia.com>

There are AENs from alternate command sets that include
extra data in their AEN's CQE.DW1.  For example, the ZNS
Zone-Descriptor-Changed AEN uses it to indicate the NSID
of the event's log page.

NVME_AEN uevent now includes the value of CQE.DW1 as a new
property.  It is only included when non-zero to keep previously
existing uevents unmodified.

Signed-off-by: Clay Mayers <clay.mayers at kioxia.com>
---
 drivers/nvme/host/core.c | 17 ++++++++++++-----
 drivers/nvme/host/nvme.h |  1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 66446f1e06cf..4fcc7aec5a8c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4615,17 +4615,22 @@ static void nvme_change_uevent(struct nvme_ctrl *ctrl, char *envdata)
 
 static void nvme_aen_uevent(struct nvme_ctrl *ctrl)
 {
-	char *envp[2] = { NULL, NULL };
+	char *envp[3] = { NULL, NULL, NULL };
 	u32 aen_result = ctrl->aen_result;
+	u32 aen_data = ctrl->aen_data;
 
 	ctrl->aen_result = 0;
+	ctrl->aen_data = 0;
 	if (!aen_result)
 		return;
 
 	envp[0] = kasprintf(GFP_KERNEL, "NVME_AEN=%#08x", aen_result);
-	if (!envp[0])
-		return;
-	kobject_uevent_env(&ctrl->device->kobj, KOBJ_CHANGE, envp);
+	if (aen_data)
+		envp[1] = kasprintf(GFP_KERNEL, "NVME_AEN_DATA=%#08x", aen_data);
+	if (envp[0] && (envp[1] || !aen_data))
+		kobject_uevent_env(&ctrl->device->kobj, KOBJ_CHANGE, envp);
+
+	kfree(envp[1]);
 	kfree(envp[0]);
 }
 
@@ -4799,8 +4804,10 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
 		break;
 	}
 
-	if (requeue)
+	if (requeue) {
+		ctrl->aen_data = le64_to_cpu(res->u64) >> 32;
 		queue_work(nvme_wq, &ctrl->async_event_work);
+	}
 }
 EXPORT_SYMBOL_GPL(nvme_complete_async_event);
 
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 1bdf714dcd9e..a1bab447dc65 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -299,6 +299,7 @@ struct nvme_ctrl {
 	u16 cctemp;
 	u32 oaes;
 	u32 aen_result;
+	u32 aen_data;
 	u32 ctratt;
 	unsigned int shutdown_timeout;
 	unsigned int kato;
-- 
2.27.0




More information about the Linux-nvme mailing list