intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Oscar Mateo <oscar.mateo@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [RFC PATCH 04/20] drm/i915: Transform context WAs into static tables
Date: Mon, 06 Nov 2017 13:59:38 +0200	[thread overview]
Message-ID: <1509969578.5418.53.camel@linux.intel.com> (raw)
In-Reply-To: <1509732588-10599-5-git-send-email-oscar.mateo@intel.com>

On Fri, 2017-11-03 at 11:09 -0700, Oscar Mateo wrote:
> This is for WAs that need to touch registers that get saved/restored
> together with the logical context. The idea is that WAs are "pretty"
> static, so a table is more declarative than a programmatic approah.
> Note however that some amount is caching is needed for those things
> that are dynamic (e.g. things that need some calculation, or have
> a criteria different than the more obvious GEN + stepping).
> 
> Also, this makes very explicit which WAs live in the context.
> 
> Suggested-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>

<SNIP>

> +struct i915_wa_reg;
> +
> +typedef bool (* wa_pre_hook_func)(struct drm_i915_private *dev_priv,
> +				  struct i915_wa_reg *wa);
> +typedef void (* wa_post_hook_func)(struct drm_i915_private *dev_priv,
> +				   struct i915_wa_reg *wa);

To avoid carrying any variables over, how about just apply() hook?
Also, you don't have to have "_hook" going there, it's tak

>  struct i915_wa_reg {
> +	const char *name;

We may want some Kconfig option for skipping these.

> +	enum wa_type {
> +		I915_WA_TYPE_CONTEXT = 0,
> +		I915_WA_TYPE_GT,
> +		I915_WA_TYPE_DISPLAY,
> +		I915_WA_TYPE_WHITELIST
> +	} type;
> +

Any specific reason not to have the gen here too? Then you can have one
big table, instead of tables of tables. Then the numeric code of a WA
(position in that table) would be equally identifying it compared to
the WA name (which is nice to have information, so config time opt-in).

> +	u8 since;
> +	u8 until;

Most seem to have ALL_REVS, so this could be after the coarse-grained
gen-check in the apply function.

> +
>  	i915_reg_t addr;
> -	u32 value;
> -	/* bitmask representing WA bits */
>  	u32 mask;
> +	u32 value;
> +	bool is_masked_reg;

I'd hide this detail into the apply function.

> +
> +	wa_pre_hook_func pre_hook;
> +	wa_post_hook_func post_hook;

	bool (*apply)(const struct i915_wa *wa,
		      struct drm_i915_private *dev_priv);

> +	u32 hook_data;
> +	bool applied;

The big point would be to make this into const, so "applied" would
defeat that.

<SNIP>

> +#define MASK(mask, value)	((mask) << 16 | (value))
> +#define MASK_ENABLE(x)		(MASK((x), (x)))
> +#define MASK_DISABLE(x)		(MASK((x), 0))
>  
> -#define WA_REG(addr, mask, val) do { \
> -		const int r = wa_add(dev_priv, (addr), (mask), (val)); \
> -		if (r) \
> -			return r; \
> -	} while (0)
> +#define SET_BIT_MASKED(m) 		\
> +	.mask = (m),			\
> +	.value = MASK_ENABLE(m),	\
> +	.is_masked_reg = true
>  
> -#define WA_SET_BIT_MASKED(addr, mask) \
> -	WA_REG(addr, (mask), _MASKED_BIT_ENABLE(mask))
> +#define CLEAR_BIT_MASKED( m) 		\
> +	.mask = (m),			\
> +	.value = MASK_DISABLE(m),	\
> +	.is_masked_reg = true
>  
> -#define WA_CLR_BIT_MASKED(addr, mask) \
> -	WA_REG(addr, (mask), _MASKED_BIT_DISABLE(mask))
> +#define SET_FIELD_MASKED(m, v) 		\
> +	.mask = (m),			\
> +	.value = MASK(m, v),		\
> +	.is_masked_reg = true

Lets try to have the struct i915_wa as small as possible, so this could
be calculated in the apply function.

So, avoiding the macros this would indeed become rather declarative;

{
	WA_NAME("WaDisableAsyncFlipPerfMode")
	.gen = ...,
	.reg = MI_MODE,
	.value = ASYNC_FLIP_PERF_DISABLE,
	.apply = set_bit_masked,
},

Or, we could also have;

static const struct i915_wa WaDisableAsyncFlipPerfMode = {
	.gen = ...,
	.reg = MI_MODE,
	.value = ASYNC_FLIP_PERF_DISABLE,
	.apply = set_bit_masked,
};

And then one array of those.

	WA(WaDisableAsyncFlipPerfMode),

Then you could at compile time decide if you stringify and store the
name. But that'd be more const data than necessary (pointers to
structs, instead of an array of structs).

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-11-06 12:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 18:09 [RFC PATCH v5 00/20] Refactor HW workaround code Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 01/20] drm/i915: Remove Gen9 WAs with no effect Oscar Mateo
2017-11-06 12:40   ` Chris Wilson
2017-11-03 18:09 ` [RFC PATCH 02/20] drm/i915: Move a bunch of workaround-related code to its own file Oscar Mateo
2017-11-06 12:42   ` Chris Wilson
2017-11-06 12:47     ` Joonas Lahtinen
2017-11-03 18:09 ` [RFC PATCH 03/20] drm/i915: Split out functions for different kinds of workarounds Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 04/20] drm/i915: Transform context WAs into static tables Oscar Mateo
2017-11-06 11:59   ` Joonas Lahtinen [this message]
2017-11-06 18:54     ` Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 05/20] drm/i915: Transform GT " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 06/20] drm/i915: Transform Whitelist " Oscar Mateo
2017-11-03 20:43   ` [RFC PATCH v2] " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 07/20] drm/i915: Create a new category of display WAs Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 08/20] drm/i915: Print all workaround types correctly in debugfs Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 09/20] drm/i915: Do not store the total counts of WAs Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 10/20] drm/i915: Move WA BB stuff to the workarounds file as well Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 11/20] drm/i915/cnl: Move GT and Display workarounds from init_clock_gating Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 12/20] drm/i915/gen9: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 13/20] drm/i915/cfl: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 14/20] drm/i915/glk: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 15/20] drm/i915/kbl: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 16/20] drm/i915/bxt: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 17/20] drm/i915/skl: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 18/20] drm/i915/chv: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 19/20] drm/i915/bdw: " Oscar Mateo
2017-11-03 18:09 ` [RFC PATCH 20/20] drm/i915: Document the i915_workarounds file Oscar Mateo
2017-11-03 18:37 ` ✗ Fi.CI.BAT: failure for Refactor HW workaround code (rev5) Patchwork
2017-11-03 21:05 ` ✗ Fi.CI.BAT: failure for Refactor HW workaround code (rev6) Patchwork
2017-11-03 21:51 ` [RFC PATCH v5 00/20] Refactor HW workaround code Oscar Mateo

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=1509969578.5418.53.camel@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=oscar.mateo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).