summaryrefslogtreecommitdiffstats
path: root/sys/scsi (follow)
Commit message (Collapse)AuthorAgeFilesLines
* TL;DR -- don't configure devices that return insufficient INQUIRY data.krw2020-11-192-29/+41
| | | | | | | | | | | | | | | Treat INQUIRY data with fewer than SID_SCSI2_HDRLEN bytes as invalid. Use only INQUIRY data returned by the device. Get all available INQUIRY data (up to sizeof(struct scsi_inquiry_data)) even when SCSIDEBUG is not set. Tweak returned INQUIRY data so additional_length field does not point past end of returned data when available data is greater than sizeof(struct scsi_inquiry_data). Missing dmafree() spotted by gnezdo@. ok jmatthew@.
* Introduce scsi_copy_internal_data() to copy 'faked' data from a driver to akrw2020-10-142-2/+23
| | | | | scsi_xfer. Will replace various equivalent functions/hand-rolled chunks, none of which were setting xs->resid.
* Remove 'void *sc_sdhook' member of sd_softc.krw2020-09-231-2/+1
| | | | Unused since mpi@ removed sd_shutdown() in 2014.
* Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'krw2020-09-2210-72/+70
| | | | | | | | | | | | member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*' from cmd. Take the address of cmd as required by the various casts. No intentional functional change. luna88k test by aoyama@, sparc64 test by jmatthew@ Identification of 2009's last *cmd use and ok jmatthew@
* No need to check for SDEV_DYING as the first thing in both branches of ankrw2020-09-141-14/+9
| | | | | | | if/else. Just do it once before the if. Move the SC_DEBUG() documenting entry into sdopen() to before the various error bailouts.
* Always use READ(16)/WRITE(16) commands for disks large enough to requirekrw2020-09-131-7/+8
| | | | | | | | | | | READ(16)/WRITE(16) to access the last sectors Fixes (at least) large 512E (a.k.a. emulated 512-byte sector) devices plugged into overly helpful USB <-> ATA/ATAPI bridges. Which can tell you they are using 512-byte sector addresses but spontaneously/silently interpret READ(10)/WRITE(10) commands as using 4K sector addresses/sizes. Diagnosed and fix tested with James Cook. Thanks!
* Use SID_SCSI2_RESPONSE instead of '2' when checking INQUIRY data format.krw2020-09-121-2/+2
|
* No need to check inq for NULL when it always points at the inqdata inside akrw2020-09-122-8/+2
| | | | scsi_link.
* No need to ask for extra INQUIRY data, all available data is already cached inkrw2020-09-122-45/+6
| | | | scsi_link's inqdata.
* If SCSI_IGNORE_ILLEGAL_REQUEST is set no error is returned from scsi_xs_sync()krw2020-09-082-3/+8
| | | | | | | | | | | when the request is unsupported. So check mode sense(6) and mode sense(10) results for valid headers before passing the results back. Avoid overwriting any error that was returned. ok jmatthew@
* Rename SID_INQUIRY_HDR (a.k.a. 5) to more explicit SID_SCSI2_HDRLEN and use itkrw2020-09-053-13/+14
| | | | | | | | to replace various uses of '5' when calculating the amount of data in the INQUIRY response. Matches up more naturally with SID_SCSI2_ALEN. Also use to fix SCSIDEBUG display of INQUIRY responses to show correct count of bytes received/available.
* Add #define SID_SCSI2_RESPONSE 0x2 to allow elimination of another bunch ofkrw2020-09-021-1/+2
| | | | | magic numbers. As the nearby comment says '< 2 is obsolete. >2 is reserved'. So 0x2 is just right.
* Rename [READ|WRITE]_BIG to [READ|WRITE]_10. Rename struct scsi_rw_big tokrw2020-09-014-17/+17
| | | | | | struct scsi_rw_10. ok gnezdo@ jmatthew@ (who also did sparc64 compile test)
* Compactify SDEV_/ADEV_ flags & quirks to eliminate the gaps in bit use and thuskrw2020-08-302-17/+10
| | | | allow shrinking the names arrays.
* More recent MMC specificiations add READ(12)/WRITE(12). So add cd_cmd_rw12()krw2020-08-291-4/+20
| | | | | | and let cdstart() use it if the requested i/o is unable to fit into a READ(10). Certainly better than silently truncating the i/o into a READ(10)/WRITE(10).
* Use ISSET() to check b_flags for B_READ.krw2020-08-292-4/+4
|
* Missing u_int -> u_int32_t chunks from previous.krw2020-08-291-5/+9
|
* Use u_int32_t for nsecs, making it crystal clear that the valueskrw2020-08-292-12/+16
| | | | are expected to fit into a 4-byte field.
* Have [cd|sd]_cmd_rw[6|10|12|16] return the length of the created command andkrw2020-08-292-39/+39
| | | | | | have the caller assign it to xs->cmdlen. Pass in xs->cmd instead of xs. A slightly cleaner API that provides the potential of detecting and reacting to a failure to create the desired command.
* Shuffle [cd|sd]start code into closer alignment. Move the initialization of thekrw2020-08-282-49/+22
| | | | | xs fields to a more convenient location, shrinking upcoming diffs. Nuke some Captain Obvious comments.
* Abstract cd_cmd_rw6() and cd_cmd_rw10() a la sd_cmd_rw6() and sd_cmd_rw10().krw2020-08-281-15/+29
|
* Nuke CDF_ANCIENT, SDF_ANCIENT SDEV_ONLYBIG and bogus check of SID_RelAdr inkrw2020-08-285-29/+12
| | | | | | | favour of simply using the device's claimed SCSI level of support. Except of course for ATAPI/USB devices which often don't claim anything. Keep assuming they are at least SCSI-2. Use consistant tests in sdminphys/cdminphys/sdstart/cdstart.
* Remove needless uses of SDEV_ONLYBIG. It was always set when SDEV_UMASS was set,krw2020-08-263-15/+6
| | | | | | | | and was always checked in concert with SDEV_ATAPI. Just rely on SDEV_ATAPI and SDEV_UMASS in all but the one place sd(4) where SDEV_ONLYBIG is set independently of SDEV_ATAPI/_UMASS. ok jmatthew@
* The last timeout_add(sc_timeout) died in the great XS_NO_CCB purge of 2017. Nukekrw2020-08-224-17/+4
| | | | | pointless timeout_set(sc_timoeut) and timeout_del(sc_timeout) calls and the sc_timeout fields themselves.
* Revert DYING. At least some USB memory sticks get very upset.krw2020-08-204-55/+55
|
* Replace last 2 'blah & (flag1 | flag2) == 0' with !ISSET(blah, (flag1 | flag2)).krw2020-08-192-4/+4
|
* Nuke SDF_DYING, CDF_DYING and ST_DYING flags. Use the scsi_link flagkrw2020-08-194-55/+55
| | | | | SDEV_S_DYING instead. Makes it clear that the scsi_link and the [cd|sd|st] device always agree on their state.
* Try to avoid a theoretical infinite loop while detaching all the scsi_link's onkrw2020-08-181-4/+3
| | | | | | the bus. Use SLIST_FOREACH_SAFE() rather than 'while (!SLIST_EMPTY())'' as there is a condition which would cause scsi_detach_link() to return without removing the scsi_link from the SLIST.
* Don't include scsi_debug.h via scsiconf.h. Nobody but scsi/* should be using thekrw2020-08-161-2/+1
| | | | | | | contents thereof. Compile tests by martjn@ (alpha), visa@ (sgi) jmatthew@ (sparc64) aoyama@ (luna88k)
* The last SET()s of CDF_WAITING, SDF_WAITING, and ST_WAITING died in the greatkrw2020-08-154-16/+7
| | | | | | XS_NO_CCB purge of 2017. Nuke pointless ISSET()/CLR() checks and the #define's.
* Redistribute and tweak the scsi_[attach|probe|detach]_[bus|target|lun]() code tokrw2020-08-142-105/+96
| | | | | | make the three variants more similar and easier to understand. Ensures consistent error checks and eliminates pointless adapter_buswidth checks when processing the list of scsi_links.
* Explicitly #include <scsi/scsi_debug.h> rather than assuming scsiconf.h will dokrw2020-08-118-8/+16
| | | | | | | it. Prepares for removal of #include <scsi/scsi_debug.h> from scsiconf.h as soon as the alpha tester digs out from hurricane to compile last untested files.
* Minor code shuffle to get all *_activate(), *_probe() and *_detach() functionskrw2020-08-101-60/+60
| | | | | nestled together. Rename scsibusprint() to scsibussubprint() since it is used with scsibussubmatch().
* More code shuffling. Fix a rename missed in previous.krw2020-08-091-93/+89
|
* Shuffle functions and declarations around to more logical grouping. Nuke somekrw2020-08-091-384/+379
| | | | leading whitespace. Rename some local functions.
* scsi_link's are born knowing their bus. Use that instead of passing extrakrw2020-08-081-18/+19
| | | | scsibus_softc pointers around.
* Refactor scsi_show_flags() to allow 32-bit flags. Display unnamed flags as onekrw2020-07-272-27/+34
| | | | | hex value after named flags. Make flag name arrays NULL terminated rathar than fixed size.
* SDEV_2NDBUS is gone. Update flagnames[] appropriately.krw2020-07-271-2/+2
|
* Nuke unused struct scsi_link members of adapter softc's where thekrw2020-07-221-2/+1
| | | | driver successfully compiles on one or more of amd64, i386, hppa.
* Move remaining scsi bus initialization info from "prototype scsi link"krw2020-07-203-16/+20
| | | | | | | fields to struct scsibus_attach_args. Nuke the struct scsi_link * (saa_sc_link) in scaibus_attach_args. Explicitly initialize each field in scsibus_attach_args variables.
* Move the adapter related items (luns, adapter, adapter_target,krw2020-07-193-25/+20
| | | | | | | adapter_buswidth, adapter_softc) from struct scsi_link to struct scsibus_attach_args. Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).
* Access scsibus_softc info (luns, adapter, adapter_target,krw2020-07-167-27/+28
| | | | | adapter_softc, adapter_buswidth) via link->bus rather than using copies currently residing in the link.
* Beef up struct scsibus_softc to hold the information needed tokrw2020-07-162-38/+65
| | | | | | initialize the scsi_link's on the bus. After sucking this information out of the "prototype" link provided by the scsibus_attach_arg, no need to keep a pointer to that prototype.
* Nuke struct scsi_link's "scsibus" member. The two drivers using itkrw2020-07-052-4/+2
| | | | | | | | (ahc(4) and qlw(4)) can just compare the values of the "bus" member directly. A slightly different path to the same result that matthew@ traversed in his work culminating in scsiconf.h r1.146.
* Nuke unneeded 'sa_inqbuf' member of struct scsi_attach_args. It alwayskrw2020-06-3012-32/+30
| | | | | points to the inquiry data contained in the struct scsi_link pointed to by the other member, sa_sc_link.
* Garbage collect SDEV_S_WAITING, last used in scsi_base.c r1.167 inkrw2020-06-301-2/+1
| | | | | | 2010. Part of matthew@'s reverted scsiconf.h r1.146.
* Garbage collect SDEV_2NDBUS. Only used in isp(4) which was removed inkrw2020-06-271-2/+1
| | | | 2015 in favour of ql*(4).
* No need to bzero()/memset() 'struct scsibus_attach_args' variableskrw2020-06-271-2/+1
| | | | immediately before initializing the only field in the struct.
* Use SDEV_NO_ADAPTER_TARGET instead of the value that is beingkrw2020-06-241-2/+2
| | | | | | | aassigned to adapter_buswidth to indicate the adapter is not a target on the bus. ok dlg@ as part of a larger diff.
* Adapters that do not appear as a target on the SCSI bus must setkrw2020-06-241-3/+4
| | | | | | | | | | 'adapter_target' to a value greater than or equal to 'adapater_buswidth' to allow all possible targets to be probed. Add SDEV_NO_ADAPTER_TARGET (0xffff), a value guaranteed to be greater than or equal to the u_int16_t 'adapter_buswidth'. ok dlg@ as part of a larger diff.