]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
15 months agonetlink: fix interface dump.
Alexander V. Chernikov [Thu, 16 Feb 2023 13:17:58 +0000 (13:17 +0000)]
netlink: fix interface dump.

The current code missed interface addition when reallocating
 temporary buffer.
Tweak the code to perform the reallocation first and add
 interface afterwards unconditionally.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit 86fd0bdba540132ae298457e160b651f61d1db6b)

15 months agofibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.
Alexander V. Chernikov [Sat, 11 Feb 2023 15:43:23 +0000 (15:43 +0000)]
fibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.

Reported by: olivier
Tested by: olivier
Reviewed by: kp, glebius
Differential Revision: https://reviews.freebsd.org/D38505
MFC after: 1 week

(cherry picked from commit 69e7d9b7e6b369b760e1f189af2e25587b56a102)

15 months agonetlink: return optional metadata with the operation result.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:53:44 +0000 (14:53 +0000)]
netlink: return optional metadata with the operation result.

Some operations like interface creation may need to return metadata
 - in this case, interface name - back to the caller if the operation
 is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
 interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
 TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after: 1 week

(cherry picked from commit 25c2dd2f2c6c6144d59d463c95f0471301d6efaa)

15 months agonetlink: call genetlink notification handler upon successful family
Alexander V. Chernikov [Fri, 17 Feb 2023 17:58:53 +0000 (17:58 +0000)]
netlink: call genetlink notification handler upon successful family
search.

MFC after: 3 days

(cherry picked from commit 7cbe771f013f6cf3316910648f6d46641cad7f44)

15 months agocleanvar: Be more careful when cleaning up /var.
Xin LI [Mon, 13 Feb 2023 04:56:17 +0000 (20:56 -0800)]
cleanvar: Be more careful when cleaning up /var.

The cleanvar script uses find -delete to remove stale files under /var,
which could lead to unwanted removal of files in some unusual scenarios.
For example, when a mounted fdescfs(5) is present under /var/run/samba/fd,
find(1) could descend into a directory that is out of /var/run and remove
files that should not be removed.

To mitigate this, modify the script to use find -x, which restricts the
find scope to one file system only instead of descending into mounted
file systems.

PR: 269213

(cherry picked from commit 39e8c2a29a860bdb69ffcfbc06de4d4ad103b458)

15 months agofusefs: fix some resource leaks
Alan Somers [Sat, 11 Feb 2023 23:43:30 +0000 (16:43 -0700)]
fusefs: fix some resource leaks

fusefs would leak tickets in three cases:
* After FUSE_CREATE, if the server returned a bad inode number.
* After a FUSE_FALLOCATE operation during VOP_ALLOCATE
* After a FUSE_FALLOCATE operation during VOP_DEALLOCATE

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38526

(cherry picked from commit 1bdf879b97b686a8f36fdba050b68f9e7493f363)

MFC Note: changes to VOP_DEALLOCATE are not MFCed, because that VOP does
not exist in stable/13.

15 months agocpuset: Add compat shim to the sched_affinity functions
Dmitry Chagin [Wed, 15 Feb 2023 09:23:15 +0000 (12:23 +0300)]
cpuset: Add compat shim to the sched_affinity functions

To allow to run a newer world on a pre-1400079 kernel a compat shims to
the sched_affinity functions has beed added.

Reported by: antoine
Tested by: antoine
Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D38555
MFC after: 3 days

(cherry picked from commit cbc32e4c5e8427e0f1032d9d3aa5863dd1538c11)

15 months agotmpfs: remove IFF macro
Konstantin Belousov [Mon, 13 Feb 2023 23:47:44 +0000 (01:47 +0200)]
tmpfs: remove IFF macro

(cherry picked from commit b918ee2ce4850253ddd884e39dabecd6e96bf474)

15 months agotmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts
Konstantin Belousov [Mon, 13 Feb 2023 23:23:24 +0000 (01:23 +0200)]
tmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts

(cherry picked from commit 9ff2fbdf2ded59e276fdbf7ef7d18c726386b6fb)

15 months agosys/param.h: Add _WANT_P_OSREL
Konstantin Belousov [Tue, 14 Feb 2023 08:52:14 +0000 (10:52 +0200)]
sys/param.h: Add _WANT_P_OSREL

(cherry picked from commit 5942b4b6fde3f4ce6d0295fbcf135f552f92c607)

15 months agomsdosfs deextend: validate pages of the partial buffer
Konstantin Belousov [Sat, 11 Feb 2023 18:09:30 +0000 (20:09 +0200)]
msdosfs deextend: validate pages of the partial buffer

PR: 269341

(cherry picked from commit 0152d453a08fa2bad694dc04a8184fce2b7faa10)

15 months agomsdosfs deextend(): memoize DETOV(dep)
Konstantin Belousov [Sat, 11 Feb 2023 18:05:14 +0000 (20:05 +0200)]
msdosfs deextend(): memoize DETOV(dep)

(cherry picked from commit 67dc1e7b0457ec014a1291c5874decdefe7bffdd)

15 months agomsdosfs: correct handling of vnode pager size on file extension error
Konstantin Belousov [Fri, 10 Feb 2023 04:58:43 +0000 (06:58 +0200)]
msdosfs: correct handling of vnode pager size on file extension error

(cherry picked from commit e59180ea09a1d1d1463f2a269e94efa0f0b677c5)

15 months agoallocbuf(): convert direct panic() calls to KASSERT()s
Konstantin Belousov [Sat, 11 Feb 2023 18:03:22 +0000 (20:03 +0200)]
allocbuf(): convert direct panic() calls to KASSERT()s

(cherry picked from commit 020e8a4d0609d56cb49a9f35258ff07815d5e478)

15 months agoefivar: Really look for labels for the provider with right efimedia
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: Really look for labels for the provider with right efimedia

The prior code mistakently thought that the g_consumer that hung off the
provider we found were the right thing to use to find all the glabel
aliases for this node. However, the only way to find that is to iterate
through all the geoms that belong to the glabel geom class, looking for
those geoms with the same name as the provider with the right efimedia.
Do this in a way that caches glabel class, and allows for it to be
absent. Tighten the filter for mounted filesystems to only look
for the ones that are mounted on /dev/.. since the rest of the code
assumes that.

MFC After: 3 days
Sponsored by: Netflix
Reviewed by: corvink, asomers
Differential Revision: https://reviews.freebsd.org/D38619

(cherry picked from commit 2b460910326c4f39068fe2158a0726dc3d362f68)

15 months agoefibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file

"efibootmgr --efidev unix-path" will return the UEFI device-path to the
file or device specified by unix-path. It's useful for debugging, but
may also be useful for scripting.

Sponsored by: Netflix
Reviewed by: corvink, manu
Differential Revision: https://reviews.freebsd.org/D38617

(cherry picked from commit 9a7915299484a767fbffc7234b8dc45c29954cca)

15 months agoefivar: support device paths as well as mounted paths in path_to_dp
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: support device paths as well as mounted paths in path_to_dp

In path_to_dp, allow passing in either the actual device path "eg
/dev/foo/bar" or the path where the device is mounted (say
/mnt/baz/bing). In the former case we'll assume the path within the
device is nothing (the relpath). In the latter, we'll take from the
mount point on down as the relpath.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38616

(cherry picked from commit 57d5ca4eeba6192e91044aad86fca4429966cfac)

15 months agoefivar: Allow NULL paths in build_dp
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: Allow NULL paths in build_dp

Allow there to be NULL paths in buildp. This lets us return the device
path to the partition, as well as to files on the partition.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38615

(cherry picked from commit 49fd6affdbfe6af53f119ebb27ff5e5e292e1f67)

15 months agoefivar: Try harder to find label's efimedia
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: Try harder to find label's efimedia

If there's no efimedia attribute on the provider, and the provider's a
glabel, then find the 'parent' geom. In this case, the provider's name
is label-type/name, but the geom's label will that of the underlying
device (eg ada0p1). If it is, recurisvely call find_geom_efimedia with
the geom's name, which shuold have the efimedia attribute.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38614

(cherry picked from commit ccf2121d59ac51e1a0287d75262d48018d09cad6)

15 months agonetlink: validate rtable value in RTM_<NEW|DEL|GET>ROUTE.
Alexander V. Chernikov [Fri, 17 Feb 2023 17:31:40 +0000 (17:31 +0000)]
netlink: validate rtable value in RTM_<NEW|DEL|GET>ROUTE.

Reported by: Stefan Grundmann <sg2342@googlemail.com>
MFC after: 1 day

(cherry picked from commit f2f7911c5513096e46422ad7756bc90c13c6e6d8)

15 months agorouting: always pass rtentry to add_route_flags().
Alexander V. Chernikov [Fri, 17 Feb 2023 17:20:38 +0000 (17:20 +0000)]
routing: always pass rtentry to add_route_flags().

add_route_flags() uses `rt` prefix data to lookup the the current
 rtentry from the routing table. Update rib_add_route_px() to
 always pass rtentry regardless of the op_flags.

Reported by: Stefan Grundmann <sg2342@googlemail.com>
MFC after: 1 day

(cherry picked from commit a0aa160b6d261f67b29a25c7cc5e04668fb6faf7)

15 months agonetlink: use ifmedia to provide vlan interface operstate.
Alexander V. Chernikov [Wed, 15 Feb 2023 20:22:47 +0000 (20:22 +0000)]
netlink: use ifmedia to provide vlan interface operstate.

Netlink customers rely on admin and operational state when
 working with interfaces. The current implementation retuns
 "unknown" operstate for all interface types except IFT_ETHER
 and IFT_LOOP.

This change updates the code to fetch vlan operstate in the same way
 as for the ether interfaces. For the rest of the interface types,
 operstate is now mapped to the admin state.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit 5dd48f718433959c283a8a4d6e46512426f1e200)

15 months agonetlink: fix if_allocdescr() malloc options argument.
Alexander V. Chernikov [Fri, 17 Feb 2023 17:35:28 +0000 (17:35 +0000)]
netlink: fix if_allocdescr() malloc options argument.

The current value was based on the initial revision of D37566 and
 was not updated afterwards.

MFC after: 1 day

(cherry picked from commit 6694cb1f5784d6ceacd684d29b3e3012e1e4e4d5)

15 months agonetlink: add forgotten pru_rcvd handler.
Alexander V. Chernikov [Sat, 18 Feb 2023 11:48:40 +0000 (11:48 +0000)]
netlink: add forgotten pru_rcvd handler.

There were changes in -HEAD domain/protosw setup logic and
 .pru_rcvd netlink handler was missed when performing the merge.
Lack of this handler resulted in userland being waiting forever
 when performing large dumps of data.

This change restores the handler as direct commit to stable/13.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>

15 months agonetlink: Zero-initialize writer structures allocated on the stack
Mark Johnston [Thu, 26 Jan 2023 15:46:19 +0000 (10:46 -0500)]
netlink: Zero-initialize writer structures allocated on the stack

The prevailing pattern seems to be to simply initialize all fields to
zero.  Without this, it's possible to trigger a branch on uninitialized
memory, specifically, when testing nw->ignore_limit in
nlmsg_refill_buffer().

Initialize the writer structure in a couple of functions where this is
necessary.

Reported by: KMSAN
Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38213

(cherry picked from commit 7a78ae88659e0f6a901574d17672d1ccdc3e971b)

15 months agonetlink: Fix indentation in netlink_message_writer.c
Mark Johnston [Tue, 17 Jan 2023 14:37:33 +0000 (09:37 -0500)]
netlink: Fix indentation in netlink_message_writer.c

This file is indented with a mixture of tabs and spaces.  No functional
change intended.

Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38100

(cherry picked from commit 35472cb60ab95b4d99981492a87443022181eac2)

15 months agonetlink: Make the writers function table static and const
Mark Johnston [Tue, 17 Jan 2023 14:37:21 +0000 (09:37 -0500)]
netlink: Make the writers function table static and const

No functional change intended.

Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38099

(cherry picked from commit e262610007f01398630dc8ce7bf404dbcfd6350c)

15 months agonetlink: Zero-initialize mbuf messages
Mark Johnston [Tue, 17 Jan 2023 14:36:54 +0000 (09:36 -0500)]
netlink: Zero-initialize mbuf messages

Some users of nlmsg_reserve_object() and nlmsg_reserve_data() are not
careful to fully initialize pad and reserved fields, allowing
uninitialized bytes to leak to userspace.  For example, dump_nhgrp()
doesn't set nhm->resvd = 0.

Meanwhile, nlmsg_get_ns_buf() and nlmsg_get_ns_lbuf() zero-initialize
the buffer, so nlmsg_get_ns_mbuf() is inconsistent.  Let's just make
them all behave the same here.

Reported by: KMSAN
Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38098

(cherry picked from commit d91be0f1211b0196a0087cdfa237a6a0d2a43b65)

15 months agousb: Remove unused member in struct mos_softc
Zhenlei Huang [Wed, 15 Feb 2023 05:07:19 +0000 (13:07 +0800)]
usb: Remove unused member in struct mos_softc

Spotted by jhibbits in D37812.

Reviewed by: #network, glebius
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38581

(cherry picked from commit 3bafe73affe37de3e94d91d4c1310f1272375970)

15 months agoBump __FreeBSD_version to 1302502 after LinuxKPI changes.
Bjoern A. Zeeb [Fri, 17 Feb 2023 23:40:29 +0000 (23:40 +0000)]
Bump __FreeBSD_version to 1302502 after LinuxKPI changes.

Help out-of-tree consumers detect changes to LinuxKPI pci and 802.11.

15 months agoLinuxKPI: dummy: remove files which have implementation
Bjoern A. Zeeb [Sun, 29 Jan 2023 17:52:15 +0000 (17:52 +0000)]
LinuxKPI: dummy: remove files which have implementation

Remove former dummy/ files which now have an actual implementation
in common/ .

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38269

(cherry picked from commit 78cab57ac6aad5c4c9334ca99ed89cbc3579ffff)

15 months agoLinuxKPI: return an address string in pci_name()
Val Packett [Mon, 6 Feb 2023 21:50:13 +0000 (21:50 +0000)]
LinuxKPI: return an address string in pci_name()

amdgpu's virtual display feature uses pci_name() to match a module parameter
string, and the documentation shows an example of `0000:26:00.0` for the name.
In our case the name was just `drmn`, which is not actually unique across
devices.

The other consumers are wireless drivers, which will benefit from this
change.

Generate the expected string for pci_name() to return.

Related to: https://github.com/freebsd/drm-kmod/issues/134
Sponsored by: https://www.patreon.com/valpackett
Reviewed by: bz, hselasky, manu (earlier)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34248

(cherry picked from commit 393b0ba25f1a54dcc3f94244933c665f1c471d1a)

15 months agoLinuxKPI: pci: add more functions
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:02:51 +0000 (15:02 +0000)]
LinuxKPI: pci: add more functions

Add a dummy pci_assign_resource() and an implementation of
pci_irq_vector() returning the irq for MSI-X, MSI, and legacy interrupt.
Both are needed by wirless drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38237

(cherry picked from commit fd1a2f3dfc0e8fb20d0d397d586000bb918aab47)

15 months agoLinuxKPI: PCI: implement support for more than 1 MSI vector
Bjoern A. Zeeb [Fri, 27 Jan 2023 15:34:42 +0000 (15:34 +0000)]
LinuxKPI: PCI: implement support for more than 1 MSI vector

Following e9715b1c4474333ff119aba3a9a74bff91f72372 and
4b56afaf7bf4fa37bae5b26fd93ee1ff5969c1bb, implement support
for up-to 32 MSI vectors.  This is used by wireless drivers.
This also switches msi_desc to an array in order to store
per-vector information.

Sponsored by: The FreeBSD Foundation
Discussed with: grehan (in Dec)
MFC after: 3 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38222

(cherry picked from commit b15491b4773af99ce2470144ef6bcd9146cc9a98)

15 months agoLinuxKPI: implement irq_get_msi_desc()
Bjoern A. Zeeb [Mon, 28 Nov 2022 18:27:03 +0000 (18:27 +0000)]
LinuxKPI: implement irq_get_msi_desc()

Add irq_get_msi_desc() as a wrapper around a PCI function which will
allocate a single cached value (see comment on struct) for the
msi_desc requested if it doesn't exist yet and handle freeing it
when the PCI device goes away.  We take the values from the ivars of
the native (FreeBSD) device.

While changing struct pci_dev also add the msi_cap field requested by
a wireless driver.

MFC after: 3 days
Reviewed by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37523

(cherry picked from commit 4b56afaf7bf4fa37bae5b26fd93ee1ff5969c1bb)

15 months agoLinuxKPI: 802.11: basic implementation of *queue(s)/*txq*
Bjoern A. Zeeb [Tue, 31 Jan 2023 16:17:14 +0000 (16:17 +0000)]
LinuxKPI: 802.11: basic implementation of *queue(s)/*txq*
LinuxKPI: 802.11: deal with stopped queues

Very basic implementations of ieee80211_{wake,stop}_queue[s],
as well as ieee80211_txq_schedule_start(), ieee80211_next_txq(),
and ieee80211_schedule_txq().
Various combinations of these are used by different wireless
drivers, incl. iwlwifi.

Following 5a9a0d7803382321b5f9fff1deae5fb08463cf1a initialize the
queue values explicitly and deal with a stopped queue in
ieee80211_tx_dequeue().

Sponsored by: The FreeBSD Foundation (parts of this work)
MFC after: 3 days

(cherry picked from commit 5a9a0d7803382321b5f9fff1deae5fb08463cf1a)
(cherry picked from commit 0cbcfa1964de89cd346ee6f79437c6ab83a3b716)

15 months agoLinuxKPI: 802.11: fix indent in lkpi_wake_tx_queues()
Bjoern A. Zeeb [Tue, 31 Jan 2023 23:12:30 +0000 (23:12 +0000)]
LinuxKPI: 802.11: fix indent in lkpi_wake_tx_queues()

Fix indentation in lkpi_wake_tx_queues().
No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit b0ddb44fd427d44b8153781ce9c461e393771aff)

15 months agoLinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT
Bjoern A. Zeeb [Tue, 31 Jan 2023 23:00:28 +0000 (23:00 +0000)]
LinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT

Add code (currently disabled by #ifdef) for HT and VHT to
lkpi_scan_ies_add().  Switch to a local variable for ic given
the new code also needs the value.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit 3dd980267f4e53df259eb6d322e7332a8bc5bb0a)

15 months agoLinuxKPI: 802.11: implement ieee80211_is_pspoll()
Bjoern A. Zeeb [Tue, 31 Jan 2023 16:36:24 +0000 (16:36 +0000)]
LinuxKPI: 802.11: implement ieee80211_is_pspoll()

Implement ieee80211_is_pspoll() and move it up to the set of implemented
ieee80211_is_*() functions.

There are no further changes (git diff just looks weird).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit ff76cbc81d57ffc4bbc9bc20fd22325b2a8c2028)
(cherry picked from commit 2336248a8ba9763ad38074db40f32e117edd86f5)

15 months agoLinuxKPI: 802.11: implement ieee80211_tx_status_ext()
Bjoern A. Zeeb [Tue, 31 Jan 2023 15:35:59 +0000 (15:35 +0000)]
LinuxKPI: 802.11: implement ieee80211_tx_status_ext()

Add an implementation of ieee80211_tx_status_ext() extending the
internal linuxkpi_ieee80211_tx_status() implementation.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit a839757109891573123d8777b539fafa2d2198bb)

15 months agoLinuxKPI: 802.11: extend linuxkpi_ieee80211_rx()
Bjoern A. Zeeb [Tue, 31 Jan 2023 15:05:30 +0000 (15:05 +0000)]
LinuxKPI: 802.11: extend linuxkpi_ieee80211_rx()

Extend linuxkpi_ieee80211_rx() by another argument for
the ieee80211_rx_list() implementation (even though the argument
is currently ignored).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit e30e05d3ab3979a148068235298e1a6f73b675f0)

15 months agoLinuxKPI: 802.11: fix types and whitespace
Bjoern A. Zeeb [Tue, 31 Jan 2023 13:39:04 +0000 (13:39 +0000)]
LinuxKPI: 802.11: fix types and whitespace

Correct struct member types, fix whitespace, and remove superfluous
return statements in void functions.

No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit a3baca22d0b7789a040a60f389e3c132b6e1755b)

15 months agoLinuxKPI: skbuff: implement skb_free_frag()
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:33:12 +0000 (15:33 +0000)]
LinuxKPI: skbuff: implement skb_free_frag()

Using the work from 55038a6306a570c9f2df89f5ad076de0f7d98152 implement
skb_free_frag() calling page_frag_free().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit dbbf46ebba78770c2c3a1d7983e92e79ca67abc0)

15 months agoLinuxKPI: add more dummy header files
Bjoern A. Zeeb [Sun, 29 Jan 2023 18:16:00 +0000 (18:16 +0000)]
LinuxKPI: add more dummy header files

Add more empty header files wireless drivers try to include but
we do not (yet) need for any implementation.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38271

(cherry picked from commit 52c28b99034bd32c86e6c058f68cfbf11c8f76c3)

15 months agoLinuxKPI: pm.h: add dummy pm_wakeup_event()
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:53:03 +0000 (15:53 +0000)]
LinuxKPI: pm.h: add dummy pm_wakeup_event()

Add a dummy implementation of pm_wakeup_event() which is used to notify
the power management system about a wakeup (which we currently do not
implement yet).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38239

(cherry picked from commit 934cb7a3316609380fdea8da73233759f6dfff43)

15 months agoLinuxKPI: device: add device_set_wakeup_enable()
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:18:24 +0000 (15:18 +0000)]
LinuxKPI: device: add device_set_wakeup_enable()

Add a dummy device_set_wakeup_enable() which is used for WoWLAN which we
do not (yet) support and device_wakeup_enable() which is a wrapper to the
former with the enable argument being true.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38238

(cherry picked from commit ffdf10fb9cf13464801f2d78d3e1470201394812)

15 months agoLinuxKPI: const argument to irq_set_affinity_hint()
Bjoern A. Zeeb [Sat, 28 Jan 2023 16:15:19 +0000 (16:15 +0000)]
LinuxKPI: const argument to irq_set_affinity_hint()

irq_set_affinity_hint() takes a const mask argument and some drivers
pass it in as such where earlier implementations were more lenient.
Deal with it and __DECONST() the argument when passed to intr_setaffinity().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38242

(cherry picked from commit 4c72d075a57e9a3215639aede16df4df29e1c1da)

15 months agoLinuxKPI: mm.h: implement virt_to_head_page()
Bjoern A. Zeeb [Sat, 28 Jan 2023 16:00:55 +0000 (16:00 +0000)]
LinuxKPI: mm.h: implement virt_to_head_page()

Implement virt_to_head_page().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38240

(cherry picked from commit 70b97048a051958be37b650b8a67c89203fd6b70)

15 months agoLinuxKPI: interrupt.h: add disable_irq_nosync(), irq_set_status_flags()
Bjoern A. Zeeb [Sat, 28 Jan 2023 16:11:59 +0000 (16:11 +0000)]
LinuxKPI: interrupt.h: add disable_irq_nosync(), irq_set_status_flags()

Add a dummy irq_set_status_flags() along with #defines passed by the driver.
Add disable_irq_nosync() as another wrapper to lkpi_disable_irq().
Those are used by wireless drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38241

(cherry picked from commit bc81a2b788f5644ece58defa30880b69c9894981)

15 months agoLinuxKPI: pci.h move function declaration to top of file.
Bjoern A. Zeeb [Thu, 26 Jan 2023 14:31:26 +0000 (14:31 +0000)]
LinuxKPI: pci.h move function declaration to top of file.

No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit 0d0ca120a79ff826d7c2ad84c44359c200460640)

15 months agoLinuxKPI: linux_pci.c: fix whitespace
Bjoern A. Zeeb [Fri, 27 Jan 2023 15:18:44 +0000 (15:18 +0000)]
LinuxKPI: linux_pci.c: fix whitespace

Properly indent a line.  No functional change.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit 68b1d162505149b8629f7e22cecf298cea2ff1f9)

15 months agoice(4): Update to 1.37.7-k
Piotr Kubaj [Tue, 14 Feb 2023 01:29:44 +0000 (17:29 -0800)]
ice(4): Update to 1.37.7-k

Notable changes include:

- DSCP QoS Support (leveraging support added in
  rG9c950139051298831ce19d01ea5fb33ec6ea7f89)
- Improved PFC handling and TC queue assignments (now all remaining
  queues are assigned to TC 0 when more than one TC is enabled and the
  number of available queues does not evenly divide between them)
- Support for dumping the internal FW state for additional debugging by
  Intel support
- Support for allowing "No FEC" to be a valid state for the LESM to
  negotiate when using non-standard compliant modules

Also includes various bug fixes and smaller enhancements, too.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Jeff Pieper <jeffrey.pieper@intel.com>
MFC after: 3 days
Relnotes: yes
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D38109

(cherry picked from commit 8923de59054358980102ea5acda6c6dd58273957)

15 months agoice_ddp: Update package to 1.3.30.0
Eric Joyner [Tue, 24 Jan 2023 22:01:57 +0000 (14:01 -0800)]
ice_ddp: Update package to 1.3.30.0

This updated DDP is intended to be used with the forthcoming ice(4)
driver update to 1.37.7-k. (But it will still work with the current
version.)

Co-authored-by: Piotr Kubaj <pkubaj@FreeBSD.org>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
MFC after: 1 week
Sponsored by: Intel Corporation

(cherry picked from commit 2508da22cd6f0904fe55d2d5f6cab7c6011f918c)

15 months agopf tests: improve pfsync:basic_defer test
Kristof Provost [Fri, 3 Feb 2023 03:10:32 +0000 (04:10 +0100)]
pf tests: improve pfsync:basic_defer test

Create state on output only, to ensure we trigger the defer code.

MFC after: 2 weeks

(cherry picked from commit afa77b6996513df98fd27f91ae4c9fe57f7ac4b2)

15 months agopfsync: add missing bucket lock
Kristof Provost [Thu, 2 Feb 2023 09:34:57 +0000 (10:34 +0100)]
pfsync: add missing bucket lock

pfsync_q_ins() expects us to hold the bucket lock, but when we enter it
from pfsync_state_import() we don't.

MFC after: 2 weeks

(cherry picked from commit 0ed5f66c5ad23a6fe02d60765acf5e5e00957542)

15 months agovmm: Remove an unneeded initialization of "retu"
Mark Johnston [Thu, 9 Feb 2023 20:51:11 +0000 (15:51 -0500)]
vmm: Remove an unneeded initialization of "retu"

vm_handle_ipi() unconditionally initializes "retu".  No functional
change intended.

Reviewed by: jhb, corvink
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38446

(cherry picked from commit ba34de1b3bf965d15f6c76c97fa7e6d17194d401)

15 months agovmm: Collapse identical case statements in vlapic_icrlo_write_handler()
Mark Johnston [Thu, 9 Feb 2023 20:49:40 +0000 (15:49 -0500)]
vmm: Collapse identical case statements in vlapic_icrlo_write_handler()

No functional change intended.

Reviewed by: jhb, corvink
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38446

(cherry picked from commit f3bbd0e818008ddc4fbf1f6ade0f7e411b1dfee5)

15 months agoatomic: Fix the atomic_load_ptr() *SAN interceptor
Mark Johnston [Thu, 9 Feb 2023 14:54:52 +0000 (09:54 -0500)]
atomic: Fix the atomic_load_ptr() *SAN interceptor

The interceptor didn't handle a pointer of type "foo * const *" and in
that case we'd get compiler errors 1) an invalid cast to volatile
uintptr_t, and 2) an assignment to a variable of type "foo * const"
(__retptr).

Reported by: mjg
MFC after: 1 week

(cherry picked from commit 08b0c98006b6b9f3722df0ce462f6a4aa8ee06f2)

15 months agobridge: Make the ioctl table local to if_bridge.c
Mark Johnston [Tue, 7 Feb 2023 19:34:37 +0000 (14:34 -0500)]
bridge: Make the ioctl table local to if_bridge.c

No functional change intended.

MFC after: 1 week
Sponsored by: Klara, Inc.

(cherry picked from commit 3bc099eb71200b843de94b8e84b30b152a38f2f4)

15 months agosys/_endian.h: Move powerpc workaround into _endian.h
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
sys/_endian.h: Move powerpc workaround into _endian.h

Powerpc compilers often define _BIG_ENDIAN or _LITTLE_ENDIAN depending
on the byte order of the target. This interfers with the endian.h and
sys/endian.h APIs which expect those two to be 4321 or 1234.
Unconditionally undefine these two before we define them to work around
this issue. By including endian.h, the programmer is saying they want
this API not the native one. This matches historic practice as well.

Fixes: e35448a901aa
Sponsored by: Netflix
Noticed by: powerpc, powerpc64 CI jobs

(cherry picked from commit 6f23df1ae7f6ec3cd06a15c87f0aaaa770b2941b)

15 months agopowerpc: Drop old workaround for old gcc
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
powerpc: Drop old workaround for old gcc

Very old versions of gcc defined _BIG_ENDIAN and _LITTLE_ENDIAN. So to
work around that, we undefined them here. However, that causes problems
for programs that do:

(and many other variations on that theme). Since this often is the
result of weirdly nested includes in the ports world that are hard to
unwind, drop this workaround to help more ports build out of the box.
If there's still an issue here (and my testing hasn't shown it), we'll
fix the issue in a brand-new way once I have a reproducer.

This fixes the mesa-devel build, and others

Sponsored by: Netflix
Tested by: pkubaj
MFC After: 3 days
Differential Revision: https://reviews.freebsd.org/D38564

(cherry picked from commit e35448a901aa56aa232efbc4fe7a73a9bdac3511)

15 months agocdce: add to cdce.4 information about NCM network mode
Michael Paepcke [Thu, 16 Feb 2023 16:50:18 +0000 (09:50 -0700)]
cdce: add to cdce.4 information about NCM network mode

add a new section how to use NCM network mode and specify the required
kernel modules

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/646

(cherry picked from commit 58e1d01022415e29d3e08c4d3936b6631c27406c)

15 months agou3g: add huawei device id
Michael Paepcke [Thu, 16 Feb 2023 16:49:00 +0000 (09:49 -0700)]
u3g: add huawei device id

Add missing entry for E3372h Model already in NCM mode

Noticed by: David BOYER
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/645

(cherry picked from commit 08ecb40e88a0d34cf6a177218a22f07431cadf3c)

15 months agousb/u3g: Add support for QUECTEL EP06-E 4G modem
ev [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb/u3g: Add support for QUECTEL EP06-E 4G modem

Add QUECTEL EP06-E modem support via USB for FreeBSD.
Tested and works like a ppp on FreeBSD-13.

Reviewed by: imp
PR: 269326

(cherry picked from commit 0cec5b99b3c0484925f3cc0813040c160987bd45)

15 months agou3g: Add new 4G Huawei devices
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
u3g: Add new 4G Huawei devices

New 4G devices. Longer description of new modes to follow.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit 75d41cb6967bef0e534afd6d20ea5eeeb2435e36)

15 months agousb: Remove obsolete Huawei 3G from usbdevs
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb: Remove obsolete Huawei 3G from usbdevs

- remove Huawei 3G E3131 (E3131_INIT):
- frees up 0x1505/0x14fe shared IDs => product is EOL (since...)
- 3G networks are shutdown/scheduled
- E3131 devices will still work the same via scsi_huawei_eject2
- new 4G devices will switch & report correctly now

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit 848ac8451b08d09a81de7bac8ff8fbe0d35df8cb)

15 months agousb: add support for Huawei E5573Cs322
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb: add support for Huawei E5573Cs322

Switch the now added E5573Cs322_ECM (0x14db) as well per default to NCM.
With this patch we default all devices to simple NCM mode to avoid the
problem and get a consistent reliable behavior. No matter what firmware
version and provider mix are involved.

Rationale:
Even the bigger SOC shows under complex load in ECM (double-nat) mode
the same performance drop from 25Mbit to 2Mbit Line Speed, similar to E3372h.
Reason: Thermal problems (reported via serial debug interface in ACM Mode)
after 2-3 minutes load.

Fix the root cause and bundle a working firmware is out of reach because
Huawei sells the same hardware, different (crippled) firmware versions
at different price points in different markets as strategy.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit e66352013a67183dfeec14b2a22913305c26e838)

15 months agousb: add new scsi_huawei eject3 & eject4 driver support
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb: add new scsi_huawei eject3 & eject4 driver support

Add initialization for new Huawei 4G E3372_NCM, E3372v153_NCM,
E5573Cs322_NCM, E5573Cs322_ECM, and E5573Cs322_ACM.

Remove now-obsolete Huawei 3G E3131 init sequence. These devices are
obsolete, share IDs with new devices and the 3G networks are shutdown.
These old devices work correctly via the 4G code while still allowing
the shared IDs to work differently for the new devices.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit 1997d3a4a9f20a846cf762306fd5193526a1d603)

15 months agousb: add new scsi_huawei eject3 & eject4 sequences
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb: add new scsi_huawei eject3 & eject4 sequences

Add new Huawei eject3 and eject4 command sequences.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit 7d4b2b5834dba66732596d68d7f817d18affb67f)

15 months agousb: add new scsi_huawei eject3 & eject4 quirks
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb: add new scsi_huawei eject3 & eject4 quirks

Add new scsi_huawei eject3 & eject4 mode driver to usb quirks

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit 64fd867f8cdbad24d7af678ee17bd3893832b905)

15 months agousb: Add Huawei 4G Modem devices (2022) to usbdevs
Michael Paepcke [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
usb: Add Huawei 4G Modem devices (2022) to usbdevs

ADD [sys/dev/usb/usbdevs]
- add new Huawei 4G E3372_NCM  0x1505
- add new Huawei 4G E3372v153_NCM 0x155f
- add new Huawei 4G E5573Cs322_NCM 0x155e
- add new Huawei 4G E5573Cs322_ECM 0x14db
- add new Huawei 4G E5573Cs322_ACM 0x1442

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/633

(cherry picked from commit 2c6b88da7174b02c98b87cd4b7251ccf9d7acbae)

15 months agoChange "ctlstat -P"'s schema
Alan Somers [Wed, 25 Jan 2023 18:00:49 +0000 (11:00 -0700)]
Change "ctlstat -P"'s schema

It now reports stats separately for both ports and luns.

Also, prohibit using both "-p" and "-P" at the same time.

Sponsored by: Axcient
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D38500

(cherry picked from commit 4c163a5480809d0dc8b68dd00bf2ba7d882450f9)

15 months agoBump __FreeBSD_version to 1302501
Jean-Sébastien Pédron [Thu, 16 Feb 2023 10:27:43 +0000 (11:27 +0100)]
Bump __FreeBSD_version to 1302501

... after adding `totalram_pages()` to linuxkpi. This is needed by the
DRM drivers.

Approved by: manu

15 months agolinuxkpi: Define `totalram_pages()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:52:43 +0000 (18:52 +0100)]
linuxkpi: Define `totalram_pages()`

It returns `physmem`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38531

(cherry picked from commit 53da54b936e646ba1216c0cc19582dad058ca5d0)

15 months agolinuxkpi: Add `strscpy_pad()` to <linux/string.h>
Jean-Sébastien Pédron [Tue, 14 Feb 2023 23:46:13 +0000 (00:46 +0100)]
linuxkpi: Add `strscpy_pad()` to <linux/string.h>

It's the same as `strscpy()` except that it fills the rest of the
destination buffer with zeroes if the source buffer is shorter.

Reviewed by: manu
Approved by: manu

(cherry picked from commit b1a9e570fe2da0a43c41327d7ce21b27bf8257b8)

15 months agolinuxkpi: Define `debugfs_initialized()`
Jean-Sébastien Pédron [Tue, 14 Feb 2023 23:38:59 +0000 (00:38 +0100)]
linuxkpi: Define `debugfs_initialized()`

It always return true on FreeBSD, at least for now, because all DRM
drivers using it depend on lindebugfs.

Reviewed by: manu
Approved by: manu

(cherry picked from commit 4dac88cd150b444cf67a09f7c0c8af795e9c1bd6)

15 months agolinuxkpi: Move `IS_ENABLED()` and friends to <linux/kconfig.h>
Jean-Sébastien Pédron [Mon, 13 Feb 2023 20:52:08 +0000 (21:52 +0100)]
linuxkpi: Move `IS_ENABLED()` and friends to <linux/kconfig.h>

The header is included in <linux/xarray.h> like it is on Linux. Some DRM
code depends on this header "pollution".

Reviewed by: bz
Approved by: bz
Differential Revision: https://reviews.freebsd.org/D38567

(cherry picked from commit 4b0552d5f4ea0bd09d7f0f178810886472e84d63)

15 months agolinuxkpi: Add <linux/cc_platform.h>
Jean-Sébastien Pédron [Tue, 14 Feb 2023 21:44:21 +0000 (22:44 +0100)]
linuxkpi: Add <linux/cc_platform.h>

It defines the `cc_platform_has()` function.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38596

(cherry picked from commit 96e16cf368f6d8aa3c0efd44db4c4678892e1fea)

15 months agolinuxkpi: Update `ww_mutex_trylock()` API for Linux 5.16
Jean-Sébastien Pédron [Mon, 13 Feb 2023 22:22:54 +0000 (23:22 +0100)]
linuxkpi: Update `ww_mutex_trylock()` API for Linux 5.16

It gains new `struct ww_acquire_ctx *` argument we don't use currently.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38568

(cherry picked from commit e6f7fe74a903b4085d60b0054ff75ee677beaf76)

15 months agolinuxkpi: Declare `struct fwnode_handle` in <linux/fwnode.h>
Jean-Sébastien Pédron [Mon, 13 Feb 2023 20:51:00 +0000 (21:51 +0100)]
linuxkpi: Declare `struct fwnode_handle` in <linux/fwnode.h>

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38566

(cherry picked from commit 7d03acf065ed96fd04a54bf8e1c83a032ffed097)

15 months agolinuxkpi: Add `synchronize_shrinkers()`
Jean-Sébastien Pédron [Mon, 13 Feb 2023 20:49:28 +0000 (21:49 +0100)]
linuxkpi: Add `synchronize_shrinkers()`

It takes the lock and release it immediately to make sure no shrinkers
are running in parallel.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38565

(cherry picked from commit 83636727291714c235726da987a02c5b1d51bb54)

15 months agolinuxkpi: Accept NULL as a value in `linux_xarray`
Jean-Sébastien Pédron [Sat, 11 Feb 2023 10:12:08 +0000 (11:12 +0100)]
linuxkpi: Accept NULL as a value in `linux_xarray`

Linux' XArray allows to store a NULL pointer as a value. `xa_load()`
would return NULL for both an unused index and an index set to NULL. But
it impacts `xa_alloc()` which needs to find the next available index.

However, our implementation relies on a radix tree (see `linux_radix.c`)
which does not accept NULL pointers as values. I'm not sure if this is a
limitation or a feature, so to work around this, a NULL value is
replaced by `NULL_VALUE`, an unlikely address, when we pass it to
linux_radix.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D38543

(cherry picked from commit 3102ea3b15b6c3ed1ea50716d65980b680375ebc)

15 months agolinuxkpi: Define `cpu_data(cpu)`
Jean-Sébastien Pédron [Fri, 10 Feb 2023 15:38:43 +0000 (16:38 +0100)]
linuxkpi: Define `cpu_data(cpu)`

`cpu_data(cpu)` evaluates to a `struct cpuinfo_x86` filled with
attributes of the given CPU number. The CPU number is an index in the
`__cpu_data[]` array with MAXCPU entries. On FreeBSD, we simply
initialize all of them like we do with `boot_cpu_data`.

While here, we add the `x86_model` field to the `struct cpuinfo_x86`. We
use `CPUID_TO_MODEL()` to set it.

At the same time, we fix the value of `x86` which should have been set
to the CPU family. It was using the same implementation as
`CPUID_TO_MODEL()` before. It now uses `CPUID_TO_FAMILY()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38542

(cherry picked from commit a27902c1838836b3fb00cd660ce37a4f20bd7991)

15 months agolinuxkpi: Add `sg_alloc_table_from_pages_segment()`
Jean-Sébastien Pédron [Fri, 10 Feb 2023 15:37:31 +0000 (16:37 +0100)]
linuxkpi: Add `sg_alloc_table_from_pages_segment()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38541

(cherry picked from commit f3490083b731700f2aa7c17ac6fe159826dc59a5)

15 months agolinuxkpi: Add <linux/stdarg.h> + include it from <linux/string.h>
Jean-Sébastien Pédron [Fri, 10 Feb 2023 10:52:12 +0000 (11:52 +0100)]
linuxkpi: Add <linux/stdarg.h> + include it from <linux/string.h>

The <stdarg.h> header was moved in Linux 5.15.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38540

(cherry picked from commit d91cf060205cfe479675d7fb4ec95d2ed6a9b76c)

15 months agolinuxkpi: Define `IRQ_NOTCONNECTED`
Jean-Sébastien Pédron [Fri, 10 Feb 2023 10:26:17 +0000 (11:26 +0100)]
linuxkpi: Define `IRQ_NOTCONNECTED`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38539

(cherry picked from commit 210e756d4b32f43e8cc5f748456158757892a46a)

15 months agolinuxkpi: Define `lockdep_assert{,_once}()`
Jean-Sébastien Pédron [Thu, 9 Feb 2023 22:04:26 +0000 (23:04 +0100)]
linuxkpi: Define `lockdep_assert{,_once}()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38538

(cherry picked from commit b82bcfb66fa5ef30939f3f5169a07bf4bc139e71)

15 months agolinuxkpi: Move definition of `struct list_head` to <linux/types.h>
Jean-Sébastien Pédron [Thu, 9 Feb 2023 12:11:34 +0000 (13:11 +0100)]
linuxkpi: Move definition of `struct list_head` to <linux/types.h>

This is the case on Linux.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38537

(cherry picked from commit 54606590dffcd23136af1c26da38206f4d3a6269)

15 months agolinuxkpi: Define `FIELD_FIT()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 23:38:22 +0000 (00:38 +0100)]
linuxkpi: Define `FIELD_FIT()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38536

(cherry picked from commit bf6f6650813959ecf3469854ad266c5a5590c754)

15 months agolinuxkpi: Add `i2c_adapter_quirks` support
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:57:32 +0000 (18:57 +0100)]
linuxkpi: Add `i2c_adapter_quirks` support

While here, also declare `I2C_CLASS_HWMON`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38535

(cherry picked from commit 83276e1f952d720c23092ea17e95c03fef8476b7)

15 months agolinuxkpi: Define `xa_is_err()`, `xa_{store,erase}_irq()` and `xa_{,un}lock_irq*()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:55:29 +0000 (18:55 +0100)]
linuxkpi: Define `xa_is_err()`, `xa_{store,erase}_irq()` and `xa_{,un}lock_irq*()`

`xa_is_err()` is synonymous to `IS_ERR()`.

Other introduced functions call their equivalent without the `irq*`
suffix.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38534

(cherry picked from commit 5542309ec6eba3af9e26c50acd654de462181b8e)

15 months agolinuxkpi: Update `vga_client_register()` and add `vga_client_unregister()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:53:57 +0000 (18:53 +0100)]
linuxkpi: Update `vga_client_register()` and add `vga_client_unregister()`

For `vga_client_register()`, the API is modified twice in a row. To keep
the API compatible with all commits in the DRM driver, we introduce two
`LINUXKPI_VERSION` version bumps.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38533

(cherry picked from commit 1c6d8146fdec8267712615c261bf6c8800f8ecfe)

15 months agolinuxkpi: Declare missing `DMI_*` enum entries
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:53:23 +0000 (18:53 +0100)]
linuxkpi: Declare missing `DMI_*` enum entries

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38532

(cherry picked from commit cf5416908658ed0e4f2ae72916dfe1a84d7fd61c)

15 months agolinuxkpi: Define `backlight_get_brightness()` and `backlight_is_blank()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:51:16 +0000 (18:51 +0100)]
linuxkpi: Define `backlight_get_brightness()` and `backlight_is_blank()`

This is not used by the DRM driver yet because we comment out the code
calling them, but they are easy to implement.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38530

(cherry picked from commit a82a8a5e193587d819288c3c27f1c9472178e10e)

15 months agolinuxkpi: list_sort()'s callback now takes list arguments
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:22:07 +0000 (23:22 +0100)]
linuxkpi: list_sort()'s callback now takes list arguments

This change breaks the API of `list_sort()`. `LINUXKPI_VERSION >= 51300`
is used to keep the header compatible with both versions of the
prototype.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38082

(cherry picked from commit a83b3ec719eb6c53658656b7b90607564d3c64d3)

15 months agolinuxkpi: Define `dev_is_platform()` and `to_platform_device()`
Jean-Sébastien Pédron [Sun, 22 Jan 2023 13:46:54 +0000 (14:46 +0100)]
linuxkpi: Define `dev_is_platform()` and `to_platform_device()`

The former returns false and the latter returns NULL.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38163

(cherry picked from commit b9ef0689433d7d08c96695e571c4c262a3ac9007)

15 months agolinuxkpi: Try to solve headers dependencies
Jean-Sébastien Pédron [Fri, 20 Jan 2023 18:08:39 +0000 (19:08 +0100)]
linuxkpi: Try to solve headers dependencies

I'm sure I got it wrong but at least the DRM drivers compile.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38157

(cherry picked from commit 11aaefc9ca8537be0ea5f62a5927dd39a6109e4f)

15 months agolinuxkpi: Add `io_mapping_map_local_wc()` and `io_mapping_unmap_local()`
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:53:49 +0000 (18:53 +0100)]
linuxkpi: Add `io_mapping_map_local_wc()` and `io_mapping_unmap_local()`

`io_mapping_map_local_wc()` is synonymous to `io_mapping_map_atomic_wc()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38156

(cherry picked from commit 29d0c85c86347cd3eafe3c8974c693abf8d9ca51)

15 months agolinuxkpi: Add `kmap_local_page_prot()` and `kunmap_local()`
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:52:39 +0000 (18:52 +0100)]
linuxkpi: Add `kmap_local_page_prot()` and `kunmap_local()`

They are synonymous to `kmap_atomic_prot()` and `kunmap_atomic()`
respectively.

While here, fix several style(9) issues.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38155

(cherry picked from commit 9dafbd0c69a6aade69b23a649548b6c7133f1091)

15 months agolinuxkpi: Add <linux/pgtable.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:50:39 +0000 (18:50 +0100)]
linuxkpi: Add <linux/pgtable.h>

For now, it's empty. It is included by the DRM drivers but nothing is
missing otherwise. Perhaps something we already defined should be in
`pgtable.h` instead of another header.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38153

(cherry picked from commit 7649b89cc12696d540b20ad2f5896827b102225e)