[Intel-gfx] [PATCH] drm/i915/guc: Use formalized struct definition for ads object

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 7 10:39:46 UTC 2017


On Tue, Mar 07, 2017 at 10:29:35AM +0000, Michal Wajdeczko wrote:
> Manual pointer manipulation is error prone. Let compiler calculate
> right offsets for us in case we need to change ads layout.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Oscar Mateo <oscar.mateo at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_guc_submission.c | 49 ++++++++++++++----------------
>  1 file changed, 23 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
> index beb38e3..f87649b 100644
> --- a/drivers/gpu/drm/i915/i915_guc_submission.c
> +++ b/drivers/gpu/drm/i915/i915_guc_submission.c
> @@ -810,22 +810,21 @@ static void guc_addon_create(struct intel_guc *guc)
>  {
>  	struct drm_i915_private *dev_priv = guc_to_i915(guc);
>  	struct i915_vma *vma;
> -	struct guc_ads *ads;
> -	struct guc_policies *policies;
> -	struct guc_mmio_reg_state *reg_state;
> -	struct intel_engine_cs *engine;
> -	enum intel_engine_id id;
>  	struct page *page;
> -	u32 size;
> -
>  	/* The ads obj includes the struct itself and buffers passed to GuC */
> -	size = sizeof(struct guc_ads) + sizeof(struct guc_policies) +
> -			sizeof(struct guc_mmio_reg_state) +
> -			GUC_S3_SAVE_SPACE_PAGES * PAGE_SIZE;
> +	struct __guc_ads_object {
> +		struct guc_ads ads;
> +		struct guc_policies policies;
> +		struct guc_mmio_reg_state reg_state;
> +		u8 reg_state_buffer[GUC_S3_SAVE_SPACE_PAGES * PAGE_SIZE];
> +	} __packed *obj;

A humble request not to call this obj. I was confused later and worrying
about what you were adding to drm_i915_gem_object.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list