Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: <saurabhg.gupta@intel.com>, <alex.zuo@intel.com>,
	<matthew.d.roper@intel.com>, <rodrigo.vivi@intel.com>,
	<tejas.upadhyay@intel.com>
Subject: Re: [PATCH v3 3/7] drm/xe/xe_device: Reintroduce xe_device_get_gt
Date: Tue, 14 Oct 2025 19:28:42 +0200	[thread overview]
Message-ID: <bb9ecccd-0d56-4da0-8130-4619b03a515a@intel.com> (raw)
In-Reply-To: <20251014164758.125598-12-jonathan.cavitt@intel.com>



On 10/14/2025 6:48 PM, Jonathan Cavitt wrote:
> Reintroduce the function xe_device_get_gt, as it was earlier renamed to
> xe_device_lookup_gt.  It performs the same functionality as
> xe_device_lookup_gt, but it guarantees the xe_gt pointer returned is not
> NULL using an assertion.

assert() does not guarantee anything, it will just WARN if cond is false 

> 
> Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Suggested-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_device.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
> index 807db49a5306..af9476879454 100644
> --- a/drivers/gpu/drm/xe/xe_device.h
> +++ b/drivers/gpu/drm/xe/xe_device.h
> @@ -97,6 +97,21 @@ static inline struct xe_gt *xe_device_lookup_gt(struct xe_device *xe, u8 gt_id)
>  	return gt;
>  }
>  
> +/**
> + * xe_device_get_gt() - Same as xe_device_lookup_gt, but return must not be NULL
> + * @xe: The XE device to search
> + * @gt_id: The ID of the GT to search for
> + *
> + * Returns a pointer to the xe_gt struct with the given gt_id.
> + */
> +static inline struct xe_gt *xe_device_get_gt(struct xe_device *xe, u8 gt_id)
> +{
> +	struct xe_gt *gt = xe_device_lookup_gt(xe, gt_id);
> +
> +	xe_assert(xe, gt);

and IMO this trick will not fool the tool as it may still say that gt returned
by the xe_device_lookup_gt() can be NULL, returned here as-is, and caller does
not check for NULL

unless you explicitly tell the tool that xe_assert() is something more than WARN
and it should stop processing at that point, but that is another abuse IMO 

> +	return gt;
> +}
> +
>  /*
>   * Provide a GT structure suitable for performing non-GT MMIO operations against
>   * the primary tile.  Primarily intended for early tile initialization, display


  reply	other threads:[~2025-10-14 17:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 16:47 [PATCH v3 0/7] drm/xe: Guard against NULL return for xe_device_get_gt Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 1/7] drm/xe: s/xe_device_get_gt/xe_device_lookup_gt Jonathan Cavitt
2025-10-14 17:17   ` Michal Wajdeczko
2025-10-14 17:21     ` Cavitt, Jonathan
2025-10-14 16:48 ` [PATCH v3 2/7] drm/xe: Don't call xe_device_lookup_gt twice in xe_hw_engine_lookup Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 3/7] drm/xe/xe_device: Reintroduce xe_device_get_gt Jonathan Cavitt
2025-10-14 17:28   ` Michal Wajdeczko [this message]
2025-10-14 16:48 ` [PATCH v3 4/7] drm/xe: Guard against NULL GT in xe_sriov_vf.c Jonathan Cavitt
2025-10-14 17:32   ` Michal Wajdeczko
2025-10-14 17:34     ` Cavitt, Jonathan
2025-10-14 16:48 ` [PATCH v3 5/7] drm/xe: Guard against NULL GT in xe_pmu.c Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 6/7] drm/xe: Guard against NULL GT in xe_guc.c Jonathan Cavitt
2025-10-14 16:48 ` [PATCH v3 7/7] drm/xe/tests: Use any available GT for testing Jonathan Cavitt
2025-10-14 17:51   ` Michal Wajdeczko
2025-10-14 18:06     ` Cavitt, Jonathan
2025-10-14 16:55 ` ✓ CI.KUnit: success for drm/xe: Guard against NULL return for xe_device_get_gt Patchwork
2025-10-14 17:44 ` ✓ Xe.CI.BAT: " Patchwork
2025-10-15  2:37 ` ✗ Xe.CI.Full: 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=bb9ecccd-0d56-4da0-8130-4619b03a515a@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=saurabhg.gupta@intel.com \
    --cc=tejas.upadhyay@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