All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: <intel-gfx@lists.freedesktop.org>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v2 4/6] drm/i915/gt: add a macro for mock gt wakeref special value and use it
Date: Thu, 26 Sep 2024 16:49:06 -0400	[thread overview]
Message-ID: <ZvXIwmTfzK6mx9bb@intel.com> (raw)
In-Reply-To: <1da887a6b4fe1ec45355571ea7b56d91fadf0af2.1726680898.git.jani.nikula@intel.com>

On Wed, Sep 18, 2024 at 08:35:46PM +0300, Jani Nikula wrote:
> Add a dedicated macro for the special mock gt wakeref value, with a cast
> to intel_wakeref_t, instead of assuming you can assign or compare the
> wakeref to -ENODEV directly.
> 
> Arguably the whole thing is a hack that should not exist, but at least
> make it slightly less hacky.

I couldn't agree more

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> 
> Side note: If this value were to ever end up in
> intel_ref_tracker_free(), it would wreak havoc.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/gt/intel_gt_pm.h            | 6 +++++-
>  drivers/gpu/drm/i915/gt/intel_tlb.c              | 2 +-
>  drivers/gpu/drm/i915/selftests/mock_gem_device.c | 2 +-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> index 911fd0160221..fef8d5d288f8 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> @@ -105,9 +105,13 @@ int intel_gt_runtime_resume(struct intel_gt *gt);
>  
>  ktime_t intel_gt_get_awake_time(const struct intel_gt *gt);
>  
> +#define INTEL_WAKEREF_MOCK_GT ((intel_wakeref_t)-ENODEV)
> +
>  static inline bool is_mock_gt(const struct intel_gt *gt)
>  {
> -	return I915_SELFTEST_ONLY(gt->awake == -ENODEV);
> +	BUILD_BUG_ON(INTEL_WAKEREF_DEF == INTEL_WAKEREF_MOCK_GT);
> +
> +	return I915_SELFTEST_ONLY(gt->awake == INTEL_WAKEREF_MOCK_GT);
>  }
>  
>  #endif /* INTEL_GT_PM_H */
> diff --git a/drivers/gpu/drm/i915/gt/intel_tlb.c b/drivers/gpu/drm/i915/gt/intel_tlb.c
> index 756e9ebbc725..2487768bc230 100644
> --- a/drivers/gpu/drm/i915/gt/intel_tlb.c
> +++ b/drivers/gpu/drm/i915/gt/intel_tlb.c
> @@ -122,7 +122,7 @@ void intel_gt_invalidate_tlb_full(struct intel_gt *gt, u32 seqno)
>  {
>  	intel_wakeref_t wakeref;
>  
> -	if (I915_SELFTEST_ONLY(gt->awake == -ENODEV))
> +	if (is_mock_gt(gt))
>  		return;
>  
>  	if (intel_gt_is_wedged(gt))
> diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> index 70f3d7bf47d0..ae57eb03dfca 100644
> --- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> +++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
> @@ -203,7 +203,7 @@ struct drm_i915_private *mock_gem_device(void)
>  	intel_root_gt_init_early(i915);
>  	mock_uncore_init(&i915->uncore, i915);
>  	atomic_inc(&to_gt(i915)->wakeref.count); /* disable; no hw support */
> -	to_gt(i915)->awake = -ENODEV;
> +	to_gt(i915)->awake = INTEL_WAKEREF_MOCK_GT;
>  	mock_gt_probe(i915);
>  
>  	ret = intel_region_ttm_device_init(i915);
> -- 
> 2.39.2
> 

  reply	other threads:[~2024-09-26 20:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18 17:35 [PATCH v2 0/6] drm/i915: wakeref fixes and improvements Jani Nikula
2024-09-18 17:35 ` [PATCH v2 1/6] drm/i915/gem: fix bitwise and logical AND mixup Jani Nikula
2024-09-26 20:40   ` Rodrigo Vivi
2024-09-27  8:38     ` Jani Nikula
2024-09-30 13:54       ` Jani Nikula
2024-09-30 14:23         ` Matthew Auld
2024-09-30 14:58           ` Jani Nikula
2024-09-18 17:35 ` [PATCH v2 2/6] drm/i915: use INTEL_WAKEREF_DEF instead of magic -1 for intel_wakeref_t Jani Nikula
2024-09-26 20:45   ` Rodrigo Vivi
2024-09-18 17:35 ` [PATCH v2 3/6] drm/i915/display: return 0 instead of false for disabled power wakeref Jani Nikula
2024-09-26 20:46   ` Rodrigo Vivi
2024-09-18 17:35 ` [PATCH v2 4/6] drm/i915/gt: add a macro for mock gt wakeref special value and use it Jani Nikula
2024-09-26 20:49   ` Rodrigo Vivi [this message]
2024-09-18 17:35 ` [PATCH v2 5/6] drm/i915/audio: be explicit about intel_wakeref_t conversions Jani Nikula
2024-09-26 20:49   ` Rodrigo Vivi
2024-09-18 17:35 ` [PATCH v2 6/6] drm/i915: switch intel_wakeref_t underlying type to struct ref_tracker * Jani Nikula
2024-09-26 20:52   ` Rodrigo Vivi
2024-09-18 18:24 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: wakeref fixes and improvements (rev2) Patchwork
2024-09-18 18:24 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-09-18 18:36 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-09-18 21:37 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: wakeref fixes and improvements (rev3) Patchwork
2024-09-18 21:37 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-09-18 21:38 ` ✓ CI.Patch_applied: success for drm/i915: wakeref fixes and improvements (rev2) Patchwork
2024-09-18 21:39 ` ✗ CI.checkpatch: warning " Patchwork
2024-09-18 21:40 ` ✓ CI.KUnit: success " Patchwork
2024-09-18 21:46 ` ✓ Fi.CI.BAT: success for drm/i915: wakeref fixes and improvements (rev3) Patchwork
2024-09-18 21:51 ` ✓ CI.Build: success for drm/i915: wakeref fixes and improvements (rev2) Patchwork
2024-09-18 21:54 ` ✓ CI.Hooks: " Patchwork
2024-09-18 21:55 ` ✗ CI.checksparse: warning " Patchwork
2024-09-18 22:14 ` ✓ CI.BAT: success " Patchwork
2024-09-19  9:25 ` ✗ Fi.CI.IGT: failure for drm/i915: wakeref fixes and improvements (rev3) Patchwork
2024-09-19 11:05 ` ✗ CI.FULL: failure for drm/i915: wakeref fixes and improvements (rev2) 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=ZvXIwmTfzK6mx9bb@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@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.