Rev 5078 | Rev 6938 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5078 | Rev 5271 | ||
---|---|---|---|
Line 967... | Line 967... | ||
967 | * will test it against a list of register needind special handling. |
967 | * will test it against a list of register needind special handling. |
968 | */ |
968 | */ |
969 | static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) |
969 | static int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx) |
970 | { |
970 | { |
971 | struct r600_cs_track *track = (struct r600_cs_track *)p->track; |
971 | struct r600_cs_track *track = (struct r600_cs_track *)p->track; |
972 | struct radeon_cs_reloc *reloc; |
972 | struct radeon_bo_list *reloc; |
973 | u32 m, i, tmp, *ib; |
973 | u32 m, i, tmp, *ib; |
974 | int r; |
974 | int r; |
Line 975... | Line 975... | ||
975 | 975 | ||
976 | i = (reg >> 7); |
976 | i = (reg >> 7); |
Line 1624... | Line 1624... | ||
1624 | } |
1624 | } |
Line 1625... | Line 1625... | ||
1625 | 1625 | ||
1626 | static int r600_packet3_check(struct radeon_cs_parser *p, |
1626 | static int r600_packet3_check(struct radeon_cs_parser *p, |
1627 | struct radeon_cs_packet *pkt) |
1627 | struct radeon_cs_packet *pkt) |
1628 | { |
1628 | { |
1629 | struct radeon_cs_reloc *reloc; |
1629 | struct radeon_bo_list *reloc; |
1630 | struct r600_cs_track *track; |
1630 | struct r600_cs_track *track; |
1631 | volatile u32 *ib; |
1631 | volatile u32 *ib; |
1632 | unsigned idx; |
1632 | unsigned idx; |
1633 | unsigned i; |
1633 | unsigned i; |
Line 2314... | Line 2314... | ||
2314 | if (r) { |
2314 | if (r) { |
2315 | kfree(p->track); |
2315 | kfree(p->track); |
2316 | p->track = NULL; |
2316 | p->track = NULL; |
2317 | return r; |
2317 | return r; |
2318 | } |
2318 | } |
2319 | } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw); |
2319 | } while (p->idx < p->chunk_ib->length_dw); |
2320 | #if 0 |
2320 | #if 0 |
2321 | for (r = 0; r < p->ib.length_dw; r++) { |
2321 | for (r = 0; r < p->ib.length_dw; r++) { |
2322 | printk(KERN_INFO "%05d 0x%08X\n", r, p->ib.ptr[r]); |
2322 | printk(KERN_INFO "%05d 0x%08X\n", r, p->ib.ptr[r]); |
2323 | mdelay(1); |
2323 | mdelay(1); |
2324 | } |
2324 | } |
Line 2349... | Line 2349... | ||
2349 | kfree(parser->chunks_array); |
2349 | kfree(parser->chunks_array); |
2350 | } |
2350 | } |
Line 2351... | Line 2351... | ||
2351 | 2351 | ||
2352 | static int r600_cs_parser_relocs_legacy(struct radeon_cs_parser *p) |
2352 | static int r600_cs_parser_relocs_legacy(struct radeon_cs_parser *p) |
2353 | { |
2353 | { |
2354 | if (p->chunk_relocs_idx == -1) { |
2354 | if (p->chunk_relocs == NULL) { |
2355 | return 0; |
2355 | return 0; |
2356 | } |
2356 | } |
2357 | p->relocs = kzalloc(sizeof(struct radeon_cs_reloc), GFP_KERNEL); |
2357 | p->relocs = kzalloc(sizeof(struct radeon_bo_list), GFP_KERNEL); |
2358 | if (p->relocs == NULL) { |
2358 | if (p->relocs == NULL) { |
2359 | return -ENOMEM; |
2359 | return -ENOMEM; |
2360 | } |
2360 | } |
2361 | return 0; |
2361 | return 0; |
Line 2396... | Line 2396... | ||
2396 | return r; |
2396 | return r; |
2397 | } |
2397 | } |
2398 | /* Copy the packet into the IB, the parser will read from the |
2398 | /* Copy the packet into the IB, the parser will read from the |
2399 | * input memory (cached) and write to the IB (which can be |
2399 | * input memory (cached) and write to the IB (which can be |
2400 | * uncached). */ |
2400 | * uncached). */ |
2401 | ib_chunk = &parser.chunks[parser.chunk_ib_idx]; |
2401 | ib_chunk = parser.chunk_ib; |
2402 | parser.ib.length_dw = ib_chunk->length_dw; |
2402 | parser.ib.length_dw = ib_chunk->length_dw; |
2403 | *l = parser.ib.length_dw; |
2403 | *l = parser.ib.length_dw; |
2404 | if (copy_from_user(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) { |
2404 | if (copy_from_user(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) { |
2405 | r = -EFAULT; |
2405 | r = -EFAULT; |
2406 | r600_cs_parser_fini(&parser, r); |
2406 | r600_cs_parser_fini(&parser, r); |
Line 2433... | Line 2433... | ||
2433 | * |
2433 | * |
2434 | * Return the next reloc, do bo validation and compute |
2434 | * Return the next reloc, do bo validation and compute |
2435 | * GPU offset using the provided start. |
2435 | * GPU offset using the provided start. |
2436 | **/ |
2436 | **/ |
2437 | int r600_dma_cs_next_reloc(struct radeon_cs_parser *p, |
2437 | int r600_dma_cs_next_reloc(struct radeon_cs_parser *p, |
2438 | struct radeon_cs_reloc **cs_reloc) |
2438 | struct radeon_bo_list **cs_reloc) |
2439 | { |
2439 | { |
2440 | struct radeon_cs_chunk *relocs_chunk; |
2440 | struct radeon_cs_chunk *relocs_chunk; |
2441 | unsigned idx; |
2441 | unsigned idx; |
Line 2442... | Line 2442... | ||
2442 | 2442 | ||
2443 | *cs_reloc = NULL; |
2443 | *cs_reloc = NULL; |
2444 | if (p->chunk_relocs_idx == -1) { |
2444 | if (p->chunk_relocs == NULL) { |
2445 | DRM_ERROR("No relocation chunk !\n"); |
2445 | DRM_ERROR("No relocation chunk !\n"); |
2446 | return -EINVAL; |
2446 | return -EINVAL; |
2447 | } |
2447 | } |
2448 | relocs_chunk = &p->chunks[p->chunk_relocs_idx]; |
2448 | relocs_chunk = p->chunk_relocs; |
2449 | idx = p->dma_reloc_idx; |
2449 | idx = p->dma_reloc_idx; |
2450 | if (idx >= p->nrelocs) { |
2450 | if (idx >= p->nrelocs) { |
2451 | DRM_ERROR("Relocs at %d after relocations chunk end %d !\n", |
2451 | DRM_ERROR("Relocs at %d after relocations chunk end %d !\n", |
2452 | idx, p->nrelocs); |
2452 | idx, p->nrelocs); |
2453 | return -EINVAL; |
2453 | return -EINVAL; |
2454 | } |
2454 | } |
2455 | *cs_reloc = p->relocs_ptr[idx]; |
2455 | *cs_reloc = &p->relocs[idx]; |
2456 | p->dma_reloc_idx++; |
2456 | p->dma_reloc_idx++; |
2457 | return 0; |
2457 | return 0; |
Line 2458... | Line 2458... | ||
2458 | } |
2458 | } |
Line 2470... | Line 2470... | ||
2470 | * checks for errors. (R6xx-R7xx) |
2470 | * checks for errors. (R6xx-R7xx) |
2471 | * Returns 0 for success and an error on failure. |
2471 | * Returns 0 for success and an error on failure. |
2472 | **/ |
2472 | **/ |
2473 | int r600_dma_cs_parse(struct radeon_cs_parser *p) |
2473 | int r600_dma_cs_parse(struct radeon_cs_parser *p) |
2474 | { |
2474 | { |
2475 | struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx]; |
2475 | struct radeon_cs_chunk *ib_chunk = p->chunk_ib; |
2476 | struct radeon_cs_reloc *src_reloc, *dst_reloc; |
2476 | struct radeon_bo_list *src_reloc, *dst_reloc; |
2477 | u32 header, cmd, count, tiled; |
2477 | u32 header, cmd, count, tiled; |
2478 | volatile u32 *ib = p->ib.ptr; |
2478 | volatile u32 *ib = p->ib.ptr; |
2479 | u32 idx, idx_value; |
2479 | u32 idx, idx_value; |
2480 | u64 src_offset, dst_offset; |
2480 | u64 src_offset, dst_offset; |
2481 | int r; |
2481 | int r; |
Line 2617... | Line 2617... | ||
2617 | break; |
2617 | break; |
2618 | default: |
2618 | default: |
2619 | DRM_ERROR("Unknown packet type %d at %d !\n", cmd, idx); |
2619 | DRM_ERROR("Unknown packet type %d at %d !\n", cmd, idx); |
2620 | return -EINVAL; |
2620 | return -EINVAL; |
2621 | } |
2621 | } |
2622 | } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw); |
2622 | } while (p->idx < p->chunk_ib->length_dw); |
2623 | #if 0 |
2623 | #if 0 |
2624 | for (r = 0; r < p->ib->length_dw; r++) { |
2624 | for (r = 0; r < p->ib->length_dw; r++) { |
2625 | printk(KERN_INFO "%05d 0x%08X\n", r, p->ib.ptr[r]); |
2625 | printk(KERN_INFO "%05d 0x%08X\n", r, p->ib.ptr[r]); |
2626 | mdelay(1); |
2626 | mdelay(1); |
2627 | } |
2627 | } |