All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] dmaengine: qcom: bam_dma: fixes for remotely controlled bam
@ 2018-02-15 12:25 srinivas.kandagatla
  2018-03-01  8:44 ` Vinod Koul
  0 siblings, 1 reply; 15+ messages in thread
From: srinivas.kandagatla @ 2018-02-15 12:25 UTC (permalink / raw)
  To: vinod.koul, andy.gross, dmaengine
  Cc: robh+dt, mark.rutland, david.brown, dan.j.williams, devicetree,
	linux-arm-msm, linux-kernel, linux-soc, yanhe, ramkri, sdharia,
	Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Hi Andy,

I did hit few issues while trying out SLIMBus BAM on DB820c, this BAM instance
is remotely controlled and powered up after ADSP is booted using QMI commands.

Firstly some of the master registers are written even when the BAM is remotely
controlled, and secondly reading registers when bam is not ready yet.

These 4 patches address these issues, there are few more issues like doing PM
in simillar usecase, these will be addressed soon.

Thanks,
Srini

Changes since v2:
	return clk error in default case, suggested by Bjorn

Srinivas Kandagatla (5):
  dmaengine: qcom: bam_dma: make bam clk optional
  dt-bindings: dmaengine: bam_dma: add remote controlled bindings
  dmaengine: qcom: bam_dma: get num-channels and num-ees from dt
  dmaengine: qcom: bam_dma: do not write to global regs in remote mode
  dmaengine: qcom: bam_dma: disable runtime pm on remote controlled

 .../devicetree/bindings/dma/qcom_bam_dma.txt       |  4 ++
 drivers/dma/qcom/bam_dma.c                         | 59 +++++++++++++++++-----
 2 files changed, 49 insertions(+), 14 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [v3,1/5] dmaengine: qcom: bam_dma: make bam clk optional
  2018-02-15 12:25 [PATCH v3 0/5] dmaengine: qcom: bam_dma: fixes for remotely controlled bam srinivas.kandagatla
@ 2018-02-15 12:25 ` srinivas.kandagatla
  0 siblings, 0 replies; 15+ messages in thread
From: Srinivas Kandagatla @ 2018-02-15 12:25 UTC (permalink / raw)
  To: vinod.koul, andy.gross, dmaengine
  Cc: robh+dt, mark.rutland, david.brown, dan.j.williams, devicetree,
	linux-arm-msm, linux-kernel, linux-soc, yanhe, ramkri, sdharia,
	Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

When BAM is remotely controlled it does not sound correct to control
its clk on Linux side. Make it optional, so that its not mandatory
for remote controlled BAM instances.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/dma/qcom/bam_dma.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index d076940e0c69..b79691fcc82d 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -1233,8 +1233,12 @@ static int bam_dma_probe(struct platform_device *pdev)
 						"qcom,controlled-remotely");
 
 	bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
-	if (IS_ERR(bdev->bamclk))
-		return PTR_ERR(bdev->bamclk);
+	if (IS_ERR(bdev->bamclk)) {
+		if (!bdev->controlled_remotely)
+			return PTR_ERR(bdev->bamclk);
+
+		bdev->bamclk = NULL;
+	}
 
 	ret = clk_prepare_enable(bdev->bamclk);
 	if (ret) {

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [v3,2/5] dt-bindings: dmaengine: bam_dma: add remote controlled bindings
  2018-02-15 12:25 [PATCH v3 0/5] dmaengine: qcom: bam_dma: fixes for remotely controlled bam srinivas.kandagatla
@ 2018-02-15 12:25 ` srinivas.kandagatla
  0 siblings, 0 replies; 15+ messages in thread
From: Srinivas Kandagatla @ 2018-02-15 12:25 UTC (permalink / raw)
  To: vinod.koul, andy.gross, dmaengine
  Cc: robh+dt, mark.rutland, david.brown, dan.j.williams, devicetree,
	linux-arm-msm, linux-kernel, linux-soc, yanhe, ramkri, sdharia,
	Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

This patch adds 2 new properties for remote controlled bam dt bindings.
1. num-channels to indicate number of dma channels.
2. qcom,num-ees to indicate number of Execution Environments.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 Documentation/devicetree/bindings/dma/qcom_bam_dma.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt b/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
index 9cbf5d9df8fd..cf5b9e44432c 100644
--- a/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
+++ b/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
@@ -15,6 +15,10 @@ Required properties:
   the secure world.
 - qcom,controlled-remotely : optional, indicates that the bam is controlled by
   remote proccessor i.e. execution environment.
+- num-channels : optional, indicates supported number of DMA channels in a
+  remotely controlled bam.
+- qcom,num-ees : optional, indicates supported number of Execution Environments
+  in a remotely controlled bam.
 
 Example:
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [v3,3/5] dmaengine: qcom: bam_dma: get num-channels and num-ees from dt
@ 2018-02-15 12:25 ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
  0 siblings, 0 replies; 15+ messages in thread
From: Srinivas Kandagatla @ 2018-02-15 12:25 UTC (permalink / raw)
  To: vinod.koul, andy.gross, dmaengine
  Cc: robh+dt, mark.rutland, david.brown, dan.j.williams, devicetree,
	linux-arm-msm, linux-kernel, linux-soc, yanhe, ramkri, sdharia,
	Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

When Linux is master of BAM, it can directly read registers to know number
of supported channels, however when its remotely controlled reading these
registers would trigger a crash if the BAM is not yet initialized or
powered up on the remote side.

This patch allows driver to read num-channels and num-ees from Device Tree
for remotely controlled BAM.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/dma/qcom/bam_dma.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index b79691fcc82d..139e9f5e47a9 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -393,6 +393,7 @@ struct bam_device {
 	struct device_dma_parameters dma_parms;
 	struct bam_chan *channels;
 	u32 num_channels;
+	u32 num_ees;
 
 	/* execution environment ID, from DT */
 	u32 ee;
@@ -1128,15 +1129,19 @@ static int bam_init(struct bam_device *bdev)
 	u32 val;
 
 	/* read revision and configuration information */
-	val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)) >> NUM_EES_SHIFT;
-	val &= NUM_EES_MASK;
+	if (!bdev->num_ees) {
+		val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
+		bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
+	}
 
 	/* check that configured EE is within range */
-	if (bdev->ee >= val)
+	if (bdev->ee >= bdev->num_ees)
 		return -EINVAL;
 
-	val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
-	bdev->num_channels = val & BAM_NUM_PIPES_MASK;
+	if (!bdev->num_channels) {
+		val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
+		bdev->num_channels = val & BAM_NUM_PIPES_MASK;
+	}
 
 	if (bdev->controlled_remotely)
 		return 0;
@@ -1232,6 +1237,18 @@ static int bam_dma_probe(struct platform_device *pdev)
 	bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
 						"qcom,controlled-remotely");
 
+	if (bdev->controlled_remotely) {
+		ret = of_property_read_u32(pdev->dev.of_node, "num-channels",
+					   &bdev->num_channels);
+		if (ret)
+			dev_err(bdev->dev, "num-channels unspecified in dt\n");
+
+		ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees",
+					   &bdev->num_ees);
+		if (ret)
+			dev_err(bdev->dev, "num-ees unspecified in dt\n");
+	}
+
 	bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
 	if (IS_ERR(bdev->bamclk)) {
 		if (!bdev->controlled_remotely)

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [v3,4/5] dmaengine: qcom: bam_dma: do not write to global regs in remote mode
  2018-02-15 12:25 [PATCH v3 0/5] dmaengine: qcom: bam_dma: fixes for remotely controlled bam srinivas.kandagatla
@ 2018-02-15 12:25 ` srinivas.kandagatla
  0 siblings, 0 replies; 15+ messages in thread
From: Srinivas Kandagatla @ 2018-02-15 12:25 UTC (permalink / raw)
  To: vinod.koul, andy.gross, dmaengine
  Cc: robh+dt, mark.rutland, david.brown, dan.j.williams, devicetree,
	linux-arm-msm, linux-kernel, linux-soc, yanhe, ramkri, sdharia,
	Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

BAM_DESC_CNT_TRSHLD register is global register, which can only be written
when BAM is in master mode, So check the mode of operation before writing
it.

Without this check SOC's xPU would catch such access and crash the system.
First noticed on DB820c while testing SLIMBus BAM.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/dma/qcom/bam_dma.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 139e9f5e47a9..6919f501b9f3 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -935,12 +935,15 @@ static void bam_apply_new_config(struct bam_chan *bchan,
 	struct bam_device *bdev = bchan->bdev;
 	u32 maxburst;
 
-	if (dir == DMA_DEV_TO_MEM)
-		maxburst = bchan->slave.src_maxburst;
-	else
-		maxburst = bchan->slave.dst_maxburst;
+	if (!bdev->controlled_remotely) {
+		if (dir == DMA_DEV_TO_MEM)
+			maxburst = bchan->slave.src_maxburst;
+		else
+			maxburst = bchan->slave.dst_maxburst;
 
-	writel_relaxed(maxburst, bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
+		writel_relaxed(maxburst,
+			       bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
+	}
 
 	bchan->reconfigure = 0;
 }

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [v3,5/5] dmaengine: qcom: bam_dma: disable runtime pm on remote controlled
  2018-02-15 12:25 [PATCH v3 0/5] dmaengine: qcom: bam_dma: fixes for remotely controlled bam srinivas.kandagatla
@ 2018-02-15 12:25 ` srinivas.kandagatla
  0 siblings, 0 replies; 15+ messages in thread
From: Srinivas Kandagatla @ 2018-02-15 12:25 UTC (permalink / raw)
  To: vinod.koul, andy.gross, dmaengine
  Cc: robh+dt, mark.rutland, david.brown, dan.j.williams, devicetree,
	linux-arm-msm, linux-kernel, linux-soc, yanhe, ramkri, sdharia,
	Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Remotely controlled BAM instance should not do any power management from
CPU side, as cpu can not reliably say if the BAM is busy or not.

Disable it for such instances.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/dma/qcom/bam_dma.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 6919f501b9f3..d29275b97e84 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -1333,6 +1333,11 @@ static int bam_dma_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_unregister_dma;
 
+	if (bdev->controlled_remotely) {
+		pm_runtime_disable(&pdev->dev);
+		return 0;
+	}
+
 	pm_runtime_irq_safe(&pdev->dev);
 	pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY);
 	pm_runtime_use_autosuspend(&pdev->dev);
@@ -1416,7 +1421,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev)
 {
 	struct bam_device *bdev = dev_get_drvdata(dev);
 
-	pm_runtime_force_suspend(dev);
+	if (!bdev->controlled_remotely)
+		pm_runtime_force_suspend(dev);
 
 	clk_unprepare(bdev->bamclk);
 
@@ -1432,7 +1438,8 @@ static int __maybe_unused bam_dma_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	pm_runtime_force_resume(dev);
+	if (!bdev->controlled_remotely)
+		pm_runtime_force_resume(dev);
 
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [v3,2/5] dt-bindings: dmaengine: bam_dma: add remote controlled bindings
  2018-02-15 12:25 ` [PATCH v3 2/5] " srinivas.kandagatla
@ 2018-02-19 14:35 ` Rob Herring
  -1 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2018-02-19 14:35 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: vinod.koul, andy.gross, dmaengine, mark.rutland, david.brown,
	dan.j.williams, devicetree, linux-arm-msm, linux-kernel,
	linux-soc, yanhe, ramkri, sdharia

On Thu, Feb 15, 2018 at 12:25:08PM +0000, srinivas.kandagatla@linaro.org wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> 
> This patch adds 2 new properties for remote controlled bam dt bindings.
> 1. num-channels to indicate number of dma channels.
> 2. qcom,num-ees to indicate number of Execution Environments.
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  Documentation/devicetree/bindings/dma/qcom_bam_dma.txt | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-03-01  8:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-15 12:25 [PATCH v3 0/5] dmaengine: qcom: bam_dma: fixes for remotely controlled bam srinivas.kandagatla
2018-03-01  8:44 ` Vinod Koul
  -- strict thread matches above, loose matches on Subject: below --
2018-02-15 12:25 [v3,1/5] dmaengine: qcom: bam_dma: make bam clk optional Srinivas Kandagatla
2018-02-15 12:25 ` [PATCH v3 1/5] " srinivas.kandagatla
2018-02-15 12:25 [v3,2/5] dt-bindings: dmaengine: bam_dma: add remote controlled bindings Srinivas Kandagatla
2018-02-15 12:25 ` [PATCH v3 2/5] " srinivas.kandagatla
2018-02-15 12:25 [v3,3/5] dmaengine: qcom: bam_dma: get num-channels and num-ees from dt Srinivas Kandagatla
2018-02-15 12:25 ` [PATCH v3 3/5] " srinivas.kandagatla
2018-02-15 12:25 ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
2018-02-15 12:25 [v3,4/5] dmaengine: qcom: bam_dma: do not write to global regs in remote mode Srinivas Kandagatla
2018-02-15 12:25 ` [PATCH v3 4/5] " srinivas.kandagatla
2018-02-15 12:25 [v3,5/5] dmaengine: qcom: bam_dma: disable runtime pm on remote controlled Srinivas Kandagatla
2018-02-15 12:25 ` [PATCH v3 5/5] " srinivas.kandagatla
2018-02-19 14:35 [v3,2/5] dt-bindings: dmaengine: bam_dma: add remote controlled bindings Rob Herring
2018-02-19 14:35 ` [PATCH v3 2/5] " Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.