1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct fence</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="ch02s03.html" title="Device Drivers DMA Management"><link rel="prev" href="re398.html" title=".//drivers/dma-buf/seqno-fence.c"><link rel="next" href="API-struct-fence-cb.html" title="struct fence_cb"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct fence</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re398.html">Prev</a> </td><th width="60%" align="center">Device Drivers DMA Management</th><td width="20%" align="right"> <a accesskey="n" href="API-struct-fence-cb.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-fence"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct fence — 2 software synchronization primitive 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct fence { 5 struct kref refcount; 6 const struct fence_ops * ops; 7 struct rcu_head rcu; 8 struct list_head cb_list; 9 spinlock_t * lock; 10 unsigned context; 11 unsigned seqno; 12 unsigned long flags; 13 ktime_t timestamp; 14 int status; 15}; </pre></div><div class="refsect1"><a name="idp1110383556"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">refcount</span></dt><dd><p> 16refcount for this fence 17 </p></dd><dt><span class="term">ops</span></dt><dd><p> 18fence_ops associated with this fence 19 </p></dd><dt><span class="term">rcu</span></dt><dd><p> 20used for releasing fence with kfree_rcu 21 </p></dd><dt><span class="term">cb_list</span></dt><dd><p> 22list of all callbacks to call 23 </p></dd><dt><span class="term">lock</span></dt><dd><p> 24spin_lock_irqsave used for locking 25 </p></dd><dt><span class="term">context</span></dt><dd><p> 26execution context this fence belongs to, returned by 27<code class="function">fence_context_alloc</code> 28 </p></dd><dt><span class="term">seqno</span></dt><dd><p> 29the sequence number of this fence inside the execution context, 30can be compared to decide which fence would be signaled later. 31 </p></dd><dt><span class="term">flags</span></dt><dd><p> 32A mask of FENCE_FLAG_* defined below 33 </p></dd><dt><span class="term">timestamp</span></dt><dd><p> 34Timestamp when the fence was signaled. 35 </p></dd><dt><span class="term">status</span></dt><dd><p> 36Optional, only valid if < 0, must be set before calling 37fence_signal, indicates that the fence has completed with an error. 38 </p></dd></dl></div></div><div class="refsect1"><a name="idp1110391924"></a><h2>Description</h2><p> 39 the flags member must be manipulated and read using the appropriate 40 atomic ops (bit_*), so taking the spinlock will not be needed most 41 of the time. 42 </p><p> 43 44 FENCE_FLAG_SIGNALED_BIT - fence is already signaled 45 FENCE_FLAG_ENABLE_SIGNAL_BIT - enable_signaling might have been called* 46 FENCE_FLAG_USER_BITS - start of the unused bits, can be used by the 47 implementer of the fence for its own purposes. Can be used in different 48 ways by different fence implementers, so do not rely on this. 49 </p><p> 50 51 *) Since atomic bitops are used, this is not guaranteed to be the case. 52 Particularly, if the bit was set, but fence_signal was called right 53 before this bit was set, it would have been able to set the 54 FENCE_FLAG_SIGNALED_BIT, before enable_signaling was called. 55 Adding a check for FENCE_FLAG_SIGNALED_BIT after setting 56 FENCE_FLAG_ENABLE_SIGNAL_BIT closes this race, and makes sure that 57 after fence_signal was called, any enable_signaling call will have either 58 been completed, or never called at all. 59</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re398.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch02s03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-struct-fence-cb.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> 60 .//drivers/dma-buf/seqno-fence.c 61  </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">struct fence_cb</span></td></tr></table></div></body></html> 62