opnsense-src/sys/powerpc
Mitchell Horne 0a40193a6e busdma: fix page miscount for small segment sizes
For small segments (< PAGE_SIZE) there is a mismatch between how
required bounce pages are counted in _bus_dmamap_count_pages() and
bounce_bus_dmamap_load_buffer().

This problem has been observed on the RISC-V VisionFive v2 SoC (and
earlier revisions of the hardware) which has memory physically addressed
above 4GB. This requires some bouncing for the dwmmc driver, which has
has a maximum segment size of 2048 bytes. When attempting to load a
page-aligned 4-page buffer that requires bouncing, we can end up
counting 4 bounce pages for an 8-segment transfer. These pages will be
incorrectly configured to cover only the first half of the transfer (4 x
2048 bytes).

Fix the immediate issue by adding the maxsegsz check to
_bus_dmamap_count_pages(); this is what _bus_dmamap_count_phys() does
already. The result is that we will inefficiently allocate a separate
bounce page for each segment (8 pages for the example above), but the
transfer will proceed in its entirety.

The more complete fix is to address the shortcomings in how small
segments are assigned to bounce pages, so that we opportunistically
batch multiple segments to a page whenever they fit (e.g. two 2048 bytes
segments per 4096 page). This will be addressed more holistically in the
future. For now this change will prevent the (silent) incomplete
transfers that have been observed.

PR:		273694
Reported by:	Jari Sihvola <jsihv@gmx.com>
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34118

(cherry picked from commit b134c10d658c3b350e04aa8dbd2628e955ddcce0)
2024-04-18 15:09:02 -03:00
..
aim powerpc pmap: initialize kernel pmap radix trie 2023-09-19 21:09:37 -05:00
amigaone sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
booke pmap: Prefer consistent naming for loader tunable 2023-10-23 18:12:21 +08:00
conf ath(4): always enable 11n 2024-04-01 23:46:10 +00:00
cpufreq sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
fpu sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
include powerpc: Implement fpu_kern_enter/fpu_kern_leave 2023-11-19 17:55:24 -03:00
mambo sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
mikrotik sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
mpc85xx sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ofw powerpc: Bump maximum number of FDT reserved mem entries 2024-04-01 22:09:57 -04:00
powermac powerpc: better handling of shutdown flags 2023-12-08 18:02:44 -04:00
powernv powerpc: better handling of shutdown flags 2023-12-08 18:02:44 -04:00
powerpc busdma: fix page miscount for small segment sizes 2024-04-18 15:09:02 -03:00
ps3 ehci_ps3: Remove unused struct definition. 2024-01-03 12:34:35 -08:00
pseries powerpc: better handling of shutdown flags 2023-12-08 18:02:44 -04:00
psim sys: Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:54:58 -06:00