* [PATCH] nvme: add bug report info for global duplicate id @ 2022-06-06 16:40 Keith Busch 2022-06-06 17:15 ` Chaitanya Kulkarni 2022-06-07 10:15 ` Christoph Hellwig 0 siblings, 2 replies; 5+ messages in thread From: Keith Busch @ 2022-06-06 16:40 UTC (permalink / raw) To: linux-nvme; +Cc: hch, sagi, Keith Busch From: Keith Busch <kbusch@kernel.org> The recent global id check is finding poorly implemented devices in the wild. Include relavant device information in the output to help quicken an appropriate quirk patch. Signed-off-by: Keith Busch <kbusch@kernel.org> --- drivers/nvme/host/core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 24165daee3c8..4cda5024a352 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3852,6 +3852,13 @@ static int nvme_global_check_duplicate_ids(struct nvme_subsystem *this, return ret; } +static int nvme_str_len(char *s, int len) +{ + while (s[len - 1] == ' ') + len--; + return len; +} + static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, struct nvme_ns_ids *ids, bool is_shared) { @@ -3861,8 +3868,18 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, ret = nvme_global_check_duplicate_ids(ctrl->subsys, ids); if (ret) { + struct nvme_subsystem *subsys = ctrl->subsys; + dev_err(ctrl->device, "globally duplicate IDs for nsid %d\n", nsid); + dev_err(ctrl->device, + "bug report info: VID:%04x model:%.*s firmware:%.*s\n", + subsys->vendor_id, + nvme_str_len(subsys->model, sizeof(subsys->model)), + subsys->model, + nvme_str_len(subsys->firmware_rev, + sizeof(subsys->firmware_rev)), + subsys->firmware_rev); return ret; } -- 2.30.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: add bug report info for global duplicate id 2022-06-06 16:40 [PATCH] nvme: add bug report info for global duplicate id Keith Busch @ 2022-06-06 17:15 ` Chaitanya Kulkarni 2022-06-07 10:15 ` Christoph Hellwig 1 sibling, 0 replies; 5+ messages in thread From: Chaitanya Kulkarni @ 2022-06-06 17:15 UTC (permalink / raw) To: Keith Busch, linux-nvme@lists.infradead.org Cc: hch@lst.de, sagi@grimberg.me, Keith Busch On 6/6/22 09:40, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > The recent global id check is finding poorly implemented devices in the > wild. Include relavant device information in the output to help quicken > an appropriate quirk patch. > > Signed-off-by: Keith Busch <kbusch@kernel.org> Looks good. Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: add bug report info for global duplicate id 2022-06-06 16:40 [PATCH] nvme: add bug report info for global duplicate id Keith Busch 2022-06-06 17:15 ` Chaitanya Kulkarni @ 2022-06-07 10:15 ` Christoph Hellwig 2022-06-07 14:23 ` Keith Busch 1 sibling, 1 reply; 5+ messages in thread From: Christoph Hellwig @ 2022-06-07 10:15 UTC (permalink / raw) To: Keith Busch; +Cc: linux-nvme, hch, sagi, Keith Busch On Mon, Jun 06, 2022 at 09:40:47AM -0700, Keith Busch wrote: > if (ret) { > + struct nvme_subsystem *subsys = ctrl->subsys; > + > dev_err(ctrl->device, > "globally duplicate IDs for nsid %d\n", nsid); > + dev_err(ctrl->device, > + "bug report info: VID:%04x model:%.*s firmware:%.*s\n", > + subsys->vendor_id, > + nvme_str_len(subsys->model, sizeof(subsys->model)), > + subsys->model, > + nvme_str_len(subsys->firmware_rev, > + sizeof(subsys->firmware_rev)), > + subsys->firmware_rev); So I like the idea here, but this won't give us the PCI device id that we usually need for quirks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: add bug report info for global duplicate id 2022-06-07 10:15 ` Christoph Hellwig @ 2022-06-07 14:23 ` Keith Busch 2022-06-07 14:44 ` Christoph Hellwig 0 siblings, 1 reply; 5+ messages in thread From: Keith Busch @ 2022-06-07 14:23 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Keith Busch, linux-nvme, sagi On Tue, Jun 07, 2022 at 12:15:26PM +0200, Christoph Hellwig wrote: > On Mon, Jun 06, 2022 at 09:40:47AM -0700, Keith Busch wrote: > > if (ret) { > > + struct nvme_subsystem *subsys = ctrl->subsys; > > + > > dev_err(ctrl->device, > > "globally duplicate IDs for nsid %d\n", nsid); > > + dev_err(ctrl->device, > > + "bug report info: VID:%04x model:%.*s firmware:%.*s\n", > > + subsys->vendor_id, > > + nvme_str_len(subsys->model, sizeof(subsys->model)), > > + subsys->model, > > + nvme_str_len(subsys->firmware_rev, > > + sizeof(subsys->firmware_rev)), > > + subsys->firmware_rev); > > So I like the idea here, but this won't give us the PCI device id > that we usually need for quirks. Yeah, we don't have the DID from core. Should I add a driver specific op to print device info? Just a quick rough idea here: --- diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 9b72b6ecf33c..8daf13eaddac 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -503,6 +503,7 @@ struct nvme_ctrl_ops { void (*submit_async_event)(struct nvme_ctrl *ctrl); void (*delete_ctrl)(struct nvme_ctrl *ctrl); int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size); + void (*print_device_info)(struct nvme_ctrl *ctrl); }; /* diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 9d963f6cdbae..709793efe16c 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2984,6 +2984,18 @@ static int nvme_pci_get_address(struct nvme_ctrl *ctrl, char *buf, int size) return snprintf(buf, size, "%s\n", dev_name(&pdev->dev)); } + +static void nvme_pci_print_device_info(struct nvme_ctrl *ctrl) +{ + struct pci_dev *pdev = to_pci_dev(to_nvme_dev(ctrl)->dev); + struct nvme_subsystem *subsys = ctrl->subsys; + + dev_err(ctrl->device, + "VID:DID %04x:%04x model:%.*s firmware:%.*s\n", + pdev->vendor, pdev->device, 20, subsys->model, 8, + subsys->firmware_rev); +} + static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = { .name = "pcie", .module = THIS_MODULE, @@ -2995,6 +3007,7 @@ static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = { .free_ctrl = nvme_pci_free_ctrl, .submit_async_event = nvme_pci_submit_async_event, .get_address = nvme_pci_get_address, + .print_device_info = nvme_pci_print_device_info, }; static int nvme_dev_map(struct nvme_dev *dev) -- ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: add bug report info for global duplicate id 2022-06-07 14:23 ` Keith Busch @ 2022-06-07 14:44 ` Christoph Hellwig 0 siblings, 0 replies; 5+ messages in thread From: Christoph Hellwig @ 2022-06-07 14:44 UTC (permalink / raw) To: Keith Busch; +Cc: Christoph Hellwig, Keith Busch, linux-nvme, sagi On Tue, Jun 07, 2022 at 08:23:13AM -0600, Keith Busch wrote: > > So I like the idea here, but this won't give us the PCI device id > > that we usually need for quirks. > > Yeah, we don't have the DID from core. Should I add a driver specific op to > print device info? Just a quick rough idea here: Yes, something like this looks reasonable to me. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-07 14:44 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-06-06 16:40 [PATCH] nvme: add bug report info for global duplicate id Keith Busch 2022-06-06 17:15 ` Chaitanya Kulkarni 2022-06-07 10:15 ` Christoph Hellwig 2022-06-07 14:23 ` Keith Busch 2022-06-07 14:44 ` Christoph Hellwig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox