Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758944AbcLWIwe (ORCPT ); Fri, 23 Dec 2016 03:52:34 -0500 Received: from mail-sn1nam02on0088.outbound.protection.outlook.com ([104.47.36.88]:22656 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757835AbcLWIwa (ORCPT ); Fri, 23 Dec 2016 03:52:30 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Kedareswara rao Appana To: , , , , , , , , CC: , , Subject: [PATCH v2 2/3] dmaeninge: xilinx_dma: Fix bug in multiple frame stores scenario in vdma Date: Fri, 23 Dec 2016 14:22:14 +0530 Message-ID: <1482483135-14767-3-git-send-email-appanad@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1482483135-14767-1-git-send-email-appanad@xilinx.com> References: <1482483135-14767-1-git-send-email-appanad@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22778.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39840400002)(39860400002)(39450400003)(39410400002)(39850400002)(2980300002)(438002)(199003)(189002)(5003940100001)(48376002)(50466002)(626004)(5660300001)(47776003)(33646002)(305945005)(90966002)(76176999)(50986999)(2906002)(8676002)(8936002)(81166006)(81156014)(4326007)(50226002)(356003)(36386004)(45336002)(38730400001)(106466001)(52956003)(5001770100001)(2201001)(189998001)(36756003)(46386002)(2950100002)(6666003)(42186005)(63266004)(103686003)(92566002)(107986001)(5001870100001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR02MB196;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT014;1:bPIXDc/+l4j4SVEcyYf5Pg9372P3C7Bs71U6WkjfCMPxO908EUUuQ1ugGNAEV911R0dHadZLwmm+NRu50E7k+NS6S/+vFgY0Ur/ebmdM5zQamd8LkmUB48+1RKCERsXbRT5FBA+/VOZ8cgFlyg0QKuxAXS5KTUJZW0nn0YnyjB8Np8a++C4UMnNyrsr4zj6+2cpOvBqOSCROAE7CzhxV+r2qRvsMzqFgF2KUtxgYOHbYEn+dYcC04vUZaSZ6CwlZiZRRBUOtBQSkWI0uaxb0/lSYpDW7ULknYvJ4SHTnG7Iuat0yewx1pH83B8O1Ppnut+Zx8ZHjqSsDVrX75J6f6wEVvSxoygJpmkW1JU2E9n8ZuFjGJlOVwEbNAktKRDLp6YNhqeiJUS1TGxMpjNTx+wkfT0ej+e5syZgZ6tl52d2E3fk3c56GTwSGCw5Znf5MUF5ua90bxkAU0dOynq230CkF3Zp/9+mUBmg23DKPOFGJQhXHTZFBjNFOKjen3TnUMkPvCZhEJy7RslhMOV45fa1/eMihDBfTHL6VEk1Mx5RJaT8Pt7irytkRdPUK0/3ake2H4gQLwGG0cq8HsLPRXRlUYtgSaThKKOH2v8l7XNz+Ti0sSDi7zvRAUnm0OcGCRMer0P3jDzb6fLfBxr8FNA== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f59158c2-1cbd-4f63-b81e-08d42b1105a2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002);SRVR:BLUPR02MB196; X-Microsoft-Exchange-Diagnostics: 1;BLUPR02MB196;3:D7RNVFnf647Op5tEx/MGLAadQgKMgo9XAyJkEI4mIWx3WJC1I9MOPXcrf9HcQmBydWP7WqKb2PAqPGzpq2DAEh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lkqv+JGemWN8xwD9P1QPQMBIkcSQWjz5byEU8EovtQDlPSizdZQJ/S2BI4MbG4f6JObc9PeZs1JIUL1W0tkQJrmGwbasmiYc8U34/cypzKK2krwjkB1V258AKVs5kWWT7mTqWbh2MiJZK2Ysj9AIY8sh0= X-Microsoft-Exchange-Diagnostics: 1;BLUPR02MB196;31:OGfjRFod9gD2PnIMprosqfJNG7FqZWAcAH3qArlYydogB9wg24QZ7zxugacmnrZPyEEHMTR5AB7qDfFMs1UkpRQA5Lon2Lh9vMNyrYF2U05aWYCsTja7rnUm5hrlBQdW0FCQyWGQJwSFF+W6Rrx/EiwyIIWzfc6Gi8/mKTLDs30IyGcT074L9NmwKf8aAlusnDBMq1dBTWE+ogicRCefPaVsmFR5DVIJSQMUnhzVyX9jfJHBO14PnS4BP917JaGIAnoATht+yiw483NxcFznOt7Mth/IGBMEANJboVVFo8s=;20:9/B+Q8xsdT0vtzNkjPOCY3/oTewqhIANi69Gx6bDMCrGNRzmXxJCKivqWDeGybkyxc2LtMhwpro11mJEYGOV8mTKhseIPceZHu/qm8gprM8Hx8L2SrLOizW8YzNxz792hqA2fhPOSODUsr4THmxyI+eLEYleUc1eaG4da4HL4Pur527VMppzWYeypCOtRaE/kixzTgFbrFme1i/GSwygV9jFzNfYRyb5aSmqgeuZrGLkLpPbXoPA8NvK6UUN0kgPaUNyRNMkfeR35KudclGSZG7RgTezgji4U2wlcuCK21CIgb4QtMWG6wl5oxN41fk1a98a563oNjqsDYp3XDqCi7kt5XIjVZXyNRY+B+b4P+2+NJk3pdCILD6Bsf3BuMY4MHNqtI8gP9aGBZGnNAlp3Jdq5vgH3dvEMHI6OTkXYA43a36eCCB4V6FH+qibkYo53DR/VJR7FLEKVmDV7pS1BTPGkzpAZx7XM+terLD48ObM+r9LkvGwgh+vmHVXKhuU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(13017025)(13015025)(13018025)(13023025)(13024025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(6072148);SRVR:BLUPR02MB196;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB196; X-Microsoft-Exchange-Diagnostics: 1;BLUPR02MB196;4:nlewfhpDBfA4bTZrRTjfp8z1ChH3wrgi0b1t9WyvmhAzdHg2eH2bFU7d78YR8tY+sJmDYwR/zhGakMnN3HG7iqZYuUEO6lurfHMXpabrL/IDbZbQZ04O/FR8wEd2N5+w/jPPYk6DSR2myy5ZvmBY2qYHzuWV+k7D0UOcPIWL3Fmp3wt9SbBmlDXfyotoGMZIKqmO5LRnmiRGh81MzbrOPdlLSuKPw9rEIgAPNavnA45LVVtkfokkDhtaoXzqaoh/orAohwl7Bw2kTYnb1s2CsYXJUVZg1PTUhCbj+5VpZY3HSE4zmMzZlUTn5rm0O2JSOFqvVFb1nbWEZp+EqRfQPH+5IfNYwHLVp6KSYE87yQYO4XbYbwJbRN8tX/cR25HVUFUXrCOtIYiTJKP2jZTUqqw7JfDVPFDzMhheeNpUwdBj+pQLiu5n/m7MzdYwtpvRdi8gOb1jiJhuHRMpZWRiQWBZGzjDEuXO1s2dKPtTb3ZNtBVrfw/mkjfDBt7KFk1QiVRIy4CM23wbTb9HP9Gli4X1V2PYDCI2SsR6aSZXxHNFf6bB8chvvQuQO8ngjBtydO1thmeqN2ksbbxR1Iw6JofNScjNv1v0XMI4i+m6Xrpksmxq8RXZhFXj3dTBTkF8WFifLBAgTlzG9ZFdbsSQEuAHhQ1GK8aTmlA1WJTfZR+5En5+wU7KR5XdmkuOjOQDMCQvVvRIGT62lz+uCM320c8MvXiCpUHhMYNxlR/ZYf0= X-Forefront-PRVS: 016572D96D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR02MB196;23:R+SYxYk/oMQqUGTd8wJQE13V+UbTTjDIYzw2l8WgQ0?= =?us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dWRUv7Pow5amNRmGtyScvQSrbo=;24:6RCAStYrsOeqbibgTrVEIuF52DWwh8m3dxczEkX4VEjpVfK0lGtEvLFgzZg5i2P5EUTIIcIcYitS78ar5QVbw18Ff0Nr7gYo+m8FUEDUfME= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR02MB196;7:tfhKbgofiZdnIMf3jMK9zdaj/3Bh+FLFjN/g2m0ZIxm2r383NZFC/eyj4BhDIOJFcImhnXHXWJSvtq3lvSsyklxTypz//rjCnv9HucGSGuhWmtEaViyd0uewOQXKiZcMEH3oivn8AAuLpqHhw1OpybEFRN7xeeZVe+smNPKXclOYsaq/de5V7h8Soh3aPEuKQGD8qQ8dUuNdRS3GRy6hJpF66+6appbbeb4/h0t5nPocrVPw82775pJvHm3dy9EWAIufMmAx+wG0TwZOkR/Y+u0KdU3EtmFdSYew2EfT4Ma3Y38NMAgvDXp976WRLSLIxwOJ5YSMU9SHLmzX3asJCgdHck8a7i8i2jxOVcksd9/jk+KPxwrcOditBY5gMvi8MMD4E3jetA5dbfHDCApIiZ+/dCZJVf3d8uCHaS65p8gnud14u3W7PKNIuY4hKyjwMNz9Dt283JDObXHkkuYlEw== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2016 08:52:27.2570 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB196 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3399 Lines: 110 When VDMA is configured for more than one frame in the h/w for example h/w is configured for n number of frames and user Submits n number of frames and triggered the DMA using issue_pending API. In the current driver flow we are submitting one frame at a time but we should submit all the n number of frames at one time as the h/w Is configured for n number of frames. This patch fixes this issue. Signed-off-by: Kedareswara rao Appana --- Changes for v2: ---> Fixed race conditions in the driver as suggested by Jose Abreu ---> Fixed unnecessray if else checks in the vdma_start_transfer as suggested by Laurent Pinchart. drivers/dma/xilinx/xilinx_dma.c | 54 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index be7eb41..cf9edd8 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -1052,25 +1052,38 @@ static void xilinx_vdma_start_transfer(struct xilinx_dma_chan *chan) if (chan->has_sg) { dma_ctrl_write(chan, XILINX_DMA_REG_TAILDESC, tail_segment->phys); + list_splice_tail_init(&chan->pending_list, &chan->active_list); + chan->desc_pendingcount = 0; } else { struct xilinx_vdma_tx_segment *segment, *last = NULL; - int i = 0; + int i = 0, j = 0; if (chan->desc_submitcount < chan->num_frms) i = chan->desc_submitcount; - list_for_each_entry(segment, &desc->segments, node) { - if (chan->ext_addr) - vdma_desc_write_64(chan, - XILINX_VDMA_REG_START_ADDRESS_64(i++), - segment->hw.buf_addr, - segment->hw.buf_addr_msb); - else - vdma_desc_write(chan, - XILINX_VDMA_REG_START_ADDRESS(i++), - segment->hw.buf_addr); - - last = segment; + for (j = 0; j < chan->num_frms; ) { + list_for_each_entry(segment, &desc->segments, node) { + if (chan->ext_addr) + vdma_desc_write_64(chan, + XILINX_VDMA_REG_START_ADDRESS_64(i++), + segment->hw.buf_addr, + segment->hw.buf_addr_msb); + else + vdma_desc_write(chan, + XILINX_VDMA_REG_START_ADDRESS(i++), + segment->hw.buf_addr); + + last = segment; + } + list_del(&desc->node); + list_add_tail(&desc->node, &chan->active_list); + j++; + if (list_empty(&chan->pending_list) || + (i == chan->num_frms)) + break; + desc = list_first_entry(&chan->pending_list, + struct xilinx_dma_tx_descriptor, + node); } if (!last) @@ -1081,20 +1094,14 @@ static void xilinx_vdma_start_transfer(struct xilinx_dma_chan *chan) vdma_desc_write(chan, XILINX_DMA_REG_FRMDLY_STRIDE, last->hw.stride); vdma_desc_write(chan, XILINX_DMA_REG_VSIZE, last->hw.vsize); - } - chan->idle = false; - if (!chan->has_sg) { - list_del(&desc->node); - list_add_tail(&desc->node, &chan->active_list); - chan->desc_submitcount++; - chan->desc_pendingcount--; + chan->desc_submitcount += j; + chan->desc_pendingcount -= j; if (chan->desc_submitcount == chan->num_frms) chan->desc_submitcount = 0; - } else { - list_splice_tail_init(&chan->pending_list, &chan->active_list); - chan->desc_pendingcount = 0; } + + chan->idle = false; } /** @@ -1342,6 +1349,7 @@ static int xilinx_dma_reset(struct xilinx_dma_chan *chan) chan->err = false; chan->idle = true; + chan->desc_submitcount = 0; return err; } -- 2.1.2