mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
There are significant problems with the current autoquirk code. This results in quite a bit of bogus over-quirking. Most commands don't do the proper "sense" dance to get the scsi sense codes to see if the failures are interesting or not. A number of 'sleeps' are used to try to get around this, but they are racy. Rather than fix these, use better hueristics just introduced to catch SYNCHRONIZE CACHE problems, etc. The test for getting max lun number was bogus. It would set this quirk both on errors and when 0 was returned. It appears to be an attempt to filter our REPORT LUNS error messages that are actually benign (we ignore the errors properly). These errors are also only filtered sometimes, so the test is unreliable. In addition, it's doing exactly the same test that the umass driver is doing and recovering in the same way. There's no value add here. The TEST UNIT READY almost always fails because the drive is becoming ready. The SENSE is usually UNIT ATTENTION 28/0 "Drive went from not ready to ready" which is a normal condition. The crazy looping to get INQUIRY data is odd. It shouldn't be needed and rarely actually fails (I've not seen any, despite using this code on some really sketchy drives). It should set a NO_INQUIRY quirk if it fails, but instead sets a whole bunch of other, mostly unrelated quirks if it fails. The INQUIRY code also doesn't recognie RBC devices as well as DIRECT devices. This means it fails on some older generations of cameras that could actually benefit from this code. The SYNCHRONIZE CACHE test is flawed. It will do the same failed test over and over again in the event the command succeeds. There are better ways to detect probelms. The START STOP test is useless. It doesn't really help on any of the devices I've tested on. It appears to be another result of the failure to properly obtain the SENSE code and do appropriate things with it. The PREVENT ALLOW test is useless. It is overwhelmingly used to prevent an error message later. However, after it was added the error message was changed to be informative and not scary. We properly probe this at runtime on all the devices I tested on. At the end of the tests, we try to clear the SENSE errors, but do so imperfectly. Only one is cleared and we use INQUIRY rather than the better TEST UNIT READY. Attempted re-write to fix this caused additional problems as the reset code was not at all robust (the same sequnce in umass / CAM worked when we disabled this code). In addition, the over-quirking and hair-triggered declaration that SYNCHRONIE CACHE is bad would mean that some working drives that have cache wouldn't flush the cache when WCE=1, leading to corruption. Thankfully, nearly all (but not all) the USB sticks I have default to WCE=0. One, however, did default to WCE=1 and some allow setting it (despite the fact this is a bad idea on removeable devices). However, for real disks attached via USB could be tripped up over this. When we do reset, some small subset of drives are now failing to probe. There are reports on the FreeBSD forums that at least one ebook reader no longer works. A different ebook reads is affected as well (one of my long-time friends has htis). in my collection, one USB memory stick, one SD card reader and one USB to generic PATA adapter no longer work. All of them are pretty obscure (you could literally say they were found in my junk drawer), but are troubling. These problems appear to disappear if we stop doing the auto-quirk code. For all these reasons, I'm turning this off and will likely remove it entirely in the future once the alternative SYNC CACHE code has provent itself. Differential Revision: https://reviews.freebsd.org/D49477 Sponsored by: Netflix
103 lines
3.8 KiB
C
103 lines
3.8 KiB
C
/*-
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2013 Hans Petter Selasky. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
|
|
/*
|
|
* Including this file is mandatory for all USB related c-files in the loader.
|
|
*/
|
|
|
|
#ifndef _USB_FREEBSD_LOADER_H_
|
|
#define _USB_FREEBSD_LOADER_H_
|
|
|
|
/* Default USB configuration */
|
|
#define USB_HAVE_UGEN 0
|
|
#define USB_HAVE_DEVCTL 0
|
|
#define USB_HAVE_BUSDMA 1
|
|
#define USB_HAVE_COMPAT_LINUX 0
|
|
#define USB_HAVE_USER_IO 0
|
|
#define USB_HAVE_MBUF 0
|
|
#define USB_HAVE_TT_SUPPORT 1
|
|
#define USB_HAVE_POWERD 1
|
|
#define USB_HAVE_MSCTEST 1
|
|
#define USB_HAVE_MSCTEST_AUTOQUIRK 0
|
|
#define USB_HAVE_MSCTEST_DETACH 0
|
|
#define USB_HAVE_PF 0
|
|
#define USB_HAVE_ROOT_MOUNT_HOLD 0
|
|
#define USB_HAVE_ID_SECTION 0
|
|
#define USB_HAVE_PER_BUS_PROCESS 0
|
|
#define USB_HAVE_FIXED_ENDPOINT 0
|
|
#define USB_HAVE_FIXED_IFACE 0
|
|
#define USB_HAVE_FIXED_CONFIG 0
|
|
#define USB_HAVE_FIXED_PORT 0
|
|
#define USB_HAVE_DISABLE_ENUM 0
|
|
#define USB_HAVE_MALLOC_WAITOK 0
|
|
|
|
#define USB_CALLOUT_ZERO_TICKS 1
|
|
|
|
#define USB_TD_GET_PROC(td) (td)->td_proc
|
|
#define USB_PROC_GET_GID(td) (td)->p_pgid
|
|
|
|
#if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0)
|
|
/* Use default value. */
|
|
#undef USB_HOST_ALIGN
|
|
#define USB_HOST_ALIGN 8 /* bytes, must be power of two */
|
|
#endif
|
|
/* Sanity check for USB_HOST_ALIGN: Verify power of two. */
|
|
#if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN
|
|
#error "USB_HOST_ALIGN is not power of two."
|
|
#endif
|
|
#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */
|
|
#define USB_BUS_MAX 256 /* units */
|
|
#define USB_MAX_DEVICES 128 /* units */
|
|
#define USB_CONFIG_MAX 65535 /* bytes */
|
|
#define USB_IFACE_MAX 32 /* units */
|
|
#define USB_FIFO_MAX 128 /* units */
|
|
#define USB_MAX_EP_UNITS 32 /* units */
|
|
#define USB_MAX_EP_STREAMS 8 /* units */
|
|
#define USB_MAX_PORTS 255 /* units */
|
|
|
|
#define USB_MAX_FS_ISOC_FRAMES_PER_XFER (120) /* units */
|
|
#define USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120) /* units */
|
|
|
|
#define USB_HUB_MAX_DEPTH 5
|
|
#define USB_EP0_BUFSIZE 1024 /* bytes */
|
|
#define USB_CS_RESET_LIMIT 20 /* failures = 20 * 50 ms = 1sec */
|
|
|
|
#define USB_MAX_AUTO_QUIRK 8 /* maximum number of dynamic quirks */
|
|
|
|
#define USB_IN_POLLING_MODE_FUNC() 0
|
|
#define USB_IN_POLLING_MODE_VALUE() 0
|
|
|
|
typedef uint32_t usb_timeout_t; /* milliseconds */
|
|
typedef uint32_t usb_frlength_t; /* bytes */
|
|
typedef uint32_t usb_frcount_t; /* units */
|
|
typedef uint32_t usb_size_t; /* bytes */
|
|
typedef uint32_t usb_ticks_t; /* system defined */
|
|
typedef uint16_t usb_power_mask_t; /* see "USB_HW_POWER_XXX" */
|
|
typedef uint16_t usb_stream_t; /* stream ID */
|
|
|
|
#endif /* _USB_FREEBSD_LOADER_H_ */
|