dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning
authorFrank Li <Frank.Li@nxp.com>
Mon, 19 Feb 2024 15:59:39 +0000 (10:59 -0500)
committerVinod Koul <vkoul@kernel.org>
Fri, 23 Feb 2024 06:50:39 +0000 (12:20 +0530)
commit1878840a0328dac1c85d29fee31456ec26fcc01c
tree202cf683eb69cb4e34531c9ab8a9dc5cce1d5d8a
parentd3ea125df37dc37972d581b74a5d3785c3f283ab
dmaengine: fsl-qdma: add __iomem and struct in union to fix sparse warning

Fix below sparse warnings.

drivers/dma/fsl-qdma.c:645:50: sparse: warning: incorrect type in argument 2 (different address spaces)
drivers/dma/fsl-qdma.c:645:50: sparse:    expected void [noderef] __iomem *addr
drivers/dma/fsl-qdma.c:645:50: sparse:    got void

drivers/dma/fsl-qdma.c:387:15: sparse: sparse: restricted __le32 degrades to integer
drivers/dma/fsl-qdma.c:390:19: sparse:     expected restricted __le64 [usertype] data
drivers/dma/fsl-qdma.c:392:13: sparse:     expected unsigned int [assigned] [usertype] cmd

QDMA decriptor have below 3 kind formats. (little endian)

Compound Command Descriptor Format
  ┌──────┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
  │Offset│3│3│2│2│2│2│2│2│2│2│2│2│1│1│1│1│1│1│1│1│1│1│ │ │ │ │ │ │ │ │ │ │
  │      │1│0│9│8│7│6│5│4│3│2│1│0│9│8│7│6│5│4│3│2│1│0│9│8│7│6│5│4│3│2│1│0│
  ├──────┼─┴─┼─┴─┴─┼─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┤
  │ 0x0C │DD │  -  │QUEUE│             -                 │      ADDR     │
  ├──────┼───┴─────┴─────┴───────────────────────────────┴───────────────┤
  │ 0x08 │                       ADDR                                    │
  ├──────┼─────┬─────────────────┬───────────────────────────────────────┤
  │ 0x04 │ FMT │    OFFSET       │                   -                   │
  ├──────┼─┬─┬─┴─────────────────┴───────────────────────┬───────────────┤
  │      │ │S│                                           │               │
  │ 0x00 │-│E│                   -                       │    STATUS     │
  │      │ │R│                                           │               │
  └──────┴─┴─┴───────────────────────────────────────────┴───────────────┘

Compound S/G Table Entry Format
 ┌──────┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
 │Offset│3│3│2│2│2│2│2│2│2│2│2│2│1│1│1│1│1│1│1│1│1│1│ │ │ │ │ │ │ │ │ │ │
 │      │1│0│9│8│7│6│5│4│3│2│1│0│9│8│7│6│5│4│3│2│1│0│9│8│7│6│5│4│3│2│1│0│
 ├──────┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┤
 │ 0x0C │                      -                        │    ADDR       │
 ├──────┼───────────────────────────────────────────────┴───────────────┤
 │ 0x08 │                          ADDR                                 │
 ├──────┼─┬─┬───────────────────────────────────────────────────────────┤
 │ 0x04 │E│F│                    LENGTH                                 │
 ├──────┼─┴─┴─────────────────────────────────┬─────────────────────────┤
 │ 0x00 │              -                      │        OFFSET           │
 └──────┴─────────────────────────────────────┴─────────────────────────┘

Source/Destination Descriptor Format
  ┌──────┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
  │Offset│3│3│2│2│2│2│2│2│2│2│2│2│1│1│1│1│1│1│1│1│1│1│ │ │ │ │ │ │ │ │ │ │
  │      │1│0│9│8│7│6│5│4│3│2│1│0│9│8│7│6│5│4│3│2│1│0│9│8│7│6│5│4│3│2│1│0│
  ├──────┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤
  │ 0x0C │                            CMD                                │
  ├──────┼───────────────────────────────────────────────────────────────┤
  │ 0x08 │                             -                                 │
  ├──────┼───────────────┬───────────────────────┬───────────────────────┤
  │ 0x04 │       -       │         S[D]SS        │        S[D]SD         │
  ├──────┼───────────────┴───────────────────────┴───────────────────────┤
  │ 0x00 │                             -                                 │
  └──────┴───────────────────────────────────────────────────────────────┘

Previous code use 64bit 'data' map to 0x8 and 0xC. In little endian system
CMD is high part of 64bit 'data'. It is correct by left shift 32. But in
big endian system, shift left 32 will write to 0x8 position. Sparse detect
this problem.

Add below field ot match 'Source/Destination Descriptor Format'.
struct {
__le32 __reserved2;
__le32 cmd;
} __packed;

Using ddf(sdf)->cmd save to correct posistion regardless endian.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402081929.mggOTHaZ-lkp@intel.com/
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240219155939.611237-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/fsl-qdma.c