public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
	Sasha Levin <sashal@kernel.org>,
	axboe@fb.com, sagi@grimberg.me, linux-nvme@lists.infradead.org
Subject: [PATCH AUTOSEL 5.18 06/22] nvme: add bug report info for global duplicate id
Date: Tue, 21 Jun 2022 16:49:12 -0400	[thread overview]
Message-ID: <20220621204928.249907-6-sashal@kernel.org> (raw)
In-Reply-To: <20220621204928.249907-1-sashal@kernel.org>

From: Keith Busch <kbusch@kernel.org>

[ Upstream commit 2f0dad1719cbbd690e916a42d937b7605ee63964 ]

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>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/nvme/host/core.c |  1 +
 drivers/nvme/host/nvme.h | 28 ++++++++++++++++++++++++++++
 drivers/nvme/host/pci.c  | 16 ++++++++++++++++
 3 files changed, 45 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 2d6a01853109..0e18f8b38081 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3803,6 +3803,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
 	if (ret) {
 		dev_err(ctrl->device,
 			"globally duplicate IDs for nsid %d\n", nsid);
+		nvme_print_device_info(ctrl);
 		return ret;
 	}
 
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a2b53ca63335..764dd1d88777 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -502,6 +502,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);
 };
 
 /*
@@ -547,6 +548,33 @@ static inline struct request *nvme_cid_to_rq(struct blk_mq_tags *tags,
 	return blk_mq_tag_to_rq(tags, nvme_tag_from_cid(command_id));
 }
 
+/*
+ * Return the length of the string without the space padding
+ */
+static inline int nvme_strlen(char *s, int len)
+{
+	while (s[len - 1] == ' ')
+		len--;
+	return len;
+}
+
+static inline void nvme_print_device_info(struct nvme_ctrl *ctrl)
+{
+	struct nvme_subsystem *subsys = ctrl->subsys;
+
+	if (ctrl->ops->print_device_info) {
+		ctrl->ops->print_device_info(ctrl);
+		return;
+	}
+
+	dev_err(ctrl->device,
+		"VID:%04x model:%.*s firmware:%.*s\n", subsys->vendor_id,
+		nvme_strlen(subsys->model, sizeof(subsys->model)),
+		subsys->model, nvme_strlen(subsys->firmware_rev,
+					   sizeof(subsys->firmware_rev)),
+		subsys->firmware_rev);
+}
+
 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
 void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
 			    const char *dev_name);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 17aeb7d5c485..37e05c83786d 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2970,6 +2970,21 @@ 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,
+		nvme_strlen(subsys->model, sizeof(subsys->model)),
+		subsys->model, nvme_strlen(subsys->firmware_rev,
+					   sizeof(subsys->firmware_rev)),
+		subsys->firmware_rev);
+}
+
 static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
 	.name			= "pcie",
 	.module			= THIS_MODULE,
@@ -2981,6 +2996,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)
-- 
2.35.1


  parent reply	other threads:[~2022-06-21 20:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 20:49 [PATCH AUTOSEL 5.18 01/22] genirq: PM: Use runtime PM for chained interrupts Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 02/22] irqchip/uniphier-aidet: Add compatible string for NX1 SoC Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 03/22] staging: rtl8723bs: Allocate full pwep structure Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 04/22] mei: me: set internal pg flag to off on hardware reset Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 05/22] eeprom: at25: Split reads into chunks and cap write size Sasha Levin
2022-06-22  7:15   ` Geert Uytterhoeven
2022-06-21 20:49 ` Sasha Levin [this message]
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 07/22] nvme-pci: add trouble shooting steps for timeouts Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 08/22] nvme-pci: add NVME_QUIRK_BOGUS_NID for ADATA XPG GAMMIX S50 Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 09/22] nvme-pci: phison e12 has bogus namespace ids Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 10/22] nvme-pci: smi " Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 11/22] nvme-pci: sk hynix p31 " Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 12/22] nvme-pci: avoid the deepest sleep state on ZHITAI TiPro7000 SSDs Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 13/22] nvme-pci: disable write zeros support on UMIC and Samsung SSDs Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 14/22] net: usb: ax88179_178a needs FLAG_SEND_ZLP Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 15/22] ext2: fix fs corruption when trying to remove a non-empty directory with IO error Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 16/22] ext4: fix warning when submitting superblock in ext4_commit_super() Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 17/22] ext4: improve write performance with disabled delalloc Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 18/22] blk-mq: protect q->elevator by ->sysfs_lock in blk_mq_elv_switch_none Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 19/22] blk-mq: avoid to touch q->elevator without any protection Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 20/22] blk-mq: don't clear flush_rq from tags->rqs[] Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 21/22] cifs: when a channel is not found for server, log its connection id Sasha Levin
2022-06-21 20:49 ` [PATCH AUTOSEL 5.18 22/22] ext4: correct the judgment of BUG in ext4_mb_normalize_request Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220621204928.249907-6-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox