From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbcBVFy7 (ORCPT ); Mon, 22 Feb 2016 00:54:59 -0500 Received: from mail-bl2nam02on0068.outbound.protection.outlook.com ([104.47.38.68]:25776 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752224AbcBVFy4 (ORCPT ); Mon, 22 Feb 2016 00:54:56 -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 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 Content-Type: text/plain 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.1.2