Lines Matching refs:vsg
67 via_unmap_blit_from_device(struct pci_dev *pdev, drm_via_sg_info_t *vsg) in via_unmap_blit_from_device() argument
69 int num_desc = vsg->num_desc; in via_unmap_blit_from_device()
70 unsigned cur_descriptor_page = num_desc / vsg->descriptors_per_page; in via_unmap_blit_from_device()
71 unsigned descriptor_this_page = num_desc % vsg->descriptors_per_page; in via_unmap_blit_from_device()
72 drm_via_descriptor_t *desc_ptr = vsg->desc_pages[cur_descriptor_page] + in via_unmap_blit_from_device()
74 dma_addr_t next = vsg->chain_start; in via_unmap_blit_from_device()
79 descriptor_this_page = vsg->descriptors_per_page - 1; in via_unmap_blit_from_device()
80 desc_ptr = vsg->desc_pages[cur_descriptor_page] + in via_unmap_blit_from_device()
84 dma_unmap_page(&pdev->dev, desc_ptr->mem_addr, desc_ptr->size, vsg->direction); in via_unmap_blit_from_device()
100 drm_via_sg_info_t *vsg, in via_map_blit_for_device() argument
118 desc_ptr = vsg->desc_pages[cur_descriptor_page]; in via_map_blit_for_device()
134 vsg->pages[VIA_PFN(cur_mem) - in via_map_blit_for_device()
137 vsg->direction); in via_map_blit_for_device()
145 if (++num_descriptors_this_page >= vsg->descriptors_per_page) { in via_map_blit_for_device()
147 desc_ptr = vsg->desc_pages[++cur_descriptor_page]; in via_map_blit_for_device()
161 vsg->chain_start = next; in via_map_blit_for_device()
162 vsg->state = dr_via_device_mapped; in via_map_blit_for_device()
164 vsg->num_desc = num_desc; in via_map_blit_for_device()
175 via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) in via_free_sg_info() argument
179 switch (vsg->state) { in via_free_sg_info()
181 via_unmap_blit_from_device(pdev, vsg); in via_free_sg_info()
184 for (i = 0; i < vsg->num_desc_pages; ++i) { in via_free_sg_info()
185 if (vsg->desc_pages[i] != NULL) in via_free_sg_info()
186 free_page((unsigned long)vsg->desc_pages[i]); in via_free_sg_info()
188 kfree(vsg->desc_pages); in via_free_sg_info()
191 unpin_user_pages_dirty_lock(vsg->pages, vsg->num_pages, in via_free_sg_info()
192 (vsg->direction == DMA_FROM_DEVICE)); in via_free_sg_info()
195 vfree(vsg->pages); in via_free_sg_info()
198 vsg->state = dr_via_sg_init; in via_free_sg_info()
200 vfree(vsg->bounce_buffer); in via_free_sg_info()
201 vsg->bounce_buffer = NULL; in via_free_sg_info()
202 vsg->free_on_sequence = 0; in via_free_sg_info()
210 via_fire_dmablit(struct drm_device *dev, drm_via_sg_info_t *vsg, int engine) in via_fire_dmablit() argument
220 via_write(dev_priv, VIA_PCI_DMA_DPR0 + engine*0x10, vsg->chain_start); in via_fire_dmablit()
232 via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer) in via_lock_all_dma_pages() argument
236 vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) - in via_lock_all_dma_pages()
239 vsg->pages = vzalloc(array_size(sizeof(struct page *), vsg->num_pages)); in via_lock_all_dma_pages()
240 if (NULL == vsg->pages) in via_lock_all_dma_pages()
243 vsg->num_pages, in via_lock_all_dma_pages()
244 vsg->direction == DMA_FROM_DEVICE ? FOLL_WRITE : 0, in via_lock_all_dma_pages()
245 vsg->pages); in via_lock_all_dma_pages()
246 if (ret != vsg->num_pages) { in via_lock_all_dma_pages()
249 vsg->state = dr_via_pages_locked; in via_lock_all_dma_pages()
252 vsg->state = dr_via_pages_locked; in via_lock_all_dma_pages()
264 via_alloc_desc_pages(drm_via_sg_info_t *vsg) in via_alloc_desc_pages() argument
268 vsg->descriptors_per_page = PAGE_SIZE / sizeof(drm_via_descriptor_t); in via_alloc_desc_pages()
269 vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) / in via_alloc_desc_pages()
270 vsg->descriptors_per_page; in via_alloc_desc_pages()
272 if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, sizeof(void *), GFP_KERNEL))) in via_alloc_desc_pages()
275 vsg->state = dr_via_desc_pages_alloc; in via_alloc_desc_pages()
276 for (i = 0; i < vsg->num_desc_pages; ++i) { in via_alloc_desc_pages()
277 if (NULL == (vsg->desc_pages[i] = in via_alloc_desc_pages()
281 DRM_DEBUG("Allocated %d pages for %d descriptors.\n", vsg->num_desc_pages, in via_alloc_desc_pages()
282 vsg->num_desc); in via_alloc_desc_pages()
576 via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer) in via_build_sg_info() argument
582 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; in via_build_sg_info()
583 vsg->bounce_buffer = NULL; in via_build_sg_info()
585 vsg->state = dr_via_sg_init; in via_build_sg_info()
656 if (0 != (ret = via_lock_all_dma_pages(vsg, xfer))) { in via_build_sg_info()
658 via_free_sg_info(pdev, vsg); in via_build_sg_info()
662 via_map_blit_for_device(pdev, xfer, vsg, 0); in via_build_sg_info()
663 if (0 != (ret = via_alloc_desc_pages(vsg))) { in via_build_sg_info()
665 via_free_sg_info(pdev, vsg); in via_build_sg_info()
668 via_map_blit_for_device(pdev, xfer, vsg, 1); in via_build_sg_info()
727 drm_via_sg_info_t *vsg; in via_dmablit() local
742 if (NULL == (vsg = kmalloc(sizeof(*vsg), GFP_KERNEL))) { in via_dmablit()
746 if (0 != (ret = via_build_sg_info(dev, vsg, xfer))) { in via_dmablit()
748 kfree(vsg); in via_dmablit()
753 blitq->blits[blitq->head++] = vsg; in via_dmablit()