Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1636750

Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum mismatches

From Matthias Kaehlcke <mka@chromium.org>
Newsgroups linux.kernel
Subject Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum mismatches
Date 2017-05-05 23:40 +0200
Message-ID <tDT7b-7k4-9@gated-at.bofh.it> (permalink)
References (1 earlier) <tDPdf-4Km-1@gated-at.bofh.it> <tDPwC-4T3-7@gated-at.bofh.it> <tDQVH-5Uw-3@gated-at.bofh.it> <tDRRL-6Av-19@gated-at.bofh.it> <tDS1r-6E3-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

El Fri, May 05, 2017 at 01:29:32PM -0700 Grant Grundler ha dit:

> On Fri, May 5, 2017 at 1:08 PM, Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> ...
> >> > I'm not convinced the patch is making things any better really. To
> >> > fix this really properly, I think we'd need to introduce a new enum
> >> > pch_transcoder and thus avoid the confusion of which type of
> >> > transcoder we're talking about.

I agree, the patch certainly doesn't improve the confusing use of the enums.

> >> Is an enum better than coding an explicit conversion in an inline function?
> >
> > The point of the enum would be to make it more clear which piece of
> > hardware we're talking to in each case.
> 
> Ah ok - I misunderstood - I thought this was already the case.
> 
> > But this would require going
> > through the entire PCH code and changing things to use the right type
> > in each case. Quite a bit of work with little measurable gain I'd say.
> 
> IMHO, one of the best things that happened to C standard was addition
> of strong type checking. It's helped prevent developers from making
> one class of "stupid mistakes". So while this change wouldn't improve
> performance, it would allow a form of automated correctness checking
> that can be enforced with every patch you get (every time the code
> base is compiled).
> 
> In other words, the gain isn't currently measurable the same way
> performance is but I believe it's worth doing.  Given the number of
> typedefs and enums in kernel code, I suspect most kernel developers
> would agree.

I also think that proper use of enums is an additional line of defense
against "stupid mistakes". While weeding out these warnings in
different drivers I came across a few cases were the code was working
out of sheer luck because the (unintentionally) mismatched enums
resolved to the same value.

Cheers

Matthias

> >> Then the code can do some sanity checking as well. Something like:
> >>
> >> enum transcoder pch_to_cpu_enum(enum pipe)
> >> {
> >>     WARN_ON(pipe > FOO);
> >>     return (enum transcoder) pipe;
> >> }
> >
> > That would have to be called pipe_to_pch_transcoder() or something like
> > that.
> >
> >>
> >> > Currently most places expect an
> >> > enum pipe when dealing with PCH transcoders, and enum transcoder
> >> > when dealing with CPU transcoders. But there are some exceptions
> >> > of course.
> >>
> >> cheers,
> >> grant
> >> >
> >

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH RESEND] drm/i915: Fix pipe/transcoder enum mismatches Matthias Kaehlcke <mka@chromium.org> - 2017-05-05 19:30 +0200
  Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum  mismatches Ville Syrjälä <ville.syrjala@linux.intel.com> - 2017-05-05 19:50 +0200
    Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum mismatches Grant Grundler <grundler@chromium.org> - 2017-05-05 21:20 +0200
      Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum  mismatches Ville Syrjälä <ville.syrjala@linux.intel.com> - 2017-05-05 22:20 +0200
        Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum mismatches Grant Grundler <grundler@chromium.org> - 2017-05-05 22:30 +0200
          Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum  mismatches Matthias Kaehlcke <mka@chromium.org> - 2017-05-05 23:40 +0200
    Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum  mismatches Daniel Vetter <daniel@ffwll.ch> - 2017-05-08 09:30 +0200
      Re: [Intel-gfx] [PATCH RESEND] drm/i915: Fix pipe/transcoder enum mismatches Jani Nikula <jani.nikula@linux.intel.com> - 2017-05-08 10:20 +0200

csiph-web