All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization
@ 2020-04-26 19:08 ` Dmitry Osipenko
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2020-04-26 19:08 UTC (permalink / raw)
  To: Laxman Dewangan, Vinod Koul, Dan Williams, Thierry Reding,
	Jonathan Hunter
  Cc: dmaengine, linux-tegra, linux-kernel

DMA synchronization hook checks whether interrupt is raised by testing
corresponding bit in a hardware status register, and thus, clock should
be enabled in this case, otherwise CPU may hang if synchronization is
invoked while Runtime PM is in suspended state. This patch resumes the RPM
during of the DMA synchronization process in order to avoid potential
problems. It is a minor clean up of a previous commit, no real problem is
fixed by this patch because currently RPM is always in a resumed state
while DMA is synchronized, although this may change in the future.

Fixes: 6697255f239f ("dmaengine: tegra-apb: Improve DMA synchronization")
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/dma/tegra20-apb-dma.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index a42c0b4d14ac..55fc7400f717 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -816,6 +816,13 @@ static bool tegra_dma_eoc_interrupt_deasserted(struct tegra_dma_channel *tdc)
 static void tegra_dma_synchronize(struct dma_chan *dc)
 {
 	struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
+	int err;
+
+	err = pm_runtime_get_sync(tdc->tdma->dev);
+	if (err < 0) {
+		dev_err(tdc2dev(tdc), "Failed to synchronize DMA: %d\n", err);
+		return;
+	}
 
 	/*
 	 * CPU, which handles interrupt, could be busy in
@@ -825,6 +832,8 @@ static void tegra_dma_synchronize(struct dma_chan *dc)
 	wait_event(tdc->wq, tegra_dma_eoc_interrupt_deasserted(tdc));
 
 	tasklet_kill(&tdc->tasklet);
+
+	pm_runtime_put(tdc->tdma->dev);
 }
 
 static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc,
-- 
2.26.0


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

* [PATCH v1] dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization
@ 2020-04-26 19:08 ` Dmitry Osipenko
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2020-04-26 19:08 UTC (permalink / raw)
  To: Laxman Dewangan, Vinod Koul, Dan Williams, Thierry Reding,
	Jonathan Hunter
  Cc: dmaengine-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

DMA synchronization hook checks whether interrupt is raised by testing
corresponding bit in a hardware status register, and thus, clock should
be enabled in this case, otherwise CPU may hang if synchronization is
invoked while Runtime PM is in suspended state. This patch resumes the RPM
during of the DMA synchronization process in order to avoid potential
problems. It is a minor clean up of a previous commit, no real problem is
fixed by this patch because currently RPM is always in a resumed state
while DMA is synchronized, although this may change in the future.

Fixes: 6697255f239f ("dmaengine: tegra-apb: Improve DMA synchronization")
Signed-off-by: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/dma/tegra20-apb-dma.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index a42c0b4d14ac..55fc7400f717 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -816,6 +816,13 @@ static bool tegra_dma_eoc_interrupt_deasserted(struct tegra_dma_channel *tdc)
 static void tegra_dma_synchronize(struct dma_chan *dc)
 {
 	struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
+	int err;
+
+	err = pm_runtime_get_sync(tdc->tdma->dev);
+	if (err < 0) {
+		dev_err(tdc2dev(tdc), "Failed to synchronize DMA: %d\n", err);
+		return;
+	}
 
 	/*
 	 * CPU, which handles interrupt, could be busy in
@@ -825,6 +832,8 @@ static void tegra_dma_synchronize(struct dma_chan *dc)
 	wait_event(tdc->wq, tegra_dma_eoc_interrupt_deasserted(tdc));
 
 	tasklet_kill(&tdc->tasklet);
+
+	pm_runtime_put(tdc->tdma->dev);
 }
 
 static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc,
-- 
2.26.0

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

* Re: [PATCH v1] dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization
@ 2020-04-27 16:05   ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2020-04-27 16:05 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Laxman Dewangan, Dan Williams, Thierry Reding, Jonathan Hunter,
	dmaengine, linux-tegra, linux-kernel

On 26-04-20, 22:08, Dmitry Osipenko wrote:
> DMA synchronization hook checks whether interrupt is raised by testing
> corresponding bit in a hardware status register, and thus, clock should
> be enabled in this case, otherwise CPU may hang if synchronization is
> invoked while Runtime PM is in suspended state. This patch resumes the RPM
> during of the DMA synchronization process in order to avoid potential
> problems. It is a minor clean up of a previous commit, no real problem is
> fixed by this patch because currently RPM is always in a resumed state
> while DMA is synchronized, although this may change in the future.

Applied, thanks

-- 
~Vinod

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

* Re: [PATCH v1] dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization
@ 2020-04-27 16:05   ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2020-04-27 16:05 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Laxman Dewangan, Dan Williams, Thierry Reding, Jonathan Hunter,
	dmaengine-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 26-04-20, 22:08, Dmitry Osipenko wrote:
> DMA synchronization hook checks whether interrupt is raised by testing
> corresponding bit in a hardware status register, and thus, clock should
> be enabled in this case, otherwise CPU may hang if synchronization is
> invoked while Runtime PM is in suspended state. This patch resumes the RPM
> during of the DMA synchronization process in order to avoid potential
> problems. It is a minor clean up of a previous commit, no real problem is
> fixed by this patch because currently RPM is always in a resumed state
> while DMA is synchronized, although this may change in the future.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2020-04-27 16:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 19:08 [PATCH v1] dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization Dmitry Osipenko
2020-04-26 19:08 ` Dmitry Osipenko
2020-04-27 16:05 ` Vinod Koul
2020-04-27 16:05   ` Vinod Koul

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.