[Intel-gfx] [PATCH v8 5/7] drm/i915: keep track of used entries in MOCS table
Chris Wilson
chris at chris-wilson.co.uk
Tue Jan 22 14:40:48 UTC 2019
Quoting Lucas De Marchi (2019-01-22 05:12:25)
> Instead of considering we have defined entries for any index in the
> table, let's keep track of the ones we explicitly defined. This will
> allow Gen 11 to have it's new table defined in which we have holes of
> undefined entries.
>
> Repeated comments about the meaning of undefined entries were removed
> since they are overly verbose and copy-pasted in several functions: now
> the definition is in the top only.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
> drivers/gpu/drm/i915/intel_mocs.c | 88 ++++++++++++++++++++-----------
> 1 file changed, 57 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_mocs.c b/drivers/gpu/drm/i915/intel_mocs.c
> index faae2eefc5cc..af2ae2f396ae 100644
> --- a/drivers/gpu/drm/i915/intel_mocs.c
> +++ b/drivers/gpu/drm/i915/intel_mocs.c
> @@ -28,6 +28,7 @@
> struct drm_i915_mocs_entry {
> u32 control_value;
> u16 l3cc_value;
> + u16 used;
> };
> + /* Set unused values to PTE */
> + unused_index = I915_MOCS_PTE;
> +
> + for (i = 0; i < table.size / 2; i++) {
> + u16 low = table.table[2 * i].used ?
> + 2 * i : unused_index;
> + u16 high = table.table[2 * i + 1].used ?
> + 2 * i + 1 : unused_index;
I'm underwhelmed here.
Could we not do something like
static unsigned int
get_entry_index(struct tbl *tbl, unsigned int idx, unsigned int unused_index)
{
return tbl->used ? idx : unused_index;
}
u16 lo = get_entry_index(table.table, 2 * i, unused_index);
u16 hi = get_entry_index(table.table, 2 * i + 1, unused_index);
That just fits and repeated enough to be worth a little extra effort.
-Chris
More information about the Intel-gfx
mailing list