[PATCH 07/15] drm/arc: Use drmm_mode_config_cleanup

Daniel Vetter daniel at ffwll.ch
Thu Feb 25 11:16:25 UTC 2021


On Tue, Jan 12, 2021 at 12:29:59PM +0100, Thomas Zimmermann wrote:
> Hi
> 
> Am 12.01.21 um 09:43 schrieb Daniel Vetter:
> > With autocleanup through drm_device management we can delete all the
> > code. Possible now that there's no confusion against devm_kzalloc'ed
> > structures anymore.
> > 
> > I inlined arcpgu_setup_mode_config because it's tiny and the newly
> > needed return value handling would have been more ...
> > 
> > Acked-by: Sam Ravnborg <sam at ravnborg.org>
> > Cc: Eugeniy Paltsev <Eugeniy.Paltsev at synopsys.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> > Cc: Alexey Brodkin <abrodkin at synopsys.com>
> > ---
> >   drivers/gpu/drm/arc/arcpgu_crtc.c |  4 +---
> >   drivers/gpu/drm/arc/arcpgu_drv.c  | 21 +++++++++------------
> >   drivers/gpu/drm/arc/arcpgu_hdmi.c |  6 +-----
> >   drivers/gpu/drm/arc/arcpgu_sim.c  | 11 ++---------
> >   4 files changed, 13 insertions(+), 29 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> > index 31a85c703307..43313adb1981 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> > @@ -209,10 +209,8 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
> >   	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
> >   					&arc_pgu_crtc_funcs, NULL);
> > -	if (ret) {
> > -		arc_pgu_plane_destroy(primary);
> > +	if (ret)
> >   		return ret;
> > -	}
> >   	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
> >   	return 0;
> > diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> > index 9020352816fa..6349e9dc770e 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> > @@ -30,16 +30,6 @@ static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
> >   	.atomic_commit = drm_atomic_helper_commit,
> >   };
> > -static void arcpgu_setup_mode_config(struct drm_device *drm)
> > -{
> > -	drm_mode_config_init(drm);
> > -	drm->mode_config.min_width = 0;
> > -	drm->mode_config.min_height = 0;
> > -	drm->mode_config.max_width = 1920;
> > -	drm->mode_config.max_height = 1080;
> > -	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
> > -}
> > -
> >   DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
> >   static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
> > @@ -54,7 +44,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
> >   	if (IS_ERR(arcpgu->clk))
> >   		return PTR_ERR(arcpgu->clk);
> > -	arcpgu_setup_mode_config(drm);
> > +	ret = drmm_mode_config_init(drm);
> > +	if (ret)
> > +		return ret;
> > +
> > +	drm->mode_config.min_width = 0;
> > +	drm->mode_config.min_height = 0;
> > +	drm->mode_config.max_width = 1920;
> > +	drm->mode_config.max_height = 1080;
> > +	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
> 
> It feels wrong to do this before even acquiring I/O memory. I would have
> moved all this just before the call to arc_pgu_setup_crtc().

It really doesn't matter, as long as everything is set up before we call
drm_dev_register, or register the fbdev emulation. So I think I'll just
stick with the color choice the original author went with.

But yeah grouping all the kms stuff a bit more together can't hurt.
-Daniel

> 
> Best regards
> Thomas
> 
> >   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >   	arcpgu->regs = devm_ioremap_resource(&pdev->dev, res);
> > @@ -108,7 +106,6 @@ static int arcpgu_unload(struct drm_device *drm)
> >   {
> >   	drm_kms_helper_poll_fini(drm);
> >   	drm_atomic_helper_shutdown(drm);
> > -	drm_mode_config_cleanup(drm);
> >   	return 0;
> >   }
> > diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> > index dbad2c9237fe..925d6d31bb78 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> > @@ -39,9 +39,5 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
> >   		return ret;
> >   	/* Link drm_bridge to encoder */
> > -	ret = drm_bridge_attach(encoder, bridge, NULL, 0);
> > -	if (ret)
> > -		drm_encoder_cleanup(encoder);
> > -
> > -	return ret;
> > +	return drm_bridge_attach(encoder, bridge, NULL, 0);
> >   }
> > diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> > index 3772df1647aa..afc34f8b4de0 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> > @@ -73,21 +73,14 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> >   			DRM_MODE_CONNECTOR_VIRTUAL);
> >   	if (ret < 0) {
> >   		dev_err(drm->dev, "failed to initialize drm connector\n");
> > -		goto error_encoder_cleanup;
> > +		return ret;
> >   	}
> >   	ret = drm_connector_attach_encoder(connector, encoder);
> >   	if (ret < 0) {
> >   		dev_err(drm->dev, "could not attach connector to encoder\n");
> > -		goto error_connector_cleanup;
> > +		return ret;
> >   	}
> >   	return 0;
> > -
> > -error_connector_cleanup:
> > -	drm_connector_cleanup(connector);
> > -
> > -error_encoder_cleanup:
> > -	drm_encoder_cleanup(encoder);
> > -	return ret;
> >   }
> > 
> 
> -- 
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
> 




-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list