Commit graph

43676 commits

Author SHA1 Message Date
Olivier Certner
bb04712e37
smbios: Carefully print wrong entry point signature on identify
Using printf() with '%s' can lead to arbitrary long printing (although,
usually, a NUL byte should appear quite quickly) and trying to print
unprintable characters.

Instead, print in hexadecimal the exact bytes that are compared to the
expected signature.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
fdf08ac1e9
smbios: Print an error on unexpected entry point length on identify
This helps figuring out quickly why no SMBIOS device appears in this case.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
f6cbd6b6d2
smbios: Apply the v2.1's length fixup only on a 32-bit entry point
Only allow the length tolerance (0x1e instead of 0x1f) for a 32-bit
entry point, as there was no 64-bit entry point in the erroneous SMBIOS
v2.1 standard and assigning the length with 0x1f does not make sense in
this case.

While here, fix accessing the major/minor versions via 'eps' even in the
64-bit entry point case (not causing any practical problem thus far as
the entry point length is greater than any SMBIOS revisions in
existence, so the comparison guarding the fixup would not pass).

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
3907feff7a
smbios: Print an error on memory map failure on identify
Consistently with what the probe and attach methods are doing.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
67d510f0c0
smbios: Unmap memory on error on identify
While here, de-indent most of the code by simply bailing out if 'addr'
is still 0 after the various detection methods have been tried.

Reviewed by:    emaste, imp
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49180
2025-03-07 17:42:45 +01:00
Olivier Certner
e421a6615d
smbios: On attach, print the entry point version and revision
Additionally, on verbose boot, print the entry point revision as
a diagnostic/debugging help.

PR:             284460
Reviewed by:    markj, imp (both older version)
MFC after:      2 weeks
Event:          February src bug-busting session
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49179
2025-03-07 17:42:45 +01:00
Olivier Certner
bc7f650836
smbios: Search for v3 (64-bit) entry point first on BIOS boot
When booted from BIOS (i.e., not EFI), also search for a 64-bit version
of the SMBIOS Entry Point.

This allows us to detect and report the proper SMBIOS version with
BIOSes that only provide the v3 table, as happens on Hetzner virtual
machines.

For machines that provide both, leverage the v3 table in priority
consistently with the EFI case.

PR:             284460
Reviewed by:    markj, imp (both older version)
MFC after:      2 weeks
Relnotes:       yes
Event:          February src bug-busting session
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49179
2025-03-07 17:42:45 +01:00
Olivier Certner
69cf9e9a45
smbios: style(9): sizeof(): No space before the parenthesis
No functional change.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:40 +01:00
Vladimir Kondratyev
adc2c156ac gpioaei: Add support for ACPI _EVT method
This method is often used to process GPIO "Power on" button press on
modern x86 laptops with S0ix sleep mode.

Tested with patch from https://reviews.freebsd.org/D26407

Sponsored by:	Future Crew LLC
MFC after:	2 month
2025-03-07 18:59:12 +03:00
Ahmad Khalifa
6aab381a49 acpi_gpiobus: assume GPIO_PIN_INPUT for interrupt pins
Different drivers respond differently to having neither GPIO_PIN_INPUT
or GPIO_PIN_OUTPUT set, this stops the unpredictable results.
2025-03-07 18:59:11 +03:00
Vladimir Kondratyev
daa098cc37 iichid(4): Wait for RESET command response while attaching
before starting of children initialization to ensure that parent device
is fully functional.

Sponsored by:	Future Crew LLC
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D48958
2025-03-07 09:26:51 +03:00
Vladimir Kondratyev
548d3aa856 iichid(4): Read wMaxInputLength bytes over I2C even if we discards data
For some devices e.g. ITE5570 it is not enough to read HID-over-I2C
input length header of RESET command response to acknowledge interrupt.
Do a full-size read to avoid interrupt storm.

Sponsored by:	Future Crew LLC
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D48957
2025-03-07 09:26:51 +03:00
Vladimir Kondratyev
c7225a3ede ig4_iic: Allow sleeping if called from iichid interrupt handler.
This replaces 50 ms busy loop with mtx_sleep for the same duration thus
saving CPU time when iichid is driven with interrupts.

Sponsored by:	Future Crew, LLC
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D48956
2025-03-07 09:26:51 +03:00
Colin Percival
d70bac252d acpi_pci: Add quirk for PSTAT_PME-before-detach
In order to signal to Graviton [123] systems that a device is ready
to be "ejected" (after a detach request is made via the EC2 API) we
need to set PCIM_PSTAT_PME to 1 and PCIM_PSTAT_PMEENABLE to 0.  We are
not aware of any rationale for this requirement beyond "another OS
kernel happens to do this", i.e. this is effectively bug-for-bug
compatibility.

Arguably this should be done by the ACPI _EJ0 method on these systems,
but it is not.

Create a new ACPI_Q_CLEAR_PME_ON_DETACH quirk and set it in EC2 AMIs,
and add the PCI register write to acpi_pci_device_notify_handler when
that quirk is set.

Reviewed by:	jhb
MFC after:	1 month
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D49146
2025-03-05 12:25:49 -08:00
SHENGYI HONG
8ee127efb0 vm_lowmem: Fix signature mismatches in vm_lowmem callbacks
This is required for kernel CFI.

Reviewed by:	rrs, jhb, glebius
Differential Revision:	https://reviews.freebsd.org/D49111
2025-03-04 20:18:52 -05:00
Warner Losh
ca48e43ba9 usb: Kill left-over cdefs.h includes
These includes were for __FBSD_RCSID() macro. They weren't formatted
like the rest of the tree so weren't trimmed automatically when that
script was run. Trim them now.

MFC After: 1 week
Sponsored by:		Netflix
2025-03-04 14:44:22 -07:00
Kyle Evans
2bef0d54f7 kern: wg: remove overly-restrictive address family check
IPv4 packets can be routed via an IPv6 nexthop, so the handling of the
parsed address family is more strict than it needs to be.  If we have a
valid header that matches a known peer, then we have no reason to
decline the packet.

Convert it to an assertion that it matches the destination as viewed by
the stack below it, instead.  `dst` may be the gateway instead of the
destination in the case of a nexthop, so the `af` assignment must be
switched to use the destination in all cases.

Add a test case that approximates a setup like in the PR and
demonstrates the issue.

PR:		284857
Reviewed by:	markj (earlier version), zlei
Differential Revision:	https://reviews.freebsd.org/D49172
2025-03-04 13:57:34 -06:00
Slava Shwartsman
85af37e159 mlx5en: Fix domain set usage in TLS tag import functions
Use the correct device pointer to obtain the domain set for memory
allocation. Previously, the functions were incorrectly using the arg
parameter directly instead of accessing mlx5_core_dev.

Signed-off-by: Slava Shwartsman <slavash@nvidia.com>

Sponsored by:	NVidia networking
MFC after:	1 week
2025-03-04 06:58:07 +02:00
Doug Ambrisko
1c9c4a25e6 enic: fix potential panic due to not understanding what iflib had allocated
For safety I was trying to clear out the descriptor but the full descriptor
was not allocated.  Remove any code trying to do that so the same mistake
won't be made.  This was found when looking to MFC the prior change
and having the loader, load the module.

Remove cq->ntxqsets since the completion queue is part of the RX and TX sets
2025-03-03 12:49:01 -08:00
Mitchell Horne
e2a08ac9ce riscv: enable EFI framebuffer
Pass framebuffer information from loader(8) to the kernel via the
MODINFOMD_EFI_FB metadata field.

Enable the vt_efifb driver. A small tweak is required to work around the
lack of VM_MEMATTR_WRITE_COMBINING on this platform; we use
VM_MEMATTR_UNCACHEABLE instead.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48884
2025-03-03 12:12:15 -04:00
Adrian Chadd
10c633ab12 ath_rate_sample: fix setting HT rates
ieee80211_node_set_txrate_ht_mcsrate() takes an MCS rate from 0..76,
the high bit (IEEE80211_RATE_MCS) must not be set.

This is definitely my fault - I likely didn't get to testing this
diff when I changed it from ieee80211_node_set_txrate_dot11rate()
just before landing.

Differential Revision:	https://reviews.freebsd.org/D49197
Reviewed by:	bz
2025-03-01 15:32:56 -08:00
Adrian Chadd
50ec1e7af0 ath: fix 20MHz HT short-gi logic.
This was broken in an earlier commit

(ca389486a9).

PR:		kern/285096
Differential Revision:	https://reviews.freebsd.org/D49196
Fixes:	ca389486a9
Reviewed by:	bz
2025-03-01 15:32:04 -08:00
Eric Joyner
7ee310c80e igc(4): Fix attach for I226-K and LMVP devices
Summary:
The device IDs for these were in the driver's list of PCI ids to attach
to, but igc_set_mac_type() had never been setup to set the correct mac
type for these devices. Fix this by adding these IDs to the switch block
in order for them to be recognized by the driver instead of returning an
error.

This fixes the igc(4) attach for the I226-K LOM on the ASRock Z790
PG-ITX/TB4 motherboard, allowing it to be recognized and used.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Reviewed by:	kbowling@
MFC after:	3 days
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D49147
2025-02-26 10:15:38 -08:00
Kevin Lo
5c7087c349 ixgbe: Fix a logic error in ixgbe_read_mailbox_vf()
Reviewed by:	kbowling
Differential Revision:	https://reviews.freebsd.org/D49156
2025-02-28 16:12:00 +08:00
Wei Hu
9b8701b81f mana: refill the rx mbuf in batch
Set the default refill threshod to be one quarter of the rx queue
length. User can change this value with hw.mana.rx_refill_thresh
in loader.conf. It improves the rx completion handling by saving
10% to 15% of overall time with this change.

Tested by:	whu
MFC after:	2 weeks
Sponsored by:	Microsoft
2025-02-27 08:08:13 +00:00
Adrian Chadd
fdc8841611 rtwn: move to using ieee80211_node_get_txrate()
Migrate the transmit path to use ieee80211_node_get_txrate(), and handle
VHT rates.

Nothing is currently setting VHT rates, but the driver should now
be ready.

Differential Revision:	https://reviews.freebsd.org/D48606
Reviewed by:	bz
2025-02-26 11:30:01 -08:00
Adrian Chadd
46de4d9fc2 net80211: change ieee80211_ratectl_rate() to not return a rix
There are only a few places where the returned rix is used:

* linuxkpi - logging
* bwi/bwn - used for finding a fallback rate to choose, which
  honestly should be returned by the ratectl API
* iwm - building the rateset to program into firmware

Everyone else uses the dot11rate value in ni->ni_txnode.

This is a precursor for VHT and later rate support; where currently
there aren't rate tables in ieee80211_phy.c for VHT and later
rates.

Although it's likely doable to add tables for VHT, 11ax and MU-OFDMA
(HE) rates are sufficiently larger/different to just not fit in the
current scheme without more refactoring.

Differential Revision:	https://reviews.freebsd.org/D48603
Reviewed by:	bz, thj
2025-02-26 11:29:36 -08:00
Adrian Chadd
7067450010 sys: convert ni->ni_txrate references use to the new net80211 API
This just mechanically converts things.

* For linuxkpi, it was just used for display.
* For uath, it was just used for display, as firmware
  doesn't report it up.

Differential Revision:	https://reviews.freebsd.org/D48602
Reviewed by:	bz, thj
2025-02-26 11:29:18 -08:00
Navdeep Parhar
e19d84979a cxgbe(4): Block most access to the hardware as soon as the adapter stops.
Add a new hw_all_ok() routine and use it to avoid hardware access in the
public control interfaces (ifnet ioctls, ifmedia calls, etc.).  Continue
to use hw_off_limits() in the private ioctls/sysctls and other debug
code.  Retire adapter_stopped() as it's of no use by itself.

This fixes problems where ifnet slow-path operations would enter a
synch_op just before set_adapter_hwstatus(false) and touch the hardware
when it's not safe to do so.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2025-02-25 11:33:40 -08:00
Warner Losh
dc95228d98 nvme: Fix hotplug on one of the amazon platforms
Amazon EC2 m7i cloud instances use PCI hotplug rather than ACPI
hotplug. The card is removed and detach is called to remove the drive
from the system. The hardware is no longer present at this point, but
the bridge doesn't translate the now-missing hardware reads to all ff's
leading us to conclude the hardware is there and we need to do a proper
shutdown of it. Fix this oversight by asking the bridge if the device is
still present as well. We need both tests since some systems one cane
remove the card w/o a hotplug event and we want to fail-safe in those
cases.

Convert gone to a bool while I'm here and update a comment about
shutting down the controller and why that's important.

Tested by: cperciva
Sponsored by: Netflix
2025-02-25 09:36:53 -07:00
Christos Margiolis
bc7e65e950 sound: Call chn_kill() in chn_init() failure
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48966
2025-02-25 13:44:37 +02:00
Christos Margiolis
2868776c9c sound: Update comment and channel insertion in vchan_create()
The comment and rationale behind choosing CHN_INSERT_SORT_DESCEND()
instead of CHN_INSERT_SORT_ASCEND() are no longer relevant as of FILLME
("sound: Allocate vchans on-demand").

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48962
2025-02-25 13:44:30 +02:00
Christos Margiolis
fd906e47b1 sound: Simplify locking during device creation
The mechanism of acquiring SD_F_BUSY in pcm_init() and releasing it in
pcm_register() is a leftover from the previous device creation scheme,
where pcm_init() (previously pcm_register()) would create the sysctl
nodes, as well as the device node. In this scenario, acquiring SD_F_BUSY
was necessary, in order to avoid races in case the device was accessed
before it was ready for use. Commit 66f3eb14e9 ("sound: Move sysctl
and /dev/dspX creation to pcm_setstatus()") fixed this issue, so we can
simplify things now. Only acquire SD_F_BUSY in pcm_addchan(), because
chn_init() expects to be called with SD_F_BUSY acquired.

While here, move the sndstat_register() call further down to be more
robust.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D48482
2025-02-25 13:44:24 +02:00
Christos Margiolis
352aa9ad1d snd_uaudio: Remove undefined functions
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D48424
2025-02-25 13:44:18 +02:00
Christos Margiolis
40616b7e41 sound: Return if the new speed/format is the same as the current one
This gives us a slight performance boost since we do not have to go
through chn_setparam() and the driver functions.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D48012
2025-02-25 13:44:12 +02:00
Christos Margiolis
4e1b75bebf sound: Get rid of redundant variables in chn_setspeed() and chn_setformat()
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D48011
2025-02-25 13:44:05 +02:00
Christos Margiolis
6524d2a5af sound: Remove SNDBUF_LOCKASSERT()
It's a no-op. There is no lock associated with the buffer.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D48008
2025-02-25 13:43:59 +02:00
Christos Margiolis
1cbafcd137 sound: Handle multiple primary channel cases in vchan sysctls
vchan_getparentchannel() is used by various vchan sysctl functions to
fetch the first primary channel. However, this assumes that all devices
have only one primary channel per direction. If a device does not meet
this assumption, then the sysctl functions will be applying the
configurations on the first primary channel only.

Since we now have the "primary" channel sublist, we can retire
vchan_getparentchannel() and iterate through the "primary" list in each
sysctl function and apply the settings to all primary channels.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48336
2025-02-25 13:43:52 +02:00
Christos Margiolis
b50f53cf87 sound: Cache vchanmode
We already cache vchanrate and vchanformat.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48335
2025-02-25 13:43:46 +02:00
Christos Margiolis
02d4eeabfd sound: Allocate vchans on-demand
Refactor pcm_chnalloc() and merge with parts of vchan_setnew() (now
removed) and dsp_open()’s channel creation into a new dsp_chn_alloc()
function. The function is responsible for either using a free HW channel
(if vchans are disabled), or allocating a new vchan.

Clean up allocated vchans associated with a given dsp_cdevpriv on
dsp_close() instead of leaving them unused.

hw.snd.vchans_enable (previously hw.snd.maxautovchans) and
dev.pcm.X.{play|rec}.vchans now work as tunables to only enable/disable
vchans, as opposed to setting their number and/or (de-)allocating
vchans. Since these sysctls do not trigger any (de-)allocations anymore,
their effect is instantaneous, whereas before we could have frozen the
machine (when trying to allocate new vchans) when setting
dev.pcm.X.{play|rec}.vchans to a very large value.

Create a new "primary" channel sublist so that we do not waste time
looping through all channels in dsp_chn_alloc(), since we are only
looking for a parent channel to either use, or add a new vchan to. This
guarantees a steady traversal speed, as the parent channels are most
likely going to be just a handful (2). What was currently in place was a
loop through the whole channel list, which meant that the traversal
would take longer the more channels were added to that list.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47917
2025-02-25 13:43:39 +02:00
Christos Margiolis
d39be38a35 sound: Report actual vchanrate and vchanformat in sysctl
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48435
2025-02-25 13:43:33 +02:00
Christos Margiolis
e89ee05b7c sound: Initialize channels with sane default rate and format
There is no good reason to initialize with AFMT_U8 at 8000Hz.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48434
2025-02-25 13:43:26 +02:00
Christos Margiolis
2546ab1b36 sound: Call vchan_destroy() on vchan_create() failure
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48183
2025-02-25 13:43:19 +02:00
Christos Margiolis
405b1e5092 sound: Do not fail from vchan_destroy() if children list is empty
vchan_destroy() should be able to call chn_kill() regardless of whether
the channel has been added to the children list yet or not. Also remove
the CHN_F_BUSY check. There is no reason we shouldn't execute the code
below if the parent is not busy.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48185
2025-02-25 13:43:11 +02:00
Christos Margiolis
164651f16c sound: Do not return an error from chn_notify() if the children list is empty
An empty children list does not mean that there is an error.

Reported by:	Florian Walpen <dev@submerge.ch>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D48156
2025-02-25 13:42:59 +02:00
Wei Hu
a18e999454 mana: Increase default tx and rx ring size to 1024
Tcp perfomance tests show high number of retries under heave tx
traffic. The numbers of queue stops and wakeups also increase.
Further analysis suggests the FreeBSD network stack tends to send
TSO packets with multiple sg entries, typically ranging from
10 to 16. On mana, every two sgs takes one unit of tx ring.
Therefore, adding up one unit for the head, it takes 6 to 9 units
of tx ring to send a typical TSO packet.

Current default tx ring size is 256, which can get filled up
quickly under heavy load. When tx ring is full, the send queue
is stopped waiting for the ring space to be freed. This could
cause the network stack to drop packets, and lead to tcp
retransmissions.

Increase the default tx and rx ring size to 1024 units. Also
introduce two tuneables allowing users to request tx and rx ring
size in loader.conf:
        hw.mana.rx_req_size
        hw.mana.tx_req_size
When mana is loading, the driver checks these two values and
round them up to power of 2. If these two are not set or
the request values are out of the allowable range, it sets the
default ring size instead.

Also change the tx and rx single loop completion budget to 8.

Tested by:	whu
MFC after:	2 weeks
Sponsored by:	Microsoft
2025-02-24 13:56:06 +00:00
Adrian Chadd
9f32893b05 qcom_ess_edma: Add the IPQ4018/IPQ4019 ethernet MAC/MDIO driver.
This adds the ESS EDMA driver introduced by the IPQ4018/IPQ4019.

It provides a number of transmit and receive rings which can be mapped
into virtual ethernet devices, which this driver supports.

It's partially integrated into the ar40xx etherswitch which supplies
the port and some filtering/VPN offload functionality. This driver
only currently supports the per-port options which allow for the
virtual ethernet driver mapping.

This was written by reverse engineering the functionality of the
ethernet switch and ethernet driver support provided by Qualcomm
Atheros via their OpenWRT contributions.  The code is all originally
authored by myself.

Differential Revision:	https://reviews.freebsd.org/D49027
2025-02-20 18:48:12 -08:00
John Baldwin
11509c6ef2 nvmft: Export more info for a ctl port for use by ctladm
In particular, export a "port" entry as well as an array of "host"
entries for each active connection.

Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48775
2025-02-20 10:31:20 -05:00
John Baldwin
97ca2ada80 nvmft: Switch the per-port lock from sx(9) to mtx(9)
This is needed to avoid LORs for a following commit.

Sponsored by:	Chelsio Communications
2025-02-20 10:31:20 -05:00
Christos Margiolis
18457e7e25 sound: Bail out early if a format is not supported
If a format is unsupported, the feeder_build_* functions will fail
anyway, so bail out early to avoid unnecessary computation.

This is also needed by a series of upcoming patches to the feeder
framework.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48031
2025-02-18 21:37:22 +02:00