[igt-dev] [PATCH i-g-t v18 06/31] lib/intel_allocator: Add intel_allocator core

Chris Wilson chris at chris-wilson.co.uk
Mon Feb 1 16:07:23 UTC 2021


Quoting Zbigniew Kempczyński (2021-01-29 14:44:29)
> +static inline uint64_t CANONICAL(uint64_t address)
> +{
> +       return (int64_t)(address << 16) >> 16;
> +}
> +
> +#define DECANONICAL(offset) (offset & ((1ull << 48) - 1))

Please do define 48 as something like

#define GEN8_GTT_ADDRESS_WIDTH 48

And then we can derive 16 as (64 - GEN8_GTT_WIDTH)

Or if you prefer, HIGH_BIT.

So

static inline uint64_t sign_extend64(uint64_t x, int high)
{
	return (int64_t)(x << (63 - high)) >> 16;
}

static inline uint64_t CANONICAL(uint64_t offset)
{
	sign_extend64(offset, GEN8_GTT_ADDRESS_WIDTH - 1);
}

#define DECANONICAL(offset) (offset & ((1ull << GEN8_GTT_ADDRESS_WIDTH) - 1))
-Chris


More information about the igt-dev mailing list