From patchwork Fri Feb 26 14:03:52 2016 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: 8437341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CC5DEC0553 for ; Fri, 26 Feb 2016 14:06:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAD42203A4 for ; Fri, 26 Feb 2016 14:06:40 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 96FF2200F2 for ; Fri, 26 Feb 2016 14:06:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZJ0n-0002iX-6e; Fri, 26 Feb 2016 14:04:53 +0000 Received: from mail-sn1nam02on0080.outbound.protection.outlook.com ([104.47.36.80] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZJ0i-0002LG-5D for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2016 14:04:50 +0000 Received: from BL2NAM02FT035.eop-nam02.prod.protection.outlook.com (10.152.76.60) by BL2NAM02HT106.eop-nam02.prod.protection.outlook.com (10.152.76.172) with Microsoft SMTP Server (TLS) id 15.1.422.5; Fri, 26 Feb 2016 14:04:26 +0000 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; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by BL2NAM02FT035.mail.protection.outlook.com (10.152.77.157) with Microsoft SMTP Server (TLS) id 15.1.415.6 via Frontend Transport; Fri, 26 Feb 2016 14:04:25 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:45081 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1aZJ0K-0001b7-Vs; Fri, 26 Feb 2016 06:04:24 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1aZJ0K-00083l-OO; Fri, 26 Feb 2016 06:04:24 -0800 Received: from xsj-pvapsmtp01 (mailhost.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u1QE4Lcn032395; Fri, 26 Feb 2016 06:04:21 -0800 Received: from [172.23.64.207] (helo=xhd-lin64re117.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1aZJ0H-00082t-4P; Fri, 26 Feb 2016 06:04:21 -0800 Received: by xhd-lin64re117.xilinx.com (Postfix, from userid 13614) id 5793B20917; Fri, 26 Feb 2016 19:34:20 +0530 (IST) From: Kedareswara rao Appana To: , , , , , , , , Subject: [PATCH v3 2/4] dmaengine: xilinx_vdma: Simplify spin lock handling Date: Fri, 26 Feb 2016 19:33:52 +0530 Message-ID: <1456495434-11722-2-git-send-email-appanad@xilinx.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1456495434-11722-1-git-send-email-appanad@xilinx.com> References: <1456495434-11722-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-22156.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.100; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(586003)(92566002)(19580395003)(19580405001)(106466001)(63266004)(5003940100001)(87936001)(103686003)(2950100001)(90966002)(551934003)(52956003)(1220700001)(5008740100001)(1096002)(11100500001)(229853001)(86362001)(50226001)(42186005)(2201001)(50466002)(36756003)(76176999)(33646002)(2906002)(48376002)(5001960100002)(6806005)(4326007)(5001770100001)(47776003)(189998001)(50986999)(4001450100002)(46386002)(45336002)(107986001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT106; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; MLV:sfv; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 751d952c-f3d2-4737-5aaf-08d33eb5bc72 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BL2NAM02HT106; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(13015025)(13024025)(8121501046)(5005006)(13018025)(13023025)(3002001)(10201501046); SRVR:BL2NAM02HT106; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT106; X-Forefront-PRVS: 0864A36BBF X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2016 14:04:25.8329 (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: BL2NAM02HT106 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160226_060448_339836_7E80DD4D X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -1.9 (-) 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, 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch simplifies the spin lock handling in the driver by moving locking out of xilinx_dma_start_transfer() API and xilinx_dma_update_completed_cookie() API. Signed-off-by: Kedareswara rao Appana --- Changes for v3: ---> Updated commit message as suggested by vinod. ---> Added description to the API's(start_transfer/complete_cookie) regarding locking as suggested by vinod. Changes for v2: ---> splitted the changes into multiple patches drivers/dma/xilinx/xilinx_vdma.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c index 06bffec..ce330d4 100644 --- a/drivers/dma/xilinx/xilinx_vdma.c +++ b/drivers/dma/xilinx/xilinx_vdma.c @@ -605,17 +605,15 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) { struct xilinx_vdma_config *config = &chan->config; struct xilinx_vdma_tx_descriptor *desc, *tail_desc; - unsigned long flags; u32 reg; struct xilinx_vdma_tx_segment *tail_segment; + /* This function was invoked with lock held */ if (chan->err) return; - spin_lock_irqsave(&chan->lock, flags); - if (list_empty(&chan->pending_list)) - goto out_unlock; + return; desc = list_first_entry(&chan->pending_list, struct xilinx_vdma_tx_descriptor, node); @@ -629,7 +627,7 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) if (chan->has_sg && xilinx_vdma_is_running(chan) && !xilinx_vdma_is_idle(chan)) { dev_dbg(chan->dev, "DMA controller still busy\n"); - goto out_unlock; + return; } /* @@ -676,7 +674,7 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) xilinx_vdma_start(chan); if (chan->err) - goto out_unlock; + return; /* Start the transfer */ if (chan->has_sg) { @@ -696,7 +694,7 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) } if (!last) - goto out_unlock; + return; /* HW expects these parameters to be same for one transaction */ vdma_desc_write(chan, XILINX_VDMA_REG_HSIZE, last->hw.hsize); @@ -707,9 +705,6 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) list_splice_tail_init(&chan->pending_list, &chan->active_list); chan->desc_pendingcount = 0; - -out_unlock: - spin_unlock_irqrestore(&chan->lock, flags); } /** @@ -719,8 +714,11 @@ out_unlock: static void xilinx_vdma_issue_pending(struct dma_chan *dchan) { struct xilinx_vdma_chan *chan = to_xilinx_chan(dchan); + unsigned long flags; + spin_lock_irqsave(&chan->lock, flags); xilinx_vdma_start_transfer(chan); + spin_unlock_irqrestore(&chan->lock, flags); } /** @@ -732,21 +730,16 @@ static void xilinx_vdma_issue_pending(struct dma_chan *dchan) static void xilinx_vdma_complete_descriptor(struct xilinx_vdma_chan *chan) { struct xilinx_vdma_tx_descriptor *desc, *next; - unsigned long flags; - - spin_lock_irqsave(&chan->lock, flags); + /* This function was invoked with lock held */ if (list_empty(&chan->active_list)) - goto out_unlock; + return; list_for_each_entry_safe(desc, next, &chan->active_list, node) { list_del(&desc->node); dma_cookie_complete(&desc->async_tx); list_add_tail(&desc->node, &chan->done_list); } - -out_unlock: - spin_unlock_irqrestore(&chan->lock, flags); } /** @@ -857,8 +850,10 @@ static irqreturn_t xilinx_vdma_irq_handler(int irq, void *data) } if (status & XILINX_VDMA_DMASR_FRM_CNT_IRQ) { + spin_lock(&chan->lock); xilinx_vdma_complete_descriptor(chan); xilinx_vdma_start_transfer(chan); + spin_unlock(&chan->lock); } tasklet_schedule(&chan->tasklet);