drm/vc4: drv: Call component_unbind_all()
authorMaxime Ripard <maxime@cerno.tech>
Mon, 9 May 2022 10:33:32 +0000 (12:33 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Wed, 7 Sep 2022 08:53:00 +0000 (10:53 +0200)
While we were using the component framework to deal with all the DRM
subdevices, we were not calling component_unbind_all().

This leads to none of the subdevices freeing up their resources as part of
their unbind() or device managed hooks.

Fixes: c8b75bca92cb ("drm/vc4: Add KMS support for Raspberry Pi.")
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_drv.h

index c8534f9..da9e561 100644 (file)
@@ -274,6 +274,13 @@ static void vc4_match_add_drivers(struct device *dev,
        }
 }
 
+static void vc4_component_unbind_all(void *ptr)
+{
+       struct vc4_dev *vc4 = ptr;
+
+       component_unbind_all(vc4->dev, &vc4->base);
+}
+
 const struct of_device_id vc4_dma_range_matches[] = {
        { .compatible = "brcm,bcm2835-hvs" },
        { .compatible = "brcm,bcm2711-hvs" },
@@ -330,6 +337,7 @@ static int vc4_drm_bind(struct device *dev)
        if (IS_ERR(vc4))
                return PTR_ERR(vc4);
        vc4->is_vc5 = is_vc5;
+       vc4->dev = dev;
 
        drm = &vc4->base;
        platform_set_drvdata(pdev, drm);
@@ -380,6 +388,10 @@ static int vc4_drm_bind(struct device *dev)
        if (ret)
                return ret;
 
+       ret = devm_add_action_or_reset(dev, vc4_component_unbind_all, vc4);
+       if (ret)
+               return ret;
+
        if (!vc4->firmware_kms) {
                ret = vc4_plane_create_additional_planes(drm);
                if (ret)
@@ -404,8 +416,6 @@ static int vc4_drm_bind(struct device *dev)
        return 0;
 
 unbind_all:
-       component_unbind_all(dev, drm);
-
        return ret;
 }
 
index 4a8940c..0b3d149 100644 (file)
@@ -76,6 +76,7 @@ struct vc4_perfmon {
 
 struct vc4_dev {
        struct drm_device base;
+       struct device *dev;
 
        bool is_vc5;