1/*- 2 * Copyright 2003 Eric Anholt. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, --- 8 unchanged lines hidden (view full) --- 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24#include <sys/cdefs.h> |
25__FBSDID("$FreeBSD: head/sys/dev/drm/drm_pci.c 182883 2008-09-09 02:05:03Z rnoland $"); |
26 27/** 28 * \file drm_pci.h 29 * \brief PCI consistent, DMA-accessible memory allocation. 30 * 31 * \author Eric Anholt <anholt@FreeBSD.org> 32 */ 33 --- 35 unchanged lines hidden (view full) --- 69 return NULL; 70 } 71 72 dmah = malloc(sizeof(drm_dma_handle_t), M_DRM, M_ZERO | M_NOWAIT); 73 if (dmah == NULL) 74 return NULL; 75 76#ifdef __FreeBSD__ |
77 /* Make sure we aren't holding locks here */ 78 if (mtx_owned(&dev->dev_lock)) 79 DRM_ERROR("called while holding dev_lock\n"); 80 if (mtx_owned(&dev->dma_lock)) 81 DRM_ERROR("called while holding dma_lock\n"); 82 |
83 ret = bus_dma_tag_create(NULL, align, 0, /* tag, align, boundary */ 84 maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */ 85 NULL, NULL, /* filtfunc, filtfuncargs */ 86 size, 1, size, /* maxsize, nsegs, maxsegsize */ 87 BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */ 88 &dmah->tag); 89 if (ret != 0) { 90 free(dmah, M_DRM); |
91 return NULL; 92 } 93 94 ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, BUS_DMA_NOWAIT, 95 &dmah->map); 96 if (ret != 0) { 97 bus_dma_tag_destroy(dmah->tag); 98 free(dmah, M_DRM); |
99 return NULL; 100 } |
101 |
102 ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr, size, 103 drm_pci_busdma_callback, dmah, 0); 104 if (ret != 0) { 105 bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); 106 bus_dma_tag_destroy(dmah->tag); 107 free(dmah, M_DRM); 108 return NULL; 109 } --- 42 unchanged lines hidden --- |