29 #include <linux/slab.h>
40 #include "r300_reg_safe.h"
63 for (i = 0; i < 2; i++) {
72 #define R300_PTE_WRITEABLE (1 << 2)
73 #define R300_PTE_READABLE (1 << 3)
79 if (i < 0 || i > rdev->
gart.num_gpu_pages) {
96 if (rdev->
gart.robj) {
97 WARN(1,
"RV370 PCIE GART already initialized\n");
104 r = rv370_debugfs_pcie_gart_info_init(rdev);
106 DRM_ERROR(
"Failed to register debugfs file for PCIE gart !\n");
107 rdev->
gart.table_size = rdev->
gart.num_gpu_pages * 4;
120 dev_err(rdev->
dev,
"No VRAM object for PCIE GART.\n");
135 table_addr = rdev->
gart.table_addr;
147 DRM_INFO(
"PCIE GART of %uM enabled (table at 0x%016llX).\n",
148 (
unsigned)(rdev->
mc.gtt_size >> 20),
149 (
unsigned long long)table_addr);
150 rdev->
gart.ready =
true;
211 unsigned gb_tile_config;
358 "programming pipes. Bad things might happen.\n");
370 "programming pipes. Bad things might happen.\n");
374 "programming pipes. Bad things might happen.\n");
376 DRM_INFO(
"radeon: %d quad pipes, %d Z pipes initialized.\n",
392 dev_info(rdev->
dev,
"(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
411 dev_info(rdev->
dev,
"(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
423 dev_info(rdev->
dev,
"(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
446 rdev->
mc.vram_is_ddr =
true;
450 case 0: rdev->
mc.vram_width = 64;
break;
451 case 1: rdev->
mc.vram_width = 128;
break;
452 case 2: rdev->
mc.vram_width = 256;
break;
453 default: rdev->
mc.vram_width = 128;
break;
456 base = rdev->
mc.aper_base;
460 rdev->
mc.gtt_base_align = 0;
513 link_width_cntl |=
mask;
520 while (link_width_cntl == 0xffffffff)
556 #if defined(CONFIG_DEBUG_FS)
557 static int rv370_debugfs_pcie_gart_info(
struct seq_file *
m,
void *
data)
559 struct drm_info_node *
node = (
struct drm_info_node *) m->
private;
565 seq_printf(m,
"PCIE_TX_GART_CNTL 0x%08x\n", tmp);
567 seq_printf(m,
"PCIE_TX_GART_BASE 0x%08x\n", tmp);
569 seq_printf(m,
"PCIE_TX_GART_START_LO 0x%08x\n", tmp);
571 seq_printf(m,
"PCIE_TX_GART_START_HI 0x%08x\n", tmp);
573 seq_printf(m,
"PCIE_TX_GART_END_LO 0x%08x\n", tmp);
575 seq_printf(m,
"PCIE_TX_GART_END_HI 0x%08x\n", tmp);
577 seq_printf(m,
"PCIE_TX_GART_ERROR 0x%08x\n", tmp);
581 static struct drm_info_list rv370_pcie_gart_info_list[] = {
582 {
"rv370_pcie_gart_info", rv370_debugfs_pcie_gart_info, 0,
NULL},
586 static int rv370_debugfs_pcie_gart_info_init(
struct radeon_device *rdev)
588 #if defined(CONFIG_DEBUG_FS)
597 unsigned idx,
unsigned reg)
616 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
635 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
640 track->
cb[
i].robj = reloc->
robj;
641 track->
cb[
i].offset = idx_value;
643 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
648 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
653 track->
zb.robj = reloc->
robj;
654 track->
zb.offset = idx_value;
656 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
677 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
684 ib[
idx] = (idx_value & 31) |
685 ((idx_value & ~31) + (
u32)reloc->
lobj.gpu_offset);
694 tmp = idx_value + ((
u32)reloc->
lobj.gpu_offset);
722 track->
maxy = ((idx_value >> 13) & 0x1FFF) + 1;
731 if ((idx_value & (1 << 10)) &&
733 DRM_ERROR(
"Invalid RB3D_CCTL: Cannot enable CMASK.\n");
736 track->
num_cb = ((idx_value >> 5) & 0x3) + 1;
750 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
763 tmp = idx_value & ~(0x7 << 16);
767 i = (reg - 0x4E38) >> 2;
768 track->
cb[
i].pitch = idx_value & 0x3FFE;
769 switch (((idx_value >> 21) & 0xF)) {
773 track->
cb[
i].cpp = 1;
779 track->
cb[
i].cpp = 2;
783 DRM_ERROR(
"Invalid color buffer format (%d)!\n",
784 ((idx_value >> 21) & 0xF));
789 track->
cb[
i].cpp = 4;
792 track->
cb[
i].cpp = 8;
795 track->
cb[
i].cpp = 16;
798 DRM_ERROR(
"Invalid color buffer format (%d) !\n",
799 ((idx_value >> 21) & 0xF));
815 switch ((idx_value & 0xF)) {
824 DRM_ERROR(
"Invalid z buffer format (%d) !\n",
835 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
848 tmp = idx_value & ~(0x7 << 16);
852 track->
zb.pitch = idx_value & 0x3FFC;
857 for (i = 0; i < 16; i++) {
860 enabled = !!(idx_value & (1 <<
i));
882 i = (reg - 0x44C0) >> 2;
883 tmp = (idx_value >> 25) & 0x3;
885 switch ((idx_value & 0x1F)) {
933 DRM_ERROR(
"Invalid texture format %u\n",
945 DRM_ERROR(
"Invalid texture format %u\n",
968 i = (reg - 0x4400) >> 2;
969 tmp = idx_value & 0x7;
970 if (tmp == 2 || tmp == 4 || tmp == 6) {
973 tmp = (idx_value >> 3) & 0x7;
974 if (tmp == 2 || tmp == 4 || tmp == 6) {
996 i = (reg - 0x4500) >> 2;
997 tmp = idx_value & 0x3FFF;
1000 tmp = ((idx_value >> 15) & 1) << 11;
1002 tmp = ((idx_value >> 16) & 1) << 11;
1006 if (idx_value & (1 << 14)) {
1011 }
else if (idx_value & (1 << 14)) {
1012 DRM_ERROR(
"Forbidden bit TXFORMAT_MSB\n");
1034 i = (reg - 0x4480) >> 2;
1035 tmp = idx_value & 0x7FF;
1037 tmp = (idx_value >> 11) & 0x7FF;
1039 tmp = (idx_value >> 26) & 0xF;
1041 tmp = idx_value & (1 << 31);
1043 tmp = (idx_value >> 22) & 0xF;
1050 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1055 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1066 if (p->
rdev->hyperz_filp != p->
filp) {
1067 if (idx_value & 0x1)
1068 ib[
idx] = idx_value & ~1;
1076 if (p->
rdev->hyperz_filp != p->
filp) {
1092 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1097 track->
aa.robj = reloc->
robj;
1098 track->
aa.offset = idx_value;
1100 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1103 track->
aa.pitch = idx_value & 0x3FFE;
1114 if (idx_value && (p->
rdev->hyperz_filp != p->
filp))
1118 if (idx_value && (p->
rdev->hyperz_filp != p->
filp))
1135 printk(
KERN_ERR "Forbidden register 0x%04X in cs at %d (val=%08x)\n",
1136 reg, idx, idx_value);
1161 DRM_ERROR(
"No reloc for packet3 %d\n", pkt->
opcode);
1177 DRM_ERROR(
"PRIM_WALK must be 3 for IMMD draw\n");
1192 DRM_ERROR(
"PRIM_WALK must be 3 for IMMD draw\n");
1232 if (p->
rdev->hyperz_filp != p->
filp)
1236 if (p->
rdev->cmask_filp != p->
filp)
1242 DRM_ERROR(
"Packet3 opcode %x not supported\n", pkt->
opcode);
1268 p->
rdev->config.r300.reg_safe_bm,
1269 p->
rdev->config.r300.reg_safe_bm_size,
1270 &r300_packet0_check);
1275 r = r300_packet3_check(p, &pkt);
1278 DRM_ERROR(
"Unknown packet type %d !\n", pkt.
type);
1290 rdev->
config.
r300.reg_safe_bm = r300_reg_safe_bm;
1301 dev_err(rdev->
dev,
"Failed to create r100_mc debugfs file.\n");
1320 DRM_INFO(
"Failed to wait MC idle before programming MC.\n");
1353 r300_gpu_init(rdev);
1380 dev_err(rdev->
dev,
"failed initializing CP fences (%d).\n", r);
1390 dev_err(rdev->
dev,
"failed initializing CP (%d).\n", r);
1396 dev_err(rdev->
dev,
"IB initialization failed (%d).\n", r);
1416 dev_warn(rdev->
dev,
"GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
1428 r = r300_startup(rdev);
1485 dev_err(rdev->
dev,
"Expecting combios for RS400/RS480 GPU\n");
1495 "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
1539 r = r300_startup(rdev);
1542 dev_err(rdev->
dev,
"Disabling GPU acceleration\n");