Commit Graph

447 Commits

Author SHA1 Message Date
Tejun Heo a9beec9535 [PATCH] libata-hp-prep: make probing related functions global
Hotplug will be implemented in libata-eh.c.  Make ata_dev_read_id()
and ata_dev_configure() global.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-31 18:27:44 +09:00
Tejun Heo 453b07accb [PATCH] libata-hp-prep: add ata_aux_wq
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>
2006-05-31 18:27:42 +09:00
Tejun Heo 5a04bf4bef [PATCH] libata-hp-prep: implement ap->hw_sata_spd_limit
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>
2006-05-31 18:27:38 +09:00
Tejun Heo 72fa4b742b [PATCH] libata-hp-prep: make some ata_device fields persistent
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>
2006-05-31 18:27:32 +09:00
Tejun Heo 3ef3b43d56 [PATCH] libata-hp-prep: implement ata_dev_init()
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>
2006-05-31 18:27:30 +09:00
Tejun Heo c6cf9e99d1 [PATCH] libata: implement ata_eh_wait()
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>
2006-05-31 18:27:27 +09:00
Borislav Petkov ef2824073f libata debugging: set initial dbg value
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>
2006-05-29 01:06:23 -04:00
Jeff Garzik e42d7be25c Merge branch 'upstream-fixes' into upstream
Conflicts:

	drivers/scsi/libata-core.c
2006-05-28 16:32:59 -04:00
Mark Lord 0737ac895a [PATCH] the latest consensus libata resume fix
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>
2006-05-28 16:32:08 -04:00
Alan Cox 75e995855f [PATCH] libata: add pio_data_xfer_noirq
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-05-26 22:02:23 -04:00
Alan Cox a6b2c5d475 [PATCH] PATCH: libata. Add ->data_xfer method
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>
2006-05-24 01:58:54 -04:00
Alan Cox b6079ca409 [PATCH] libata: PIO 0
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>
2006-05-24 01:53:00 -04:00
Jeff Garzik c81e29b4ac Merge branch 'upstream-fixes' into upstream
Conflicts:

	drivers/scsi/libata-core.c
2006-05-24 01:49:12 -04:00
Albert Lee bb31a8faa2 [PATCH] libata: add pio flush for via atapi (was: Re: TR: ASUS A8V Deluxe, x86_64)
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>
2006-05-24 01:43:53 -04:00
Albert Lee eec4c3f317 [PATCH] libata: use qc->result_tf for temp taskfile storage
Use qc->result_tf for temp taskfile storage.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-05-20 00:37:01 -04:00
Albert Lee 3655d1d323 [PATCH] libata: Fix the HSM error_mask mapping (was: Re: libata-tj and SMART)
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>
2006-05-20 00:37:01 -04:00
Jeff Garzik 3d71b3b0b6 Merge branch 'upstream-fixes' into upstream
Conflicts:

	drivers/scsi/libata-core.c
2006-05-20 00:36:08 -04:00
Randy Dunlap e2a7f77a7b [PATCH] libata-core: fix current kernel-doc warnings
Fix all current kernel-doc warnings.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-05-20 00:33:51 -04:00
Tejun Heo a6e6ce8e8d [PATCH] libata-ncq: implement NCQ device configuration
Now that all NCQ related stuff are in place, implement NCQ device
configuration and bump ATA_MAX_QUEUE to 32 thus activating NCQ
support.

Original implementation is from Jens Axboe.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 21:03:48 +09:00
Tejun Heo 3dc1d88193 [PATCH] libata-ncq: implement NCQ command translation and exclusion
This patch implements NCQ command translation and exclusion.  Note
that NCQ commands don't use ata_rwcmd_protocol() to choose ATA
command.  This is because, unlike non-NCQ RW commands, NCQ commands
can only be used for NCQ protocol and FUA handling is done with a flag
rather than separate command.

NCQ enabled device will have queue depth larger than one but no two
non-NCQ commands can be issued simultaneously, neither can a non-NCQ
command and NCQ commands.  This patch makes ata_scsi_translate()
return SCSI_MLQUEUE_DEVICE_BUSY if such exclusion is necessary.  SCSI
midlayer will retry the command later.

As SCSI midlayer always retries once a command completes, this doesn't
incur unnecessary delays and as most commands will be NCQ ones for NCQ
device, so the overhead should be negligible.

Initial implementation is from Jens Axboe and using
SCSI_MLQUEUE_DEVICE_BUSY for exclusion is suggested by Jeff Garzik.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 21:03:45 +09:00
Tejun Heo dedaf2b036 [PATCH] libata-ncq: implement ap->qc_active, ap->sactive and complete helper
Add ap->qc_active and ap->sactive, mask of all active qcs and libata's
view of the SActive register, respectively.  Also, implement
ata_qc_complete_multiple() which takes new qc_active mask and complete
multiple qcs according to the mask.

These will be used to track NCQ commands and complete them.  The
distinction between ap->qc_active and ap->sactive is also useful for
later PM implementation.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 21:03:43 +09:00
Tejun Heo 6cec4a3943 [PATCH] libata-ncq: rename ap->qactive to ap->qc_allocated
Rename ap->qactive to ap->qc_allocated.  This is to accomodate
addition of ap->qc_active, mask of active qcs.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 21:03:41 +09:00
Tejun Heo c17ea20d9a [PATCH] libata: fix irq-pio merge
* kill ata_poll_qc_complete() and implement/use ata_hsm_qc_complete()
  which completes qcs in new EH compliant manner from HSM

* don't print error message from ata_hsm_move().  it's responsibility
  of EH.

* kill ATA_FLAG_NOINTR usage in bmdma EH

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:59:29 +09:00
Tejun Heo 12436c30f4 Merge branch 'irq-pio'
Conflicts:

	drivers/scsi/libata-core.c
	include/linux/libata.h
2006-05-15 20:59:15 +09:00
Tejun Heo 6d97dbd72d [PATCH] libata-eh: implement BMDMA EH
Implement stock BMDMA error handling methods.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:24 +09:00
Tejun Heo 022bdb075b [PATCH] libata-eh: implement new EH
Implement new EH.  The exported interface is ata_do_eh() which is to
be called from ->error_handler and performs the following steps to
recover the failed port.

ata_eh_autopsy() : analyze SError/TF, determine the cause of failure
		   and required recovery actions and record it in
		   ap->eh_context
ata_eh_report()	 : report the failure to user
ata_eh_recover() : perform recovery actions described in ap->eh_context
ata_eh_finish()	 : finish failed qcs

LLDDs can customize error handling by modifying eh_context before
calling ata_do_eh() or, if necessary, doing so inbetween each major
steps by calling each step explicitly.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:22 +09:00
Tejun Heo d95a717f57 [PATCH] libata-eh-fw: update ata_exec_internal() for new EH
Update ata_exec_internal() such that it uses new EH framework.
->post_internal_cmd() is always invoked regardless of completion
status.  Also, when ata_exec_internal() detects a timeout condition
and new EH is in place, it freezes the port as timeout for normal
commands would do.

Note that ata_port_flush_task() is called regardless of
wait_for_completion status.  This is necessary as exceptions unrelated
to the qc can abort the qc, in which case PIO task could still be
running after the wait for completion returns.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:14 +09:00
Tejun Heo dafadcde8d [PATCH] libata-eh-fw: implement new EH scheduling from PIO
PIO executes without holding host_set lock, so it cannot be
synchronized using the same mechanism as interrupt driven execution.
port_task framework makes sure that EH is not entered until PIO task
is flushed, so PIO task can be sure the qc in progress won't go away
underneath it.  One thing it cannot be sure of is whether the qc has
already been scheduled for EH by another exception condition while
host_set lock was released.

This patch makes ata_poll_qc-complete() handle such conditions
properly and make it freeze the port if HSM violation is detected
during PIO execution.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:11 +09:00
Tejun Heo e318049949 [PATCH] libata-eh-fw: implement freeze/thaw
Freezing is performed atomic w.r.t. host_set->lock and once frozen
LLDD is not allowed to access the port or any qc on it.  Also, libata
makes sure that no new qc gets issued to a frozen port.

A frozen port is thawed after a reset operation completes
successfully, so reset methods must do its job while the port is
frozen.  During initialization all ports get frozen before requesting
IRQ, so reset methods are always invoked on a frozen port.

Optional ->freeze and ->thaw operations notify LLDD that the port is
being frozen and thawed, respectively.  LLDD can disable/enable
hardware interrupt in these callbacks if the controller's IRQ mask can
be changed dynamically.  If the controller doesn't allow such
operation, LLDD can check for frozen state in the interrupt handler
and ack/clear interrupts unconditionally while frozen.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:09 +09:00
Tejun Heo 7b70fc0398 [PATCH] libata-eh-fw: implement ata_port_schedule_eh() and ata_port_abort()
ata_port_schedule_eh() directly schedules EH for @ap without
associated qc.  Once EH scheduled, no further qc is allowed and EH
kicks in as soon as all currently active qc's are drained.

ata_port_abort() schedules all currently active commands for EH by
qc_completing them with ATA_QCFLAG_FAILED set.  If ata_port_abort()
doesn't find any qc to abort, it directly schedule EH using
ata_port_schedule_eh().

These two functions provide ways to invoke EH for conditions which
aren't directly related to any specfic qc.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:07 +09:00
Tejun Heo f686bcb807 [PATCH] libata-eh-fw: implement new EH scheduling via error completion
There are several ways a qc can get schedule for EH in new EH.  This
patch implements one of them - completing a qc with ATA_QCFLAG_FAILED
set or with non-zero qc->err_mask.  ALL such qc's are examined by EH.

New EH schedules a qc for EH from completion iff ->error_handler is
implemented, qc is marked as failed or qc->err_mask is non-zero and
the command is not an internal command (internal cmd is handled via
->post_internal_cmd).  The EH scheduling itself is performed by asking
SCSI midlayer to schedule EH for the specified scmd.

For drivers implementing old-EH, nothing changes.  As this change
makes ata_qc_complete() rather large, it's not inlined anymore and
__ata_qc_complete() is exported to other parts of libata for later
use.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:05 +09:00
Tejun Heo f69499f42c [PATCH] libata-eh-fw: update ata_qc_from_tag() to enforce normal/EH qc ownership
New EH framework has clear distinction about who owns a qc.  Every qc
starts owned by normal execution path - PIO, interrupt or whatever.
When an exception condition occurs which affects the qc, the qc gets
scheduled for EH.  Note that some events (say, link lost and regained,
command timeout) may schedule qc's which are not directly related but
could have been affected for EH too.  Scheduling for EH is atomic
w.r.t. ap->host_set->lock and once schedule for EH, normal execution
path is not allowed to access the qc in whatever way.  (PIO
synchronization acts a bit different and will be dealt with later)

This patch make ata_qc_from_tag() check whether a qc is active and
owned by normal path before returning it.  If conditions don't match,
NULL is returned and thus access to the qc is denied.
__ata_qc_from_tag() is the original ata_qc_from_tag() and is used by
libata core/EH layers to access inactive/failed qc's.

This change is applied only if the associated LLDD implements new EH
as indicated by non-NULL ->error_handler

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:03 +09:00
Tejun Heo 2ab7db1ff1 [PATCH] libata-eh-fw: use special reserved tag and qc for internal commands
New EH may issue internal commands to recover from error while failed
qc's are still hanging around.  To allow such usage, reserve tag
ATA_MAX_QUEUE-1 for internal command.  This also makes it easy to tell
whether a qc is for internal command or not.  ata_tag_internal() test
implements this test.

To avoid breaking existing drivers, ata_exec_internal() uses
ATA_TAG_INTERNAL only for drivers which implement ->error_handler.
For drivers using old EH, tag 0 is used.  Note that this makes
ata_tag_internal() test valid only when ->error_handler is
implemented.  This is okay as drivers on old EH should not and does
not have any reason to use ata_tag_internal().

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:02 +09:00
Tejun Heo dc2b351586 [PATCH] libata-eh-fw: clear SError in ata_std_postreset()
Clear SError in ata_std_postreset().  This is to clear SError bits
which get set during reset.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:58:00 +09:00
Tejun Heo f15a1dafed [PATCH] libata: use ATA printk helpers
Use ATA printk helpers.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:56 +09:00
Tejun Heo 3373efd89d [PATCH] libata: use dev->ap
Use dev->ap where possible and eliminate superflous @ap from functions
and structures.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:53 +09:00
Tejun Heo 38d87234d6 [PATCH] libata: add dev->ap
Add dev->ap which points back to the port the device belongs to.  This
makes it unnecessary to pass @ap for silly reasons (e.g. printks).
Also, this change is necessary to accomodate later PM support which
will introduce ATA link inbetween port and device.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:51 +09:00
Tejun Heo 81952c5497 [PATCH] libata: use new SCR and on/offline functions
Use new SCR and on/offline functions.  Note that for LLDD which know
it implements SCR callbacks, SCR functions are guaranteed to succeed
and ata_port_online() == !ata_port_offline().

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:47 +09:00
Tejun Heo 34bf21704c [PATCH] libata: implement new SCR handling and port on/offline functions
Implement ata_scr_{valid|read|write|write_flush}() and
ata_port_{online|offline}().  These functions replace
scr_{read|write}() and sata_dev_present().

Major difference between between the new SCR functions and the old
ones is that the new ones have a way to signal error to the caller.
This makes handling SCR-available and SCR-unavailable cases in the
same path easier.  Also, it eases later PM implementation where SCR
access can fail due to various reasons.

ata_port_{online|offline}() functions return 1 only when they are
affirmitive of the condition.  e.g.  if SCR is unaccessible or
presence cannot be determined for other reasons, these functions
return 0.  So, ata_port_online() != !ata_port_offline().  This
distinction is useful in many exception handling cases.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:46 +09:00
Tejun Heo 838df6284c [PATCH] libata: init ap->cbl to ATA_CBL_SATA early
Init ap->cbl to ATA_CBL_SATA in ata_host_init().  This is necessary
for soon-to-follow SCR handling function changes.  LLDDs are free to
change ap->cbl during probing.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:44 +09:00
Tejun Heo e61e067227 [PATCH] libata: implement qc->result_tf
Add qc->result_tf and ATA_QCFLAG_RESULT_TF.  This moves the
responsibility of loading result TF from post-compltion path to qc
execution path.  qc->result_tf is loaded if explicitly requested or
the qc failsa.  This allows more efficient completion implementation
and correct handling of result TF for controllers which don't have
global TF representation such as sil3124/32.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:40 +09:00
Tejun Heo 96bd39ec29 [PATCH] libata: remove postreset handling from ata_do_reset()
Make ata_do_reset() deal only with reset.  postreset is now the
responsibility of the caller.  This is simpler and eases later
prereset addition.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:38 +09:00
Tejun Heo 3adcebb2b5 [PATCH] libata: move ->set_mode() handling into ata_set_mode()
Move ->set_mode() handlng into ata_set_mode().

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:37 +09:00
Tejun Heo fe635c7e91 [PATCH] libata: use preallocated buffers
It's not a very good idea to allocate memory during EH.  Use
statically allocated buffer for dev->id[] and add 512byte buffer
ap->sector_buf.  This buffer is owned by EH (or probing) and to be
used as temporary buffer for various purposes (IDENTIFY, NCQ log page
10h, PM GSCR block).

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:35 +09:00
Tejun Heo 158693031d [PATCH] libata: hold host_set lock while finishing internal qc
Hold host_set lock while finishing internal qc.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:33 +09:00
Tejun Heo 7401abf2f4 [PATCH] libata: clear ap->active_tag atomically w.r.t. command completion
ap->active_tag was cleared in ata_qc_free().  This left ap->active_tag
dangling after ata_qc_complete().  Spurious interrupts inbetween could
incorrectly access the qc.  Clear active_tag in ata_qc_complete().
This change is necessary for later EH changes.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:32 +09:00
Tejun Heo f8c2c4202d [PATCH] libata: fix ->phy_reset class code handling in ata_bus_probe()
ata_bus_probe() doesn't clear dev->class after ->phy_reset().  This
can result in falsely enabled devices if probing fails.  Clear
dev->class to ATA_DEV_UNKNOWN after fetching it.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:30 +09:00
Tejun Heo e23befe901 [PATCH] libata: unexport ata_scsi_error()
While moving ata_scsi_error() from LLDD sht to libata transportt,
EXPORT_SYMBOL_GPL() entry was left out.  Kill it.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:27 +09:00
Tejun Heo 3c567b7d11 [PATCH] libata: rename ata_down_sata_spd_limit() and friends
Rename ata_down_sata_spd_limit() and friends to sata_down_spd_limit()
and likewise for simplicity & consistency.

Signed-off-by: Tejun Heo <htejun@gmail.com>
2006-05-15 20:57:23 +09:00
Jeff Garzik a890b15c09 Merge branch 'upstream' 2006-04-12 16:54:43 -04:00
Tejun Heo 499a86af41 [PATCH] libata: export ata_set_sata_spd()
This will be used by LLDD hardreset implementation.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:31:35 -04:00
Tejun Heo 51713d359a [PATCH] libata: cosmetic update to ata_bus_probe()
Move ata_set_mode() failure handling outside of ap->ops->set_mode if
clause such that it can handle ap->ops->set_mode failures after it's
updated.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:22:17 -04:00
Tejun Heo ec573755fc [PATCH] libata: disable failed devices only once in ata_bus_probe()
Devices which consumed all their changes used to be disabled every
iteration.  This causes unnecessary noise in the console output.
Disable once and leave alone.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:22:17 -04:00
Tejun Heo c22daff410 [PATCH] libata: implement ata_wait_register()
As waiting for some register bits to change seems to be a common
operation shared by some controllers, implement helper function
ata_wait_register().  This function also takes care of register write
flushing.

Note that the condition is inverted, the wait is over when the masked
value does NOT match @val.  As we're waiting for bits to change, this
test is more powerful and allows the function to be used in more
places.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:19:11 -04:00
Tejun Heo 987d2f05b3 [PATCH] libata: make reset methods complain when they fail
Make reset methods complain loud when they fail.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:12:46 -04:00
Tejun Heo 2bf2cb26b2 [PATCH] libata: kill @verbose from ata_reset_fn_t
@verbose was added to ata_reset_fn_t because AHCI complained during
probing if no device was attached to the port.  However, muting
failure message isn't the correct approach.  Reset methods are
responsible for detecting no device condition and finishing
successfully.  Now that AHCI softreset is fixed, kill @verbose.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:12:46 -04:00
Tejun Heo db70fef075 [PATCH] libata: set default cbl in probeinit
Make setting CBL type responsibility of probeinit.  This allows using
only ap->cbl == ATA_CBL_SATA test in all other parts.  Without this,
ata_down_sata_spd_limit() doesn't work during probe reset.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-11 13:12:46 -04:00
Jeff Garzik 35bb94b116 libata: Add helper ata_shost_to_port() 2006-04-11 13:12:34 -04:00
Christoph Hellwig 9227c33de8 [PATCH] move ->eh_strategy_handler to the transport class
Overriding the whole EH code is a per-transport, not per-host thing.
Move ->eh_strategy_handler to the transport class, same as
->eh_timed_out.

Downside is that scsi_host_alloc can't check for the total lack of EH
anymore, but the transition period from old EH where we needed it is
long gone already.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-10 14:15:47 -04:00
Jeff Garzik 79fa1b677b Merge branch 'upstream' 2006-04-04 08:45:13 -04:00
Albert Lee 95de719adc [PATCH] libata: convert ATAPI_ENABLE_DMADIR to module parameter
Convert the ATAPI_ENABLE_DMADIR compile time option needed
by some SATA-PATA bridge to runtime module parameter.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-04 08:44:24 -04:00
Albert Lee 31ce6daefe [PATCH] libata-dev: irq-pio minor fix 2
irq-pio minor fix 2:
- Use qc as data for ata_pio_task().

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-04 08:42:26 -04:00
Albert Lee 4332a771f4 [PATCH] libata-dev: irq-pio minor fix
irq-pio minor fix:
- remove the redundant hsm_task_state = HSM_ST_IDLE
- add devno to printk() as done in upstream

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-04 08:42:25 -04:00
Jeff Garzik a808be8a12 Merge branch 'upstream' 2006-04-02 11:38:12 -04:00
Tejun Heo 6d5f9732a1 [PATCH] libata: print SControl in SATA link status info message
Now that libata mangles with SControl, it's helpful to print out
SControl in link status message.  Add it.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 11:37:57 -04:00
Jeff Garzik c13b56a113 [libata] irq-pio: Fix merge mistake 2006-04-02 10:34:24 -04:00
Jeff Garzik 029f5468b5 Merge branch 'upstream'
Conflicts:

	drivers/scsi/libata-core.c
	drivers/scsi/pdc_adma.c
	drivers/scsi/sata_mv.c
	drivers/scsi/sata_nv.c
	drivers/scsi/sata_promise.c
	drivers/scsi/sata_qstor.c
	drivers/scsi/sata_sx4.c
	drivers/scsi/sata_vsc.c
	include/linux/libata.h
2006-04-02 10:30:40 -04:00
Tejun Heo 1ad8e7f9eb [PATCH] libata: make some libata-core routines extern
Make libata-core routines which will be used by EH implementation
extern.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:21 -04:00
Tejun Heo ece1d63619 [PATCH] libata: separate out libata-eh.c
A lot of EH codes are about to be added to libata.  Separate out
libata-eh.c.  ata_scsi_timed_out(), ata_scsi_error(),
ata_qc_timeout(), ata_eng_timeout(), ata_eh_qc_complete() and
ata_eh_qc_retry() are moved.  No code is changed by this patch.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:21 -04:00
Tejun Heo d69cf37d53 [PATCH] libata: add @cdb to ata_exec_internal()
Add @cdb to ata_exec_internal().  It will be used by new EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:20 -04:00
Tejun Heo c91af2c87e [PATCH] libata: pass qc around intead of ap during PIO
The current code passes pointer to ap around and repeatedly performs
ata_qc_from_tag() to access the ongoing qc.  This is unnatural and
makes EH synchronization cumbersome.  Make PIO codes deal with qc
instead of ap.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:20 -04:00
Tejun Heo e8384607d4 [PATCH] libata: clear ATA_DFLAG_PIO before setting it
ata_dev_set_mode() is now responsible for managing ATA_DFLAG_PIO.
Clear it before setting it.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:20 -04:00
Tejun Heo ea1dd4e130 [PATCH] libata: clear only affected flags during ata_dev_configure()
ata_dev_configure() should not clear dynamic device flags determined
elsewhere.  Lower eight bits are reserved for feature flags, define
ATA_DFLAG_CFG_MASK and clear only those bits before configuring
device.  Without this patch, ATA_DFLAG_PIO gets turned off during
revalidation making PIO mode unuseable.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:19 -04:00
Tejun Heo 198e0fed9e [PATCH] libata: rename ATA_FLAG_PORT_DISABLED to ATA_FLAG_DISABLED
Rename ATA_FLAG_PORT_DISABLED to ATA_FLAG_DISABLED for consistency.
(ATA_FLAG_* are always about ports).

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:19 -04:00
Tejun Heo 5eb45c02a9 [PATCH] libata: ata_dev_revalidate() printk update
Make sure ata_dev_revalidate() complains on failures and kill
revalidation failure message printed from ata_dev_set_mode().

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:19 -04:00
Tejun Heo d63cb4a636 [PATCH] libata: report device number when PIO fails
Report device number on PIO failure.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:09:19 -04:00
Tejun Heo 565083e1f1 [PATCH] libata: consider disabled devices in ata_dev_xfermask()
ata_bus_probe() now marks failed devices properly and leaves
meaningful transfer mode masks.  This patch makes ata_dev_xfermask()
consider disable devices when determining PIO mode to avoid violating
device selection timing.

While at it, move port-wide resttriction out of device iteration loop
and try to make the function look a bit prettier.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:02:58 -04:00
Tejun Heo 14d2bac187 [PATCH] libata: improve ata_bus_probe()
Improve ata_bus_probe() such that configuration failures are handled
better.  Each device is given ATA_PROBE_MAX_TRIES chances, but any
non-transient error (revalidation failure with -ENODEV, configuration
failure with -EINVAL...) disables the device directly.  Any IO error
results in SATA PHY speed down and ata_set_mode() failure lowers
transfer mode.  The last try always puts a device into PIO-0.

After each failure, the whole port is reset to make sure that the
controller and all the devices are in a known and stable state.  The
reset also applies SATA SPD configuration if necessary.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:02:57 -04:00
Tejun Heo cf176e1aa9 [PATCH] libata: implement ata_down_xfermask_limit()
Implement ata_down_xfermask_limit().  This function manipulates
@dev->pio/mwdma/udma_mask such that the next lower transfer mode is
selected.  This will be used to improve ata_bus_probe() failure
handling and later by EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:02:57 -04:00
Tejun Heo edbabd8679 [PATCH] libata: add 5s sleep between resets
Some devices react badly if resets are performed back-to-back.  Give
devices some time to breath and tell user that we're taking a nap.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:02:57 -04:00
Tejun Heo 90dac02c08 [PATCH] libata: use SATA speed down in ata_drive_probe_reset()
Make ata_drive_probe_reset() use SATA SPD configuration.  Hardreset
will be force if speed renegotiation is necessary.  Also, if a
hardreset fails, PHY speed is stepped down and hardreset is retried
until the lowest speed is reached.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:02:57 -04:00
Tejun Heo 1c3fae4d7e [PATCH] libata: implement ap->sata_spd_limit and helpers
ap->sata_spd_limit contrains SATA PHY speed of the port.  It is
initialized to the configured value prior to probing thus preserving
BIOS configured value.  hardreset is responsible for applying SPD
limit and sata_std_hardreset() is updated to do that.  SATA SPD limit
will be used to enhance failure handling during probing and later by
EH.

This patch also normalizes some comments around affected code.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-02 10:02:57 -04:00
Jeff Garzik 8e181c14f2 Merge branch 'upstream' 2006-04-01 15:17:56 -05:00
Tejun Heo 852ee16a91 [PATCH] libata: preserve SATA SPD setting over hard resets
Don't overwrite SPD setting during hard reset.  This change has the
(intended) side effect of honoring the BIOS configuration.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 14:52:08 -05:00
Tejun Heo e82cbdb9a3 [PATCH] libata: don't disable devices from ata_set_mode()
When ata_set_mode() fails on a device, make ata_set_mode() return
error code and pointer to the device instead of disabling it directly.
This gives more control to higher level driving logic.

This patch does not change the end result (configured transfer mode)
although it may make libata repeat mode configuration to the peer of a
failing device.  Later ata_bus_probe() rewrite will make full use of
this change.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 14:46:09 -05:00
Albert Lee eee6c32f5f [PATCH] libata-dev: handle DRQ=1 ERR=1 (revised)
Handle DRQ=1 ERR=1 situation. Revised according to what IDE try_to_flush_leftover_data() does.

Changes:
 - For ATA PIO writes and ATAPI devices, just stop the HSM and let EH handle it.
 - For ATA PIO reads, read only one block of junk data and then let EH handle it.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 14:29:21 -05:00
Jeff Garzik 6e07e16404 Merge branch 'upstream' 2006-04-01 14:29:12 -05:00
Tejun Heo e8e0619f68 [PATCH] libata: reorganize ata_set_mode()
Merge ata_host_set_pio() and ata_host_set_dma() into ata_set_mode()
and use function-level *dev to iterate over devices.  This eases
soon-to-follow ata_set_mode() interface change.

While at it, kill an unnecessary comment and normalize others.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:46 -05:00
Tejun Heo 4f65977df0 [PATCH] libata: make ata_set_mode() handle no-device case properly
Make ata_set_mode() return without doing anything if there is no
device on the port.  This is in preparation for ata_bus_probe()
changes.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:46 -05:00
Tejun Heo e1211e3fa7 [PATCH] libata: implement ata_dev_enabled and disabled()
This patch renames ata_dev_present() to ata_dev_enabled() and adds
ata_dev_disabled().  This is to discern the state where a device is
present but disabled from not-present state.  This disctinction is
necessary when configuring transfer mode because device selection
timing must not be violated even if a device fails to configure.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:45 -05:00
Tejun Heo 9974e7cc6c [PATCH] libata: convert do_probe_reset() to ata_do_reset()
Make do_probe_reset() generic by pushing classification check into
ata_drive_probe_reset() and rename it to ata_do_reset().  This will be
used by EH reset.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:45 -05:00
Tejun Heo 4c360c81a6 [PATCH] libata: separate out ata_spd_string()
Separate out ata_spd_string() from sata_print_link_status().  This
will be used by SATA spd configuration routines.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:45 -05:00
Tejun Heo 96072e699b [PATCH] libata: make ata_bus_probe() return negative errno on failure
ata_bus_probe() uses unsigned int rc to receive negative errno and
returns the converted unsigned int value.  Convert temporary variables
to int and make ata_bus_probe() return negative errno on failure.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:45 -05:00
Tejun Heo 5bbc53f4cf [PATCH] libata: fix ata_set_mode() return value
Make ata_set_mode() return correct error value when ata_dev_set_mode()
fails.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-04-01 12:33:45 -05:00
Tejun Heo be9a50c852 [PATCH] libata: fix ata_xfer_tbl termination
ata_xfer_tbl is terminated by entry with -1 as ->shift.  However,
->shift was unsigned int making the termination condition bogus.  This
patch converts ->shift and ->bits to int.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-03-31 10:14:42 -05:00
Tejun Heo 8e0e694a3a [PATCH] libata: make ata_qc_issue complete failed qcs
There is no reason for the issuer to diddle with a failed qc as the
issuer has complete control over when a qc gets freed (usually in
->complete_fn).  Make ata_qc_issue() responsible for completing qcs
which failed to issue.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-03-31 10:14:42 -05:00
Tejun Heo e4a70e76ad [PATCH] libata: fix ata_qc_issue failure path
On sg_err failure path, ata_qc_issue() doesn't mark the qc active
before returning.  This triggers WARN_ON() in __ata_qc_complete() when
the qc gets completed.  This patch moves ap->active_tag and
QCFLAG_ACTIVE setting to the top of the function.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-03-31 10:14:42 -05:00
Albert Lee 08a556db91 [PATCH] libata-dev: print out information for ATAPI devices with CDB interrupts
print out information for ATAPI devices with CDB interrupts

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-03-31 10:07:06 -05:00
Jeff Garzik 4f0e7c51ae Merge branch 'upstream'
Conflicts:

	drivers/scsi/sata_mv.c
2006-03-29 19:59:39 -05:00
Albert Lee 00b6f5e9e0 [PATCH] libata: ata_dev_init_params() fixes
ata_dev_init_params() fixes:
- Get the "heads" and "sectors" parameters from caller instead of implicitly from dev->id[].
- Return AC_ERR_INVALID instead of 0 if an invalid parameter is found

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2006-03-29 19:30:28 -05:00