public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE
@ 2021-10-19 16:22 Sven Peter
  2021-10-19 16:49 ` Hector Martin
  2021-10-27  8:08 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Sven Peter @ 2021-10-19 16:22 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Sven Peter, Martin Povišer, Alyssa Rosenzweig, Hector Martin,
	Will Deacon, iommu, linux-kernel

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) however have some streams disabled initially. Make sure those
work by initializing DART_STREAMS_ENABLE during reset.

Reported-by: Martin Povišer <povik@protonmail.com>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---

While this could technically count as a fix I don't think it needs to go to
5.15 since no driver that requires this is in there. The first driver
that needs this will likely only be ready for the 5.17 merge window.

 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 ce92195db638..6f8c240d8d40 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -70,6 +70,8 @@
 #define DART_ERROR_ADDR_HI 0x54
 #define DART_ERROR_ADDR_LO 0x50
 
+#define DART_STREAMS_ENABLE 0xfc
+
 #define DART_TCR(sid) (0x100 + 4 * (sid))
 #define DART_TCR_TRANSLATE_ENABLE BIT(7)
 #define DART_TCR_BYPASS0_ENABLE BIT(8)
@@ -299,6 +301,9 @@ static int apple_dart_hw_reset(struct apple_dart *dart)
 	apple_dart_hw_disable_dma(&stream_map);
 	apple_dart_hw_clear_all_ttbrs(&stream_map);
 
+	/* enable all streams globally since TCR is used to control isolation */
+	writel(DART_STREAM_ALL, dart->regs + DART_STREAMS_ENABLE);
+
 	/* clear any pending errors before the interrupt is unmasked */
 	writel(readl(dart->regs + DART_ERROR), dart->regs + DART_ERROR);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE
  2021-10-19 16:22 [PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE Sven Peter
@ 2021-10-19 16:49 ` Hector Martin
  2021-10-27  8:08 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Hector Martin @ 2021-10-19 16:49 UTC (permalink / raw)
  To: Sven Peter, Joerg Roedel
  Cc: Martin Povišer, Alyssa Rosenzweig, Will Deacon, iommu,
	linux-kernel

On 20/10/2021 01.22, Sven Peter wrote:
> 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) however have some streams disabled initially. Make sure those
> work by initializing DART_STREAMS_ENABLE during reset.
> 
> Reported-by: Martin Povišer <povik@protonmail.com>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---
> 
> While this could technically count as a fix I don't think it needs to go to
> 5.15 since no driver that requires this is in there. The first driver
> that needs this will likely only be ready for the 5.17 merge window.
> 
>   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 ce92195db638..6f8c240d8d40 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -70,6 +70,8 @@
>   #define DART_ERROR_ADDR_HI 0x54
>   #define DART_ERROR_ADDR_LO 0x50
>   
> +#define DART_STREAMS_ENABLE 0xfc
> +
>   #define DART_TCR(sid) (0x100 + 4 * (sid))
>   #define DART_TCR_TRANSLATE_ENABLE BIT(7)
>   #define DART_TCR_BYPASS0_ENABLE BIT(8)
> @@ -299,6 +301,9 @@ static int apple_dart_hw_reset(struct apple_dart *dart)
>   	apple_dart_hw_disable_dma(&stream_map);
>   	apple_dart_hw_clear_all_ttbrs(&stream_map);
>   
> +	/* enable all streams globally since TCR is used to control isolation */
> +	writel(DART_STREAM_ALL, dart->regs + DART_STREAMS_ENABLE);
> +
>   	/* clear any pending errors before the interrupt is unmasked */
>   	writel(readl(dart->regs + DART_ERROR), dart->regs + DART_ERROR);
>   
> 

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

-- 
Hector Martin (marcan@marcan.st)
Public Key: https://mrcn.st/pub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE
  2021-10-19 16:22 [PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE Sven Peter
  2021-10-19 16:49 ` Hector Martin
@ 2021-10-27  8:08 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2021-10-27  8:08 UTC (permalink / raw)
  To: Sven Peter
  Cc: Martin Povišer, Alyssa Rosenzweig, Hector Martin,
	Will Deacon, iommu, linux-kernel

On Tue, Oct 19, 2021 at 06:22:53PM +0200, Sven Peter wrote:
> 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) however have some streams disabled initially. Make sure those
> work by initializing DART_STREAMS_ENABLE during reset.
> 
> Reported-by: Martin Povišer <povik@protonmail.com>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
> ---

Applied, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-27  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 16:22 [PATCH] iommu/dart: Initialize DART_STREAMS_ENABLE Sven Peter
2021-10-19 16:49 ` Hector Martin
2021-10-27  8:08 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox