aboutsummaryrefslogtreecommitdiff
path: root/sys/modules/linuxkpi
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in current: (cherry picked from commit 031beb4e239b)
* Revert "LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag."John Baldwin2023-05-271-2/+1
| | | | | | | | This broke part of the KBI used by drm-kmod. This reverts commit 8ca78eb03fd4b3c9f514ea6c075fc44dc9c02d27. Reported by: manu
* LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.Hans Petter Selasky2023-03-221-1/+2
| | | | | | | | | | Reviewed by: kib Submitted by: greg@unrelenting.technology Differential Revision: https://reviews.freebsd.org/D29921 MFC after: 1 week Sponsored by: NVIDIA Networking (cherry picked from commit 469884cf04a9b92677c7c83e229ca6b8814f8b0a)
* linuxkpi: drm-kmod debugfs supportJake Freeland2022-11-291-1/+2
| | | | | | | | | | | | | | 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) (cherry picked from commit f697b9432d9c7aa4c5ab5f5445ef5dc1bd40ce00)
* LinuxKPI: define LINUXKPI_INCLUDES for module builds as wellBjoern A. Zeeb2022-10-171-1/+1
| | | | | | | | | | | | | | | 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. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D36683 (cherry picked from commit 514fb3872166a361faa81d89909f65913e90b1b2)
* linuxkpi: Add i2c supportEmmanuel Vadot2022-06-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 (cherry picked from commit 1961a14a47437595fb7fcdc20e327440e3eb51e2)
* linuxkpi: fix module build outside of kernel build environmentEugene Grosbein2022-03-131-0/+1
| | | | (cherry picked from commit f5a2e7b0e8483bf51519046fd149a6a31acef6b1)
* LinuxKPI: import beginning of a new version of netdevice.hBjoern A. Zeeb2021-12-301-0/+1
| | | | | | | | | | | | | | | | | | | | 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 X-Differential Revision: D33075 (abandoned without feedback a while ago) (cherry picked from commit d105895844848ddba85d686e03e0d14c03ad4eb4)
* LinuxKPI: add a work-in-progress skbuff implementationBjoern A. Zeeb2021-12-301-0/+1
| | | | | | | | | | | | | | | | 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 (cherry picked from commit 49ed6e979c3b327ae466a559884802d901aa5792)
* Fix some modules to export more used symbolsKonstantin Belousov2021-11-251-0/+2
| | | | (cherry picked from commit 5bb3134a8c21cb87b30e135ef168483f0333dabb)
* LinuxKPI: Remove FreeBSD struct resource from all LKPI headersVladimir Kondratyev2021-10-131-0/+1
| | | | | | | | | | 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 Differential revision: https://reviews.freebsd.org/D31673 (cherry picked from commit 66ea390652d2ede405b43c168157986bd2b52bb9)
* MFC ebe5cf355dca:Hans Petter Selasky2021-03-231-0/+1
| | | | | | | | | | | Implement basic support for allocating memory from a specific numa node in the LinuxKPI. Differential Revision: https://reviews.freebsd.org/D29077 Reviewed by: markj@ and kib@ Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit ebe5cf355dca1d7827a70b99a9d9c4f97f78691d)
* LinuxKPI: implement devres() framework parts and two examplesBjoern A. Zeeb2021-02-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 (cherry picked from commit fa765ca73e553399ffbad382e579e4c2b4d0fc12)
* LinuxKPI: add firmware loading supportBjoern A. Zeeb2021-02-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 (cherry picked from commit a6c2507d1baedb183268e31bc6b6f659a9529904) (cherry picked from commit 4a26380ba6dc487a7525d909ee29fbc710b558d1)
* linuxkpi: add kernel_fpu_begin/kernel_fpu_endEmmanuel Vadot2021-01-121-1/+1
| | | | | | | | | | | 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
* linuxkpi: Add shrinker supportEmmanuel Vadot2021-01-121-0/+1
| | | | | | | | | | 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
* Add missing header file when building the LinuxKPI module separately.Hans Petter Selasky2020-11-181-1/+1
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=367788
* LinuxKPI: Implement ACPI bits required by drm-kmod in base systemEmmanuel Vadot2020-11-091-0/+5
| | | | | | | | | | | | | | | 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
* linuxkpi: Add dmi_* functionEmmanuel Vadot2020-10-021-0/+1
| | | | | | | | | | | | 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
* Implement extensible arrays API using the existing radix tree implementationHans Petter Selasky2020-08-271-1/+2
| | | | | | | | | | | | 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
* Introduce LINUXKPI_GENSRCS.Konstantin Belousov2020-03-201-8/+1
| | | | | | | | | | | | | | 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
* Add pci_iov_if.h header as a dependency for Linuxkpi consumers.Konstantin Belousov2020-03-181-0/+1
| | | | | | | | Sponsored by: Mellanox Technologies MFC after: 2 weeks Notes: svn path=/head/; revision=359095
* linuxkpi: Move shmem related functions in it's own fileEmmanuel Vadot2020-02-211-0/+1
| | | | | | | | | | | | | 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
* LinuxKPI: Finalize import of seq_file.Johannes Lundberg2019-05-161-0/+1
| | | | | | | | | | | | | | 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
* Implement the dump_stack() function in the LinuxKPI.Hans Petter Selasky2018-10-301-1/+2
| | | | | | | | | Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=339924
* Sort SRCS.Mark Johnston2017-06-261-3/+3
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=320386
* Implement parts of the hrtimer API in the LinuxKPI.Mark Johnston2017-06-261-0/+1
| | | | | | | | | Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11359 Notes: svn path=/head/; revision=320364
* Augment wait queue support in the LinuxKPI.Mark Johnston2017-06-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement support for mutexes with deadlock avoidance in the LinuxKPI.Hans Petter Selasky2017-03-091-0/+1
| | | | | | | | | | | 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
* Cleanup the LinuxKPI slab implementation.Hans Petter Selasky2017-03-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* LinuxKPI workqueue cleanup.Hans Petter Selasky2017-03-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* sys/modules: normalize .CURDIR-relative paths to SRCTOPEnji Cooper2017-03-041-3/+3
| | | | | | | | | | | 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
* Optimise unmapped LinuxKPI page allocations.Hans Petter Selasky2017-02-221-0/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Replace dummy implementation of RCU in the LinuxKPI with one based onHans Petter Selasky2017-02-211-0/+2
| | | | | | | | | | | | 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
* Add support for LinuxKPI tasklets.Hans Petter Selasky2017-02-211-0/+1
| | | | | | | | | | | | | | 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
* Make the LinuxKPI task struct persistent accross system calls.Hans Petter Selasky2017-02-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Finish process of moving the LinuxKPI module into the default kernel build.Hans Petter Selasky2015-10-291-4/+7
| | | | | | | | | | | | | | | | | | | | | | - 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
* Rename linuxapi[.ko] into linuxkpi[.ko], to reflect that it is aHans Petter Selasky2015-10-221-0/+18
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