[PATCHv2 3/3] nvme: Expose cntrltype and dctype through sysfs
Greg KH
gregkh at linuxfoundation.org
Thu Feb 3 23:45:31 PST 2022
On Thu, Feb 03, 2022 at 04:17:48PM -0500, Martin Belanger wrote:
> From: Martin Belanger <martin.belanger at dell.com>
>
> TP8010 introduces the Discovery Controller Type attribute (dctype).
> The dctype is returned in the response to the Identify command. This
> patch exposes the dctype through the sysfs. Since the dctype depends on
> the Controller Type (cntrltype), another attribute of the Identify
> response, the patch also exposes the cntrltype as well. The dctype will
> only be displayed for discovery controllers.
>
> Signed-off-by: Martin Belanger <martin.belanger at dell.com>
> ---
> drivers/nvme/host/core.c | 45 ++++++++++++++++++++++++++++++++++++++++
> drivers/nvme/host/nvme.h | 3 +++
> include/linux/nvme.h | 10 ++++++++-
> 3 files changed, 57 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index b5e452aa3c0e..4e3db5ec3924 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2990,6 +2990,9 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
> ctrl->max_namespaces = le32_to_cpu(id->mnan);
> ctrl->ctratt = le32_to_cpu(id->ctratt);
>
> + ctrl->cntrltype = id->cntrltype;
> + ctrl->dctype = id->dctype;
> +
> if (id->rtd3e) {
> /* us -> s */
> u32 transition_time = le32_to_cpu(id->rtd3e) / USEC_PER_SEC;
> @@ -3115,6 +3118,10 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
> return ret;
> }
>
> + ret = device_update_groups(ctrl->device);
> + if (ret)
> + return ret;
Why is this needed here? How did the class or type just change? That
should never change over the lifespan of a device. If it does, you need
to tear down the old device and create a new one as something really
wrong just happened.
thanks,
greg k-h
More information about the Linux-nvme
mailing list