{"body":"commit 7ad7ab903681cc7ac2ee7be00d85ad63bfa78d08\nAuthor: Arnd Bergmann <arnd@arndb.de>\nDate:   Fri May 6 21:06:25 2022 +0200\n\n    nvme-apple: fix sparse endianess warnings\n    \n    The new nvme-apple driver is missing a few conversions to and\n    from little-endian data:\n    \n    drivers/nvme/host/apple.c:291:19: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned long long [usertype] prp1 @@     got restricted __le64 [usertype] prp1 @@\n    drivers/nvme/host/apple.c:291:19: sparse:     expected unsigned long long [usertype] prp1\n    drivers/nvme/host/apple.c:291:19: sparse:     got restricted __le64 [usertype] prp1\n    drivers/nvme/host/apple.c:292:19: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned long long [usertype] prp2 @@     got restricted __le64 [usertype] prp2 @@\n    drivers/nvme/host/apple.c:293:21: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] length @@     got restricted __le16 [usertype] length @@\n    drivers/nvme/host/apple.c:351:52: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int [usertype] next_dma_addr @@     got restricted __le64 [usertype] @@\n    drivers/nvme/host/apple.c:456:45: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le64 [usertype] @@     got unsigned int [addressable] [usertype] prp_dma @@\n    drivers/nvme/host/apple.c:459:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le64 [usertype] @@     got unsigned long long [assigned] [usertype] dma_addr @@\n    drivers/nvme/host/apple.c:474:25: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le64 [usertype] prp1 @@     got unsigned int [usertype] dma_address @@\n    drivers/nvme/host/apple.c:475:25: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le64 [usertype] prp2 @@     got unsigned int [usertype] first_dma @@\n    \n    Reported-by: kernel test robot <lkp@intel.com>\n    Signed-off-by: Arnd Bergmann <arnd@arndb.de>\n\ndiff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c\nindex b321f5c0563f..d702d7d60235 100644\n--- a/drivers/nvme/host/apple.c\n+++ b/drivers/nvme/host/apple.c\n@@ -112,10 +112,10 @@ struct apple_nvmmu_tcb {\n \n \tu8 command_id;\n \tu8 _unk0;\n-\tu32 length;\n-\tu8 _unk1[16];\n-\tu64 prp1;\n-\tu64 prp2;\n+\t__le16 length;\n+\tu8 _unk1[18];\n+\t__le64 prp1;\n+\t__le64 prp2;\n \tu8 _unk2[16];\n \tu8 aes_iv[8];\n \tu8 _aes_unk[64];\n@@ -348,7 +348,7 @@ static void apple_nvme_free_prps(struct apple_nvme *anv, struct request *req)\n \n \tfor (i = 0; i < iod->npages; i++) {\n \t\t__le64 *prp_list = apple_nvme_iod_list(req)[i];\n-\t\tdma_addr_t next_dma_addr = prp_list[last_prp];\n+\t\tdma_addr_t next_dma_addr = le64_to_cpu(prp_list[last_prp]);\n \n \t\tdma_pool_free(anv->prp_page_pool, prp_list, dma_addr);\n \t\tdma_addr = next_dma_addr;\n@@ -453,10 +453,10 @@ static blk_status_t apple_nvme_setup_prps(struct apple_nvme *anv,\n \t\t\t\tgoto free_prps;\n \t\t\tlist[iod->npages++] = prp_list;\n \t\t\tprp_list[0] = old_prp_list[i - 1];\n-\t\t\told_prp_list[i - 1] = prp_dma;\n+\t\t\told_prp_list[i - 1] = cpu_to_le64(prp_dma);\n \t\t\ti = 1;\n \t\t}\n-\t\tprp_list[i++] = dma_addr;\n+\t\tprp_list[i++] = cpu_to_le64(dma_addr);\n \t\tdma_len -= NVME_CTRL_PAGE_SIZE;\n \t\tdma_addr += NVME_CTRL_PAGE_SIZE;\n \t\tlength -= NVME_CTRL_PAGE_SIZE;\n@@ -471,8 +471,8 @@ static blk_status_t apple_nvme_setup_prps(struct apple_nvme *anv,\n \t\tdma_len = sg_dma_len(sg);\n \t}\n done:\n-\tcmnd->dptr.prp1 = sg_dma_address(iod->sg);\n-\tcmnd->dptr.prp2 = iod->first_dma;\n+\tcmnd->dptr.prp1 = cpu_to_le64(sg_dma_address(iod->sg));\n+\tcmnd->dptr.prp2 = cpu_to_le64(iod->first_dma);\n \treturn BLK_STS_OK;\n free_prps:\n \tapple_nvme_free_prps(anv, req);\n@@ -498,9 +498,9 @@ static blk_status_t apple_nvme_setup_prp_simple(struct apple_nvme *anv,\n \t\treturn BLK_STS_RESOURCE;\n \tiod->dma_len = bv->bv_len;\n \n-\tcmnd->dptr.prp1 = iod->first_dma;\n+\tcmnd->dptr.prp1 = cpu_to_le64(iod->first_dma);\n \tif (bv->bv_len > first_prp_len)\n-\t\tcmnd->dptr.prp2 = iod->first_dma + first_prp_len;\n+\t\tcmnd->dptr.prp2 = cpu_to_le64(iod->first_dma + first_prp_len);\n \treturn BLK_STS_OK;\n }\n \n@@ -570,7 +570,7 @@ static inline bool apple_nvme_cqe_pending(struct apple_nvme_queue *q)\n {\n \tstruct nvme_completion *hcqe = &q->cqes[q->cq_head];\n \n-\treturn (READ_ONCE(hcqe->status) & 1) == q->cq_phase;\n+\treturn (le16_to_cpu(READ_ONCE(hcqe->status)) & 1) == q->cq_phase;\n }\n \n static inline struct blk_mq_tags *\n@@ -682,11 +682,11 @@ static int apple_nvme_create_cq(struct apple_nvme *anv)\n \t * is attached to the request.\n \t */\n \tc.create_cq.opcode = nvme_admin_create_cq;\n-\tc.create_cq.prp1 = anv->ioq.cq_dma_addr;\n-\tc.create_cq.cqid = 1;\n-\tc.create_cq.qsize = APPLE_ANS_MAX_QUEUE_DEPTH - 1;\n-\tc.create_cq.cq_flags = NVME_QUEUE_PHYS_CONTIG | NVME_CQ_IRQ_ENABLED;\n-\tc.create_cq.irq_vector = 0;\n+\tc.create_cq.prp1 = cpu_to_le64(anv->ioq.cq_dma_addr);\n+\tc.create_cq.cqid = cpu_to_le16(1);\n+\tc.create_cq.qsize = cpu_to_le16(APPLE_ANS_MAX_QUEUE_DEPTH - 1);\n+\tc.create_cq.cq_flags = cpu_to_le16(NVME_QUEUE_PHYS_CONTIG | NVME_CQ_IRQ_ENABLED);\n+\tc.create_cq.irq_vector = cpu_to_le16(0);\n \n \treturn nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0);\n }\n@@ -696,7 +696,7 @@ static int apple_nvme_remove_cq(struct apple_nvme *anv)\n \tstruct nvme_command c = {};\n \n \tc.delete_queue.opcode = nvme_admin_delete_cq;\n-\tc.delete_queue.qid = 1;\n+\tc.delete_queue.qid = cpu_to_le16(1);\n \n \treturn nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0);\n }\n@@ -710,11 +710,11 @@ static int apple_nvme_create_sq(struct apple_nvme *anv)\n \t * is attached to the request.\n \t */\n \tc.create_sq.opcode = nvme_admin_create_sq;\n-\tc.create_sq.prp1 = anv->ioq.sq_dma_addr;\n-\tc.create_sq.sqid = 1;\n-\tc.create_sq.qsize = APPLE_ANS_MAX_QUEUE_DEPTH - 1;\n-\tc.create_sq.sq_flags = NVME_QUEUE_PHYS_CONTIG;\n-\tc.create_sq.cqid = 1;\n+\tc.create_sq.prp1 = cpu_to_le64(anv->ioq.sq_dma_addr);\n+\tc.create_sq.sqid = cpu_to_le16(1);\n+\tc.create_sq.qsize = cpu_to_le16(APPLE_ANS_MAX_QUEUE_DEPTH - 1);\n+\tc.create_sq.sq_flags = cpu_to_le16(NVME_QUEUE_PHYS_CONTIG);\n+\tc.create_sq.cqid = cpu_to_le16(1);\n \n \treturn nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0);\n }\n@@ -724,7 +724,7 @@ static int apple_nvme_remove_sq(struct apple_nvme *anv)\n \tstruct nvme_command c = {};\n \n \tc.delete_queue.opcode = nvme_admin_delete_sq;\n-\tc.delete_queue.qid = 1;\n+\tc.delete_queue.qid = cpu_to_le16(1);\n \n \treturn nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0);\n }\n","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/EtJPzidT","modified":1651864178,"id":"EtJPzidT","size":6590,"lines":148,"own_paste":false,"theme":"","date":1651864178}