Skip to content

Commit

Permalink
dmatest: support xor-only, or pq-only channels in tests
Browse files Browse the repository at this point in the history
Currently we only test raid channels that happen to also have 'copy'
capability.  Search for capable channels that do not have DMA_MEMCPY.

Note the return value from run_threaded_test never really made sense
because it could return errors after successfully starting tests.  We
already have the test results per channel so missing channels can be
detected at that time.

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Dan Williams committed Nov 14, 2013
1 parent a310d03 commit a9e5549
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,31 +734,20 @@ static bool filter(struct dma_chan *chan, void *param)
return true;
}

static int run_threaded_test(struct dmatest_info *info)
static void request_channels(struct dmatest_info *info,
enum dma_transaction_type type)
{
dma_cap_mask_t mask;
struct dma_chan *chan;
struct dmatest_params *params = &info->params;
int err = 0;

/* Copy test parameters */
params->buf_size = test_buf_size;
strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
strlcpy(params->device, strim(test_device), sizeof(params->device));
params->threads_per_chan = threads_per_chan;
params->max_channels = max_channels;
params->iterations = iterations;
params->xor_sources = xor_sources;
params->pq_sources = pq_sources;
params->timeout = timeout;

dma_cap_zero(mask);
dma_cap_set(DMA_MEMCPY, mask);
dma_cap_set(type, mask);
for (;;) {
struct dmatest_params *params = &info->params;
struct dma_chan *chan;

chan = dma_request_channel(mask, filter, params);
if (chan) {
err = dmatest_add_channel(info, chan);
if (err) {
if (dmatest_add_channel(info, chan)) {
dma_release_channel(chan);
break; /* add_channel failed, punt */
}
Expand All @@ -768,9 +757,27 @@ static int run_threaded_test(struct dmatest_info *info)
info->nr_channels >= params->max_channels)
break; /* we have all we need */
}
return err;
}

static void run_threaded_test(struct dmatest_info *info)
{
struct dmatest_params *params = &info->params;

/* Copy test parameters */
params->buf_size = test_buf_size;
strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
strlcpy(params->device, strim(test_device), sizeof(params->device));
params->threads_per_chan = threads_per_chan;
params->max_channels = max_channels;
params->iterations = iterations;
params->xor_sources = xor_sources;
params->pq_sources = pq_sources;
params->timeout = timeout;

request_channels(info, DMA_MEMCPY);
request_channels(info, DMA_XOR);
request_channels(info, DMA_PQ);
}

static void stop_threaded_test(struct dmatest_info *info)
{
Expand All @@ -788,19 +795,19 @@ static void stop_threaded_test(struct dmatest_info *info)
info->nr_channels = 0;
}

static int restart_threaded_test(struct dmatest_info *info, bool run)
static void restart_threaded_test(struct dmatest_info *info, bool run)
{
/* we might be called early to set run=, defer running until all
* parameters have been evaluated
*/
if (!info->did_init)
return 0;
return;

/* Stop any running test first */
stop_threaded_test(info);

/* Run test with new parameters */
return run_threaded_test(info);
run_threaded_test(info);
}

static bool is_threaded_test_run(struct dmatest_info *info)
Expand Down Expand Up @@ -850,7 +857,7 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
if (is_threaded_test_run(info))
ret = -EBUSY;
else if (dmatest_run)
ret = restart_threaded_test(info, dmatest_run);
restart_threaded_test(info, dmatest_run);

mutex_unlock(&info->lock);

Expand All @@ -860,11 +867,10 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
static int __init dmatest_init(void)
{
struct dmatest_info *info = &test_info;
int ret = 0;

if (dmatest_run) {
mutex_lock(&info->lock);
ret = run_threaded_test(info);
run_threaded_test(info);
mutex_unlock(&info->lock);
}

Expand All @@ -873,7 +879,7 @@ static int __init dmatest_init(void)
*/
info->did_init = true;

return ret;
return 0;
}
/* when compiled-in wait for drivers to load first */
late_initcall(dmatest_init);
Expand Down

0 comments on commit a9e5549

Please sign in to comment.