From 376d8d577fe94a8dc8742deff5a7524aa1595e1c Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sat, 3 Apr 2010 22:02:09 +0000 Subject: Add IO priority handling. Currently all IO has equal priority, except the dircache scanning thread which is lower. This fixes the slow boot problem for me, with the added benefit that actual audio playback also starts faster. Lots of the changes are due to changing storage_(read|write)sectors() from macros to wrapper functions. This means that they have to be called with IF_MD2(drive,) again. Flyspray: FS#11167 Author: Frank Gevaerts git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25459 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config.h | 4 ++++ firmware/export/storage.h | 20 ++++++++------------ firmware/export/thread.h | 10 ++++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/config.h b/firmware/export/config.h index 9d8dc41111..858d9bf250 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -921,4 +921,8 @@ Lyre prototype 1 */ #define HAVE_PLUGIN_CHECK_OPEN_CLOSE #endif +#ifdef HAVE_DIRCACHE +#define HAVE_IO_PRIORITY +#endif + #endif /* __CONFIG_H__ */ diff --git a/firmware/export/storage.h b/firmware/export/storage.h index 0096e87a8d..e62cf0d902 100644 --- a/firmware/export/storage.h +++ b/firmware/export/storage.h @@ -57,6 +57,7 @@ struct storage_info */ #define storage_num_drives() NUM_DRIVES #if (CONFIG_STORAGE & STORAGE_ATA) + #define STORAGE_FUNCTION(NAME) (ata_## NAME) #define storage_spindown ata_spindown #define storage_sleep ata_sleep #define storage_spin ata_spin @@ -67,8 +68,6 @@ struct storage_info #define storage_soft_reset() ata_soft_reset() #define storage_init() ata_init() #define storage_close() ata_close() - #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MD2(drive,) start, count, buf) - #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MD2(drive,) start, count, buf) #ifdef HAVE_STORAGE_FLUSH #define storage_flush() (void)0 #endif @@ -84,6 +83,7 @@ struct storage_info #define storage_present(drive) ata_present(IF_MD(drive)) #endif #elif (CONFIG_STORAGE & STORAGE_SD) + #define STORAGE_FUNCTION(NAME) (sd_## NAME) #define storage_spindown sd_spindown #define storage_sleep sd_sleep #define storage_spin sd_spin @@ -93,8 +93,6 @@ struct storage_info #define storage_disk_is_active() 0 #define storage_soft_reset() (void)0 #define storage_init() sd_init() - #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MD2(drive,) start, count, buf) - #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MD2(drive,) start, count, buf) #ifdef HAVE_STORAGE_FLUSH #define storage_flush() (void)0 #endif @@ -110,6 +108,7 @@ struct storage_info #define storage_present(drive) sd_present(IF_MD(drive)) #endif #elif (CONFIG_STORAGE & STORAGE_MMC) + #define STORAGE_FUNCTION(NAME) (mmc_## NAME) #define storage_spindown mmc_spindown #define storage_sleep mmc_sleep #define storage_spin mmc_spin @@ -119,8 +118,6 @@ struct storage_info #define storage_disk_is_active() mmc_disk_is_active() #define storage_soft_reset() (void)0 #define storage_init() mmc_init() - #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MD2(drive,) start, count, buf) - #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MD2(drive,) start, count, buf) #ifdef HAVE_STORAGE_FLUSH #define storage_flush() (void)0 #endif @@ -136,6 +133,7 @@ struct storage_info #define storage_present(drive) mmc_present(IF_MD(drive)) #endif #elif (CONFIG_STORAGE & STORAGE_NAND) + #define STORAGE_FUNCTION(NAME) (nand_## NAME) #define storage_spindown nand_spindown #define storage_sleep nand_sleep #define storage_spin nand_spin @@ -145,8 +143,6 @@ struct storage_info #define storage_disk_is_active() 0 #define storage_soft_reset() (void)0 #define storage_init() nand_init() - #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MD2(drive,) start, count, buf) - #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MD2(drive,) start, count, buf) #ifdef HAVE_STORAGE_FLUSH #define storage_flush() nand_flush() #endif @@ -162,6 +158,7 @@ struct storage_info #define storage_present(drive) nand_present(IF_MD(drive)) #endif #elif (CONFIG_STORAGE & STORAGE_RAMDISK) + #define STORAGE_FUNCTION(NAME) (ramdisk_## NAME) #define storage_spindown ramdisk_spindown #define storage_sleep ramdisk_sleep #define storage_spin ramdisk_spin @@ -171,8 +168,6 @@ struct storage_info #define storage_disk_is_active() 0 #define storage_soft_reset() (void)0 #define storage_init() ramdisk_init() - #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MD2(drive,) start, count, buf) - #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MD2(drive,) start, count, buf) #ifdef HAVE_STORAGE_FLUSH #define storage_flush() (void)0 #endif @@ -200,8 +195,6 @@ void storage_sleepnow(void); bool storage_disk_is_active(void); int storage_soft_reset(void); int storage_init(void); -int storage_read_sectors(int drive, unsigned long start, int count, void* buf); -int storage_write_sectors(int drive, unsigned long start, int count, const void* buf); int storage_flush(void); void storage_spin(void); void storage_spindown(int seconds); @@ -217,4 +210,7 @@ bool storage_present(int drive); #endif #endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/ + +int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); +int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); #endif diff --git a/firmware/export/thread.h b/firmware/export/thread.h index 2a2a7a8619..a75981dcba 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h @@ -58,6 +58,9 @@ #define NUM_PRIORITIES 32 #define PRIORITY_IDLE 32 /* Priority representative of no tasks */ +#define IO_PRIORITY_IMMEDIATE 0 +#define IO_PRIORITY_BACKGROUND 32 + #if CONFIG_CODEC == SWCODEC #ifdef HAVE_RECORDING @@ -294,6 +297,9 @@ struct thread_entry struct corelock waiter_cl; /* Corelock for thread_wait */ struct corelock slot_cl; /* Corelock to lock thread slot */ #endif +#ifdef HAVE_IO_PRIORITY + unsigned char io_priority; +#endif }; /*** Macros for internal use ***/ @@ -539,6 +545,10 @@ unsigned int wakeup_thread(struct thread_entry **list); int thread_set_priority(unsigned int thread_id, int priority); int thread_get_priority(unsigned int thread_id); #endif /* HAVE_PRIORITY_SCHEDULING */ +#ifdef HAVE_IO_PRIORITY +void thread_set_io_priority(unsigned int thread_id, int io_priority); +int thread_get_io_priority(unsigned int thread_id); +#endif /* HAVE_IO_PRIORITY */ #if NUM_CORES > 1 unsigned int switch_core(unsigned int new_core); #endif -- cgit v1.2.3