Commit e3d7874d authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe

nvme: send uevent for some asynchronous events

This will give udev a chance to observe and handle asynchronous event
notifications and clear the log to unmask future events of the same type.
The driver will create a change uevent of the asyncronuos event result
before submitting the next AEN request to the device if a completed AEN
event is of type error, smart, command set or vendor specific,
Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
Reviewed-by: default avatarGuan Junxiong <guanjunxiong@huawei.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d99ca609
...@@ -2665,11 +2665,28 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) ...@@ -2665,11 +2665,28 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
} }
EXPORT_SYMBOL_GPL(nvme_remove_namespaces); EXPORT_SYMBOL_GPL(nvme_remove_namespaces);
static void nvme_aen_uevent(struct nvme_ctrl *ctrl)
{
char *envp[2] = { NULL, NULL };
u32 aen_result = ctrl->aen_result;
ctrl->aen_result = 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);
kfree(envp[0]);
}
static void nvme_async_event_work(struct work_struct *work) static void nvme_async_event_work(struct work_struct *work)
{ {
struct nvme_ctrl *ctrl = struct nvme_ctrl *ctrl =
container_of(work, struct nvme_ctrl, async_event_work); container_of(work, struct nvme_ctrl, async_event_work);
nvme_aen_uevent(ctrl);
ctrl->ops->submit_async_event(ctrl); ctrl->ops->submit_async_event(ctrl);
} }
...@@ -2741,6 +2758,17 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, ...@@ -2741,6 +2758,17 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
if (le16_to_cpu(status) >> 1 != NVME_SC_SUCCESS) if (le16_to_cpu(status) >> 1 != NVME_SC_SUCCESS)
return; return;
switch (result & 0x7) {
case NVME_AER_ERROR:
case NVME_AER_SMART:
case NVME_AER_CSS:
case NVME_AER_VS:
ctrl->aen_result = result;
break;
default:
break;
}
switch (result & 0xff07) { switch (result & 0xff07) {
case NVME_AER_NOTICE_NS_CHANGED: case NVME_AER_NOTICE_NS_CHANGED:
dev_info(ctrl->device, "rescanning\n"); dev_info(ctrl->device, "rescanning\n");
......
...@@ -168,6 +168,7 @@ struct nvme_ctrl { ...@@ -168,6 +168,7 @@ struct nvme_ctrl {
u16 kas; u16 kas;
u8 npss; u8 npss;
u8 apsta; u8 apsta;
u32 aen_result;
unsigned int shutdown_timeout; unsigned int shutdown_timeout;
unsigned int kato; unsigned int kato;
bool subsystem; bool subsystem;
......
...@@ -428,6 +428,10 @@ enum { ...@@ -428,6 +428,10 @@ enum {
}; };
enum { enum {
NVME_AER_ERROR = 0,
NVME_AER_SMART = 1,
NVME_AER_CSS = 6,
NVME_AER_VS = 7,
NVME_AER_NOTICE_NS_CHANGED = 0x0002, NVME_AER_NOTICE_NS_CHANGED = 0x0002,
NVME_AER_NOTICE_FW_ACT_STARTING = 0x0102, NVME_AER_NOTICE_FW_ACT_STARTING = 0x0102,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment