Skip to content

Commit ccc1d05

Browse files
committed
Merge tag 'dmaengine-fix-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fix from Vinod Koul: "Fix dmatest for misconfigured channel" * tag 'dmaengine-fix-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: dmaengine: dmatest: Prevent to run on misconfigured channel
2 parents 1ccfa66 + ce65d55 commit ccc1d05

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

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)