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

Commit 37b789fd authored by Lee Susman's avatar Lee Susman Committed by Matt Wagantall
Browse files

scsi: ufs: fix's to ufs_lun_depth unit test



This patch fixes the ufs unit test case "lun_depth" to work properly.
In cases where nutrs == lun_qdepth, 0 was an argument for the random
number generating function, which returned bogus numbers as a result.
In this patch we distinguish between equality and inequality cases, where
in the equality case we remove the irrelevant test cases.

Change-Id: Id7967e894e9d4d0fa1e250852895debcefcbf818
Signed-off-by: default avatarLee Susman <lsusman@codeaurora.org>
parent 32dd7793
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -653,7 +653,8 @@ static void ufs_test_run_scenario(void *data, async_cookie_t cookie)
		 * We want to run the queue every run_q requests, or,
		 * when the requests pool is exhausted
		 */
		if (ts->td->test_count >= QUEUE_MAX_REQUESTS ||

		if (ts->td->dispatched_count >= QUEUE_MAX_REQUESTS ||
				(ts->run_q && !(i % ts->run_q)))
			blk_run_queue(ts->td->req_q);
	}
@@ -748,15 +749,12 @@ static int ufs_test_run_lun_depth_test(struct test_data *td)
	struct scsi_device *sdev;
	bool changed_seed = false;
	int i = 0, num_req[LUN_DEPTH_TEST_SIZE];
	int lun_qdepth, nutrs;
	int lun_qdepth, nutrs, num_scenarios;

	BUG_ON(!td || !td->req_q || !td->req_q->queuedata);
	sdev = (struct scsi_device *)td->req_q->queuedata;
	lun_qdepth = sdev->max_queue_depth;
	nutrs = sdev->host->can_queue;
	/* in case there is no specific queue size per LU */
	if (lun_qdepth == nutrs)
		lun_qdepth = lun_qdepth >> 2;

	/* allow randomness even if user forgot */
	if (utd->random_test_seed <= 0) {
@@ -770,22 +768,29 @@ static int ufs_test_run_lun_depth_test(struct test_data *td)
	num_req[i++] = lun_qdepth - 1;
	num_req[i++] = lun_qdepth;
	num_req[i++] = lun_qdepth + 1;
	/* if (nutrs-lun_qdepth-2 <= 0), do not run this scenario */
	if (nutrs - lun_qdepth - 2 > 0)
		num_req[i++] = lun_qdepth + 1 + ufs_test_pseudo_random_seed(
			&utd->random_test_seed, 1, nutrs - lun_qdepth - 2);

	/* if nutrs == lun_qdepth, do not run these three scenarios */
	if (nutrs != lun_qdepth) {
		num_req[i++] = nutrs - 1;
		num_req[i++] = nutrs;
		num_req[i++] = nutrs + 1;
	}

	/* a random number up to 10, not to cause overflow or timeout */
	num_req[i++] = nutrs + 1 + ufs_test_pseudo_random_seed(
			&utd->random_test_seed, 1, 10);


	num_scenarios = i;
	utd->test_stage = UFS_TEST_LUN_DEPTH_TEST_RUNNING;
	utd->fail_threads = 0;
	read_data = get_scenario(td, SCEN_RANDOM_READ_32_NO_FLUSH);
	write_data = get_scenario(td, SCEN_RANDOM_READ_32_NO_FLUSH);
	write_data = get_scenario(td, SCEN_RANDOM_WRITE_32_NO_FLUSH);

	for (i = 0; i < LUN_DEPTH_TEST_SIZE; i++) {
	for (i = 0; i < num_scenarios; i++) {
		int reqs = num_req[i];

		read_data->total_req = reqs;