Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a6a28e7 authored by Richard Weinberger's avatar Richard Weinberger Committed by Brian Norris
Browse files

mtd: Make MTD tests cancelable



I always go nuts when I start an MTD test on a slow device and have to
wait forever until it finishes. From the debug output I already know
what the issue is but I have to wait or reset the board hard. Resetting
is often not an option (remote access, you don't want lose the current
state, etc...).

The solution is easy, check for pending signals at key positions in the
code. Using that one can even stop a test by pressing CTRL-C as
insmod/modprobe have SIGINT pending.

Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent d2b51c80
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@
#include <linux/slab.h>
#include <linux/mtd/nand_ecc.h>

#include "mtd_test.h"

/*
 * Test the implementation for software ECC
 *
@@ -274,6 +276,10 @@ static int nand_ecc_test_run(const size_t size)
		}
		pr_info("ok - %s-%zd\n",
			nand_ecc_test[i].name, size);

		err = mtdtest_relax();
		if (err)
			break;
	}
error:
	kfree(error_data);
+12 −0
Original line number Diff line number Diff line
#include <linux/mtd/mtd.h>
#include <linux/sched.h>

static inline int mtdtest_relax(void)
{
	cond_resched();
	if (signal_pending(current)) {
		pr_info("aborting test due to pending signal!\n");
		return -EINTR;
	}

	return 0;
}

int mtdtest_erase_eraseblock(struct mtd_info *mtd, unsigned int ebnum);
int mtdtest_scan_for_bad_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
+4 −0
Original line number Diff line number Diff line
@@ -320,6 +320,10 @@ static int overwrite_test(void)
			break;
		}

		err = mtdtest_relax();
		if (err)
			break;

		opno++;
	}

+21 −5
Original line number Diff line number Diff line
@@ -112,7 +112,10 @@ static int write_whole_device(void)
			return err;
		if (i % 256 == 0)
			pr_info("written up to eraseblock %u\n", i);
		cond_resched();

		err = mtdtest_relax();
		if (err)
			return err;
	}
	pr_info("written %u eraseblocks\n", i);
	return 0;
@@ -318,7 +321,10 @@ static int verify_all_eraseblocks(void)
			return err;
		if (i % 256 == 0)
			pr_info("verified up to eraseblock %u\n", i);
		cond_resched();

		err = mtdtest_relax();
		if (err)
			return err;
	}
	pr_info("verified %u eraseblocks\n", i);
	return 0;
@@ -429,7 +435,10 @@ static int __init mtd_oobtest_init(void)
			goto out;
		if (i % 256 == 0)
			pr_info("verified up to eraseblock %u\n", i);
		cond_resched();

		err = mtdtest_relax();
		if (err)
			goto out;
	}
	pr_info("verified %u eraseblocks\n", i);

@@ -642,7 +651,11 @@ static int __init mtd_oobtest_init(void)
				goto out;
			if (i % 256 == 0)
				pr_info("written up to eraseblock %u\n", i);
			cond_resched();

			err = mtdtest_relax();
			if (err)
				goto out;

			addr += mtd->writesize;
		}
	}
@@ -680,7 +693,10 @@ static int __init mtd_oobtest_init(void)
		}
		if (i % 256 == 0)
			pr_info("verified up to eraseblock %u\n", i);
		cond_resched();

		err = mtdtest_relax();
		if (err)
			goto out;
	}
	pr_info("verified %u eraseblocks\n", i);

+8 −2
Original line number Diff line number Diff line
@@ -407,7 +407,10 @@ static int __init mtd_pagetest_init(void)
			goto out;
		if (i % 256 == 0)
			pr_info("written up to eraseblock %u\n", i);
		cond_resched();

		err = mtdtest_relax();
		if (err)
			goto out;
	}
	pr_info("written %u eraseblocks\n", i);

@@ -422,7 +425,10 @@ static int __init mtd_pagetest_init(void)
			goto out;
		if (i % 256 == 0)
			pr_info("verified up to eraseblock %u\n", i);
		cond_resched();

		err = mtdtest_relax();
		if (err)
			goto out;
	}
	pr_info("verified %u eraseblocks\n", i);

Loading