* Allocate a handle for mapping from kva/uva/physical * address space into bus device space. */
| 713 | * address space into bus device space. |
| 714 | */ |
| 715 | int |
| 716 | bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) |
| 717 | { |
| 718 | bus_dmamap_t map; |
| 719 | int error = 0; |
| 720 | |
| 721 | *mapp = map = allocate_map(dmat, M_NOWAIT); |
| 722 | if (map == NULL) { |
| 723 | CTR3(KTR_BUSDMA, "%s: tag %p error %d", __func__, dmat, ENOMEM); |
| 724 | return (ENOMEM); |
| 725 | } |
| 726 | |
| 727 | /* |
| 728 | * Bouncing might be required if the driver asks for an exclusion |
| 729 | * region, a data alignment that is stricter than 1, or DMA that begins |
| 730 | * or ends with a partial cacheline. Whether bouncing will actually |
| 731 | * happen can't be known until mapping time, but we need to pre-allocate |
| 732 | * resources now because we might not be allowed to at mapping time. |
| 733 | */ |
| 734 | error = allocate_bz_and_pages(dmat, map); |
| 735 | if (error != 0) { |
| 736 | free(map, M_BUSDMA); |
| 737 | *mapp = NULL; |
| 738 | return (error); |
| 739 | } |
| 740 | if (map->flags & DMAMAP_COHERENT) |
| 741 | atomic_add_32(&maps_coherent, 1); |
| 742 | atomic_add_32(&maps_total, 1); |
| 743 | dmat->map_count++; |
| 744 | |
| 745 | return (0); |
| 746 | } |
| 747 | |
| 748 | /* |
| 749 | * Destroy a handle for mapping from kva/uva/physical |
no test coverage detected