linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Li Yu <liyu65@hisilicon.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vinod Koul <vkoul@kernel.org>,
	Tanglei Han <hantanglei@huawei.com>,
	Zhuangluan Su <suzhuangluan@hisilicon.com>,
	Ryan Grachek <ryan@edited.us>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Guodong Xu <guodong.xu@linaro.org>,
	dmaengine@vger.kernel.org, John Stultz <john.stultz@linaro.org>
Subject: [PATCH 5/8 v2] dma: k3dma: Add support to dma_avail_chan
Date: Fri,  4 Jan 2019 12:56:25 -0800	[thread overview]
Message-ID: <1546635388-13795-6-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1546635388-13795-1-git-send-email-john.stultz@linaro.org>

From: Li Yu <liyu65@hisilicon.com>

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 <dan.j.williams@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Tanglei Han <hantanglei@huawei.com>
Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
Cc: Ryan Grachek <ryan@edited.us>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: dmaengine@vger.kernel.org
Signed-off-by: Li Yu <liyu65@hisilicon.com>
[jstultz: Reworked to use a channel mask]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 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..431094b 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<<pch)))
+			continue;
+
 		p = &d->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<<pch)))
+			continue;
+
 		if (pch_alloc & (1 << pch)) {
 			p = &d->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,
+				"dma-avail-chan", &d->dma_avail_chan);
+		if (ret) {
+			dev_warn(&op->dev,
+				 "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<<i)))
+			continue;
 
+		p = &d->phy[i];
 		p->idx = i;
 		p->base = d->base + i * 0x40;
 	}
-- 
2.7.4


  parent reply	other threads:[~2019-01-04 20:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 20:56 [PATCH 0/8 v2] k3dma patches to add support for hi3660/HiKey960 John Stultz
2019-01-04 20:56 ` [PATCH 1/8 v2] Documentation: bindings: k3dma: Extend the k3dma driver binding to support hisi-asp John Stultz
2019-01-04 20:56 ` [PATCH 2/8 v2] Documentation: bindings: k3dma: Add binding for dma-avail-chan John Stultz
2019-01-05  4:00   ` Manivannan Sadhasivam
2019-01-05  4:39     ` John Stultz
2019-01-05  4:53       ` Manivannan Sadhasivam
2019-01-05  4:58         ` John Stultz
2019-01-05 13:46         ` Vinod Koul
2019-01-05 14:08           ` Manivannan Sadhasivam
2019-01-07  6:24             ` Vinod Koul
2019-01-04 20:56 ` [PATCH 3/8 v2] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware John Stultz
2019-01-05  3:41   ` Manivannan Sadhasivam
2019-01-05  5:22     ` John Stultz
2019-01-05  5:39       ` Manivannan Sadhasivam
2019-01-05  5:44         ` John Stultz
2019-01-05  5:48           ` Manivannan Sadhasivam
2019-01-04 20:56 ` [PATCH 4/8 v2] dma: k3dma: Delete axi_config John Stultz
2019-01-05  3:44   ` Manivannan Sadhasivam
2019-01-04 20:56 ` John Stultz [this message]
2019-01-04 20:56 ` [PATCH 6/8 v2] arm64: dts: hi3660: Add dma to uart nodes John Stultz
2019-01-05  3:49   ` Manivannan Sadhasivam
2019-01-05  4:34     ` John Stultz
2019-01-05  5:37       ` John Stultz
2019-01-04 20:56 ` [PATCH 7/8 v2] arm64: dts: hi3660: Add hisi asp dma device John Stultz
2019-01-05  3:50   ` Manivannan Sadhasivam
2019-01-04 20:56 ` [PATCH 8/8 v2] arm64: dts: hi3660: Fixup unofficial dma-min-chan to dma-avail-chan John Stultz
2019-01-05  3:37 ` [PATCH 0/8 v2] k3dma patches to add support for hi3660/HiKey960 Manivannan Sadhasivam
2019-01-05  4:28   ` John Stultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1546635388-13795-6-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=guodong.xu@linaro.org \
    --cc=hantanglei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liyu65@hisilicon.com \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=ryan@edited.us \
    --cc=suzhuangluan@hisilicon.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).