dw-axi-dmac updates (debug, minor bugfixes)
Subsystems (2)
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.
PATCH 1/3 dmaengine: dw-axi-dmac: dump channel registers on error
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.
--- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +28 -0
@@ -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);
Signature · 1 line
2.35.1
Vinod Koul
maintainerRe: [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error
Quoted 20 lines · 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 <[email protected]>--- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +3
-0@@ -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) +{
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c axi_chan_iowrite64(struct axi_dma_chan *chan, u32 reg, u64 val) · line 94
Quoted 10 lines
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +10
-0+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()?
Quoted 34 lines
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +15
-0+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);Signature · 1 line
2.35.1
Signature · 1 line
~Vinod
Re: [PATCH 1/3] dmaengine: dw-axi-dmac: dump channel registers on error
Quoted 18 lines · Vinod Koul
Quoted 17 lines · 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 <[email protected]>--- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +0
-0@@ -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 ); }
Quoted 15 lines
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c axi_chan_iowrite64(struct axi_dma_chan *chan, u32 reg, u64 val) · line 94
Quoted 13 lines
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +13
-0+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.
PATCH 2/3 dmaengine: dw-axi-dmac: do not print NULL LLI during error
In reply to Ben DooksDuring 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.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +5 -0
@@ -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),
Signature · 1 line
2.35.1
Re: [PATCH 2/3] dmaengine: dw-axi-dmac: do not print NULL LLI during error
Quoted 4 lines · 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.
Applied, thanks
Quoted 24 lines
Signed-off-by Ben Dooks <[email protected]>--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +5
-0@@ -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),Signature · 1 line
2.35.1
Signature · 1 line
~Vinod
PATCH 3/3 dmaengine: dw-axi-dmac: ignore interrupt if no descriptor
In reply to Ben DooksIf 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.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +6 -0
@@ -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); }
Signature · 1 line
2.35.1
Re: [PATCH 3/3] dmaengine: dw-axi-dmac: ignore interrupt if no descriptor
Quoted 3 lines · 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 handleraxi_chan_block_xfer_complete()to avoid the error happening.
Applied, thanks
Quoted 32 lines
Signed-off-by Ben Dooks <[email protected]>--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +6
-0@@ -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); }Signature · 1 line
2.35.1
Signature · 1 line
~Vinod