[PATCH] nvme: add bug report info for global duplicate id
Keith Busch
kbusch at kernel.org
Tue Jun 7 07:23:13 PDT 2022
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)
--
More information about the Linux-nvme
mailing list