Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: intel-xe@lists.freedesktop.org,
	Matthew Brost <matthew.brost@intel.com>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v2] drm/xe: Work around clang multiple goto-label error
Date: Wed, 17 Sep 2025 11:26:51 -0700	[thread overview]
Message-ID: <20250917182651.GA383510@ax162> (raw)
In-Reply-To: <20250911080324.180307-1-thomas.hellstrom@linux.intel.com>

On Thu, Sep 11, 2025 at 10:03:24AM +0200, Thomas Hellström wrote:
> When using drm_exec_retry_on_contention(), clang may consider
> all labels for which we take addresses in a function as
> potential retry goto targets, although strictly only one
> is possible. It will then in some situations generate false
> positive errors.
> 
> In this case, the compiler, for some architectures, consider the
> 
> might_lock(&m->job_mutex);
> 
> as a potential goto target from drm_exec_retry_on_contention(),
> and errors.
> 
> Work around that by moving the xe_validate / drm_exec
> transaction to a separate function.
> 
> v2:
> - New commit message based on analysis of Nathan Chancellor
> 
> Fixes: 59eabff2a352 ("drm/xe: Convert xe_bo_create_pin_map() for exhaustive eviction")
> Cc: Matthew Brost <matthew.brost@intel.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202509101853.nDmyxTEM-lkp@intel.com/
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org> # build

> ---
>  drivers/gpu/drm/xe/xe_migrate.c | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index 6fad5d469629..1d667fa36cf3 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -394,6 +394,24 @@ struct xe_migrate *xe_migrate_alloc(struct xe_tile *tile)
>  	return m;
>  }
>  
> +static int xe_migrate_lock_prepare_vm(struct xe_tile *tile, struct xe_migrate *m, struct xe_vm *vm)
> +{
> +	struct xe_device *xe = tile_to_xe(tile);
> +	struct xe_validation_ctx ctx;
> +	struct drm_exec exec;
> +	int err = 0;
> +
> +	xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
> +		err = xe_vm_drm_exec_lock(vm, &exec);
> +		drm_exec_retry_on_contention(&exec);
> +		err = xe_migrate_prepare_vm(tile, m, vm, &exec);
> +		drm_exec_retry_on_contention(&exec);
> +		xe_validation_retry_on_oom(&ctx, &err);
> +	}
> +
> +	return err;
> +}
> +
>  /**
>   * xe_migrate_init() - Initialize a migrate context
>   * @m: The migration context
> @@ -405,8 +423,6 @@ int xe_migrate_init(struct xe_migrate *m)
>  	struct xe_tile *tile = m->tile;
>  	struct xe_gt *primary_gt = tile->primary_gt;
>  	struct xe_device *xe = tile_to_xe(tile);
> -	struct xe_validation_ctx ctx;
> -	struct drm_exec exec;
>  	struct xe_vm *vm;
>  	int err;
>  
> @@ -416,14 +432,7 @@ int xe_migrate_init(struct xe_migrate *m)
>  	if (IS_ERR(vm))
>  		return PTR_ERR(vm);
>  
> -	err = 0;
> -	xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
> -		err = xe_vm_drm_exec_lock(vm, &exec);
> -		drm_exec_retry_on_contention(&exec);
> -		err = xe_migrate_prepare_vm(tile, m, vm, &exec);
> -		drm_exec_retry_on_contention(&exec);
> -		xe_validation_retry_on_oom(&ctx, &err);
> -	}
> +	err = xe_migrate_lock_prepare_vm(tile, m, vm);
>  	if (err)
>  		return err;
>  
> -- 
> 2.51.0
> 

      parent reply	other threads:[~2025-09-17 18:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11  8:03 [PATCH v2] drm/xe: Work around clang multiple goto-label error Thomas Hellström
2025-09-11  8:14 ` ✓ CI.KUnit: success for " Patchwork
2025-09-11  9:01 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-11 13:40 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-11 15:48 ` [PATCH v2] " Lucas De Marchi
2025-09-17 18:26 ` Nathan Chancellor [this message]

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=20250917182651.GA383510@ax162 \
    --to=nathan@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lkp@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@linux.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