From patchwork Wed Jan 4 06:54:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Appana Durga Kedareswara rao X-Patchwork-Id: 9496159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C61860413 for ; Wed, 4 Jan 2017 06:57:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF49920246 for ; Wed, 4 Jan 2017 06:57:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3CB226C9B; Wed, 4 Jan 2017 06:57:55 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3843220246 for ; Wed, 4 Jan 2017 06:57:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cOfTd-0007En-3i; Wed, 04 Jan 2017 06:55:13 +0000 Received: from mail-co1nam03on0062.outbound.protection.outlook.com ([104.47.40.62] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cOfT9-0006e1-6E for linux-arm-kernel@lists.infradead.org; Wed, 04 Jan 2017 06:54:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SQYZtiAMIZYKznpDy0n6xOfRavw8H2W1A4foBWtIiUc=; b=JCIMT9tVGBgXRDkJVoYSFLMKALzZeV/hryT+G2KZ0EhcVhEzebNhnyo/i+wD6mQUI7fQpePLU7rcvdBKGwUVl1TURJsDcXG9S7TZun3K/f5WyeVL1S3ounLJpzoZvMC90FDhbKlmqA5a/+lpuXmXZpOgxHV89vNJxS0AhNJjeXM= Received: from BY1PR0201CA0019.namprd02.prod.outlook.com (10.160.191.157) by CO1PR02MB208.namprd02.prod.outlook.com (10.242.165.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10; Wed, 4 Jan 2017 06:54:20 +0000 Received: from SN1NAM02FT011.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::205) by BY1PR0201CA0019.outlook.office365.com (2a01:111:e400:4814::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10 via Frontend Transport; Wed, 4 Jan 2017 06:54:20 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) 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; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT011.mail.protection.outlook.com (10.152.72.82) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Wed, 4 Jan 2017 06:54:19 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1cOfSk-0002zC-Bk; Tue, 03 Jan 2017 22:54:18 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1cOfSk-0005AF-7o; Tue, 03 Jan 2017 22:54:18 -0800 Received: from xsj-pvapsmtp01 (xsj-smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id v046sDmb012410; Tue, 3 Jan 2017 22:54:13 -0800 Received: from [172.23.64.208] (helo=xhdrdevl6.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1cOfSe-00054d-AY; Tue, 03 Jan 2017 22:54:12 -0800 Received: by xhdrdevl6.xilinx.com (Postfix, from userid 13614) id 6DE9FF20014; Wed, 4 Jan 2017 12:24:11 +0530 (IST) From: Kedareswara rao Appana To: , , , , , , , , , , Subject: [PATCH v3 3/3] dmaengine: xilinx_dma: Fix race condition in the driver for multiple descriptor scenario Date: Wed, 4 Jan 2017 12:24:07 +0530 Message-ID: <1483512847-25710-4-git-send-email-appanad@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1483512847-25710-1-git-send-email-appanad@xilinx.com> References: <1483512847-25710-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-22800.006 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.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39850400002)(39410400002)(39840400002)(39860400002)(39450400003)(2980300002)(438002)(199003)(189002)(36386004)(189998001)(50986999)(626004)(76176999)(5660300001)(5003940100001)(5001770100001)(8936002)(42186005)(63266004)(106466001)(81156014)(103686003)(8676002)(305945005)(47776003)(356003)(81166006)(33646002)(7416002)(90966002)(50226002)(4326007)(38730400001)(2906002)(48376002)(50466002)(92566002)(551934003)(45336002)(52956003)(2950100002)(2201001)(54906002)(6666003)(46386002)(36756003)(921003)(107986001)(2101003)(83996005)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO1PR02MB208; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; PTR:unknown-60-83.xilinx.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT011; 1:QtzmKbPN7+hCzTgAgJ0PypaEMYAvZfcXSrluodzc8RMlFPsCZodlQq7FLEUpAKvteJbFY2btgICDlD1r8HmrsxBlE3gay3JNlgMJTS1iV45MIeFP1gRFgdMblbzjlRtcLUlU3S7VrZ85Ftdqjdka8y3BM2sqaCxy+RcJ8ah/mG6YcQEo4TUp+4Mca9MjS9AYTDIEMSddO2Fj+b1wKJe92N1QOSb5KJh8l4vvZMHCIHF8dmJKb9X7SLj3uCao/Yi3Seq13Urwa4vujaiy1mtNOnwxOMz1p50kmHTnlqMvZIplbaxoXgqCZJ9K55u6381ahCG9GoXMXxqtL2squYiwbP4llUcidrM2ABg7hiSAwoPEnkDYMHsPhi2/px6qz6GAkr7uXOWuai9bERIzyRMOHeRXk0iLJlMnlN45N8ZOUH71F7nXt/mBP0RTxUmUaCgJBkxj3iuNJUC4GJFiA/QdcBg92ew/2FzcMvQvLympeMhRc5WCWAjskAvihKs9DJdBi3O8CPDSZ+qFF+2bYS/Y8MYGB0x9Dmcc53BcUtj2nRqX2Rw4hTv0x6UuPVTJVYlrFoYDD3LNOnuQKqR2SI/CMHFpkz67zw/Y77hH+Lxj4zeE4SpHLlthZDwBFqKp6BpqvQVvvJwT7Ac6aQSwYBNGcg== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7583a1ad-5665-47f9-b267-08d4346e8261 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(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u2k7YXcwReWqQkXqeePhKGSOYrIc8i6tCqNtaFXukuPaIwfzbGFYlsuAqbzhMSeaKNFnCi4ve1DIZrZYfsrZYQhSgxoPhTeLo+Pj2b3KEciP8XoeDJfjfbnem0x1/cwib5bCtBiehO7BO1MXbwPBErl25zcGMGAyI0MtZPft2QQJ/LHzrExNMYldx6bjOnY9ci0TXoMc4YOMNfEdF5swiF/CPcbxq44rdotvF6ar+; 20:I+yf8w9MPHP4xO6LGx1kZ5e3otwUDXkoQK27VmgM7MbLI5kDW4tc263kvBpayxktegNE1qgRJnyLTNVlnEn4OhQoQzlqwqq+Qy0X/8cuur/gSihGPdaYc14vS9IEt0oS7lW5BMP2vBd7uHe/TCBZtQ6RlKaJ3t39rHQ+1Byvfk1q7TRynzZXP3xOiYFV3mKskaMJfpUyowTwE2YjyTjd8DCh9ZhHl1l5RhIesw6/lemQQJBTdq9QNcv4adHrDayauvMb47S3kt47x2FH27eRx+2fpc4sa+63Jp4rc3EgW+Rd95jexHWVFe/al7yaAWrdaTxIAQCbJ3Re7FD5faPySfBwyeKuoNKyKLbTiCXKBU01SsOcGXX3x9LYmzDIO8V6sIOJMgtQj+ijb0I/a9feBQeEWCenS+9Va7KLPtTPfrDPLdP03/kpzOwqM1zoeWnZolsZlD7asSkpJaImEXu8ibwilPirpkZnvWbXMRX8cCh+b38LDU4aTAIFDH3teaFT 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)(13023025)(13017025)(13015025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:CO1PR02MB208; BCL:0; PCL:0; RULEID:; SRVR:CO1PR02MB208; X-Microsoft-Exchange-Diagnostics: 1; CO1PR02MB208; 4:kUEVg0ISalXb1f3Mf0xrakZnK/K+C78cy81qLsjKNR/Kpn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: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO1PR02MB208; 7:X/8KDwzr6yFREyCnnSi3xR0IRdQIAeruhzuXf0mYhlx1yOdhXaJ2K2L2vrPV/SBEp8UQZj2c4qWMFB4S8tJDW1bxXaeRYL00/jhadF+9WJvCDRZ3g+hHDpkCCBdLkYX5vXxJSABkqUnWQ94pB2BZ6oUPcigKQ9lUjFj0IwYwwbzAhJuvig8HzZUqmOECkA80l9jvKHVGUu1BdYlXsBRMWidgXgiom6dVkdd/bT7xqnyGanxpFljsXvhO5Du1Ia4I7S/ww20nnX7L4avPIDVkJYS0YfCDk8pCuvLXQs21F8Fox6lOhfMbhAohTQAt2rSVU/AKSajfXWPfe45wlnd0ff9FW9JUzFvqQPNmvdbMxFrXyHdQHI49122GhE9OOo5GjV0pLGcALEjzfrsKgrZ+0Nvln2x7Umk7eQRvx5ip6ETLXnYsLFyra11KNwlGLnvveReOeb7hPqI4is9OFoUtUw== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2017 06:54:19.8476 (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.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR02MB208 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170103_225443_442288_A7715C72 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When driver is handling AXI DMA SoftIP When user submits multiple descriptors back to back on the S2MM(recv) side with the current driver flow the last buffer descriptor next bd points to a invalid location resulting the invalid data or errors in the DMA engine. This patch fixes this issue by creating a BD Chain during channel allocation itself and use those BD's. Signed-off-by: Kedareswara rao Appana --- Changes for v3: ---> None. Changes for v2: ---> None. drivers/dma/xilinx/xilinx_dma.c | 133 +++++++++++++++++++++++++--------------- 1 file changed, 83 insertions(+), 50 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index 7cd8e08..822ccf00 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -163,6 +163,7 @@ #define XILINX_DMA_BD_SOP BIT(27) #define XILINX_DMA_BD_EOP BIT(26) #define XILINX_DMA_COALESCE_MAX 255 +#define XILINX_DMA_NUM_DESCS 255 #define XILINX_DMA_NUM_APP_WORDS 5 /* Multi-Channel DMA Descriptor offsets*/ @@ -310,6 +311,7 @@ struct xilinx_dma_tx_descriptor { * @pending_list: Descriptors waiting * @active_list: Descriptors ready to submit * @done_list: Complete descriptors + * @free_seg_list: Free descriptors * @common: DMA common channel * @desc_pool: Descriptors pool * @dev: The dma device @@ -331,7 +333,9 @@ struct xilinx_dma_tx_descriptor { * @desc_submitcount: Descriptor h/w submitted count * @residue: Residue for AXI DMA * @seg_v: Statically allocated segments base + * @seg_p: Physical allocated segments base * @cyclic_seg_v: Statically allocated segment base for cyclic transfers + * @cyclic_seg_p: Physical allocated segments base for cyclic dma * @start_transfer: Differentiate b/w DMA IP's transfer */ struct xilinx_dma_chan { @@ -342,6 +346,7 @@ struct xilinx_dma_chan { struct list_head pending_list; struct list_head active_list; struct list_head done_list; + struct list_head free_seg_list; struct dma_chan common; struct dma_pool *desc_pool; struct device *dev; @@ -363,7 +368,9 @@ struct xilinx_dma_chan { u32 desc_submitcount; u32 residue; struct xilinx_axidma_tx_segment *seg_v; + dma_addr_t seg_p; struct xilinx_axidma_tx_segment *cyclic_seg_v; + dma_addr_t cyclic_seg_p; void (*start_transfer)(struct xilinx_dma_chan *chan); u16 tdest; }; @@ -569,17 +576,31 @@ static struct xilinx_axidma_tx_segment * xilinx_axidma_alloc_tx_segment(struct xilinx_dma_chan *chan) { struct xilinx_axidma_tx_segment *segment; - dma_addr_t phys; - - segment = dma_pool_zalloc(chan->desc_pool, GFP_ATOMIC, &phys); - if (!segment) - return NULL; + unsigned long flags; - segment->phys = phys; + spin_lock_irqsave(&chan->lock, flags); + if (!list_empty(&chan->free_seg_list)) { + segment = list_first_entry(&chan->free_seg_list, + struct xilinx_axidma_tx_segment, + node); + list_del(&segment->node); + } + spin_unlock_irqrestore(&chan->lock, flags); return segment; } +static void xilinx_dma_clean_hw_desc(struct xilinx_axidma_desc_hw *hw) +{ + u32 next_desc = hw->next_desc; + u32 next_desc_msb = hw->next_desc_msb; + + memset(hw, 0, sizeof(struct xilinx_axidma_desc_hw)); + + hw->next_desc = next_desc; + hw->next_desc_msb = next_desc_msb; +} + /** * xilinx_dma_free_tx_segment - Free transaction segment * @chan: Driver specific DMA channel @@ -588,7 +609,9 @@ xilinx_axidma_alloc_tx_segment(struct xilinx_dma_chan *chan) static void xilinx_dma_free_tx_segment(struct xilinx_dma_chan *chan, struct xilinx_axidma_tx_segment *segment) { - dma_pool_free(chan->desc_pool, segment, segment->phys); + xilinx_dma_clean_hw_desc(&segment->hw); + + list_add_tail(&segment->node, &chan->free_seg_list); } /** @@ -713,16 +736,26 @@ static void xilinx_dma_free_descriptors(struct xilinx_dma_chan *chan) static void xilinx_dma_free_chan_resources(struct dma_chan *dchan) { struct xilinx_dma_chan *chan = to_xilinx_chan(dchan); + unsigned long flags; dev_dbg(chan->dev, "Free all channel resources.\n"); xilinx_dma_free_descriptors(chan); + if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { - xilinx_dma_free_tx_segment(chan, chan->cyclic_seg_v); - xilinx_dma_free_tx_segment(chan, chan->seg_v); + spin_lock_irqsave(&chan->lock, flags); + INIT_LIST_HEAD(&chan->free_seg_list); + spin_unlock_irqrestore(&chan->lock, flags); + + /* Free Memory that is allocated for cyclic DMA Mode */ + dma_free_coherent(chan->dev, sizeof(*chan->cyclic_seg_v), + chan->cyclic_seg_v, chan->cyclic_seg_p); + } + + if (chan->xdev->dma_config->dmatype != XDMA_TYPE_AXIDMA) { + dma_pool_destroy(chan->desc_pool); + chan->desc_pool = NULL; } - dma_pool_destroy(chan->desc_pool); - chan->desc_pool = NULL; } /** @@ -805,6 +838,7 @@ static void xilinx_dma_do_tasklet(unsigned long data) static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) { struct xilinx_dma_chan *chan = to_xilinx_chan(dchan); + int i; /* Has this channel already been allocated? */ if (chan->desc_pool) @@ -815,11 +849,30 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) * for meeting Xilinx VDMA specification requirement. */ if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { - chan->desc_pool = dma_pool_create("xilinx_dma_desc_pool", - chan->dev, - sizeof(struct xilinx_axidma_tx_segment), - __alignof__(struct xilinx_axidma_tx_segment), - 0); + /* Allocate the buffer descriptors. */ + chan->seg_v = dma_zalloc_coherent(chan->dev, + sizeof(*chan->seg_v) * + XILINX_DMA_NUM_DESCS, + &chan->seg_p, GFP_KERNEL); + if (!chan->seg_v) { + dev_err(chan->dev, + "unable to allocate channel %d descriptors\n", + chan->id); + return -ENOMEM; + } + + for (i = 0; i < XILINX_DMA_NUM_DESCS; i++) { + chan->seg_v[i].hw.next_desc = + lower_32_bits(chan->seg_p + sizeof(*chan->seg_v) * + ((i + 1) % XILINX_DMA_NUM_DESCS)); + chan->seg_v[i].hw.next_desc_msb = + upper_32_bits(chan->seg_p + sizeof(*chan->seg_v) * + ((i + 1) % XILINX_DMA_NUM_DESCS)); + chan->seg_v[i].phys = chan->seg_p + + sizeof(*chan->seg_v) * i; + list_add_tail(&chan->seg_v[i].node, + &chan->free_seg_list); + } } else if (chan->xdev->dma_config->dmatype == XDMA_TYPE_CDMA) { chan->desc_pool = dma_pool_create("xilinx_cdma_desc_pool", chan->dev, @@ -834,7 +887,8 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) 0); } - if (!chan->desc_pool) { + if (!chan->desc_pool && + (chan->xdev->dma_config->dmatype != XDMA_TYPE_AXIDMA)) { dev_err(chan->dev, "unable to allocate channel %d descriptor pool\n", chan->id); @@ -843,22 +897,20 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { /* - * For AXI DMA case after submitting a pending_list, keep - * an extra segment allocated so that the "next descriptor" - * pointer on the tail descriptor always points to a - * valid descriptor, even when paused after reaching taildesc. - * This way, it is possible to issue additional - * transfers without halting and restarting the channel. - */ - chan->seg_v = xilinx_axidma_alloc_tx_segment(chan); - - /* * For cyclic DMA mode we need to program the tail Descriptor * register with a value which is not a part of the BD chain * so allocating a desc segment during channel allocation for * programming tail descriptor. */ - chan->cyclic_seg_v = xilinx_axidma_alloc_tx_segment(chan); + chan->cyclic_seg_v = dma_zalloc_coherent(chan->dev, + sizeof(*chan->cyclic_seg_v), + &chan->cyclic_seg_p, GFP_KERNEL); + if (!chan->cyclic_seg_v) { + dev_err(chan->dev, + "unable to allocate desc segment for cyclic DMA\n"); + return -ENOMEM; + } + chan->cyclic_seg_v->phys = chan->cyclic_seg_p; } dma_cookie_init(dchan); @@ -1197,7 +1249,7 @@ static void xilinx_cdma_start_transfer(struct xilinx_dma_chan *chan) static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) { struct xilinx_dma_tx_descriptor *head_desc, *tail_desc; - struct xilinx_axidma_tx_segment *tail_segment, *old_head, *new_head; + struct xilinx_axidma_tx_segment *tail_segment; u32 reg; if (chan->err) @@ -1216,21 +1268,6 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) tail_segment = list_last_entry(&tail_desc->segments, struct xilinx_axidma_tx_segment, node); - if (chan->has_sg && !chan->xdev->mcdma) { - old_head = list_first_entry(&head_desc->segments, - struct xilinx_axidma_tx_segment, node); - new_head = chan->seg_v; - /* Copy Buffer Descriptor fields. */ - new_head->hw = old_head->hw; - - /* Swap and save new reserve */ - list_replace_init(&old_head->node, &new_head->node); - chan->seg_v = old_head; - - tail_segment->hw.next_desc = chan->seg_v->phys; - head_desc->async_tx.phys = new_head->phys; - } - reg = dma_ctrl_read(chan, XILINX_DMA_REG_DMACR); if (chan->desc_pendingcount <= XILINX_DMA_COALESCE_MAX) { @@ -1728,7 +1765,7 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg( { struct xilinx_dma_chan *chan = to_xilinx_chan(dchan); struct xilinx_dma_tx_descriptor *desc; - struct xilinx_axidma_tx_segment *segment = NULL, *prev = NULL; + struct xilinx_axidma_tx_segment *segment = NULL; u32 *app_w = (u32 *)context; struct scatterlist *sg; size_t copy; @@ -1779,10 +1816,6 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg( XILINX_DMA_NUM_APP_WORDS); } - if (prev) - prev->hw.next_desc = segment->phys; - - prev = segment; sg_used += copy; /* @@ -1796,7 +1829,6 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg( segment = list_first_entry(&desc->segments, struct xilinx_axidma_tx_segment, node); desc->async_tx.phys = segment->phys; - prev->hw.next_desc = segment->phys; /* For the last DMA_MEM_TO_DEV transfer, set EOP */ if (chan->direction == DMA_MEM_TO_DEV) { @@ -2340,6 +2372,7 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev, INIT_LIST_HEAD(&chan->pending_list); INIT_LIST_HEAD(&chan->done_list); INIT_LIST_HEAD(&chan->active_list); + INIT_LIST_HEAD(&chan->free_seg_list); /* Retrieve the channel properties from the device tree */ has_dre = of_property_read_bool(node, "xlnx,include-dre");