]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/nouveau: Make fence container helper usable driver-wide
authorPhilipp Stanner <phasta@kernel.org>
Thu, 10 Jul 2025 12:54:10 +0000 (14:54 +0200)
committerPhilipp Stanner <phasta@kernel.org>
Thu, 10 Jul 2025 15:07:08 +0000 (17:07 +0200)
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
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_fence.h

index d5654e26d5bce019354f0b98680c8fed9300727f..869d4335c0f45cb9d6e2319bf10d10bc83ff716c 100644 (file)
 static const struct dma_fence_ops nouveau_fence_ops_uevent;
 static const struct dma_fence_ops nouveau_fence_ops_legacy;
 
-static inline struct nouveau_fence *
-from_fence(struct dma_fence *fence)
-{
-       return container_of(fence, struct nouveau_fence, base);
-}
-
 static inline struct nouveau_fence_chan *
 nouveau_fctx(struct nouveau_fence *fence)
 {
@@ -77,7 +71,7 @@ nouveau_local_fence(struct dma_fence *fence, struct nouveau_drm *drm)
            fence->ops != &nouveau_fence_ops_uevent)
                return NULL;
 
-       return from_fence(fence);
+       return to_nouveau_fence(fence);
 }
 
 void
@@ -268,7 +262,7 @@ nouveau_fence_done(struct nouveau_fence *fence)
 static long
 nouveau_fence_wait_legacy(struct dma_fence *f, bool intr, long wait)
 {
-       struct nouveau_fence *fence = from_fence(f);
+       struct nouveau_fence *fence = to_nouveau_fence(f);
        unsigned long sleep_time = NSEC_PER_MSEC / 1000;
        unsigned long t = jiffies, timeout = t + wait;
 
@@ -448,7 +442,7 @@ static const char *nouveau_fence_get_get_driver_name(struct dma_fence *fence)
 
 static const char *nouveau_fence_get_timeline_name(struct dma_fence *f)
 {
-       struct nouveau_fence *fence = from_fence(f);
+       struct nouveau_fence *fence = to_nouveau_fence(f);
        struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
 
        return !fctx->dead ? fctx->name : "dead channel";
@@ -462,7 +456,7 @@ static const char *nouveau_fence_get_timeline_name(struct dma_fence *f)
  */
 static bool nouveau_fence_is_signaled(struct dma_fence *f)
 {
-       struct nouveau_fence *fence = from_fence(f);
+       struct nouveau_fence *fence = to_nouveau_fence(f);
        struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
        struct nouveau_channel *chan;
        bool ret = false;
@@ -478,7 +472,7 @@ static bool nouveau_fence_is_signaled(struct dma_fence *f)
 
 static bool nouveau_fence_no_signaling(struct dma_fence *f)
 {
-       struct nouveau_fence *fence = from_fence(f);
+       struct nouveau_fence *fence = to_nouveau_fence(f);
 
        /*
         * caller should have a reference on the fence,
@@ -503,7 +497,7 @@ static bool nouveau_fence_no_signaling(struct dma_fence *f)
 
 static void nouveau_fence_release(struct dma_fence *f)
 {
-       struct nouveau_fence *fence = from_fence(f);
+       struct nouveau_fence *fence = to_nouveau_fence(f);
        struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
 
        kref_put(&fctx->fence_ref, nouveau_fence_context_put);
@@ -521,7 +515,7 @@ static const struct dma_fence_ops nouveau_fence_ops_legacy = {
 
 static bool nouveau_fence_enable_signaling(struct dma_fence *f)
 {
-       struct nouveau_fence *fence = from_fence(f);
+       struct nouveau_fence *fence = to_nouveau_fence(f);
        struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
        bool ret;
 
index 6a983dd9f7b9070e7628f0a9a3d47288d1371759..183dd43ecfff4ab3c8858899bc835089fe1b655d 100644 (file)
@@ -17,6 +17,12 @@ struct nouveau_fence {
        unsigned long timeout;
 };
 
+static inline struct nouveau_fence *
+to_nouveau_fence(struct dma_fence *fence)
+{
+       return container_of(fence, struct nouveau_fence, base);
+}
+
 int  nouveau_fence_create(struct nouveau_fence **, struct nouveau_channel *);
 int  nouveau_fence_new(struct nouveau_fence **, struct nouveau_channel *);
 void nouveau_fence_unref(struct nouveau_fence **);