Re: [PATCH] iommu/dart: check return value after calling platform_get_resource()

2022-04-26 Thread Sven Peter via iommu
> On 25. Apr 2022, at 10:56, Yang Yingliang wrote: > > It will cause null-ptr-deref in resource_size(), if platform_get_resource() > returns NULL, move calling resource_size() after devm_ioremap_resource() that > will check 'res' to avoid null-ptr-deref. > And use

Re: [PATCH 06/13] iommu/dart: Clean up bus_set_iommu()

2022-04-15 Thread Sven Peter via iommu
On Thu, Apr 14, 2022, at 14:42, Robin Murphy wrote: > Stop calling bus_set_iommu() since it's now unnecessary, and simplify > the probe failure path accordingly. > > Signed-off-by: Robin Murphy Tested-by: Sven Peter Reviewed-by: Sven Peter Can't wait until that saga is completed :) Sven

[PATCH] MAINTAINERS: merge DART into ARM/APPLE MACHINE

2022-04-12 Thread Sven Peter via iommu
It's the same people anyway. Signed-off-by: Sven Peter --- MAINTAINERS | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index fd768d43e048..5af879de869c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1375,14 +1375,6 @@ L:

[PATCH 4/4] iommu: dart: Support t6000 variant

2021-11-17 Thread Sven Peter via iommu
The M1 Pro/Max SoCs come with a new variant of DART which supports a larger physical address space with a slightly different PTE format. Pass through the correct paddr address space size to the io-pgtable code which will take care of the rest. Signed-off-by: Sven Peter ---

[PATCH 1/4] dt-bindings: iommu: dart: add t6000 compatible

2021-11-17 Thread Sven Peter via iommu
The M1 Max/Pro SoCs come with a new DART variant that is incompatible with the previous one. Add a new compatible for those. Signed-off-by: Sven Peter --- Documentation/devicetree/bindings/iommu/apple,dart.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git

[PATCH 3/4] iommu/io-pgtable: Add DART PTE support for t6000

2021-11-17 Thread Sven Peter via iommu
The DARTs present in the M1 Pro/Max SoC support a 42bit physical address space by shifting the paddr and extending its mask inside the PTE. Signed-off-by: Sven Peter --- drivers/iommu/io-pgtable-arm.c | 30 +- include/linux/io-pgtable.h | 2 ++ 2 files changed,

[PATCH 2/4] iommu/io-pgtable: Add DART subpage protection support

2021-11-17 Thread Sven Peter via iommu
DART allows to only expose a subpage to the device. While this is an optional feature on the M1 DARTs the new ones present on the Pro/Max models require this field in every PTE. Signed-off-by: Sven Peter --- drivers/iommu/io-pgtable-arm.c | 10 ++ 1 file changed, 10 insertions(+) diff

[PATCH 0/4] iommu: M1 Pro/Max DART support

2021-11-17 Thread Sven Peter via iommu
Hi, This is a fairly brief series to add support for the DARTs present in the M1 Pro/Max. They have two differences that make them incompatible with those in the M1: - the physical addresses are shifted left by 4 bits and and have 2 more bits inside the PTE entries - the subpage

Re: [PATCH v3 4/6] iommu: Move IOMMU pagesize check to attach_device

2021-10-23 Thread Sven Peter via iommu
t;>> Lu Baolu wrote: >>>>> >>>>> On 10/20/21 10:22 PM, Marc Zyngier wrote: >>>>>> On Wed, 20 Oct 2021 06:21:44 +0100, >>>>>> Lu Baolu wrote: >>>>>>> >>>>>>> On 2021/10/20 0:37, Sve

Re: [PATCH v3 4/6] iommu: Move IOMMU pagesize check to attach_device

2021-10-21 Thread Sven Peter via iommu
On Wed, Oct 20, 2021, at 07:21, Lu Baolu wrote: > On 2021/10/20 0:37, Sven Peter via iommu wrote: >> The iova allocator is capable of handling any granularity which is a power >> of two. Remove the much stronger condition that the granularity must be >> smaller or equal

[PATCH v3 6/6] iommu/dart: Remove force_bypass logic

2021-10-19 Thread Sven Peter via iommu
Now that the dma-iommu API supports IOMMU granules which are larger than the CPU page size and that the kernel no longer runs into a BUG_ON when devices are attached to a domain with such a granule there's no need to force bypass mode anymore. Signed-off-by: Sven Peter ---

[PATCH v3 5/6] iommu: Introduce __IOMMU_DOMAIN_LP

2021-10-19 Thread Sven Peter via iommu
__IOMMU_DOMAIN_LP (large pages) indicates that a domain can handle conditions where PAGE_SIZE might be smaller than the IOMMU page size. Always allow attaching trusted devices to such domains and set the flag for IOMMU_DOMAIN_DMA, which can now handle these situations. Note that untrusted devices

[PATCH v3 4/6] iommu: Move IOMMU pagesize check to attach_device

2021-10-19 Thread Sven Peter via iommu
The iova allocator is capable of handling any granularity which is a power of two. Remove the much stronger condition that the granularity must be smaller or equal to the CPU page size from a BUG_ON there. Instead, check this condition during __iommu_attach_device and fail gracefully.

[PATCH v3 3/6] iommu/dma: Support granule > PAGE_SIZE allocations

2021-10-19 Thread Sven Peter via iommu
Noncontiguous allocations must be made up of individual blocks in a way that allows those blocks to be mapped contiguously in IOVA space. For IOMMU page sizes larger than the CPU page size this can be done by allocating all individual blocks from pools with order >= get_order(iovad->granule). Some

[PATCH v3 2/6] iommu/dma: Support granule > PAGE_SIZE in dma_map_sg

2021-10-19 Thread Sven Peter via iommu
Add support to iommu_dma_map_sg's impedance matching to also align sg_lists correctly when the IOMMU granule is larger than PAGE_SIZE. Co-developed-by: Robin Murphy Signed-off-by: Robin Murphy Signed-off-by: Sven Peter --- drivers/iommu/dma-iommu.c | 25 - 1 file

[PATCH v3 1/6] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE

2021-10-19 Thread Sven Peter via iommu
While this function *probably* works correctly without any changes for granule > PAGE_SIZE I don't have any code to actually test it and cannot reason about how the function is supposed to work. Disable it instead until we run into a use case where it's required. Signed-off-by: Sven Peter ---

[PATCH v3 0/6] Support IOMMU page sizes larger than the CPU page size

2021-10-19 Thread Sven Peter via iommu
Hi, RFC: https://lore.kernel.org/linux-iommu/20210806155523.50429-1-s...@svenpeter.dev/ v2: https://lore.kernel.org/linux-iommu/20210828153642.19396-1-s...@svenpeter.dev/ Time to revive this series: v2 -> v3: - Dropped support for untrusted devices since swiotlb currently does not

[PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE

2021-10-19 Thread Sven Peter via iommu
DART has an additional global register to control which streams are isolated. This register is a bit redundant since DART_TCR can already be used to control isolation and is usually initialized to DART_STREAM_ALL by the time we get control. Some DARTs (namely the one used for the audio controller)

Re: [PATCH] iommu/dart: use kmemdup instead of kzalloc and memcpy

2021-10-16 Thread Sven Peter via iommu
On Wed, Oct 13, 2021, at 08:34, Wan Jiabing wrote: > Fix following coccicheck warning: > drivers/iommu/apple-dart.c:704:20-27: WARNING opportunity for kmemdup > > Signed-off-by: Wan Jiabing > --- > drivers/iommu/apple-dart.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Looks

[PATCH] iommu/dart: Clear sid2group entry when a group is freed

2021-09-24 Thread Sven Peter via iommu
sid2groups keeps track of which stream id combinations belong to a iommu_group to assign those correctly to devices. When a iommu_group is freed a stale pointer will however remain in sid2groups. This prevents devices with the same stream id combination to ever be attached again (see below). Fix

[PATCH] iommu/dart: Remove iommu_flush_ops

2021-09-21 Thread Sven Peter via iommu
apple_dart_tlb_flush_{all,walk} expect to get a struct apple_dart_domain but instead get a struct iommu_domain right now. This breaks those two functions and can lead to kernel panics like the one below. DART can only invalidate the entire TLB and apple_dart_iotlb_sync will already flush

Re: [PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE

2021-09-03 Thread Sven Peter via iommu
On Fri, Sep 3, 2021, at 17:45, Robin Murphy wrote: > On 2021-09-03 16:16, Sven Peter wrote: > > > > > > On Thu, Sep 2, 2021, at 21:42, Robin Murphy wrote: > >> On 2021-09-02 19:19, Sven Peter wrote: > >>> > >>> > >>> On Wed, Sep 1, 2021, at 23:10, Alyssa Rosenzweig wrote: > > My biggest

Re: [PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE

2021-09-03 Thread Sven Peter via iommu
On Thu, Sep 2, 2021, at 21:42, Robin Murphy wrote: > On 2021-09-02 19:19, Sven Peter wrote: > > > > > > On Wed, Sep 1, 2021, at 23:10, Alyssa Rosenzweig wrote: > >>> My biggest issue is that I do not understand how this function is supposed > >>> to be used correctly. It would work fine as-is

Re: [PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE

2021-09-02 Thread Sven Peter via iommu
On Wed, Sep 1, 2021, at 23:10, Alyssa Rosenzweig wrote: > > My biggest issue is that I do not understand how this function is supposed > > to be used correctly. It would work fine as-is if it only ever gets passed > > buffers > > allocated by the coherent API but there's not way to check or

Re: [PATCH v2 6/8] iommu: Move IOMMU pagesize check to attach_device

2021-09-01 Thread Sven Peter via iommu
On Tue, Aug 31, 2021, at 23:39, Alyssa Rosenzweig wrote: > > + if ((1 << __ffs(domain->pgsize_bitmap)) > PAGE_SIZE) { > > Not a fan of this construction. Could you assign `(1 << > __ffs(domain->pgsize_bitmap))` to an appropriately named temporary (e.g > min_io_pgsize) so it's clearer what's

Re: [PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE

2021-09-01 Thread Sven Peter via iommu
On Tue, Aug 31, 2021, at 23:30, Alyssa Rosenzweig wrote: > I use this function for cross-device sharing on the M1 display driver. > Arguably this is unsafe but it works on 16k kernels and if you want to > test the function on 4k, you know where my code is. > My biggest issue is that I do not

Re: [PATCH v2 2/8] iommu/dma: Fail unaligned map requests for untrusted devs

2021-08-28 Thread Sven Peter via iommu
and ofc shortly after submitting this series I realized this doesn't quite work yet: swiotlb_tbl_map_single can return a 16KB buffer that's only aligned to a 4KB boundary. v3 will need at least another change to ensure that the result will be aligned to a 16KB boundary as well. Sven On

[PATCH v2 8/8] iommu/dart: Remove force_bypass logic

2021-08-28 Thread Sven Peter via iommu
Now that the dma-iommu API supports IOMMU granules which are larger than the CPU page size and that the kernel no longer runs into a BUG_ON when devices are attached to a domain with such a granule there's no need to force bypass mode anymore. Signed-off-by: Sven Peter ---

[PATCH v2 7/8] iommu: Introduce __IOMMU_DOMAIN_LP

2021-08-28 Thread Sven Peter via iommu
__IOMMU_DOMAIN_LP (large pages) indicates that a domain can handle conditions where PAGE_SIZE might be smaller than the IOMMU page size. Always allow attaching devices to such domains and set the flag for IOMMU_DOMAIN_DMA, which can now handle these situations. Signed-off-by: Sven Peter ---

[PATCH v2 6/8] iommu: Move IOMMU pagesize check to attach_device

2021-08-28 Thread Sven Peter via iommu
The iova allocator is capable of handling any granularity which is a power of two. Remove the much stronger condition that the granularity must be smaller or equal to the CPU page size from a BUG_ON there. Instead, check this condition during __iommu_attach_device and fail gracefully.

[PATCH v2 4/8] iommu/dma: Support granule > PAGE_SIZE in dma_map_sg

2021-08-28 Thread Sven Peter via iommu
Add support to iommu_dma_map_sg's impedance matching to also align sg_lists correctly when the IOMMU granule is larger than PAGE_SIZE. Co-developed-by: Robin Murphy Signed-off-by: Robin Murphy Signed-off-by: Sven Peter --- drivers/iommu/dma-iommu.c | 18 ++ 1 file changed, 10

[PATCH v2 5/8] iommu/dma: Support PAGE_SIZE < iovad->granule allocations

2021-08-28 Thread Sven Peter via iommu
Noncontiguous allocations must be made up of individual blocks in a way that allows those blocks to be mapped contiguously in IOVA space. For IOMMU page sizes larger than the CPU page size this can be done by allocating all individual blocks from pools with order >= get_order(iovad->granule). Some

[PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE

2021-08-28 Thread Sven Peter via iommu
Pretend that iommu_dma_get_sgtable is not implemented when granule > PAGE_SIZE since I can neither test this function right now nor do I fully understand how it is used. Signed-off-by: Sven Peter --- drivers/iommu/dma-iommu.c | 6 ++ 1 file changed, 6 insertions(+) diff --git

[PATCH v2 1/8] iommu/dma: Align size for untrusted devs to IOVA granule

2021-08-28 Thread Sven Peter via iommu
Up until now PAGE_SIZE was always a multiple of iovad->granule such that adjacent pages were never exposed to untrusted devices due to allocations done as part of the coherent DMA API. With PAGE_SIZE < iovad->granule however all these allocations must also be aligned to iovad->granule.

[PATCH v2 2/8] iommu/dma: Fail unaligned map requests for untrusted devs

2021-08-28 Thread Sven Peter via iommu
If swiotlb is enabled we should never try to create any mappings that would expose more memory than requested to the device. WARN_ON and refuse those mappings just in case. Signed-off-by: Sven Peter --- drivers/iommu/dma-iommu.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-)

[PATCH v2 0/8] Support IOMMU page sizes larger than the CPU page size

2021-08-28 Thread Sven Peter via iommu
RFC Patch: https://lore.kernel.org/linux-iommu/20210806155523.50429-1-s...@svenpeter.dev/ Hi, After a very helpful discussion with Robin Murphy on the RFC, here's v2 that is slowly starting to look sane. I've been running this code for two weeks now and mainly tested it with usb storage

Re: [PATCH v4 00/24] iommu: Refactor DMA domain strictness

2021-08-21 Thread Sven Peter via iommu
On Wed, Aug 18, 2021, at 17:13, Robin Murphy wrote: > Sven - I've prepared the follow-up patches already[1], so consider > yourself off the hook (I see no point in trying to fix the nominal DART > cookie bugs between now and then) :) > Great, thanks for taking care of that! :) Just tested

Re: [iommu:apple/dart 3/3] drivers/iommu/apple-dart.c:730:17: error: initialization of 'size_t (*)(struct iommu_domain *, long unsigned int, size_t, struct iommu_iotlb_gather *)' {aka 'long unsigned

2021-08-16 Thread Sven Peter via iommu
On Thu, Aug 12, 2021, at 13:29, Joerg Roedel wrote: > Hi Sven, > > On Tue, Aug 10, 2021 at 08:09:53AM +0200, Sven Peter wrote: > > This happens because apple/dart is missing the "Optimizing > > iommu_[map/unmap] performance" > > series which is already in the core branch [1]. > > The same

Re: [RFC PATCH 2/3] iommu/dma-iommu: Support iovad->granule > PAGE_SIZE

2021-08-11 Thread Sven Peter via iommu
On Tue, Aug 10, 2021, at 11:51, Robin Murphy wrote: > On 2021-08-09 21:45, Sven Peter wrote: > > > > > > On Mon, Aug 9, 2021, at 19:41, Robin Murphy wrote: > >> On 2021-08-07 12:47, Sven Peter via iommu wrote: > >>> > >>> > >>>

Re: [PATCH] iommu: APPLE_DART should depend on ARCH_APPLE

2021-08-11 Thread Sven Peter via iommu
Good catch, thanks! Acked-by: Sven Peter Sven On Tue, Aug 10, 2021, at 15:47, Geert Uytterhoeven wrote: > The Apple DART (Device Address Resolution Table) IOMMU is only present > on Apple ARM SoCs like the M1. Hence add a dependency on ARCH_APPLE, to > prevent asking the user about this

Re: [iommu:apple/dart 3/3] drivers/iommu/apple-dart.c:730:17: error: initialization of 'size_t (*)(struct iommu_domain *, long unsigned int, size_t, struct iommu_iotlb_gather *)' {aka 'long unsigned

2021-08-10 Thread Sven Peter via iommu
Hi Joerg, This happens because apple/dart is missing the "Optimizing iommu_[map/unmap] performance" series which is already in the core branch [1]. The same commit works fine in iommu/next since that branch merges both iommu/core and apple/dart. Thanks, Sven [1]

Re: [RFC PATCH 2/3] iommu/dma-iommu: Support iovad->granule > PAGE_SIZE

2021-08-09 Thread Sven Peter via iommu
On Mon, Aug 9, 2021, at 19:41, Robin Murphy wrote: > On 2021-08-07 12:47, Sven Peter via iommu wrote: > > > > > > On Fri, Aug 6, 2021, at 20:04, Robin Murphy wrote: > >> On 2021-08-06 16:55, Sven Peter via iommu wrote: > >>> @@ -1006,6 +1019,31 @@

Re: [RFC PATCH 2/3] iommu/dma-iommu: Support iovad->granule > PAGE_SIZE

2021-08-09 Thread Sven Peter via iommu
Hi, On Mon, Aug 9, 2021, at 20:37, Robin Murphy wrote: > On 2021-08-07 09:41, Sven Peter wrote: > > Hi, > > > > Thanks a lot for quick reply! > > > > On Fri, Aug 6, 2021, at 20:04, Robin Murphy wrote: > >> On 2021-08-06 16:55, Sven Peter via iommu

Re: [RFC PATCH 2/3] iommu/dma-iommu: Support iovad->granule > PAGE_SIZE

2021-08-07 Thread Sven Peter via iommu
On Fri, Aug 6, 2021, at 20:04, Robin Murphy wrote: > On 2021-08-06 16:55, Sven Peter via iommu wrote: > > @@ -1006,6 +1019,31 @@ static int iommu_dma_map_sg(struct device *dev, > > struct scatterlist *sg, > > if (dev_is_untrusted(dev)) > > return i

Re: [RFC PATCH 2/3] iommu/dma-iommu: Support iovad->granule > PAGE_SIZE

2021-08-07 Thread Sven Peter via iommu
Hi, Thanks a lot for quick reply! On Fri, Aug 6, 2021, at 20:04, Robin Murphy wrote: > On 2021-08-06 16:55, Sven Peter via iommu wrote: > > DMA IOMMU domains can support hardware where the IOMMU page size is > > larger than the CPU page size. > > Alignments need to be done

[RFC PATCH 0/3] iommu/dma-iommu: Support IOMMU page size larger than the CPU page size

2021-08-06 Thread Sven Peter via iommu
Hi, On the Apple M1 there's this slightly annoying situation where the DART IOMMU has a hard-wired page size of 16KB. Additionally, the DARTs for some hardware (USB A ports, WiFi, Ethernet, Thunderbolt PCIe) cannot be switched to bypass mode and it's also not easily possible to program a software

[RFC PATCH 3/3] iommu: Introduce __IOMMU_DOMAIN_LARGE_PAGES

2021-08-06 Thread Sven Peter via iommu
__IOMMU_DOMAIN_LARGE_PAGES indicates that a domain can handle conditions where PAGE_SIZE might be smaller than the IOMMU page size. Always allow attaching devices to such domains and set the flag for IOMMU_DOMAIN_DMA, which can now handle these situations. Signed-off-by: Sven Peter ---

[RFC PATCH 2/3] iommu/dma-iommu: Support iovad->granule > PAGE_SIZE

2021-08-06 Thread Sven Peter via iommu
DMA IOMMU domains can support hardware where the IOMMU page size is larger than the CPU page size. Alignments need to be done with respect to both PAGE_SIZE and iovad->granule. Additionally, the sg list optimization to use a single IOVA allocation cannot be used in those cases since the physical

[RFC PATCH 1/3] iommu: Move IOMMU pagesize check to attach_device

2021-08-06 Thread Sven Peter via iommu
The iova allocator is capable of handling any granularity which is a power of two. Remove the much stronger condition that the granularity must be smaller or equal to the CPU page size from a BUG_ON there. Instead, check this condition during __iommu_attach_device and fail gracefully.

[PATCH v5 3/3] iommu/dart: Add DART iommu driver

2021-08-03 Thread Sven Peter via iommu
Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be setup before these peripherals can act as DMA masters. Tested-by: Alyssa Rosenzweig Signed-off-by: Sven Peter --- MAINTAINERS| 1 + drivers/iommu/Kconfig | 14 +

[PATCH v5 1/3] iommu/io-pgtable: Add DART pagetable format

2021-08-03 Thread Sven Peter via iommu
Apple's DART iommu uses a pagetable format that shares some similarities with the ones already implemented by io-pgtable.c. Add a new format variant to support the required differences so that we don't have to duplicate the pagetable handling code. Reviewed-by: Alexander Graf Reviewed-by: Alyssa

[PATCH v5 2/3] dt-bindings: iommu: add DART iommu bindings

2021-08-03 Thread Sven Peter via iommu
DART (Device Address Resolution Table) is the iommu found on Apple ARM SoCs such as the M1. Reviewed-by: Rob Herring Reviewed-by: Alyssa Rosenzweig Signed-off-by: Sven Peter --- .../devicetree/bindings/iommu/apple,dart.yaml | 81 +++ MAINTAINERS

[PATCH v5 0/3] Apple M1 DART IOMMU driver

2021-08-03 Thread Sven Peter via iommu
Hi, This is v5 of my Apple M1 DART IOMMU driver series as a follow up to the previous versions [1][2][3][7]. Short summary: this series adds support for the iommu found in Apple's new M1 SoC which is required to use DMA on most peripherals like the display controller, the USB ports or the

Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-07-25 Thread Sven Peter via iommu
On Mon, Jul 19, 2021, at 20:15, Robin Murphy wrote: > On 2021-07-15 17:41, Sven Peter via iommu wrote: > [...] > >>> + u64 sw_bypass_cpu_start; > >>> + u64 sw_bypass_dma_start; > >>> + u64 sw_bypass_len; > >>> + > >>> + struct

Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-07-15 Thread Sven Peter via iommu
Hi, Awesome, thanks a lot for the detailed review! On Wed, Jul 14, 2021, at 01:23, Robin Murphy wrote: > ^^ Nit: the subsystem style for the subject format should be > "iommu/dart: Add..." - similarly on patch #1, which I just realised I > missed (sorry!) Sure! > > On 2021-06-27 15:34,

Re: [PATCH v4 1/3] iommu: io-pgtable: add DART pagetable format

2021-07-14 Thread Sven Peter via iommu
Hi, On Tue, Jul 13, 2021, at 21:17, Robin Murphy wrote: > On 2021-06-27 15:34, Sven Peter wrote: > > Apple's DART iommu uses a pagetable format that shares some > > similarities with the ones already implemented by io-pgtable.c. > > Add a new format variant to support the required differences > >

Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-07-12 Thread Sven Peter via iommu
Hi, On Wed, Jun 30, 2021, at 15:49, Alyssa Rosenzweig wrote: > Looks really good! Just a few minor comments. With them addressed, > > Reviewed-by: Alyssa Rosenzweig Thanks! > > > + Say Y here if you are using an Apple SoC with a DART IOMMU. > > Nit: Do we need to spell out "with

Re: [PATCH v4 1/3] iommu: io-pgtable: add DART pagetable format

2021-06-29 Thread Sven Peter via iommu
On Mon, Jun 28, 2021, at 12:54, Alexander Graf wrote: > > > On 27.06.21 16:34, Sven Peter wrote: > > > > Apple's DART iommu uses a pagetable format that shares some > > similarities with the ones already implemented by io-pgtable.c. > > Add a new format variant to support the required

[PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-06-27 Thread Sven Peter via iommu
Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be setup before these peripherals can act as DMA masters. Signed-off-by: Sven Peter --- MAINTAINERS |1 + drivers/iommu/Kconfig| 15 +

[PATCH v4 2/3] dt-bindings: iommu: add DART iommu bindings

2021-06-27 Thread Sven Peter via iommu
DART (Device Address Resolution Table) is the iommu found on Apple ARM SoCs such as the M1. Reviewed-by: Rob Herring Signed-off-by: Sven Peter --- .../devicetree/bindings/iommu/apple,dart.yaml | 81 +++ MAINTAINERS | 6 ++ 2 files changed, 87

[PATCH v4 0/3] Apple M1 DART IOMMU driver

2021-06-27 Thread Sven Peter via iommu
Hi, This is v4 of my Apple M1 DART IOMMU driver series as a follow up to the previous versions [1][2][3]. Short summary: this series adds support for the iommu found in Apple's new M1 SoC which is required to use DMA on most peripherals like the display controller, the USB ports or the

[PATCH v4 1/3] iommu: io-pgtable: add DART pagetable format

2021-06-27 Thread Sven Peter via iommu
Apple's DART iommu uses a pagetable format that shares some similarities with the ones already implemented by io-pgtable.c. Add a new format variant to support the required differences so that we don't have to duplicate the pagetable handling code. Signed-off-by: Sven Peter ---

Re: [PATCH v3 2/3] dt-bindings: iommu: add DART iommu bindings

2021-06-12 Thread Sven Peter via iommu
Hi, On Thu, Jun 10, 2021, at 18:52, Rob Herring wrote: > On Thu, Jun 03, 2021 at 10:50:02AM +0200, Sven Peter wrote: > > + > > +examples: > > + - |+ > > +dart1: iommu@82f8 { > > + compatible = "apple,t8103-dart"; > > + reg = <0x82f8 0x4000>; > > + interrupts = <1 781

Re: [PATCH v3 3/3] iommu: dart: Add DART iommu driver

2021-06-05 Thread Sven Peter via iommu
Hi Rouven, On Sat, Jun 5, 2021, at 13:50, Rouven Czerwinski wrote: > Hi Sven, > > just a small comment, see inline. > > On Thu, 2021-06-03 at 10:50 +0200, Sven Peter wrote: > > + > > +/* must be called with held dart_domain->lock */ > > You can remove this comment, include lockdep.h and… > >

[PATCH v3 3/3] iommu: dart: Add DART iommu driver

2021-06-03 Thread Sven Peter via iommu
Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be setup before these peripherals can act as DMA masters. Signed-off-by: Sven Peter --- MAINTAINERS | 1 + drivers/iommu/Kconfig| 15 + drivers/iommu/Makefile

[PATCH v3 1/3] iommu: io-pgtable: add DART pagetable format

2021-06-03 Thread Sven Peter via iommu
Apple's DART iommu uses a pagetable format that shares some similarities with the ones already implemented by io-pgtable.c. Add a new format variant to support the required differences so that we don't have to duplicate the pagetable handling code. Signed-off-by: Sven Peter ---

[PATCH v3 2/3] dt-bindings: iommu: add DART iommu bindings

2021-06-03 Thread Sven Peter via iommu
DART (Device Address Resolution Table) is the iommu found on Apple ARM SoCs such as the M1. Signed-off-by: Sven Peter --- .../devicetree/bindings/iommu/apple,dart.yaml | 81 +++ MAINTAINERS | 6 ++ 2 files changed, 87 insertions(+) create mode

[PATCH v3 0/3] Apple M1 DART IOMMU driver

2021-06-03 Thread Sven Peter via iommu
Hi, This is v3 of my Apple M1 DART IOMMU driver series as a follow up to the original two versions [1][2]. Short summary: this series adds support for the iommu found in Apple's new M1 SoC which is required to use DMA on most peripherals. So far this code has been tested with dwc3 in host and

Re: [PATCH v3] iommu/dma: Fix IOVA reserve dma ranges

2021-06-02 Thread Sven Peter via iommu
Hi, I just ran into the exact same issue while working on the M1 DART IOMMU driver and it was fixed by this commit. Thanks! Would be great if this could be picked up. Tested-by: Sven Peter Best, Sven On Mon, Sep 14, 2020, at 09:23, Srinath Mannam via iommu wrote: > Fix IOVA reserve

Re: [PATCH] iommu: dart: fix call_kern.cocci warnings

2021-04-09 Thread Sven Peter via iommu
On Sun, Apr 4, 2021, at 17:26, Julia Lawall wrote: > From: kernel test robot > > Function apple_dart_attach_stream called on line 519 inside > lock on line 509 but uses GFP_KERNEL Thanks! Fixed for v3. Best, Sven ___ iommu mailing list

Re: [PATCH v2 1/3] iommu: io-pgtable: add DART pagetable format

2021-04-09 Thread Sven Peter via iommu
On Wed, Apr 7, 2021, at 12:44, Will Deacon wrote: > On Sun, Mar 28, 2021 at 09:40:07AM +0200, Sven Peter wrote: [...] > > > > +static struct io_pgtable * > > +apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) > > +{ > > + struct arm_lpae_io_pgtable *data; > > + > > + if

Re: [PATCH v2 3/3] iommu: dart: Add DART iommu driver

2021-04-09 Thread Sven Peter via iommu
On Wed, Apr 7, 2021, at 12:42, Will Deacon wrote: > On Sun, Mar 28, 2021 at 09:40:09AM +0200, Sven Peter wrote: > > Apple's new SoCs use iommus for almost all peripherals. These Device > > Address Resolution Tables must be setup before these peripherals can > > act as DMA masters. > > > >

Re: [PATCH v2 2/3] dt-bindings: iommu: add DART iommu bindings

2021-03-28 Thread Sven Peter via iommu
On Sun, Mar 28, 2021, at 10:16, Arnd Bergmann wrote: > On Sun, Mar 28, 2021 at 9:40 AM Sven Peter wrote: > > I noticed only one detail here: > > > + - |+ > > +dart2a: dart2a@82f0 { > > + compatible = "apple,t8103-dart"; > > + reg = <0x82f0 0x4000>; > > +

[PATCH v2 3/3] iommu: dart: Add DART iommu driver

2021-03-28 Thread Sven Peter via iommu
Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be setup before these peripherals can act as DMA masters. Signed-off-by: Sven Peter --- MAINTAINERS | 1 + drivers/iommu/Kconfig| 14 + drivers/iommu/Makefile

[PATCH v2 2/3] dt-bindings: iommu: add DART iommu bindings

2021-03-28 Thread Sven Peter via iommu
DART (Device Address Resolution Table) is the iommu found on Apple ARM SoCs such as the M1. Signed-off-by: Sven Peter --- .../devicetree/bindings/iommu/apple,dart.yaml | 81 +++ MAINTAINERS | 6 ++ 2 files changed, 87 insertions(+) create mode

[PATCH v2 0/3] Apple M1 DART IOMMU driver

2021-03-28 Thread Sven Peter via iommu
Hi, Here's v2 of my Apple M1 DART IOMMU driver series as a follow up to the original version [1]. Short summary: this series adds support for the iommu found in Apple's new M1 SoC which is required to use DMA on most peripherals. So far this code has been tested with dwc3 in host and device mode

[PATCH v2 1/3] iommu: io-pgtable: add DART pagetable format

2021-03-28 Thread Sven Peter via iommu
Apple's DART iommu uses a pagetable format that shares some similarities with the ones already implemented by io-pgtable.c. Add a new format variant to support the required differences so that we don't have to duplicate the pagetable handling code. Signed-off-by: Sven Peter ---

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-27 Thread Sven Peter via iommu
Hi Robin, On Thu, Mar 25, 2021, at 12:50, Robin Murphy wrote: > On 2021-03-25 07:53, Sven Peter wrote: > > The iommu binding documentation [1] mentions that > > > > The device tree node of the IOMMU device's parent bus must contain a > > valid > > "dma-ranges" property that describes

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-27 Thread Sven Peter via iommu
On Fri, Mar 26, 2021, at 20:59, Arnd Bergmann wrote: > On Fri, Mar 26, 2021 at 6:51 PM Sven Peter wrote: > > dart-sio: 0021c000 fbde4000 (at least their Secure Enclave/TPM > > co-processor) > > Same here: > dart-sio { >vm-base = <0x0>; >vm-size = <0xfc00>; >

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-26 Thread Sven Peter via iommu
On Fri, Mar 26, 2021, at 18:34, Robin Murphy wrote: > On 2021-03-26 17:26, Mark Kettenis wrote: > > > > Anyway, from my viewpoint having the information about the IOVA > > address space sit on the devices makes little sense. This information > > is needed by the DART driver, and there is no

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-26 Thread Sven Peter via iommu
On Fri, Mar 26, 2021, at 17:38, Arnd Bergmann wrote: > On Fri, Mar 26, 2021 at 5:10 PM Sven Peter wrote: > > On Fri, Mar 26, 2021, at 16:59, Mark Kettenis wrote: > > > Some of the DARTs provide a bypass facility. That code make using the > > > standard "dma-ranges" property tricky. That

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-26 Thread Sven Peter via iommu
On Fri, Mar 26, 2021, at 16:59, Mark Kettenis wrote: > Some of the DARTs provide a bypass facility. That code make using the > standard "dma-ranges" property tricky. That property would need to > contain the bypass address range. But that would mean that if the > DART driver needs to look at

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-25 Thread Sven Peter via iommu
On Thu, Mar 25, 2021, at 12:50, Robin Murphy wrote: > On 2021-03-25 07:53, Sven Peter wrote: > > > > > > On Tue, Mar 23, 2021, at 21:53, Rob Herring wrote: > >> On Sun, Mar 21, 2021 at 05:00:50PM +0100, Mark Kettenis wrote: > >>> > >>> As I mentioned before, not all DARTs support the full

Re: [PATCH 1/3] iommu: io-pgtable: add DART pagetable format

2021-03-25 Thread Sven Peter via iommu
Hi Robin, Thanks for the review! On Wed, Mar 24, 2021, at 17:37, Robin Murphy wrote: > On 2021-03-20 15:19, Sven Peter wrote: > > Apple's DART iommu uses a pagetable format that's very similar to the ones > > already implemented by io-pgtable.c. > > Add a new format variant to support the

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-25 Thread Sven Peter via iommu
Hi Robin, On Wed, Mar 24, 2021, at 16:29, Robin Murphy wrote: > On 2021-03-20 15:19, Sven Peter wrote: > > > > I have just noticed today though that at least the USB DWC3 controller in > > host > > mode uses *two* darts at the same time. I'm not sure yet which parts seem to > > require which

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-25 Thread Sven Peter via iommu
On Tue, Mar 23, 2021, at 21:53, Rob Herring wrote: > On Sun, Mar 21, 2021 at 05:00:50PM +0100, Mark Kettenis wrote: > > > Date: Sat, 20 Mar 2021 15:19:33 + > > > From: Sven Peter > > > I have just noticed today though that at least the USB DWC3 controller in > > > host > > > mode uses

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-23 Thread Sven Peter via iommu
Hi Mark, On Tue, Mar 23, 2021, at 21:00, Mark Kettenis wrote: > The problem with both #1 and #2 is that you end up with two references > to (effectively) different iommu's in the dwc3 device node. I don't > see how that is compatible with the idea of using a single translation > table for both

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-22 Thread Sven Peter via iommu
Hi Mark, On Sun, Mar 21, 2021, at 19:35, Mark Kettenis wrote: > > Guess we do need to understand a little bit better how the USB DART > actually works. My hypothesis (based on our discussion on #asahi) is > that the XHCI host controller and the peripheral controller of the > DWC3 block use

Re: [PATCH 2/3] dt-bindings: iommu: add DART iommu bindings

2021-03-22 Thread Sven Peter via iommu
Hi Rob, On Mon, Mar 22, 2021, at 01:15, Rob Herring wrote: > > This check can fail if there are any dependencies. The base for a patch > series is generally the most recent rc1. > > If you already ran 'make dt_binding_check' and didn't see the above > error(s), then make sure 'yamllint' is

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-21 Thread Sven Peter via iommu
Hi Mark, > On 21. Mar 2021, at 17:00, Mark Kettenis wrote: > > I don't think the first option is going to work for PCIe. PCIe > devices will have to use "iommu-map" properties to map PCI devices to > the right iommu, and the currently implementation seems to assume that > #iommu-cells = <1>.

Re: [PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-21 Thread Sven Peter via iommu
Hi Mark, Sorry for the spam if you get this message twice. This is pretty embarrassing but I've just switched mail providers after ProtonMail messed up yesterday and it looks like my new one defaulted to sending HTML messages even though I only typed plaintext. This shouldn't have happened in

[PATCH 0/3] Apple M1 DART IOMMU driver

2021-03-20 Thread Sven Peter via iommu
Hi, After Hector's initial work [1] to bring up Linux on Apple's M1 it's time to bring up more devices. Most peripherals connected to the SoC are behind a iommu which Apple calls "Device Address Resolution Table", or DART for short [2]. Unfortunately, it only shares the name with PowerPC's DART.

[PATCH 3/3] iommu: dart: Add DART iommu driver

2021-03-20 Thread Sven Peter via iommu
Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be setup before these peripherals can act as DMA masters. Signed-off-by: Sven Peter --- MAINTAINERS | 1 + drivers/iommu/Kconfig| 13 + drivers/iommu/Makefile

[PATCH 1/3] iommu: io-pgtable: add DART pagetable format

2021-03-20 Thread Sven Peter via iommu
Apple's DART iommu uses a pagetable format that's very similar to the ones already implemented by io-pgtable.c. Add a new format variant to support the required differences. Signed-off-by: Sven Peter --- drivers/iommu/Kconfig | 13 +++ drivers/iommu/io-pgtable-arm.c | 70

[PATCH 2/3] dt-bindings: iommu: add DART iommu bindings

2021-03-20 Thread Sven Peter via iommu
DART (Device Address Resolution Table) is the iommu found on Apple ARM SoCs such as the M1. Signed-off-by: Sven Peter --- .../bindings/iommu/apple,t8103-dart.yaml | 82 +++ MAINTAINERS | 6 ++ 2 files changed, 88 insertions(+) create mode