From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753433AbcBVFys (ORCPT ); Mon, 22 Feb 2016 00:54:48 -0500 Received: from mail-sn1nam02on0064.outbound.protection.outlook.com ([104.47.36.64]:25881 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752909AbcBVFyq (ORCPT ); Mon, 22 Feb 2016 00:54:46 -0500 X-Greylist: delayed 4148 seconds by postgrey-1.27 at vger.kernel.org; Mon, 22 Feb 2016 00:54:45 EST 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; From: Kedareswara rao Appana To: , , , , , , , , CC: , , Subject: [PATCH v2 2/4] dmaengine: xilinx_vdma: Simplify spin lock handling Date: Mon, 22 Feb 2016 11:24:35 +0530 Message-ID: <1456120477-32134-2-git-send-email-appanad@xilinx.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1456120477-32134-1-git-send-email-appanad@xilinx.com> References: <1456120477-32134-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-22144.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(5001770100001)(36386004)(33646002)(551934003)(76176999)(5001960100002)(52956003)(50986999)(2950100001)(103686003)(86362001)(36756003)(50466002)(229853001)(106466001)(50226001)(87936001)(63266004)(2906002)(90966002)(5003940100001)(4326007)(92566002)(4001450100002)(46386002)(5008740100001)(11100500001)(6806005)(586003)(1096002)(1220700001)(42186005)(47776003)(45336002)(2201001)(189998001)(19580405001)(19580395003)(107986001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1NAM02HT162;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: db1c2002-c200-4549-4f6c-08d33b4caa00 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501002);SRVR:SN1NAM02HT162; X-Microsoft-Antispam-PRVS: <497056ffa47b43fdaf5503bf308afb53@SN1NAM02HT162.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13024025)(13018025)(8121501046)(13015025)(13023025)(5005006)(13017025)(3002001)(10201501046);SRVR:SN1NAM02HT162;BCL:0;PCL:0;RULEID:;SRVR:SN1NAM02HT162; X-Forefront-PRVS: 0860FE717F X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2016 05:54:44.1165 (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: SN1NAM02HT162 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch simplifies the spin lock handling in the driver. Signed-off-by: Kedareswara rao Appana --- Changes for v2: ---> splitted the changes into multiple patches. drivers/dma/xilinx/xilinx_vdma.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c index 06bffec..d646218 100644 --- a/drivers/dma/xilinx/xilinx_vdma.c +++ b/drivers/dma/xilinx/xilinx_vdma.c @@ -605,17 +605,14 @@ 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; 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 +626,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 +673,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 +693,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 +704,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 +713,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 +729,15 @@ 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); 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 +848,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); -- 2.1.2