Re: [PATCH] drm: add locked variant ofdrm_fb_helper_force_kernel_mode

From: Jesse Barnes
Date: Mon Apr 12 2010 - 11:45:59 EST


On Mon, 12 Apr 2010 10:05:00 +1000
Dave Airlie <airlied@xxxxxxxxx> wrote:

> On Sat, Apr 10, 2010 at 8:11 AM, Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx> wrote:
> > Needed for panic and kdb, since we need to avoid taking the mode_config
> > mutex.
>
> One comment below.
>
> >
> > Signed-off-by: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>
> > ---
> > Âdrivers/gpu/drm/drm_fb_helper.c | Â 42 +++++++++++++++++++++++++++++++++-----
> > Â1 files changed, 36 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> > index 6929f5b..962eadb 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -242,18 +242,22 @@ static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper)
> > Â Â Â Âreturn 0;
> > Â}
> >
> > -bool drm_fb_helper_force_kernel_mode(void)
> > +bool drm_fb_helper_force_kernel_mode_locked(void)
> > Â{
> > Â Â Â Âint i = 0;
> > Â Â Â Âbool ret, error = false;
> > Â Â Â Âstruct drm_fb_helper *helper;
> > -
> > - Â Â Â if (list_empty(&kernel_fb_helper_list))
> > - Â Â Â Â Â Â Â return false;
> > + Â Â Â struct drm_mode_set *mode_set;
> > + Â Â Â struct drm_crtc *crtc;
> >
> > Â Â Â Âlist_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
> > Â Â Â Â Â Â Â Âfor (i = 0; i < helper->crtc_count; i++) {
> > - Â Â Â Â Â Â Â Â Â Â Â struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set;
> > + Â Â Â Â Â Â Â Â Â Â Â mode_set = &helper->crtc_info[i].mode_set;
> > + Â Â Â Â Â Â Â Â Â Â Â crtc = helper->crtc_info[i].mode_set.crtc;
> > +
> > + Â Â Â Â Â Â Â Â Â Â Â if (!crtc->enabled)
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue;
> > +
> > Â Â Â Â Â Â Â Â Â Â Â Âret = drm_crtc_helper_set_config(mode_set);
> > Â Â Â Â Â Â Â Â Â Â Â Âif (ret)
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âerror = true;
> > @@ -262,11 +266,37 @@ bool drm_fb_helper_force_kernel_mode(void)
> > Â Â Â Âreturn error;
> > Â}
> >
> > +bool drm_fb_helper_force_kernel_mode(void)
> > +{
> > + Â Â Â bool ret;
> > + Â Â Â struct drm_device *dev;
> > + Â Â Â struct drm_fb_helper *helper;
> > + Â Â Â struct drm_mode_set *mode_set;
> > +
> > + Â Â Â if (list_empty(&kernel_fb_helper_list)) {
> > + Â Â Â Â Â Â Â DRM_DEBUG_KMS("no fb helper list??\n");
> > + Â Â Â Â Â Â Â return false;
> > + Â Â Â }
> > +
> > + Â Â Â /* Get the DRM device */
> > + Â Â Â helper = list_first_entry(&kernel_fb_helper_list,
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct drm_fb_helper,
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â kernel_fb_list);
> > + Â Â Â mode_set = &helper->crtc_info[0].mode_set;
> > + Â Â Â dev = mode_set->crtc->dev;
> > +
> > + Â Â Â mutex_lock(&dev->mode_config.mutex);
> > + Â Â Â ret = drm_fb_helper_force_kernel_mode_locked();
> > + Â Â Â mutex_unlock(&dev->mode_config.mutex);
> > +
> > + Â Â Â return ret;
> > +}
> > +
> > Âint drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed,
> > Â Â Â Â Â Â Â Â Â Â Â Âvoid *panic_str)
> > Â{
> > Â Â Â ÂDRM_ERROR("panic occurred, switching back to text console\n");
> > - Â Â Â return drm_fb_helper_force_kernel_mode();
> > + Â Â Â drm_fb_helper_force_kernel_mode_locked();
>
> Any reason to drop the return here?
>
> not just remove the return 0?

Oh no; I don't think the return value is checked anywhere but we may as
well return it anyway.

--
Jesse Barnes, Intel Open Source Technology Center
--
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/