Page MenuHomeFreeBSD

busdma: better handling of small segment bouncing
ClosedPublic

Authored by mhorne on May 1 2024, 4:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 12, 4:06 PM
Unknown Object (File)
Tue, Nov 12, 11:28 AM
Unknown Object (File)
Mon, Nov 4, 11:42 AM
Unknown Object (File)
Mon, Nov 4, 11:41 AM
Unknown Object (File)
Mon, Nov 4, 11:40 AM
Unknown Object (File)
Mon, Nov 4, 11:26 AM
Unknown Object (File)
Sun, Nov 3, 4:32 PM
Unknown Object (File)
Sun, Nov 3, 4:32 PM

Details

Summary

Typically, when a DMA transaction requires bouncing, we will break up
the request into segments that are, at maximum, page-sized.

However, in the atypical case of a driver whose maximum segment size is
smaller than PAGE_SIZE, we end up inefficiently assigning each segment
its own bounce page. For example, the dwmmc driver has a maximum segment
size of 2048 (PAGE_SIZE / 2); a 4-page transfer ends up requiring 8
bounce pages in the current scheme.

We should attempt to batch segments into bounce pages more efficiently.
This is achieved by pushing all considerations of the maximum segment
size into the new _bus_dmamap_addsegs() function, which wraps
_bus_dmamap_addseg(). Thus we allocate the minimal number of bounce
pages required to complete the entire transfer, while still performing
the transfer with smaller-sized transactions.

For most drivers with a segment size >= PAGE_SIZE, this will have no
impact. For drivers like dwmmc mentioned above, this improves the memory
and performance efficiency when bouncing a large transfer.

Co-authored-by: jhb

Test Plan

Tinderbox.

Tested on the VisionFive v2 RISC-V SBC (dwmmc small segment case).

I am running this change on my amd64 workstation; no regressions so far. Will smoke test on arm64 as well.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 57501
Build 54389: arc lint + arc unit