public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: maarten.lankhorst@linux.intel.com
Subject: Re: [Intel-gfx] [PATCH v2 1/6] drm/i915/ttm: Implement a function to copy the contents of two TTM-base objects
Date: Tue, 7 Sep 2021 09:54:34 +0100	[thread overview]
Message-ID: <41c1b026-0a4f-b5e2-bd25-bc0f3d5d547f@intel.com> (raw)
In-Reply-To: <20210906165515.450541-2-thomas.hellstrom@linux.intel.com>

On 06/09/2021 17:55, Thomas Hellström wrote:
> When backing up or restoring contents of pinned objects at suspend /
> resume time we need to allocate a new object as the backup. Add a function
> to facilitate copies between the two. Some data needs to be copied before
> the migration context is ready for operation, so make sure we can
> disable accelerated copies.
> 
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---

<snip>

> +
> +/**
> + * i915_gem_obj_copy_ttm - Copy the contents of one ttm-based gem object to
> + * another
> + * @dst: The destination object
> + * @src: The source object
> + * @allow_accel: Allow using the blitter. Otherwise TTM memcpy is used.
> + * @intr: Whether to perform waits interruptible:
> + *
> + * Note: The caller is responsible for assuring that the underlying
> + * TTM objects are populated if needed and locked.
> + *
> + * Return: Zero on success. Negative error code on error. If @intr == true,
> + * then it may return -ERESTARTSYS or -EINTR.
> + */
> +int i915_gem_obj_copy_ttm(struct drm_i915_gem_object *dst,
> +			  struct drm_i915_gem_object *src,
> +			  bool allow_accel, bool intr)
> +{
> +	struct ttm_buffer_object *dst_bo = i915_gem_to_ttm(dst);
> +	struct ttm_buffer_object *src_bo = i915_gem_to_ttm(src);
> +	struct ttm_operation_ctx ctx = {
> +		.interruptible = intr,
> +	};
> +	struct sg_table *dst_st;
> +	int ret;
> +
> +	assert_object_held(dst);
> +	assert_object_held(src);
> +
> +	/*
> +	 * Sync for now. This will change with async moves.
> +	 */
> +	ret = ttm_bo_wait_ctx(dst_bo, &ctx);
> +	if (!ret)
> +		ttm_bo_wait_ctx(src_bo, &ctx);

ret = ?

> +	if (ret)
> +		return ret;
> +
> +	dst_st = gpu_binds_iomem(dst_bo->resource) ?
> +		dst->ttm.cached_io_st : i915_ttm_tt_get_st(dst_bo->ttm);
> +
> +	__i915_ttm_move(src_bo, false, dst_bo->resource, dst_bo->ttm,
> +			dst_st, allow_accel);
> +
> +	return 0;
> +}
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.h b/drivers/gpu/drm/i915/gem/i915_gem_ttm.h
> index 40927f67b6d9..34ac78d47b0d 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.h
> @@ -46,4 +46,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
>   			       resource_size_t size,
>   			       resource_size_t page_size,
>   			       unsigned int flags);
> +
> +int i915_gem_obj_copy_ttm(struct drm_i915_gem_object *dst,
> +			  struct drm_i915_gem_object *src,
> +			  bool allow_accel, bool intr);
>   #endif
> 

  reply	other threads:[~2021-09-07  8:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06 16:55 [Intel-gfx] [PATCH v2 0/6] drm/i915: Suspend / resume backup- and restore of LMEM Thomas Hellström
2021-09-06 16:55 ` [Intel-gfx] [PATCH v2 1/6] drm/i915/ttm: Implement a function to copy the contents of two TTM-base objects Thomas Hellström
2021-09-07  8:54   ` Matthew Auld [this message]
2021-09-06 16:55 ` [Intel-gfx] [PATCH v2 2/6] drm/i915/gem: Implement a function to process all gem objects of a region Thomas Hellström
2021-09-07  9:12   ` Matthew Auld
2021-09-06 16:55 ` [Intel-gfx] [PATCH v2 3/6] drm/i915 Implement LMEM backup and restore for suspend / resume Thomas Hellström
2021-09-07 17:37   ` Matthew Auld
2021-09-08  7:58     ` Thomas Hellström
2021-09-10 13:27   ` Thomas Hellström
2021-09-06 16:55 ` [Intel-gfx] [PATCH v2 4/6] drm/i915/gt: Register the migrate contexts with their engines Thomas Hellström
2021-09-06 16:55 ` [Intel-gfx] [PATCH v2 5/6] drm/i915: Don't back up pinned LMEM context images and rings during suspend Thomas Hellström
2021-09-08 11:01   ` Matthew Auld
2021-09-08 11:07   ` Matthew Auld
2021-09-08 12:26     ` Thomas Hellström
2021-09-08 13:18       ` Matthew Auld
2021-09-06 16:55 ` [Intel-gfx] [PATCH v2 6/6] drm/i915: Reduce the number of objects subject to memcpy recover Thomas Hellström
2021-09-06 17:10 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Suspend / resume backup- and restore of LMEM. (rev2) Patchwork
2021-09-06 17:41 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-09-06 19:16 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2021-09-08 15:24 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Suspend / resume backup- and restore of LMEM. (rev3) Patchwork
2021-09-08 15:53 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-09-08 19:41 ` [Intel-gfx] ✗ Fi.CI.IGT: 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=41c1b026-0a4f-b5e2-bd25-bc0f3d5d547f@intel.com \
    --to=matthew.auld@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.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