aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2010-08-05 03:19:26 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-08-06 04:22:16 -0400
commit8ae664184c45def51ff0b61d4bd6c6671db6cb4f (patch)
treee377d32da757a7c61150f2569bda85411a1835eb /drivers/mtd
parentb8664b3762dc81e7a19ad4ffaae4055d6d5a7196 (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')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c20
-rw-r--r--drivers/mtd/lpddr/lpddr_cmds.c20
2 files changed, 20 insertions, 20 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 2fadb0239ba3..97d5546f9ea4 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -720,7 +720,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
720 chip = &newcfi->chips[0]; 720 chip = &newcfi->chips[0];
721 for (i = 0; i < cfi->numchips; i++) { 721 for (i = 0; i < cfi->numchips; i++) {
722 shared[i].writing = shared[i].erasing = NULL; 722 shared[i].writing = shared[i].erasing = NULL;
723 spin_lock_init(&shared[i].lock); 723 mutex_init(&shared[i].lock);
724 for (j = 0; j < numparts; j++) { 724 for (j = 0; j < numparts; j++) {
725 *chip = cfi->chips[i]; 725 *chip = cfi->chips[i];
726 chip->start += j << partshift; 726 chip->start += j << partshift;
@@ -889,7 +889,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
889 */ 889 */
890 struct flchip_shared *shared = chip->priv; 890 struct flchip_shared *shared = chip->priv;
891 struct flchip *contender; 891 struct flchip *contender;
892 spin_lock(&shared->lock); 892 mutex_lock(&shared->lock);
893 contender = shared->writing; 893 contender = shared->writing;
894 if (contender && contender != chip) { 894 if (contender && contender != chip) {
895 /* 895 /*
@@ -902,7 +902,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
902 * get_chip returns success we're clear to go ahead. 902 * get_chip returns success we're clear to go ahead.
903 */ 903 */
904 ret = mutex_trylock(&contender->mutex); 904 ret = mutex_trylock(&contender->mutex);
905 spin_unlock(&shared->lock); 905 mutex_unlock(&shared->lock);
906 if (!ret) 906 if (!ret)
907 goto retry; 907 goto retry;
908 mutex_unlock(&chip->mutex); 908 mutex_unlock(&chip->mutex);
@@ -917,7 +917,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
917 mutex_unlock(&contender->mutex); 917 mutex_unlock(&contender->mutex);
918 return ret; 918 return ret;
919 } 919 }
920 spin_lock(&shared->lock); 920 mutex_lock(&shared->lock);
921 921
922 /* We should not own chip if it is already 922 /* We should not own chip if it is already
923 * in FL_SYNCING state. Put contender and retry. */ 923 * in FL_SYNCING state. Put contender and retry. */
@@ -933,7 +933,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
933 * on this chip. Sleep. */ 933 * on this chip. Sleep. */
934 if (mode == FL_ERASING && shared->erasing 934 if (mode == FL_ERASING && shared->erasing
935 && shared->erasing->oldstate == FL_ERASING) { 935 && shared->erasing->oldstate == FL_ERASING) {
936 spin_unlock(&shared->lock); 936 mutex_unlock(&shared->lock);
937 set_current_state(TASK_UNINTERRUPTIBLE); 937 set_current_state(TASK_UNINTERRUPTIBLE);
938 add_wait_queue(&chip->wq, &wait); 938 add_wait_queue(&chip->wq, &wait);
939 mutex_unlock(&chip->mutex); 939 mutex_unlock(&chip->mutex);
@@ -947,7 +947,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
947 shared->writing = chip; 947 shared->writing = chip;
948 if (mode == FL_ERASING) 948 if (mode == FL_ERASING)
949 shared->erasing = chip; 949 shared->erasing = chip;
950 spin_unlock(&shared->lock); 950 mutex_unlock(&shared->lock);
951 } 951 }
952 ret = chip_ready(map, chip, adr, mode); 952 ret = chip_ready(map, chip, adr, mode);
953 if (ret == -EAGAIN) 953 if (ret == -EAGAIN)
@@ -962,7 +962,7 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
962 962
963 if (chip->priv) { 963 if (chip->priv) {
964 struct flchip_shared *shared = chip->priv; 964 struct flchip_shared *shared = chip->priv;
965 spin_lock(&shared->lock); 965 mutex_lock(&shared->lock);
966 if (shared->writing == chip && chip->oldstate == FL_READY) { 966 if (shared->writing == chip && chip->oldstate == FL_READY) {
967 /* We own the ability to write, but we're done */ 967 /* We own the ability to write, but we're done */
968 shared->writing = shared->erasing; 968 shared->writing = shared->erasing;
@@ -970,7 +970,7 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
970 /* give back ownership to who we loaned it from */ 970 /* give back ownership to who we loaned it from */
971 struct flchip *loaner = shared->writing; 971 struct flchip *loaner = shared->writing;
972 mutex_lock(&loaner->mutex); 972 mutex_lock(&loaner->mutex);
973 spin_unlock(&shared->lock); 973 mutex_unlock(&shared->lock);
974 mutex_unlock(&chip->mutex); 974 mutex_unlock(&chip->mutex);
975 put_chip(map, loaner, loaner->start); 975 put_chip(map, loaner, loaner->start);
976 mutex_lock(&chip->mutex); 976 mutex_lock(&chip->mutex);
@@ -988,11 +988,11 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
988 * Don't let the switch below mess things up since 988 * Don't let the switch below mess things up since
989 * we don't have ownership to resume anything. 989 * we don't have ownership to resume anything.
990 */ 990 */
991 spin_unlock(&shared->lock); 991 mutex_unlock(&shared->lock);
992 wake_up(&chip->wq); 992 wake_up(&chip->wq);
993 return; 993 return;
994 } 994 }
995 spin_unlock(&shared->lock); 995 mutex_unlock(&shared->lock);
996 } 996 }
997 997
998 switch(chip->oldstate) { 998 switch(chip->oldstate) {
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) {