Commit Graph

161 Commits

Author SHA1 Message Date
thorpej 0ad3db4759 Move most of the atabus layer into ata.c. 2003-12-30 16:28:37 +00:00
thorpej 9de2760c3e Add a (*drv_probe)() optional callback into the driver to probe for
drives on a channel.  Drivers should provide this if they have some
sort of intelligent probing mechanism.
2003-12-15 00:27:13 +00:00
thorpej e4aa90cdc6 Rename __wdcprobe() to wdcprobe1(). 2003-12-14 18:51:10 +00:00
thorpej d8f4e7306d No need to include wdvar.h anymore. 2003-12-14 05:34:29 +00:00
he fc44e8511e Patterned after the rest of the code, add one more check that
chp->wdc is non-null before de-referencing it.
2003-11-29 16:17:31 +00:00
fvdl 6242a54566 There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

	bus_space_write_4(tag, handle, offset, value)

becomes

	bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-27 23:02:40 +00:00
bouyer a452a585a7 Some combination of controller/drive sends a continous stream of
interrupt while SRST is asserted. Work around by blocking interrupts while
SRST is asserted, and clearing any pending interrupt before unblocking.
Fix kern/23529 from Michael Hertrick.
2003-11-25 21:03:15 +00:00
bouyer c941eecbd0 Clear DRIVE_ATA|DRIVE_ATAPI for both drives only when we're sure this is
an old drive. Should fix kern/23468.
When we know there's no drive here, abort the probe and try next drive.
2003-11-17 20:01:35 +00:00
bouyer 9494bbf9c9 If we detected an old drive on a channel, clear (ATA|ATAPI) for both
drives on the channel.
2003-11-13 22:18:10 +00:00
bouyer eb42e75cd8 If we already have a channel reset pending, don't try to queue a new one.
Otherwise we would bump queue_freeze several times, but the kernel thread would
decrease it only one time.
Fix PR kern/23377 by Mattias Karlsson, and should also fix similar problem
reported by Mihai CHELARU and Bruce J.A. Nourish on current-users.
2003-11-07 08:58:33 +00:00
wiz c5670263e0 Fix some typos. From Tom Cosgrove via jmc@openbsd. 2003-11-02 11:07:44 +00:00
briggs e6f9248f47 Use aprint_*(9) instead of printf() in attach routines. 2003-10-31 21:25:09 +00:00
simonb b6abb6ab1d Remove some assigned-to but otherwise unused variables. 2003-10-30 01:58:17 +00:00
bouyer f974ecc32b Remove check for the error register value at probe time. There have been report
on -current-users of some drives not returning the proper value here.
This shouldn't affect the probe time for the common cases.
2003-10-29 22:09:41 +00:00
bouyer 14cd9d8cff freese->freeze, as pointed out by Frederick Bruck. 2003-10-29 22:05:15 +00:00
bouyer ef9a315b24 - test if we have some work to do before tsleep() in the kernel thread,
in case the previous loop scheduled some more work to do (e.g. reset)
- use queue_freese to block the queue when a reset is pending too
- Avoid using WDCF_TH_RUN in some place that can be called from callout.
  If the kernel thread is tsleep()ing somewhere, we may come here with
  WDCF_TH_RUN set while being in the callout context. Fix a panic() in
  tsleep() reported by Chuck Silvers.
- Use AT_WAIT instead of WDCF_TH_RUN wdcwait(), as we may not be in the
  channel's thread context but still be able to tsleep(). Fix queue_freese
  panics for WDC_CAPABILITY_NOIRQ controllers (port-mac68k/23208 by
  Frederick Bruck).
2003-10-29 21:44:41 +00:00
christos 21027e6048 more uninitialized variables 2003-10-25 08:37:00 +00:00
christos 551bd8b829 fix uninitialized variables 2003-10-25 08:30:46 +00:00
briggs 7dc8540d52 Avoid a race condition that could allow a removable controller (such as
a compact flash card) to lock the atabus thread if it gets detached during
the probe process.
2003-10-22 23:59:00 +00:00
bouyer 70b50b0608 Make sure chp->atabus is initialised, and wakeup the right address when
shutting down the kernel thread.
2003-10-15 20:29:26 +00:00
bouyer ea6912c52d - don't ignore last bit when checking for floating bus value on slave
device; some ATAPI devices as master will report 0x7f in all registers
  for slave before reset
- For the same reason, remove the er1 check.
Makes slave device with a "strange" ATAPI master probe again.
Problem reported and fix tested by Gary Duzan on current-users.
2003-10-15 20:26:33 +00:00
bouyer 3d6919754d Clear chp->ch_drive[i].drive_flags if we didn't find a driver for the
drive.
2003-10-15 19:54:30 +00:00
bouyer c298ea9fc9 Remove block that has been pasted twice. Pointed out by Alexander Yurchenko. 2003-10-12 19:28:50 +00:00
bouyer 0ea3fa883e Remove the check for WAIT+POLL+READ case in __wdccommand_start(),
this case is already handled in __wdccommand_intr().
Pointed out by Charles M. Hannum.
2003-10-09 18:40:19 +00:00
bouyer 7719e83c8b Following Matt Thomas's request, rename ata attribute to ata_hl, and
wdc_base to ata. We can now have
atabus* at ata?
in kernel config files.
2003-10-08 20:57:59 +00:00
bouyer 99d6009c2a Make the ATA mid-layer appears as atabus, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0006.html
This adds a device (atabus) between IDE controllers and wd or atapibus, to
have each ATA channel show up in the device tree. Later there will be atabus
devices in /dev, so that we can do IOCTL on them.
Each atabus has its own kernel thread, to handle operations that needs polling,
e.g. reset and others.

Device probing on each bus it defered to the atabus thread creation.
This allows to do the reset and basic device probes in parallel, which reduce
boot time on systems with several pciide controllers.
2003-10-08 10:58:12 +00:00
mycroft 32856df936 We really don't need to do 2 resets in wdc_channel_attach() -- the one done
by wdcprobe() is enough.
2003-10-08 08:47:58 +00:00
bouyer 3e1a342dd1 Revert to polling for ata_get_params() in wdc_channel_attach().
When probing a nonexistent slave, we may timeout waiting for an interrupt.
In __wdccommand_start(), for polled data in commands, abort quickly if
status still read 0 after 400ns (for a nonexistant slave, the
command will either be aborted, or the status register will report 0; for
a real device we should have BSY, DRQ or ERR).
Thanks to Alexander Yurchenko for reporting the problem and testing the
fix.
2003-10-06 21:51:31 +00:00
mycroft eefae40298 Hide the use of config_interrupts() in one place. 2003-09-25 19:29:48 +00:00
bouyer 703c60f5c6 Don't print modes we are using if we don't know which modes are really used. 2003-09-25 09:38:09 +00:00
bouyer 5a2aac1c7c Fix a typo that prevented pre-ata drives from working since 1999. 2003-09-23 16:27:10 +00:00
mycroft f9d629fb93 Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
   BSY clear, abort the command and ignore the drive.  (Do this by testing
   for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
   non-block command that reads data) -- we don't do this for block I/O, and
   empirically it doesn't clear on my CF cards at all, causing a pointless 1s
   delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
   and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
   overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
   as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.

Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 09:19:22 +00:00
enami a7c2135a0c Correctly resurrect the style in previous. While I'm here, also removed
whitespace at the end of line in comment.
2003-09-21 11:56:40 +00:00
bouyer c6beeca692 Since we can't detect ghost drives in the wdc back-end, resurect
WDC_CAPABILITY_SINGLE_DRIVE.
2003-09-21 11:14:00 +00:00
bouyer d9ce986b70 Remove the "Register ghost test". It won't work, because on ATA register
of both devices are written, and device 0 will respond for device 1 if
device 1 isn't present. Pointed out by Quentin Garnier.
So the only way to know if device 1 is there or not is to send a command, which
is done later.
Detecting the second device here isn't important and won't speed up the probe.
We just need to know if there is at last one device on the bus.

Fix PR kern/22869 from Julio M. Merino Vidal.
2003-09-20 21:42:47 +00:00
christos 5508d7c9b8 print the name of the driver that found the ghost 2003-09-20 07:07:39 +00:00
enami 3144acc341 Now wdcattach() is called interrupts enabled, config_interrupts() tries to
call ata_raid_check_component() immediately, and panics since DMA setup
isn't done yet.  So, defer the call until attach stage is almost done.
Tested with Promise TX2000.
2003-09-20 02:19:36 +00:00
mycroft d40837608f 1) Use config_interrupts() to attach IDE and ATAPI drives. This eliminates
most polling.
2) Clean up some goofiness in pciide -- get rid of the whole "candisable" path
   (it's gratuitous) and simplify the code by calling pciide_map_compat_intr(),
   *_set_modes() and wdc_print_modes() from central locations.
3) Add a register writability and register ghost test to eliminate phantom
   drives more quickly.
2003-09-19 21:35:56 +00:00
drochner b2a29ce0a3 typo in comment 2003-09-17 11:56:19 +00:00
thorpej 577fd9d8fa * Use aprint*().
* Add Ultra/133 to wdc_print_modes().
2003-05-17 21:52:03 +00:00
thorpej 3381232270 Experimental support for RAID volumes configured by ATA "RAID" controllers.
Such RAID controllers are actually just IDE controllers with a BIOS that
can create RAID volumes and write the configuration info to config blocks
on the disks.  The BIOS can do I/O to these volumes, and the OS must
understand the config blocks and implement RAID in software in order to be
able to use these volumes.

Only SPAN (simple concatenation) and RAID0 are supported at this time,
and writing back config blocks is also not supported at this time.  Currently,
only the Promise configuration scheme is supported, although supporting
the Highpoint scheme should not be too difficult.

In any case, this is sufficient to use the Promise RAID0 volume (thus
preserving the win2k AS installation) on this new Intel server I have.

Thanks to Soren Schmidt for doing the work in FreeBSD; it made this
task much easier.  The config block parsing code is adapted from his
work.
2003-01-27 18:21:23 +00:00
simonb 4cde8adf99 Remove variable that is only assigned too but not referenced. 2003-01-20 07:34:37 +00:00
thorpej 72a7af27b0 Use aprint_normal() in cfprint routines. 2003-01-01 00:10:15 +00:00
drochner 10e96d1336 typo in comment 2002-12-06 14:05:34 +00:00
provos 0f09ed48a5 remove trailing \n in panic(). approved perry. 2002-09-27 15:35:29 +00:00
bouyer 7e6804d723 Add support for Ultra/133 (ultra-DMA6) in wdc_probe_caps(). 2002-08-25 17:22:38 +00:00
wiz b02ee1f0b7 Two typos in comments. 2002-07-26 14:10:22 +00:00
bouyer 6280502d5f Bump delay() between reset and IDENTIFY from 100 to 5000. Some ATAPI devices
wedge when talking to them too soon, and incorrectly react to WDC_RESET.
Close PR kern/17208 by Paul Goyette.
2002-06-12 09:55:47 +00:00
bouyer 10b49b13b9 In wdc_exec_command(), for data commands, read the status register after
the data transfer. This is mandatory for data out commands (although none are
used for now), and not forbiddend for data in commands. Also record if we
did transfers any data.
May solve kern/16159 by making the probe more robust in face of fake identify.
2002-04-09 21:17:53 +00:00
bouyer da0cf38ed5 In wdcintr(), it !WDCF_IRQ_WAIT, read the status register anyway to clear a
possible pending interrupt. This should avoid the interrupt loop described
in PR kern/15841.
It is safe to read status here, because if we're not waiting for an interrupt
we have no command pending, so the device should be idle.
2002-03-28 22:51:58 +00:00