Page MenuHomeFreeBSD

D35490.id.diff
No OneTemporary

D35490.id.diff

Index: sys/arm64/arm64/busdma_bounce.c
===================================================================
--- sys/arm64/arm64/busdma_bounce.c
+++ sys/arm64/arm64/busdma_bounce.c
@@ -73,8 +73,8 @@
struct bus_dma_tag {
struct bus_dma_tag_common common;
- size_t alloc_size;
- size_t alloc_alignment;
+ bus_size_t alloc_size;
+ bus_size_t alloc_alignment;
int map_count;
int bounce_flags;
bus_dma_segment_t *segments;
@@ -251,8 +251,12 @@
*/
newtag->alloc_alignment = MAX(newtag->common.alignment,
dcache_line_size);
- newtag->alloc_size = roundup2(newtag->common.maxsize,
- dcache_line_size);
+ if (newtag->common.maxsize <
+ (BUS_SPACE_MAXSIZE - dcache_line_size))
+ newtag->alloc_size = roundup2(newtag->common.maxsize,
+ dcache_line_size);
+ else
+ newtag->alloc_size = newtag->common.maxsize;
}
if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) ||
@@ -261,12 +265,6 @@
if ((flags & BUS_DMA_ALLOCNOW) != 0) {
struct bounce_zone *bz;
- /*
- * Round size up to a full page, and add one more page because
- * there can always be one more boundary crossing than the
- * number of pages in a transfer.
- */
- maxsize = roundup2(maxsize, PAGE_SIZE) + PAGE_SIZE;
/* Must bounce */
if ((error = alloc_bounce_zone(newtag)) != 0) {
@@ -276,7 +274,7 @@
bz = newtag->bounce_zone;
if (ptoa(bz->total_bpages) < maxsize) {
- int pages;
+ bus_size_t pages;
pages = atop(maxsize) + 1 - bz->total_bpages;
@@ -376,7 +374,7 @@
bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
{
struct bounce_zone *bz;
- int error, maxpages, pages;
+ int error, maxpages;
error = 0;
@@ -424,7 +422,10 @@
atop(dmat->common.lowaddr));
if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 ||
(bz->map_count > 0 && bz->total_bpages < maxpages)) {
- pages = atop(roundup2(dmat->common.maxsize, PAGE_SIZE)) + 1;
+ bus_size_t pages;
+
+ pages = atop(dmat->common.maxsize);
+ pages = MAX(pages + 1, 1);
pages = MIN(maxpages - bz->total_bpages, pages);
pages = MAX(pages, 2);
if (alloc_bounce_pages(dmat, pages) < pages)
@@ -476,7 +477,7 @@
/*
* Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
+ * bus device space based on the constraints listed in the dma tag.
* A dmamap to for use with dmamap_load is also allocated.
*/
static int
Index: sys/kern/subr_busdma_bounce.c
===================================================================
--- sys/kern/subr_busdma_bounce.c
+++ sys/kern/subr_busdma_bounce.c
@@ -249,7 +249,7 @@
}
static int
-alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
+alloc_bounce_pages(bus_dma_tag_t dmat, bus_size_t numpages)
{
struct bounce_zone *bz;
int count;
Index: sys/riscv/riscv/busdma_bounce.c
===================================================================
--- sys/riscv/riscv/busdma_bounce.c
+++ sys/riscv/riscv/busdma_bounce.c
@@ -174,9 +174,9 @@
bz = newtag->bounce_zone;
if (ptoa(bz->total_bpages) < maxsize) {
- int pages;
+ bus_size_t pages;
- pages = atop(round_page(maxsize)) - bz->total_bpages;
+ pages = atop(maxsize) + 1 - bz->total_bpages;
/* Add pages to our bounce pool */
if (alloc_bounce_pages(newtag, pages) < pages)
@@ -261,7 +261,7 @@
bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
{
struct bounce_zone *bz;
- int error, maxpages, pages;
+ int error, maxpages;
error = 0;
@@ -311,9 +311,11 @@
atop(dmat->common.lowaddr));
if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 ||
(bz->map_count > 0 && bz->total_bpages < maxpages)) {
+ bus_size_t pages;
+
pages = MAX(atop(dmat->common.maxsize), 1);
pages = MIN(maxpages - bz->total_bpages, pages);
- pages = MAX(pages, 1);
+ pages = MAX(pages, 2);
if (alloc_bounce_pages(dmat, pages) < pages)
error = ENOMEM;
if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP)
Index: sys/x86/x86/busdma_bounce.c
===================================================================
--- sys/x86/x86/busdma_bounce.c
+++ sys/x86/x86/busdma_bounce.c
@@ -130,7 +130,7 @@
bz = dmat->bounce_zone;
if (ptoa(bz->total_bpages) < dmat->common.maxsize) {
- int pages;
+ bus_size_t pages;
pages = atop(dmat->common.maxsize) - bz->total_bpages;
@@ -273,7 +273,7 @@
bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
{
struct bounce_zone *bz;
- int error, maxpages, pages;
+ int error, maxpages;
error = 0;
@@ -324,9 +324,11 @@
atop(dmat->common.lowaddr));
if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 ||
(bz->map_count > 0 && bz->total_bpages < maxpages)) {
+ bus_size_t pages;
+
pages = MAX(atop(dmat->common.maxsize), 1);
pages = MIN(maxpages - bz->total_bpages, pages);
- pages = MAX(pages, 1);
+ pages = MAX(pages, 2);
if (alloc_bounce_pages(dmat, pages) < pages)
error = ENOMEM;
if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP)

File Metadata

Mime Type
text/plain
Expires
Fri, May 1, 2:30 AM (2 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32550103
Default Alt Text
D35490.id.diff (4 KB)

Event Timeline