From patchwork Fri Jan 4 20:56:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 154797 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1020926ljp; Fri, 4 Jan 2019 12:56:41 -0800 (PST) X-Received: by 2002:a17:902:20c6:: with SMTP id v6mr52858122plg.156.1546635400979; Fri, 04 Jan 2019 12:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546635400; cv=none; d=google.com; s=arc-20160816; b=u0jY1/z7KFRrTMYHtAj6zINM/Gny9AC9kSHl7opTmhleicWUkhxhdKTOkjKb+BwDbd 1wBsm1BrT8jjQA3pryQ5gfTyxhWHzu6ttWIBkweTufSgWClIpLETB/QrLzmIp66WXnVH YA5Ye7plG/F6ceZB7lhBqsTcWsZ8BMJn1CLa8U5ilyET4ek63EyVnSRdgKLO7xkS2hDk ZCnnQV3l7d6GxOUnleatdm2GQ3O0rre2MWYxo3R90GP3knpPHj7RT3rmPBNymndXVeGV atHgz8k48f1y+P47TQkawxzQMUjF/1jOtx+UTTRBjes4Ci6gtSl2RbKyzT493Jz3MNWo Blnw== 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=4Vbeu6DpRnZCwP7K+9a0P9RRTER2t/Z433kGqekFBrY=; b=BC3+9LYEnW7BgyaBrMd6CrTc/nej1Kzk9gl+FjZvjRYNoyevI/3wJY/DApfjXcmIoO doFEILvKsEit4eZHZsGM2x4q5ET6aZ2waWNp7u6cMhzrd9dN8h1drLjvgKX2e5aDA3l1 47742KvTycaCrF4kwIBEr6Kaxz1oNEzbAobzWu6rMBKjQKFE7B9dTXsZx8StkqO1j6j6 zM0puo1p+vOmBoK9he8DABMaQGmCZ3HFhK4WdXWnLBmpLaxFlDMdtcHLOHcJQcigwc1B 2+YPpwB6uzquBKRaMQSjqMTmwrCPX4y4gimYE4z8FeS88g6j//clOXk3CViCXZuaVfTQ qSgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HrTCH0zz; 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 u69sor28795814pgd.63.2019.01.04.12.56.40 for (Google Transport Security); Fri, 04 Jan 2019 12:56:40 -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=HrTCH0zz; 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=4Vbeu6DpRnZCwP7K+9a0P9RRTER2t/Z433kGqekFBrY=; b=HrTCH0zz+n6La7vqDvNKqVoi9EadZuIp9wKa9nVjaa+GZpAvVbNfqnKkXY2If1wD55 1JCUORAappLk7F/4W8yjdSB/nH7jiKjS2ewP51awR+I/LP5XTl8MveF/puXTPOWOjt9A 7yTjkkGp35GsgZKkNL78hh3FRXWa/08398Bgw= 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=4Vbeu6DpRnZCwP7K+9a0P9RRTER2t/Z433kGqekFBrY=; b=Ujwa0RPYYyYeRUt28uAemMB2OIPZYhPVzdjQD0NsEnRuukbOClW1BecNFhir+9M1vJ yn9gLzrm1obldkB3oJAXUqfzf6emg2FrVcFKnWBPVMO7RR4W8Yr7govJTlgWIRiwkwqQ FDZVI024CZcs3ufZdmfFdhUed65rl+iTRGFI59ZzPURBZxTFLvrrWbyhOf1XIT2F+i8A vAKXukfGTdDjtn5jM2usCkSj+5o/w6iv96NrdcNrLCjFT9nYjJ4vf3LhAuaUdAHiok4e 3uvu4WPbKYjY+6Oat1k+G64/b2aM2wroyOCGciYeLY5wzMZb8Cmy8kOFhYNsd10X3IY9 jQAw== X-Gm-Message-State: AJcUuke9w4N/hl1RpETpLS5p4Tba3G1N48DSK1KUSiD6ELHLI4wnfALH UUlxtzYgwBQS5t9v37SlMEngmYOl X-Google-Smtp-Source: ALg8bN7jekfTkokUDuAB0tR3PpbgapZjIX70zUYb4Eon0+Mzrw5OPpJfkJmPRNyXXAePaGZwsq6ReQ== X-Received: by 2002:a63:ee0e:: with SMTP id e14mr2835866pgi.8.1546635400454; Fri, 04 Jan 2019 12:56:40 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l3sm98058334pga.92.2019.01.04.12.56.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Jan 2019 12:56:39 -0800 (PST) From: John Stultz To: lkml Cc: Li Yu , Dan Williams , Vinod Koul , Tanglei Han , Zhuangluan Su , Ryan Grachek , Manivannan Sadhasivam , Guodong Xu , dmaengine@vger.kernel.org, John Stultz Subject: [PATCH 5/8 v2] dma: k3dma: Add support to dma_avail_chan Date: Fri, 4 Jan 2019 12:56:25 -0800 Message-Id: <1546635388-13795-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546635388-13795-1-git-send-email-john.stultz@linaro.org> References: <1546635388-13795-1-git-send-email-john.stultz@linaro.org> From: Li Yu 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 --- 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..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<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, + "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<phy[i]; p->idx = i; p->base = d->base + i * 0x40; }