All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-06-15 15:48 ` Steven Price
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Price @ 2022-06-15 15:48 UTC (permalink / raw)
  To: Heiko Stübner, Daniel Vetter, David Airlie, Sandy Huang
  Cc: Steven Price, dri-devel, linux-arm-kernel, linux-kernel,
	linux-rockchip, Robin Murphy

Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
interfaces") the Rockchip display driver on the Firefly RK3288 fails to
initialise properly. This is because ARM DMA domain is still attached.

Let's follow the lead of exynos and tegra and add code to explicitly
remove the ARM domain before attaching a new one.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
---
See also the thread[1] where I reported the regression.

[1] https://lore.kernel.org/linux-kernel/da9cca0a-ec5b-2e73-9de0-a930f7d947b2%40arm.com
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 67d38f53d3e5..13ed33e74457 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -23,6 +23,14 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
+#if defined(CONFIG_ARM_DMA_USE_IOMMU)
+#include <asm/dma-iommu.h>
+#else
+#define arm_iommu_detach_device(...)	({ })
+#define arm_iommu_release_mapping(...)	({ })
+#define to_dma_iommu_mapping(dev) NULL
+#endif
+
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_fb.h"
 #include "rockchip_drm_gem.h"
@@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
 	if (!private->domain)
 		return 0;
 
+	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
+		struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+
+		if (mapping) {
+			arm_iommu_detach_device(dev);
+			arm_iommu_release_mapping(mapping);
+		}
+	}
+
 	ret = iommu_attach_device(private->domain, dev);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");
-- 
2.25.1


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

* [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-06-15 15:48 ` Steven Price
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Price @ 2022-06-15 15:48 UTC (permalink / raw)
  To: Heiko Stübner, Daniel Vetter, David Airlie, Sandy Huang
  Cc: linux-kernel, dri-devel, Steven Price, linux-rockchip,
	Robin Murphy, linux-arm-kernel

Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
interfaces") the Rockchip display driver on the Firefly RK3288 fails to
initialise properly. This is because ARM DMA domain is still attached.

Let's follow the lead of exynos and tegra and add code to explicitly
remove the ARM domain before attaching a new one.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
---
See also the thread[1] where I reported the regression.

[1] https://lore.kernel.org/linux-kernel/da9cca0a-ec5b-2e73-9de0-a930f7d947b2%40arm.com
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 67d38f53d3e5..13ed33e74457 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -23,6 +23,14 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
+#if defined(CONFIG_ARM_DMA_USE_IOMMU)
+#include <asm/dma-iommu.h>
+#else
+#define arm_iommu_detach_device(...)	({ })
+#define arm_iommu_release_mapping(...)	({ })
+#define to_dma_iommu_mapping(dev) NULL
+#endif
+
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_fb.h"
 #include "rockchip_drm_gem.h"
@@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
 	if (!private->domain)
 		return 0;
 
+	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
+		struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+
+		if (mapping) {
+			arm_iommu_detach_device(dev);
+			arm_iommu_release_mapping(mapping);
+		}
+	}
+
 	ret = iommu_attach_device(private->domain, dev);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");
-- 
2.25.1


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

* [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-06-15 15:48 ` Steven Price
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Price @ 2022-06-15 15:48 UTC (permalink / raw)
  To: Heiko Stübner, Daniel Vetter, David Airlie, Sandy Huang
  Cc: Steven Price, dri-devel, linux-arm-kernel, linux-kernel,
	linux-rockchip, Robin Murphy

Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
interfaces") the Rockchip display driver on the Firefly RK3288 fails to
initialise properly. This is because ARM DMA domain is still attached.

Let's follow the lead of exynos and tegra and add code to explicitly
remove the ARM domain before attaching a new one.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
---
See also the thread[1] where I reported the regression.

[1] https://lore.kernel.org/linux-kernel/da9cca0a-ec5b-2e73-9de0-a930f7d947b2%40arm.com
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 67d38f53d3e5..13ed33e74457 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -23,6 +23,14 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
+#if defined(CONFIG_ARM_DMA_USE_IOMMU)
+#include <asm/dma-iommu.h>
+#else
+#define arm_iommu_detach_device(...)	({ })
+#define arm_iommu_release_mapping(...)	({ })
+#define to_dma_iommu_mapping(dev) NULL
+#endif
+
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_fb.h"
 #include "rockchip_drm_gem.h"
@@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
 	if (!private->domain)
 		return 0;
 
+	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
+		struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+
+		if (mapping) {
+			arm_iommu_detach_device(dev);
+			arm_iommu_release_mapping(mapping);
+		}
+	}
+
 	ret = iommu_attach_device(private->domain, dev);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");
-- 
2.25.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-06-15 15:48 ` Steven Price
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Price @ 2022-06-15 15:48 UTC (permalink / raw)
  To: Heiko Stübner, Daniel Vetter, David Airlie, Sandy Huang
  Cc: Steven Price, dri-devel, linux-arm-kernel, linux-kernel,
	linux-rockchip, Robin Murphy

Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
interfaces") the Rockchip display driver on the Firefly RK3288 fails to
initialise properly. This is because ARM DMA domain is still attached.

Let's follow the lead of exynos and tegra and add code to explicitly
remove the ARM domain before attaching a new one.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
---
See also the thread[1] where I reported the regression.

[1] https://lore.kernel.org/linux-kernel/da9cca0a-ec5b-2e73-9de0-a930f7d947b2%40arm.com
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 67d38f53d3e5..13ed33e74457 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -23,6 +23,14 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
+#if defined(CONFIG_ARM_DMA_USE_IOMMU)
+#include <asm/dma-iommu.h>
+#else
+#define arm_iommu_detach_device(...)	({ })
+#define arm_iommu_release_mapping(...)	({ })
+#define to_dma_iommu_mapping(dev) NULL
+#endif
+
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_fb.h"
 #include "rockchip_drm_gem.h"
@@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
 	if (!private->domain)
 		return 0;
 
+	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
+		struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+
+		if (mapping) {
+			arm_iommu_detach_device(dev);
+			arm_iommu_release_mapping(mapping);
+		}
+	}
+
 	ret = iommu_attach_device(private->domain, dev);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
  2022-06-15 15:48 ` Steven Price
                   ` (2 preceding siblings ...)
  (?)
@ 2022-07-04 15:13 ` Tomeu Vizoso
  -1 siblings, 0 replies; 9+ messages in thread
From: Tomeu Vizoso @ 2022-07-04 15:13 UTC (permalink / raw)
  To: Steven Price
  Cc: David Airlie, Sandy Huang, dri-devel, open list,
	open list:ARM/Rockchip SoC...,
	Robin Murphy,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

Thanks, this fixes the DRM driver on 5.19-rc2 on the rk3288-veyron-jaq.

Tested-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>

Cheers,

Tomeu

On Wed, Jun 15, 2022 at 5:52 PM Steven Price <steven.price@arm.com> wrote:

> Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
> interfaces") the Rockchip display driver on the Firefly RK3288 fails to
> initialise properly. This is because ARM DMA domain is still attached.
>
> Let's follow the lead of exynos and tegra and add code to explicitly
> remove the ARM domain before attaching a new one.
>
> Suggested-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
> See also the thread[1] where I reported the regression.
>
> [1]
> https://lore.kernel.org/linux-kernel/da9cca0a-ec5b-2e73-9de0-a930f7d947b2%40arm.com
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 67d38f53d3e5..13ed33e74457 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -23,6 +23,14 @@
>  #include <drm/drm_probe_helper.h>
>  #include <drm/drm_vblank.h>
>
> +#if defined(CONFIG_ARM_DMA_USE_IOMMU)
> +#include <asm/dma-iommu.h>
> +#else
> +#define arm_iommu_detach_device(...)   ({ })
> +#define arm_iommu_release_mapping(...) ({ })
> +#define to_dma_iommu_mapping(dev) NULL
> +#endif
> +
>  #include "rockchip_drm_drv.h"
>  #include "rockchip_drm_fb.h"
>  #include "rockchip_drm_gem.h"
> @@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device
> *drm_dev,
>         if (!private->domain)
>                 return 0;
>
> +       if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
> +               struct dma_iommu_mapping *mapping =
> to_dma_iommu_mapping(dev);
> +
> +               if (mapping) {
> +                       arm_iommu_detach_device(dev);
> +                       arm_iommu_release_mapping(mapping);
> +               }
> +       }
> +
>         ret = iommu_attach_device(private->domain, dev);
>         if (ret) {
>                 DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");
> --
> 2.25.1
>
>

[-- Attachment #2: Type: text/html, Size: 3796 bytes --]

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

* Re: [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
  2022-06-15 15:48 ` Steven Price
  (?)
  (?)
@ 2022-07-04 15:31   ` Heiko Stuebner
  -1 siblings, 0 replies; 9+ messages in thread
From: Heiko Stuebner @ 2022-07-04 15:31 UTC (permalink / raw)
  To: Steven Price, Sandy Huang, David Airlie, Daniel Vetter
  Cc: Heiko Stuebner, linux-kernel, dri-devel, linux-rockchip,
	linux-arm-kernel, Robin Murphy

On Wed, 15 Jun 2022 16:48:30 +0100, Steven Price wrote:
> Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
> interfaces") the Rockchip display driver on the Firefly RK3288 fails to
> initialise properly. This is because ARM DMA domain is still attached.
> 
> Let's follow the lead of exynos and tegra and add code to explicitly
> remove the ARM domain before attaching a new one.

Applied, thanks!

[1/1] drm/rockchip: Detach from ARM DMA domain in attach_device
      commit: 8490cad4dc4e2ee265ba9e12cd47bdfd6b9a3d34

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

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

* Re: [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-07-04 15:31   ` Heiko Stuebner
  0 siblings, 0 replies; 9+ messages in thread
From: Heiko Stuebner @ 2022-07-04 15:31 UTC (permalink / raw)
  To: Steven Price, Sandy Huang, David Airlie, Daniel Vetter
  Cc: Heiko Stuebner, linux-kernel, dri-devel, linux-rockchip,
	linux-arm-kernel, Robin Murphy

On Wed, 15 Jun 2022 16:48:30 +0100, Steven Price wrote:
> Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
> interfaces") the Rockchip display driver on the Firefly RK3288 fails to
> initialise properly. This is because ARM DMA domain is still attached.
> 
> Let's follow the lead of exynos and tegra and add code to explicitly
> remove the ARM domain before attaching a new one.

Applied, thanks!

[1/1] drm/rockchip: Detach from ARM DMA domain in attach_device
      commit: 8490cad4dc4e2ee265ba9e12cd47bdfd6b9a3d34

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-07-04 15:31   ` Heiko Stuebner
  0 siblings, 0 replies; 9+ messages in thread
From: Heiko Stuebner @ 2022-07-04 15:31 UTC (permalink / raw)
  To: Steven Price, Sandy Huang, David Airlie, Daniel Vetter
  Cc: Heiko Stuebner, linux-kernel, dri-devel, linux-rockchip,
	linux-arm-kernel, Robin Murphy

On Wed, 15 Jun 2022 16:48:30 +0100, Steven Price wrote:
> Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
> interfaces") the Rockchip display driver on the Firefly RK3288 fails to
> initialise properly. This is because ARM DMA domain is still attached.
> 
> Let's follow the lead of exynos and tegra and add code to explicitly
> remove the ARM domain before attaching a new one.

Applied, thanks!

[1/1] drm/rockchip: Detach from ARM DMA domain in attach_device
      commit: 8490cad4dc4e2ee265ba9e12cd47bdfd6b9a3d34

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device
@ 2022-07-04 15:31   ` Heiko Stuebner
  0 siblings, 0 replies; 9+ messages in thread
From: Heiko Stuebner @ 2022-07-04 15:31 UTC (permalink / raw)
  To: Steven Price, Sandy Huang, David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, linux-rockchip, Robin Murphy, linux-arm-kernel

On Wed, 15 Jun 2022 16:48:30 +0100, Steven Price wrote:
> Since commit 1ea2a07a532b ("iommu: Add DMA ownership management
> interfaces") the Rockchip display driver on the Firefly RK3288 fails to
> initialise properly. This is because ARM DMA domain is still attached.
> 
> Let's follow the lead of exynos and tegra and add code to explicitly
> remove the ARM domain before attaching a new one.

Applied, thanks!

[1/1] drm/rockchip: Detach from ARM DMA domain in attach_device
      commit: 8490cad4dc4e2ee265ba9e12cd47bdfd6b9a3d34

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

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

end of thread, other threads:[~2022-07-05 11:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 15:48 [PATCH] drm/rockchip: Detach from ARM DMA domain in attach_device Steven Price
2022-06-15 15:48 ` Steven Price
2022-06-15 15:48 ` Steven Price
2022-06-15 15:48 ` Steven Price
2022-07-04 15:13 ` Tomeu Vizoso
2022-07-04 15:31 ` Heiko Stuebner
2022-07-04 15:31   ` Heiko Stuebner
2022-07-04 15:31   ` Heiko Stuebner
2022-07-04 15:31   ` Heiko Stuebner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.