Commit Graph

4739 Commits

Author SHA1 Message Date
Justin Hibbits
97583aa256 linuxkpi: Migrate to IfAPI
Summary:
Trivial changes for LinuxKPI to use IfAPI.  The 'bsdifp' looks unused,
so removed it instead of converting it to a pointer.

Bump __FreeBSD_version for change to struct net_device.

Reviewed by:	bz, hselasky
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D39491
2023-04-24 09:54:22 -04:00
Bjoern A. Zeeb
06a1103fe3 ath10k: ath11k: add specific LinuxKPI support
Add files needed by ath1?k drivers to linuxkpi/linuxkpi_wlan.
This contain (skeleton) implementations of what is needed to
compile but specifically mhi/qmi/qrtr will need more work for
ath11k.

MFC after:	2 months
2023-04-23 21:31:07 +00:00
Bjoern A. Zeeb
6c92544d7c mt76: import mediatek/mt76 driver
Import ISC-licensed driver parts of mediatek/mt76
assumed to be based on Linux wireless-testing at
a02411a5b98612c12be99349836d99f07db12a77 (tag: wt-2022-11-23).

Complement the driver and LinuxKPI with our own (dummy)
implementations of missing parts (util.h and soc/mediatek/)
as well as changes to make compile on FreeBSD with changes
covered by #ifdef (__FreeBSD__) conditions.
Further select updates were applied since the initial import
in order to keep compiling along with other LinuxKPI based
drivers.

For the moment we only target the mt7915 and mt7921 PCI parts.
More may follow in the future.

Firmware is provided by port net/wifi-firmware-mt76-kmod.

Given the lack of full license texts on non-local files this is
imported under the draft policy for handling SPDX files (D29226). [1]

Approved by:	core (emaste, 2022-04-08) [1]
MFC after:	2 months
2023-04-23 21:29:49 +00:00
Bjoern A. Zeeb
0e8953b94b LinuxKPI: pci.h: always initialize return value
In pcie_capability_read_*() always initialize the return value to
avoid warnings of uninitialized values in callers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39721
2023-04-23 13:29:30 +00:00
Dmitry Chagin
66e8f1f7d3 linux(4): Fix arm64 build after b7a6bcdd, missed chunk added
MFC after:		1 month
2023-04-23 01:41:12 +03:00
Dmitry Chagin
0ef30b5d6b linux(4): Bump osrelease to 5.15.0
Linux kernel version 5.15 named Trick or Treat is a 22nd LTS release.

Reviewed by:		trasz, emaste
Differential Revision:	https://reviews.freebsd.org/D39649
MFC after:		1 month
2023-04-22 22:18:08 +03:00
Dmitry Chagin
b7a6bcdd13 linux(4): Export the AT_MINSIGSTKSZ depending on the process osreldata
AT_MINSIGSTKSZ has appeared in the 5.13.0 Linux kernel first time.

Differential Revision:	https://reviews.freebsd.org/D39648
MFC after:		1 month
2023-04-22 22:17:52 +03:00
Dmitry Chagin
70eab81d6f linux(4): Export the AT_EXECFN depending on the process osreldata
AT_EXECFN has appeared in the 2.6.26 Linux kernel first time.

Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D39647
MFC after:		1 month
2023-04-22 22:17:36 +03:00
Dmitry Chagin
40c36c4674 linux(4): Export the AT_RANDOM depending on the process osreldata
AT_RANDOM has appeared in the 2.6.30 Linux kernel first time.

Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D39646
MFC after:		1 month
2023-04-22 22:17:17 +03:00
Dmitry Chagin
7d8c983983 linux(4): Deduplicate linux_copyout_auxargs()
Export default MINSIGSTKSZ value for the x86 until we do not preserve AVX
registers in the signal context.

Differential Revision:	https://reviews.freebsd.org/D39644
MFC after:		1 month
2023-04-22 22:16:02 +03:00
Vladimir Kondratyev
06c844e175 LinuxKPI: Fix building on 32bit archs
Reported by:	Jenkins
Fixes:	e5cf9deb61 ("LinuxKPI: Add bitmap_to_arr32() to <linux/bitmap.h>")
2023-04-22 13:25:49 +03:00
Vladimir Kondratyev
53d821d651 LinuxKPI: Define noinline_for_stack compiler attribute
It is identical to noinline and used for documentation reasons.

Required by:	drm-kmod 5.15-lts
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D39553
2023-04-22 11:29:29 +03:00
Vladimir Kondratyev
e5cf9deb61 LinuxKPI: Add bitmap_to_arr32() to <linux/bitmap.h>
bitmap_to_arr32() copies contents of bitmap to a uint32_t array of bits

Required by:	drm-kmod 5.15-lts
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D39552
2023-04-22 11:29:29 +03:00
Vladimir Kondratyev
b14c03f808 LinuxKPI: define acpi_put_table() in <acpi/acpi.h>
FreeBSD ACPICA calls it AcpiPutTable()

Required by:	drm-kmod 5.15-lts
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D39551
2023-04-22 11:29:29 +03:00
Warner Losh
7b42f338d7 freebsd32: Regen
Need to regen freebsd32 as well when sys/kern/syscalls.master is
updated.

Sponsored by:		Netflix
2023-04-21 10:25:10 -06:00
Austin Shafer
3f686532c9 linuxkpi: Fix __sg_alloc_table_from_pages loop
Commit 3e0856b63f updated
__sg_alloc_table_from_pages to use the same API as linux, but modified
the loop condition when going over the pages in a sg list. Part of the
change included moving the sg_next call out of the for loop and into the
body, which causes an off by one error when traversing the list. Since
sg_next is called before the loop body it will skip the first element
and read one past the last element.

This caused panics when running PRIME with nvidia-drm as the off-by-one
issue causes a NULL dereference.

Reviewed by:	bz, hselasky
Differential Revision:	https://reviews.freebsd.org/D39628
Fixes:	3e0856b63f ("linuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux")
2023-04-21 09:56:50 +02:00
Bjoern A. Zeeb
35f7fa4ac1 LinuxKPI: 802.11: improve assertion and tkip code
Move a KASSERT out of a function and make it a CTASSERT with
appropriate comments.

Skeleton implement two tkip functions, still left TODO, initializing
variables with dummy values to quiten compiler warnings.  It is
unclear to me if we should still ever properly implement TKIP
compat code at this point.  If so the current code gives a good
idea what needs to be done in addition to allocating references
to real state along with keyconf.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-04-20 16:07:50 +00:00
Bjoern A. Zeeb
74e908b3c6 LinuxKPI: fix READ_ONCE() -Wcast-equal warnings
Rather than using ACCESS_ONCE() in READ_ONCE() add a missing cast
to const in order to satisfy -Wcast-equal by gcc.
Sadly we cannot do the same to WRITE_ONCE() which still is very
noisy.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D39706
2023-04-20 11:51:22 +00:00
Bjoern A. Zeeb
f369f10dd8 LinuxKPI: 802.11: fix a -Wenum-compare warning
We are asserting that two values from different enums are the same.
gcc warns about these.  Cast the values to (int) to avoid the warning.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-04-19 21:49:17 +00:00
Bjoern A. Zeeb
b2dcb84868 LinuxKPI: skbuff.h: fix -Warray-bounds warnings
Harmonize sk_buff_head and sk_buff further and fix -Warray-bounds
warnings reports by gcc.  At the same time simplify some code by
re-using other functions or factoring some code out.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-04-19 21:49:00 +00:00
Gleb Smirnoff
a6b55ee6be net: replace IFF_KNOWSEPOCH with IFF_NEEDSEPOCH
Expect that drivers call into the network stack with the net epoch
entered. This has already been the fact since early 2020. The net
interrupts, that are marked with INTR_TYPE_NET, were entering epoch
since 511d1afb6b. For the taskqueues there is NET_TASK_INIT() and
all drivers that were known back in 2020 we marked with it in
6c3e93cb5a. However in e87c494015 we took conservative approach
and preferred to opt-in rather than opt-out for the epoch.

This change not only reverts e87c494015 but adds a safety belt to
avoid panicing with INVARIANTS if there is a missed driver. With
INVARIANTS we will run in_epoch() check, print a warning and enter
the net epoch.  A driver that prints can be quickly fixed with the
IFF_NEEDSEPOCH flag, but better be augmented to properly enter the
epoch itself.

Note on TCP LRO: it is a backdoor to enter the TCP stack bypassing
some layers of net stack, ignoring either old IFF_KNOWSEPOCH or the
new IFF_NEEDSEPOCH.  But the tcp_lro_flush_all() asserts the presence
of network epoch.  Indeed, all NIC drivers that support LRO already
provide the epoch, either with help of INTR_TYPE_NET or just running
NET_EPOCH_ENTER() in their code.

Reviewed by:		zlei, gallatin, erj
Differential Revision:	https://reviews.freebsd.org/D39510
2023-04-17 09:08:35 -07:00
Dmitry Chagin
71bc17803e linux(4): Implement close_range over native
Handling of the CLOSE_RANGE_UNSHARE flag is not implemented due to
difference in fd unsharing mechanism in the Linux and FreeBSD.

Reviewed by:		mjg
Differential revision:	https://reviews.freebsd.org/D39398
MFC after:		2 weeks
2023-04-04 23:24:04 +03:00
Konstantin Belousov
11cdffc603 Regen 2023-04-04 16:19:08 +03:00
Emmanuel Vadot
63b113af57 linuxkpi: Add a few more dummy includes
Needed by drm-kmod.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-04-04 14:11:32 +02:00
Emmanuel Vadot
44312c28fe linuxkpi: Add linux/agp_backend.h
It declares the structs needed by drm code for AGP.

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-04-04 11:49:48 +02:00
Emmanuel Vadot
7c7419f60c linuxkpi: Add linux/stddef.h
It simply include sys/stdef.h

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-04-04 11:39:27 +02:00
Emmanuel Vadot
0bf561351b linuxkpi: Include linux/types.h in linux/mod_devicetable.h
It's done like this in linux too.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
2023-04-04 10:48:28 +02:00
Emmanuel Vadot
3f39ff2420 linuxkpi: Include linux/math64.h in linux/time.h
It's done like this in linux too.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-04-04 10:48:27 +02:00
Dmitry Chagin
7ae0972c7b linsysfs(4): Reimplement listnics() using ifAPI
Handle if arrival/departure events and VNETs.

Differential Revision:	https://reviews.freebsd.org/D38901
MFC after:		1 month
XMFC with:		ifAPI, pseudofs
2023-04-03 11:22:16 +03:00
Bjoern A. Zeeb
cfccc7f30a LinuxKPI: 802.11: remove extra spaces
Remove two extra spaces.  No functional change.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-04-02 22:25:28 +00:00
Emmanuel Vadot
4fd9e20671 linuxkpi: hdmi: Remove wrong dependency on wlan
Copy-paste mistake.

Reported by:	Alastair Hogge <agh@riseup.net>
Fixes:	f1d7ae31d4 ("linuxkpi: Add hdmi helpers")
2023-04-02 16:56:23 +02:00
Bjoern A. Zeeb
8ac540d3b8 LinuxKPI: 802.11: adjust locking
Split up the lhw lock and the scan lock.  The latter is a mtx
while the former changes from mtx to sx as mac80211 downcalls may
sleep (and the ic lock is not usable in that case either and a larger
project to fix).
This will also enforce some lookups under lock (mostly scan) as well
as general protection for more compat code and avoid a possible
deadlock with one of the upcoming callbacks from driver into the
compat code.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
2023-03-31 19:59:50 +00:00
John Baldwin
ad83dd2b2b LinuxKPI: Appease -Wunused-but-set-variable warnings from GCC.
- Mark assert dummy variables as __unused.

- Use a dummy (void) cast of the flags argument passed to
  spin_unlock_irqrestore so it gets treated as used.

Reviewed by:	manu, hselasky
Differential Revision:	https://reviews.freebsd.org/D39349
2023-03-31 10:56:33 -07:00
Dmitry Chagin
f94b5734bc Revert "linsysfs(4): Reimplement listnics() using ifAPI"
This reverts commit 0b56641cfc.

As it poorly interacts with vnet subsystem
2023-03-31 14:54:33 +03:00
Bjoern A. Zeeb
3f0083c4e3 LinuxKPI: 802.11: use ic_printf more consistently
Rather than printing ic_name ourselves (or not at all) use ic_printf()
as a common function from net80211 where possible.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-03-31 07:14:32 +00:00
Emmanuel Vadot
51d07956cf linuxkpi: Add alderlake defines in intel-family
Needed by drm-kmod.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-03-28 10:57:13 +02:00
Emmanuel Vadot
aaf6129c9d linuxkpi: Add devm_add_action and devm_add_action_or_reset
Those adds a new devres and will exectute some function on release.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D39142
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-03-28 09:19:05 +02:00
Emmanuel Vadot
f1d7ae31d4 linuxkpi: Add hdmi helpers
This is a direct port of the Linux code as the licence allows it, so
style(9) isn't respected to allow applying directly the upstream commits.
Do not add it to linuxkpi directly but add a new linuxkpi_hdmi module
that drm modules will require later, no need to bloat linuxkpi more.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39122
2023-03-28 09:11:06 +02:00
Konstantin Belousov
6a0a634590 Regen 2023-03-28 02:39:26 +03:00
Alexander V. Chernikov
b894193501 netlink: fix linux module build w/ netlink.
Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after:	2 weeks
2023-03-27 18:21:26 +00:00
Vico Chen
1f0c8bfd65 linsysfs(4): Keep Linux compatible sysfs the same as Ubuntu
By checking Ubuntu, there is no `/sys/subsystem' in sysfs. To compatible
with Ubuntu, delete the 'subsystem' creation in Linux compatible module.

On the other hand, the sysfs `/sys/subsystem' cause failure for some
Linux udev cases. In Linux udev source code, there is a function named
`scan_devices_all', and it will scan `/sys/subsystem' if it is existed,
but now there are nothing in /sys/subsystem `, and it returns empty
to cause some use cases failed.

Reviewed by:		dchagin
Differential Revision:	https://reviews.freebsd.org/D38885
MFC after:		1 month
XMFC with:		ifAPI
2023-03-25 13:41:04 +03:00
Dmitry Chagin
0b56641cfc linsysfs(4): Reimplement listnics() using ifAPI
Handle if arrival/departure events.

Reviewed by:		melifaro (early version)
Differential Revision:	https://reviews.freebsd.org/D38901
MFC after:		1 month
XMFC with:		ifAPI
2023-03-25 13:40:41 +03:00
Bjoern A. Zeeb
59559d1354 LinuxKPI: remove now implemented dummy headers.
Both iommu.h and kconfig.h now exist in the common code.
There is no need for the duplicate (empty) headers anymore.
2023-03-23 01:15:53 +00:00
Jean-Sébastien Pédron
83df72e5fb
linuxkpi: Define pat_enabled()
This new <asm/memtype.h> header is included from <linux/pci.h> because
that's how it is included in Linux too. DRM drivers depend on this.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39052
2023-03-21 23:36:40 +01:00
Jean-Sébastien Pédron
5fbfe9517b
linuxkpi: Define seq_has_overflowed() and single_open_size()
This required non-trivial changes to `linux_seq_file.c` to manage a new
`(struct seq_file)->size` field. This field is read directly by DRM
drivers, so we can't alias it to a call to sbuf_len(9).

`single_open_size()` also depended on the ability to allocate the sbuf
with a specified size instead of relying on `sbuf_new_auto()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39056
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
1b4e08b483
linuxkpi: Support non-NULL zero-size pointers
DRM drivers set some pointers to `ZERO_SIZE_PTR` directly (without
allocating anything), to treat pointers which were "initialized" (set to
`ZERO_SIZE_PTR`) with no memory allocation like really allocated
pointers. NULL isn't used because it represents a third state.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D39055
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
eef905a859
linuxkpi: Add <linux/iommu.h>
It defines a small part of the IOMMU API of Linux. We don't implement
that yet.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39054
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
af19988f6c
linuxkpi: Define pcie_aspm_enabled()
This is not the same as querying the PCIE ASPM capability. The function
should return if the feature is actually enabled or not. It always
return false on FreeBSD.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39053
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
19a355436e
linuxkpi: Add default_groups field to struct kobj_type
We don't use it, but it is set by the DRM drivers.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39051
2023-03-20 21:47:35 +01:00
Jean-Sébastien Pédron
e91f5814b8
linuxkpi: Define device_iommu_mapped()
For now, it always return false.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39050
2023-03-20 21:47:35 +01:00