All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP
@ 2016-12-09 12:35 Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 1/6] v4l: rcar-fcp: Don't get/put module reference Ulrich Hecht
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Ulrich Hecht

Hi!

This is a slightly updated version of Laurent's series that adds the fix
suggested by Magnus Damm and connects the FCP devices on M3-W to their
IPMMU. It also drops the patches that have already been picked up in the
media tree.

With this series and an assortment of patches from the renesas-drivers tree (
    iommu/ipmmu-vmsa: Remove platform data handling
    iommu/ipmmu-vmsa: Rework interrupt code and use bitmap for context
    iommu/ipmmu-vmsa: Break out utlb parsing code
    iommu/ipmmu-vmsa: Break out domain allocation code
    iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops
    iommu/ipmmu-vmsa: ARM and ARM64 archdata access
    iommu/ipmmu-vmsa: Drop LPAE Kconfig dependency
    iommu/ipmmu-vmsa: Introduce features, break out alias
    iommu/ipmmu-vmsa: Add optional root device feature
    iommu/ipmmu-vmsa: Enable multi context support
    iommu/ipmmu-vmsa: Reuse iommu groups
    iommu/ipmmu-vmsa: Make use of IOMMU_OF_DECLARE()
    iommu/ipmmu-vmsa: Teach xlate() to skip disabled iommus
    iommu/ipmmu-vmsa: IPMMU device is 64-bit bus master
    iommu/ipmmu-vmsa: Write IMCTR twice
    iommu/ipmmu-vmsa: Make IMBUSCTR setup optional
    iommu/ipmmu-vmsa: Allow two bit SL0
    iommu/ipmmu-vmsa: Hook up r8a7795 DT matching code
    iommu/ipmmu-vmsa: Add r8a7796 DT binding
    iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
    iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code
    arm64: dts: r8a7795: Add IPMMU device nodes
    arm64: dts: r8a7795: Hook up SYS-DMAC to IPMMU
    arm64: dts: r8a7795: Point FCP devices to IPMMU
    arm64: dts: r8a7795: Connect Ethernet AVB to IPMMU
    arm64: dts: r8a7796: Add IPMMU device nodes
    clk: renesas: r8a7796: Add FCP clocks
    clk: renesas: r8a7796: Add VSP clocks
    clk: renesas: r8a7796: Add DU and LVDS clocks
    drm: rcar-du: Add R8A7796 device support
    arm64: dts: renesas: r8a7795: Remove FCP SoC-specific compatible strings
    arm64: dts: renesas: r8a7796: Add FCPF and FCPV instances
    arm64: dts: renesas: r8a7796: Add VSP instances
    arm64: dts: renesas: r8a7796: Add DU device to DT
    arm64: dts: renesas: r8a7796-salvator-x: Enable DU
), I can enable IPMMU on both the H3 and M3-W Salvator-X boards with no ill
effects on the results of the vsp-tests suite.

CU
Uli


Laurent Pinchart (4):
  v4l: rcar-fcp: Don't get/put module reference
  v4l: rcar-fcp: Add an API to retrieve the FCP device
  v4l: vsp1: Add API to map and unmap DRM buffers through the VSP
  drm: rcar-du: Map memory through the VSP device

Ulrich Hecht (2):
  v4l: vsp1: Provide display list and VB2 queue with FCP device
  arm64: dts: r8a7796: Connect FCP devices to IPMMU

 arch/arm64/boot/dts/renesas/r8a7796.dtsi |  3 ++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c    | 74 +++++++++++++++++++++++++++++---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h    |  2 +
 drivers/media/platform/rcar-fcp.c        | 17 ++++----
 drivers/media/platform/vsp1/vsp1_dl.c    | 12 ++++--
 drivers/media/platform/vsp1/vsp1_drm.c   | 24 +++++++++++
 drivers/media/platform/vsp1/vsp1_video.c |  6 ++-
 include/media/rcar-fcp.h                 |  5 +++
 include/media/vsp1.h                     |  3 ++
 9 files changed, 127 insertions(+), 19 deletions(-)

-- 
2.7.4


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

* [PATCH v1.5 1/6] v4l: rcar-fcp: Don't get/put module reference
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
@ 2016-12-09 12:35 ` Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 2/6] v4l: rcar-fcp: Add an API to retrieve the FCP device Ulrich Hecht
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Laurent Pinchart

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Direct callers of the FCP API hold a reference to the FCP module due to
module linkage, there's no need to take another one manually. Take a
reference to the device instead to ensure that it won't disappear behind
the caller's back.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/rcar-fcp.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
index 7146fc5..e9f609e 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -53,14 +53,7 @@ struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np)
 		if (fcp->dev->of_node != np)
 			continue;
 
-		/*
-		 * Make sure the module won't be unloaded behind our back. This
-		 * is a poor man's safety net, the module should really not be
-		 * unloaded while FCP users can be active.
-		 */
-		if (!try_module_get(fcp->dev->driver->owner))
-			fcp = NULL;
-
+		get_device(fcp->dev);
 		goto done;
 	}
 
@@ -81,7 +74,7 @@ EXPORT_SYMBOL_GPL(rcar_fcp_get);
 void rcar_fcp_put(struct rcar_fcp_device *fcp)
 {
 	if (fcp)
-		module_put(fcp->dev->driver->owner);
+		put_device(fcp->dev);
 }
 EXPORT_SYMBOL_GPL(rcar_fcp_put);
 
-- 
2.7.4


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

* [PATCH v1.5 2/6] v4l: rcar-fcp: Add an API to retrieve the FCP device
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 1/6] v4l: rcar-fcp: Don't get/put module reference Ulrich Hecht
@ 2016-12-09 12:35 ` Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 3/6] v4l: vsp1: Add API to map and unmap DRM buffers through the VSP Ulrich Hecht
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Laurent Pinchart

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

The new rcar_fcp_get_device() function retrieves the struct device
related to the FCP device. This is useful to handle DMA mapping through
the right device.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/rcar-fcp.c | 6 ++++++
 include/media/rcar-fcp.h          | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
index e9f609e..2988031 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -78,6 +78,12 @@ void rcar_fcp_put(struct rcar_fcp_device *fcp)
 }
 EXPORT_SYMBOL_GPL(rcar_fcp_put);
 
+struct device *rcar_fcp_get_device(struct rcar_fcp_device *fcp)
+{
+	return fcp->dev;
+}
+EXPORT_SYMBOL_GPL(rcar_fcp_get_device);
+
 /**
  * rcar_fcp_enable - Enable an FCP
  * @fcp: The FCP instance
diff --git a/include/media/rcar-fcp.h b/include/media/rcar-fcp.h
index 8723f05..b60a7b1 100644
--- a/include/media/rcar-fcp.h
+++ b/include/media/rcar-fcp.h
@@ -19,6 +19,7 @@ struct rcar_fcp_device;
 #if IS_ENABLED(CONFIG_VIDEO_RENESAS_FCP)
 struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np);
 void rcar_fcp_put(struct rcar_fcp_device *fcp);
+struct device *rcar_fcp_get_device(struct rcar_fcp_device *fcp);
 int rcar_fcp_enable(struct rcar_fcp_device *fcp);
 void rcar_fcp_disable(struct rcar_fcp_device *fcp);
 #else
@@ -27,6 +28,10 @@ static inline struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np)
 	return ERR_PTR(-ENOENT);
 }
 static inline void rcar_fcp_put(struct rcar_fcp_device *fcp) { }
+static inline struct device *rcar_fcp_get_device(struct rcar_fcp_device *fcp)
+{
+	return NULL;
+}
 static inline int rcar_fcp_enable(struct rcar_fcp_device *fcp)
 {
 	return 0;
-- 
2.7.4


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

* [PATCH v1.5 3/6] v4l: vsp1: Add API to map and unmap DRM buffers through the VSP
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 1/6] v4l: rcar-fcp: Don't get/put module reference Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 2/6] v4l: rcar-fcp: Add an API to retrieve the FCP device Ulrich Hecht
@ 2016-12-09 12:35 ` Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 4/6] drm: rcar-du: Map memory through the VSP device Ulrich Hecht
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Laurent Pinchart

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

The display buffers must be mapped for DMA through the device that
performs memory access. Expose an API to map and unmap memory through
the VSP device to be used by the DU.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 24 ++++++++++++++++++++++++
 include/media/vsp1.h                   |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index cd209dc..bb35603 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -12,9 +12,11 @@
  */
 
 #include <linux/device.h>
+#include <linux/dma-mapping.h>
 #include <linux/slab.h>
 
 #include <media/media-entity.h>
+#include <media/rcar-fcp.h>
 #include <media/v4l2-subdev.h>
 #include <media/vsp1.h>
 
@@ -519,6 +521,28 @@ void vsp1_du_atomic_flush(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
 
+int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt)
+{
+	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+	struct device *map_dev;
+
+	map_dev = vsp1->fcp ? rcar_fcp_get_device(vsp1->fcp) : dev;
+
+	return dma_map_sg(map_dev, sgt->sgl, sgt->nents, DMA_TO_DEVICE);
+}
+EXPORT_SYMBOL_GPL(vsp1_du_map_sg);
+
+void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt)
+{
+	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+	struct device *map_dev;
+
+	map_dev = vsp1->fcp ? rcar_fcp_get_device(vsp1->fcp) : dev;
+
+	dma_unmap_sg(map_dev, sgt->sgl, sgt->nents, DMA_TO_DEVICE);
+}
+EXPORT_SYMBOL_GPL(vsp1_du_unmap_sg);
+
 /* -----------------------------------------------------------------------------
  * Initialization
  */
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index 458b400..8d3d07a 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -13,6 +13,7 @@
 #ifndef __MEDIA_VSP1_H__
 #define __MEDIA_VSP1_H__
 
+#include <linux/scatterlist.h>
 #include <linux/types.h>
 #include <linux/videodev2.h>
 
@@ -37,5 +38,7 @@ void vsp1_du_atomic_begin(struct device *dev);
 int vsp1_du_atomic_update(struct device *dev, unsigned int rpf,
 			  const struct vsp1_du_atomic_config *cfg);
 void vsp1_du_atomic_flush(struct device *dev);
+int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt);
+void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt);
 
 #endif /* __MEDIA_VSP1_H__ */
-- 
2.7.4


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

* [PATCH v1.5 4/6] drm: rcar-du: Map memory through the VSP device
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
                   ` (2 preceding siblings ...)
  2016-12-09 12:35 ` [PATCH v1.5 3/6] v4l: vsp1: Add API to map and unmap DRM buffers through the VSP Ulrich Hecht
@ 2016-12-09 12:35 ` Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 5/6] v4l: vsp1: Provide display list and VB2 queue with FCP device Ulrich Hecht
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Laurent Pinchart

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

For planes handled by a VSP instance, map the framebuffer memory through
the VSP to ensure proper IOMMU handling.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 74 ++++++++++++++++++++++++++++++++---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h |  2 +
 2 files changed, 70 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 83ebd16..851c2e7 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -19,7 +19,9 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_plane_helper.h>
 
+#include <linux/dma-mapping.h>
 #include <linux/of_platform.h>
+#include <linux/scatterlist.h>
 #include <linux/videodev2.h>
 
 #include <media/vsp1.h>
@@ -166,12 +168,9 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 	cfg.dst.width = state->state.crtc_w;
 	cfg.dst.height = state->state.crtc_h;
 
-	for (i = 0; i < state->format->planes; ++i) {
-		struct drm_gem_cma_object *gem;
-
-		gem = drm_fb_cma_get_gem_obj(fb, i);
-		cfg.mem[i] = gem->paddr + fb->offsets[i];
-	}
+	for (i = 0; i < state->format->planes; ++i)
+		cfg.mem[i] = sg_dma_address(state->sg_tables[i].sgl)
+			   + fb->offsets[i];
 
 	for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {
 		if (formats_kms[i] == state->format->fourcc) {
@@ -183,6 +182,67 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 	vsp1_du_atomic_update(plane->vsp->vsp, plane->index, &cfg);
 }
 
+static int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane,
+					struct drm_plane_state *state)
+{
+	struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
+	struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp;
+	struct rcar_du_device *rcdu = vsp->dev;
+	unsigned int i;
+	int ret;
+
+	if (!state->fb)
+		return 0;
+
+	for (i = 0; i < rstate->format->planes; ++i) {
+		struct drm_gem_cma_object *gem =
+			drm_fb_cma_get_gem_obj(state->fb, i);
+		struct sg_table *sgt = &rstate->sg_tables[i];
+
+		ret = dma_get_sgtable(rcdu->dev, sgt, gem->vaddr, gem->paddr,
+				      gem->base.size);
+		if (ret)
+			goto fail;
+
+		ret = vsp1_du_map_sg(vsp->vsp, sgt);
+		if (!ret) {
+			sg_free_table(sgt);
+			ret = -ENOMEM;
+			goto fail;
+		}
+	}
+
+	return 0;
+
+fail:
+	for (i--; i >= 0; i--) {
+		struct sg_table *sgt = &rstate->sg_tables[i];
+
+		vsp1_du_unmap_sg(vsp->vsp, sgt);
+		sg_free_table(sgt);
+	}
+
+	return ret;
+}
+
+static void rcar_du_vsp_plane_cleanup_fb(struct drm_plane *plane,
+					 struct drm_plane_state *state)
+{
+	struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
+	struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp;
+	unsigned int i;
+
+	if (!state->fb)
+		return;
+
+	for (i = 0; i < rstate->format->planes; ++i) {
+		struct sg_table *sgt = &rstate->sg_tables[i];
+
+		vsp1_du_unmap_sg(vsp->vsp, sgt);
+		sg_free_table(sgt);
+	}
+}
+
 static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
 					  struct drm_plane_state *state)
 {
@@ -223,6 +283,8 @@ static void rcar_du_vsp_plane_atomic_update(struct drm_plane *plane,
 }
 
 static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = {
+	.prepare_fb = rcar_du_vsp_plane_prepare_fb,
+	.cleanup_fb = rcar_du_vsp_plane_cleanup_fb,
 	.atomic_check = rcar_du_vsp_plane_atomic_check,
 	.atomic_update = rcar_du_vsp_plane_atomic_update,
 };
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
index 510dcc9..bbb4161 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
@@ -43,6 +43,7 @@ static inline struct rcar_du_vsp_plane *to_rcar_vsp_plane(struct drm_plane *p)
  * struct rcar_du_vsp_plane_state - Driver-specific plane state
  * @state: base DRM plane state
  * @format: information about the pixel format used by the plane
+ * @sg_tables: scatter-gather tables for the frame buffer memory
  * @alpha: value of the plane alpha property
  * @zpos: value of the plane zpos property
  */
@@ -50,6 +51,7 @@ struct rcar_du_vsp_plane_state {
 	struct drm_plane_state state;
 
 	const struct rcar_du_format_info *format;
+	struct sg_table sg_tables[3];
 
 	unsigned int alpha;
 	unsigned int zpos;
-- 
2.7.4


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

* [PATCH v1.5 5/6] v4l: vsp1: Provide display list and VB2 queue with FCP device
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
                   ` (3 preceding siblings ...)
  2016-12-09 12:35 ` [PATCH v1.5 4/6] drm: rcar-du: Map memory through the VSP device Ulrich Hecht
@ 2016-12-09 12:35 ` Ulrich Hecht
  2016-12-09 12:35 ` [PATCH v1.5 6/6] arm64: dts: r8a7796: Connect FCP devices to IPMMU Ulrich Hecht
  2017-08-30  8:46 ` [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Simon Horman
  6 siblings, 0 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Ulrich Hecht

Prevents IPMMU trap during boot on r8a7795/6 Salvator-X boards:
ipmmu-vmsa febd0000.mmu: Unhandled faut: status 0x00000101 iova 0x7f09a000

Code by Magnus Damm.

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
 drivers/media/platform/vsp1/vsp1_dl.c    | 12 +++++++++---
 drivers/media/platform/vsp1/vsp1_video.c |  6 +++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
index ad545af..f610c88 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -17,6 +17,8 @@
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 
+#include <media/rcar-fcp.h>
+
 #include "vsp1.h"
 #include "vsp1_dl.h"
 
@@ -133,12 +135,13 @@ static int vsp1_dl_body_init(struct vsp1_device *vsp1,
 			     size_t extra_size)
 {
 	size_t size = num_entries * sizeof(*dlb->entries) + extra_size;
+	struct device *fcp = rcar_fcp_get_device(vsp1->fcp);
 
 	dlb->vsp1 = vsp1;
 	dlb->size = size;
 
-	dlb->entries = dma_alloc_wc(vsp1->dev, dlb->size, &dlb->dma,
-				    GFP_KERNEL);
+	dlb->entries = dma_alloc_wc(fcp ? fcp : vsp1->dev,
+				    dlb->size, &dlb->dma, GFP_KERNEL);
 	if (!dlb->entries)
 		return -ENOMEM;
 
@@ -150,7 +153,10 @@ static int vsp1_dl_body_init(struct vsp1_device *vsp1,
  */
 static void vsp1_dl_body_cleanup(struct vsp1_dl_body *dlb)
 {
-	dma_free_wc(dlb->vsp1->dev, dlb->size, dlb->entries, dlb->dma);
+	struct device *fcp = rcar_fcp_get_device(dlb->vsp1->fcp);
+
+	dma_free_wc(fcp ? fcp : dlb->vsp1->dev,
+		    dlb->size, dlb->entries, dlb->dma);
 }
 
 /**
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 41e8b09..8f8e57e 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -27,6 +27,8 @@
 #include <media/videobuf2-v4l2.h>
 #include <media/videobuf2-dma-contig.h>
 
+#include <media/rcar-fcp.h>
+
 #include "vsp1.h"
 #include "vsp1_bru.h"
 #include "vsp1_dl.h"
@@ -1094,6 +1096,7 @@ struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
 {
 	struct vsp1_video *video;
 	const char *direction;
+	struct device *fcp;
 	int ret;
 
 	video = devm_kzalloc(vsp1->dev, sizeof(*video), GFP_KERNEL);
@@ -1151,7 +1154,8 @@ struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
 	video->queue.ops = &vsp1_video_queue_qops;
 	video->queue.mem_ops = &vb2_dma_contig_memops;
 	video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
-	video->queue.dev = video->vsp1->dev;
+	fcp = rcar_fcp_get_device(vsp1->fcp);
+	video->queue.dev = fcp ? fcp : video->vsp1->dev;
 	ret = vb2_queue_init(&video->queue);
 	if (ret < 0) {
 		dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n");
-- 
2.7.4


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

* [PATCH v1.5 6/6] arm64: dts: r8a7796: Connect FCP devices to IPMMU
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
                   ` (4 preceding siblings ...)
  2016-12-09 12:35 ` [PATCH v1.5 5/6] v4l: vsp1: Provide display list and VB2 queue with FCP device Ulrich Hecht
@ 2016-12-09 12:35 ` Ulrich Hecht
  2017-08-30  8:46 ` [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Simon Horman
  6 siblings, 0 replies; 8+ messages in thread
From: Ulrich Hecht @ 2016-12-09 12:35 UTC (permalink / raw)
  To: linux-renesas-soc
  Cc: laurent.pinchart, dri-devel, linux-media, magnus.damm, Ulrich Hecht

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index 52e81bb..f5496d4 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -440,6 +440,7 @@
 			reg = <0 0xfea27000 0 0x200>;
 			clocks = <&cpg CPG_MOD 603>;
 			power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+			iommus = <&ipmmu_vi 8>;
 		};
 
 		vspd1: vsp@fea28000 {
@@ -457,6 +458,7 @@
 			reg = <0 0xfea2f000 0 0x200>;
 			clocks = <&cpg CPG_MOD 602>;
 			power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+			iommus = <&ipmmu_vi 9>;
 		};
 
 		vspd2: vsp@fea30000 {
@@ -474,6 +476,7 @@
 			reg = <0 0xfea37000 0 0x200>;
 			clocks = <&cpg CPG_MOD 601>;
 			power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+			iommus = <&ipmmu_vi 10>;
 		};
 
 		du: display@feb00000 {
-- 
2.7.4


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

* Re: [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP
  2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
                   ` (5 preceding siblings ...)
  2016-12-09 12:35 ` [PATCH v1.5 6/6] arm64: dts: r8a7796: Connect FCP devices to IPMMU Ulrich Hecht
@ 2017-08-30  8:46 ` Simon Horman
  6 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2017-08-30  8:46 UTC (permalink / raw)
  To: Ulrich Hecht
  Cc: linux-renesas-soc, laurent.pinchart, dri-devel, linux-media, magnus.damm

On Fri, Dec 09, 2016 at 01:35:06PM +0100, Ulrich Hecht wrote:
> Hi!
> 
> This is a slightly updated version of Laurent's series that adds the fix
> suggested by Magnus Damm and connects the FCP devices on M3-W to their
> IPMMU. It also drops the patches that have already been picked up in the
> media tree.
> 
> With this series and an assortment of patches from the renesas-drivers tree (
>     iommu/ipmmu-vmsa: Remove platform data handling
>     iommu/ipmmu-vmsa: Rework interrupt code and use bitmap for context
>     iommu/ipmmu-vmsa: Break out utlb parsing code
>     iommu/ipmmu-vmsa: Break out domain allocation code
>     iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops
>     iommu/ipmmu-vmsa: ARM and ARM64 archdata access
>     iommu/ipmmu-vmsa: Drop LPAE Kconfig dependency
>     iommu/ipmmu-vmsa: Introduce features, break out alias
>     iommu/ipmmu-vmsa: Add optional root device feature
>     iommu/ipmmu-vmsa: Enable multi context support
>     iommu/ipmmu-vmsa: Reuse iommu groups
>     iommu/ipmmu-vmsa: Make use of IOMMU_OF_DECLARE()
>     iommu/ipmmu-vmsa: Teach xlate() to skip disabled iommus
>     iommu/ipmmu-vmsa: IPMMU device is 64-bit bus master
>     iommu/ipmmu-vmsa: Write IMCTR twice
>     iommu/ipmmu-vmsa: Make IMBUSCTR setup optional
>     iommu/ipmmu-vmsa: Allow two bit SL0
>     iommu/ipmmu-vmsa: Hook up r8a7795 DT matching code
>     iommu/ipmmu-vmsa: Add r8a7796 DT binding
>     iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
>     iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code
>     arm64: dts: r8a7795: Add IPMMU device nodes
>     arm64: dts: r8a7795: Hook up SYS-DMAC to IPMMU
>     arm64: dts: r8a7795: Point FCP devices to IPMMU
>     arm64: dts: r8a7795: Connect Ethernet AVB to IPMMU
>     arm64: dts: r8a7796: Add IPMMU device nodes
>     clk: renesas: r8a7796: Add FCP clocks
>     clk: renesas: r8a7796: Add VSP clocks
>     clk: renesas: r8a7796: Add DU and LVDS clocks
>     drm: rcar-du: Add R8A7796 device support
>     arm64: dts: renesas: r8a7795: Remove FCP SoC-specific compatible strings
>     arm64: dts: renesas: r8a7796: Add FCPF and FCPV instances
>     arm64: dts: renesas: r8a7796: Add VSP instances
>     arm64: dts: renesas: r8a7796: Add DU device to DT
>     arm64: dts: renesas: r8a7796-salvator-x: Enable DU
> ), I can enable IPMMU on both the H3 and M3-W Salvator-X boards with no ill
> effects on the results of the vsp-tests suite.
> 
> CU
> Uli
> 
> 
> Laurent Pinchart (4):
>   v4l: rcar-fcp: Don't get/put module reference
>   v4l: rcar-fcp: Add an API to retrieve the FCP device
>   v4l: vsp1: Add API to map and unmap DRM buffers through the VSP
>   drm: rcar-du: Map memory through the VSP device
> 
> Ulrich Hecht (2):
>   v4l: vsp1: Provide display list and VB2 queue with FCP device
>   arm64: dts: r8a7796: Connect FCP devices to IPMMU

Hi Ulrich,

I am wondering what the status of this work is.

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

end of thread, other threads:[~2017-08-30  8:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-09 12:35 [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Ulrich Hecht
2016-12-09 12:35 ` [PATCH v1.5 1/6] v4l: rcar-fcp: Don't get/put module reference Ulrich Hecht
2016-12-09 12:35 ` [PATCH v1.5 2/6] v4l: rcar-fcp: Add an API to retrieve the FCP device Ulrich Hecht
2016-12-09 12:35 ` [PATCH v1.5 3/6] v4l: vsp1: Add API to map and unmap DRM buffers through the VSP Ulrich Hecht
2016-12-09 12:35 ` [PATCH v1.5 4/6] drm: rcar-du: Map memory through the VSP device Ulrich Hecht
2016-12-09 12:35 ` [PATCH v1.5 5/6] v4l: vsp1: Provide display list and VB2 queue with FCP device Ulrich Hecht
2016-12-09 12:35 ` [PATCH v1.5 6/6] arm64: dts: r8a7796: Connect FCP devices to IPMMU Ulrich Hecht
2017-08-30  8:46 ` [PATCH v1.5 0/6] R-Car DU: Fix IOMMU operation when connected to VSP Simon Horman

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.