Commit Graph

801 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
ee857ce73b Remove dead code.
Found with:	Coverity Prevent(tm)
CID:		3667
2009-05-12 16:38:32 +00:00
Edward Tomasz Napierala
9b61a5b95e Add missing free(9) in error case.
Found with:	Coverity Prevent(tm)
CID:		4224
2009-05-12 15:14:37 +00:00
Edward Tomasz Napierala
0c70e3070b Add missing 'break' statements.
Found with:	Coverity Prevent(tm)
CID:		3936, 3937
Reviewed by:	scottl@
2009-05-12 15:03:47 +00:00
Ed Schouten
2cbf101b17 Get rid of the device index number stored in the sa(4) unit number.
The device index number stored in the unit number of sa(4) devices is
only used to print debug messages. Get rid of this index number and use
devtoname() to just print the entire device name.
2009-04-20 10:40:42 +00:00
Ed Schouten
dae0d1b1d5 Remove unused SESUNIT() macro from ses(4). 2009-04-18 07:39:11 +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
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
Max Khon
aa812d9e2a cam_periph_alloc: fix "invalid periph name" error condition
Found with:	Coverity Prevent(tm)
CID:		130
2009-02-09 17:02:54 +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
Bjoern A. Zeeb
53071a66d4 There is no need to initialize the variable here.
Submitted by:	Christoph Mallon christoph.mallon@gmx.de
Reviewed by:	kib (as part of a larger patch)
MFC after:	2 weeks
2009-01-31 17:34:55 +00:00
John Baldwin
1fa738c26f Now that mtx_sleep/msleep can accept Giant as the interlock, simplify the
CAM locking code slightly to no longer special case sleeping when a sim
uses Giant for its lock.

Tested by:	trasz
2009-01-26 15:01:47 +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
041361d899 Don't leak memory when alloc fails.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		2908
2009-01-23 21:06:16 +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
53f8b22b34 Guard against NULL pointer dereference.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		130
2009-01-23 21:03:59 +00:00
Edward Tomasz Napierala
4fee613e42 Add missing 'break' statement.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		3667
2009-01-14 21:31:22 +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
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
Edward Tomasz Napierala
1cec6ef6a9 Add missing 'break' statement.
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
Found with:	Coverity Prevent(tm)
CID:		3927
2009-01-14 21:25:17 +00:00
Edward Tomasz Napierala
5f3fed855c Don't call destroy_dev(9) with a mutex held. While here, shuffle
things around so the periph destructors look alike.  Based on a patch
by Jaakko Heinonen.

Submitted by:	Jaakko Heinonen
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2009-01-10 17:22:49 +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
Warner Losh
8550170477 Make it possible to override the number of retries for the CD media.
When trying to read scratched or damaged CDs and DVDs, the default
mechanism is sub-optimal.  Programs like ddrescue do much better if
you turn off retries entirely, since their algorithms are designed
scan big areas fast, then winnow the areas down.  Turning off retries
speeds these programs up by as much as 20x, since the drive is able to
'stream past' many small errors...

The sysctl/tunable kern.cam.cd.retry_count controls this.  That
defaults to '4' (for a total of 5 attempts).  Setting to 0 turns off
all retry attempts.

Reviewed by:	scottl@
2009-01-08 00:45:47 +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
Scott Long
d13994cec0 Fix a comment to reflect what really happens. 2008-12-22 16:58:47 +00:00
Scott Long
835187bff8 Fix refcount locking in cd, pass, and sg periphs. 2008-12-21 06:20:11 +00:00
Edward Tomasz Napierala
7412d60d0b Fix cam_sim_free() wakeup condition and add mtx_asserts.
Submitted by:	Christoph Mallon
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2008-12-19 14:33:29 +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
a4e2e711a5 Move mtx_assert lower, when we can be sure that the pointer
to the mutex is valid.

Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2008-12-19 14:27:10 +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
Edward Tomasz Napierala
fa6099fda0 Add SIM refcounting. This is slightly different from what DragonFly
does - in DragonFly, it's cam_sim_release() what actually frees the
SIM; cam_sim_free does nothing more than calling cam_sim_release().
Here, we drain in cam_sim_free, waiting for refcount to drop to zero.
We cannot do the same think DragonFly does, because after cam_sim_free
returns, client would destroy the sim->mtx, and CAM would trip over
an initialized mutex.

Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2008-12-16 16:57:33 +00:00
Edward Tomasz Napierala
96100101a8 Get rid of dead_sim. There is no way to make it work - any attempt
to actually use it would panic on mtx operation, as dead_sim doesn't
have a proper mutex.  Even if it had a properly initialized mutex,
it wouldn't have properly locked and owned one.

Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2008-12-16 16:54:51 +00:00
Dag-Erling Smørgrav
1ede983cc9 Retire the MALLOC and FREE macros. They are an abomination unto style(9).
MFC after:	3 months
2008-10-23 15:53:51 +00:00
Ed Schouten
6bfa9a2d66 Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by:	kib
2008-09-27 08:51:18 +00:00
Ed Schouten
d3ce832719 Remove unit2minor() use from kernel code.
When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by:	kib
2008-09-26 14:19:52 +00:00
Sean Bruno
954e36405f Add a new cam_status CAM_SCSI_IT_NEXUS_LOST. This will be used by future patches
for target mode that are forthcoming.

Reviewed by:	Scott Long
MFC after:	2 days
2008-09-18 14:48:46 +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
Kenneth D. Merry
337b89a0e0 SCSI_DELAY is specified in milliseconds, not seconds.
Submitted by:	Andre Albsmeier <Andre.Albsmeier@siemens.com>
MFC after:	1 week
2008-08-16 21:26:58 +00:00
Jung-uk Kim
874bd08821 Update SCSI opcodes and ASCs from t10.org.
http://www.t10.org/lists/1spc-lst.htm

Note opcodes for scanner and communication devices are taken from the previous
revision because they are not listed in the files any more.
Also, note newly added ASCs are all marked with 'XXX TBD' and take SS_RDEF action
for now.  Some ASCs need SS_TUR for error recovery or SS_FATAL to prevent further
retrials.  We should deal with them later.

Reviewed by:	scottl, ken
2008-08-07 17:25:05 +00:00
Ed Maste
879afbd55a Fix whitespace. 2008-08-01 15:13:56 +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
Scott Long
ad97d96c40 Locking in the ses_ioctl handler doesn't have to be so strict because
the referenced data is only obtained/changed in the device open handler,
and the ioctl handler can only run after the open handler.  Also fix a
few nearby style issues.

Submitted by: Matt Jacob
2008-03-17 17:18:16 +00:00
Scott Long
4b800c7df1 When probing a newly found device, don't automatically assume that the
device supports retrieving a serial number.  Instead, first query the
list of VPD pages it does support, and only query the serial number if
it's supported, else silently move on.  This eliminates a lot of noise
during verbose booting, and will likely eliminate the need for most
NOSERIAL quirks.
2008-02-27 08:47:13 +00:00