From: "Sven Peter" <sven@svenpeter.dev>
To: "Alyssa Rosenzweig" <alyssa@rosenzweig.io>
Cc: "Hector Martin" <marcan@marcan.st>,
"Rob Herring" <robh+dt@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Keith Busch" <kbusch@kernel.org>, "axboe@fb.com" <axboe@fb.com>,
"hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me>,
"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 4/9] soc: apple: Add SART driver
Date: Sat, 02 Apr 2022 14:40:06 +0200 [thread overview]
Message-ID: <28ed16fd-84db-427c-bba0-7f2669f50517@www.fastmail.com> (raw)
In-Reply-To: <YjizGmjlAhyU6bC6@rosenzweig.io>
On Mon, Mar 21, 2022, at 18:17, Alyssa Rosenzweig wrote:
>> +/*
>> + * Adds the region [paddr, paddr+size] to the DMA allow list.
>> + *
>> + * @sart: SART reference
>> + * @paddr: Start address of the region to be used for DMA
>> + * @size: Size of the region to be used for DMA.
>> + */
>> +int apple_sart_add_allowed_region(struct apple_sart *sart, phys_addr_t paddr,
>> + size_t size);
>> +
>> +/*
>> + * Removes the region [paddr, paddr+size] from the DMA allow list.
>> + *
>> + * Note that exact same paddr and size used for apple_sart_add_allowed_region
>> + * have to be passed.
>> + *
>> + * @sart: SART reference
>> + * @paddr: Start address of the region no longer used for DMA
>> + * @size: Size of the region no longer used for DMA.
>> + */
>> +int apple_sart_remove_allowed_region(struct apple_sart *sart, phys_addr_t paddr,
>> + size_t size);
>
> Might it be simpler for add_allowed_region to return a handle that
> remove_allowed_region takes instead of paddr+size? Then
> remove_allowed_region doesn't have to walk anything, and the requirement
> to use the same paddr/size is implicit.
I liked that idea and just prototyped it and them remembered why I have
the API like it is:
In a perfect world this would be an IOMMU and just implement the IOMMU device ops.
In a slightly less perfect world this would implement dma_map_ops and transparently
allow using the normal DMA API inside the NVMe driver.
In Apple's world the NVMe driver needs two separate IOMMU-like filters and you can't
have two separate dma_map_ops without ugly hacks.
This will usually be used just next to dma_map_coherent and dma_free_coherent and
for those you need to keep track of phys_addr, dma_addr and size anyway,
e.g. (with the error handling removed here)
bfr->buffer = dma_alloc_coherent(anv->dev, size, &iova, GFP_KERNEL);
ret = apple_sart_add_allowed_region(anv->sart, iova, size);
and later then
apple_sart_remove_allowed_region(anv->sart, bfr->iova, bfr->size);
dma_free_coherent(anv->dev, bfr->size, bfr->buffer, bfr->iova);
Best,
Sven
next prev parent reply other threads:[~2022-04-02 12:40 UTC|newest]
Thread overview: 55+ 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 ` [PATCH 1/9] dt-bindings: soc: apple: Add Apple SART Sven Peter
2022-03-31 21:23 ` Rob Herring
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-23 11:14 ` Krzysztof Kozlowski
2022-04-02 13:05 ` Sven Peter
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 ` [PATCH 4/9] soc: apple: Add SART driver Sven Peter
2022-03-21 17:07 ` Arnd Bergmann
2022-04-02 12:38 ` Sven Peter
2022-04-02 19:07 ` Arnd Bergmann
2022-04-04 14:58 ` Rob Herring
2022-04-04 15:01 ` Hector Martin
2022-04-05 15:37 ` Sven Peter
2022-03-21 17:17 ` Alyssa Rosenzweig
2022-04-02 12:40 ` Sven Peter [this message]
2022-03-21 16:50 ` [PATCH 5/9] soc: apple: Add RTKit IPC library Sven Peter
2022-03-22 13:13 ` Arnd Bergmann
2022-03-22 17:41 ` Robin Murphy
2022-04-02 12:56 ` Sven Peter
2022-04-02 18:30 ` Arnd Bergmann
2022-04-03 10:45 ` Sven Peter
2022-03-22 17:23 ` Alyssa Rosenzweig
2022-04-02 12:50 ` Sven Peter
2022-03-23 11:19 ` Krzysztof Kozlowski
2022-04-02 13:51 ` Sven Peter
2022-04-02 16:08 ` Krzysztof Kozlowski
2022-04-04 15:02 ` Rob Herring
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 17:01 ` Keith Busch
2022-04-02 13:10 ` Sven Peter
2022-03-22 13:38 ` Arnd Bergmann
2022-04-02 13:34 ` Sven Peter
2022-04-02 13:58 ` Janne Grunau
2022-04-02 14:02 ` Sven Peter
2022-04-02 21:26 ` Arnd Bergmann
2022-03-24 6:16 ` Christoph Hellwig
2022-04-02 12:47 ` Sven Peter
2022-04-04 15:57 ` Hector Martin
2022-04-04 15:59 ` Christoph Hellwig
2022-04-04 16:03 ` Sven Peter
2022-04-04 16:05 ` hch
2022-04-04 16:05 ` Hector Martin
2022-04-04 18:29 ` Jens Axboe
2022-04-05 6:24 ` Christoph Hellwig
2022-03-21 16:50 ` [PATCH 7/9] nvme-apple: Serialize command issue Sven Peter
2022-03-24 6:16 ` Christoph Hellwig
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 ` [PATCH 9/9] nvme-apple: Add support for suspend/resume Sven Peter
2022-03-24 6:17 ` Christoph Hellwig
2022-03-22 17:26 ` [PATCH 0/9] Apple M1 (Pro/Max) NVMe driver 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=28ed16fd-84db-427c-bba0-7f2669f50517@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 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).