* [PATCH] nvme: copy firmware_rev on each init
@ 2022-09-19 19:45 Keith Busch
2022-09-19 23:04 ` Chaitanya Kulkarni
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Keith Busch @ 2022-09-19 19:45 UTC (permalink / raw)
To: linux-nvme, hch, sagi; +Cc: Keith Busch, Jeff Lien
From: Keith Busch <kbusch@kernel.org>
The firmware revision can change on after a reset so copy the most
recent info each time instead of just the first time, otherwise the
sysfs firmware_rev entry may contain stale data.
Reported-by: Jeff Lien <jeff.lien@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ea6694fd550f..e56ecc7fda2d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2893,7 +2893,6 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
nvme_init_subnqn(subsys, ctrl, id);
memcpy(subsys->serial, id->sn, sizeof(subsys->serial));
memcpy(subsys->model, id->mn, sizeof(subsys->model));
- memcpy(subsys->firmware_rev, id->fr, sizeof(subsys->firmware_rev));
subsys->vendor_id = le16_to_cpu(id->vid);
subsys->cmic = id->cmic;
@@ -3112,6 +3111,8 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
ctrl->quirks |= core_quirks[i].quirks;
}
}
+ memcpy(ctrl->subsys->firmware_rev, id->fr,
+ sizeof(ctrl->subsys->firmware_rev));
if (force_apst && (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) {
dev_warn(ctrl->device, "forcibly allowing all power states due to nvme_core.force_apst -- use at your own risk\n");
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: copy firmware_rev on each init
2022-09-19 19:45 [PATCH] nvme: copy firmware_rev on each init Keith Busch
@ 2022-09-19 23:04 ` Chaitanya Kulkarni
2022-09-20 8:23 ` Sagi Grimberg
2022-09-21 1:48 ` Chao Leng
2 siblings, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2022-09-19 23:04 UTC (permalink / raw)
To: Keith Busch; +Cc: Keith Busch, hch, sagi, linux-nvme
On 9/19/22 12:45, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> The firmware revision can change on after a reset so copy the most
> recent info each time instead of just the first time, otherwise the
> sysfs firmware_rev entry may contain stale data.
>
> Reported-by: Jeff Lien <jeff.lien@wdc.com>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: copy firmware_rev on each init
2022-09-19 19:45 [PATCH] nvme: copy firmware_rev on each init Keith Busch
2022-09-19 23:04 ` Chaitanya Kulkarni
@ 2022-09-20 8:23 ` Sagi Grimberg
2022-09-21 1:48 ` Chao Leng
2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2022-09-20 8:23 UTC (permalink / raw)
To: Keith Busch, linux-nvme, hch; +Cc: Keith Busch, Jeff Lien
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: copy firmware_rev on each init
2022-09-19 19:45 [PATCH] nvme: copy firmware_rev on each init Keith Busch
2022-09-19 23:04 ` Chaitanya Kulkarni
2022-09-20 8:23 ` Sagi Grimberg
@ 2022-09-21 1:48 ` Chao Leng
2 siblings, 0 replies; 4+ messages in thread
From: Chao Leng @ 2022-09-21 1:48 UTC (permalink / raw)
To: Keith Busch, linux-nvme, hch, sagi; +Cc: Keith Busch, Jeff Lien
On 2022/9/20 3:45, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> The firmware revision can change on after a reset so copy the most
> recent info each time instead of just the first time, otherwise the
> sysfs firmware_rev entry may contain stale data.
>
> Reported-by: Jeff Lien <jeff.lien@wdc.com>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> drivers/nvme/host/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index ea6694fd550f..e56ecc7fda2d 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2893,7 +2893,6 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
> nvme_init_subnqn(subsys, ctrl, id);
> memcpy(subsys->serial, id->sn, sizeof(subsys->serial));
> memcpy(subsys->model, id->mn, sizeof(subsys->model));
> - memcpy(subsys->firmware_rev, id->fr, sizeof(subsys->firmware_rev));
> subsys->vendor_id = le16_to_cpu(id->vid);
> subsys->cmic = id->cmic;
>
> @@ -3112,6 +3111,8 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
> ctrl->quirks |= core_quirks[i].quirks;
> }
> }
> + memcpy(ctrl->subsys->firmware_rev, id->fr,
> + sizeof(ctrl->subsys->firmware_rev));
Perhaps it would be better to place it near the call to nvme_init_subsystem.
>
> if (force_apst && (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) {
> dev_warn(ctrl->device, "forcibly allowing all power states due to nvme_core.force_apst -- use at your own risk\n");
>
Anyway, looks good to me.
Reviewed-by: Chao Leng <lengchao@huawei.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-21 1:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19 19:45 [PATCH] nvme: copy firmware_rev on each init Keith Busch
2022-09-19 23:04 ` Chaitanya Kulkarni
2022-09-20 8:23 ` Sagi Grimberg
2022-09-21 1:48 ` Chao Leng
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.