mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
Finally, out goes struct spinlock for anything but mutiprocessor targets where it becomes a reenterable corelock.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16105 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3b36b98ff8
commit
6a8379674c
8 changed files with 61 additions and 145 deletions
|
|
@ -66,7 +66,7 @@
|
|||
#define ATA_POWER_OFF_TIMEOUT 2*HZ
|
||||
#endif
|
||||
|
||||
static struct spinlock ata_spinlock NOCACHEBSS_ATTR;
|
||||
static struct mutex ata_mtx NOCACHEBSS_ATTR;
|
||||
int ata_device; /* device 0 (master) or 1 (slave) */
|
||||
|
||||
int ata_spinup_time = 0;
|
||||
|
|
@ -234,7 +234,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
#endif
|
||||
|
||||
last_disk_activity = current_tick;
|
||||
|
|
@ -246,14 +246,14 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
spinup = true;
|
||||
if (poweroff) {
|
||||
if (ata_power_on()) {
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
ata_led(false);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (perform_soft_reset()) {
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
ata_led(false);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
SET_REG(ATA_SELECT, ata_device);
|
||||
if (!wait_for_rdy())
|
||||
{
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
ata_led(false);
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
ata_led(false);
|
||||
|
||||
#ifndef MAX_PHYS_SECTOR_SIZE
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
@ -442,7 +442,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
#endif
|
||||
|
||||
last_disk_activity = current_tick;
|
||||
|
|
@ -454,14 +454,14 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
spinup = true;
|
||||
if (poweroff) {
|
||||
if (ata_power_on()) {
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
ata_led(false);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (perform_soft_reset()) {
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
ata_led(false);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
SET_REG(ATA_SELECT, ata_device);
|
||||
if (!wait_for_rdy())
|
||||
{
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
ata_led(false);
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -534,7 +534,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
ata_led(false);
|
||||
|
||||
#ifndef MAX_PHYS_SECTOR_SIZE
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
@ -580,7 +580,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
|
||||
offset = start & (phys_sector_mult - 1);
|
||||
|
||||
|
|
@ -630,7 +630,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
}
|
||||
|
||||
error:
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -646,7 +646,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
#ifdef HAVE_MULTIVOLUME
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
|
||||
offset = start & (phys_sector_mult - 1);
|
||||
|
||||
|
|
@ -707,7 +707,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
}
|
||||
|
||||
error:
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -767,13 +767,13 @@ static int ata_perform_sleep(void)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
|
||||
SET_REG(ATA_SELECT, ata_device);
|
||||
|
||||
if(!wait_for_rdy()) {
|
||||
DEBUGF("ata_perform_sleep() - not RDY\n");
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -786,7 +786,7 @@ static int ata_perform_sleep(void)
|
|||
}
|
||||
|
||||
sleeping = true;
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -797,7 +797,7 @@ void ata_sleep(void)
|
|||
|
||||
void ata_sleepnow(void)
|
||||
{
|
||||
if (!spinup && !sleeping && !ata_spinlock.locked && initialized)
|
||||
if (!spinup && !sleeping && !ata_mtx.locked && initialized)
|
||||
{
|
||||
call_ata_idle_notifys(false);
|
||||
ata_perform_sleep();
|
||||
|
|
@ -819,7 +819,7 @@ static void ata_thread(void)
|
|||
while ( queue_empty( &ata_queue ) ) {
|
||||
if (!spinup && !sleeping)
|
||||
{
|
||||
if (!ata_spinlock.locked)
|
||||
if (!ata_mtx.locked)
|
||||
{
|
||||
if (!last_seen_mtx_unlock)
|
||||
last_seen_mtx_unlock = current_tick;
|
||||
|
|
@ -844,9 +844,9 @@ static void ata_thread(void)
|
|||
if ( !spinup && sleeping && !poweroff &&
|
||||
TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT ))
|
||||
{
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
ide_power_enable(false);
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
poweroff = true;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -858,11 +858,11 @@ static void ata_thread(void)
|
|||
#ifndef USB_NONE
|
||||
case SYS_USB_CONNECTED:
|
||||
if (poweroff) {
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
ata_led(true);
|
||||
ata_power_on();
|
||||
ata_led(false);
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
}
|
||||
|
||||
/* Tell the USB thread that we are safe */
|
||||
|
|
@ -936,11 +936,11 @@ int ata_soft_reset(void)
|
|||
{
|
||||
int ret;
|
||||
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
|
||||
ret = perform_soft_reset();
|
||||
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1132,11 +1132,11 @@ int ata_init(void)
|
|||
bool coldstart;
|
||||
|
||||
if ( !initialized ) {
|
||||
spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH));
|
||||
mutex_init(&ata_mtx);
|
||||
queue_init(&ata_queue, true);
|
||||
}
|
||||
|
||||
spinlock_lock(&ata_spinlock);
|
||||
mutex_lock(&ata_mtx);
|
||||
|
||||
/* must be called before ata_device_init() */
|
||||
coldstart = ata_is_coldstart();
|
||||
|
|
@ -1150,7 +1150,7 @@ int ata_init(void)
|
|||
|
||||
if ( !initialized ) {
|
||||
/* First call won't have multiple thread contention */
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
|
||||
if (!ide_powered()) /* somebody has switched it off */
|
||||
{
|
||||
|
|
@ -1223,7 +1223,7 @@ int ata_init(void)
|
|||
if (rc)
|
||||
rc = -70 + rc;
|
||||
|
||||
spinlock_unlock(&ata_spinlock);
|
||||
mutex_unlock(&ata_mtx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue