Commit Graph

612 Commits

Author SHA1 Message Date
drochner fa3cb84d62 replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
2005-08-25 18:35:38 +00:00
drochner 2d0de57f09 remove unused (hopefully:-) softc fields for disk geometry 2005-07-25 12:52:44 +00:00
briggs 2622309630 Update array of software RAID names in ata_raid.c.
Change a boundary check to ensure that we won't accidentally read and use
uninitialized memory if ATA_RAID_TYPE_MAX is updated without updating the
array.
Update comment near ATA_RAID_TYPE_MAX to note that the array in ata_raid.c
should be updated if a new ATA_RAID_TYPE_* is added.
2005-07-18 15:21:48 +00:00
drochner a8dbed44ea tighten the autoconf constraints by passing the atapi/ata/ata_hl attribute
to config_found()
(after some cleanup we might be able to kill SCSIPI_BUSTYPE_*)
2005-07-07 17:51:31 +00:00
thorpej 527d62e0a2 - When starting an ATA or ATAPI transfer, handle the case where (*dma_init)()
returns EINVAL, indicating that DMA cannot be done for this transfer.
  Fall back to PIO in this case.
- Add a geodeide_dma_init() routine that checks to make sure that transfers
  start on a 16 byte boundary, returning EINVAL if not.  Works around a chip
  bug that causes a hard system hang.

Problem reported and patch tested by Erik Fair.
2005-07-06 01:46:52 +00:00
dsainty 867423adde Force LBA48 access to ST3160827AS drives. Without this change the entire
system hangs whenever a read or write request to sector 0xfffffff occurs.

The hang appears to happen when:

status = bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_status], 0);

is executed in __wdcwait(), and it is not possible to enter the debugger or
make the system respond at all after this point.

Whilst not necessarily the most prudent solution to handling the large number
of drives that exhibit this problem, it is currently the popular workaround.

[An alternative approach is to just always drop to LBA48 if the request
happens to pass by sector 0xfffffff and the drive reported as larger than
0xfffffff sectors.  My understanding is that the 32 bit addressing below
0x10000000 is purely there as a performance booster, not to resolve a
compatibility issue.]
2005-07-02 04:29:01 +00:00
briggs b0366b2ebd Basic support for RAID0 and RAID1 for the Adaptec HostRAID format as found
on the Intel 6300ESB on-board RAID.  Adapted from FreeBSD.
2005-06-20 02:11:57 +00:00
bouyer 19abf3be02 The ST3160023A* also need the LBA48 quirk. From Timo Schoeler. 2005-06-19 18:26:40 +00:00
bouyer 69baf4357d Use pmatch() metacharacters to match both SATA and PATA versions of seagate
drives in the quirk table.
2005-06-16 20:03:35 +00:00
martti ec63076a4b Added LBA48 quirk for Seagate ST3200822AS. Tested by Teemu Rinta-aho. 2005-06-16 05:47:17 +00:00
peter 130e3c23a2 Fix typos. 2005-06-07 13:45:11 +00:00
christos 9b1843d7c2 - remove casts [to avoid volatile]
- sprinkle const
- avoid shadowed variables
2005-05-29 22:11:28 +00:00
bouyer 633e533c5c Close a window where (disks) interrupts could be enabled while the
ATACH_TH_RUN flag is still set. Should fix panic reported by Jukka Salmi
on netbsd-users@.
2005-05-20 14:39:04 +00:00
bouyer eaa19a67b8 Add a ata_queue_idle() function, which freeze a queue and tsleep() until the
controller is idle.
Change the powerhook function to call ata_queue_idle() on standby/suspend,
and ata_reset_channel() on resume (to wake up the disks and start from a
clean state).
Fix PR kern/30194 by Lubomir Sedlacik.
2005-05-16 21:43:33 +00:00
bouyer 04f2acc1f3 Add another broken seagate device to the quirk list.
Problem reported by rudolf <netbsd at eq.cz> on netbsd-help@
2005-05-16 15:36:57 +00:00
drochner 10e5ded54b add definition for "security freeze" 2005-04-12 11:45:40 +00:00
matt 2d8931a849 Fix mode printing. (don't panic on unmatched devices) 2005-04-11 04:24:54 +00:00
yamt 99229e5d39 introduce a function to drain bufq and use it where appropriate. 2005-03-31 11:28:53 +00:00
tacha 357eb4e7e6 Disestablish powerhook while detaching atabus. 2005-03-04 11:00:54 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
jmcneill 3ab5a3900d Add powerhook for atabus. 2005-01-26 21:51:40 +00:00
bouyer c306ebdd4c Also call ata_dmaerr() on DMA errors (as reported by the underlying controller
driver). We want to downgrade to PIO mode if DMA isn't functionnal.
2005-01-16 20:17:37 +00:00
bouyer 937bfab712 Move ata_dmaerr() so that it's called only when there really has been an error
(ata_bio->r_error doesn't containt anything meaningfull if no error occured).
Fix kern/28255 by Izumi Tsutsui, but with a different patch.
2004-12-08 18:49:52 +00:00
bouyer 3d94454016 Some drives reports ATA version < 4, and still support (and need) the
WDCC_FLUSHCACHE command. So for drive < ATA4, test WDC_CMD2_FC in atap_cmd_set2
before returning ENODEV.
Problem reported and fix tested by Michael Gerhards on port-sparc64.
2004-11-18 22:14:53 +00:00
soren ba1f348292 s/using DMA data transfers/using DMA/ to make it fit in 80 columns.
DMA only applies to data transfers anyway..
2004-11-14 15:25:11 +00:00
bouyer c31b572a47 Allow polled commands to be queued, if ata_exec_xfer() is called in thread
context. For this introduce 3 new xfer tags:
- C_WAIT, equivalent of AT_WAIT
- C_WAITACT, when there is a thread waiting on this xfer to become the active
  one (that is, to be at the head of the queue)
- C_FREE, set by ata_free_xfer() when it can't free the xfer because it's
  still in use. The holder should then free the xfer ASAP.

If ata_exec_xfer() is called with (C_POLL | C_WAIT), and there is already
xfers to be processed, assert C_WAITACT and sleep.
atastart() checks for C_WAITACT, and wakeup the thread waiting for this xfer
to become active if set. atastart() won't process this xfer, it's the
responsability of the thread waked up to handle it.

Fix (the right way) kern/27421 by Martin Husemann.
2004-10-30 23:10:37 +00:00
bouyer 2bdbaab58f Call xfer->c_start() with the channel from the xfer, not the one from the
thread. They may be different if we have a shared queue.
2004-10-28 20:11:41 +00:00
yamt 05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
thorpej 45bba4e135 Change config_attach_pseudo() to take a cfdata * that contains the
necessary information to create the pseudo-device instance.  Pseudo-device
device's will reference this cfdata, just as normal devices reference
their corresponding cfdata.

Welcome to 2.99.10.
2004-10-15 04:38:36 +00:00
bouyer b31a120195 Add a WD_QUIRK_FORCE_LBA48 quirck, which forces all access to use LBA48.
Use it for ST3200822A, which has a broken firmware and return an error
when accessing sector 0xfffffff with a LBA command.
Patch tested by David Brownlee.
2004-09-28 18:22:33 +00:00
thorpej cc79c7aeb0 Add support for wedges to the ATA disk driver. 2004-09-25 03:34:02 +00:00
enami 6d7958ac59 Minimal support for mirror component. The relation between original and
mirror component learned from FreeBSD driver.
2004-09-17 23:21:53 +00:00
bouyer cdc0918196 In case of error, reset the channel with AT_RST_NOCMD. We know the reset
won't abort any command at this point.
2004-09-16 20:52:43 +00:00
drochner 96b589fc18 a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
 config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
 on "locators.h"
2004-09-13 12:55:47 +00:00
bouyer bf02dcb5ca If we're not going to handle a reset request because one if already pending,
decrease queue_freeze that we just increased (otherwise the queue stay
frozen after the reset).
Should fix kern/26873 and port-i386/26910.
2004-09-11 18:01:58 +00:00
drochner b4b2fd9326 make the software managed bad-sector list optional
(kernel option WD_SOFTBADSECT)
2004-08-30 09:34:41 +00:00
he 764115cc85 Put an #ifdef _KERNEL around inline functions using panic().
Fixes compile problem for the atactl program for the vax target.
2004-08-23 10:08:48 +00:00
thorpej 09662eaa73 Register description for SATA port multipliers. 2004-08-21 02:25:26 +00:00
thorpej 5373bdd103 - Move to48() to atareg.h and rename it atacmd_to48().
- Add an atacmd_tosataq() that converts a 32-bit command to a Native
  SATA Queued command.
2004-08-21 02:17:07 +00:00
thorpej 8eaae3f96b Eliminate some gratuitous spl frobbing in atabus_thread(). 2004-08-21 00:48:32 +00:00
thorpej 335b799580 atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
2004-08-21 00:28:34 +00:00
thorpej 2aaf643e25 - atabus_detach(): Manipulate ch_flags at splbio().
- ata_reset_channel(): Assert that we're at splbio() when called.
- Sprinkle some comments about functions that must be called at splbio().
2004-08-20 23:50:13 +00:00
thorpej 4af8216045 WDC_DIAGNOSTIC -> ATA_DEBUG 2004-08-20 23:36:52 +00:00
thorpej e975b9caee - Add an (*ata_reset_channel)() member to ata_bustype.
- Add an ata_reset_channel() function that performs the common parts
  of resetting an ATA channel, which uses the (*ata_reset_channel)()
  callback to do the heavy lifting.  Adjust callers to use ata_reset_channel()
  instead of wdc_reset_channel().

This removes the last wdc-specific code from ata.c!
2004-08-20 23:26:53 +00:00
thorpej bd165f8e47 Use ANSI function decls for atabus open/close/ioctl. 2004-08-20 22:26:23 +00:00
thorpej c5adb42199 wdcreg.h is not needed here any more. 2004-08-20 22:19:00 +00:00
thorpej 56e2a255b5 Move common parts of attaching an ata_channel to a new ata_channel_attach()
function.
2004-08-20 22:17:06 +00:00
thorpej 3234a02f48 Move atabusconfig() to ata.c. 2004-08-20 22:02:40 +00:00
thorpej 51c34ebedf In ata_get_params(), use the (*ata_exec_command)() available from the
ata_bustype rather than using wdc_exec_command() directly.
2004-08-20 20:53:20 +00:00
thorpej 2606542c7b - Add an atac_bustype_ata member to atac_softc to hold a pointer to
the ata_bustype for the controller.  Fill it in and use it instead
  of referencing wdc_ata_bustype directly.
- Add an atac_atapibus_attach member to atac_softc to hold a pointer
  to the function that attaches the ATAPI bus for the controller.  Fill
  it in and use it instead of referencing wdc_atapibus_attach directly.
2004-08-20 20:52:31 +00:00
thorpej 709a2d87fc Rename the ata_bustype "ata_reset_channel" member to "ata_reset_drive"
to reflect the new reality after Manuel added the bus reset ioctls.
2004-08-20 17:19:44 +00:00
thorpej 9cc521a148 Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
2004-08-20 06:39:37 +00:00
thorpej 4b51cecfc2 - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
  to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
  ata_channel.  Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
  maximum number of drives that can be present on the channel.  For now,
  this is always 2.  Add an ATA_MAXDRIVES constant that places an upper
  limit on this value, also currently 2.
2004-08-14 15:08:04 +00:00
thorpej 46f4277564 WDCDEBUG -> ATADEBUG. 2004-08-13 04:10:49 +00:00
thorpej ab20886f7b Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
2004-08-13 03:12:59 +00:00
thorpej 577bf67014 Move wdcstart() to ata.c and rename it to atastart(). 2004-08-13 02:16:40 +00:00
thorpej 996c3ca90e Move wdc_exec_xfer() to ata.c and rename it ata_exec_xfer(). 2004-08-13 02:10:43 +00:00
thorpej e6d61c5bc9 Move wdc_addref() and wdc_delref() to ata.c and rename them to
ata_*.
2004-08-12 22:39:40 +00:00
thorpej 2eaa5c6142 Move wdc_kill_pending() to ata.c and rename it ata_kill_pending(). 2004-08-12 22:33:45 +00:00
thorpej 2600c55e01 - Move wdc_xfer_pool, wdc_get_xfer(), wdc_free_xfer() to ata.c, and rename
to ata_*.
- Use a static initializer for the ata_xfer_pool.
2004-08-12 21:34:52 +00:00
thorpej 52ed169a28 Move wdc_probe_caps() to ata.c and rename it ata_probe_caps(). 2004-08-12 21:10:18 +00:00
thorpej ac7276784a Move wdc_downgrade_mode() to ata.c and rename it to ata_downgrade_mode(). 2004-08-12 21:05:09 +00:00
thorpej 9939d3c63d Move wdc_print_modes() into ata.c and rename it ata_print_modes(). 2004-08-12 20:59:27 +00:00
thorpej 9167731c79 Rename some constants:
WDC_COMPLETE -> ATACMD_COMPLETE
WDC_QUEUED -> ATACMD_QUEUED
WDC_TRY_AGAIN -> ATACMD_TRY_AGAIN
2004-08-12 05:02:50 +00:00
thorpej 3ddac9b2da Rename "struct wdc_command" to "struct ata_command". 2004-08-12 04:57:19 +00:00
thorpej f45b99ef1d Add SATA queued read/write commands. 2004-08-12 04:26:06 +00:00
thorpej 77cc762658 Don't assume wdc-specific ATA / ATAPI code should be brought in if atabus
or atapibus are configured; use a separate wdc_common attribute to indicate
that the shared wdc code is also present.
2004-08-12 04:23:02 +00:00
mycroft 6741190fbc Make datain_pio and dataout_pio function pointers in wdc_softc, which can
be overridden by the backend if desired.  Add experimental code to wdc_pcmcia
to use this in memory-mapped mode, disabled by default.
2004-08-11 18:41:46 +00:00
mycroft 04a46876e5 Add two helper functions -- wdc_datain_pio() and wdc_dataout_pio() -- which
encapsulate the logic for the various methods of transferring data.  Use these
throughout.
2004-08-11 17:49:27 +00:00
mycroft 32dee96c25 Hold a reference between atabus_attach() and atabusconfig() to avoid an extra
enable/disable cycle.  Now my CF card attaches a bit faster.

XXX This code is split strangely between files.
2004-08-10 23:09:38 +00:00
mycroft 646cec1d1d A few things:
* Kill off device nodes *before* we clear out the queue, to help prevent any
  new I/O being queued.
* More useful error reporting in wd_setcache() and wd_flushcache().
* Add a wd_standby() (tested but not used yet).

And the most important:
* In wddetach(), if the device was open, call adapt_delref() so that we
  propagate the disable up to our PCMCIA socket.
2004-08-10 02:33:58 +00:00
bouyer 1f5d4dd9dd Change wdc_kill_pending() to take a struct ata_drive_datas * as argument,
and kill only pending requests for this drive.
Implement a DRIVE_WAITDRAIN flag, which will cause the active command to
be killed once complete.
Other minor fixes.
Now it's possible to detach a ATA or ATAPI device from ioctl even when
a dd on the raw char partition is running.
2004-08-04 22:44:04 +00:00
bouyer 9b0cc941a3 Add
struct ata_xfer *active_xfer
to ata_queue. Now the active xfer isn't the head of the queue any more,
this makes a few things easier (this will also help for tagged queuing
support).
Remove the WDCF_ACTIVE flag, test active_xfer != NULL instead.
clean up wdc_free_xfer() and kill_xfer().
Clean up wdc_reset_channel(), and make it issue a ATAPI_SOFT_RESET if the
active command is ATAPI.
In wdc_atapi_get_params(), use AT_WAIT | AT_POLL for ATAPI_SOFT_RESET,
so that we'll use tsleep() instead of delay().
In wdc_atapi_start(), call wdc_dmawait() at the right place.
2004-08-04 18:24:10 +00:00
bouyer bedea96dd4 First cut at implementing ATABUSIODETACH. Still buggy. 2004-08-03 22:37:19 +00:00
bouyer a861f41a39 wddetach(): move lockmgr(LK_DRAIN) near the end; otherwise we'll panic in
wddone() (vdevgone() may end up calling it) trying to get the lock.
wdopen(): check for DVF_ACTIVE.
2004-08-03 22:03:46 +00:00
bouyer 9ad121a77a move cleaning of the bad block list in wddetach() after the call to
disk_detach(), to avoid a race condition with the interrupt code.
2004-08-03 21:38:45 +00:00
bouyer 495631e4d6 Clean up interraction between wdc_reset_channel and the kernel thread.
Move kill_xfer() after the reset, and stop the DMA engine if needed
(this will unload the DMA maps).
2004-08-02 22:02:35 +00:00
bouyer 011181ac3e Implement an atabus control device, and define some ATA bus control
IOCTLS. Implement ATABUSIORESET, which will reset the given ATA bus.
2004-08-01 21:40:41 +00:00
bouyer 7ffa35d1a2 Implement asynchronous channel reset.
Use this to reset the channel before doing a dump, instead of the hack in
  wdc_exec_xfer() based on C_POLL. This hack was causing problems on
  controllers with a shared queue, because we now can have C_POLL set during
  concurent channels probes (problem found and analysed on sparc64 by
  Martin Husemann).
This should even make core dumps marginally more reliable on ATA drives.
2004-07-31 21:26:42 +00:00
mycroft d7027450cd Update copyright. 2004-06-22 19:20:56 +00:00
mycroft d1a1c698b0 Do not force ATA_SINGLE on devices that don't support READ/WRITE MULTI. We
just have to take an interrupt for each sector.
Tested with one laptop disk (which normally runs in DMA mode and was forced
to single-sector transfers) and 3 CF cards.  Increases the performance of
the CF cards substantially (760KB/s->1240KB/s in one case, 410KB/s->750KB/s
in the other two cases).
2004-06-22 19:20:14 +00:00
mycroft d78e8eee67 Fix an extremely obvious bug in the handling of the bad block list: the "max"
block was being set 512x further out than it should be, causing rather severe
escalation of the error.

XXX WTF is the point of this shit, anyway?  In most cases, the way you're
supposed to fix a bad block on an ATA disk is to rewrite it -- which will
either just transparently fix it, or spare it.  This code actively prevents
that.
2004-06-01 20:53:03 +00:00
mycroft a4135d1d48 Only downgrade modes due to an actual CRC error. Downgrading on other errors
is anti-social -- especially given that there's no way to upgrade again short
of rebooting.

Also, downgrade UDMA modes more slowly.  It's entirely possible that they're
using an 80-wire cable, but it's just too long for the higher modes, or there
is minor crosstalk.
2004-06-01 19:32:30 +00:00
thorpej f2da431235 Add common routines for SATA controllers. Right now, we have sata_speed(),
which reports the speed encoded in the SStatus register.
2004-05-28 23:26:27 +00:00
thorpej aeb454bce4 Clean-up of use of "precomp". It is used as "features" everywhere, so
rename the fields in wdc_command as appropriate.
2004-05-27 02:23:12 +00:00
wiz d406ce5c68 Fix typo reported by Alexander Yurchenko grange at rt mipt ru in private
mail.
2004-05-23 23:07:59 +00:00
bouyer c88ebc6e3e Add support for the DIOCCACHESYNC ioctl. 2004-05-21 20:35:53 +00:00
bouyer 879d21cebe Add a delay(10) after re-enabling interrupts in the control register.
Some controllers/drives (e.g. SataLink 3114 with WD Raptor) require
it. Should fix kern/23808 by Chris Gilbert, patch suplied by Chris Gilbert
on tech-kern, extended to all places enabling interrupts by me.
2004-05-08 15:03:32 +00:00
bouyer aaf27601c3 When using LBA48, use Flush cache extended command if supported.
From Christos Zoulas in PR 25366, with minor adjustements from me.
2004-05-03 20:11:40 +00:00
itojun aca4c091d3 sprintf -> snprintf 2004-04-22 00:17:10 +00:00
minoura c5bd25260a Change the value of DRIVE_ATAPIST which was same as that of DRIVE_DMAERR.
Ok'd by bouyer.
2004-04-14 05:26:29 +00:00
bouyer fca16a87e1 Make wdc_channel->ch_flags volatile, and cast it to (void *) when used
in tsleep()/wakeup() to appease gcc. Otherwise, the ch_flags value may
be cached in a register in atabus_thread(), and when it sets the WDCF_TH_RUN
bit after tsleep() it may loose loose the changes made by an interrupt handler
or another thread.
Problem analysed by Jukka Andberg on tech-kern.
2004-04-13 19:51:06 +00:00
wiz 4fdf521f76 It's extension, not extention. From Miod Vallat (miod at online fr). 2004-03-14 20:11:24 +00:00
fvdl 7e3d28789f During a control operation (like a reset), wait 10us after selecting
the drive. This fixes (or rather, works around) a timing problem
with WD Raptor drives attached to a Sil3114 SATA controller.

Should fix PR 23808, it fixes the same problem for me.
2004-03-02 13:13:57 +00:00
yamt 395e9958f2 change the way to handle NEW_BUFQ_STRATEGY option.
instead of putting #ifdefs into each drivers,
use a global variable to indicate default strategy.

XXX should have a way to specify other strategies.
2004-02-28 06:28:47 +00:00
hannken 3db4e2acd8 Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern.
VOP_STRATEGY(bp) is replaced by one of two new functions:

- VOP_STRATEGY(vp, bp)  Call the strategy routine of vp for bp.
- DEV_STRATEGY(bp)      Call the d_strategy routine of bp->b_dev for bp.

DEV_STRATEGY(bp) is used only for block-to-block device situations.
2004-01-25 18:06:48 +00:00
yamt 7266a95907 store a i/o priority hint in struct buf for buffer queue discipline. 2004-01-10 14:39:50 +00:00
thorpej 197f2f50da More structure member namespace cleanup: thread -> ch_thread 2004-01-03 23:59:58 +00:00
thorpej a963286f8d More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
2004-01-03 22:56:52 +00:00
thorpej 5bd80d8373 Rename "struct channel_softc" to "struct wdc_channel". 2004-01-03 01:50:52 +00:00
thorpej 9bc0bf3f15 Prepend "wdc_" to wait_for_drq, wait_for_unbusy, and wait_for_ready. 2004-01-01 20:25:22 +00:00
thorpej 527c829fa0 Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers.  Clean up the member names of these structures while at it.
2004-01-01 17:18:53 +00:00
thorpej 3787a92812 Move the register definitions for ATA Task File registers to atareg.h;
they are also used by controllers that do not map the registers into the
system address space, and are thus distinct from the "controller" registers.
2003-12-30 19:30:13 +00:00
thorpej 3695c4271b SMART info is logically part of the register set; move it from atavar.h
to atareg.h
2003-12-30 19:12:24 +00:00
thorpej 0ad3db4759 Move most of the atabus layer into ata.c. 2003-12-30 16:28:37 +00:00
thorpej 962cc4da4a Tweak function names in debug messages. 2003-12-30 00:43:31 +00:00
lha 56a919527c add more fields to ata_smart_attr, add structures for selftest log 2003-12-20 19:53:54 +00:00
thorpej d6d47a7224 Some additional SATA-II registers. 2003-12-17 16:16:36 +00:00
thorpej 5af2747f1e Serial ATA register definitions. 2003-12-14 17:14:47 +00:00
thorpej b9ee1b0117 Move the wddone() prototype to wd.c 2003-12-14 05:38:20 +00:00
thorpej 777270ce9b Garbage-collect __ATA_DISK_PRIVATE; it is no longer needed. 2003-12-14 05:37:25 +00:00
thorpej d8f4e7306d No need to include wdvar.h anymore. 2003-12-14 05:34:29 +00:00
thorpej a58ada4aad Instead of calling wddone() directly, set a (*drv_done)() callback in
the ata_drive_datas structure and invoke that.
2003-12-14 05:33:29 +00:00
thorpej 3dd2f16d75 Move struct ata_device from wdvar.h to atavar.h. 2003-12-14 05:14:39 +00:00
thorpej 09bbcae770 Move struct ata_bustype from wdvar.h to atavar.h. 2003-12-14 05:10:19 +00:00
thorpej be3146e7b3 Move struct ata_bio from wdvar.h to atavar.h. 2003-12-14 05:03:28 +00:00
thorpej 86046f9e1b Tidy up the whitespace. 2003-12-14 04:59:40 +00:00
thorpej a644de6271 Liberally apply static. 2003-12-14 02:48:36 +00:00
thorpej 0848b66944 Cosmetic changes in some autoconfiguration messages. 2003-12-14 02:46:34 +00:00
thorpej 51132ab100 De-__P and use ANSI-style function decls. 2003-12-14 02:45:48 +00:00
keihan b8702f530b netbsd.org -> NetBSD.org
This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean".  Thanks for the patiance, and sorry for all the commits.
2003-12-04 13:57:30 +00:00
yamt c64b77bad6 add definitions of new feature bits. 2003-11-30 14:05:47 +00:00
yamt b9bb4e3f05 - rename WDC_CAP_LBA48 to ATA_CMD2_LBA48.
- remove WDC_CAP_QUEUE. (there's already ATA_CMD2_RWQ.)

as discussed on tech-kern@.
2003-11-30 13:57:12 +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
yamt d1e85f1677 remove ATA_CMD2_SMART, which seems wrong and isn't used. 2003-11-26 15:03:14 +00:00
mycroft 552d27479a Replace home-grown locks with lockmgr(). 2003-11-07 04:10:56 +00:00
wiz c0177219fe Fix some typos. From Tom Cosgrove via jmc@openbsd. 2003-11-02 09:52:33 +00:00
wiz 0aca09fbc0 Fix two typos. From Tom Cosgrove via jmc@openbsd. 2003-11-02 09:49:20 +00:00
bouyer 14cd9d8cff freese->freeze, as pointed out by Frederick Bruck. 2003-10-29 22:05:15 +00:00
mycroft 3fbc866a6e Back out the bogus initializer -- the compiler bug is fixed. 2003-10-29 21:26:43 +00:00
cl b8d68ee313 note 'm68k {u,}int64_t used uninitialized' bug.
add reference to gcc bug report.
mark all (known) occurrences.
2003-10-28 02:01:46 +00:00
fredb fc4e07a00b Appease gcc3 "-Wno-uninitialized". 2003-10-27 23:06:15 +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
bouyer 7b066791c8 Remove references to University of California from my copyright notices. 2003-10-05 17:48:49 +00:00
grant d2b2b89242 typo in comment 2003-09-29 23:31:04 +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
skd f3de6832d9 Additional definitions as per SATA specifications.
Approved by Manuel Bouyer.
2003-09-23 03:55:59 +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
bouyer feddcdfa5d For LBA drives, compute the number of cylinders from the drive capacity
in the default disklabel and the boot message, instead of using the
value reported by the drive (which is 16383 if the drive is larger than 8G).
Should fix PR 9864
2003-08-03 17:53:04 +00:00
lukem 365cbd9428 add missing __KERNEL_RCSID() 2003-07-14 15:47:00 +00:00
dsl 31722f62d8 KNF and whitespace (and indent a contuation line) 2003-07-11 15:33:13 +00:00
matt 258cc62412 Add LBA48_THRESHOLD #define and set it to the *correct* value. Use it
in place of "0xffffff" (which is one too few 'f').
2003-07-10 23:23:44 +00:00
itojun 7f6ed16ef4 function prototype must not have variable name 2003-07-08 10:06:28 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
bouyer 7a5f4f28d0 Don't use LBA48 if we don't have to (that is, if the request is inside the
first 128GB). Tested by Andreas Johansson.
2003-06-29 19:28:16 +00:00
bouyer b55e87ab48 Remove unused WAITTIME definition. Pointed out by Andreas Johansson. 2003-06-29 17:03:47 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
thorpej 47edad1115 Always queue transfers in the ld driver to prevent transient resource
shortages in the back-ends from aborting transfers.

Reviewed by ad@.
2003-06-07 23:37:24 +00:00
thorpej 577fd9d8fa * Use aprint*().
* Add Ultra/133 to wdc_print_modes().
2003-05-17 21:52:03 +00:00
thorpej e43fecb228 Change bounds_check_with_label() to take a pointer to the disk structure,
rather than the label itself.  This paves the way for some future changes.
2003-05-10 23:12:28 +00:00
dsl d91455ce26 Change return type of readdisklabel() to const char *
I hope I've found all the correct places!
2003-05-02 08:45:10 +00:00
nakayama 1e411d7027 Make DMA mode works on Promise Ultra66/100 with 48-bit LBA drives.
Ok'ed by bouyer in tech-kern@netbsd.org.
2003-04-28 05:20:29 +00:00
bouyer a704b24037 Fix typo. 2003-04-27 14:33:20 +00:00
bouyer 07e96ff3d7 Acceptable cache operations are r and rw, not none and w
Properly initialise the timeout value.
2003-04-27 14:27:36 +00:00
bouyer 1e2dac7786 Add support for the getcache/setcache ioctls. 2003-04-26 09:54:15 +00:00
explorer 2248468d68 add my 80 GB SATA drive to the quirk table. 2003-04-18 04:32:19 +00:00
mason d1b448c6e5 From current-users:
On Thu, Apr 17, 2003 at 11:26:26AM -0500, Dave Huang wrote:

> Typo police here :) "whose," not "who's."
2003-04-18 00:35:14 +00:00
darrenr 0b2e3c6317 add missing setting of b_error (thanks Manuel) 2003-04-16 00:07:17 +00:00
nathanw ad743e234b Add a missing paren. 2003-04-15 19:14:58 +00:00
darrenr 8dac8843a5 Implement (and document!) "dkctl <dev> badsector .." to `manage' the bad
sector information in the kernel.  Doing this uncovered some shortcomings
that should have been pretty obvious with the code committed prior, addressing
the major kludge with a new struct - disk_bacsecinfo to be passed into
DIOCBSLIST.
2003-04-15 18:27:26 +00:00
dogcow 277607fced fix typos 2003-04-15 17:42:44 +00:00
darrenr f4965045a0 Automatically build up a list of bad sectors from failed read operations and
prempt read operations on matching regions with a failure rather than waiting
for the device to return a failure.  The I/O operation must have already failed
MAXRETRIES times before being added to the list - this can generally take up
to 12 seconds.
List is made accessible to userspace via DIOCBSLIST and DIOCBSFLUSH.
2003-04-15 14:11:00 +00:00
fvdl 8103646465 Check RAW_PART against the media size instead of the disklabel.
Add the media size in 512-byte sectors to the softc, to avoid
some 64 bit computations. Bump the capacity stored in softcs
for disks to 64 bits.
2003-04-03 22:18:23 +00:00
thorpej 3f2184def7 Work around a buggy PHY in some Seagate S-ATA drives which get confused
by the way some S-ATA controllers packetize data when the sector count of
the transfer mod 15 is 1.
2003-03-21 22:40:56 +00:00
thorpej 3ea6b8be93 Add missing splbio() protecting of bufpool access. Add a clarifying
comment to <sys/buf.h> reminding everyone of the need for splbio().
2003-02-25 21:25:40 +00:00
thorpej eb14e86676 Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it.  This fixes a few places where either b_dep or b_interlock were
not properly initialized.
2003-02-25 20:35:31 +00:00
yamt bcd7beec98 initialize b_interlock properly.
(for ioctl)
2003-02-23 08:50:58 +00:00
pk 338f31f581 Make the buffer cache code MP-safe. 2003-02-05 21:38:38 +00:00
thorpej 2051b2d8e7 Don't set LDF_ENABLED unless the device is really okay. Noted by
Andrew Doran.
2003-01-29 16:50:37 +00:00
bouyer a1f27a3f79 Bump WDCC_IDENTIFY timeout to 3 seconds, as required by some drives.
Reported by Karl Janmar <karlj@mdstud.chalmers.se> on tech-kern.
2003-01-27 21:27:52 +00:00
thorpej 4155034751 G/C something left over from an earlier version of this code. 2003-01-27 20:18:11 +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
bad f4aacfe9fc Being able to make image backups of your whole disk, not to mention not
causing certain ata disks to lock up by reading beyond the last block,
beats catering to broken devices.

bounds_check_with_label() RAW_PART too.
2003-01-23 00:00:32 +00:00
simonb 276fd1665c The Double-Semi-Colon Police. 2003-01-20 05:29:53 +00:00
fvdl 8db111aeb4 Fix error in ODIOCGDINFO handling caused by previous change to it. 2003-01-07 18:35:04 +00:00
fvdl 74fe783bef Avoid using a lot of kernel stack. 2002-12-15 01:56:02 +00:00
mrg 603098b9b5 implement separate read/write disk statistics:
- disk_unbusy() gets a new parameter to tell the IO direction.
	- struct disk_sysctl gets 4 new members for read/write bytes/transfers.
	when processing hw.diskstats, add the read&write bytes/transfers for
	the old combined stats to attempt to keep backwards compatibility.

unfortunately, due to multiple bugs, this will cause new kernels and old
vmstat/iostat/systat programs to fail.  however, the next time this is
change it will not fail again.

this is just the kernel portion.
2002-11-01 11:31:50 +00:00
jdolecek e0cc03a09b merge kqueue branch into -current
kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
2002-10-23 09:10:23 +00:00
junyoung cc537c2f3a Add option NEW_BUFQ_STRATEGY, a new buffer queue strategy for better
system responsiness under high disk I/O load.

OK'ed by Juergen Hannken-Illjes.
2002-10-18 14:31:10 +00:00
thorpej c9b3657ce9 Add trailing ; to CFATTACH_DECL. 2002-10-02 16:33:28 +00:00
thorpej 387fc6dc87 Use CFATTACH_DECL(). 2002-09-30 20:37:04 +00:00
thorpej f818766afe Declare all cfattach structures const. 2002-09-27 20:31:45 +00:00
drochner 0766f7d128 Remove a check whether the drive is initialized before crashdump.
It prevents dumping on an otherwise unused disk and seems
unnecessary anyway - the driver will deal with initialization.
fixes my PR kern/18135
2002-09-27 17:17:53 +00:00
provos 0f09ed48a5 remove trailing \n in panic(). approved perry. 2002-09-27 15:35:29 +00:00
gehenna 77a6b82b27 Merge the gehenna-devsw branch into the trunk.
This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

	device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
  by using this grammer.

- Added the new naming convention.
  The name of the device switch must be <prefix>_[bc]devsw for auto-generation
  of device switch tables.

- The backward compatibility of loading block/character device
  switch by LKM framework is broken. This is necessary to convert
  from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
  We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
  the LKM framework will refer it to assign device major number dynamically.
2002-09-06 13:18:43 +00:00
soren 9e129fde67 Add ATA SMART reporting support from Ben Collver in kern/12787. 2002-08-05 23:29:27 +00:00
wiz 5db23d2c5d enouth -> enough. 2002-07-26 01:00:39 +00:00
hannken 7de36862a8 Rename bufq_init() to bufq_alloc().
Add bufq_free() to remove a buffer queue.
Avoid MALLOC while holding a spinlock.

From Chuck Silvers.
2002-07-21 15:32:17 +00:00
hannken 10ff5e6607 Implement a new device buffer queue interface.
One basic struct, a function to setup a queue with a specific strategy and
three macros to put buf's into the queue, get and remove the next buf or
get the next buf without removal.

The BUFQ_XXX interface will be removed in the future.
The B_ORDERED flag is not longer supported.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>
2002-07-16 18:03:17 +00:00
yamt ec594e3ef5 do previous differently for wddump case. 2002-06-28 16:50:30 +00:00
yamt 2d80988a26 - remove big buffers on stack. discussed on tech-kern.
- constify.
2002-06-28 16:40:50 +00:00
bouyer cd3578d7ef More copyright fixes, pointed out by Thomas. Thanks ! 2002-04-23 20:41:13 +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
christos c8ce02fd2c add the dma command ext translations. pointed out by manuel. 2002-01-14 02:17:59 +00:00
christos f9b7ffe292 Add LBA48 support based on patches from Keisuke YOSHIDA. KNF a bit while
I am there.
2002-01-13 17:24:28 +00:00
tsutsui 1267bddc09 Call malloc(9) with M_ZERO flag instead of memset() after malloc(). 2002-01-12 16:29:30 +00:00
bouyer bfc80822c7 Update my copyrigth. 2001-12-03 00:20:22 +00:00
bouyer 4ca5497111 Allow wd to attach to something else than wdc/pciide (like USB<->ATA bridges):
- move some functions from ata.c to ata_wdc.c or wdc.c.
- add callbacks to struct ata_bustype so that wd.c doesn't call directly
  functions from the lower level driver.
2001-12-03 00:11:15 +00:00
bouyer 4809ad42cb Clean up attach of wd/atapibus:
kill ata_atapi_attach. Change atapibus to use a struct scsipi_channel instead
of ata_atapi_attach as attach arch. Create a ata_device, compatible with
scsipi_channel, to attach wd.
2001-12-02 22:44:32 +00:00