diff options
author | Stefani Seibold <stefani@seibold.net> | 2010-04-18 16:46:44 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-05-10 09:22:30 -0400 |
commit | c4e773764cead9358fd4b036d1b883fff3968513 (patch) | |
tree | ceb30e53d7ba33a071653c2bc05c06293d84575f /include/linux/mtd | |
parent | 67026418f534045525a7c39f506006cd7fbd197f (diff) |
mtd: fix a huge latency problem in the MTD CFI and LPDDR flash drivers.
The use of a memcpy() during a spinlock operation will cause very long
thread context switch delays if the flash chip bandwidth is low and the
data to be copied large, because a spinlock will disable preemption.
For example: A flash with 6,5 MB/s bandwidth will cause under ubifs,
which request sometimes 128 KiB (the flash erase size), a preemption delay of
20 milliseconds. High priority threads will not be served during this
time, regardless whether this threads access the flash or not. This behavior
breaks real time.
The patch changes all the use of spin_lock operations for xxxx->mutex
into mutex operations, which is exact what the name says and means.
I have checked the code of the drivers and there is no use of atomic
pathes like interrupt or timers. The mtdoops facility will also not be used
by this drivers. So it is dave to replace the spin_lock against mutex.
There is no performance regression since the mutex is normally not
acquired.
Changelog:
06.03.2010 First release
26.03.2010 Fix mutex[1] issue and tested it for compile failure
Signed-off-by: Stefani Seibold <stefani@seibold.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r-- | include/linux/mtd/flashchip.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/mtd/flashchip.h b/include/linux/mtd/flashchip.h index d0bf422ae374..f43e9b49b751 100644 --- a/include/linux/mtd/flashchip.h +++ b/include/linux/mtd/flashchip.h | |||
@@ -15,6 +15,7 @@ | |||
15 | * has asm/spinlock.h, or 2.4, which has linux/spinlock.h | 15 | * has asm/spinlock.h, or 2.4, which has linux/spinlock.h |
16 | */ | 16 | */ |
17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
18 | #include <linux/mutex.h> | ||
18 | 19 | ||
19 | typedef enum { | 20 | typedef enum { |
20 | FL_READY, | 21 | FL_READY, |
@@ -74,8 +75,7 @@ struct flchip { | |||
74 | unsigned int erase_suspended:1; | 75 | unsigned int erase_suspended:1; |
75 | unsigned long in_progress_block_addr; | 76 | unsigned long in_progress_block_addr; |
76 | 77 | ||
77 | spinlock_t *mutex; | 78 | struct mutex mutex; |
78 | spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */ | ||
79 | wait_queue_head_t wq; /* Wait on here when we're waiting for the chip | 79 | wait_queue_head_t wq; /* Wait on here when we're waiting for the chip |
80 | to be ready */ | 80 | to be ready */ |
81 | int word_write_time; | 81 | int word_write_time; |