linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags
@ 2023-02-24 15:22 Martin Povišer
  2023-02-24 15:22 ` [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Martin Povišer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Martin Povišer @ 2023-02-24 15:22 UTC (permalink / raw)
  To: Hector Martin, Sven Peter, Vinod Koul
  Cc: Alyssa Rosenzweig, Martin Povišer, asahi, linux-arm-kernel,
	dmaengine, linux-kernel

In addition to TX channel and RX channel interrupt flags there's
another class of 'global' interrupt flags with unknown semantics. Those
weren't being handled up to now, and they are the suspected cause of
stuck IRQ states that have been sporadically occurring. Check the global
flags and clear them if raised.

Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
---
 drivers/dma/apple-admac.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 90f28bda29c8..00cbfafe0ed9 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -75,6 +75,7 @@
 
 #define REG_TX_INTSTATE(idx)		(0x0030 + (idx) * 4)
 #define REG_RX_INTSTATE(idx)		(0x0040 + (idx) * 4)
+#define REG_GLOBAL_INTSTATE(idx)	(0x0050 + (idx) * 4)
 #define REG_CHAN_INTSTATUS(ch, idx)	(0x8010 + (ch) * 0x200 + (idx) * 4)
 #define REG_CHAN_INTMASK(ch, idx)	(0x8020 + (ch) * 0x200 + (idx) * 4)
 
@@ -672,13 +673,14 @@ static void admac_handle_chan_int(struct admac_data *ad, int no)
 static irqreturn_t admac_interrupt(int irq, void *devid)
 {
 	struct admac_data *ad = devid;
-	u32 rx_intstate, tx_intstate;
+	u32 rx_intstate, tx_intstate, global_intstate;
 	int i;
 
 	rx_intstate = readl_relaxed(ad->base + REG_RX_INTSTATE(ad->irq_index));
 	tx_intstate = readl_relaxed(ad->base + REG_TX_INTSTATE(ad->irq_index));
+	global_intstate = readl_relaxed(ad->base + REG_GLOBAL_INTSTATE(ad->irq_index));
 
-	if (!tx_intstate && !rx_intstate)
+	if (!tx_intstate && !rx_intstate && !global_intstate)
 		return IRQ_NONE;
 
 	for (i = 0; i < ad->nchannels; i += 2) {
@@ -693,6 +695,12 @@ static irqreturn_t admac_interrupt(int irq, void *devid)
 		rx_intstate >>= 1;
 	}
 
+	if (global_intstate) {
+		dev_warn(ad->dev, "clearing unknown global interrupt flag: %x\n",
+			 global_intstate);
+		writel_relaxed(~(u32) 0, ad->base + REG_GLOBAL_INTSTATE(ad->irq_index));
+	}
+
 	return IRQ_HANDLED;
 }
 
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed
  2023-02-24 15:22 [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Martin Povišer
@ 2023-02-24 15:22 ` Martin Povišer
  2023-02-24 15:22 ` [PATCH 3/3] dmaengine: apple-admac: Set src_addr_widths capability Martin Povišer
  2023-03-31 12:47 ` [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Povišer @ 2023-02-24 15:22 UTC (permalink / raw)
  To: Hector Martin, Sven Peter, Vinod Koul
  Cc: Alyssa Rosenzweig, Martin Povišer, asahi, linux-arm-kernel,
	dmaengine, linux-kernel

In terminate_all we should queue up all submitted descriptors to be
freed. We do that for the content of the 'issued' and 'submitted' lists,
but the 'current_tx' descriptor falls through the cracks as it's
removed from the 'issued' list once it gets assigned to be the current
descriptor. Explicitly queue up freeing of the 'current_tx' descriptor
to address a memory leak that is otherwise present.

Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
---
 drivers/dma/apple-admac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 00cbfafe0ed9..497bb65b7d6d 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -512,7 +512,10 @@ static int admac_terminate_all(struct dma_chan *chan)
 	admac_stop_chan(adchan);
 	admac_reset_rings(adchan);
 
-	adchan->current_tx = NULL;
+	if (adchan->current_tx) {
+		list_add_tail(&adchan->current_tx->node, &adchan->to_free);
+		adchan->current_tx = NULL;
+	}
 	/*
 	 * Descriptors can only be freed after the tasklet
 	 * has been killed (in admac_synchronize).
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/3] dmaengine: apple-admac: Set src_addr_widths capability
  2023-02-24 15:22 [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Martin Povišer
  2023-02-24 15:22 ` [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Martin Povišer
@ 2023-02-24 15:22 ` Martin Povišer
  2023-03-31 12:47 ` [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Povišer @ 2023-02-24 15:22 UTC (permalink / raw)
  To: Hector Martin, Sven Peter, Vinod Koul
  Cc: Alyssa Rosenzweig, Martin Povišer, asahi, linux-arm-kernel,
	dmaengine, linux-kernel

Add missing setting of 'src_addr_widths', which is the same as for the
other direction.

Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
---
 drivers/dma/apple-admac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 497bb65b7d6d..4cf8da77bdd9 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -861,6 +861,9 @@ static int admac_probe(struct platform_device *pdev)
 
 	dma->directions = BIT(DMA_MEM_TO_DEV) | BIT(DMA_DEV_TO_MEM);
 	dma->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+	dma->src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
+			BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
+			BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
 	dma->dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
 			BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
 			BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags
  2023-02-24 15:22 [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Martin Povišer
  2023-02-24 15:22 ` [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Martin Povišer
  2023-02-24 15:22 ` [PATCH 3/3] dmaengine: apple-admac: Set src_addr_widths capability Martin Povišer
@ 2023-03-31 12:47 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2023-03-31 12:47 UTC (permalink / raw)
  To: Martin Povišer
  Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, asahi,
	linux-arm-kernel, dmaengine, linux-kernel

On 24-02-23, 16:22, Martin Povišer wrote:
> In addition to TX channel and RX channel interrupt flags there's
> another class of 'global' interrupt flags with unknown semantics. Those
> weren't being handled up to now, and they are the suspected cause of
> stuck IRQ states that have been sporadically occurring. Check the global
> flags and clear them if raised.

Applied, thanks

-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-03-31 12:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 15:22 [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Martin Povišer
2023-02-24 15:22 ` [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Martin Povišer
2023-02-24 15:22 ` [PATCH 3/3] dmaengine: apple-admac: Set src_addr_widths capability Martin Povišer
2023-03-31 12:47 ` [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags 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).