From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: Janne Grunau <j@jannau.net>
Cc: u-boot@lists.u-boot-project.org, asahi@lists.linux.dev,
kettenis@openbsd.org, sven@kernel.org, neil.armstrong@linaro.org,
bmeng.cn@gmail.com, trini@konsulko.com, fberder@outlook.fr,
j@jannau.net
Subject: Re: [PATCH 1/4] nvme: apple: Don't set a DMA direction for commands without a data transfer
Date: Mon, 07 Sep 2026 23:21:19 +0200 [thread overview]
Message-ID: <87tso0sqpc.fsf@bloch.sibelius.xs4all.nl> (raw)
In-Reply-To: <20260904-apple-nvme-fwabi-v1-1-f7ede661c469@jannau.net> (message from Janne Grunau on Fri, 04 Sep 2026 21:22:39 +0200)
> From: Janne Grunau <j@jannau.net>
> Date: Fri, 04 Sep 2026 21:22:39 +0200
>
> 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").
It is probably best to keep this aligned with Linux. However, on
OpenBSD I set the bits based on the low two bits of the opcode. Like:
if (cmd->common.opcode & nvme_cmd_write)
tcb->flags |= ANS_NVMMU_TCB_READ;
if (cmd->common.opcode & nvme_cmd_read)
tcb->flags |= ANS_NVMMU_TCB_WRITE;
(the directions are reversed as the commands are memory -> device
whereas the NVMMU bits are device -> memory).
The NVMe commands are documented like this. I believe, there aren't
actually any commands that do both a read and a write. But this would
do the right thing if they ever show up.
Anyway:
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
> Link: https://lore.kernel.org/asahi/20260806-b4-nvme-fwabi-v1-2-bde19ce8db04@kernel.org/
> Fixes: 50333c94f2de ("nvme: apple: Add driver for Apple NVMe storage controller")
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
> 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
>
>
next prev parent reply other threads:[~2026-09-07 21:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 19:22 [PATCH 0/4] Apple NVMe fixes for macOS 15+ firmware / M4 support Janne Grunau
2026-09-04 19:22 ` [PATCH 1/4] nvme: apple: Don't set a DMA direction for commands without a data transfer Janne Grunau
2026-09-07 21:21 ` Mark Kettenis [this message]
2026-09-04 19:22 ` [PATCH 2/4] nvme: apple: Never set the opcode in the NVMMU TCB Janne Grunau
2026-09-07 21:21 ` Mark Kettenis
2026-09-04 19:22 ` [PATCH 3/4] nvme: apple: Add WARN_ON_ONCE for non page-aligned admin queue buffers Janne Grunau
2026-09-07 21:23 ` Mark Kettenis
2026-09-04 19:22 ` [PATCH 4/4] nvme: apple: Drop the PRP null check chicken bit Janne Grunau
2026-09-07 21:24 ` Mark Kettenis
2026-09-10 12:44 ` [PATCH 0/4] Apple NVMe fixes for macOS 15+ firmware / M4 support Neil Armstrong
2026-09-10 13:11 ` Mark Kettenis
2026-09-10 13:14 ` Neil Armstrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tso0sqpc.fsf@bloch.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=asahi@lists.linux.dev \
--cc=bmeng.cn@gmail.com \
--cc=fberder@outlook.fr \
--cc=j@jannau.net \
--cc=kettenis@openbsd.org \
--cc=neil.armstrong@linaro.org \
--cc=sven@kernel.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox