[Intel-gfx] [PATCH 2/6] drm/i915: Pack the partial view size and offset into a single u64

Chris Wilson chris at chris-wilson.co.uk
Thu Jan 12 14:09:22 UTC 2017

On Wed, Jan 11, 2017 at 09:51:02PM +0000, Chris Wilson wrote:
> Since the partial offset must be page aligned, we can use those low 12
> bits to encode the size of the partial view (which then cannot be larger
> than 8MiB in pages). A requirement for avoiding unused bits inside the
> struct is imposed later by avoiding the clear of the struct (or of
> copying around static initialisers). This is easier to guarantee by
> manual packing into a single u64 - the presence of the u64 inside a
> struct causes gcc to pad the struct out to a u64 boundary, even if we
> use the __packed attribute.

I made a mistake in my testing. :|

I assked gcc whether struct {u64; u32;} was the same size as a u64.
If we ask gcc whether struct {u64; u32;} is 12 bytes, all we need is the
__packed attribute.

Chris Wilson, Intel Open Source Technology Centre

More information about the Intel-gfx mailing list