Rev 5271 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5271 | Rev 6104 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | * the CP read collide with the flush somehow, or maybe the MC, hard to |
48 | * the CP read collide with the flush somehow, or maybe the MC, hard to |
49 | * tell. (Jerome Glisse) |
49 | * tell. (Jerome Glisse) |
50 | */ |
50 | */ |
Line 51... | Line 51... | ||
51 | 51 | ||
- | 52 | /* |
|
- | 53 | * Indirect registers accessor |
|
- | 54 | */ |
|
- | 55 | uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) |
|
- | 56 | { |
|
- | 57 | unsigned long flags; |
|
- | 58 | uint32_t r; |
|
- | 59 | ||
- | 60 | spin_lock_irqsave(&rdev->pcie_idx_lock, flags); |
|
- | 61 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
|
- | 62 | r = RREG32(RADEON_PCIE_DATA); |
|
- | 63 | spin_unlock_irqrestore(&rdev->pcie_idx_lock, flags); |
|
- | 64 | return r; |
|
- | 65 | } |
|
- | 66 | ||
- | 67 | void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
|
- | 68 | { |
|
- | 69 | unsigned long flags; |
|
- | 70 | ||
- | 71 | spin_lock_irqsave(&rdev->pcie_idx_lock, flags); |
|
- | 72 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
|
- | 73 | WREG32(RADEON_PCIE_DATA, (v)); |
|
- | 74 | spin_unlock_irqrestore(&rdev->pcie_idx_lock, flags); |
|
- | 75 | } |
|
- | 76 | ||
52 | /* |
77 | /* |
53 | * rv370,rv380 PCIE GART |
78 | * rv370,rv380 PCIE GART |
54 | */ |
79 | */ |
Line 55... | Line 80... | ||
55 | static int rv370_debugfs_pcie_gart_info_init(struct radeon_device *rdev); |
80 | static int rv370_debugfs_pcie_gart_info_init(struct radeon_device *rdev); |
Line 64... | Line 89... | ||
64 | tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL); |
89 | tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL); |
65 | WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp | RADEON_PCIE_TX_GART_INVALIDATE_TLB); |
90 | WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp | RADEON_PCIE_TX_GART_INVALIDATE_TLB); |
66 | (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL); |
91 | (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL); |
67 | WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp); |
92 | WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp); |
68 | } |
93 | } |
69 | mb(); |
94 | mb(); |
70 | } |
95 | } |
Line 71... | Line 96... | ||
71 | 96 | ||
72 | #define R300_PTE_UNSNOOPED (1 << 0) |
97 | #define R300_PTE_UNSNOOPED (1 << 0) |
73 | #define R300_PTE_WRITEABLE (1 << 2) |
98 | #define R300_PTE_WRITEABLE (1 << 2) |
Line 74... | Line 99... | ||
74 | #define R300_PTE_READABLE (1 << 3) |
99 | #define R300_PTE_READABLE (1 << 3) |
75 | - | ||
76 | void rv370_pcie_gart_set_page(struct radeon_device *rdev, unsigned i, |
100 | |
77 | uint64_t addr, uint32_t flags) |
- | |
78 | { |
- | |
79 | void __iomem *ptr = rdev->gart.ptr; |
101 | uint64_t rv370_pcie_gart_get_page_entry(uint64_t addr, uint32_t flags) |
80 | 102 | { |
|
81 | addr = (lower_32_bits(addr) >> 8) | |
103 | addr = (lower_32_bits(addr) >> 8) | |
82 | ((upper_32_bits(addr) & 0xff) << 24); |
104 | ((upper_32_bits(addr) & 0xff) << 24); |
83 | if (flags & RADEON_GART_PAGE_READ) |
105 | if (flags & RADEON_GART_PAGE_READ) |
84 | addr |= R300_PTE_READABLE; |
106 | addr |= R300_PTE_READABLE; |
85 | if (flags & RADEON_GART_PAGE_WRITE) |
107 | if (flags & RADEON_GART_PAGE_WRITE) |
86 | addr |= R300_PTE_WRITEABLE; |
108 | addr |= R300_PTE_WRITEABLE; |
- | 109 | if (!(flags & RADEON_GART_PAGE_SNOOP)) |
|
- | 110 | addr |= R300_PTE_UNSNOOPED; |
|
- | 111 | return addr; |
|
- | 112 | } |
|
- | 113 | ||
- | 114 | void rv370_pcie_gart_set_page(struct radeon_device *rdev, unsigned i, |
|
- | 115 | uint64_t entry) |
|
- | 116 | { |
|
87 | if (!(flags & RADEON_GART_PAGE_SNOOP)) |
117 | void __iomem *ptr = rdev->gart.ptr; |
88 | addr |= R300_PTE_UNSNOOPED; |
118 | |
89 | /* on x86 we want this to be CPU endian, on powerpc |
119 | /* on x86 we want this to be CPU endian, on powerpc |
90 | * on powerpc without HW swappers, it'll get swapped on way |
120 | * on powerpc without HW swappers, it'll get swapped on way |
91 | * into VRAM - so no need for cpu_to_le32 on VRAM tables */ |
121 | * into VRAM - so no need for cpu_to_le32 on VRAM tables */ |
Line 92... | Line 122... | ||
92 | writel(addr, ((void __iomem *)ptr) + (i * 4)); |
122 | writel(entry, ((void __iomem *)ptr) + (i * 4)); |
93 | } |
123 | } |
94 | 124 | ||
Line 107... | Line 137... | ||
107 | r = rv370_debugfs_pcie_gart_info_init(rdev); |
137 | r = rv370_debugfs_pcie_gart_info_init(rdev); |
108 | if (r) |
138 | if (r) |
109 | DRM_ERROR("Failed to register debugfs file for PCIE gart !\n"); |
139 | DRM_ERROR("Failed to register debugfs file for PCIE gart !\n"); |
110 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; |
140 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; |
111 | rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush; |
141 | rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush; |
- | 142 | rdev->asic->gart.get_page_entry = &rv370_pcie_gart_get_page_entry; |
|
112 | rdev->asic->gart.set_page = &rv370_pcie_gart_set_page; |
143 | rdev->asic->gart.set_page = &rv370_pcie_gart_set_page; |
113 | return radeon_gart_table_vram_alloc(rdev); |
144 | return radeon_gart_table_vram_alloc(rdev); |
114 | } |
145 | } |
Line 115... | Line 146... | ||
115 | 146 | ||
Line 168... | Line 199... | ||
168 | } |
199 | } |
Line 169... | Line 200... | ||
169 | 200 | ||
170 | void rv370_pcie_gart_fini(struct radeon_device *rdev) |
201 | void rv370_pcie_gart_fini(struct radeon_device *rdev) |
171 | { |
202 | { |
172 | radeon_gart_fini(rdev); |
203 | radeon_gart_fini(rdev); |
173 | rv370_pcie_gart_disable(rdev); |
204 | rv370_pcie_gart_disable(rdev); |
174 | radeon_gart_table_vram_free(rdev); |
205 | radeon_gart_table_vram_free(rdev); |
Line 175... | Line 206... | ||
175 | } |
206 | } |
176 | 207 | ||
Line 534... | Line 565... | ||
534 | if (!(rdev->flags & RADEON_IS_PCIE)) |
565 | if (!(rdev->flags & RADEON_IS_PCIE)) |
535 | return 0; |
566 | return 0; |
Line 536... | Line 567... | ||
536 | 567 | ||
Line 537... | Line 568... | ||
537 | /* FIXME wait for idle */ |
568 | /* FIXME wait for idle */ |
Line 538... | Line 569... | ||
538 | 569 | ||
539 | link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
570 | link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
540 | 571 | ||
541 | switch ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) >> RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT) { |
572 | switch ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) >> RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT) { |
Line 685... | Line 716... | ||
685 | if (p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS) { |
716 | if (p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS) { |
686 | ib[idx] = (idx_value & 31) | /* keep the 1st 5 bits */ |
717 | ib[idx] = (idx_value & 31) | /* keep the 1st 5 bits */ |
687 | ((idx_value & ~31) + (u32)reloc->gpu_offset); |
718 | ((idx_value & ~31) + (u32)reloc->gpu_offset); |
688 | } else { |
719 | } else { |
689 | if (reloc->tiling_flags & RADEON_TILING_MACRO) |
720 | if (reloc->tiling_flags & RADEON_TILING_MACRO) |
690 | tile_flags |= R300_TXO_MACRO_TILE; |
721 | tile_flags |= R300_TXO_MACRO_TILE; |
691 | if (reloc->tiling_flags & RADEON_TILING_MICRO) |
722 | if (reloc->tiling_flags & RADEON_TILING_MICRO) |
692 | tile_flags |= R300_TXO_MICRO_TILE; |
723 | tile_flags |= R300_TXO_MICRO_TILE; |
693 | else if (reloc->tiling_flags & RADEON_TILING_MICRO_SQUARE) |
724 | else if (reloc->tiling_flags & RADEON_TILING_MICRO_SQUARE) |
694 | tile_flags |= R300_TXO_MICRO_TILE_SQUARE; |
725 | tile_flags |= R300_TXO_MICRO_TILE_SQUARE; |
Line 695... | Line 726... | ||
695 | 726 | ||
696 | tmp = idx_value + ((u32)reloc->gpu_offset); |
727 | tmp = idx_value + ((u32)reloc->gpu_offset); |
697 | tmp |= tile_flags; |
728 | tmp |= tile_flags; |
698 | ib[idx] = tmp; |
729 | ib[idx] = tmp; |
699 | } |
730 | } |
700 | track->textures[i].robj = reloc->robj; |
731 | track->textures[i].robj = reloc->robj; |
701 | track->tex_dirty = true; |
732 | track->tex_dirty = true; |
702 | break; |
733 | break; |
Line 746... | Line 777... | ||
746 | /* RB3D_COLORPITCH1 */ |
777 | /* RB3D_COLORPITCH1 */ |
747 | /* RB3D_COLORPITCH2 */ |
778 | /* RB3D_COLORPITCH2 */ |
748 | /* RB3D_COLORPITCH3 */ |
779 | /* RB3D_COLORPITCH3 */ |
749 | if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) { |
780 | if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) { |
750 | r = radeon_cs_packet_next_reloc(p, &reloc, 0); |
781 | r = radeon_cs_packet_next_reloc(p, &reloc, 0); |
751 | if (r) { |
782 | if (r) { |
752 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
783 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
753 | idx, reg); |
784 | idx, reg); |
754 | radeon_cs_dump_packet(p, pkt); |
785 | radeon_cs_dump_packet(p, pkt); |
755 | return r; |
786 | return r; |
756 | } |
787 | } |
Line 757... | Line 788... | ||
757 | 788 | ||
758 | if (reloc->tiling_flags & RADEON_TILING_MACRO) |
789 | if (reloc->tiling_flags & RADEON_TILING_MACRO) |
759 | tile_flags |= R300_COLOR_TILE_ENABLE; |
790 | tile_flags |= R300_COLOR_TILE_ENABLE; |
760 | if (reloc->tiling_flags & RADEON_TILING_MICRO) |
791 | if (reloc->tiling_flags & RADEON_TILING_MICRO) |
761 | tile_flags |= R300_COLOR_MICROTILE_ENABLE; |
792 | tile_flags |= R300_COLOR_MICROTILE_ENABLE; |
762 | else if (reloc->tiling_flags & RADEON_TILING_MICRO_SQUARE) |
793 | else if (reloc->tiling_flags & RADEON_TILING_MICRO_SQUARE) |
Line 763... | Line 794... | ||
763 | tile_flags |= R300_COLOR_MICROTILE_SQUARE_ENABLE; |
794 | tile_flags |= R300_COLOR_MICROTILE_SQUARE_ENABLE; |
764 | 795 | ||
765 | tmp = idx_value & ~(0x7 << 16); |
796 | tmp = idx_value & ~(0x7 << 16); |
766 | tmp |= tile_flags; |
797 | tmp |= tile_flags; |
767 | ib[idx] = tmp; |
798 | ib[idx] = tmp; |
768 | } |
799 | } |
769 | i = (reg - 0x4E38) >> 2; |
800 | i = (reg - 0x4E38) >> 2; |
770 | track->cb[i].pitch = idx_value & 0x3FFE; |
801 | track->cb[i].pitch = idx_value & 0x3FFE; |
Line 831... | Line 862... | ||
831 | break; |
862 | break; |
832 | case 0x4F24: |
863 | case 0x4F24: |
833 | /* ZB_DEPTHPITCH */ |
864 | /* ZB_DEPTHPITCH */ |
834 | if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) { |
865 | if (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) { |
835 | r = radeon_cs_packet_next_reloc(p, &reloc, 0); |
866 | r = radeon_cs_packet_next_reloc(p, &reloc, 0); |
836 | if (r) { |
867 | if (r) { |
837 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
868 | DRM_ERROR("No reloc for ib[%d]=0x%04X\n", |
838 | idx, reg); |
869 | idx, reg); |
839 | radeon_cs_dump_packet(p, pkt); |
870 | radeon_cs_dump_packet(p, pkt); |
840 | return r; |
871 | return r; |
841 | } |
872 | } |
Line 842... | Line 873... | ||
842 | 873 | ||
843 | if (reloc->tiling_flags & RADEON_TILING_MACRO) |
874 | if (reloc->tiling_flags & RADEON_TILING_MACRO) |
844 | tile_flags |= R300_DEPTHMACROTILE_ENABLE; |
875 | tile_flags |= R300_DEPTHMACROTILE_ENABLE; |
845 | if (reloc->tiling_flags & RADEON_TILING_MICRO) |
876 | if (reloc->tiling_flags & RADEON_TILING_MICRO) |
846 | tile_flags |= R300_DEPTHMICROTILE_TILED; |
877 | tile_flags |= R300_DEPTHMICROTILE_TILED; |
847 | else if (reloc->tiling_flags & RADEON_TILING_MICRO_SQUARE) |
878 | else if (reloc->tiling_flags & RADEON_TILING_MICRO_SQUARE) |
Line 848... | Line 879... | ||
848 | tile_flags |= R300_DEPTHMICROTILE_TILED_SQUARE; |
879 | tile_flags |= R300_DEPTHMICROTILE_TILED_SQUARE; |
849 | 880 | ||
850 | tmp = idx_value & ~(0x7 << 16); |
881 | tmp = idx_value & ~(0x7 << 16); |
851 | tmp |= tile_flags; |
882 | tmp |= tile_flags; |
852 | ib[idx] = tmp; |
883 | ib[idx] = tmp; |
853 | } |
884 | } |
854 | track->zb.pitch = idx_value & 0x3FFC; |
885 | track->zb.pitch = idx_value & 0x3FFC; |
855 | track->zb_dirty = true; |
886 | track->zb_dirty = true; |
Line 1134... | Line 1165... | ||
1134 | } |
1165 | } |
1135 | return 0; |
1166 | return 0; |
1136 | fail: |
1167 | fail: |
1137 | printk(KERN_ERR "Forbidden register 0x%04X in cs at %d (val=%08x)\n", |
1168 | printk(KERN_ERR "Forbidden register 0x%04X in cs at %d (val=%08x)\n", |
1138 | reg, idx, idx_value); |
1169 | reg, idx, idx_value); |
1139 | return -EINVAL; |
1170 | return -EINVAL; |
1140 | } |
1171 | } |
Line 1141... | Line 1172... | ||
1141 | 1172 | ||
1142 | static int r300_packet3_check(struct radeon_cs_parser *p, |
1173 | static int r300_packet3_check(struct radeon_cs_parser *p, |
1143 | struct radeon_cs_packet *pkt) |
1174 | struct radeon_cs_packet *pkt) |
Line 1153... | Line 1184... | ||
1153 | track = (struct r100_cs_track *)p->track; |
1184 | track = (struct r100_cs_track *)p->track; |
1154 | switch(pkt->opcode) { |
1185 | switch(pkt->opcode) { |
1155 | case PACKET3_3D_LOAD_VBPNTR: |
1186 | case PACKET3_3D_LOAD_VBPNTR: |
1156 | r = r100_packet3_load_vbpntr(p, pkt, idx); |
1187 | r = r100_packet3_load_vbpntr(p, pkt, idx); |
1157 | if (r) |
1188 | if (r) |
1158 | return r; |
1189 | return r; |
1159 | break; |
1190 | break; |
1160 | case PACKET3_INDX_BUFFER: |
1191 | case PACKET3_INDX_BUFFER: |
1161 | r = radeon_cs_packet_next_reloc(p, &reloc, 0); |
1192 | r = radeon_cs_packet_next_reloc(p, &reloc, 0); |
1162 | if (r) { |
1193 | if (r) { |
1163 | DRM_ERROR("No reloc for packet3 %d\n", pkt->opcode); |
1194 | DRM_ERROR("No reloc for packet3 %d\n", pkt->opcode); |
Line 1391... | Line 1422... | ||
1391 | } |
1422 | } |
Line 1392... | Line 1423... | ||
1392 | 1423 | ||
1393 | r100_irq_set(rdev); |
1424 | r100_irq_set(rdev); |
1394 | rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL); |
1425 | rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL); |
1395 | /* 1M ring buffer */ |
1426 | /* 1M ring buffer */ |
1396 | r = r100_cp_init(rdev, 1024 * 1024); |
1427 | r = r100_cp_init(rdev, 1024 * 1024); |
1397 | if (r) { |
1428 | if (r) { |
1398 | dev_err(rdev->dev, "failed initializing CP (%d).\n", r); |
1429 | dev_err(rdev->dev, "failed initializing CP (%d).\n", r); |
1399 | return r; |
1430 | return r; |
Line 1400... | Line 1431... | ||
1400 | } |
1431 | } |
1401 | 1432 | ||
1402 | r = radeon_ib_pool_init(rdev); |
1433 | r = radeon_ib_pool_init(rdev); |
1403 | if (r) { |
1434 | if (r) { |
Line 1409... | Line 1440... | ||
1409 | } |
1440 | } |
Line -... | Line 1441... | ||
- | 1441 | ||
- | 1442 | ||
- | 1443 | ||
- | 1444 | ||
- | 1445 | void r300_fini(struct radeon_device *rdev) |
|
- | 1446 | { |
|
- | 1447 | radeon_pm_fini(rdev); |
|
- | 1448 | r100_cp_fini(rdev); |
|
- | 1449 | radeon_wb_fini(rdev); |
|
- | 1450 | radeon_ib_pool_fini(rdev); |
|
- | 1451 | radeon_gem_fini(rdev); |
|
- | 1452 | if (rdev->flags & RADEON_IS_PCIE) |
|
- | 1453 | rv370_pcie_gart_fini(rdev); |
|
- | 1454 | if (rdev->flags & RADEON_IS_PCI) |
|
- | 1455 | r100_pci_gart_fini(rdev); |
|
- | 1456 | radeon_agp_fini(rdev); |
|
- | 1457 | radeon_irq_kms_fini(rdev); |
|
- | 1458 | radeon_fence_driver_fini(rdev); |
|
- | 1459 | radeon_bo_fini(rdev); |
|
Line 1410... | Line 1460... | ||
1410 | 1460 | radeon_atombios_fini(rdev); |
|
1411 | 1461 | kfree(rdev->bios); |
|
1412 | 1462 | rdev->bios = NULL; |
|
Line 1487... | Line 1537... | ||
1487 | rdev->accel_working = true; |
1537 | rdev->accel_working = true; |
1488 | r = r300_startup(rdev); |
1538 | r = r300_startup(rdev); |
1489 | if (r) { |
1539 | if (r) { |
1490 | /* Something went wrong with the accel init, so stop accel */ |
1540 | /* Something went wrong with the accel init, so stop accel */ |
1491 | dev_err(rdev->dev, "Disabling GPU acceleration\n"); |
1541 | dev_err(rdev->dev, "Disabling GPU acceleration\n"); |
- | 1542 | r100_cp_fini(rdev); |
|
- | 1543 | radeon_wb_fini(rdev); |
|
- | 1544 | radeon_ib_pool_fini(rdev); |
|
- | 1545 | radeon_irq_kms_fini(rdev); |
|
1492 | if (rdev->flags & RADEON_IS_PCIE) |
1546 | if (rdev->flags & RADEON_IS_PCIE) |
1493 | rv370_pcie_gart_fini(rdev); |
1547 | rv370_pcie_gart_fini(rdev); |
1494 | if (rdev->flags & RADEON_IS_PCI) |
1548 | if (rdev->flags & RADEON_IS_PCI) |
1495 | r100_pci_gart_fini(rdev); |
1549 | r100_pci_gart_fini(rdev); |
1496 | rdev->accel_working = false; |
1550 | rdev->accel_working = false; |