diff options
Diffstat (limited to 'drivers/char/drm/drm_dma.c')
-rw-r--r-- | drivers/char/drm/drm_dma.c | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/drivers/char/drm/drm_dma.c b/drivers/char/drm/drm_dma.c index 4a28c053c98b..2afab95ca036 100644 --- a/drivers/char/drm/drm_dma.c +++ b/drivers/char/drm/drm_dma.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * \file drm_dma.h | 2 | * \file drm_dma.c |
3 | * DMA IOCTL and function support | 3 | * DMA IOCTL and function support |
4 | * | 4 | * |
5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> | 5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> |
@@ -37,23 +37,23 @@ | |||
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Initialize the DMA data. | 39 | * Initialize the DMA data. |
40 | * | 40 | * |
41 | * \param dev DRM device. | 41 | * \param dev DRM device. |
42 | * \return zero on success or a negative value on failure. | 42 | * \return zero on success or a negative value on failure. |
43 | * | 43 | * |
44 | * Allocate and initialize a drm_device_dma structure. | 44 | * Allocate and initialize a drm_device_dma structure. |
45 | */ | 45 | */ |
46 | int drm_dma_setup( drm_device_t *dev ) | 46 | int drm_dma_setup(drm_device_t * dev) |
47 | { | 47 | { |
48 | int i; | 48 | int i; |
49 | 49 | ||
50 | dev->dma = drm_alloc( sizeof(*dev->dma), DRM_MEM_DRIVER ); | 50 | dev->dma = drm_alloc(sizeof(*dev->dma), DRM_MEM_DRIVER); |
51 | if ( !dev->dma ) | 51 | if (!dev->dma) |
52 | return -ENOMEM; | 52 | return -ENOMEM; |
53 | 53 | ||
54 | memset( dev->dma, 0, sizeof(*dev->dma) ); | 54 | memset(dev->dma, 0, sizeof(*dev->dma)); |
55 | 55 | ||
56 | for ( i = 0 ; i <= DRM_MAX_ORDER ; i++ ) | 56 | for (i = 0; i <= DRM_MAX_ORDER; i++) |
57 | memset(&dev->dma->bufs[i], 0, sizeof(dev->dma->bufs[0])); | 57 | memset(&dev->dma->bufs[i], 0, sizeof(dev->dma->bufs[0])); |
58 | 58 | ||
59 | return 0; | 59 | return 0; |
@@ -67,14 +67,15 @@ int drm_dma_setup( drm_device_t *dev ) | |||
67 | * Free all pages associated with DMA buffers, the buffers and pages lists, and | 67 | * Free all pages associated with DMA buffers, the buffers and pages lists, and |
68 | * finally the the drm_device::dma structure itself. | 68 | * finally the the drm_device::dma structure itself. |
69 | */ | 69 | */ |
70 | void drm_dma_takedown(drm_device_t *dev) | 70 | void drm_dma_takedown(drm_device_t * dev) |
71 | { | 71 | { |
72 | drm_device_dma_t *dma = dev->dma; | 72 | drm_device_dma_t *dma = dev->dma; |
73 | int i, j; | 73 | int i, j; |
74 | 74 | ||
75 | if (!dma) return; | 75 | if (!dma) |
76 | return; | ||
76 | 77 | ||
77 | /* Clear dma buffers */ | 78 | /* Clear dma buffers */ |
78 | for (i = 0; i <= DRM_MAX_ORDER; i++) { | 79 | for (i = 0; i <= DRM_MAX_ORDER; i++) { |
79 | if (dma->bufs[i].seg_count) { | 80 | if (dma->bufs[i].seg_count) { |
80 | DRM_DEBUG("order %d: buf_count = %d," | 81 | DRM_DEBUG("order %d: buf_count = %d," |
@@ -85,64 +86,63 @@ void drm_dma_takedown(drm_device_t *dev) | |||
85 | for (j = 0; j < dma->bufs[i].seg_count; j++) { | 86 | for (j = 0; j < dma->bufs[i].seg_count; j++) { |
86 | if (dma->bufs[i].seglist[j]) { | 87 | if (dma->bufs[i].seglist[j]) { |
87 | drm_free_pages(dma->bufs[i].seglist[j], | 88 | drm_free_pages(dma->bufs[i].seglist[j], |
88 | dma->bufs[i].page_order, | 89 | dma->bufs[i].page_order, |
89 | DRM_MEM_DMA); | 90 | DRM_MEM_DMA); |
90 | } | 91 | } |
91 | } | 92 | } |
92 | drm_free(dma->bufs[i].seglist, | 93 | drm_free(dma->bufs[i].seglist, |
93 | dma->bufs[i].seg_count | 94 | dma->bufs[i].seg_count |
94 | * sizeof(*dma->bufs[0].seglist), | 95 | * sizeof(*dma->bufs[0].seglist), DRM_MEM_SEGS); |
95 | DRM_MEM_SEGS); | ||
96 | } | 96 | } |
97 | if (dma->bufs[i].buf_count) { | 97 | if (dma->bufs[i].buf_count) { |
98 | for (j = 0; j < dma->bufs[i].buf_count; j++) { | 98 | for (j = 0; j < dma->bufs[i].buf_count; j++) { |
99 | if (dma->bufs[i].buflist[j].dev_private) { | 99 | if (dma->bufs[i].buflist[j].dev_private) { |
100 | drm_free(dma->bufs[i].buflist[j].dev_private, | 100 | drm_free(dma->bufs[i].buflist[j]. |
101 | dma->bufs[i].buflist[j].dev_priv_size, | 101 | dev_private, |
102 | DRM_MEM_BUFS); | 102 | dma->bufs[i].buflist[j]. |
103 | dev_priv_size, DRM_MEM_BUFS); | ||
103 | } | 104 | } |
104 | } | 105 | } |
105 | drm_free(dma->bufs[i].buflist, | 106 | drm_free(dma->bufs[i].buflist, |
106 | dma->bufs[i].buf_count * | 107 | dma->bufs[i].buf_count * |
107 | sizeof(*dma->bufs[0].buflist), | 108 | sizeof(*dma->bufs[0].buflist), DRM_MEM_BUFS); |
108 | DRM_MEM_BUFS); | ||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | if (dma->buflist) { | 112 | if (dma->buflist) { |
113 | drm_free(dma->buflist, | 113 | drm_free(dma->buflist, |
114 | dma->buf_count * sizeof(*dma->buflist), | 114 | dma->buf_count * sizeof(*dma->buflist), DRM_MEM_BUFS); |
115 | DRM_MEM_BUFS); | ||
116 | } | 115 | } |
117 | 116 | ||
118 | if (dma->pagelist) { | 117 | if (dma->pagelist) { |
119 | drm_free(dma->pagelist, | 118 | drm_free(dma->pagelist, |
120 | dma->page_count * sizeof(*dma->pagelist), | 119 | dma->page_count * sizeof(*dma->pagelist), |
121 | DRM_MEM_PAGES); | 120 | DRM_MEM_PAGES); |
122 | } | 121 | } |
123 | drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER); | 122 | drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER); |
124 | dev->dma = NULL; | 123 | dev->dma = NULL; |
125 | } | 124 | } |
126 | 125 | ||
127 | |||
128 | /** | 126 | /** |
129 | * Free a buffer. | 127 | * Free a buffer. |
130 | * | 128 | * |
131 | * \param dev DRM device. | 129 | * \param dev DRM device. |
132 | * \param buf buffer to free. | 130 | * \param buf buffer to free. |
133 | * | 131 | * |
134 | * Resets the fields of \p buf. | 132 | * Resets the fields of \p buf. |
135 | */ | 133 | */ |
136 | void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf) | 134 | void drm_free_buffer(drm_device_t * dev, drm_buf_t * buf) |
137 | { | 135 | { |
138 | if (!buf) return; | 136 | if (!buf) |
137 | return; | ||
139 | 138 | ||
140 | buf->waiting = 0; | 139 | buf->waiting = 0; |
141 | buf->pending = 0; | 140 | buf->pending = 0; |
142 | buf->filp = NULL; | 141 | buf->filp = NULL; |
143 | buf->used = 0; | 142 | buf->used = 0; |
144 | 143 | ||
145 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && waitqueue_active(&buf->dma_wait)) { | 144 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) |
145 | && waitqueue_active(&buf->dma_wait)) { | ||
146 | wake_up_interruptible(&buf->dma_wait); | 146 | wake_up_interruptible(&buf->dma_wait); |
147 | } | 147 | } |
148 | } | 148 | } |
@@ -154,12 +154,13 @@ void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf) | |||
154 | * | 154 | * |
155 | * Frees each buffer associated with \p filp not already on the hardware. | 155 | * Frees each buffer associated with \p filp not already on the hardware. |
156 | */ | 156 | */ |
157 | void drm_core_reclaim_buffers(drm_device_t *dev, struct file *filp) | 157 | void drm_core_reclaim_buffers(drm_device_t * dev, struct file *filp) |
158 | { | 158 | { |
159 | drm_device_dma_t *dma = dev->dma; | 159 | drm_device_dma_t *dma = dev->dma; |
160 | int i; | 160 | int i; |
161 | 161 | ||
162 | if (!dma) return; | 162 | if (!dma) |
163 | return; | ||
163 | for (i = 0; i < dma->buf_count; i++) { | 164 | for (i = 0; i < dma->buf_count; i++) { |
164 | if (dma->buflist[i]->filp == filp) { | 165 | if (dma->buflist[i]->filp == filp) { |
165 | switch (dma->buflist[i]->list) { | 166 | switch (dma->buflist[i]->list) { |
@@ -176,5 +177,5 @@ void drm_core_reclaim_buffers(drm_device_t *dev, struct file *filp) | |||
176 | } | 177 | } |
177 | } | 178 | } |
178 | } | 179 | } |
179 | EXPORT_SYMBOL(drm_core_reclaim_buffers); | ||
180 | 180 | ||
181 | EXPORT_SYMBOL(drm_core_reclaim_buffers); | ||