From patchwork Mon Apr 15 12:14:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DF2C139A for ; Mon, 15 Apr 2019 12:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38627287EF for ; Mon, 15 Apr 2019 12:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CB3128807; Mon, 15 Apr 2019 12:15:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 CFD30287EF for ; Mon, 15 Apr 2019 12:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727244AbfDOMP5 (ORCPT ); Mon, 15 Apr 2019 08:15:57 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34852 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727177AbfDOMPT (ORCPT ); Mon, 15 Apr 2019 08:15:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id t21so8512482pfh.2 for ; Mon, 15 Apr 2019 05:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=CAUNijlh9/PyuN9Nu9xMccDkwi74nLVT9vlXbtkz1ds=; b=ucpboVWlQ5/w5Wu9P8+gVZtpfga1IRqvUoAo5DPUJU0Pxdb6xA3tpyd1e57aAy0pgb ieOVfBtAJXpRZlmX+n4tMGCGGW29Ce6U+Q6HYFKnLDDgGfjQRvXQU+sW3fvbiDsXBT5q xoHIE5eZorhruD6XJdKUujPzV+O+DgFbHynEfd/Zn795a42mbE+slNNCFEcGW3VOb7Hg WSm2R4TRtGlQQY0mBjPS4YHtzOABnCp0hiYddfZLU/keK/qtdoA74w0aJDpksXTM5gNY mE8OQW8PaFIsb4FMsKRjHLw1c1kymt/Cs2IWeMgDqIoJlEDmlNXpkEGl0QBxGHpw2OdI IHPg== 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:in-reply-to :references:in-reply-to:references; bh=CAUNijlh9/PyuN9Nu9xMccDkwi74nLVT9vlXbtkz1ds=; b=YTTkS8tIj4yWr1SexUUBEpa6MpDZrZkymo+mhdIJrW53ymV1SF5/b4caF5KJuJZ3OE iQ5Kpdaqgh7KkJxlkgTyvnLyhxm8bfzX/dy4mtoS3kmXkYkE3zv/mq3uvNN7WRKhe9BM 9ciF9pCkcuU7TjrQz5w7o978NwnYMiOP9bErzKQ4ihyitBfYbDF/37vR7RSH9qccBLE0 RMkYoLjWVgmQ2uDyKeNnuSawUGTqlo0K85bbrISYW7GBtVaGNeWVClIC6t7hdzgh3sk2 jPtW2ocDomL8HA8I8nm549FyHqeZwNb8YGGtNXuAnzWvmQ1GQdxFE9HGSuBba+rEWvw4 y7Pg== X-Gm-Message-State: APjAAAW62Q3S8B1reDQ193OSanvpuh8wTA9M9nXRDgwWp7cM7RL2iC7s QgmYVH/WXGpYRMvxLyKTxqTjvQ== X-Google-Smtp-Source: APXvYqzFwA1PM9j5ZwIwdADWuSPlcmW3p3seKOvWmE7l0Qs8TQWml2IfQNh29iOponW4uMd7MtMLlg== X-Received: by 2002:a63:b64:: with SMTP id a36mr70563796pgl.58.1555330518223; Mon, 15 Apr 2019 05:15:18 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:16 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] dmaengine: sprd: Fix the possible crash when getting engine status Date: Mon, 15 Apr 2019 20:14:55 +0800 Message-Id: <2eecd528e85377f03e6fbc5e7d6544b9c9f59cb1.1555330115.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We will get a NULL virtual descriptor by vchan_find_desc() when the descriptor has been submitted, that will crash the kernel when getting the engine status. In this case, since the descriptor has been submitted, which means the pointer 'schan->cur_desc' will point to the current descriptor, then we can use 'schan->cur_desc' to get the engine status to avoid this issue. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 48431e2..e29342a 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -625,7 +625,7 @@ static enum dma_status sprd_dma_tx_status(struct dma_chan *chan, else pos = 0; } else if (schan->cur_desc && schan->cur_desc->vd.tx.cookie == cookie) { - struct sprd_dma_desc *sdesc = to_sprd_dma_desc(vd); + struct sprd_dma_desc *sdesc = schan->cur_desc; if (sdesc->dir == DMA_DEV_TO_MEM) pos = sprd_dma_get_dst_addr(schan); From patchwork Mon Apr 15 12:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B153922 for ; Mon, 15 Apr 2019 12:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31915287EF for ; Mon, 15 Apr 2019 12:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 261D428823; Mon, 15 Apr 2019 12:15:57 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 1AF0C287EF for ; Mon, 15 Apr 2019 12:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727471AbfDOMPY (ORCPT ); Mon, 15 Apr 2019 08:15:24 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42471 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbfDOMPX (ORCPT ); Mon, 15 Apr 2019 08:15:23 -0400 Received: by mail-pg1-f194.google.com with SMTP id p6so8484243pgh.9 for ; Mon, 15 Apr 2019 05:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=qLRP/D/hBzlVyCM9RDEp0f+vh3r0DuWzHyoLapUEEZa49Vw6obIm07znxPAArbNXDx y6lOAS00ZKnidgR6SGOXa/t9lPXGvLz2q1ti+8fdgPMQz+fteVALwWaLWAie/7RPNYgl g6ubl5Vdy9CbG1gzDzKSgBj6TNhnWikVKlpJld4b4VDeqtqp32k3aX7QErvNQEfWWE6e iuq1j14ALAK4WEAVMOv7851BZgFKS2KkKlZ0dujn8lAzV3Twm+7blCirxwnLpnlfdlA+ FBtgU/fzY7iGtpk5ap8KVOqTRhlwfUHIGmPAcKDwT927EK3tNeHmrW5+kIdlQ4osChFs FAxw== 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:in-reply-to :references:in-reply-to:references; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=T8jjnrXi/SRAVUZZgKaltt9M8oAv5HO3XQrrXVEQu/HMUQ6IAvOaZqpZq0kyXSrW1P RZGchhisSSK6EzoqWbwpc6Es+A7Yep2exnnQgBltqeGe51MeHoFzmrqaTxJzUh1QiVtS WNj2lDPPofX9TGzGfCDsn5SMoRFKK4PRcAju3jV1Gmsw/cjwQmqFRsypwCyHnXbNmS9/ o5SpHErNYaHIFAMD6q7A9P6JtBdyWgDQqFu5RbLQ/4fupRqKh8GJU8LcQ81khy7q5m/i Z6dn9mRU6Az4gtIgAwFlbJNLNeIcm8WUU+jGq3zANJynVB2CfYYqeBYLdccDNHK/hry2 FCuw== X-Gm-Message-State: APjAAAWLoxUUTnpbcfATly6uOk3MdpQsk96VnwjQEYi/2ysG7kT+w7Qm W25IkZBCejWmfOwxexO/y3n60Q== X-Google-Smtp-Source: APXvYqxjlmrCVN54lGUd6cUjcklkpR8/UtXRZeB3Cgyt1f6wd//reg/A3MEZcNsaUsGIwwC8zLMF9Q== X-Received: by 2002:a63:185a:: with SMTP id 26mr43154699pgy.337.1555330522160; Mon, 15 Apr 2019 05:15:22 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.18 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:21 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] dmaengine: sprd: Add validation of current descriptor in irq handler Date: Mon, 15 Apr 2019 20:14:56 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When user terminates one DMA channel to free all its descriptors, but at the same time one transaction interrupt was triggered possibly, now we should not handle this interrupt by validating if the 'schan->cur_desc' was set as NULL to avoid crashing the kernel. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index e29342a..431e289 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -552,12 +552,17 @@ static irqreturn_t dma_irq_handle(int irq, void *dev_id) schan = &sdev->channels[i]; spin_lock(&schan->vc.lock); + + sdesc = schan->cur_desc; + if (!sdesc) { + spin_unlock(&schan->vc.lock); + return IRQ_HANDLED; + } + int_type = sprd_dma_get_int_type(schan); req_type = sprd_dma_get_req_type(schan); sprd_dma_clear_int(schan); - sdesc = schan->cur_desc; - /* cyclic mode schedule callback */ cyclic = schan->linklist.phy_addr ? true : false; if (cyclic == true) { From patchwork Mon Apr 15 12:14:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05D40922 for ; Mon, 15 Apr 2019 12:15:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E156D2870D for ; Mon, 15 Apr 2019 12:15:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53C7287FB; Mon, 15 Apr 2019 12:15:28 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 67A9D287EF for ; Mon, 15 Apr 2019 12:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727335AbfDOMP0 (ORCPT ); Mon, 15 Apr 2019 08:15:26 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44552 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727482AbfDOMP0 (ORCPT ); Mon, 15 Apr 2019 08:15:26 -0400 Received: by mail-pg1-f195.google.com with SMTP id i2so8481425pgj.11 for ; Mon, 15 Apr 2019 05:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=l9ir60nNJwBbII3Z7YfygeQjey9MNonvD8+mCs5l+c4=; b=XZ3GWmt1mWC7qqDk0CPUMjbeP75BO7JsbiGnDALS1fBKvH9BaB8hWahTFAEy+c4eNd bwLKGTd3LrMkmeBsQ4r81KbvlCg4JPSsx3nPRGh29o4erxiT+uTL4DJ0Yl+J1JG0pmWV UROk08EZ3klQ2fO6BBKeLCN+dladovWVISj58XT/H0kjpcXZPMJZ0Nv/4DEpUU5b6jd4 ACocZm20dVGjbONsv8C7eLZZve99otr8o6wQDye6PjU8/eucZhH/oNQqVmCkr0Fc9YWA +mMpDMi4f6QzajlBm23N/sz1qZ39Lf2doqpQN5upgUdgSWlrEvbjM2VDL2I8dNC0aEd9 QuPQ== 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:in-reply-to :references:in-reply-to:references; bh=l9ir60nNJwBbII3Z7YfygeQjey9MNonvD8+mCs5l+c4=; b=KOT5ZNdlD3jAU9Q25OztRzfGs+Yaub4pXNYSWtkyQSR8jBdBBUaI213mjxnsc8zVt9 Lh/3Xki3aDQkZobjXKs4VH386oACOBuz0ICRixeMIlkzUCs+n7+2jh0T/6fDJdwcJm+T Mpod6ne/2gcnGZf2GuzFDLPWdrVzKJcXj8sXLKq2MH+5q3NGrw8IE+pC3cOm+LS6IKEo /EJyMVqr0xhppHEHLWAuBMdE8hnW907e/8pmDJxRlX/fVz7X127p/Z22fdg98yA4HQAh em+BN3/34qvUJzzqtbMpMq1DTiNPRAPzZHxCFgPtj64WVibbALvoDw8Pu0TjiZQxkFx9 CnWA== X-Gm-Message-State: APjAAAVwhERm8Rwnh3XAvLNyDcQXGWwXDS+vpCXhMWNJvkSNLyDUK6Af fls1iOK1LpjkilnAUK6ay1XpLg== X-Google-Smtp-Source: APXvYqwvy3o1loKMe5y4T1evlTYCE1hZ0agu92GNiNDBU3S1WzJjPEqKOC428FOIh/6JILVAEfglmw== X-Received: by 2002:a62:62c3:: with SMTP id w186mr42971295pfb.73.1555330525672; Mon, 15 Apr 2019 05:15:25 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:24 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] dmaengine: sprd: Fix the incorrect start for 2-stage destination channels Date: Mon, 15 Apr 2019 20:14:57 +0800 Message-Id: <035654558b82bc26ee78a815cc9287e478baac92.1555330115.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Long The 2-stage destination channel will be triggered by source channel automatically, which means we should not trigger it by software request. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 431e289..0f92e60 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -510,7 +510,9 @@ static void sprd_dma_start(struct sprd_dma_chn *schan) sprd_dma_set_uid(schan); sprd_dma_enable_chn(schan); - if (schan->dev_id == SPRD_DMA_SOFTWARE_UID) + if (schan->dev_id == SPRD_DMA_SOFTWARE_UID && + schan->chn_mode != SPRD_DMA_DST_CHN0 && + schan->chn_mode != SPRD_DMA_DST_CHN1) sprd_dma_soft_request(schan); } From patchwork Mon Apr 15 12:14:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E98BE922 for ; Mon, 15 Apr 2019 12:15:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0ADA2870D for ; Mon, 15 Apr 2019 12:15:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B39287FB; Mon, 15 Apr 2019 12:15:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 68F252870D for ; Mon, 15 Apr 2019 12:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727501AbfDOMPc (ORCPT ); Mon, 15 Apr 2019 08:15:32 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41355 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbfDOMPa (ORCPT ); Mon, 15 Apr 2019 08:15:30 -0400 Received: by mail-pl1-f195.google.com with SMTP id d1so8475091plj.8 for ; Mon, 15 Apr 2019 05:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=lTV/HwBV1wkVNbsMEdMR98H0jnrUsLsqBHs1N83HCIU=; b=exbKQxTI4xxMk74weN1pp2wuWgBFrTV9NGMiVFBHcSOizFz6Pm1jJnsGxfzgw6aiZl WTZuVOV27S2Q/kVYJy44QMwfvkZWepHXib3hYamU+tiN/c6VURhf7etsMsdTK1o9qLie yNGlyJ6v2Yz3v1vgXciDRK2F/rULdNOQq6GrSAivnwrVe6HeUA/T6mjfNByP14j6smbK 2Smp0i7gWEX//tj2tce9NLHqnI4U4FGzml63MT5exyr1d8fubsuqsrcHqbQOG7ICSlTP fxw1JPFdDt2h8Rr4kaYNFEzpqeXIRZnuD604uXsMxWfqqzHlCNmLHN8py/gbxBb2OFJQ VTsQ== 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:in-reply-to :references:in-reply-to:references; bh=lTV/HwBV1wkVNbsMEdMR98H0jnrUsLsqBHs1N83HCIU=; b=WlfbnzT478xDA3drCWiJaBNc/7uOg5enBHT72fQ6VoYEDL/1mOW6HkNKVud6sFjgUD F3M+tf+VDEE5ldGyZSxrmBjy/cQbLuo41QbPfRD/NVDhNLBPWN3Hgf/ixRka1bS7nfNK 0XLM1HJOMFeqR34rqgdWFunINvlpfxL1520JP+E1z6Q/mmTQ6VVaDnveeR6m/0v/4IxX dKQR29JKMwKYizVu/yZZyhGH45CcC9JnWsPwAFqKWIcwbNxBRmCGZ5renpZB2Sn3tB7O ZQbfbtolKIthwPy9Gf3lWWAQ+SRxFT0qmhjdhnWoYhA2DahG9g6xUDEGNSdOplA7jA7H b3TQ== X-Gm-Message-State: APjAAAWU2dN8PuETGgi/KiCBp+RF4MuXBZUSWB9UWEpnpoiR9teNRsUa dAoumPBdmegWtXCKiPIm3I26Sw== X-Google-Smtp-Source: APXvYqxyOesy66KaWP5IzQdijN7MfwXi/pMBporGCAAsQQYxbnf4/O/N5kUUgpF51R3icRYVy6aQ+Q== X-Received: by 2002:a17:902:6bc7:: with SMTP id m7mr27139625plt.146.1555330530070; Mon, 15 Apr 2019 05:15:30 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:29 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] dmaengine: sprd: Add device validation to support multiple controllers Date: Mon, 15 Apr 2019 20:14:58 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Long Since we can support multiple DMA engine controllers, we should add device validation in filter function to check if the correct controller to be requested. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 0f92e60..9f99d4b 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -1020,8 +1020,13 @@ static void sprd_dma_free_desc(struct virt_dma_desc *vd) static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param) { struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); + struct of_phandle_args *dma_spec = + container_of(param, struct of_phandle_args, args[0]); u32 slave_id = *(u32 *)param; + if (chan->device->dev->of_node != dma_spec->np) + return false; + schan->dev_id = slave_id; return true; } From patchwork Mon Apr 15 12:14:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC6B2139A for ; Mon, 15 Apr 2019 12:15:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C40F62870D for ; Mon, 15 Apr 2019 12:15:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8577287FB; Mon, 15 Apr 2019 12:15:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 691812870D for ; Mon, 15 Apr 2019 12:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727496AbfDOMPg (ORCPT ); Mon, 15 Apr 2019 08:15:36 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45571 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727505AbfDOMPe (ORCPT ); Mon, 15 Apr 2019 08:15:34 -0400 Received: by mail-pl1-f196.google.com with SMTP id bf11so8459242plb.12 for ; Mon, 15 Apr 2019 05:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=EPBexP/YCMERN6VOL5fv1yV7pop7BN15G/3B+N0nQ3U=; b=k0T6x4sWoWO1mBc+OId0DMBw+LrVnMU9zm0p6EsTYO/gUBNMYZKo11zY+DswnZgNt9 hvgxI0ywLRGa/hlJyBh506+Le5G4rFLeuxya780+q9eWikKxy5O8aa0W/8gUdOOgE+np +FMg36Tr6d8dmrUl4QkCHHOgqLjaCvk6UvWbVIXZXio120GB05/WUAhYgaSyCabsZZei sax3hHlC/z6qHbXVkOmlIz+6SZw+rp4CMc2+cxPc5twLByBb1aPExtKsDBTydLG5yAcB xFDHS8C7Uzmn04mEefA0Xs6oJBmLCpJyJok+fN94irPRBuLhOmGMbLtslyRZj9czrBwD 27Ag== 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:in-reply-to :references:in-reply-to:references; bh=EPBexP/YCMERN6VOL5fv1yV7pop7BN15G/3B+N0nQ3U=; b=pVZ21fzG94XV/hZLTLZ+lbHHTqxuGNmBjQr1RcbaXH+M3LNf2jkl9sAC3XCMnkcPye BeytUFm3pS36++EILVPuRVHdQQZyesCTK3HOjVVlXYyZBxX40bULp8VWNrzzOQYXuGvT O32/L6HSyd9TIrn2/RCFUDedu9NA+bCXhDmcA5NsUotbBcUMIMVVBVBv7/xs5BVqRU+6 QrUAyF0ZRGhlJ6In5bVnDGsViq94TgdJdZjFUYLkYaaIK1zthRCq0JJSvUnyGU+cCJ/e 72VsEpSAHQjnp3/azioBGB6YE1aRAVm0pN6CUWQJwiw8EJ0lQdOTpXIQ1D/IH9VkbRR0 1CbQ== X-Gm-Message-State: APjAAAUMOCe4o25kUrZDDfkRroopS+/3ZfSMUT8RJyauelKPFLeImCxW 0H7erQf2GTf+Q2Y/xLoRrLfanw== X-Google-Smtp-Source: APXvYqz6YojtFUUCP32JI2uCJ0plSoSuhQ4QnxncHO0rwmGARrnpkNtjTTtNr1F1bEYZuEEJYILPYg== X-Received: by 2002:a17:902:d701:: with SMTP id w1mr76553552ply.124.1555330533557; Mon, 15 Apr 2019 05:15:33 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:32 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] dmaengine: sprd: Fix block length overflow Date: Mon, 15 Apr 2019 20:14:59 +0800 Message-Id: <93626039ad49c1c9d5726218b060c2267c1779cf.1555330115.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Long The maximum value of block length is 0xffff, so if the configured transfer length is more than 0xffff, that will cause block length overflow to lead a configuration error. Thus we can set block length as the maximum burst length to avoid this issue, since the maximum burst length will not be a big value which is more than 0xffff. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 9f99d4b..a64271e 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -778,7 +778,7 @@ static int sprd_dma_fill_desc(struct dma_chan *chan, temp |= slave_cfg->src_maxburst & SPRD_DMA_FRG_LEN_MASK; hw->frg_len = temp; - hw->blk_len = len & SPRD_DMA_BLK_LEN_MASK; + hw->blk_len = slave_cfg->src_maxburst & SPRD_DMA_BLK_LEN_MASK; hw->trsc_len = len & SPRD_DMA_TRSC_LEN_MASK; temp = (dst_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_DEST_TRSF_STEP_OFFSET; From patchwork Mon Apr 15 12:15:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF8991823 for ; Mon, 15 Apr 2019 12:15:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78212870D for ; Mon, 15 Apr 2019 12:15:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBFEA287EF; Mon, 15 Apr 2019 12:15:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 699C428807 for ; Mon, 15 Apr 2019 12:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727527AbfDOMPm (ORCPT ); Mon, 15 Apr 2019 08:15:42 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39857 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbfDOMPh (ORCPT ); Mon, 15 Apr 2019 08:15:37 -0400 Received: by mail-pg1-f195.google.com with SMTP id k3so8492462pga.6 for ; Mon, 15 Apr 2019 05:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=OLZzLqUboevMo/zGKOZIE23Q23oS2GeJKEJKfaBooIQ=; b=SYRkR298A05uhWDzh3IUYZxWHo6jbGm4Y12GyENCpC0LW3h39lL+yHnRPlVBfvq0nv luuqBV0yEWf3bYy8ktE9+x3k+80S3LAYhP3slKw1pXNeX+vqzSbtjqk+QXhBX9CFyi57 m9LxZzhQJUgifPk+56jRx0Tyuyi+vlAcB/W1hVdasAOAdzxFj2CoipBJ1UGJ72wgBKXX NLC0zIlPNIWrEDIQB73d7HImzT5QSdZrBU3Itnco6IwleZlnrkvWRUaZ5r/ux7WMuto2 gom2m98f2ucsoSixQcKZsWM8IY+1q97kd+OgW2t+0FIMtg4XPzZoBL/cyl5WQovKAQHx JTaA== 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:in-reply-to :references:in-reply-to:references; bh=OLZzLqUboevMo/zGKOZIE23Q23oS2GeJKEJKfaBooIQ=; b=peelsymfT7Z6LPtCPpye1HkleQ1m4E9poeT3hYy4iPBHA2N+TUiCXz003H3ZoppiUO bhCquhFRbv8Y9RBLF0/1oPal1/92i/54yIPdg49khG96WA0Mq8a9FkKRAk6UTq1TEfoY PkhitEwXsRIxIXtW2hl6Yv6CjrqFAf038gOtI0Uw+WDNCSbba4Ync1DwM34n58ldkh5n 9lodZok5ACrtPHHEb8jAV5U4gGcClXiYUFFG6l9o7obWNaH+/PlD6ykDfczWKKNHbUCT IESaIq67dFl/fGVUsSf5cfaEm4fyGdHhvMaiqsr3I18n2WHp0ZEtnW9I/nLakb8sPWqK DFnA== X-Gm-Message-State: APjAAAWHGOTd6lxJFz9Jgb4wKNH81vKCRKNcZTmhsV+94KseD3jLdJ4s vQ7sfCAdeJhaqxGpET4DBnqetg== X-Google-Smtp-Source: APXvYqwYNHweGeNHukStorwJm0SMxCCUmZwndTeN2AzIvl47d2aqEeODnwcCaK3ITyy/7S2pFAX1pw== X-Received: by 2002:aa7:8251:: with SMTP id e17mr57741476pfn.147.1555330537319; Mon, 15 Apr 2019 05:15:37 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:36 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] dmaengine: sprd: Fix the right place to configure 2-stage transfer Date: Mon, 15 Apr 2019 20:15:00 +0800 Message-Id: <8fe45a4139ba57eb014d921b6988e43f7fe07b11.1555330115.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Long Move the 2-stage configuration before configuring the link-list mode, since we will use some 2-stage configuration to fill the link-list configuration. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index a64271e..cc9c24d 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -911,6 +911,12 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, schan->linklist.virt_addr = 0; } + /* Set channel mode and trigger mode for 2-stage transfer */ + schan->chn_mode = + (flags >> SPRD_DMA_CHN_MODE_SHIFT) & SPRD_DMA_CHN_MODE_MASK; + schan->trg_mode = + (flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK; + sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT); if (!sdesc) return NULL; @@ -944,12 +950,6 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, } } - /* Set channel mode and trigger mode for 2-stage transfer */ - schan->chn_mode = - (flags >> SPRD_DMA_CHN_MODE_SHIFT) & SPRD_DMA_CHN_MODE_MASK; - schan->trg_mode = - (flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK; - ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, src, dst, len, dir, flags, slave_cfg); if (ret) { From patchwork Mon Apr 15 12:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10900657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 445D5922 for ; Mon, 15 Apr 2019 12:15:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DE992870D for ; Mon, 15 Apr 2019 12:15:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F234287FB; Mon, 15 Apr 2019 12:15:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 E6B282870D for ; Mon, 15 Apr 2019 12:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfDOMPm (ORCPT ); Mon, 15 Apr 2019 08:15:42 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43094 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727512AbfDOMPl (ORCPT ); Mon, 15 Apr 2019 08:15:41 -0400 Received: by mail-pl1-f194.google.com with SMTP id n8so8465239plp.10 for ; Mon, 15 Apr 2019 05:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=FU8i9sjlSh306RyY3KlsqQMktsvNVB138smTRNfYHGU=; b=AFS5IiI7xOQqGJvdX3jWPeHMgEaddq60Wu+mQTWo9KU//G0mncQiIddMO45w+tjPA+ Kv3+9yZefuPBQeli3eiNPKZqkd8JNSY4QuxA6x4tLrpRpTL9T89A6scpglan6YaBRyZj gChs7FtshKwf/UtqCecWfo393HIOS3cc53Nq54k39Zf5AKKQ7C0w8GCK/RIZFsXU+Ng3 imk61hg41zMEk1DH96nE5Jn+jGjJAq1Ow+yVNBB13nOVKc3FS9P+Xm+830WtjJYASdp+ AR0CJWj7vwkz5MWIPEAGve53UGAvZ3V0KUy+v3HUG6rY5S6cd+nnQ0x6Zl7pXuPqfKjL dnZw== 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:in-reply-to :references:in-reply-to:references; bh=FU8i9sjlSh306RyY3KlsqQMktsvNVB138smTRNfYHGU=; b=FN/hWW138jFm8/+ERl+OKKxsJb6HAhYl1PHIuBN+oYiPhD18QUiATXamaE3W3nqICc PFatUb4KtRabSefn9hf3nGgrVRGilNAxfW9qilos2ORtDKw6LT1aBv4PmHE74H1fpQoG uPJ00Fh+RBG1R4XIyypxlchvc6JfbRtBXZbnI8DrIWrODxMXCqknl3VzSnkp22OjO/Oj m4Gc9VzmCuUm0uHquCHUS16scyYuMxfe0KVIoGPB227/iFeNfxdS1qw77aAuV4SrYj/x +wASnkvZUD9/pvFSn8q4385yBK/OIr1lK5Q8ZO1eD+cly8gZS3bQ838DAdWIWjO8RbAp Px7A== X-Gm-Message-State: APjAAAXOEzWM4Jpn/Nu/SGGKYRcmqYynY2Q7RZszAAoFlnLc99Yg7jkY wFcBFPG822JBV8rQhhGoQM1/Mg== X-Google-Smtp-Source: APXvYqyjtYWF0hbMw90duq0+/dpp5oFpiJeExGC/I4MZEP6GJXBrPIFhLbOlqjDD1GmeOvdA12BVVg== X-Received: by 2002:a17:902:32b:: with SMTP id 40mr53043634pld.204.1555330540739; Mon, 15 Apr 2019 05:15:40 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:40 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] dmaengine: sprd: Add interrupt support for 2-stage transfer Date: Mon, 15 Apr 2019 20:15:01 +0800 Message-Id: <07c070b4397296a4500d04abe16dfd8a71a2f211.1555330115.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For 2-stage transfer, some users like Audio still need transaction interrupt to notify when the 2-stage transfer is completed. Thus we should enable 2-stage transfer interrupt to support this feature. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index cc9c24d..4c18f44 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -62,6 +62,8 @@ /* SPRD_DMA_GLB_2STAGE_GRP register definition */ #define SPRD_DMA_GLB_2STAGE_EN BIT(24) #define SPRD_DMA_GLB_CHN_INT_MASK GENMASK(23, 20) +#define SPRD_DMA_GLB_DEST_INT BIT(22) +#define SPRD_DMA_GLB_SRC_INT BIT(20) #define SPRD_DMA_GLB_LIST_DONE_TRG BIT(19) #define SPRD_DMA_GLB_TRANS_DONE_TRG BIT(18) #define SPRD_DMA_GLB_BLOCK_DONE_TRG BIT(17) @@ -135,6 +137,7 @@ /* define DMA channel mode & trigger mode mask */ #define SPRD_DMA_CHN_MODE_MASK GENMASK(7, 0) #define SPRD_DMA_TRG_MODE_MASK GENMASK(7, 0) +#define SPRD_DMA_INT_TYPE_MASK GENMASK(7, 0) /* define the DMA transfer step type */ #define SPRD_DMA_NONE_STEP 0 @@ -190,6 +193,7 @@ struct sprd_dma_chn { u32 dev_id; enum sprd_dma_chn_mode chn_mode; enum sprd_dma_trg_mode trg_mode; + enum sprd_dma_int_type int_type; struct sprd_dma_desc *cur_desc; }; @@ -429,6 +433,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = chn & SPRD_DMA_GLB_SRC_CHN_MASK; val |= BIT(schan->trg_mode - 1) << SPRD_DMA_GLB_TRG_OFFSET; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_SRC_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP1, val, val); break; @@ -436,6 +443,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = chn & SPRD_DMA_GLB_SRC_CHN_MASK; val |= BIT(schan->trg_mode - 1) << SPRD_DMA_GLB_TRG_OFFSET; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_SRC_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP2, val, val); break; @@ -443,6 +453,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = (chn << SPRD_DMA_GLB_DEST_CHN_OFFSET) & SPRD_DMA_GLB_DEST_CHN_MASK; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_DEST_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP1, val, val); break; @@ -450,6 +463,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = (chn << SPRD_DMA_GLB_DEST_CHN_OFFSET) & SPRD_DMA_GLB_DEST_CHN_MASK; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_DEST_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP2, val, val); break; @@ -911,11 +927,15 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, schan->linklist.virt_addr = 0; } - /* Set channel mode and trigger mode for 2-stage transfer */ + /* + * Set channel mode, interrupt mode and trigger mode for 2-stage + * transfer. + */ schan->chn_mode = (flags >> SPRD_DMA_CHN_MODE_SHIFT) & SPRD_DMA_CHN_MODE_MASK; schan->trg_mode = (flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK; + schan->int_type = flags & SPRD_DMA_INT_TYPE_MASK; sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT); if (!sdesc)