From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [Intel-xe] [PATCH 4/4] drm/xe/vm: Fix ASID XA usage
Date: Wed, 22 Nov 2023 12:03:59 +0100 [thread overview]
Message-ID: <20231122110359.4087-5-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20231122110359.4087-1-thomas.hellstrom@linux.intel.com>
xa_alloc_cyclic() returns 1 on successful allocation, if wrapping occurs,
but the code incorrectly treats that as an error. Fix that.
Also, xa_alloc_cyclic() requires xa_init_flags(..., XA_FLAGS_ALLOC), so
fix that, and assuming we don't want a zero ASID, instead of using
XA_FLAGS_ALLOC1, adjust the xa limits at alloc_cyclic time.
Suggested-by: Ohad Sharabi <osharabi@habana.ai>
Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/946
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 2 +-
drivers/gpu/drm/xe/xe_vm.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 8be765adf702..a67aaa15b4ae 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -230,7 +230,7 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
init_waitqueue_head(&xe->ufence_wq);
drmm_mutex_init(&xe->drm, &xe->usm.lock);
- xa_init_flags(&xe->usm.asid_to_vm, XA_FLAGS_ALLOC1);
+ xa_init_flags(&xe->usm.asid_to_vm, XA_FLAGS_ALLOC);
drmm_mutex_init(&xe->drm, &xe->persistent_engines.lock);
INIT_LIST_HEAD(&xe->persistent_engines.list);
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index b39c6f43f01f..85b9d6f864ec 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1994,13 +1994,14 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
if (xe->info.has_asid) {
mutex_lock(&xe->usm.lock);
err = xa_alloc_cyclic(&xe->usm.asid_to_vm, &asid, vm,
- XA_LIMIT(0, XE_MAX_ASID - 1),
+ XA_LIMIT(1, XE_MAX_ASID - 1),
&xe->usm.next_asid, GFP_KERNEL);
mutex_unlock(&xe->usm.lock);
- if (err) {
+ if (err < 0) {
xe_vm_close_and_put(vm);
return err;
}
+ err = 0;
vm->usm.asid = asid;
}
--
2.41.0
next prev parent reply other threads:[~2023-11-22 11:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 11:03 [Intel-xe] [PATCH 0/4] drm/xe: Assorted memory-management fixes Thomas Hellström
2023-11-22 11:03 ` [Intel-xe] [PATCH 1/4] drm/xe: Ensure that we don't access the placements array out-of-bounds Thomas Hellström
2023-11-22 12:20 ` Matthew Auld
2023-11-23 14:30 ` Thomas Hellström
2023-11-22 17:18 ` Ohad Sharabi
2023-11-23 14:32 ` Thomas Hellström
2023-11-22 11:03 ` [Intel-xe] [PATCH 2/4] drm/xe/bo: Rename xe_bo_get_sg() to xe_bo_sg() Thomas Hellström
2023-11-22 12:21 ` Matthew Auld
2023-11-22 17:19 ` Ohad Sharabi
2023-11-22 11:03 ` [Intel-xe] [PATCH 3/4] drm/xe/bo: Remove leftover trace_printk() Thomas Hellström
2023-11-22 12:22 ` Matthew Auld
2023-11-22 17:19 ` Ohad Sharabi
2023-11-22 11:03 ` Thomas Hellström [this message]
2023-11-22 12:35 ` [Intel-xe] [PATCH 4/4] drm/xe/vm: Fix ASID XA usage Matthew Auld
2023-11-22 17:23 ` Ohad Sharabi
2023-11-22 13:32 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe: Assorted memory-management fixes Patchwork
2023-11-22 13:32 ` [Intel-xe] ✓ CI.checkpatch: " Patchwork
2023-11-22 13:34 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-11-22 13:41 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-22 13:41 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-11-22 13:43 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
2023-11-23 10:09 ` [Intel-xe] ✓ CI.Patch_applied: " Patchwork
2023-11-23 10:10 ` [Intel-xe] ✓ CI.checkpatch: " Patchwork
2023-11-23 10:11 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-11-23 10:18 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-23 10:19 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-11-23 10:20 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
2023-11-23 10:58 ` [Intel-xe] ✓ CI.BAT: " 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=20231122110359.4087-5-thomas.hellstrom@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--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