All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [Intel-gfx] [PATCH 1/4] drm/i915/guc: Verify result from CTB (de)register action
Date: Wed, 18 Aug 2021 16:21:46 +0200	[thread overview]
Message-ID: <YR0XemRAhh6kmJw0@phenom.ffwll.local> (raw)
In-Reply-To: <20210701155513.2024-2-michal.wajdeczko@intel.com>

On Thu, Jul 01, 2021 at 05:55:10PM +0200, Michal Wajdeczko wrote:
> In commit b839a869dfc9 ("drm/i915/guc: Add support for data
> reporting in GuC responses") we missed the hypothetical case
> that GuC might return positive non-zero value as success data.
> 
> While that would be lucky treated as error case, and at the
> end will result in reporting valid -EIO, in the meantime this
> value will be passed to ERR_PTR that could be misleading.
> 
> v2: rebased
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Dan Carpenter <dan.carpenter@oracle.com>

Return value where all integers are possible is always a bit fragile,
especially here where the meaning additionally depends upon whether you
supply a reply buffer or not.

Would be good to document this with some kerneldoc, but maybe the CTB
interface is a bit too unclear here and that's not worth it (there's at
least a ton of functions/variants that just arent used).

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c
> index 43409044528e..a26bb55c0898 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c
> @@ -148,12 +148,15 @@ static int guc_action_register_ct_buffer(struct intel_guc *guc, u32 type,
>  		FIELD_PREP(HOST2GUC_REGISTER_CTB_REQUEST_MSG_2_DESC_ADDR, desc_addr),
>  		FIELD_PREP(HOST2GUC_REGISTER_CTB_REQUEST_MSG_3_BUFF_ADDR, buff_addr),
>  	};
> +	int ret;
>  
>  	GEM_BUG_ON(type != GUC_CTB_TYPE_HOST2GUC && type != GUC_CTB_TYPE_GUC2HOST);
>  	GEM_BUG_ON(size % SZ_4K);
>  
>  	/* CT registration must go over MMIO */
> -	return intel_guc_send_mmio(guc, request, ARRAY_SIZE(request), NULL, 0);
> +	ret = intel_guc_send_mmio(guc, request, ARRAY_SIZE(request), NULL, 0);
> +
> +	return ret > 0 ? -EPROTO : ret;
>  }
>  
>  static int ct_register_buffer(struct intel_guc_ct *ct, u32 type,
> @@ -177,11 +180,14 @@ static int guc_action_deregister_ct_buffer(struct intel_guc *guc, u32 type)
>  		FIELD_PREP(GUC_HXG_REQUEST_MSG_0_ACTION, GUC_ACTION_HOST2GUC_DEREGISTER_CTB),
>  		FIELD_PREP(HOST2GUC_DEREGISTER_CTB_REQUEST_MSG_1_TYPE, type),
>  	};
> +	int ret;
>  
>  	GEM_BUG_ON(type != GUC_CTB_TYPE_HOST2GUC && type != GUC_CTB_TYPE_GUC2HOST);
>  
>  	/* CT deregistration must go over MMIO */
> -	return intel_guc_send_mmio(guc, request, ARRAY_SIZE(request), NULL, 0);
> +	ret = intel_guc_send_mmio(guc, request, ARRAY_SIZE(request), NULL, 0);
> +
> +	return ret > 0 ? -EPROTO : ret;
>  }
>  
>  static int ct_deregister_buffer(struct intel_guc_ct *ct, u32 type)
> -- 
> 2.25.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2021-08-18 14:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 15:55 [Intel-gfx] [PATCH 0/4] drm/i915/guc: Improve CTB error handling Michal Wajdeczko
2021-07-01 15:55 ` Michal Wajdeczko
2021-07-01 15:55 ` [Intel-gfx] [PATCH 1/4] drm/i915/guc: Verify result from CTB (de)register action Michal Wajdeczko
2021-07-01 15:55   ` Michal Wajdeczko
2021-08-18 14:21   ` Daniel Vetter [this message]
2021-07-01 15:55 ` [Intel-gfx] [PATCH 2/4] drm/i915/guc: Print error name on CTB (de)registration failure Michal Wajdeczko
2021-07-01 15:55   ` Michal Wajdeczko
2021-08-18 14:20   ` [Intel-gfx] " Daniel Vetter
2021-08-18 15:11     ` Michal Wajdeczko
2021-08-18 16:35       ` Daniel Vetter
2021-08-18 19:12         ` Michal Wajdeczko
2021-08-19  8:35           ` Daniel Vetter
2021-07-01 15:55 ` [Intel-gfx] [PATCH 3/4] drm/i915/guc: Print error name on CTB send failure Michal Wajdeczko
2021-07-01 15:55   ` Michal Wajdeczko
2021-08-18 14:22   ` [Intel-gfx] " Daniel Vetter
2021-07-01 15:55 ` [Intel-gfx] [PATCH 4/4] drm/i915/guc: Move and improve error message for missed CTB reply Michal Wajdeczko
2021-07-01 15:55   ` Michal Wajdeczko
2021-08-18 14:24   ` [Intel-gfx] " Daniel Vetter
2021-07-01 20:31 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/guc: Improve CTB error handling Patchwork
2021-07-02  1:31 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=YR0XemRAhh6kmJw0@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michal.wajdeczko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.