Commit graph

39683 commits

Author SHA1 Message Date
Tong Zhang
110b8112e5 stge: fix null pointer dereference
stge_attach() could fail at line 464, sc->sc_spec remains NULL when
calling stge_detach(), thus bus_release_resources() at line 704 will
trigger null pointer dereference. We need to check the nulliness before
calling bus_release_resources().

PR:		258420
Reviewed by:	markj

(cherry picked from commit 2108cc7290)
2022-04-06 20:30:45 -04:00
Chandrakanth Patil
09e161a29e mrsas: if controller reset is in progress, refrain from firing DCMDs to
firmware in shutdown

If controller reset is in progress, at same time if system shutdown is
issued then corresponding shutdown function in driver will be invoked
where driver is waiting 15 seconds to complete the controller reset.

If the reset is not complteted within that time frame driver will go
ahead and fire cache flush and shutdown DCMDs which will end up
accessing the the queues which are not initialized due to undergoing
reset leads to FMU error in firmware.

Fix:
In shutdown function, if controller reset is not finished within 15
seconds than driver will return to the OS without firing any DCMDs.

Reviewed by: imp
PR: 261375

(cherry picked from commit 79c4c4be96)
2022-04-06 10:27:25 -06:00
Chandrakanth Patil
2ebe518597 mrsas: remove additional MPT command allocation for R1 FP command
There is an additional MPT command allocation for R1 fp command which
will lead to MPT command unavailablity in case of rigorous R1 FP IOs.

Remove additional MPT command allocation for R1 FP.

Reviewed by: imp
PR: 261377

(cherry picked from commit 241bb95552)
2022-04-06 10:27:25 -06:00
Colin Percival
5cc5cd739e uart(4): Add a concept of "unique" serial devices
FreeBSD detects serial ports twice: First, very early in the boot
process, in order to obtain a usable console; and second, during
the device probe/attach process.  When a UART is discovered during
device probing, FreeBSD attempts to determine whether it is a
device which was already being used as a console; without this,
the console doesn't work in userland.

Unfortunately it's possible for a UART to be mapped to a different
location in memory when it is discovered on a bus than it has when
it is announced via the ACPI SPCR table; this breaks the matching
process, which relies on comparing bus addresses.

To address this, we introduce a concept of "unique" serial devices,
i.e. devices which are guaranteed to be present *only once* on any
system.  If we discover one of these during device probing, we can
match it to a same-PCI-vendor-and-device-numbers console which was
announced via the ACPI SPCR table, regardless of the differing bus
addresses.

At present, the only unique serial device is the "Amazon PCI serial
device" (vendor 0x1d0f, device 0x8250) found in some EC2 instances.
This unbreaks the serial console on those systems.

Reviewed by:	imp
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D34703

(cherry picked from commit ad93649d23)
2022-04-04 12:11:41 -07:00
Andrew Gallatin
392d7f0269 cxgbe: fix enabling lro & rxtimestamps
A recent change caused iq flags, like LRO, to be set before
init_iq(). However, init_iq() clears those flags, so they
became effectively impossible to set.   This change moves
the initializion of these flags to after the call to init_iq().
This fixes LRO.

Differential Revision: https://reviews.freebsd.org/D30460
Reviewed by: np, rrs
Sponsored by: Netflix
Fixes: 43bbae1948

(cherry picked from commit df8437a93d)
2022-04-04 11:57:15 -07:00
Ed Maste
0b29e1b9f9 mpr/mps/mpt: verify cfg page ioctl lengths
*_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a
buffer of a caller-specified size, but copied to it a fixed size header.
Add checks that the size is at least the required minimum.

Note that the device nodes are owned by root:operator with 0640
permissions so the ioctls are not available to unprivileged users.

This change includes suggestions from scottl, markj and mav.

Two of the mpt cases were reported by Lucas Leong (@_wmliang_) of
Trend Micro Zero Day Initiative; scottl reported the third case in mpt.
Same issue found in mpr and mps after discussion with imp.

Reported by:	Lucas Leong (@_wmliang_), Trend Micro Zero Day Initiative
Reviewed by:	imp, mav
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34692

(cherry picked from commit 8276c4149b)
2022-04-03 20:45:41 -04:00
Gordon Bergling
f4dc553a72 mlx5en(4): Fix a few typos in source code comments
- s/persistant/persistent/

(cherry picked from commit 4a87beeccb)
2022-04-02 15:35:02 +02:00
Gordon Bergling
813aa329c5 isci(4): Fix a typo in a source code comment
- s/recored/recorded/

(cherry picked from commit e4c1b3f060)
2022-04-02 15:31:30 +02:00
Gordon Bergling
0ca14b2d9e qlnxe(4): Fix a typo in a source code comment
- s/existance/existence/

(cherry picked from commit a216b9c2e0)
2022-04-02 15:31:16 +02:00
Gordon Bergling
a251b748ad drm2: Fix a typo in a source code comment
- s/mmaping/mapping/

(cherry picked from commit 22ba115b49)
2022-04-02 15:31:02 +02:00
Gordon Bergling
69b9881705 exca(4): Fix a typo in a source code comment
- s/maping/mapping/

(cherry picked from commit 9a9d901bf2)
2022-04-02 15:30:13 +02:00
Gordon Bergling
42a2373d22 cxgbe(4): Fix a typo in a source code comment
- s/begining/beginning/

(cherry picked from commit c9023cf7fe)
2022-04-02 15:29:40 +02:00
Navdeep Parhar
8c711d0aa2 cxgbe(4): Handle FORCE_FEC in pcaps correctly.
The firmware doesn't report FORCE_FEC in pcaps if the transceiver
plugged in at that time does not support a speed that may use FEC.  It
is incorrect for the driver to assume that the FORCE_FEC value it read
during attach (in init_link_config) is permanent.  Instead, it should
check pcaps just before issuing the L1CFG command.

Sponsored by:	Chelsio Communications

(cherry picked from commit 231f211240)
2022-04-01 18:49:43 -07:00
Navdeep Parhar
82386f825e cxgbe(4): Allow dump_cimla and dump_devlog to sleep.
This has been safe since e9e7bc8250, which moved parts of error
handling from the ithread to a taskqueue.

Sponsored by:	Chelsio Communications

(cherry picked from commit 41c4e1c7f7)
2022-04-01 18:48:52 -07:00
Henri Hennebert
ee772cbdc4 rtsx: Remove update of softc during probe and some var rename.
MFC after:	1 week

(cherry picked from commit 2e88306786)
2022-03-30 21:48:24 -04:00
Henri Hennebert
c1a9422b99 rtsx: Display error if rtsx_read()/rtsx_write() fail.
MFC after:	1 week

(cherry picked from commit 9b261d2e0a)
2022-03-30 21:48:24 -04:00
Henri Hennebert
cd89969685 rtsx: Don't detach during shutdown
MFC after:	1 week

(cherry picked from commit 6b7718377b)
2022-03-30 21:48:24 -04:00
Ed Maste
74f11a40f8 sound: test PCM_REGISTERED before PCM_DETACHING
PCM_REGISTERED(d) tests that d is not NULL, so perform that check first
as we may have cases where devclass_get_softc has a null entry.

PR:		262671
Reviewed by:	hselasky
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34648

(cherry picked from commit da03ac41c9)
2022-03-30 16:43:57 -04:00
Gordon Bergling
81f92d0fe6 ath: Fix a typo in a source code comment
- s/ony/only/

(cherry picked from commit 8eb774fe54)
2022-03-30 18:37:54 +02:00
Ed Maste
797b8b9c40 Remove snd_aureal driver source
This driver was not finished when it was committed in 1999 and was never
connected to the build.

A version of the driver used to be available in ports as
audio/aureal-kmod, but it has been removed.  It did not build on FreeBSD
10.x or later and the binary objects it required were not available
after Google Code disappeared.

PR:		124343
Reported by:	joel
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit ef5dec7cc7)
2022-03-29 21:18:05 -04:00
Sebastien Bini
992e326cd8 neta: split fixed and in-band link status configuration
Fixed-link mode requires different handling than the in-band
managed connection. Update interrupt, link-up/down and
autonegotiation settings for the former.

Reviewed by: mw
MFC after: 1 week
Obtained from: Stormshield
Differential Revision: https://reviews.freebsd.org/D34394

(cherry picked from commit 231237bbb0)
2022-03-30 00:24:56 +02:00
Kornel Duleba
817556add3 Extend device_get_property API
In order to support various types of data stored in device
tree properties or ACPI _DSD packages, create a new enum so
the caller can specify the expected type of a property they
want to read, according to the binding. The bus logic will use
that information to process the underlying data.

For example in DT all integer properties are stored in BE format.
In order to get constant results across different platforms we
need to convert its endianness to match the host.

Another example are ACPI_TYPE_INTEGER properties stored
as uint64_t. Before this patch the ACPI logic would refuse
to read them if the provided buffer was smaller than 8 bytes.
Now this can be handled by using DEVICE_PROP_UINT32 type.

Modify the existing consumers of this API to reflect the changes
and update the man pages accordingly.

Reviewed by: mw
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33457

(cherry picked from commit b344de4d0d)
2022-03-30 00:24:29 +02:00
Kornel Duleba
a2bd4cd786 bus_if: Add a default implementation of get_property
There are multiple buses that pretend to be ofw compatible,
e.g ofw_pci, mii_fdt. We now need to provide an implementation
of BUS_GET_PROPERTY for every one of them. Instead of modifying
them one by one it's better to just provide a default
implementation that simply traverses up the device tree.
Remove the now unneeded BUS_GET_PROPERTY implementation in mii_fdt.

Reviewed by: andrew, bz
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34031

(cherry picked from commit 206dc82bc3)
2022-03-30 00:24:28 +02:00
Kornel Duleba
f0a6f99b2a miibus: Add support for mapping OFW nodes to PHY devices
Create a new miibus OFW specific layer leveraging miibus_fdt.c code.
PHY drivers can than read the properties using device_get_property(9) API.
Resource(interrupt) allocation is also supported.
In order to enable this each NIC/switch driver will have to be modified,
because of how miibus is attached to the parent driver.

Obtained from: Semihalf
Sponsored by: Alstom Group
Differential revision: https://reviews.freebsd.org/D32812

(cherry picked from commit 9174eab414)
2022-03-30 00:24:28 +02:00
Kornel Duleba
b329bb8fd7 mii_fdt: Add support for switch PHY node lookup
Previously we would only search for a PHY xref in node of the miibus
parent.
That didn't work very well with switches.
Fix that by searching through "ports" subnode, checking if any of its
children have a valid PHY xref.
Since switches tend to have multiple ports we also have multiple
candidates.
Use the PHY address read from mii_attach_args to find the right one.

Obtained from: Semihalf
Sponsored by: Alstom Group
Reviewed by: mw
Differential revision: https://reviews.freebsd.org/D32690

(cherry picked from commit 4b843e7f03)
2022-03-30 00:24:27 +02:00
Bartlomiej Grzesik
993cd606c2 sdhci_xenon: add ACPI support
Add support for ACPI device probing for SDHCI controller found on Marvell chips.

Reviewed by: mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31600

(cherry picked from commit adbce5ff74)
2022-03-30 00:24:27 +02:00
Bartlomiej Grzesik
693af80b74 sdhci_xenon: split driver file into generic file and fdt parts
This patch splits driver code into two seperate files sdhci_xenon.c
and sdhci_xenon_fdt.c. This will allow future implementation of ACPI
discovery of sdhci on Xenon chips.

Reviewed by: mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31599

(cherry picked from commit d78e464d23)
2022-03-30 00:24:27 +02:00
Bartlomiej Grzesik
2f9a9149e5 mmc: switch mmc_helper to device_ api
Add generic mmc_helper which uses newly introduced device_*_property
api. Thanks to this change the sd/mmc drivers will be capable
of parsing both DT and ACPI description.

Ensure backward compatibility for all mmc_fdt_helper users.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31598

(cherry picked from commit 8a8166e5bc)

mmc: Fix regression in 8a8166e5bc breaking Stratix 10 boot

The refactoring in 8a8166e5bc introduced a functional change that
breaks booting on the Stratix 10, hanging when it should be attaching
da0. Previously OF_getencprop was called with a pointer to host->f_max,
so if it wasn't present then the existing value was left untouched, but
after that commit it will instead clobber the value with 0. The dwmmc
driver, as used on the Stratix 10, sets a default value before calling
mmc_fdt_parse and so was broken by this functional change. It appears
that aw_mmc also does the same thing, so was presumably also broken on
some boards.

Fixes:	8a8166e5bc ("mmc: switch mmc_helper to device_ api")
Reviewed by:	manu, mw
Differential Revision:	https://reviews.freebsd.org/D32209

(cherry picked from commit 4a331971d2)
2022-03-30 00:24:26 +02:00
Bartlomiej Grzesik
45b49a0f96 device: add device_get_property and device_has_property
Generialize bus specific property accessors. Those functions allow driver code
to access device specific information.

Currently there is only support for FDT and ACPI buses.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31597

(cherry picked from commit 3f9a00e3b5)

acpi: Fix error code returned in acpi_bus_get_prop

ACPI implementation of device_get_property would return "-1" when
property was found, but it's type wasn't supported.
This causes device_has_property to return false in that scenario, which
arguably could be considered as incorrect.

Fix that by returning "0" in that case.

Reviewed by: bz, mw
Tested by: mw
MFC after: 2 weeks
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D33103

(cherry picked from commit d9ed1dcc5c)
2022-03-30 00:24:26 +02:00
Bartlomiej Grzesik
fd08253cdc acpica: add ACPI_GET_PROPERTY to access Device Specific Data (DSD)
Add lazy acquiring of DSD package, which allows accessing Device
Specific Data.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31596

(cherry picked from commit b91fc6c43a)
2022-03-30 00:24:25 +02:00
Alexander V. Chernikov
453b4f8193 u3g: Add support Quectel EM12-G modem.
Submitted by:	<tda.77793 at gmail.com>
PR:		260218
MFC after:	2 weeks

(cherry picked from commit 217481a333)
2022-03-28 08:54:30 +00:00
Mark Johnston
18a3bada30 hdac: Handle interrupts racing with device suspend
- Avoid looping forever if a concurrent reset causes a read of the
  interrupt status register to return all ones.
- Lock the softc before reading the interrupt status, so as to avoid a
  similar infinite loop in hdac_one_intr().

This fixes suspend-to-S3 on some laptops.

PR:		261207
Reviewed by:	mav, imp
Tested by:	uqs
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 077564cfdb)
2022-03-24 10:28:14 -04:00
Ed Maste
ff73087a89 hda: add patch for Framework laptop headphone jack
For Framework laptops built after Oct 2021 (like mine) that have a Tempo
Semiconductor 92HD95B codec rather than Realtek ALC295 (see
https://frame.work/ca/en/blog/solving-for-silicon-shortages).

As we do for many other laptops, put the headphone jack and speakers in
the same association by default so that the generic sound device
automatically switches between them.  Also specify the jack colour and
location.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34596

(cherry picked from commit 06731139ca)
2022-03-24 09:52:38 -04:00
Philippe Michaud-Boudreault
43354d9570 sound: add patch for Lenovo Legion 5 AMD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30333

(cherry picked from commit 45f0e57105)
2022-03-24 09:52:37 -04:00
Ed Maste
5694c481e1 snd_hda: restore pin patch for headphones on Lenovo X1 7th Gen
Fixes:		ef790cc740 ("hdaa: update pin patch configurations")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33900

(cherry picked from commit 301b2b02df)
2022-03-24 09:52:37 -04:00
Xin LI
08dfec6cf2 snd_hda(4): Fix sound on headset jack for ThinkPad T51.
sys/dev/sound/pci/hda/hdaa_patches.c:
 match_pin_patches: Use HDA_DEV_MATCH instead of regular ==

sys/dev/sound/pci/hda/pin_patch_realtek.h:
 Add quirk for Lenovo laptops when ALC298 is used.

(cherry picked from commit c43bf3f591)
2022-03-24 09:52:37 -04:00
K Staring
6228b19e0e hdaa: update pin patch configurations
A number of structural changes:
  - Use decimal nid numbers instead of hex
  - updated the branch to incoorporate the suggestions made in the
    ALC280 pull request github thread
  - Convert magic pin values into strings.
  - Also update hdaa_patches to use clearer enums..
  - made pin patch type enum clearer, add macro for 'string' type
    patches
  - Added pin_patch structures to separate data from logic.
  - Integrated Realtek patches into new structure.

These incorporate fixes for ALC255, ALC256, ALC260, ALC262, ALC268,
ALC269, ALC280, ALC282, ALC283, ALC286, ALC290, ALC293, ALC296, ALC2880

And have definitions for a number of Dell and HP laptops.

Much of this data has been mined fromt he tables in the Linux driver.

imp squashed these into one commit because the changes from the github
pull requests no longer cleanly apply individually and made light style
changes after feedback from jhb.

Pull Request:		https://github.com/freebsd/freebsd-src/pull/139
Pull Request:		https://github.com/freebsd/freebsd-src/pull/140
Pull Request:		https://github.com/freebsd/freebsd-src/pull/141
Pull Request:		https://github.com/freebsd/freebsd-src/pull/142
Pull Request:		https://github.com/freebsd/freebsd-src/pull/143
Pull Request:		https://github.com/freebsd/freebsd-src/pull/144
Pull Request:		https://github.com/freebsd/freebsd-src/pull/145
Pull Request:		https://github.com/freebsd/freebsd-src/pull/146
Pull Request:		https://github.com/freebsd/freebsd-src/pull/147
Pull Request:		https://github.com/freebsd/freebsd-src/pull/148
Pull Request:		https://github.com/freebsd/freebsd-src/pull/149
Pull Request:		https://github.com/freebsd/freebsd-src/pull/150
Differential Revision:	https://reviews.freebsd.org/D30619

(cherry picked from commit ef790cc740)
(cherry picked from commit 29b4fa7876)
(cherry picked from commit a10c85e0f9)
(cherry picked from commit 86d69de88d)
2022-03-24 09:52:37 -04:00
Alexander Motin
c79ba14012 ipmi: Make all sysctls also tunables.
MFC after:	1 week

(cherry picked from commit 016d18229c)
2022-03-23 20:50:25 -04:00
Roger Pau Monné
41a0aef504 vt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized
There's too many broken hardware out there that wrongly has the
ACPI_FADT_NO_VGA bit set. Ignore it unless running as a virtualized
guest, as then the expectation would be that the hypervisor does
provide correct ACPI tables.

Reviewed by: emaste, 0mp, eugen
Sponsored by: Citrix Systems R&D
PR: 230172

(cherry picked from commit 0518832011)
2022-03-23 14:44:30 +01:00
Ed Maste
79902c8c2d Add Tempo Semiconductor 92HD95B HDA codec ID
This codec is found in recent versions of the Framework laptop.  Tempo
Semiconductor acquired these products from IDT's Audio Business Unit.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e997f33700)
2022-03-22 21:27:16 -04:00
hlh-restart
205fa5f0a5 rtsx: Call rtsx_init() on resume.
MFC after:	3 days

(cherry picked from commit 1b1bab0078)
2022-03-21 20:28:34 -04:00
Vincenzo Maffione
ddb842e2ad netmap: add a tunable for the maximum number of VALE switches
The new dev.netmap.max_bridges sysctl tunable can be set in
loader.conf(5) to change the default maximum number of VALE
switches that can be created. Current defaults is 8.

MFC after:	2 weeks

(cherry picked from commit dd6ab49a9a)
2022-03-20 09:00:50 +00:00
Vincenzo Maffione
9f600a260a netmap: Fix TOCTOU vulnerability in nmreq_copyin
The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after:	3 days

(cherry picked from commit 3937299165)
2022-03-19 17:36:39 +00:00
Vincenzo Maffione
9df8dd3ea3 netmap: Fix integer overflow in nmreq_copyin
An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085

(cherry picked from commit 694ea59c70)
2022-03-19 17:36:27 +00:00
Eugene Grosbein
4a11315a2c virtio_random(8): MFC: avoid deadlock at shutdown time (regression fix)
FreeBSD 13+ running as virtual guest may load virtio_random(8) driver
by means of devd(8) unless the driver is blacklisted or disabled
via device.hints(5). Currently, the driver may prevent
the system from rebooting or shutting down correctly.

This change deactivates virtio_random at very late stage
during system shutdown sequence to avoid deadlock
that results in kernel hang.

PR:		253175
Tested by:	tom
Relnotes:	yes

(cherry picked from commit adbf7727b3)
2022-03-19 11:20:58 +07:00
Hans Petter Selasky
19b779498c xhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".
Submitted by:		John F Carr <jfc@mit.edu>
Sponsored by:		NVIDIA Networking

(cherry picked from commit 19837718ab)
2022-03-17 10:55:18 +01:00
Hans Petter Selasky
ea318f1ad1 xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".
Tested by:	br@
Sponsored by:	NVIDIA Networking

(cherry picked from commit 33cbbf268f)
2022-03-16 15:55:22 +01:00
Colin Percival
dd6c1475a6 Add support for getting early entropy from UEFI
UEFI provides a protocol for accessing randomness. This is a good way
to gather early entropy, especially when there's no driver for the RNG
on the platform (as is the case on the Marvell Armada8k (MACCHIATObin)
for now).

If the entropy_efi_seed option is enabled in loader.conf (default: YES)
obtain 2048 bytes of entropy from UEFI and pass is to the kernel as a
"module" of name "efi_rng_seed" and type "boot_entropy_platform"; if
present, ingest it into the kernel RNG.

Submitted by:	Greg V
Reviewed by:	markm, kevans
Approved by:	csprng (markm)
Differential Revision:	https://reviews.freebsd.org/D20780
2022-03-10 18:11:41 -08:00
Hans Petter Selasky
cea6dbdf1b Make sure the avr32dci_odevd structure is used.
This fixes a compilation error.

Sponsored by:	NVIDIA Networking

(cherry picked from commit 3f5054862a)
2022-03-10 09:29:22 +01:00
Hans Petter Selasky
9997736943 Factor out repeated code in the USB controller drivers to avoid bugs
computing the same isochronous start frame number over and over again.

PR:		257082
Sponsored by:	NVIDIA Networking

(cherry picked from commit 8fc2a3c417)
(cherry picked from commit f52783fcf5)
(cherry picked from commit cf48d1f771)
2022-03-10 09:29:19 +01:00