Page MenuHomeFreeBSD

Improve loading of multipage aligned buffers.
ClosedPublic

Authored by mmel on Oct 11 2020, 9:00 AM.

Details

Summary

The multipage alignment requirements is incompatible with many aspects
of actual busdma code. Multi-page alignment requests are incompatible
with many aspects of current busdma code. Mainly with partially bounced
buffer segments and per-page loop in bus_dmamap_load_buffer(). Because
proper implementation would be a major restructuring of the code, add
the fix only for already known uses and do KASSERT for all other cases.

For this reason, bus_dmamap_load_buffer() should take the memory allocated
by bus_dmamap_alloc() as one segment bypassing per page segmentation. We can
do this because it is guaranteed that the memory is physically continuous.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mmel requested review of this revision.Oct 11 2020, 9:00 AM
bz added inline comments.
sys/arm64/arm64/busdma_bounce.c
831 ↗(On Diff #78095)

alignment

835 ↗(On Diff #78095)

than

I tend to print the questionable value usually in KASSERTs as to see when it panics, what we got so we might be able to track down why we got there.

890 ↗(On Diff #78095)

than instead of that again

946 ↗(On Diff #78095)

and than again

I booted this on my emag:
CPU 1: APM eMAG 8180 r3p2 affinity: 0 1
and it seems to fix the issues that I had with cd sometimes detecting, other times not, as well as some weird reliability stuff relating to /etc/rc running at boot reliably.
I also had a weird issue where I'd type 'sudo reboot' and it would echo back 'sudo rebeoot' sometimes.
Not super extensive, but it's definitely not worse and preliminary indications are that it's better (though I'll admit to a smaller sample size with the patch than testing to produce the litany of horrors I've recounted).

This seems to fix issues with my USB connected optical drives not showing up as cd (only pass device). I've done 10 reboots, replugging it 10 times and they show up correctly each time.

Tested on:
FreeBSD 13.0-CURRENT r366770M
Hardware:
Pine64 RockPro64
USB adapter(s):
2x ASMedia Technology 1153e-based (external PSU connected) - Firmware: 141126_A1_EE_82, USB 3.0 compatible - Used for reboot/replug testing
JMicron-based PATA/SATA-adapter (PATA, external PSU connected), USB 2.0 compatible (don't know exact chipset)

This MR solved problem with eMMC cards on RK3399. Previously card slot was not initialized correctly due to some DMA mapping issues.

Tested on Armada 8040 DB - this patch fixes SDHCI DMA allocation issue.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 2 2020, 8:26 AM
This revision was automatically updated to reflect the committed changes.