Lines Matching refs:buf
35 unsigned int flags, struct exynos_drm_gem_buf *buf)
49 if (buf->dma_addr) {
54 if (buf->size >= SZ_1M) {
55 npages = buf->size >> SECTION_SHIFT;
57 } else if (buf->size >= SZ_64K) {
58 npages = buf->size >> 16;
61 npages = buf->size >> PAGE_SHIFT;
65 buf->sgt = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
66 if (!buf->sgt) {
71 ret = sg_alloc_table(buf->sgt, npages, GFP_KERNEL);
74 kfree(buf->sgt);
75 buf->sgt = NULL;
79 buf->kvaddr = dma_alloc_writecombine(dev->dev, buf->size,
80 &buf->dma_addr, GFP_KERNEL);
81 if (!buf->kvaddr) {
87 buf->pages = kzalloc(sizeof(struct page) * npages, GFP_KERNEL);
88 if (!buf->pages) {
94 sgl = buf->sgt->sgl;
95 start_addr = buf->dma_addr;
98 buf->pages[i] = phys_to_page(start_addr);
99 sg_set_page(sgl, buf->pages[i], page_size, 0);
107 (unsigned long)buf->kvaddr,
108 (unsigned long)buf->dma_addr,
109 buf->size);
113 dma_free_writecombine(dev->dev, buf->size, buf->kvaddr,
114 (dma_addr_t)buf->dma_addr);
115 buf->dma_addr = (dma_addr_t)NULL;
117 sg_free_table(buf->sgt);
118 kfree(buf->sgt);
119 buf->sgt = NULL;
125 unsigned int flags, struct exynos_drm_gem_buf *buf)
139 if (!buf->dma_addr) {
145 (unsigned long)buf->kvaddr,
146 (unsigned long)buf->dma_addr,
147 buf->size);
149 sg_free_table(buf->sgt);
151 kfree(buf->sgt);
152 buf->sgt = NULL;
154 kfree(buf->pages);
155 buf->pages = NULL;
157 dma_free_writecombine(dev->dev, buf->size, buf->kvaddr,
158 (dma_addr_t)buf->dma_addr);
159 buf->dma_addr = (dma_addr_t)NULL;
195 struct exynos_drm_gem_buf *buf, unsigned int flags)
202 if (lowlevel_buffer_allocate(dev, flags, buf) < 0)