Commit Graph

4352 Commits

Author SHA1 Message Date
Greg Lehey
31e076d70b Add devices and quirks for some Olympus cameras.
Reviewed by:	hps@
Fixes:	   	Problems attaching Olympus cameras.
MFC after:	2 weeks
2022-03-23 12:40:28 +11:00
Hans Petter Selasky
6bce8a35cf usb(4): Check return value from bus_generic_get_device_path().
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-17 15:27:50 +01:00
Hans Petter Selasky
5e203517e0 usb(4): Use the global BUS topology lock where appropriate.
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-17 15:27:45 +01:00
Hans Petter Selasky
19837718ab xhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".
Submitted by:		John F Carr <jfc@mit.edu>
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-16 16:49:00 +01:00
Hans Petter Selasky
c7cd6f809d usb(4): Don't skip calling uhub_explore_sub() even on HUB port errors.
This should fix an issue where the "udev->re_enumerate_wait" field never gets
processed and reset. In this case usbconfig will wait forever and never return.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-08 19:59:23 +01:00
Hans Petter Selasky
a75444c143 u3g(4): Add new USB IDs.
Submitted by:	Matthew Luckie <mjl@luckie.org.nz>
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-08 11:03:33 +01:00
Hans Petter Selasky
33cbbf268f xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".
Tested by:	br@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-03 18:14:21 +01:00
Hans Petter Selasky
fcca9fd98c usbhid(4): Be more restrictive about what requests are allowed from user-space.
MFC after:	1 month
Sponsored by:	NVIDIA Networking
2022-03-03 10:24:43 +01:00
Hans Petter Selasky
8ed5bb59e9 usb(4): Factor out the usb_check_request() function.
No functional change.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-03 10:24:24 +01:00
Vladimir Kondratyev
82e38b012c usbhid(4): Implement USB_REQUEST command in hid_ioctl method
This command is intended to be compatible with USB_REQUEST ioctl.
It is required to perform arbitrary control endpoint requests by device
drivers which can switch between HID and native non-HID modes.

MFC after:	2 month
2022-03-03 02:35:23 +03:00
Warner Losh
9c750429af Add USB UEFI locator support
Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32788
2022-03-01 08:06:42 -07:00
Warner Losh
cae7d9ec83 bus: Add ACPI locator support
Add support for printing ACPI paths. This is a bit of a degenerate case
for this interface since it's always just the device handle if the
device has one. But it is illustrtive of how to do this for a few nodes
in the tree.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D32748
2022-03-01 08:06:41 -07:00
Mark Johnston
ceb246c7b2 cdce: Fix a -Wunused-but-set-variable warning
MFC after:	1 week
2022-02-28 11:08:55 -05:00
Mark Johnston
f4a5d1f6c4 axe: Fix a -Wunused-but-set-variable warning
MFC after:	1 week
2022-02-28 11:07:19 -05:00
Mark Johnston
9218449b98 axge: Fix a -Wunused-but-set-variable warning
MFC after:	1 week
2022-02-28 10:54:32 -05:00
Hans Petter Selasky
7520b88860 usb(4): Automagically apply all quirks for USB mass storage devices.
Currently there are five quirks the USB stack tries to automagically detect:
- UQ_MSC_NO_PREVENT_ALLOW
- UQ_MSC_NO_SYNC_CACHE
- UQ_MSC_NO_TEST_UNIT_READY
- UQ_MSC_NO_GETMAXLUN
- UQ_MSC_NO_START_STOP

If any of the quirks above are set, no further quirks will be probed.

If any of the USB mass storage tests fail, the USB device is
re-enumerated as a last resort to clear any error states from the
device. Then the USB stack will try to probe and attach the umass<N>
device passing the detected quirks.

While at it give more details in dmesg about what is going on.

Tested by:		several
Submitted by:		Idwer Vollering <vidwer_fbsdbugs@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D30919
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-02-24 10:28:55 +01:00
Emmanuel Vadot
fb6cebd8bd usb: Make ext_resources non-optional
EXT_RESOURCES have been introduced in 12-CURRENT and all supported
releases have it enabled in their kernel config.

MFC after:      1 month
Differential Revision:	https://reviews.freebsd.org/D33827
2022-02-21 17:28:52 +01:00
Hans Petter Selasky
e85af89fa7 Add more USB host controller PCI ID's.
Submitted by:	Gary Jennejohn <gljennjohn@gmail.com>
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-02-08 00:29:24 +01:00
Jung-uk Kim
379797d4b4 usb(4): Belatedly add a PCI device ID for AMD Bolton chipset 2022-02-07 13:48:09 -05:00
Hans Petter Selasky
42cf33dd1a Add new USB host controller PCI ID's.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-02-06 13:18:35 +01:00
Hans Petter Selasky
a88e1a04df usb(4): Ignore port resume failures.
If port resume fails, likely the USB device is detached. Ignore such errors,
because else the USB stack might try forever trying to resume the device,
before it will proceed detaching it.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-02-02 13:00:48 +01:00
Alexander V. Chernikov
217481a333 u3g: Add support Quectel EM12-G modem.
Submitted by:	<tda.77793 at gmail.com>
PR:		260218
MFC after:	2 weeks
2022-01-29 09:59:20 +00:00
Andrew Turner
a3cea15680 Fix undefined behaviour in the USB controllers
The USB controller drivers assume they can cast a NULL pointer to a
struct and find the address of a member. KUBSan complains about this so
replace with the __offsetof and __containerof macros that use either a
builtin function where available, or the same NULL pointer on older
compilers without the builtin.

Reviewers: hselasky

Subscribers: imp

Reviewed by:	hselasky
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33865
2022-01-12 13:53:19 +00:00
Hans Petter Selasky
75d20a5e38 rtwn(4): Add new USB ID.
Submitted by:	Wensi <supdrewin@outlook.com>
PR:		261098
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-11 21:19:53 +01:00
Hans Petter Selasky
2891a28052 rtwn(4): Add new USB ID.
Submitted by:	arved@
PR:		260952
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-07 14:02:30 +01:00
Hans Petter Selasky
34bedcee3c uchcom(4): Add new USB ID.
Submitted by:	darius@dons.net.au
PR:		260783
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-07 14:02:30 +01:00
Warner Losh
44796b7e82 mips: remove saf1761
The saf1761 OTG support was only for mips targets (BERI?). Retire it.

Sponsored by:		Netflix
Reviewed by:		brooks
Differential Revision:	https://reviews.freebsd.org/D33706
2022-01-04 16:01:14 -07:00
Hans Petter Selasky
8b60419b79 usb(4): Fix build on 32-bit platforms after 0ec590d24e.
Cast pointer to "long" for now, to match the fueword() prototype.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-18 21:31:58 +01:00
Brooks Davis
ea972feea2 usb: remove COMPAT_32BIT ifdefs
Now that we have proper 32-bit compat support, remove COMPAT_32BIT
ifdefs to allow 32-bit code to use the 64-bit layout of USB ioctl
structs and struct usb_fs_endpoint.

This includes the removal of redundant alignment directives that had
no effect in practice.

Reviewed by:	hselasky, jrtc27 (prior version)
2021-12-17 21:28:39 +00:00
Brooks Davis
0ec590d24e usb: add 32-bit compat for FIFOs
Unlike most 32-bit compatability code, this isn't just a simple thunk
in the ioctl code.  An ioctl (USB_FS_INIT) is used to install a
pointer to an array of usb_fs_endpoint structs which are then used
by the ugen fifo code.  These struct contains an array of pointers
which requires translation.  We change the interfaces around
struct usb_fs_endpoint as follows:
 - We store the size of struct usb_fs_endpoint in struct usb_fifo
   in the USB_FS_INIT handler so we know the ABI of the userspace
   array.
 - APIs to manipulate userspace struct usb_fs_endpoint objects now
   take a struct usb_fifo and an index rather than a pointer to
   the object.  This allows most code to remain oblivious to the
   different struct usb_fs_endpoint sizes.
 - Add ugen_fs_copyin() which copies the struct usb_fs_endpoint
   from userspace, thunking it to the native size if required.
 - Uses of struct usb_fs_endpoint's ppBuffer member are now
   via ugen_fs_getbuffer() which produces a native pointer.
 - Updates to userspace are now handled by ugen_fs_update().

For clarity, single, fixed-sized members now are accessed with
fueword/suword rather than copyin/copyout.

Reviewed by:	hselasky, jrtc27 (prior version)
2021-12-17 21:28:14 +00:00
Brooks Davis
45b48cbc2b usb: real freebsd32 support for most ioctls
Use thunks or alternative access methods to support ioctls without
the COMPAT_32BIT hacks that store pointers in uint64_t's on 32-bit
platforms.  This should allow a normal i386 libusb to work.

On CheriBSD, the sizes of the structs will differ between CheriABI
(the default) and freebsd64 no matter what so we need proper compat
support there.  This change paves the way.

Reviewed by:	hselasky, jrtc27 (prior version)
2021-12-17 21:28:13 +00:00
Warner Losh
c6df6f5322 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831
2021-12-09 17:04:45 -07:00
Mitchell Horne
e43d081f35 ucom: s/sio/ucom/
Seems like a copy-paste error, or at least this made more sense when the
sio(4) driver still existed. This modifies the debug port name displayed
at boot, but otherwise has no functional change.

Reviewed by:	hselasky
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D33278
2021-12-06 10:10:27 -04:00
Andreas Wetzel
cd6f0b4769 rtwn/usb: add product ID for Asus USB N10 Nano Rev. B1
According to information found on the internet the following products
use exactly the same hardware but probably different USB IDs:
- Edimax EW-7811Un V2 (v2)
- Edimax EW-7811GLN 2.0A (v2)
I am not adding them as I cannot verify.

PR:		254280
MFC after:	1 week
2021-12-06 09:43:26 +02:00
Gleb Smirnoff
4b4cce02ac xhci: add PCI IDs for USB controllers found on Supermicro M12SWA-TF 2021-12-02 20:12:33 -08:00
Bjoern A. Zeeb
1910048eb9 USB: add CYUSB330x to usbdevs
Add the Cypress dual USB3/2 HUB CYUSB330x as found in SolidRun's
HoneyComb to usbdevs.
2021-11-29 17:44:08 +00:00
Edward Tomasz Napierala
1cde21402a cdceem(4): Fix "set but not used" warnings
No functional changes.

Sponsored By:	EPSRC
2021-11-29 16:45:15 +00:00
Alexander Motin
cfb0e4d76c xhci: Add PCI IDs for Thunderbolt 3/4 USB controllers.
MFC after:	2 weeks
2021-11-28 21:29:26 -05:00
Alexander Motin
83d7b2f335 xhci: Add PCI IDs from recent Intel CPUs.
MFC after:	2 weeks
2021-11-26 20:35:12 -05:00
Hans Petter Selasky
0229172a65 usb/u3g: Add support for Quectel EM05.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/565
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-11-25 15:29:47 +01:00
Elyes HAOUAS
9097ac9af4 Fix typo on "Celsius"
"Celcius" --> "Celsius"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Pull Request: https://github.com/freebsd/freebsd-src/pull/551/files
2021-11-18 23:05:32 -07:00
Bjoern A. Zeeb
3987e50611 USB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk
Add support for the "snps,dis_rxdet_inp3_quirk" quirk needed
at least on SolidRun's HoneyComb.

Reviewed by:	manu, mw
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D32921
2021-11-10 09:44:44 +00:00
Alexander Motin
dc238358f9 Add some of Intel Alder Lake device IDs.
MFC after:	1 week
2021-11-05 23:06:59 -04:00
Jessica Clarke
29863d1eff xhci: Rework 64-byte context support to avoid pointer abuse
Currently, to support 64-byte contexts, xhci_ctx_[gs]et_le(32|64) take a
pointer to the field within a 32-byte context and, if 64-byte contexts
are in use, compute where the 64-byte context field is and use that
instead by deriving a pointer from the 32-byte field pointer. This is
done by exploiting a combination of 64-byte contexts being the same
layout as their 32-byte counterparts, just with 32 bytes of padding at
the end, and that all individual contexts are either in a device
context or an input context which itself is page-aligned. By masking out
the low 4 bits (which is the offset of the field within the 32-byte
contxt) of the offset within the page, the offset of the invididual
context within the containing device/input context can be determined,
which is itself 32 times the number of preceding contexts. Thus, adding
this value to the pointer again gets 64 times the number of preceding
contexts plus the field offset, which gives the offset of the 64-byte
context plus the field offset, which is the address of the field in the
64-byte context.

However, this involves a fair amount of lying to the compiler when
constructing these intermediate pointers, and is rather difficult to
reason about. In particular, this is problematic for CHERI, where we
compile the kernel with subobject bounds enabled; that is, unless
annotated to opt out (e.g. for C struct inheritance reasons where you
need to be able to downcast, or containerof idioms), a pointer to a
member of a struct is a capability whose bounds only cover that field,
and any attempt to dereference outside those bounds will fault,
protecting against intra-object buffer overflows. Thus the pointer given
to xhci_ctx_[gs]et_le(32|64) is a capability whose bounds only cover the
field in the 32-byte context, and computing the pointer to the 64-byte
context field takes the address out of bounds, resulting in a fault when
later dereferenced.

This can be cleaned up by using a different abstraction. Instead of
doing the 32-byte to 64-byte conversion on access to the field, we can
do the conversion when getting a pointer to the context itself, and
define proper 64-byte versions of contexts in order to let the compiler
do all the necessary arithmetic rather than do it manually ourselves.
This provides a cleaner implementation, works for CHERI and may even be
slightly more performant as it avoids the need to mess with masking
pointers (which cannot in the general case be optimised by compilers to
be reused across accesses to different fields within the same context,
since it does not know that the contexts are over-aligned compared with
the C ABI requirements).

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D32554
2021-10-27 18:38:37 +01:00
Hans Petter Selasky
aad0c65d6b usb(4): Fix for use after free in combination with EVDEV_SUPPORT.
When EVDEV_SUPPORT was introduced, the USB transfers may be running
after the main FIFO is closed. In connection to this a race may appear
which can lead to use-after-free scenarios. Fix this for all FIFO
consumers by initializing and resetting the FIFO queues under the
lock used by the client. Then the client driver will see an empty
queue in all cases a race may appear.

Found by:	pho@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-10-24 19:37:17 +02:00
Bjoern A. Zeeb
9a6695532b net80211/drivers: improve ieee80211_rx_stats for band
While IEEE80211_R_BAND was defined, there was no place to store the
band.  Add a field for that, adjust ieee80211_lookup_channel_rxstatus()
to require it, and update drivers passing "R_{FREQ|IEEE}" in already to
provide the band as well.  For the moment keep the fall-back code
requiring all three fields.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D30662
2021-10-22 09:55:54 +00:00
Bjoern A. Zeeb
76f3b8cb64 USB: adjust the Generic XHCI ACPI probe return value
Change the probe return value from BUS_PROBE_DEFAULT to BUS_PROBE_GENERIC
given this is the "generic" attach method.  This allows individual
drivers using XHCI generic but needing their own intialisation to
gain priority for attaching over the generic implementation.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32257
2021-10-08 10:28:44 +00:00
Gordon Bergling
9599d8141f smsc(4): Fix a typo in a comment
- s/setings/settings/

MFC after:	3 days
2021-10-02 10:45:58 +02:00
Ian Lepore
dc91a9715f Fix busdma resource leak on usb device detach.
When a usb device is detached, usb_pc_dmamap_destroy() called
bus_dmamap_destroy() while the map was still loaded. That's harmless on x86
architectures, but on all other platforms it causes bus_dmamap_destroy() to
return EBUSY and leak away any memory resources (including bounce buffers)
associated with the mapping, as well as any allocated map structure itself.

This change introduces a new is_loaded flag to the usb_page_cache struct to
track whether a map is loaded or not. If the map is loaded,
bus_dmamap_unload() is called before bus_dmamap_destroy() to avoid leaking
away resources.

MFC after:	7 days
Differential Revision:	https://reviews.freebsd.org/D32208
2021-09-28 13:29:10 -06:00
Vladimir Kondratyev
527b6d60f8 wmt(4): Adapt to recent KPI changes
MFC after:	2 weeks
2021-09-02 22:35:26 +03:00