Message ID | 20230125200415.14123-5-tzimmermann@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/fb-helper: Various cleanups | expand |
Hi Thomas, On Wed, Jan 25, 2023 at 09:04:09PM +0100, Thomas Zimmermann wrote: > Initialize the fb-helper structure immediately after its allocation > in drm_fbdev_generic_setup(). That will make it easier to fill it with > driver-specific values, such as the preferred BPP. > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> > Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> > --- > drivers/gpu/drm/drm_fbdev_generic.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c > index 135d58b8007b..63f66325a8a5 100644 > --- a/drivers/gpu/drm/drm_fbdev_generic.c > +++ b/drivers/gpu/drm/drm_fbdev_generic.c > @@ -385,8 +385,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) > if (dev->fb_helper) > return drm_fb_helper_hotplug_event(dev->fb_helper); > > - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); > - > ret = drm_fb_helper_init(dev, fb_helper); > if (ret) > goto err; From the documentation: The drm_fb_helper_prepare() helper must be called first to initialize the minimum required to make hotplug detection work. ... To finish up the fbdev helper initialization, the drm_fb_helper_init() function is called. So this change do not follow the documentation as drm_fb_helper_init() is now called before drm_fb_helper_prepare() I did not follow all the code - but my gut feeling is that the documentation is right. Sam > @@ -456,12 +454,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, > fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); > if (!fb_helper) > return; > + drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); > > ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); > if (ret) { > - kfree(fb_helper); > drm_err(dev, "Failed to register client: %d\n", ret); > - return; > + goto err_drm_client_init; > } > > /* > @@ -484,5 +482,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, > drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); > > drm_client_register(&fb_helper->client); > + > + return; > + > +err_drm_client_init: > + drm_fb_helper_unprepare(fb_helper); > + kfree(fb_helper); > + return; > } > EXPORT_SYMBOL(drm_fbdev_generic_setup); > -- > 2.39.0
Hi Am 25.01.23 um 22:03 schrieb Sam Ravnborg: > Hi Thomas, > > On Wed, Jan 25, 2023 at 09:04:09PM +0100, Thomas Zimmermann wrote: >> Initialize the fb-helper structure immediately after its allocation >> in drm_fbdev_generic_setup(). That will make it easier to fill it with >> driver-specific values, such as the preferred BPP. >> >> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> >> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> >> --- >> drivers/gpu/drm/drm_fbdev_generic.c | 13 +++++++++---- >> 1 file changed, 9 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c >> index 135d58b8007b..63f66325a8a5 100644 >> --- a/drivers/gpu/drm/drm_fbdev_generic.c >> +++ b/drivers/gpu/drm/drm_fbdev_generic.c >> @@ -385,8 +385,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) >> if (dev->fb_helper) >> return drm_fb_helper_hotplug_event(dev->fb_helper); >> >> - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); >> - >> ret = drm_fb_helper_init(dev, fb_helper); >> if (ret) >> goto err; > > From the documentation: > The drm_fb_helper_prepare() > helper must be called first to initialize the minimum required to make > hotplug detection work. > ... > To finish up the fbdev helper initialization, the > drm_fb_helper_init() function is called. > > So this change do not follow the documentation as drm_fb_helper_init() > is now called before drm_fb_helper_prepare() No, we now call drm_fb_helper_prepare() from within drm_fbdev_generic_setup(), right after allocating the fb_helper. drm_fb_helper_init() will only be called after the client received a hot-plug event. > > I did not follow all the code - but my gut feeling is that the > documentation is right. The docs are of low quality. The _prepare() helper is the actual init function and _init() only sets the fb_helper in the device instance. Best regards Thomas > > Sam > > >> @@ -456,12 +454,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, >> fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); >> if (!fb_helper) >> return; >> + drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); >> >> ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); >> if (ret) { >> - kfree(fb_helper); >> drm_err(dev, "Failed to register client: %d\n", ret); >> - return; >> + goto err_drm_client_init; >> } >> >> /* >> @@ -484,5 +482,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, >> drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); >> >> drm_client_register(&fb_helper->client); >> + >> + return; >> + >> +err_drm_client_init: >> + drm_fb_helper_unprepare(fb_helper); >> + kfree(fb_helper); >> + return; >> } >> EXPORT_SYMBOL(drm_fbdev_generic_setup); >> -- >> 2.39.0
On Fri, Jan 27, 2023 at 03:21:30PM +0100, Thomas Zimmermann wrote: > Hi > > Am 25.01.23 um 22:03 schrieb Sam Ravnborg: > > Hi Thomas, > > > > On Wed, Jan 25, 2023 at 09:04:09PM +0100, Thomas Zimmermann wrote: > > > Initialize the fb-helper structure immediately after its allocation > > > in drm_fbdev_generic_setup(). That will make it easier to fill it with > > > driver-specific values, such as the preferred BPP. > > > > > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> > > > Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> > > > --- > > > drivers/gpu/drm/drm_fbdev_generic.c | 13 +++++++++---- > > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c > > > index 135d58b8007b..63f66325a8a5 100644 > > > --- a/drivers/gpu/drm/drm_fbdev_generic.c > > > +++ b/drivers/gpu/drm/drm_fbdev_generic.c > > > @@ -385,8 +385,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) > > > if (dev->fb_helper) > > > return drm_fb_helper_hotplug_event(dev->fb_helper); > > > - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); > > > - > > > ret = drm_fb_helper_init(dev, fb_helper); > > > if (ret) > > > goto err; > > > > From the documentation: > > The drm_fb_helper_prepare() > > helper must be called first to initialize the minimum required to make > > hotplug detection work. > > ... > > To finish up the fbdev helper initialization, the > > drm_fb_helper_init() function is called. > > > > So this change do not follow the documentation as drm_fb_helper_init() > > is now called before drm_fb_helper_prepare() > > No, we now call drm_fb_helper_prepare() from within > drm_fbdev_generic_setup(), right after allocating the fb_helper. > drm_fb_helper_init() will only be called after the client received a > hot-plug event. > > > > > I did not follow all the code - but my gut feeling is that the > > documentation is right. > > The docs are of low quality. The _prepare() helper is the actual init > function and _init() only sets the fb_helper in the device instance. OK, thanks for the follow-up. Sam
diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c index 135d58b8007b..63f66325a8a5 100644 --- a/drivers/gpu/drm/drm_fbdev_generic.c +++ b/drivers/gpu/drm/drm_fbdev_generic.c @@ -385,8 +385,6 @@ static int drm_fbdev_client_hotplug(struct drm_client_dev *client) if (dev->fb_helper) return drm_fb_helper_hotplug_event(dev->fb_helper); - drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); - ret = drm_fb_helper_init(dev, fb_helper); if (ret) goto err; @@ -456,12 +454,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); if (!fb_helper) return; + drm_fb_helper_prepare(dev, fb_helper, &drm_fb_helper_generic_funcs); ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); if (ret) { - kfree(fb_helper); drm_err(dev, "Failed to register client: %d\n", ret); - return; + goto err_drm_client_init; } /* @@ -484,5 +482,12 @@ void drm_fbdev_generic_setup(struct drm_device *dev, drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); drm_client_register(&fb_helper->client); + + return; + +err_drm_client_init: + drm_fb_helper_unprepare(fb_helper); + kfree(fb_helper); + return; } EXPORT_SYMBOL(drm_fbdev_generic_setup);