Commit Graph

243 Commits

Author SHA1 Message Date
Konstantin Belousov
378c532c1f Add quirk to override default BAR(5) rid for AHCI.
Use it for Cavium AHCI.

Submitted by:	Michaе┌ Stanek
Reviewed by:	imp (previous version)
MFC after:	1 week
2015-01-13 00:11:56 +00:00
Marius Strobl
21190895ab - Const'ify the ahci_ids table.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.

MFC after:	3 days
2014-12-28 20:42:28 +00:00
Steven Hartland
e4a8f2e2ec style (9) nits
Use return (val); instead of return val;

Differential Revision:	D838
MFC after:	2 weeks
Sponsored by:	Multiplay
2014-12-21 16:38:29 +00:00
Steven Hartland
5f59ea478e Return the error from ahci_setup_interrupt in ahci_attach
Previously ahci_attach returned a hard coded ENXIO instead of the value
from ahci_setup_interrupt. This is effectively a NOOP change as currently
ahci_setup_interrupt only ever returns 0 or ENXIO, so just there to protect
against any future changes to that.

Differential Revision:	D838
MFC after:	2 weeks
Sponsored by:	Multiplay
2014-12-21 16:32:57 +00:00
Steven Hartland
a12f5777df Clamp ahci max irq's to AHCI_MAX_IRQS
This prevents the possiblity of any overruns on the statically allocated
struct irqs field.

Differential Revision:	D838
MFC after:	2 weeks
X-MFC-With:	r276012
Sponsored by:	Multiplay
2014-12-21 16:15:29 +00:00
Steven Hartland
55972826f2 Add a constant AHCI_MAX_IRQS removing magic number
Sponsored by:	Multiplay
2014-12-21 16:07:46 +00:00
Alexander Motin
e67f3bec39 Add bunch of PCI IDs of Intel Wildcat Point (9 Series) chipsets.
MFC after:	1 week
2014-11-26 04:23:21 +00:00
Steven Hartland
85c9dd9d89 Prevent overflow issues in timeout processing
Previously, any timeout value for which (timeout * hz) will overflow the
signed integer, will give weird results, since callout(9) routines will
convert negative values of ticks to '1'. For unsigned integer overflow we
will get sufficiently smaller timeout values than expected.

Switch from callout_reset, which requires conversion to int based ticks
to callout_reset_sbt to avoid this.

Also correct isci to correctly resolve ccb timeout.

This was based on the original work done by Eygene Ryabinkin
<rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid
the overlow.

Differential Revision:	https://reviews.freebsd.org/D1157
Reviewed by:	mav, davide
MFC after:	1 month
Sponsored by:	Multiplay
2014-11-21 21:01:24 +00:00
Ian Lepore
faab4473eb A dma tag alignment should be 1 (not 0) when a device can dma at any address. 2014-11-06 18:15:16 +00:00
Alexander Motin
88971a900d Use r271207 optimization only for MSI-enabled HBAs.
It was found that VirtualBox' AHCI does not allow nterrupt to be cleared
before the interrupt status register is read, causing interrupt storm.

AHCI specification allows to skip this register use when multi-vector MSI
is enabled and so interrupting port is known.  For single-vector MSI that
is not stated explicitly, but if the port is only one, it is obviously
known too.
2014-10-06 10:58:54 +00:00
Steven Hartland
6e9a599b27 Use a local STAILQ for unlocked done CCB processing in ahci direct mode
Previously it was possible for issues e.g. use after free, to result
from processing the done queue while not holding the channel lock.

While this should never happen in practice, unexpected code flows
which result in two threads processing from the same queue may
be possible.

We now use a local STAILQ to prevent this ever being an issue.

Sponsored by:	Multiplay
2014-09-27 19:14:22 +00:00
Alexander Motin
6e88c2c572 Initialize variables before resource_int_value().
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
2014-09-12 08:37:21 +00:00
Alexander Motin
03d89c944a Add PCI ID for Promise TX8660 8-port 3Gbps HBA.
This device reports RAID subclass, but appears to be AHCI compatible.

Submitted by:	Yuri Perejilin <yuri@rivera.ru>
MFC after:	1 week
2014-09-10 19:53:31 +00:00
Alexander Motin
fcd7f38fb0 Bunch of microoptimizations to reduce dereferences and cache collisions. 2014-09-08 12:11:49 +00:00
Alexander Motin
c45ff92177 Save one register read (AHCI_IS) for AHCI controllers with only one port.
For controllers with only one port (like PCIe or M.2 SSDs) interrupt can
come from only one source, and skipping read saves few percents of CPU time.

MFC after:	1 month
H/W donated by:	I/O Switch
2014-09-06 19:43:48 +00:00
Warner Losh
4acab041dd Restore order of interrupt setup. Minor problems can result by
setting up the interrupts too early:

Reviewed by: mav@
Sponsored by: Netflix
2014-09-06 18:20:50 +00:00
Alexander Motin
985da6db1c Fix typo in comments.
Submitted by:	Benedict Reuschling <bcr@FreeBSD.org>
MFC after:	6 days
2014-09-06 15:37:55 +00:00
Alexander Motin
c6efb4c41d Invert AHCI_Q_NOBSYRES quirk meaning, waiting for readiness by default.
I gave up to update list of Marvell chips that require this quirk.
The final nail was growing number of PCIe/M.2 SSDs where Marvell chips
have PCI IDs of different vendors.

MFC after:	1 week
H/W donated by:	I/O Switch
2014-09-05 13:45:14 +00:00
Warner Losh
802df3ace6 Separate out PCI attachment from the main AHCI driver. Move checks of
PCI IDs into quirks, which mostly fit (though you'd get no argument
from me that AHCI_Q_SATA1_UNIT0 is oddly specific). Set these quirks
in the PCI attachment. Make some shared functions public so that PCI
and possibly other bus attachments can use them.

The split isn't perfect yet, but it is functional. The split will be
perfected as other bus attachments for AHCI are written.

Sponsored by: Netflix
Reviewed by: kan, mav
Differential Revision: https://reviews.freebsd.org/D699
2014-09-04 22:22:53 +00:00
Warner Losh
0375d6f5f9 We were returning 20 bytes as the FIS size to send, but only
initializing 16. Initialize all 20 so we don't send garbage in the
Auxiliary register. The SATA standard mandates a 5 dword length for
the Host to Device FIS.

Sponsored by: Netflix
2014-08-30 02:13:09 +00:00
John Baldwin
a2677ff239 Don't bother clearing maps for static DMA allocations to NULL. Instead,
leave them as purely opaque values that are only set by bus_dmamem_alloc().
2014-06-17 18:10:06 +00:00
Alexander Motin
48ecfdc414 Correct AMD chipsets identification.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2014-04-17 14:16:02 +00:00
Alexander Motin
3fcad654e2 Add ID for one more ASMedia AHCI-compatible controller.
Reported by:	ignace.peeters@gmail.com
MFC after:	2 weeks
2014-01-17 17:16:49 +00:00
Zbigniew Bodek
b1c5afbb2f Revert r260165: Proper configuration of unmapped_buf_allowed should be used
To avoid failures in bus_dmamap_sync() on ARM unmapped_buf_allowed should
be set to 0. Hence, ARM-specific changes in AHCI should not be applied.
2014-01-02 11:24:04 +00:00
Zbigniew Bodek
49390e758d Use only mapped BIOs on ARM
Using unmapped BIOs causes failure inside bus_dmamap_sync, since
this function requires valid MVA address, which is not present
if mapping is not set up.

Submitted by:	Wojciech Macek <wma@semihalf.com>
Obtained from:	Semihalf
2014-01-01 20:26:08 +00:00
Zbigniew Bodek
df2ec2e4fb Do not attach to PCI bridges in AHCI driver
Some vendors use the same VID:PID combination in AHCI and PCI bridge cards

Submitted by:	Wojciech Macek <wma@semihalf.com>
Obtained from:	Semihalf
2014-01-01 20:18:03 +00:00
Alexander Motin
8adff99c8d Destroy mtx lock when failed to allocate memory during attach.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2013-12-11 17:40:35 +00:00
Eitan Adler
7a22215c53 Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit.  Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with:	-arch, rdivacky
Reviewed by:	cperciva
2013-11-30 22:17:27 +00:00
Alexander Motin
9a6b4cb929 Add few more minor parts of DevSleep support from AHCI 1.3.1 proposal. 2013-11-15 15:14:07 +00:00
Alexander Motin
eda36fb4f5 Add some more IDs for Intel ATA, AHCI and USB controllers. 2013-11-15 10:28:59 +00:00
Alexander Motin
227d67aa54 Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

Replace big per-SIM locks with bunch of smaller ones:
 - per-LUN locks to protect device and peripheral drivers state;
 - per-target locks to protect list of LUNs on target;
 - per-bus locks to protect reference counting;
 - per-send queue locks to protect queue of CCBs to be sent;
 - per-done queue locks to protect queue of completed CCBs;
 - remaining per-SIM locks now protect only HBA driver internals.

While holding LUN lock it is allowed (while not recommended for performance
reasons) to take SIM lock.  The opposite acquisition order is forbidden.
All the other locks are leaf locks, that can be taken anywhere, but should
not be cascaded.  Many functions, such as: xpt_action(), xpt_done(),
xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM
lock to be held.

To keep compatibility and solve cases where SIM lock can't be dropped, all
xpt_async() calls in addition to xpt_done() calls are queued to completion
threads for async processing in clean environment without SIM lock held.

Instead of single CAM SWI thread, used for commands completion processing
before, use multiple (depending on number of CPUs) threads.  Load balanced
between them using "hash" of the device B:T:L address.

HBA drivers that can drop SIM lock during completion processing and have
sufficient number of completion threads to efficiently scale to multiple
CPUs can use new function xpt_done_direct() to avoid extra context switch.
Make ahci(4) driver to use this mechanism depending on hardware setup.

Sponsored by:	iXsystems, Inc.
MFC after:	2 months
2013-10-21 12:00:26 +00:00
Gavin Atkinson
0d9bc65de7 Support the PCI-Express SSD in the new MacBook Air (model A1465)
Submitted by:	Johannes Lundberg <johannes brilliantservice.co.jp>
MFC after:	3 days
2013-08-28 14:29:33 +00:00
Alexander Motin
48f2741c29 Decode some bits defined in AHCI 1.3.1 Device Sleep Technical Proposal.
For now this is only conmetics to report HBA capabilities (Haswell?).

Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
2013-07-25 10:29:40 +00:00
Jack F Vogel
428e286da3 Add new Coleto Creek device support: SATA, SMBus, and Watchdog devices.
MFC after: 1 week
2013-07-19 21:37:40 +00:00
Alexander Motin
122ecf1eca Add ID for Marvell 88SE9215 AHCI SATA controller.
MFC after:	3 days
2013-07-09 08:49:17 +00:00
Alexander Motin
c4aea6be90 Add one more ID of Marvell SATA controller.
Submitted by:	marck
MFC after:	3 days
2013-07-09 08:32:17 +00:00
Steven Hartland
6fb5c84ea2 Added output of device QUIRKS for CAM and AHCI devices during boot.
Reviewed by:	mav
Approved by:	pjd (mentor)
MFC after:	2 weeks
2013-05-18 23:36:21 +00:00
Alexander Motin
943a5fa82e Add IDs for HighPoint RocketRAID 640L/642L/644L -- new series of 4-port
6Gbps PCIe 2.0 x2 SATA controllers, based on Marvell 88SE9235 chips.

MFC after:	1 week
2013-05-02 16:09:06 +00:00
Alexander Motin
234aa0297c Create controller-level DMA tag, handling range of supported addresses.
That simplifies logic for channels and gives the bus information about what
device actually allocated the tag.

Submitted by:	jhb@
2013-04-10 20:38:15 +00:00
Alexander Motin
c6eeee5e44 Check status of ahci_em_reset() on attach and abort if reset failed.
For now it is just a hypothetical case.

Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
2013-04-04 09:15:19 +00:00
Alexander Motin
6a740c4a4f Read Asynchronous Notification statuses only if Port Multiplier or ATAPI
device are connected. ATA disks are not using ANs, while the extra register
read operation is quite expensive.
2013-03-25 13:58:17 +00:00
Alexander Motin
3d44989055 Depending on combination of running commands (NCQ/non-NCQ) try to avoid
extra read from PxCI/PxSACT registers.  If only NCQ commands are running, we
don't really need PxCI.  If only non-NCQ commands are running we don't need
PxSACT.  Mixed set may happen only on controllers with FIS-based switching
when port multiplier is attached, and then we have to read both registers.

MFC after:	1 month
2013-03-25 08:50:51 +00:00
Alexander Motin
db12db318d No need to erase all 64 bytes of CFIS area if we never use more then 16. 2013-03-24 16:51:21 +00:00
Konstantin Belousov
129c6621f7 ahci(4) and siis(4) are ready to process the unmapped i/o requests
Sponsored by:	The FreeBSD Foundation
Tested by:	pho
Submitted by:	bf (siis patch)
2013-03-19 15:09:32 +00:00
Konstantin Belousov
dd0b4fb6d5 Reform the busdma API so that new types may be added without modifying
every architecture's busdma_machdep.c.  It is done by unifying the
bus_dmamap_load_buffer() routines so that they may be called from MI
code.  The MD busdma is then given a chance to do any final processing
in the complete() callback.

The cam changes unify the bus_dmamap_load* handling in cam drivers.

The arm and mips implementations are updated to track virtual
addresses for sync().  Previously this was done in a type specific
way.  Now it is done in a generic way by recording the list of
virtuals in the map.

Submitted by:	jeff (sponsored by EMC/Isilon)
Reviewed by:	kan (previous version), scottl,
	mjacob (isp(4), no objections for target mode changes)
Discussed with:	     ian (arm changes)
Tested by:	marius (sparc64), mips (jmallet), isci(4) on x86 (jharris),
	amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)
2013-02-12 16:57:20 +00:00
Alexander Motin
abd1548c8d Disable MSI interrupts for SB600 chipset. According to the report they are
not functional.

PR:		kern/174880, kern/174985, kern/175002
MFC after:	1 week
2013-01-24 09:33:43 +00:00
Jack F Vogel
e1d6f7b47b Add Intel Lynx Point PCH SATA Controller Device IDs 2013-01-02 22:26:46 +00:00
Alexander Motin
4587cbadc5 Add IDs for SATA controllers on AMD Hudson-2 series chipsets.
I am not exactly sure about the naming due to lack of specs on AMD site,
but it is better to have some identification then none at all.

MFC after:	1 month
2012-12-12 11:53:15 +00:00
Alexander Motin
aaff3a7331 Announce diagnostic page 7 (Element Descriptor) support. 2012-11-07 22:53:46 +00:00
Eitan Adler
db702c59cf remove duplicate semicolons where possible.
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:00:37 +00:00
Gavin Atkinson
e935190a33 Switch some PCI register reads from using magic numbers to using the names
defined in pcireg.h

MFC after:	1 week
2012-09-19 12:27:23 +00:00
Alexander Motin
189d85cc15 Fix AHCI 1.2 version checks. This should be mostly cosmetic.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2012-09-12 09:20:37 +00:00
Alexander Motin
49a4a59a54 Add IDs for JMicron JMB360/JMB362 AHCI SATA controllers.
MFC after:	1 week
2012-08-30 15:23:59 +00:00
Alexander Motin
cf977ac20a Return "locally assigned" Enclosure Logical Identifier instead of 8 zero
bytes. Zeroes there are incorrect and tend to cause false device ID matches.
2012-08-25 23:01:57 +00:00
Alexander Motin
d19f06b324 Refactor enclosure manegement support in ahci(4). Move it out into separate
subdevice ahciem. Emulate SEMB SES device from AHCI LED interface to expose
it to users in form of ses(4) CAM device. If we ever see AHCI controllers
supporting SES of SAF-TE over I2C as described by specification, they should
fit well into this new picture.

Sponsored by:	iXsystems, Inc.
2012-07-26 13:44:48 +00:00
Alexander Motin
eb586bd9ee Partially revert r236666:
Return PROTO_ATA protocol in response to XPT_PATH_INQ.

smartmontools uses it to identify ATA devices and I don't know any other
place now where it is important. It could probably use XPT_GDEV_TYPE
instead for more accurate protocol information, but let it live for now.

Reported by:	matthew
MFC after:	3 days
2012-06-10 11:17:14 +00:00
Alexander Motin
c18783f219 Add IDs for Marvell 88SE9220/9230/9235 PCIe 2.0 x2 6Gbps SATA controllers.
Marvell 88SE9230 was confirmed to work, the rest two are just guessed.

MFC after:	1 week
2012-06-08 07:44:42 +00:00
Alexander Motin
bc1bf6e842 ATA/SATA controllers have no idea about protocol of the connected device
until transport will do some probe actions (at least soft reset).
Make ATA/SATA SIMs to not report bogus and confusing PROTO_ATA protocol.
Make ATA/SATA transport to fill that gap by reporting protocol to SIM with
XPT_SET_TRAN_SETTINGS and patching XPT_GET_TRAN_SETTINGS results if needed.
2012-06-06 06:52:51 +00:00
Hans Petter Selasky
58a9da85fe Add quirk for Marvell based AHCI controller.
MFC after:	3 days
Suggested by:	mav @
2012-05-29 15:56:30 +00:00
Alexander Motin
711f661393 Add two functions xpt_batch_start() and xpt_batch_done() to the CAM SIM KPI
to allow drivers to handle request completion directly without passing
them to the CAM SWI thread removing extra context switch.
Modify all ATA/SATA drivers to use them.

Reviewed by:	gibbs, ken
MFC after:	2 weeks
2012-05-12 13:55:36 +00:00
Alexander Motin
9364490242 Fix names of some Marvell SATA chips. It looks like chips with proprietary
interface supported by mvs(4) are 88SX, while AHCI-like chips are 88SE.

PR:		kern/165271
Submitted by:	Jia-Shiun Li <jiashiun@gmail.com>
MFC after:	1 week
2012-03-02 08:49:07 +00:00
Ulrich Spörlein
9a14aa017b Convert files to UTF-8 2012-01-15 13:23:18 +00:00
Jim Harris
9bea89c1b0 Add 0x2826 device ID for C600 (Patsburg) SATA controller in RAID mode.
Reviewed by: mav
Approved by: scottl
2012-01-06 00:22:55 +00:00
Alexander Motin
c8973d9e6c Add hw.ahci.force tunable to control whether AHCI drivers should attach
to known AHCI-capable chips (AMD/NVIDIA), configured for legacy emulation.

Enabled by default to get additional performance and functionality of AHCI
when it can't be enabled by BIOS. Can be disabled to honor BIOS settings if
needed for some reason.

MFC after:	1 month
2011-12-02 12:52:33 +00:00
Hans Petter Selasky
3b12bdb58f Rename device_delete_all_children() into device_delete_children().
Suggested by:	jhb @ and marius @
MFC after:	1 week
2011-11-22 21:56:55 +00:00
Hans Petter Selasky
11bcf702f4 Move the device_delete_all_children() function from usb_util.c
to kern/subr_bus.c. Simplify this function so that it no longer
depends on malloc() to execute. Identify a few other places where
it makes sense to use device_delete_all_children().

MFC after:	1 week
2011-11-19 10:11:50 +00:00
Alexander Motin
72a61203fc Change the way how "not implemented" AHCI channels handled. Instead of
completely skipping them, create ahcich devices for them to allocate unit
numbers, but mark them as disabled to prevent driver probe and attach.

Last time some BIOSes tend to report unused channels as "not implemented".
This change makes ahcichX devices numbering consistent, independently of
connected disks. It makes per-channel driver hints usable and CAM devices
wiring possible on such systems.
2011-11-17 20:46:51 +00:00
Ed Schouten
d745c852be Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.
This means that their use is restricted to a single C file.
2011-11-07 06:44:47 +00:00
Alexander Motin
cf2446231a Add one more ID for the Marvell 88SE9128 6Gbps SATA controller.
MFC after:	3 days
2011-09-27 09:32:34 +00:00
Alexander Motin
376271fb4c Add ID for ASMedia ASM1061 2-port PCIe 2.0 x1 6Gb/s SATA controller.
Approved by:	re (blackend)
MFC after:	1 week
2011-08-24 09:08:07 +00:00
Alexander Motin
df6f430410 Do not force AHCI mode on NVIDIA MCP89 SATA controllers. Recent Apple
Mac with this chipset does not initialize AHCI mode unless it is started
from EFI loader.  However, legacy ATA mode works.

Submitted by:	jkim@ (original version)
Approved by:	re (kib)
MFC after:	1 week
2011-08-02 11:07:47 +00:00
Alexander Motin
2d33cc7688 In some cases, at least on Marvell 88SE912x controllers, Current Command
Slot field of the PxCMD register may point to an empty command slot.
That breaks command timeout detection logic, making impossible to find
what command actually caused timeout, and leading to infinite wait.
Workaround that by checking whether pointed command slot is really used
and can timeout in its time. And if not, fallback to the dumb algorithm
used with FBS -- let all commands to time out and then fail all of them.

Approved by:	re (kib)
MFC after:	1 week
2011-07-29 20:35:23 +00:00
Alexander Motin
35ded6a6a7 Add ID for Marvell 88SE9125 SATA controller.
PR:		kern/157843
MFC after:	1 week
2011-06-30 19:23:17 +00:00
Alexander Motin
1d4ce50afe Add Marvell 88SE9172 chip PCI ID. 2011-05-26 10:10:10 +00:00
Alexander Motin
232a9d55fb Marvell 88SE91xx controllers are known to report soft-reset completion
without waiting for device readiness (or at least not updating FIS receive
area in time). To workaround that, special quirk was added earlier to wait
for the FIS receive area update. But it was found that under same PCI ID
0x91231b4b and revision 0x11 there are two completely different chip
versions (firmware?): HBA and RAID. The problem is that RAID version in
some cases, such as hot-plug, does not update FIS receive area at all!

To workaround that, differentiate the chip versions by their capabilities,
and, if RAID version found, skip FIS receive area update waiting and read
device signature from the PxSIG register instead. This method doesn't work
for HBA version when PMP attached, so keep using previous workaround there.
2011-05-26 09:23:01 +00:00
Alexander Motin
08c8fde007 According to SATA specification, when Serial ATA Enclosure Management Bridge
(SEMB) is unable to communicate to Storage Enclosure Processor (SEP), in
response to hard and soft resets it should among other things return value
0x7F in Status register. The weird side is that it means DRQ bit set, which
tells that reset request is not completed. It would be fine if SEMB was the
only device on port. But if SEMB connected to PMP or built into it, it may
block access to other devices sharing same SATA port.

Make some tunings/fixes to soft-reset handling to workaround the issue:
 - ahci(4): request CLO on the port after soft reset to ignore DRQ bit;
 - siis(4): gracefully reinitialize port after soft reset timeout (hardware
doesn't detect reset request completion in this case);
 - mvs(4): if PMP is used, send dummy soft-reset to the PMP port to make it
clear DRQ bit for us.

For now this makes quirks in ata_pmp.c, hiding SEMB ports of SiI3726/SiI4726
PMPs, less important. Further, if hardware permit, I hope to implement real
SEMB support.
2011-05-25 13:55:49 +00:00
Alexander Motin
96b7988f12 Add support for "LED" enclosure management messages, defined by the AHCI.
When supported by hardware, this allows to control per-port activity, locate
and fault LEDs via the led(4) API for localization and status reporting
purposes. Supporting AHCI controllers may transmit that information to the
backplane controllers via SGPIO interface. Backplane controllers interpret
received statuses in some way (IBPI standard) to report them using present
indicators.
2011-05-17 22:07:45 +00:00
Jack F Vogel
73e3bb6563 Chipset support for the new Intel Panther Point PCH, thanks
to Seth Heasley for preparing the changes.
2011-05-11 20:31:27 +00:00
Alexander Motin
e2d6ccef4b Add PCI ID for Marvell 88SE9182 -- PCIe 2.x x2 relative of the 88SE912x.
Submitted by:	dchagin
MFC after:	1 week
2011-05-05 17:11:26 +00:00
Alexander Motin
7bcc595738 Fix some English grammar. 2011-04-19 10:57:40 +00:00
Alexander Motin
1f145eafea According to specification. device should respond to COMRESET with COMINIT
in no more then 10ms. If we detected no device presence within that time,
there is no reason to wait longer.
2011-04-19 10:51:19 +00:00
Alexander Motin
6ac0befde2 Properly handle memory allocation errors during error recovery. 2011-04-19 08:01:17 +00:00
Alexander Motin
18301f742e Handle ready timeout during polled operation same as done in mvs(4) before. 2011-04-18 16:00:46 +00:00
Alexander Motin
3a3d820b3d - Tune different wait loops to cut some more milliseconds from reset time.
- Do not call ahci_start() before device signature received. It is required
by the specification and caused non-fatal reset timeouts on AMD chipsets.
2011-04-18 13:34:31 +00:00
Alexander Motin
06ccfe1dd7 Some changes around hot-plug and interface power-management:
- use ATA_SE_EXCHANGED (SError.DIAG.X) bit to detect hot-plug events when
power-management enabled and ATA_SE_PHY_CHANGED (SError.DIAG.N) can't be
trusted;
 - on controllers supporting staggered spin-up (SS) put unused channels
into Listen state instead of Off. It should still save some power, but
allow plug-in events to be detected;
 - on controllers supporting cold presence detection (CPD), when power
management enabled, use CPD events to detect hot-plug in addition to PHY
events.
2011-04-15 16:40:31 +00:00
Alexander Motin
8d169381e4 Improve SATA Asynchronous Notification feature support in CAM:
- make SATA SIMs announce capabilities to handle SDB with Notification bit;
 - make PMP driver honor this SIMs capability;
 - make SATA XPT to negotiate and enable this feature for ATAPI devices.

This feature allows supporting SATA ATAPI devices to inform system about
some events happened, that may require attention. In my case this allows
LG GH22LS50 SATA DVR-RW drive to report tray open/close events. Events
reported to CAM in form of AC_SCSI_AEN async. Further they could be used
as a hints for checking device status and reporting media change to upper
layers, for example, via spoiling mechanism of GEOM.
2011-04-13 16:20:54 +00:00
Alexander Motin
df1439e31f Refactor hard-reset implementation in ahci(4).
Instead of spinning in a tight loop for up to 15 seconds, polling for device
readiness while it spins up, return reset completion just after PHY reports
"connect well" or 100ms connection timeout. If device was found, use callout
for checking device readiness with 100ms period up to full 31 second timeout.

This fixes system freeze for 5-10 seconds on drives hot plug-in.
2011-04-12 20:50:57 +00:00
Alexander Motin
6bbd332e5d Implement automatic SCSI sense fetching for ahci(4). 2011-04-12 11:24:59 +00:00
Alexander Motin
5b917bfc3f Add one more ID for Marvell 88SE912x chip found on Asus U3S6 card.
Submitted by:	Jonas Jonsson <fatbrain@gmail.com>
2011-04-07 08:28:53 +00:00
Alexander Motin
65c63cd22f Add some more IDs of HighPoint RocketRAID 64x. 2011-03-06 16:10:39 +00:00
Alexander Motin
fa84e0f903 Restore DH89xxCC/Patsburg chip IDs accentally dropped at r218596. 2011-02-12 13:28:50 +00:00
Alexander Motin
a7c797f063 Disable NCQ for multiport Marvell 88SX61XX SATA controllers. Simultaneous
active I/O to several disks (copying large file on ZFS) causes timeout after
just a few seconds of run. Single port 88SX6111 seems like not affected.

Skip reading transferred bytes count for these controllers. It works for
88SX6111, but 88SX6145 always returns zero there. Haven't tested others,
but better to be safe.
2011-02-12 07:06:40 +00:00
Jack F Vogel
bf0477b215 Support for the new Patsburg PCH chipset:
- SMBus Controller
     - SATA Controller
     - HD Audio Controller
     - Watchdog Controller

Thanks to Seth Heasley (seth.heasley@intel.com) for providing us code.

MFC after 3 days
2011-02-01 01:05:11 +00:00
Jack F Vogel
d5267ede37 Support for the new DH89xxCC PCH chipset including:
- SATA controller
      - Watchdog timer
      - SMBus controller
2011-01-31 18:41:52 +00:00
Alexander Motin
da839e639b Add IDs for HighPoint RocketRAID 64x controllers.
These controllers consist of two Marvell 88SE9128 6Gbps SATA chips and
PLX PCIe bridge. As result, they seem to be agree to work with ahci(4)
as usual HBAs. The only noticed issue is that RAID BIOS disables all
drive caches during boot, though `camcontrol cmd ...` is able to fix that.

Those who wants RAID functionality can still use closed proprietary driver
from HighPoint site.

MFC after:	1 week
2011-01-10 22:27:52 +00:00
Alexander Motin
ee65f30a14 Add IDs of HighPoint RocketRAID 62x cards (Marvell 88SE9128 chips).
PR:		kern/152926
Submitted by:	Mike Tancsa <mike@sentex.net>
MFC after:	1 week
2010-12-08 20:35:20 +00:00
Alexander Motin
96ecb95ed9 Fix small typo.
Submitted by:	Artem Belevich
2010-11-22 23:04:25 +00:00
Alexander Motin
ba3a999598 Teach ahci(4), siis(4) and ATA_CAM ata(4) wrapper report to CAM residual
I/O length on underruns, that often happens for some SCSI commands.
2010-11-08 15:36:15 +00:00
Alexander Motin
5b9392e840 Add missing mtx_destroy() on channel attach failure. 2010-10-25 07:41:21 +00:00
Alexander Motin
bf12976c76 Fix panic, when due to some kind of congestion on FIS-based switching
port multiplier some command triggers false positive timeout, but then
completes normally.

MFC after:	2 weeks
2010-09-16 12:39:50 +00:00
Alexander Motin
90400bed63 MFata(4):
Add Intel Cougar Point PCH SATA Controller DeviceIDs. Correct some existing
entries for Intel Ibex Peak (5 Series/3400 Series) PCH SATA controllers.
2010-08-28 07:24:45 +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
Alexander Motin
a47eae85b4 Disable NCQ and PMP support for VIA VT8251 AHCI. It was reported to be
unreliable under load. Linux does the same.
2010-06-08 10:03:08 +00:00
Alexander Motin
dc5a530b04 Plug memory leak to silent Coverity. Error is still not really handled.
Found with:   Coverity Prevent(tm)
CID:          4130
2010-06-05 08:07:54 +00:00
Alexander Motin
c4d8fe61a1 Fix attach errors handling.
Found with:   Coverity Prevent(tm)
CID:          3424
2010-06-05 08:02:19 +00:00
Alexander Motin
cc6b610bea Fill rman range start/end values. It makes devinfo output more readable. 2010-05-22 08:30:47 +00:00
Alexander Motin
445cc79ca9 Report ATA/SATA channel number to NewBus at location string. 2010-05-22 07:32:47 +00:00
Alexander Motin
6533cd198d Improve suspend/resume support. Make sure controller is idle on suspend
and reset it on resume.
2010-05-21 13:29:28 +00:00
Alexander Motin
205367f9bc Enable PCI busmastering explicitly to be sure. 2010-05-02 14:46:05 +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
89f2835fc9 Add Target/LUN ID checks and deny access to targets 1-14 when PMP absent.
Enforce PMA bit clearing when PMP detached to avoid further scan timeouts.
2010-04-30 08:02:12 +00:00
Rui Paulo
0ff2943ecb Revert r206755. It causes some laptops to stop booting. 2010-04-19 14:07:33 +00:00
Rui Paulo
25eb6a7d87 Add another ICH7M chipset that works.
MFC after:	1 week
2010-04-17 11:40:39 +00:00
Alexander Motin
e67afc40da - Spec tells that CCC interrupt is edge triggered. Acknowledge it as such.
- Do not try to enable CCC if it is not supported.
2010-03-21 18:18:58 +00:00
Alexander Motin
b41cd53957 MFp4:
With FBS enabled, we have no idea what command caused timeout.
Implement same logic as in siis(4) - wait for other commands
complete or timeout and then give some more time.
2010-02-14 12:30:35 +00:00
Alexander Motin
4c9d5e6b0f Disable PHY of unconnected ports when interface power management enabled.
It allows to save a bit more power (about 0.5W on 2 unused ports of ICH8M).
2010-02-03 12:00:57 +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
ed70cffd35 Reset port on disconnect event, to abort any running requests. 2010-01-29 12:47:04 +00:00
Alexander Motin
0e6eb06168 Add FIS-based switching support. If controller supports FBS, it allows
several devices beyond Port Multiplier to work simultaneously, substantially
increasing performance.
2010-01-28 17:54:47 +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
6268666c1b Add support for SATA part of Marvell 88SE912x controllers to ahci(4).
Limit early revisions from 6Gb/s to 3Gb/s by default, or they negotiate
only 1.5Gbps, when 3Gb/s devices connected.

Add dummy driver for PATA part of these controllers, preventing generic
driver attach them. It causes system freeze when SATA controller used after
PATA was touched.
2010-01-26 15:25:24 +00:00
Alexander Motin
f343c07f96 While AHCI specification tells that multi-vector MSI doesn't use global IS
register, nVidia chipsets have different oppinion, requiring every interrupt
to be acknowledged there.

While there, add interrupt descriptions in multi-vector MSI mode.
2010-01-10 16:05:05 +00:00
Alexander Motin
f45946a8f7 Avoid false positive probe on ICH6 chipsets. 2009-12-25 07:59:31 +00:00
Alexander Motin
45e1aff18a Clear all ports interrupt status bits in single write. Clearing one by one
causes additional MSIs messages sent if several ports asked for attention
same time. Time window before clearing is not important, as these interrupts
are level triggered by interrupt source.
2009-12-21 21:27:56 +00:00
Alexander Motin
a48eed8352 Add Asynchronous Notification support for controllers without SNTF
capability by snooping SDB FIS receive area. It should be even faster
then regular way, but less reliable.
2009-12-06 23:56:54 +00:00
Alexander Motin
b447e682d6 MFp4:
Improve ATA mode/SATA revision control.
2009-11-26 08:49:46 +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
9ece9ab1eb Do not attach JMicrons with single PCI function. They are not working as
AHCI for some reason, even when declaring so. Let atajmicron configure
them for us and provide PATA support.
2009-11-23 18:07:28 +00:00
Alexander Motin
6bd8779bb9 Change the way in which AHCI+PATA combined controllers, such as JMicron
and Marvell handled. Instead of trying to attach two different drivers to
single device, wrapping each call, make one of them (atajmicron, atamarvell)
attach do device solely, but create child device for AHCI driver,
passing it all required resources. It is quite easy, as none of
resources are shared, except IRQ.

As result, it:
- makes drivers operation more independent and straitforward,
- allows to use new ahci(4) driver with such devices, adding support for
new features, such as PMP and NCQ, same time keeping legacy PATA support,
- will allow to just drop old ataahci driver, when it's time come.
2009-11-16 15:38:27 +00:00
Alexander Motin
49b96d25da MFp4:
Check SNCQ HBA capability bit when reporting NCQ support to CAM.
2009-11-14 20:06:04 +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
8e57bf8357 MFp4:
Add set of chip IDs, known to support AHCI.
2009-11-11 10:44:09 +00:00
Alexander Motin
a69552e4b6 MFp4:
- Handle timeouts and fatal errors with port hard-reset. The rest of
recovery will be done by XPT on receiving async event. More gracefull
per-device soft-reset recovery can be implemented later.
- Add workaround for ATI SB600/SB700 PMP probe related bug, to speedup boot.
2009-11-03 11:47:07 +00:00
Alexander Motin
c269e21049 Revert interrupt reason check order back.
ATAPI errors may set IF bit together with TFE.
2009-10-23 13:07:22 +00:00
Alexander Motin
8e7cccb3bd MFp4:
Report real max_target = 15. SIM doesn't need to know that target 15 is PMP.
It is XPT business.
2009-10-21 13:00:01 +00:00
Alexander Motin
a1aa38dedf MFp4:
On error, freeze device queue, to allow periph driver to do proper recovery.
Freeze SIM queue only in some cases, when it is needed to protect SIM.

Implement better command timeout detection logic for non-queued commands.
This fixes false positives when command with short timeout waiting for the
long one. For example, when hald tastes CD during burning process.

Read and clear SERR register on interrupt.
2009-10-21 12:42:25 +00:00
Alexander Motin
660d482a4e On command timeout handle frozen command first, to not run it inside
XXX_end_transaction().

Submitted by:	avg
2009-10-07 15:40:04 +00:00
Alexander Motin
aed39f0d65 To save small bit of CPU time, hide part of SNTF register read latency
behind other reads.
2009-09-06 21:22:24 +00:00
Alexander Motin
ce531e6b83 Round maxio for ATI SB600 to 64K.
Submitted by:	scottl@
2009-09-03 19:02:17 +00:00
Alexander Motin
19dbe46d28 ATI SB600 can't handle 256 sectors transfers with FPDMA (NCQ).
MFC after:	3 days
2009-09-03 12:37:17 +00:00
Alexander Motin
4e931d3116 Fix build with INVARIANTS. 2009-08-30 19:40:09 +00:00
Alexander Motin
4dbabf1049 MFp4:
- Add Command Completion Coalescing support.
 - Add SNTF support.
 - Add two more power management modes (4, 5), implemented on driver level.
 - Fix interface mode setting.
 - Reduce interface reset time.
 - Do not report meaningless protocol/transport versions.
 - Report CAP2 register content.
 - Some performance optimizations.
2009-08-30 15:20:13 +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