diff options
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r-- | firmware/drivers/ata.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 1b917686c5..cacf4583ae 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -66,7 +66,7 @@ | |||
66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ | 66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | static struct spinlock ata_spinlock NOCACHEBSS_ATTR; | 69 | static struct mutex ata_mtx NOCACHEBSS_ATTR; |
70 | int ata_device; /* device 0 (master) or 1 (slave) */ | 70 | int ata_device; /* device 0 (master) or 1 (slave) */ |
71 | 71 | ||
72 | int ata_spinup_time = 0; | 72 | int ata_spinup_time = 0; |
@@ -234,7 +234,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
234 | #ifdef HAVE_MULTIVOLUME | 234 | #ifdef HAVE_MULTIVOLUME |
235 | (void)drive; /* unused for now */ | 235 | (void)drive; /* unused for now */ |
236 | #endif | 236 | #endif |
237 | spinlock_lock(&ata_spinlock); | 237 | mutex_lock(&ata_mtx); |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | last_disk_activity = current_tick; | 240 | last_disk_activity = current_tick; |
@@ -246,14 +246,14 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
246 | spinup = true; | 246 | spinup = true; |
247 | if (poweroff) { | 247 | if (poweroff) { |
248 | if (ata_power_on()) { | 248 | if (ata_power_on()) { |
249 | spinlock_unlock(&ata_spinlock); | 249 | mutex_unlock(&ata_mtx); |
250 | ata_led(false); | 250 | ata_led(false); |
251 | return -1; | 251 | return -1; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | else { | 254 | else { |
255 | if (perform_soft_reset()) { | 255 | if (perform_soft_reset()) { |
256 | spinlock_unlock(&ata_spinlock); | 256 | mutex_unlock(&ata_mtx); |
257 | ata_led(false); | 257 | ata_led(false); |
258 | return -1; | 258 | return -1; |
259 | } | 259 | } |
@@ -265,7 +265,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
265 | SET_REG(ATA_SELECT, ata_device); | 265 | SET_REG(ATA_SELECT, ata_device); |
266 | if (!wait_for_rdy()) | 266 | if (!wait_for_rdy()) |
267 | { | 267 | { |
268 | spinlock_unlock(&ata_spinlock); | 268 | mutex_unlock(&ata_mtx); |
269 | ata_led(false); | 269 | ata_led(false); |
270 | return -2; | 270 | return -2; |
271 | } | 271 | } |
@@ -376,7 +376,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
376 | ata_led(false); | 376 | ata_led(false); |
377 | 377 | ||
378 | #ifndef MAX_PHYS_SECTOR_SIZE | 378 | #ifndef MAX_PHYS_SECTOR_SIZE |
379 | spinlock_unlock(&ata_spinlock); | 379 | mutex_unlock(&ata_mtx); |
380 | #endif | 380 | #endif |
381 | 381 | ||
382 | return ret; | 382 | return ret; |
@@ -442,7 +442,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
442 | #ifdef HAVE_MULTIVOLUME | 442 | #ifdef HAVE_MULTIVOLUME |
443 | (void)drive; /* unused for now */ | 443 | (void)drive; /* unused for now */ |
444 | #endif | 444 | #endif |
445 | spinlock_lock(&ata_spinlock); | 445 | mutex_lock(&ata_mtx); |
446 | #endif | 446 | #endif |
447 | 447 | ||
448 | last_disk_activity = current_tick; | 448 | last_disk_activity = current_tick; |
@@ -454,14 +454,14 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
454 | spinup = true; | 454 | spinup = true; |
455 | if (poweroff) { | 455 | if (poweroff) { |
456 | if (ata_power_on()) { | 456 | if (ata_power_on()) { |
457 | spinlock_unlock(&ata_spinlock); | 457 | mutex_unlock(&ata_mtx); |
458 | ata_led(false); | 458 | ata_led(false); |
459 | return -1; | 459 | return -1; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | else { | 462 | else { |
463 | if (perform_soft_reset()) { | 463 | if (perform_soft_reset()) { |
464 | spinlock_unlock(&ata_spinlock); | 464 | mutex_unlock(&ata_mtx); |
465 | ata_led(false); | 465 | ata_led(false); |
466 | return -1; | 466 | return -1; |
467 | } | 467 | } |
@@ -471,7 +471,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
471 | SET_REG(ATA_SELECT, ata_device); | 471 | SET_REG(ATA_SELECT, ata_device); |
472 | if (!wait_for_rdy()) | 472 | if (!wait_for_rdy()) |
473 | { | 473 | { |
474 | spinlock_unlock(&ata_spinlock); | 474 | mutex_unlock(&ata_mtx); |
475 | ata_led(false); | 475 | ata_led(false); |
476 | return -2; | 476 | return -2; |
477 | } | 477 | } |
@@ -534,7 +534,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
534 | ata_led(false); | 534 | ata_led(false); |
535 | 535 | ||
536 | #ifndef MAX_PHYS_SECTOR_SIZE | 536 | #ifndef MAX_PHYS_SECTOR_SIZE |
537 | spinlock_unlock(&ata_spinlock); | 537 | mutex_unlock(&ata_mtx); |
538 | #endif | 538 | #endif |
539 | 539 | ||
540 | return ret; | 540 | return ret; |
@@ -580,7 +580,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
580 | #ifdef HAVE_MULTIVOLUME | 580 | #ifdef HAVE_MULTIVOLUME |
581 | (void)drive; /* unused for now */ | 581 | (void)drive; /* unused for now */ |
582 | #endif | 582 | #endif |
583 | spinlock_lock(&ata_spinlock); | 583 | mutex_lock(&ata_mtx); |
584 | 584 | ||
585 | offset = start & (phys_sector_mult - 1); | 585 | offset = start & (phys_sector_mult - 1); |
586 | 586 | ||
@@ -630,7 +630,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
630 | } | 630 | } |
631 | 631 | ||
632 | error: | 632 | error: |
633 | spinlock_unlock(&ata_spinlock); | 633 | mutex_unlock(&ata_mtx); |
634 | 634 | ||
635 | return rc; | 635 | return rc; |
636 | } | 636 | } |
@@ -646,7 +646,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
646 | #ifdef HAVE_MULTIVOLUME | 646 | #ifdef HAVE_MULTIVOLUME |
647 | (void)drive; /* unused for now */ | 647 | (void)drive; /* unused for now */ |
648 | #endif | 648 | #endif |
649 | spinlock_lock(&ata_spinlock); | 649 | mutex_lock(&ata_mtx); |
650 | 650 | ||
651 | offset = start & (phys_sector_mult - 1); | 651 | offset = start & (phys_sector_mult - 1); |
652 | 652 | ||
@@ -707,7 +707,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
707 | } | 707 | } |
708 | 708 | ||
709 | error: | 709 | error: |
710 | spinlock_unlock(&ata_spinlock); | 710 | mutex_unlock(&ata_mtx); |
711 | 711 | ||
712 | return rc; | 712 | return rc; |
713 | } | 713 | } |
@@ -767,13 +767,13 @@ static int ata_perform_sleep(void) | |||
767 | { | 767 | { |
768 | int ret = 0; | 768 | int ret = 0; |
769 | 769 | ||
770 | spinlock_lock(&ata_spinlock); | 770 | mutex_lock(&ata_mtx); |
771 | 771 | ||
772 | SET_REG(ATA_SELECT, ata_device); | 772 | SET_REG(ATA_SELECT, ata_device); |
773 | 773 | ||
774 | if(!wait_for_rdy()) { | 774 | if(!wait_for_rdy()) { |
775 | DEBUGF("ata_perform_sleep() - not RDY\n"); | 775 | DEBUGF("ata_perform_sleep() - not RDY\n"); |
776 | spinlock_unlock(&ata_spinlock); | 776 | mutex_unlock(&ata_mtx); |
777 | return -1; | 777 | return -1; |
778 | } | 778 | } |
779 | 779 | ||
@@ -786,7 +786,7 @@ static int ata_perform_sleep(void) | |||
786 | } | 786 | } |
787 | 787 | ||
788 | sleeping = true; | 788 | sleeping = true; |
789 | spinlock_unlock(&ata_spinlock); | 789 | mutex_unlock(&ata_mtx); |
790 | return ret; | 790 | return ret; |
791 | } | 791 | } |
792 | 792 | ||
@@ -797,7 +797,7 @@ void ata_sleep(void) | |||
797 | 797 | ||
798 | void ata_sleepnow(void) | 798 | void ata_sleepnow(void) |
799 | { | 799 | { |
800 | if (!spinup && !sleeping && !ata_spinlock.locked && initialized) | 800 | if (!spinup && !sleeping && !ata_mtx.locked && initialized) |
801 | { | 801 | { |
802 | call_ata_idle_notifys(false); | 802 | call_ata_idle_notifys(false); |
803 | ata_perform_sleep(); | 803 | ata_perform_sleep(); |
@@ -819,7 +819,7 @@ static void ata_thread(void) | |||
819 | while ( queue_empty( &ata_queue ) ) { | 819 | while ( queue_empty( &ata_queue ) ) { |
820 | if (!spinup && !sleeping) | 820 | if (!spinup && !sleeping) |
821 | { | 821 | { |
822 | if (!ata_spinlock.locked) | 822 | if (!ata_mtx.locked) |
823 | { | 823 | { |
824 | if (!last_seen_mtx_unlock) | 824 | if (!last_seen_mtx_unlock) |
825 | last_seen_mtx_unlock = current_tick; | 825 | last_seen_mtx_unlock = current_tick; |
@@ -844,9 +844,9 @@ static void ata_thread(void) | |||
844 | if ( !spinup && sleeping && !poweroff && | 844 | if ( !spinup && sleeping && !poweroff && |
845 | TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT )) | 845 | TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT )) |
846 | { | 846 | { |
847 | spinlock_lock(&ata_spinlock); | 847 | mutex_lock(&ata_mtx); |
848 | ide_power_enable(false); | 848 | ide_power_enable(false); |
849 | spinlock_unlock(&ata_spinlock); | 849 | mutex_unlock(&ata_mtx); |
850 | poweroff = true; | 850 | poweroff = true; |
851 | } | 851 | } |
852 | #endif | 852 | #endif |
@@ -858,11 +858,11 @@ static void ata_thread(void) | |||
858 | #ifndef USB_NONE | 858 | #ifndef USB_NONE |
859 | case SYS_USB_CONNECTED: | 859 | case SYS_USB_CONNECTED: |
860 | if (poweroff) { | 860 | if (poweroff) { |
861 | spinlock_lock(&ata_spinlock); | 861 | mutex_lock(&ata_mtx); |
862 | ata_led(true); | 862 | ata_led(true); |
863 | ata_power_on(); | 863 | ata_power_on(); |
864 | ata_led(false); | 864 | ata_led(false); |
865 | spinlock_unlock(&ata_spinlock); | 865 | mutex_unlock(&ata_mtx); |
866 | } | 866 | } |
867 | 867 | ||
868 | /* Tell the USB thread that we are safe */ | 868 | /* Tell the USB thread that we are safe */ |
@@ -936,11 +936,11 @@ int ata_soft_reset(void) | |||
936 | { | 936 | { |
937 | int ret; | 937 | int ret; |
938 | 938 | ||
939 | spinlock_lock(&ata_spinlock); | 939 | mutex_lock(&ata_mtx); |
940 | 940 | ||
941 | ret = perform_soft_reset(); | 941 | ret = perform_soft_reset(); |
942 | 942 | ||
943 | spinlock_unlock(&ata_spinlock); | 943 | mutex_unlock(&ata_mtx); |
944 | return ret; | 944 | return ret; |
945 | } | 945 | } |
946 | 946 | ||
@@ -1132,11 +1132,11 @@ int ata_init(void) | |||
1132 | bool coldstart; | 1132 | bool coldstart; |
1133 | 1133 | ||
1134 | if ( !initialized ) { | 1134 | if ( !initialized ) { |
1135 | spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH)); | 1135 | mutex_init(&ata_mtx); |
1136 | queue_init(&ata_queue, true); | 1136 | queue_init(&ata_queue, true); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | spinlock_lock(&ata_spinlock); | 1139 | mutex_lock(&ata_mtx); |
1140 | 1140 | ||
1141 | /* must be called before ata_device_init() */ | 1141 | /* must be called before ata_device_init() */ |
1142 | coldstart = ata_is_coldstart(); | 1142 | coldstart = ata_is_coldstart(); |
@@ -1150,7 +1150,7 @@ int ata_init(void) | |||
1150 | 1150 | ||
1151 | if ( !initialized ) { | 1151 | if ( !initialized ) { |
1152 | /* First call won't have multiple thread contention */ | 1152 | /* First call won't have multiple thread contention */ |
1153 | spinlock_unlock(&ata_spinlock); | 1153 | mutex_unlock(&ata_mtx); |
1154 | 1154 | ||
1155 | if (!ide_powered()) /* somebody has switched it off */ | 1155 | if (!ide_powered()) /* somebody has switched it off */ |
1156 | { | 1156 | { |
@@ -1223,7 +1223,7 @@ int ata_init(void) | |||
1223 | if (rc) | 1223 | if (rc) |
1224 | rc = -70 + rc; | 1224 | rc = -70 + rc; |
1225 | 1225 | ||
1226 | spinlock_unlock(&ata_spinlock); | 1226 | mutex_unlock(&ata_mtx); |
1227 | return rc; | 1227 | return rc; |
1228 | } | 1228 | } |
1229 | 1229 | ||