All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: Support user mode processing of ZNS Zone Changed AEN
@ 2022-09-29  0:16 clay.mayers
  2022-09-29  8:18 ` Sagi Grimberg
  0 siblings, 1 reply; 3+ messages in thread
From: clay.mayers @ 2022-09-29  0:16 UTC (permalink / raw)
  To: linux-nvme; +Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg

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

The ZNS Zone-Descriptor-Changes AEN is of type notify and uses CQE.DW1
to convey the namespace of the log page to read. Unhandled notify AENs
now generate an NVME_AEN uevent and include the value of CQE.DW1 as a
new property when non-zero.

All unhandled notify events are include to avoid command set specific
code in the aen handling.  This support is planned to be used by both
zone based applications and another unreleased device with an alternate
command set.

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

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 66446f1e06cf..fa865b8da1d3 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4615,17 +4615,20 @@ 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);
+	envp[1] = kasprintf(GFP_KERNEL, "NVME_AEN_DATA=%#08x", aen_data);
+	if (envp[0] && envp[1])
+		kobject_uevent_env(&ctrl->device->kobj, KOBJ_CHANGE, envp);
+	kfree(envp[1]);
 	kfree(envp[0]);
 }
 
@@ -4748,11 +4751,9 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
 		queue_work(nvme_wq, &ctrl->ana_work);
 		break;
 #endif
-	case NVME_AER_NOTICE_DISC_CHANGED:
+	default:
 		ctrl->aen_result = result;
 		break;
-	default:
-		dev_warn(ctrl->device, "async event result %08x\n", result);
 	}
 	return requeue;
 }
@@ -4799,8 +4800,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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: Support user mode processing of ZNS Zone Changed AEN
  2022-09-29  0:16 [PATCH] nvme: Support user mode processing of ZNS Zone Changed AEN clay.mayers
@ 2022-09-29  8:18 ` Sagi Grimberg
  2022-09-29 22:20   ` Clay Mayers
  0 siblings, 1 reply; 3+ messages in thread
From: Sagi Grimberg @ 2022-09-29  8:18 UTC (permalink / raw)
  To: clay.mayers, linux-nvme; +Cc: Keith Busch, Jens Axboe, Christoph Hellwig


> The ZNS Zone-Descriptor-Changes AEN is of type notify and uses CQE.DW1
> to convey the namespace of the log page to read. Unhandled notify AENs
> now generate an NVME_AEN uevent and include the value of CQE.DW1 as a
> new property when non-zero.

But you always send it...

> 
> All unhandled notify events are include to avoid command set specific
> code in the aen handling.  This support is planned to be used by both
> zone based applications and another unreleased device with an alternate
> command set.

This needs to be split into two patches.

> 
> Signed-off-by: Clay Mayers <clay.mayers@kioxia.com>
> ---
>   drivers/nvme/host/core.c | 19 +++++++++++--------
>   drivers/nvme/host/nvme.h |  1 +
>   2 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 66446f1e06cf..fa865b8da1d3 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4615,17 +4615,20 @@ 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);
> +	envp[1] = kasprintf(GFP_KERNEL, "NVME_AEN_DATA=%#08x", aen_data);
> +	if (envp[0] && envp[1])
> +		kobject_uevent_env(&ctrl->device->kobj, KOBJ_CHANGE, envp);
> +	kfree(envp[1]);
>   	kfree(envp[0]);
>   }
>   
> @@ -4748,11 +4751,9 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
>   		queue_work(nvme_wq, &ctrl->ana_work);
>   		break;
>   #endif
> -	case NVME_AER_NOTICE_DISC_CHANGED:
> +	default:
>   		ctrl->aen_result = result;
>   		break;
> -	default:
> -		dev_warn(ctrl->device, "async event result %08x\n", result);

I'd keep the log... and also don't know if we want to pass any unknown
possible spam to userspace... not sure that being blindly forward
compatible is the right choice here.

>   	}
>   	return requeue;
>   }
> @@ -4799,8 +4800,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;

Please use a helper for that.
aen_data is not a great name... maybe use a union for that for the
specific aen subtype?

Maybe it'd be better that zoned namespace aen is handled explicitly
and passes a AEN_NSID env veriable to the uevent.

>   		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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] nvme: Support user mode processing of ZNS Zone Changed AEN
  2022-09-29  8:18 ` Sagi Grimberg
@ 2022-09-29 22:20   ` Clay Mayers
  0 siblings, 0 replies; 3+ messages in thread
From: Clay Mayers @ 2022-09-29 22:20 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme; +Cc: Keith Busch, Jens Axboe, Christoph Hellwig

> From: Sagi Grimberg <sagi@grimberg.me>
> Sent: Thursday, September 29, 2022 1:19 AM
> 
> > The ZNS Zone-Descriptor-Changes AEN is of type notify and uses CQE.DW1
> > to convey the namespace of the log page to read. Unhandled notify AENs
> > now generate an NVME_AEN uevent and include the value of CQE.DW1 as a
> > new property when non-zero.
> 
> But you always send it...

Thanks for the quick review and catching my mistake.

> 
> >
> > All unhandled notify events are include to avoid command set specific
> > code in the aen handling.  This support is planned to be used by both
> > zone based applications and another unreleased device with an alternate
> > command set.
> 
> This needs to be split into two patches.
> 

It will be split in two for V2

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-29 22:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29  0:16 [PATCH] nvme: Support user mode processing of ZNS Zone Changed AEN clay.mayers
2022-09-29  8:18 ` Sagi Grimberg
2022-09-29 22:20   ` Clay Mayers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.