2022-06-15 19:54:32

by Erwan Velu

[permalink] [raw]
Subject: [PATCH] nvme: Report model,sn,fw,pci device information during init

SCSI-based device get their identify properties being printed when initialized like :

[ 1.245357] scsi 0:0:0:0: Direct-Access ATA HGST HTE721010A9 A3M0 PQ: 0 ANSI: 5

When initializing nvme devices, no identification message is reported
making difficult to identify them during the boot process. If the system
crashes during boot process or if the init phase fail, it could be very diffcult
to identify the faulty disk.

This patch reports model, serial, firmware version and pci information
as soon as possible making this early identifying task possible.

Reporting the serial has the interest of being able to ensure which
physical drive is concerned if a hardware replacement is required and
host features the exact same drive multiple times.

A typical output looks like:
[ 0.383353] nvme nvme0: pci function 0000:00:03.0
[ 0.418184] nvme nvme0: MODEL:QEMU NVMe Ctrl SN:deadbeef FW:1.0 PCI_ID:1b36:1af4
[ 0.422020] nvme nvme0: 1/0/0 default/read/poll queues

Signed-off-by: Erwan Velu <[email protected]>
---
drivers/nvme/host/core.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 24165daee3c8..0922b7a470b1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2987,6 +2987,14 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
if (!ctrl->identified) {
unsigned int i;

+ /* Reporting model, serial, firmware and pci info */
+ dev_info(ctrl->device, "MODEL:%.*s SN:%.*s FW:%.*s PCI_ID:%04x:%04x\n",
+ (int)sizeof(id->mn), id->mn,
+ (int)sizeof(id->sn),id->sn,
+ (int)sizeof(id->fr), id->fr,
+ le16_to_cpu(id->vid),
+ le16_to_cpu(id->ssvid));
+
ret = nvme_init_subsystem(ctrl, id);
if (ret)
goto out_free;
--
2.35.3


2022-06-15 19:57:12

by Keith Busch

[permalink] [raw]
Subject: Re: [PATCH] nvme: Report model,sn,fw,pci device information during init

On Wed, Jun 15, 2022 at 08:02:13PM +0200, Erwan Velu wrote:
> SCSI-based device get their identify properties being printed when initialized like :
>
> [ 1.245357] scsi 0:0:0:0: Direct-Access ATA HGST HTE721010A9 A3M0 PQ: 0 ANSI: 5
>
> When initializing nvme devices, no identification message is reported
> making difficult to identify them during the boot process. If the system
> crashes during boot process or if the init phase fail, it could be very diffcult
> to identify the faulty disk.
>
> This patch reports model, serial, firmware version and pci information
> as soon as possible making this early identifying task possible.
>
> Reporting the serial has the interest of being able to ensure which
> physical drive is concerned if a hardware replacement is required and
> host features the exact same drive multiple times.
>
> A typical output looks like:
> [ 0.383353] nvme nvme0: pci function 0000:00:03.0
> [ 0.418184] nvme nvme0: MODEL:QEMU NVMe Ctrl SN:deadbeef FW:1.0 PCI_ID:1b36:1af4
> [ 0.422020] nvme nvme0: 1/0/0 default/read/poll queues

The PCI_ID: print is misleading. That format usually indicates VID:DID, but
you're printing VID:SSVID.

This is also very similar to the recently introduced nvme_print_device_info(),
but that one removes the annoying trailing spaces if they exist. I guess if
we're going this direction, just use that print, but change it from dev_err to
dev_info, and remove the call on global id collision detection.

2022-06-15 19:58:37

by Erwan Velu

[permalink] [raw]
Subject: Re: [PATCH] nvme: Report model,sn,fw,pci device information during init

[...]

> The PCI_ID: print is misleading. That format usually indicates VID:DID, but
> you're printing VID:SSVID.
True.

> This is also very similar to the recently introduced nvme_print_device_info(),
> but that one removes the annoying trailing spaces if they exist. I guess if
> we're going this direction, just use that print, but change it from dev_err to
> dev_info, and remove the call on global id collision detection.
Oh I missed it.
Shall I provide a patch for nvme-5.19 or wait until the next window ?