[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220321165049.35985-8-sven@svenpeter.dev>
Date: Mon, 21 Mar 2022 17:50:47 +0100
From: Sven Peter <sven@...npeter.dev>
To: Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...com>,
Christoph Hellwig <hch@....de>,
Sagi Grimberg <sagi@...mberg.me>
Cc: Sven Peter <sven@...npeter.dev>, Hector Martin <marcan@...can.st>,
Alyssa Rosenzweig <alyssa@...enzweig.io>,
Rob Herring <robh+dt@...nel.org>,
Arnd Bergmann <arnd@...db.de>, Marc Zyngier <maz@...nel.org>,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-nvme@...ts.infradead.org,
Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 7/9] nvme-apple: Serialize command issue
From: Jens Axboe <axboe@...nel.dk>
This controller shouldn't need serialization of command issue since
the SQ is replaced by a simple array and commands are issued by writing
the array index to a MMIO register.
Without serialization however sometimes commands are still executed
correctly and appear in the CQ but never trigger an interrupt.
Signed-off-by: Jens Axboe <axboe@...nel.dk>
[sven: added our best guess why this needs to be done]
Signed-off-by: Sven Peter <sven@...npeter.dev>
---
drivers/nvme/host/apple.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index 587d6c7014a0..a4193429564e 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -292,6 +292,7 @@ static void apple_nvmmu_inval(struct apple_nvme_queue *q, unsigned int tag)
static void apple_nvme_submit_cmd(struct apple_nvme_queue *q,
struct nvme_command *cmd)
{
+ struct apple_nvme *anv = queue_to_apple_nvme(q);
u32 tag = nvme_tag_from_cid(cmd->common.command_id);
struct apple_nvmmu_tcb *tcb = &q->tcbs[tag];
@@ -308,7 +309,18 @@ static void apple_nvme_submit_cmd(struct apple_nvme_queue *q,
tcb->dma_flags |= APPLE_ANS_TCB_DMA_FROM_DEVICE;
memcpy(&q->sqes[tag], cmd, sizeof(*cmd));
+
+ /*
+ * This lock here doesn't make much sense at a first glace but
+ * removing it will result in occasional missed completetion
+ * interrupts even though the commands still appear on the CQ.
+ * It's unclear why this happens but our best guess is that
+ * there is a bug in the firmware triggered when a write to the
+ * CQ and the SQ happen simultaneously.
+ */
+ spin_lock_irq(&anv->lock);
writel(tag, q->sq_db);
+ spin_unlock_irq(&anv->lock);
}
/*
--
2.25.1
Powered by blists - more mailing lists