[Intel-gfx] [RFC] drm/i915: Smarten up and use to_i915() everywhere

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Fri Mar 18 09:33:35 UTC 2016


On 18/03/16 00:36, Arun Siluvery wrote:
> On 17/03/2016 16:00, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin at 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.
>>
> I get the readability aspect but is it advisable to hide too many things
> under macros? In the new code is it expected to always use these macros?
> if yes then in that case aren't we forcing certain usage? good or bad.
> This has even wider impact than ring/engine renaming. If we must go this
> route then we should at least do it in stages to minimize impact.

No worries it was just an RFC, like an OCD code tidy thing, and I 
definitely agree it is not useful enough in the general scheme of things 
to justify another big disruption.

However, going back to Jani's comment, I am not sure that multiple 
T_to_i915(p) are better than a little bit of fake dynamic typing for 
this special case.

Doing it in stages is a good idea, maybe roughly by a set of related 
files at convenient times. TBD. :)

Regards,

Tvrtko


More information about the Intel-gfx mailing list