busdma_machdep.c (289701) | busdma_machdep.c (289708) |
---|---|
1/*- 2 * Copyright (c) 2006 Oleksandr Tymoshenko 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * From i386/busdma_machdep.c,v 1.26 2002/04/19 22:58:09 alfred 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006 Oleksandr Tymoshenko 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * From i386/busdma_machdep.c,v 1.26 2002/04/19 22:58:09 alfred 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/mips/mips/busdma_machdep.c 289701 2015-10-21 15:06:48Z ian $"); | 30__FBSDID("$FreeBSD: head/sys/mips/mips/busdma_machdep.c 289708 2015-10-21 17:41:20Z ian $"); |
31 32/* 33 * MIPS bus dma support routines 34 */ 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/malloc.h> --- 296 unchanged lines hidden (view full) --- 335 336 slist = malloc(sizeof(*slist) * dmat->nsegments, M_BUSDMA, M_NOWAIT); 337 if (slist == NULL) 338 return (NULL); 339 map = uma_zalloc_arg(dmamap_zone, dmat, M_NOWAIT); 340 if (map != NULL) 341 map->slist = slist; 342 else | 31 32/* 33 * MIPS bus dma support routines 34 */ 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/malloc.h> --- 296 unchanged lines hidden (view full) --- 335 336 slist = malloc(sizeof(*slist) * dmat->nsegments, M_BUSDMA, M_NOWAIT); 337 if (slist == NULL) 338 return (NULL); 339 map = uma_zalloc_arg(dmamap_zone, dmat, M_NOWAIT); 340 if (map != NULL) 341 map->slist = slist; 342 else |
343 free(slist, M_DEVBUF); | 343 free(slist, M_BUSDMA); |
344 return (map); 345} 346 347static __inline void 348_busdma_free_dmamap(bus_dmamap_t map) 349{ | 344 return (map); 345} 346 347static __inline void 348_busdma_free_dmamap(bus_dmamap_t map) 349{ |
350 free(map->slist, M_DEVBUF); | 350 351 free(map->slist, M_BUSDMA); |
351 uma_zfree(dmamap_zone, map); 352} 353 354/* 355 * Allocate a device specific dma_tag. 356 */ 357#define SEG_NB 1024 358 --- 75 unchanged lines hidden (view full) --- 434 435 if (((newtag->flags & BUS_DMA_COULD_BOUNCE) != 0) && 436 (flags & BUS_DMA_ALLOCNOW) != 0) { 437 struct bounce_zone *bz; 438 439 /* Must bounce */ 440 441 if ((error = alloc_bounce_zone(newtag)) != 0) { | 352 uma_zfree(dmamap_zone, map); 353} 354 355/* 356 * Allocate a device specific dma_tag. 357 */ 358#define SEG_NB 1024 359 --- 75 unchanged lines hidden (view full) --- 435 436 if (((newtag->flags & BUS_DMA_COULD_BOUNCE) != 0) && 437 (flags & BUS_DMA_ALLOCNOW) != 0) { 438 struct bounce_zone *bz; 439 440 /* Must bounce */ 441 442 if ((error = alloc_bounce_zone(newtag)) != 0) { |
442 free(newtag, M_DEVBUF); | 443 free(newtag, M_BUSDMA); |
443 return (error); 444 } 445 bz = newtag->bounce_zone; 446 447 if (ptoa(bz->total_bpages) < maxsize) { 448 int pages; 449 450 pages = atop(maxsize) - bz->total_bpages; 451 452 /* Add pages to our bounce pool */ 453 if (alloc_bounce_pages(newtag, pages) < pages) 454 error = ENOMEM; 455 } 456 /* Performed initial allocation */ 457 newtag->flags |= BUS_DMA_MIN_ALLOC_COMP; 458 } else 459 newtag->bounce_zone = NULL; 460 if (error != 0) | 444 return (error); 445 } 446 bz = newtag->bounce_zone; 447 448 if (ptoa(bz->total_bpages) < maxsize) { 449 int pages; 450 451 pages = atop(maxsize) - bz->total_bpages; 452 453 /* Add pages to our bounce pool */ 454 if (alloc_bounce_pages(newtag, pages) < pages) 455 error = ENOMEM; 456 } 457 /* Performed initial allocation */ 458 newtag->flags |= BUS_DMA_MIN_ALLOC_COMP; 459 } else 460 newtag->bounce_zone = NULL; 461 if (error != 0) |
461 free(newtag, M_DEVBUF); | 462 free(newtag, M_BUSDMA); |
462 else 463 *dmat = newtag; 464 CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d", 465 __func__, newtag, (newtag != NULL ? newtag->flags : 0), error); 466 467 return (error); 468} 469 --- 10 unchanged lines hidden (view full) --- 480 481 while (dmat != NULL) { 482 bus_dma_tag_t parent; 483 484 parent = dmat->parent; 485 atomic_subtract_int(&dmat->ref_count, 1); 486 if (dmat->ref_count == 0) { 487 if (dmat->segments != NULL) | 463 else 464 *dmat = newtag; 465 CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d", 466 __func__, newtag, (newtag != NULL ? newtag->flags : 0), error); 467 468 return (error); 469} 470 --- 10 unchanged lines hidden (view full) --- 481 482 while (dmat != NULL) { 483 bus_dma_tag_t parent; 484 485 parent = dmat->parent; 486 atomic_subtract_int(&dmat->ref_count, 1); 487 if (dmat->ref_count == 0) { 488 if (dmat->segments != NULL) |
488 free(dmat->segments, M_DEVBUF); 489 free(dmat, M_DEVBUF); | 489 free(dmat->segments, M_BUSDMA); 490 free(dmat, M_BUSDMA); |
490 /* 491 * Last reference count, so 492 * release our reference 493 * count on our parent. 494 */ 495 dmat = parent; 496 } else 497 dmat = NULL; --- 221 unchanged lines hidden (view full) --- 719 struct busdma_bufzone *bufzone; 720 busdma_bufalloc_t ba; 721 722 if (map->flags & DMAMAP_UNCACHEABLE) 723 ba = coherent_allocator; 724 else 725 ba = standard_allocator; 726 | 491 /* 492 * Last reference count, so 493 * release our reference 494 * count on our parent. 495 */ 496 dmat = parent; 497 } else 498 dmat = NULL; --- 221 unchanged lines hidden (view full) --- 720 struct busdma_bufzone *bufzone; 721 busdma_bufalloc_t ba; 722 723 if (map->flags & DMAMAP_UNCACHEABLE) 724 ba = coherent_allocator; 725 else 726 ba = standard_allocator; 727 |
727 free(map->slist, M_DEVBUF); | 728 free(map->slist, M_BUSDMA); |
728 uma_zfree(dmamap_zone, map); 729 730 bufzone = busdma_bufalloc_findzone(ba, dmat->maxsize); 731 732 if (bufzone != NULL && dmat->alignment <= bufzone->size && 733 !_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr)) 734 uma_zfree(bufzone->umazone, vaddr); 735 else --- 607 unchanged lines hidden (view full) --- 1343 if (bpage == NULL) 1344 break; 1345 bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_BOUNCE, 1346 M_NOWAIT, 0ul, 1347 bz->lowaddr, 1348 PAGE_SIZE, 1349 0); 1350 if (bpage->vaddr == 0) { | 729 uma_zfree(dmamap_zone, map); 730 731 bufzone = busdma_bufalloc_findzone(ba, dmat->maxsize); 732 733 if (bufzone != NULL && dmat->alignment <= bufzone->size && 734 !_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr)) 735 uma_zfree(bufzone->umazone, vaddr); 736 else --- 607 unchanged lines hidden (view full) --- 1344 if (bpage == NULL) 1345 break; 1346 bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_BOUNCE, 1347 M_NOWAIT, 0ul, 1348 bz->lowaddr, 1349 PAGE_SIZE, 1350 0); 1351 if (bpage->vaddr == 0) { |
1351 free(bpage, M_DEVBUF); | 1352 free(bpage, M_BUSDMA); |
1352 break; 1353 } 1354 bpage->busaddr = pmap_kextract(bpage->vaddr); 1355 bpage->vaddr_nocache = 1356 (vm_offset_t)pmap_mapdev(bpage->busaddr, PAGE_SIZE); 1357 mtx_lock(&bounce_lock); 1358 STAILQ_INSERT_TAIL(&bz->bounce_page_list, bpage, links); 1359 total_bpages++; --- 124 unchanged lines hidden --- | 1353 break; 1354 } 1355 bpage->busaddr = pmap_kextract(bpage->vaddr); 1356 bpage->vaddr_nocache = 1357 (vm_offset_t)pmap_mapdev(bpage->busaddr, PAGE_SIZE); 1358 mtx_lock(&bounce_lock); 1359 STAILQ_INSERT_TAIL(&bz->bounce_page_list, bpage, links); 1360 total_bpages++; --- 124 unchanged lines hidden --- |