From: maarten.lankhorst@linux.intel.com
To: intel-xe@lists.freedesktop.org
Cc: Maarten Lankhorst <dev@lankhorst.se>
Subject: [Intel-xe] [PATCH 1/4] drm/xe: Add uapi for dumpable bos
Date: Fri, 13 Oct 2023 17:21:39 +0200 [thread overview]
Message-ID: <20231013152142.52869-2-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20231013152142.52869-1-maarten.lankhorst@linux.intel.com>
From: Maarten Lankhorst <dev@lankhorst.se>
Add XE_GEM_CREATE_FLAG_DUMPABLE for use with VM_BIND.
After this, we can use the flag XE_VM_BIND_FLAG_DUMPABLE to notify
devcoredump that this mapping should be dumped.
This is not hooked up, but the uapi should be ready before merging.
It's likely easier to dump the contents of the bo's at devcoredump
readout time, so it's better if the bos will stay unmodified after
a hang. The NEEDS_CPU_MAPPING flag is removed as requirement.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 4 ++++
drivers/gpu/drm/xe/xe_bo.h | 1 +
drivers/gpu/drm/xe/xe_vm.c | 17 ++++++++++++++---
include/uapi/drm/xe_drm.h | 25 +++++++++++++++++++++++++
4 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 61789c0e88fb..1df606fe97a7 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1776,6 +1776,7 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
~(XE_GEM_CREATE_FLAG_DEFER_BACKING |
XE_GEM_CREATE_FLAG_SCANOUT |
XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM |
+ XE_GEM_CREATE_FLAG_DUMPABLE |
xe->info.mem_region_mask)))
return -EINVAL;
@@ -1810,6 +1811,9 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
bo_flags |= XE_BO_NEEDS_CPU_ACCESS;
}
+ if (args->flags & XE_GEM_CREATE_FLAG_DUMPABLE)
+ bo_flags |= XE_BO_DUMPABLE;
+
if (args->vm_id) {
vm = xe_vm_lookup(xef, args->vm_id);
if (XE_IOCTL_DBG(xe, !vm))
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 78da28f4ea13..9714b53715b1 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -35,6 +35,7 @@
#define XE_BO_FIXED_PLACEMENT_BIT BIT(11)
#define XE_BO_PAGETABLE BIT(12)
#define XE_BO_NEEDS_CPU_ACCESS BIT(13)
+#define XE_BO_DUMPABLE BIT(14)
/* this one is trigger internally only */
#define XE_BO_INTERNAL_TEST BIT(30)
#define XE_BO_INTERNAL_64K BIT(31)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index d25dfa402267..6eab1a478ed5 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -3189,11 +3189,12 @@ static void vm_bind_ioctl_ops_unwind(struct xe_vm *vm,
#define SUPPORTED_FLAGS \
(FORCE_ASYNC_OP_ERROR | XE_VM_BIND_FLAG_ASYNC | \
XE_VM_BIND_FLAG_READONLY | XE_VM_BIND_FLAG_IMMEDIATE | \
- XE_VM_BIND_FLAG_NULL | 0xffff)
+ XE_VM_BIND_FLAG_NULL | XE_VM_BIND_FLAG_DUMPABLE | 0xffff)
#else
#define SUPPORTED_FLAGS \
(XE_VM_BIND_FLAG_ASYNC | XE_VM_BIND_FLAG_READONLY | \
- XE_VM_BIND_FLAG_IMMEDIATE | XE_VM_BIND_FLAG_NULL | 0xffff)
+ XE_VM_BIND_FLAG_IMMEDIATE | XE_VM_BIND_FLAG_NULL | \
+ XE_VM_BIND_FLAG_DUMPABLE | 0xffff)
#endif
#define XE_64K_PAGE_MASK 0xffffull
@@ -3430,8 +3431,13 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
u32 obj = bind_ops[i].obj;
u64 obj_offset = bind_ops[i].obj_offset;
- if (!obj)
+ if (!obj) {
+ if (XE_IOCTL_DBG(xe, bind_ops[i].op & XE_VM_BIND_FLAG_DUMPABLE)) {
+ err = -EINVAL;
+ goto put_obj;
+ }
continue;
+ }
gem_obj = drm_gem_object_lookup(file, obj);
if (XE_IOCTL_DBG(xe, !gem_obj)) {
@@ -3456,6 +3462,11 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
goto put_obj;
}
}
+ if (bind_ops[i].op & XE_VM_BIND_FLAG_DUMPABLE &&
+ XE_IOCTL_DBG(xe, !(bos[i]->flags & XE_BO_DUMPABLE))) {
+ err = -EINVAL;
+ goto put_obj;
+ }
}
if (args->num_syncs) {
diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
index d48d8e3c898c..dc96f7297edb 100644
--- a/include/uapi/drm/xe_drm.h
+++ b/include/uapi/drm/xe_drm.h
@@ -433,6 +433,20 @@ struct drm_xe_gem_create {
* objects, otherwise an error is thrown on small-bar systems.
*/
#define XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM (0x1 << 26)
+
+/*
+ * This bo is mapped into a vm with dumpable flag set, and as such needs to
+ * be specially marked as dumpable so the kernel can map it as required.
+ *
+ * For bo's that reside in VRAM, you need XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM.
+ *
+ * NOTE: devcoredump is not creating a copy of each bo currently, and there is
+ * no guarantee that future devcoredump support won't simply take a ref on the
+ * bo as it makes lifetime tracking easier.
+ * It's advised after an engine is banned to create a new copy of each BO that
+ * is created with the dumpable flag.
+ */
+#define XE_GEM_CREATE_FLAG_DUMPABLE (0x1 << 27)
/**
* @flags: Flags, currently a mask of memory instances of where BO can
* be placed
@@ -626,6 +640,17 @@ struct drm_xe_vm_bind_op {
* intended to implement VK sparse bindings.
*/
#define XE_VM_BIND_FLAG_NULL (0x1 << 19)
+
+ /*
+ * This flag is used to notify that the VM binding should be dumped
+ * when a devcoredump is created.
+ *
+ * The BO should be mappable, so the BO needs to be created with
+ * XE_GEM_CREATE_FLAG_DUMPABLE, and possibly with
+ * XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM.
+ * See the NOTE there for more informations.
+ */
+#define XE_VM_BIND_FLAG_DUMPABLE (0x1 << 20)
/** @op: Operation to perform (lower 16 bits) and flags (upper 16 bits) */
__u32 op;
--
2.40.1
next prev parent reply other threads:[~2023-10-13 15:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 15:21 [Intel-xe] [PATCH 0/4] RFC for discussion of devcoredump uapi maarten.lankhorst
2023-10-13 15:21 ` maarten.lankhorst [this message]
2023-10-13 15:21 ` [Intel-xe] [PATCH 2/4] drm/xe: Annotate each dumpable vma as such maarten.lankhorst
2023-10-13 15:21 ` [Intel-xe] [PATCH 3/4] drm/xe: Add vm snapshot mutex for easily taking a vm snapshot during devcoredump maarten.lankhorst
2023-10-13 19:21 ` Matthew Brost
2023-10-17 10:15 ` Maarten Lankhorst
2023-10-13 15:21 ` [Intel-xe] [PATCH 4/4] drm/xe: Almost implement snapshot support maarten.lankhorst
2023-10-13 17:23 ` [Intel-xe] ✓ CI.Patch_applied: success for RFC for discussion of devcoredump uapi Patchwork
2023-10-13 17:23 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-10-13 17:24 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-10-13 17:31 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-10-13 17:32 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-10-13 17:33 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-10-24 12:22 [Intel-xe] [PATCH 0/4] drm/xe: Implement snapshot support Maarten, Lankhorst <maarten.lankhorst
2023-10-24 12:22 ` [Intel-xe] [PATCH 1/4] drm/xe: Add uapi for dumpable bos Maarten, Lankhorst <maarten.lankhorst
2023-11-13 21:41 ` Souza, Jose
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=20231013152142.52869-2-maarten.lankhorst@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
/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