From patchwork Wed Jun 28 00:19:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9813311 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 5494060210 for ; Wed, 28 Jun 2017 00:19:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49EAE27E71 for ; Wed, 28 Jun 2017 00:19:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E54F2807B; Wed, 28 Jun 2017 00:19:50 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 B254527E71 for ; Wed, 28 Jun 2017 00:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754095AbdF1ATi (ORCPT ); Tue, 27 Jun 2017 20:19:38 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44144 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754084AbdF1ATh (ORCPT ); Tue, 27 Jun 2017 20:19:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 22A6460AD1; Wed, 28 Jun 2017 00:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1498609176; bh=Ts5a/mrw+SSSKG+JR9XNsr0DUfmoEBzL2ZpUvzfyrX4=; h=From:To:Cc:Subject:Date:From; b=GIgkowFxf8pIztwKBfpcFL5KJRA6vVeDW4NaFYRz3jtSMg3GcqG9nUX/cjaMw2KOt U1+gAnTOfTv0w8JsT+8YGqJdiCVePG1iwofwaP+C68Kbew/cBzzFX2L/SnYtsc/uFC 3UlLmfa60UQkvJhYKPf1qeMZ1o9BnjRGT23SnW0o= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B1DEB60996; Wed, 28 Jun 2017 00:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1498609175; bh=Ts5a/mrw+SSSKG+JR9XNsr0DUfmoEBzL2ZpUvzfyrX4=; h=From:To:Cc:Subject:Date:From; b=gm4oheBPr1wv7th/EXzsEl96bBpHhbY2RrsL6ZGJe8LgiUyvjzlMo3eNLLtv2Ajsb xpVIFK7dgehiuFnv6lnjzn+DDXQFXFxzgNYUM7AGC9E/eLvMlM4QxbK3NCrKfl5/XV aTstDR3tO4Fj/GDqQ7iqcX2wFPEMT/G28XtlZap4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B1DEB60996 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: dmaengine@vger.kernel.org, timur@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Andy Gross , David Brown , Dan Williams , Vinod Koul , linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] dmaengine: qcom_hidma: correct API violation for submit Date: Tue, 27 Jun 2017 20:19:17 -0400 Message-Id: <1498609157-19736-1-git-send-email-okaya@codeaurora.org> 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 Current code is violating the DMA Engine API by putting the submitted requests directly into the HW queue. This causes queued transactions to be started by another thread as soon as the first one finishes. The DMA Engine document clearly states this. "dmaengine_submit() will not start the DMA operation". Move HW queuing of the requests into the issue_pending() routine to comply with API requirements also create a new queued state for temporarily holding the requests. A descriptor goes through these transitions now. free->prepared->queued->active->completed->free as opposed to free->prepared->active->completed->free Signed-off-by: Sinan Kaya --- drivers/dma/qcom/hidma.c | 14 +++++++++++--- drivers/dma/qcom/hidma.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c index 84e3699..8ed29bd 100644 --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -210,6 +210,7 @@ static int hidma_chan_init(struct hidma_dev *dmadev, u32 dma_sig) INIT_LIST_HEAD(&mchan->prepared); INIT_LIST_HEAD(&mchan->active); INIT_LIST_HEAD(&mchan->completed); + INIT_LIST_HEAD(&mchan->queued); spin_lock_init(&mchan->lock); list_add_tail(&mchan->chan.device_node, &ddev->channels); @@ -230,9 +231,16 @@ static void hidma_issue_pending(struct dma_chan *dmach) struct hidma_chan *mchan = to_hidma_chan(dmach); struct hidma_dev *dmadev = mchan->dmadev; unsigned long flags; + struct hidma_desc *qdesc, *next; int status; spin_lock_irqsave(&mchan->lock, flags); + + list_for_each_entry_safe(qdesc, next, &mchan->queued, node) { + hidma_ll_queue_request(dmadev->lldev, qdesc->tre_ch); + list_move_tail(&qdesc->node, &mchan->active); + } + if (!mchan->running) { struct hidma_desc *desc = list_first_entry(&mchan->active, struct hidma_desc, @@ -319,13 +327,12 @@ static dma_cookie_t hidma_tx_submit(struct dma_async_tx_descriptor *txd) mdesc = container_of(txd, struct hidma_desc, desc); spin_lock_irqsave(&mchan->lock, irqflags); - /* Move descriptor to active */ - list_move_tail(&mdesc->node, &mchan->active); + /* Move descriptor to queued */ + list_move_tail(&mdesc->node, &mchan->queued); /* Update cookie */ cookie = dma_cookie_assign(txd); - hidma_ll_queue_request(dmadev->lldev, mdesc->tre_ch); spin_unlock_irqrestore(&mchan->lock, irqflags); return cookie; @@ -431,6 +438,7 @@ static int hidma_terminate_channel(struct dma_chan *chan) list_splice_init(&mchan->active, &list); list_splice_init(&mchan->prepared, &list); list_splice_init(&mchan->completed, &list); + list_splice_init(&mchan->queued, &list); spin_unlock_irqrestore(&mchan->lock, irqflags); /* this suspends the existing transfer */ diff --git a/drivers/dma/qcom/hidma.h b/drivers/dma/qcom/hidma.h index c7d0142..41e0aa2 100644 --- a/drivers/dma/qcom/hidma.h +++ b/drivers/dma/qcom/hidma.h @@ -104,6 +104,7 @@ struct hidma_chan { struct dma_chan chan; struct list_head free; struct list_head prepared; + struct list_head queued; struct list_head active; struct list_head completed;