Setting the DMA direction for commands that don't do any transfer likely
triggered the PRP NULL check for which we needed a chicken bit. That bit
has disappeared starting with macOS 15 so let's just do this correctly
instead.

Based on Linux kernel commit 94dd5804938d ("nvme-apple: Don't set a DMA
direction for commands without a data transfer").

Link: 
https://lore.kernel.org/asahi/[email protected]/
Fixes: 50333c94f2de ("nvme: apple: Add driver for Apple NVMe storage 
controller")
Signed-off-by: Janne Grunau <[email protected]>
---
 drivers/nvme/nvme_apple.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/nvme_apple.c b/drivers/nvme/nvme_apple.c
index e674eda8344..dc94988e2ff 100644
--- a/drivers/nvme/nvme_apple.c
+++ b/drivers/nvme/nvme_apple.c
@@ -122,7 +122,10 @@ static void apple_nvme_submit_cmd(struct nvme_queue *nvmeq,
        tcb = ((void *)priv->tcbs[nvmeq->qid]) + tail * ANS_NVMMU_TCB_PITCH;
        memset(tcb, 0, sizeof(*tcb));
        tcb->opcode = cmd->common.opcode;
-       tcb->flags = ANS_NVMMU_TCB_WRITE | ANS_NVMMU_TCB_READ;
+       if (cmd->common.prp1)
+               tcb->flags = ANS_NVMMU_TCB_WRITE | ANS_NVMMU_TCB_READ;
+       else
+               tcb->flags = 0;
        tcb->slot = tail;
        tcb->prpl_len = cmd->rw.length;
        tcb->prp1 = cmd->common.prp1;

-- 
2.55.0

Reply via email to