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.
The controller is handling them, calling scsipi_done() here will end up in the
xfer being scsipi_done()'ed a second time when it completes in the controller
code. In addition, the way the loop was done here would end up in an infinite
loop, because the channel kernel thread needs to run to remove a command from
this queue.
scsibusdetach(): scsipi_done() all commands from periph_xferq. The controller
is already gone, and these commands will never complete.
Shut down the channel (which will cause the kenrel thread to exit) after
detaching the childs, as they will need the kernel thread for
scsipi_wait_drain().
Fix kernel hang or deadlock when detaching devices (either by scsictl detach
or unplug) with active commands.
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.
- only call periph_switch->psw_start() if the device is active; if it is not
psw_start() may try to access invalid data.
- remove the TAILQ_FIRST(&periph->periph_xferq) != NULL diagnostic in
scsipi_kill_pending(). This can't be true at this point (unless the device
was idle at the time of the detach), because the scsipi channel kernel
thread has to run for the queue to be flushed.
There are still other problems to be fixed here ...
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.
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.
try page 5 (flex geometry) first. This fixes problems with some broken USB
devices that do not handle page 4 correctly (rather than returning nothing,
or stalling, they return the CSW where there should be data).
Device Reset Occurred") when the device is not opened. So let the default
error handler deal with that.
This fix the retrieval of the sense page during autoconfig.
Provided by mycroft@.
Approved by bouyer@.
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.
Don't decrease/check xs_retries when the device report "Power On, Reset, or
Bus Device Reset" sense condition, just retry the command. The initial bus
reset would cause the first TEST_UNIT_READY to report this condition,
and as xs_retries is set to 0 when XS_CTL_DISCOVERY is set, it would report an
error instead of being retried, causing the disk probe to report "drive
offline" instead of the geometry and capacity. Checking/decreasing
xs_retries on the bus reset reported by the adapter is enouth to avoid the
problem reported by rev 1.102.
Problem analysed by Paul Kranenburg, fix confirmed by Anders Hjalmars,
and explaination as to why the INQUIRY wasn't affected by this provided by
Bill Studenmund.
the mode sense request. So fall back on mode sense data including a block
descriptor section.
See also sd.c rev. 1.214. Again: should we bother trying DBD at all?
OS needs such a hack, and the same drive works fine on Suns -- and is much
more likely to be a bug in the host adapter driver (which is corroborated by
the PQUIRK_NOLUNS).
- 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.
the mode sense request. So fall back on mode sense data including a block
descriptor section.
XXX this applies to the `page 4' case. The `page 5' didn't consider the
possible presence of a block descriptor at all, though it did allow the
device to return one. While that's fixed now, the `page 5' mode sense
does not use the `disable block descriptors' bit.
I'm not sure we should bother with this at all..
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).
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.
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.
another function, always doing a page 0 MODE SENSE to get the block
descriptor if we use READ CAPACITY, and use SMS_DBD on the page 4/5 MODE
SENSE. This does one extra command in some cases, but it separates and
simplifies the code a little.
Why do we prefer READ CAPACITY over READ FORMAT CAPACITIES? Two reasons:
1) It's much older and is much less likely to have had its command code
abused, and is thus "safer" to try first. 2) ALL of my USB flash readers
and pen drives screw up their capacity descriptors -- mostly off-by-one
errors in the size (they return the maximum LBA number instead, a la READ
CAPACITY, which has *never* been how READ FORMAT CAPACITIES was documented
in the MMC spec), and one returns the "no media" code on slots that have
media inserted (despite returning almost-correct data otherwise)!
F*** me with a chainsaw.
ready. This avoids gratuitously starting the motor on floppy and CD-ROM
drives, and eliminates the need for the audio playing test in cdopen().
Therefore, also remove PQUIRK_NOSTARTUNIT.
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.
Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.
if our other MODE SENSEs fail. Use this code for the optical device case,
at least for now. (We could query the optical media type and do a table
lookup for the geometry, but why bother? Actually, why bother with geometry
at all, but I digress...)
the "bus type" for this.
Merge all the code in the SCSI and ATAPI backends for "cd" devices. All of
the mode page handling and whatnot is general to SCSI MMC devices, and should
never have been separated to begin with. This fixes a variety of problems,
and adds load/unload support for SCSI-attached devices.
have to adjust for whether he have a "small" or "large" mode sense response.
sd_scsibus_getcache(), sd_scsibus_setache(): Set SMS_DBD so that we don't
have to deal with block descriptors here.
sd_scsibus_mode_sense(): Add a new parameter, "int *big", which tells the
caller whether it's a small or large header.
sd_scsibus_get_parms(), sd_scsibus_getcache(), sd_scsibus_setcache(): Use
the "big" value to find the data following the mode sense header correctly.
sd_scsibus_mode_sense(): Disable PQUIRK_NOBIGMODESENSE for now, as the
reasons for it were dubious and most likely fixed now.
sd_scsibus_get_parms(): Now that we're actually locating the right data,
check the returned page code to see if it's correct before using the mode
page info.
sd_scsibus_get_parms(): Get the rotational rate from the flex geometry page
too, if present.
XXX sd_scsibus_get_{opt,simplifiedparms}() need some work.
* Use the "block descriptor length" to find the beginning of the mode page
data. This is critical, since some devices do not return a block descriptor
at all. (XXX There is disgusting structure hackery here.)
* Always use scsipi_size() (i.e. READ CAPACITY) to get the total disk size.
* Get the rotational rate from the rigid geometry page.
* Don't read the block size from the block descriptor if there was none.
* Get the block size from the flexible geometry page if possible.
* If we don't like the way page 4 smells, try page 5, rather than just punting.
three PRs regarding them: 17836, 17837, 17838. Did a few kernel
compiles with them just to make sure they are okay. Approved by
christos@, thanks to Dave for sending the PRs and verifying to me
that they work.
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
fine at U2W, but barf at U160, with different controllers. Unfortunately
sometimes just being initialized at U160 does the trick, so setting them
to lower speed in the BIOS may also be needed.
rather than 10ths of ns. This is necessary in order to represent
Ultra320 SCSI.
* Add Ultra320 SCSI to the scsipi_syncparams[] table.
We're not going to bother bumping any version numbers with this change; only
the "hba" driver uses scsipi_sync_period_to_factor(), and the uses of
scsipi_sync_factor_to_period() are all internal to the scsipi code. Most
things just pass the factor around, which is unchanged by this.
Reviewed by Frank van der Linden.
This reveals some ugly points in the sd driver, as
the PQUIRK_ONLYBIG flag (there are 6, 10, 12 and 16 byte
CDBs for r/w) and the handling of small/big mode
select/sense. This should be cleaned up.
Also the "long" struct disk_parms.disksize is worth
a thought...