dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset
@ 2020-11-06 15:14 Maxime Ripard
  2020-11-06 15:14 ` [PATCH 1/7] drm/sun4i: backend: Fix probe failure with multiple backends Maxime Ripard
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

Hi,

Here's an attempt to removing the dma_direct_set_offset calls we have in
numerous drivers and move all those quirks into a global notifier as suggested
by Robin.

Let me know what you think,
Maxime

Maxime Ripard (7):
  drm/sun4i: backend: Fix probe failure with multiple backends
  soc: sunxi: Deal with the MBUS DMA offsets in a central place
  drm/sun4i: backend: Remove the MBUS quirks
  media: sun4i: Remove the MBUS quirks
  media: sun6i: Remove the MBUS quirks
  media: cedrus: Remove the MBUS quirks
  media: sun8i-di: Remove the call to of_dma_configure

 drivers/gpu/drm/sun4i/sun4i_backend.c         |  13 --
 .../platform/sunxi/sun4i-csi/sun4i_csi.c      |  27 ----
 .../platform/sunxi/sun6i-csi/sun6i_csi.c      |  17 ---
 .../media/platform/sunxi/sun8i-di/sun8i-di.c  |   4 -
 drivers/soc/sunxi/Kconfig                     |   8 ++
 drivers/soc/sunxi/Makefile                    |   1 +
 drivers/soc/sunxi/sunxi_mbus.c                | 132 ++++++++++++++++++
 drivers/staging/media/sunxi/cedrus/cedrus.c   |   1 -
 drivers/staging/media/sunxi/cedrus/cedrus.h   |   3 -
 .../staging/media/sunxi/cedrus/cedrus_hw.c    |  18 ---
 10 files changed, 141 insertions(+), 83 deletions(-)
 create mode 100644 drivers/soc/sunxi/sunxi_mbus.c

-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 1/7] drm/sun4i: backend: Fix probe failure with multiple backends
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 15:14 ` [PATCH 2/7] soc: sunxi: Deal with the MBUS DMA offsets in a central place Maxime Ripard
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

Commit e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting
dma_pfn_offset") introduced a regression in our code since the second
backed to probe will now get -EINVAL back from dma_direct_set_offset and
will prevent the entire DRM device from probing.

Ignore -EINVAL as a temporary measure to get it back working, before
removing that call entirely.

Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 77497b45f9a2..55960cbb1019 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -814,9 +814,15 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
 		 *
 		 * XXX(hch): this has no business in a driver and needs to move
 		 * to the device tree.
+		 *
+		 * If we have two subsequent calls to dma_direct_set_offset
+		 * returns -EINVAL. Unfortunately, this happens when we have two
+		 * backends in the system, and will result in the driver
+		 * reporting an error while it has been setup properly before.
+		 * Ignore EINVAL, but it should really be removed eventually.
 		 */
 		ret = dma_direct_set_offset(drm->dev, PHYS_OFFSET, 0, SZ_4G);
-		if (ret)
+		if (ret && ret != -EINVAL)
 			return ret;
 	}
 
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 2/7] soc: sunxi: Deal with the MBUS DMA offsets in a central place
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
  2020-11-06 15:14 ` [PATCH 1/7] drm/sun4i: backend: Fix probe failure with multiple backends Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 15:14 ` [PATCH 3/7] drm/sun4i: backend: Remove the MBUS quirks Maxime Ripard
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

So far most of the drivers with the MBUS quirks had to duplicate the
code to deal with DT compatibility and enforcing the DMA offsets.

Let's move for a more maintainable solution by putting everything in a
notifier that would take care of setting up the DMA offsets for all the
MBUS devices.

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/soc/sunxi/Kconfig      |   8 ++
 drivers/soc/sunxi/Makefile     |   1 +
 drivers/soc/sunxi/sunxi_mbus.c | 132 +++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
 create mode 100644 drivers/soc/sunxi/sunxi_mbus.c

diff --git a/drivers/soc/sunxi/Kconfig b/drivers/soc/sunxi/Kconfig
index f10fd6cae13e..1fef0e711056 100644
--- a/drivers/soc/sunxi/Kconfig
+++ b/drivers/soc/sunxi/Kconfig
@@ -2,6 +2,14 @@
 #
 # Allwinner sunXi SoC drivers
 #
+
+config SUNXI_MBUS
+	bool
+	default ARCH_SUNXI
+	help
+	  Say y to enable the fixups needed to support the Allwinner
+	  MBUS DMA quirks.
+
 config SUNXI_SRAM
 	bool
 	default ARCH_SUNXI
diff --git a/drivers/soc/sunxi/Makefile b/drivers/soc/sunxi/Makefile
index 7816fbbec387..549159571d4f 100644
--- a/drivers/soc/sunxi/Makefile
+++ b/drivers/soc/sunxi/Makefile
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_SUNXI_MBUS) +=	sunxi_mbus.o
 obj-$(CONFIG_SUNXI_SRAM) +=	sunxi_sram.o
diff --git a/drivers/soc/sunxi/sunxi_mbus.c b/drivers/soc/sunxi/sunxi_mbus.c
new file mode 100644
index 000000000000..a9d077f73c3a
--- /dev/null
+++ b/drivers/soc/sunxi/sunxi_mbus.c
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2020 Maxime Ripard <maxime@cerno.tech> */
+
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/init.h>
+#include <linux/notifier.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+static const char * const sunxi_mbus_devices[] = {
+	/*
+	 * The display engine virtual devices are not strictly speaking
+	 * connected to the MBUS, but since DRM will perform all the
+	 * memory allocations and DMA operations through that device, we
+	 * need to have the quirk on those devices too.
+	 */
+	"allwinner,sun4i-a10-display-engine",
+	"allwinner,sun5i-a10s-display-engine",
+	"allwinner,sun5i-a13-display-engine",
+	"allwinner,sun6i-a31-display-engine",
+	"allwinner,sun6i-a31s-display-engine",
+	"allwinner,sun7i-a20-display-engine",
+	"allwinner,sun8i-a23-display-engine",
+	"allwinner,sun8i-a33-display-engine",
+	"allwinner,sun8i-a83t-display-engine",
+	"allwinner,sun8i-h3-display-engine",
+	"allwinner,sun8i-r40-display-engine",
+	"allwinner,sun8i-v3s-display-engine",
+	"allwinner,sun9i-a80-display-engine",
+	"allwinner,sun50i-a64-display-engine",
+
+	/*
+	 * And now we have the regular devices connected to the MBUS
+	 * (that we know of).
+	 */
+	"allwinner,sun4i-a10-csi1",
+	"allwinner,sun4i-a10-display-backend",
+	"allwinner,sun4i-a10-display-frontend",
+	"allwinner,sun4i-a10-video-engine",
+	"allwinner,sun5i-a13-display-backend",
+	"allwinner,sun5i-a13-video-engine",
+	"allwinner,sun6i-a31-csi",
+	"allwinner,sun6i-a31-display-backend",
+	"allwinner,sun7i-a20-csi0",
+	"allwinner,sun7i-a20-display-backend",
+	"allwinner,sun7i-a20-display-frontend",
+	"allwinner,sun7i-a20-video-engine",
+	"allwinner,sun8i-a23-display-backend",
+	"allwinner,sun8i-a23-display-frontend",
+	"allwinner,sun8i-a33-display-backend",
+	"allwinner,sun8i-a33-display-frontend",
+	"allwinner,sun8i-a33-video-engine",
+	"allwinner,sun8i-a83t-csi",
+	"allwinner,sun8i-h3-csi",
+	"allwinner,sun8i-h3-video-engine",
+	"allwinner,sun8i-v3s-csi",
+	"allwinner,sun9i-a80-display-backend",
+	"allwinner,sun50i-a64-csi",
+	"allwinner,sun50i-a64-video-engine",
+	"allwinner,sun50i-h5-video-engine",
+	NULL,
+};
+
+static int sunxi_mbus_notifier(struct notifier_block *nb,
+			       unsigned long event, void *__dev)
+{
+	struct device *dev = __dev;
+	int ret;
+
+	if (event != BUS_NOTIFY_ADD_DEVICE)
+		return NOTIFY_DONE;
+
+	/*
+	 * Only the devices that need a large memory bandwidth do DMA
+	 * directly over the memory bus (called MBUS), instead of going
+	 * through the regular system bus.
+	 */
+	if (!of_device_compatible_match(dev->of_node, sunxi_mbus_devices))
+		return NOTIFY_DONE;
+
+	/*
+	 * Devices with an interconnects property have the MBUS
+	 * relationship described in their DT and dealt with by
+	 * of_dma_configure, so we can just skip them.
+	 *
+	 * Older DTs or SoCs who are not clearly understood need to set
+	 * that DMA offset though.
+	 */
+	if (of_find_property(dev->of_node, "interconnects", NULL))
+		return NOTIFY_DONE;
+
+	ret = dma_direct_set_offset(dev, PHYS_OFFSET, 0, SZ_4G);
+	if (ret)
+		dev_err(dev, "Couldn't setup our DMA offset: %d\n", ret);
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block sunxi_mbus_nb = {
+	.notifier_call = sunxi_mbus_notifier,
+};
+
+static const char * const sunxi_mbus_platforms[] __initconst = {
+	"allwinner,sun4i-a10",
+	"allwinner,sun5i-a10s",
+	"allwinner,sun5i-a13",
+	"allwinner,sun6i-a31",
+	"allwinner,sun7i-a20",
+	"allwinner,sun8i-a23",
+	"allwinner,sun8i-a33",
+	"allwinner,sun8i-a83t",
+	"allwinner,sun8i-h3",
+	"allwinner,sun8i-r40",
+	"allwinner,sun8i-v3",
+	"allwinner,sun8i-v3s",
+	"allwinner,sun9i-a80",
+	"allwinner,sun50i-a64",
+	"allwinner,sun50i-h5",
+	"nextthing,gr8",
+	NULL,
+};
+
+static int __init sunxi_mbus_init(void)
+{
+	if (!of_device_compatible_match(of_root, sunxi_mbus_platforms))
+		return 0;
+
+	bus_register_notifier(&platform_bus_type, &sunxi_mbus_nb);
+	return 0;
+}
+arch_initcall(sunxi_mbus_init);
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 3/7] drm/sun4i: backend: Remove the MBUS quirks
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
  2020-11-06 15:14 ` [PATCH 1/7] drm/sun4i: backend: Fix probe failure with multiple backends Maxime Ripard
  2020-11-06 15:14 ` [PATCH 2/7] soc: sunxi: Deal with the MBUS DMA offsets in a central place Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 15:14 ` [PATCH 4/7] media: sun4i: " Maxime Ripard
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

Now that the MBUS quirks are applied by our global notifier, we can
remove them from our DRM driver.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 55960cbb1019..522e51a404cc 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -805,25 +805,6 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
 		ret = of_dma_configure(drm->dev, dev->of_node, true);
 		if (ret)
 			return ret;
-	} else {
-		/*
-		 * If we don't have the interconnect property, most likely
-		 * because of an old DT, we need to set the DMA offset by hand
-		 * on our device since the RAM mapping is at 0 for the DMA bus,
-		 * unlike the CPU.
-		 *
-		 * XXX(hch): this has no business in a driver and needs to move
-		 * to the device tree.
-		 *
-		 * If we have two subsequent calls to dma_direct_set_offset
-		 * returns -EINVAL. Unfortunately, this happens when we have two
-		 * backends in the system, and will result in the driver
-		 * reporting an error while it has been setup properly before.
-		 * Ignore EINVAL, but it should really be removed eventually.
-		 */
-		ret = dma_direct_set_offset(drm->dev, PHYS_OFFSET, 0, SZ_4G);
-		if (ret && ret != -EINVAL)
-			return ret;
 	}
 
 	backend->engine.node = dev->of_node;
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 4/7] media: sun4i: Remove the MBUS quirks
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
                   ` (2 preceding siblings ...)
  2020-11-06 15:14 ` [PATCH 3/7] drm/sun4i: backend: Remove the MBUS quirks Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 15:14 ` [PATCH 5/7] media: sun6i: " Maxime Ripard
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

Now that the MBUS quirks are applied by our global notifier, we can
remove them from our CSI driver for the A10.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 .../platform/sunxi/sun4i-csi/sun4i_csi.c      | 27 -------------------
 1 file changed, 27 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
index eb15c8c725ca..ec46cff80fdb 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
@@ -167,33 +167,6 @@ static int sun4i_csi_probe(struct platform_device *pdev)
 	if (!csi->traits)
 		return -EINVAL;
 
-	/*
-	 * On Allwinner SoCs, some high memory bandwidth devices do DMA
-	 * directly over the memory bus (called MBUS), instead of the
-	 * system bus. The memory bus has a different addressing scheme
-	 * without the DRAM starting offset.
-	 *
-	 * In some cases this can be described by an interconnect in
-	 * the device tree. In other cases where the hardware is not
-	 * fully understood and the interconnect is left out of the
-	 * device tree, fall back to a default offset.
-	 */
-	if (of_find_property(csi->dev->of_node, "interconnects", NULL)) {
-		ret = of_dma_configure(csi->dev, csi->dev->of_node, true);
-		if (ret)
-			return ret;
-	} else {
-		/*
-		 * XXX(hch): this has no business in a driver and needs to move
-		 * to the device tree.
-		 */
-#ifdef PHYS_PFN_OFFSET
-		ret = dma_direct_set_offset(csi->dev, PHYS_OFFSET, 0, SZ_4G);
-		if (ret)
-			return ret;
-#endif
-	}
-
 	csi->mdev.dev = csi->dev;
 	strscpy(csi->mdev.model, "Allwinner Video Capture Device",
 		sizeof(csi->mdev.model));
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 5/7] media: sun6i: Remove the MBUS quirks
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
                   ` (3 preceding siblings ...)
  2020-11-06 15:14 ` [PATCH 4/7] media: sun4i: " Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 15:14 ` [PATCH 6/7] media: cedrus: " Maxime Ripard
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

Now that the MBUS quirks are applied by our global notifier, we can
remove them from our CSI driver for the A31.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 .../media/platform/sunxi/sun6i-csi/sun6i_csi.c  | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index e69e14379fc6..27935f1e9555 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -881,14 +881,6 @@ static int sun6i_csi_resource_request(struct sun6i_csi_dev *sdev,
 	return 0;
 }
 
-/*
- * PHYS_OFFSET isn't available on all architectures. In order to
- * accommodate for COMPILE_TEST, let's define it to something dumb.
- */
-#if defined(CONFIG_COMPILE_TEST) && !defined(PHYS_OFFSET)
-#define PHYS_OFFSET 0
-#endif
-
 static int sun6i_csi_probe(struct platform_device *pdev)
 {
 	struct sun6i_csi_dev *sdev;
@@ -899,15 +891,6 @@ static int sun6i_csi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	sdev->dev = &pdev->dev;
-	/*
-	 * The DMA bus has the memory mapped at 0.
-	 *
-	 * XXX(hch): this has no business in a driver and needs to move
-	 * to the device tree.
-	 */
-	ret = dma_direct_set_offset(sdev->dev, PHYS_OFFSET, 0, SZ_4G);
-	if (ret)
-		return ret;
 
 	ret = sun6i_csi_resource_request(sdev, pdev);
 	if (ret)
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 6/7] media: cedrus: Remove the MBUS quirks
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
                   ` (4 preceding siblings ...)
  2020-11-06 15:14 ` [PATCH 5/7] media: sun6i: " Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 15:14 ` [PATCH 7/7] media: sun8i-di: Remove the call to of_dma_configure Maxime Ripard
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

Now that the MBUS quirks are applied by our global notifier, we can
remove them from Cedrus. Since the only quirk was whether or not we had
to apply that DMA quirk, we can also remove the quirks infrastructure.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/staging/media/sunxi/cedrus/cedrus.c    |  1 -
 drivers/staging/media/sunxi/cedrus/cedrus.h    |  3 ---
 drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 18 ------------------
 3 files changed, 22 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index e0e35502e34a..d5fca10ea5b4 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -523,7 +523,6 @@ static const struct cedrus_variant sun50i_h5_cedrus_variant = {
 static const struct cedrus_variant sun50i_h6_cedrus_variant = {
 	.capabilities	= CEDRUS_CAPABILITY_UNTILED |
 			  CEDRUS_CAPABILITY_H265_DEC,
-	.quirks		= CEDRUS_QUIRK_NO_DMA_OFFSET,
 	.mod_rate	= 600000000,
 };
 
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h
index 93c843ae14bb..626090a5811c 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
@@ -29,8 +29,6 @@
 #define CEDRUS_CAPABILITY_UNTILED	BIT(0)
 #define CEDRUS_CAPABILITY_H265_DEC	BIT(1)
 
-#define CEDRUS_QUIRK_NO_DMA_OFFSET	BIT(0)
-
 enum cedrus_codec {
 	CEDRUS_CODEC_MPEG2,
 	CEDRUS_CODEC_H264,
@@ -150,7 +148,6 @@ struct cedrus_dec_ops {
 
 struct cedrus_variant {
 	unsigned int	capabilities;
-	unsigned int	quirks;
 	unsigned int	mod_rate;
 };
 
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
index bcf050a04ffc..286c7fe844c3 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
@@ -222,24 +222,6 @@ int cedrus_hw_probe(struct cedrus_dev *dev)
 		return ret;
 	}
 
-	/*
-	 * The VPU is only able to handle bus addresses so we have to subtract
-	 * the RAM offset to the physcal addresses.
-	 *
-	 * This information will eventually be obtained from device-tree.
-	 *
-	 * XXX(hch): this has no business in a driver and needs to move
-	 * to the device tree.
-	 */
-
-#ifdef PHYS_PFN_OFFSET
-	if (!(variant->quirks & CEDRUS_QUIRK_NO_DMA_OFFSET)) {
-		ret = dma_direct_set_offset(dev->dev, PHYS_OFFSET, 0, SZ_4G);
-		if (ret)
-			return ret;
-	}
-#endif
-
 	ret = of_reserved_mem_device_init(dev->dev);
 	if (ret && ret != -ENODEV) {
 		dev_err(dev->dev, "Failed to reserve memory\n");
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 7/7] media: sun8i-di: Remove the call to of_dma_configure
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
                   ` (5 preceding siblings ...)
  2020-11-06 15:14 ` [PATCH 6/7] media: cedrus: " Maxime Ripard
@ 2020-11-06 15:14 ` Maxime Ripard
  2020-11-06 16:03 ` [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Chen-Yu Tsai
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-06 15:14 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Hans Verkuil, Jernej Skrabec, Thomas Zimmermann,
	linux-kernel, dri-devel, Paul Kocialkowski, Maxime Ripard,
	Yong Deng, Mauro Carvalho Chehab, Robin Murphy, linux-arm-kernel,
	linux-media

of_dma_configure is called by the core before probe gets called so this
is redundant.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index ba5d07886607..ed863bf5ea80 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -825,10 +825,6 @@ static int deinterlace_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = of_dma_configure(dev->dev, dev->dev->of_node, true);
-	if (ret)
-		return ret;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dev->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(dev->base))
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
                   ` (6 preceding siblings ...)
  2020-11-06 15:14 ` [PATCH 7/7] media: sun8i-di: Remove the call to of_dma_configure Maxime Ripard
@ 2020-11-06 16:03 ` Chen-Yu Tsai
       [not found] ` <20201106160737.GA31913@lst.de>
  2020-11-11 14:42 ` Hans Verkuil
  9 siblings, 0 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2020-11-06 16:03 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: devel, Paul Kocialkowski, Jernej Skrabec, Yong Deng,
	David Airlie, linux-kernel, dri-devel, Hans Verkuil,
	Thomas Zimmermann, Daniel Vetter, Mauro Carvalho Chehab,
	Robin Murphy, Christoph Hellwig, linux-arm-kernel,
	Linux Media Mailing List

Hi,

On Fri, Nov 6, 2020 at 11:15 PM Maxime Ripard <maxime@cerno.tech> wrote:
>
> Hi,
>
> Here's an attempt to removing the dma_direct_set_offset calls we have in
> numerous drivers and move all those quirks into a global notifier as suggested
> by Robin.
>
> Let me know what you think,
> Maxime
>
> Maxime Ripard (7):
>   drm/sun4i: backend: Fix probe failure with multiple backends
>   soc: sunxi: Deal with the MBUS DMA offsets in a central place
>   drm/sun4i: backend: Remove the MBUS quirks
>   media: sun4i: Remove the MBUS quirks
>   media: sun6i: Remove the MBUS quirks
>   media: cedrus: Remove the MBUS quirks
>   media: sun8i-di: Remove the call to of_dma_configure

Whole series looks good to me.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

Now the question remaining is how do we merge this series so that
the notifier gets merged before all the code dealing with the MBUS
quirk gets removed.


>  drivers/gpu/drm/sun4i/sun4i_backend.c         |  13 --
>  .../platform/sunxi/sun4i-csi/sun4i_csi.c      |  27 ----
>  .../platform/sunxi/sun6i-csi/sun6i_csi.c      |  17 ---
>  .../media/platform/sunxi/sun8i-di/sun8i-di.c  |   4 -
>  drivers/soc/sunxi/Kconfig                     |   8 ++
>  drivers/soc/sunxi/Makefile                    |   1 +
>  drivers/soc/sunxi/sunxi_mbus.c                | 132 ++++++++++++++++++
>  drivers/staging/media/sunxi/cedrus/cedrus.c   |   1 -
>  drivers/staging/media/sunxi/cedrus/cedrus.h   |   3 -
>  .../staging/media/sunxi/cedrus/cedrus_hw.c    |  18 ---
>  10 files changed, 141 insertions(+), 83 deletions(-)
>  create mode 100644 drivers/soc/sunxi/sunxi_mbus.c
>
> --
> 2.28.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset
       [not found] ` <20201106160737.GA31913@lst.de>
@ 2020-11-09  9:43   ` Maxime Ripard
       [not found]     ` <20201119075959.GA15942@lst.de>
  0 siblings, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2020-11-09  9:43 UTC (permalink / raw)
  To: Christoph Hellwig, Hans Verkuil, wens
  Cc: devel, Jernej Skrabec, Thomas Zimmermann, David Airlie,
	linux-kernel, dri-devel, Paul Kocialkowski, Yong Deng,
	Daniel Vetter, Mauro Carvalho Chehab, Robin Murphy,
	linux-arm-kernel, linux-media


[-- Attachment #1.1: Type: text/plain, Size: 435 bytes --]

Hi Christoph, Chen-Yu, Hans,

On Fri, Nov 06, 2020 at 05:07:37PM +0100, Christoph Hellwig wrote:
> Thanks,
> 
> this looks good to me:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Can you include this patch at the end of your series to that it gets
> picked up with the other patches?

I guess the easiest to avoid bisection issues would be to merge all this
through drm-misc, would that work for you?

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset
  2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
                   ` (8 preceding siblings ...)
       [not found] ` <20201106160737.GA31913@lst.de>
@ 2020-11-11 14:42 ` Hans Verkuil
  9 siblings, 0 replies; 12+ messages in thread
From: Hans Verkuil @ 2020-11-11 14:42 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, David Airlie, Christoph Hellwig
  Cc: devel, Jernej Skrabec, Thomas Zimmermann, linux-kernel,
	dri-devel, Paul Kocialkowski, Yong Deng, Mauro Carvalho Chehab,
	Robin Murphy, linux-arm-kernel, linux-media

On 06/11/2020 16:14, Maxime Ripard wrote:
> Hi,
> 
> Here's an attempt to removing the dma_direct_set_offset calls we have in
> numerous drivers and move all those quirks into a global notifier as suggested
> by Robin.

For patches 4-7:

Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

It's fine by me if this series is merged via the drm subsystem.

Regards,

	Hans

> 
> Let me know what you think,
> Maxime
> 
> Maxime Ripard (7):
>   drm/sun4i: backend: Fix probe failure with multiple backends
>   soc: sunxi: Deal with the MBUS DMA offsets in a central place
>   drm/sun4i: backend: Remove the MBUS quirks
>   media: sun4i: Remove the MBUS quirks
>   media: sun6i: Remove the MBUS quirks
>   media: cedrus: Remove the MBUS quirks
>   media: sun8i-di: Remove the call to of_dma_configure
> 
>  drivers/gpu/drm/sun4i/sun4i_backend.c         |  13 --
>  .../platform/sunxi/sun4i-csi/sun4i_csi.c      |  27 ----
>  .../platform/sunxi/sun6i-csi/sun6i_csi.c      |  17 ---
>  .../media/platform/sunxi/sun8i-di/sun8i-di.c  |   4 -
>  drivers/soc/sunxi/Kconfig                     |   8 ++
>  drivers/soc/sunxi/Makefile                    |   1 +
>  drivers/soc/sunxi/sunxi_mbus.c                | 132 ++++++++++++++++++
>  drivers/staging/media/sunxi/cedrus/cedrus.c   |   1 -
>  drivers/staging/media/sunxi/cedrus/cedrus.h   |   3 -
>  .../staging/media/sunxi/cedrus/cedrus_hw.c    |  18 ---
>  10 files changed, 141 insertions(+), 83 deletions(-)
>  create mode 100644 drivers/soc/sunxi/sunxi_mbus.c
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset
       [not found]     ` <20201119075959.GA15942@lst.de>
@ 2020-11-19  8:42       ` Maxime Ripard
  0 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2020-11-19  8:42 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: devel, Paul Kocialkowski, Jernej Skrabec, Mauro Carvalho Chehab,
	Thomas Zimmermann, David Airlie, linux-kernel, dri-devel,
	Hans Verkuil, Yong Deng, Daniel Vetter, wens, Robin Murphy,
	linux-arm-kernel, linux-media


[-- Attachment #1.1: Type: text/plain, Size: 959 bytes --]

Hi Christoph,

On Thu, Nov 19, 2020 at 08:59:59AM +0100, Christoph Hellwig wrote:
> On Mon, Nov 09, 2020 at 10:43:03AM +0100, Maxime Ripard wrote:
> > Hi Christoph, Chen-Yu, Hans,
> > 
> > On Fri, Nov 06, 2020 at 05:07:37PM +0100, Christoph Hellwig wrote:
> > > Thanks,
> > > 
> > > this looks good to me:
> > > 
> > > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > > 
> > > Can you include this patch at the end of your series to that it gets
> > > picked up with the other patches?
> > 
> > I guess the easiest to avoid bisection issues would be to merge all this
> > through drm-misc, would that work for you?
> 
> Is this going to get picked up in drm-misc?  I don't see it in linux-next
> so far.

After some discussion with Arnd and Daniel, this will go through
arm-soc, and I sent the PR here:
https://lore.kernel.org/linux-arm-kernel/20201118091303.wa5npxyop3cdsczb@gilmour.lan/

It hasn't been merged yet though

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-11-19 20:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 15:14 [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Maxime Ripard
2020-11-06 15:14 ` [PATCH 1/7] drm/sun4i: backend: Fix probe failure with multiple backends Maxime Ripard
2020-11-06 15:14 ` [PATCH 2/7] soc: sunxi: Deal with the MBUS DMA offsets in a central place Maxime Ripard
2020-11-06 15:14 ` [PATCH 3/7] drm/sun4i: backend: Remove the MBUS quirks Maxime Ripard
2020-11-06 15:14 ` [PATCH 4/7] media: sun4i: " Maxime Ripard
2020-11-06 15:14 ` [PATCH 5/7] media: sun6i: " Maxime Ripard
2020-11-06 15:14 ` [PATCH 6/7] media: cedrus: " Maxime Ripard
2020-11-06 15:14 ` [PATCH 7/7] media: sun8i-di: Remove the call to of_dma_configure Maxime Ripard
2020-11-06 16:03 ` [PATCH 0/7] sunxi: Remove the calls to dma_direct_set_offset Chen-Yu Tsai
     [not found] ` <20201106160737.GA31913@lst.de>
2020-11-09  9:43   ` Maxime Ripard
     [not found]     ` <20201119075959.GA15942@lst.de>
2020-11-19  8:42       ` Maxime Ripard
2020-11-11 14:42 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).