diff --git a/1001-nvme.patch b/1001-nvme.patch new file mode 100644 index 0000000..e5916d5 --- /dev/null +++ b/1001-nvme.patch @@ -0,0 +1,69 @@ +Link: https://bugzilla.kernel.org/show_bug.cgi?id=214509 +Cc: Sven Peter +Reported-by: Orlando Chamberlain +Reported-by: Aditya Garg +Signed-off-by: Keith Busch +--- +v1->v2: fixed logical bug checking the quirk setting + + drivers/nvme/host/core.c | 4 +++- + drivers/nvme/host/nvme.h | 6 ++++++ + drivers/nvme/host/pci.c | 3 ++- + 3 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c +index e486845d2c7e..7712a8f78337 100644 +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -978,6 +978,7 @@ EXPORT_SYMBOL_GPL(nvme_cleanup_cmd); + blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) + { + struct nvme_command *cmd = nvme_req(req)->cmd; ++ struct nvme_ctrl *ctrl = nvme_req(req)->ctrl; + blk_status_t ret = BLK_STS_OK; + + if (!(req->rq_flags & RQF_DONTPREP)) { +@@ -1026,7 +1027,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) + return BLK_STS_IOERR; + } + +- nvme_req(req)->genctr++; ++ if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN)) ++ nvme_req(req)->genctr++; + cmd->common.command_id = nvme_cid(req); + trace_nvme_setup_cmd(req, cmd); + return ret; +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h +index 9871c0c9374c..ed79a6c7e804 100644 +--- a/drivers/nvme/host/nvme.h ++++ b/drivers/nvme/host/nvme.h +@@ -138,6 +138,12 @@ enum nvme_quirks { + * 48 bits. + */ + NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16), ++ ++ /* ++ * The controller requires the command_id value be be limited, so skip ++ * encoding the generation sequence number. ++ */ ++ NVME_QUIRK_SKIP_CID_GEN = (1 << 17), + }; + + /* +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c +index b82492cd7503..456a0e8a5718 100644 +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -3369,7 +3369,8 @@ static const struct pci_device_id nvme_id_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005), + .driver_data = NVME_QUIRK_SINGLE_VECTOR | + NVME_QUIRK_128_BYTES_SQES | +- NVME_QUIRK_SHARED_TAGS }, ++ NVME_QUIRK_SHARED_TAGS | ++ NVME_QUIRK_SKIP_CID_GEN }, + + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +-- +2.25.4 + diff --git a/1001-revert-nvme.patch b/1001-revert-nvme.patch deleted file mode 100644 index 7678783..0000000 --- a/1001-revert-nvme.patch +++ /dev/null @@ -1,237 +0,0 @@ -From 9e9464bd0b7c6f205d49089503059b90d3f654ce Mon Sep 17 00:00:00 2001 -From: Aditya Garg <85610623+AdityaGarg8@users.noreply.github.com> -Date: Fri, 24 Sep 2021 15:36:45 +0530 -Subject: [PATCH] Revert nvme to 5.10.66 - ---- - drivers/nvme/host/core.c | 3 +-- - drivers/nvme/host/nvme.h | 47 +------------------------------------- - drivers/nvme/host/pci.c | 2 +- - drivers/nvme/host/rdma.c | 4 ++-- - drivers/nvme/host/tcp.c | 38 ++++++++++++++++++------------ - drivers/nvme/target/loop.c | 4 ++-- - 6 files changed, 30 insertions(+), 68 deletions(-) - -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index 5a9b2f1b1..ff5a16b17 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -878,8 +878,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, - return BLK_STS_IOERR; - } - -- nvme_req(req)->genctr++; -- cmd->common.command_id = nvme_cid(req); -+ cmd->common.command_id = req->tag; - trace_nvme_setup_cmd(req, cmd); - return ret; - } -diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h -index 8c735c55c..3cb3c8206 100644 ---- a/drivers/nvme/host/nvme.h -+++ b/drivers/nvme/host/nvme.h -@@ -153,7 +153,6 @@ enum nvme_quirks { - struct nvme_request { - struct nvme_command *cmd; - union nvme_result result; -- u8 genctr; - u8 retries; - u8 flags; - u16 status; -@@ -470,49 +469,6 @@ struct nvme_ctrl_ops { - int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size); - }; - --/* -- * nvme command_id is constructed as such: -- * | xxxx | xxxxxxxxxxxx | -- * gen request tag -- */ --#define nvme_genctr_mask(gen) (gen & 0xf) --#define nvme_cid_install_genctr(gen) (nvme_genctr_mask(gen) << 12) --#define nvme_genctr_from_cid(cid) ((cid & 0xf000) >> 12) --#define nvme_tag_from_cid(cid) (cid & 0xfff) -- --static inline u16 nvme_cid(struct request *rq) --{ -- return nvme_cid_install_genctr(nvme_req(rq)->genctr) | rq->tag; --} -- --static inline struct request *nvme_find_rq(struct blk_mq_tags *tags, -- u16 command_id) --{ -- u8 genctr = nvme_genctr_from_cid(command_id); -- u16 tag = nvme_tag_from_cid(command_id); -- struct request *rq; -- -- rq = blk_mq_tag_to_rq(tags, tag); -- if (unlikely(!rq)) { -- pr_err("could not locate request for tag %#x\n", -- tag); -- return NULL; -- } -- if (unlikely(nvme_genctr_mask(nvme_req(rq)->genctr) != genctr)) { -- dev_err(nvme_req(rq)->ctrl->device, -- "request %#x genctr mismatch (got %#x expected %#x)\n", -- tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr)); -- return NULL; -- } -- return rq; --} -- --static inline struct request *nvme_cid_to_rq(struct blk_mq_tags *tags, -- u16 command_id) --{ -- return blk_mq_tag_to_rq(tags, nvme_tag_from_cid(command_id)); --} -- - #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS - void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj, - const char *dev_name); -@@ -610,8 +566,7 @@ static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl) - - static inline bool nvme_is_aen_req(u16 qid, __u16 command_id) - { -- return !qid && -- nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH; -+ return !qid && command_id >= NVME_AQ_BLK_MQ_DEPTH; - } - - void nvme_complete_rq(struct request *req); -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index 09767a805..fb48a88d1 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -1012,7 +1012,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx) - return; - } - -- req = nvme_find_rq(nvme_queue_tagset(nvmeq), command_id); -+ req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), command_id); - if (unlikely(!req)) { - dev_warn(nvmeq->dev->ctrl.device, - "invalid id %d completed on queue %d\n", -diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c -index 9c356be7f..c6c2e2361 100644 ---- a/drivers/nvme/host/rdma.c -+++ b/drivers/nvme/host/rdma.c -@@ -1738,10 +1738,10 @@ static void nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue, - struct request *rq; - struct nvme_rdma_request *req; - -- rq = nvme_find_rq(nvme_rdma_tagset(queue), cqe->command_id); -+ rq = blk_mq_tag_to_rq(nvme_rdma_tagset(queue), cqe->command_id); - if (!rq) { - dev_err(queue->ctrl->ctrl.device, -- "got bad command_id %#x on QP %#x\n", -+ "tag 0x%x on QP %#x not found\n", - cqe->command_id, queue->qp->qp_num); - nvme_rdma_error_recovery(queue->ctrl); - return; -diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c -index c9a925999..5b11d8a23 100644 ---- a/drivers/nvme/host/tcp.c -+++ b/drivers/nvme/host/tcp.c -@@ -484,11 +484,11 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, - { - struct request *rq; - -- rq = nvme_find_rq(nvme_tcp_tagset(queue), cqe->command_id); -+ rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), cqe->command_id); - if (!rq) { - dev_err(queue->ctrl->ctrl.device, -- "got bad cqe.command_id %#x on queue %d\n", -- cqe->command_id, nvme_tcp_queue_id(queue)); -+ "queue %d tag 0x%x not found\n", -+ nvme_tcp_queue_id(queue), cqe->command_id); - nvme_tcp_error_recovery(&queue->ctrl->ctrl); - return -EINVAL; - } -@@ -505,11 +505,11 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue, - { - struct request *rq; - -- rq = nvme_find_rq(nvme_tcp_tagset(queue), pdu->command_id); -+ rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id); - if (!rq) { - dev_err(queue->ctrl->ctrl.device, -- "got bad c2hdata.command_id %#x on queue %d\n", -- pdu->command_id, nvme_tcp_queue_id(queue)); -+ "queue %d tag %#x not found\n", -+ nvme_tcp_queue_id(queue), pdu->command_id); - return -ENOENT; - } - -@@ -603,7 +603,7 @@ static int nvme_tcp_setup_h2c_data_pdu(struct nvme_tcp_request *req, - data->hdr.plen = - cpu_to_le32(data->hdr.hlen + hdgst + req->pdu_len + ddgst); - data->ttag = pdu->ttag; -- data->command_id = nvme_cid(rq); -+ data->command_id = rq->tag; - data->data_offset = cpu_to_le32(req->data_sent); - data->data_length = cpu_to_le32(req->pdu_len); - return 0; -@@ -616,11 +616,11 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue, - struct request *rq; - int ret; - -- rq = nvme_find_rq(nvme_tcp_tagset(queue), pdu->command_id); -+ rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id); - if (!rq) { - dev_err(queue->ctrl->ctrl.device, -- "got bad r2t.command_id %#x on queue %d\n", -- pdu->command_id, nvme_tcp_queue_id(queue)); -+ "queue %d tag %#x not found\n", -+ nvme_tcp_queue_id(queue), pdu->command_id); - return -ENOENT; - } - req = blk_mq_rq_to_pdu(rq); -@@ -699,9 +699,17 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb, - unsigned int *offset, size_t *len) - { - struct nvme_tcp_data_pdu *pdu = (void *)queue->pdu; -- struct request *rq = -- nvme_cid_to_rq(nvme_tcp_tagset(queue), pdu->command_id); -- struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); -+ struct nvme_tcp_request *req; -+ struct request *rq; -+ -+ rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id); -+ if (!rq) { -+ dev_err(queue->ctrl->ctrl.device, -+ "queue %d tag %#x not found\n", -+ nvme_tcp_queue_id(queue), pdu->command_id); -+ return -ENOENT; -+ } -+ req = blk_mq_rq_to_pdu(rq); - - while (true) { - int recv_len, ret; -@@ -793,8 +801,8 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue, - } - - if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) { -- struct request *rq = nvme_cid_to_rq(nvme_tcp_tagset(queue), -- pdu->command_id); -+ struct request *rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), -+ pdu->command_id); - - nvme_tcp_end_request(rq, NVME_SC_SUCCESS); - queue->nr_cqe++; -diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c -index ff3258c3e..16d71cc5a 100644 ---- a/drivers/nvme/target/loop.c -+++ b/drivers/nvme/target/loop.c -@@ -107,10 +107,10 @@ static void nvme_loop_queue_response(struct nvmet_req *req) - } else { - struct request *rq; - -- rq = nvme_find_rq(nvme_loop_tagset(queue), cqe->command_id); -+ rq = blk_mq_tag_to_rq(nvme_loop_tagset(queue), cqe->command_id); - if (!rq) { - dev_err(queue->ctrl->ctrl.device, -- "got bad command_id %#x on queue %d\n", -+ "tag 0x%x on queue %d not found\n", - cqe->command_id, nvme_loop_queue_idx(queue)); - return; - } diff --git a/1002-reapply-tcp-patch.patch b/1002-reapply-tcp-patch.patch deleted file mode 100644 index 034d044..0000000 --- a/1002-reapply-tcp-patch.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c -index 8cb15ee5b249e..d649b446da66c 100644 ---- a/drivers/nvme/host/tcp.c -+++ b/drivers/nvme/host/tcp.c -@@ -702,17 +702,9 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb, - unsigned int *offset, size_t *len) - { - struct nvme_tcp_data_pdu *pdu = (void *)queue->pdu; -- struct nvme_tcp_request *req; -- struct request *rq; -- -- rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id); -- if (!rq) { -- dev_err(queue->ctrl->ctrl.device, -- "queue %d tag %#x not found\n", -- nvme_tcp_queue_id(queue), pdu->command_id); -- return -ENOENT; -- } -- req = blk_mq_rq_to_pdu(rq); -+ struct request *rq = -+ blk_mq_tag_to_rq(nvme_tcp_tagset(queue), pdu->command_id); -+ struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); - - while (true) { - int recv_len, ret; diff --git a/PKGBUILD b/PKGBUILD index d8e6261..5e8b4c2 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -28,8 +28,7 @@ source=( 0002-HID-quirks-Add-Apple-Magic-Trackpad-2-to-hid_have_sp.patch #NVMe fix - 1001-revert-nvme.patch - 1002-reapply-tcp-patch.patch + 1001-nvme.patch # Hack for AMD DC eDP link rate bug 2001-drm-amd-display-Force-link_rate-as-LINK_RATE_RBR2-fo.patch @@ -245,8 +244,7 @@ sha256sums=('ca0eda14c512efa7fc054e9eb89dd8f6a6e7075aef1e39d30b5f243f7bde9b89' '1ddd4443470ad66aff8075e0528ad7757de41d474152db1362e23be72e243919' '6b4da532421cac5600d09c0c52742aa52d848af098f7853abe60c02e9d0a3752' '2184069ab00ef43d9674756e9b7a56d15188bc4494d34425f04ddc779c52acd8' - '78ea4702928d87bfdd41c6998154d7c2e1396c823a012d3891f1b803198712aa' - 'ec658c85b9cfaa32acda11ec768e608bafe5b53a7511523b55c8c082d8dce04a' + '50bab6fa754e857c462fb1cf88a74b88bd85b5a34fdebbc54e4ded7a9a04e004' '786dfc22e4c6ece883e7dedd0ba3f6c14018584df95450b2cb78f3da8b01f7cb' '7366a08383900a09f8e742b1e4f0a02e0839a385e68e70a89d1815c197df3300' '8d8401a99a9dfbc41aa2dc5b6a409a19860b1b918465e19de4a4ff18de075ea3'