sunxi: Remove the calls to dma_direct_set_offset
Subsystems (19)
cover sunxi: Remove the calls to dma_direct_set_offset
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
Signature · 7 lines
2.28.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/7 drm/sun4i: backend: Fix probe failure with multiple backends
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.
--- drivers/gpu/drm/sun4i/sun4i_backend.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_backend.c +7 -1
@@ -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; }
Signature · 1 line
2.28.0
PATCH 2/7 soc: sunxi: Deal with the MBUS DMA offsets in a central place
In reply to Maxime RipardSo 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.
--- 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
drivers/soc/sunxi/Kconfig +8 -0
@@ -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
drivers/soc/sunxi/Makefile +1 -0
@@ -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
drivers/soc/sunxi/sunxi_mbus.c new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 3/7 drm/sun4i: backend: Remove the MBUS quirks
In reply to Maxime RipardNow that the MBUS quirks are applied by our global notifier, we can remove them from our DRM driver.
--- drivers/gpu/drm/sun4i/sun4i_backend.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/gpu/drm/sun4i/sun4i_backend.c +0 -19
@@ -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;
Signature · 1 line
2.28.0
PATCH 4/7 media: sun4i: Remove the MBUS quirks
In reply to Maxime RipardNow that the MBUS quirks are applied by our global notifier, we can remove them from our CSI driver for the A10.
--- .../platform/sunxi/sun4i-csi/sun4i_csi.c | 27 ------------------- 1 file changed, 27 deletions(-)
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c +0 -27
@@ -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));
Signature · 7 lines
2.28.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/7 media: sun6i: Remove the MBUS quirks
In reply to Maxime RipardNow that the MBUS quirks are applied by our global notifier, we can remove them from our CSI driver for the A31.
--- .../media/platform/sunxi/sun6i-csi/sun6i_csi.c | 17 ----------------- 1 file changed, 17 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +0 -17
@@ -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)
Signature · 7 lines
2.28.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 6/7 media: cedrus: Remove the MBUS quirks
In reply to Maxime RipardNow 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.
--- 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(-)
drivers/staging/media/sunxi/cedrus/cedrus.c +0 -1
@@ -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 , };
drivers/staging/media/sunxi/cedrus/cedrus.h +0 -3
@@ -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; };
drivers/staging/media/sunxi/cedrus/cedrus_hw.c +0 -18
@@ -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" );
Signature · 7 lines
2.28.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 7/7 media: sun8i-di: Remove the call to of_dma_configure
In reply to Maxime Ripardof_dma_configure is called by the core before probe gets called so this is redundant.
--- drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c +0 -4
@@ -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))
Signature · 1 line
2.28.0
Hi,
Quoted 10 lines · Maxime Ripard
Hi,
Here's an attempt to removing the
dma_direct_set_offsetcalls 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
Quoted 8 lines
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 toof_dma_configure
Whole series looks good to me.
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.
Quoted 13 lines
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
Quoted 8 lines
--
2.28.0_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thanks,
this looks good to me:
Can you include this patch at the end of your series to that it gets picked up with the other patches?
---
From 5963f88d365367fe74d477b8420d34562d684406 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Fri, 6 Nov 2020 17:02:17 +0100
Subject: dma-mapping: remove the dma_direct_set_offset export
Drop the dma_direct_set_offset export and move the declaration to dma-map-ops.h now that the Allwinner drivers have stopped calling it.
--- arch/arm/mach-keystone/keystone.c | 2 +- arch/arm/mach-omap1/usb.c | 2 +- arch/sh/drivers/pci/pcie-sh7786.c | 2 +- arch/x86/pci/sta2x11-fixup.c | 3 ++- include/linux/dma-map-ops.h | 3 +++ include/linux/dma-mapping.h | 7 ------- kernel/dma/direct.c | 1 - 7 files changed, 8 insertions(+), 12 deletions(-)
arch/arm/mach-keystone/keystone.c +1 -1
@@ -8,7 +8,7 @@*/ #include <linux/io.h> #include <linux/of.h> -#include <linux/dma-mapping.h> +#include <linux/dma-map-ops.h> #include <linux/init.h> #include <linux/of_platform.h> #include <linux/of_address.h>
arch/arm/mach-omap1/usb.c +1 -1
@@ -9,7 +9,7 @@#include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> -#include <linux/dma-mapping.h> +#include <linux/dma-map-ops.h> #include <linux/io.h> #include <asm/irq.h>
arch/sh/drivers/pci/pcie-sh7786.c +1 -1
@@ -12,7 +12,7 @@#include <linux/io.h> #include <linux/async.h> #include <linux/delay.h> -#include <linux/dma-mapping.h> +#include <linux/dma-map-ops.h> #include <linux/slab.h> #include <linux/clk.h> #include <linux/sh_clk.h>
arch/x86/pci/sta2x11-fixup.c +2 -1
@@ -11,7 +11,8 @@#include <linux/pci_ids.h> #include <linux/export.h> #include <linux/list.h> -#include <linux/dma-direct.h> +#include <linux/dma-map-ops.h> +#include <linux/swiotlb.h> #include <asm/iommu.h> #define STA2X11_SWIOTLB_SIZE (4*1024*1024)
include/linux/dma-map-ops.h +3 -0
@@ -226,6 +226,9 @@ struct page *dma_alloc_from_pool(struct device *dev, size_t size, bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t));bool dma_free_from_pool (struct device *dev,void *start,size_t size); +int dma_direct_set_offset (struct device *dev,phys_addr_t cpu_start, +dma_addr_t dma_start,u64 size); +#ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H #include <asm/dma-coherence.h> #elif defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
include/linux/dma-mapping.h +0 -7
@@ -558,11 +558,4 @@ static inline int dma_mmap_wc(struct device *dev,#define dma_unmap_len_set (PTR ,LEN_NAME ,VAL ) do { } while (0)#endif -/* -* Legacy interface to set up the dma offset map. Drivers really should not -* actually use it, but we have a few legacy cases left. -*/ -int dma_direct_set_offset (struct device *dev,phys_addr_t cpu_start, -dma_addr_t dma_start,u64 size); -#endif /* _LINUX_DMA_MAPPING_H */
kernel/dma/direct.c +0 -1
@@ -547,4 +547,3 @@ int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start, dev->dma_range_map = map;return 0 ; } -EXPORT_SYMBOL_GPL (dma_direct_set_offset);
Signature · 1 line
2.28.0
Hi Christoph, Chen-Yu, Hans,
Quoted 8 lines · Christoph Hellwig
Thanks,
this looks good to me:
Reviewed-by Christoph Hellwig <[email protected]>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
Quoted 7 lines · Maxime Ripard
Hi Christoph, Chen-Yu, Hans,
Quoted 4 lines · Christoph Hellwig
Thanks,
this looks good to me:
Quoted 7 lines
Quoted 4 lines
Reviewed-by Christoph Hellwig <[email protected]>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?
Fine with me!
Quoted 7 lines · Maxime Ripard
Hi Christoph, Chen-Yu, Hans,
Quoted 4 lines · Christoph Hellwig
Thanks,
this looks good to me:
Quoted 7 lines
Quoted 4 lines
Reviewed-by Christoph Hellwig <[email protected]>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.
Hi Christoph,
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Maxime Ripard
Hi Christoph, Chen-Yu, Hans,
Quoted 6 lines · Christoph Hellwig
Thanks,
this looks good to me:
Reviewed-by Christoph Hellwig <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
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/[email protected]/
It hasn't been merged yet though
Maxime
Quoted 5 lines · Maxime Ripard
Hi,
Here's an attempt to removing the
dma_direct_set_offsetcalls we have in numerous drivers and move all those quirks into a global notifier as suggested by Robin.
For patches 4-7:
It's fine by me if this series is merged via the drm subsystem.
Regards,
Hans
Quoted 26 lines
Let me know what you think,
MaximeMaxime 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 toof_dma_configuredrivers/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