Commit Graph

251 Commits

Author SHA1 Message Date
Matt Jacob
6e4b813833 Don't lock buses around a call to xptperiphlistmatch- the buses will be
locked at appropriate places.

MFC after:	1 week
X-MFC:		208752
2010-06-29 17:10:55 +00:00
Matt Jacob
82b361b11b Implement the usage of Report Luns as part of SCSI probing for SCP3 or
better devices. This can be disabled on a per-device basis using quirks as
well.

This also handles the case where there is actually no connected LUN 0
(which can definitely be the case for storage arrays).

Reviewed by:	scsi@
MFC after:	1 month
2010-06-08 16:17:25 +00:00
Matt Jacob
f1e2546a8c Protect periph drivers list and rearrange things to minimize the chance of
stepping oneself during probing.

Don't blindly decrement a periph probe count.

Reviewed by:	scsi@
Obtained from:	Alexander Motin, Atillio Rao, Others
MFC after:	1 month
2010-06-02 18:06:32 +00:00
Matt Jacob
0e85f214e3 Add a new primitive, XPT_SCAN_TGT, to cover the range between scanning a
whole bus (XPT_SCAN_BUS) and a single lun on that bus (XPT_SCAN_LUN).

It's less resource comsumptive than scanning a whole bus when the
caller knows only one target has changes.

Reviewed by:	scsi@
Sponsored by:	Panasas
MFC after:	1 month
2010-05-26 22:49:42 +00:00
Alexander Motin
8caae13f68 Add xpt_schedule_dev_sendq() call, lost at r203108. It is not needed in
usual operation, but required in some conditions to make queue running
after being shrinked.

MFC after:	3 days
2010-05-02 04:16:39 +00:00
Alexander Motin
6ee4d8696f Revert r198705.
As scottl@ noticed, max_target/max_lun was intended to be only a hint for
existing bus scanner. Some FC/SAS SIMs report fake values there, that are
smaller then maximum supported IDs. In that case this check makes impossible
manual scan outside hinted range.

For ATA/SATA SIMs respective check was instead implemented at SIM level.
Newer SCSI SIMs expected to have these checks at driver or firmware level.
Some older SCSI SIMs have no this check and the issues will get back there.
2010-04-30 08:57:03 +00:00
Matt Jacob
b882a6d37a For unhandled actions in xpt_action_default, remember to call
xpt_done for queued requests. This solves the problem of
indefinite hangs for unspecified transports when XPT_SCAN_BUS
is called.

A few minor cosmetics elsewhere.

MFC after:	1 week
2010-03-31 17:47:57 +00:00
Alexander Motin
0aacc53526 Fix newlines broken at r204220. 2010-02-26 10:33:48 +00:00
Alexander Motin
411cadae7b Make xpt_rescan() more correct, as it was before r197208: do not use
XPT_SCAN_LUN for wildcard LUN, fall back to XPT_SCAN_BUS.
2010-02-23 18:42:07 +00:00
Alexander Motin
57079b1773 Virtualize transport part of periph announcement. 2010-02-22 19:17:17 +00:00
Alexander Motin
6a5d28b93a Improve output for controllers that doesn't report SATA speed. 2010-02-22 10:45:40 +00:00
Alexander Motin
a2bd4f84b9 Disable kern.cam.power_down ATM. It doesn't work fine on some controllers. 2010-02-03 20:00:56 +00:00
Alexander Motin
6f15a274a8 MFp4:
Make CAM to stop all attached devices on system shutdown.
It allows devices to park heads, reducing stress on power loss.
Add `kern.cam.power_down` tunable and sysctl to controll it.
2010-02-03 08:42:08 +00:00
Alexander Motin
7685edec41 Change the way in which fake async events generated. Do not use
taskqueue for lock decoupling, as it causes unwanted races.
2010-02-02 18:07:16 +00:00
Alexander Motin
e9d240ecf3 Some missed parts for r203376. 2010-02-02 17:56:54 +00:00
Alexander Motin
83c5d981ac MFp4: Large set of CAM inprovements.
- Unify bus reset/probe sequence. Whenever bus attached at boot or later,
CAM will automatically reset and scan it. It allows to remove duplicate
code from many drivers.
- Any bus, attached before CAM completed it's boot-time initialization,
will equally join to the process, delaying boot if needed.
- New kern.cam.boot_delay loader tunable should help controllers that
are still unable to register their buses in time (such as slow USB/
PCCard/ CardBus devices), by adding one more event to wait on boot.
- To allow synchronization between different CAM levels, concept of
requests priorities was extended. Priorities now split between several
"run levels". Device can be freezed at specified level, allowing higher
priority requests to pass. For example, no payload requests allowed,
until PMP driver enable port. ATA XPT negotiate transfer parameters,
periph driver configure caching and so on.
- Frozen requests are no more counted by request allocation scheduler.
It fixes deadlocks, when frozen low priority payload requests occupying
slots, required by higher levels to manage theit execution.
- Two last changes were holding proper ATA reinitialization and error
recovery implementation. Now it is done: SATA controllers and Port
Multipliers now implement automatic hot-plug and should correctly
recover from timeouts and bus resets.
- Improve SCSI error recovery for devices on buses without automatic sense
reporting, such as ATAPI or USB. For example, it allows CAM to wait, while
CD drive loads disk, instead of immediately return error status.
- Decapitalize diagnostic messages and make them more readable and sensible.
- Teach PMP driver to limit maximum speed on fan-out ports.
- Make boot wait for PMP scan completes, and make rescan more reliable.
- Fix pass driver, to return CCB to user level in case of error.
- Increase number of retries in cd driver, as device may return several UAs.
2010-01-28 08:41:30 +00:00
Alexander Motin
c8039fc667 MFp4:
- Extend XPT-SIM transfer settings control API. Now it allows to report to
SATA SIM number of tags supported by each device, implement ATA mode and
SATA revision negotiation for both SATA and PATA SIMs.
- Make ahci(4) and siis(4) to use submitted maximum tag number, when
scheduling requests. It allows to support NCQ on devices with lower tags
count then controller supports.
- Make PMP driver to report attached devices connection speeds.
- Implement ATA mode negotiation between user settings, device and
controller capabilities.
2009-11-24 12:47:58 +00:00
Alexander Motin
ec700f26b9 MFp4:
Remove code that years ago was closing race between request submission
to SIM and device/SIM freeze. That race become impossible after moving from
spl to mutex locking, while this workaround causes some unexpected effects.
2009-11-14 20:23:20 +00:00
Alexander Motin
30a4094f86 MFp4:
- Move tagged queueing control from ADA to ATA XPT. It allows to control
  device command queue length correctly. First step to support < 32 tags.
- Limit queue for non-tagged devices by 2 slots for ahci(4) and siis(4).
- Implement quirk matching for ATA devices.
- Move xpt_schedule_dev_sendq() from header to source file.
- Move delayed queue shrinking to the more expected place - element freeing.
- Remove some SCSIsms in ATA.
2009-11-11 11:10:36 +00:00
Alexander Motin
efa575b6be MFp4:
- Remove CAM_PERIPH_POLLED flag. It is broken by design. Polling can't be
periph flag. May be SIM, may be CCB, but now it works fine just without it.
- Remove check unused for at least five years. If we will ever have non-BIO
devices in CAM, this check is smallest of what we will need.
- If several controllers complete requests same time, call swi_sched()
only once.
2009-11-04 15:40:19 +00:00
Alexander Motin
9efda2c908 The async callback could free the device. If it is a broadcast async,
it doesn't hold device reference, so take our own reference.

Submitted by:   thompsa
2009-11-02 08:31:00 +00:00
Alexander Motin
f98d7a47e2 MFp4:
Fix reference counting bug, when device unreferenced before then
invalidated. To do it, do not handle validity flag as another
reference, but explicitly modify reference count each time flag is
modified.

Discovered by:	thompsa
2009-11-01 11:31:06 +00:00
Alexander Motin
1e637ba677 MFp4:
- Reduce code duplication in ATA XPT and PMP driver.
- Move PIO size setting from ada driver to ATA XPT. It is XPT business
to negotiate transfer details. ada driver is now stateless.
- Report PIO size to SIM. It is required for correct PATA SIM operation.
- Tune PMP scan timings. It workarounds some problems with SiI.
- If reset hapens during PMP initialization - restart it.
- Introduce early-initialized periph drivers, which are used during initial
scan process. Use it for xpt, probe, aprobe and pmp. It gives pmp chance
to finish scan before mountroot and numerate devices in right order.
2009-10-31 10:43:38 +00:00
Alexander Motin
d521940e9a MFp4:
Ensure target/lun passed from user-level supported on this bus.
Scanning unsupported IDs causes different issues from duplicate
devices to system crash.
2009-10-31 09:03:48 +00:00
Alexander Motin
48f2bfe224 Fix the build. 2009-10-23 11:26:58 +00:00
Alexander Motin
bbfa4aa1a6 Replace most of priority numbers with defines. No logical changes. 2009-10-23 08:27:55 +00:00
Alexander Motin
20a7933f53 After thinking again, implement cam_ccbq_fini().
This is effectively NULL change, but makes this API a bit more consistent.
2009-10-22 21:07:32 +00:00
Alexander Motin
c0d232d988 MFp4:
Do not search for bus when it is not needed,
2009-10-21 15:57:16 +00:00
Kenneth D. Merry
5a73cc12bc Fix some instances where CAM rescans get hung up or take a long time to
complete.

Also, allow xpt_rescan() to rescan a LUN instead of a full bus.

MFC after:	3 days
Sponsored by:	Copan Systems, Inc.
2009-09-15 00:15:24 +00:00
Alexander Motin
ee358e6376 MFp4:
Remove duplicate qfrozen_cnt variable from struct cam_ed.
ccbq.queue.qfrozen_cnt should be used instead.
2009-09-06 19:06:50 +00:00
Alexander Motin
f96d66a41e Remove unneeded CAM_SIM_MPSAFE check. 2009-09-06 18:59:46 +00:00
Alexander Motin
70f2d05499 s/bus %d/scbus%d/ in some messages to correct terminology. 2009-09-06 18:56:08 +00:00
Alexander Motin
ad41300955 MFp4:
Report scbusX in xpt_announce_periph() to less confuse users by two
different bus addressing schemes.
2009-09-06 18:48:18 +00:00
Alexander Motin
788fb3767d Avoid extra swi_sched() call, if this SIM is already queued.
It reduces overhead for coalesced command completions.
2009-09-06 18:40:48 +00:00
Alexander Motin
33ea30fed7 Fix iSCSI initiator and vpo driver operation, broken by CAM changes.
Reviewed by:	scottl, Danny Braniss
Approved by:	re (rwatson)
2009-08-18 08:46:54 +00:00
Matt Jacob
2df76c160b Add 8Gb support (isp_2500). Fix a fair number of configuration and
firmware loading bugs.

Target mode support has received some serious attention to make it
more usable and stable.

Some backward compatible additions to CAM have been made that make
target mode async events easier to deal with have also been put
into place.

Further refinement and better support for NP-IV (N-port Virtualization)
is now in place.

Code for release prior to RELENG_7 has been stripped away for code clarity.

Sponsored by: Copan Systems

Reviewed by:    scottl, ken, jung-uk kim
Approved by:    re
2009-08-01 01:04:26 +00:00
Scott Long
52c9ce25d8 Separate the parallel scsi knowledge out of the core of the XPT, and
modularize it so that new transports can be created.

Add a transport for SATA

Add a periph+protocol layer for ATA

Add a driver for AHCI-compliant hardware.

Add a maxio field to CAM so that drivers can advertise their max
I/O capability.  Modify various drivers so that they are insulated
from the value of MAXPHYS.

The new ATA/SATA code supports AHCI-compliant hardware, and will override
the classic ATA driver if it is loaded as a module at boot time or compiled
into the kernel.  The stack now support NCQ (tagged queueing) for increased
performance on modern SATA drives.  It also supports port multipliers.

ATA drives are accessed via 'ada' device nodes.  ATAPI drives are
accessed via 'cd' device nodes.  They can all be enumerated and manipulated
via camcontrol, just like SCSI drives.  SCSI commands are not translated to
their ATA equivalents; ATA native commands are used throughout the entire
stack, including camcontrol.  See the camcontrol manpage for further
details.  Testing this code may require that you update your fstab, and
possibly modify your BIOS to enable AHCI functionality, if available.

This code is very experimental at the moment.  The userland ABI/API has
changed, so applications will need to be recompiled.  It may change
further in the near future.  The 'ada' device name may also change as
more infrastructure is completed in this project.  The goal is to
eventually put all CAM busses and devices until newbus, allowing for
interesting topology and management options.

Few functional changes will be seen with existing SCSI/SAS/FC drivers,
though the userland ABI has still changed.  In the future, transports
specific modules for SAS and FC may appear in order to better support
the topologies and capabilities of these technologies.

The modularization of CAM and the addition of the ATA/SATA modules is
meant to break CAM out of the mold of being specific to SCSI, letting it
grow to be a framework for arbitrary transports and protocols.  It also
allows drivers to be written to support discrete hardware without
jeopardizing the stability of non-related hardware.  While only an AHCI
driver is provided now, a Silicon Image driver is also in the works.
Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware
is possible and encouraged.  Help with new transports is also encouraged.

Submitted by:	scottl, mav
Approved by:	re
2009-07-10 08:18:08 +00:00
Andrew Thompson
853a10a581 Revert r190676,190677
The geom and CAM changes for root_hold are the wrong solution for USB design
quirks.

Requested by:	scottl
2009-04-10 04:08:34 +00:00
Andrew Thompson
31da42bab2 Add interleaving root hold tokens from the CAM probe to disk_create and geom
provider tasting. This is needed for disk attachments that happen after threads
are running in the boot process.

Tested by:	rnoland
2009-04-03 19:49:33 +00:00
Scott Long
6de67521aa GCC attacks! 2009-02-16 18:02:32 +00:00
Scott Long
daed819b02 Fix parallel SCSI negotiation in the CAM_NEW_TRAN_CODE world order.
Overzealous sanity checks were locking the sync_rate and offset values to
zero, thanks to a twisty maze of recursive code.
2009-02-16 14:57:15 +00:00
Scott Long
5dc642bd9f Instrument the probe state machine so that things like DV can be tracked. 2009-02-16 14:38:52 +00:00
Scott Long
1b47c9b69d In the case that the probe has determined that it can't query the device for
a serial number, fall through to the next case so that initial negotiation
still happens.  Without this, devices were showing up with only 1 available
tag opening, leading to observations of very poor I/O performance.

This should fix problems reported with VMWare Fusion and ESX.  Early
generation MPT-SAS controllers with SATA disks might also be affected.
HP CISS controllers are also likely affected, as are many other
pseudo-scsi disk subsystems.
2009-02-13 10:04:59 +00:00
Edward Tomasz Napierala
a8d4700dbb Remove an overzealous check.
Submitted by:	das
Reviewed by:	scottl
Approved by:	rwatson (mentor, implicit)
Sponsored by:	FreeBSD Foundation
2009-02-08 22:08:48 +00:00
Edward Tomasz Napierala
aac35298e6 Protect against NULL pointer dereference.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2009-01-23 21:08:00 +00:00
Edward Tomasz Napierala
ac37e649a9 Guard against NULL pointer dereference.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		1847
2009-01-23 21:05:16 +00:00
Edward Tomasz Napierala
f96b106236 Fix use after free.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		3712
2009-01-14 21:29:20 +00:00
Edward Tomasz Napierala
02caf36ee1 Make "kldunload atapicam" return EBUSY instead of deadlocking when a device
created by atapicam is being kept opened or mounted.  This is probably just
a temporary solution until we invent something better.

Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Reported by:	Jaakko Heinonen
2009-01-08 17:26:51 +00:00
Rafal Jaworowski
2872efae88 cam: Retry TEST UNIT READY command if not successful.
This fixes problems with discovering some USB devices that are very slow to
respond during initialisation.

When a USB device is inserted, CAM performs the sequence:
  1) INQUIRY
  2) INQUIRY (second time with other parameters)
  3) TEST UNIT READY
  4) READ CAPACITY

Before this change CAM didn't check if TEST UNIT READY was successful and went
on blindly to the next state and sent READ CAPACITY. If the device was still
not ready by then, CAM ended with error message. This patch adds checking for the
status of TEST UNIT READY command and retrying up to 10 times with 0.5 sec
interval.

Submitted by:	Grzegorz Bernacki gjb ! semihalf dot com
Reviewed by:	scottl
2009-01-08 10:16:02 +00:00
Edward Tomasz Napierala
24ebf56636 Periph driver fixes, second try.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2008-12-19 14:31:40 +00:00