mirror-linux/drivers/dma
Linus Torvalds d440148418 tegra210-adma: fix 32-bit x86 build
The Tegra210 Audio DMA controller driver did a plain divide:

	page_no = (res_page->start - res_base->start) / cdata->ch_base_offset;

which causes problems on 32-bit x86 configurations that have 64-bit
resource sizes:

  x86_64-linux-ld: drivers/dma/tegra210-adma.o: in function `tegra_adma_probe':
  tegra210-adma.c:(.text+0x1322): undefined reference to `__udivdi3'

because gcc doesn't generate the trivial code for a 64-by-32 divide,
turning it into a function call to do a full 64-by-64 divide.  And the
kernel intentionally doesn't provide that helper function, because 99%
of the time all you want is the narrower version.

Of course, tegra210 is a 64-bit architecture and the 32-bit x86 build is
purely for build testing, so this really is just about build coverage
failure.

But build coverage is good.

Side note: div_u64() would be suboptimal if you actually have a 32-bit
resource_t, so our "helper" for divides are admittedly making it harder
than it should be to generate good code for all the possible cases.

At some point, I'll consider 32-bit x86 so entirely legacy that I can't
find it in myself to care any more, and we'll just add the __udivdi3
library function.

But for now, the right thing to do is to use "div_u64()" to show that
you know that you are doing the simpler divide with a 32-bit number.
And the build error enforces that.

While fixing the build issue, also check for division-by-zero, and for
overflow.  Which hopefully cannot happen on real production hardware,
but the value of 'ch_base_offset' can definitely be zero in other
places.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2025-02-15 09:28:55 -08:00
..
amd Merge branch 'fixes' into next 2024-12-24 15:45:33 +05:30
bestcomm dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
dw dmaengine: dw: Select only supported masters for ACPI devices 2024-12-02 22:35:45 +05:30
dw-axi-dmac dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
dw-edma dmaengine: dw-edma: Do not enable watermark interrupts for HDMA 2024-08-28 18:40:17 +05:30
fsl-dpaa2-qdma dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
hsu
idxd dmaengine updates for v6.14 2025-01-29 14:29:57 -08:00
ioat x86/cpu: Make all all CPUID leaf names consistent 2024-12-18 06:17:46 -08:00
lgm dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
mediatek dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
ppc4xx dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
qcom dmaengine: qcom: gpi: Add GPI immediate DMA support for SPI protocol 2024-12-24 16:05:42 +05:30
sf-pdma dmaengine: fix typo in the comment 2024-10-21 23:07:08 +05:30
sh dmaengine: sh: rcar-dmac: add comment for r8a779a0 compatible 2024-12-04 18:00:56 +05:30
stm32 dmaengine: stm32-dma3: clamp AXI burst using match data 2024-10-21 22:51:45 +05:30
ti dmaengine: ti: k3-udma: Add support for J722S CSI BCDMA 2024-12-24 15:32:21 +05:30
xilinx dmaengine: xilinx_dma: Configure parking registers only if parking enabled 2024-12-02 22:30:41 +05:30
Kconfig dma-engine: sun4i: Add support for Allwinner suniv F1C100s 2024-12-11 17:35:03 +05:30
Makefile dmaengine: Move AMD PTDMA driver to amd directory 2024-12-02 22:55:27 +05:30
TODO
acpi-dma.c dmaengine: acpi: Clean up headers 2024-10-14 23:27:57 +05:30
altera-msgdma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
amba-pl08x.c dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
apple-admac.c dmaengine: apple-admac: Avoid accessing registers in probe 2024-12-04 17:42:27 +05:30
at_hdmac.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
at_xdmac.c dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset 2024-12-02 22:14:19 +05:30
bcm-sba-raid.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
bcm2835-dma.c dmaengine: bcm2835-dma: Prevent suspend if DMA channel is busy 2024-12-24 15:37:19 +05:30
dma-axi-dmac.c dmaengine: dma-axi-dmac: Implement device_prep_peripheral_dma_vec 2024-06-21 15:31:57 +05:30
dma-jz4780.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
dmaengine.c dmaengine: avoid non-constant format string 2024-08-29 22:49:53 +05:30
dmaengine.h
dmatest.c dmaengine: dmatest: Explicitly cast divisor to u32 2024-08-05 22:30:55 +05:30
ep93xx_dma.c dmaengine updates for v6.13 2024-11-27 13:25:47 -08:00
fsl-edma-common.c dmaengine: fsl-edma: read/write multiple registers in cyclic transactions 2024-12-24 15:14:13 +05:30
fsl-edma-common.h Merge branch 'fixes' into next 2024-12-24 15:45:33 +05:30
fsl-edma-main.c Merge branch 'fixes' into next 2024-12-24 15:45:33 +05:30
fsl-edma-trace.c dmaengine: fsl-edma: add trace event support 2024-05-04 18:00:16 +05:30
fsl-edma-trace.h dmaengine: fsl-edma: add trace event support 2024-05-04 18:00:16 +05:30
fsl-qdma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
fsl_raid.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
fsl_raid.h
fsldma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
fsldma.h
hisi_dma.c dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
idma64.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
idma64.h
img-mdc-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
imx-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
imx-sdma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
k3dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
loongson1-apb-dma.c dmaengine: loongson1-apb-dma: Fix the build warning caused by the size of pdev_irqname 2024-09-02 13:56:32 +05:30
loongson2-apb-dma.c dmaengine: loongson2-apb: Change GENMASK to GENMASK_ULL 2024-12-02 22:48:57 +05:30
lpc18xx-dmamux.c dmaengine: Explicitly include correct DT includes 2023-08-01 23:51:27 +05:30
lpc32xx-dmamux.c dmaengine: Add dma router for pl08x in LPC32XX SoC 2024-08-29 22:54:11 +05:30
mcf-edma-main.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
milbeaut-hdmac.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
milbeaut-xdmac.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
mmp_pdma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
mmp_tdma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
moxart-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
mpc512x_dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
mv_xor.c dmaengine: mv_xor: switch to for_each_child_of_node_scoped() 2024-12-24 15:45:50 +05:30
mv_xor.h dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
mv_xor_v2.c dmaengine: fix typo in the comment 2024-10-21 23:07:08 +05:30
mxs-dma.c dmaengine: Explicitly include correct DT includes 2023-08-01 23:51:27 +05:30
nbpfaxi.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
of-dma.c dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
owl-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
pch_dma.c dmaengine: pch_dma: remove unused function chan2parent 2024-04-07 18:36:58 +05:30
pl330.c dma-mapping: don't return errors from dma_set_max_seg_size 2024-08-29 07:22:49 +03:00
plx_dma.c
pxa_dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
sa11x0-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
sprd-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
st_fdma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
st_fdma.h dmaengine: st_fdma: Annotate struct st_fdma_desc with __counted_by 2023-09-28 16:42:14 +05:30
ste_dma40.c dma-mapping: don't return errors from dma_set_max_seg_size 2024-08-29 07:22:49 +03:00
ste_dma40.h dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
ste_dma40_ll.c
ste_dma40_ll.h dmaengine: Fix spelling mistakes 2024-09-02 13:56:01 +05:30
sun4i-dma.c dma-engine: sun4i: Add support for Allwinner suniv F1C100s 2024-12-11 17:35:03 +05:30
sun6i-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
tegra20-apb-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
tegra186-gpc-dma.c dmaengine: tegra: Return correct DMA status when paused 2024-12-24 15:49:30 +05:30
tegra210-adma.c tegra210-adma: fix 32-bit x86 build 2025-02-15 09:28:55 -08:00
timb_dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
txx9dmac.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
txx9dmac.h
uniphier-mdmac.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
uniphier-xdmac.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30
virt-dma.c dmaengine: virt-dma: add missing MODULE_DESCRIPTION() macro 2024-06-28 13:03:13 +05:30
virt-dma.h dma: Add lockdep asserts to virt-dma 2024-04-07 17:08:19 +05:30
xgene-dma.c dmaengine: Switch back to struct platform_driver::remove() 2024-10-14 23:50:34 +05:30