Skip to content

Commit ce65d55

Browse files
murzinvvinodkoul
authored andcommitted
dmaengine: dmatest: Prevent to run on misconfigured channel
Andy reported that commit 6b41030 ("dmaengine: dmatest: Restore default for channel") broke his scripts for the case where "busy" channel is used for configuration with expectation that run command would do nothing. Instead, behavior was (unintentionally) changed to treat such case as under-configuration and progress with defaults, i.e. run command would start a test with default setting for channel (which would use all channels). Restore original behavior with tracking status of channel setter so we can distinguish between misconfigured and under-configured cases in run command and act accordingly. Fixes: 6b41030 ("dmaengine: dmatest: Restore default for channel") Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com> Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200922115847.30100-1-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent f4d51df commit ce65d55

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

drivers/dma/dmatest.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct dmatest_params {
129129
* @nr_channels: number of channels under test
130130
* @lock: access protection to the fields of this structure
131131
* @did_init: module has been initialized completely
132+
* @last_error: test has faced configuration issues
132133
*/
133134
static struct dmatest_info {
134135
/* Test parameters */
@@ -137,6 +138,7 @@ static struct dmatest_info {
137138
/* Internal state */
138139
struct list_head channels;
139140
unsigned int nr_channels;
141+
int last_error;
140142
struct mutex lock;
141143
bool did_init;
142144
} test_info = {
@@ -1184,10 +1186,22 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
11841186
return ret;
11851187
} else if (dmatest_run) {
11861188
if (!is_threaded_test_pending(info)) {
1187-
pr_info("No channels configured, continue with any\n");
1188-
if (!is_threaded_test_run(info))
1189-
stop_threaded_test(info);
1190-
add_threaded_test(info);
1189+
/*
1190+
* We have nothing to run. This can be due to:
1191+
*/
1192+
ret = info->last_error;
1193+
if (ret) {
1194+
/* 1) Misconfiguration */
1195+
pr_err("Channel misconfigured, can't continue\n");
1196+
mutex_unlock(&info->lock);
1197+
return ret;
1198+
} else {
1199+
/* 2) We rely on defaults */
1200+
pr_info("No channels configured, continue with any\n");
1201+
if (!is_threaded_test_run(info))
1202+
stop_threaded_test(info);
1203+
add_threaded_test(info);
1204+
}
11911205
}
11921206
start_threaded_tests(info);
11931207
} else {
@@ -1204,7 +1218,7 @@ static int dmatest_chan_set(const char *val, const struct kernel_param *kp)
12041218
struct dmatest_info *info = &test_info;
12051219
struct dmatest_chan *dtc;
12061220
char chan_reset_val[20];
1207-
int ret = 0;
1221+
int ret;
12081222

12091223
mutex_lock(&info->lock);
12101224
ret = param_set_copystring(val, kp);
@@ -1259,12 +1273,14 @@ static int dmatest_chan_set(const char *val, const struct kernel_param *kp)
12591273
goto add_chan_err;
12601274
}
12611275

1276+
info->last_error = ret;
12621277
mutex_unlock(&info->lock);
12631278

12641279
return ret;
12651280

12661281
add_chan_err:
12671282
param_set_copystring(chan_reset_val, kp);
1283+
info->last_error = ret;
12681284
mutex_unlock(&info->lock);
12691285

12701286
return ret;

0 commit comments

Comments
 (0)