Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Matthew Brost <matthew.brost@intel.com>
Subject: Re: [PATCH v3 5/5] drm/xe: Move job creation out of the struct xe_migrate::job_mutex
Date: Fri, 24 May 2024 09:14:56 -0400	[thread overview]
Message-ID: <ZlCS0CH2ZYsCgbPW@intel.com> (raw)
In-Reply-To: <20240524071940.83042-6-thomas.hellstrom@linux.intel.com>

On Fri, May 24, 2024 at 09:19:40AM +0200, Thomas Hellström wrote:
> In order to be able to run gpu jobs from reclaim context,
> move job creation (where allocation takes place) out of the
> struct xe_migrate::job_mutex, and prime that mutex as reclaim
> tainted.
> 
> Jobs that may need to run from reclaim context include
> CCS metadata extraction at shrinking time.
> 

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

> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
>  drivers/gpu/drm/xe/xe_migrate.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index bacb23de411b..cccffaf3db06 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -383,6 +383,9 @@ struct xe_migrate *xe_migrate_init(struct xe_tile *tile)
>  	}
>  
>  	mutex_init(&m->job_mutex);
> +	fs_reclaim_acquire(GFP_KERNEL);
> +	might_lock(&m->job_mutex);
> +	fs_reclaim_release(GFP_KERNEL);
>  
>  	err = drmm_add_action_or_reset(&xe->drm, xe_migrate_fini, m);
>  	if (err)
> @@ -807,7 +810,6 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
>  						  IS_DGFX(xe) ? dst_is_vram : dst_is_pltt,
>  						  src_L0, ccs_ofs, copy_ccs);
>  
> -		mutex_lock(&m->job_mutex);
>  		job = xe_bb_create_migration_job(m->q, bb,
>  						 xe_migrate_batch_base(m, usm),
>  						 update_idx);
> @@ -827,6 +829,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
>  				goto err_job;
>  		}
>  
> +		mutex_lock(&m->job_mutex);
>  		xe_sched_job_arm(job);
>  		dma_fence_put(fence);
>  		fence = dma_fence_get(&job->drm.s_fence->finished);
> @@ -844,7 +847,6 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
>  err_job:
>  		xe_sched_job_put(job);
>  err:
> -		mutex_unlock(&m->job_mutex);
>  		xe_bb_free(bb, NULL);
>  
>  err_sync:
> @@ -1044,7 +1046,6 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  			flush_flags = MI_FLUSH_DW_CCS;
>  		}
>  
> -		mutex_lock(&m->job_mutex);
>  		job = xe_bb_create_migration_job(m->q, bb,
>  						 xe_migrate_batch_base(m, usm),
>  						 update_idx);
> @@ -1067,6 +1068,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  				goto err_job;
>  		}
>  
> +		mutex_lock(&m->job_mutex);
>  		xe_sched_job_arm(job);
>  		dma_fence_put(fence);
>  		fence = dma_fence_get(&job->drm.s_fence->finished);
> @@ -1083,7 +1085,6 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  err_job:
>  		xe_sched_job_put(job);
>  err:
> -		mutex_unlock(&m->job_mutex);
>  		xe_bb_free(bb, NULL);
>  err_sync:
>  		/* Sync partial copies if any. FIXME: job_mutex? */
> @@ -1377,9 +1378,6 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
>  			write_pgtable(tile, bb, 0, &updates[i], pt_update);
>  	}
>  
> -	if (!q)
> -		mutex_lock(&m->job_mutex);
> -
>  	job = xe_bb_create_migration_job(q ?: m->q, bb,
>  					 xe_migrate_batch_base(m, usm),
>  					 update_idx);
> @@ -1420,6 +1418,9 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
>  		if (err)
>  			goto err_job;
>  	}
> +	if (!q)
> +		mutex_lock(&m->job_mutex);
> +
>  	xe_sched_job_arm(job);
>  	fence = dma_fence_get(&job->drm.s_fence->finished);
>  	xe_sched_job_push(job);
> @@ -1435,8 +1436,6 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
>  err_job:
>  	xe_sched_job_put(job);
>  err_bb:
> -	if (!q)
> -		mutex_unlock(&m->job_mutex);
>  	xe_bb_free(bb, NULL);
>  err:
>  	drm_suballoc_free(sa_bo, NULL);
> -- 
> 2.44.0
> 

  reply	other threads:[~2024-05-24 13:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24  7:19 [PATCH v3 0/5] drm/xe: Allow migrate vm gpu submissions from reclaim context Thomas Hellström
2024-05-24  7:19 ` [PATCH v3 1/5] drm/xe: Decouple job seqno and lrc seqno Thomas Hellström
2024-05-24 12:26   ` Rodrigo Vivi
2024-05-24 12:56     ` Thomas Hellström
2024-05-24 19:44       ` Rodrigo Vivi
2024-05-24  7:19 ` [PATCH v3 2/5] drm/xe: Split lrc seqno fence creation up Thomas Hellström
2024-05-24 12:32   ` Rodrigo Vivi
2024-05-24  7:19 ` [PATCH v3 3/5] drm/xe: Don't initialize fences at xe_sched_job_create() Thomas Hellström
2024-05-24 13:12   ` Rodrigo Vivi
2024-05-24 13:22     ` Thomas Hellström
2024-05-24 19:45       ` Rodrigo Vivi
2024-05-24  7:19 ` [PATCH v3 4/5] drm/xe: Remove xe_lrc_create_seqno_fence() Thomas Hellström
2024-05-24 12:33   ` Rodrigo Vivi
2024-05-24  7:19 ` [PATCH v3 5/5] drm/xe: Move job creation out of the struct xe_migrate::job_mutex Thomas Hellström
2024-05-24 13:14   ` Rodrigo Vivi [this message]
2024-05-24  8:18 ` ✓ CI.Patch_applied: success for drm/xe: Allow migrate vm gpu submissions from reclaim context (rev3) Patchwork
2024-05-24  8:18 ` ✓ CI.checkpatch: " Patchwork
2024-05-24  8:19 ` ✓ CI.KUnit: " Patchwork
2024-05-24  8:31 ` ✓ CI.Build: " Patchwork
2024-05-24  8:33 ` ✓ CI.Hooks: " Patchwork
2024-05-24  8:35 ` ✓ CI.checksparse: " Patchwork
2024-05-24  9:05 ` ✓ CI.BAT: " Patchwork
2024-05-24 10:48 ` ✗ 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=ZlCS0CH2ZYsCgbPW@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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