Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932818AbcDYPeS (ORCPT ); Mon, 25 Apr 2016 11:34:18 -0400 Received: from mail-am1on0106.outbound.protection.outlook.com ([157.56.112.106]:53456 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932511AbcDYPeQ convert rfc822-to-8bit (ORCPT ); Mon, 25 Apr 2016 11:34:16 -0400 From: Ramon Fried To: Kedareswara rao Appana CC: "dmaengine@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] dmaengine: dmatest: Add support for scatter-gather DMA mode Thread-Topic: [PATCH] dmaengine: dmatest: Add support for scatter-gather DMA mode Thread-Index: AQHRns80OKEL1AjlE0ay+I8uIoDXpp+auESg Date: Mon, 25 Apr 2016 14:01:59 +0000 Message-ID: References: <1461574085-18036-1-git-send-email-appanad@xilinx.com> In-Reply-To: <1461574085-18036-1-git-send-email-appanad@xilinx.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: xilinx.com; dkim=none (message not signed) header.d=none;xilinx.com; dmarc=none action=none header.from=tandemg.com; x-originating-ip: [82.81.98.25] x-ms-office365-filtering-correlation-id: 90db736e-af94-4eea-b10f-08d36d122bb9 x-microsoft-exchange-diagnostics: 1;AM2PR02MB0690;5:uUz9UYoVWlincSDj03mjMqKtmVTPtwhLpvGtF4ruOdFHVkxDfKxXSWQBXAQCcsY2egGqwKBAwW7Pl6PR2CB/FnBUg+F646b1SbUViYqZGzrvFU/lVqyJJVQc7YsOBeGZznxq8Y0vM7OiiAeFuWPIFw==;24:bpBfXQXWCRzW2vO65YtvBdFoQx0P3So7t09USuvhmrSmvc2s2GDU9eGl7P/x7aPRrWUatnY/+dJv/Txepm7KYjmLruLNA4sQrDMUmddH6KY=;7:OasjT4mDPXzwgK+N2yfzz7qEa2Gng+0n84srbzoHLn9i2kCwFFCpkU/2sc9RyXU8tVOLMhLLxoSVsuPVAxdBYXc29Z8Cb3ftqDI1pK32PaNXg06aLmheAKYAfrrWAO5SwA3h96sF9Au0uVle0M4mGQ0lP+VSD7Bes8+dK/gLHfHWOnjdnhXQ8zGNpocYIAO+ x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0690; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(9101521026)(6040130)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041072)(6043046);SRVR:AM2PR02MB0690;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0690; x-forefront-prvs: 0923977CCA x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(13464003)(377454003)(92566002)(2906002)(3660700001)(81166005)(3280700002)(5002640100001)(4326007)(122556002)(189998001)(5003600100002)(2900100001)(77096005)(66066001)(110136002)(50986999)(87936001)(19580405001)(19580395003)(106116001)(76576001)(54356999)(76176999)(86362001)(102836003)(6116002)(9686002)(1096002)(74316001)(586003)(3846002)(1220700001)(33656002)(5004730100002)(11100500001)(10400500002)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:AM2PR02MB0690;H:AM2PR02MB0689.eurprd02.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: tandemg.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2016 14:01:59.7925 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d690b55a-f04a-454b-9f62-fb1e25467a25 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR02MB0690 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3854 Lines: 106 Wow. Thanks a lot ! -----Original Message----- From: Kedareswara rao Appana [mailto:appana.durga.rao@xilinx.com] Sent: Monday, April 25, 2016 11:48 AM To: vinod.koul@intel.com; dan.j.williams@intel.com; Ramon Fried Cc: dmaengine@vger.kernel.org; linux-kernel@vger.kernel.org; Kedareswara rao Appana Subject: [PATCH] dmaengine: dmatest: Add support for scatter-gather DMA mode This patch updates the dmatest client to support scatter-gather dma mode. Signed-off-by: Kedareswara rao Appana --- drivers/dma/dmatest.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index b8576fd..6f259d8 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -51,6 +51,14 @@ module_param(iterations, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(iterations, "Iterations before stopping test (default: infinite)"); +static unsigned int sg_sources = 1; +module_param(sg_sources, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(sg_sources, + "Number of scatter gather buffers (default: 1)"); static unsigned int +dmatest = 1; module_param(dmatest, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(dmatest, + "dmatest 0-memcpy 1-slave_sg (default: 1)"); static unsigned int xor_sources = 3; module_param(xor_sources, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(xor_sources, @@ -431,6 +439,8 @@ static int dmatest_func(void *data) dev = chan->device; if (thread->type == DMA_MEMCPY) src_cnt = dst_cnt = 1; + else if (thread->type == DMA_SG) + src_cnt = dst_cnt = sg_sources; else if (thread->type == DMA_XOR) { /* force odd to ensure dst = src */ src_cnt = min_odd(params->xor_sources | 1, dev->max_xor); @@ -485,6 +495,8 @@ static int dmatest_func(void *data) dma_addr_t *dsts; unsigned int src_off, dst_off, len; u8 align = 0; + struct scatterlist tx_sg[src_cnt]; + struct scatterlist rx_sg[src_cnt]; total_tests++; @@ -577,10 +589,21 @@ static int dmatest_func(void *data) um->bidi_cnt++; } + sg_init_table(tx_sg, src_cnt); + sg_init_table(rx_sg, dst_cnt); + for (i = 0; i < src_cnt; i++) { + sg_dma_address(&rx_sg[i]) = srcs[i]; + sg_dma_address(&tx_sg[i]) = dsts[i] + dst_off; + sg_dma_len(&tx_sg[i]) = len; + sg_dma_len(&rx_sg[i]) = len; + } if (thread->type == DMA_MEMCPY) tx = dev->device_prep_dma_memcpy(chan, dsts[0] + dst_off, srcs[0], len, flags); + else if (thread->type == DMA_SG) + tx = dev->device_prep_dma_sg(chan, tx_sg, + dst_cnt, rx_sg, src_cnt, flags); else if (thread->type == DMA_XOR) tx = dev->device_prep_dma_xor(chan, dsts[0] + dst_off, @@ -748,6 +771,8 @@ static int dmatest_add_threads(struct dmatest_info *info, if (type == DMA_MEMCPY) op = "copy"; + else if (type == DMA_SG) + op = "sg"; else if (type == DMA_XOR) op = "xor"; else if (type == DMA_PQ) @@ -802,8 +827,16 @@ static int dmatest_add_channel(struct dmatest_info *info, INIT_LIST_HEAD(&dtc->threads); if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) { - cnt = dmatest_add_threads(info, dtc, DMA_MEMCPY); - thread_count += cnt > 0 ? cnt : 0; + if (dmatest == 0) { + cnt = dmatest_add_threads(info, dtc, DMA_MEMCPY); + thread_count += cnt > 0 ? cnt : 0; + } + } + if (dma_has_cap(DMA_SG, dma_dev->cap_mask)) { + if (dmatest == 1) { + cnt = dmatest_add_threads(info, dtc, DMA_SG); + thread_count += cnt > 0 ? cnt : 0; + } } if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { cnt = dmatest_add_threads(info, dtc, DMA_XOR); @@ -877,6 +910,7 @@ static void run_threaded_test(struct dmatest_info *info) request_channels(info, DMA_MEMCPY); request_channels(info, DMA_XOR); + request_channels(info, DMA_SG); request_channels(info, DMA_PQ); } -- 2.1.2