Lines Matching refs:buf
88 char *buf) in dmabounce_show() argument
91 return sprintf(buf, "%lu %lu %lu %lu %lu %lu\n", in dmabounce_show()
110 struct safe_buffer *buf; in alloc_safe_buffer() local
126 buf = kmalloc(sizeof(struct safe_buffer), GFP_ATOMIC); in alloc_safe_buffer()
127 if (buf == NULL) { in alloc_safe_buffer()
132 buf->ptr = ptr; in alloc_safe_buffer()
133 buf->size = size; in alloc_safe_buffer()
134 buf->direction = dir; in alloc_safe_buffer()
135 buf->pool = pool; in alloc_safe_buffer()
138 buf->safe = dma_pool_alloc(pool->pool, GFP_ATOMIC, in alloc_safe_buffer()
139 &buf->safe_dma_addr); in alloc_safe_buffer()
141 buf->safe = dma_alloc_coherent(dev, size, &buf->safe_dma_addr, in alloc_safe_buffer()
145 if (buf->safe == NULL) { in alloc_safe_buffer()
149 kfree(buf); in alloc_safe_buffer()
160 list_add(&buf->node, &device_info->safe_buffers); in alloc_safe_buffer()
163 return buf; in alloc_safe_buffer()
187 free_safe_buffer(struct dmabounce_device_info *device_info, struct safe_buffer *buf) in free_safe_buffer() argument
191 dev_dbg(device_info->dev, "%s(buf=%p)\n", __func__, buf); in free_safe_buffer()
195 list_del(&buf->node); in free_safe_buffer()
199 if (buf->pool) in free_safe_buffer()
200 dma_pool_free(buf->pool->pool, buf->safe, buf->safe_dma_addr); in free_safe_buffer()
202 dma_free_coherent(device_info->dev, buf->size, buf->safe, in free_safe_buffer()
203 buf->safe_dma_addr); in free_safe_buffer()
205 kfree(buf); in free_safe_buffer()
249 struct safe_buffer *buf; in map_single() local
254 buf = alloc_safe_buffer(device_info, ptr, size, dir); in map_single()
255 if (buf == NULL) { in map_single()
262 __func__, buf->ptr, virt_to_dma(dev, buf->ptr), in map_single()
263 buf->safe, buf->safe_dma_addr); in map_single()
267 __func__, ptr, buf->safe, size); in map_single()
268 memcpy(buf->safe, ptr, size); in map_single()
271 return buf->safe_dma_addr; in map_single()
274 static inline void unmap_single(struct device *dev, struct safe_buffer *buf, in unmap_single() argument
277 BUG_ON(buf->size != size); in unmap_single()
278 BUG_ON(buf->direction != dir); in unmap_single()
281 __func__, buf->ptr, virt_to_dma(dev, buf->ptr), in unmap_single()
282 buf->safe, buf->safe_dma_addr); in unmap_single()
287 void *ptr = buf->ptr; in unmap_single()
290 __func__, buf->safe, ptr, size); in unmap_single()
291 memcpy(ptr, buf->safe, size); in unmap_single()
300 free_safe_buffer(dev->archdata.dmabounce, buf); in unmap_single()
349 struct safe_buffer *buf; in dmabounce_unmap_page() local
354 buf = find_safe_buffer_dev(dev, dma_addr, __func__); in dmabounce_unmap_page()
355 if (!buf) { in dmabounce_unmap_page()
360 unmap_single(dev, buf, size, dir); in dmabounce_unmap_page()
366 struct safe_buffer *buf; in __dmabounce_sync_for_cpu() local
372 buf = find_safe_buffer_dev(dev, addr, __func__); in __dmabounce_sync_for_cpu()
373 if (!buf) in __dmabounce_sync_for_cpu()
376 off = addr - buf->safe_dma_addr; in __dmabounce_sync_for_cpu()
378 BUG_ON(buf->direction != dir); in __dmabounce_sync_for_cpu()
381 __func__, buf->ptr, virt_to_dma(dev, buf->ptr), off, in __dmabounce_sync_for_cpu()
382 buf->safe, buf->safe_dma_addr); in __dmabounce_sync_for_cpu()
388 __func__, buf->safe + off, buf->ptr + off, sz); in __dmabounce_sync_for_cpu()
389 memcpy(buf->ptr + off, buf->safe + off, sz); in __dmabounce_sync_for_cpu()
406 struct safe_buffer *buf; in __dmabounce_sync_for_device() local
412 buf = find_safe_buffer_dev(dev, addr, __func__); in __dmabounce_sync_for_device()
413 if (!buf) in __dmabounce_sync_for_device()
416 off = addr - buf->safe_dma_addr; in __dmabounce_sync_for_device()
418 BUG_ON(buf->direction != dir); in __dmabounce_sync_for_device()
421 __func__, buf->ptr, virt_to_dma(dev, buf->ptr), off, in __dmabounce_sync_for_device()
422 buf->safe, buf->safe_dma_addr); in __dmabounce_sync_for_device()
428 __func__,buf->ptr + off, buf->safe + off, sz); in __dmabounce_sync_for_device()
429 memcpy(buf->safe + off, buf->ptr + off, sz); in __dmabounce_sync_for_device()