Commit Graph

129 Commits

Author SHA1 Message Date
kardel 052322e3b1 Add reading of supported opcodes and their timeouts
at attachment time. Though this information is optional,
it allows to override our fixed timeouts with device
provided timeouts. These timeouts will override the
hardcoded values if the device provided timeouts
exceed the hardcoded values and are less than a day.

Using the device provided timeouts avoids premature
device resets and unreliable operation due to
inadequate timeouts.

Due to the limited implementations of USB
umass devices this feature is disabled for all
umass attached devices.
2019-03-28 10:44:29 +00:00
christos 8e212b8902 Handle the SATA to USB external enclosure sold by "Sabrent" and
made by JMicro (vendor=0x152d product=0x0578). This bridge does
not understand FUA, so add a quirk for it.
2018-10-07 18:14:32 +00:00
mlelstv 0b4ba8daf5 Wait in detach if the discovery thread is still running. Avoids crashes
when a device is attached/detached rapidly.
2018-09-01 07:20:29 +00:00
kamil 1879ee6236 Avoid undefined behavior in scsipiconf.h in _4ltol() and _4btol()
Do not shift (through integer promotion) a signed value in an operation
than can change the bit of signedness.

sys/dev/scsipi/scsipiconf.h:808:17, left shift of 255 by 24 places cannot be represented in type 'int'

Detected with Kernel Undefined Behavior Sanitizer.

Reported by <Harry Pantazis>
2018-07-04 03:17:01 +00:00
mlelstv a6a95dd65a reference count adapter mutex possibly shared by multiple channels.
fix error in atapibusdetach, when a child device cannot be detached,
keep atapibus instance alive.
2016-11-29 03:23:00 +00:00
christos 5b538677ea Move the #endif down to include other kernel only routines. 2016-11-25 02:23:14 +00:00
mlelstv b6a6db8fe4 Make scsipi framework MPSAFE.
Data structures are now protected by a per-adapter mutex at IPL_BIO
that is created by the scsibus or atapibus instance when the adapter
is configured.
The enable reference counter and the channel freeze counter which are
currently used by HBA code before the adapter is configured, are made
atomic.
The target drivers are now all tagged as D_MPSAFE.

Almost all HBA drivers still require the kernel lock to present,
so all callbacks into HBA code are still protected by kernel lock
unless the driver is tagged as SCSIPI_ADAPT_MPSAFE.

TODO: refactor sd and cd to use dksubr.
2016-11-20 15:37:19 +00:00
christos ee17f398d4 move scsipi_strvis -> libkern:strnvisx()
change the prototype to match userland
fix sizes of strings passed to it
2016-05-02 19:18:29 +00:00
dholland da7427b662 "peripheral", not "peripherial". 2014-07-13 17:12:23 +00:00
bouyer 976962ad8c Add a bustype_async_event_xfer_mode() callback to scsipi_bustype (which can
be NULL), so that transport-specific details of transfer mode setting/printing
can be handled more easily.
Move scsipi_async_event_xfer_mode() and scsipi_print_xfer_mode() to
scsi_base.c and split in parallel scsi and FC/SAS parts.
size of struct scsipi_bustype has changed, welcome to 6.99.5
2012-04-20 20:23:20 +00:00
bouyer 63d14cff85 Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
  SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
  subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
  SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
  is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
  so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
  along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
  sync/wide parameters only make sense for parallel SCSI.
  For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
  tagged queing status if enabled. Just be silent for other
  bustypes.

This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
  do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
  call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
  runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
  appropriate parameters is enough to enable tagged queuing,
  but then scsipi will print:
  sd0: async, 8-bit transfers, tagged queueing
  which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
  but will confuse users. With this change scsipi will only print:
  sd0: tagged queueing
  which is correct.

In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
2012-04-19 17:45:20 +00:00
christos d365bff1e6 Add a quirk for the Apple iPod whose mode sense commands fails with not ready.
Seems to work just fine if we send a start command first...
2012-04-06 22:50:39 +00:00
pgoyette 4eee9f144a Update scsiverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
2010-06-07 01:41:39 +00:00
pgoyette 1dad7e2286 Extract SCSIVERBOSE into a kernel module. The module can be builtin
by defining 'options SCSIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

The module is built for all architectures, whether or not SCSI or
atapi support exists.
2010-05-30 04:38:03 +00:00
rmind 40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
christos 467b3dd79a sprinkle #ifdef _KERNEL to make scsictl compile. 2009-05-13 02:35:25 +00:00
cegger 7cf2991222 struct device * -> device_t, no functional changes intended. 2009-05-12 14:38:26 +00:00
gmcgarry 0de5da9678 Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
2008-09-08 23:36:53 +00:00
mlelstv 42e9b7252f Reintroduce the NODOORLOCK quirk. Helps with PR kern/23875. 2008-05-11 05:17:23 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
itohy e73f75f98e If the block size reported by Read Capacity looks valid, just use it.
Use Request Sense only if Read Capacity succeeded and did not return
valid block size.
Discussed on tech-kern.
Fix the easier part of NetBSD PR kern/26537.
(The harder part is the device hangs on large (>= 8KB) transfer.
Possibly umass BBB problem?)

Remove scsipi_size() and scsipi_validate_secsize() from scsipi_base.c
and add their functions to sd.c since they are used only by sd.c.

Use SCSI term `block' instead of `sector' where applicable.
2006-11-26 05:01:09 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
skrll ebb445db43 Remove the boot-from-disk hppa hack now that a real fix has been found. 2006-10-30 16:15:56 +00:00
scw 4526a898c6 Validate the sector size returned by READ CAPACITY. If it looks bogus
print a warning and fallback to a suitable default.

Fixes a problem on hp700 reported by skrll@
2006-10-20 07:11:50 +00:00
scw 056c6fdd05 Some removable umass(4) devices don't respond to mode sense page 6, or
simply return zero for logical block size. In either case, use the sector
length reported by READ_CAPACITY instead of defaulting to 512 bytes.

This partially addresses the problems reported in PR port-i386/34707 and
PR kern/34737. Namely the incorrectly reported drive geometry and the
'hanging' issue.

However, since the device in question reports 2048-byte physical sectors
it will remain unusable until DEV_BSIZE is banished.
2006-10-09 21:29:14 +00:00
perry fbae48b901 Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
2006-02-16 20:17:12 +00:00
perry 93124077ae Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:27:29 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
christos a984bbf91a - remove bogus casts
- add more const
2005-05-30 04:25:32 +00:00
christos 3acb3fe622 - Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
2005-05-29 22:00:50 +00:00
chs a4ef51503f as a stop-gap measure to allow boot-from-disk to work on hppa,
add some padding to the end of struct scsipi_xfer on that platform.
2005-05-18 13:58:10 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
thorpej df9803ce96 Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding.  Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes.  Place items described
by the SCSI Primary Commands document into scsi_spc.h.
2005-02-21 00:29:06 +00:00
reinoud f323bc537c Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
2005-02-01 00:19:34 +00:00
reinoud b220d67a3e Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
2005-01-31 23:06:41 +00:00
reinoud f93ea32254 As part of cleaning up sys/scsipi, replace all u_char by uint8_t and
replace all `short' with int16_t.
2005-01-31 21:13:16 +00:00
thorpej e0747e9825 Use READ/WRITE (16) if the LBA is larger than 32 bits. Another bit
of kern/28514.
2004-12-04 19:02:25 +00:00
thorpej e112950229 And thus spake SBC-3:
If the number of logical blocks exceeds the maximum value that is able to be
specified in the RETURNED  LOGICAL BLOCK ADDRESS field, the device server
shall set the RETURNED LOGICAL BLOCK ADDRESS field to  FFFFFFFFh. The
application client should then issue a READ CAPACITY (16) command (see 5.11)
to  retrieve the READ CAPACITY (16) parameter data.

Implement this in scsipi_size().

First issue in kern/28514.
2004-12-03 20:20:32 +00:00
mycroft 1e243afe67 Remove the "xfer" argument to scsipi_command(). 2004-09-17 23:43:17 +00:00
mycroft ba781da1dc Change the way bustype_cmd is used. Rather than having it be responsible for
calling scsipi_make_xs() and scsipi_execute_xs(), instead push these into
scsipi_command.  Make bustype_cmd and PHOLD/PRELE be called from
scsipi_execute_xs().  This allows us to create a xfer structure -- possibly on
the stack -- and call scsipi_execute_xs() directly.
2004-09-17 23:30:22 +00:00
mycroft 8b6c2af171 Do not manipulate xs->bp in "generic" code -- do it only in the psw_done
routine.  As part of this, pass down our pre-parsed error code -- though this
interface will probably change later to accomodate better error handling.
2004-09-17 23:10:50 +00:00
bouyer 4849b82163 Make the xxstart() functions reentrant again, as some drivers HBA can call
scsipi_done() from their scsipi_request().
For this, add a struct scsipi_xfer * argument to scsipi_command().
If not NULL scsipi_command() will use this to enqueue this xfer, otherwise
it'll try to allocate a new one. This scsipi_xfer has to be allocated
and initialised by scsipi_make_xs() or equivalent.
In xxstart(), allocate a scsipi_xfer using scsipi_make_xs(), and if not NULL,
dequeue the buffer before calling scsipi_command(). This makes sure that
scsipi_command() will not fail, and also makes sure that xxstart() won't
be called again between the BUFQ_PEEK() and BUFQ_GET().

Fix "dequeued wrong buf" panics reported by Juergen Hannken-Illjes in
private mail and Andreas Wrede on current-users@.
Thanks to Jason Thorpe and Chuck Silver for review, and Andreas Wrede for
testing the patch.
2004-09-09 19:35:30 +00:00
thorpej cb3eb355e7 Const poison scsipi_dtype(). 2004-08-21 21:30:29 +00:00
thorpej 3a4c3c0872 - De-__P.
- Use ANSI function decls.
2004-08-21 20:40:36 +00:00
bouyer 751597cddb cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.
2004-03-16 19:10:43 +00:00
bouyer 542c876565 Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.
2004-03-15 22:43:43 +00:00
bouyer 285ce8d78e Indent. 2004-03-15 22:28:30 +00:00
mycroft 289d7af075 Remove PQUIRK_CDROM. It is definitely not correct -- witness that no other
OS needs such a hack, and the same drive works fine on Suns -- and is much
more likely to be a bug in the host adapter driver (which is corroborated by
the PQUIRK_NOLUNS).
2004-02-22 07:26:15 +00:00