sh: dma: Fix DMA channel offset calculation
authorArtur Rojek <contact@artur-rojek.eu>
Sat, 27 May 2023 16:44:50 +0000 (18:44 +0200)
committerJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Wed, 5 Jul 2023 16:55:25 +0000 (18:55 +0200)
commite82e47584847129a20b8c9f4a1dcde09374fb0e0
tree94ad71d8fb0ea00b793e9d8b0f938ae597da5ded
parent4bd04b2037423f11e6be03709d1fccdc6045c4a1
sh: dma: Fix DMA channel offset calculation

Various SoCs of the SH3, SH4 and SH4A family, which use this driver,
feature a differing number of DMA channels, which can be distributed
between up to two DMAC modules. The existing implementation fails to
correctly accommodate for all those variations, resulting in wrong
channel offset calculations and leading to kernel panics.

Rewrite dma_base_addr() in order to properly calculate channel offsets
in a DMAC module. Fix dmaor_read_reg() and dmaor_write_reg(), so that
the correct DMAC module base is selected for the DMAOR register.

Fixes: 7f47c7189b3e8f19 ("sh: dma: More legacy cpu dma chainsawing.")
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Link: https://lore.kernel.org/r/20230527164452.64797-2-contact@artur-rojek.eu
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
arch/sh/drivers/dma/dma-sh.c