nvme: respect NVME_QUIRK_DISABLE_WRITE_ZEROES when wzsl is set
Subsystems (2)
PATCH 1/2 nvme: respect NVME_QUIRK_DISABLE_WRITE_ZEROES when wzsl is set
From: Robert Beckett <[email protected]>
The NVM Command Set Identify Controller data may report a non-zero Write Zeroes Size Limit (wzsl). When present, nvme_init_non_mdts_limits() unconditionally overrides max_zeroes_sectors from wzsl, even if NVME_QUIRK_DISABLE_WRITE_ZEROES previously set it to zero.
This effectively re-enables write zeroes for devices that need it disabled, defeating the quirk. Several Kingston OM* drives rely on this quirk to avoid firmware issues with write zeroes commands.
Check for the quirk before applying the wzsl override.
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -3388,7 +3388,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl) ctrl->dmrl = id->dmrl; ctrl->dmrsl =le32_to_cpu (id->dmrsl); -if (id->wzsl) +if (id->wzsl && !(ctrl->quirks &NVME_QUIRK_DISABLE_WRITE_ZEROES )) ctrl->max_zeroes_sectors =nvme_mps_to_sectors (ctrl, id->wzsl); free_data:
Signature · 1 line
2.48.1
PATCH 2/2 nvme-pci: add NVME_QUIRK_DISABLE_WRITE_ZEROES for Kingston OM3SGP4
From: Robert Beckett <[email protected]>
The Kingston OM3SGP42048K2-A00 (PCI ID 2646:502f) firmware has a race condition when processing concurrent write zeroes and DSM (discard) commands, causing spurious "LBA Out of Range" errors and IOMMU page faults at address 0x0.
The issue is reliably triggered by running two concurrent mkfs commands on different partitions of the same drive, which generates interleaved write zeroes and discard operations.
Disable write zeroes for this device, matching the pattern used for other Kingston OM* drives that have similar firmware issues.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -4178,6 +4178,8 @@ static const struct pci_device_id nvme_id_table[] = { .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x2646, 0x501E), /* KINGSTON OM3PGP4xxxxQ OS21011 NVMe SSD */ .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, + { PCI_DEVICE(0x2646, 0x502F), /* KINGSTON OM3SGP4xxxxK NVMe SSD */ + .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x1f40, 0x1202), /* Netac Technologies Co. NV3000 NVMe SSD */ .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1f40, 0x5236), /* Netac Technologies Co. NV7000 NVMe SSD */
Signature · 1 line
2.48.1
Keith Busch
maintainerQuoted 9 lines · Bob Beckett
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/core.c +0
-0
drivers/nvme/host/core.c static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl) · line 3392
Quoted 6 lines
drivers/nvme/host/core.c +1
-1@@ -3388,7 +3388,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl) ctrl->dmrl = id->dmrl; ctrl->dmrsl =le32_to_cpu (id->dmrsl); -if (id->wzsl) +if (id->wzsl && !(ctrl->quirks &NVME_QUIRK_DISABLE_WRITE_ZEROES )) ctrl->max_zeroes_sectors =nvme_mps_to_sectors (ctrl, id->wzsl);
Interesting. This is from a more recent identification that I would have hoped devices going through the trouble of implementing it would have figured out by now how to report write zeroes support correctly.
Patches applied to nvme-7.1, thanks.