Commit graph

43535 commits

Author SHA1 Message Date
Warner Losh
dea3eef94c uart: Ingore pl011 historic mistakes
Some veresions of EDK-II and QEMU reported the wrong values for the
register shift and the region I/O size. Detect those and set it to the
correct values. In general, anything other than a shift of 2 and a
regio width of 4 (bytes, or 32 bits) is a mistake. However, allow
for overrides in the future by only overriding the buggy values.
Otherwise, we will fail to boot.

PR:			282936
Sponsored by:		Netflix
Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D47946
2025-01-14 19:24:35 -07:00
John Baldwin
c2cd12b7ae cxgbe tom: Make t4_push_frames static to t4_cpl_io.c
This function is not used outside of this file.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D47760
2025-01-14 10:34:45 -05:00
Adrian Chadd
8896f36587 rtwn: allow firmware rate control to be enabled for rtl8192cu
Although there's no RTS/CTS rate control available yet, the support
is enough to enable firmware rate control for experimenting.

This won't be enabled by default - users will need to set a tunable
before loading the driver (eg kenv dev.rtwn.0.ratectl=2) but it is
enough for experimentation, feedback and continued work.

Locally tested:

* RTL8192CU, STA mode

Differential Revision:	https://reviews.freebsd.org/D48143
Reviewed by:	bz, emaste
2025-01-13 20:34:35 -08:00
Adrian Chadd
ce7fca1928 rtwn: refactor out the r92c path protection decision / configuration
* refactor out the r92c path protection (RTS/CTS) decision
* handle firmware rate control being enabled - if DRVRATE isn't
  set then the RTSRATE field is ignored and instead RRSR/INIRTS
  registers are used (and the firmware/hardware will do RTS
  rate adaptation / retry.)
* when making protection decisions with firmware rate control,
  default to the channel mode rather than rate index.

This works on RTL8192CU both with firmware rate control and driver
rate control.

Locally tested:

* RTL8192CU, STA - firmware and net80211 rate control

Differential Revision:	https://reviews.freebsd.org/D48142
2025-01-13 20:34:14 -08:00
Adrian Chadd
ea347b7fda rtwn: refactor out datarate and short preamble setup
Refactor out the datarate setup and short preamble setup.
These will eventually be slightly different based on whether
firmware rate control is being performed or not.

Locally tested:

* RTL8192CU, STA mode

Differential Revision:	https://reviews.freebsd.org/D48141
2025-01-13 20:33:56 -08:00
Adrian Chadd
f45f66fada rtwn: explicitly configure RTS based on basic rates
The NIC/firmware initialises the initial RTS/CTS rate to something
high, like OFDM48.  That's not going to be very reliable.

It's not a problem right now as we program in the RTS/CTS value
to use in the TX descriptor setup path based on the control rate
for the given frame TX rate, and like the INIDATA/driver rate
stuff in the TX descriptor, the TX descriptor RTS/CTS rate overrides
the INIRTS rate.

However when it's time to flip on firmware based rate control,
the initial rate needs to not be OFDM48.  Yes, the firmware and
hardware does have some rate retry schedule for RTS/CTS frames,
but there's no point in wasting short retries trying to do OFDM48
based RTS/CTS setup.

Add some warning logging if there are no basic or RTS/CTS rates
available, and leave things at default.  If this happens in
production for someone then it would be good to know and what
the rate mask was.

Locally tested:

* RTL8192CU, STA mode (with/without firmware rate control enabled locally)

Differential Revision:	https://reviews.freebsd.org/D48140
2025-01-13 20:33:44 -08:00
Adrian Chadd
f167ba7357 rtwn: fix RTWN_RIDX_VHT_MCS() macro
Add parenthesis as appropriate.  Oops!
2025-01-13 16:11:18 -08:00
John Baldwin
6751f65e6a nvmf: Defer the post-sync shutdown handler to SHUTDOWN_PRI_LAST
nda(4) has its own shutdown handler that runs at SHUTDOWN_PRI_DEFAULT
that calls ndaflush() that could run after the nvmf handler.  Instead,
give a the flush a chance to run before the graceful shutdown of the
controller.

While here, be a bit more defensive in the post-sync case and shutdown
the consumers (sim and /dev/nvmeXnY devices) before destroying the
queue pairs so that if any requests are submitted after the post-sync
handler they fail gracefully instead of trying to use a destroyed
queue pair.

Reported by:	Sony Arpita Das <sonyarpitad@chelsio.com>
Sponsored by:	Chelsio Communications
2025-01-13 15:04:29 -05:00
Kyle Evans
b769044f30 nvmf: fix build with __assert_unreachable() addition to userland
<assert.h> now has a usable definition, so we don't need to shim it out
in the nvmf header anymore.

Reviewed by:	emaste, jhb
Differential Revision:	https://reviews.freebsd.org/D48078
2025-01-12 18:41:37 -06:00
Simon Wells
a9a71513cc amdsmn(4), amdtemp(4): add support for Zen 5
Zen 5 support, tested on Ryzen 7 9700X

PR:	284010
MFC after:	1 week
2025-01-12 14:14:01 +02:00
Simon Wells
7aa6eeb220 amdsmn(4), amdtemp(4): add support for AMD Ryzen 7 "Cezanne" cpus
Tested on AMD 5700G

PR:	284009
MFC after:	1 week
2025-01-12 14:14:01 +02:00
Mitchell Horne
def7999c2c riscv: enable cpufreq_dt driver
Implement the small amount of MD code required; copied from arm/arm64.

One tweak is made to cpufreq_dt itself: if the opp-shared property is
missing, but there is only one CPU, then we can still attach. This is
relevant for the single-core Allwinner D1.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48124
2025-01-10 15:16:06 -04:00
Mitchell Horne
ac9de183f3 ofw_cpu: check for "disabled" status during probe
Some RISC-V CPUs contain a "monitor core" with limited functionality (no
MMU). These cores appear in some device trees, but we don't run the
kernel on them; in early CPU start-up code we skip them, and they have
no impact on mp_ncpu. It seems the new trend is to mark these monitor
cores with a 'status' property of 'disabled'.

However, we still instantiate an ofw_cpu pseudo device for the disabled
core. This is generally harmless, but there is an impact when attempting
to attach the cpufreq_dt driver. It counts more OFW CPU devices (unit
number) than logical CPUs (mp_ncpus), and therefore fails to attach for
the last logical CPU.

The solution is to check the status property in ofw_cpu_probe(), and
fail if the core is marked "disabled". This is subject to the same
exception already in ofw_cpu_early_foreach(); that is, if a disabled CPU
has an 'enable-method' property, it can be used by the kernel.

Reviewed by:	andrew, jrtc27
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48123
2025-01-10 14:59:08 -04:00
Mitchell Horne
4ea0c3f04f ofw_cpu: collapse some #ifdef code
Mainly, to avoid repeating the list of architectures, #define HAS_CLK.

Further, split the clk code into a helper function, which is a stub in
the !HAS_CLK case. This aids in overall legibility.

While here, add one separating whitespace, again for legibility.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48149
2025-01-10 14:55:03 -04:00
Mitchell Horne
aa766e2a03 ofw_cpu: fix __riscv preprocessor check
The canonical name is __riscv, not __riscv__. Newer compilers no longer
emit the latter.

This re-enables finding the nominal frequency from the CPU's clock.

I checked, and there are no remaining mistakes like this in the tree.

Reviewed by:	jrtc27, imp, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48122
2025-01-10 14:46:01 -04:00
Mitchell Horne
9eb30ef4b7 riscv: enable Allwinner D1 USB drivers
Add the generic USB drivers and FDT glue to the build.

Make small tweaks to the aw_usbphy and aw_musb drivers for the Allwinner
D1.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48126
2025-01-10 13:57:36 -04:00
Doug Ambrisko
0acab8b3d1 enic(4): fix down/up, MTU changes and more
ifconfig down/up cycles was not working.  Fix that which is required
to support MTU changes.  Now doing ifconfig enic0 mtu 3000 for example
works.  If the MTU is changes in the VIC HW configuration, that is not
reflected in and the OS reports the default 1500.  I need to look at
that but changing it via ifconfig works.  So this is different then
what Linux does.

Change TX interrupt allocation to be in this driver.  Change the admin
interrupt count to 2.  This make multiple queues work but need to be
done as pairs so if the VIC has more TX or RX queues setup in the
VIC configuration it will use the lesser value.

While updating the TX interrupt also add support for devcmd2.

Enable checksum offloading.

PR:	282095
2025-01-09 08:52:54 -08:00
Mark Johnston
4a46ece6c6 vmm: Fix error handling in vmm_handler()
In commit a97f683fe3 I didn't add code to remove the vmmctl device
when vmm.ko is unloaded, so it would persist and prevent vmm.ko from
being re-loaded.

Extend vmmdev_cleanup() to destroy the vmmctl cdev.  Also call
vmmdev_cleanup() if vmm_init() fails.

Reviewed by:	corvink, andrew
Fixes:		a97f683fe3 ("vmm: Add a device file interface for creating and destroying VMs")
Differential Revision:	https://reviews.freebsd.org/D48269
2025-01-09 14:49:34 +00:00
Adrian Chadd
ec07af2a3d rtwn: announce VHT support for RTL8812AU/RTL8821AU.
Although the transmit path doesn't yet support VHT rates (because
the rate control and rate representation in net80211 doesn't yet
know about VHT rates) the NIC will receive VHT frames but only
transmit HT frames.

Locally tested:

* RTL8812AU, STA mode

Differential Revision:	https://reviews.freebsd.org/D48103
2025-01-08 16:52:12 -08:00
Adrian Chadd
82182587bc rtwn: add VHT20/VHT40/VHT80 bandwidth configuration for transmit.
Add a separate function and path for VHT 20/40/80MHz bandwidth
transmission.

Differential Revision:	https://reviews.freebsd.org/D48102
2025-01-08 16:52:00 -08:00
Alexander Motin
2c48a8f161 isp: Fix abort issue introduced by previous commit
Aborting ATIO while its CTIOs are in progress makes impossible to
handle their completions, making them stuck forever.  Detect this
case by checking ctcnt counter and if so instead of aborting just
mark the ATIO as dead to block any new CTIOs.  It is not perfect
since the task id can not be reused for some more time, but not
as bad as the task stuck forever.

MFC after:	1 week
2025-01-08 13:23:26 -05:00
Alexander Motin
e6c96c7af7 Revert "isp: Fix abort issue introduced by previous commit"
This reverts commit 1f7c379c07.

Leaked unintended changes.  I'm sorry.
2025-01-08 13:20:09 -05:00
Alexander Motin
1f7c379c07 isp: Fix abort issue introduced by previous commit
Aborting ATIO while its CTIOs are in progress makes impossible to
handle their completions, making them stuck forever.  Detect this
case by checking ctcnt counter and if so instead of aborting just
mark the ATIO as dead to block any new CTIOs.  It is not perfect
since the task id can not be reused for some more time, but not
as bad as the task stuck forever.

MFC after:	1 week
2025-01-08 13:04:34 -05:00
Adrian Chadd
dd58d03a2a rtwn: set the maximum A-MPDU size correctly for RTL8812AU/RTL8821AU
The vendor driver sets it to 64k or 128k depending upon chipset,
along with bit 31 being set in hal/rtl8812a_hal_init.c:SetHwReg8812A().

Differential Revision:	 https://reviews.freebsd.org/D48118
Obtained from:	https://github.com/lwfinger/rtl8812au
Reviewed by:	bz
2025-01-07 18:32:56 -08:00
Adrian Chadd
d82bfe73a3 rtwn: don't set the RTS/CTS primary channel field for RTL8812AU/RTL8821AU
According to the rtl8812au reference driver, this seems to control
the bandwidth used by lower-bandwidth frames when transmitted in
a higher bandwidth channel.  For example, transmitting a 20MHz frame
on an 80MHz channel (eg in hostap mode) is doable, but you may want
to at least duplicate the RTS/CTS exchange across all four 20MHz
subchannels, AND perhaps duplicate the 20MHz frame.

I haven't fired this up with a spectrum analyser to see what the
result is.

The vendor driver doesn't bother with this and it doesn't change
performance.  My guess is that for modes like AP mode we MAY wantto
be able to control the RTS/CTS bandwidth choices rather than letting
the firmare do it, but we're not there yet.

The rtl8812au code in hal/rtl8812a_xmit.c:SCMapping_8812() has
the gory details, but then the one place it's used just has it
commented out and 0 (ie "do not care") is always programmed in.

Differential Revision:	https://reviews.freebsd.org/D48113
Obtained from:	https://github.com/lwfinger/rtl8812au
Reviewed by:	bz
2025-01-07 18:32:42 -08:00
Konstantin Belousov
6ba2c036a0 pci_find_cap_method(): limit number of iterations for finding a capability
Powered down device might return 0xff of extended config registers
reads, causing loop.

PR:	283815
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D48348
2025-01-07 17:34:59 +02:00
Ariel Ehrenberg
080f68d0ab mlx5_core: Add steering support for IPsec with IPv6
ipv6 flow tables were not connected to previous FS tables.
Created an additional table to serve as IPsec RX root.
This table has 2 rules for redirecting the received packets
to ipv4/ipv6 based on the IP family in the packet header.

Sponsored by:	   NVidia networking
2025-01-07 02:53:37 +02:00
Adrian Chadd
93411b39ff rtwn: calculate control rate for VHT rate frames
If the passed in rate is a VHT rate, use rtwn_ctl_vhtrate() to
find a suitable rate for RTS/CTS.

Differential Revision:	 https://reviews.freebsd.org/D48295
Reviewed by:	bz, cy, emaste
2025-01-05 09:21:53 -08:00
Daniel Schaefer
48b9d78a0a hda: Add patch for Framework Laptop Intel 13th gen
It uses the same audio codec as 12th gen (PCI ID 0x0002).
Actually everything is the same, except the CPU.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
2025-01-05 08:23:04 -05:00
Andrew Turner
b714eacb79 acpi: Pass the correct device to acpi_pcib_osc
Fix a copy-and-paste error in acpi_pcib_request_feature where the
child device was passed into acpi_pcib_osc rather than the pcib
device.

Reviewed by:	garga, jhb
Fixes:	ba1904937d ("acpica: Extract _OSC parsing to a common file")
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48285
2025-01-03 16:10:41 +00:00
Andrew Turner
143dff0f9c pci: Only claim to support PCI ASPM on x86
We claim to support Active State Power Management, but don't appear to
do anything different in the kernel when it's enabled other than tell
the firmware we do.

This breaks VMware Fusion on Apple Silicon when it's enabled as it
expects the kernel to enable the ports. As it is reported to be needed
on some x86 servers keep it enabled there, but disable on non-x86
architectures.

Reported by:	kp, tuexen
Reviewed by:	tuexen, mav, imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48303
2025-01-03 16:10:41 +00:00
Adrian Chadd
64ecfc27db rtwn: add forcerate flag to TX descriptor setup
When doing firmware rate control there will be situations where
the rate being passed in needs to actually override the rate
control selection.  So add a flag to the descriptor setup path
to indicate that indeed this particular rate should be forced,
rather than rely on the firmware rate control.

This is currently a no-op as firmware rate control isn't working
in-tree, but it is working for me locally with other changes.
Without this, there's no way to force low rates for management,
DHCP traffic, and to allow fixed rate via "ifconfig wlanX ucastrate Y"
to function.

Locally tested:

* RTL8192CU, STA mode (firmware and driver/net80211 rate control)

Differential Revision:	https://reviews.freebsd.org/D48100
Reviewed by:	bz, gavin
2025-01-02 17:24:01 -08:00
Adrian Chadd
2be951a526 rtwn: enable VHT if it's configured in the device
If the driver attach path adds the VHT flag then add the 20/40/80 MHz
VHT channels.

This is a no-op right now as nothing is enabling it.

Differential Revision:	https://reviews.freebsd.org/D48097
Reviewed by:	bz
2025-01-02 17:18:16 -08:00
John Baldwin
925e1016b1 puc: Use device_delete_children if attach fails
This is slightly simpler than deleting individual devices.

Differential Revision:	https://reviews.freebsd.org/D47974
2025-01-02 13:25:38 -05:00
John Baldwin
d174ffca3a mfi: Use bus_generic_detach to simplify deleting children during detach
Differential Revision:	https://reviews.freebsd.org/D47973
2025-01-02 13:25:27 -05:00
John Baldwin
11a9117871 Use bus_generic_detach to detach and delete child devices during detach
This is simpler and more robust than individual calls to
device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47972
2025-01-02 13:25:12 -05:00
John Baldwin
0ac15e476d spibus: Use bus_generic_* directly instead of wrappers
Differential Revision:	https://reviews.freebsd.org/D47971
2025-01-02 13:25:01 -05:00
John Baldwin
aa48c1ae08 etherswitch: Cleanup detach and delete of child devices during detach
Call bus_generic_detach first and return any error.  Remove no longer
needed individual device_delete_child calls.

Differential Revision:	https://reviews.freebsd.org/D47970
2025-01-02 13:24:46 -05:00
John Baldwin
3ddaf8200b Use bus_generic_detach instead of device_delete_children in detach
While here, check for errors from bus_generic_detach and move it to
the start of detach if necessary.

Differential Revision:	https://reviews.freebsd.org/D47969
2025-01-02 13:24:28 -05:00
John Baldwin
20f932af29 bhnd bcma/siba: Remove duplicate call to device_delete_children
bcma/siba_add_children already call device_delete_children if an error
occurs.

Differential Revision:	https://reviews.freebsd.org/D47968
2025-01-02 13:24:13 -05:00
John Baldwin
919f911ea4 siba: Use device_delete_children in siba_add_children
Differential Revision:	https://reviews.freebsd.org/D47967
2025-01-02 13:23:54 -05:00
John Baldwin
64d1a02e4e Check for errors from bus_generic_detach in various drivers
In some cases, move the call to bus_generic_detach earlier so that any
detach failures from child devices do not leave the parent device
partially detached.

Differential Revision:	https://reviews.freebsd.org/D47966
2025-01-02 13:23:41 -05:00
John Baldwin
6da28bb2a3 csa/emu10kx: Simplify deleting child devices
Use bus_generic_detach to detach and delete all child devices instead
of several explicit calls to device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47965
2025-01-02 13:23:28 -05:00
John Baldwin
faf0bf43df cgem: Cleanup detaching of child miibus device
Move bus_generic_detach earlier in place of the existing
device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47964
2025-01-02 13:23:16 -05:00
John Baldwin
160179ea3e Remove now-redundant calls to device_delete_children
Earlier calls to bus_generic_detach now take care of deleting
children.

Differential Revision:	https://reviews.freebsd.org/D47962
2025-01-02 13:22:50 -05:00
John Baldwin
4e62c3cafa Remove now-redundant calls to device_delete_child
Deleting a child explicitly before calling bus_generic_detach is now
redundant, so remove those calls and rely on bus_generic_detach to
delete children instead.

Differential Revision:	https://reviews.freebsd.org/D47961
2025-01-02 13:22:35 -05:00
John Baldwin
cf416f56eb Use the new bus_generic_detach directly in place of home-grown versions
Differential Revision:	https://reviews.freebsd.org/D47960
2025-01-02 13:22:20 -05:00
John Baldwin
b196276c20 bus_generic_detach: Delete children after detaching them
This provides better semantics as a standalone DEVMETHOD for
device_attach as bus drivers should remove child devices they created
as part of detach cleanup.  The implementation calls
bus_detach_children() first to permit child devices an opportunity to
veto the detach operation.  If that succeeds, device_delete_children()
is used to delete the child devices.

This requires fixing various drivers that were deleting devices
explicitly (via a device_t pointer cached in the softc) after calling
bus_generic_detach to stop doing that and just rely on
bus_generic_detach to remove child devices.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47959
2025-01-02 13:21:30 -05:00
John Baldwin
28f5e880e8 Use device_delete_children instead of explicit calls to device_delete_child
This is simpler and more robust in the face of potential double-frees
(e.g. if called after bus_generic_detach which will delete devices in
a future commit).

Reviewed by:	manu, imp
Differential Revision:	https://reviews.freebsd.org/D47958
2025-01-02 13:20:21 -05:00
John Baldwin
e9d3857040 Use bus_detach_children instead of bus_generic_detach
These drivers perform additional teardown steps in between detaching
child devices and deleting child devices.

Differential Revision:	https://reviews.freebsd.org/D47957
2025-01-02 13:19:39 -05:00