From patchwork Mon Feb 22 05:54:37 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: 8372031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4E0769F372 for ; Mon, 22 Feb 2016 05:57:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 637E6203A1 for ; Mon, 22 Feb 2016 05:57:31 +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 7763B202EB for ; Mon, 22 Feb 2016 05:57:30 +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 1aXjTP-0002HA-4J; Mon, 22 Feb 2016 05:55:55 +0000 Received: from mail-cys01nam02on0079.outbound.protection.outlook.com ([104.47.37.79] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aXjSn-0000n8-5N for linux-arm-kernel@lists.infradead.org; Mon, 22 Feb 2016 05:55:19 +0000 Received: from BL2NAM02FT017.eop-nam02.prod.protection.outlook.com (10.152.76.54) by BL2NAM02HT138.eop-nam02.prod.protection.outlook.com (10.152.77.29) with Microsoft SMTP Server (TLS) id 15.1.415.6; Mon, 22 Feb 2016 05:54:55 +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 BL2NAM02FT017.mail.protection.outlook.com (10.152.77.174) with Microsoft SMTP Server (TLS) id 15.1.415.6 via Frontend Transport; Mon, 22 Feb 2016 05:54:54 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:39660 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1aXjSP-0008J3-Nw; Sun, 21 Feb 2016 21:54:53 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1aXjSP-0004KN-Ie; Sun, 21 Feb 2016 21:54:53 -0800 Received: from xsj-pvapsmtp01 (smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u1M5sgMP006348; Sun, 21 Feb 2016 21:54:42 -0800 Received: from [172.23.64.207] (helo=xhd-lin64re117.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1aXjSD-0004Ik-Qj; Sun, 21 Feb 2016 21:54:42 -0800 Received: by xhd-lin64re117.xilinx.com (Postfix, from userid 13614) id 6AFBF20917; Mon, 22 Feb 2016 11:24:40 +0530 (IST) From: Kedareswara rao Appana To: , , , , , , , , Subject: [PATCH v2 4/4] dmaengine: xilinx_vdma: Improve channel idle checking Date: Mon, 22 Feb 2016 11:24:37 +0530 Message-ID: <1456120477-32134-4-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.100; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(5001770100001)(36386004)(33646002)(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:BL2NAM02HT138; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b1071905-ee57-4717-b322-08d33b4cb014 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BL2NAM02HT138; X-Microsoft-Antispam-PRVS: <199bd00805504372b4aed00eb2a9d82d@BL2NAM02HT138.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)(8121501046)(13018025)(5005006)(13017025)(13023025)(13024025)(13015025)(10201501046)(3002001); SRVR:BL2NAM02HT138; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT138; X-Forefront-PRVS: 0860FE717F X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2016 05:54:54.4573 (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: BL2NAM02HT138 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160221_215517_445989_C465F2EE X-CRM114-Status: GOOD ( 14.26 ) 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 improves the channel idle cheking by introduing a new varibale in chan private structure. Signed-off-by: Kedareswara rao Appana --- Changes for v2: ---> splitted the changes into multiple patches. drivers/dma/xilinx/xilinx_vdma.c | 41 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c index 8db07f7..51686d1 100644 --- a/drivers/dma/xilinx/xilinx_vdma.c +++ b/drivers/dma/xilinx/xilinx_vdma.c @@ -202,6 +202,7 @@ struct xilinx_vdma_tx_descriptor { * @has_sg: Support scatter transfers * @genlock: Support genlock mode * @err: Channel has errors + * @idle: Check for channel idle * @tasklet: Cleanup work after irq * @config: Device configuration info * @flush_on_fsync: Flush on Frame sync @@ -225,6 +226,7 @@ struct xilinx_vdma_chan { bool has_sg; bool genlock; bool err; + bool idle; struct tasklet_struct tasklet; struct xilinx_vdma_config config; bool flush_on_fsync; @@ -519,32 +521,6 @@ static enum dma_status xilinx_vdma_tx_status(struct dma_chan *dchan, } /** - * xilinx_vdma_is_running - Check if VDMA channel is running - * @chan: Driver specific VDMA channel - * - * Return: '1' if running, '0' if not. - */ -static bool xilinx_vdma_is_running(struct xilinx_vdma_chan *chan) -{ - return !(vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) & - XILINX_VDMA_DMASR_HALTED) && - (vdma_ctrl_read(chan, XILINX_VDMA_REG_DMACR) & - XILINX_VDMA_DMACR_RUNSTOP); -} - -/** - * xilinx_vdma_is_idle - Check if VDMA channel is idle - * @chan: Driver specific VDMA channel - * - * Return: '1' if idle, '0' if not. - */ -static bool xilinx_vdma_is_idle(struct xilinx_vdma_chan *chan) -{ - return vdma_ctrl_read(chan, XILINX_VDMA_REG_DMASR) & - XILINX_VDMA_DMASR_IDLE; -} - -/** * xilinx_vdma_halt - Halt VDMA channel * @chan: Driver specific VDMA channel */ @@ -614,6 +590,9 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) if (list_empty(&chan->pending_list)) return; + if (!chan->idle) + return; + desc = list_first_entry(&chan->pending_list, struct xilinx_vdma_tx_descriptor, node); tail_desc = list_last_entry(&chan->pending_list, @@ -622,13 +601,6 @@ static void xilinx_vdma_start_transfer(struct xilinx_vdma_chan *chan) tail_segment = list_last_entry(&tail_desc->segments, struct xilinx_vdma_tx_segment, node); - /* If it is SG mode and hardware is busy, cannot submit */ - if (chan->has_sg && xilinx_vdma_is_running(chan) && - !xilinx_vdma_is_idle(chan)) { - dev_dbg(chan->dev, "DMA controller still busy\n"); - return; - } - /* * If hardware is idle, then all descriptors on the running lists are * done, start new transfers @@ -708,6 +680,7 @@ 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; + chan->idle = false; } /** @@ -854,6 +827,7 @@ 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); + chan->idle = true; xilinx_vdma_start_transfer(chan); spin_unlock(&chan->lock); } @@ -1212,6 +1186,7 @@ static int xilinx_vdma_chan_probe(struct xilinx_vdma_device *xdev, list_add_tail(&chan->common.device_node, &xdev->common.channels); xdev->chan[chan->id] = chan; + chan->idle = true; /* Reset the channel */ err = xilinx_vdma_chan_reset(chan);