From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Subject: [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap
Date: Tue, 14 Apr 2026 19:03:41 -0700 [thread overview]
Message-ID: <20260415020342.782987-3-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20260415020342.782987-1-ashutosh.dixit@intel.com>
OA buffer mmap can currently only mmap OA buffer in system memory. CRI
MERTOA buffer can be located in device memory. Switch OA buffer mmap to
using drm_gem_mmap_obj, which can handle mmap's of both system and device
memory buffers.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
drivers/gpu/drm/xe/xe_oa.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index 4d13d8ef8103f..5b8a9bd26770c 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -9,6 +9,7 @@
#include <linux/poll.h>
#include <drm/drm_drv.h>
+#include <drm/drm_gem.h>
#include <drm/drm_managed.h>
#include <drm/drm_syncobj.h>
#include <uapi/drm/xe_drm.h>
@@ -900,9 +901,6 @@ static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream, size_t size)
stream->oa_buffer.bo = bo;
- /* mmap implementation requires OA buffer to be in system memory */
- xe_assert(stream->oa->xe, bo->vmap.is_iomem == 0);
-
stream->oa_buffer.bounce = kmalloc(stream->oa_buffer.format->size, GFP_KERNEL);
if (!stream->oa_buffer.bounce) {
xe_bo_unpin_map_no_vm(stream->oa_buffer.bo);
@@ -1690,8 +1688,6 @@ static int xe_oa_mmap(struct file *file, struct vm_area_struct *vma)
{
struct xe_oa_stream *stream = file->private_data;
struct xe_bo *bo = stream->oa_buffer.bo;
- unsigned long start = vma->vm_start;
- int i, ret;
if (xe_observation_paranoid && !perfmon_capable()) {
drm_dbg(&stream->oa->xe->drm, "Insufficient privilege to map OA buffer\n");
@@ -1699,7 +1695,7 @@ static int xe_oa_mmap(struct file *file, struct vm_area_struct *vma)
}
/* Can mmap the entire OA buffer or nothing (no partial OA buffer mmaps) */
- if (vma->vm_end - vma->vm_start != xe_bo_size(stream->oa_buffer.bo)) {
+ if (vma->vm_end - vma->vm_start != xe_bo_size(bo)) {
drm_dbg(&stream->oa->xe->drm, "Wrong mmap size, must be OA buffer size\n");
return -EINVAL;
}
@@ -1715,17 +1711,7 @@ static int xe_oa_mmap(struct file *file, struct vm_area_struct *vma)
vm_flags_mod(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_DONTCOPY,
VM_MAYWRITE | VM_MAYEXEC);
- xe_assert(stream->oa->xe, bo->ttm.ttm->num_pages == vma_pages(vma));
- for (i = 0; i < bo->ttm.ttm->num_pages; i++) {
- ret = remap_pfn_range(vma, start, page_to_pfn(bo->ttm.ttm->pages[i]),
- PAGE_SIZE, vma->vm_page_prot);
- if (ret)
- break;
-
- start += PAGE_SIZE;
- }
-
- return ret;
+ return drm_gem_mmap_obj(&bo->ttm.base, xe_bo_size(bo), vma);
}
static const struct file_operations xe_oa_fops = {
--
2.48.1
next prev parent reply other threads:[~2026-04-15 2:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 2:03 [PATCH v4 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-15 2:03 ` [PATCH 1/3] drm/xe/oa: Use xe_map layer Ashutosh Dixit
2026-04-24 21:05 ` Umesh Nerlige Ramappa
2026-04-24 23:56 ` Dixit, Ashutosh
2026-04-25 0:16 ` Dixit, Ashutosh
2026-04-27 18:27 ` Umesh Nerlige Ramappa
2026-04-27 19:04 ` Dixit, Ashutosh
2026-04-15 2:03 ` Ashutosh Dixit [this message]
2026-04-15 2:03 ` [PATCH 3/3] drm/xe/oa: Implement Wa_14026633728 Ashutosh Dixit
2026-04-15 2:10 ` ✓ CI.KUnit: success for drm/xe/oa: Wa_14026633728 (rev4) Patchwork
2026-04-15 3:13 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-15 4:26 ` ✗ Xe.CI.FULL: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2026-04-27 22:11 [PATCH v8 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-27 22:11 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-27 20:26 [PATCH v7 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-27 20:26 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-27 19:02 [PATCH v6 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-27 19:02 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-25 0:14 [PATCH v5 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-25 0:14 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-11 0:48 [PATCH v3 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-11 0:48 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-09 23:17 [PATCH v2 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-09 23:17 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-07 3:02 [PATCH 0/3] drm/xe/oa: Wa_14026633728 Ashutosh Dixit
2026-04-07 3:02 ` [PATCH 2/3] drm/xe/oa: Use drm_gem_mmap_obj for OA buffer mmap Ashutosh Dixit
2026-04-07 22:52 ` Umesh Nerlige Ramappa
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=20260415020342.782987-3-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=umesh.nerlige.ramappa@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 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.