Lines Matching refs:p

81 static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)  in radeon_cs_parser_relocs()  argument
89 if (p->chunk_relocs == NULL) { in radeon_cs_parser_relocs()
92 chunk = p->chunk_relocs; in radeon_cs_parser_relocs()
93 p->dma_reloc_idx = 0; in radeon_cs_parser_relocs()
95 p->nrelocs = chunk->length_dw / 4; in radeon_cs_parser_relocs()
96 p->relocs = kvcalloc(p->nrelocs, sizeof(struct radeon_bo_list), in radeon_cs_parser_relocs()
98 if (p->relocs == NULL) { in radeon_cs_parser_relocs()
104 for (i = 0; i < p->nrelocs; i++) { in radeon_cs_parser_relocs()
110 gobj = drm_gem_object_lookup(p->filp, r->handle); in radeon_cs_parser_relocs()
116 p->relocs[i].robj = gem_to_radeon_bo(gobj); in radeon_cs_parser_relocs()
132 if (p->ring == R600_RING_TYPE_UVD_INDEX && in radeon_cs_parser_relocs()
133 (i <= 0 || pci_find_capability(p->rdev->pdev, PCI_CAP_ID_AGP) || in radeon_cs_parser_relocs()
134 p->rdev->family == CHIP_RS780 || in radeon_cs_parser_relocs()
135 p->rdev->family == CHIP_RS880)) { in radeon_cs_parser_relocs()
138 p->relocs[i].preferred_domains = in radeon_cs_parser_relocs()
141 p->relocs[i].allowed_domains = in radeon_cs_parser_relocs()
156 p->relocs[i].preferred_domains = domain; in radeon_cs_parser_relocs()
159 p->relocs[i].allowed_domains = domain; in radeon_cs_parser_relocs()
162 if (radeon_ttm_tt_has_userptr(p->rdev, p->relocs[i].robj->tbo.ttm)) { in radeon_cs_parser_relocs()
163 uint32_t domain = p->relocs[i].preferred_domains; in radeon_cs_parser_relocs()
171 p->relocs[i].preferred_domains = domain; in radeon_cs_parser_relocs()
172 p->relocs[i].allowed_domains = domain; in radeon_cs_parser_relocs()
176 if (p->relocs[i].robj->prime_shared_count) { in radeon_cs_parser_relocs()
177 p->relocs[i].allowed_domains &= ~RADEON_GEM_DOMAIN_VRAM; in radeon_cs_parser_relocs()
178 if (!p->relocs[i].allowed_domains) { in radeon_cs_parser_relocs()
185 p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; in radeon_cs_parser_relocs()
186 p->relocs[i].tv.num_shared = !r->write_domain; in radeon_cs_parser_relocs()
188 radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head, in radeon_cs_parser_relocs()
192 radeon_cs_buckets_get_list(&buckets, &p->validated); in radeon_cs_parser_relocs()
194 if (p->cs_flags & RADEON_CS_USE_VM) in radeon_cs_parser_relocs()
195 p->vm_bos = radeon_vm_get_bos(p->rdev, p->ib.vm, in radeon_cs_parser_relocs()
196 &p->validated); in radeon_cs_parser_relocs()
200 r = radeon_bo_list_validate(p->rdev, &p->ticket, &p->validated, p->ring); in radeon_cs_parser_relocs()
208 static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority) in radeon_cs_get_ring() argument
210 p->priority = priority; in radeon_cs_get_ring()
217 p->ring = RADEON_RING_TYPE_GFX_INDEX; in radeon_cs_get_ring()
220 if (p->rdev->family >= CHIP_TAHITI) { in radeon_cs_get_ring()
221 if (p->priority > 0) in radeon_cs_get_ring()
222 p->ring = CAYMAN_RING_TYPE_CP1_INDEX; in radeon_cs_get_ring()
224 p->ring = CAYMAN_RING_TYPE_CP2_INDEX; in radeon_cs_get_ring()
226 p->ring = RADEON_RING_TYPE_GFX_INDEX; in radeon_cs_get_ring()
229 if (p->rdev->family >= CHIP_CAYMAN) { in radeon_cs_get_ring()
230 if (p->priority > 0) in radeon_cs_get_ring()
231 p->ring = R600_RING_TYPE_DMA_INDEX; in radeon_cs_get_ring()
233 p->ring = CAYMAN_RING_TYPE_DMA1_INDEX; in radeon_cs_get_ring()
234 } else if (p->rdev->family >= CHIP_RV770) { in radeon_cs_get_ring()
235 p->ring = R600_RING_TYPE_DMA_INDEX; in radeon_cs_get_ring()
241 p->ring = R600_RING_TYPE_UVD_INDEX; in radeon_cs_get_ring()
245 p->ring = TN_RING_TYPE_VCE1_INDEX; in radeon_cs_get_ring()
251 static int radeon_cs_sync_rings(struct radeon_cs_parser *p) in radeon_cs_sync_rings() argument
256 list_for_each_entry(reloc, &p->validated, tv.head) { in radeon_cs_sync_rings()
260 r = radeon_sync_resv(p->rdev, &p->ib.sync, resv, in radeon_cs_sync_rings()
269 int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) in radeon_cs_parser_init() argument
278 INIT_LIST_HEAD(&p->validated); in radeon_cs_parser_init()
285 p->idx = 0; in radeon_cs_parser_init()
286 p->ib.sa_bo = NULL; in radeon_cs_parser_init()
287 p->const_ib.sa_bo = NULL; in radeon_cs_parser_init()
288 p->chunk_ib = NULL; in radeon_cs_parser_init()
289 p->chunk_relocs = NULL; in radeon_cs_parser_init()
290 p->chunk_flags = NULL; in radeon_cs_parser_init()
291 p->chunk_const_ib = NULL; in radeon_cs_parser_init()
292 p->chunks_array = kvmalloc_array(cs->num_chunks, sizeof(uint64_t), GFP_KERNEL); in radeon_cs_parser_init()
293 if (p->chunks_array == NULL) { in radeon_cs_parser_init()
297 if (copy_from_user(p->chunks_array, chunk_array_ptr, in radeon_cs_parser_init()
301 p->cs_flags = 0; in radeon_cs_parser_init()
302 p->nchunks = cs->num_chunks; in radeon_cs_parser_init()
303 p->chunks = kvcalloc(p->nchunks, sizeof(struct radeon_cs_chunk), GFP_KERNEL); in radeon_cs_parser_init()
304 if (p->chunks == NULL) { in radeon_cs_parser_init()
307 for (i = 0; i < p->nchunks; i++) { in radeon_cs_parser_init()
312 chunk_ptr = (void __user*)(unsigned long)p->chunks_array[i]; in radeon_cs_parser_init()
317 p->chunks[i].length_dw = user_chunk.length_dw; in radeon_cs_parser_init()
319 p->chunk_relocs = &p->chunks[i]; in radeon_cs_parser_init()
322 p->chunk_ib = &p->chunks[i]; in radeon_cs_parser_init()
324 if (p->chunks[i].length_dw == 0) in radeon_cs_parser_init()
328 p->chunk_const_ib = &p->chunks[i]; in radeon_cs_parser_init()
330 if (p->chunks[i].length_dw == 0) in radeon_cs_parser_init()
334 p->chunk_flags = &p->chunks[i]; in radeon_cs_parser_init()
336 if (p->chunks[i].length_dw == 0) in radeon_cs_parser_init()
340 size = p->chunks[i].length_dw; in radeon_cs_parser_init()
342 p->chunks[i].user_ptr = cdata; in radeon_cs_parser_init()
347 if (!p->rdev || !(p->rdev->flags & RADEON_IS_AGP)) in radeon_cs_parser_init()
351 p->chunks[i].kdata = kvmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); in radeon_cs_parser_init()
353 if (p->chunks[i].kdata == NULL) { in radeon_cs_parser_init()
356 if (copy_from_user(p->chunks[i].kdata, cdata, size)) { in radeon_cs_parser_init()
360 p->cs_flags = p->chunks[i].kdata[0]; in radeon_cs_parser_init()
361 if (p->chunks[i].length_dw > 1) in radeon_cs_parser_init()
362 ring = p->chunks[i].kdata[1]; in radeon_cs_parser_init()
363 if (p->chunks[i].length_dw > 2) in radeon_cs_parser_init()
364 priority = (s32)p->chunks[i].kdata[2]; in radeon_cs_parser_init()
369 if (p->rdev) { in radeon_cs_parser_init()
370 if ((p->cs_flags & RADEON_CS_USE_VM) && in radeon_cs_parser_init()
371 !p->rdev->vm_manager.enabled) { in radeon_cs_parser_init()
376 if (radeon_cs_get_ring(p, ring, priority)) in radeon_cs_parser_init()
380 if ((p->cs_flags & RADEON_CS_USE_VM) == 0) { in radeon_cs_parser_init()
381 if (p->rdev->asic->ring[p->ring]->cs_parse == NULL) { in radeon_cs_parser_init()
382 DRM_ERROR("Ring %d requires VM!\n", p->ring); in radeon_cs_parser_init()
386 if (p->rdev->asic->ring[p->ring]->ib_parse == NULL) { in radeon_cs_parser_init()
388 p->ring); in radeon_cs_parser_init()
502 static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p, in radeon_bo_vm_update_pte() argument
505 struct radeon_device *rdev = p->rdev; in radeon_bo_vm_update_pte()
527 for (i = 0; i < p->nrelocs; i++) { in radeon_bo_vm_update_pte()
530 bo = p->relocs[i].robj; in radeon_bo_vm_update_pte()
541 radeon_sync_fence(&p->ib.sync, bo_va->last_pt_update); in radeon_bo_vm_update_pte()
742 int radeon_cs_packet_parse(struct radeon_cs_parser *p, in radeon_cs_packet_parse() argument
746 struct radeon_cs_chunk *ib_chunk = p->chunk_ib; in radeon_cs_packet_parse()
747 struct radeon_device *rdev = p->rdev; in radeon_cs_packet_parse()
756 header = radeon_get_ib_value(p, idx); in radeon_cs_packet_parse()
792 printk("\t0x%08x <---\n", radeon_get_ib_value(p, i)); in radeon_cs_packet_parse()
794 printk("\t0x%08x\n", radeon_get_ib_value(p, i)); in radeon_cs_packet_parse()
805 bool radeon_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser *p) in radeon_cs_packet_next_is_pkt3_nop() argument
810 r = radeon_cs_packet_parse(p, &p3reloc, p->idx); in radeon_cs_packet_next_is_pkt3_nop()
827 void radeon_cs_dump_packet(struct radeon_cs_parser *p, in radeon_cs_dump_packet() argument
834 ib = p->ib.ptr; in radeon_cs_dump_packet()
849 int radeon_cs_packet_next_reloc(struct radeon_cs_parser *p, in radeon_cs_packet_next_reloc() argument
858 if (p->chunk_relocs == NULL) { in radeon_cs_packet_next_reloc()
863 relocs_chunk = p->chunk_relocs; in radeon_cs_packet_next_reloc()
864 r = radeon_cs_packet_parse(p, &p3reloc, p->idx); in radeon_cs_packet_next_reloc()
867 p->idx += p3reloc.count + 2; in radeon_cs_packet_next_reloc()
872 radeon_cs_dump_packet(p, &p3reloc); in radeon_cs_packet_next_reloc()
875 idx = radeon_get_ib_value(p, p3reloc.idx + 1); in radeon_cs_packet_next_reloc()
879 radeon_cs_dump_packet(p, &p3reloc); in radeon_cs_packet_next_reloc()
884 *cs_reloc = p->relocs; in radeon_cs_packet_next_reloc()
889 *cs_reloc = &p->relocs[(idx / 4)]; in radeon_cs_packet_next_reloc()