diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-03-25 02:34:12 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-03-25 02:34:12 +0000 |
commit | 27cf67733936abd75fcb1f8da765977cd75906ee (patch) | |
tree | f894211a8a0c77b402dd3250b2bee2d17dcfe13f /firmware/drivers | |
parent | bc2f8fd8f38a3e010cd67bbac358f6e9991153c6 (diff) | |
download | rockbox-27cf67733936abd75fcb1f8da765977cd75906ee.tar.gz rockbox-27cf67733936abd75fcb1f8da765977cd75906ee.zip |
Add a complete priority inheritance implementation to the scheduler (all mutex ownership and queue_send calls are inheritable). Priorities are differential so that dispatch depends on the runnable range of priorities. Codec priority can therefore be raised in small steps (pcmbuf updated to enable). Simplify the kernel functions to ease implementation and use the same kernel.c for both sim and target (I'm tired of maintaining two ;_). 1) Not sure if a minor audio break at first buffering issue will exist on large-sector disks (the main mutex speed issue was genuinely resolved earlier). At this point it's best dealt with at the buffering level. It seems a larger filechunk could be used again. 2) Perhaps 64-bit sims will have some minor issues (finicky) but a backroll of the code of concern there is a 5-minute job. All kernel objects become incompatible so a full rebuild and update is needed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16791 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 50 | ||||
-rw-r--r-- | firmware/drivers/fat.c | 6 |
2 files changed, 8 insertions, 48 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index e067235d95..56b303da8d 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -95,52 +95,6 @@ static unsigned short identify_info[SECTOR_SIZE/2]; | |||
95 | 95 | ||
96 | #ifdef MAX_PHYS_SECTOR_SIZE | 96 | #ifdef MAX_PHYS_SECTOR_SIZE |
97 | 97 | ||
98 | /** This is temporary **/ | ||
99 | /* Define the mutex functions to use the special hack object */ | ||
100 | #define mutex_init ata_spin_init | ||
101 | #define mutex_lock ata_spin_lock | ||
102 | #define mutex_unlock ata_spin_unlock | ||
103 | |||
104 | void ata_spin_init(struct mutex *m) | ||
105 | { | ||
106 | m->thread = NULL; | ||
107 | m->locked = 0; | ||
108 | m->count = 0; | ||
109 | #if CONFIG_CORELOCK == SW_CORELOCK | ||
110 | corelock_init(&m->cl); | ||
111 | #endif | ||
112 | } | ||
113 | |||
114 | void ata_spin_lock(struct mutex *m) | ||
115 | { | ||
116 | struct thread_entry *current = thread_get_current(); | ||
117 | |||
118 | if (current == m->thread) | ||
119 | { | ||
120 | m->count++; | ||
121 | return; | ||
122 | } | ||
123 | |||
124 | while (test_and_set(&m->locked, 1, &m->cl)) | ||
125 | yield(); | ||
126 | |||
127 | m->thread = current; | ||
128 | } | ||
129 | |||
130 | void ata_spin_unlock(struct mutex *m) | ||
131 | { | ||
132 | if (m->count > 0) | ||
133 | { | ||
134 | m->count--; | ||
135 | return; | ||
136 | } | ||
137 | |||
138 | m->thread = NULL; | ||
139 | test_and_set(&m->locked, 0, &m->cl); | ||
140 | } | ||
141 | |||
142 | /****/ | ||
143 | |||
144 | struct sector_cache_entry { | 98 | struct sector_cache_entry { |
145 | bool inuse; | 99 | bool inuse; |
146 | unsigned long sectornum; /* logical sector */ | 100 | unsigned long sectornum; /* logical sector */ |
@@ -163,7 +117,7 @@ STATICIRAM int wait_for_bsy(void) | |||
163 | long timeout = current_tick + HZ*30; | 117 | long timeout = current_tick + HZ*30; |
164 | while (TIME_BEFORE(current_tick, timeout) && (ATA_STATUS & STATUS_BSY)) { | 118 | while (TIME_BEFORE(current_tick, timeout) && (ATA_STATUS & STATUS_BSY)) { |
165 | last_disk_activity = current_tick; | 119 | last_disk_activity = current_tick; |
166 | priority_yield(); | 120 | yield(); |
167 | } | 121 | } |
168 | 122 | ||
169 | if (TIME_BEFORE(current_tick, timeout)) | 123 | if (TIME_BEFORE(current_tick, timeout)) |
@@ -185,7 +139,7 @@ STATICIRAM int wait_for_rdy(void) | |||
185 | while (TIME_BEFORE(current_tick, timeout) && | 139 | while (TIME_BEFORE(current_tick, timeout) && |
186 | !(ATA_ALT_STATUS & STATUS_RDY)) { | 140 | !(ATA_ALT_STATUS & STATUS_RDY)) { |
187 | last_disk_activity = current_tick; | 141 | last_disk_activity = current_tick; |
188 | priority_yield(); | 142 | yield(); |
189 | } | 143 | } |
190 | 144 | ||
191 | if (TIME_BEFORE(current_tick, timeout)) | 145 | if (TIME_BEFORE(current_tick, timeout)) |
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 8ae3b70cd3..a538b92695 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -259,6 +259,12 @@ void fat_init(void) | |||
259 | mutex_init(&cache_mutex); | 259 | mutex_init(&cache_mutex); |
260 | } | 260 | } |
261 | 261 | ||
262 | #ifdef HAVE_PRIORITY_SCHEDULING | ||
263 | /* Disable this because it is dangerous due to the assumption that | ||
264 | * mutex_unlock won't yield */ | ||
265 | mutex_set_preempt(&cache_mutex, false); | ||
266 | #endif | ||
267 | |||
262 | /* mark the FAT cache as unused */ | 268 | /* mark the FAT cache as unused */ |
263 | for(i = 0;i < FAT_CACHE_SIZE;i++) | 269 | for(i = 0;i < FAT_CACHE_SIZE;i++) |
264 | { | 270 | { |