Re: [PATCH] drm: add check for plane functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 17, 2017 at 01:08:43PM +0200, Ville Syrjälä wrote:
> On Fri, Mar 17, 2017 at 03:46:34PM +0530, Shirish S wrote:
> > On Fri, Mar 17, 2017 at 3:26 PM, Ville Syrjälä
> > <ville.syrjala@xxxxxxxxxxxxxxx> wrote:
> > > On Fri, Mar 17, 2017 at 01:25:08PM +0530, Shirish S wrote:
> > >> update_plane() and disable_plane() functions
> > >> assoiciated with setting plane are called
> > >> without any check, causing kernel panic.
> > >
> > > Why are you registering a plane without the funcs?
> > >
> > Basically, enabling planes and making them fully functional is
> > generally a 2 -step process,
> > so i suggest for new drivers wanting to implement/re-design  planes,
> > would like to tap
> > the flow at enabling(listing caps) and later at ensuring it works.
> 
> I don't think there's much point in exposing something that
> doesn't work. And even if you do, you could always just use
> stub functions.

Yes, just wire up stub functions if you want to enable planes with
multi-step patch series.

> > I noticed that there is a underlying assumption only for
> > plane->(funcs) are implemented, whereas for
> > other function for crtc/connector/encoder function calls there is a
> > sanity check(or WARN_ON) through out the framework.
> > 
> > I believe this check wont cause any performance/functional impact.
> > Please let me know if am missing anything.
> > And further more help developers to focus on enabling planes via
> > various tests without causing reboots/system hangs.
> 
> I don't particularly like adding more unconditional runtime checks
> that just to protect developers from themselves. If you really
> think there's value in these, then at least add the checks into
> the plane init codepath so that it's a one time cost.
> 
> The same approach could be used for all the other non-optional
> hooks. Otherwise the same WARN_ON()s would have to be sprinkled
> all over the place, and there's always the risk of missing a few
> codepaths that call a specific hook.

I think for these here there's negative value - it allows developers to
create completely broken planes. Stub functions really seem like a much
better idea.

Note that for the helpers we allow you to not have a lot of the hooks,
since there's indeed piles of hw where they are not needed. But this one
here really is.

Also, with an atomic driver you get it for free, so there's really never
any reason at all not too hook this up.

Add this to the list of reasons why you _really_ should have an atomic
driver :-)
-Daniel

> 
> > >>
> > >> This patch adds the required check to avoid it.
> > >>
> > >> Change-Id: I0d6792608b33e674c217388aa57c4b7d680d9bc7
> > >> Signed-off-by: Shirish S <shirish.s@xxxxxxx>
> > >> ---
> > >>  drivers/gpu/drm/drm_plane.c | 6 ++++++
> > >>  1 file changed, 6 insertions(+)
> > >>
> > >> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > >> index 249c0ae..f675f8b 100644
> > >> --- a/drivers/gpu/drm/drm_plane.c
> > >> +++ b/drivers/gpu/drm/drm_plane.c
> > >> @@ -456,6 +456,12 @@ static int __setplane_internal(struct drm_plane *plane,
> > >>  {
> > >>       int ret = 0;
> > >>
> > >> +     if (plane->funcs->disable_plane == NULL ||
> > >> +                             plane->funcs->update_plane == NULL) {
> > >> +             DRM_ERROR("plane funcs not implemented\n");
> > >> +             ret = -EPERM;
> > >> +             goto out;
> > >> +     }
> > >>       /* No fb means shut it down */
> > >>       if (!fb) {
> > >>               plane->old_fb = plane->fb;
> > >> --
> > >> 2.7.4
> > >>
> > >> _______________________________________________
> > >> dri-devel mailing list
> > >> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> > >> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > >
> > > --
> > > Ville Syrjälä
> > > Intel OTC
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux