Commit graph

42094 commits

Author SHA1 Message Date
Mark Johnston
8adca661c2 mpi3mr: Check for copyin errors in mpi3mr_map_data_buffer_dma()
A failed copyin will cause the driver to use the contents of
uninitialized buffers instead, which is unlikely to be the behaviour
that we want.  Check for errors.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43098

(cherry picked from commit 6bfb7306ef92aaccffae42ed00ce6d7201b76966)
2024-01-01 19:29:45 -05:00
Mark Johnston
f9946e9ae7 uhid: Check for errors from copyin() in ioctl handlers
This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43103

(cherry picked from commit b2caed2f8d699d6dc59ecf8810d945cdea148c44)
2024-01-01 19:29:44 -05:00
Mark Johnston
4f1e5e94d4 hid: Handle errors from copyin() in ioctl handlers
If copyin() fails, the driver will proceed blindly with a zeroed buffer,
which is not what we want.  In preparation for annotating copyin() with
__result_use_check, start checking for errors.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43102

(cherry picked from commit e452fa70d50761b5fe5f19c3c93c107be116728c)
2024-01-01 19:29:43 -05:00
Mark Johnston
9483388587 ath: Handle errors from copyout() in ath_rate_fetch_node_stats()
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43096

(cherry picked from commit 711880597c6c4ac971eb2aba6a2dadb5933d38dd)
2024-01-01 19:29:39 -05:00
Yuji Hagiwara
1e9df419f1 mlx4(5): fix driver initialization
PR:	275897
MFC after:	1 week

(cherry picked from commit 553ed8e38bfdd4832deecdec1c0b023824dcff94)
2023-12-30 02:24:07 +02:00
John Baldwin
90ac116d5e nehemiah RNG: Switch to using FPU_KERN_NOCTX
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41583

(cherry picked from commit 7aec088cbce8381bd5bf730419b8fdcddf43b08d)
2023-12-29 13:49:41 -08:00
Ronald Klop
028e4c6548 Teach if_smsc to get MAC from bootargs.
Some Raspberry Pi pass smsc95xx.macaddr=XX:XX:XX:XX:XX:XX as bootargs.
Use this if no ethernet address is found in an EEPROM.
As last resort fall back to ether_gen_addr() instead of random MAC.

(cherry picked from commit 3878bbf1bb9e68f8579b57cde7d4e5c77de93320)

if_smsc: fix build on armv6 & armv7

compile error was:
/usr/src/sys/dev/usb/net/if_smsc.c:1597:40: error: format specifies type 'unsigned long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
                                "failed alloc for bootargs (%lu)", len);
                                                            ~~~    ^~~
                                                            %zd

(cherry picked from commit 8a0ee306227a17a998bdc7af2275fd94b9164342)

PR:	274092
Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	imp, karels, zlei
Tested by:	Patrick M. Hausen
Approved by:	karels
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D42463
2023-12-28 15:40:31 +01:00
Ram Kishore Vegesna
0a6b61a89a ocs_fc: Use xpt_path_sbuf() to copy the path to sbuf.
Reported by:	imp
 MFC after:	1 week

(cherry picked from commit a9504d76ccdad240b7d5761f4208e252f57042dd)
2023-12-27 17:49:51 +05:30
Ram Kishore Vegesna
b70cf00842 ocs_fc: IO timeout handling and error reporting fix.
Hardware timeout uses a 8-bit timeout value and expects the timeout to
be less than 255 seconds. Added software timer implemetation to timeout
and abort the IOs with timeout more than 255 seconds.

Fix the timeout problem by dividing CAM timeouts by 1000 as hardware
expects timeout value in seconds.  Before this change, CAM timeouts in
milliseconds were getting truncated to 8 bits and converted to seconds.
So the actual timeout used when going down to the card would depend on
the bottom 8 bits of the timeout used.

Add the mapping of ocs_fc error status to CAM status.

Reported by:	ken
Reviewed by:	ken
Tested by:	ken, ram
Approved by:	ken
MFC after:	1 week

(cherry picked from commit 70547544ce931357c980be47d937e5b57a2d7f49)
2023-12-27 17:46:08 +05:30
Mark Johnston
dcd747fda5 nvme: Initialize HMB entries before loading them into the controller
struct nvme_hmb_desc contains a pad field which was not getting
initialized before being synced.  This doesn't have much consequence but
triggers a report from KMSAN, which verifies that host-filled DMA memory
is initialized before it is made visible to the device.  So, let's just
initialize it properly.

Reported by:	KMSAN
Reviewed by:	mav, imp
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43090

(cherry picked from commit d9b7301bb791faab48b6c7733c34078427b9a374)
2023-12-25 11:58:19 -05:00
Alexander Motin
129c3aa4b2 Use xpt_path_sbuf() in few drivers
xpt_path_string() is now a wrapper around xpt_path_sbuf().  Using it
to than concatenate result to another sbuf makes no sense.  Just call
xpt_path_sbuf() directly.

MFC after:	1 month

(cherry picked from commit 8c4ee0b22c98fc1e208dd133f617bd329cd10728)
2023-12-22 23:36:56 -05:00
Kenneth D. Merry
504e85ade1 mpr, mps: Establish busdma boundaries for memory pools
Most all of the memory used by the cards in the mpr(4) and mps(4)
drivers is required, according to the specs and Broadcom developers,
to be within a 4GB segment of memory.

This includes:

System Request Message Frames pool
Reply Free Queues pool
ReplyDescriptorPost Queues pool
Chain Segments pool
Sense Buffers pool
SystemReply message pool

We got a bug report from Dwight Engen, who ran into data corruption
in the BAE port of FreeBSD:

> We have a port of the FreeBSD mpr driver to our kernel and recently
> I found an issue under heavy load where a DMA may go to the wrong
> address. The test system is a Supermicro X10SRH-CLN4F with the
> onboard SAS3008 controller setup with 2 enterprise Micron SSDs in
> RAID 0 (striped). I have debugged the issue and narrowed down that
> the errant DMA is one that has a segment that crosses a 4GB
> physical boundary.  There are more details I can provide if you'd
> like, but with the attached patch in place I can no longer
> re-create the issue.

> I'm not sure if this is a known limit of the card (have not found a
> datasheet/programming docs for the chip) or our system is just
> doing something a bit different. Any helpful info or insight would
> be welcome.

> Anyway, just thought this might be helpful info if you want to
> apply a similar fix to FreeBSD. You can ignore/discard the commit
> message as it is my internal commit (blkio is our own tool we use
> to write/read every block of a device with CRC verification which
> is how I found the problem).

The commit message was:

> [PATCH 8/9] mpr: fix memory corrupting DMA when sg segment crosses
> 4GB boundary

> Test case was two SSD's in RAID 0 (stripe). The logical disk was
> then partitioned into two partitions. One partition had lots of
> filesystem I/O and the other was initially filled using blkio with
> CRCable data and then read back with blkio CRC verify in a loop.
> Eventually blkio would report a bad CRC block because the physical
> page being read-ahead into didn't contain the right data. If the
> physical address in the arq/segs was for example 0x500003000 the
> data would actually be DMAed to 0x400003000.

The original patch was against mpr(4) before busdma templates were
introduced, and only affected the buffer pool (sc->buffer_dmat) in
the mpr(4) driver. After some discussion with Dwight and the
LSI/Broadcom developers and looking through the driver, it looks
like most of the queues in the driver are ok, because they limit
the memory used to memory below 4GB. The buffer queue and the chain
frames seem to be the exceptions.

This is pretty much the same between the mpr(4) and mps(4) drivers.

So, apply a 4GB boundary limitation for the buffer and chain frame pools
in the mpr(4) and mps(4) drivers.

Reported by:	Dwight Engen <dwight.engen@gmail.com>
Reviewed by:	imp
Obtained from:	Dwight Engen <dwight.engen@gmail.com>
Differential Revision:	<https://reviews.freebsd.org/D43008>

(cherry picked from commit 264610a86e14f8e123d94c3c3bd9632d75c078a3)
2023-12-20 10:40:42 -05:00
Gordon Bergling
2ad07dc6ce qat: Fix two typos in source code comments
- s/parmeters/parameters/

(cherry picked from commit ada4cd3f7710d9759e391e84ad21b7763062bdbc)
2023-12-20 08:35:25 +01:00
Vladimir Kondratyev
36d6a45654 ig4: Add PCI IDs for Intel Ice Lake I2C controller.
PR:		275115
Tested by:	Sam <sam3423.yntmr_AT_slmail_DOT_me>
2023-12-19 23:34:56 +03:00
Mark Johnston
d264ddb9c7 bhnd: Correct the softc size in the siba_bhndb_driver definition
struct siba_bhndb_softc embeds struct siba_softc and adds an extra
field, "quirks".  In practice, this bug was harmless since "quirks" is
unconditionally initialized during driver attach and would have lived in
the redzone of the softc allocation, but KASAN catches the out-of-bounds
access.

PR:		275515
Reported by:	Frank Hilgendorf <frank.hilgendorf@posteo.de>
MFC after:	1 week

(cherry picked from commit 4c3aa00c0a0093c78f42d138bb9eef9b1a7cbb39)
2023-12-11 19:30:05 -05:00
Mitchell Horne
121656c2b1 pst: improve shutdown_post_sync handler
It is desirable to shut down the raid controller even in the face of a
panic. In the SCHEDULER_STOPPED() case, set the interrupt mask bits so
that we request a polled wait, rather than sleep(), from
iop_queue_wait_msg().

Tweak the function name and signature.

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

(cherry picked from commit c4dacfa7f4b82f23ec0924d9db772860b2066f9b)
(cherry picked from commit f97aab79868cd7d891c52b14bd964523fa56f015)
2023-12-08 18:02:45 -04:00
Mitchell Horne
a8ba64ca91 iscsi: adjust shutdown_pre_sync handler
Don't attempt to service reconnections if RB_NOSYNC is set. More
crucially, don't do it if the scheduler is stopped, as the maintenance
thread will never run again.

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

(cherry picked from commit 2ce1c45b3411410a5d0a4d08198a3b0010d493b7)
2023-12-08 18:02:44 -04:00
Mitchell Horne
c13f564f91 xen: improve shutdown hook
Make better use of the shutdown flags. In particular this now handles
standard reboot where RB_POWERCYCLE is not set, and indicates a crash
when the system has panicked.

While here, give the function a prefix.

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

(cherry picked from commit 9e0b0f5de67fd46bddf0e12ef7b71d76a7ec1667)
2023-12-08 18:02:44 -04:00
Mitchell Horne
951d60ee3a shutdown: audit shutdown_post_sync event callbacks
Ensure they are all panic/debugger safe.

Most handlers for this event are for disk drivers/geom modules. There
are a mix of checks being used here (or not), so let's standardize on
checking the presence of the RB_NOSYNC flag.

This flag is set whenever:
 1. The kernel has panicked and kern.sync_on_panic=0*
 2. We reboot from within the kernel debugger (the "reset" command)
 3. Userspace requested it, e.g. by 'reboot -n'

Name the functions consistently.

*This sysctl is tuned to zero by default, but its existence means that
these handlers can be executed after a panic, at the user's discretion.
IMO this use-case is implicitly understood to be risky, and we'd be
better off eliminating it altogether.

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

(cherry picked from commit 4eb861d362d6a9493df7f77eab8e28f9c826702a)
2023-12-08 18:02:44 -04:00
Mitchell Horne
9af585120d pst-raid.c: sort #includes
Reviewed by:	imp, jhb
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42336

(cherry picked from commit 66d9c2f38d2db9e50c0dbf56dca4a2f3e6c3107c)
2023-12-08 18:02:44 -04:00
Mitchell Horne
c154cad532 hptmv: remove vestigial EVENTHANDLER_DEREGISTER()
The registration was removed in favor of DEVICE_SHUTDOWN(). Drop the
unused eventhandler tag from the IAL_ADAPTER_T structure.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:	cd3ef66680 ("Use DEVICE_SHUTDOWN(9) mechanism...")
Differential Revision:	https://reviews.freebsd.org/D42334

(cherry picked from commit a4b19cf5c76ac66d02a3ef8a549115ba865d630c)
2023-12-08 18:02:44 -04:00
Eugene Grosbein
8c165cbaf0 usbdevs: add quirk for WD MyPassport Ultra External HDD
WD MyPassport Ultra External HDD needs quirk
UQ_MSC_NO_TEST_UNIT_READY to attach.

(cherry picked from commit 970d73856b626a68597de19d37b68c376e2c0491)
2023-12-06 11:21:42 +07:00
Patrisious Haddad
0312449c67 mlx5: Fix HCA cap 2 query
(cherry picked from commit 0cd90ee598cef68cef72db8b912241868d1067d0)
2023-12-06 02:27:14 +02:00
Bjoern A. Zeeb
45000447c1 mii: add Vitesse/Microsemi VSC8514
The VSC8514 Quad-Port 10/100/1000BASE-T PHY seems to match the handling
for the VSC8504 (for the little we support of what we could) and while
it works with our generic ukphy add it as vscphy for porper display of
names in the system message buffer and the like (or in case we decide
to implement some extra features).

Tested on:	Ten64

(cherry picked from commit 1965dd85c3b33ed99cb8ef164dd7c5b20425a85e)
2023-11-30 00:36:56 +00:00
Bjoern A. Zeeb
c3216127bc mii: resort VSC8641 entry in miidevs
VSC8641 is a ciphy not a vscphy.
Sort it with the other entries of ciphy to avoid confusion.

(cherry picked from commit 43324ec770f6b598f0ce25487f69a64b3c9822bd)
2023-11-30 00:36:56 +00:00
Bjoern A. Zeeb
e0910cf2d6 dpaa2: make software VLANs usable on dpni
dpni announces IFCAP_VLAN_MTU but internally does not increase the
maximum frame length.  Createing a vlan interface on top of a dpni
interface will result in full-sized frames not passing.
Extend the maximum frame length by ETHER_VLAN_ENCAP_LEN to allow at
least for one layer of (software) vlans for now

GH-Issue:	https://github.com/mcusim/freebsd-src/issues/22
Reviewed by:	dsl
Differential Revision: https://reviews.freebsd.org/D42645

(cherry picked from commit 0480dccd3f347da0dbccf5917633435d5ce6cb86)
2023-11-30 00:36:56 +00:00
Bjoern A. Zeeb
91987a9597 dpaa2: defer link_state updates until we are up
dpaa2_ni_media_change() was called in early setup stages, before we
were fully setup.  That lead to internal driver state being all synched
and fine but hardware state was lost/never setup corrently.

Introduce dpaa2_ni_media_change_locked() so we can avoid reccursive
locking and call "dpaa2_ni_media_change()" instead of mii_mediachg()
as the latter does not setup our state there either.

In order for this all to work, call if_setdrvflagbits() just before
rather than after the above.

Also remove an unecessary direct call to dpaa2_ni_miibus_statchg()
which mii_mediachg() will trigger anyway.

This all fixes a problem [1] that one had to lose the link (either
unplugging/replugging the cable or using ifconfig media none;
ifconfig media auto) to re-trigger the all updates and get the
full state programmed when hardware expected.

GH-Issue:	https://github.com/mcusim/freebsd-src/issues/21 [1]
Reviewed by:	dsl, dch
Differential Revision: https://reviews.freebsd.org/D42643

(cherry picked from commit 964b3408fa872178aacf58f2d84dc43564ec0aa7)
2023-11-30 00:36:56 +00:00
Bjoern A. Zeeb
9197f220d8 dpaa2: fdt improve detection for dpmac/phys
'pcs-handles' are not mandatory in the device tree here so do not
enforce them.  This allows us to find dpmac entries needed for phys
on the WHLE-LS1 as well.

Reviewed by:	jceel, dsl
Differential Revision: https://reviews.freebsd.org/D42644

(cherry picked from commit 6c46ebb05dccdcee18f64dc122e6685c05180217)
2023-11-30 00:36:56 +00:00
Vladimir Kondratyev
16a379ffde hmt(4): Do not require input report HID usages to be a member of TLC
Some touchpads places button usages (in HID report descriptor) in to
the 2-nd level collection rather than in to the top level one. That
confuses current code. Remove collection level check in HID report
descriptor parser to fix device detection.

Reported by:	Peter Much <pmc@citylink.dinoex.sub.org>
PR:		267094

(cherry picked from commit 1d46c8e5c2702c141c6be982b3ca44e74d1cb8f1)
2023-11-27 18:20:16 +03:00
Vladimir Kondratyev
dad62799f5 evdev: Sync event codes with Linux kernel 6.5
(cherry picked from commit 87a53bef41fe769920f925e74fedddafd5187b93)
2023-11-27 18:19:55 +03:00
Gordon Bergling
ab3a178eb1 ath(4): Fix a typo in a source code comment
- s/mutiple/multiple/

(cherry picked from commit 4e36d081f377ecfa8375e5fe3d0763099f4a780d)
2023-11-26 08:53:44 +01:00
Mazin Fadl
6c22e9fa0c usb: add necessary quirks for the NOREL Systems NS1081 SD reader
Without these, the Norelsys NS1081 is completely defunct.

PR:	263868
Fixes:	7520b88860 ("usb(4): Automagically apply all quirks [...]")
(cherry picked from commit b332adfa96218148dfbb936a9c09d00484c868e3)
2023-11-25 22:07:11 -06:00
Mazin Fadl
93f1302dc6 usb: add quirks for the Genesys GL3220 card reader
Without these, card hotplugging does not work on the GL3220.

PR:	263868
Fixes:	7520b88860 ("usb(4): Automagically apply all quirks [...]")
(cherry picked from commit 94efe9f91be7f3aa501983716db5a4378282a734)
2023-11-25 22:07:11 -06:00
Brad Smith
d0b589b231 re(4): Add support for 8168FP HW rev
(cherry picked from commit 88d2b69c719a20da9eb53f1c58adf6ecb005f8ce)
Differential Revision:	https://reviews.freebsd.org/D42671
2023-11-25 16:38:05 -08:00
Martin Matuska
ac83e415ef mlx5_core: fix deadlock when using RXTLS
If removing a node of type FS_TYPE_FLOW_DEST we lock the flow group too
late. This can lead to a deadlock with fs_add_dst_fg().

PR:		274715
Reviewed by:	kib
Tested by:	mm
Differential Revision: https://reviews.freebsd.org/D42368

(cherry picked from commit a592812327deaf69ab226afc5c8a01af43dc03c2)
2023-11-22 09:00:23 +01:00
Konstantin Belousov
8377dd1c9a mlx5core: add linux/bitops.h include for mlx5_ifc.h use of BIT()
(cherry picked from commit 97beac79edf450851474934199e504e6244a7116)
2023-11-22 03:40:28 +02:00
Patrisious Haddad
588203bfbd mlx5: Introduce new destination type TABLE_TYPE
(cherry picked from commit 7b959396ca6fae5635260131eedb9bc19f2726a3)
2023-11-22 03:40:28 +02:00
Konstantin Belousov
d826188941 mlx5ib: adjust for the mlx5_create_auto_grouped_flow_table() interface change
(cherry picked from commit b94ef2a3bcbb369d85b276a45504d42f2f2cd369)
2023-11-22 03:40:28 +02:00
Mark Bloch
e073fccf14 mlx5: add ability to attach flow counter to steering rule
(cherry picked from commit ad744541311bfddd74ea3c5d49d52a4c366b9762)
2023-11-22 03:40:28 +02:00
Raed Salem
52164cb3bd mlx5: add fs_counters
(cherry picked from commit 35bbcf0916992d77fe1521962db42b3106a701fb)
2023-11-22 03:40:28 +02:00
Mark Bloch
5a2ff1f03a mlx5: Add a no-append flow insertion mode
(cherry picked from commit 6a6af22b6ec42eb0436381fae8dd1b86bc4c6327)
2023-11-22 03:40:28 +02:00
Mark Bloch
67a9c8868a net/mlx5: Allow creating autogroups with reserved entries
(cherry picked from commit 0a5db6bb3a953bd22f53f3607ae6853487548532)
2023-11-22 03:40:28 +02:00
Mark Bloch
4c6a46cea4 net/mlx5: Fix auto group size calculation
(cherry picked from commit 04db54fe4309e896c4c80baadbcc47b171722027)
2023-11-22 03:40:28 +02:00
Mark Bloch
0759f76e57 mlx5: Use software enum in APIs instead of PRM
(cherry picked from commit 76ed99ed8ad259792fea752461e2cd1ed481e8e1)
2023-11-22 03:40:28 +02:00
Mark Bloch
6fb2eebf64 mlx5: Add packet reformat support to flow rules
(cherry picked from commit 45e2e55df665c9b5749c9f2269d1b804147917eb)
2023-11-22 03:40:27 +02:00
Mark Bloch
8895a05096 mlx5: Add modify header support to flow rules
(cherry picked from commit 847542c60c2b3d922d636cc36ce51714032f9825)
2023-11-22 03:40:27 +02:00
Mark Bloch
08e7b322db mlx5: Refactor flow actions into a struct
(cherry picked from commit cb054a493a95cbd5a4b00c693c3924622914c51a)
2023-11-22 03:40:27 +02:00
Mark Bloch
87d86f3733 mlx5: Add packet reformat allocation support
(cherry picked from commit bb4645b95b0b3976decb4e68934b2e5cc002c53d)
2023-11-22 03:40:27 +02:00
Mark Bloch
2b729c222d mlx5: Add modify header support
(cherry picked from commit e4f84168b3c8bf99297dda712b147906d463b20e)
2023-11-22 03:40:27 +02:00
Aaron LI
9ed67f1307 if_wg: Missing radix unlock can cause deadlock
In function 'wg_aip_add()', the error path of returning ENOMEM when
(node == NULL) is forgetting to unlock the radix tree, and thus may lead
to a deadlock.

PR:		275001
Reviewed by:	kp
MFC after:	1 week

(cherry picked from commit dcc4d2939f789a6d1f272ffeab2068ba2b7525ea)
2023-11-18 10:46:21 +01:00