Restore bus DMA bounce pages to an offset of 0 when they are released by
a tag that has BUS_DMA_KEEP_PG_OFFSET set. Otherwise the page could be reused with a non-zero offset by a tag that doesn't have BUS_DMA_KEEP_PG_OFFSET leading to data corruption. Sleuthing by: avg Reviewed by: scottl
This commit is contained in:
parent
e932b25b93
commit
842f11bef6
@ -1137,9 +1137,7 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
||||
mtx_unlock(&bounce_lock);
|
||||
|
||||
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
|
||||
/* page offset needs to be preserved */
|
||||
bpage->vaddr &= ~PAGE_MASK;
|
||||
bpage->busaddr &= ~PAGE_MASK;
|
||||
/* Page offset needs to be preserved. */
|
||||
bpage->vaddr |= vaddr & PAGE_MASK;
|
||||
bpage->busaddr |= vaddr & PAGE_MASK;
|
||||
}
|
||||
@ -1158,6 +1156,15 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
|
||||
bz = dmat->bounce_zone;
|
||||
bpage->datavaddr = 0;
|
||||
bpage->datacount = 0;
|
||||
if (dmat->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);
|
||||
|
@ -1427,9 +1427,7 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
||||
mtx_unlock(&bounce_lock);
|
||||
|
||||
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
|
||||
/* page offset needs to be preserved */
|
||||
bpage->vaddr &= ~PAGE_MASK;
|
||||
bpage->busaddr &= ~PAGE_MASK;
|
||||
/* Page offset needs to be preserved. */
|
||||
bpage->vaddr |= vaddr & PAGE_MASK;
|
||||
bpage->busaddr |= vaddr & PAGE_MASK;
|
||||
}
|
||||
@ -1448,6 +1446,15 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
|
||||
bz = dmat->bounce_zone;
|
||||
bpage->datavaddr = 0;
|
||||
bpage->datacount = 0;
|
||||
if (dmat->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);
|
||||
|
@ -1155,9 +1155,7 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
||||
mtx_unlock(&bounce_lock);
|
||||
|
||||
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
|
||||
/* page offset needs to be preserved */
|
||||
bpage->vaddr &= ~PAGE_MASK;
|
||||
bpage->busaddr &= ~PAGE_MASK;
|
||||
/* Page offset needs to be preserved. */
|
||||
bpage->vaddr |= vaddr & PAGE_MASK;
|
||||
bpage->busaddr |= vaddr & PAGE_MASK;
|
||||
}
|
||||
@ -1176,6 +1174,15 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
|
||||
bz = dmat->bounce_zone;
|
||||
bpage->datavaddr = 0;
|
||||
bpage->datacount = 0;
|
||||
if (dmat->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);
|
||||
|
@ -940,9 +940,7 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
|
||||
mtx_unlock(&bounce_lock);
|
||||
|
||||
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
|
||||
/* page offset needs to be preserved */
|
||||
bpage->vaddr &= ~PAGE_MASK;
|
||||
bpage->busaddr &= ~PAGE_MASK;
|
||||
/* Page offset needs to be preserved. */
|
||||
bpage->vaddr |= vaddr & PAGE_MASK;
|
||||
bpage->busaddr |= vaddr & PAGE_MASK;
|
||||
}
|
||||
@ -959,6 +957,15 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
|
||||
|
||||
bpage->datavaddr = 0;
|
||||
bpage->datacount = 0;
|
||||
if (dmat->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(&bounce_page_list, bpage, links);
|
||||
|
Loading…
x
Reference in New Issue
Block a user