summaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/workqueue.h
AgeCommit message (Collapse)Author
2025-05-12linuxkpi: Fix up jiffies handlingMark Johnston
A few issues found by code inspection while hunting for bugzilla PR 286512: - The "expires" field in struct delayed_work should be unsigned. - In linux_timer_jiffies_until(), clamp the return value to INT_MAX: this return value is used as a ticks count, not a jiffies count, so we should avoid returning too large a value, lest it get truncated. It's unlikely we are dealing with values that large, but we should be careful anyway. - In linux_add_to_sleepqueue(), truncate the timeout to INT_MAX, as this value is passed to sleepq_set_timeout() as a ticks value. Typically it's multiplied by ticks_sbt to get an sbintime, and we should make sure the multiplication doesn't overflow. In drm-kmod, there is at least one call mod_delayed_work(... MAX_SCHEDULE_TIMEOUT). Fixes: 325aa4dbd10d ("linuxkpi: Introduce a properly typed jiffies") Reviewed by: olce, bz, dumbbell, kib Tested by: dumbbell, bz Differential Revision: https://reviews.freebsd.org/D50192
2025-04-29linuxkpi: Introduce a properly typed jiffiesMark Johnston
Now that we have a long-sized tick counter, we can migrate to using properly typed timeout parameters in various bits of the LinuxKPI. This fixes a subtle incompatibility that is otherwise difficult to paper over and leads to bugs when ticks values are sign-extended. - Introduce a "jiffies" symbol in subr_ticks.S, declared only in the LinuxKPI as an unsigned long. - Remove all references to "ticks" from the LinuxKPI. - Convert interfaces to match Linux's type signatures where it makes sense. Reviewed by: manu Tested by: bz Differential Revision: https://reviews.freebsd.org/D48523
2025-04-07linuxkpi: Add `queue_work_node()`Jean-Sébastien Pédron
This a variant of `queue_work()` that takes a NUMA node as its first argument. The NUMA node is ignored and `queue_work()` is called. The i915 DRM driver started to use this starting from Linux 6.8. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49377
2023-12-24LinuxKPI: Add cancel_work() function.Vladimir Kondratyev
Cancel a work not waiting for it to finish. Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42811
2023-08-16sys: Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2022-01-10LinuxKPI: Constantly use _LINUXKPI_ prefix in include guardsVladimir Kondratyev
MFC after: 1 week Reviewed by: bz, emaste, hselasky, manu Differential Revision: https://reviews.freebsd.org/D33562
2020-05-21linuxkpi: Add rcu_work functionsEmmanuel Vadot
The rcu_work function helps to queue some work after waiting for a grace period. This is needed by DRM drivers. Sponsored-by: The FreeBSD Foundation Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24942 Notes: svn path=/head/; revision=361343
2019-08-17Linuxkpi: Prevent easy generated ctor name conflicts with prefixConrad Meyer
Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=351158
2018-08-06Implement current_work() function in the LinuxKPI.Hans Petter Selasky
Tested by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=337376
2018-06-05Declare and set the global "system_highpri_wq" workqueue structure pointerHans Petter Selasky
in the LinuxKPI. Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Notes: svn path=/head/; revision=334664
2018-06-05Implement the INIT_DELAYED_WORK_ONSTACK() function macro in the LinuxKPI.Hans Petter Selasky
Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies Sponsored by: Limelight Networks Notes: svn path=/head/; revision=334663
2018-03-23linuxkpi whitespace cleanupEd Maste
Reviewed by: hselasky, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14807 Notes: svn path=/head/; revision=331433
2017-10-04Make sure the timer belonging to the delayed work in the LinuxKPIHans Petter Selasky
gets drained before invoking the work function. Else the timer mutex may still be in use which can lead to use-after-free situations, because the work function might free the work structure before returning. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=324278
2017-03-09Fix implementation of the DECLARE_WORK() macro in the LinuxKPI to fullyHans Petter Selasky
initialize the declared work structure and not only the function callback pointer. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314971
2017-03-07LinuxKPI workqueue cleanup.Hans Petter Selasky
This change makes the workqueue implementation behave more like in Linux, both functionality wise and structure wise. All workqueue code has been moved to linux_work.c Add an atomic based statemachine to the work_struct to ensure proper operation. Prior to this change struct_work was directly mapped to a FreeBSD task. When a taskqueue has multiple threads the same task may end up being executed on more than one worker thread simultaneously. This might cause problems with code coming from Linux, which expects serial behaviour, similar to Linux tasklets. Move all global workqueue function names into the linux_xxx domain to avoid symbol name clashes in the future. Implement a few more workqueue related functions and macros. Create two multithreaded taskqueues for the LinuxKPI during module load, one for time-consuming callbacks and one for non-time consuming callbacks. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314843
2015-12-21Implement drain_workqueue() function.Hans Petter Selasky
MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=292544
2015-12-21In the zero delay case in queue_delayed_work() use the return valueHans Petter Selasky
from taskqueue_enqueue() instead of reading "ta_pending" unlocked and also ensure the callout is stopped before proceeding. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=292543
2015-12-21Minor workqueue cleanup:Hans Petter Selasky
- Make some functions global instead of inline to ease debugging. - Fix some minor style issues. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=292542
2015-11-30Add more functions and types to the LinuxKPI.Hans Petter Selasky
MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=291481
2015-10-29Finish process of moving the LinuxKPI module into the default kernel build.Hans Petter Selasky
- Move all files related to the LinuxKPI into sys/compat/linuxkpi and its subfolders. - Update sys/conf/files and some Makefiles to use new file locations. - Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn adds the LinuxKPI to all LINT builds. - The LinuxKPI can be added to the kernel by setting the COMPAT_LINUXKPI option. The OFED kernel option no longer builds the LinuxKPI into the kernel. This was done to keep the build rules for the LinuxKPI in sys/conf/files simple. - Extend the LinuxKPI module to include support for USB by moving the Linux USB compat from usb.ko to linuxkpi.ko. - Bump the FreeBSD_version. - A universe kernel build has been done. Reviewed by: np @ (cxgb and cxgbe related changes only) Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=290135