From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "Christian König" <christian.koenig@amd.com>,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de
Cc: Matthew Brost <matthew.brost@intel.com>,
<intel-xe@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>,
<thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v7 2/8] drm/ttm: Add ttm_bo_access
Date: Thu, 28 Nov 2024 05:47:37 -0500 [thread overview]
Message-ID: <Z0hKSYRokwJoi_T1@intel.com> (raw)
In-Reply-To: <0554dd02-06a5-4da1-821a-e2b26b651402@amd.com>
On Wed, Nov 27, 2024 at 02:19:32PM +0100, Christian König wrote:
> Am 26.11.24 um 18:46 schrieb Matthew Brost:
> > Non-contiguous VRAM cannot easily be mapped in TTM nor can non-visible
> > VRAM easily be accessed. Add ttm_bo_access, which is similar to
> > ttm_bo_vm_access, to access such memory.
> >
> > v4:
> > - Fix checkpatch warnings (CI)
> > v5:
> > - Fix checkpatch warnings (CI)
> > v6:
> > - Fix kernel doc (Auld)
> > v7:
> > - Move ttm_bo_access to ttm_bo_vm.c (Christian)
> >
> > Cc: Christian König <christian.koenig@amd.com>
> > Reported-by: Christoph Manszewski <christoph.manszewski@intel.com>
> > Suggested-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > Tested-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> > Reviewed-by: Matthew Auld <matthew.auld@intel.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Thank you!
Ack on get this through drm-xe-next?
drm-misc-maintainers?
>
> > ---
> > drivers/gpu/drm/ttm/ttm_bo_vm.c | 40 ++++++++++++++++++++++++++-------
> > include/drm/ttm/ttm_bo.h | 2 ++
> > 2 files changed, 34 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index 2c699ed1963a..f02d3966cc84 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -405,13 +405,25 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
> > return len;
> > }
> > -int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
> > - void *buf, int len, int write)
> > +/**
> > + * ttm_bo_access - Helper to access a buffer object
> > + *
> > + * @bo: ttm buffer object
> > + * @offset: access offset into buffer object
> > + * @buf: pointer to caller memory to read into or write from
> > + * @len: length of access
> > + * @write: write access
> > + *
> > + * Utility function to access a buffer object. Useful when buffer object cannot
> > + * be easily mapped (non-contiguous, non-visible, etc...). Should not directly
> > + * be exported to user space via a peak / poke interface.
> > + *
> > + * Returns:
> > + * @len if successful, negative error code on failure.
> > + */
> > +int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
> > + void *buf, int len, int write)
> > {
> > - struct ttm_buffer_object *bo = vma->vm_private_data;
> > - unsigned long offset = (addr) - vma->vm_start +
> > - ((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
> > - << PAGE_SHIFT);
> > int ret;
> > if (len < 1 || (offset + len) > bo->base.size)
> > @@ -429,8 +441,8 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
> > break;
> > default:
> > if (bo->bdev->funcs->access_memory)
> > - ret = bo->bdev->funcs->access_memory(
> > - bo, offset, buf, len, write);
> > + ret = bo->bdev->funcs->access_memory
> > + (bo, offset, buf, len, write);
> > else
> > ret = -EIO;
> > }
> > @@ -439,6 +451,18 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
> > return ret;
> > }
> > +EXPORT_SYMBOL(ttm_bo_access);
> > +
> > +int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
> > + void *buf, int len, int write)
> > +{
> > + struct ttm_buffer_object *bo = vma->vm_private_data;
> > + unsigned long offset = (addr) - vma->vm_start +
> > + ((vma->vm_pgoff - drm_vma_node_start(&bo->base.vma_node))
> > + << PAGE_SHIFT);
> > +
> > + return ttm_bo_access(bo, offset, buf, len, write);
> > +}
> > EXPORT_SYMBOL(ttm_bo_vm_access);
> > static const struct vm_operations_struct ttm_bo_vm_ops = {
> > diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
> > index 5804408815be..8ea11cd8df39 100644
> > --- a/include/drm/ttm/ttm_bo.h
> > +++ b/include/drm/ttm/ttm_bo.h
> > @@ -421,6 +421,8 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo);
> > int ttm_bo_evict_first(struct ttm_device *bdev,
> > struct ttm_resource_manager *man,
> > struct ttm_operation_ctx *ctx);
> > +int ttm_bo_access(struct ttm_buffer_object *bo, unsigned long offset,
> > + void *buf, int len, int write);
> > vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
> > struct vm_fault *vmf);
> > vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
>
next prev parent reply other threads:[~2024-11-28 10:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 17:46 [PATCH v7 0/8] Fix non-contiguous VRAM BO access in Xe Matthew Brost
2024-11-26 17:46 ` [PATCH v7 1/8] drm/xe: Add xe_bo_vm_access Matthew Brost
2024-11-26 17:46 ` [PATCH v7 2/8] drm/ttm: Add ttm_bo_access Matthew Brost
2024-11-27 13:19 ` Christian König
2024-11-28 10:47 ` Rodrigo Vivi [this message]
2024-11-29 14:05 ` Maxime Ripard
2024-12-02 8:00 ` Christian König
2024-11-26 17:46 ` [PATCH v7 3/8] drm/xe: Add xe_ttm_access_memory Matthew Brost
2024-11-26 17:46 ` [PATCH v7 4/8] drm/xe: Take PM ref in delayed snapshot capture worker Matthew Brost
2024-11-26 17:46 ` [PATCH v7 5/8] drm/xe/display: Update intel_bo_read_from_page to use ttm_bo_access Matthew Brost
2024-12-02 11:43 ` Jani Nikula
2024-12-02 14:17 ` Matthew Auld
2024-12-03 9:08 ` Jani Nikula
2024-11-26 17:46 ` [PATCH v7 6/8] drm/xe: Use ttm_bo_access in xe_vm_snapshot_capture_delayed Matthew Brost
2025-01-15 8:44 ` Thomas Hellström
2024-11-26 17:46 ` [PATCH v7 7/8] drm/xe: Set XE_BO_FLAG_PINNED in migrate selftest BOs Matthew Brost
2024-11-26 17:46 ` [PATCH v7 8/8] drm/xe: Only allow contiguous BOs to use xe_bo_vmap Matthew Brost
2024-11-26 18:18 ` ✓ CI.Patch_applied: success for Fix non-contiguous VRAM BO access in Xe (rev7) Patchwork
2024-11-26 18:19 ` ✗ CI.checkpatch: warning " Patchwork
2024-11-26 18:20 ` ✓ CI.KUnit: success " Patchwork
2024-11-26 18:38 ` ✓ CI.Build: " Patchwork
2024-11-26 18:40 ` ✓ CI.Hooks: " Patchwork
2024-11-26 18:41 ` ✗ CI.checksparse: warning " Patchwork
2024-11-26 19:23 ` ✓ Xe.CI.BAT: success " Patchwork
2024-11-26 21:04 ` ✗ Xe.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=Z0hKSYRokwJoi_T1@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.