aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-01-27 02:45:00 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-27 02:45:00 -0500
commitf6ef65e6d004b77d516037424c7ccc209d0d3509 (patch)
tree394bac3559237abb94be5051828b3e45315d6489 /drivers/scsi/libata-core.c
parent7103c7bc863c10dd2a26c19c8cf4d7d2846da947 (diff)
parentc19ba8af4f104cca28d548cac55c128b28dd31fb (diff)
Merge branch 'upstream-2.6.17'
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c87
1 files changed, 61 insertions, 26 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index c67c7a49c8ba..6daba4e2c3fd 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -61,9 +61,6 @@
61 61
62#include "libata.h" 62#include "libata.h"
63 63
64static unsigned int ata_busy_sleep (struct ata_port *ap,
65 unsigned long tmout_pat,
66 unsigned long tmout);
67static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev); 64static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev);
68static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev); 65static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev);
69static void ata_set_mode(struct ata_port *ap); 66static void ata_set_mode(struct ata_port *ap);
@@ -834,6 +831,7 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf)
834 * ata_dev_try_classify - Parse returned ATA device signature 831 * ata_dev_try_classify - Parse returned ATA device signature
835 * @ap: ATA channel to examine 832 * @ap: ATA channel to examine
836 * @device: Device to examine (starting at zero) 833 * @device: Device to examine (starting at zero)
834 * @r_err: Value of error register on completion
837 * 835 *
838 * After an event -- SRST, E.D.D., or SATA COMRESET -- occurs, 836 * After an event -- SRST, E.D.D., or SATA COMRESET -- occurs,
839 * an ATA/ATAPI-defined set of values is placed in the ATA 837 * an ATA/ATAPI-defined set of values is placed in the ATA
@@ -846,11 +844,14 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf)
846 * 844 *
847 * LOCKING: 845 * LOCKING:
848 * caller. 846 * caller.
847 *
848 * RETURNS:
849 * Device type - %ATA_DEV_ATA, %ATA_DEV_ATAPI or %ATA_DEV_NONE.
849 */ 850 */
850 851
851static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) 852static unsigned int
853ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err)
852{ 854{
853 struct ata_device *dev = &ap->device[device];
854 struct ata_taskfile tf; 855 struct ata_taskfile tf;
855 unsigned int class; 856 unsigned int class;
856 u8 err; 857 u8 err;
@@ -861,8 +862,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
861 862
862 ap->ops->tf_read(ap, &tf); 863 ap->ops->tf_read(ap, &tf);
863 err = tf.feature; 864 err = tf.feature;
864 865 if (r_err)
865 dev->class = ATA_DEV_NONE; 866 *r_err = err;
866 867
867 /* see if device passed diags */ 868 /* see if device passed diags */
868 if (err == 1) 869 if (err == 1)
@@ -870,18 +871,16 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
870 else if ((device == 0) && (err == 0x81)) 871 else if ((device == 0) && (err == 0x81))
871 /* do nothing */ ; 872 /* do nothing */ ;
872 else 873 else
873 return err; 874 return ATA_DEV_NONE;
874 875
875 /* determine if device if ATA or ATAPI */ 876 /* determine if device is ATA or ATAPI */
876 class = ata_dev_classify(&tf); 877 class = ata_dev_classify(&tf);
878
877 if (class == ATA_DEV_UNKNOWN) 879 if (class == ATA_DEV_UNKNOWN)
878 return err; 880 return ATA_DEV_NONE;
879 if ((class == ATA_DEV_ATA) && (ata_chk_status(ap) == 0)) 881 if ((class == ATA_DEV_ATA) && (ata_chk_status(ap) == 0))
880 return err; 882 return ATA_DEV_NONE;
881 883 return class;
882 dev->class = class;
883
884 return err;
885} 884}
886 885
887/** 886/**
@@ -1073,6 +1072,24 @@ static unsigned int ata_pio_modes(const struct ata_device *adev)
1073 timing API will get this right anyway */ 1072 timing API will get this right anyway */
1074} 1073}
1075 1074
1075static inline void
1076ata_queue_packet_task(struct ata_port *ap)
1077{
1078 queue_work(ata_wq, &ap->packet_task);
1079}
1080
1081static inline void
1082ata_queue_pio_task(struct ata_port *ap)
1083{
1084 queue_work(ata_wq, &ap->pio_task);
1085}
1086
1087static inline void
1088ata_queue_delayed_pio_task(struct ata_port *ap, unsigned long delay)
1089{
1090 queue_delayed_work(ata_wq, &ap->pio_task, delay);
1091}
1092
1076void ata_qc_complete_internal(struct ata_queued_cmd *qc) 1093void ata_qc_complete_internal(struct ata_queued_cmd *qc)
1077{ 1094{
1078 struct completion *waiting = qc->private_data; 1095 struct completion *waiting = qc->private_data;
@@ -1478,7 +1495,24 @@ static int ata_bus_probe(struct ata_port *ap)
1478{ 1495{
1479 unsigned int i, found = 0; 1496 unsigned int i, found = 0;
1480 1497
1481 ap->ops->phy_reset(ap); 1498 if (ap->ops->probe_reset) {
1499 unsigned int classes[ATA_MAX_DEVICES];
1500 int rc;
1501
1502 ata_port_probe(ap);
1503
1504 rc = ap->ops->probe_reset(ap, classes);
1505 if (rc == 0) {
1506 for (i = 0; i < ATA_MAX_DEVICES; i++)
1507 ap->device[i].class = classes[i];
1508 } else {
1509 printk(KERN_ERR "ata%u: probe reset failed, "
1510 "disabling port\n", ap->id);
1511 ata_port_disable(ap);
1512 }
1513 } else
1514 ap->ops->phy_reset(ap);
1515
1482 if (ap->flags & ATA_FLAG_PORT_DISABLED) 1516 if (ap->flags & ATA_FLAG_PORT_DISABLED)
1483 goto err_out; 1517 goto err_out;
1484 1518
@@ -1952,9 +1986,8 @@ err_out:
1952 * 1986 *
1953 */ 1987 */
1954 1988
1955static unsigned int ata_busy_sleep (struct ata_port *ap, 1989unsigned int ata_busy_sleep (struct ata_port *ap,
1956 unsigned long tmout_pat, 1990 unsigned long tmout_pat, unsigned long tmout)
1957 unsigned long tmout)
1958{ 1991{
1959 unsigned long timer_start, timeout; 1992 unsigned long timer_start, timeout;
1960 u8 status; 1993 u8 status;
@@ -2173,9 +2206,9 @@ void ata_bus_reset(struct ata_port *ap)
2173 /* 2206 /*
2174 * determine by signature whether we have ATA or ATAPI devices 2207 * determine by signature whether we have ATA or ATAPI devices
2175 */ 2208 */
2176 err = ata_dev_try_classify(ap, 0); 2209 ap->device[0].class = ata_dev_try_classify(ap, 0, &err);
2177 if ((slave_possible) && (err != 0x81)) 2210 if ((slave_possible) && (err != 0x81))
2178 ata_dev_try_classify(ap, 1); 2211 ap->device[1].class = ata_dev_try_classify(ap, 1, &err);
2179 2212
2180 /* re-enable interrupts */ 2213 /* re-enable interrupts */
2181 if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */ 2214 if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */
@@ -3598,7 +3631,7 @@ fsm_start:
3598 } 3631 }
3599 3632
3600 if (timeout) 3633 if (timeout)
3601 queue_delayed_work(ata_wq, &ap->pio_task, timeout); 3634 ata_queue_delayed_pio_task(ap, timeout);
3602 else if (has_next) 3635 else if (has_next)
3603 goto fsm_start; 3636 goto fsm_start;
3604} 3637}
@@ -3960,7 +3993,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3960 if (qc->tf.flags & ATA_TFLAG_WRITE) { 3993 if (qc->tf.flags & ATA_TFLAG_WRITE) {
3961 /* PIO data out protocol */ 3994 /* PIO data out protocol */
3962 ap->hsm_task_state = HSM_ST_FIRST; 3995 ap->hsm_task_state = HSM_ST_FIRST;
3963 queue_work(ata_wq, &ap->pio_task); 3996 ata_queue_pio_task(ap);
3964 3997
3965 /* always send first data block using 3998 /* always send first data block using
3966 * the ata_pio_task() codepath. 3999 * the ata_pio_task() codepath.
@@ -3970,7 +4003,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3970 ap->hsm_task_state = HSM_ST; 4003 ap->hsm_task_state = HSM_ST;
3971 4004
3972 if (qc->tf.flags & ATA_TFLAG_POLLING) 4005 if (qc->tf.flags & ATA_TFLAG_POLLING)
3973 queue_work(ata_wq, &ap->pio_task); 4006 ata_queue_pio_task(ap);
3974 4007
3975 /* if polling, ata_pio_task() handles the rest. 4008 /* if polling, ata_pio_task() handles the rest.
3976 * otherwise, interrupt handler takes over from here. 4009 * otherwise, interrupt handler takes over from here.
@@ -3985,12 +4018,13 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3985 ata_qc_set_polling(qc); 4018 ata_qc_set_polling(qc);
3986 4019
3987 ata_tf_to_host(ap, &qc->tf); 4020 ata_tf_to_host(ap, &qc->tf);
4021
3988 ap->hsm_task_state = HSM_ST_FIRST; 4022 ap->hsm_task_state = HSM_ST_FIRST;
3989 4023
3990 /* send cdb by polling if no cdb interrupt */ 4024 /* send cdb by polling if no cdb interrupt */
3991 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) || 4025 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) ||
3992 (qc->tf.flags & ATA_TFLAG_POLLING)) 4026 (qc->tf.flags & ATA_TFLAG_POLLING))
3993 queue_work(ata_wq, &ap->pio_task); 4027 ata_queue_packet_task(ap);
3994 break; 4028 break;
3995 4029
3996 case ATA_PROT_ATAPI_DMA: 4030 case ATA_PROT_ATAPI_DMA:
@@ -4002,7 +4036,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4002 4036
4003 /* send cdb by polling if no cdb interrupt */ 4037 /* send cdb by polling if no cdb interrupt */
4004 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) 4038 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
4005 queue_work(ata_wq, &ap->pio_task); 4039 ata_queue_packet_task(ap);
4006 break; 4040 break;
4007 4041
4008 default: 4042 default:
@@ -5433,6 +5467,7 @@ EXPORT_SYMBOL_GPL(__sata_phy_reset);
5433EXPORT_SYMBOL_GPL(ata_bus_reset); 5467EXPORT_SYMBOL_GPL(ata_bus_reset);
5434EXPORT_SYMBOL_GPL(ata_port_disable); 5468EXPORT_SYMBOL_GPL(ata_port_disable);
5435EXPORT_SYMBOL_GPL(ata_ratelimit); 5469EXPORT_SYMBOL_GPL(ata_ratelimit);
5470EXPORT_SYMBOL_GPL(ata_busy_sleep);
5436EXPORT_SYMBOL_GPL(ata_scsi_ioctl); 5471EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
5437EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 5472EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
5438EXPORT_SYMBOL_GPL(ata_scsi_error); 5473EXPORT_SYMBOL_GPL(ata_scsi_error);