Skip to contentSkip to conversation

mtd: ubi: Fix worker handling

PATCH New Heiko Schocher 1 participant 2 messages Feb 8, 2018 – Feb 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: ubi: Fix worker handling

From: Richard Weinberger <[email protected]>

Fixes a bug found on thuban boards, which were for 2 years in a long-term test with varying temperatures. They showed problems in u-boot when attaching the ubi partition:

U-Boot# run flash_self_test
Booting from nand
set A...
UBI: attaching mtd1 to ubi0
UBI: scanning is finished
data abort

pc : [<87f97c3c>]          lr : [<87f97c28>]

reloc pc : [<8012cc3c>] lr : [<8012cc28>]
sp : 85f686e8 ip : 00000020 fp : 000001f7
r10: 8605ce40 r9 : 85f68ef8 r8 : 0001f000
r7 : 00000001 r6 : 00000006 r5 : 0001f000 r4 : 85f6ecc0
r3 : 00000000 r2 : 44e35000 r1 : 87fcbcd4 r0 : 87fc755b
Flags: nZCv IRQs off FIQs on Mode SVC_32
Resetting CPU ...

Reason is, that accidentially the U-Boot implementation from __schedule_ubi_work() did not check the flag ubi->thread_enabled and started with wearleveling work, but ubi did not have setup all structures at this point and crashes.

Solve this problem by splitting work scheduling and processing.

---

 drivers/mtd/ubi/build.c | 10 +---------
 drivers/mtd/ubi/ubi.h   |  2 +-
 drivers/mtd/ubi/wl.c    | 53 +++++++++++++++++++++++++++++++++++--------------
 3 files changed, 40 insertions(+), 25 deletions(-)
drivers/mtd/ubi/build.c +1 -9
index baf4e2d25b..d81bd434ac 100644
@@ -1060,15 +1060,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 #ifndef __UBOOT__
 	wake_up_process(ubi->bgt_thread);
 #else
-	/*
-	 * U-Boot special: We have no bgt_thread in U-Boot!
-	 * So just call do_work() here directly.
-	 */
-	err = do_work(ubi);
-	if (err) {
-		ubi_err(ubi, "%s: work failed with error code %d",
-			ubi->bgt_name, err);
-	}
+	ubi_do_worker(ubi);
 #endif
 
 	spin_unlock(&ubi->wl_lock);
drivers/mtd/ubi/ubi.h +1 -1
index 540f721e1b..3337201fb0 100644
@@ -1119,6 +1119,6 @@ static inline int idx2vol_id(const struct ubi_device *ubi, int idx)
 }
 
 #ifdef __UBOOT__
-int do_work(struct ubi_device *ubi);
+void ubi_do_worker(struct ubi_device *ubi);
 #endif
 #endif /* !__UBI_UBI_H__ */
drivers/mtd/ubi/wl.c +38 -15

86 lines not on this page · raw message

Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/1 mtd: ubi: Fix worker handling

Hello Richard,

Am 08.02.2018 um 07:29 schrieb Heiko Schocher:

Quoted 29 lines

From: Richard Weinberger <[email protected]>

Fixes a bug found on thuban boards, which were for 2 years in a long-term test with varying temperatures. They showed problems in u-boot when attaching the ubi partition:

U-Boot# run flash_self_test
Booting from nand
set A...
UBI: attaching mtd1 to ubi0
UBI: scanning is finished
data abort

pc : [<87f97c3c>]          lr : [<87f97c28>]

reloc pc : [<8012cc3c>] lr : [<8012cc28>]
sp : 85f686e8 ip : 00000020 fp : 000001f7
r10: 8605ce40 r9 : 85f68ef8 r8 : 0001f000
r7 : 00000001 r6 : 00000006 r5 : 0001f000 r4 : 85f6ecc0
r3 : 00000000 r2 : 44e35000 r1 : 87fcbcd4 r0 : 87fc755b
Flags: nZCv IRQs off FIQs on Mode SVC_32
Resetting CPU ...

Reason is, that accidentially the U-Boot implementation from __schedule_ubi_work() did not check the flag ubi->thread_enabled and started with wearleveling work, but ubi did not have setup all structures at this point and crashes.

Solve this problem by splitting work scheduling and processing.

Quoted 8 lines

---

  drivers/mtd/ubi/build.c | 10 +---------
  drivers/mtd/ubi/ubi.h   |  2 +-
  drivers/mtd/ubi/wl.c    | 53 +++++++++++++++++++++++++++++++++++--------------
  3 files changed, 40 insertions(+), 25 deletions(-)

Applied to u-boot-ubi master

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de