mbox series

[v5,0/5] iommu: M1 Pro/Max DART support

Message ID 20220916094152.87137-1-j@jannau.net
Headers show
Series iommu: M1 Pro/Max DART support | expand

Message

Janne Grunau Sept. 16, 2022, 9:41 a.m. UTC
Hej,

this is the next attempt adding support for the DART found in Apple's
M1 Pro/Max/Ultra. This adds a separate io-pgtable implementation for
DART. As already mentioned in v2 the pte format is not fully compatible
with io-pgtable-arm. Especially the 2nd least significant bit is used
and is not available to tag tables/pages.
io-pgtable-dart.c is copied from io-pgtable-arm.c and support for
unused features is removed. Support for 4k IO pages is left for A7 to
A11 SoCs as there's work underway to run Linux on them.

The incompatibilities between both Apple DART pte seems manageable in
their own io-pgtable implementation. A short list of the known
differences:

 - the physical addresses are shifted left by 4 bits and and have 2 more
   bits inside the PTE entries
 - the read/write protection flags are at a different position
 - the subpage protection feature is now mandatory. For Linux we can
   just configure it to always allow access to the entire page.
 - BIT(1) tags "uncached" mappings (used for the display controller)

There is second type of DART (t8110) present on M1 Pro/Max SoCs which
uses the same PTE format as t6000.

Changes in v5:
- collected Sven's ack
- minor fixes in "iommu/io-pgtable: Move Apple DART support to its own
  file"

Changes in v4:
- split dart and io-pgtable-dart build to allow building dart as module
- add missing "SELECT IOMMU_IO_PGTABLE"
- made map/unmap_pages/iova_to_phys inon-recursive
- replace pgd concatenation with multiple table handling
- simplified config and page size checks
- collected Robin's Ack

Changes in v3:
- move APPLE_DART to its own io-pgtable implementation, copied from
  io-pgtable-arm and simplified

Changes in v2:
- added Rob's Acked-by:
- add APPLE_DART2 io-pgtable format

Janne Grunau (1):
  iommu/io-pgtable: Move Apple DART support to its own file

Sven Peter (4):
  dt-bindings: iommu: dart: add t6000 compatible
  iommu/io-pgtable: Add DART subpage protection support
  iommu/io-pgtable-dart: Add DART PTE support for t6000
  iommu: dart: Support t6000 variant

 .../devicetree/bindings/iommu/apple,dart.yaml |   4 +-
 MAINTAINERS                                   |   1 +
 drivers/iommu/Kconfig                         |  13 +-
 drivers/iommu/Makefile                        |   1 +
 drivers/iommu/apple-dart.c                    |  24 +-
 drivers/iommu/io-pgtable-arm.c                |  63 ---
 drivers/iommu/io-pgtable-dart.c               | 470 ++++++++++++++++++
 drivers/iommu/io-pgtable.c                    |   3 +
 include/linux/io-pgtable.h                    |   1 +
 9 files changed, 512 insertions(+), 68 deletions(-)
 create mode 100644 drivers/iommu/io-pgtable-dart.c

Comments

Robin Murphy Sept. 21, 2022, 1:20 p.m. UTC | #1
On 2022-09-16 10:41, Janne Grunau wrote:
> Hej,
> 
> this is the next attempt adding support for the DART found in Apple's
> M1 Pro/Max/Ultra. This adds a separate io-pgtable implementation for
> DART. As already mentioned in v2 the pte format is not fully compatible
> with io-pgtable-arm. Especially the 2nd least significant bit is used
> and is not available to tag tables/pages.
> io-pgtable-dart.c is copied from io-pgtable-arm.c and support for
> unused features is removed. Support for 4k IO pages is left for A7 to
> A11 SoCs as there's work underway to run Linux on them.
> 
> The incompatibilities between both Apple DART pte seems manageable in
> their own io-pgtable implementation. A short list of the known
> differences:
> 
>   - the physical addresses are shifted left by 4 bits and and have 2 more
>     bits inside the PTE entries
>   - the read/write protection flags are at a different position
>   - the subpage protection feature is now mandatory. For Linux we can
>     just configure it to always allow access to the entire page.
>   - BIT(1) tags "uncached" mappings (used for the display controller)
> 
> There is second type of DART (t8110) present on M1 Pro/Max SoCs which
> uses the same PTE format as t6000.

FWIW I think there's minimal risk in queueing this up as a late addition 
for 6.1, lest it get forgotten again. I've not been following it since 
I've been busy with other things and I largely trust that DART patches 
are well-tested, but from a quick skim it all earns a solid "yeah, why 
not" from me :)

Cheers,
Robin.

> Changes in v5:
> - collected Sven's ack
> - minor fixes in "iommu/io-pgtable: Move Apple DART support to its own
>    file"
> 
> Changes in v4:
> - split dart and io-pgtable-dart build to allow building dart as module
> - add missing "SELECT IOMMU_IO_PGTABLE"
> - made map/unmap_pages/iova_to_phys inon-recursive
> - replace pgd concatenation with multiple table handling
> - simplified config and page size checks
> - collected Robin's Ack
> 
> Changes in v3:
> - move APPLE_DART to its own io-pgtable implementation, copied from
>    io-pgtable-arm and simplified
> 
> Changes in v2:
> - added Rob's Acked-by:
> - add APPLE_DART2 io-pgtable format
> 
> Janne Grunau (1):
>    iommu/io-pgtable: Move Apple DART support to its own file
> 
> Sven Peter (4):
>    dt-bindings: iommu: dart: add t6000 compatible
>    iommu/io-pgtable: Add DART subpage protection support
>    iommu/io-pgtable-dart: Add DART PTE support for t6000
>    iommu: dart: Support t6000 variant
> 
>   .../devicetree/bindings/iommu/apple,dart.yaml |   4 +-
>   MAINTAINERS                                   |   1 +
>   drivers/iommu/Kconfig                         |  13 +-
>   drivers/iommu/Makefile                        |   1 +
>   drivers/iommu/apple-dart.c                    |  24 +-
>   drivers/iommu/io-pgtable-arm.c                |  63 ---
>   drivers/iommu/io-pgtable-dart.c               | 470 ++++++++++++++++++
>   drivers/iommu/io-pgtable.c                    |   3 +
>   include/linux/io-pgtable.h                    |   1 +
>   9 files changed, 512 insertions(+), 68 deletions(-)
>   create mode 100644 drivers/iommu/io-pgtable-dart.c
>
Hector Martin Sept. 22, 2022, 2:05 p.m. UTC | #2
On 16/09/2022 18.41, Janne Grunau wrote:
> Hej,
> 
> this is the next attempt adding support for the DART found in Apple's
> M1 Pro/Max/Ultra. This adds a separate io-pgtable implementation for
> DART. As already mentioned in v2 the pte format is not fully compatible
> with io-pgtable-arm. Especially the 2nd least significant bit is used
> and is not available to tag tables/pages.
> io-pgtable-dart.c is copied from io-pgtable-arm.c and support for
> unused features is removed. Support for 4k IO pages is left for A7 to
> A11 SoCs as there's work underway to run Linux on them.
> 
> The incompatibilities between both Apple DART pte seems manageable in
> their own io-pgtable implementation. A short list of the known
> differences:
> 
>  - the physical addresses are shifted left by 4 bits and and have 2 more
>    bits inside the PTE entries
>  - the read/write protection flags are at a different position
>  - the subpage protection feature is now mandatory. For Linux we can
>    just configure it to always allow access to the entire page.
>  - BIT(1) tags "uncached" mappings (used for the display controller)
> 
> There is second type of DART (t8110) present on M1 Pro/Max SoCs which
> uses the same PTE format as t6000.
> 
> Changes in v5:
> - collected Sven's ack
> - minor fixes in "iommu/io-pgtable: Move Apple DART support to its own
>   file"
> 
> Changes in v4:
> - split dart and io-pgtable-dart build to allow building dart as module
> - add missing "SELECT IOMMU_IO_PGTABLE"
> - made map/unmap_pages/iova_to_phys inon-recursive
> - replace pgd concatenation with multiple table handling
> - simplified config and page size checks
> - collected Robin's Ack
> 
> Changes in v3:
> - move APPLE_DART to its own io-pgtable implementation, copied from
>   io-pgtable-arm and simplified
> 
> Changes in v2:
> - added Rob's Acked-by:
> - add APPLE_DART2 io-pgtable format
> 
> Janne Grunau (1):
>   iommu/io-pgtable: Move Apple DART support to its own file
> 
> Sven Peter (4):
>   dt-bindings: iommu: dart: add t6000 compatible
>   iommu/io-pgtable: Add DART subpage protection support
>   iommu/io-pgtable-dart: Add DART PTE support for t6000
>   iommu: dart: Support t6000 variant
> 
>  .../devicetree/bindings/iommu/apple,dart.yaml |   4 +-
>  MAINTAINERS                                   |   1 +
>  drivers/iommu/Kconfig                         |  13 +-
>  drivers/iommu/Makefile                        |   1 +
>  drivers/iommu/apple-dart.c                    |  24 +-
>  drivers/iommu/io-pgtable-arm.c                |  63 ---
>  drivers/iommu/io-pgtable-dart.c               | 470 ++++++++++++++++++
>  drivers/iommu/io-pgtable.c                    |   3 +
>  include/linux/io-pgtable.h                    |   1 +
>  9 files changed, 512 insertions(+), 68 deletions(-)
>  create mode 100644 drivers/iommu/io-pgtable-dart.c
> 

For the whole series, modulo the trivial warning I mentioned:

Acked-by: Hector Martin <marcan@marcan.st>

Let's get this merged please, it's been blocking t6000 support for a
long time now :)

- Hector
Joerg Roedel Sept. 26, 2022, 11:50 a.m. UTC | #3
On Fri, Sep 16, 2022 at 11:41:47AM +0200, Janne Grunau wrote:
> Janne Grunau (1):
>   iommu/io-pgtable: Move Apple DART support to its own file
> 
> Sven Peter (4):
>   dt-bindings: iommu: dart: add t6000 compatible
>   iommu/io-pgtable: Add DART subpage protection support
>   iommu/io-pgtable-dart: Add DART PTE support for t6000
>   iommu: dart: Support t6000 variant

Applied patches 2-5 for v6.1, thanks everyone.