]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/arm/komeda: Fix komeda probe failing if there are no links in the secondary pipeline
authorFaiz Abbas <faiz.abbas@arm.com>
Mon, 19 Feb 2024 10:09:13 +0000 (15:39 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Aug 2024 06:59:49 +0000 (08:59 +0200)
[ Upstream commit 9054c46d479b55768adae31031a1afa1b7d62228 ]

Since commit 4cfe5cc02e3f ("drm/arm/komeda: Remove component framework and
add a simple encoder"), the devm_drm_of_get_bridge() call happens
regardless of whether any remote nodes are available on the pipeline. Fix
this by moving the bridge attach to its own function and calling it
conditional on there being an output link.

Fixes: 4cfe5cc02e3f ("drm/arm/komeda: Remove component framework and add a simple encoder")
Signed-off-by: Faiz Abbas <faiz.abbas@arm.com>
[Corrected Commit-id of the fixed patch to match mainline]
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240219100915.192475-2-faiz.abbas@arm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c

index 2c661f28410eda2d297a1fe33b0f33e003af775c..b645c5998230b0ea71cf208f7c657f76944d007e 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 #include <linux/clk.h>
+#include <linux/of.h>
 #include <linux/pm_runtime.h>
 #include <linux/spinlock.h>
 
@@ -610,12 +611,34 @@ get_crtc_primary(struct komeda_kms_dev *kms, struct komeda_crtc *crtc)
        return NULL;
 }
 
+static int komeda_attach_bridge(struct device *dev,
+                               struct komeda_pipeline *pipe,
+                               struct drm_encoder *encoder)
+{
+       struct drm_bridge *bridge;
+       int err;
+
+       bridge = devm_drm_of_get_bridge(dev, pipe->of_node,
+                                       KOMEDA_OF_PORT_OUTPUT, 0);
+       if (IS_ERR(bridge))
+               return dev_err_probe(dev, PTR_ERR(bridge), "remote bridge not found for pipe: %s\n",
+                                    of_node_full_name(pipe->of_node));
+
+       err = drm_bridge_attach(encoder, bridge, NULL, 0);
+       if (err)
+               dev_err(dev, "bridge_attach() failed for pipe: %s\n",
+                       of_node_full_name(pipe->of_node));
+
+       return err;
+}
+
 static int komeda_crtc_add(struct komeda_kms_dev *kms,
                           struct komeda_crtc *kcrtc)
 {
        struct drm_crtc *crtc = &kcrtc->base;
        struct drm_device *base = &kms->base;
-       struct drm_bridge *bridge;
+       struct komeda_pipeline *pipe = kcrtc->master;
+       struct drm_encoder *encoder = &kcrtc->encoder;
        int err;
 
        err = drm_crtc_init_with_planes(base, crtc,
@@ -626,27 +649,25 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms,
 
        drm_crtc_helper_add(crtc, &komeda_crtc_helper_funcs);
 
-       crtc->port = kcrtc->master->of_output_port;
+       crtc->port = pipe->of_output_port;
 
        /* Construct an encoder for each pipeline and attach it to the remote
         * bridge
         */
        kcrtc->encoder.possible_crtcs = drm_crtc_mask(crtc);
-       err = drm_simple_encoder_init(base, &kcrtc->encoder,
-                                     DRM_MODE_ENCODER_TMDS);
+       err = drm_simple_encoder_init(base, encoder, DRM_MODE_ENCODER_TMDS);
        if (err)
                return err;
 
-       bridge = devm_drm_of_get_bridge(base->dev, kcrtc->master->of_node,
-                                       KOMEDA_OF_PORT_OUTPUT, 0);
-       if (IS_ERR(bridge))
-               return PTR_ERR(bridge);
-
-       err = drm_bridge_attach(&kcrtc->encoder, bridge, NULL, 0);
+       if (pipe->of_output_links[0]) {
+               err = komeda_attach_bridge(base->dev, pipe, encoder);
+               if (err)
+                       return err;
+       }
 
        drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE);
 
-       return err;
+       return 0;
 }
 
 int komeda_kms_add_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev)