From: Matthew Auld <matthew.auld@intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: paulo.r.zanoni@intel.com, jani.nikula@intel.com,
thomas.hellstrom@intel.com, daniel.vetter@intel.com,
christian.koenig@amd.com
Subject: Re: [Intel-gfx] [PATCH v10 22/23] drm/i915/vm_bind: Properly build persistent map sg table
Date: Wed, 18 Jan 2023 12:49:25 +0000 [thread overview]
Message-ID: <c5584e3e-69ac-baed-4764-90af1fea9e95@intel.com> (raw)
In-Reply-To: <20230118071609.17572-23-niranjana.vishwanathapura@intel.com>
On 18/01/2023 07:16, Niranjana Vishwanathapura wrote:
> Properly build the sg table for persistent mapping which can
> be partial map of the underlying object. Ensure the sg pages
> are properly set for page backed regions. The dump capture
> support requires this for page backed regions.
>
> v2: Remove redundant sg_mark_end() call
>
> Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
> ---
> drivers/gpu/drm/i915/i915_vma.c | 113 +++++++++++++++++++++++++++++++-
> 1 file changed, 112 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index 5b9ae5ebf55c..2f0994f0ed42 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -1328,6 +1328,113 @@ intel_partial_pages(const struct i915_gtt_view *view,
> return ERR_PTR(ret);
> }
>
> +static unsigned int
> +intel_copy_dma_sg(struct sg_table *src_st, struct sg_table *dst_st,
> + u64 offset, u64 length, bool dry_run)
> +{
> + struct scatterlist *dst_sg, *src_sg;
> + unsigned int i, len, nents = 0;
> +
> + dst_sg = dst_st->sgl;
> + for_each_sgtable_dma_sg(src_st, src_sg, i) {
> + if (sg_dma_len(src_sg) <= offset) {
> + offset -= sg_dma_len(src_sg);
> + continue;
> + }
> +
> + nents++;
> + len = min(sg_dma_len(src_sg) - offset, length);
> + if (!dry_run) {
> + sg_dma_address(dst_sg) = sg_dma_address(src_sg) + offset;
> + sg_dma_len(dst_sg) = len;
> + dst_sg = sg_next(dst_sg);
> + }
> +
> + length -= len;
> + offset = 0;
> + if (!length)
> + break;
> + }
> + WARN_ON_ONCE(length);
> +
> + return nents;
> +}
> +
> +static unsigned int
> +intel_copy_sg(struct sg_table *src_st, struct sg_table *dst_st,
> + u64 offset, u64 length, bool dry_run)
> +{
> + struct scatterlist *dst_sg, *src_sg;
> + unsigned int i, len, nents = 0;
> +
> + dst_sg = dst_st->sgl;
> + for_each_sgtable_sg(src_st, src_sg, i) {
> + if (src_sg->length <= offset) {
> + offset -= src_sg->length;
> + continue;
> + }
> +
> + nents++;
> + len = min(src_sg->length - offset, length);
> + if (!dry_run) {
> + unsigned long pfn;
> +
> + pfn = page_to_pfn(sg_page(src_sg)) + offset / PAGE_SIZE;
> + sg_set_page(dst_sg, pfn_to_page(pfn), len, 0);
> + dst_sg = sg_next(dst_sg);
> + }
> +
> + length -= len;
> + offset = 0;
> + if (!length)
> + break;
> + }
> + WARN_ON_ONCE(length);
> +
> + return nents;
> +}
> +
> +static noinline struct sg_table *
Not sure why this noinline is needed here?
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
> +intel_persistent_partial_pages(const struct i915_gtt_view *view,
> + struct drm_i915_gem_object *obj)
> +{
> + u64 offset = view->partial.offset << PAGE_SHIFT;
> + struct sg_table *st, *obj_st = obj->mm.pages;
> + u64 length = view->partial.size << PAGE_SHIFT;
> + unsigned int nents;
> + int ret = -ENOMEM;
> +
> + st = kmalloc(sizeof(*st), GFP_KERNEL);
> + if (!st)
> + goto err_st_alloc;
> +
> + /* Get required sg_table size */
> + nents = intel_copy_dma_sg(obj_st, st, offset, length, true);
> + if (i915_gem_object_has_struct_page(obj)) {
> + unsigned int pg_nents;
> +
> + pg_nents = intel_copy_sg(obj_st, st, offset, length, true);
> + if (nents < pg_nents)
> + nents = pg_nents;
> + }
> +
> + ret = sg_alloc_table(st, nents, GFP_KERNEL);
> + if (ret)
> + goto err_sg_alloc;
> +
> + /* Build sg_table for specified <offset, length> section */
> + intel_copy_dma_sg(obj_st, st, offset, length, false);
> + if (i915_gem_object_has_struct_page(obj))
> + intel_copy_sg(obj_st, st, offset, length, false);
> +
> + return st;
> +
> +err_sg_alloc:
> + kfree(st);
> +err_st_alloc:
> + return ERR_PTR(ret);
> +}
> +
> static int
> __i915_vma_get_pages(struct i915_vma *vma)
> {
> @@ -1360,7 +1467,11 @@ __i915_vma_get_pages(struct i915_vma *vma)
> break;
>
> case I915_GTT_VIEW_PARTIAL:
> - pages = intel_partial_pages(&vma->gtt_view, vma->obj);
> + if (i915_vma_is_persistent(vma))
> + pages = intel_persistent_partial_pages(&vma->gtt_view,
> + vma->obj);
> + else
> + pages = intel_partial_pages(&vma->gtt_view, vma->obj);
> break;
> }
>
next prev parent reply other threads:[~2023-01-18 12:49 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 7:15 [Intel-gfx] [PATCH v10 00/23] drm/i915/vm_bind: Add VM_BIND functionality Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 01/23] drm/i915/vm_bind: Expose vm lookup function Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 02/23] drm/i915/vm_bind: Add __i915_sw_fence_await_reservation() Niranjana Vishwanathapura
2023-02-01 17:14 ` Andi Shyti
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 03/23] drm/i915/vm_bind: Expose i915_gem_object_max_page_size() Niranjana Vishwanathapura
2023-02-01 17:23 ` Andi Shyti
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 04/23] drm/i915/vm_bind: Support partially mapped vma resource Niranjana Vishwanathapura
2023-02-01 17:25 ` Andi Shyti
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 05/23] drm/i915/vm_bind: Add support to create persistent vma Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 06/23] drm/i915/vm_bind: Implement bind and unbind of object Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 07/23] drm/i915/vm_bind: Support for VM private BOs Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 08/23] drm/i915/vm_bind: Add support to handle object evictions Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 09/23] drm/i915/vm_bind: Support persistent vma activeness tracking Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 10/23] drm/i915/vm_bind: Add out fence support Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 11/23] drm/i915/vm_bind: Abstract out common execbuf functions Niranjana Vishwanathapura
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 12/23] drm/i915/vm_bind: Use common execbuf functions in execbuf path Niranjana Vishwanathapura
2023-02-02 16:04 ` Andi Shyti
2023-01-18 7:15 ` [Intel-gfx] [PATCH v10 13/23] drm/i915/vm_bind: Implement I915_GEM_EXECBUFFER3 ioctl Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 14/23] drm/i915/vm_bind: Update i915_vma_verify_bind_complete() Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 15/23] drm/i915/vm_bind: Expose i915_request_await_bind() Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 16/23] drm/i915/vm_bind: Handle persistent vmas in execbuf3 Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 17/23] drm/i915/vm_bind: userptr dma-resv changes Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 18/23] drm/i915/vm_bind: Limit vm_bind mode to non-recoverable contexts Niranjana Vishwanathapura
2023-02-02 16:11 ` Andi Shyti
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 19/23] drm/i915/vm_bind: Add uapi for user to enable vm_bind_mode Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 20/23] drm/i915/vm_bind: Render VM_BIND documentation Niranjana Vishwanathapura
2023-02-02 16:38 ` Andi Shyti
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 21/23] drm/i915/vm_bind: Async vm_unbind support Niranjana Vishwanathapura
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 22/23] drm/i915/vm_bind: Properly build persistent map sg table Niranjana Vishwanathapura
2023-01-18 12:49 ` Matthew Auld [this message]
2023-02-02 16:51 ` Andi Shyti
2023-01-18 7:16 ` [Intel-gfx] [PATCH v10 23/23] drm/i915/vm_bind: Support capture of persistent mappings Niranjana Vishwanathapura
2023-01-18 12:45 ` Matthew Auld
2023-01-18 18:19 ` Niranjana Vishwanathapura
2023-01-18 12:46 ` kernel test robot
2023-01-18 20:27 ` kernel test robot
2023-02-02 17:03 ` Andi Shyti
2023-01-18 8:17 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/vm_bind: Add VM_BIND functionality (rev13) Patchwork
2023-01-18 8:45 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-01-19 8:03 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-02-02 1:54 ` [Intel-gfx] [PATCH v10 00/23] drm/i915/vm_bind: Add VM_BIND functionality Zanoni, Paulo R
2023-04-13 18:51 ` Niranjana Vishwanathapura
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=c5584e3e-69ac-baed-4764-90af1fea9e95@intel.com \
--to=matthew.auld@intel.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=niranjana.vishwanathapura@intel.com \
--cc=paulo.r.zanoni@intel.com \
--cc=thomas.hellstrom@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