Commit graph

766 commits

Author SHA1 Message Date
Bjoern A. Zeeb
d1b8fbbe3c LinuxKPI: firmware: add request_partial_firmware_into_buf()
A (so far out-of-tree) driver update needs
request_partial_firmware_into_buf().  Given we load the full .ko file
using firmware(9) just do that and copy the requeste data into the
buffer (rather than poissibly only reading portions of the firmware
file).

(cherry picked from commit fb3c549738)
2022-09-21 11:46:47 +00:00
Bjoern A. Zeeb
4e1153c4c3 net80211 / drivers: rename to IEEE80211_FC0_SUBTYPE_QOS_DATA
Going through the Frame (Sub)types the "QOS Data" being called "QOS"
scheme leads to a naming conflict for QOS_CFPOLL and QOS_CFACKPOLL
(if added).   Rename QOS* to QOS_DATA* to avoid the conflict and
to also better match the standards name.

No functional changes intended.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36409

(cherry picked from commit c9b7e9df18)
2022-09-21 11:46:46 +00:00
Bjoern A. Zeeb
855405e175 LinuxKPI: extend kfifo to be usable
Implement some basic kfifo pieces as needed by drivers.

Reviewed by:	wulf, hselasky
Differential Revision: https://reviews.freebsd.org/D35829

(cherry picked from commit 4a7e8c7bd4)
2022-09-21 11:46:45 +00:00
Bjoern A. Zeeb
14a66de621 LinuxKPI: 802.11 header updates
LinuxKPI: 802.11: add missing linuxkpi_cfg80211_bss_flush()

While working on new and updates to drivers more structs, fields,
functions, .. were found, had to be shuffled around, ..
Some of these are (so far still dummy) functions or not properly
typed fields.  The IEEE80211_HE_ constants are all still dummy.
This was msotly as a start to make new (out-of-tree) things compile.

Sponsored by:	The FreeBSD Foundation (minor VHT/chan width bits)

Add the missing implementation of linuxkpi_cfg80211_bss_flush().
without this we get unresolved symbols and drivers won't load.

Reported by:	eduardo, Berislav Purgar (bpurgar gmail.com)

(cherry picked from commit b0f7376822)
(cherry picked from commit d8dd6b329e)
2022-09-21 11:46:07 +00:00
Bjoern A. Zeeb
6145d25fa0 LinuxKPI: skbuff: sort list header and add new (dummy) functions
While working on new and updates to drivers more skbuff changes
came up.  Sort out the list/prev/next header problem and add more
(so far dummy) functions needed.

(cherry picked from commit 89c32dafa5)
2022-09-21 11:40:04 +00:00
Doug Moore
412f27c18c rb_tree: speed-up double rotation
RB_ROTATE_LEFT (and it symmetric twin) modify the rb-tree, adjusting
pointers so that what started as a proper tree ends up a proper
tree. When two consecutive rotations move the same node up the tree,
some of the pointers changed in the first rotation are immediately
changed again in the second - namely, the pointer from the rising node
to its new parent, and the pointer from that parent back to the rising
node. This change removes from RB_ROTATE macros the responsibility for
managing those two pointers, and leaves it to the code that calls for
rotations to fix up those pointers afterward. That drops a comparison
and a pair of assignments from every INSERT_COLOR or REMOVE_COLOR call
that ends in a double rotation.

A side-effect of this change is that the SWAP_CHILD macro must take as
a parameter a pointer to the node that is changing children, where it
is now computed from the old child. Since this macro is called in a
couple of places besides the RB_ROTATE macros, those calls are also
affected.

Reviewed by:	alc
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36266

(cherry picked from commit 02d0c43c9e)
2022-09-09 12:11:44 -05:00
Emmanuel Vadot
b3814a4806 linuxkpi: unbreak linux_i2cbb
This is a joint work with manu.

- fixed conditions in do_i2c_transfer and i2c_transfer as linux_i2cbb
  does not set adapter->algo->master_xfer but does set
  adapter->algo_data;
- fixed parent bus specification for linux_i2cbb driver module;
- actually implemented iicbb_transfer method;
- added iicbb_pre_xfer and iicbb_post_xfer methods;
- removed unnecessary and harmful delays (and other extra logic) from
  iicbb methods as iicbb driver already has them;
- added setting of iicbb speed based on algo_data->udelay, so that iicbb
  uses correct delays;

PR:		265920
Fixes:		1961a14a47 linuxkpi: Add i2c support
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG (manu's work)

(cherry picked from commit 6364180582)
2022-09-07 17:09:06 +02:00
Emmanuel Vadot
de73f3d52d linuxkpi: Add I2C_NAME_SIZE and I2C_MODULE_PREFIX defines
Both are needed by drm-kmod

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	//reviews.freebsd.org/D36212

(cherry picked from commit 7bf65b00c6)
2022-09-07 17:09:06 +02:00
Emmanuel Vadot
01bccdf204 linuxkpi: Add linux/vgaarb.h
Needed by drm-kmod.

Reviewed by:	bz
Obtained from:	Linux
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36104

(cherry picked from commit 4b4ab8c310)
2022-09-07 17:09:06 +02:00
Emmanuel Vadot
9ecde17362 linuxkpi: Add __copy_to_user_inatomic and __copy_from_user_inatomic
Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36113

(cherry picked from commit 76d93395c5)
2022-09-07 17:09:06 +02:00
Emmanuel Vadot
4d1302618e linuxkpi: Add add_taint stub
Needed by drm-kmod.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36112

(cherry picked from commit bf27839aa9)
2022-09-07 17:09:06 +02:00
Emmanuel Vadot
2dcfd01379 linuxkpi: Add few more include in linux/kernel.h
Those are needed and also included in linux (via polution).

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36111

(cherry picked from commit 4b2cb13e91)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
8b67991635 linuxkpi: swap.h: Fix include
Add needed includes so we can use it.

Reviewed by:	bz
Fixes:	c3f4f28c63 ("linuxkpi: Add some basic swap functions")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36109

(cherry picked from commit 6d3d565316)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
d43c533ecb linuxkpi: Add stub kmem_cache_shrink
Needed by drm-kmod.

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36108

(cherry picked from commit 35b7625ed0)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
5a82e33df4 linuxkpi: Add dma_{un,}map_sgtable
Variant of dma_{un,}map_sg_attrs for struct sg_table.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36106

(cherry picked from commit 9202c95f47)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
68987d8ff6 linuxkpi: Add linux/stackdepot.h
With a typedef needed by drm-kmod.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36105

(cherry picked from commit b1c82bd402)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
45962e192b linuxkpi: Add sched/mm.h
With stubs needed by drm-kmod.

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36100

(cherry picked from commit 8828ebd6fc)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
37e0760950 linuxkpi: Add refcount_dec_and_test
In Linux this takes a refcount_t argument but in linuxkpi struct kref
uses an atomic_t for the refcount and code in drm directly uses this
function with a kref so use an atomic_t here.

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36099

(cherry picked from commit 1a6874e3a4)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
ad5366ba41 linuxkpi: Add for_each_sgtable_{sg,page}
Needed by drm-kmod.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36098

(cherry picked from commit 4370e9f1cf)
2022-09-07 17:09:05 +02:00
Emmanuel Vadot
e7a86da0db linuxkpi: io.h: Only exclude armv6 and armv7 for asm/set_memory.h
Other arches like powerpc* needs it.

Fixes:  d387a1b4b1 ("linuxkpi: io.h: Do not include asm/set_memory.h for armv6 and armv7")
Fixes:  789dbdbb48 ("linuxkpi: Add arch_io_{reserve,free}_memtype_wc")
Sponsored by:	Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 521abc32e2)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
adbc2b9385 linuxkpi: io.h: Do not include asm/set_memory.h for armv6 and armv7
They do not have the same pmap api and this cannot work for those arch.

Fixes:	789dbdbb48 ("linuxkpi: Add arch_io_{reserve,free}_memtype_wc")
Sponsored by:	Beckhoff Automation GmbH & Co. KG

(cherry picked from commit d387a1b4b1)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
b296b4574e linuxkpi: pm: Add more defines and includes
Needed by drm-kmod.

Reviewed By:	emaste, hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36024

(cherry picked from commit 2ff0f05149)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
5bb01b65a7 linuxkpi: Include highmem.h in pagemap.h
Linux does the same.

Reviewed by:	bz, emaste, hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36023

(cherry picked from commit b829f450a7)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
567ee6830d linuxkpi: Add arch_io_{reserve,free}_memtype_wc
Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36022

(cherry picked from commit 789dbdbb48)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
8d5dbbc942 linuxkpi: Add dev_info_once
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36021

(cherry picked from commit a7727e1a6d)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
c84bd1f287 linuxkpi: Add trylock_page and unlock_page
Simple wrapper around vm_page_trylock and vm_page_unlock.

Reviewed by:	hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36019

(cherry picked from commit d1c3cfd79d)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
d3d30e4d2f linuxkpi: Add more notifier defines
Needded by drm-kmod.

Reviewed by:	bz, emaste, hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36018

(cherry picked from commit 7d2702a198)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
368174cdc5 linuxkpi: errno: Add EHWPOISON
Needed by drm-kmod.

Reviewed by:	bz, hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36017

(cherry picked from commit 2d4b17685f)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
dc42582096 linuxkpi: Add compat_ptr and ptr_to_compat
Needed by drm-kmod.

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36016

(cherry picked from commit 37cda2837c)
2022-09-07 17:09:04 +02:00
Emmanuel Vadot
af4fb0c0fe linuxkpi: Add some memset functions
Needed by drm-kmod

Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35943

(cherry picked from commit fa1f02baaf)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
e82a5dd0e6 linuxkpi: Add pagevec implementation
Needed by drm-kmod.

Reviewed by:	hselasky
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35941

(cherry picked from commit a0c171328f)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
988ccb61b5 linuxkpi: Add linux/nospec.h
Needed by drm-kmod.

Reviewed by:	hselasky
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35940

(cherry picked from commit aec6a64c68)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
8f607f895c linuxkpi: Add mapping_clear_unevictable stub
Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35939

(cherry picked from commit 4aa82e4358)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
d2210bd41a linuxkpi: pci: Add more functions needed by drm
Mostly stubs to satisfy building

Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35938

(cherry picked from commit 6890e327a8)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
b00f8e7ff0 linuxkpi: math.h: Add mul_u64_u32_div and mul_u64_u32_shr
Needed by drm-kmod.

Reviewed by:	hselasky
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35937

(cherry picked from commit 885ab0dba2)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
c4f5684feb linuxkpi: Add pwm.h
Provide dummy functions needed for drm-kmod.

Reviewed by:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35572

(cherry picked from commit 2b743f65f1)
2022-09-07 17:09:03 +02:00
Emmanuel Vadot
860d777158 linuxkpi: Add typecheck.h
typecheck macro check if the type of a variable matches a type.

MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35569

(cherry picked from commit 631bf94fe9)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
01af6b95d1 linuxkpi: Add pm_runtime.h
Provide dummy functions needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35568

(cherry picked from commit 456a92d5d3)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
1d9565f913 linuxkpi: Add mmu_notifier.h
Provide dummy structure needed for drm-kmod.

MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35567

(cherry picked from commit cfe72b9f09)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
5d4470e646 linuxkpi: Add mmu_context.h
Provide dummy functions needed for drm-kmod.

Reviewed by:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35566

(cherry picked from commit a95f28800a)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
9b2c359569 linuxkpi: Add media-bus-format.h
Provide macros needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35565

(cherry picked from commit 7e4f9ebeaa)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
1cfea86b30 linuxkpi: Add kmemleak.h
Provide macros needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35564

(cherry picked from commit 8730ba418e)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
afca4d971b linuxkpi: Add kfifo.h
Provide macros needed for drm-kmod.

Reviewed by:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35563

(cherry picked from commit 088b746cbd)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
cd1a0f5f10 linuxkpi: Add console.h
Provide dummy functions needed for drm-kmod.

Reviewed By:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35562

(cherry picked from commit 57c9ec539c)
2022-09-07 17:09:02 +02:00
Emmanuel Vadot
6d8dc6c971 linuxkpi: Add circ_buf.h
Provide macros needed for drm-kmod.

Reviewed by:	bz
MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35561

(cherry picked from commit 7674baeb37)
2022-09-07 17:09:02 +02:00
Bjoern A. Zeeb
07bec0d40e net80211 / LinuxKPI: 802.11: add Control Trigger Subframe information
Add definitions related to 802.11ax Control Trigger frame format
needed for rtw89.

(cherry picked from commit 4c3684ef5c)
2022-07-01 13:49:19 +00:00
Bjoern A. Zeeb
a478f4afd8 LinuxKPI: move pm_message_t from kernel.h to pm.h
Move pm_message_t from kernel.h to pm.h and remove a private define
in usb.h as well as adjust the implementation in linux_usb.c.
This cleans up what I believe to be a historic shortcut and is
needed for future wireless driver updates.

Leave a note in UPDATING that drm-kmod users need to update to the
latest version before re-compiling a new kernel to avoid errors
(see PR).

Sponsored by:	The FreeBSD Foundation
PR:		264449 (drm-kmod port update, thanks wulf)
Obtained from:	bz_git_iwlwifi (Dec 2020) (partly)
Reviewed by:	hselasky, imp
Differential Revision: https://reviews.freebsd.org/D35276

(cherry picked from commit 0e981d79b1)
2022-07-01 13:48:24 +00:00
Emmanuel Vadot
7f14bc4402 linuxkpi: Add i2c support
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 1961a14a47)
2022-06-21 17:13:57 +02:00
Warner Losh
db761c6a64 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831

(cherry picked from commit c6df6f5322)
2022-06-21 17:13:20 +02:00
Bjoern A. Zeeb
26526bf171 LinuxKPI: 802.11 updates
Add more values to the ieee80211_min_mpdu_start_spacing enum with
two missing given we do not know how they are called.  Also update
the reference while here.

Add struct ieee80211_hdr_3addr and correct the comment on the
ieee80211_hdr to match the one in net80211 to avoid future confusion.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d296b65d89)
2022-06-03 16:56:56 +00:00