mbox series

[v2,0/4] Apple M1 USB4/Thunderbolt DART support

Message ID 20230228202132.4919-1-sven@svenpeter.dev
Headers show
Series Apple M1 USB4/Thunderbolt DART support | expand

Message

Sven Peter Feb. 28, 2023, 8:21 p.m. UTC
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.

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

Best,

Sven

Sven Peter (4):
  dt-bindings: iommu: dart: Add t8103-usb4-dart compatible
  iommu: dart: Add flag to override bypass support
  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                    | 42 ++++++++++++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)

Comments

Robin Murphy March 2, 2023, 3:04 p.m. UTC | #1
On 28/02/2023 8:21 pm, Sven Peter wrote:
> The USB4 PCIe DARTs claim to support bypass but we never want to allow
> that on externally facing ports.

IOMMU drivers shouldn't be implementing their own individual policies 
for this - externally-facing ports should be correctly marked as 
such[1], so that the PCI layer is properly informed, which in turn will 
be picked up and handled properly by IOMMU core code.

Thanks,
Robin.

[1] see Documentation/devicetree/bindings/pci/pci.txt

> Acked-by: Hector Martin <marcan@marcan.st>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---
>   drivers/iommu/apple-dart.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index 42666617803d..7d8b2b90cdb6 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -182,6 +182,8 @@ struct apple_dart_hw {
>   	u64 ttbr_addr_field_shift;
>   	u64 ttbr_shift;
>   	int ttbr_count;
> +
> +	bool disable_bypass;
>   };
>   
>   /*
> @@ -1075,6 +1077,9 @@ static int apple_dart_probe(struct platform_device *pdev)
>   	dart->pgsize = 1 << FIELD_GET(DART_PARAMS1_PAGE_SHIFT, dart_params[0]);
>   	dart->supports_bypass = dart_params[1] & DART_PARAMS2_BYPASS_SUPPORT;
>   
> +	if (dart->hw->disable_bypass)
> +		dart->supports_bypass = 0;
> +
>   	switch (dart->hw->type) {
>   	case DART_T8020:
>   	case DART_T6000: