xref: /dflybsd-src/sys/dev/drm/linux_workqueue.c (revision 591d50430760bd31759dc7f5343a7122560f86ce)
1df8db295SFrançois Tigeot /*
2df8db295SFrançois Tigeot  * Copyright (c) 2015 François Tigeot
3df8db295SFrançois Tigeot  * All rights reserved.
4df8db295SFrançois Tigeot  *
5df8db295SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6df8db295SFrançois Tigeot  * modification, are permitted provided that the following conditions
7df8db295SFrançois Tigeot  * are met:
8df8db295SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9df8db295SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10df8db295SFrançois Tigeot  *    disclaimer.
11df8db295SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12df8db295SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13df8db295SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14df8db295SFrançois Tigeot  *
15df8db295SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16df8db295SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17df8db295SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18df8db295SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19df8db295SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20df8db295SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21df8db295SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22df8db295SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23df8db295SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24df8db295SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25df8db295SFrançois Tigeot  */
26df8db295SFrançois Tigeot 
27df8db295SFrançois Tigeot #include <drm/drmP.h>
28df8db295SFrançois Tigeot #include <linux/workqueue.h>
29df8db295SFrançois Tigeot 
30df8db295SFrançois Tigeot struct workqueue_struct *system_wq;
31df8db295SFrançois Tigeot struct workqueue_struct *system_long_wq;
32*591d5043SFrançois Tigeot struct workqueue_struct *system_power_efficient_wq;
33df8db295SFrançois Tigeot 
34df8db295SFrançois Tigeot static int init_workqueues(void *arg)
35df8db295SFrançois Tigeot {
36df8db295SFrançois Tigeot 	system_wq = alloc_workqueue("system_wq", 0, 1);
37df8db295SFrançois Tigeot 	system_long_wq = alloc_workqueue("system_long_wq", 0, 1);
38*591d5043SFrançois Tigeot 	system_power_efficient_wq = alloc_workqueue("system_power_efficient_wq", 0, 1);
39df8db295SFrançois Tigeot 
40df8db295SFrançois Tigeot 	return 0;
41df8db295SFrançois Tigeot }
42f5e8ad19SImre Vadász 
43f5e8ad19SImre Vadász static int destroy_workqueues(void *arg)
44f5e8ad19SImre Vadász {
45f5e8ad19SImre Vadász 	destroy_workqueue(system_wq);
46f5e8ad19SImre Vadász 	destroy_workqueue(system_long_wq);
47f5e8ad19SImre Vadász 
48f5e8ad19SImre Vadász 	return 0;
49f5e8ad19SImre Vadász }
50f5e8ad19SImre Vadász 
51f5e8ad19SImre Vadász SYSINIT(linux_workqueue_init, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, init_workqueues, NULL);
52f5e8ad19SImre Vadász SYSUNINIT(linux_workqueue_destroy, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, destroy_workqueues, NULL);
53