From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/i915/icl: decouple dpll ids from type
Date: Wed, 27 Feb 2019 20:15:51 +0200 [thread overview]
Message-ID: <20190227181551.GY20097@intel.com> (raw)
In-Reply-To: <20190226190258.c6awuraryxdghpy2@ldmartin-desk.jf.intel.com>
On Tue, Feb 26, 2019 at 11:02:58AM -0800, Lucas De Marchi wrote:
> On Tue, Feb 26, 2019 at 04:48:23PM +0200, Ville Syrjälä wrote:
> >> >This seems a rather roundabout way of doing things when we already have
> >> >the vfuncs.
> >> >
> >> >How about just:
> >> >
> >> >mg_pll_enable()
> >> >{
> >> > icl_pll_enable(MG_REG);
> >> >}
> >> >
> >> >combo_pll_enable()
> >> >{
> >> > icl_pll_enable(COMBO_REG);
> >> >}
> >> >
> >> >or something along those lines.
> >>
> >> humn... I thought about this approach as an intermediate step to the
> >> full blown "add another vfunc struct and pass that instead". Platforms
> >> are free to use this for small differences that don't justify going that
> >> route.
> >>
> >> In your approach you go the route of "always use vfunc and add
> >> additional arguments to the common function".
> >> Compared to the approach here, it's not subjective on what to do in
> >> similar cases, but has its downsides as well.
> >>
> >> 1) The function can't be inlined so there's and extra hop when calling
> >> the vfunc
> >
> >We already have the vfunc. And even if we didn't, an extra vfunc in
> >modesetting code is probably in the noise.
>
> I'm talking about the extra function you added here. The vfunc will call
> this, which then calls the real common function.
>
> >> 2) if the callee is inlined we basically duplicate .text, but I doubt
> >> any compiler would do that
> >
> >Either it inlines or not. Why should we care in this particular case?
>
> In this case I'm referring to icl_pll_enable() being inlined inside
> mg_pll_enable() and combo_pll_enable().
>
> But let's leave alone the inlines and extra function calls and talk
> about the organization below.
>
> >> 3) reg as the argument is probably not a good choice as it may change
> >> in the next platform - so we would need to add a "type" nonetheless
> >
> >Not sure what you mean. If the reg changes you pass in a different reg.
> >If other things differ significantly you write a new function.
>
> because here the function can share more when I consider the *type* of
> the pll, not if it's reg 0x10, 0x30 or 0x40.
>
> >>
> >> Since flags is already there
> >> and under-utilized I don't see much
> >> advantage on the vfunc-only approach. I'm not strongly opposed though:
> >> IMO both are better than the current state.
> >
> >If the existing mechanism is sufficient to the task then we should
> >generally use it rather than adding yet another mechanism. This
> >keeps the code more uniform and thus easier for everyone to
> >understand.
>
>
> both of them already exist - flags is already there. If I handle the
> *types* differently with your approach I would basically have:
>
> enum pll_type {
> A,
> B,
> C,
> }
>
> pll_enable()
> {
> ...
>
> if (type == A)
> else if (type == B)
> else
This thing shouldn't have any ifs in it if this is done right.
The more ifs you have the harder it is to follow the code.
Ideally we'd have none.
>
> ...
> }
>
> a_pll_enable()
> {
> return pll_enable(A);
> }
>
> b_pll_enable()
> {
> return pll_enable(B);
> }
>
> c_pll_enable()
> {
> return pll_enable(C);
> }
>
> static const struct funcs a_funcs = {
> .enable = a_pll_enable(),
> };
> static const struct funcs b_funcs = {
> .eanble = b_pll_enable(),
> };
> static const struct funcs c_funcs = {
> .enable = c_pll_enable(),
> };
>
> static const struct plls[] = {
> { a_funcs, ... },
> { b_funcs, ... },
> { c_funcs, ... },
> };
>
>
> This approach has its value when the implementations are completely
> different - e.g. the mg vs combo approach in patch 1. When the
> implementation is very similar, what I'm proposing is to be able to do:
>
> enum pll_type {
> A,
> B,
> C,
> }
>
> pll_enable()
> {
> ...
>
> if (type == A)
> else if (type == B)
> else
>
> ...
> }
>
> static const struct funcs funcs = {
> .enable = pll_enable(),
> };
>
> static const struct plls[] = {
> { funcs, A, ... }
> { funcs, B, ... }
> { funcs, C, ... }
> }
>
> We have less boilerplate code and the information is in the table rather
> than spread across multiple functions. Don't get me wrong, the other
> approach has its place and is even used in patch 1 because the impl
> is totally different.
>
> In the ICL case, the type in the table is used to tweak the behavior for
> MG vs TBT, because they reuse most of the same calls. Combo vs MG is
> handled in patch 1, not here.
>
> Lucas De Marchi
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-02-27 18:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 23:23 [PATCH 1/3] drm/i915/icl: move MG pll hw_state readout Lucas De Marchi
2019-02-22 23:23 ` [PATCH 2/3] drm/i915: introduce platform_flags to use with dpll hooks Lucas De Marchi
2019-02-22 23:23 ` [PATCH 3/3] drm/i915/icl: decouple dpll ids from type Lucas De Marchi
2019-02-25 20:45 ` Ville Syrjälä
2019-02-25 21:28 ` Lucas De Marchi
2019-02-26 14:48 ` Ville Syrjälä
2019-02-26 19:02 ` Lucas De Marchi
2019-02-27 18:15 ` Ville Syrjälä [this message]
2019-02-23 0:09 ` ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915/icl: move MG pll hw_state readout Patchwork
2019-02-23 6:03 ` ✓ Fi.CI.IGT: " Patchwork
2019-02-25 20:42 ` [PATCH 1/3] " Ville Syrjälä
2019-02-26 0:03 ` Lucas De Marchi
2019-02-26 14:21 ` Ville Syrjälä
2019-02-26 19:15 ` Lucas De Marchi
2019-02-27 18:13 ` Ville Syrjälä
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190227181551.GY20097@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.