All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sven Peter" <sven@svenpeter.dev>
To: "Keith Busch" <kbusch@kernel.org>
Cc: "axboe@fb.com" <axboe@fb.com>, "hch@lst.de" <hch@lst.de>,
	"sagi@grimberg.me" <sagi@grimberg.me>,
	"Hector Martin" <marcan@marcan.st>,
	"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Arnd Bergmann" <arnd@arndb.de>, "Marc Zyngier" <maz@kernel.org>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 6/9] nvme-apple: Add initial Apple SoC NVMe driver
Date: Sat, 02 Apr 2022 15:10:34 +0200	[thread overview]
Message-ID: <96fcc1ec-888a-4ff2-a41b-8cc352d4f2b1@www.fastmail.com> (raw)
In-Reply-To: <Yjivcz4BlCMfJBkM@C02CK6Q3MD6M>

On Mon, Mar 21, 2022, at 18:01, Keith Busch wrote:
> On Mon, Mar 21, 2022 at 05:50:46PM +0100, Sven Peter wrote:
>> +static bool apple_nvme_poll_cq(struct apple_nvme_queue *q,
>> +			       struct io_comp_batch *iob)
>> +{
>> +	bool found = false;
>> +
>> +	while (apple_nvme_cqe_pending(q)) {
>> +		found = true;
>> +
>> +		/*
>> +		 * load-load control dependency between phase and the rest of
>> +		 * the cqe requires a full read memory barrier
>> +		 */
>> +		dma_rmb();
>> +		apple_nvme_handle_cqe(q, iob, q->cq_head);
>> +		apple_nvme_update_cq_head(q);
>> +	}
>> +
>> +	if (found)
>> +		writel_relaxed(q->cq_head, q->cq_db);
>
> Doesn't a relaxed write mean that a subsequent write can bypass the previous?
> If so, that sounds like it can corrupt the cq head.

No, writel_relaxed just means there's no synchronization barrier for writes to
normal memory and that those could bypass the store to device memory and only
become visible later.
The underlying memory (q->cq_db) is still mapped as Device-nGnRnE which prevents
reordering of writes to the same endpoint such that the N-th CQ update is still
guaranteed to be visible to the device before the N+1-th CQ update.

I'll either add a comment why it's okay to use _relaxed here or just use writel
instead since there doesn't seem to be any performance difference.



Sven

WARNING: multiple messages have this Message-ID (diff)
From: "Sven Peter" <sven@svenpeter.dev>
To: "Keith Busch" <kbusch@kernel.org>
Cc: "axboe@fb.com" <axboe@fb.com>, "hch@lst.de" <hch@lst.de>,
	"sagi@grimberg.me" <sagi@grimberg.me>,
	"Hector Martin" <marcan@marcan.st>,
	"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Arnd Bergmann" <arnd@arndb.de>, "Marc Zyngier" <maz@kernel.org>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: Re: [PATCH 6/9] nvme-apple: Add initial Apple SoC NVMe driver
Date: Sat, 02 Apr 2022 15:10:34 +0200	[thread overview]
Message-ID: <96fcc1ec-888a-4ff2-a41b-8cc352d4f2b1@www.fastmail.com> (raw)
In-Reply-To: <Yjivcz4BlCMfJBkM@C02CK6Q3MD6M>

On Mon, Mar 21, 2022, at 18:01, Keith Busch wrote:
> On Mon, Mar 21, 2022 at 05:50:46PM +0100, Sven Peter wrote:
>> +static bool apple_nvme_poll_cq(struct apple_nvme_queue *q,
>> +			       struct io_comp_batch *iob)
>> +{
>> +	bool found = false;
>> +
>> +	while (apple_nvme_cqe_pending(q)) {
>> +		found = true;
>> +
>> +		/*
>> +		 * load-load control dependency between phase and the rest of
>> +		 * the cqe requires a full read memory barrier
>> +		 */
>> +		dma_rmb();
>> +		apple_nvme_handle_cqe(q, iob, q->cq_head);
>> +		apple_nvme_update_cq_head(q);
>> +	}
>> +
>> +	if (found)
>> +		writel_relaxed(q->cq_head, q->cq_db);
>
> Doesn't a relaxed write mean that a subsequent write can bypass the previous?
> If so, that sounds like it can corrupt the cq head.

No, writel_relaxed just means there's no synchronization barrier for writes to
normal memory and that those could bypass the store to device memory and only
become visible later.
The underlying memory (q->cq_db) is still mapped as Device-nGnRnE which prevents
reordering of writes to the same endpoint such that the N-th CQ update is still
guaranteed to be visible to the device before the N+1-th CQ update.

I'll either add a comment why it's okay to use _relaxed here or just use writel
instead since there doesn't seem to be any performance difference.



Sven

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-04-02 13:11 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 16:50 [PATCH 0/9] Apple M1 (Pro/Max) NVMe driver Sven Peter
2022-03-21 16:50 ` Sven Peter
2022-03-21 16:50 ` Sven Peter
2022-03-21 16:50 ` [PATCH 1/9] dt-bindings: soc: apple: Add Apple SART Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-31 21:23   ` Rob Herring
2022-03-31 21:23     ` Rob Herring
2022-04-02 12:58     ` Sven Peter
2022-04-02 12:58       ` Sven Peter
2022-03-21 16:50 ` [PATCH 2/9] dt-bindings: soc: apple: Add ANS NVMe Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-23 11:14   ` Krzysztof Kozlowski
2022-03-23 11:14     ` Krzysztof Kozlowski
2022-04-02 13:05     ` Sven Peter
2022-04-02 13:05       ` Sven Peter
2022-04-02 16:06       ` Krzysztof Kozlowski
2022-04-02 16:06         ` Krzysztof Kozlowski
2022-03-21 16:50 ` [PATCH 3/9] soc: apple: Always include Makefile Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 16:50 ` [PATCH 4/9] soc: apple: Add SART driver Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 17:07   ` Arnd Bergmann
2022-03-21 17:07     ` Arnd Bergmann
2022-04-02 12:38     ` Sven Peter
2022-04-02 12:38       ` Sven Peter
2022-04-02 19:07       ` Arnd Bergmann
2022-04-02 19:07         ` Arnd Bergmann
2022-04-04 14:58         ` Rob Herring
2022-04-04 14:58           ` Rob Herring
2022-04-04 15:01           ` Hector Martin
2022-04-04 15:01             ` Hector Martin
2022-04-05 15:37           ` Sven Peter
2022-04-05 15:37             ` Sven Peter
2022-03-21 17:17   ` Alyssa Rosenzweig
2022-03-21 17:17     ` Alyssa Rosenzweig
2022-04-02 12:40     ` Sven Peter
2022-04-02 12:40       ` Sven Peter
2022-03-21 16:50 ` [PATCH 5/9] soc: apple: Add RTKit IPC library Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-22 13:13   ` Arnd Bergmann
2022-03-22 13:13     ` Arnd Bergmann
2022-03-22 17:41     ` Robin Murphy
2022-03-22 17:41       ` Robin Murphy
2022-04-02 12:56     ` Sven Peter
2022-04-02 12:56       ` Sven Peter
2022-04-02 18:30       ` Arnd Bergmann
2022-04-02 18:30         ` Arnd Bergmann
2022-04-03 10:45         ` Sven Peter
2022-04-03 10:45           ` Sven Peter
2022-03-22 17:23   ` Alyssa Rosenzweig
2022-03-22 17:23     ` Alyssa Rosenzweig
2022-04-02 12:50     ` Sven Peter
2022-04-02 12:50       ` Sven Peter
2022-03-23 11:19   ` Krzysztof Kozlowski
2022-03-23 11:19     ` Krzysztof Kozlowski
2022-04-02 13:51     ` Sven Peter
2022-04-02 13:51       ` Sven Peter
2022-04-02 16:08       ` Krzysztof Kozlowski
2022-04-02 16:08         ` Krzysztof Kozlowski
2022-04-04 15:02       ` Rob Herring
2022-04-04 15:02         ` Rob Herring
2022-04-04 15:47         ` Hector Martin
2022-04-04 15:47           ` Hector Martin
2022-03-21 16:50 ` [PATCH 6/9] nvme-apple: Add initial Apple SoC NVMe driver Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 17:01   ` Keith Busch
2022-03-21 17:01     ` Keith Busch
2022-04-02 13:10     ` Sven Peter [this message]
2022-04-02 13:10       ` Sven Peter
2022-03-22 13:38   ` Arnd Bergmann
2022-03-22 13:38     ` Arnd Bergmann
2022-04-02 13:34     ` Sven Peter
2022-04-02 13:34       ` Sven Peter
2022-04-02 13:58       ` Janne Grunau
2022-04-02 13:58         ` Janne Grunau
2022-04-02 14:02         ` Sven Peter
2022-04-02 14:02           ` Sven Peter
2022-04-02 21:26       ` Arnd Bergmann
2022-04-02 21:26         ` Arnd Bergmann
2022-03-24  6:16   ` Christoph Hellwig
2022-03-24  6:16     ` Christoph Hellwig
2022-04-02 12:47     ` Sven Peter
2022-04-02 12:47       ` Sven Peter
2022-04-04 15:57     ` Hector Martin
2022-04-04 15:57       ` Hector Martin
2022-04-04 15:59       ` Christoph Hellwig
2022-04-04 15:59         ` Christoph Hellwig
2022-04-04 16:03         ` Sven Peter
2022-04-04 16:03           ` Sven Peter
2022-04-04 16:05           ` hch
2022-04-04 16:05             ` hch
2022-04-04 16:05         ` Hector Martin
2022-04-04 16:05           ` Hector Martin
2022-04-04 18:29         ` Jens Axboe
2022-04-04 18:29           ` Jens Axboe
2022-04-05  6:24           ` Christoph Hellwig
2022-04-05  6:24             ` Christoph Hellwig
2022-03-21 16:50 ` [PATCH 7/9] nvme-apple: Serialize command issue Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-24  6:16   ` Christoph Hellwig
2022-03-24  6:16     ` Christoph Hellwig
2022-04-02 12:42     ` Sven Peter
2022-04-02 12:42       ` Sven Peter
2022-03-21 16:50 ` [PATCH 8/9] nvme-apple: Add support for multiple power domains Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-21 16:50 ` [PATCH 9/9] nvme-apple: Add support for suspend/resume Sven Peter
2022-03-21 16:50   ` Sven Peter
2022-03-24  6:17   ` Christoph Hellwig
2022-03-24  6:17     ` Christoph Hellwig
2022-03-22 17:26 ` [PATCH 0/9] Apple M1 (Pro/Max) NVMe driver Alyssa Rosenzweig
2022-03-22 17:26   ` Alyssa Rosenzweig

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=96fcc1ec-888a-4ff2-a41b-8cc352d4f2b1@www.fastmail.com \
    --to=sven@svenpeter.dev \
    --cc=alyssa@rosenzweig.io \
    --cc=arnd@arndb.de \
    --cc=axboe@fb.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=kbusch@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=maz@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sagi@grimberg.me \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.