From: Jani Nikula <jani.nikula@linux.intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
Intel-gfx@lists.freedesktop.org
Subject: Re: [RFC] drm/i915: Smarten up and use to_i915() everywhere
Date: Thu, 17 Mar 2016 20:46:05 +0200 [thread overview]
Message-ID: <871t79hriq.fsf@intel.com> (raw)
In-Reply-To: <1458230458-14176-1-git-send-email-tvrtko.ursulin@linux.intel.com>
On Thu, 17 Mar 2016, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> There is a lot of ways to get to our dev_priv depending on which
> object is at hand and often what was chosen by the developer.
>
> We can make to_i915() accept different pointers by using compile
> time magic. Like:
>
> dev_priv = to_i915(request);
> dev_priv = to_i915(engine);
> dev_priv = to_i915(ctx);
> dev_priv = to_i915(dev);
> dev_priv = to_i915(guc);
> dev_priv = to_i915(device);
>
> If an unknown pointer is passed to the function it will cause
> a compile time failure.
>
> Main advantage is that with this in place we could add and
> remove shourtcuts to dev_priv from supported structures easily
> and without touching the code which uses it. If we wanted to
> fiddle with the balance of structure sizes and number of pointer
> dereferencing for example. And it makes the code a bit tidier
> and uniform.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> --
> However the churn is huge so I don't really think this is a
> must have.
The "magic" __I915__() macro was added to support a transition from
using dev pointer to using dev_priv pointer. I like the transition, and
we slowly keep doing it.
IMO there have been two problems with that. First, the transition is
slow, because there's nothing forcing us to switch. This was expected,
as we explicitly didn't want a huge patch (like this). Second, it
appears to *still* confuse people after over a year that you can pass
either type of pointer to the macros in C.
I object to this patch both because it's huge (and I'll get my fair
share of the conflicts) and, more importantly, because it promotes an
appearance of a sort of dynamic typing in a statically typed
language. The latter contains an element of surprise to the programmer,
and surprising is not a quality I want to associate with code.
I think I'd rather promote a sensible set of T_to_i915() macros for
cleanly doing the conversion from various types we often use, and slowly
keep transitioning.
BR,
Jani.
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-03-17 18:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 16:00 [RFC] drm/i915: Smarten up and use to_i915() everywhere Tvrtko Ursulin
2016-03-17 18:46 ` Jani Nikula [this message]
2016-03-17 19:17 ` Chris Wilson
2016-03-17 19:14 ` Chris Wilson
2016-03-18 0:36 ` Arun Siluvery
2016-03-18 9:33 ` Tvrtko Ursulin
2016-03-18 15:28 ` Jani Nikula
2016-03-18 8:31 ` ✗ Fi.CI.BAT: failure for " Patchwork
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=871t79hriq.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=tvrtko.ursulin@linux.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.