aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-iops.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:31 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-12-29 14:27:31 -0500
commit2a2ca6a96194c4744a2adeefbc09ce881f3c5abe (patch)
tree50b43d823d4a589fbfb8f8751278d6101cd3ecf3 /drivers/ide/ide-iops.c
parent6ea52226ca131a99bb619bd56fbeee566ea5a966 (diff)
ide: replace the global ide_lock spinlock by per-hwgroup spinlocks (v2)
Now that (almost) all host drivers have been fixed not to abuse ide_lock and core code usage of ide_lock has been sanitized we may safely replace ide_lock by per-hwgroup locks. This patch is partially based on earlier patch from Ravikiran G Thirumalai. While at it: - don't use deprecated HWIF() and HWGROUP() macros - update locking documentation in ide.h v2: Add missing spin_lock_init(&hwgroup->lock). (Noticed by Elias Oltmanns) Cc: Vaibhav V. Nivargi <vaibhav.nivargi@gmail.com> Cc: Alok N. Kataria <alokk@calsoftinc.com> Cc: Shai Fultheim <shai@scalex86.org> Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org> Cc: Elias Oltmanns <eo@nebensachen.de> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r--drivers/ide/ide-iops.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index c41c3b9b6f02..ad8bd6539283 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -835,10 +835,12 @@ static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
835void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, 835void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
836 unsigned int timeout, ide_expiry_t *expiry) 836 unsigned int timeout, ide_expiry_t *expiry)
837{ 837{
838 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup;
838 unsigned long flags; 839 unsigned long flags;
839 spin_lock_irqsave(&ide_lock, flags); 840
841 spin_lock_irqsave(&hwgroup->lock, flags);
840 __ide_set_handler(drive, handler, timeout, expiry); 842 __ide_set_handler(drive, handler, timeout, expiry);
841 spin_unlock_irqrestore(&ide_lock, flags); 843 spin_unlock_irqrestore(&hwgroup->lock, flags);
842} 844}
843 845
844EXPORT_SYMBOL(ide_set_handler); 846EXPORT_SYMBOL(ide_set_handler);
@@ -860,10 +862,11 @@ EXPORT_SYMBOL(ide_set_handler);
860void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, 862void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
861 unsigned timeout, ide_expiry_t *expiry) 863 unsigned timeout, ide_expiry_t *expiry)
862{ 864{
865 ide_hwif_t *hwif = drive->hwif;
866 ide_hwgroup_t *hwgroup = hwif->hwgroup;
863 unsigned long flags; 867 unsigned long flags;
864 ide_hwif_t *hwif = HWIF(drive);
865 868
866 spin_lock_irqsave(&ide_lock, flags); 869 spin_lock_irqsave(&hwgroup->lock, flags);
867 __ide_set_handler(drive, handler, timeout, expiry); 870 __ide_set_handler(drive, handler, timeout, expiry);
868 hwif->tp_ops->exec_command(hwif, cmd); 871 hwif->tp_ops->exec_command(hwif, cmd);
869 /* 872 /*
@@ -873,19 +876,20 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
873 * FIXME: we could skip this delay with care on non shared devices 876 * FIXME: we could skip this delay with care on non shared devices
874 */ 877 */
875 ndelay(400); 878 ndelay(400);
876 spin_unlock_irqrestore(&ide_lock, flags); 879 spin_unlock_irqrestore(&hwgroup->lock, flags);
877} 880}
878EXPORT_SYMBOL(ide_execute_command); 881EXPORT_SYMBOL(ide_execute_command);
879 882
880void ide_execute_pkt_cmd(ide_drive_t *drive) 883void ide_execute_pkt_cmd(ide_drive_t *drive)
881{ 884{
882 ide_hwif_t *hwif = drive->hwif; 885 ide_hwif_t *hwif = drive->hwif;
886 ide_hwgroup_t *hwgroup = hwif->hwgroup;
883 unsigned long flags; 887 unsigned long flags;
884 888
885 spin_lock_irqsave(&ide_lock, flags); 889 spin_lock_irqsave(&hwgroup->lock, flags);
886 hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET); 890 hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET);
887 ndelay(400); 891 ndelay(400);
888 spin_unlock_irqrestore(&ide_lock, flags); 892 spin_unlock_irqrestore(&hwgroup->lock, flags);
889} 893}
890EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); 894EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
891 895
@@ -1076,22 +1080,16 @@ static void pre_reset(ide_drive_t *drive)
1076 */ 1080 */
1077static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) 1081static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1078{ 1082{
1079 unsigned int unit; 1083 ide_hwif_t *hwif = drive->hwif;
1080 unsigned long flags, timeout; 1084 ide_hwgroup_t *hwgroup = hwif->hwgroup;
1081 ide_hwif_t *hwif; 1085 struct ide_io_ports *io_ports = &hwif->io_ports;
1082 ide_hwgroup_t *hwgroup; 1086 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
1083 struct ide_io_ports *io_ports;
1084 const struct ide_tp_ops *tp_ops;
1085 const struct ide_port_ops *port_ops; 1087 const struct ide_port_ops *port_ops;
1088 unsigned long flags, timeout;
1089 unsigned int unit;
1086 DEFINE_WAIT(wait); 1090 DEFINE_WAIT(wait);
1087 1091
1088 spin_lock_irqsave(&ide_lock, flags); 1092 spin_lock_irqsave(&hwgroup->lock, flags);
1089 hwif = HWIF(drive);
1090 hwgroup = HWGROUP(drive);
1091
1092 io_ports = &hwif->io_ports;
1093
1094 tp_ops = hwif->tp_ops;
1095 1093
1096 /* We must not reset with running handlers */ 1094 /* We must not reset with running handlers */
1097 BUG_ON(hwgroup->handler != NULL); 1095 BUG_ON(hwgroup->handler != NULL);
@@ -1106,7 +1104,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1106 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1104 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
1107 hwgroup->polling = 1; 1105 hwgroup->polling = 1;
1108 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 1106 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
1109 spin_unlock_irqrestore(&ide_lock, flags); 1107 spin_unlock_irqrestore(&hwgroup->lock, flags);
1110 return ide_started; 1108 return ide_started;
1111 } 1109 }
1112 1110
@@ -1129,9 +1127,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1129 if (time_before_eq(timeout, now)) 1127 if (time_before_eq(timeout, now))
1130 break; 1128 break;
1131 1129
1132 spin_unlock_irqrestore(&ide_lock, flags); 1130 spin_unlock_irqrestore(&hwgroup->lock, flags);
1133 timeout = schedule_timeout_uninterruptible(timeout - now); 1131 timeout = schedule_timeout_uninterruptible(timeout - now);
1134 spin_lock_irqsave(&ide_lock, flags); 1132 spin_lock_irqsave(&hwgroup->lock, flags);
1135 } while (timeout); 1133 } while (timeout);
1136 finish_wait(&ide_park_wq, &wait); 1134 finish_wait(&ide_park_wq, &wait);
1137 1135
@@ -1143,7 +1141,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1143 pre_reset(&hwif->drives[unit]); 1141 pre_reset(&hwif->drives[unit]);
1144 1142
1145 if (io_ports->ctl_addr == 0) { 1143 if (io_ports->ctl_addr == 0) {
1146 spin_unlock_irqrestore(&ide_lock, flags); 1144 spin_unlock_irqrestore(&hwgroup->lock, flags);
1147 ide_complete_drive_reset(drive, -ENXIO); 1145 ide_complete_drive_reset(drive, -ENXIO);
1148 return ide_stopped; 1146 return ide_stopped;
1149 } 1147 }
@@ -1179,7 +1177,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1179 if (port_ops && port_ops->resetproc) 1177 if (port_ops && port_ops->resetproc)
1180 port_ops->resetproc(drive); 1178 port_ops->resetproc(drive);
1181 1179
1182 spin_unlock_irqrestore(&ide_lock, flags); 1180 spin_unlock_irqrestore(&hwgroup->lock, flags);
1183 return ide_started; 1181 return ide_started;
1184} 1182}
1185 1183