All of lore.kernel.org
 help / color / mirror / Atom feed
* dw-axi-dmac updates (debug, minor bugfixes)
@ 2022-07-08 17:01 Ben Dooks
  2022-07-08 17:01 ` [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error Ben Dooks
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Ben Dooks @ 2022-07-08 17:01 UTC (permalink / raw)
  To: dmaengine, Eugeniy.Paltsev
  Cc: linux-kernel, vkoul, Sudip Mukherjee, Jude Onyenegecha

During some recent testing, it was useful to have a dump of the
registers during an channel dump and a couple of minor bugs were
found with issues where a slow response or race condition occured.



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

* [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error
  2022-07-08 17:01 dw-axi-dmac updates (debug, minor bugfixes) Ben Dooks
@ 2022-07-08 17:01 ` Ben Dooks
  2022-07-21 12:30   ` Vinod Koul
  2022-07-08 17:01 ` [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error Ben Dooks
  2022-07-08 17:01 ` [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor Ben Dooks
  2 siblings, 1 reply; 8+ messages in thread
From: Ben Dooks @ 2022-07-08 17:01 UTC (permalink / raw)
  To: dmaengine, Eugeniy.Paltsev
  Cc: linux-kernel, vkoul, Sudip Mukherjee, Jude Onyenegecha, Ben Dooks

On channel error, dump the channel register state before
the channel's LLI entries to see what the controller was
actually doing when the error happend.

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
---
 .../dma/dw-axi-dmac/dw-axi-dmac-platform.c    | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index e9c9bcb1f5c2..75c537153e92 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -79,6 +79,20 @@ axi_chan_iowrite64(struct axi_dma_chan *chan, u32 reg, u64 val)
 	iowrite32(upper_32_bits(val), chan->chan_regs + reg + 4);
 }
 
+static inline u64
+axi_chan_ioread64(struct axi_dma_chan *chan, u32 reg)
+{
+	u32 high, low;
+	u64 result;
+
+	low = ioread32(chan->chan_regs + reg);
+	high = ioread32(chan->chan_regs + reg + 4);
+
+	result = low;
+	result |= (u64)high << 32;
+	return result;
+}
+
 static inline void axi_chan_config_write(struct axi_dma_chan *chan,
 					 struct axi_dma_chan_config *config)
 {
@@ -979,6 +993,18 @@ static int dw_axi_dma_chan_slave_config(struct dma_chan *dchan,
 	return 0;
 }
 
+static void axi_chan_dump_regs(struct axi_dma_chan *chan)
+{
+	dev_err(dchan2dev(&chan->vc.chan),
+		"R: SAR: 0x%llx DAR: 0x%llx LLP: 0x%llx BTS 0x%x CTL: 0x%x:%08x\n",
+		axi_chan_ioread64(chan, CH_SAR),
+		axi_chan_ioread64(chan, CH_DAR),
+		axi_chan_ioread64(chan, CH_LLP),
+		axi_chan_ioread32(chan, CH_BLOCK_TS),
+		axi_chan_ioread32(chan, CH_CTL_H),
+		axi_chan_ioread32(chan, CH_CTL_L));
+}
+
 static void axi_chan_dump_lli(struct axi_dma_chan *chan,
 			      struct axi_dma_hw_desc *desc)
 {
@@ -1020,6 +1046,8 @@ static noinline void axi_chan_handle_err(struct axi_dma_chan *chan, u32 status)
 	dev_err(chan2dev(chan),
 		"Bad descriptor submitted for %s, cookie: %d, irq: 0x%08x\n",
 		axi_chan_name(chan), vd->tx.cookie, status);
+
+	axi_chan_dump_regs(chan);
 	axi_chan_list_dump_lli(chan, vd_to_axi_desc(vd));
 
 	vchan_cookie_complete(vd);
-- 
2.35.1


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

* [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error
  2022-07-08 17:01 dw-axi-dmac updates (debug, minor bugfixes) Ben Dooks
  2022-07-08 17:01 ` [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error Ben Dooks
@ 2022-07-08 17:01 ` Ben Dooks
  2022-07-21 12:33   ` Vinod Koul
  2022-07-08 17:01 ` [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor Ben Dooks
  2 siblings, 1 reply; 8+ messages in thread
From: Ben Dooks @ 2022-07-08 17:01 UTC (permalink / raw)
  To: dmaengine, Eugeniy.Paltsev
  Cc: linux-kernel, vkoul, Sudip Mukherjee, Jude Onyenegecha, Ben Dooks

During debugging we have seen an issue where axi_chan_dump_lli()
is passed a NULL LLI pointer which ends up causing an OOPS due
to trying to get fields from it. Simply print NULL LLI and exit
to avoid this.

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 75c537153e92..d6ef5f49f281 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1008,6 +1008,11 @@ static void axi_chan_dump_regs(struct axi_dma_chan *chan)
 static void axi_chan_dump_lli(struct axi_dma_chan *chan,
 			      struct axi_dma_hw_desc *desc)
 {
+	if (!desc->lli) {
+		dev_err(dchan2dev(&chan->vc.chan), "NULL LLI\n");
+		return;
+	}
+
 	dev_err(dchan2dev(&chan->vc.chan),
 		"SAR: 0x%llx DAR: 0x%llx LLP: 0x%llx BTS 0x%x CTL: 0x%x:%08x",
 		le64_to_cpu(desc->lli->sar),
-- 
2.35.1


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

* [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor
  2022-07-08 17:01 dw-axi-dmac updates (debug, minor bugfixes) Ben Dooks
  2022-07-08 17:01 ` [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error Ben Dooks
  2022-07-08 17:01 ` [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error Ben Dooks
@ 2022-07-08 17:01 ` Ben Dooks
  2022-07-21 12:33   ` Vinod Koul
  2 siblings, 1 reply; 8+ messages in thread
From: Ben Dooks @ 2022-07-08 17:01 UTC (permalink / raw)
  To: dmaengine, Eugeniy.Paltsev
  Cc: linux-kernel, vkoul, Sudip Mukherjee, Jude Onyenegecha, Ben Dooks

If the channel has no descriptor and the interrupt is raised then the
kernel will OOPS. Check the result of vchan_next_desc() in the handler
axi_chan_block_xfer_complete() to avoid the error happening.

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index d6ef5f49f281..1fedf4376678 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1082,6 +1082,11 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
 
 	/* The completed descriptor currently is in the head of vc list */
 	vd = vchan_next_desc(&chan->vc);
+	if (!vd) {
+		dev_err(chan2dev(chan), "BUG: %s, IRQ with no descriptors\n",
+			axi_chan_name(chan));
+		goto out;
+	}
 
 	if (chan->cyclic) {
 		desc = vd_to_axi_desc(vd);
@@ -1111,6 +1116,7 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
 		axi_chan_start_first_queued(chan);
 	}
 
+out:
 	spin_unlock_irqrestore(&chan->vc.lock, flags);
 }
 
-- 
2.35.1


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

* Re: [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error
  2022-07-08 17:01 ` [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error Ben Dooks
@ 2022-07-21 12:30   ` Vinod Koul
  2022-07-21 22:16     ` Ben Dooks
  0 siblings, 1 reply; 8+ messages in thread
From: Vinod Koul @ 2022-07-21 12:30 UTC (permalink / raw)
  To: Ben Dooks
  Cc: dmaengine, Eugeniy.Paltsev, linux-kernel, Sudip Mukherjee,
	Jude Onyenegecha

On 08-07-22, 18:01, Ben Dooks wrote:
> On channel error, dump the channel register state before
> the channel's LLI entries to see what the controller was
> actually doing when the error happend.
> 
> Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
> ---
>  .../dma/dw-axi-dmac/dw-axi-dmac-platform.c    | 28 +++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index e9c9bcb1f5c2..75c537153e92 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> @@ -79,6 +79,20 @@ axi_chan_iowrite64(struct axi_dma_chan *chan, u32 reg, u64 val)
>  	iowrite32(upper_32_bits(val), chan->chan_regs + reg + 4);
>  }
>  
> +static inline u64
> +axi_chan_ioread64(struct axi_dma_chan *chan, u32 reg)
> +{
> +	u32 high, low;
> +	u64 result;
> +
> +	low = ioread32(chan->chan_regs + reg);
> +	high = ioread32(chan->chan_regs + reg + 4);
> +
> +	result = low;
> +	result |= (u64)high << 32;
> +	return result;
> +}

Better to use helpers like lo_hi_readq()?

> +
>  static inline void axi_chan_config_write(struct axi_dma_chan *chan,
>  					 struct axi_dma_chan_config *config)
>  {
> @@ -979,6 +993,18 @@ static int dw_axi_dma_chan_slave_config(struct dma_chan *dchan,
>  	return 0;
>  }
>  
> +static void axi_chan_dump_regs(struct axi_dma_chan *chan)
> +{
> +	dev_err(dchan2dev(&chan->vc.chan),
> +		"R: SAR: 0x%llx DAR: 0x%llx LLP: 0x%llx BTS 0x%x CTL: 0x%x:%08x\n",
> +		axi_chan_ioread64(chan, CH_SAR),
> +		axi_chan_ioread64(chan, CH_DAR),
> +		axi_chan_ioread64(chan, CH_LLP),
> +		axi_chan_ioread32(chan, CH_BLOCK_TS),
> +		axi_chan_ioread32(chan, CH_CTL_H),
> +		axi_chan_ioread32(chan, CH_CTL_L));
> +}
> +
>  static void axi_chan_dump_lli(struct axi_dma_chan *chan,
>  			      struct axi_dma_hw_desc *desc)
>  {
> @@ -1020,6 +1046,8 @@ static noinline void axi_chan_handle_err(struct axi_dma_chan *chan, u32 status)
>  	dev_err(chan2dev(chan),
>  		"Bad descriptor submitted for %s, cookie: %d, irq: 0x%08x\n",
>  		axi_chan_name(chan), vd->tx.cookie, status);
> +
> +	axi_chan_dump_regs(chan);
>  	axi_chan_list_dump_lli(chan, vd_to_axi_desc(vd));
>  
>  	vchan_cookie_complete(vd);
> -- 
> 2.35.1

-- 
~Vinod

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

* Re: [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error
  2022-07-08 17:01 ` [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error Ben Dooks
@ 2022-07-21 12:33   ` Vinod Koul
  0 siblings, 0 replies; 8+ messages in thread
From: Vinod Koul @ 2022-07-21 12:33 UTC (permalink / raw)
  To: Ben Dooks
  Cc: dmaengine, Eugeniy.Paltsev, linux-kernel, Sudip Mukherjee,
	Jude Onyenegecha

On 08-07-22, 18:01, Ben Dooks wrote:
> During debugging we have seen an issue where axi_chan_dump_lli()
> is passed a NULL LLI pointer which ends up causing an OOPS due
> to trying to get fields from it. Simply print NULL LLI and exit
> to avoid this.

Applied, thanks

> 
> Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
> ---
>  drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index 75c537153e92..d6ef5f49f281 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> @@ -1008,6 +1008,11 @@ static void axi_chan_dump_regs(struct axi_dma_chan *chan)
>  static void axi_chan_dump_lli(struct axi_dma_chan *chan,
>  			      struct axi_dma_hw_desc *desc)
>  {
> +	if (!desc->lli) {
> +		dev_err(dchan2dev(&chan->vc.chan), "NULL LLI\n");
> +		return;
> +	}
> +
>  	dev_err(dchan2dev(&chan->vc.chan),
>  		"SAR: 0x%llx DAR: 0x%llx LLP: 0x%llx BTS 0x%x CTL: 0x%x:%08x",
>  		le64_to_cpu(desc->lli->sar),
> -- 
> 2.35.1

-- 
~Vinod

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

* Re: [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor
  2022-07-08 17:01 ` [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor Ben Dooks
@ 2022-07-21 12:33   ` Vinod Koul
  0 siblings, 0 replies; 8+ messages in thread
From: Vinod Koul @ 2022-07-21 12:33 UTC (permalink / raw)
  To: Ben Dooks
  Cc: dmaengine, Eugeniy.Paltsev, linux-kernel, Sudip Mukherjee,
	Jude Onyenegecha

On 08-07-22, 18:01, Ben Dooks wrote:
> If the channel has no descriptor and the interrupt is raised then the
> kernel will OOPS. Check the result of vchan_next_desc() in the handler
> axi_chan_block_xfer_complete() to avoid the error happening.

Applied, thanks

> 
> Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
> ---
>  drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index d6ef5f49f281..1fedf4376678 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> @@ -1082,6 +1082,11 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
>  
>  	/* The completed descriptor currently is in the head of vc list */
>  	vd = vchan_next_desc(&chan->vc);
> +	if (!vd) {
> +		dev_err(chan2dev(chan), "BUG: %s, IRQ with no descriptors\n",
> +			axi_chan_name(chan));
> +		goto out;
> +	}
>  
>  	if (chan->cyclic) {
>  		desc = vd_to_axi_desc(vd);
> @@ -1111,6 +1116,7 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
>  		axi_chan_start_first_queued(chan);
>  	}
>  
> +out:
>  	spin_unlock_irqrestore(&chan->vc.lock, flags);
>  }
>  
> -- 
> 2.35.1

-- 
~Vinod

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

* Re: [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error
  2022-07-21 12:30   ` Vinod Koul
@ 2022-07-21 22:16     ` Ben Dooks
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Dooks @ 2022-07-21 22:16 UTC (permalink / raw)
  To: Vinod Koul
  Cc: dmaengine, Eugeniy.Paltsev, linux-kernel, Sudip Mukherjee,
	Jude Onyenegecha

On 21/07/2022 13:30, Vinod Koul wrote:
> On 08-07-22, 18:01, Ben Dooks wrote:
>> On channel error, dump the channel register state before
>> the channel's LLI entries to see what the controller was
>> actually doing when the error happend.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
>> ---
>>   .../dma/dw-axi-dmac/dw-axi-dmac-platform.c    | 28 +++++++++++++++++++
>>   1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
>> index e9c9bcb1f5c2..75c537153e92 100644
>> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
>> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
>> @@ -79,6 +79,20 @@ axi_chan_iowrite64(struct axi_dma_chan *chan, u32 reg, u64 val)
>>   	iowrite32(upper_32_bits(val), chan->chan_regs + reg + 4);
>>   }
>>   
>> +static inline u64
>> +axi_chan_ioread64(struct axi_dma_chan *chan, u32 reg)
>> +{
>> +	u32 high, low;
>> +	u64 result;
>> +
>> +	low = ioread32(chan->chan_regs + reg);
>> +	high = ioread32(chan->chan_regs + reg + 4);
>> +
>> +	result = low;
>> +	result |= (u64)high << 32;
>> +	return result;
>> +}
> 
> Better to use helpers like lo_hi_readq()?

Will go check on those, thanks.

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

end of thread, other threads:[~2022-07-21 22:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 17:01 dw-axi-dmac updates (debug, minor bugfixes) Ben Dooks
2022-07-08 17:01 ` [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error Ben Dooks
2022-07-21 12:30   ` Vinod Koul
2022-07-21 22:16     ` Ben Dooks
2022-07-08 17:01 ` [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error Ben Dooks
2022-07-21 12:33   ` Vinod Koul
2022-07-08 17:01 ` [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor Ben Dooks
2022-07-21 12:33   ` 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.