2023-03-11 13:39:07

by Sven Peter

[permalink] [raw]
Subject: [PATCH v3 0/3] Apple M1 USB4/Thunderbolt DART support

Hi,

The M1 SoCs have a second slightly different variant of the regular
DART used for the USB4 PCIe ports. It supports 64 instead of 16 streams
which requires a minor change to the MMIO layout.
There seems to be no way to tell them apart from the regular DARTs by
just looking at the DART_PARAMs register so we have to add a new
compatible for those.

Changes since v2:
- drop the manual bypass disable
- added Rob's tag

Changes since v1:
- apple,t8103-usb4-dart instead of apple,t8103-dart-usb4 as the
compatible
- collected Hector's tags

Best,

Sven

Sven Peter (3):
dt-bindings: iommu: dart: Add t8103-usb4-dart compatible
iommu: dart: Write to all DART_T8020_STREAM_SELECT
iommu: dart: Add support for t8103 USB4 DART

.../devicetree/bindings/iommu/apple,dart.yaml | 1 +
drivers/iommu/apple-dart.c | 35 +++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)

--
2.25.1



2023-03-11 13:39:10

by Sven Peter

[permalink] [raw]
Subject: [PATCH v3 1/3] dt-bindings: iommu: dart: Add t8103-usb4-dart compatible

This DART variant is found in the t8103 (M1) SoCs and used for the
USB4/Thunderbolt PCIe ports. Unlike the regular t8103 DART these support
up to 64 SIDs and require a slightly different MMIO layout.

Acked-by: Hector Martin <[email protected]>
Acked-by: Rob Herring <[email protected]>
Signed-off-by: Sven Peter <[email protected]>
---
Documentation/devicetree/bindings/iommu/apple,dart.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml
index 903edf85d72e..7adb1de455a5 100644
--- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml
+++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml
@@ -24,6 +24,7 @@ properties:
compatible:
enum:
- apple,t8103-dart
+ - apple,t8103-usb4-dart
- apple,t8110-dart
- apple,t6000-dart

--
2.25.1


2023-03-11 13:39:18

by Sven Peter

[permalink] [raw]
Subject: [PATCH v3 2/3] iommu: dart: Write to all DART_T8020_STREAM_SELECT

We're about to add support for a DART variant that use more than 16
streams and requires writing to two separate stream select registers
when issuing TLB flushes.

Acked-by: Hector Martin <[email protected]>
Signed-off-by: Sven Peter <[email protected]>
---
drivers/iommu/apple-dart.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 74a367302d34..f73d0288e133 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -370,12 +370,14 @@ apple_dart_t8020_hw_stream_command(struct apple_dart_stream_map *stream_map,
u32 command)
{
unsigned long flags;
- int ret;
+ int ret, i;
u32 command_reg;

spin_lock_irqsave(&stream_map->dart->lock, flags);

- writel(stream_map->sidmap[0], stream_map->dart->regs + DART_T8020_STREAM_SELECT);
+ for (i = 0; i < BITS_TO_U32(stream_map->dart->num_streams); i++)
+ writel(stream_map->sidmap[i],
+ stream_map->dart->regs + DART_T8020_STREAM_SELECT + 4 * i);
writel(command, stream_map->dart->regs + DART_T8020_STREAM_COMMAND);

ret = readl_poll_timeout_atomic(
--
2.25.1


2023-03-11 13:39:22

by Sven Peter

[permalink] [raw]
Subject: [PATCH v3 3/3] iommu: dart: Add support for t8103 USB4 DART

This variant of the regular t8103 DART is used for the two
USB4/Thunderbolt PCIe controllers. It supports 64 instead of 16 streams
which requires a slightly different MMIO layout.

Acked-by: Hector Martin <[email protected]>
Signed-off-by: Sven Peter <[email protected]>
---
drivers/iommu/apple-dart.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index f73d0288e133..23f79659a48b 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -81,6 +81,7 @@
#define DART_T8020_TCR_BYPASS_DAPF BIT(12)

#define DART_T8020_TTBR 0x200
+#define DART_T8020_USB4_TTBR 0x400
#define DART_T8020_TTBR_VALID BIT(31)
#define DART_T8020_TTBR_ADDR_FIELD_SHIFT 0
#define DART_T8020_TTBR_SHIFT 12
@@ -1192,6 +1193,33 @@ static const struct apple_dart_hw apple_dart_hw_t8103 = {
.ttbr_shift = DART_T8020_TTBR_SHIFT,
.ttbr_count = 4,
};
+
+static const struct apple_dart_hw apple_dart_hw_t8103_usb4 = {
+ .type = DART_T8020,
+ .irq_handler = apple_dart_t8020_irq,
+ .invalidate_tlb = apple_dart_t8020_hw_invalidate_tlb,
+ .oas = 36,
+ .fmt = APPLE_DART,
+ .max_sid_count = 64,
+
+ .enable_streams = DART_T8020_STREAMS_ENABLE,
+ .lock = DART_T8020_CONFIG,
+ .lock_bit = DART_T8020_CONFIG_LOCK,
+
+ .error = DART_T8020_ERROR,
+
+ .tcr = DART_T8020_TCR,
+ .tcr_enabled = DART_T8020_TCR_TRANSLATE_ENABLE,
+ .tcr_disabled = 0,
+ .tcr_bypass = 0,
+
+ .ttbr = DART_T8020_USB4_TTBR,
+ .ttbr_valid = DART_T8020_TTBR_VALID,
+ .ttbr_addr_field_shift = DART_T8020_TTBR_ADDR_FIELD_SHIFT,
+ .ttbr_shift = DART_T8020_TTBR_SHIFT,
+ .ttbr_count = 4,
+};
+
static const struct apple_dart_hw apple_dart_hw_t6000 = {
.type = DART_T6000,
.irq_handler = apple_dart_t8020_irq,
@@ -1292,6 +1320,7 @@ DEFINE_SIMPLE_DEV_PM_OPS(apple_dart_pm_ops, apple_dart_suspend, apple_dart_resum

static const struct of_device_id apple_dart_of_match[] = {
{ .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 },
+ { .compatible = "apple,t8103-usb4-dart", .data = &apple_dart_hw_t8103_usb4 },
{ .compatible = "apple,t8110-dart", .data = &apple_dart_hw_t8110 },
{ .compatible = "apple,t6000-dart", .data = &apple_dart_hw_t6000 },
{},
--
2.25.1


2023-03-11 13:52:45

by Mark Kettenis

[permalink] [raw]
Subject: Re: [PATCH v3 1/3] dt-bindings: iommu: dart: Add t8103-usb4-dart compatible

> From: Sven Peter <[email protected]>
> Date: Sat, 11 Mar 2023 14:38:54 +0100
>
> This DART variant is found in the t8103 (M1) SoCs and used for the
> USB4/Thunderbolt PCIe ports. Unlike the regular t8103 DART these support
> up to 64 SIDs and require a slightly different MMIO layout.
>
> Acked-by: Hector Martin <[email protected]>
> Acked-by: Rob Herring <[email protected]>
> Signed-off-by: Sven Peter <[email protected]>

Reviewed-by: Mark Kettenis <[email protected]>

> ---
> Documentation/devicetree/bindings/iommu/apple,dart.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml
> index 903edf85d72e..7adb1de455a5 100644
> --- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml
> +++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml
> @@ -24,6 +24,7 @@ properties:
> compatible:
> enum:
> - apple,t8103-dart
> + - apple,t8103-usb4-dart
> - apple,t8110-dart
> - apple,t6000-dart
>
> --
> 2.25.1
>
>
>