Linux only implements these functions on x86. They return 0 on other
architectures. The FreeBSD implementation calls PHYS_TO_DMAP but this
panics on i386 because it does not have a direct map so return 0 on i386
as well for now. These functions are only used by graphics/drm-*-kmod
to mark the VRAM aperture write-combining but this is also accomplished
by a call to vm_phys_fictitious_reg_range so this change is sufficient
to fix drm-*-kmod on i386 for FreeBSD 14.1.
Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D45125
(cherry picked from commit 2ae0f5a4d0931067c672be9a791909f0e32d5a0e)
Add checks for __counted_by(_x) and __nonstring as and depending
on compiler support enable the attribute/feature.
This is needed to make mtk76 and ath1xk drivers compile.
Sposnored by: The FreeBSD Foundation
Reviewed by: emaste, dim
Differential Revision: https://reviews.freebsd.org/D44587
(cherry picked from commit 2a8c50592f7fce8bceedf004f674a5a9eae0fd46)
mt76 calls devm_kfree() directly, so alias it to our
lkpi_devm_kmalloc_release() function.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44589
(cherry picked from commit 170c2e0e2bb1b2d9a7661ba729f8264381c9d9d7)
A newer version of iwlwifi requires a return value from napi_schedule();
unclear if the function always should have been bool. Add the bool to test
based on the napi_schedule_prep() result.
Also add napi_is_scheduled() for rtw89.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste (previous version)
Differential Revision: https://reviews.freebsd.org/D44591
(cherry picked from commit 21761f2ede4ebad13e78112b9409c1f20f946781)
Implement skb_queue_splice_tail_init() and SKB_DATA_ALIGN() as
needed by the mt76 wireless driver.
Sponsord by: The FreeBD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D44590
(cherry picked from commit 3d3ec17825a124f0119d76c4d2523d73012fa226)
Add dev_alloc_pages() though it seems a weird KPI, not passing a dev
despite its name. Used by updated wireless driver.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D44588
(cherry picked from commit 738c02ba24c66391870067602f1c9c030d5c5e5d)
Just like BITS_TO_LONG() ... used in rtw89.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D44603
(cherry picked from commit f674f016c03d49e14f1c651ed088a6f2d01a62ee)
This addresses a -Wunused-but-set-variable warning in the gcc builds.
No functional change intended.
Reported by: Jenkins
(cherry picked from commit 344a04ad2c5e62b2905bc2f8b6f992ae590403fd)
The variable fileid stores the result from kern_kldload() but never gets
used. Since the third parameter `*fileid` of kern_kldload() can be NULL,
this unused variable can be safely removed.
No functional change intended.
Reviewed by: emaste, bz, #linuxkpi
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44583
(cherry picked from commit 317cc829ee227cfdffe7b25125c070112ce0c2f1)
hash_add_rcu asserted that the node's prev pointer was NULL in an
attempt to detect addition of a node already on a list, but the caller
is not required to provide a zeroed node.
Reported in https://github.com/freebsd/drm-kmod/issues/282
Reviewed by: bz, manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43645
(cherry picked from commit 7e77089dccd702eb767350a8bd3d20102c4fb591)
Correct skb_queue_tail to queue the buffer at the tail of the skbuff.
The skbuff is a circular doubly-linked list, and we call with a pointer
to the head of the list. Thus queueing before the head gives us a
queueing at the tail.
As a motivating factor, the current behaviour (queueing at the head) was
causing frequent kernel panics from my RTL8822BE wireless card, which
uses the rtw88 driver. Interrupts can cause buffers to be added to the
rtwdev c2h_queue while the queue is being drained in rtw_c2h_work.
Queueing at the head would leave the nascent entry in the linked list
pointing to the old, now freed, memory for the buffer being processed.
When rtw_c2h_work is next called, we try reading this and so panic.
Reviewed by: emaste, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44192
(cherry picked from commit d3befb534b9c8cd80f1b8d75ce6451e3f62b8ba9)
It seems during the initial buildup of the file, the defines were
either mixed or not flagged as "FIXME".
Define the values through to the net80211 definitions and also
annotate them by at least some standards reference.
Fixes: 6b4cac814e
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43658
(cherry picked from commit 53eb2c63c9628f7f19d88d759e1932c10c9f08af)
For iwlwifi(4) d3.c we need another struct in struct ieee80211_key_seq
and related WLAN_KEY_LEN_* defines in.
Reviewed by: cc, emaste
Differential Revision: https://reviews.freebsd.org/D43646
(cherry picked from commit 2f029bf911e29dc46c32ea142daba4f26a2078f4)
Fix defines and structures to use proper types.
Bring in basic ni->sta synchronization, some channel width handling,
and overload the net80211 functions so that we can talk to
driver/firmware to setup parameters. We will likely not need one
or two of those but it is good for tracing currently.
Cover HT and bits of VHT code in LinuxKPI behind apropriate #ifdef
which are currently not enabled (like LKPI_80211_HW_CRYPTO) until
confirmed to work.
Last, IEEE80211_AMPDU_RX_START made some firmware unhappy.
This will allow others to work on it and test as well.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 9fb914634eff85b3b36bcbf39c1faf2967b0aa9e)
Sort the dev_<loglevel> functions by loglevel order, add the dev_alert()
version and an indentation change.
No functional changes.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D43719
(cherry picked from commit 70617458676eb0b0076aa19657d21f2a9f3b704a)
Amdgpu driver does a lot of memory allocations in FPU-protected sections
of code for certain display cores, e.g. for DCN30. This does not work
on FreeBSD as its malloc function can not be run within a critical
section. Check this condition and temporally exit from FPU-protected
context to workaround issue and reduce source code patching.
Sponsored by: Serenity Cyber Security, LLC
Reviewed by: manu (previous version)
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42822
(cherry picked from commit c0b8047bdc13040eafb162c4b7b5dba11034ff4b)
It does a Read-Modify-Write operation using clear and set bitmasks on
PCI Express Capability Register at pos. As certain PCI Express
Capability Registers are accessed concurrently in RMW fashion, hence
require locking which is handled transparently to the caller.
Sponsored by: Serenity CyberSecurity, LLC
Reviewed by: manu, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42821
(cherry picked from commit 808ae4e29b6b9c9acc7eab013c5045370df8182a)
and bitmap_shift_right() functions to linux/bitmap.h
They perform calculation of two bitmaps intersection,
copying the contents of u32 array of bits to bitmap and
logical right shifting of the bits in a bitmap.
Sponsored by: Serenity Cyber Security, LLC
Reviewed by: manu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42812
(cherry picked from commit 5ae2e6f913fa1df5f3262255558b76af05409a09)
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
(cherry picked from commit 1b2f43a7427ebf51561867f6c497833268014512)
Linux uses it only if SHRINKER_DEBUG config option is enabled. Ignore it.
Sponsored by: Serenity Cyber Security, LLC
Reviewers: manu, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42809
(cherry picked from commit a39ed121eab16bd2579422f71df7ef29b55965d1)
ida_alloc_min() allocates an unused ID. between min and INT_MAX.
While here allow end parameter of ida_simple_get() be larger than
INT_MAX. Linux caps the value to INT_MAX.
Sponsored by: Serenity Cyber Security, LLC
Reviewers: manu, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42806
(cherry picked from commit c7312643b7e5f01adc2a3094c5139f5dcab5f0a4)
It is implemented like ktime_get_raw_ns() function but uses less
precise getnanouptime() call.
Sponsored by: Serenity Cyber Security, LLC
Reviewed by: manu, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42804
(cherry picked from commit e964da141523e1eec2322082936cdb20ba0cf4a7)
And move it along BUILD_BUG family in to
linux/build_bug.h to match Linux.
Sponsored by: Serenity Cyber Security, LLC
Reviewed by: manu, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42800
(cherry picked from commit 31ef29091b0fbadefb4ccfb21e4b30ca7ddca3ed)
sys/rman.h defines `resource` structure which conflicts with the Linux
structure of the same name. To fix that remove reference to sys/rman.h
from linux/pci.h and move resource management code to linux_pci.c.
Update consumers which were depending on linux/pci.h pollution.
No functional changes intended.
Sponsored by: Serenity Cyber Security, LLC
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42792
(cherry picked from commit 96ab16ebab6319dce9b3041961b0ab6e20a4fecc)
[Why]
The i915 DRM driver in Linux 5.18 relies on this indirect include.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D43030
(cherry picked from commit d6d1e73e5f66f3b12881fffceff58ca54b506792)
[Why]
This header and str_yes_no() are now used by the i915 DRM driver in
Linux 5.18.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D43014
(cherry picked from commit 38138beb42d1892dbd8ebb29c01c4471c86d8845)
[Why]
The passed structure may not have a `.store` field. This is the case in
the amdgpu DRM driver starting with Linux 5.18.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D43023
(cherry picked from commit d752a5e82ac92603fadf82e7de75878e1f5d054a)
[Why]
The amdgpu DRM driver started to use it in Linux 5.18.
[How]
The function is a no-op as I'm not sure how to implement this with
sysctls yet.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D43022
(cherry picked from commit 509707e8b6b7326c7f4793b6e291f0a8e6939412)
[Why]
The amdgpu DRM driver started to use it in Linux 5.18.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D43021
(cherry picked from commit b723bcd05a991d446491e914f2b9f35e66227398)