ata_hsm_move() will be used by LLDDs which depend on standard PIO HSM
but implement their own interrupt handlers.
Signed-off-by: Tejun Heo <htejun@gmail.com>
In some cases, hardreset must be followed by SRST.
* some controllers can't classify with hardreset
* some controllers can't wait for !BSY after hardreset (LLDD should
explicitly request followup softreset by returning -EAGAIN)
* (later) PM needs SRST w/ PMP==15 to operate after hardreset
To handle above cases, this patch implements follow-up softreset.
After a hardreset, ata_eh_reset() checks whether any of above
conditions are met and do a follow-up softreset if necessary.
Signed-off-by: Tejun Heo <htejun@gmail.com>
With hotplug, every reset might be a probing reset and thus something
similar to probe_init() is needed. prereset() method is called before
a series of resets to a port and is the counterpart of postreset().
prereset() can tell EH to use different type of reset or skip reset by
modifying ehc->i.action.
This patch also implements ata_std_prereset(). Most controllers
should be able to use this function directly or with some wrapping.
After hotplug, different controllers need different actions to resume
the PHY and detect the newly attached device. Controllers can be
categorized as follows.
* Controllers which can wait for the first D2H FIS after hotplug.
Note that if the waiting is implemented by polling TF status, there
needs to be a way to set BSY on PHY status change. It can be
implemented by hardware or with the help of the driver.
* Controllers which can wait for the first D2H FIS after sending
COMRESET. These controllers need to issue COMRESET to wait for the
first FIS. Note that the received D2H FIS could be the first D2H
FIS after POR (power-on-reset) or D2H FIS in response to the
COMRESET. Some controllers use COMRESET as TF status
synchronization point and clear TF automatically (sata_sil).
* Controllers which cannot wait for the first D2H FIS reliably.
Blindly issuing SRST to spinning-up device often results in command
issue failure or timeout, causing extended delay. For these
controllers, ata_std_prereset() explicitly waits ATA_SPINUP_WAIT
(currently 8s) to give newly attached device time to spin up, then
issues reset. Note that failing to getting ready in ATA_SPINUP_WAIT
is not critical. libata will retry. So, the timeout needs to be
long enough to spin up most devices.
LLDDs can tell ata_std_prereset() which of above action is needed with
ATA_FLAG_HRST_TO_RESUME and ATA_FLAG_SKIP_D2H_BSY flags. These flags
are PHY-specific property and will be moved to ata_link later.
While at it, this patch unifies function typedef's such that they all
have named arguments.
Signed-off-by: Tejun Heo <htejun@gmail.com>
With hotplug, PHY always needs to be debounced before a reset as any
reset might find new devices. Extract PHY waiting code from
sata_phy_resume() and extend it to include SStatus debouncing. Note
that sata_phy_debounce() is superset of what used to be done inside
sata_phy_resume().
Three default debounce timing parameters are defined to be used by
hot/boot plug. As resume failure during probing will be properly
handled as errors, timeout doesn't have to be long as before.
probeinit() uses the same timeout to retain the original behavior.
Signed-off-by: Tejun Heo <htejun@gmail.com>
It's best to run ATA hotplug from EH but attaching SCSI devices needs
working EH. ata_aux_wq is used to give SCSI hotplug operations a
separate context.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Add device persistent field dev->sdev and store the attached SCSI
device. With hotplug, libata needs to know the attached SCSI device
to offline and detach it, but scsi_device_lookup() cannot be used
because libata will reuse SCSI ID numbers - dead but not gone devices
(due to zombie opens, etc...) interfere with the lookup.
dev->sdev doesn't hold reference to the SCSI device. It's cleared
when the SCSI device goes away.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Add ap->hw_sata_spd_limit and initialize it once during the boot
initialization (or driver load initialization). ap->sata_spd_limit is
reset to ap->hw_sata_spd_limit on hotplug. This prevents spd limits
introduced by earlier devices from affecting new devices.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Separate out ata_find_dev() and __ata_scsi_find_dev() from
ata_scsi_find_dev(). These will be used by later hotplug
implementation.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Lifetimes of some fields span over device plugging/unplugging. This
patch moves such persistent fields to the top of ata_device and
separate them with ATA_DEVICE_CLEAR_OFFSET. Fields above the offset
are initialized once during host initializatino while all other fields
are cleared before hotplugging. Currently ->ap, devno and part of
flags are persistent.
Note that flags is partially cleared while holding host_set lock.
This is to synchronize with later warm plug implementation which will
record hotplug request in dev->flags.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Move initialization of struct ata_device into ata_dev_init() in
preparation for hotplug. This patch calls ata_dev_init() from
ata_host_init() and thus makes no functional difference.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Implement ata_eh_wait(). On return from this function, it's
guaranteed that the EH which was pending or in progress when the
function was called is complete - including the tailing part of SCSI
EH. This will be used by hotplug and others to synchronize with EH.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Set ata_device->pio_mode to XFER_PIO_0 after a successful reset. This
is to keep EH resets consistent with probe resets as updated by the
commit b6079ca409. Note that, with
soon-to-follow hotplug update, EH resets will include probe resets.
Signed-off-by: Tejun Heo <htejun@gmail.com>
This patch sets the prerequisites for the new debugging scheme that more or
less resembles Donald Becker's net driver example. This one liner doesn't
change any functionality beside setting the appropriate debug level for the
msg_enable control in the ata_port struct, which will be later used by the
ata_msg_* macros to control the amount of debug information sent to printk.
Signed-off-by: <petkov@uni-muenster.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Okay, just to sum things up.
This forces libata to wait for up to 2 seconds for BUSY|DRQ to clear
on resume before continuing.
[jgarzik adds...] During testing we never saw DRQ asserted, but
nonetheless (a) this works and (b) testing for DRQ won't hurt.
Signed-off-by: Mark Lord <liml@rtr.ca>
Acked-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
We need to pass the device in order to do per device checks such as
32bit I/O enables. With the changes to include dev->ap we now don't have
to add parameters however just clean them up. Also add data_xfer methods
to the existing drivers except ata_piix (which is in the other block of
patches). If you reject the piix one just add a data_xfer to it...
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
The upstream tree has the ATA_DFLAG_PIO bug fixed but does not have the
pass throuugh bug fix
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Ensure the pio_mode is always setup. Don't do any setup on the controller b
just ensure the mode reporting is valid to avoid tons of special cases
in PATA driver code when mode switching on the fly.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Backport the "pio flush" from the libata major update to 2.6.17 for via atapi.
Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
libata implemented a feature to schedule EH without an associated EH
by manipulating shost->host_eh_scheduled in ata_scsi_schedule_eh()
directly. Move this function to scsi_error.c and rename it to
scsi_schedule_eh(). It is now an exported API for SCSI transports and
exported via new header file drivers/scsi/scsi_transport_api.h
This patch also de-export scsi_eh_wakeup() which was exported
specifically for ata_scsi_schedule_eh().
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
LLDDs rely on libata that certain EH actions are automatically taken
on some errors. If the port is frozen or one or more qc's have failed
with HSM violation or timeout, softreset is enforced (LLDD can ask for
storonger EH action at will). If any other error condition exists,
libata EH always revalidates.
This behavior existed in earlier revisions of new EH but lost during
development process. This patch restores it.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Fix the HSM error_mask mapping.
Changes:
- Better mapping in ac_err_mask()
- In HSM_ST_FIRST ans HSM_ST state, check ATA_ERR|ATA_DF and map it to AC_ERR_DEV instead of AC_ERR_HSM.
- In HSM_ST_FIRST and HSM_ST state, map DRQ=1 ERR=1 to AC_ERR_HSM.
- For PIO data in and DRQ=1 ERR=1, add check after the junk data block is read.
Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
This fixes a byte-swap issue on PPC, found by Zang Roy-r61911
on the powerpc platform. His original patch also had some other
platform-specific changes in #ifdef's, but I'm not sure yet how to
incorporate them. Look for another patch for those (soon).
Signed-off-by: Mark Lord <liml@rtr.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
The driver currently keeps local copies of the hardware request/response queue indexes.
But it expends significant effort ensuring consistency between the two views,
and still gets it wrong after an error or reset occurs.
This patch removes the local copies, in favour of just accessing the hardware
whenever we need them. Eventually this may need to be tweaked again for NCQ,
but for now this works and solves problems some users were seeing.
Signed-off-by: Mark Lord <liml@rtr.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
The 60xx chips, and possibly others, incorrectly assert DEV_IRQ interrupts
on a regular basis. The cause of this is under investigation (by me and
in theory by Marvell also), but regardless we do need to deal with these events.
This patch tidies up some interrupt handler code, and ensures that we ignore
DEV_IRQ interrupts when the drive still has ATA_BUSY asserted.
Signed-off-by: Mark Lord <liml@rtr.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
The interface control register of the 60xx (and later) Marvell chip
requires certain bits to always be set when writing to it. These bits
incorrectly read-back as zeros, so the pattern must be ORed in
with each write of the register. Also, bit 12 should NOT be set
(note that Marvell's own driver also had bit-12 wrong here).
While we're at it, we also now do pci_set_master() in the init code.
Signed-off-by: Mark Lord <liml@rtr.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
In some systems, it is possible that the BIOS may have enabled interrupt coalescing
for the Marvell controllers which support it. This patch adds code to detect/ack
interrupts from the chip's coalescing (combing) logic.
Signed-off-by: Mark Lord <liml@rtr.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
The mv_err_intr() function is invoked from the driver's interrupt handler,
as well as from the timeout function. This patch prevents it from triggering
a one-after-the-other double reset of the controller when invoked
from the timeout function.
This also adds a check for a timeout race condition that has been observed
to occur with this driver in earlier kernels. This should not be needed,
in theory, but in practice it has caught bugs. Maybe nuke it at a later date.
Signed-off-by: Mark Lord <liml@rtr.ca>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Implement NCQ support. Sil24 has 31 command slots and all of them are
used for NCQ command queueing. libata guarantees that no other
command is in progress when it issues an internal command, so always
use tag 0 for internal commands.
Signed-off-by: Tejun Heo <htejun@gmail.com>