From patchwork Tue Feb 12 15:11:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10808101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDE7713A4 for ; Tue, 12 Feb 2019 15:11:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB7A32BC5B for ; Tue, 12 Feb 2019 15:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8FAB2BC90; Tue, 12 Feb 2019 15:11:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C07742BC7A for ; Tue, 12 Feb 2019 15:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729789AbfBLPLu (ORCPT ); Tue, 12 Feb 2019 10:11:50 -0500 Received: from mail-eopbgr770070.outbound.protection.outlook.com ([40.107.77.70]:8416 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726550AbfBLPLs (ORCPT ); Tue, 12 Feb 2019 10:11:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w9z9RD2WYeGZJB/54fUqrvNBL41Dz/XdVEXmMHeTAt8=; b=GBbybpFsgjzd8UoJT308B4lJ4sRTh+N4JH/fPm0OBB+EKUtGZ558Q2dMAJa2iysUiHLXh2pIqYnJg84jbRXsbQ95ly/unlYyV/o9hoNV8q4OeP4zJNVE566+U2Wa8/dNZCK1s3gQFr4Wee3QVvvczB+UA1EM3F9IlVXu9i7X7ik= Received: from DM6PR03CA0055.namprd03.prod.outlook.com (2603:10b6:5:100::32) by CY4PR03MB3063.namprd03.prod.outlook.com (2603:10b6:910:53::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.24; Tue, 12 Feb 2019 15:11:45 +0000 Received: from CY1NAM02FT015.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::203) by DM6PR03CA0055.outlook.office365.com (2603:10b6:5:100::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1601.19 via Frontend Transport; Tue, 12 Feb 2019 15:11:45 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by CY1NAM02FT015.mail.protection.outlook.com (10.152.75.146) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.10 via Frontend Transport; Tue, 12 Feb 2019 15:11:44 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1CFBh1d024174 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 12 Feb 2019 07:11:44 -0800 Received: from saturn.analog.com (10.50.1.244) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 12 Feb 2019 10:11:43 -0500 From: Alexandru Ardelean To: , CC: Alexandru Ardelean Subject: [V2 PATCH 1/3] dmaengine: dmatest: wrap src & dst data into a struct Date: Tue, 12 Feb 2019 17:11:37 +0200 Message-ID: <20190212151139.20613-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(39860400002)(346002)(136003)(2980300002)(199004)(189003)(54534003)(336012)(2906002)(77096007)(44832011)(14444005)(30864003)(126002)(476003)(426003)(2616005)(486006)(26005)(50466002)(6666004)(51416003)(186003)(478600001)(36756003)(48376002)(86362001)(7696005)(356004)(50226002)(53416004)(106002)(316002)(8676002)(110136005)(8936002)(47776003)(106466001)(7636002)(4326008)(16586007)(305945005)(1076003)(107886003)(246002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB3063;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT015;1:be/9eI1/Ui7e4jsgpyxzFNc93PkbCdX7enMTDYhOjLmYnEmztymEClmampFeBTY+yigvjUx0xap89Z4O2ZOJIQjlHJCPMd+07xFLg4h5Gyf0nqxBoHsTdyCDCijD7T1OzJ5sP84RJgFvJlrzNFcAAg== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ce9b4bf-f5f6-41ed-570c-08d690fc66bb X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4608076)(4709027)(2017052603328)(7153060);SRVR:CY4PR03MB3063; X-MS-TrafficTypeDiagnostic: CY4PR03MB3063: X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB3063;20:goRtxgmXHJTJ1k97RJEWH7/hWr/79kUJE4z29uabj4OYzyKxlV72WJUe158bHk9yywwGp/eXO0z5lvwDTpsarjlPxiAGa4ylueSMmwY3EisnqT/zFwsxPT10M2yu+LX6BKL2O2pDB36DrlHXcQY28jgSg3PQA4puop0SehlqcSrUqi7GV/x2TrjA2kvW5cni6Eq/lmyTrz3m7sy27sodeGTpDuw4RzNa8XdNUDPTNyYRpPA8JXwVmT5OzUrhRfDDxMwbirmdSKwyP+Vg5bbUaVz2u8OOFXASRl9/18QIO2O8RzFc8eZfJAJd7I0u0rADNe9+3a1fHy75qR207R3441TS13HnQbuLefa4Ra5LnERChoXm5+aFqsE1KI27PMi1ybFTFxCIShN0XNdcVbo7eyz2yl9lm2ogvH0IF+VzihNrd2a4blK7kozsWKOx4EQfLkobSKGZeL+aYlZcbmY/ttgDofO3pLqYRt/8kasm1vSPdpwEnxJkOC+I6958D1Mp X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0946DC87A1 X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB3063;23:HTifyAOHxE2xn977RF1QUIVRqtoL4QWMxdrNo4d8sSt2E6yM6DAnm30yqInmP2phpEU0BR97VrWY3nZkt36QLVqMSt9yTaXqhT7OlSW+MUzij5e9q0E3ULhPN8unxpSLXjj7GTT2dYckNnxO6NcslZHGObIeocVX7joV5ekcmlVqnoMNyzA1YpGIWVFk1b/ejChcQUa62Tlqlf8Mj6I1tBwG5YjwBbSstsE2APX4Ei0m6kEJJBq5Lt3pIYn7E9r4tIjVu33+z3Nlw+OY7G2zHBlOSXCLdsyBuE/Pl010um/g8VqMr1YIKBUKAqwMb9dSoVvpVhiYJ4LnhMbcumKx7o/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WyoIJ7guat8qzLaeFeDATVeb4gC6VoX3GrHOxHbotgb+eKXbEpaW86VmNJ6J52EjfgHtKFoYRvHxxlrSDWjVAQc/7Ift2QOZ5oIM= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2019 15:11:44.6343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ce9b4bf-f5f6-41ed-570c-08d690fc66bb X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3063 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change wraps the data for the source & destination buffers into a `struct dmatest_data`. The rename patterns are: * src_cnt -> src->cnt * dst_cnt -> dst->cnt * src_off -> src->off * dst_off -> dst->off * thread->srcs -> src->aligned * thread->usrcs -> src->raw * thread->dsts -> dst->aligned * thread->udsts -> dst->raw The intent is to make a function that moves duplicate parts of the code into common alloc & free functions, which will unclutter the `dmatest_func()` function. Signed-off-by: Alexandru Ardelean --- Changelog v1 -> v2: * split original `[PATCH] dmaengine: dmatest: wrap src & dst data into a struct` into 3 smaller patches drivers/dma/dmatest.c | 195 ++++++++++++++++++++++-------------------- 1 file changed, 101 insertions(+), 94 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 2eea4ef72915..ea1f885e70f4 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -200,15 +200,20 @@ struct dmatest_done { wait_queue_head_t *wait; }; +struct dmatest_data { + u8 **raw; + u8 **aligned; + unsigned int cnt; + unsigned int off; +}; + struct dmatest_thread { struct list_head node; struct dmatest_info *info; struct task_struct *task; struct dma_chan *chan; - u8 **srcs; - u8 **usrcs; - u8 **dsts; - u8 **udsts; + struct dmatest_data src; + struct dmatest_data dst; enum dma_transaction_type type; wait_queue_head_t done_wait; struct dmatest_done test_done; @@ -511,8 +516,8 @@ static int dmatest_func(void *data) enum dma_ctrl_flags flags; u8 *pq_coefs = NULL; int ret; - int src_cnt; - int dst_cnt; + struct dmatest_data *src; + struct dmatest_data *dst; int i; ktime_t ktime, start, diff; ktime_t filltime = 0; @@ -535,25 +540,27 @@ static int dmatest_func(void *data) params = &info->params; chan = thread->chan; dev = chan->device; + src = &thread->src; + dst = &thread->dst; if (thread->type == DMA_MEMCPY) { align = params->alignment < 0 ? dev->copy_align : params->alignment; - src_cnt = dst_cnt = 1; + src->cnt = dst->cnt = 1; } else if (thread->type == DMA_MEMSET) { align = params->alignment < 0 ? dev->fill_align : params->alignment; - src_cnt = dst_cnt = 1; + src->cnt = dst->cnt = 1; is_memset = true; } else if (thread->type == DMA_XOR) { /* force odd to ensure dst = src */ - src_cnt = min_odd(params->xor_sources | 1, dev->max_xor); - dst_cnt = 1; + src->cnt = min_odd(params->xor_sources | 1, dev->max_xor); + dst->cnt = 1; align = params->alignment < 0 ? dev->xor_align : params->alignment; } else if (thread->type == DMA_PQ) { /* force odd to ensure dst = src */ - src_cnt = min_odd(params->pq_sources | 1, dma_maxpq(dev, 0)); - dst_cnt = 2; + src->cnt = min_odd(params->pq_sources | 1, dma_maxpq(dev, 0)); + dst->cnt = 2; align = params->alignment < 0 ? dev->pq_align : params->alignment; @@ -561,15 +568,15 @@ static int dmatest_func(void *data) if (!pq_coefs) goto err_thread_type; - for (i = 0; i < src_cnt; i++) + for (i = 0; i < src->cnt; i++) pq_coefs[i] = 1; } else goto err_thread_type; /* Check if buffer count fits into map count variable (u8) */ - if ((src_cnt + dst_cnt) >= 255) { + if ((src->cnt + dst->cnt) >= 255) { pr_err("too many buffers (%d of 255 supported)\n", - src_cnt + dst_cnt); + src->cnt + dst->cnt); goto err_free_coefs; } @@ -579,57 +586,57 @@ static int dmatest_func(void *data) goto err_free_coefs; } - thread->srcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!thread->srcs) + src->aligned = kcalloc(src->cnt + 1, sizeof(u8 *), GFP_KERNEL); + if (!src->aligned) goto err_free_coefs; - thread->usrcs = kcalloc(src_cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!thread->usrcs) + src->raw = kcalloc(src->cnt + 1, sizeof(u8 *), GFP_KERNEL); + if (!src->raw) goto err_usrcs; - for (i = 0; i < src_cnt; i++) { - thread->usrcs[i] = kmalloc(params->buf_size + align, + for (i = 0; i < src->cnt; i++) { + src->raw[i] = kmalloc(params->buf_size + align, GFP_KERNEL); - if (!thread->usrcs[i]) + if (!src->raw[i]) goto err_srcbuf; /* align srcs to alignment restriction */ if (align) - thread->srcs[i] = PTR_ALIGN(thread->usrcs[i], align); + src->aligned[i] = PTR_ALIGN(src->raw[i], align); else - thread->srcs[i] = thread->usrcs[i]; + src->aligned[i] = src->raw[i]; } - thread->srcs[i] = NULL; + src->aligned[i] = NULL; - thread->dsts = kcalloc(dst_cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!thread->dsts) + dst->aligned = kcalloc(dst->cnt + 1, sizeof(u8 *), GFP_KERNEL); + if (!dst->aligned) goto err_dsts; - thread->udsts = kcalloc(dst_cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!thread->udsts) + dst->raw = kcalloc(dst->cnt + 1, sizeof(u8 *), GFP_KERNEL); + if (!dst->raw) goto err_udsts; - for (i = 0; i < dst_cnt; i++) { - thread->udsts[i] = kmalloc(params->buf_size + align, + for (i = 0; i < dst->cnt; i++) { + dst->raw[i] = kmalloc(params->buf_size + align, GFP_KERNEL); - if (!thread->udsts[i]) + if (!dst->raw[i]) goto err_dstbuf; /* align dsts to alignment restriction */ if (align) - thread->dsts[i] = PTR_ALIGN(thread->udsts[i], align); + dst->aligned[i] = PTR_ALIGN(dst->raw[i], align); else - thread->dsts[i] = thread->udsts[i]; + dst->aligned[i] = dst->raw[i]; } - thread->dsts[i] = NULL; + dst->aligned[i] = NULL; set_user_nice(current, 10); - srcs = kcalloc(src_cnt, sizeof(dma_addr_t), GFP_KERNEL); + srcs = kcalloc(src->cnt, sizeof(dma_addr_t), GFP_KERNEL); if (!srcs) goto err_dstbuf; - dma_pq = kcalloc(dst_cnt, sizeof(dma_addr_t), GFP_KERNEL); + dma_pq = kcalloc(dst->cnt, sizeof(dma_addr_t), GFP_KERNEL); if (!dma_pq) goto err_srcs_array; @@ -644,7 +651,7 @@ static int dmatest_func(void *data) struct dma_async_tx_descriptor *tx = NULL; struct dmaengine_unmap_data *um; dma_addr_t *dsts; - unsigned int src_off, dst_off, len; + unsigned int len; total_tests++; @@ -670,59 +677,59 @@ static int dmatest_func(void *data) total_len += len; if (params->norandom) { - src_off = 0; - dst_off = 0; + src->off = 0; + dst->off = 0; } else { - src_off = dmatest_random() % (params->buf_size - len + 1); - dst_off = dmatest_random() % (params->buf_size - len + 1); + src->off = dmatest_random() % (params->buf_size - len + 1); + dst->off = dmatest_random() % (params->buf_size - len + 1); - src_off = (src_off >> align) << align; - dst_off = (dst_off >> align) << align; + src->off = (src->off >> align) << align; + dst->off = (dst->off >> align) << align; } if (!params->noverify) { start = ktime_get(); - dmatest_init_srcs(thread->srcs, src_off, len, + dmatest_init_srcs(src->aligned, src->off, len, params->buf_size, is_memset); - dmatest_init_dsts(thread->dsts, dst_off, len, + dmatest_init_dsts(dst->aligned, dst->off, len, params->buf_size, is_memset); diff = ktime_sub(ktime_get(), start); filltime = ktime_add(filltime, diff); } - um = dmaengine_get_unmap_data(dev->dev, src_cnt + dst_cnt, + um = dmaengine_get_unmap_data(dev->dev, src->cnt + dst->cnt, GFP_KERNEL); if (!um) { failed_tests++; result("unmap data NULL", total_tests, - src_off, dst_off, len, ret); + src->off, dst->off, len, ret); continue; } um->len = params->buf_size; - for (i = 0; i < src_cnt; i++) { - void *buf = thread->srcs[i]; + for (i = 0; i < src->cnt; i++) { + void *buf = src->aligned[i]; struct page *pg = virt_to_page(buf); unsigned long pg_off = offset_in_page(buf); um->addr[i] = dma_map_page(dev->dev, pg, pg_off, um->len, DMA_TO_DEVICE); - srcs[i] = um->addr[i] + src_off; + srcs[i] = um->addr[i] + src->off; ret = dma_mapping_error(dev->dev, um->addr[i]); if (ret) { dmaengine_unmap_put(um); result("src mapping error", total_tests, - src_off, dst_off, len, ret); + src->off, dst->off, len, ret); failed_tests++; continue; } um->to_cnt++; } /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ - dsts = &um->addr[src_cnt]; - for (i = 0; i < dst_cnt; i++) { - void *buf = thread->dsts[i]; + dsts = &um->addr[src->cnt]; + for (i = 0; i < dst->cnt; i++) { + void *buf = dst->aligned[i]; struct page *pg = virt_to_page(buf); unsigned long pg_off = offset_in_page(buf); @@ -732,7 +739,7 @@ static int dmatest_func(void *data) if (ret) { dmaengine_unmap_put(um); result("dst mapping error", total_tests, - src_off, dst_off, len, ret); + src->off, dst->off, len, ret); failed_tests++; continue; } @@ -741,30 +748,30 @@ static int dmatest_func(void *data) if (thread->type == DMA_MEMCPY) tx = dev->device_prep_dma_memcpy(chan, - dsts[0] + dst_off, + dsts[0] + dst->off, srcs[0], len, flags); else if (thread->type == DMA_MEMSET) tx = dev->device_prep_dma_memset(chan, - dsts[0] + dst_off, - *(thread->srcs[0] + src_off), + dsts[0] + dst->off, + *(src->aligned[0] + src->off), len, flags); else if (thread->type == DMA_XOR) tx = dev->device_prep_dma_xor(chan, - dsts[0] + dst_off, - srcs, src_cnt, + dsts[0] + dst->off, + srcs, src->cnt, len, flags); else if (thread->type == DMA_PQ) { - for (i = 0; i < dst_cnt; i++) - dma_pq[i] = dsts[i] + dst_off; + for (i = 0; i < dst->cnt; i++) + dma_pq[i] = dsts[i] + dst->off; tx = dev->device_prep_dma_pq(chan, dma_pq, srcs, - src_cnt, pq_coefs, + src->cnt, pq_coefs, len, flags); } if (!tx) { dmaengine_unmap_put(um); - result("prep error", total_tests, src_off, - dst_off, len, ret); + result("prep error", total_tests, src->off, + dst->off, len, ret); msleep(100); failed_tests++; continue; @@ -777,8 +784,8 @@ static int dmatest_func(void *data) if (dma_submit_error(cookie)) { dmaengine_unmap_put(um); - result("submit error", total_tests, src_off, - dst_off, len, ret); + result("submit error", total_tests, src->off, + dst->off, len, ret); msleep(100); failed_tests++; continue; @@ -793,58 +800,58 @@ static int dmatest_func(void *data) dmaengine_unmap_put(um); if (!done->done) { - result("test timed out", total_tests, src_off, dst_off, + result("test timed out", total_tests, src->off, dst->off, len, 0); failed_tests++; continue; } else if (status != DMA_COMPLETE) { result(status == DMA_ERROR ? "completion error status" : - "completion busy status", total_tests, src_off, - dst_off, len, ret); + "completion busy status", total_tests, src->off, + dst->off, len, ret); failed_tests++; continue; } if (params->noverify) { - verbose_result("test passed", total_tests, src_off, - dst_off, len, 0); + verbose_result("test passed", total_tests, src->off, + dst->off, len, 0); continue; } start = ktime_get(); pr_debug("%s: verifying source buffer...\n", current->comm); - error_count = dmatest_verify(thread->srcs, 0, src_off, + error_count = dmatest_verify(src->aligned, 0, src->off, 0, PATTERN_SRC, true, is_memset); - error_count += dmatest_verify(thread->srcs, src_off, - src_off + len, src_off, + error_count += dmatest_verify(src->aligned, src->off, + src->off + len, src->off, PATTERN_SRC | PATTERN_COPY, true, is_memset); - error_count += dmatest_verify(thread->srcs, src_off + len, - params->buf_size, src_off + len, + error_count += dmatest_verify(src->aligned, src->off + len, + params->buf_size, src->off + len, PATTERN_SRC, true, is_memset); pr_debug("%s: verifying dest buffer...\n", current->comm); - error_count += dmatest_verify(thread->dsts, 0, dst_off, + error_count += dmatest_verify(dst->aligned, 0, dst->off, 0, PATTERN_DST, false, is_memset); - error_count += dmatest_verify(thread->dsts, dst_off, - dst_off + len, src_off, + error_count += dmatest_verify(dst->aligned, dst->off, + dst->off + len, src->off, PATTERN_SRC | PATTERN_COPY, false, is_memset); - error_count += dmatest_verify(thread->dsts, dst_off + len, - params->buf_size, dst_off + len, + error_count += dmatest_verify(dst->aligned, dst->off + len, + params->buf_size, dst->off + len, PATTERN_DST, false, is_memset); diff = ktime_sub(ktime_get(), start); comparetime = ktime_add(comparetime, diff); if (error_count) { - result("data error", total_tests, src_off, dst_off, + result("data error", total_tests, src->off, dst->off, len, error_count); failed_tests++; } else { - verbose_result("test passed", total_tests, src_off, - dst_off, len, 0); + verbose_result("test passed", total_tests, src->off, + dst->off, len, 0); } } ktime = ktime_sub(ktime_get(), ktime); @@ -857,18 +864,18 @@ static int dmatest_func(void *data) err_srcs_array: kfree(srcs); err_dstbuf: - for (i = 0; thread->udsts[i]; i++) - kfree(thread->udsts[i]); - kfree(thread->udsts); + for (i = 0; dst->raw[i]; i++) + kfree(dst->raw[i]); + kfree(dst->raw); err_udsts: - kfree(thread->dsts); + kfree(dst->aligned); err_dsts: err_srcbuf: - for (i = 0; thread->usrcs[i]; i++) - kfree(thread->usrcs[i]); - kfree(thread->usrcs); + for (i = 0; src->raw[i]; i++) + kfree(src->raw[i]); + kfree(src->raw); err_usrcs: - kfree(thread->srcs); + kfree(src->aligned); err_free_coefs: kfree(pq_coefs); err_thread_type: From patchwork Tue Feb 12 15:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10808107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8363C13A4 for ; Tue, 12 Feb 2019 15:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73CB12BB75 for ; Tue, 12 Feb 2019 15:11:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 682A72BC71; Tue, 12 Feb 2019 15:11:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC122BC8E for ; Tue, 12 Feb 2019 15:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729636AbfBLPL6 (ORCPT ); Tue, 12 Feb 2019 10:11:58 -0500 Received: from mail-eopbgr780087.outbound.protection.outlook.com ([40.107.78.87]:42416 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728165AbfBLPL6 (ORCPT ); Tue, 12 Feb 2019 10:11:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ax05oCin/s3KbSWIj2mmPZSsxdlQxKQDMF5WA5vrkac=; b=rPIkICi3zoMkyJUPyjCXPxKthBDdbUyeBFhgQtLWLGPIH2+/51ARcZjikQZhPiivUp4VKEP4JxFK5F3E3Ue7fnHp90J2baCxVAkq2k/KiG/isV65cn8kdAtuF0yYr5j2pN3hqsax7+Uuy7LUTMoojNQq15yQy0oASgmHWH6w4BQ= Received: from BN8PR03CA0026.namprd03.prod.outlook.com (2603:10b6:408:94::39) by SN6PR03MB3758.namprd03.prod.outlook.com (2603:10b6:805:69::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.19; Tue, 12 Feb 2019 15:11:54 +0000 Received: from SN1NAM02FT023.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::206) by BN8PR03CA0026.outlook.office365.com (2603:10b6:408:94::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1601.19 via Frontend Transport; Tue, 12 Feb 2019 15:11:54 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by SN1NAM02FT023.mail.protection.outlook.com (10.152.72.156) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.10 via Frontend Transport; Tue, 12 Feb 2019 15:11:50 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1CFBjjM024198 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 12 Feb 2019 07:11:45 -0800 Received: from saturn.analog.com (10.50.1.244) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 12 Feb 2019 10:11:44 -0500 From: Alexandru Ardelean To: , CC: Alexandru Ardelean Subject: [V2 PATCH 2/3] dmaengine: dmatest: add short-hand `buf_size` var in dmatest_func() Date: Tue, 12 Feb 2019 17:11:38 +0200 Message-ID: <20190212151139.20613-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212151139.20613-1-alexandru.ardelean@analog.com> References: <20190212151139.20613-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(346002)(376002)(39860400002)(136003)(2980300002)(199004)(189003)(36756003)(50226002)(50466002)(47776003)(106002)(336012)(44832011)(76176011)(110136005)(1076003)(316002)(48376002)(16586007)(126002)(476003)(2616005)(426003)(305945005)(86362001)(106466001)(246002)(7696005)(51416003)(7636002)(26005)(446003)(14444005)(186003)(107886003)(11346002)(4326008)(356004)(8936002)(478600001)(6666004)(486006)(77096007)(53416004)(2906002)(8676002)(81973001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR03MB3758;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM02FT023;1:cjMgnsjQPX01hspP0GwQh2xrCELIn7UcNqf9C7CrbbDGf0CuefeyQ92bUWpNsD/GfEYuv1mzNPu1lnaUpVtx859Z8N/aYyc7Tz9UXBImgw6zRSlng8W9jjRFZPJto4c3OIzj2h8o6DCoZdllYOB3ug== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73119c50-d2b2-4e2a-c69c-08d690fc6ad0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4608076)(4709027)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060);SRVR:SN6PR03MB3758; X-MS-TrafficTypeDiagnostic: SN6PR03MB3758: X-Microsoft-Exchange-Diagnostics: 1;SN6PR03MB3758;20:vBMryipl4cU/QR04+DLA1owZCq+mpqnyt0YInje6+I/dRva42SFbJq6X2YUQsVycSjnrE1fVIlw3YzLsqxEsvf2gEusplIQVYt99LWQlLWT5ANczRK5JahF2Z7AHqGqbaIekpVHBjn4m0ZoAHflbEOsuswa8K1jeqE5sf0e6GHaL3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oJT7biYc8aY3+TxmNHQ/uCDF1ItoqUA56MbraYppt54CP7hICrNDiZh69xMds7ZRBbCIalSMk6ZRpjNeVEaBXOMAZbAIfrpAFuorvO7ypEPikWEiy5ZTFisBG0g6T8e3e7t99ISTf4Nz9tM5vvZCoNys3NQ/3JKH8rL47sCKJ2vmKIY/TTb6Zj3FN+bFc78e/JG6Qx1huAVA63BqNEUG9OdctgPx0nss7aIAvzpjJe5XiXyG6H42+t1DD9YPfq66TZfQ7DqVdmZbpTB7SBU2Z2zPIuvQou9GbjmekQtAMwyW6aLNQP+uv5liUDmS81gwCdkNtLKlf6/nXcQOAFj9zNWrffPb6tt+116AtBry9HRevCP1WyXHbbAFuVGxclNGKWf69oERVYqLlf8DL7neD6QXtvy6KTG/lNfXpkhrCA X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 7t958Ai+Xz2CfOIUvxaRMQ08FgZwIPmvKSyzekFonJGVvY69jJPduRek+nIHGi3XuF8vpkD9UwO0EUpLgz2qcYQRLe7kYQYDfS8BOjNA2ATQYzrJ77Y8gSNMLMAy7z/9XBlJ9eNqfpb1pwHrPDpISwF5o3ldXvShvuz+ItjO6iRMWgMIy3UoG3GrkjZ6v/Kn8SBETQA3BGE1ogn0qhu0CBaDZhtfpA2aL/IBD9/7Pv7twihJZQhx04UYXtGKZpQIkz7wgPFsNaYuIGhwWFn2Jtl8BHAqTciH3m455RvOYjdclhibjkMXEo2MaM1ZGOuT3wihhM0ABuJdUoW0/Pnlwn+/RqBBvZV1HB0xbtO+BCYTiblwhHJiVKL94DfRtlhYkb427Sik4iuWeGi3wkwXhPd9exPEhNgZm5Xw/Pt0Nu8= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2019 15:11:50.2846 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73119c50-d2b2-4e2a-c69c-08d690fc6ad0 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB3758 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is just a cosmetic change, since this variable gets used quite a bit inside the dmatest_func() routine. Signed-off-by: Alexandru Ardelean --- drivers/dma/dmatest.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index ea1f885e70f4..3b148c2647f8 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -516,6 +516,7 @@ static int dmatest_func(void *data) enum dma_ctrl_flags flags; u8 *pq_coefs = NULL; int ret; + unsigned int buf_size; struct dmatest_data *src; struct dmatest_data *dst; int i; @@ -580,9 +581,10 @@ static int dmatest_func(void *data) goto err_free_coefs; } - if (1 << align > params->buf_size) { + buf_size = params->buf_size; + if (1 << align > buf_size) { pr_err("%u-byte buffer too small for %d-byte alignment\n", - params->buf_size, 1 << align); + buf_size, 1 << align); goto err_free_coefs; } @@ -595,7 +597,7 @@ static int dmatest_func(void *data) goto err_usrcs; for (i = 0; i < src->cnt; i++) { - src->raw[i] = kmalloc(params->buf_size + align, + src->raw[i] = kmalloc(buf_size + align, GFP_KERNEL); if (!src->raw[i]) goto err_srcbuf; @@ -617,7 +619,7 @@ static int dmatest_func(void *data) goto err_udsts; for (i = 0; i < dst->cnt; i++) { - dst->raw[i] = kmalloc(params->buf_size + align, + dst->raw[i] = kmalloc(buf_size + align, GFP_KERNEL); if (!dst->raw[i]) goto err_dstbuf; @@ -656,16 +658,16 @@ static int dmatest_func(void *data) total_tests++; if (params->transfer_size) { - if (params->transfer_size >= params->buf_size) { + if (params->transfer_size >= buf_size) { pr_err("%u-byte transfer size must be lower than %u-buffer size\n", - params->transfer_size, params->buf_size); + params->transfer_size, buf_size); break; } len = params->transfer_size; } else if (params->norandom) { - len = params->buf_size; + len = buf_size; } else { - len = dmatest_random() % params->buf_size + 1; + len = dmatest_random() % buf_size + 1; } /* Do not alter transfer size explicitly defined by user */ @@ -680,8 +682,8 @@ static int dmatest_func(void *data) src->off = 0; dst->off = 0; } else { - src->off = dmatest_random() % (params->buf_size - len + 1); - dst->off = dmatest_random() % (params->buf_size - len + 1); + src->off = dmatest_random() % (buf_size - len + 1); + dst->off = dmatest_random() % (buf_size - len + 1); src->off = (src->off >> align) << align; dst->off = (dst->off >> align) << align; @@ -690,9 +692,9 @@ static int dmatest_func(void *data) if (!params->noverify) { start = ktime_get(); dmatest_init_srcs(src->aligned, src->off, len, - params->buf_size, is_memset); + buf_size, is_memset); dmatest_init_dsts(dst->aligned, dst->off, len, - params->buf_size, is_memset); + buf_size, is_memset); diff = ktime_sub(ktime_get(), start); filltime = ktime_add(filltime, diff); @@ -707,7 +709,7 @@ static int dmatest_func(void *data) continue; } - um->len = params->buf_size; + um->len = buf_size; for (i = 0; i < src->cnt; i++) { void *buf = src->aligned[i]; struct page *pg = virt_to_page(buf); @@ -827,7 +829,7 @@ static int dmatest_func(void *data) src->off + len, src->off, PATTERN_SRC | PATTERN_COPY, true, is_memset); error_count += dmatest_verify(src->aligned, src->off + len, - params->buf_size, src->off + len, + buf_size, src->off + len, PATTERN_SRC, true, is_memset); pr_debug("%s: verifying dest buffer...\n", current->comm); @@ -839,7 +841,7 @@ static int dmatest_func(void *data) PATTERN_SRC | PATTERN_COPY, false, is_memset); error_count += dmatest_verify(dst->aligned, dst->off + len, - params->buf_size, dst->off + len, + buf_size, dst->off + len, PATTERN_DST, false, is_memset); diff = ktime_sub(ktime_get(), start); From patchwork Tue Feb 12 15:11:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10808103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39B1817FB for ; Tue, 12 Feb 2019 15:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AC3B2BC6E for ; Tue, 12 Feb 2019 15:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2924C2BC81; Tue, 12 Feb 2019 15:11:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 719342BC6E for ; Tue, 12 Feb 2019 15:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbfBLPLv (ORCPT ); Tue, 12 Feb 2019 10:11:51 -0500 Received: from mail-eopbgr730063.outbound.protection.outlook.com ([40.107.73.63]:27286 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728165AbfBLPLv (ORCPT ); Tue, 12 Feb 2019 10:11:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=buBbF39cztroXDoi8xuu9fBBS7Rt9W+O00eqonSFH84=; b=HJ7IbGGSAV/upTCDNYSkG8rhllYFO3sa9NEdz2NODzMQOyl5NkHlcndrKbziWcyIjhlA/qCtt3EmeBUx5bQoXVpM6lPmcTCn35A1ih9raJq71fStuz1shuBh+4VsuKozjyjaDgFLRVuSP7ocZ0BmBwZTcAzAA9c/KStYDVvAXAs= Received: from BYAPR03CA0017.namprd03.prod.outlook.com (2603:10b6:a02:a8::30) by BN7PR03MB3748.namprd03.prod.outlook.com (2603:10b6:408:23::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16; Tue, 12 Feb 2019 15:11:47 +0000 Received: from SN1NAM02FT035.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::203) by BYAPR03CA0017.outlook.office365.com (2603:10b6:a02:a8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1622.16 via Frontend Transport; Tue, 12 Feb 2019 15:11:47 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by SN1NAM02FT035.mail.protection.outlook.com (10.152.72.145) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.10 via Frontend Transport; Tue, 12 Feb 2019 15:11:46 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x1CFBkp8024211 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 12 Feb 2019 07:11:46 -0800 Received: from saturn.analog.com (10.50.1.244) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 12 Feb 2019 10:11:45 -0500 From: Alexandru Ardelean To: , CC: Alexandru Ardelean Subject: [V2 PATCH 3/3] dmaengine: dmatest: move test data alloc & free into functions Date: Tue, 12 Feb 2019 17:11:39 +0200 Message-ID: <20190212151139.20613-3-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212151139.20613-1-alexandru.ardelean@analog.com> References: <20190212151139.20613-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(396003)(39860400002)(376002)(346002)(2980300002)(199004)(189003)(186003)(106466001)(478600001)(106002)(86362001)(336012)(4326008)(53416004)(50466002)(6666004)(77096007)(26005)(356004)(2616005)(44832011)(476003)(446003)(11346002)(486006)(2906002)(126002)(426003)(48376002)(36756003)(1076003)(246002)(7696005)(76176011)(51416003)(316002)(50226002)(16586007)(110136005)(107886003)(8676002)(305945005)(7636002)(47776003)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR03MB3748;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM02FT035;1:TerUMsjvsG2mR+ViFX7B6HKmiJeyyZlPDLef+Dad5YW9YuG6tOubvkZ/aV5tKQnH9cWpjipkzNH5YoUowusgLXgCTf5d1ReYSG6JD60NnkIWslPjlaVFFTj8XcVbTABLfJ+AEVW3hpA7JLCgK095Rw== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 296320b4-caf5-4698-ce70-08d690fc6805 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4608076)(4709027)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060);SRVR:BN7PR03MB3748; X-MS-TrafficTypeDiagnostic: BN7PR03MB3748: X-Microsoft-Exchange-Diagnostics: 1;BN7PR03MB3748;20:5i6569fx2gb1IiohB4A5UU36U4As7j6sglqGJFOOcBbRKfGp/YUW5AikI4AO5ToEsJg/8xkw5Qvzy1jyZ4AhvPTO53b+9GCX77e+E8FZkchsCIjM8TdYscpD7zZkDvMGX+zpPMKF5fxFSlGxmY0WL2Vu3ZCp1hsAc5wwIYvlho6Enga9QXG/6yZ77cOF7LHk2UKq6k9yIF3BDysC0AUMtoeXBafxGMs4o8TRUXlXf5biAEQEU+N8Nu0OUcOSmfkFxvbNCjjwSZSD1+XwPuCTjgvhFyMLlLgPO3wHHNv4USNBENXdQOG0Lm2jSOIKkyiZO5GUNLHo64nOqfRB38uaTguvjXlIK0Q48ZZVCs0XACB+8x0jvWMgI20YqjGmexcJzShSZhcuF2F11n6fPZeMqtjU8sfbfFax3aywVGKFRQC8sslSBrxptXAvQGUSc9LrIBt66m9vJOFIWhlxzF4yMmVeAzpnHJr0psIBBJnBPTdruNGhawmj7LUz68k1De0O X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0946DC87A1 X-Microsoft-Exchange-Diagnostics: 1;BN7PR03MB3748;23:YqBsOCabTHI5zkIDPk5J4qOuMACxcrXoN5QUKdZ7fQIaASHu98qMyhRG9HRGYUweLjUNgOzMng5n6oX5dsriGH5dftKNzadEDTi/fQO8Pe8RvI1DBk1is2VqoH2KBL4P5TlE9Rw+FaHuNMQs1U6ZjnktuGgaLLwuj0CeQmlZVXeBmelWouJbPxSf0Kp1VAhtkF2LGmtIp1hg5arLtNIXnD7Bmkic6fmSHDi86GgtlKR0ZGUzb7LoVrPBTsh4gdsPuSGEWUnqem90f/BKExL87rvwELTgkPZRoGXzvI3WCPAp1qfTo89WmPh3Rev3iP/TC0ZDq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Axk3e89bJfmV9vfOD6i5ijESQCKFVO8TyMOeFUUUvkZrwpX5md2x/hxyQ2ErUbKrbZ3nBJYqUFB/0NSAsMziYR6J427UOXpUYBS0IIY= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2019 15:11:46.8201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 296320b4-caf5-4698-ce70-08d690fc6805 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3748 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch starts to take advantage of the `dmatest_data` struct by moving the common allocation & free-ing bits into functions. Signed-off-by: Alexandru Ardelean --- drivers/dma/dmatest.c | 110 +++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 3b148c2647f8..50221d467d86 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -486,6 +486,53 @@ static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len) return FIXPT_TO_INT(dmatest_persec(runtime, len >> 10)); } +static void __dmatest_free_test_data(struct dmatest_data *d, unsigned int cnt) +{ + unsigned int i; + + for (i = 0; i < cnt; i++) + kfree(d->raw[i]); + + kfree(d->aligned); + kfree(d->raw); +} + +static void dmatest_free_test_data(struct dmatest_data *d) +{ + __dmatest_free_test_data(d, d->cnt); +} + +static int dmatest_alloc_test_data(struct dmatest_data *d, + unsigned int buf_size, u8 align) +{ + unsigned int i = 0; + + d->raw = kcalloc(d->cnt + 1, sizeof(u8 *), GFP_KERNEL); + if (!d->raw) + return -ENOMEM; + + d->aligned = kcalloc(d->cnt + 1, sizeof(u8 *), GFP_KERNEL); + if (!d->aligned) + goto err; + + for (i = 0; i < d->cnt; i++) { + d->raw[i] = kmalloc(buf_size + align, GFP_KERNEL); + if (!d->raw[i]) + goto err; + + /* align to alignment restriction */ + if (align) + d->aligned[i] = PTR_ALIGN(d->raw[i], align); + else + d->aligned[i] = d->raw[i]; + } + + return 0; +err: + __dmatest_free_test_data(d, i); + return -ENOMEM; +} + /* * This function repeatedly tests DMA transfers of various lengths and * offsets for a given operation type until it is told to exit by @@ -588,55 +635,17 @@ static int dmatest_func(void *data) goto err_free_coefs; } - src->aligned = kcalloc(src->cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!src->aligned) + if (dmatest_alloc_test_data(src, buf_size, align) < 0) goto err_free_coefs; - src->raw = kcalloc(src->cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!src->raw) - goto err_usrcs; - - for (i = 0; i < src->cnt; i++) { - src->raw[i] = kmalloc(buf_size + align, - GFP_KERNEL); - if (!src->raw[i]) - goto err_srcbuf; - - /* align srcs to alignment restriction */ - if (align) - src->aligned[i] = PTR_ALIGN(src->raw[i], align); - else - src->aligned[i] = src->raw[i]; - } - src->aligned[i] = NULL; - - dst->aligned = kcalloc(dst->cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!dst->aligned) - goto err_dsts; - - dst->raw = kcalloc(dst->cnt + 1, sizeof(u8 *), GFP_KERNEL); - if (!dst->raw) - goto err_udsts; - - for (i = 0; i < dst->cnt; i++) { - dst->raw[i] = kmalloc(buf_size + align, - GFP_KERNEL); - if (!dst->raw[i]) - goto err_dstbuf; - - /* align dsts to alignment restriction */ - if (align) - dst->aligned[i] = PTR_ALIGN(dst->raw[i], align); - else - dst->aligned[i] = dst->raw[i]; - } - dst->aligned[i] = NULL; + if (dmatest_alloc_test_data(dst, buf_size, align) < 0) + goto err_src; set_user_nice(current, 10); srcs = kcalloc(src->cnt, sizeof(dma_addr_t), GFP_KERNEL); if (!srcs) - goto err_dstbuf; + goto err_dst; dma_pq = kcalloc(dst->cnt, sizeof(dma_addr_t), GFP_KERNEL); if (!dma_pq) @@ -865,19 +874,10 @@ static int dmatest_func(void *data) kfree(dma_pq); err_srcs_array: kfree(srcs); -err_dstbuf: - for (i = 0; dst->raw[i]; i++) - kfree(dst->raw[i]); - kfree(dst->raw); -err_udsts: - kfree(dst->aligned); -err_dsts: -err_srcbuf: - for (i = 0; src->raw[i]; i++) - kfree(src->raw[i]); - kfree(src->raw); -err_usrcs: - kfree(src->aligned); +err_dst: + dmatest_free_test_data(dst); +err_src: + dmatest_free_test_data(src); err_free_coefs: kfree(pq_coefs); err_thread_type: