Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	maarten.lankhorst@linux.intel.com,
	intel-xe@lists.freedesktop.org, philippe.lecluse@intel.com
Subject: Re: [Intel-xe] [PATCH 12/37] drm/xe/migrate: Add kerneldoc for the migrate subsystem
Date: Sat, 21 Jan 2023 00:03:58 +0100	[thread overview]
Message-ID: <20230121000358.4cb8d6ec@coco.lan> (raw)
In-Reply-To: <20230112222538.2000142-13-rodrigo.vivi@intel.com>

Em Thu, 12 Jan 2023 17:25:13 -0500
Rodrigo Vivi <rodrigo.vivi@intel.com> escreveu:

> From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> 
> Add kerneldoc for structs and external functions.
> 
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>

LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_migrate.c | 108 +++++++++++++++++++++++++++++++-
>  drivers/gpu/drm/xe/xe_migrate.h |  16 ++++-
>  2 files changed, 120 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index 01177ee31d43..7b9f3de11b47 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -27,16 +27,37 @@
>  
>  #include "../i915/gt/intel_gpu_commands.h"
>  
> +/**
> + * struct xe_migrate - migrate context.
> + */
>  struct xe_migrate {
> +	/** @eng: Default engine used for migration */
>  	struct xe_engine *eng;
> +	/** @gt: Backpointer to the gt this struct xe_migrate belongs to. */
>  	struct xe_gt *gt;
> +	/** @job_mutex: Timeline mutex for @eng. */
>  	struct mutex job_mutex;
> +	/** @pt_bo: Page-table buffer object. */
>  	struct xe_bo *pt_bo;
> +	/**
> +	 * @cleared_bo: Zeroed out bo used as a source for CCS metadata clears
> +	 */
>  	struct xe_bo *cleared_bo;
> +	/** @batch_base_ofs: VM offset of the migration batch buffer */
>  	u64 batch_base_ofs;
> +	/** @usm_batch_base_ofs: VM offset of the usm batch buffer */
>  	u64 usm_batch_base_ofs;
> +	/** @cleared_vram_ofs: VM offset of @cleared_bo. */
>  	u64 cleared_vram_ofs;
> +	/**
> +	 * @fence: dma-fence representing the last migration job batch.
> +	 * Protected by @job_mutex.
> +	 */
>  	struct dma_fence *fence;
> +	/**
> +	 * @vm_update_sa: For integrated, used to suballocate page-tables
> +	 * out of the pt_bo.
> +	 */
>  	struct drm_suballoc_manager vm_update_sa;
>  };
>  
> @@ -45,6 +66,15 @@ struct xe_migrate {
>  #define NUM_PT_SLOTS 32
>  #define NUM_PT_PER_BLIT (MAX_PREEMPTDISABLE_TRANSFER / SZ_2M)
>  
> +/**
> + * xe_gt_migrate_engine() - Get this gt's migrate engine.
> + * @gt: The gt.
> + *
> + * Returns the default migrate engine of this gt.
> + * TODO: Perhaps this function is slightly misplaced, and even unneeded?
> + *
> + * Return: The default migrate engine
> + */
>  struct xe_engine *xe_gt_migrate_engine(struct xe_gt *gt)
>  {
>  	return gt->migrate->eng;
> @@ -271,6 +301,12 @@ static int xe_migrate_prepare_vm(struct xe_gt *gt, struct xe_migrate *m,
>  	return 0;
>  }
>  
> +/**
> + * xe_migrate_init() - Initialize a migrate context
> + * @gt: Back-pointer to the gt we're initializing for.
> + *
> + * Return: Pointer to a migrate context on success. Error pointer on error.
> + */
>  struct xe_migrate *xe_migrate_init(struct xe_gt *gt)
>  {
>  	struct xe_device *xe = gt_to_xe(gt);
> @@ -540,6 +576,24 @@ static u32 xe_migrate_ccs_copy(struct xe_migrate *m,
>  	return flush_flags;
>  }
>  
> +/**
> + * xe_migrate_copy() - Copy content of TTM resources.
> + * @m: The migration context.
> + * @bo: The buffer object @src is currently bound to.
> + * @src: The source TTM resource.
> + * @dst: The dst TTM resource.
> + *
> + * Copies the contents of @src to @dst: On flat CCS devices,
> + * the CCS metadata is copied as well if needed, or if not present,
> + * the CCS metadata of @dst is cleared for security reasons.
> + * It's currently not possible to copy between two system resources,
> + * since that would require two TTM page-vectors.
> + * TODO: Eliminate the @bo argument and supply two TTM page-vectors.
> + *
> + * Return: Pointer to a dma_fence representing the last copy batch, or
> + * an error pointer on failure. If there is a failure, any copy operation
> + * started by the function call has been synced.
> + */
>  struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
>  				  struct xe_bo *bo,
>  				  struct ttm_resource *src,
> @@ -683,7 +737,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
>  		xe_bb_free(bb, NULL);
>  
>  err_sync:
> -		/* Sync partial copy if any. */
> +		/* Sync partial copy if any. FIXME: under job_mutex? */
>  		if (fence) {
>  			dma_fence_wait(fence, false);
>  			dma_fence_put(fence);
> @@ -733,6 +787,21 @@ static int emit_clear(struct xe_gt *gt, struct xe_bb *bb, u64 src_ofs,
>  	return 0;
>  }
>  
> +/**
> + * xe_migrate_clear() - Copy content of TTM resources.
> + * @m: The migration context.
> + * @bo: The buffer object @dst is currently bound to.
> + * @dst: The dst TTM resource to be cleared.
> + * @value: Clear value.
> + *
> + * Clear the contents of @dst. On flat CCS devices,
> + * the CCS metadata is cleared to zero as well on VRAM destionations.
> + * TODO: Eliminate the @bo argument.
> + *
> + * Return: Pointer to a dma_fence representing the last clear batch, or
> + * an error pointer on failure. If there is a failure, any clear operation
> + * started by the function call has been synced.
> + */
>  struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  				   struct xe_bo *bo,
>  				   struct ttm_resource *dst,
> @@ -836,7 +905,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  		mutex_unlock(&m->job_mutex);
>  		xe_bb_free(bb, NULL);
>  err_sync:
> -		/* Sync partial copies if any. */
> +		/* Sync partial copies if any. FIXME: job_mutex? */
>  		if (fence) {
>  			dma_fence_wait(m->fence, false);
>  			dma_fence_put(fence);
> @@ -974,6 +1043,33 @@ static bool engine_is_idle(struct xe_engine *e)
>  		xe_lrc_seqno(&e->lrc[0]) == e->lrc[0].fence_ctx.next_seqno;
>  }
>  
> +/**
> + * xe_migrate_update_pgtables() - Pipelined page-table update
> + * @m: The migrate context.
> + * @vm: The vm we'll be updating.
> + * @bo: The bo whose dma-resv we will await before updating, or NULL if userptr.
> + * @eng: The engine to be used for the update or NULL if the default
> + * migration engine is to be used.
> + * @updates: An array of update descriptors.
> + * @num_updates: Number of descriptors in @updates.
> + * @syncs: Array of xe_sync_entry to await before updating. Note that waits
> + * will block the engine timeline.
> + * @num_syncs: Number of entries in @syncs.
> + * @pt_update: Pointer to a struct xe_migrate_pt_update, which contains
> + * pointers to callback functions and, if subclassed, private arguments to
> + * those.
> + *
> + * Perform a pipelined page-table update. The update descriptors are typically
> + * built under the same lock critical section as a call to this function. If
> + * using the default engine for the updates, they will be performed in the
> + * order they grab the job_mutex. If different engines are used, external
> + * synchronization is needed for overlapping updates to maintain page-table
> + * consistency. Note that the meaing of "overlapping" is that the updates
> + * touch the same page-table, which might be a higher-level page-directory.
> + * If no pipelining is needed, then updates may be performed by the cpu.
> + *
> + * Return: A dma_fence that, when signaled, indicates the update completion.
> + */
>  struct dma_fence *
>  xe_migrate_update_pgtables(struct xe_migrate *m,
>  			   struct xe_vm *vm,
> @@ -1157,6 +1253,14 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
>  	return ERR_PTR(err);
>  }
>  
> +/**
> + * xe_migrate_wait() - Complete all operations using the xe_migrate context
> + * @m: Migrate context to wait for.
> + *
> + * Waits until the GPU no longer uses the migrate context's default engine
> + * or its page-table objects. FIXME: What about separate page-table update
> + * engines?
> + */
>  void xe_migrate_wait(struct xe_migrate *m)
>  {
>  	if (m->fence)
> diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
> index 267057a3847f..b2d55283252f 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.h
> +++ b/drivers/gpu/drm/xe/xe_migrate.h
> @@ -23,9 +23,13 @@ struct xe_vm;
>  struct xe_vm_pgtable_update;
>  struct xe_vma;
>  
> +/**
> + * struct xe_migrate_pt_update_ops - Callbacks for the
> + * xe_migrate_update_pgtables() function.
> + */
>  struct xe_migrate_pt_update_ops {
>  	/**
> -	 * populate() - Populate a command buffer or page-table with ptes.
> +	 * @populate: Populate a command buffer or page-table with ptes.
>  	 * @pt_update: Embeddable callback argument.
>  	 * @gt: The gt for the current operation.
>  	 * @map: struct iosys_map into the memory to be populated.
> @@ -44,7 +48,7 @@ struct xe_migrate_pt_update_ops {
>  			 const struct xe_vm_pgtable_update *update);
>  
>  	/**
> -	 * pre_commit(): Callback to be called just before arming the
> +	 * @pre_commit: Callback to be called just before arming the
>  	 * sched_job.
>  	 * @pt_update: Pointer to embeddable callback argument.
>  	 *
> @@ -53,8 +57,16 @@ struct xe_migrate_pt_update_ops {
>  	int (*pre_commit)(struct xe_migrate_pt_update *pt_update);
>  };
>  
> +/**
> + * struct xe_migrate_pt_update - Argument to the
> + * struct xe_migrate_pt_update_ops callbacks.
> + *
> + * Intended to be subclassed to support additional arguments if necessary.
> + */
>  struct xe_migrate_pt_update {
> +	/** @ops: Pointer to the struct xe_migrate_pt_update_ops callbacks */
>  	const struct xe_migrate_pt_update_ops *ops;
> +	/** @vma: The vma we're updating the pagetable for. */
>  	struct xe_vma *vma;
>  };
>  



Thanks,
Mauro


  reply	other threads:[~2023-01-20 23:03 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 22:25 [Intel-xe] [PATCH 00/37] Catching up since we went public Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 01/37] drm/msm: Fix compile error Rodrigo Vivi
2023-01-31 18:48   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 02/37] drm/xe: Implement a local xe_mmio_wait32 Rodrigo Vivi
2023-01-31 18:49   ` Rodrigo Vivi
2023-02-01  4:44     ` Matthew Brost
2023-01-12 22:25 ` [Intel-xe] [PATCH 03/37] drm/xe: Stop using i915's range_overflows_t macro Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 04/37] drm/xe: Let's return last value read on xe_mmio_wait32 Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 05/37] drm/xe: Convert guc_ready to regular xe_mmio_wait32 Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 06/37] drm/xe: Wait for success on guc done Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 07/37] drm/xe: Remove i915_utils dependency from xe_guc_pc Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 08/37] drm/xe: Stop using i915_utils in xe_wopcm Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 09/37] drm/xe: Let's avoid i915_utils in the xe_force_wake Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 10/37] drm/xe: Convert xe_mmio_wait32 to us so we can stop using wait_for_us Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 11/37] drm/xe: Remove i915_utils dependency from xe_pcode Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 12/37] drm/xe/migrate: Add kerneldoc for the migrate subsystem Rodrigo Vivi
2023-01-20 23:03   ` Mauro Carvalho Chehab [this message]
2023-01-12 22:25 ` [Intel-xe] [PATCH 13/37] drm/xe: Take memory ref on kernel job creation Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 14/37] drm/xe: Add intel_pps support too Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 15/37] drm/xe: Rework initialisation ordering slightly so we can inherit fb Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 16/37] drm/xe: Implement stolen memory Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 17/37] drm/xe: Allow fbdev to allocate " Rodrigo Vivi
2023-01-24 15:42   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 18/37] drm/xe: Implement initial hw readout for framebuffer Rodrigo Vivi
2023-01-24 15:43   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 19/37] drm/xe: Put DPT into stolen memory, if available Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 20/37] drm/xe: Implement FBC support Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 21/37] drm/i915: Remove i915_drm_suspend_mode Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 22/37] drm/xe: Fix compilation when Xe driver is builtin Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 23/37] drm/xe: Fix dumb bo create Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 24/37] drm/i915: Expand force_probe to block probe of devices as well Rodrigo Vivi
2023-01-20 23:08   ` Mauro Carvalho Chehab
2023-01-12 22:25 ` [Intel-xe] [PATCH 25/37] drm/xe: Introduce force_probe parameter Rodrigo Vivi
2023-01-20 23:07   ` Mauro Carvalho Chehab
2023-01-12 22:25 ` [Intel-xe] [PATCH 26/37] Revert "drm/xe: Validate BO on CPU fault" Rodrigo Vivi
2023-01-24 15:44   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 27/37] drm/xe: Ensure VMA not userptr before calling xe_bo_is_stolen Rodrigo Vivi
2023-02-03 19:56   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 28/37] drm/xe: Don't use engine_mask until after hwconfig parse Rodrigo Vivi
2023-01-31 18:51   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 29/37] drm/xe: Fake pulling gt->info.engine_mask from hwconfig blob Rodrigo Vivi
2023-01-31 19:03   ` Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 30/37] drm/xe/guc: Report submission version of GuC firmware Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 31/37] drm/xe/guc: s/xe_guc_send_mmio/xe_guc_mmio_send Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 32/37] drm/xe/guc: Add support GuC MMIO send / recv Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 33/37] drm/xe: Make FBC check stolen at use time Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 34/37] drm/xe: Move xe_ttm_stolen_mgr_init back Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 35/37] drm/xe: Fix hidden gotcha regression with bo create Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 36/37] drm/xe: Fix xe_mmio_wait32 timeouts Rodrigo Vivi
2023-01-12 22:25 ` [Intel-xe] [PATCH 37/37] drm/xe: enforce GSMBASE for DG1 instead of BAR2 Rodrigo Vivi
2023-01-24 15:46   ` Rodrigo Vivi
2023-01-24 16:25     ` Lecluse, Philippe
2023-01-31 19:11       ` Rodrigo Vivi
2023-01-31 19:13       ` Rodrigo Vivi
2023-02-01  9:12         ` Matthew Auld
2023-02-01  9:13           ` Matthew Auld

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=20230121000358.4cb8d6ec@coco.lan \
    --to=mchehab@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=philippe.lecluse@intel.com \
    --cc=rodrigo.vivi@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