Re: [PATCH 1/4] HID: picolcd: fix deferred_io init/cleanup to (un)register_framebuffer ordering

From: Bruno PrÃmont
Date: Wed Jun 30 2010 - 01:57:05 EST


Hi Jaya,

On Wed, 30 Jun 2010 09:52:13 Jaya Kumar wrote:
> On Tue, Jun 29, 2010 at 4:29 AM, Bruno PrÃmont
> <bonbons@xxxxxxxxxxxxxxxxx> wrote:
> > We need to call fb_deferred_io_init() before we
> > register_framebuffer() as otherwise, in case fbcon uses our
> > framebuffer, we will get a BUG() because in picolcd_fb_imageblit()
> > we schedule defio which has not been initialized yet.
>
> Hi Bruno,
>
> The comment above seems confusing to me in that it talks about fbcon
> and defio schedule.

Well I talk about fbcon as that's the trigger I have seen causing an
issue.

I'm fine with rewriting the changelog as to just talk about the
correct/expected order of initialization.

Thanks for looking at it,
Bruno


> What I see is that you originally had in picolcd:
>
> > error = register_framebuffer(info);
> ...
> > fb_deferred_io_init(info);
>
> which was a bug because it called register_framebuffer (ie: made the
> framebuffer available for use) and only then initialized the defio
> handlers which were needed for that framebuffer memory to be used.
> Drivers must always call defio_init _before_ register_framebuffer. The
> bug fix to picolcd below looks correct because it now does that
> sequence in the correct order.
>
> Thanks,
> jaya
>
>
>
> >
> > Note: this BUG() deadlocks ttys.
> >
> > Signed-off-by: Bruno PrÃmont <bonbons@xxxxxxxxxxxxxxxxx>
> > ---
> > Âdrivers/hid/hid-picolcd.c | Â Â4 ++--
> > Â1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
> > index 95253b3..883d720 100644
> > --- a/drivers/hid/hid-picolcd.c
> > +++ b/drivers/hid/hid-picolcd.c
> > @@ -707,18 +707,19 @@ static int picolcd_init_framebuffer(struct
> > picolcd_data *data) dev_err(dev, "failed to create sysfs
> > attributes\n"); goto err_cleanup;
> > Â Â Â Â}
> > + Â Â Â fb_deferred_io_init(info);
> >    Âdata->fb_info  Â= info;
> > Â Â Â Âerror = register_framebuffer(info);
> > Â Â Â Âif (error) {
> > Â Â Â Â Â Â Â Âdev_err(dev, "failed to register framebuffer\n");
> > Â Â Â Â Â Â Â Âgoto err_sysfs;
> > Â Â Â Â}
> > - Â Â Â fb_deferred_io_init(info);
> > Â Â Â Â/* schedule first output of framebuffer */
> > Â Â Â Âschedule_delayed_work(&info->deferred_work, 0);
> > Â Â Â Âreturn 0;
> >
> > Âerr_sysfs:
> > + Â Â Â fb_deferred_io_cleanup(info);
> > Â Â Â Âdevice_remove_file(dev, &dev_attr_fb_update_rate);
> > Âerr_cleanup:
> > Â Â Â Âdata->fb_vbitmap = NULL;
> > @@ -747,7 +748,6 @@ static void picolcd_exit_framebuffer(struct
> > picolcd_data *data) data->fb_bpp   = 0;
> >    Âdata->fb_info  Â= NULL;
> > Â Â Â Âdevice_remove_file(&data->hdev->dev,
> > &dev_attr_fb_update_rate);
> > - Â Â Â fb_deferred_io_cleanup(info);
> > Â Â Â Âunregister_framebuffer(info);
> > Â Â Â Âvfree(fb_bitmap);
> > Â Â Â Âkfree(fb_vbitmap);
> > --
> > 1.7.1
> >
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/