Commit Graph

916 Commits

Author SHA1 Message Date
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
8c52d7f70c One byte off for scsi_target_group cdb.
MFC after:	2 weeks
2010-06-08 17:44:49 +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
36af9f04a3 Make additional definitions up to and including SPC-4. Add in definitions
for REPORT and SET TARGET PORT GROUP commands (foundations for future work).

Regularize opcodes to be upper case hex.

Pick *one* of tab or space after #define (tab) and stick with that.

MFC after:	2 weeks
2010-06-08 05:14:18 +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
Alexander Motin
f1893540ff Add allocation error hadling.
Found with:   Coverity Prevent(tm)
CID:          3897
2010-06-05 09:31:13 +00:00
Alexander Motin
81bfc0fc44 Fix double free on error.
Found with:   Coverity Prevent(tm)
CID:          4573
2010-06-05 08:36:37 +00:00
Andriy Gapon
1a7b0de575 scsi_cd: pass correct pointer to free()
Found with:	Coverity Prevent(tm)
CID:		2986
MFC after:	4 days
2010-06-04 13:55:55 +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
Marius Strobl
4461491b3e Change ad_firmware_geom_adjust() to operate on a struct disk * only and
hook it up to ada(4) also. While at it, rename *ad_firmware_geom_adjust()
to *ata_disk_firmware_geom_adjust() etc now that these are no longer
limited to ad(4).

Reviewed by:	mav
MFC after:	3 days
2010-05-20 12:46:19 +00:00
Marius Strobl
f399274395 Remove unnecessary headers which were inherited from cam_xpt.c without
reason.

Reviewed by:	mav
MFC after:	3 days
2010-05-20 12:44:06 +00:00
Matt Jacob
c59b4dcdb4 Pick up the right change, not it's close cousin. The one
previously submitted was wrong.

Point hat:      mjacob
X-MFC:          207933
MFC after:	1 week
2010-05-11 22:51:13 +00:00
Matt Jacob
cf454e30b6 Deal sensibly with more than 26 sg devices. It isn't a complete
solution.

Sponsored by:   Panasas
MFC after:	1 week
2010-05-11 22:22:01 +00:00
Alexander Motin
da6808c111 Make SATA XPT negotiate and enable some additional SATA features, such as:
- device initiated power management (some devices support only this way);
 - Automatic Partial to Slumber Transition (more power saving);
 - DMA auto-activation (expected to slightly improve performance).
More features could be added later, when hardware supports.
2010-05-02 12:07:47 +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
Alexander Motin
e2a751891f Report PMP absence using target 15, same as for precence (not a wildcard),
to not confuse target ID checks at SIMs.
2010-04-30 07:56:21 +00:00
Alexander Motin
2eb4a8dcae Update device identify data and serial number when device change detected.
Reprobe immediately following this should have fresh data.
2010-04-27 15:59:38 +00:00
Alexander Motin
699f853bed MFp4:
Move PI_TAG_ABLE check from ada driver to ATA XPT.
2010-04-26 12:03:55 +00:00
Andriy Gapon
a3a86fc397 scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set d_sectorsize and
d_mediasize

CD_FLAG_VALID_TOC is not required for setting those media properties.

PR:		kern/145385
Submitted by:	Juergen Lock <nox@jelal.kn-bremen.de>
		a slightly different version
Tested by:	Pavel Sukhoy <sukhoy@ripn.net>,
		Markus Wild <m.wild@cybernet.ch>,
		Juergen Lock <nox@jelal.kn-bremen.de>,
		uqs
MFC after:	1 week
2010-04-15 08:29:14 +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
Matt Jacob
f33cab323c Add a couple missing basic mode page codes.
MFC after:	1 week
2010-04-01 01:49:43 +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
Matt Jacob
75b06c87a7 We actually can generate a host number.
MFC after:	1 month
2010-03-17 18:53:58 +00:00
Alexander Motin
1254b6802f Make PUIS detection more strict. Previous implementation caused false
positives on VMWare's virtual CD-ROMs.
2010-02-26 10:42:46 +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
c89d1732ba Make CD driver a bit more robust and predictable to unreported errors. 2010-02-15 18:14:51 +00:00
Alexander Motin
639c2d4fad On probe error, if restart requested, skip any retries and recovery.
Just restart probe from the beginning immediately.
2010-02-04 18:56:38 +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
4ef08dc5a5 MFp4:
Add Power Up In Stand-by feature support. Device with PUIS enabled
require explicit command to do initial spin-up. Mark that command
with CAM_HIGH_POWER flag, to allow CAM manage staggered spin-up.
2010-02-03 10:06:03 +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
a9b8edb194 - Use separate buffer for identify data fetching. We can't use main buffer
here if device already running, as data need to be formatted before use.
- Remove some saved_ccb variables. They are unused now.
2010-02-02 18:03:21 +00:00
Alexander Motin
e9d240ecf3 Some missed parts for r203376. 2010-02-02 17:56:54 +00:00
Alexander Motin
4cca153030 - Give ATA/SATA SIMs info about ATAPI packet size, supported by device.
- Make ATA XPT to reject longer SCSI CDBs then supported by device, or
any SCSI CDBs, if device doesn't support ATAPI.
2010-02-02 11:09:28 +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
0025eb12c8 - Report SATA in legacy emulation mode still as SATA.
- Make ATA XPT able to handle such case.
2010-01-10 09:20:56 +00:00
Martin Blapp
c2ede4b379 Remove extraneous semicolons, no functional changes.
Submitted by:	Marc Balmer <marc@msys.ch>
MFC after:	1 week
2010-01-07 21:01:37 +00:00
Alexander Motin
1c80ec0a6b Add BIO_DELETE support to ada(4):
- For SSDs use TRIM feature of DATA SET MANAGEMENT command, as defined by
ACS-2 specification working draft.
- For CompactFlash use CFA ERASE command, same as ad(4) does.

With this patch, `newfs -E /dev/ada1` was able to restore write speed of
my heavily weared OCZ Vertex SSD (firmware 1.4) up to the initial level
for the most part of it's capacity. Previous 1.3 firmware, even reportiong
TRIM capabilty bit set, was not working, reporting ABORT error for every
DSM command.

I have no idea whether it is normal, but for some reason it takes 200ms
to handle any TRIM command on this drive, that was making delete extremely
slow. But TRIM command is able to accept long list of LBAs and the length of
that list seems doesn't affect it's execution time. Implemented request
clusting algorithm allowed me to rise delete rate up to reasonable numbers,
when many parallel DELETE requests running.
2009-12-28 20:08:01 +00:00
Alexander Motin
ce8332d468 Report stripe size only if physical sector size is not equal to logical. 2009-12-24 21:54:44 +00:00
Alexander Motin
7485a8eb62 Remove duplicate devstat_start_transaction_bio() call. It is already called
from geom_disk. Dulicate call causes wrong queue depth and busy accounting.
2009-12-18 14:41:30 +00:00
Alexander Motin
2ec0f2e186 Clear result before requesting XPT_PATH_INQ.
Many SIMs doesn't fill maxio field yet.
2009-12-09 14:21:21 +00:00
Alexander Motin
7bdb664e50 MFp4;
- Cleanup kernel messages, mostly PMP.
- Took references on devices, while PMP reinitializes them, to not let them
go and distort freeze reference counting.
2009-12-07 16:23:25 +00:00
Alexander Motin
21cc85878c MFp4:
If we panicked with SIM lock held, do not try to flush caches.
Extra lock recursing will not make debugging easier.
2009-12-06 11:48:53 +00:00
Alexander Motin
066f913a94 MFp4:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this options deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.

As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.atapi_dma tunable work again.

Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.

Submitted by:	nwitehorn (powerpc part)
2009-12-06 00:10:13 +00:00