]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/dma-fence.h
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux.git] / include / linux / dma-fence.h
index 6b788467b2e3b650d4688f036f5e28a90fea8938..05d29dbc7e62c12b7d99bb8d4d4e5cccf2e46461 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Fence mechanism for dma-buf to allow for asynchronous dma access
  *
@@ -7,15 +8,6 @@
  * Authors:
  * Rob Clark <robdclark@gmail.com>
  * Maarten Lankhorst <maarten.lankhorst@canonical.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
  */
 
 #ifndef __LINUX_DMA_FENCE_H
@@ -111,6 +103,14 @@ struct dma_fence_cb {
  *
  */
 struct dma_fence_ops {
+       /**
+        * @use_64bit_seqno:
+        *
+        * True if this dma_fence implementation uses 64bit seqno, false
+        * otherwise.
+        */
+       bool use_64bit_seqno;
+
        /**
         * @get_driver_name:
         *
@@ -410,18 +410,19 @@ dma_fence_is_signaled(struct dma_fence *fence)
  * __dma_fence_is_later - return if f1 is chronologically later than f2
  * @f1: the first fence's seqno
  * @f2: the second fence's seqno from the same context
+ * @ops: dma_fence_ops associated with the seqno
  *
  * Returns true if f1 is chronologically later than f2. Both fences must be
  * from the same context, since a seqno is not common across contexts.
  */
-static inline bool __dma_fence_is_later(u64 f1, u64 f2)
+static inline bool __dma_fence_is_later(u64 f1, u64 f2,
+                                       const struct dma_fence_ops *ops)
 {
        /* This is for backward compatibility with drivers which can only handle
-        * 32bit sequence numbers. Use a 64bit compare when any of the higher
-        * bits are none zero, otherwise use a 32bit compare with wrap around
-        * handling.
+        * 32bit sequence numbers. Use a 64bit compare when the driver says to
+        * do so.
         */
-       if (upper_32_bits(f1) || upper_32_bits(f2))
+       if (ops->use_64bit_seqno)
                return f1 > f2;
 
        return (int)(lower_32_bits(f1) - lower_32_bits(f2)) > 0;
@@ -441,7 +442,7 @@ static inline bool dma_fence_is_later(struct dma_fence *f1,
        if (WARN_ON(f1->context != f2->context))
                return false;
 
-       return __dma_fence_is_later(f1->seqno, f2->seqno);
+       return __dma_fence_is_later(f1->seqno, f2->seqno, f1->ops);
 }
 
 /**