lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210507220036.GI2484@yoga>
Date:   Fri, 7 May 2021 17:00:36 -0500
From:   Bjorn Andersson <bjorn.andersson@...aro.org>
To:     Lyude Paul <lyude@...hat.com>
Cc:     Douglas Anderson <dianders@...omium.org>,
        Andrzej Hajda <a.hajda@...sung.com>,
        Neil Armstrong <narmstrong@...libre.com>,
        Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        Jonas Karlman <jonas@...boo.se>,
        Jernej Skrabec <jernej.skrabec@...l.net>,
        Sam Ravnborg <sam@...nborg.org>, Wolfram Sang <wsa@...nel.org>,
        Ville Syrjala <ville.syrjala@...el.com>,
        Steev Klimaszewski <steev@...i.org>,
        Stephen Boyd <swboyd@...omium.org>,
        linux-arm-msm@...r.kernel.org,
        Stanislav Lisovskiy <stanislav.lisovskiy@...el.com>,
        Linus W <linus.walleij@...aro.org>, robdclark@...omium.org,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Thierry Reding <treding@...dia.com>, linux-i2c@...r.kernel.org,
        dri-devel@...ts.freedesktop.org, Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...ux.ie>,
        Maxime Ripard <mripard@...nel.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 2/5] drm/dp: Allow an early call to register DDC i2c
 bus

On Fri 07 May 16:18 CDT 2021, Lyude Paul wrote:

> Adding ville from Intel to also get their take on this.
> 
> In general we've been trying to move DRM to a design where we don't expose any
> devices until everything is ready. That's pretty much the main reason that we
> register things during bridge attach time. Note though that even before the
> DDC bus is registered it should still be usable, just things like get_device()
> won't work.
> 
> This isn't the first time we've run into a problem like the one you're trying
> to solve though, Tegra currently has a similar issue. Something we discussed
> as a possible long-term solution for this was splitting i2c_add_adapter() into
> a minimal initialization function and a registration function. Linux's device
> core already allows for this (device_initialize() and device_add(), which are
> called together when device_register() is called). Would this be a solution
> that might work for you (and even better, would you possibly be willing to
> write the patches? :)
> 

It's not enough that the adapter is half-baked, because the bridge's
initialization depends on that the panel device is done probing, and the
panel driver will only complete its probe if it can find it's resources.

So we need a mechanism to fully create the resources exposed by the
bridge chip (i2c bus, gpio chip and (soon) a pwm chip), then allow the
panel to probe and after that initialize the bridge.

We did discuss possible ways to register these resources and then
"sleep for a while" before resolving the panel, but what we came up with
was definitely suboptimal - and ugly.

Regards,
Bjorn

> On Mon, 2021-05-03 at 14:58 -0700, Douglas Anderson wrote:
> > It can be helpful to fully register the AUX channel as an i2c bus even
> > before the bridge is created. Let's optionally allow bridges to do
> > that.
> > 
> > Specifically the case we're running into:
> > - The panel driver wants to get its DDC bus at probe time.
> > - The ti-sn65dsi86 MIPI-to-eDP bridge code, which provides the DDC
> >   bus, wants to get the panel at probe time.
> > 
> > The next patches ("drm/bridge: ti-sn65dsi86: Promote the AUX channel
> > to its own sub-dev") solves the chicken-and-egg problem by breaking
> > the ti-sn65dsi86 driver into sub-devices, but in order for it to
> > actually work we need the i2c bus to get registered at probe time and
> > not in bridge attach time.
> > 
> > Cc: Lyude Paul <lyude@...hat.com>
> > Cc: Thierry Reding <treding@...dia.com>
> > Signed-off-by: Douglas Anderson <dianders@...omium.org>
> > ---
> > 
> > Changes in v6:
> > - ("drm/dp: Allow an early call to register DDC i2c bus") new for v6.
> > 
> >  drivers/gpu/drm/drm_dp_helper.c | 67 +++++++++++++++++++++++++++------
> >  include/drm/drm_dp_helper.h     |  2 +
> >  2 files changed, 57 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_dp_helper.c
> > b/drivers/gpu/drm/drm_dp_helper.c
> > index cb56d74e9d38..830294f0b341 100644
> > --- a/drivers/gpu/drm/drm_dp_helper.c
> > +++ b/drivers/gpu/drm/drm_dp_helper.c
> > @@ -1757,6 +1757,49 @@ void drm_dp_aux_init(struct drm_dp_aux *aux)
> >  }
> >  EXPORT_SYMBOL(drm_dp_aux_init);
> >  
> > +/**
> > + * drm_dp_aux_register_ddc() - register the DDC parts of the aux channel
> > + * @aux: DisplayPort AUX channel
> > + *
> > + * This can be called after drm_dp_aux_init() to fully register the ddc bus
> > + * as an i2c adapter with the rest of Linux.
> > + *
> > + * If you don't explicitly call this function it will be done implicitly as
> > + * part of drm_dp_aux_register().
> > + *
> > + * Returns 0 on success or a negative error code on failure.
> > + */
> > +int drm_dp_aux_register_ddc(struct drm_dp_aux *aux)
> > +{
> > +       WARN_ON_ONCE(!aux->dev);
> > +
> > +       aux->ddc.class = I2C_CLASS_DDC;
> > +       aux->ddc.owner = THIS_MODULE;
> > +       aux->ddc.dev.parent = aux->dev;
> > +
> > +       strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
> > +               sizeof(aux->ddc.name));
> > +
> > +       return i2c_add_adapter(&aux->ddc);
> > +}
> > +EXPORT_SYMBOL(drm_dp_aux_register_ddc);
> > +
> > +/**
> > + * drm_dp_aux_unregister_ddc() - unregister the DDC parts of the aux
> > channel
> > + *
> > + * This is useful if you called drm_dp_aux_register_ddc(). If you let
> > + * drm_dp_aux_register() implicitly register the DDC for you then you don't
> > + * need to worry about calling this yourself.
> > + *
> > + * @aux: DisplayPort AUX channel
> > + */
> > +void drm_dp_aux_unregister_ddc(struct drm_dp_aux *aux)
> > +{
> > +       i2c_del_adapter(&aux->ddc);
> > +       aux->ddc.dev.parent = NULL;
> > +}
> > +EXPORT_SYMBOL(drm_dp_aux_unregister_ddc);
> > +
> >  /**
> >   * drm_dp_aux_register() - initialise and register aux channel
> >   * @aux: DisplayPort AUX channel
> > @@ -1793,20 +1836,19 @@ int drm_dp_aux_register(struct drm_dp_aux *aux)
> >         if (!aux->ddc.algo)
> >                 drm_dp_aux_init(aux);
> >  
> > -       aux->ddc.class = I2C_CLASS_DDC;
> > -       aux->ddc.owner = THIS_MODULE;
> > -       aux->ddc.dev.parent = aux->dev;
> > -
> > -       strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
> > -               sizeof(aux->ddc.name));
> > +       /*
> > +        * Implicitly register if drm_dp_aux_register_ddc() wasn't already
> > +        * called (as evidenced by a NULL parent pointer).
> > +        */
> > +       if (!aux->ddc.dev.parent) {
> > +               ret = drm_dp_aux_register_ddc(aux);
> > +               if (ret)
> > +                       return ret;
> > +       }
> >  
> >         ret = drm_dp_aux_register_devnode(aux);
> > -       if (ret)
> > -               return ret;
> > -
> > -       ret = i2c_add_adapter(&aux->ddc);
> >         if (ret) {
> > -               drm_dp_aux_unregister_devnode(aux);
> > +               drm_dp_aux_unregister_ddc(aux);
> >                 return ret;
> >         }
> >  
> > @@ -1821,7 +1863,8 @@ EXPORT_SYMBOL(drm_dp_aux_register);
> >  void drm_dp_aux_unregister(struct drm_dp_aux *aux)
> >  {
> >         drm_dp_aux_unregister_devnode(aux);
> > -       i2c_del_adapter(&aux->ddc);
> > +       if (aux->ddc.dev.parent)
> > +               drm_dp_aux_unregister_ddc(aux);
> >  }
> >  EXPORT_SYMBOL(drm_dp_aux_unregister);
> >  
> > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > index e932b2c40095..d4d2d5e25bb7 100644
> > --- a/include/drm/drm_dp_helper.h
> > +++ b/include/drm/drm_dp_helper.h
> > @@ -2021,6 +2021,8 @@ bool drm_dp_lttpr_pre_emphasis_level_3_supported(const
> > u8 caps[DP_LTTPR_PHY_CAP_
> >  
> >  void drm_dp_remote_aux_init(struct drm_dp_aux *aux);
> >  void drm_dp_aux_init(struct drm_dp_aux *aux);
> > +int drm_dp_aux_register_ddc(struct drm_dp_aux *aux);
> > +void drm_dp_aux_unregister_ddc(struct drm_dp_aux *aux);
> >  int drm_dp_aux_register(struct drm_dp_aux *aux);
> >  void drm_dp_aux_unregister(struct drm_dp_aux *aux);
> >  
> 
> -- 
> Cheers,
>  Lyude Paul (she/her)
>  Software Engineer at Red Hat
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ