1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct fence_ops</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="API-struct-fence-cb.html" title="struct fence_cb"><link rel="next" href="API-fence-get.html" title="fence_get"></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_ops</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-fence-cb.html">Prev</a> </td><th width="60%" align="center">Device Drivers DMA Management</th><td width="20%" align="right"> <a accesskey="n" href="API-fence-get.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-fence-ops"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct fence_ops — 2 operations implemented for fence 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct fence_ops { 5 const char * (* get_driver_name) (struct fence *fence); 6 const char * (* get_timeline_name) (struct fence *fence); 7 bool (* enable_signaling) (struct fence *fence); 8 bool (* signaled) (struct fence *fence); 9 signed long (* wait) (struct fence *fence, bool intr, signed long timeout); 10 void (* release) (struct fence *fence); 11 int (* fill_driver_data) (struct fence *fence, void *data, int size); 12 void (* fence_value_str) (struct fence *fence, char *str, int size); 13 void (* timeline_value_str) (struct fence *fence, char *str, int size); 14}; </pre></div><div class="refsect1"><a name="idp1110405436"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">get_driver_name</span></dt><dd><p> 15 returns the driver name. 16 </p></dd><dt><span class="term">get_timeline_name</span></dt><dd><p> 17 return the name of the context this fence belongs to. 18 </p></dd><dt><span class="term">enable_signaling</span></dt><dd><p> 19 enable software signaling of fence. 20 </p></dd><dt><span class="term">signaled</span></dt><dd><p> 21 [optional] peek whether the fence is signaled, can be null. 22 </p></dd><dt><span class="term">wait</span></dt><dd><p> 23 custom wait implementation, or fence_default_wait. 24 </p></dd><dt><span class="term">release</span></dt><dd><p> 25 [optional] called on destruction of fence, can be null 26 </p></dd><dt><span class="term">fill_driver_data</span></dt><dd><p> 27 [optional] callback to fill in free-form debug info 28 Returns amount of bytes filled, or -errno. 29 </p></dd><dt><span class="term">fence_value_str</span></dt><dd><p> 30 [optional] fills in the value of the fence as a string 31 </p></dd><dt><span class="term">timeline_value_str</span></dt><dd><p> 32 [optional] fills in the current value of the timeline 33 as a string 34 </p></dd></dl></div></div><div class="refsect1"><a name="idp1110412652"></a><h2>Notes on enable_signaling</h2><p> 35 For fence implementations that have the capability for hw->hw 36 signaling, they can implement this op to enable the necessary 37 irqs, or insert commands into cmdstream, etc. This is called 38 in the first <code class="function">wait</code> or <code class="function">add_callback</code> path to let the fence 39 implementation know that there is another driver waiting on 40 the signal (ie. hw->sw case). 41 </p><p> 42 43 This function can be called called from atomic context, but not 44 from irq context, so normal spinlocks can be used. 45 </p><p> 46 47 A return value of false indicates the fence already passed, 48 or some failure occurred that made it impossible to enable 49 signaling. True indicates successful enabling. 50 </p><p> 51 52 fence->status may be set in enable_signaling, but only when false is 53 returned. 54 </p><p> 55 56 Calling fence_signal before enable_signaling is called allows 57 for a tiny race window in which enable_signaling is called during, 58 before, or after fence_signal. To fight this, it is recommended 59 that before enable_signaling returns true an extra reference is 60 taken on the fence, to be released when the fence is signaled. 61 This will mean fence_signal will still be called twice, but 62 the second time will be a noop since it was already signaled. 63</p></div><div class="refsect1"><a name="idp1110416284"></a><h2>Notes on signaled</h2><p> 64 May set fence->status if returning true. 65</p></div><div class="refsect1"><a name="idp1110417020"></a><h2>Notes on wait</h2><p> 66 Must not be NULL, set to fence_default_wait for default implementation. 67 the fence_default_wait implementation should work for any fence, as long 68 as enable_signaling works correctly. 69 </p><p> 70 71 Must return -ERESTARTSYS if the wait is intr = true and the wait was 72 interrupted, and remaining jiffies if fence has signaled, or 0 if wait 73 timed out. Can also return other error values on custom implementations, 74 which should be treated as if the fence is signaled. For example a hardware 75 lockup could be reported like that. 76</p></div><div class="refsect1"><a name="idp1110418300"></a><h2>Notes on release</h2><p> 77 Can be NULL, this function allows additional commands to run on 78 destruction of the fence. Can be called from irq context. 79 If pointer is set to NULL, kfree will get called instead. 80</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-fence-cb.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-fence-get.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct fence_cb</span> </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">fence_get</span></td></tr></table></div></body></html> 81