Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-apple: fix sparse endianess warnings

The new nvme-apple driver is missing a few conversions to and
from little-endian data:

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 @@
drivers/nvme/host/apple.c:291:19: sparse: expected unsigned long long [usertype] prp1
drivers/nvme/host/apple.c:291:19: sparse: got restricted __le64 [usertype] prp1
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 @@
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 @@
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] @@
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 @@
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 @@
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 @@
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 @@

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+24 -24
+24 -24
drivers/nvme/host/apple.c
··· 112 112 113 113 u8 command_id; 114 114 u8 _unk0; 115 - u32 length; 116 - u8 _unk1[16]; 117 - u64 prp1; 118 - u64 prp2; 115 + __le16 length; 116 + u8 _unk1[18]; 117 + __le64 prp1; 118 + __le64 prp2; 119 119 u8 _unk2[16]; 120 120 u8 aes_iv[8]; 121 121 u8 _aes_unk[64]; ··· 348 348 349 349 for (i = 0; i < iod->npages; i++) { 350 350 __le64 *prp_list = apple_nvme_iod_list(req)[i]; 351 - dma_addr_t next_dma_addr = prp_list[last_prp]; 351 + dma_addr_t next_dma_addr = le64_to_cpu(prp_list[last_prp]); 352 352 353 353 dma_pool_free(anv->prp_page_pool, prp_list, dma_addr); 354 354 dma_addr = next_dma_addr; ··· 453 453 goto free_prps; 454 454 list[iod->npages++] = prp_list; 455 455 prp_list[0] = old_prp_list[i - 1]; 456 - old_prp_list[i - 1] = prp_dma; 456 + old_prp_list[i - 1] = cpu_to_le64(prp_dma); 457 457 i = 1; 458 458 } 459 - prp_list[i++] = dma_addr; 459 + prp_list[i++] = cpu_to_le64(dma_addr); 460 460 dma_len -= NVME_CTRL_PAGE_SIZE; 461 461 dma_addr += NVME_CTRL_PAGE_SIZE; 462 462 length -= NVME_CTRL_PAGE_SIZE; ··· 471 471 dma_len = sg_dma_len(sg); 472 472 } 473 473 done: 474 - cmnd->dptr.prp1 = sg_dma_address(iod->sg); 475 - cmnd->dptr.prp2 = iod->first_dma; 474 + cmnd->dptr.prp1 = cpu_to_le64(sg_dma_address(iod->sg)); 475 + cmnd->dptr.prp2 = cpu_to_le64(iod->first_dma); 476 476 return BLK_STS_OK; 477 477 free_prps: 478 478 apple_nvme_free_prps(anv, req); ··· 498 498 return BLK_STS_RESOURCE; 499 499 iod->dma_len = bv->bv_len; 500 500 501 - cmnd->dptr.prp1 = iod->first_dma; 501 + cmnd->dptr.prp1 = cpu_to_le64(iod->first_dma); 502 502 if (bv->bv_len > first_prp_len) 503 - cmnd->dptr.prp2 = iod->first_dma + first_prp_len; 503 + cmnd->dptr.prp2 = cpu_to_le64(iod->first_dma + first_prp_len); 504 504 return BLK_STS_OK; 505 505 } 506 506 ··· 570 570 { 571 571 struct nvme_completion *hcqe = &q->cqes[q->cq_head]; 572 572 573 - return (READ_ONCE(hcqe->status) & 1) == q->cq_phase; 573 + return (le16_to_cpu(READ_ONCE(hcqe->status)) & 1) == q->cq_phase; 574 574 } 575 575 576 576 static inline struct blk_mq_tags * ··· 682 682 * is attached to the request. 683 683 */ 684 684 c.create_cq.opcode = nvme_admin_create_cq; 685 - c.create_cq.prp1 = anv->ioq.cq_dma_addr; 686 - c.create_cq.cqid = 1; 687 - c.create_cq.qsize = APPLE_ANS_MAX_QUEUE_DEPTH - 1; 688 - c.create_cq.cq_flags = NVME_QUEUE_PHYS_CONTIG | NVME_CQ_IRQ_ENABLED; 689 - c.create_cq.irq_vector = 0; 685 + c.create_cq.prp1 = cpu_to_le64(anv->ioq.cq_dma_addr); 686 + c.create_cq.cqid = cpu_to_le16(1); 687 + c.create_cq.qsize = cpu_to_le16(APPLE_ANS_MAX_QUEUE_DEPTH - 1); 688 + c.create_cq.cq_flags = cpu_to_le16(NVME_QUEUE_PHYS_CONTIG | NVME_CQ_IRQ_ENABLED); 689 + c.create_cq.irq_vector = cpu_to_le16(0); 690 690 691 691 return nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0); 692 692 } ··· 696 696 struct nvme_command c = {}; 697 697 698 698 c.delete_queue.opcode = nvme_admin_delete_cq; 699 - c.delete_queue.qid = 1; 699 + c.delete_queue.qid = cpu_to_le16(1); 700 700 701 701 return nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0); 702 702 } ··· 710 710 * is attached to the request. 711 711 */ 712 712 c.create_sq.opcode = nvme_admin_create_sq; 713 - c.create_sq.prp1 = anv->ioq.sq_dma_addr; 714 - c.create_sq.sqid = 1; 715 - c.create_sq.qsize = APPLE_ANS_MAX_QUEUE_DEPTH - 1; 716 - c.create_sq.sq_flags = NVME_QUEUE_PHYS_CONTIG; 717 - c.create_sq.cqid = 1; 713 + c.create_sq.prp1 = cpu_to_le64(anv->ioq.sq_dma_addr); 714 + c.create_sq.sqid = cpu_to_le16(1); 715 + c.create_sq.qsize = cpu_to_le16(APPLE_ANS_MAX_QUEUE_DEPTH - 1); 716 + c.create_sq.sq_flags = cpu_to_le16(NVME_QUEUE_PHYS_CONTIG); 717 + c.create_sq.cqid = cpu_to_le16(1); 718 718 719 719 return nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0); 720 720 } ··· 724 724 struct nvme_command c = {}; 725 725 726 726 c.delete_queue.opcode = nvme_admin_delete_sq; 727 - c.delete_queue.qid = 1; 727 + c.delete_queue.qid = cpu_to_le16(1); 728 728 729 729 return nvme_submit_sync_cmd(anv->ctrl.admin_q, &c, NULL, 0); 730 730 }