Skip to content

Commit e3d7874

Browse files
Keith Buschaxboe
authored andcommitted
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: Keith Busch <keith.busch@intel.com> Reviewed-by: Guan Junxiong <guanjunxiong@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d99ca60 commit e3d7874

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

drivers/nvme/host/core.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,11 +2665,28 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
26652665
}
26662666
EXPORT_SYMBOL_GPL(nvme_remove_namespaces);
26672667

2668+
static void nvme_aen_uevent(struct nvme_ctrl *ctrl)
2669+
{
2670+
char *envp[2] = { NULL, NULL };
2671+
u32 aen_result = ctrl->aen_result;
2672+
2673+
ctrl->aen_result = 0;
2674+
if (!aen_result)
2675+
return;
2676+
2677+
envp[0] = kasprintf(GFP_KERNEL, "NVME_AEN=%#08x", aen_result);
2678+
if (!envp[0])
2679+
return;
2680+
kobject_uevent_env(&ctrl->device->kobj, KOBJ_CHANGE, envp);
2681+
kfree(envp[0]);
2682+
}
2683+
26682684
static void nvme_async_event_work(struct work_struct *work)
26692685
{
26702686
struct nvme_ctrl *ctrl =
26712687
container_of(work, struct nvme_ctrl, async_event_work);
26722688

2689+
nvme_aen_uevent(ctrl);
26732690
ctrl->ops->submit_async_event(ctrl);
26742691
}
26752692

@@ -2741,6 +2758,17 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
27412758
if (le16_to_cpu(status) >> 1 != NVME_SC_SUCCESS)
27422759
return;
27432760

2761+
switch (result & 0x7) {
2762+
case NVME_AER_ERROR:
2763+
case NVME_AER_SMART:
2764+
case NVME_AER_CSS:
2765+
case NVME_AER_VS:
2766+
ctrl->aen_result = result;
2767+
break;
2768+
default:
2769+
break;
2770+
}
2771+
27442772
switch (result & 0xff07) {
27452773
case NVME_AER_NOTICE_NS_CHANGED:
27462774
dev_info(ctrl->device, "rescanning\n");

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct nvme_ctrl {
168168
u16 kas;
169169
u8 npss;
170170
u8 apsta;
171+
u32 aen_result;
171172
unsigned int shutdown_timeout;
172173
unsigned int kato;
173174
bool subsystem;

include/linux/nvme.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ enum {
428428
};
429429

430430
enum {
431+
NVME_AER_ERROR = 0,
432+
NVME_AER_SMART = 1,
433+
NVME_AER_CSS = 6,
434+
NVME_AER_VS = 7,
431435
NVME_AER_NOTICE_NS_CHANGED = 0x0002,
432436
NVME_AER_NOTICE_FW_ACT_STARTING = 0x0102,
433437
};

0 commit comments

Comments
 (0)