From: Nick Chan <towinchenmi@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Neal Gompa <neal@gompa.dev>,
Jassi Brar <jassisinghbrar@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Hector Martin <marcan@marcan.st>, Joerg Roedel <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Sagi Grimberg <sagi@grimberg.me>,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
iommu@lists.linux.dev, linux-nvme@lists.infradead.org
Subject: Re: [PATCH v2 7/9] nvme: apple: Add Apple A11 support
Date: Wed, 20 Aug 2025 00:22:01 +0800 [thread overview]
Message-ID: <66ec7bd7-6b14-4766-97a1-3928d9129880@gmail.com> (raw)
In-Reply-To: <20250819083038.GA1901@lst.de>
On 19/8/2025 16:30, Christoph Hellwig wrote:
> On Mon, Aug 18, 2025 at 04:43:00PM +0800, Nick Chan wrote:
>> };
>>
>> +struct apple_nvme_hw {
>> + bool has_lsq_nvmmu;
>> + u32 max_queue_depth;
>> + void (*submit_cmd)(struct apple_nvme_queue *q, struct nvme_command *cmd);
>
> Please stick to 80 character lines for the NVMe code.
>
> Also I don't think an indirect call here is a good idea. This is right
> in the command submission fast path. A simple branch will be a lot
> faster.
Ack for both of these points will check the other codes that got more
indented as well.
>
>> +
>> + if (q->is_adminq)
>> + memcpy(&q->sqes[tag], cmd, sizeof(*cmd));
>> + else
>> + memcpy((void *)q->sqes + (tag << APPLE_NVME_IOSQES), cmd, sizeof(*cmd));
>
> This could use a helper and / or comment to make the calculation
> more obvious.
This part of the code could be further simplified and after that
it is similar to nvme_sq_copy_cmd() in pci.c:
diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index f3999b8ef7ab..ff4c2f87770c 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -295,20 +295,17 @@ static void apple_nvme_submit_cmd_t8015(struct apple_nvme_queue *q,
struct nvme_command *cmd)
{
struct apple_nvme *anv = queue_to_apple_nvme(q);
- u32 tag;
spin_lock_irq(&anv->lock);
- tag = q->sq_tail;
- q->sq_tail += 1;
-
- if (q->sq_tail == anv->hw->max_queue_depth)
- q->sq_tail = 0;
-
if (q->is_adminq)
- memcpy(&q->sqes[tag], cmd, sizeof(*cmd));
+ memcpy(&q->sqes[q->sq_tail], cmd, sizeof(*cmd));
else
- memcpy((void *)q->sqes + (tag << APPLE_NVME_IOSQES), cmd, sizeof(*cmd));
+ memcpy((void *)q->sqes + (q->sq_tail << APPLE_NVME_IOSQES),
+ cmd, sizeof(*cmd));
+
+ if (++q->sq_tail == anv->hw->max_queue_depth)
+ q->sq_tail = 0;
writel(q->sq_tail, q->sq_db);
spin_unlock_irq(&anv->lock);
And this seems obvious enough on its own, and should not need comments.
>
>> + anv->hw = (const struct apple_nvme_hw *)of_device_get_match_data(&pdev->dev);
>
> Do we even need this cast?
Don't think so, will remove.
Best regards,
Nick Chan
next prev parent reply other threads:[~2025-08-19 16:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 8:42 [PATCH v2 0/9] Add support ANS2 NVMe on Apple A11 Nick Chan
2025-08-18 8:42 ` [PATCH v2 1/9] dt-bindings: mailbox: apple,mailbox: Add ASC mailboxes on Apple A11 and T2 Nick Chan
2025-08-20 22:18 ` Rob Herring (Arm)
2025-08-18 8:42 ` [PATCH v2 2/9] soc: apple: mailbox: Add Apple A11 and T2 mailbox support Nick Chan
2025-08-18 8:42 ` [PATCH v2 3/9] dt-bindings: iommu: apple,sart: Add Apple A11 Nick Chan
2025-08-20 22:18 ` Rob Herring (Arm)
2025-08-20 22:20 ` Rob Herring
2025-08-27 13:20 ` Krzysztof Kozlowski
2025-08-29 7:44 ` Sven Peter
2025-08-18 8:42 ` [PATCH v2 4/9] soc: apple: sart: Make allow flags SART version dependent Nick Chan
2025-08-18 8:42 ` [PATCH v2 5/9] soc: apple: sart: Add SARTv0 support Nick Chan
2025-08-18 8:42 ` [PATCH v2 6/9] dt-bindings: nvme: apple,nvme-ans: Add Apple A11 Nick Chan
2025-08-19 9:18 ` Krzysztof Kozlowski
2025-08-19 10:01 ` Sven Peter
2025-08-19 11:34 ` Krzysztof Kozlowski
2025-08-21 10:25 ` Sven Peter
2025-08-21 13:09 ` Krzysztof Kozlowski
2025-08-21 15:47 ` Sven Peter
2025-08-27 12:25 ` Janne Grunau
2025-08-27 13:19 ` Krzysztof Kozlowski
2025-08-18 8:43 ` [PATCH v2 7/9] nvme: apple: Add Apple A11 support Nick Chan
2025-08-19 8:30 ` Christoph Hellwig
2025-08-19 16:22 ` Nick Chan [this message]
2025-08-18 8:43 ` [PATCH v2 8/9] arm64: dts: apple: t8015: Fix PCIE power domains dependencies Nick Chan
2025-08-18 8:43 ` [PATCH v2 9/9] arm64: dts: apple: t8015: Add NVMe nodes Nick Chan
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=66ec7bd7-6b14-4766-97a1-3928d9129880@gmail.com \
--to=towinchenmi@gmail.com \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=axboe@kernel.dk \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=j@jannau.net \
--cc=jassisinghbrar@gmail.com \
--cc=joro@8bytes.org \
--cc=kbusch@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=marcan@marcan.st \
--cc=neal@gompa.dev \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sagi@grimberg.me \
--cc=sven@kernel.org \
--cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).