diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 67aab8a9ba..1b917686c5 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -1128,12 +1128,18 @@ static int init_and_check(bool hard_reset) | |||
1128 | 1128 | ||
1129 | int ata_init(void) | 1129 | int ata_init(void) |
1130 | { | 1130 | { |
1131 | int rc; | 1131 | int rc = 0; |
1132 | bool coldstart = ata_is_coldstart(); | 1132 | bool coldstart; |
1133 | /* must be called before ata_device_init() */ | ||
1134 | 1133 | ||
1135 | spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH)); | 1134 | if ( !initialized ) { |
1135 | spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH)); | ||
1136 | queue_init(&ata_queue, true); | ||
1137 | } | ||
1138 | |||
1139 | spinlock_lock(&ata_spinlock); | ||
1136 | 1140 | ||
1141 | /* must be called before ata_device_init() */ | ||
1142 | coldstart = ata_is_coldstart(); | ||
1137 | ata_led(false); | 1143 | ata_led(false); |
1138 | ata_device_init(); | 1144 | ata_device_init(); |
1139 | sleeping = false; | 1145 | sleeping = false; |
@@ -1143,6 +1149,9 @@ int ata_init(void) | |||
1143 | #endif | 1149 | #endif |
1144 | 1150 | ||
1145 | if ( !initialized ) { | 1151 | if ( !initialized ) { |
1152 | /* First call won't have multiple thread contention */ | ||
1153 | spinlock_unlock(&ata_spinlock); | ||
1154 | |||
1146 | if (!ide_powered()) /* somebody has switched it off */ | 1155 | if (!ide_powered()) /* somebody has switched it off */ |
1147 | { | 1156 | { |
1148 | ide_power_enable(true); | 1157 | ide_power_enable(true); |
@@ -1202,8 +1211,6 @@ int ata_init(void) | |||
1202 | if (rc) | 1211 | if (rc) |
1203 | return -60 + rc; | 1212 | return -60 + rc; |
1204 | 1213 | ||
1205 | queue_init(&ata_queue, true); | ||
1206 | |||
1207 | last_disk_activity = current_tick; | 1214 | last_disk_activity = current_tick; |
1208 | create_thread(ata_thread, ata_stack, | 1215 | create_thread(ata_thread, ata_stack, |
1209 | sizeof(ata_stack), 0, ata_thread_name | 1216 | sizeof(ata_stack), 0, ata_thread_name |
@@ -1214,9 +1221,10 @@ int ata_init(void) | |||
1214 | } | 1221 | } |
1215 | rc = set_multiple_mode(multisectors); | 1222 | rc = set_multiple_mode(multisectors); |
1216 | if (rc) | 1223 | if (rc) |
1217 | return -70 + rc; | 1224 | rc = -70 + rc; |
1218 | 1225 | ||
1219 | return 0; | 1226 | spinlock_unlock(&ata_spinlock); |
1227 | return rc; | ||
1220 | } | 1228 | } |
1221 | 1229 | ||
1222 | #if (CONFIG_LED == LED_REAL) | 1230 | #if (CONFIG_LED == LED_REAL) |