drm/vc4: gem: Add a managed action to cleanup the job queue
authorMaxime Ripard <maxime@cerno.tech>
Thu, 29 Oct 2020 19:01:01 +0000 (20:01 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 2 Nov 2020 11:14:43 +0000 (12:14 +0100)
The job queue needs to be cleaned up using vc4_gem_destroy, but it's
not used consistently (vc4_drv's bind calls it in its error path, but
doesn't in unbind), and we can make that automatic through a managed
action. Let's remove the requirement to call vc4_gem_destroy.

Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20201029190104.2181730-3-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_gem.c

index 44209077000d56de78f90f1fef9495de675b31ca..2e418fa5b81cb1991e643f37a472b9a638ea59f7 100644 (file)
@@ -285,11 +285,13 @@ static int vc4_drm_bind(struct device *dev)
        if (ret)
                goto dev_put;
 
-       vc4_gem_init(drm);
+       ret = vc4_gem_init(drm);
+       if (ret)
+               goto dev_put;
 
        ret = component_bind_all(dev, drm);
        if (ret)
-               goto gem_destroy;
+               goto dev_put;
 
        ret = vc4_plane_create_additional_planes(drm);
        if (ret)
@@ -314,8 +316,6 @@ static int vc4_drm_bind(struct device *dev)
 
 unbind_all:
        component_unbind_all(dev, drm);
-gem_destroy:
-       vc4_gem_destroy(drm);
 dev_put:
        drm_dev_put(drm);
        return ret;
index 437ff036198d77fde7b164abbb471ebe9878a914..6de6c232fefbef1e7c7b6d4b85165e54b1c5af14 100644 (file)
@@ -874,8 +874,7 @@ extern struct platform_driver vc4_dsi_driver;
 extern const struct dma_fence_ops vc4_fence_ops;
 
 /* vc4_gem.c */
-void vc4_gem_init(struct drm_device *dev);
-void vc4_gem_destroy(struct drm_device *dev);
+int vc4_gem_init(struct drm_device *dev);
 int vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
                        struct drm_file *file_priv);
 int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data,
index 9f01ddd5b932655eadf3849f3262dc2b28277477..32367980d204dfd9390913bcec000ffcc82ed5f0 100644 (file)
@@ -1263,8 +1263,8 @@ fail:
        return ret;
 }
 
-void
-vc4_gem_init(struct drm_device *dev)
+static void vc4_gem_destroy(struct drm_device *dev, void *unused);
+int vc4_gem_init(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
 
@@ -1285,10 +1285,11 @@ vc4_gem_init(struct drm_device *dev)
 
        INIT_LIST_HEAD(&vc4->purgeable.list);
        mutex_init(&vc4->purgeable.lock);
+
+       return drmm_add_action_or_reset(dev, vc4_gem_destroy, NULL);
 }
 
-void
-vc4_gem_destroy(struct drm_device *dev)
+static void vc4_gem_destroy(struct drm_device *dev, void *unused)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);