summaryrefslogtreecommitdiff
path: root/sys/modules/linuxkpi
AgeCommit message (Collapse)Author
2026-01-05linuxkpi: Add <linux/siphash.h>Jean-Sébastien Pédron
The file is copied as is from Linux 6.10 as it dual-licensend under the GPLv2 and BSD 3-clause. The amdgpu DRM driver started to use it in Linux 6.10. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54501
2025-05-12linuxkpi: Add `folio` and `folio_batch` APIsJean-Sébastien Pédron
They are used by the i915 DRM driver in Linux 6.6 (although this change was only backported with Linux 6.7 DRM drivers). `struct folio` simply wraps `struct page` for now. `struct folio_batch` is the same as `struct pagevec` but it works with `struct folio` instead of `struct page` directly. Reviewed by: bz, kib, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48743
2023-12-13linuxkpi: Move `struct kobject` code to `linux_kobject.c`Jean-Sébastien Pédron
[Why] `linux_compat.c` is already too long. I will need to add `struct kset` in a follow-up commit, so let's move the existing `struct kobject` code to its own file. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D43019
2023-08-16sys: Remove $FreeBSD$: one-line sh patternWarner Losh
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2022-09-26LinuxKPI: define LINUXKPI_INCLUDES for module builds as wellBjoern A. Zeeb
While for in-kernel we already have LINUXKPI_INCLUDES in kern.pre.mk for kmod builds we've not had a common define to use leading to various spellings of include paths. In order for the include list to be expanded more easily in the future, e.g., adding the "dummy" includes (for all) and to harmonize code, duplicate LINUXKPI_INCLUDES to kmod.mk and use it for all module Makefiles. MFC after: 1 week Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D36683
2022-09-20linuxkpi: drm-kmod debugfs supportJake Freeland
This diff extends LinuxKPI to support simple attribute files in debugfs. These simple attributes are an essential component for compiling drm-kmod with CONFIG_DEBUG_FS enabled. This will allow for easier graphics driver debugging using Intel's igt-gpu-tools. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D35883 Sponsored by: Google, Inc. (GSoC 2022)
2022-09-01linuxkpi: on i386 only use first_msi_irq if apic is in kernel configTijl Coosemans
2022-03-11linuxkpi: fix module build outside of kernel build environmentEugene Grosbein
MFC after: 3 days
2022-01-25linuxkpi: Add i2c supportEmmanuel Vadot
Add i2c support to linuxkpi. This is needed by drm-kmod. For every i2c_adapter added by i2c_add_adapter we add a child to the device named "lkpi_iic". This child handle the conversion between Linux i2c_msgs to FreeBSD iic_msgs. For every i2c_adapter added by i2c_bit_add_bus we add a child to the device named "lkpi_iicbb". This child handle the conversion between Linux i2c_msgs to FreeBSD iic_msgs. With the help of iic(4), this expose the i2c controller to userspace allowing a user to query DDC information from a monitor. e.g.: i2c -f /dev/iic0 -a 0x28 -c 128 -d r will query the standard EDID from the monitor if plugged. The bitbang part (lkpi_iicbb) isn't tested at all for now as I don't have compatible hardware (all my hardware have native i2c controller). Tested on: Intel (SandyBridge, Skylake, ApolloLake) Tested on: AMD (Picasso, Polaris (amd64 and arm64)) MFC after: 1 month Reviewed by: hselasky Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33053
2021-12-27LinuxKPI: import beginning of a new version of netdevice.hBjoern A. Zeeb
Import a netdevice update complementing the last remaining bits of the old ifnet derived implementation. Along add a (for now) task based NAPI implementation. This is the minimal set of chnages which are needed for the initial support of wireless drivers. The NAPI implementation has an option to still switch to "direct dispatch" as it had been used by these drivers before not relying on a deferred context along with some printf tracing. This has been helpful in the last weeks for debugging and will be cleaned once we have had broader testing and are sure this is fine as-is. Should we need a more time-sensitive or load-sensitive response in the future we can always switch to something more sophisticated. Sponsored by: The FreeBSD Foundation MFC after: 3 days X-Differential Revision: D33075 (abandoned without feedback a while ago)
2021-12-27LinuxKPI: add a work-in-progress skbuff implementationBjoern A. Zeeb
This is a work-in-progress implementation of sk_buff compat code used for wireless drivers only currently. Bring in this version of the code as it has proven to be good enough to have packets going for a few months. The current implementation has several drawbacks including the need for us to copy data between sk_buffs and mbufs. Do not rely on the internals of this implementation. They are highly likely to change as we will improve the integration to FreeBSD mbufs. Sponsored by: The FreeBSD Foundation MFC after: 3 days
2021-11-18Fix some modules to export more used symbolsKonstantin Belousov
and remove non-present symbols that are now reported by kmod_syms.awk. Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878
2021-09-29LinuxKPI: Remove FreeBSD struct resource from all LKPI headersVladimir Kondratyev
except linux/pci.h to avoid conflicts with Linux version. This allows to #define resource in drm-kmod globally and strip some #ifdef-s Reviewed by: hselasky, manu MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D31673
2021-07-31LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.Hans Petter Selasky
Reviewed by: kib Submitted by: greg@unrelenting.technology Differential Revision: https://reviews.freebsd.org/D29921 MFC after: 1 week Sponsored by: NVIDIA Networking
2021-03-09Implement basic support for allocating memory from a specific numa nodeHans Petter Selasky
in the LinuxKPI. Differential Revision: https://reviews.freebsd.org/D29077 Reviewed by: markj@ and kib@ MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-28LinuxKPI: implement devres() framework parts and two examplesBjoern A. Zeeb
This code implements a version of the devres framework found working for various iwlwifi use cases and also providing functions for ttm_page_alloc_dma.c from DRM. Part of the framework replicates the consumed KPI, while others are internal helper functions. In addition the simple devm_k*malloc() consumers were implemented and kvasprintf() was enhanced to also work for the devm_kasprintf() case. Addmittingly lkpi_devm_kmalloc_release() could be avoided but for the overall understanding of the code and possible memory tracing it may still be helpful. Further devsres consumer are implemented for iwlwifi but will follow later as the main reason for this change is to sort out overlap with DRM. Sponsored-by: The FreeBSD Foundation Obtained-from: bz_iwlwifi MFC After: 3 days Reviewed-by: hselasky, manu Differential Revision: https://reviews.freebsd.org/D28189
2021-01-28LinuxKPI: add firmware loading supportBjoern A. Zeeb
Implement linux firmware KPI compat code. This includes: request_firmware() request_firmware_nowait(), request_firmware_direct(), firmware_request_nowarn(), and release_firmware(). Given we will try to map requested names from natively ported or full-linuxkpi-using drivers to a firmware(9) auto-loading name format (.ko file name and image name matching), we quieten firmware(9) and print success or failure (unless the _nowarn() version was called) in the linuxkpi implementation. At the moment we try up-to 4 different naming combinations, with path stripped, original name, and requested name with '/' or '.' replaced. We do not currently defer loading in the "nowait" case. Sponsored-by: The FreeBSD Foundation Sponsored-by: Rubicon Communications, LLC ("Netgate") (firmware(9) nowarn update from D27413) MFC after: 3 days Reviewed by: kib, manu (looked at older versions) Differential Revision: https://reviews.freebsd.org/D27414
2021-01-12linuxkpi: add kernel_fpu_begin/kernel_fpu_endEmmanuel Vadot
With newer AMD GPUs (>=Navi,Renoir) there is FPU context usage in the amdgpu driver. The `kernel_fpu_begin/end` implementations in drm did not even allow nested begin-end blocks. Submitted by: Greg V Reviewed By: manu, hselasky Differential Revision: https://reviews.freebsd.org/D28061
2021-01-12linuxkpi: Add shrinker supportEmmanuel Vadot
A driver can register a shrinker that will be called when the kernel wants to free some memory. Add support for that in linuxkpi and call the registered shrinkers when the lowmem event is triggered. Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D27728
2020-11-18Add missing header file when building the LinuxKPI module separately.Hans Petter Selasky
MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=367788
2020-11-09LinuxKPI: Implement ACPI bits required by drm-kmod in base systemEmmanuel Vadot
It includes: ACPI_HANDLE() implementation. AC and VIDEO ACPI events notification support. Replacement of hand-rolled GPLed _DSM method evaluation helpers with in-base ones. Submitted by: wulf Differential Revision: https://reviews.freebsd.org/D26603 Notes: svn path=/head/; revision=367521
2020-10-02linuxkpi: Add dmi_* functionEmmanuel Vadot
dmi function are used to get smbios values. The DRM subsystem and drivers use it to enabled (or not) quirks. Reviewed by: hselasky Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26046 Notes: svn path=/head/; revision=366373
2020-08-27Implement extensible arrays API using the existing radix tree implementationHans Petter Selasky
in the LinuxKPI. Differential Revision: https://reviews.freebsd.org/D25101 Reviewed by: kib @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=364860
2020-03-20Introduce LINUXKPI_GENSRCS.Konstantin Belousov
Centralize the list of generated files required by linuxkpi consumers, into the common variable. This way, consumers that use the variable are insulated from possible changes in the list. Reviewed by: hselasky, imp Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24137 Notes: svn path=/head/; revision=359185
2020-03-18Add pci_iov_if.h header as a dependency for Linuxkpi consumers.Konstantin Belousov
Sponsored by: Mellanox Technologies MFC after: 2 weeks Notes: svn path=/head/; revision=359095
2020-02-21linuxkpi: Move shmem related functions in it's own fileEmmanuel Vadot
For drmkpi (D23085) we don't want the Linux struct file as we don't emulate everything. Also the prototypes should be in shmem_fs.h to have 100% compatibility with Linux. Reviewed by: hselasky MFC after: Maybe Differential Revision: https://reviews.freebsd.org/D23764 Notes: svn path=/head/; revision=358217
2019-05-16LinuxKPI: Finalize import of seq_file.Johannes Lundberg
seq_file.h and linux_seq_file.c was imported form ports earlier but linux_seq_file.c was never compiled in with the module. With this commit base seq_file will replace ports seq_file and it required a few modifications to not break functionality and build. Reviewed by: hps Approved by: imp (mentor), hps MFC after: 1 week Notes: svn path=/head/; revision=347892
2018-10-30Implement the dump_stack() function in the LinuxKPI.Hans Petter Selasky
Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=339924
2017-06-26Sort SRCS.Mark Johnston
MFC after: 1 week Notes: svn path=/head/; revision=320386
2017-06-26Implement parts of the hrtimer API in the LinuxKPI.Mark Johnston
Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11359 Notes: svn path=/head/; revision=320364
2017-06-09Augment wait queue support in the LinuxKPI.Mark Johnston
In particular: - Don't evaluate event conditions with a sleepqueue lock held, since such code may attempt to acquire arbitrary locks. - Fix the return value for wait_event_interruptible() in the case that the wait is interrupted by a signal. - Implement wait_on_bit_timeout() and wait_on_atomic_t(). - Implement some functions used to test for pending signals. - Implement a number of wait_event_*() variants and unify the existing implementations. - Unify the mechanism used by wait_event_*() and schedule() to put the calling thread to sleep. This is required to support updated DRM drivers. Thanks to hselasky for finding and fixing a number of bugs in the original revision. Reviewed by: hselasky MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10986 Notes: svn path=/head/; revision=319757
2017-03-09Implement support for mutexes with deadlock avoidance in the LinuxKPI.Hans Petter Selasky
When locking a mutex and deadlock is detected the first mutex lock call that sees the deadlock will return -EDEADLK . MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314970
2017-03-08Cleanup the LinuxKPI slab implementation.Hans Petter Selasky
Put large functions into linux_slab.c instead of declaring them static inline. Add support for more memory allocation wrappers like kmalloc_array() and __vmalloc(). Make sure either the M_WAITOK or the M_NOWAIT flag is set and mask away unused memory allocation flags before calling FreeBSD's malloc() routine. Move kmalloc_node() definition to slab.h where it belongs. Implement support for the SLAB_DESTROY_BY_RCU feature when creating a kmem_cache which basically means kmem_cache memory is freed using call_rcu(). MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314905
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
2017-03-04sys/modules: normalize .CURDIR-relative paths to SRCTOPEnji Cooper
This simplifies make output/logic Tested with: `cd sys/modules; make ALL_MODULES=` on amd64 MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314651
2017-02-22Optimise unmapped LinuxKPI page allocations.Hans Petter Selasky
When allocating unmapped pages, take advantage of the direct map on AMD64 to get the virtual address corresponding to a page. Else all pages allocated must be mapped because sometimes the virtual address of a page is requested. Move all page allocation and deallocation code into an own C-file. Add support for GFP_DMA32, GFP_KERNEL, GFP_ATOMIC and __GFP_ZERO allocation flags. Make a clear separation between mapped and unmapped allocations. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314106
2017-02-21Replace dummy implementation of RCU in the LinuxKPI with one based onHans Petter Selasky
the in-kernel concurrency kit's ck_epoch API. Factor RCU hlist_xxx() functions into own rculist.h header file. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314050
2017-02-21Add support for LinuxKPI tasklets.Hans Petter Selasky
Tasklets are implemented using a taskqueue and a small statemachine on top. The additional statemachine is required to ensure all LinuxKPI tasklets get serialized. FreeBSD taskqueues do not guarantee serialisation of its tasks, except when there is only one worker thread configured. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314043
2017-02-21Make the LinuxKPI task struct persistent accross system calls.Hans Petter Selasky
A set of helper functions have been added to manage the life of the LinuxKPI task struct. When an external system call or task is invoked, a check is made to create the task struct by demand. A thread destructor callback is registered to free the task struct when a thread exits to avoid memory leaks. This change lays the ground for emulating the Linux kernel more closely which is a dependency by the code using the LinuxKPI APIs. Add new dedicated td_lkpi_task field has been added to struct thread instead of abusing td_retval[1]. Fix some header file inclusions to make LINT kernel build properly after this change. Bump the __FreeBSD_version to force a rebuild of all kernel modules. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=314040
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
2015-10-22Rename linuxapi[.ko] into linuxkpi[.ko], to reflect that it is aHans Petter Selasky
kernel programming interface module, KPI, to avoid confusion with the existing Linux userspace binary compatibility shims. Bump the FreeBSD_version number. Reviewed by: np @ Suggested by: dumbbell @ Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=289749