Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131846861
D4119.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D4119.diff
View Options
Index: head/sys/x86/x86/busdma_bounce.c
===================================================================
--- head/sys/x86/x86/busdma_bounce.c
+++ head/sys/x86/x86/busdma_bounce.c
@@ -476,8 +476,7 @@
while (buflen != 0) {
sgsize = MIN(buflen, dmat->common.maxsegsz);
if (bus_dma_run_filter(&dmat->common, curaddr)) {
- sgsize = MIN(sgsize,
- PAGE_SIZE - (curaddr & PAGE_MASK));
+ sgsize = MIN(PAGE_SIZE, sgsize);
map->pagesneeded++;
}
curaddr += sgsize;
@@ -517,8 +516,7 @@
else
paddr = pmap_extract(pmap, vaddr);
if (bus_dma_run_filter(&dmat->common, paddr) != 0) {
- sg_len = roundup2(sg_len,
- dmat->common.alignment);
+ sg_len = PAGE_SIZE;
map->pagesneeded++;
}
vaddr += sg_len;
@@ -554,9 +552,7 @@
max_sgsize = MIN(buflen, dmat->common.maxsegsz);
sg_len = MIN(sg_len, max_sgsize);
if (bus_dma_run_filter(&dmat->common, paddr) != 0) {
- sg_len = roundup2(sg_len,
- dmat->common.alignment);
- sg_len = MIN(sg_len, max_sgsize);
+ sg_len = MIN(PAGE_SIZE, max_sgsize);
KASSERT((sg_len & (dmat->common.alignment - 1))
== 0, ("Segment size is not aligned"));
map->pagesneeded++;
@@ -652,7 +648,7 @@
int *segp)
{
bus_size_t sgsize;
- bus_addr_t curaddr;
+ bus_addr_t curaddr, nextaddr;
int error;
if (map == NULL)
@@ -676,9 +672,12 @@
if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
map->pagesneeded != 0 &&
bus_dma_run_filter(&dmat->common, curaddr)) {
- sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK));
- curaddr = add_bounce_page(dmat, map, 0, curaddr, 0,
- sgsize);
+ nextaddr = 0;
+ sgsize = MIN(PAGE_SIZE, sgsize);
+ if ((curaddr & PAGE_MASK) + sgsize > PAGE_SIZE)
+ nextaddr = roundup2(curaddr, PAGE_SIZE);
+ curaddr = add_bounce_page(dmat, map, 0, curaddr,
+ nextaddr, sgsize);
}
sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs,
segp);
@@ -744,8 +743,7 @@
if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
map->pagesneeded != 0 &&
bus_dma_run_filter(&dmat->common, curaddr)) {
- sgsize = roundup2(sgsize, dmat->common.alignment);
- sgsize = MIN(sgsize, max_sgsize);
+ sgsize = MIN(PAGE_SIZE, max_sgsize);
curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, 0,
sgsize);
} else {
@@ -774,17 +772,6 @@
int error, page_index;
bus_size_t sgsize, max_sgsize;
- if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
- /*
- * If we have to keep the offset of each page this function
- * is not suitable, switch back to bus_dmamap_load_ma_triv
- * which is going to do the right thing in this case.
- */
- error = bus_dmamap_load_ma_triv(dmat, map, ma, buflen, ma_offs,
- flags, segs, segp);
- return (error);
- }
-
if (map == NULL)
map = &nobounce_dmamap;
@@ -811,10 +798,7 @@
if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
map->pagesneeded != 0 &&
bus_dma_run_filter(&dmat->common, paddr)) {
- sgsize = roundup2(sgsize, dmat->common.alignment);
- sgsize = MIN(sgsize, max_sgsize);
- KASSERT((sgsize & (dmat->common.alignment - 1)) == 0,
- ("Segment size is not aligned"));
+ sgsize = MIN(PAGE_SIZE, max_sgsize);
/*
* Check if two pages of the user provided buffer
* are used.
@@ -1175,13 +1159,6 @@
bz->active_bpages++;
mtx_unlock(&bounce_lock);
- if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
- /* Page offset needs to be preserved. */
- bpage->vaddr |= addr1 & PAGE_MASK;
- bpage->busaddr |= addr1 & PAGE_MASK;
- KASSERT(addr2 == 0,
- ("Trying to bounce multiple pages with BUS_DMA_KEEP_PG_OFFSET"));
- }
bpage->datavaddr = vaddr;
bpage->datapage[0] = PHYS_TO_VM_PAGE(addr1);
KASSERT((addr2 & PAGE_MASK) == 0, ("Second page is not aligned"));
@@ -1201,15 +1178,6 @@
bz = dmat->bounce_zone;
bpage->datavaddr = 0;
bpage->datacount = 0;
- if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
- /*
- * Reset the bounce page to start at offset 0. Other uses
- * of this bounce page may need to store a full page of
- * data and/or assume it starts on a page boundary.
- */
- bpage->vaddr &= ~PAGE_MASK;
- bpage->busaddr &= ~PAGE_MASK;
- }
mtx_lock(&bounce_lock);
STAILQ_INSERT_HEAD(&bz->bounce_page_list, bpage, links);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 12, 4:18 PM (2 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23630237
Default Alt Text
D4119.diff (4 KB)
Attached To
Mode
D4119: x86/bounce: try to always completely fill bounce pages
Attached
Detach File
Event Timeline
Log In to Comment