diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-03-28 23:39:28 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-03-28 23:39:28 +0000 |
commit | 58787280b808838b9812258645d6df69591bbb37 (patch) | |
tree | b0bd7e398d3483d8413802f5999f685c358e01db /firmware/drivers/ata.c | |
parent | 8f44dd2b72fd9b537512fece7bf13c5fe286d39c (diff) | |
download | rockbox-58787280b808838b9812258645d6df69591bbb37.tar.gz rockbox-58787280b808838b9812258645d6df69591bbb37.zip |
Go back to the ata lock hack for 5g until whatever is going on there is discovered and fixed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16870 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r-- | firmware/drivers/ata.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 56b303da8d..681160cf01 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -66,6 +66,74 @@ | |||
66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ | 66 | #define ATA_POWER_OFF_TIMEOUT 2*HZ |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #ifdef MAX_PHYS_SECTOR_SIZE | ||
70 | /* Hack - what's the deal with 5g? */ | ||
71 | struct ata_lock | ||
72 | { | ||
73 | struct thread_entry *thread; | ||
74 | int count; | ||
75 | volatile unsigned char locked; | ||
76 | IF_COP( struct corelock cl; ) | ||
77 | }; | ||
78 | |||
79 | static void ata_lock_init(struct ata_lock *l) | ||
80 | { | ||
81 | corelock_init(&l->cl); | ||
82 | l->locked = 0; | ||
83 | l->count = 0; | ||
84 | l->thread = NULL; | ||
85 | } | ||
86 | |||
87 | static void ata_lock_lock(struct ata_lock *l) | ||
88 | { | ||
89 | struct thread_entry * const current = thread_get_current(); | ||
90 | |||
91 | if (current == l->thread) | ||
92 | { | ||
93 | l->count++; | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | corelock_lock(&l->cl); | ||
98 | |||
99 | IF_PRIO( current->skip_count = -1; ) | ||
100 | |||
101 | while (l->locked != 0) | ||
102 | { | ||
103 | corelock_unlock(&l->cl); | ||
104 | switch_thread(); | ||
105 | corelock_lock(&l->cl); | ||
106 | } | ||
107 | |||
108 | l->locked = 1; | ||
109 | l->thread = current; | ||
110 | corelock_unlock(&l->cl); | ||
111 | } | ||
112 | |||
113 | static void ata_lock_unlock(struct ata_lock *l) | ||
114 | { | ||
115 | if (l->count > 0) | ||
116 | { | ||
117 | l->count--; | ||
118 | return; | ||
119 | } | ||
120 | |||
121 | corelock_lock(&l->cl); | ||
122 | |||
123 | IF_PRIO( l->thread->skip_count = 0; ) | ||
124 | |||
125 | l->thread = NULL; | ||
126 | l->locked = 0; | ||
127 | |||
128 | corelock_unlock(&l->cl); | ||
129 | } | ||
130 | |||
131 | #define mutex ata_lock | ||
132 | #define mutex_init ata_lock_init | ||
133 | #define mutex_lock ata_lock_lock | ||
134 | #define mutex_unlock ata_lock_unlock | ||
135 | #endif /* MAX_PHYS_SECTOR_SIZE */ | ||
136 | |||
69 | static struct mutex ata_mtx NOCACHEBSS_ATTR; | 137 | static struct mutex ata_mtx NOCACHEBSS_ATTR; |
70 | int ata_device; /* device 0 (master) or 1 (slave) */ | 138 | int ata_device; /* device 0 (master) or 1 (slave) */ |
71 | 139 | ||