Page MenuHomeFreeBSD

x86/bounce: try to always completely fill bounce pages
ClosedPublic

Authored by royger on Nov 10 2015, 12:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 21, 9:05 AM
Unknown Object (File)
Fri, Jun 21, 7:57 AM
Unknown Object (File)
Thu, Jun 20, 1:08 PM
Unknown Object (File)
Thu, Jun 20, 12:42 PM
Unknown Object (File)
Thu, Jun 20, 8:57 AM
Unknown Object (File)
Thu, Jun 20, 8:50 AM
Unknown Object (File)
Thu, Jun 20, 2:32 AM
Unknown Object (File)
May 15 2024, 9:52 PM
Subscribers

Details

Summary

Current code doesn't try to make use of the full page when bouncing because
the size is only expanded to be a multiple of the alignment. Instead try to
always create segments of PAGE_SIZE when using bounce pages.

This allows us to remove the specific casing done for
BUS_DMA_KEEP_PG_OFFSET, since the requirement is to make sure the offsets
into contiguous segments are aligned, and now this is done by default.

Test Plan

I haven't been able to get my usb controller to do any bouncing. Hans, can
you please test this?

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

royger retitled this revision from to x86/bounce: try to always completely fill bounce pages.
royger updated this object.
royger edited the test plan for this revision. (Show Details)
royger added reviewers: jah, kib, hselasky, ian.

Testing: You can set a artificially low memory limit in sys/dev/usb/usb_busdma.c and bounce buffers will be used.

hselasky edited edge metadata.

USB test OK, using the following patch:

diff --git a/sys/dev/usb/usb_busdma.c b/sys/dev/usb/usb_busdma.c
index 821e0fb..3ec3e5e 100644
--- a/sys/dev/usb/usb_busdma.c
+++ b/sys/dev/usb/usb_busdma.c
@@ -390,7 +390,7 @@ usb_dma_tag_create(struct usb_dma_tag *udt,
            ( /* parent    */ udt->tag_parent->tag,
             /* alignment */ align,
             /* boundary  */ 0,
-            /* lowaddr   */ (2ULL << (udt->tag_parent->dma_bits - 1)) - 1,
+            /* lowaddr   */ (2ULL << (28 - 1)) - 1,
             /* highaddr  */ BUS_SPACE_MAXADDR,
             /* filter    */ NULL,
             /* filterarg */ NULL,
@@ -472,6 +472,8 @@ usb_pc_common_mem_cb(void *arg, bus_dma_segment_t *segs,
        pc->page_offset_buf = rem;
        pc->page_offset_end += rem;
 #ifdef USB_DEBUG
+       if (rem != (USB_P2U(pc->buffer) & (USB_PAGE_SIZE - 1)))
+               printf("WORKS %d %d\n", (int)rem, (int)(USB_P2U(pc->buffer) & (USB_PAGE_SIZE - 1)));
        if (nseg > 1 &&
            ((segs->ds_addr + segs->ds_len) & (USB_PAGE_SIZE - 1)) !=
            ((segs + 1)->ds_addr & (USB_PAGE_SIZE - 1))) {
This revision is now accepted and ready to land.Nov 10 2015, 5:15 PM
kib edited edge metadata.
This revision was automatically updated to reflect the committed changes.