Lines Matching defs:vsg
58 via_unmap_blit_from_device(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
60 int num_desc = vsg->num_desc;
61 unsigned cur_descriptor_page = num_desc / vsg->descriptors_per_page;
62 unsigned descriptor_this_page = num_desc % vsg->descriptors_per_page;
63 drm_via_descriptor_t *desc_ptr = vsg->desc_pages[cur_descriptor_page] +
65 dma_addr_t next = vsg->chain_start;
70 descriptor_this_page = vsg->descriptors_per_page - 1;
71 desc_ptr = vsg->desc_pages[cur_descriptor_page] +
75 dma_unmap_page(&pdev->dev, desc_ptr->mem_addr, desc_ptr->size, vsg->direction);
91 drm_via_sg_info_t *vsg,
109 desc_ptr = vsg->desc_pages[cur_descriptor_page];
125 vsg->pages[VIA_PFN(cur_mem) -
128 vsg->direction);
136 if (++num_descriptors_this_page >= vsg->descriptors_per_page) {
138 desc_ptr = vsg->desc_pages[++cur_descriptor_page];
152 vsg->chain_start = next;
153 vsg->state = dr_via_device_mapped;
155 vsg->num_desc = num_desc;
166 via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
171 switch (vsg->state) {
173 via_unmap_blit_from_device(pdev, vsg);
175 for (i = 0; i < vsg->num_desc_pages; ++i) {
176 if (vsg->desc_pages[i] != NULL)
177 free_page((unsigned long)vsg->desc_pages[i]);
179 kfree(vsg->desc_pages);
181 for (i = 0; i < vsg->num_pages; ++i) {
182 if (NULL != (page = vsg->pages[i])) {
183 if (!PageReserved(page) && (DMA_FROM_DEVICE == vsg->direction))
189 vfree(vsg->pages);
191 vsg->state = dr_via_sg_init;
193 vfree(vsg->bounce_buffer);
194 vsg->bounce_buffer = NULL;
195 vsg->free_on_sequence = 0;
203 via_fire_dmablit(struct drm_device *dev, drm_via_sg_info_t *vsg, int engine)
213 VIA_WRITE(VIA_PCI_DMA_DPR0 + engine*0x10, vsg->chain_start);
225 via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
229 vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) -
232 if (NULL == (vsg->pages = vmalloc(sizeof(struct page *) * vsg->num_pages)))
234 memset(vsg->pages, 0, sizeof(struct page *) * vsg->num_pages);
238 vsg->num_pages,
239 (vsg->direction == DMA_FROM_DEVICE),
240 0, vsg->pages, NULL);
243 if (ret != vsg->num_pages) {
246 vsg->state = dr_via_pages_locked;
249 vsg->state = dr_via_pages_locked;
261 via_alloc_desc_pages(drm_via_sg_info_t *vsg)
265 vsg->descriptors_per_page = PAGE_SIZE / sizeof(drm_via_descriptor_t);
266 vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) /
267 vsg->descriptors_per_page;
269 if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, sizeof(void *), GFP_KERNEL)))
272 vsg->state = dr_via_desc_pages_alloc;
273 for (i = 0; i < vsg->num_desc_pages; ++i) {
274 if (NULL == (vsg->desc_pages[i] =
278 DRM_DEBUG("Allocated %d pages for %d descriptors.\n", vsg->num_desc_pages,
279 vsg->num_desc);
572 via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
577 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
578 vsg->bounce_buffer = NULL;
580 vsg->state = dr_via_sg_init;
651 if (0 != (ret = via_lock_all_dma_pages(vsg, xfer))) {
653 via_free_sg_info(dev->pdev, vsg);
657 via_map_blit_for_device(dev->pdev, xfer, vsg, 0);
658 if (0 != (ret = via_alloc_desc_pages(vsg))) {
660 via_free_sg_info(dev->pdev, vsg);
663 via_map_blit_for_device(dev->pdev, xfer, vsg, 1);
722 drm_via_sg_info_t *vsg;
737 if (NULL == (vsg = kmalloc(sizeof(*vsg), GFP_KERNEL))) {
741 if (0 != (ret = via_build_sg_info(dev, vsg, xfer))) {
743 kfree(vsg);
748 blitq->blits[blitq->head++] = vsg;