Skip to content

Commit a9e5549

Browse files
committed
dmatest: support xor-only, or pq-only channels in tests
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>
1 parent a310d03 commit a9e5549

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

drivers/dma/dmatest.c

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -734,31 +734,20 @@ static bool filter(struct dma_chan *chan, void *param)
734734
return true;
735735
}
736736

737-
static int run_threaded_test(struct dmatest_info *info)
737+
static void request_channels(struct dmatest_info *info,
738+
enum dma_transaction_type type)
738739
{
739740
dma_cap_mask_t mask;
740-
struct dma_chan *chan;
741-
struct dmatest_params *params = &info->params;
742-
int err = 0;
743-
744-
/* Copy test parameters */
745-
params->buf_size = test_buf_size;
746-
strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
747-
strlcpy(params->device, strim(test_device), sizeof(params->device));
748-
params->threads_per_chan = threads_per_chan;
749-
params->max_channels = max_channels;
750-
params->iterations = iterations;
751-
params->xor_sources = xor_sources;
752-
params->pq_sources = pq_sources;
753-
params->timeout = timeout;
754741

755742
dma_cap_zero(mask);
756-
dma_cap_set(DMA_MEMCPY, mask);
743+
dma_cap_set(type, mask);
757744
for (;;) {
745+
struct dmatest_params *params = &info->params;
746+
struct dma_chan *chan;
747+
758748
chan = dma_request_channel(mask, filter, params);
759749
if (chan) {
760-
err = dmatest_add_channel(info, chan);
761-
if (err) {
750+
if (dmatest_add_channel(info, chan)) {
762751
dma_release_channel(chan);
763752
break; /* add_channel failed, punt */
764753
}
@@ -768,9 +757,27 @@ static int run_threaded_test(struct dmatest_info *info)
768757
info->nr_channels >= params->max_channels)
769758
break; /* we have all we need */
770759
}
771-
return err;
772760
}
773761

762+
static void run_threaded_test(struct dmatest_info *info)
763+
{
764+
struct dmatest_params *params = &info->params;
765+
766+
/* Copy test parameters */
767+
params->buf_size = test_buf_size;
768+
strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
769+
strlcpy(params->device, strim(test_device), sizeof(params->device));
770+
params->threads_per_chan = threads_per_chan;
771+
params->max_channels = max_channels;
772+
params->iterations = iterations;
773+
params->xor_sources = xor_sources;
774+
params->pq_sources = pq_sources;
775+
params->timeout = timeout;
776+
777+
request_channels(info, DMA_MEMCPY);
778+
request_channels(info, DMA_XOR);
779+
request_channels(info, DMA_PQ);
780+
}
774781

775782
static void stop_threaded_test(struct dmatest_info *info)
776783
{
@@ -788,19 +795,19 @@ static void stop_threaded_test(struct dmatest_info *info)
788795
info->nr_channels = 0;
789796
}
790797

791-
static int restart_threaded_test(struct dmatest_info *info, bool run)
798+
static void restart_threaded_test(struct dmatest_info *info, bool run)
792799
{
793800
/* we might be called early to set run=, defer running until all
794801
* parameters have been evaluated
795802
*/
796803
if (!info->did_init)
797-
return 0;
804+
return;
798805

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

802809
/* Run test with new parameters */
803-
return run_threaded_test(info);
810+
run_threaded_test(info);
804811
}
805812

806813
static bool is_threaded_test_run(struct dmatest_info *info)
@@ -850,7 +857,7 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
850857
if (is_threaded_test_run(info))
851858
ret = -EBUSY;
852859
else if (dmatest_run)
853-
ret = restart_threaded_test(info, dmatest_run);
860+
restart_threaded_test(info, dmatest_run);
854861

855862
mutex_unlock(&info->lock);
856863

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

865871
if (dmatest_run) {
866872
mutex_lock(&info->lock);
867-
ret = run_threaded_test(info);
873+
run_threaded_test(info);
868874
mutex_unlock(&info->lock);
869875
}
870876

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

876-
return ret;
882+
return 0;
877883
}
878884
/* when compiled-in wait for drivers to load first */
879885
late_initcall(dmatest_init);

0 commit comments

Comments
 (0)