diff options
author | Stefani Seibold <stefani@seibold.net> | 2010-08-05 03:19:26 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-08-06 04:22:16 -0400 |
commit | 8ae664184c45def51ff0b61d4bd6c6671db6cb4f (patch) | |
tree | e377d32da757a7c61150f2569bda85411a1835eb /drivers/mtd/lpddr | |
parent | b8664b3762dc81e7a19ad4ffaae4055d6d5a7196 (diff) |
mtd: change struct flchip_shared spinlock locking into mutex
This patch prevent to schedule while atomic by changing the
flchip_shared spinlock into a mutex. This should be save since no atomic
path will use this lock.
It was suggested by Arnd Bergmann and Vasiliy Kulikov.
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 'drivers/mtd/lpddr')
-rw-r--r-- | drivers/mtd/lpddr/lpddr_cmds.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c index fece5be58715..04fdfcca93f7 100644 --- a/drivers/mtd/lpddr/lpddr_cmds.c +++ b/drivers/mtd/lpddr/lpddr_cmds.c | |||
@@ -98,7 +98,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map) | |||
98 | numchips = lpddr->numchips / lpddr->qinfo->HWPartsNum; | 98 | numchips = lpddr->numchips / lpddr->qinfo->HWPartsNum; |
99 | for (i = 0; i < numchips; i++) { | 99 | for (i = 0; i < numchips; i++) { |
100 | shared[i].writing = shared[i].erasing = NULL; | 100 | shared[i].writing = shared[i].erasing = NULL; |
101 | spin_lock_init(&shared[i].lock); | 101 | mutex_init(&shared[i].lock); |
102 | for (j = 0; j < lpddr->qinfo->HWPartsNum; j++) { | 102 | for (j = 0; j < lpddr->qinfo->HWPartsNum; j++) { |
103 | *chip = lpddr->chips[i]; | 103 | *chip = lpddr->chips[i]; |
104 | chip->start += j << lpddr->chipshift; | 104 | chip->start += j << lpddr->chipshift; |
@@ -217,7 +217,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode) | |||
217 | */ | 217 | */ |
218 | struct flchip_shared *shared = chip->priv; | 218 | struct flchip_shared *shared = chip->priv; |
219 | struct flchip *contender; | 219 | struct flchip *contender; |
220 | spin_lock(&shared->lock); | 220 | mutex_lock(&shared->lock); |
221 | contender = shared->writing; | 221 | contender = shared->writing; |
222 | if (contender && contender != chip) { | 222 | if (contender && contender != chip) { |
223 | /* | 223 | /* |
@@ -230,7 +230,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode) | |||
230 | * get_chip returns success we're clear to go ahead. | 230 | * get_chip returns success we're clear to go ahead. |
231 | */ | 231 | */ |
232 | ret = mutex_trylock(&contender->mutex); | 232 | ret = mutex_trylock(&contender->mutex); |
233 | spin_unlock(&shared->lock); | 233 | mutex_unlock(&shared->lock); |
234 | if (!ret) | 234 | if (!ret) |
235 | goto retry; | 235 | goto retry; |
236 | mutex_unlock(&chip->mutex); | 236 | mutex_unlock(&chip->mutex); |
@@ -245,7 +245,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode) | |||
245 | mutex_unlock(&contender->mutex); | 245 | mutex_unlock(&contender->mutex); |
246 | return ret; | 246 | return ret; |
247 | } | 247 | } |
248 | spin_lock(&shared->lock); | 248 | mutex_lock(&shared->lock); |
249 | 249 | ||
250 | /* We should not own chip if it is already in FL_SYNCING | 250 | /* We should not own chip if it is already in FL_SYNCING |
251 | * state. Put contender and retry. */ | 251 | * state. Put contender and retry. */ |
@@ -261,7 +261,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode) | |||
261 | Must sleep in such a case. */ | 261 | Must sleep in such a case. */ |
262 | if (mode == FL_ERASING && shared->erasing | 262 | if (mode == FL_ERASING && shared->erasing |
263 | && shared->erasing->oldstate == FL_ERASING) { | 263 | && shared->erasing->oldstate == FL_ERASING) { |
264 | spin_unlock(&shared->lock); | 264 | mutex_unlock(&shared->lock); |
265 | set_current_state(TASK_UNINTERRUPTIBLE); | 265 | set_current_state(TASK_UNINTERRUPTIBLE); |
266 | add_wait_queue(&chip->wq, &wait); | 266 | add_wait_queue(&chip->wq, &wait); |
267 | mutex_unlock(&chip->mutex); | 267 | mutex_unlock(&chip->mutex); |
@@ -275,7 +275,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, int mode) | |||
275 | shared->writing = chip; | 275 | shared->writing = chip; |
276 | if (mode == FL_ERASING) | 276 | if (mode == FL_ERASING) |
277 | shared->erasing = chip; | 277 | shared->erasing = chip; |
278 | spin_unlock(&shared->lock); | 278 | mutex_unlock(&shared->lock); |
279 | } | 279 | } |
280 | 280 | ||
281 | ret = chip_ready(map, chip, mode); | 281 | ret = chip_ready(map, chip, mode); |
@@ -348,7 +348,7 @@ static void put_chip(struct map_info *map, struct flchip *chip) | |||
348 | { | 348 | { |
349 | if (chip->priv) { | 349 | if (chip->priv) { |
350 | struct flchip_shared *shared = chip->priv; | 350 | struct flchip_shared *shared = chip->priv; |
351 | spin_lock(&shared->lock); | 351 | mutex_lock(&shared->lock); |
352 | if (shared->writing == chip && chip->oldstate == FL_READY) { | 352 | if (shared->writing == chip && chip->oldstate == FL_READY) { |
353 | /* We own the ability to write, but we're done */ | 353 | /* We own the ability to write, but we're done */ |
354 | shared->writing = shared->erasing; | 354 | shared->writing = shared->erasing; |
@@ -356,7 +356,7 @@ static void put_chip(struct map_info *map, struct flchip *chip) | |||
356 | /* give back the ownership */ | 356 | /* give back the ownership */ |
357 | struct flchip *loaner = shared->writing; | 357 | struct flchip *loaner = shared->writing; |
358 | mutex_lock(&loaner->mutex); | 358 | mutex_lock(&loaner->mutex); |
359 | spin_unlock(&shared->lock); | 359 | mutex_unlock(&shared->lock); |
360 | mutex_unlock(&chip->mutex); | 360 | mutex_unlock(&chip->mutex); |
361 | put_chip(map, loaner); | 361 | put_chip(map, loaner); |
362 | mutex_lock(&chip->mutex); | 362 | mutex_lock(&chip->mutex); |
@@ -374,11 +374,11 @@ static void put_chip(struct map_info *map, struct flchip *chip) | |||
374 | * Don't let the switch below mess things up since | 374 | * Don't let the switch below mess things up since |
375 | * we don't have ownership to resume anything. | 375 | * we don't have ownership to resume anything. |
376 | */ | 376 | */ |
377 | spin_unlock(&shared->lock); | 377 | mutex_unlock(&shared->lock); |
378 | wake_up(&chip->wq); | 378 | wake_up(&chip->wq); |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | spin_unlock(&shared->lock); | 381 | mutex_unlock(&shared->lock); |
382 | } | 382 | } |
383 | 383 | ||
384 | switch (chip->oldstate) { | 384 | switch (chip->oldstate) { |