Message ID | 20220610092924.754942-17-maxime@cerno.tech (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/vc4: Fix hotplug for vc4 | expand |
On Fri, 10 Jun 2022 at 10:30, Maxime Ripard <maxime@cerno.tech> wrote: > > Let's switch to drmm_universal_plane_alloc() for our plane allocation and > initialisation to make the driver a bit simpler. > > Signed-off-by: Maxime Ripard <maxime@cerno.tech> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> > --- > drivers/gpu/drm/vc4/vc4_crtc.c | 12 +----------- > drivers/gpu/drm/vc4/vc4_plane.c | 23 ++++++++--------------- > 2 files changed, 9 insertions(+), 26 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c > index 840a93484bb1..7163f924b48b 100644 > --- a/drivers/gpu/drm/vc4/vc4_crtc.c > +++ b/drivers/gpu/drm/vc4/vc4_crtc.c > @@ -1176,7 +1176,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) > const struct vc4_pv_data *pv_data; > struct vc4_crtc *vc4_crtc; > struct drm_crtc *crtc; > - struct drm_plane *destroy_plane, *temp; > int ret; > > vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL); > @@ -1211,7 +1210,7 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) > IRQF_SHARED, > "vc4 crtc", vc4_crtc); > if (ret) > - goto err_destroy_planes; > + return ret; > > platform_set_drvdata(pdev, vc4_crtc); > > @@ -1219,15 +1218,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) > &vc4_crtc->regset); > > return 0; > - > -err_destroy_planes: > - list_for_each_entry_safe(destroy_plane, temp, > - &drm->mode_config.plane_list, head) { > - if (destroy_plane->possible_crtcs == drm_crtc_mask(crtc)) > - destroy_plane->funcs->destroy(destroy_plane); > - } > - > - return ret; > } > > static void vc4_crtc_unbind(struct device *dev, struct device *master, > diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c > index 17dab470ecdf..673c963f5c5a 100644 > --- a/drivers/gpu/drm/vc4/vc4_plane.c > +++ b/drivers/gpu/drm/vc4/vc4_plane.c > @@ -1442,8 +1442,6 @@ static bool vc4_format_mod_supported(struct drm_plane *plane, > static const struct drm_plane_funcs vc4_plane_funcs = { > .update_plane = drm_atomic_helper_update_plane, > .disable_plane = drm_atomic_helper_disable_plane, > - .destroy = drm_plane_cleanup, > - .set_property = NULL, > .reset = vc4_plane_reset, > .atomic_duplicate_state = vc4_plane_duplicate_state, > .atomic_destroy_state = vc4_plane_destroy_state, > @@ -1454,11 +1452,10 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, > enum drm_plane_type type, > unsigned int possible_crtcs) > { > - struct drm_plane *plane = NULL; > + struct drm_plane *plane; > struct vc4_plane *vc4_plane; > u32 formats[ARRAY_SIZE(hvs_formats)]; > int num_formats = 0; > - int ret = 0; > unsigned i; > bool hvs5 = of_device_is_compatible(dev->dev->of_node, > "brcm,bcm2711-vc5"); > @@ -1471,11 +1468,6 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, > DRM_FORMAT_MOD_INVALID > }; > > - vc4_plane = devm_kzalloc(dev->dev, sizeof(*vc4_plane), > - GFP_KERNEL); > - if (!vc4_plane) > - return ERR_PTR(-ENOMEM); > - > for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) { > if (!hvs_formats[i].hvs5_only || hvs5) { > formats[num_formats] = hvs_formats[i].drm; > @@ -1483,13 +1475,14 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, > } > } > > + vc4_plane = drmm_universal_plane_alloc(dev, struct vc4_plane, base, > + possible_crtcs, > + &vc4_plane_funcs, > + formats, num_formats, > + modifiers, type, NULL); > + if (IS_ERR(vc4_plane)) > + return ERR_CAST(vc4_plane); > plane = &vc4_plane->base; > - ret = drm_universal_plane_init(dev, plane, possible_crtcs, > - &vc4_plane_funcs, > - formats, num_formats, > - modifiers, type, NULL); > - if (ret) > - return ERR_PTR(ret); > > drm_plane_helper_add(plane, &vc4_plane_helper_funcs); > > -- > 2.36.1 >
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c index 840a93484bb1..7163f924b48b 100644 --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c @@ -1176,7 +1176,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) const struct vc4_pv_data *pv_data; struct vc4_crtc *vc4_crtc; struct drm_crtc *crtc; - struct drm_plane *destroy_plane, *temp; int ret; vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL); @@ -1211,7 +1210,7 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) IRQF_SHARED, "vc4 crtc", vc4_crtc); if (ret) - goto err_destroy_planes; + return ret; platform_set_drvdata(pdev, vc4_crtc); @@ -1219,15 +1218,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) &vc4_crtc->regset); return 0; - -err_destroy_planes: - list_for_each_entry_safe(destroy_plane, temp, - &drm->mode_config.plane_list, head) { - if (destroy_plane->possible_crtcs == drm_crtc_mask(crtc)) - destroy_plane->funcs->destroy(destroy_plane); - } - - return ret; } static void vc4_crtc_unbind(struct device *dev, struct device *master, diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 17dab470ecdf..673c963f5c5a 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -1442,8 +1442,6 @@ static bool vc4_format_mod_supported(struct drm_plane *plane, static const struct drm_plane_funcs vc4_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = drm_plane_cleanup, - .set_property = NULL, .reset = vc4_plane_reset, .atomic_duplicate_state = vc4_plane_duplicate_state, .atomic_destroy_state = vc4_plane_destroy_state, @@ -1454,11 +1452,10 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, enum drm_plane_type type, unsigned int possible_crtcs) { - struct drm_plane *plane = NULL; + struct drm_plane *plane; struct vc4_plane *vc4_plane; u32 formats[ARRAY_SIZE(hvs_formats)]; int num_formats = 0; - int ret = 0; unsigned i; bool hvs5 = of_device_is_compatible(dev->dev->of_node, "brcm,bcm2711-vc5"); @@ -1471,11 +1468,6 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, DRM_FORMAT_MOD_INVALID }; - vc4_plane = devm_kzalloc(dev->dev, sizeof(*vc4_plane), - GFP_KERNEL); - if (!vc4_plane) - return ERR_PTR(-ENOMEM); - for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) { if (!hvs_formats[i].hvs5_only || hvs5) { formats[num_formats] = hvs_formats[i].drm; @@ -1483,13 +1475,14 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, } } + vc4_plane = drmm_universal_plane_alloc(dev, struct vc4_plane, base, + possible_crtcs, + &vc4_plane_funcs, + formats, num_formats, + modifiers, type, NULL); + if (IS_ERR(vc4_plane)) + return ERR_CAST(vc4_plane); plane = &vc4_plane->base; - ret = drm_universal_plane_init(dev, plane, possible_crtcs, - &vc4_plane_funcs, - formats, num_formats, - modifiers, type, NULL); - if (ret) - return ERR_PTR(ret); drm_plane_helper_add(plane, &vc4_plane_helper_funcs);
Let's switch to drmm_universal_plane_alloc() for our plane allocation and initialisation to make the driver a bit simpler. Signed-off-by: Maxime Ripard <maxime@cerno.tech> --- drivers/gpu/drm/vc4/vc4_crtc.c | 12 +----------- drivers/gpu/drm/vc4/vc4_plane.c | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 26 deletions(-)