Commit Graph

154 Commits

Author SHA1 Message Date
Alexander Motin
bda55b6adb Set of legacy mode SATA enchancements:
- Implement proper combined mode decoding for Intel controllers to properly
identify SATA and PATA channels and associate ATA channels with SATA ports.
This fixes wrong reporting and in some cases hard resets to wrong SATA ports.
- Improve SATA registers support to handle hot-plug events and potentially
interface errors. For ICH5/6300ESB chipsets these registers accessible via
PCI config space. For later ones they may be accessible via PCI BAR(5).
- For controllers not generating interrupts on hot-plug events, implement
periodic status polling. Use it to detect hot-plug on Intel and VIA
controllers. Same probably could also be used for Serverworks and SIS.
2010-10-18 11:30:13 +00:00
Alexander Motin
e064bdc08a Make legacy ATA emulation detection more strict. This should fix false
positive legacy detection and attach failure/panic for Marvell 88SX6141
controller and potentially some others.

PR:		kern/145064
2010-07-16 17:27:43 +00:00
Alexander Motin
6332c92180 Improve interrupt setup errors handling. 2010-07-16 10:05:00 +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
6a5d28b93a Improve output for controllers that doesn't report SATA speed. 2010-02-22 10:45:40 +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
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
Alexander Motin
ff09f97fb4 Do not ignore device interrupt if bus mastering is still active. It is
normal in case of media read error and some ATAPI cases, when transfer size
is unknown beforehand. PCI ATA BM specification tells that in case of such
underrun driver should just manually stop DMA engine. DMA engine should
same time guarantie that all bus mastering transfers completed at the moment
of driver reads interrupt flag asserted.
This change should fix interrupt storms and command timeouts in many cases.

PR:		kern/103602, sparc64/121539, kern/133122, kern/139654
2009-12-05 13:40:51 +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
ebbb35ba70 MFp4:
- Remove most of direct relations between ATA(4) peripherial and controller
levels. It makes logic more transparent and is a mandatory step to wrap
ATA(4) controller level into ATA-native CAM SIM.
- Tune AHCI and SATA2 SiI drivers memory allocation a bit to allow bigger
I/O transaction sizes without additional cost.
2009-10-31 13:24:14 +00:00
Alexander Motin
4c10f2e605 Add experimental support for SATA interface power management.
Feature is controlled by hint.ata.X.pm_level tunable:
 0 - PM disabled, old behaviour, default.
 1 - device is allowed to initiate PM state change, host is passive.
 2 - host initiates PARTIAL state transition every time port is idle.
 3 - host initiates SLUMBER state transition every time port is idle.

PARTIAL state has up to 100us (50us for me) wakeup latency, but for my
ICH8M saves 0.5W of power per drive. SLUMBER state has up to 10ms (3.5ms
for me) wakeup latency, but saves 0.8W of power.

Modes 2 and 3 are implemented only for AHCI driver now.

Interface power management is incompatible with device presence detection
(host receives no signal from drive, so unable to monitor it), so later is
disabled when PM is used.
2009-04-29 21:17:18 +00:00
Jung-uk Kim
c6b8ee96f6 - Give generic AHCI driver lower priority than device-specific drivers.
- Consistently use BUS_PROBE_GENERIC instead of -100.
2009-04-27 21:34:15 +00:00
Jung-uk Kim
7267edac39 Reduce code duplication and excessive pci_get_slot() calls.
Reviewed by:	mav
2009-04-27 19:39:18 +00:00
Jung-uk Kim
3388ca6b71 Reduce excessive pci_get_devid() and pci_get_revid() calls
on the same PCI device while device probing.
2009-04-27 18:10:42 +00:00
Alexander Motin
9cf4fe2ebe Integrate user/mav/ata branch:
Add ch_suspend/ch_resume methods for PCI controllers and implement them
for AHCI. Refactor AHCI channel initialization according to it.

Fix Port Multipliers operation. It is far from perfect yet, but works now.
Tested with JMicron JMB363 AHCI + SiI 3726 PMP pair.
Previous version was also tested with SiI 4726 PMP.

Hardware sponsored by: Vitsch Electronics / VEHosting.nl
2009-03-30 22:18:38 +00:00
Alexander Motin
79ca9100fd Add type specific suspend/resume ata channel functions. Add checks to avoid
crash on detached channel resume. Add placeholder for possible type-specific
suspend/resume routines.
2009-03-09 20:48:57 +00:00
Alexander Motin
b50bb79c6a Use channel driver's attach/detach routines instead of ata_attach()/
ata_detach() to implement IOCATAATTACH/IOCATADETACH ioctls.
This will permit channel drivers to properly shutdown port hardware on channel
detach and init it on attach.
2009-02-19 12:47:24 +00:00
Alexander Motin
78d154163c Quite mechanical ch_detach implementations for all atapci subdrivers.
Some dmainit call fixes for previous commit.
2009-02-19 00:32:55 +00:00
Alexander Motin
04ff88ceac As soon as they called in only same one place (ata_pcichannel_attach()),
join allocate() and dmainit() atapci subdriver's channel initialization
methods into single ch_attach() method.

As opposite to ch_attach() add new ch_detach() method to deallocate/disable
channel.
2009-02-18 22:17:48 +00:00
Alexander Motin
6340835dfd Make ch->dma.free() called symmetrically to ch->dma.alloc(). 2009-02-18 21:12:48 +00:00
Alexander Motin
9f8919f236 Give atapci knowledge about set of implemented AHCI ports. It is possible
to not allocate them after the recent ata channels enumeration changes.
It allows to save some resources, not bother user with unexisting hardware
and not check unimplemented ports status on every interrupt.
2009-02-16 19:10:07 +00:00
Alexander Motin
a3b7c762ba Add initial single-vector MSI support into atapci driver.
Works fine with AHCI and theoretically other MSI capable devices.

At this moment support disabled by default. To enable it, set
"hint.atapci.X.msi=1" device hint.
2009-02-15 20:37:55 +00:00
Alexander Motin
d7216f5694 DEVICE_PROBE(9) claims that we must not initialize softc on probe stage.
Move channel softc initialization from ata_XXX_probe() to ata_XXX_attach().

Instead of calculating ata channel number as position in child device list,
pass it's real number directly from controller probe routine using ivars.
It is simpler and IMHO more correct.
2009-02-14 21:54:44 +00:00
Alexander Motin
cb33306f41 Call ata_legacy() only once on attach and save it's result. Scanning PCI
configuration registers (which are not going to change) on every interrupt
looks expensive, especially when interrupt is shared. Profiling shows me 3%
of time spent by atapci0 on pure network load due to IRQ sharing with em0.
2008-12-16 16:04:40 +00:00
Søren Schmidt
13014ca04a This is the roumored ATA modulerisation works, and it needs a little explanation.
If you just config KERNEL as usual there should be no apparent changes, you'll get all chipset support code compiled in.

However there is now a way to only compile in code for chipsets needed on a pr vendor basis. ATA now has the following "device" entries:

atacore:	ATA core functionality, always needed for any ATA setup

atacard:	CARDBUS support
atacbus:	PC98 cbus support
ataisa:		ISA bus support
atapci:		PCI bus support only generic chipset support.

ataahci:	AHCI support, also pulled in by some vendor modules.

ataacard, ataacerlabs, ataadaptec, ataamd, ataati, atacenatek, atacypress, atacyrix, atahighpoint, ataintel, ataite, atajmicron, atamarvell, atamicron, atanational, atanetcell, atanvidia, atapromise, ataserverworks, atasiliconimage, atasis, atavia;	Vendor support, ie atavia for VIA chipsets

atadisk:	ATA disk driver
ataraid:	ATA softraid driver

atapicd:	ATAPI cd/dvd driver
atapifd:	ATAPI floppy/flashdisk driver
atapist:	ATAPI tape driver

atausb:		ATA<>USB bridge
atapicam:	ATA<>CAM bridge

This makes it possible to config a kernel with just VIA chipset support by having the following ATA lines in the kernel config file:

device          atacore
device          atapci
device          atavia

And then you need the atadisk, atapicd etc lines in there just as usual.

If you use ATA as modules loaded at boot there is few changes except the rename of the "ata" module to "atacore", things looks just as usual.
However under atapci you now have a whole bunch of vendor specific drivers, that you can kldload individually depending on you needs. Drivers have the same names as used in the kernel config explained above.
2008-10-09 12:56:57 +00:00
Søren Schmidt
7aab7e054f Cleanup the AHCI code a bit.
Add suspend/resume for AHCI, general methods added.

Inspired by: Andrey V. Elsukov
2008-09-18 12:12:34 +00:00
Søren Schmidt
082b99a8b9 Rearrange how to call dma.alloc() so that we have resources alloc'd when need but also late enough to know how many to create. 2008-06-11 06:44:58 +00:00
Søren Schmidt
347458c95e Add HW level support for the Adaptec 1420SA controller. 2008-04-21 10:51:38 +00:00
Søren Schmidt
104c094e06 Go back to preallocating everything possible on init.
This avoids calling busdma in the request processing path which caused a traumatic performance degradation.
Allocation has be postponed to after we know how many devices we possible can have on portmulitpliers to save some space.
2008-04-17 12:29:35 +00:00
Søren Schmidt
a7c33e78bf Dont call hw.status recursively.
Spotted by: Marcel Moolenaar
2008-04-12 17:21:22 +00:00
Søren Schmidt
9f82379c24 Add experimental support for SATA Port Multipliers
Support is working on the Silicon Image SiI3124/3132.
Support is working on some AHCI chips but far from all.

Remember this is WIP, so test reports and (constructive) suggestions are welcome!
2008-04-10 13:05:05 +00:00
Søren Schmidt
200c7605c8 Add generic support for chipsets that say they support AHCI. This should catch new chipsets that we dont know but that we should support.
Add a few new PCI id's.
Misc cleanups.
2007-11-18 14:44:52 +00:00
Søren Schmidt
f31e86f556 Fix treating some modern chips (mem mapped) as legacy devices. 2007-10-26 08:57:08 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00
Søren Schmidt
4471f79eb4 Try again with supporting AHCI chipsets with partly implemented ports. 2007-02-21 19:03:34 +00:00
Søren Schmidt
cfaed55fd5 Add support for chipsets that has NULL'd BAR's for legacy ports.
This allows DMA to be used on a fine little geode system I got here and
most like on lots of older systems like that.

HW donated by:  Paul Ghering
2007-02-17 16:56:39 +00:00
Rink Springer
cece26a63a Add support for the NetCell NC3000/5000 series SATA RAID cards.
Reviewed by:	sos
Approved by:	imp (mentor)
MFC after:	1 week
2007-02-03 20:12:00 +00:00
John Baldwin
73dbd3da73 Remove various bits of conditional Alpha code and fixup a few comments. 2006-05-12 05:04:46 +00:00
Søren Schmidt
e3989d3ebf Add support for the JMicron JMB363 dual SATA + single PATA controller.
Documentation and HW kindly provided by JMicron.
2006-02-16 17:09:24 +00:00
Søren Schmidt
0a3a1935b3 Unbreak dump on legacy systems. Needs a more clean solution but that is
more intrusive and can wait 'til after 6.1
2006-02-09 20:53:32 +00:00
Søren Schmidt
797c12eed9 Add support for the JMicron JMB360 SATAII controller.
Thanks to JMicron for providing needed info.

HW donated by:	Ralf Folkerts
2006-01-25 23:07:42 +00:00
Søren Schmidt
634c377652 Do not test for DMA status on legacy ATA devices. This has the unfortunate
side effect that legacy ATA controllers at irq14 and irq15 cannot share
interrupts with anything else without major problems.
This fixes the ATAPI DMA problems some systems/devices have seen.
2006-01-24 12:34:56 +00:00
Søren Schmidt
8453acf105 Whitespace cleanup. 2006-01-18 13:10:17 +00:00
Søren Schmidt
f5f55db308 Add support for using DMA on dump, greatly speeds up the dump process.
Add dump support in ataraid.
2006-01-18 09:14:55 +00:00
Søren Schmidt
e2bf77c5c2 Get rid of the advertising clause in the copyright. 2006-01-05 21:27:19 +00:00
Søren Schmidt
7af3abd894 Change the probes in ATA to return a negative value on success.
This allows other driver to take over if needed during probe, and allows
me to distribute new drivers as modules.
2005-12-27 18:22:11 +00:00
Søren Schmidt
4b55f0c7c7 Add initial support for the Marvell 88SX[56]0[48][01] series of SATA chips.
Hardware donated by: Matthew Jacob
Hardware donated by: Y!
2005-12-27 17:09:52 +00:00
Robert Watson
5bb84bc84b Normalize a significant number of kernel malloc type names:
- Prefer '_' to ' ', as it results in more easily parsed results in
  memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
  as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
  memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
  attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion.  Similar changes are required for UMA zone names.
2005-10-31 15:41:29 +00:00
Søren Schmidt
7ebce0231b Add support for the ATI IXP[234]00 series chipsets.
HW donated by: sentex
2005-10-12 20:00:26 +00:00
Søren Schmidt
a3ebeaa87b Use the presence of ctlr->dmainit instead of r_res1 to find out when to
initialise DMA.
2005-06-09 12:31:07 +00:00