From patchwork Fri Dec 4 18:44:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 64938 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB4Ik8dt025654 for ; Fri, 4 Dec 2009 18:46:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756870AbZLDSoa (ORCPT ); Fri, 4 Dec 2009 13:44:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753071AbZLDSoa (ORCPT ); Fri, 4 Dec 2009 13:44:30 -0500 Received: from mail.gmx.net ([213.165.64.20]:60922 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755978AbZLDSo1 (ORCPT ); Fri, 4 Dec 2009 13:44:27 -0500 Received: (qmail invoked by alias); 04 Dec 2009 18:44:32 -0000 Received: from p57BD184F.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.24.79] by mail.gmx.net (mp023) with SMTP; 04 Dec 2009 19:44:32 +0100 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX19Jo24ir4VJm8YMNWC8z4lCAKi+7WCFKZzcTx64KZ tzJ2oBSnwIRaKD Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1NGd96-0002O3-FI; Fri, 04 Dec 2009 19:44:48 +0100 Date: Fri, 4 Dec 2009 19:44:48 +0100 (CET) From: Guennadi Liakhovetski To: linux-kernel@vger.kernel.org cc: Dan Williams , linux-sh@vger.kernel.org Subject: [PATCH 2/5] dmaengine: fix dmatest to verify minimum transfer length and test buffer size In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5600000000000001 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index a32a4cf..8b90516 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -298,10 +298,6 @@ static int dmatest_func(void *data) total_tests++; - len = dmatest_random() % test_buf_size + 1; - src_off = dmatest_random() % (test_buf_size - len + 1); - dst_off = dmatest_random() % (test_buf_size - len + 1); - /* honor alignment restrictions */ if (thread->type == DMA_MEMCPY) align = dev->copy_align; @@ -310,7 +306,19 @@ static int dmatest_func(void *data) else if (thread->type == DMA_PQ) align = dev->pq_align; + if (1 << align > test_buf_size) { + pr_err("%u-byte buffer too small for %d-byte alignment\n", + test_buf_size, 1 << align); + break; + } + + len = dmatest_random() % test_buf_size + 1; len = (len >> align) << align; + if (!len) + len = 1 << align; + src_off = dmatest_random() % (test_buf_size - len + 1); + dst_off = dmatest_random() % (test_buf_size - len + 1); + src_off = (src_off >> align) << align; dst_off = (dst_off >> align) << align;