hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_linux_sched.c
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Expose some of the kernel scheduler routines
43 *
5
- * Copyright (C) 1999-2019, Broadcom Corporation
6
- *
4
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
5
+ *
6
+ * Copyright (C) 1999-2017, Broadcom Corporation
7
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -29,24 +30,47 @@
2930 */
3031 #include <linux/kernel.h>
3132 #include <linux/module.h>
33
+#include <linux/version.h>
34
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0))
35
+#include <uapi/linux/sched/types.h>
36
+#else
3237 #include <linux/sched.h>
38
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */
3339 #include <typedefs.h>
3440 #include <linuxver.h>
3541
3642 int setScheduler(struct task_struct *p, int policy, struct sched_param *param)
3743 {
3844 int rc = 0;
39
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
45
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0))
46
+ switch (policy) {
47
+ case SCHED_FIFO:
48
+ if (param->sched_priority >= MAX_RT_PRIO/2)
49
+ /* If the priority is MAX_RT_PRIO/2 or higher,
50
+ * it is considered as high priority.
51
+ * sched_priority of FIFO task dosen't
52
+ * exceed MAX_RT_PRIO/2.
53
+ */
54
+ sched_set_fifo(p);
55
+ else
56
+ /* For when you don't much care about FIFO,
57
+ * but want to be above SCHED_NORMAL.
58
+ */
59
+ sched_set_fifo_low(p);
60
+ break;
61
+ case SCHED_NORMAL:
62
+ sched_set_normal(p, PRIO_TO_NICE(p->static_prio));
63
+ break;
64
+ }
65
+#else
4066 rc = sched_setscheduler(p, policy, param);
41
-#endif /* LinuxVer */
67
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) */
4268 return rc;
4369 }
4470
4571 int get_scheduler_policy(struct task_struct *p)
4672 {
4773 int rc = SCHED_NORMAL;
48
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
4974 rc = p->policy;
50
-#endif /* LinuxVer */
5175 return rc;
5276 }