dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver
@ 2021-03-07  4:06 Laurent Pinchart
  2021-03-07  4:06 ` [PATCH 1/2] dmaengine: xilinx: dpdma: Fix descriptor issuing on video group Laurent Pinchart
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Laurent Pinchart @ 2021-03-07  4:06 UTC (permalink / raw)
  To: dmaengine; +Cc: linux-arm-kernel, Vinod Koul, Michal Simek, Rohit Visavalia

Hello,

This small patch series fixes two issues I've experienced with the
Xilinx dpdma driver. There isn't much to summarize in the cover letter,
please see individual patches for details.

Laurent Pinchart (2):
  dmaengine: xilinx: dpdma: Fix descriptor issuing on video group
  dmaengine: xilinx: dpdma: Fix race condition in done IRQ

 drivers/dma/xilinx/xilinx_dpdma.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

-- 
Regards,

Laurent Pinchart


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

* [PATCH 1/2] dmaengine: xilinx: dpdma: Fix descriptor issuing on video group
  2021-03-07  4:06 [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Laurent Pinchart
@ 2021-03-07  4:06 ` Laurent Pinchart
  2021-03-07  4:06 ` [PATCH 2/2] dmaengine: xilinx: dpdma: Fix race condition in done IRQ Laurent Pinchart
  2021-03-16 10:45 ` [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2021-03-07  4:06 UTC (permalink / raw)
  To: dmaengine; +Cc: linux-arm-kernel, Vinod Koul, Michal Simek, Rohit Visavalia

When multiple channels are part of a video group, the transfer is
triggered only when all channels in the group are ready. The logic to do
so is incorrect, as it causes the descriptors for all channels but the
last one in a group to not being pushed to the hardware. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/dma/xilinx/xilinx_dpdma.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
index 55df63dead8d..d504112c609e 100644
--- a/drivers/dma/xilinx/xilinx_dpdma.c
+++ b/drivers/dma/xilinx/xilinx_dpdma.c
@@ -839,6 +839,7 @@ static void xilinx_dpdma_chan_queue_transfer(struct xilinx_dpdma_chan *chan)
 	struct xilinx_dpdma_tx_desc *desc;
 	struct virt_dma_desc *vdesc;
 	u32 reg, channels;
+	bool first_frame;
 
 	lockdep_assert_held(&chan->lock);
 
@@ -852,14 +853,6 @@ static void xilinx_dpdma_chan_queue_transfer(struct xilinx_dpdma_chan *chan)
 		chan->running = true;
 	}
 
-	if (chan->video_group)
-		channels = xilinx_dpdma_chan_video_group_ready(chan);
-	else
-		channels = BIT(chan->id);
-
-	if (!channels)
-		return;
-
 	vdesc = vchan_next_desc(&chan->vchan);
 	if (!vdesc)
 		return;
@@ -884,13 +877,26 @@ static void xilinx_dpdma_chan_queue_transfer(struct xilinx_dpdma_chan *chan)
 			    FIELD_PREP(XILINX_DPDMA_CH_DESC_START_ADDRE_MASK,
 				       upper_32_bits(sw_desc->dma_addr)));
 
-	if (chan->first_frame)
+	first_frame = chan->first_frame;
+	chan->first_frame = false;
+
+	if (chan->video_group) {
+		channels = xilinx_dpdma_chan_video_group_ready(chan);
+		/*
+		 * Trigger the transfer only when all channels in the group are
+		 * ready.
+		 */
+		if (!channels)
+			return;
+	} else {
+		channels = BIT(chan->id);
+	}
+
+	if (first_frame)
 		reg = XILINX_DPDMA_GBL_TRIG_MASK(channels);
 	else
 		reg = XILINX_DPDMA_GBL_RETRIG_MASK(channels);
 
-	chan->first_frame = false;
-
 	dpdma_write(xdev->reg, XILINX_DPDMA_GBL, reg);
 }
 
-- 
Regards,

Laurent Pinchart


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

* [PATCH 2/2] dmaengine: xilinx: dpdma: Fix race condition in done IRQ
  2021-03-07  4:06 [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Laurent Pinchart
  2021-03-07  4:06 ` [PATCH 1/2] dmaengine: xilinx: dpdma: Fix descriptor issuing on video group Laurent Pinchart
@ 2021-03-07  4:06 ` Laurent Pinchart
  2021-03-16 10:45 ` [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2021-03-07  4:06 UTC (permalink / raw)
  To: dmaengine; +Cc: linux-arm-kernel, Vinod Koul, Michal Simek, Rohit Visavalia

The active descriptor pointer is accessed from different contexts,
including different interrupt handlers, and its access must be protected
by the channel's lock. This wasn't done in the done IRQ handler. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/dma/xilinx/xilinx_dpdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
index d504112c609e..70b29bd079c9 100644
--- a/drivers/dma/xilinx/xilinx_dpdma.c
+++ b/drivers/dma/xilinx/xilinx_dpdma.c
@@ -1048,13 +1048,14 @@ static int xilinx_dpdma_chan_stop(struct xilinx_dpdma_chan *chan)
  */
 static void xilinx_dpdma_chan_done_irq(struct xilinx_dpdma_chan *chan)
 {
-	struct xilinx_dpdma_tx_desc *active = chan->desc.active;
+	struct xilinx_dpdma_tx_desc *active;
 	unsigned long flags;
 
 	spin_lock_irqsave(&chan->lock, flags);
 
 	xilinx_dpdma_debugfs_desc_done_irq(chan);
 
+	active = chan->desc.active;
 	if (active)
 		vchan_cyclic_callback(&active->vdesc);
 	else
-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver
  2021-03-07  4:06 [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Laurent Pinchart
  2021-03-07  4:06 ` [PATCH 1/2] dmaengine: xilinx: dpdma: Fix descriptor issuing on video group Laurent Pinchart
  2021-03-07  4:06 ` [PATCH 2/2] dmaengine: xilinx: dpdma: Fix race condition in done IRQ Laurent Pinchart
@ 2021-03-16 10:45 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2021-03-16 10:45 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: dmaengine, linux-arm-kernel, Michal Simek, Rohit Visavalia

On 07-03-21, 06:06, Laurent Pinchart wrote:
> Hello,
> 
> This small patch series fixes two issues I've experienced with the
> Xilinx dpdma driver. There isn't much to summarize in the cover letter,
> please see individual patches for details.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2021-03-16 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07  4:06 [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Laurent Pinchart
2021-03-07  4:06 ` [PATCH 1/2] dmaengine: xilinx: dpdma: Fix descriptor issuing on video group Laurent Pinchart
2021-03-07  4:06 ` [PATCH 2/2] dmaengine: xilinx: dpdma: Fix race condition in done IRQ Laurent Pinchart
2021-03-16 10:45 ` [PATCH 0/2] dmaengine: Fix issues in Xilinx dpdma driver Vinod Koul

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).