From: Lukasz Laguna <lukasz.laguna@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: michal.winiarski@intel.com, michal.wajdeczko@intel.com,
lukasz.laguna@intel.com
Subject: [PATCH v1 2/3] drm/xe/bo: Add trylock helper for buffer objects
Date: Wed, 16 Oct 2024 11:57:44 +0200 [thread overview]
Message-ID: <20241016095745.7477-3-lukasz.laguna@intel.com> (raw)
In-Reply-To: <20241016095745.7477-1-lukasz.laguna@intel.com>
Wrap dma_resv_trylock() for convenient use with buffer objects.
Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 16 +++++++++++++++-
drivers/gpu/drm/xe/xe_bo.h | 2 +-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 5b232f2951b1..6af7bc586f1c 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -2168,11 +2168,25 @@ int xe_bo_lock(struct xe_bo *bo, bool intr)
return 0;
}
+/**
+ * xe_bo_trylock() - Trylock the buffer object's dma_resv object
+ * @bo: The struct xe_bo whose lock is tried to be taken.
+ *
+ * Tries to lock the buffer object's dma_resv object.
+ *
+ * Return: true if the lock was acquired, false otherwise.
+ */
+bool xe_bo_trylock(struct xe_bo *bo)
+{
+ return dma_resv_trylock(bo->ttm.base.resv);
+}
+
/**
* xe_bo_unlock() - Unlock the buffer object's dma_resv object
* @bo: The struct xe_bo whose lock is to be released.
*
- * Unlock a buffer object lock that was locked by xe_bo_lock().
+ * Unlock a buffer object lock that was locked by xe_bo_lock() or
+ * xe_bo_trylock().
*/
void xe_bo_unlock(struct xe_bo *bo)
{
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 7fa44a0138b0..83992471c510 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -147,7 +147,7 @@ static inline void xe_bo_assert_held(struct xe_bo *bo)
}
int xe_bo_lock(struct xe_bo *bo, bool intr);
-
+bool xe_bo_trylock(struct xe_bo *bo);
void xe_bo_unlock(struct xe_bo *bo);
static inline void xe_bo_unlock_vm_held(struct xe_bo *bo)
--
2.40.0
next prev parent reply other threads:[~2024-10-16 9:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 9:57 [PATCH v1 0/3] PF: Add functions to save and restore VF LMEM and CCS data Lukasz Laguna
2024-10-16 9:57 ` [PATCH v1 1/3] drm/xe/migrate: Add function for raw copy of VRAM and CCS Lukasz Laguna
2024-10-16 12:54 ` Nirmoy Das
2024-10-30 10:38 ` Laguna, Lukasz
2024-10-16 9:57 ` Lukasz Laguna [this message]
2024-10-16 9:57 ` [PATCH v1 3/3] drm/xe/pf: Add functions to save and restore VF LMEM and CCS data Lukasz Laguna
2024-10-17 11:12 ` Michal Wajdeczko
2024-10-30 10:36 ` Laguna, Lukasz
2024-10-16 12:43 ` ✓ CI.Patch_applied: success for PF: " Patchwork
2024-10-16 12:43 ` ✗ CI.checkpatch: warning " Patchwork
2024-10-16 12:44 ` ✓ CI.KUnit: success " Patchwork
2024-10-16 12:55 ` ✓ CI.Build: " Patchwork
2024-10-16 12:58 ` ✗ CI.Hooks: failure " Patchwork
2024-10-16 12:59 ` ✓ CI.checksparse: success " Patchwork
2024-10-16 13:16 ` ✓ CI.BAT: " Patchwork
2024-10-17 4:42 ` ✗ 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=20241016095745.7477-3-lukasz.laguna@intel.com \
--to=lukasz.laguna@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@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