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: 155232 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2159338jaa; Thu, 10 Jan 2019 09:34:23 -0800 (PST) X-Received: by 2002:a63:e247:: with SMTP id y7mr7597443pgj.84.1547141663658; Thu, 10 Jan 2019 09:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547141663; cv=none; d=google.com; s=arc-20160816; b=a0hU9uejfRAMpVXge/6l3PiXXMC5yPWJrYGlhOOQ0NyZwtBN2fzp2AGUuu46gr6/2i i/FeIApVZCmEaykSusRmjvdSj1rrGmnyRMkGI1ogNMdIbWT9TzD71K1hbhjeII0Fr31X ixhGWMyb/V5CIpuLAg6pSqlZAirY/eGwIDfWFlycfIeBXFjhJreaSL7O7JkVST/1sbqo Z9ao/4h8Fj7VnOrZFiJfAtDSBP2zsRvCF2OELPnsnWqSLfNrz2JqC8qg0B3D3vbFiNd3 K8PO8Rtn9uQNA34/hO1KDXcPUguSwqrWtgqRrmYQ0VyrHolXiFEfpl6trZvJJb7BUDC2 6kNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Acz25rUAnYOwtdV3EAKACd8ebfPIsH2pLWOoO+LfHkQ=; b=eQqBUT9M5iK3sABOK+0X80REpC2eW+k//nT+b9l1Po6O9KgVLkZKBR2nKhImsdJMQa JO2nsEj/uW4CB8nfCpPFZu4BhhZQOyfKRSbm/pEm5/PD18fhD4OXn5jIcfvpXaKpW80e FV7VbavCHVSGTsB3nErcccTluStdyNUPXQjuRb/FvggMLfwpgh5mQwqPYlUFyeyn8bMX pQjQFa23PUsP855v+5fGC2/QjO8EgxFSXTX5P49lUvioTEUUMZOFCVtWRe5xkQvxxq4u uD3wygC21TFKwnAzY+bcqnJS7LmliGWBopmTo3Tx+okMX8QelPC/Am3zgjlvgEWpjaF0 uMKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HL6eVqd3; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z186sor51371025pgd.6.2019.01.10.09.34.23 for (Google Transport Security); Thu, 10 Jan 2019 09:34:23 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HL6eVqd3; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=IC3+AaWIrdfJfdEljQ5q0ZrFJdR8PC9Y50BNQh6pw4l7uTsd3y5ZG+zT9+IpmtmW8g NAFGifHiSPYaIs+8ZSJ07CLKWwILSHMEddcz38g8I8HT4DT/POo1PAIrpZ9HAfuj03f6 3VzTLwp+Ocx7QwJieZ5VbyclCTQooY1UYQUVgqbGY+hQzCUan0yICIrttFGQ/2uJzwo9 ssigx4Vgon1pHhlqd3oYr9BCzB/dyuNhUgA6kNVwhM1CESuc9tG7sphLFs8uWQy/xj35 gjTTDJ1RBhLcKPF+KSJIM7x4hE3rqtU3R1e5HdTxW3fpy8G3xe53SjWEmn1IlDRlUC6q vzzw== X-Gm-Message-State: AJcUukeOnrHbScKXdlYfAlFLnSI/9DHQD5kkJ+b7KQ3oaMMMGFGpx9bS d205O4LGSMUlBtUGzVenHx4dIWni 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) Return-Path: 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> 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(-) -- 2.7.4 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; }