2022-03-28 21:50:39

by Serge Semin

[permalink] [raw]
Subject: [PATCH 12/25] dmaengine: dw-edma: Fix DebugFS reg entry type

debugfs_entries structure declared in the dw-edma-v0-debugfs.c module
contains the DebugFS node' register address. The address is declared as
dma_addr_t type, but first it's assigned with virtual CPU IOMEM address
and then it's cast back to the virtual address. Even though the castes
sandwich will unlikely cause any problem since normally DMA address is at
least of the same size as the CPU virtual address, it's at the very least
redundant if not to say logically incorrect. Let's fix it by just stop
casting the pointer back and worth and just preserve the address as a
pointer to void with __iomem qualifier.

Fixes: 305aebeff879 ("dmaengine: Add Synopsys eDMA IP version 0 debugfs support")
Signed-off-by: Serge Semin <[email protected]>
---
drivers/dma/dw-edma/dw-edma-v0-debugfs.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c
index 3a899f7f4e8d..12845a2dc016 100644
--- a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c
+++ b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c
@@ -14,7 +14,7 @@
#include "dw-edma-core.h"

#define REGS_ADDR(name) \
- ((void __force *)&regs->name)
+ ((void __iomem *)&regs->name)
#define REGISTER(name) \
{ #name, REGS_ADDR(name) }

@@ -48,12 +48,13 @@ static struct {

struct debugfs_entries {
const char *name;
- dma_addr_t *reg;
+ void __iomem *reg;
};

static int dw_edma_debugfs_u32_get(void *data, u64 *val)
{
- void __iomem *reg = (void __force __iomem *)data;
+ void __iomem *reg = data;
+
if (dw->chip->mf == EDMA_MF_EDMA_LEGACY &&
reg >= (void __iomem *)&regs->type.legacy.ch) {
void __iomem *ptr = &regs->type.legacy.ch;
--
2.35.1