From patchwork Thu Jan 10 17:34:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10756437 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 A9DAD159A for ; Thu, 10 Jan 2019 17:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94C5E26E54 for ; Thu, 10 Jan 2019 17:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8853829A86; Thu, 10 Jan 2019 17:34: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=-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 2320C26E54 for ; Thu, 10 Jan 2019 17:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729877AbfAJRet (ORCPT ); Thu, 10 Jan 2019 12:34:49 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38899 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730368AbfAJReY (ORCPT ); Thu, 10 Jan 2019 12:34:24 -0500 Received: by mail-pg1-f193.google.com with SMTP id g189so5108135pgc.5 for ; Thu, 10 Jan 2019 09:34:23 -0800 (PST) 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; bh=Acz25rUAnYOwtdV3EAKACd8ebfPIsH2pLWOoO+LfHkQ=; b=HL6eVqd3VAGtKA/ZqhGwc7urfTA9PFdcn3E/aLw3sh22SI6JuaZf+Uh1/+13tBxK9V cOpJ3YGxuk1q1H1+yU4KXo3S6zRVKketPHzEQHMzaXd8LyG1ZpaG2wgofDWOjiJ8+ipG Q8DSr1kPEWC26HS7YbYJUnNvAClIakTFeHkTs= 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; bh=Acz25rUAnYOwtdV3EAKACd8ebfPIsH2pLWOoO+LfHkQ=; b=l32M1hyO4sVhHxAC4wa8f3NhTtqYQnkV1u+Gtaba/6Q+7HzWccaoG2AkSOoRVb1LH5 DB/BYSbTGmEarn983WVsfulrxGHJJCNRQ7CwBJYS+PpTyU2DKHwNfo1ijFq1vzZN5X7F qtajPS8ezi/d2ygWdnZzphFinrOsyYjsFdUS3WHR/h2CpyrtDx5kAT+J+FF+uGXXIN9B HI2+qVWqCha8wggjOHHVYu+IhyJzwpMoPOyO3oF0sVBRFHgNzbudgFO+CQtADCOzvmyw KzIuMBPACfv/1XIioWRlmF8O81yCycZ4gAblbiipgZReNVC31E8/jZBldsSBXXV5YiWw E1qw== X-Gm-Message-State: AJcUuke1T6dvUXcRvJB4eQEHNanwGGLAFvHWHXnIZCy8EiycjgE1EzIi gjjDdaGRNB1NvdEcpALoqpi9tw== X-Google-Smtp-Source: ALg8bN5fReUPM9X00AxvG4rgs5k/K0xAWLkVnBzRFck8uyETLJK1JUIVJXlP/2orbsTSEM9dCxJDwA== X-Received: by 2002:a63:a91a:: with SMTP id u26mr10042588pge.349.1547141663245; Thu, 10 Jan 2019 09:34:23 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id k15sm125977409pfb.147.2019.01.10.09.34.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 09:34:22 -0800 (PST) From: John Stultz To: lkml Cc: Dan Williams , Vinod Koul , Tanglei Han , Zhuangluan Su , Ryan Grachek , Manivannan Sadhasivam , Guodong Xu , dmaengine@vger.kernel.org, Li Yu , John Stultz Subject: [PATCH 5/8 v3] dma: k3dma: Add support for hisi-dma-avail-chan Date: Thu, 10 Jan 2019 09:34:09 -0800 Message-Id: <1547141652-8660-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547141652-8660-1-git-send-email-john.stultz@linaro.org> References: <1547141652-8660-1-git-send-email-john.stultz@linaro.org> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Li Yu Add hisi-dma-avail-chan as a property for k3dma, it defines available dma channels which a non-secure mode driver can use. One sample usage of this is in Hi3660 SoC. DMA channel 0 is reserved to lpm3, which is a coprocessor for power management. So as a result, any request in kernel (which runs on main processor and in non-secure mode) should start from at least channel 1. Cc: Dan Williams Cc: Vinod Koul Cc: Tanglei Han Cc: Zhuangluan Su Cc: Ryan Grachek Cc: Manivannan Sadhasivam Cc: Guodong Xu Cc: dmaengine@vger.kernel.org Signed-off-by: Li Yu [jstultz: Reworked to use a channel mask] Signed-off-by: John Stultz --- v3: Rename to hisi-dma-avail-chan --- drivers/dma/k3dma.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index b2060bf..f4001ca 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -111,6 +111,7 @@ struct k3_dma_dev { struct dma_pool *pool; u32 dma_channels; u32 dma_requests; + u32 dma_avail_chan; unsigned int irq; }; @@ -318,6 +319,9 @@ static void k3_dma_tasklet(unsigned long arg) /* check new channel request in d->chan_pending */ spin_lock_irq(&d->lock); for (pch = 0; pch < d->dma_channels; pch++) { + if (!(d->dma_avail_chan & (1<phy[pch]; if (p->vchan == NULL && !list_empty(&d->chan_pending)) { @@ -335,6 +339,9 @@ static void k3_dma_tasklet(unsigned long arg) spin_unlock_irq(&d->lock); for (pch = 0; pch < d->dma_channels; pch++) { + if (!(d->dma_avail_chan & (1<phy[pch]; c = p->vchan; @@ -855,6 +862,13 @@ static int k3_dma_probe(struct platform_device *op) "dma-channels", &d->dma_channels); of_property_read_u32((&op->dev)->of_node, "dma-requests", &d->dma_requests); + ret = of_property_read_u32((&op->dev)->of_node, + "hisi-dma-avail-chan", &d->dma_avail_chan); + if (ret) { + dev_warn(&op->dev, + "hisi-dma-avail-chan doesn't exist, considering all as available.\n"); + d->dma_avail_chan = (u32)~0UL; + } } if (!(soc_data->flags & K3_FLAG_NOCLK)) { @@ -886,8 +900,12 @@ static int k3_dma_probe(struct platform_device *op) return -ENOMEM; for (i = 0; i < d->dma_channels; i++) { - struct k3_dma_phy *p = &d->phy[i]; + struct k3_dma_phy *p; + + if (!(d->dma_avail_chan & (1<phy[i]; p->idx = i; p->base = d->base + i * 0x40; }