Commit Graph

251 Commits

Author SHA1 Message Date
Justin T. Gibbs
f03f7a0ca3 Correct bioq_disksort so that bioq_insert_tail() offers barrier semantic.
Add the BIO_ORDERED flag for struct bio and update bio clients to use it.

The barrier semantics of bioq_insert_tail() were broken in two ways:

 o In bioq_disksort(), an added bio could be inserted at the head of
   the queue, even when a barrier was present, if the sort key for
   the new entry was less than that of the last queued barrier bio.

 o The last_offset used to generate the sort key for newly queued bios
   did not stay at the position of the barrier until either the
   barrier was de-queued, or a new barrier (which updates last_offset)
   was queued.  When a barrier is in effect, we know that the disk
   will pass through the barrier position just before the
   "blocked bios" are released, so using the barrier's offset for
   last_offset is the optimal choice.

sys/geom/sched/subr_disk.c:
sys/kern/subr_disk.c:
	o Update last_offset in bioq_insert_tail().

	o Only update last_offset in bioq_remove() if the removed bio is
	  at the head of the queue (typically due to a call via
	  bioq_takefirst()) and no barrier is active.

	o In bioq_disksort(), if we have a barrier (insert_point is non-NULL),
	  set prev to the barrier and cur to it's next element.  Now that
	  last_offset is kept at the barrier position, this change isn't
	  strictly necessary, but since we have to take a decision branch
	  anyway, it does avoid one, no-op, loop iteration in the while
	  loop that immediately follows.

	o In bioq_disksort(), bypass the normal sort for bios with the
	  BIO_ORDERED attribute and instead insert them into the queue
	  with bioq_insert_tail().  bioq_insert_tail() not only gives
	  the desired command order during insertion, but also provides
	  barrier semantics so that commands disksorted in the future
	  cannot pass the just enqueued transaction.

sys/sys/bio.h:
	Add BIO_ORDERED as bit 4 of the bio_flags field in struct bio.

sys/cam/ata/ata_da.c:
sys/cam/scsi/scsi_da.c
	Use an ordered command for SCSI/ATA-NCQ commands issued in
	response to bios with the BIO_ORDERED flag set.

sys/cam/scsi/scsi_da.c
	Use an ordered tag when issuing a synchronize cache command.

	Wrap some lines to 80 columns.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
sys/geom/geom_io.c
	Mark bios with the BIO_FLUSH command as BIO_ORDERED.

Sponsored by:	Spectra Logic Corporation
MFC after:	1 month
2010-09-02 19:40:28 +00:00
Matt Jacob
be55a6bd2a Revert r211434. Offline discussions have convinced me that this should
be left alone for now.
2010-08-20 17:20:05 +00:00
Matt Jacob
c9c87edbc3 Now is as good a time as any to find out if we induce breakage
by issueing aborts for any pending commands when we're decommssioning
a disk.

MFC after:	3 months
2010-08-17 17:11:15 +00:00
Alexander Motin
8edcf69406 Export PCI IDs of ATA/SATA controllers through CAM and ata(4) layers to
GEOM. This information needed for proper soft-RAID's on-disk metadata
reading and writing.
2010-07-25 15:43:52 +00:00
Matt Jacob
63ebd216e7 Rearrange how things are done to avoid dereferencing stale pointers in
the case of immediate unconfigure after configure. Hold the periph an
extra count while we have the task to create sysctl context outstanding
so that the periph doesn't go away unexpectedly.

Sponsored by:	Panasas
Reviewed by:	scsi@
MFC after:	1 month
2010-06-08 22:46:44 +00:00
Matt Jacob
c8381fba8c redfacedly noting a missing part of a patch.
Pointy Hat To:	Me
MFC after:	2 Week
X-MFC:		208896
2010-06-07 22:43:37 +00:00
Matt Jacob
9d8284a1aa Do a minor amount of stylifying. Also, get a Fibre Channel WWPN if one exists
for a da unit and create a sysctl OID for it.
2010-06-07 17:41:34 +00:00
Matt Jacob
b011449011 Nullify our periph pointer in dacleanup to try and catch
race conditions in callbacks/downcalls.
2010-04-02 20:08:44 +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
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
Andrew Thompson
bd6d02e7e9 Provide the same sanity check on the sector size in dagetcapacity as when the
disk is first probed. dagetcapacity is called whenever the disk is opened from
geom via d_open(), a zero sector size will cause geom to panic later on.
2009-11-02 23:30:15 +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
bbfa4aa1a6 Replace most of priority numbers with defines. No logical changes. 2009-10-23 08:27:55 +00:00
Alexander Motin
ee64944219 Remove some obsoleted comments. 2009-10-23 07:54:15 +00:00
Pawel Jakub Dawidek
6cf918bc9b Make serial numbers of daX disks visible by GEOM.
No objections from:	scottl
Obtained from:		Wheel Sp. z o.o. (http://www.wheel.pl)
2009-09-04 09:40:59 +00:00
Stanislav Sedov
622247c0fb - Add quirk for Sony DSC digital cameras. This umass devices fail
to attach without these quirks applied.

PR:		usb/137035
URL:		http://lists.freebsd.org/pipermail/freebsd-current/2009-August/010852.html
Reported by:	Henri Hennebert <hlh@restart.be>, Andrey V. Elsukov <bu7cher@yandex.ru>
MFC after:	1 week
2009-08-26 21:14:28 +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
John Baldwin
be246f9e94 Reorder dacleanup() and cdcleanup() slightly so that the sysctl context is
freed while the periph lock is not held.  While here, wait until after
freeing the softc before reacquiring the periph lock.

Tested by:	sbruno
2009-02-11 22:29:09 +00:00
John Baldwin
b7208da623 Adding dynamic sysctls no longer requires Giant.
Submitted by:	rdivacky
2009-02-10 22:39:44 +00:00
Edward Tomasz Napierala
c654e30995 Remove unused variable.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		3665
2009-01-14 21:27:30 +00:00
Remko Lodder
6333256401 Add quirk for the Storcase InfoStation 12bay
SATA to FC SAN.

PR:		129858
Submitted by:	Nick Triantos <nick-freebsd at triantos dot com>
MFC after:	1 week
2008-12-23 09:11:05 +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
Edward Tomasz Napierala
1fa9ee7d60 Revert r186186 for now; it breaks stuff.
Approved by:	rwatson (mentor)
2008-12-17 10:49:03 +00:00
Edward Tomasz Napierala
f5bc800067 Fix locking in periph drivers - don't try to unlock periph
that was already deallocated.

Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2008-12-16 17:01:52 +00:00
Scott Long
b574dd8dd1 Fix a locking mistake in daopen(). If the open fails, which can happen
because the media was removed, the periph would get its refcount dropped
and ultimately freed before getting unlocked.  This created a dangling
pointer that was easy to trip over.  This fixes a common source of
crashes with removaable media, but problems remain and will get tracked
down.
2008-08-29 04:39:46 +00:00
Remko Lodder
7a7ce8a36a Add quirk for the Samsung YP-U3
PR:		125398
Submitted by:	Tino Engel <goaengel at gmx dot net>
Approved by:	imp (mentor, implicit)
MFC after:	1 week
2008-07-09 17:00:14 +00:00
Maxim Konovalov
d5b851f626 o Correct EasyMP3 EM732X usb 2.0 flash mp3 player revision:
it's 1.00 not 1.0.

PR:		usb/96546
Submitted by:	Eugene Grosbein
MFC after:	1 month
2008-01-12 19:24:55 +00:00
David Xu
f5ae94753b Add quirks for Netac Onlydisk 2000 USB disk. 2007-12-11 06:41:38 +00:00
Warner Losh
3702980c1c After talking with njl@, change this wildcard entry to be a bit less wild.
Approved by: re (blanket)
2007-07-01 17:42:07 +00:00
Warner Losh
73bbb79dd4 Quirk for ChipsBnk usb stick
Submitted by: Mark Andrews
PR: 103702
Approved by: re@ (blanket)
2007-06-30 14:44:09 +00:00
Warner Losh
cdbcad0542 Add quirk for JoyFly 128mb USB Flash Drive
submitted by: Toni Schmidbauer
PR: 96133
Approved by: re@ (blanket)
2007-06-30 14:41:30 +00:00
Warner Losh
dd7153acf3 quirk for I/O Magic USB flash drive "Giga Bank"
Submitted by: Jeff Anton
PR: 108810
Approved by: re@ (blanket)
2007-06-30 05:24:25 +00:00
Warner Losh
3693ebaeac Samsung MP0402H quirk
Submitted by: Gipsy<wint3r@securimail.com>
PR: 108427
Approved by: re@ (blanket)
2007-06-30 05:21:18 +00:00
Warner Losh
c16d852cca Add support for JNC MP3 Player
Submitted by: User & <dhenin@cypries.cyclopes.org>
PR: 94439
Approved by: re (blanket)
2007-06-30 05:03:03 +00:00
Warner Losh
6d30287972 Philips USB Key Audio KEY013
Submitted by: Arnoud Engelfriet
PR: 68412
Approved by: re (blanket)
2007-06-30 04:34:45 +00:00
Warner Losh
f8f10e94cf Support for iRiver U10 USB connection
PR: 92306
Submitted by: Soren Dossing
Approved by: re (blanket)
2007-06-28 06:12:55 +00:00
Warner Losh
dcf43907af Quirk for Denver MP3 player usb.
Submitted by: Ed Schouten
PR: 107101
Approved by: re (blanket for device supprot)
2007-06-28 04:51:19 +00:00
Scott Long
036472e3ee Revert an accidental change from the previous rev. 2007-06-16 18:22:19 +00:00
Scott Long
d9fd6daad5 Work around the other uses of M_WAITOK. 2007-06-16 18:20:29 +00:00
Matt Jacob
b76f27d25b Back out 1.212 at Nate's request in order to go through the
actual formal process he's trying to get established for quirks..
2007-05-29 20:04:01 +00:00
Matt Jacob
ca05119e8a Use the Hitachi 2.5" HD, 120 GB as a USB device.
Submitted by:		Joakim Bentholm`
MFC after:	3 days
2007-05-29 01:23:38 +00:00
Matt Jacob
1cd1670b48 Zero scsi_readcapacity allocations so we can really
tell if there has been data returned (for some broken
residual checking points).

MFC after:	3 days
2007-05-18 21:58:07 +00:00
Scott Long
85d92640f8 Add a helper function for registering async callbacks. Besides
eliminating a lot of duplicated code, this also fixes a locking edge case.
2007-05-16 16:54:23 +00:00
Scott Long
0dd50e9b5e Eliminate the use of M_TEMP. 2007-05-14 21:48:53 +00:00
Scott Long
06b7b89f0d Remove obsolete headers. Move kernel specific headers under #ifdefs 2007-04-23 18:01:44 +00:00
Scott Long
919c80dfc7 Fix a leaked lock in dashutdown. 2007-04-19 22:18:15 +00:00
Scott Long
545f17a3c8 Missed locking the dump and shutdown entry points in the scsi_da driver. 2007-04-18 05:14:16 +00:00
Scott Long
cd5c9285cd Drop the periph/sim lock when calling disk_destroy(). 2007-04-16 19:41:14 +00:00
Scott Long
2b83592fdc Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM will
use to synchornize and protect all data objects that are used for that
SIM.  Drivers that are not yet MPSAFE register Giant and operate as
usual.  RIght now, no drivers are MPSAFE, though a few will be changed
in the coming week as this work settles down.

The driver API has changed, so all CAM drivers will need to be recompiled.
The userland API has not changed, so tools like camcontrol do not need to
be recompiled.
2007-04-15 08:49:19 +00:00
Nick Hibma
55fe33a350 Reduce the noise when plugging in (USB) mass storage devices, like a 4 port
flash card reader.
Also remove an 'Opened da0 -> <random number>' which is not needed on a daily
basis (available through bootverbose).

Reviewed by:	phk, ken
MFC after:	1 week
2007-02-21 07:45:02 +00:00