@@ -42,7 +42,10 @@ struct fence_cb;
* @ops: fence_ops associated with this fence
* @cb_list: list of all callbacks to call
* @lock: spin_lock_irqsave used for locking
- * @priv: fence specific private data
+ * @context: execution context this fence belongs to, returned by
+ * fence_context_alloc()
+ * @seqno: the sequence number of this fence inside the executation context,
+ * can be compared to decide which fence would be signaled later.
* @flags: A mask of FENCE_FLAG_* defined below
*
* the flags member must be manipulated and read using the appropriate
@@ -83,6 +86,7 @@ typedef void (*fence_func_t)(struct fence *fence, struct fence_cb *cb, void *pri
/**
* struct fence_cb - callback for fence_add_callback
+ * @node: used by fence_add_callback to append this struct to fence::cb_list
* @func: fence_func_t to call
* @priv: value of priv to pass to function
*
@@ -98,8 +102,9 @@ struct fence_cb {
/**
* struct fence_ops - operations implemented for fence
* @enable_signaling: enable software signaling of fence
- * @signaled: [optional] peek whether the fence is signaled
- * @release: [optional] called on destruction of fence
+ * @signaled: [optional] peek whether the fence is signaled, can be null
+ * @wait: custom wait implementation
+ * @release: [optional] called on destruction of fence, can be null
*
* Notes on enable_signaling:
* For fence implementations that have the capability for hw->hw
@@ -124,6 +129,16 @@ struct fence_cb {
* This will mean fence_signal will still be called twice, but
* the second time will be a noop since it was already signaled.
*
+ * Notes on wait:
+ * Must not be NULL, set to fence_default_wait for default implementation.
+ * the fence_default_wait implementation should work for any fence, as long
+ * as enable_signaling works correctly.
+ *
+ * Must return -ERESTARTSYS if the wait is intr = true and the wait was interrupted,
+ * and remaining jiffies if fence has signaled. Can also return other error
+ * values on custom implementations, which should be treated as if the fence
+ * is signaled. For example a hardware lockup could be reported like that.
+ *
* Notes on release:
* Can be NULL, this function allows additional commands to run on
* destruction of the fence. Can be called from irq context.
@@ -133,7 +148,7 @@ struct fence_cb {
struct fence_ops {
bool (*enable_signaling)(struct fence *fence);
bool (*signaled)(struct fence *fence);
- long (*wait)(struct fence *fence, bool intr, signed long);
+ long (*wait)(struct fence *fence, bool intr, signed long timeout);
void (*release)(struct fence *fence);
};
@@ -194,7 +209,7 @@ static inline void fence_put(struct fence *fence)
int fence_signal(struct fence *fence);
int __fence_signal(struct fence *fence);
-long fence_default_wait(struct fence *fence, bool intr, signed long);
+long fence_default_wait(struct fence *fence, bool intr, signed long timeout);
int fence_add_callback(struct fence *fence, struct fence_cb *cb,
fence_func_t func, void *priv);
bool fence_remove_callback(struct fence *fence, struct fence_cb *cb);
@@ -254,7 +269,7 @@ static inline struct fence *fence_later(struct fence *f1, struct fence *f2)
BUG_ON(f1->context != f2->context);
- if (sig1 || f2->seqno - f2->seqno <= INT_MAX)
+ if (sig1 || f2->seqno - f1->seqno <= INT_MAX)
return f2;
else
return f1;