From patchwork Mon Jan 2 09:33:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M'boumba Cedric Madianga X-Patchwork-Id: 9493259 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 5140762AB4 for ; Mon, 2 Jan 2017 09:34:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 506A4205AB for ; Mon, 2 Jan 2017 09:34:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44FD825D9E; Mon, 2 Jan 2017 09:34:23 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0407205AB for ; Mon, 2 Jan 2017 09:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932396AbdABJdq (ORCPT ); Mon, 2 Jan 2017 04:33:46 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35755 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbdABJdp (ORCPT ); Mon, 2 Jan 2017 04:33:45 -0500 Received: by mail-wm0-f66.google.com with SMTP id l2so55795639wml.2; Mon, 02 Jan 2017 01:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=C4pF6ljE+7uiUmmtCM46/EtPeCYar5Ny5LSypIY97/8=; b=dTaf/w6zCQOgj0DGoWt5ObHgeGUQuNG3UeTWEwt8A+O60FS/T+XQHUvwHMdXCZj52c vdSR5h818+pLyi4nlY6X0EgxhdsQVqdAzqnUcVY1Vk9yjTcU6Hdk5RX1BOrTqBU486tA 4pYUI+lPAkFCqgylO0z2ZTu3vUYNkKfIT8oCmlxp4t2XbKuORtUiRw/IkV9fZxbr+48p RyQ16NYd9fAYV3ReLL69hRvq/yYFr7P4exoMRi0sjW6Ic+cagwiyDGJdj0SleILITvqN rmMs84WcZ3JtH5VBu5kLZuwF78IEbnBPJo2ezFrjltZaJFsXajym6I8aPcnF/JKXaRGf 9D5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=C4pF6ljE+7uiUmmtCM46/EtPeCYar5Ny5LSypIY97/8=; b=tFCeNpPrttNykNrIJspL8Yh7HmPFYE05a1KHpc5p5qVBRmoAYadxn8CBG/bHrn+exy rINg0gasYrvbShZ45x396W3gwpvjMro1yRGoDqB/xHal811IisjZddP6hUfPTt8KfNNl sFEe1YkHG6SVBP0ixk9L839crbjyYHo/ssCLSetZDZ0mWEu0QZpxjHqa4Y5d5yxQauz5 ZGTIaT86DxxVetKBziyQQiRSrLE0cRXEWeD4qWDtDhtEMMBW0jdq0TBY87wJh9CB8QC9 NszpnEMsiGM1SSC+f/42+icpOjOvhbei8CVsubCpt2diz7LlCBe9/tPw8Kj1ZvUwyH0z XMnQ== X-Gm-Message-State: AIkVDXIc9UG9wMv0lbrtpsIr1SFrnAzBFmiPOgzk0zWuj+z1z9AwZ49aN9C6IR20N2GUEQ== X-Received: by 10.28.55.73 with SMTP id e70mr40307337wma.99.1483349623415; Mon, 02 Jan 2017 01:33:43 -0800 (PST) Received: from lmenx29w.st.com. ([37.162.27.113]) by smtp.gmail.com with ESMTPSA id d10sm86703562wja.20.2017.01.02.01.33.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jan 2017 01:33:42 -0800 (PST) From: M'boumba Cedric Madianga To: vinod.koul@intel.com, robh+dt@kernel.org, mark.rutland@arm.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, dan.j.williams@intel.com, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: M'boumba Cedric Madianga Subject: [PATCH RESEND] dmaengine: stm32-dma: Rework starting transfer management Date: Mon, 2 Jan 2017 10:33:27 +0100 Message-Id: <1483349607-16870-1-git-send-email-cedric.madianga@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch reworks the way to manage transfer starting. Now, starting DMA is only allowed when the channel is not busy. Then, stm32_dma_start_transfer is declared as void. At least, after each transfer completion, we start the next transfer if a new descriptor as been queued in the issued list during an ongoing transfer. Signed-off-by: M'boumba Cedric Madianga Reviewed-by: Ludovic BARRE --- drivers/dma/stm32-dma.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c index 3056ce7..adb846c 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -421,7 +421,7 @@ static void stm32_dma_dump_reg(struct stm32_dma_chan *chan) dev_dbg(chan2dev(chan), "SFCR: 0x%08x\n", sfcr); } -static int stm32_dma_start_transfer(struct stm32_dma_chan *chan) +static void stm32_dma_start_transfer(struct stm32_dma_chan *chan) { struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan); struct virt_dma_desc *vdesc; @@ -432,12 +432,12 @@ static int stm32_dma_start_transfer(struct stm32_dma_chan *chan) ret = stm32_dma_disable_chan(chan); if (ret < 0) - return ret; + return; if (!chan->desc) { vdesc = vchan_next_desc(&chan->vchan); if (!vdesc) - return -EPERM; + return; chan->desc = to_stm32_dma_desc(vdesc); chan->next_sg = 0; @@ -471,7 +471,7 @@ static int stm32_dma_start_transfer(struct stm32_dma_chan *chan) chan->busy = true; - return 0; + dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan); } static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan) @@ -552,15 +552,13 @@ static void stm32_dma_issue_pending(struct dma_chan *c) { struct stm32_dma_chan *chan = to_stm32_dma_chan(c); unsigned long flags; - int ret; spin_lock_irqsave(&chan->vchan.lock, flags); - if (!chan->busy) { - if (vchan_issue_pending(&chan->vchan) && !chan->desc) { - ret = stm32_dma_start_transfer(chan); - if ((!ret) && (chan->desc->cyclic)) - stm32_dma_configure_next_sg(chan); - } + if (vchan_issue_pending(&chan->vchan) && !chan->desc && !chan->busy) { + dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan); + stm32_dma_start_transfer(chan); + if (chan->desc->cyclic) + stm32_dma_configure_next_sg(chan); } spin_unlock_irqrestore(&chan->vchan.lock, flags); }