Skip to content

Commit 7b61017

Browse files
committed
Revert "dmatest: append verify result to results"
This reverts commit d86b2f2. The kernel log buffer is sufficient for collecting test results. The current logging OOMs the machine on long running tests, and usually only the first error is relevant. It is better to stop on error and parse the kernel output. If output volume becomes an issue we can always investigate using trace messages. Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 0776ae7 commit 7b61017

File tree

2 files changed

+53
-133
lines changed

2 files changed

+53
-133
lines changed

Documentation/dmatest.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,5 @@ The message format is unified across the different types of errors. A number in
7676
the parens represents additional information, e.g. error code, error counter,
7777
or status.
7878

79-
Comparison between buffers is stored to the dedicated structure.
80-
81-
Note that the verify result is now accessible only via file 'results' in the
82-
debugfs.
79+
Note that the buffer comparison is done in the old way, i.e. data is not
80+
collected and just printed out.

drivers/dma/dmatest.c

Lines changed: 51 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,6 @@ enum dmatest_error_type {
9898
DMATEST_ET_DMA_ERROR,
9999
DMATEST_ET_DMA_IN_PROGRESS,
100100
DMATEST_ET_VERIFY,
101-
DMATEST_ET_VERIFY_BUF,
102-
};
103-
104-
struct dmatest_verify_buffer {
105-
unsigned int index;
106-
u8 expected;
107-
u8 actual;
108-
};
109-
110-
struct dmatest_verify_result {
111-
unsigned int error_count;
112-
struct dmatest_verify_buffer data[MAX_ERROR_COUNT];
113-
u8 pattern;
114-
bool is_srcbuf;
115101
};
116102

117103
struct dmatest_thread_result {
@@ -122,11 +108,10 @@ struct dmatest_thread_result {
122108
unsigned int len;
123109
enum dmatest_error_type type;
124110
union {
125-
unsigned long data;
126-
dma_cookie_t cookie;
127-
enum dma_status status;
128-
int error;
129-
struct dmatest_verify_result *vr;
111+
unsigned long data;
112+
dma_cookie_t cookie;
113+
enum dma_status status;
114+
int error;
130115
};
131116
};
132117

@@ -262,38 +247,56 @@ static void dmatest_init_dsts(u8 **bufs, unsigned int start, unsigned int len,
262247
}
263248
}
264249

265-
static unsigned int dmatest_verify(struct dmatest_verify_result *vr, u8 **bufs,
266-
unsigned int start, unsigned int end, unsigned int counter,
267-
u8 pattern, bool is_srcbuf)
250+
static void dmatest_mismatch(u8 actual, u8 pattern, unsigned int index,
251+
unsigned int counter, bool is_srcbuf)
252+
{
253+
u8 diff = actual ^ pattern;
254+
u8 expected = pattern | (~counter & PATTERN_COUNT_MASK);
255+
const char *thread_name = current->comm;
256+
257+
if (is_srcbuf)
258+
pr_warn("%s: srcbuf[0x%x] overwritten! Expected %02x, got %02x\n",
259+
thread_name, index, expected, actual);
260+
else if ((pattern & PATTERN_COPY)
261+
&& (diff & (PATTERN_COPY | PATTERN_OVERWRITE)))
262+
pr_warn("%s: dstbuf[0x%x] not copied! Expected %02x, got %02x\n",
263+
thread_name, index, expected, actual);
264+
else if (diff & PATTERN_SRC)
265+
pr_warn("%s: dstbuf[0x%x] was copied! Expected %02x, got %02x\n",
266+
thread_name, index, expected, actual);
267+
else
268+
pr_warn("%s: dstbuf[0x%x] mismatch! Expected %02x, got %02x\n",
269+
thread_name, index, expected, actual);
270+
}
271+
272+
static unsigned int dmatest_verify(u8 **bufs, unsigned int start,
273+
unsigned int end, unsigned int counter, u8 pattern,
274+
bool is_srcbuf)
268275
{
269276
unsigned int i;
270277
unsigned int error_count = 0;
271278
u8 actual;
272279
u8 expected;
273280
u8 *buf;
274281
unsigned int counter_orig = counter;
275-
struct dmatest_verify_buffer *vb;
276282

277283
for (; (buf = *bufs); bufs++) {
278284
counter = counter_orig;
279285
for (i = start; i < end; i++) {
280286
actual = buf[i];
281287
expected = pattern | (~counter & PATTERN_COUNT_MASK);
282288
if (actual != expected) {
283-
if (error_count < MAX_ERROR_COUNT && vr) {
284-
vb = &vr->data[error_count];
285-
vb->index = i;
286-
vb->expected = expected;
287-
vb->actual = actual;
288-
}
289+
if (error_count < MAX_ERROR_COUNT)
290+
dmatest_mismatch(actual, pattern, i,
291+
counter, is_srcbuf);
289292
error_count++;
290293
}
291294
counter++;
292295
}
293296
}
294297

295298
if (error_count > MAX_ERROR_COUNT)
296-
pr_warning("%s: %u errors suppressed\n",
299+
pr_warn("%s: %u errors suppressed\n",
297300
current->comm, error_count - MAX_ERROR_COUNT);
298301

299302
return error_count;
@@ -334,30 +337,6 @@ static unsigned int min_odd(unsigned int x, unsigned int y)
334337
return val % 2 ? val : val - 1;
335338
}
336339

337-
static char *verify_result_get_one(struct dmatest_verify_result *vr,
338-
unsigned int i)
339-
{
340-
struct dmatest_verify_buffer *vb = &vr->data[i];
341-
u8 diff = vb->actual ^ vr->pattern;
342-
static char buf[512];
343-
char *msg;
344-
345-
if (vr->is_srcbuf)
346-
msg = "srcbuf overwritten!";
347-
else if ((vr->pattern & PATTERN_COPY)
348-
&& (diff & (PATTERN_COPY | PATTERN_OVERWRITE)))
349-
msg = "dstbuf not copied!";
350-
else if (diff & PATTERN_SRC)
351-
msg = "dstbuf was copied!";
352-
else
353-
msg = "dstbuf mismatch!";
354-
355-
snprintf(buf, sizeof(buf) - 1, "%s [0x%x] Expected %02x, got %02x", msg,
356-
vb->index, vb->expected, vb->actual);
357-
358-
return buf;
359-
}
360-
361340
static char *thread_result_get(const char *name,
362341
struct dmatest_thread_result *tr)
363342
{
@@ -373,7 +352,6 @@ static char *thread_result_get(const char *name,
373352
[DMATEST_ET_DMA_IN_PROGRESS] =
374353
"got completion callback (DMA_IN_PROGRESS)",
375354
[DMATEST_ET_VERIFY] = "errors",
376-
[DMATEST_ET_VERIFY_BUF] = "verify errors",
377355
};
378356
static char buf[512];
379357

@@ -415,51 +393,6 @@ static int thread_result_add(struct dmatest_info *info,
415393
return 0;
416394
}
417395

418-
static unsigned int verify_result_add(struct dmatest_info *info,
419-
struct dmatest_result *r, unsigned int n,
420-
unsigned int src_off, unsigned int dst_off, unsigned int len,
421-
u8 **bufs, int whence, unsigned int counter, u8 pattern,
422-
bool is_srcbuf)
423-
{
424-
struct dmatest_verify_result *vr;
425-
unsigned int error_count;
426-
unsigned int buf_off = is_srcbuf ? src_off : dst_off;
427-
unsigned int start, end;
428-
429-
if (whence < 0) {
430-
start = 0;
431-
end = buf_off;
432-
} else if (whence > 0) {
433-
start = buf_off + len;
434-
end = info->params.buf_size;
435-
} else {
436-
start = buf_off;
437-
end = buf_off + len;
438-
}
439-
440-
vr = kmalloc(sizeof(*vr), GFP_KERNEL);
441-
if (!vr) {
442-
pr_warn("dmatest: No memory to store verify result\n");
443-
return dmatest_verify(NULL, bufs, start, end, counter, pattern,
444-
is_srcbuf);
445-
}
446-
447-
vr->pattern = pattern;
448-
vr->is_srcbuf = is_srcbuf;
449-
450-
error_count = dmatest_verify(vr, bufs, start, end, counter, pattern,
451-
is_srcbuf);
452-
if (error_count) {
453-
vr->error_count = error_count;
454-
thread_result_add(info, r, DMATEST_ET_VERIFY_BUF, n, src_off,
455-
dst_off, len, (unsigned long)vr);
456-
return error_count;
457-
}
458-
459-
kfree(vr);
460-
return 0;
461-
}
462-
463396
static void result_free(struct dmatest_info *info, const char *name)
464397
{
465398
struct dmatest_result *r, *_r;
@@ -472,8 +405,6 @@ static void result_free(struct dmatest_info *info, const char *name)
472405
continue;
473406

474407
list_for_each_entry_safe(tr, _tr, &r->results, node) {
475-
if (tr->type == DMATEST_ET_VERIFY_BUF)
476-
kfree(tr->vr);
477408
list_del(&tr->node);
478409
kfree(tr);
479410
}
@@ -755,26 +686,25 @@ static int dmatest_func(void *data)
755686
error_count = 0;
756687

757688
pr_debug("%s: verifying source buffer...\n", thread_name);
758-
error_count += verify_result_add(info, result, total_tests,
759-
src_off, dst_off, len, thread->srcs, -1,
689+
error_count += dmatest_verify(thread->srcs, 0, src_off,
760690
0, PATTERN_SRC, true);
761-
error_count += verify_result_add(info, result, total_tests,
762-
src_off, dst_off, len, thread->srcs, 0,
763-
src_off, PATTERN_SRC | PATTERN_COPY, true);
764-
error_count += verify_result_add(info, result, total_tests,
765-
src_off, dst_off, len, thread->srcs, 1,
766-
src_off + len, PATTERN_SRC, true);
767-
768-
pr_debug("%s: verifying dest buffer...\n", thread_name);
769-
error_count += verify_result_add(info, result, total_tests,
770-
src_off, dst_off, len, thread->dsts, -1,
691+
error_count += dmatest_verify(thread->srcs, src_off,
692+
src_off + len, src_off,
693+
PATTERN_SRC | PATTERN_COPY, true);
694+
error_count += dmatest_verify(thread->srcs, src_off + len,
695+
params->buf_size, src_off + len,
696+
PATTERN_SRC, true);
697+
698+
pr_debug("%s: verifying dest buffer...\n",
699+
thread->task->comm);
700+
error_count += dmatest_verify(thread->dsts, 0, dst_off,
771701
0, PATTERN_DST, false);
772-
error_count += verify_result_add(info, result, total_tests,
773-
src_off, dst_off, len, thread->dsts, 0,
774-
src_off, PATTERN_SRC | PATTERN_COPY, false);
775-
error_count += verify_result_add(info, result, total_tests,
776-
src_off, dst_off, len, thread->dsts, 1,
777-
dst_off + len, PATTERN_DST, false);
702+
error_count += dmatest_verify(thread->dsts, dst_off,
703+
dst_off + len, src_off,
704+
PATTERN_SRC | PATTERN_COPY, false);
705+
error_count += dmatest_verify(thread->dsts, dst_off + len,
706+
params->buf_size, dst_off + len,
707+
PATTERN_DST, false);
778708

779709
if (error_count) {
780710
thread_result_add(info, result, DMATEST_ET_VERIFY,
@@ -1099,20 +1029,12 @@ static int dtf_results_show(struct seq_file *sf, void *data)
10991029
struct dmatest_info *info = sf->private;
11001030
struct dmatest_result *result;
11011031
struct dmatest_thread_result *tr;
1102-
unsigned int i;
11031032

11041033
mutex_lock(&info->results_lock);
11051034
list_for_each_entry(result, &info->results, node) {
1106-
list_for_each_entry(tr, &result->results, node) {
1035+
list_for_each_entry(tr, &result->results, node)
11071036
seq_printf(sf, "%s\n",
11081037
thread_result_get(result->name, tr));
1109-
if (tr->type == DMATEST_ET_VERIFY_BUF) {
1110-
for (i = 0; i < tr->vr->error_count; i++) {
1111-
seq_printf(sf, "\t%s\n",
1112-
verify_result_get_one(tr->vr, i));
1113-
}
1114-
}
1115-
}
11161038
}
11171039

11181040
mutex_unlock(&info->results_lock);

0 commit comments

Comments
 (0)