aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-iops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r--drivers/ide/ide-iops.c100
1 files changed, 41 insertions, 59 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index ad8bd6539283..e728cfe7273f 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -105,15 +105,6 @@ u8 ide_read_altstatus(ide_hwif_t *hwif)
105} 105}
106EXPORT_SYMBOL_GPL(ide_read_altstatus); 106EXPORT_SYMBOL_GPL(ide_read_altstatus);
107 107
108u8 ide_read_sff_dma_status(ide_hwif_t *hwif)
109{
110 if (hwif->host_flags & IDE_HFLAG_MMIO)
111 return readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS));
112 else
113 return inb(hwif->dma_base + ATA_DMA_STATUS);
114}
115EXPORT_SYMBOL_GPL(ide_read_sff_dma_status);
116
117void ide_set_irq(ide_hwif_t *hwif, int on) 108void ide_set_irq(ide_hwif_t *hwif, int on)
118{ 109{
119 u8 ctl = ATA_DEVCTL_OBS; 110 u8 ctl = ATA_DEVCTL_OBS;
@@ -388,7 +379,6 @@ const struct ide_tp_ops default_tp_ops = {
388 .exec_command = ide_exec_command, 379 .exec_command = ide_exec_command,
389 .read_status = ide_read_status, 380 .read_status = ide_read_status,
390 .read_altstatus = ide_read_altstatus, 381 .read_altstatus = ide_read_altstatus,
391 .read_sff_dma_status = ide_read_sff_dma_status,
392 382
393 .set_irq = ide_set_irq, 383 .set_irq = ide_set_irq,
394 384
@@ -451,7 +441,7 @@ EXPORT_SYMBOL(ide_fixstring);
451 */ 441 */
452int drive_is_ready (ide_drive_t *drive) 442int drive_is_ready (ide_drive_t *drive)
453{ 443{
454 ide_hwif_t *hwif = HWIF(drive); 444 ide_hwif_t *hwif = drive->hwif;
455 u8 stat = 0; 445 u8 stat = 0;
456 446
457 if (drive->waiting_for_dma) 447 if (drive->waiting_for_dma)
@@ -503,7 +493,8 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
503 stat = tp_ops->read_status(hwif); 493 stat = tp_ops->read_status(hwif);
504 494
505 if (stat & ATA_BUSY) { 495 if (stat & ATA_BUSY) {
506 local_irq_set(flags); 496 local_irq_save(flags);
497 local_irq_enable_in_hardirq();
507 timeout += jiffies; 498 timeout += jiffies;
508 while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) { 499 while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) {
509 if (time_after(jiffies, timeout)) { 500 if (time_after(jiffies, timeout)) {
@@ -822,25 +813,25 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
822static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, 813static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
823 unsigned int timeout, ide_expiry_t *expiry) 814 unsigned int timeout, ide_expiry_t *expiry)
824{ 815{
825 ide_hwgroup_t *hwgroup = HWGROUP(drive); 816 ide_hwif_t *hwif = drive->hwif;
826 817
827 BUG_ON(hwgroup->handler); 818 BUG_ON(hwif->handler);
828 hwgroup->handler = handler; 819 hwif->handler = handler;
829 hwgroup->expiry = expiry; 820 hwif->expiry = expiry;
830 hwgroup->timer.expires = jiffies + timeout; 821 hwif->timer.expires = jiffies + timeout;
831 hwgroup->req_gen_timer = hwgroup->req_gen; 822 hwif->req_gen_timer = hwif->req_gen;
832 add_timer(&hwgroup->timer); 823 add_timer(&hwif->timer);
833} 824}
834 825
835void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, 826void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
836 unsigned int timeout, ide_expiry_t *expiry) 827 unsigned int timeout, ide_expiry_t *expiry)
837{ 828{
838 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 829 ide_hwif_t *hwif = drive->hwif;
839 unsigned long flags; 830 unsigned long flags;
840 831
841 spin_lock_irqsave(&hwgroup->lock, flags); 832 spin_lock_irqsave(&hwif->lock, flags);
842 __ide_set_handler(drive, handler, timeout, expiry); 833 __ide_set_handler(drive, handler, timeout, expiry);
843 spin_unlock_irqrestore(&hwgroup->lock, flags); 834 spin_unlock_irqrestore(&hwif->lock, flags);
844} 835}
845 836
846EXPORT_SYMBOL(ide_set_handler); 837EXPORT_SYMBOL(ide_set_handler);
@@ -863,10 +854,9 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
863 unsigned timeout, ide_expiry_t *expiry) 854 unsigned timeout, ide_expiry_t *expiry)
864{ 855{
865 ide_hwif_t *hwif = drive->hwif; 856 ide_hwif_t *hwif = drive->hwif;
866 ide_hwgroup_t *hwgroup = hwif->hwgroup;
867 unsigned long flags; 857 unsigned long flags;
868 858
869 spin_lock_irqsave(&hwgroup->lock, flags); 859 spin_lock_irqsave(&hwif->lock, flags);
870 __ide_set_handler(drive, handler, timeout, expiry); 860 __ide_set_handler(drive, handler, timeout, expiry);
871 hwif->tp_ops->exec_command(hwif, cmd); 861 hwif->tp_ops->exec_command(hwif, cmd);
872 /* 862 /*
@@ -876,26 +866,25 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
876 * FIXME: we could skip this delay with care on non shared devices 866 * FIXME: we could skip this delay with care on non shared devices
877 */ 867 */
878 ndelay(400); 868 ndelay(400);
879 spin_unlock_irqrestore(&hwgroup->lock, flags); 869 spin_unlock_irqrestore(&hwif->lock, flags);
880} 870}
881EXPORT_SYMBOL(ide_execute_command); 871EXPORT_SYMBOL(ide_execute_command);
882 872
883void ide_execute_pkt_cmd(ide_drive_t *drive) 873void ide_execute_pkt_cmd(ide_drive_t *drive)
884{ 874{
885 ide_hwif_t *hwif = drive->hwif; 875 ide_hwif_t *hwif = drive->hwif;
886 ide_hwgroup_t *hwgroup = hwif->hwgroup;
887 unsigned long flags; 876 unsigned long flags;
888 877
889 spin_lock_irqsave(&hwgroup->lock, flags); 878 spin_lock_irqsave(&hwif->lock, flags);
890 hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET); 879 hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET);
891 ndelay(400); 880 ndelay(400);
892 spin_unlock_irqrestore(&hwgroup->lock, flags); 881 spin_unlock_irqrestore(&hwif->lock, flags);
893} 882}
894EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); 883EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
895 884
896static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) 885static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
897{ 886{
898 struct request *rq = drive->hwif->hwgroup->rq; 887 struct request *rq = drive->hwif->rq;
899 888
900 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) 889 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET)
901 ide_end_request(drive, err ? err : 1, 0); 890 ide_end_request(drive, err ? err : 1, 0);
@@ -913,7 +902,6 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int);
913static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) 902static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
914{ 903{
915 ide_hwif_t *hwif = drive->hwif; 904 ide_hwif_t *hwif = drive->hwif;
916 ide_hwgroup_t *hwgroup = hwif->hwgroup;
917 u8 stat; 905 u8 stat;
918 906
919 SELECT_DRIVE(drive); 907 SELECT_DRIVE(drive);
@@ -923,20 +911,20 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
923 if (OK_STAT(stat, 0, ATA_BUSY)) 911 if (OK_STAT(stat, 0, ATA_BUSY))
924 printk("%s: ATAPI reset complete\n", drive->name); 912 printk("%s: ATAPI reset complete\n", drive->name);
925 else { 913 else {
926 if (time_before(jiffies, hwgroup->poll_timeout)) { 914 if (time_before(jiffies, hwif->poll_timeout)) {
927 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 915 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
928 /* continue polling */ 916 /* continue polling */
929 return ide_started; 917 return ide_started;
930 } 918 }
931 /* end of polling */ 919 /* end of polling */
932 hwgroup->polling = 0; 920 hwif->polling = 0;
933 printk("%s: ATAPI reset timed-out, status=0x%02x\n", 921 printk("%s: ATAPI reset timed-out, status=0x%02x\n",
934 drive->name, stat); 922 drive->name, stat);
935 /* do it the old fashioned way */ 923 /* do it the old fashioned way */
936 return do_reset1(drive, 1); 924 return do_reset1(drive, 1);
937 } 925 }
938 /* done polling */ 926 /* done polling */
939 hwgroup->polling = 0; 927 hwif->polling = 0;
940 ide_complete_drive_reset(drive, 0); 928 ide_complete_drive_reset(drive, 0);
941 return ide_stopped; 929 return ide_stopped;
942} 930}
@@ -968,8 +956,7 @@ static void ide_reset_report_error(ide_hwif_t *hwif, u8 err)
968 */ 956 */
969static ide_startstop_t reset_pollfunc (ide_drive_t *drive) 957static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
970{ 958{
971 ide_hwgroup_t *hwgroup = HWGROUP(drive); 959 ide_hwif_t *hwif = drive->hwif;
972 ide_hwif_t *hwif = HWIF(drive);
973 const struct ide_port_ops *port_ops = hwif->port_ops; 960 const struct ide_port_ops *port_ops = hwif->port_ops;
974 u8 tmp; 961 u8 tmp;
975 int err = 0; 962 int err = 0;
@@ -986,7 +973,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
986 tmp = hwif->tp_ops->read_status(hwif); 973 tmp = hwif->tp_ops->read_status(hwif);
987 974
988 if (!OK_STAT(tmp, 0, ATA_BUSY)) { 975 if (!OK_STAT(tmp, 0, ATA_BUSY)) {
989 if (time_before(jiffies, hwgroup->poll_timeout)) { 976 if (time_before(jiffies, hwif->poll_timeout)) {
990 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); 977 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
991 /* continue polling */ 978 /* continue polling */
992 return ide_started; 979 return ide_started;
@@ -1007,7 +994,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
1007 } 994 }
1008 } 995 }
1009out: 996out:
1010 hwgroup->polling = 0; /* done polling */ 997 hwif->polling = 0; /* done polling */
1011 ide_complete_drive_reset(drive, err); 998 ide_complete_drive_reset(drive, err);
1012 return ide_stopped; 999 return ide_stopped;
1013} 1000}
@@ -1081,18 +1068,18 @@ static void pre_reset(ide_drive_t *drive)
1081static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) 1068static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1082{ 1069{
1083 ide_hwif_t *hwif = drive->hwif; 1070 ide_hwif_t *hwif = drive->hwif;
1084 ide_hwgroup_t *hwgroup = hwif->hwgroup;
1085 struct ide_io_ports *io_ports = &hwif->io_ports; 1071 struct ide_io_ports *io_ports = &hwif->io_ports;
1086 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 1072 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
1087 const struct ide_port_ops *port_ops; 1073 const struct ide_port_ops *port_ops;
1074 ide_drive_t *tdrive;
1088 unsigned long flags, timeout; 1075 unsigned long flags, timeout;
1089 unsigned int unit; 1076 int i;
1090 DEFINE_WAIT(wait); 1077 DEFINE_WAIT(wait);
1091 1078
1092 spin_lock_irqsave(&hwgroup->lock, flags); 1079 spin_lock_irqsave(&hwif->lock, flags);
1093 1080
1094 /* We must not reset with running handlers */ 1081 /* We must not reset with running handlers */
1095 BUG_ON(hwgroup->handler != NULL); 1082 BUG_ON(hwif->handler != NULL);
1096 1083
1097 /* For an ATAPI device, first try an ATAPI SRST. */ 1084 /* For an ATAPI device, first try an ATAPI SRST. */
1098 if (drive->media != ide_disk && !do_not_try_atapi) { 1085 if (drive->media != ide_disk && !do_not_try_atapi) {
@@ -1101,10 +1088,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1101 udelay (20); 1088 udelay (20);
1102 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); 1089 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
1103 ndelay(400); 1090 ndelay(400);
1104 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1091 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
1105 hwgroup->polling = 1; 1092 hwif->polling = 1;
1106 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 1093 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
1107 spin_unlock_irqrestore(&hwgroup->lock, flags); 1094 spin_unlock_irqrestore(&hwif->lock, flags);
1108 return ide_started; 1095 return ide_started;
1109 } 1096 }
1110 1097
@@ -1114,9 +1101,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1114 1101
1115 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); 1102 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
1116 timeout = jiffies; 1103 timeout = jiffies;
1117 for (unit = 0; unit < MAX_DRIVES; unit++) { 1104 ide_port_for_each_dev(i, tdrive, hwif) {
1118 ide_drive_t *tdrive = &hwif->drives[unit];
1119
1120 if (tdrive->dev_flags & IDE_DFLAG_PRESENT && 1105 if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
1121 tdrive->dev_flags & IDE_DFLAG_PARKED && 1106 tdrive->dev_flags & IDE_DFLAG_PARKED &&
1122 time_after(tdrive->sleep, timeout)) 1107 time_after(tdrive->sleep, timeout))
@@ -1127,9 +1112,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1127 if (time_before_eq(timeout, now)) 1112 if (time_before_eq(timeout, now))
1128 break; 1113 break;
1129 1114
1130 spin_unlock_irqrestore(&hwgroup->lock, flags); 1115 spin_unlock_irqrestore(&hwif->lock, flags);
1131 timeout = schedule_timeout_uninterruptible(timeout - now); 1116 timeout = schedule_timeout_uninterruptible(timeout - now);
1132 spin_lock_irqsave(&hwgroup->lock, flags); 1117 spin_lock_irqsave(&hwif->lock, flags);
1133 } while (timeout); 1118 } while (timeout);
1134 finish_wait(&ide_park_wq, &wait); 1119 finish_wait(&ide_park_wq, &wait);
1135 1120
@@ -1137,11 +1122,11 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1137 * First, reset any device state data we were maintaining 1122 * First, reset any device state data we were maintaining
1138 * for any of the drives on this interface. 1123 * for any of the drives on this interface.
1139 */ 1124 */
1140 for (unit = 0; unit < MAX_DRIVES; ++unit) 1125 ide_port_for_each_dev(i, tdrive, hwif)
1141 pre_reset(&hwif->drives[unit]); 1126 pre_reset(tdrive);
1142 1127
1143 if (io_ports->ctl_addr == 0) { 1128 if (io_ports->ctl_addr == 0) {
1144 spin_unlock_irqrestore(&hwgroup->lock, flags); 1129 spin_unlock_irqrestore(&hwif->lock, flags);
1145 ide_complete_drive_reset(drive, -ENXIO); 1130 ide_complete_drive_reset(drive, -ENXIO);
1146 return ide_stopped; 1131 return ide_stopped;
1147 } 1132 }
@@ -1164,8 +1149,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1164 tp_ops->set_irq(hwif, drive->quirk_list == 2); 1149 tp_ops->set_irq(hwif, drive->quirk_list == 2);
1165 /* more than enough time */ 1150 /* more than enough time */
1166 udelay(10); 1151 udelay(10);
1167 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1152 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
1168 hwgroup->polling = 1; 1153 hwif->polling = 1;
1169 __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); 1154 __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
1170 1155
1171 /* 1156 /*
@@ -1177,7 +1162,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1177 if (port_ops && port_ops->resetproc) 1162 if (port_ops && port_ops->resetproc)
1178 port_ops->resetproc(drive); 1163 port_ops->resetproc(drive);
1179 1164
1180 spin_unlock_irqrestore(&hwgroup->lock, flags); 1165 spin_unlock_irqrestore(&hwif->lock, flags);
1181 return ide_started; 1166 return ide_started;
1182} 1167}
1183 1168
@@ -1221,6 +1206,3 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1221 } 1206 }
1222 return -EBUSY; 1207 return -EBUSY;
1223} 1208}
1224
1225EXPORT_SYMBOL_GPL(ide_wait_not_busy);
1226