Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: dmatest: Prevent to run on misconfigured channel

Andy reported that commit 6b41030fdc79 ("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: 6b41030fdc79 ("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>

authored by

Vladimir Murzin and committed by
Vinod Koul
ce65d55f f4d51dff

+21 -5
+21 -5
drivers/dma/dmatest.c
··· 129 129 * @nr_channels: number of channels under test 130 130 * @lock: access protection to the fields of this structure 131 131 * @did_init: module has been initialized completely 132 + * @last_error: test has faced configuration issues 132 133 */ 133 134 static struct dmatest_info { 134 135 /* Test parameters */ ··· 138 137 /* Internal state */ 139 138 struct list_head channels; 140 139 unsigned int nr_channels; 140 + int last_error; 141 141 struct mutex lock; 142 142 bool did_init; 143 143 } test_info = { ··· 1186 1184 return ret; 1187 1185 } else if (dmatest_run) { 1188 1186 if (!is_threaded_test_pending(info)) { 1189 - pr_info("No channels configured, continue with any\n"); 1190 - if (!is_threaded_test_run(info)) 1191 - stop_threaded_test(info); 1192 - add_threaded_test(info); 1187 + /* 1188 + * We have nothing to run. This can be due to: 1189 + */ 1190 + ret = info->last_error; 1191 + if (ret) { 1192 + /* 1) Misconfiguration */ 1193 + pr_err("Channel misconfigured, can't continue\n"); 1194 + mutex_unlock(&info->lock); 1195 + return ret; 1196 + } else { 1197 + /* 2) We rely on defaults */ 1198 + pr_info("No channels configured, continue with any\n"); 1199 + if (!is_threaded_test_run(info)) 1200 + stop_threaded_test(info); 1201 + add_threaded_test(info); 1202 + } 1193 1203 } 1194 1204 start_threaded_tests(info); 1195 1205 } else { ··· 1218 1204 struct dmatest_info *info = &test_info; 1219 1205 struct dmatest_chan *dtc; 1220 1206 char chan_reset_val[20]; 1221 - int ret = 0; 1207 + int ret; 1222 1208 1223 1209 mutex_lock(&info->lock); 1224 1210 ret = param_set_copystring(val, kp); ··· 1273 1259 goto add_chan_err; 1274 1260 } 1275 1261 1262 + info->last_error = ret; 1276 1263 mutex_unlock(&info->lock); 1277 1264 1278 1265 return ret; 1279 1266 1280 1267 add_chan_err: 1281 1268 param_set_copystring(chan_reset_val, kp); 1269 + info->last_error = ret; 1282 1270 mutex_unlock(&info->lock); 1283 1271 1284 1272 return ret;