Add bcd2bin() in bcd.h.
Libkern does provide a bcd2bin() which cannot be used cirectly leaving
us with a conflict (see comment in file).
Rather than having code to re-define bcd2bin() for the LinuxKPI
make sure libkern.h is always included before the LinuxKPI version.
Then only re-define our local LinuxKPI implementation. [1]
From the argument truncating wrapper call the libkern version.
If we change our libkern implementation in the future we can save
us the remainder of the hassle. [2].
Suggested by: Johannes Berg (johannes sipsolutions.net) [1]
Suggested by: ian [2]
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 548ada00e5)
(cherry picked from commit ae2268efd5)
Analogous to the other sized version of kstrto[u]<type>() and
kstrtobool_from_user() add the "u8" versions needed by a driver.
(cherry picked from commit b382b78503)
Add a dummy simple_open() to fs.h as we have for other
(unsupported) functions.
This is needed by a wireless driver.
(cherry picked from commit 41dee251ee)
Add a dummy MODULE_SUPPORTED_DEVICE define as we do for other
MODULE_* macros. This is needed by a wireless driver.
(cherry picked from commit c5eec7b57c)
Make the struct pci_dev argument to the pci_{read,write}_config*()
functions "const" to match the Linux definition as some drivers
try to pass in a const argument which we currently fail to honor.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit ed5600f532)
Rename the struct pci_driver {} field to the list_head from links
to node as a driver is actually initialsing this to {} which seems
questionable but it will at least make us match the Linux structure
field name.
Reviewed by: manu, hselasky
(cherry picked from commit cf89934842)
Add netdev_features.h as a spearate file from the future netdevice.h
implementation to avoid include problems with a future skbuff.h.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 490f9d8f0e)
Coherent is lower 32bit only by default in Linux and our only default
dma mask is 64bit currently which violates expectations unless
dma_set_coherent_mask() was called explicitly with a different mask.
Implement coherent by creating a second tag, and storing the tags in the
objects and use the tag from the object wherever possible.
This currently does not update the scatterlist or pool (both could be
converted but S/G cannot be MFCed as easily).
There is a 2nd change embedded in the updated logic of
linux_dma_alloc_coherent() to always zero the allocation as
otherwise some drivers get cranky on uninialised garbage.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c39eefe715)
(cherry picked from commit 1269873159)
In some places we are using "mask" and others "dma_mask" for the
same thing. Harmonize the various places to "dma_mask" as used in
linux_pci.c. For the declaration remove the argument names to
avoid the entire problem.
This is in preparation for an upcoming change.
No functional changes intended.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 72c89ce97b)
As reported by multiple people testing iwlwifi, device_release_driver()
can lead to a panic on secondary errors (usually during attach).
Disable device_release_driver() for the short-term to prevent the panic
but leave it in place so it can be re-worked and fixed properly for
the long-term more easily.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 93b14194ac)
Add fsleep() function now required by rtw88. This seems to be
making a decision depending on time to sleep on how to sleep.
Given our compat framework already is lenient on how long to sleep,
this is a cut down version.
(cherry picked from commit cc2723370b)
Add an implementation of read_poll_timeout() and the atomic variant
which I did at some point last year for rtw88 and now updated based
on feedback.
(cherry picked from commit fed248a6ac)
Add the two new functions needed by rtw88 to register the driver and
handle the module bits as well as a version of pci_alloc_irq_vectors()
for what is needed.
(cherry picked from commit 366d68f283)
Fix a bug that slipped in in 90707c4e44
using the correct field in le32p_replace_bits().
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 22e20d852f)
Add sys/types.h to dmi.h and do not rely on other files to include
all needed headers in Linux land. I ran into compile problems with
rtw88 otherwise.
(cherry picked from commit ac134e762e)
Add the nexthdr definitions for IPv6 which are used by wireless
drivers and were previously placed in an 80211 header file by
accident.
Obtained from: bz_iwlwifi
Sponsored by: The FreeBSD Foundation
(cherry picked from commit b9d984e2c5)
The purpose of this change is to reduce the amount of dmesg(8) noise when
VT switching after a panic.
Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D30174
Sponsored by: NVIDIA Networking
(cherry picked from commit 2390a1441e)
Remove page zeroing code from consumers and stop specifying
VM_ALLOC_NOOBJ. In a few places, also convert an allocation loop to
simply use VM_ALLOC_WAITOK.
Similarly, convert vm_page_alloc_domain() callers.
Note that callers are now responsible for assigning the pindex.
Reviewed by: alc, hselasky, kib
Sponsored by: The FreeBSD Foundation
(cherry picked from commit a4667e09e6)
Linux KPIs like pci_resource_start/len assume that BARs have been
allocated, but FreeBSD lazily allocates BARs if it cannot allocate the
firmware-allocated BARs. Thus using the Linux KPIs must force allocation
of the BARs rather than returning 0 for the start and length, which can
crash drm-kmod drivers that assume the BARs are valid. This is needed
for the AMDGPU driver to be able to attach on SiFive's HiFive Unmatched.
Reviewed by: hselasky, jhb, mav
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32447
(cherry picked from commit 82098c8bb5)
Now that riscv implements pmap_mapdev_attr we can enable the non-stub
implementation for riscv, which is needed for drm-kmod to not fail at
run time for drivers that need to map I/O regions.
Reviewed by: hselasky, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32446
(cherry picked from commit 60d962e041)
For now, disable backlight if brightness level is set to 0.
In the future we may implement separate knob in backlight(8).
Required by drm-kmod v5.6
Reviewed by: hselasky, manu
Differential revision: https://reviews.freebsd.org/D32165
(cherry picked from commit b52e363840)
from other vm_objects. This workarounds "Page already inserted" panic
in vm_page_insert routine triggered on attempt to mmap file created
with shmem_file_setup call. After introduction of "GTT mmap
interface v4" a.k.a. MMAP_OFFSET, vm_objects allocated by these calls
may try to own intersected sets of pages that leads to the assertion.
Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D32090
(cherry picked from commit 62ff0566c9)
Although drm-kmod contains better implementation which is able to
allocate real entries on pseudofs, this feature has never been used.
Starting from drm-kmod v5.6 old implementation began to leak entries
on each drm device close(). Now just drop pseudofs support instead of
fixing it in drm-kmod and provide stub in base.
Reviewed by: hselasky, manu
Differential revision: https://reviews.freebsd.org/D32069
(cherry picked from commit bd6d55adb4)
from GEM and TTM page fault handlers and move it in to base system. This
code is tightly integrated with LKPI mmap support to belong to drm-kmod.
As this routine requires associated vm_object to be locked, it got
additional _locked suffix.
Reviewed by: hselasky, markj
Differential revision: https://reviews.freebsd.org/D32068
(cherry picked from commit f6823dac8f)
This fixes following warnings when shrinkers are invoked first time:
uma_zalloc_debug: zone "lkpicurr" with the following non-sleepable
locks held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker)
uma_zalloc_debug: zone "lkpimm" with the following non-sleepable locks
held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker)
Reviewed by: hselasky, manu
Differential revision: https://reviews.freebsd.org/D32066
(cherry picked from commit 2fe9ea5d3a)
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 66ea390652)
get_file_rcu() grabs a file if the file->f_count is not zero.
Required by drm-kmod 5.6
Reviewed by: hselasky, manu (previous version)
Differential revision: https://reviews.freebsd.org/D31672
(cherry picked from commit a81b36c6d3)
This is compatible with Linux, and some driver error paths depend on it.
Reviewed by: bz, emaste
Sponsored by: The FreeBSD Foundation
(cherry picked from commit a76de17715)
The code would incorrectly use curthread instead of the target proc to
resolve vnodes.
Fixes: 8d03b99b9d ("fd: move vnodes out of filedesc into a dedicated structure")
PR: 258729
Noted by: Damjan Jovanovic <damjan.jov@gmail.com>
(cherry picked from commit 69ab528386)
One of the three uses is already guarded; this guards the remaining ones
to support architectures like riscv that do not provide write-combining,
and is needed to build drm-kmod on riscv.
Reviewed by: hselasky, manu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31999
(cherry picked from commit 8167c92f65)
freebsd32_sendmsg() and freebsd32_recvmsg() both copyin the message
header twice, once directly and once in freebsd32_copyinmsghdr(). The
iovec length from the former is used when copying in msg_iov, but the
rest of the kernel uses the iovec length from the latter. When
kern_sendit() and kern_recvit() iterate over the iovec to compute the
residual for I/O, they can therefore end up walking past the end of the
copied in iovec, either resulting in a system call error, userspace
memory corruption from uiomove() with invalid iovecs, or a kernel page
fault if the copied-in iovec is followed by an unmapped KVA region.
Reported by: syzbot+7cc64cd0c49605acd421@syzkaller.appspotmail.com
Reviewed by: kib, emaste
Sponsored by: The FreeBSD Foundation
(cherry picked from commit fea1a98ead)
Move all the new elemenets to the end of the structure for 13. We
allocate this inside the linuxkpi code, so the size isn't enccoded in
client modules. However, the offsets to the different fields are
encoded. Tihs modifies 04456f7118, 40a215e38a, and 3a606aadf2
and will likely create merge conflicts there (and that's a good thing
since the elements need to be moved to the end of the structure when
merging).
Tweak irq_ent to be binary compatible. Since this is inlined into the
clients, all clients have to agree on the irq_ent offsets.
Restore visibility to linux_kmem_cache_free_rcu
linux_kmem_cache_free_rcu was made static in 10235ad056, however
client drivers depended on calling it directly. Make it visible again to
restore the 13.0-Release KBI for linuxkpi.
Bump FreeBSD_version to 1300515 for restoration of 13.0 KBI. Since this
commmit changes the linuxkpi KBI (this time back to 13.0 release to
restore the status quo of), you'll need to recompile everything that
uses it (you needed to earlier as well, but those were silent
recompilation events). The plus side is that our packages (built using
13.0) for drm-kmod 5.4 work again on -stable systems.
Reviewed by: bz, wulf
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31363