diff mbox series

[14/64] drm/vc4: hvs: Remove planes currently allocated before taking down

Message ID 20220610092924.754942-15-maxime@cerno.tech (mailing list archive)
State New, archived
Headers show
Series drm/vc4: Fix hotplug for vc4 | expand

Commit Message

Maxime Ripard June 10, 2022, 9:28 a.m. UTC
When the HVS driver is unbound, a lot of memory allocations in the LBM and
DLIST RAM are still assigned to planes that are still allocated.

Thus, we hit a warning when calling drm_mm_takedown() since the memory pool
is not completely free of allocations.

Let's free all the currently live entries before calling drm_mm_takedown().

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_hvs.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Dave Stevenson June 14, 2022, 2:51 p.m. UTC | #1
On Fri, 10 Jun 2022 at 10:30, Maxime Ripard <maxime@cerno.tech> wrote:
>
> When the HVS driver is unbound, a lot of memory allocations in the LBM and
> DLIST RAM are still assigned to planes that are still allocated.
>
> Thus, we hit a warning when calling drm_mm_takedown() since the memory pool
> is not completely free of allocations.
>
> Let's free all the currently live entries before calling drm_mm_takedown().
>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

> ---
>  drivers/gpu/drm/vc4/vc4_hvs.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
> index 483053e7b14f..b0906bb96c32 100644
> --- a/drivers/gpu/drm/vc4/vc4_hvs.c
> +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
> @@ -834,11 +834,18 @@ static void vc4_hvs_unbind(struct device *dev, struct device *master,
>         struct drm_device *drm = dev_get_drvdata(master);
>         struct vc4_dev *vc4 = to_vc4_dev(drm);
>         struct vc4_hvs *hvs = vc4->hvs;
> +       struct drm_mm_node *node, *next;
>
>         if (drm_mm_node_allocated(&vc4->hvs->mitchell_netravali_filter))
>                 drm_mm_remove_node(&vc4->hvs->mitchell_netravali_filter);
>
> +       drm_mm_for_each_node_safe(node, next, &vc4->hvs->dlist_mm)
> +               drm_mm_remove_node(node);
> +
>         drm_mm_takedown(&vc4->hvs->dlist_mm);
> +
> +       drm_mm_for_each_node_safe(node, next, &vc4->hvs->lbm_mm)
> +               drm_mm_remove_node(node);
>         drm_mm_takedown(&vc4->hvs->lbm_mm);
>
>         clk_disable_unprepare(hvs->core_clk);
> --
> 2.36.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
index 483053e7b14f..b0906bb96c32 100644
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -834,11 +834,18 @@  static void vc4_hvs_unbind(struct device *dev, struct device *master,
 	struct drm_device *drm = dev_get_drvdata(master);
 	struct vc4_dev *vc4 = to_vc4_dev(drm);
 	struct vc4_hvs *hvs = vc4->hvs;
+	struct drm_mm_node *node, *next;
 
 	if (drm_mm_node_allocated(&vc4->hvs->mitchell_netravali_filter))
 		drm_mm_remove_node(&vc4->hvs->mitchell_netravali_filter);
 
+	drm_mm_for_each_node_safe(node, next, &vc4->hvs->dlist_mm)
+		drm_mm_remove_node(node);
+
 	drm_mm_takedown(&vc4->hvs->dlist_mm);
+
+	drm_mm_for_each_node_safe(node, next, &vc4->hvs->lbm_mm)
+		drm_mm_remove_node(node);
 	drm_mm_takedown(&vc4->hvs->lbm_mm);
 
 	clk_disable_unprepare(hvs->core_clk);