Commit Graph

142823 Commits

Author SHA1 Message Date
John Baldwin
1ac10fa429 acpi_toshiba: Use device_get_softc in attach.
Rather than a detour via the devclass and hardcoding unit 0.

While here, remove a check for sc being NULL.  It will never be NULL
when attach is called.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35010
2022-04-21 10:29:15 -07:00
John Baldwin
c1d90b2d02 vgapm: Use devclass_find to lookup the vga devclass in suspend and resume.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35009
2022-04-21 10:29:15 -07:00
John Baldwin
0b377a49fa FB_INSTALL_CDEV: Remove this option and related code.
This option was never enabled in GENERIC and does not appear to work
(the cdevsw is stored in a global array but never passed to make_dev
to be associated with a character device).

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D35008
2022-04-21 10:29:14 -07:00
John Baldwin
6b06f746db sc: Use devclass_find to lookup the sc devclass.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35007
2022-04-21 10:29:14 -07:00
John Baldwin
108adb2ff5 arcmsr: Remove never-true NULL check from cdev callbacks.
si_drv1 will always hold a non-NULL pointer.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35005
2022-04-21 10:29:14 -07:00
John Baldwin
a9e5e04e64 arcmsr: Store softc pointer in si_drv1 of cdev.
Rather than fetching the softc using the controller's unit number as
an index into the devclass.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35004
2022-04-21 10:29:14 -07:00
John Baldwin
907f35efff ccp: Use devclass_find to lookup devclass in db_show_ccp.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35003
2022-04-21 10:29:14 -07:00
John Baldwin
3d7e90fc20 cpufreq_curr_sysctl: Use devclass_find to lookup cpufreq devclass.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35002
2022-04-21 10:29:14 -07:00
John Baldwin
e9d92100c7 hidbus: Use devclass_find to lookup the devclass for hidbus.
Reviewed by:	wulf, imp
Differential Revision:	https://reviews.freebsd.org/D35000
2022-04-21 10:29:14 -07:00
John Baldwin
9b6761bd13 twe: Use devclass_find in twe_report debug function.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34999
2022-04-21 10:29:14 -07:00
John Baldwin
13bebcd35f pcm: Initialize pcm_devclass in sound_modevent.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34998
2022-04-21 10:29:14 -07:00
John Baldwin
8109ec9d89 pcm: Remove dead code from sound_modevent.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34997
2022-04-21 10:29:14 -07:00
John Baldwin
489e8f24a5 smbios/vpd: Use devclass_find to lookup devclass in module event handler.
While here, use a modern function declaration for smbios_modevent and
vpd_modevent.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34996
2022-04-21 10:29:14 -07:00
John Baldwin
82496a256f nvme: Use devclass_find to lookup the nvme devclass.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34995
2022-04-21 10:29:14 -07:00
John Baldwin
967949e7c5 mlx: Use devclass_find to lookup the devclass for mlxd.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34994
2022-04-21 10:29:14 -07:00
John Baldwin
517a8a715a hptiop: Store softc pointer in si_drv1 of cdev.
Rather than fetching the softc using the controller's unit number as
an index into the devclass.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34993
2022-04-21 10:29:13 -07:00
John Baldwin
5a03f17a9a acpi_tz: Lookup devclass by name when needed.
Cache the value in a local variable in the worker thread.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34992
2022-04-21 10:29:13 -07:00
John Baldwin
9066471175 acpi_isab: Check the unit in probe instead of using the devclass.
This is an alternate way to only attach to isab0 for the reasons
described in commit 852989bdbf.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34991
2022-04-21 10:29:13 -07:00
John Baldwin
33883cdce4 acpi_hpet: Use devclass_find to find devclass in identify.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34990
2022-04-21 10:29:13 -07:00
John Baldwin
97c076d237 acpi_ec: Use device_get_devclass to find devclass in probe.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34989
2022-04-21 10:29:13 -07:00
John Baldwin
e206dddcfe acpi_cpu: Use device_get_devclass to find devclass in attach.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34988
2022-04-21 10:29:13 -07:00
John Baldwin
3730d6aa8f acpi_apei: Use devclass_find to find devclass in identify.
Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D34987
2022-04-21 10:29:13 -07:00
John Baldwin
5a84b710a9 acpi_acad: Use devclass_find to find the acpi_acad devclass.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34986
2022-04-21 10:29:13 -07:00
Mark Johnston
5d691ab4f0 mld6: Ensure that mld_domifattach() always succeeds
mld_domifattach() does a memory allocation under the global MLD mutex
and so can fail, but no error handling prevents a null pointer
dereference in this case.  The mutex is only needed when updating the
global softc list; the allocation and static initialization of the softc
does not require this mutex.  So, reduce the scope of the mutex and use
M_WAITOK for the allocation.

PR:		261457
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34943
2022-04-21 13:23:59 -04:00
Kristof Provost
efc64d02a6 pf: counter argument to pfr_pool_get() may never be NULL
Coverity points out that if counter was NULL when passed to
pfr_pool_get() we could potentially end up dereferencing it.
Happily all users of the function pass a non-NULL pointer. Enforce this
by assertion and remove the pointless NULL check.

Reported by:	Coverity (CID 273309)
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-21 17:59:45 +02:00
Kristof Provost
4302035063 pfsync: NULL check before dereference
Move the use of 'sc' to after the NULL check.
It's very unlikely that we'd actually hit this, but Coverity is correct
that it's not a good idea to dereference the pointer and only then NULL
check it.

Reported by:	Coverity (CID 1398362)
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-21 17:59:45 +02:00
Kristof Provost
ed6287c141 pf: remove pointless NULL check
pfi_kkif_attach() always returns non-NULL, and we dereference the
pointer before we check it, so that's pointless.

Reported by:	Coverity (CID 1007345)
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-21 17:59:45 +02:00
Hans Petter Selasky
cda31e7349 xhci(4): Ensure the so-called data toggle gets properly reset.
Use the drop and enable endpoint context commands to force a reset of
the data toggle for USB 2.0 and USB 3.0 after:
 - clear endpoint halt command (when the driver wishes).
 - set config command (when the kernel or user-space wants).
 - set alternate setting command (only affected endpoints).

Some XHCI HW implementations may not allow the endpoint reset command when
the endpoint context is not in the halted state.

Reported by:		Juniper and Gary Jennejohn
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-04-21 17:01:13 +02:00
Misho
0c6a2fa33e if_bnxt: Allow bnxt interfaces to use vlans
When VLAN HW filter is disabled, the NIC does not pass any vlan tagged
traffic. Setting these flags on the device allows vlan tagged traffic to
pass.

PR:		236983
Tested by:	pi
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34824
2022-04-21 09:31:51 +01:00
Konstantin Belousov
d282bb42c3 syscons: silent 'set but unused' warning in some configurations
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-04-21 01:55:12 +03:00
Doug Moore
11fced21cc dev/iommu: Include offset in maxaddr check.
If iommu_gas_match_one has to adjust for a boundary crossing, its
check against maxaddr includes 'offset' in its calculation, to ensure
that the allocated memory does not exceed the max address. However, if
there's no boundary crossing adjustment, then the maxaddr check
disregards 'offset'. Fix that.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D34978
2022-04-20 17:24:11 -05:00
Kristof Provost
a879e40ca2 callout: fix using shared rmlocks
15b1eb142c changed the callout code to store the CALLOUT_SHAREDLOCK flag
in c_iflags (where it used to be c_flags), but failed to update the
check in softclock_call_cc(). This resulted in the callout code always
taking the write lock, even if a read lock had been requested (with
the CALLOUT_SHAREDLOCK flag in callout_init_rm()).

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34959
2022-04-20 13:06:50 +02:00
Kristof Provost
812839e5aa pf: allow the use of tables in ethernet rules
Allow tables to be used for the l3 source/destination matching.
This requires taking the PF_RULES read lock.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34917
2022-04-20 13:01:12 +02:00
Gordon Bergling
7fad3ed8e9 iicbus(4): Fix two typos in kernel error messages
- s/occured/occurred/

MFC after:3 days
2022-04-20 12:55:44 +02:00
Gordon Bergling
88cdccff3f oce(4): Fix a typo in a sysctl description
- s/interupt/interrupt/

MFC after:	3 days
2022-04-20 12:51:52 +02:00
Kornel Duleba
06f659c39d dmar: Disable PMR in driver attach routine
Previously it was disabled right before translation was enabled.
This way the disable logic is still executed even when translation
is not be activated, e.g. with hw.iommu.dma=0 tunable set.
On some platforms we need to disable PMR in order for core dump to work.
At the same time it was observed that enabling translation has
a significant impact on network performance.
With this patch PMR can be disabled, with IOMMU translation not being
turned on by appending the following to the loader.conf:

hw.dmar.enable=1
hw.dmar.pmr.disable=1
hw.dmar.dma=0

Sponsored by: Stormshield
Obtained from: Semihalf
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D34907
2022-04-20 09:40:28 +02:00
Wojciech Macek
14b7706264 mac_pimd: Support for privilege drop in pimd
Create new kernel module for privilege check in case
the user wants to run pimd daemon.

Sponsored by:		Stormshield
Obtained from:		Semihalf
2022-04-20 08:07:37 +02:00
Michael Tuexen
89c6aba7cf sctp: cleanup
MFC after:	3 days
2022-04-19 21:40:22 +02:00
Michael Tuexen
868868f14e sctp: improve stopping of timers
Reported by:	syzbot+c9c70062320aaad19de7@syzkaller.appspotmail.com
MFC after:	3 days
2022-04-19 21:29:41 +02:00
John Baldwin
e8d1145d10 cxgbe: Remove unused devclass arguments to *DRIVER_MODULE().
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D34964
2022-04-19 10:44:08 -07:00
John Baldwin
2a99dd30df Deprecate the 'devclass' argument from *DRIVER_MODULE() macros.
This argument is useless for the vast majority of drivers.  For now,
use __VA_ARGS__ wrapper macros so that that the *DRIVER_MODULE()
macros accept both the old version (with a devclass) and the new
version (which omits the argument and stores NULL in the
driver_module_data structure).  This provides an API compatiblity
shim that can be merged to older stable branches.

Once all drivers relevant to 14.0 (both in and out of tree) have been
updated, the API compat shims can be dropped.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34963
2022-04-19 10:43:57 -07:00
John Baldwin
5bdea8826b devclass_add_driver: Permit NULL to be passed in dcp.
This permits a driver module structure that doesn't want to store a
pointer to the new driver's devclass.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34962
2022-04-19 10:43:50 -07:00
Gordon Bergling
f45f90c5d6 videomode: Fix a typo in an kernel message
- s/Seperate/Separate/

Obtained from:	NetBSD
MFC after:	3 days
2022-04-19 17:09:52 +02:00
Stefan Eßer
ecbbb0c85e ffs: plug a set-but-not-used var 2022-04-19 16:51:12 +02:00
Alan Somers
8c47d8f538 prometheus_sysctl_exporter: fix metric aliasing
When exporting sysctls to Prometheus, the exporter replaces "." with
"_".  This caused several metrics to alias, confusing the Prometheus
server.  Fix it by:

* Renaming the "tcp_log_bucket" UMA zone to "tcp_log_id_bucket".  Also,
  rename "tcp_log_node" to "tcp_log_id_node" for consistency.

* Not exporting sysctls with "(LEGACY)" in the description.  That is
  used by ZFS sysctls that have been replaced by others, many of which
  alias to the same Prometheus metric name (like "vfs.zfs.arc_max" and
  "vfs.zfs.arc.max").

PR:		259607
Reported by:	delphij
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	delphij,rew,thj
Differential Revision: https://reviews.freebsd.org/D34952
2022-04-19 06:56:39 -06:00
Mateusz Guzik
19447fc488 sfxge: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:57 +00:00
Mateusz Guzik
b338b1fd50 tcp: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:57 +00:00
Mateusz Guzik
c5c981d443 signals: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:57 +00:00
Mateusz Guzik
db2ce6914b sctp: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:57 +00:00
Mateusz Guzik
93494e425b linux: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:57 +00:00
Mateusz Guzik
11c5495554 ext2: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:57 +00:00
Mateusz Guzik
d37dca9ec9 cxgbe: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 12:45:56 +00:00
Michael Tuexen
a12d89332e sctp: hold the inp lock while calling ip6_output
This fixes an issue with handling IPPROTO_IPV6 level socket
options.

Reported by:	syzbot+66ede232c3d1271c6226@syzkaller.appspotmail.com
MFC after:	3 days
2022-04-19 13:03:08 +02:00
Mateusz Guzik
f2edc91557 uart: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 09:34:55 +00:00
Mateusz Guzik
0fd5c29944 tcp/rack: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-19 09:33:35 +00:00
Alan Somers
3a1b3c6a1e fusefs: correctly handle servers that report too much data written
During a FUSE_WRITE, the kernel requests the server to write a certain
amount of data, and the server responds with the amount that it actually
did write.  It is obviously an error for the server to write more than
it was provided, and we always treated it as such, but there were two
problems:

* If the server responded with a huge amount, greater than INT_MAX, it
  would trigger an integer overflow which would cause a panic.

* When extending the file, we wrongly set the file's size before
  validing the amount written.

PR:		263263
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D34955
2022-04-18 18:59:10 -06:00
John Baldwin
8b83d7e0ee Make -Wunused-but-set-variable a fatal error for clang 13+ for kernel builds.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34949
2022-04-18 16:06:27 -07:00
John Baldwin
615d289ffe Re-enable set but not used warnings for kernel builds.
make tinderbox now passes with this warning enabled as a fatal error,
so revert the change to hide it in preparation for making it fatal.

This reverts commit e8e691983b.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34948
2022-04-18 16:06:14 -07:00
Michael Tuexen
53236f905d if_vtnet: improve dumping a kernel
Disable software LRO during kernel dumping, because having it enabled
requires to be in a network epoch, which might or might not be the
case depending on the code path resulting in the panic.

Reviewed by:		markj
MFC after:		3 days
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D34787
2022-04-19 00:40:31 +02:00
Mark Johnston
081b4452a7 geli: Add a chicken switch for unmapped I/O
We have a report of a panic in GELI that appears to go away when
unmapped I/O is disabled.  Add a tunable to make such investigations
easier in the future.  No functional change intended.

PR:		262894
Reviewed by:	asomers
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34944
2022-04-18 17:55:24 -04:00
John Baldwin
ecbe50447d arm ti_mbox_attach: Write sysconfig to TI_MBOX_SYSCONFIG to request reset.
This variable was flagged as a set but unused warning as its value was
read from a register and then modified to set a bit
(TI_MBOX_SYSCONFIG_SOFTRST).  After the variable is modified, the code
then loops waiting for the SOFTRST bit to go clear in the
TI_MBOX_SYSCONFIG register.  Presumably merely reading from the
register does not request a reset as other places in the driver read
this register, so most likely the updated value of sysconfig setting
the reset bit is supposed to be written to the register to request a
reset before the polling loop that waits for the reset to finish.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34856
2022-04-18 14:09:20 -07:00
Brooks Davis
c2f6aae007 machine/in_cksum.h: don't include sys/cdefs.h
All consumers already do it and it was required on amd64 and i386
until recently (1c1bf5bd7c).

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34932
2022-04-18 21:02:19 +01:00
John Baldwin
43d5661a9d cxgbei: Return limits for the specific adapter the socket is on.
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34929
2022-04-18 12:53:33 -07:00
John Baldwin
7b02c1e8c6 iscsi: Fetch limits based on a socket rather than assuming global limits.
cxgbei needs the ability to return different limits based on the
connection (e.g. if the connection is over a T5 adapter or a T6
adapter as well as factoring in the MTU).

This change plumbs through the changes in the ioctls without changing
any of the backends.  The limits callback passed to icl_register now
accepts a second socket argument which holds the integer file
descriptor.  To support ABI compatiblity for old binaries, the
callback should return "global" values if the socket fd is zero.

The CTL_ISCSI_LIMITS argument used with CTL_ISCSI by ctld(8) now
accepts the socket fd in a field that was previously part of a
reserved spare field.  Old binaries zero this request which results in
passing a socket fd of 0 to the limits callback.

The ISCSIDREQUEST ioctl no longer returns limits.  Instead, iscsid(8)
invokes a new ISCSIDLIMITS ioctl after establishing the connection via
connect(2).  For ABI compat, if the old ISCSIDREQUEST is invoked, the
global limits are still fetched (with a socket fd of 0) and returned.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34928
2022-04-18 12:53:28 -07:00
John Baldwin
e2c5ab094b linuxkpi_ieee80211_tx_status: Mark ridx as unused.
__diagused only squelches warnings for variables used under
INVARIANTS, it does not apply to custom debug knobs like
LINUXKPI_DEBUG_80211.  Use __unused instead.
2022-04-18 12:29:47 -07:00
John Baldwin
dca7f69632 as3722_gpio_pin_setflags: Use computed mode instead of hardcoded PUSHPULL.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34855
2022-04-18 12:28:48 -07:00
John Baldwin
bc734377d9 qoriq_gpio_pin_setflags: Propagate error from qoriq_gpio_pin_configure.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34854
2022-04-18 12:28:09 -07:00
John Baldwin
540ac338d5 uhid_snes: Remove USB_ST_TRANSFERRED handling for the status request.
The result of the request computed in new_status was never returned to
the caller leaving new_status as a set-but-unused variable.  Removing
new_status leaves sc->previous_status as a write-only variable.
Removing sc->previous_status leaves current_status as a write-only
variable, so it collapses down to removing the entire
USB_ST_TRANSFERRED case.

Arguably, all of the support for UHID_SNES_STATUS_DT_RD should be
removed as it doesn't return anything to the caller.  If the request
should be fixed instead then this commit should be reverted and
new_status should be returned to whoever submitted the request.

Differential Revision:	https://reviews.freebsd.org/D34840
2022-04-18 12:27:48 -07:00
John Baldwin
7c1ff7146b powerpc cpu_idle_60x: Move some variables fully under #ifdef AIM.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34905
2022-04-18 12:08:35 -07:00
John Baldwin
ff1de4e02e powerpc booke cpu_machine_check: Remove unused variable.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34902
2022-04-18 12:08:10 -07:00
John Baldwin
6f568b14cb powerpc cpu_idle_booke: Move read of mfmsr under #ifdef BOOKE_E500.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34891
2022-04-18 12:07:34 -07:00
John Baldwin
d5472cd4b3 ata_kauai: Fix support for "shasta" controllers.
The probe routine was setting a value in the softc, but since the
probe routine was not returning zero, this value was lost since the
softc was reallocated (and re-zeroed) when the device was attached.
This is similar in nature to the fixes from
965205eb66.

To fix, move the code to set the 'shasta' flag to the start of attach
along with related code to set an IRQ resource on some non-shasta
devices.  The IRQ resource still "worked" being in the probe routine
as the IRQ resource persisted after probe returned, but it is cleaner
to go ahead and move it to attach after setting the 'shasta' flag.

I have no way to test this, but noticed this while reading the code.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34888
2022-04-18 12:06:52 -07:00
John Baldwin
52526922ac vm_phys_init: Quiet unused but set warnings about npages.
npages is used in two optional cases:

- to conditionally create a separate DMA32 free list

- to index vm_page_array for VM_PHYSSEG_SPARSE

Add in more #ifdef's around npages statements.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D34887
2022-04-18 12:06:14 -07:00
John Baldwin
d139909d6e destroy_dev_sched*: Don't hold Giant for all deferred destroy_dev.
Rather than using taskqueue_swi_giant which holds Giant for all
deferred destroy_dev calls, create a separate queue for destroyed
devices with D_NEEDGIANT set in the corresponding cdevsw.  The task
for this queue holds Giant whild destroying deferred devices while the
task for the default queue does not hold Giant.

In addition, switch to taskqueue_thread for destroy_dev_sched.
Deferred destroy_dev requests don't need to run at an SWI priority.

Reviewed by:	imp, markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34915
2022-04-18 12:04:30 -07:00
Michael Tuexen
bbf3bf3211 sctp: cleanup
MFC after:	3 days
2022-04-16 21:03:16 +02:00
Michael Tuexen
5fbf11f703 sctp: fix typo introcuded in last commit
MFC after:	3 days
2022-04-16 19:55:33 +02:00
Michael Tuexen
3dc57df91e sctp: don't wakeup 1-to-1 listening sockets for data or notifications
Reported by:	syzbot+ec9279d306a4ff0215f8@syzkaller.appspotmail.com
Reported by:	syzbot+31d54f6d486333493dd4@syzkaller.appspotmail.com
MFC after:	3 days
2022-04-16 19:42:27 +02:00
Rick Macklem
32c3e0f049 nfscl: Clean up the code by removing unused arguments
The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
local to nfs_clrpcops.c.
Future commits will do the same for other functions.
2022-04-15 18:51:01 -07:00
Warner Losh
0fd4cd405b nvme: Use controller's page size instead of PAGE_SIZE to create qpair
When constructing qpair, use the controller's notion of page size rather
than the host's PAGE_SIZE. Currently, these are both 4k, but the arm 16k
page size support requires decoupling.

There's a "hidden" PAGE_SIZE in btoc, so we must change btoc(x) to
howmany(x, ctrlr->page_size) to properly count the number of pages (in
the drive's world view) are needed for various calculations.

With these changes, we the nvme driver operates at production level load
for both host 4k and host 16k page size.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D34873
2022-04-15 14:46:19 -06:00
Warner Losh
c5ed67dc90 nvme: Prefer nvme_printf to printf when reporting formatting error
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D34872
2022-04-15 14:46:19 -06:00
Warner Losh
3740a8db13 nvme: Further refinements in Host Memory Buffer Sizing
Host Memory Buffer units are a mix. For those in the identify structure,
the size is in 4kiB chunks. For specifying the buffer description,
though, they are in terms of the drive's MPS. Add comments to this
effect and change PAGE_SIZE to ctrlr->page_size where needed, as well as
correct a mistaken use of NVME_HPS_UNITS in 214df80a9c as pointed out
by rpokala@ after the commit. No functional change is intended, as
page_size is still 4k which matches all current hosts' PAGE_SIZE, but to
support 16k pages on arm, we need to differentiate these two cases.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D34871
2022-04-15 14:46:19 -06:00
Warner Losh
3086efe895 nvme: Remove NVME_MAX_XFER_SIZE, replace inline calculation
NVME_MAX_XFER_SIZE used to be a constant (back when MAXPHYS was a
constant) to denote the smaller of MAXPHYS or the largest PRP we could
encode with our prealloation scheme. However, it's no longer constant
since MAXPHYS varies at runtime. In addition, the actual maximum is now
based on the drive's currently in use page_size, which is also a runtime
expression. As such, remove the define and expand it inline in the one
place its used still in the tree.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D34870
2022-04-15 14:46:18 -06:00
Warner Losh
3a468f2010 nvme: Use saved mps when initializing drive
Make sure we set the MPS we cached (currently the drives minimum mps) in
CC (Controller Configuration) when reinitializing the drive. It must
match the page_size that we're going to use. Also retire less specific
NVME_PAGE_SHIFT since it's now unused.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D34869
2022-04-15 14:46:18 -06:00
Warner Losh
55412ef90a nvme: Rename min_page_size to page_size and save mps
The Memory Page Size sets the basic unit of operation for the drive. We
currently set this to the drive's minimum page size, but we could set it
to any page size the drive supports in the future. Replace min_page_size
(it's now unused for that purpose) with page_size to reflect this and
cache the MPS we want to use. Use NVME_MPS_SHIFT to compute page_size.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D34868
2022-04-15 14:46:18 -06:00
Warner Losh
6e3deec8ca nvme: Base maximum data transfer size directly on MPSMIN in cap_hi
Calculate the maxmimum transfer size based on the MPSMIN we have in our
cached copy of cap_hi rather than using min_page_size in the controller.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D34867
2022-04-15 14:46:18 -06:00
Warner Losh
a7218e7a6b nvme: Fix old intel alignment size
The intel raid stripe alignment parameter is based on CAP.MPSMIN, so use
that directly now that we have it available.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D34866
2022-04-15 14:46:18 -06:00
Warner Losh
e66c1b5185 nvme: Define NVME_MPS_SHIFT
The memory page size (MPS) is expressed in terms of a 2^(number + 12)
and other items in the system inherit this. Create a define rather than
sprinkling 12 everywehere.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D34865
2022-04-15 14:46:18 -06:00
Jung-uk Kim
11d64c1d53 acpica: Drop a local patch in favor of an upstream patch
Use ACPI_ERROR() instead of fprintf().

https://github.com/acpica/acpica/pull/768
2022-04-15 16:29:09 -04:00
Alan Somers
155ac516c6 fusefs: validate servers' error values
Formerly fusefs would pass up the stack any error value returned by the
fuse server.  However, some values aren't valid for userland, but have
special meanings within the kernel.  One of these, EJUSTRETURN, could
cause a kernel page fault if the server returned it in response to
FUSE_LOOKUP.  Fix by validating all errors returned by the server.

Also, fix a data lifetime bug in the FUSE_DESTROY test.

PR:		263220
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	3 weeks
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D34931
2022-04-15 13:57:32 -06:00
Bjoern A. Zeeb
d9945d7821 LinuxKPI: 802.11: improve hw_scan
Initially we were using the IEs from ieee80211_probereq_ie() of net80211
and put them into the common_ies field.  Start by manually building the
per-band and common IE parts as drivers put them back together.
This also involves allocating the req.ie as one buffer for all IEs over
all bands and setting req.ie_len correctly based on how many bytes we
put in.

Manually building per-band scan IEs we still use the net80211 routines
to add IEs to the buffer (mostly).

This is needed by Realtek drivers but will equally used by others.
Realtek would simply panic due to skbs being allocated with the wrong
length.

Longer-term this will help us, e.g., when not supporting VHT on 2Ghz
and we would have to do this anyway.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-15 15:54:03 +00:00
Bjoern A. Zeeb
8891c45563 LinuxKPI: 802.11: use an sx lock to protect the list of vifs
Use an sx lock to protect the list of vifs.  We could use the
linux mutex compat for this but our current implementation may
re-acquire the lock recursively so allow this.  The change is
mainly motivated by the fact that some callers may sleep in the
interator function called.  Recursiveness is needed because we
see find_sta_by_ifaddr() being called from an iterator function
from iterate_interfaces().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-15 15:54:03 +00:00
Bjoern A. Zeeb
383b3e8f50 LinuxKPI: 802.11: start adding rate control to ieee80211_tx_status()
Start adding rate control feedback in ieee80211_tx_status() in order
for net80211 to be able to report something back (which may not
yet be the view of the firmware).  iwlwifi is reporting back an MSC 0
even with HT disabled (to be investigated) so we cannot (yet) use
the firmware/driver rate feedback directly.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-15 15:54:03 +00:00
Bjoern A. Zeeb
ade774b19f LinuxKPI: 802.11: implement ieee80211_probereq_get()
Implement ieee80211_probereq_get() needed by Realtek drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-15 15:54:03 +00:00
Bjoern A. Zeeb
349b042b90 LinuxKPI: skbuff: start implementing skb_copy()
Implement skb_copy() with omissions of fragments and possibly other fields
for now.  Should we hit frags at any point a log message will let us know.
For the few cases we need this currently this is enough.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-15 15:54:03 +00:00
Bjoern A. Zeeb
952643ea45 LinuxKPI: skbuff: dev_kfree_skb_irq() and improvements
While it is currently unclear if we will have to defer work in
dev_kfree_skb_irq() to call dev_kfree_skb().
We only have one caller which seems to be fine on FreeBSD by calling
it directly for now.

While here shortcut skb_put()/skb_put_data() saving us work if there
are no adjustments to do.
Also adjust the logging in skb_is_gso() to avoid getting spammed by it.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-04-15 15:54:03 +00:00
Mitchell Horne
0a90043e63 Remove 12.x ABI compat for kernel dump ioctls
This code was marked gone_in(14), so it can now be removed.

The only consumer of this interface is dumpon(8). We do not maintain
strict backwards compatibility for this utility because a) it
can't/shouldn't be used from a jail or chroot and b) it is highly
specific interface unique to FreeBSD. The host's (presumably more
up-to-date) copy of dumpon(8) should be used to configure kernel dump
devices.

Reviewed by:	markj, emaste
MFC after:	never
Differential Revision:	https://reviews.freebsd.org/D34914
2022-04-15 12:06:05 -03:00
Mitchell Horne
9c90bfcd31 Remove 11.x ABI compat for kernel dump ioctls
This code was marked gone_in(13), so its time has passed.

The only consumer of this interface is dumpon(8). We do not maintain
strict backwards compatibility for this utility because a) it
can't/shouldn't be used from a jail or chroot and b) it is highly
specific interface unique to FreeBSD. The host's (presumably more
up-to-date) copy of dumpon(8) should be used to configure kernel dump
devices.

Reviewed by:	markj, emaste
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D34913
2022-04-15 12:06:04 -03:00
Konstantin Belousov
362ff9867e Revert rest of a5970a529c: use vrefact() when working on fp->f_vnode
Now, since O_PATH-opened file descriptors use use references instead
of the hold references, vrefact() chahges from that revision can be
reverted.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34906
2022-04-15 16:56:20 +03:00
Michael Tuexen
eeba222172 sctp: don't keep a pointer to a freed stcb around
Reported by:	syzbot+b9ef06efdae7cb9ee414@syzkaller.appspotmail.com
Reported by:	syzbot+b1e4793e0e6b25b0d510@syzkaller.appspotmail.com
MFC after:	3 days
2022-04-15 14:00:00 +02:00
Michael Tuexen
e0127ea4c6 sctp: improve locking
Hold a refcount while giving up an stcp lock. This issue was
found by running syzkaller.

MFC after:	3 days
2022-04-15 13:58:45 +02:00
Rick Macklem
068fc05745 nfscl: Clean up the code by removing unused arguments
The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for nfscl_nget().
Future commits will do the same for other functions.
2022-04-14 16:15:56 -07:00
Navdeep Parhar
db28d4a0cd cxgbe/t4_tom: Support for round-robin selection of offload queues.
A COP (Connection Offload Policy) rule can now specify that the tx
and/or rx queue for a new tid should be selected in a round-robin
manner. There is no change in default behavior.

Reviewed by:	jhb@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34921
2022-04-14 15:49:58 -07:00
Navdeep Parhar
169e94c41e cxgbe(4): Add support for PPOD_EDRAM feature.
The driver queries the firmware to find out if it supports this feature
and enables it if it does. The firmware moves the iSCSI page pod region
to a lower address so that some of it is located in the faster on-chip
memory instead of external DDR.

Reviewed by:	jhb@
MFC after:	3 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34895
2022-04-14 15:43:32 -07:00
Randall Stewart
6edfc10ca5 tcp: adding a functionality to define "trace points" so that BB logging can be enabled at specific events.
This commit will add a new concept to rack, tracepoints. A tracepoint
is a defined point inserted into the code (3 are included in this initial patch) that
allows a developer to insert a point that might be of interest. The developer numbers
the point in the tcp_rack.h file and then can use sysctl to enable that (or all) trace
points. A limit is also given to how many BB logged connections will turn on
so that a box is not overrun by BB logging.

Reviewed by: tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D34898
2022-04-14 16:07:34 -04:00
Randall Stewart
6e6439b238 tcp - hpts timing is off when we are above 1200 connections.
HPTS timing begins to go off when we reach the threshold of connections (1200 by default)
where we have any returning syscall or LRO stop finding the oldest hpts thread that
has not run but instead using the CPU it is on. This ends up causing quite a lot of times
where hpts threads may not run for extended periods of time. On top of all that which
causes heartburn if you are pacing in tcp, you also have the fact that where AMD's
podded L3 cache may have sets of 8 CPU's that share a L3, hpts is unaware of this
and thus on amd you can generate a lot of cache misses.

So to fix this we will get rid of the CPU mode, and always use oldest. But also make
HPTS aware of the CPU topology and keep the "oldest" to be within the same L3 cache.
This also works nicely for NUMA as well couple with Drew's earlier NUMA changes.

Reviewed by: glebius, gallatin, tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D34916
2022-04-14 16:04:08 -04:00
Michael Tuexen
2486a7c0c7 sctp: cleanup
MFC after:	3 days
2022-04-14 21:52:25 +02:00
Mark Johnston
f82177b8cf vm: Initialize the transient buffer mapping arena with M_WAITOK
The wait flag is passed to UMA when allocating boundary tags for the
initial span, and UMA expects either M_WAITOK or M_NOWAIT to be present.

Reported by:	cperciva
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-04-14 15:46:14 -04:00
Mark Johnston
6fb7c42d59 vm: Move the "vm_wait in early boot" assertion to the proper place
The assertion was added in commit 1771e987ca.  After that, vm_wait()
and friends were refactored such that the actual sleep happens
elsewhere.  Now the assertion condition is not checked when
vm_wait_doms() is called directly, and it is checked even if we are not
going to sleep (because vm_page_count_min_set(wdoms) is false).

Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34909
2022-04-14 15:45:54 -04:00
Ed Maste
f99cc5a389 sysent: regen after 52a1d90c8b, posix_fadvise in capmode 2022-04-14 15:17:36 -04:00
Ed Maste
52a1d90c8b Allow posix_fadvise in capability mode
posix_fadvise operates only on a provided fd.  Noted by
Mathieu <sigsys@gmail.com> in review D34761.

No new CAP_ rights are added for posix_fadvise(), as 'advice' in
general only influences when I/O happens; the fd must have existing
CAP_ rights for actual data access.

Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34903
2022-04-14 15:11:21 -04:00
Mike Karels
8f45652b6b genet: fix problems with interface down/up
The genet interface did not resume operation correctly after doing
ifconfig down then up.  The down/reset procedure did not clear the
RUNNING flag, and did not reset enough of the hardware state.  This
patch is modeled on OpenBSD code, with a call to gen_reset added
to reset the controller completely.  Regularize the parameter to
gen_dma_disable() while here.

PR:             263091
Submitted by:	jiahali@blackberry.com
2022-04-14 14:10:13 -05:00
Navdeep Parhar
239170f292 cxgbe(4): Fix control flow issues reported by Coverity.
CID 1487932:  Control flow issues  (NESTING_INDENT_MISMATCH).
The macro on this line expands into multiple statements, only the first
of which is nested within the preceding parent while the rest are not.
9828                    ulp_region(RX_TLS_KEY);

Reported by:	Coverity (CID 1487932)
Fixes:	f88b31885c cxgbe(4): meminfo should get the TLS region's limits from the hardware.
MFC after:	3 days
Sponsored by:	Chelsio Communications
2022-04-14 00:17:36 -07:00
Gordon Bergling
7fa5cd3827 Revert "drm2: Fix a typo in a source code comment"
This reverts commit 5158cf0a38.
2022-04-14 09:01:29 +02:00
Konstantin Belousov
bf13db086b Mostly revert a5970a529c: Make files opened with O_PATH to not block non-forced unmount
Problem is that open(O_PATH) on nullfs -o nocache is broken then,
because there is no reference on the vnode after the open syscall exits.

Reported and tested by:	ambrisko
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-04-14 02:47:04 +03:00
John Baldwin
a30eb84a5d powerpc mpc85xx: Remove unused variables. 2022-04-13 16:08:24 -07:00
John Baldwin
1c311640c0 powerpc: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin
dd636cb9d0 ad7417: Avoid an unused but set warning when compiled with NO_SYSCTL_DESCR.
Use a ternary operator for the description string passed to
SYSCTL_ADD_PROC instead of a helper variable.
2022-04-13 16:08:23 -07:00
John Baldwin
2257e87203 dpaa: Remove unused variables. 2022-04-13 16:08:23 -07:00
John Baldwin
39f7de587b divert_packet: ip is only used for SCTP. 2022-04-13 16:08:23 -07:00
John Baldwin
fe5324aca0 in_pcballoc: error is only used for IPSEC or MAC. 2022-04-13 16:08:23 -07:00
John Baldwin
36fb372264 kern: Move variables only used for MAC under #ifdef MAC. 2022-04-13 16:08:23 -07:00
John Baldwin
a56881d3e9 riscv: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin
695d3e52ea xdma: Inline variables with simple values used once in a KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin
d586fc165c i386 getmemsize: Use __diagused for a variable only used in KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin
8bf0d2d3e3 arm64 rk_pcie: Use __diagused for a variable only used in KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin
216536350a vnic: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin
4aec198420 sched_ule: Inline value of ts in sched_thread_priority.
This avoids a set but unused warning in kernels without SMP where
TDQ_CPU() doesn't use its argument.
2022-04-13 16:08:23 -07:00
John Baldwin
718fe5ddfa ata-fsl: Remove unused variable. 2022-04-13 16:08:23 -07:00
John Baldwin
43629a8b18 arm freescale: Remove unused variables. 2022-04-13 16:08:22 -07:00
John Baldwin
9ad5422f27 arm sp804: Remove unused variables. 2022-04-13 16:08:22 -07:00
John Baldwin
09f2892eee arm vybrid: #if 0 variables only used under #if 0. 2022-04-13 16:08:22 -07:00
John Baldwin
42278fc2e6 drm2: Remove unused variables. 2022-04-13 16:08:22 -07:00
John Baldwin
fcd0ea3a38 if_mvneta: Use __diagused for a variable only used in KASSERT(). 2022-04-13 16:08:22 -07:00
John Baldwin
e6fd5ca545 xdma pl330: Remove unused variables. 2022-04-13 16:08:22 -07:00
John Baldwin
0a4089c734 gpio tca6416: Remove unused variable. 2022-04-13 16:08:22 -07:00
John Baldwin
ead64e8454 flash: Remove unused variables. 2022-04-13 16:08:22 -07:00
John Baldwin
e19883539a hwpmc: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:22 -07:00
John Baldwin
34dae08e6c linuxkpi: Use an inline function for the _ioremap_attr stub.
This "consumes" variables passed to ioremap*() avoiding set but unused
warnings.
2022-04-13 16:08:22 -07:00
John Baldwin
69c595ed7f arm: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:22 -07:00
John Baldwin
e4746e3fe4 bcm2835_systimer: Remove unused variable. 2022-04-13 16:08:22 -07:00
John Baldwin
8758ac757f sched_4bsd: ts is only used in sched_bind for SMP. 2022-04-13 16:08:22 -07:00
John Baldwin
d101d57321 arm dbg: Use PCPU_GET(cpuid) directly in assertions. 2022-04-13 16:08:21 -07:00
John Baldwin
4046178557 ipsec_encap: setdf is only used for INET. 2022-04-13 16:08:21 -07:00
John Baldwin
f328c46fdd TCP sysctl handlers: fin and lin are only used for INET. 2022-04-13 16:08:21 -07:00
John Baldwin
700a395c58 tcp_log_vain/addrs: Use a const pointer for the IPv4 header.
The pointer to the IPv6 header was already const.
2022-04-13 16:08:21 -07:00
John Baldwin
13ec6858d6 tcp_log_addr: ip is only used for INET. 2022-04-13 16:08:21 -07:00
John Baldwin
3320ca1205 ipfw: icmp6_type is only used for INET6. 2022-04-13 16:08:21 -07:00
John Baldwin
75095cd38f mlx5: fs_tcp is only used for INET or INET6. 2022-04-13 16:08:21 -07:00
John Baldwin
29a843177e sctp: #ifdef INET-only and INET6-only variables.
Duplicating the SCTP_PCB_FLAGS_BOUND_V6 check made the #ifdef's
simpler than applying #ifdef's directly to the original code.  Modern
compilers should cache the result rather than testing the flag twice.
2022-04-13 16:08:21 -07:00
John Baldwin
ac3e46fa3e infiniband_resolve_addr: ih is only used for INET or INET6. 2022-04-13 16:08:21 -07:00