2 * seqno-fence, using a dma-buf to synchronize fencing
4 * Copyright (C) 2012 Texas Instruments
5 * Copyright (C) 2012-2014 Canonical Ltd
7 * Rob Clark <robdclark@gmail.com>
8 * Maarten Lankhorst <maarten.lankhorst@canonical.com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 #include <linux/slab.h>
21 #include <linux/export.h>
22 #include <linux/seqno-fence.h>
24 static const char *seqno_fence_get_driver_name(struct fence
*fence
)
26 struct seqno_fence
*seqno_fence
= to_seqno_fence(fence
);
27 return seqno_fence
->ops
->get_driver_name(fence
);
30 static const char *seqno_fence_get_timeline_name(struct fence
*fence
)
32 struct seqno_fence
*seqno_fence
= to_seqno_fence(fence
);
33 return seqno_fence
->ops
->get_timeline_name(fence
);
36 static bool seqno_enable_signaling(struct fence
*fence
)
38 struct seqno_fence
*seqno_fence
= to_seqno_fence(fence
);
39 return seqno_fence
->ops
->enable_signaling(fence
);
42 static bool seqno_signaled(struct fence
*fence
)
44 struct seqno_fence
*seqno_fence
= to_seqno_fence(fence
);
45 return seqno_fence
->ops
->signaled
&& seqno_fence
->ops
->signaled(fence
);
48 static void seqno_release(struct fence
*fence
)
50 struct seqno_fence
*f
= to_seqno_fence(fence
);
52 dma_buf_put(f
->sync_buf
);
54 f
->ops
->release(fence
);
59 static signed long seqno_wait(struct fence
*fence
, bool intr
, signed long timeout
)
61 struct seqno_fence
*f
= to_seqno_fence(fence
);
62 return f
->ops
->wait(fence
, intr
, timeout
);
65 const struct fence_ops seqno_fence_ops
= {
66 .get_driver_name
= seqno_fence_get_driver_name
,
67 .get_timeline_name
= seqno_fence_get_timeline_name
,
68 .enable_signaling
= seqno_enable_signaling
,
69 .signaled
= seqno_signaled
,
71 .release
= seqno_release
,
73 EXPORT_SYMBOL(seqno_fence_ops
);