aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include
Commit message (Collapse)AuthorAgeFilesLines
...
* linuxkpi: Fix up jiffies handlingMark Johnston2025-05-122-12/+1
| | | | | | | | | | | | | | | | | | | | | 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
* LinuxKPI: add ktime_get_boottime_seconds()Bjoern A. Zeeb2025-05-091-0/+7
| | | | | | | | | ktime_get_boottime_seconds() is needed by an updated iwlwifi driver. Sposored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D50005
* LinuxKPI: add _devcd_free_sgtable() to devcoredump.hBjoern A. Zeeb2025-05-091-1/+8
| | | | | | | | | | | | It may be that once we implement freeing of chained tables _devcd_free_sgtable() will become our _lkpi_dev_coredumpsg_free() but further investigations need to happen. For now make an updated iwlwifi driver happy which should not need more. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D50006
* LinuxKPI: add is_unicast_ether_addr()Bjoern A. Zeeb2025-05-051-1/+7
| | | | | | | | | | | | | Needed by mediatek/mt76 wireless driver. While here adjust the way is_multicast_ether_addr() is implemented to not look weird. [1] Sponsored by: The FreeBSD Foundation Suggested by: emaste [1] MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50152
* LinuxKPI: 802.11: header updates for mt76Bjoern A. Zeeb2025-05-053-38/+100
| | | | | | | Add more structs, fields, flags, defines. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* mt76: update Mediatek's mt76 driverBjoern A. Zeeb2025-05-041-0/+1
| | | | | | | | This version is based on git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 38fec10eb60d687e30c8c6b5420d86e8149f7557 ( tag: v6.14 ). Sponsored by: The FreeBSD Foundation
* LinuxKPI: netdev: add NETIF_F_HW_TCBjoern A. Zeeb2025-05-041-1/+2
| | | | | | | Add a new flag needed by mt76. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: fix wiphy_info[_once]Bjoern A. Zeeb2025-05-041-2/+2
| | | | | | | | The dev field in wiphy is a pointer already; no need for &. Sponsored by: The FreeBSD Foundation MFC after: 3 days Fixes: ac1d519c01ca8
* linuxkpi: Introduce a properly typed jiffiesMark Johnston2025-04-296-33/+35
| | | | | | | | | | | | | | | | | 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
* LinuxKPI: define time64_tBjoern A. Zeeb2025-04-271-0/+2
| | | | | | | | | | Define time64_t to int64_t for all supported architectures unconditionally. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: imp, markj, emaste Differential Revision: https://reviews.freebsd.org/D50004
* LinuxKPI: 802.11: updates to headers for driver updateBjoern A. Zeeb2025-04-243-16/+46
| | | | | | | | | | | | | Move some structs into the appropriate header to be visible. Add new fields to structs and enums. Remove arguments from two functions (one function currently unused by drivers in the tree, for the other the argument was unused). Adjust the iwlwifi accordingly. This is in preparation for new driver versions to allow a smooth transition. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: introduce mlo field to staBjoern A. Zeeb2025-04-241-0/+1
| | | | | | | | | Driver updates introduce a new field "mlo" to the sta. Add the field to the struct and initialize it in the 802.11 compat code along with a IMPROVE so once we get to 11be we can deal with it. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: pci: add pci_info()Bjoern A. Zeeb2025-04-241-1/+3
| | | | | | | | | | | Add pci_info() needed for a driver update. While here prefix __VA_ARGS__ with ## for pci_err and pci_info in case we are only passed a string without format arguments. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50009
* LinuxKPI: sysfs: implement sysfs_match_string()Bjoern A. Zeeb2025-04-241-0/+18
| | | | | | | | | | Use a macro to automatically gather the length of the array while we can. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50007
* LinuxKPI: add container_of_const()Bjoern A. Zeeb2025-04-241-0/+8
| | | | | | | | | Implement container_of_const() needed for wireless driver updates. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D49999
* LinuxKPI: extend struct and enum for ledsBjoern A. Zeeb2025-04-241-1/+2
| | | | | | | | | | | An updated rtw88 driver requires minimal changes to leds.h. On the positive side we can now remove the __DUMMY from the enum as we actually have a valid field name. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50002
* LinuxKPI: add cleanup.h to mutex.hBjoern A. Zeeb2025-04-241-0/+1
| | | | | | | | | | Some code relies on header pollution (or self-sustainability). Add cleanup.h to mutex.h as that is one case it seems to be used with. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50001
* LinuxKPI: add ASMEDIA vendor ID for PCIBjoern A. Zeeb2025-04-241-0/+1
| | | | | | | | | This is needed for rtw89 updates. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste, zarychtam_plan-b.pwste.edu.pl Differential Revision: https://reviews.freebsd.org/D50000
* LinuxKPI: 802.11: fix TKIP RX/TX MIC offsetsBjoern A. Zeeb2025-04-231-2/+3
| | | | | | | | | | | TKIP has a special key buffer. While keylen only identifies the key length, the two MIC are appended. The LinuxKPI offsets for these were unfortunately never set correct which lead to constant Micheal counter measures as the MIC never was correct when calculations were offloaded to firmware. This is the first half of the fix. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: add IEEE80211_KEY_FLAG_BITSBjoern A. Zeeb2025-04-231-0/+5
| | | | | | | | | Add IEEE80211_KEY_FLAG_BITS to be used with %b for debugging ieee802111_key_flag bit flags. Names are a lot easier to deal with than just numbers. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: fill ieee80211_get_key_rx_seq() also for TKIP/GCMPBjoern A. Zeeb2025-04-231-6/+24
| | | | | | | | | | In addition to CCMP add TKIP and GCMP support. The others are still TODO() until we do suport them natively. Also refine checks for tid and narrow them down (also don't assert but gratiously fail). Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI 802.11: move key-related functions togetherBjoern A. Zeeb2025-04-231-42/+45
| | | | | | | No functional changes. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: skbuff: fix types, shuffle fieldsBjoern A. Zeeb2025-04-221-18/+27
| | | | | | | | | Fix the types of a few remaining fields. Shuffle the fields around so the important ones align to 64byte on a 64bit platform. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: skbuff: remove _alloc_len fieldBjoern A. Zeeb2025-04-221-1/+0
| | | | | | | | | | Initially we saved the exact allocation length for contigfree(9). contigfree can now be replaced by free(9) so there is no need to remember that value anymore. Removing it also simplifies the linuxkpi_kfree_skb() code. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: add type for __wsumBjoern A. Zeeb2025-04-221-0/+1
| | | | | | | | | Seems this is the correct type for the csum field in an sk_buff. Add it as uint32_t __bitwise__. Sponsored by; The FreeBSD Foundation MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D49831
* linuxkpi: Fix `pci_upstream_bridge()` with DRM devicesJean-Sébastien Pédron2025-04-131-1/+14
| | | | | | | | | | | | | | | | In the case of DRM drivers, the passed device is a child of `vgapci`. We want to start the lookup from `vgapci`, so the parent of the passed `drmn`. We use the `isdrm` flag to determine if we are in this situation. This fixes an infinite loop with the amdgpu DRM driver that started to use this function in Linux 6.8: `pci_upstream_bridge()` was returning itself and the code in amdgpu was calling it again, hoping to get a device with a vendor that is not "ATI". Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49388
* linuxkpi: Add `memcpy_{from,to}_page()`Jean-Sébastien Pédron2025-04-131-0/+30
| | | | | | | | The i915 DRM driver started to use it in Linux 6.8. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49384
* lindebugfs: Add `debugfs_create_str()`Jean-Sébastien Pédron2025-04-131-0/+2
| | | | | | | | This function is used by the i915 DRM driver starting with Linux 6.8. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49067
* LinuxKPI; cleanup slab.h a bit; move more free() into slab.cBjoern A. Zeeb2025-04-121-45/+66
| | | | | | | | | | | | | | | | | | | | | | Move kfree() into slab.c as an implementation and hide the private function linux_kfree_async() entirely. Remove a ; at the end of a define and sort some defines into place. Remove extern from function declarations and move the closer to where they belong. Sort the functions into "base allocator/free" functions--these have an implementation in slab.c and are ensuring contiguous physical memory allocations. Followed by inline functions using these base allocators to implement their functionality; vmalloc/kvalloc, and misc functions. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D49572
* LinuxKPI: implement krealloc() for memory being contiguousBjoern A. Zeeb2025-04-121-15/+16
| | | | | | | | | | | | | Implement krealloc_array() using krealloc(). Implement krealloc() doing the various size checks ourselves and use realloc() or kmalloc() depending on old and new allocation sizes. This way we can ensure that allocated memory stays physically contiguous. Sponsored by: The FreeBSD Foundation MFC after: 3 days Suggested by: jhb (see D46657) Reviewed by: jhb, markj Differential Revision: https://reviews.freebsd.org/D49571
* LinuxKPI: switch mallocarray to an lkpi implementation using __kmalloc()Bjoern A. Zeeb2025-04-121-18/+30
| | | | | | | | | | | | | | | | | | | | With mallocarray() we cannot guarantee that any size larger than PAGE_SIZE will be contiguous. Switch kmalloc_array() and kmalloc_array_node() to use __kmalloc()/lkpi___kmalloc_node() as their underlying implementation which now does provide that guarantee. Likewise adjust kcalloc_node() to use kmalloc_array_node(). This means we only have two (plain + _node) underlying allocation routines for the entire category of functions. Also adjust kvmalloc() and kvmalloc_array() to be a "mirrored" implementation to their non-v counterparts. These may return non-contiguous memory so can use malloc(). Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: jhb Extra thanks to: jhb for helping sorting this out Differential Revision: https://reviews.freebsd.org/D46657
* LinuxKPI: add seq_hex_dump()Bjoern A. Zeeb2025-04-122-46/+22
| | | | | | | | | | | | | | | | | | | Move the implementation of print_hex_dump() into linux_compat.c as lkpi_hex_dump() taking an extra function pointer and argument. Add two internal wrappers for printf and sbuf_printf to get a common function definition (sbuf_printf takes the extra argument). Use these to implement print_hex_dump() and the newly added seq_hex_dump(). This allows us to re-use the same implementation of print_hex_dump() for both functions without duplicating the code. Initial implementation: D49381 by dumbbell Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D49637
* linuxkpi: Add <linux/ref_tracker.h>Jean-Sébastien Pédron2025-04-121-0/+93
| | | | | | | | | | | This currently implements the empty stubs when `CONFIG_REF_TRACKER` is not defined. This is used by the i915 DRM driver starting with Linux 6.8. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49376
* LinuxKPI: 802.11: more fields moved from vif to bss_confBjoern A. Zeeb2025-04-111-3/+2
| | | | | | | | | | | | csa_active, color_change_active, mu_mimo_owner also moved from vif to bss_conf; we already have the fields in bss_conf (adjust type for one) so all we have to do is remove the old relics in vif. Sponsored by: The FreeBSD Foundation MFC after: 3 days Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734
* LinuxKPI: 802.11: move chanctx_conf from vif to vif->bss_confBjoern A. Zeeb2025-04-111-1/+0
| | | | | | | | | | | | In preparations for MLD support chanctx_conf was moved from vif to the bss_conf as it will be per-link later. Follow accordingly. Sponsored by: The FreeBSD Foundation PR: 280546 MFC after: 3 days Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734
* LinuxKPI: 802.11: reduce code duplication introducing lkpi_remove_chanctx()Bjoern A. Zeeb2025-04-111-1/+1
| | | | | | | | | | | | We have the same code three times, so factor it out into its own function to make it easier to maintain. Sponsored by: The FreeBSD Foundation PR: 280546 MFC after: 3 days Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734
* LinuxKPI: 802.11: remove cipher_scheme supportBjoern A. Zeeb2025-04-111-14/+0
| | | | | | | | | iwlwifi was the only driver we care about which "used" cipher_scheme and it was removed from there too. Remove given it is no longer used anywhere. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* linuxkpi: Add <linux/acpi_amd_wbrf.h>Jean-Sébastien Pédron2025-04-071-0/+97
| | | | | | | | | | | This header implements several stub functions that, on Linux, are used when `CONFIG_AMD_WBRF` is not set at build time. The amdgpu DRM driver started to use it in Linux 6.8. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49382
* linuxkpi: Add `local_irq_{save,restore}()`Jean-Sébastien Pédron2025-04-071-0/+8
| | | | | | | | | | These are no-ops. The i915 DRM driver started to use it in Linux 6.8. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49380
* linuxkpi: Add `BIN_ATTR*()` macrosJean-Sébastien Pédron2025-04-071-4/+37
| | | | | | | | | | | | | | | | They are helpers to declare static `struct bin_attribute`. The amdgpu DRM driver started to use them for some time but the code was commented out (and this is still the case as of this commit). In Linux 6.8, it declared a new BIN_ATTR. This new code is not commented out. While here, change the first argument of the `read` and `write` callbacks to be a `struct linux_file *` instead of a `struct file *`. This ensures the right structure is being referenced at compile time. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49378
* linuxkpi: Add `queue_work_node()`Jean-Sébastien Pédron2025-04-071-0/+6
| | | | | | | | | | | | | 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
* linuxkpi: Add `show_fdinfo()` to `struct file_operations`Jean-Sébastien Pédron2025-04-071-0/+5
| | | | | | | | | | | | | We never call this field but it allows to compile drivers without modifications. This is used by the DRM drivers for some time, but another change part of the update to Linux 6.8 led to compile them with `CONFIG_PROC_FS`. This connected code that uses this struct field. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49069
* linuxkpi: Add `sysfs_create_bin_file()` and `sysfs_remove_bin_file()`Jean-Sébastien Pédron2025-04-071-0/+83
| | | | | | | | | | | They are used by the i915 DRM driver for quite some time, but that code was commented out. It was moved around in Linux 6.8, so instead of figuring out what should be commented out now, let's add an implementation of these functions. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49068
* linuxkpi: Define `MAX_PAGE_ORDER` and `NR_PAGE_ORDERS`Jean-Sébastien Pédron2025-03-291-0/+3
| | | | | | | | | The TTM component of the DRM drivers started to use the latter in Linux 6.8. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49387
* linuxkpi: Add `pwm_apply_might_sleep()`Jean-Sébastien Pédron2025-03-291-0/+6
| | | | | | | | The i915 DRM driver started to use it in Linux 6.8. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49386
* LinuxKPI: make linux_alloc_pages() honor __GFP_NORETRYMathieu2025-03-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to fix slowdowns with drm-kmod that get worse over time as physical memory become more fragmented (and probably also depending on other factors). Based on information posted in this bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277476 By default, linux_alloc_pages() retries failed allocations by calling vm_page_reclaim_contig() to attempt to free contiguous physical memory pages. vm_page_reclaim_contig() does not always succeed and calling it can be very slow even when it fails. When physical memory is very fragmented, vm_page_reclaim_contig() can end up being called (and failing) after every allocation attempt. This could cause very noticeable graphical desktop hangs (which could last seconds). The drm-kmod code in question attempts to allocate multiple contiguous pages at once but does not actually require them to be contiguous. It can fallback to doing multiple smaller allocations when larger allocations fail. It passes alloc_pages() the __GFP_NORETRY flag in this case. This patch makes linux_alloc_pages() fail early (without retrying) when this flag is passed. [olce: The problem this patch fixes is longer and longer GUI freezes as a machine's memory gets filled and becomes fragmented, when using amdgpu from DRM kmod 5.15 and DRM kmod 6.1 (DRM kmod 5.10 is unaffected; newer Linux kernel introduced an "optimization" by which a pool of pages is filled preferentially with contiguous pages, which triggered the problem for us). The original commit message above evokes freezes lasting seconds, but I occasionally witnessed some lasting tens of minutes, rendering a machine completely useless. The patch has been reviewed for its potential impacts to other LinuxKPI parts and our existing DRM kmods' code. In particular, there is no other user of __GFP_NORETRY/GFP_NORETRY with Linux's alloc_pages*() functions in our tree or DRM kmod ports. It has also been tested extensively, by me for months against 14-STABLE and sporadically on -CURRENT on a RX580, and by several others as reported below and as is visible in more details in the quoted bugzilla PR and in the initial drm-kmod issue at https://github.com/freebsd/drm-kmod/issues/302, on a variety of other AMD GPUs (several RX580, RX570, Radeon Pro WX5100, Green Sardine 5600G, Ryzen 9 4900H with embedded Renoir).] PR: 277476 Reported by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net> Reviewed by: olce Tested by: many (olce, Pierre Pronchery, Evgenii Khramtsov, chaplina, rk) MFC after: 2 weeks Relnotes: yes Sponsored by: The FreeBSD Foundation (review and part of testing)
* linuxkpi: Document why <linux/cpufeaure.h> has an include commentted outJean-Sébastien Pédron2025-03-211-1/+7
| | | | | | | | | | | | <linux/cpufeature.h> on Linux includes <linux/init.h>. We don't have the latter on FreeBSD yet, so let's comment this include for now. It is still referenced because sometimes, consumers of headers rely voluntarily or not on the namespace pollution. Reported by: jrtc27 Approved by: jrtc27 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49448
* linuxkpi: Add <linux/cpufeature.h>Jean-Sébastien Pédron2025-03-201-0/+37
| | | | | | Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49385
* linuxkpi: Add <linux/units.h>Jean-Sébastien Pédron2025-03-201-0/+40
| | | | | | | | The amdgpu DRM driver started to use it in Linux 6.8. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49383
* linuxkpi: Define a few more `PCI_*` constantsJean-Sébastien Pédron2025-03-201-0/+6
| | | | | | | | They are synonymous to existing FreeBSD constants. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49379