xref: /dflybsd-src/sys/dev/drm/include/linux/async.h (revision a85cb24f18e3804e75ab8bcda7692564d0563317)
1796e1f6bSFrançois Tigeot /*
2*a85cb24fSFrançois Tigeot  * Copyright (c) 2015-2020 François Tigeot <ftigeot@wolfpond.org>
3796e1f6bSFrançois Tigeot  * All rights reserved.
4796e1f6bSFrançois Tigeot  *
5796e1f6bSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6796e1f6bSFrançois Tigeot  * modification, are permitted provided that the following conditions
7796e1f6bSFrançois Tigeot  * are met:
8796e1f6bSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9796e1f6bSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10796e1f6bSFrançois Tigeot  *    disclaimer.
11796e1f6bSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12796e1f6bSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13796e1f6bSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14796e1f6bSFrançois Tigeot  *
15796e1f6bSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16796e1f6bSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17796e1f6bSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18796e1f6bSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19796e1f6bSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20796e1f6bSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21796e1f6bSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22796e1f6bSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23796e1f6bSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24796e1f6bSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25796e1f6bSFrançois Tigeot  */
26796e1f6bSFrançois Tigeot 
27796e1f6bSFrançois Tigeot #ifndef _LINUX_ASYNC_H_
28796e1f6bSFrançois Tigeot #define _LINUX_ASYNC_H_
29796e1f6bSFrançois Tigeot 
30796e1f6bSFrançois Tigeot #include <linux/types.h>
31796e1f6bSFrançois Tigeot #include <linux/list.h>
32796e1f6bSFrançois Tigeot 
33796e1f6bSFrançois Tigeot typedef u64 async_cookie_t;
34796e1f6bSFrançois Tigeot typedef void (*async_func_t) (void *data, async_cookie_t cookie);
35796e1f6bSFrançois Tigeot 
36796e1f6bSFrançois Tigeot extern async_cookie_t async_schedule(async_func_t func, void *data);
37796e1f6bSFrançois Tigeot 
async_synchronize_full(void)38796e1f6bSFrançois Tigeot static inline void async_synchronize_full(void) {
39796e1f6bSFrançois Tigeot 	/*
40796e1f6bSFrançois Tigeot 	 * XXX: This function is supposed to wait until all asynchronous
41796e1f6bSFrançois Tigeot 	 * function calls have been done
42796e1f6bSFrançois Tigeot 	 */
43796e1f6bSFrançois Tigeot }
44796e1f6bSFrançois Tigeot 
4539cfddd2SFrançois Tigeot /*
4639cfddd2SFrançois Tigeot  * This function is supposed to wait until all asynchronous function calls
4739cfddd2SFrançois Tigeot  * prior to cookie have finished
4839cfddd2SFrançois Tigeot  *
4939cfddd2SFrançois Tigeot  */
5039cfddd2SFrançois Tigeot static inline void
async_synchronize_cookie(async_cookie_t cookie)5139cfddd2SFrançois Tigeot async_synchronize_cookie(async_cookie_t cookie)
5239cfddd2SFrançois Tigeot {
5339cfddd2SFrançois Tigeot }
5439cfddd2SFrançois Tigeot 
55*a85cb24fSFrançois Tigeot static inline bool
current_is_async(void)56*a85cb24fSFrançois Tigeot current_is_async(void)
57*a85cb24fSFrançois Tigeot {
58*a85cb24fSFrançois Tigeot 	/* Linux async functions are executed synchronously on DragonFly */
59*a85cb24fSFrançois Tigeot 	return false;
60*a85cb24fSFrançois Tigeot }
61*a85cb24fSFrançois Tigeot 
62796e1f6bSFrançois Tigeot #endif	/* _LINUX_ASYNC_H_ */
63