Commit graph

42216 commits

Author SHA1 Message Date
Vladimir Kondratyev
914a0c5e1b LinuxKPI: Remove sys/rman.h include from LKPI headers.
sys/rman.h defines `resource` structure which conflicts with the Linux
structure of the same name. To fix that remove reference to sys/rman.h
from linux/pci.h and move resource management code to linux_pci.c.
Update consumers which were depending on linux/pci.h pollution.

No functional changes intended.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42792

(cherry picked from commit 96ab16ebab6319dce9b3041961b0ab6e20a4fecc)
2024-02-17 23:58:36 +03:00
Jean-Sébastien Pédron
a06b366322 vt(4): Call post-switch callback after replacing the backend
[Why]
For instance, it gives a chance to the new backend to refresh the
screen. This is needed by the vt_drmfb backend and `drm_fb_helper`.

This change was lost when I posted changes to reviews.freebsd.org and it
broken the amdgpu driver... Thanks to manu@ for reporting the problem
and wulf@ to find out the missing change!

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

(cherry picked from commit 40c20fc29cad4d38d9a565e9c7ba78612097308e)
2024-02-17 23:58:35 +03:00
Jean-Sébastien Pédron
fc00c03779 vt(4): Always call vt_window_switch() in vtterm_cnungrab()
[Why]
This ensures that vtterm_cnungrab() is the mirror of vtterm_cngrab().
And the latter always call vt_window_switch() and thus the backend's
vd_postswitch().

This makes sure that whatever the backend did during vtterm_cngrab(), it
can undo it during vtterm_cnungrab().

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

(cherry picked from commit f18b3ce0b7be0b24a743ec59077ca8e7929a353c)
2024-02-17 23:58:34 +03:00
Jean-Sébastien Pédron
2567cf1925 vt(4): Call vd_postswitch callback regardless of the current window
[Why]
We want the same behavior at the backend level, regardless if we need to
switch the current window or not.

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

(cherry picked from commit 16b13bd3fd63be56653296ba54956f5526918445)
2024-02-17 23:58:34 +03:00
Jean-Sébastien Pédron
6b9da4e86e vt(4): New bitblt_text variant making a copy before unlocking vt_buf
[Why]
In the DRM drivers and the integration with vt(4), we need to execute
DRM code outside of the vtbuf_lock. The reason is that this DRM code
acquires locks which can't be acquired when vtbuf_lock, an MTX_SPIN
mutex, is already held.

[How]
A vt(4) backend can now set the `vd_bitblt_after_vtbuf_unlock` flag to
true if it wants to be called outside of vt_buf_lock.

In this case, vt(4) uses an internal version of bitblt_text that uses
the `vd_drawn` arrays, plus a new `vd_pos_to_flush` array, to track
characters to draw/refresh. This internal version then uses the
backend's bitblt_bmp callback to draw the characters after vt_buf has
been unlocked.

Drawing borders and CPU logos is also deferred after the vt_buf lock is
released for the same reason.

We introduce another lock (a default mutex), only used when the
`vd_bitblt_after_vtbuf_unlock` flag is set, to replace part the role of
the vt_buf lock and manage concurrent calls to vt_flush().

The `SC_NO_CONSDRAWN` define is dropped because we now always need the
`vd_drawn` arrays.

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

(cherry picked from commit 162a2b858854656ddd6b75d290be8a640ba8f324)
2024-02-17 23:58:34 +03:00
Jean-Sébastien Pédron
95007bfd64 vt(4): Skip vt_window_switch() for nested panics
[Why]
The same protection was added to vt_flush() in the previous commit. We
want the same one in vt_window_switch(): if e.g. the DRM driver panics
while handling a call to vt_window_switch(), we don't want to
recursively call vt_window_switch() again and trigger another panic.

Reviewed by:	imp, manu
Approved by:	imp, manu
Differential Revision:	https://reviews.freebsd.org/D42750

(cherry picked from commit 24d6f256f825e5d7f8ca6b5d16499f13614f9cdd)
2024-02-17 23:58:34 +03:00
Jean-Sébastien Pédron
608b148760 vt(4): Skip vt_flush() for nested panics
[Why]
If there is a problem with DRM drivers or in their integration with
vt(4) and displaying something on the console triggers a panic, there is
a high chance that displaying that panic will trigger another one,
recursively.

[How]
If vt_flush() is called and it detects is is called resursively from
another panic, it return immediately, doing nothing, to avoid the risk
of triggering another panic.

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

(cherry picked from commit 049e3fba04e82f840cc43080edade0ed415fee72)
2024-02-17 23:58:34 +03:00
Gordon Bergling
adac86cd7b if_eqos: Fix a typo in a kernel error message
- s/errer/error/

(cherry picked from commit 551921a757758353af51cd0283e9e4bcee9a84d2)
2024-02-17 21:30:23 +01:00
Andriy Gapon
b46dedfa48 run acpi_shutdown_final later to give other handlers a chance
For example, shutdown_panic wants to produce some output and maybe take
some input before a system is actually reset.

The change should only make difference for the case of system reset
(reboot), poweroff and halt should not be affected.

The change makes difference only if hw.acpi.handle_reboot is set.  It
used to default to zero until r213755 / ac731af567.

Also, run shutdown_halt even later, after acpi_shutdown_final.  The
reason for that is that poweroff is requested by RB_POWEROFF | RB_HALT
combination of flags.  In my opinion, that command is a bit bipolar, but
since we've been doing that forever, then so be it.  Because of that
flag combination, the order of shutdown_final handlers that check for
either flag does matter.

Some additional complexity comes from platform-specific shutdown_final
handlers that aim to handle multiple reboot options at once.  E.g.,
acpi_shutdown_final handles both poweroff and reboot / reset.  As
explained in 9cdf326b4f, such a handler must run after shutdown_panic to
give it a chance.  But as the change revealed, the handler must also run
before shutdown_halt, so that the system can actually power off before
entering the halt limbo.

Previously, shutdown_panic and shutdown_halt had the same priority which
appears to be incompatible with handlers that can do both poweroff and
reset.

The above also applies to power cycle handlers.

(cherry picked from commit 9cdf326b4faef97f0d3314b5dd693308ac494d48)
(cherry picked from commit e4ab361e53945a6c3e9d68c5e5ffc11de40a35f2)
2024-02-17 17:14:17 +02:00
Andriy Gapon
782b71ccfb hdaa_pcmchannel_setup: do not advertise AC3 8+0
The rest of the sound system supports 7+1 maximum and is not aware of 8+0.

I believe that these messages are caused by 8+0:
kernel: feeder_init(0xfffff801f935d680) on feeder_matrix returned 22
kernel: pcm0: feeder_build_matrix(): can't add feeder_matrix

(cherry picked from commit c053a56c0f5df6db5223316831142e1d8afff64f)
2024-02-17 16:18:04 +02:00
Andriy Gapon
a9bab712eb ichsmb: fix block read operation
First of all and unlike I2C, it's not the master that dictates how many
bytes to read in block read operation.  It's the device that informs the
master how many bytes it's sending back.

Thus, for ichsmb_bread() the count parameter is purely an output
parameter.  The code has been changed to reflect that.
The sanity checking of the response length is now done once it (the
first byte of the response) is received.

While here, handling of ICH_HST_STA_FAILED status bit has been added.
Plus some code style improvements and some new code comments in the
vicinity of the changed code.

(cherry picked from commit cbf7c81b608bb9311e50df9481447dc843083a0e)
2024-02-17 16:15:11 +02:00
Andriy Gapon
b5d826b1b6 change ipmi watchdog to awlays stop when system is halted
That is, wd_shutdown_countdown value is ignored when halting.

A halted system should remain halted for as long as needed until
a power cycle, so the watchdog should not reset the system.

(cherry picked from commit 8fdb26160160c4507eb2f644a982a3e05984cdf6)
2024-02-17 16:15:11 +02:00
Andriy Gapon
e009f28ea4 fix signature of ipmi_shutdown_event
The function had a signature of watchdog_fn while in fact it is used as
shutdown_fn.

(cherry picked from commit 90dc7889825d13290955d0eb7e1fb4388c0a0135)
2024-02-17 16:15:11 +02:00
Andriy Gapon
cd5038b62e mmc_fdt_parse: remove redundant bootverbose check
(cherry picked from commit 43ca38eb59ff194fb6d8ad589e74147d94717bf4)
2024-02-17 16:15:11 +02:00
Andriy Gapon
96b8d8a62b dwmmc: fix a typo
(cherry picked from commit ea7f45d3d8d5d41a9cded5765dea43ed215a663b)
2024-02-17 16:15:11 +02:00
Andriy Gapon
d6e54e538e audio_soc: set "status" as being at simplebus
This is more true and less confusing than previous "at EXPERIMENT".

(cherry picked from commit b587cb69f35cd7bd280fe1f8c82b37f56f10d5cf)
2024-02-17 16:15:10 +02:00
Andriy Gapon
1595c09ee2 gpiopower: trigger low, high and both edges
Power off or reset may be activated either by low or high signal or by an
edge.  So, try everything.

Also, the driver now supports DTS properties for timings.

Finally, the driver does not change the pin configuration during attach.
It is assumed that the pin is already in a state that does not trigger
the power event (otherwise we wouldn't be running).

(cherry picked from commit 320e4beb97618c6964380bfa404a3e96c5de7663)
2024-02-17 16:15:10 +02:00
Andriy Gapon
2036512135 usbdevs: add Ralink RT7601 aka MT7601
This is a popular USB WiFi chip.
Unfortunately, it's not supported by FreeBSD yet.

(cherry picked from commit 5b54b6ac8ca1bc0653a3b31e79c1bffd9b227c6e)
2024-02-17 16:15:10 +02:00
Andriy Gapon
1efdba4362 ds1307: restore hints-based configuration on FDT systems
Fall-through to non-FDT probe code if no matching device node is found.
While here, fix indentation of the switch statement.
Also, make the device description for the hints-based attachment the
same as for FDT attachment.

Fixes:	2486b446db ds1307: add support for the EPSON RX-8035SA I2C RTC
(cherry picked from commit 34694f3da7f9537c34b1878206c65a8cda16c6c0)
2024-02-17 16:15:10 +02:00
Alexander Motin
825b7c222a ntb_hw_plx: Workaround read-only scratchpad registers
On several systems we've noticed that when NTB link goes down, the
Physical Layer User Test Pattern registers we use as additional
scratchpad registers (that is explicitly allowed by the chip specs)
become read-only for about 100us.  I see no explanation for this in
the chip specs, neither why it was not seen before, may be a race.
Since we do need these registers, workaround it by repeating writes
until we succeed or 1ms timeout expire.

MFC after:	1 week

(cherry picked from commit 3883c6fbf232452098ba6ea802ef1426d83d2d68)
2024-02-05 15:37:15 -05:00
Mark Johnston
d87ebf35c8 mlx5: Zero DMA memory mlx5_alloc_cmd_msg() and alloc_cmd_page()
These functions may map more memory for DMA than is actually used, since
the allocator operates on multiples of a 4KB page size.  Thus,
bus_dmamap_sync() can trigger KMSAN reports when the unused portion of
a page is not zero-ed.

Reported by:	KMSAN
Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43133

(cherry picked from commit 47a6fb9d5a2ebec12114a604053ffbd2929f0021)
2024-02-01 09:02:48 -05:00
Christos Margiolis
406d5c5814 sound: use device_set_descf() to set device descriptions
Commit 6b6914c1e21b introduced a printf-like version of
device_set_desc(), so use it to simplify device description setting in
the audio stack.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D43467

(cherry picked from commit f7d3d0a4ded35ba15d63cdf9287b4a2d6f80da11)
2024-01-30 13:07:29 +02:00
Christos Margiolis
e95213b35b usb: use only usb_devinfo() in device_set_usb_desc()
device_set_usb_desc() first tries to fetch device information through
the iInterface descriptor, otherwise it falls back to usb_devinfo().
Since usb_devinfo() is both guaranteed to work, and is more verbose, get
rid of the initial iInterface attempt.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D43383

(cherry picked from commit 45cd29412eadbb0e8c40590a94b10663addac17a)
2024-01-30 13:07:29 +02:00
Christos Margiolis
f7db1b3d7b sound: add missing modules to snd_driver
While here, remove unnecessary break.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D43394

(cherry picked from commit 3a79c3ac8aa3c548aab9ad38acc4f480ab9e7a5b)
2024-01-30 13:07:29 +02:00
Christos Margiolis
b70d135ab4 snd_uaudio: prefix module declaration with "snd_"
Although the module is compiled "snd_uaudio.ko", follow the rest of the
sound modules' naming convention in the declaration as well.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D43396

(cherry picked from commit 06a4376346e55d1c7aefe7a48063dddc4d1da9b9)
2024-01-30 13:07:29 +02:00
Christos Margiolis
9b40b4faa7 sound: remove PCM_KLDSTRING() and fix status strings
PCM_KLDSTRING() prints the kernel module associated with a given audio
device only when that module is not compiled in. Get rid of
PCM_KLDSTRING() altogether and print the driver name (even for modules
that are compiled in) instead, as it implies the module as well.

While here, convert all status strings to the following dmesg-like
format:

[<port|mem> <irq>] on <driver>

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj, imp
Differential Revision:	https://reviews.freebsd.org/D43349

(cherry picked from commit 837cd192ebf2d0d4f5ded8883403ef11e6fa6438)
2024-01-30 13:07:28 +02:00
Christos Margiolis
626d9b8553 snd_uaudio: provide information about the device name and attached driver
Unlike the other sound drivers, snd_uaudio(4) doesn't provide
information about the device's description and the driver it's attached
to. A side-effect of this is that applications such as mixer(8), that
fetch these strings through the OSS API's SNDCTL_CARDINFO ioctl will
show a USB audio device as:

pcm0:mixer: <USB Audio> at ? kld snd_uaudio

This patch replaces the generic "USB Audio" description with the
device's actual manufacturer and product strings, and the "at ?" string
with the driver it's attached to:

pcm0:mixer: <Focusrite Scarlett Solo USB> at uaudio0 kld snd_uaudio

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D43347

(cherry picked from commit 18d87fe4fe3b310796e138855016678453140423)
2024-01-30 13:07:28 +02:00
Florian Walpen
8e471fbc7d snd_hdspe(4): One pcm device per physical ADAT port.
ADAT connections transport 8, 4 or 2 audio channels depending on the
sample rate. Instead of splitting each physical ADAT port into 4
(potentially unmapped) stereo pcm devices, create just one pcm
device of variable channel width for every ADAT port.
Depending on the sample rate and channel width selected, the pcm
channels may be only partially mapped to ADAT channels and vice versa.

Added flexibility of the new channel mapping is also prerequisite to
introduce more pcm device layouts in follow-up commits.

Reviewed by:	br
Differential Revision:	https://reviews.freebsd.org/D43393

(cherry picked from commit d7fde2c9eccf90b2a889e92800f3bc07376e84f6)
2024-01-30 13:07:28 +02:00
Ruslan Bukin
59fccd1e84 Setups with digital audio connections like SPDIF and ADAT require
a designated master clock to stay in sync. Add a sysctl setting
to control the preferred clock source for each HDSPe sound card.
Complement this by sysctl values to list available clock sources,
show the currently effective clock source and display the sync
status of all connections. Clock sources are named according to
RME user manuals.

Submitted by:	Florian Walpen <dev@submerge.ch>
Differential Revision:	https://reviews.freebsd.org/D43252

(cherry picked from commit b6052c10fb4ad70915e2f82ce606fd7715477eef)
2024-01-30 13:07:28 +02:00
Aaron LI
c0c932b27f wg: detach bpf upon destroy as well
bpfattach() is called in wg_clone_create(), but the bpfdetach() is
missing from wg_close_destroy().  Add the missing bpfdetach() to avoid
leaking both the associated bpf bits as well as the ifnet that bpf will
hold a reference to.

PR:		276526

(cherry picked from commit 43be2d7aaf25b719aec8f49aab110c0061f1edec)
2024-01-29 23:37:36 -06:00
Aaron LI
b0fa37f356 if_wg: fix access to noise_local->l_has_identity and l_private
These members are protected by the identity lock, so rlock it in
noise_remote_alloc() and then assert that we have it held to some extent
in noise_precompute_ss().

PR:		276392

(cherry picked from commit 7a4d1d1df0b2e369adcb32aea9ef8c180f885751)
2024-01-29 23:37:33 -06:00
Aaron LI
86986d3810 if_wg: fix erroneous calculation in calculate_padding() for p_mtu == 0
In practice this is harmless; only keepalive packets may realistically have
p_mtu == 0, and they'll also have no payload so the math works out the same
either way.  Still, let's prefer technical accuracy and calculate the amount
of padding needed rather than the padded length...

PR:		276363

(cherry picked from commit b891f61ef538a4e9b4658b4b756635c8036a5788)
2024-01-29 23:37:29 -06:00
Gordon Bergling
91e79edae6 aic7xxx: Fix a typo in a kernel message
- s/recevied/received/

(cherry picked from commit 54e047b13baaa5eb613e98991f807e7b6f893f78)
2024-01-25 07:45:52 +01:00
Gordon Bergling
bddcc06e70 bce(4): Fix a typo in a kernel message
- s/adddress/address/

(cherry picked from commit e1c0d368d630cce01691e1967ada9f36d6b8c751)
2024-01-25 07:45:37 +01:00
Gordon Bergling
7924b5f36b usb: Fix a typo in a source code comment
- s/recevied/received/

(cherry picked from commit d743711016298046ca77c5661bab41739396a180)
2024-01-25 07:45:09 +01:00
Gordon Bergling
a499baff39 vmd(4): Fix typos in source code comments
- s/harwdare/hardware/

(cherry picked from commit b2c48aa4d19268610191a0b7d7b76d01d28b0a13)
2024-01-25 07:44:55 +01:00
Gordon Bergling
d7b74e01f4 aic7xxx: Fix two typos in source code comments
- s/recevied/received/

(cherry picked from commit b971c51a4d9498c26079fd8229f7af6ef1585020)
2024-01-25 07:44:15 +01:00
Gordon Bergling
79934439c1 virtio(4): Fix a typo in a source code comment
- s/recevied/received/

(cherry picked from commit 97a4045aaf36079f54ee05a8cb314b8a90f20af8)
2024-01-25 07:43:30 +01:00
Wei Hu
33cd621105 mana: Fix TX CQE error handling
For an unknown TX CQE error type (probably from a newer hardware),
still free the mbuf, update the queue tail, etc., otherwise the
accounting will be wrong.

Also, TX errors can be triggered by injecting corrupted packets, so
replace the mana_err to mana_dbg logging.

Reported by:	NetApp
MFC after:	1 week
Sponsored by:	Microsoft

(cherry picked from commit 516b5059705b6b8bbba28821dbe05964c128f9a9)
2024-01-24 12:36:13 +00:00
Gordon Bergling
ae09f54c06 ciss(4): Fix a typo in a source code comment
- s/strucutre/structure/

(cherry picked from commit ced92d000a9435745ca2891734e6e37ab1c5e873)
2024-01-23 07:42:18 +01:00
Gordon Bergling
4aed20f637 usb: Fix two typos in source code comments
- s/bascially/basically/
- s/assistence/assistance/

(cherry picked from commit f5e3329a5a480aa1b2904106b2fdfd999439455b)
2024-01-23 07:42:03 +01:00
Gordon Bergling
788c5cebec vmware: Fix a typo in a source code comment
- s/withing/within/

(cherry picked from commit 623848af604116aa33bc8a66d2ac45b4cbaccfd8)
2024-01-23 07:41:49 +01:00
Gordon Bergling
c065e2673c atse(4): Fix a typo in a source code comment
- s/addresss/address/

(cherry picked from commit 2b1e4e5be3047411df5e4d5442aa7de6489a0309)
2024-01-23 07:40:48 +01:00
Warner Losh
e2b71e1490 mpi3mr: Minor tweak to task queue pausing
Use a while loop with cancel / drain to make sure that all tasks have
completed before proceeding to reset.

Suggested by:		jhb
Sponsored by:		Netflix

(cherry picked from commit 272a406042608da9bc3e67e41c6b7fc31d4166b8)
2024-01-19 12:16:50 -05:00
Warner Losh
344cdef0cc mpi3mr: Assume dma_hiaddr is BUS_SPACE_MAXADDR
No sense having a variable for this. So use BUS_SPACE_MAXADDR and remove
dma_hiaddr from softc.

Suggested by:		jhb
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42808

(cherry picked from commit 1ec7c672bc2854a1efb1d50f189d4881163c16c6)
2024-01-19 12:16:50 -05:00
Warner Losh
ac7d9eaf06 mpi3mr: Replace can't happen DataLength == 0 with an assert
Replace the test for DataLength == 0 with an assert. It can't happen,
but an assert doesn't hurt. Emacs removed some trailing white space too.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42807

(cherry picked from commit 2361a0056fc16b5e11df2aa948aaa633ac01d685)
2024-01-19 12:16:50 -05:00
Alexander Motin
23a5782dc0 mpi3mr: Use template for main busdma tag.
Use the simpler template code for the parent busdma tag for all I/O to
this card.

Reviewed by:		mav, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D42607

(cherry picked from commit 489eee0d41dce317678adb0dae8d509a5f1d6d93)
2024-01-19 12:16:50 -05:00
Alexander Motin
2d84c6e894 mpi3mr: Make these bus_dmamap_load calls synchronous
These calls "should" all be synchrounous. There's no bouncing that's
needed for them (at least in the typical case that we have a sane card
that has more bits of dma addresses decoded than we have memory), so
there's no errors possible. Ensure these calls are really synchronous
with BUS_DMA_NOWAIT flags (which should never fail now that the
bus_dmamem_alloc() has succeeded).

Reviewed by:		mav, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D42606

(cherry picked from commit 39a3e6a812ad9c089bd2c4935193f1b3c4c5c35a)
2024-01-19 12:16:50 -05:00
Alexander Motin
c8afd30bdb mpi3mr: Fix MAXPHYS usage
This usage is obsolete. Replace with maximum bus space size. maxphys
will sort itself out at higher levels.

Reviewed by:		mav, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D42605

(cherry picked from commit 4e6d128bd823e5b5d0b058f918c7036978a0e8bf)
2024-01-19 12:16:50 -05:00
Warner Losh
835db41823 mpi3mr: Add firmware version
Publish the firmware version on the card like we do for mps/mpr.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D42588

(cherry picked from commit 28a274342ea0b0666b56704477d2d1c17564942e)
2024-01-19 12:16:50 -05:00