]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/sun4i: Use backend/mixer as dedicated DMA device
authorChen-Yu Tsai <wenst@chromium.org>
Wed, 11 Mar 2026 09:49:28 +0000 (17:49 +0800)
committerChen-Yu Tsai <wenst@chromium.org>
Mon, 23 Mar 2026 05:23:29 +0000 (13:23 +0800)
The sun4i DRM driver deals with DMA constraints in a peculiar way.
Instead of using the actual DMA device in various helpers, it justs
reconfigures the DMA constraints of the virtual display device using
the DMA device's device tree node by calling of_dma_configure().

Turns out of_dma_configure() should only be called from bus code.
Lately this also triggers a big warning through of_iommu_configure()
and ultimately __iommu_probe_device():

    late IOMMU probe at driver bind, something fishy here!

Now that the GEM DMA helpers have proper support for allocating
and mapping buffers with a dedicated DMA device, switch over to
it as the proper solution.

The mixer change was tested on a Pine H64 model B. The backend change
was only compile tested. Though I don't expect any issues, help testing
on an older device would be appreciated.

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20260311094929.3393338-5-wenst@chromium.org
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
drivers/gpu/drm/sun4i/sun4i_backend.c
drivers/gpu/drm/sun4i/sun8i_mixer.c

index e989f75c09b7dabc703d47ea4bc113bdbd9bde01..bc35dad53b07114f8d95978c83a74ca3de0058e9 100644 (file)
@@ -798,18 +798,21 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
        dev_set_drvdata(dev, backend);
        spin_lock_init(&backend->frontend_lock);
 
-       if (of_property_present(dev->of_node, "interconnects")) {
-               /*
-                * This assume we have the same DMA constraints for all our the
-                * devices in our pipeline (all the backends, but also the
-                * frontends). This sounds bad, but it has always been the case
-                * for us, and DRM doesn't do per-device allocation either, so
-                * we would need to fix DRM first...
-                */
-               ret = of_dma_configure(drm->dev, dev->of_node, true);
-               if (ret)
-                       return ret;
-       }
+       /*
+        * This assume we have the same DMA constraints for all our the
+        * devices in our pipeline (all the backends, but also the
+        * frontends). This sounds bad, but it has always been the case
+        * for us, and DRM doesn't do per-device allocation either, so
+        * we would need to fix DRM first...
+        *
+        * Always use the first bound backend as the DMA device. While
+        * our device trees always have all backends enabled, some in
+        * the wild may actually have the first one disabled. If both
+        * are enabled, the order in which they are bound is guaranteed
+        * since the driver adds components in order.
+        */
+       if (drm_dev_dma_dev(drm) == drm->dev)
+               drm_dev_set_dma_dev(drm, dev);
 
        backend->engine.node = dev->of_node;
        backend->engine.ops = &sun4i_backend_engine_ops;
index 02acc7cbdb979db6b755fe72a0b810a5c81b462d..4071ab38b4ae526778bad4fa310692eefd5ccdc7 100644 (file)
@@ -536,18 +536,21 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
        mixer->engine.ops = &sun8i_engine_ops;
        mixer->engine.node = dev->of_node;
 
-       if (of_property_present(dev->of_node, "iommus")) {
-               /*
-                * This assume we have the same DMA constraints for
-                * all our the mixers in our pipeline. This sounds
-                * bad, but it has always been the case for us, and
-                * DRM doesn't do per-device allocation either, so we
-                * would need to fix DRM first...
-                */
-               ret = of_dma_configure(drm->dev, dev->of_node, true);
-               if (ret)
-                       return ret;
-       }
+       /*
+        * This assume we have the same DMA constraints for all our the
+        * devices in our pipeline (all the backends, but also the
+        * frontends). This sounds bad, but it has always been the case
+        * for us, and DRM doesn't do per-device allocation either, so
+        * we would need to fix DRM first...
+        *
+        * Always use the first bound backend as the DMA device. While
+        * our device trees always have all backends enabled, some in
+        * the wild may actually have the first one disabled. If both
+        * are enabled, the order in which they are bound is guaranteed
+        * since the driver adds components in order.
+        */
+       if (drm_dev_dma_dev(drm) == drm->dev)
+               drm_dev_set_dma_dev(drm, dev);
 
        /*
         * While this function can fail, we shouldn't do anything