Skip to content

Commit a2941f6

Browse files
keithbuschaxboe
authored andcommitted
nvme: add command id quirk for apple controllers
Some apple controllers use the command id as an index to implementation specific data structures and will fail if the value is out of bounds. The nvme driver's recently introduced command sequence number breaks this controller. Provide a quirk so these spec incompliant controllers can function as before. The driver will not have the ability to detect bad completions when this quirk is used, but we weren't previously checking this anyway. The quirk bit was selected so that it can readily apply to stable. Link: https://bugzilla.kernel.org/show_bug.cgi?id=214509 Cc: Sven Peter <[email protected]> Reported-by: Orlando Chamberlain <[email protected]> Reported-by: Aditya Garg <[email protected]> Signed-off-by: Keith Busch <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Sven Peter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent f278eb3 commit a2941f6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

drivers/nvme/host/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ EXPORT_SYMBOL_GPL(nvme_cleanup_cmd);
978978
blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
979979
{
980980
struct nvme_command *cmd = nvme_req(req)->cmd;
981+
struct nvme_ctrl *ctrl = nvme_req(req)->ctrl;
981982
blk_status_t ret = BLK_STS_OK;
982983

983984
if (!(req->rq_flags & RQF_DONTPREP)) {
@@ -1026,7 +1027,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
10261027
return BLK_STS_IOERR;
10271028
}
10281029

1029-
nvme_req(req)->genctr++;
1030+
if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN))
1031+
nvme_req(req)->genctr++;
10301032
cmd->common.command_id = nvme_cid(req);
10311033
trace_nvme_setup_cmd(req, cmd);
10321034
return ret;

drivers/nvme/host/nvme.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ enum nvme_quirks {
138138
* 48 bits.
139139
*/
140140
NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16),
141+
142+
/*
143+
* The controller requires the command_id value be be limited, so skip
144+
* encoding the generation sequence number.
145+
*/
146+
NVME_QUIRK_SKIP_CID_GEN = (1 << 17),
141147
};
142148

143149
/*

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,8 @@ static const struct pci_device_id nvme_id_table[] = {
33693369
{ PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005),
33703370
.driver_data = NVME_QUIRK_SINGLE_VECTOR |
33713371
NVME_QUIRK_128_BYTES_SQES |
3372-
NVME_QUIRK_SHARED_TAGS },
3372+
NVME_QUIRK_SHARED_TAGS |
3373+
NVME_QUIRK_SKIP_CID_GEN },
33733374

33743375
{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
33753376
{ 0, }

0 commit comments

Comments
 (0)