Skip to content

Commit 89b2675

Browse files
author
Philipp Stanner
committed
drm/nouveau: Make fence container helper usable driver-wide
In order to implement a new DRM GPU scheduler callback in Nouveau, a helper for obtaining a nouveau_fence from a dma_fence is necessary. Such a helper exists already inside nouveau_fence.c, called from_fence(). Make that helper available to other C files with a more precise name. Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Philipp Stanner <phasta@kernel.org> Link: https://lore.kernel.org/r/20250710125412.128476-8-phasta@kernel.org
1 parent d1e5ba8 commit 89b2675

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/gpu/drm/nouveau/nouveau_fence.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838
static const struct dma_fence_ops nouveau_fence_ops_uevent;
3939
static const struct dma_fence_ops nouveau_fence_ops_legacy;
4040

41-
static inline struct nouveau_fence *
42-
from_fence(struct dma_fence *fence)
43-
{
44-
return container_of(fence, struct nouveau_fence, base);
45-
}
46-
4741
static inline struct nouveau_fence_chan *
4842
nouveau_fctx(struct nouveau_fence *fence)
4943
{
@@ -77,7 +71,7 @@ nouveau_local_fence(struct dma_fence *fence, struct nouveau_drm *drm)
7771
fence->ops != &nouveau_fence_ops_uevent)
7872
return NULL;
7973

80-
return from_fence(fence);
74+
return to_nouveau_fence(fence);
8175
}
8276

8377
void
@@ -268,7 +262,7 @@ nouveau_fence_done(struct nouveau_fence *fence)
268262
static long
269263
nouveau_fence_wait_legacy(struct dma_fence *f, bool intr, long wait)
270264
{
271-
struct nouveau_fence *fence = from_fence(f);
265+
struct nouveau_fence *fence = to_nouveau_fence(f);
272266
unsigned long sleep_time = NSEC_PER_MSEC / 1000;
273267
unsigned long t = jiffies, timeout = t + wait;
274268

@@ -448,7 +442,7 @@ static const char *nouveau_fence_get_get_driver_name(struct dma_fence *fence)
448442

449443
static const char *nouveau_fence_get_timeline_name(struct dma_fence *f)
450444
{
451-
struct nouveau_fence *fence = from_fence(f);
445+
struct nouveau_fence *fence = to_nouveau_fence(f);
452446
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
453447

454448
return !fctx->dead ? fctx->name : "dead channel";
@@ -462,7 +456,7 @@ static const char *nouveau_fence_get_timeline_name(struct dma_fence *f)
462456
*/
463457
static bool nouveau_fence_is_signaled(struct dma_fence *f)
464458
{
465-
struct nouveau_fence *fence = from_fence(f);
459+
struct nouveau_fence *fence = to_nouveau_fence(f);
466460
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
467461
struct nouveau_channel *chan;
468462
bool ret = false;
@@ -478,7 +472,7 @@ static bool nouveau_fence_is_signaled(struct dma_fence *f)
478472

479473
static bool nouveau_fence_no_signaling(struct dma_fence *f)
480474
{
481-
struct nouveau_fence *fence = from_fence(f);
475+
struct nouveau_fence *fence = to_nouveau_fence(f);
482476

483477
/*
484478
* caller should have a reference on the fence,
@@ -503,7 +497,7 @@ static bool nouveau_fence_no_signaling(struct dma_fence *f)
503497

504498
static void nouveau_fence_release(struct dma_fence *f)
505499
{
506-
struct nouveau_fence *fence = from_fence(f);
500+
struct nouveau_fence *fence = to_nouveau_fence(f);
507501
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
508502

509503
kref_put(&fctx->fence_ref, nouveau_fence_context_put);
@@ -521,7 +515,7 @@ static const struct dma_fence_ops nouveau_fence_ops_legacy = {
521515

522516
static bool nouveau_fence_enable_signaling(struct dma_fence *f)
523517
{
524-
struct nouveau_fence *fence = from_fence(f);
518+
struct nouveau_fence *fence = to_nouveau_fence(f);
525519
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
526520
bool ret;
527521

drivers/gpu/drm/nouveau/nouveau_fence.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ struct nouveau_fence {
1717
unsigned long timeout;
1818
};
1919

20+
static inline struct nouveau_fence *
21+
to_nouveau_fence(struct dma_fence *fence)
22+
{
23+
return container_of(fence, struct nouveau_fence, base);
24+
}
25+
2026
int nouveau_fence_create(struct nouveau_fence **, struct nouveau_channel *);
2127
int nouveau_fence_new(struct nouveau_fence **, struct nouveau_channel *);
2228
void nouveau_fence_unref(struct nouveau_fence **);

0 commit comments

Comments
 (0)