Skip to contentSkip to conversation

nvme: add quirk to force medium priority for SQ creation

PATCH Superseded Jens Axboe 2 participants 3 messages May 8, 2018 NVMe

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH v2 1/1 nvme: add quirk to force medium priority for SQ creation

Some P3100 drives have a bug where they think WRRU (weighted round robin) is always enabled, even though the host doesn't set it. Since they think it's enabled, they also look at the submission queue creation priority. We used to set that to MEDIUM by default, but that was removed in commit 81c1cd98351b. This causes various issues on that drive. Add a quick to still set MEDIUM priority for that controller.

Fixes 81c1cd98351b ("nvme/pci: Don't set reserved SQ create flags")
Cc stable at vger.kernel.org
Signed-off-by Jens Axboe <axboe at kernel.dk>

---

v2: Too quick a forward port, forgot to bump the quirk bit entry.

drivers/nvme/host/nvme.h +5 -0
index 7ded7a51c430..1201b7359fa6 100644
@@ -84,6 +84,11 @@ enum nvme_quirks {
 	 * Supports the LighNVM command set if indicated in vs[1].
 	 */
 	NVME_QUIRK_LIGHTNVM			= (1 << 6),
+
+	/*
+	 * Set MEDIUM priority on SQ creation
+	 */
+	NVME_QUIRK_MEDIUM_PRIO_SQ		= (1 << 7),
 };
 
 /*
drivers/nvme/host/pci.c +10 -1
index fbc71fac6f1e..985e313fdf6c 100644
@@ -1097,6 +1097,14 @@ static int adapter_alloc_sq(struct nvme_dev *dev, u16 qid,
 	int flags = NVME_QUEUE_PHYS_CONTIG;
 
 	/*
+	 * Some drives have a bug that auto-enables WRRU if MEDIUM isn't
+	 * set. Since URGENT priority is zeroes, it makes all queues
+	 * URGENT.
+	 */
+	if (ctrl->quirks & NVME_QUIRK_MEDIUM_PRIO_SQ)
+		flags |= NVME_SQ_PRIO_MEDIUM;
+
+	/*
 	 * Note: we (ab)use the fact that the prp fields survive if no data
 	 * is attached to the request.
 	 */
@@ -2701,7 +2709,8 @@ static const struct pci_device_id nvme_id_table[] = {
 		.driver_data = NVME_QUIRK_STRIPE_SIZE |
 				NVME_QUIRK_DEALLOCATE_ZEROES, },
 	{ PCI_VDEVICE(INTEL, 0xf1a5),	/* Intel 600P/P3100 */
-		.driver_data = NVME_QUIRK_NO_DEEPEST_PS },
+		.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
+				NVME_QUIRK_MEDIUM_PRIO_SQ },
 	{ PCI_VDEVICE(INTEL, 0x5845),	/* Qemu emulated controller */
 		.driver_data = NVME_QUIRK_IDENTIFY_CNS, },
 	{ PCI_DEVICE(0x1c58, 0x0003),	/* HGST adapter */
Signature · 1 line
Jens Axboe
#1 lore raw

PATCH v2 1/1 nvme: add quirk to force medium priority for SQ creation

drivers/nvme/host/pci.c static int adapter_alloc_sq(struct nvme_dev *dev, u16 qid, · line 1105

Quoted 12 lines · Jens Axboe
drivers/nvme/host/pci.c +6 -0
@@ -1097,6 +1097,14 @@ static int adapter_alloc_sq(struct nvme_dev *dev, u16 qid,
 	int flags = NVME_QUEUE_PHYS_CONTIG;
 
 	/*
+	 * Some drives have a bug that auto-enables WRRU if MEDIUM isn't
+	 * set. Since URGENT priority is zeroes, it makes all queues
+	 * URGENT.
+	 */
+	if (ctrl->quirks & NVME_QUIRK_MEDIUM_PRIO_SQ)
+		flags |= NVME_SQ_PRIO_MEDIUM;

'ctrl' is undeclared in this function; must be 'dev->ctrl.quirks'.

author maintainer
#2 lore raw

PATCH v2 1/1 nvme: add quirk to force medium priority for SQ creation

Quoted 6 lines · Keith Busch
Quoted 5 lines · Jens Axboe
drivers/nvme/host/pci.c +0 -0
@@ -1097,6 +1097,14 @@ static int adapter_alloc_sq(struct nvme_dev *dev, u16 qid,
 	int flags = NVME_QUEUE_PHYS_CONTIG;
 
Quoted 9 lines

drivers/nvme/host/pci.c static int adapter_alloc_sq(struct nvme_dev *dev, u16 qid, · line 1105

Quoted 7 lines
drivers/nvme/host/pci.c +6 -0
 	/*
+	 * Some drives have a bug that auto-enables WRRU if MEDIUM isn't
+	 * set. Since URGENT priority is zeroes, it makes all queues
+	 * URGENT.
+	 */
+	if (ctrl->quirks & NVME_QUIRK_MEDIUM_PRIO_SQ)
+		flags |= NVME_SQ_PRIO_MEDIUM;

'ctrl' is undeclared in this function; must be 'dev->ctrl.quirks'.

Gah, that's a lot of typos in a simple patch... Sending out v3.

Signature · 1 line
Jens Axboe