29 #include <linux/slab.h>
43 #include <linux/module.h>
45 #include "r100_reg_safe.h"
46 #include "rn50_reg_safe.h"
49 #define FIRMWARE_R100 "radeon/R100_cp.bin"
50 #define FIRMWARE_R200 "radeon/R200_cp.bin"
51 #define FIRMWARE_R300 "radeon/R300_cp.bin"
52 #define FIRMWARE_R420 "radeon/R420_cp.bin"
53 #define FIRMWARE_RS690 "radeon/RS690_cp.bin"
54 #define FIRMWARE_RS600 "radeon/RS600_cp.bin"
55 #define FIRMWARE_R520 "radeon/R520_cp.bin"
175 DRM_DEBUG(
"Update pending now high. Unlocking vupdate_lock.\n");
197 rdev->
pm.dynpm_can_upclock =
true;
198 rdev->
pm.dynpm_can_downclock =
true;
200 switch (rdev->
pm.dynpm_planned_action) {
202 rdev->
pm.requested_power_state_index = 0;
203 rdev->
pm.dynpm_can_downclock =
false;
206 if (rdev->
pm.current_power_state_index == 0) {
207 rdev->
pm.requested_power_state_index = rdev->
pm.current_power_state_index;
208 rdev->
pm.dynpm_can_downclock =
false;
210 if (rdev->
pm.active_crtc_count > 1) {
211 for (i = 0; i < rdev->
pm.num_power_states; i++) {
214 else if (i >= rdev->
pm.current_power_state_index) {
215 rdev->
pm.requested_power_state_index = rdev->
pm.current_power_state_index;
218 rdev->
pm.requested_power_state_index =
i;
223 rdev->
pm.requested_power_state_index =
224 rdev->
pm.current_power_state_index - 1;
227 if ((rdev->
pm.active_crtc_count > 0) &&
228 (rdev->
pm.power_state[rdev->
pm.requested_power_state_index].clock_info[0].flags &
230 rdev->
pm.requested_power_state_index++;
234 if (rdev->
pm.current_power_state_index == (rdev->
pm.num_power_states - 1)) {
235 rdev->
pm.requested_power_state_index = rdev->
pm.current_power_state_index;
236 rdev->
pm.dynpm_can_upclock =
false;
238 if (rdev->
pm.active_crtc_count > 1) {
239 for (i = (rdev->
pm.num_power_states - 1); i >= 0; i--) {
242 else if (i <= rdev->
pm.current_power_state_index) {
243 rdev->
pm.requested_power_state_index = rdev->
pm.current_power_state_index;
246 rdev->
pm.requested_power_state_index =
i;
251 rdev->
pm.requested_power_state_index =
252 rdev->
pm.current_power_state_index + 1;
256 rdev->
pm.requested_power_state_index = rdev->
pm.default_power_state_index;
257 rdev->
pm.dynpm_can_upclock =
false;
261 DRM_ERROR(
"Requested mode for not defined action\n");
265 rdev->
pm.requested_clock_mode_index = 0;
267 DRM_DEBUG_DRIVER(
"Requested: e: %d m: %d p: %d\n",
268 rdev->
pm.power_state[rdev->
pm.requested_power_state_index].
269 clock_info[rdev->
pm.requested_clock_mode_index].sclk,
270 rdev->
pm.power_state[rdev->
pm.requested_power_state_index].
271 clock_info[rdev->
pm.requested_clock_mode_index].mclk,
272 rdev->
pm.power_state[rdev->
pm.requested_power_state_index].
334 int requested_index = rdev->
pm.requested_power_state_index;
337 u32 tmp, sclk_cntl, sclk_cntl2, sclk_more_cntl;
343 tmp |= voltage->
gpio.mask;
345 tmp &= ~(voltage->
gpio.mask);
352 tmp &= ~voltage->
gpio.mask;
354 tmp |= voltage->
gpio.mask;
381 if (voltage->
delay) {
383 switch (voltage->
delay) {
414 rdev->
asic->pm.set_pcie_lanes &&
416 rdev->
pm.power_state[rdev->
pm.current_power_state_index].pcie_lanes)) {
419 DRM_DEBUG_DRIVER(
"Setting: p: %d\n", ps->
pcie_lanes);
513 bool connected =
false;
582 enable |= 1 << radeon_connector->
hpd.hpd;
604 disable |= 1 << radeon_connector->
hpd.hpd;
624 if (rdev->
gart.ptr) {
625 WARN(1,
"R100 PCI GART already initialized\n");
632 rdev->
gart.table_size = rdev->
gart.num_gpu_pages * 4;
654 DRM_INFO(
"PCI GART of %uM enabled (table at 0x%016llX).\n",
655 (
unsigned)(rdev->
mc.gtt_size >> 20),
656 (
unsigned long long)rdev->
gart.table_addr);
657 rdev->
gart.ready =
true;
676 if (i < 0 || i > rdev->
gart.num_gpu_pages) {
694 if (!rdev->
irq.installed) {
695 WARN(1,
"Can't enable IRQ/MSI because no handler is installed\n");
702 if (rdev->
irq.crtc_vblank_int[0] ||
706 if (rdev->
irq.crtc_vblank_int[1] ||
710 if (rdev->
irq.hpd[0]) {
713 if (rdev->
irq.hpd[1]) {
741 return irqs & irq_mask;
747 bool queue_hotplug =
false;
749 status = r100_irq_ack(rdev);
763 if (rdev->
irq.crtc_vblank_int[0]) {
765 rdev->
pm.vblank_sync =
true;
772 if (rdev->
irq.crtc_vblank_int[1]) {
774 rdev->
pm.vblank_sync =
true;
781 queue_hotplug =
true;
785 queue_hotplug =
true;
788 status = r100_irq_ack(rdev);
856 unsigned num_gpu_pages,
869 stride_bytes &= 0x3fff;
871 pitch = stride_bytes / 64;
872 stride_pixels = stride_bytes / 4;
876 ndw = 64 + (10 * num_loops);
879 DRM_ERROR(
"radeon: moving bo (%d) asking for %u dw.\n", r, ndw);
882 while (num_gpu_pages > 0) {
883 cur_pages = num_gpu_pages;
884 if (cur_pages > 8191) {
887 num_gpu_pages -= cur_pages;
961 static int r100_cp_init_microcode(
struct radeon_device *rdev)
969 pdev = platform_device_register_simple(
"radeon_cp", 0,
NULL, 0);
978 DRM_INFO(
"Loading R100 Microcode\n");
984 DRM_INFO(
"Loading R200 Microcode\n");
992 DRM_INFO(
"Loading R300 Microcode\n");
997 DRM_INFO(
"Loading R400 Microcode\n");
1001 DRM_INFO(
"Loading RS690/RS740 Microcode\n");
1004 DRM_INFO(
"Loading RS600 Microcode\n");
1012 DRM_INFO(
"Loading R500 Microcode\n");
1021 }
else if (rdev->
me_fw->size % 8) {
1023 "radeon_cp: Bogus length %zu in firmware \"%s\"\n",
1024 rdev->
me_fw->size, fw_name);
1032 static void r100_cp_load_microcode(
struct radeon_device *rdev)
1039 "programming pipes. Bad things might happen.\n");
1043 size = rdev->
me_fw->size / 4;
1046 for (i = 0; i <
size; i += 2) {
1061 unsigned pre_write_timer;
1062 unsigned pre_write_limit;
1063 unsigned indirect2_start;
1064 unsigned indirect1_start;
1069 DRM_ERROR(
"Failed to register debugfs file for CP !\n");
1072 r = r100_cp_init_microcode(rdev);
1074 DRM_ERROR(
"Failed to load firmware!\n");
1081 ring_size = (1 << (rb_bufsz + 1)) * 4;
1082 r100_cp_load_microcode(rdev);
1096 pre_write_timer = 64;
1100 pre_write_limit = 0;
1111 indirect2_start = 80;
1112 indirect1_start = 16;
1114 WREG32(0x718, pre_write_timer | (pre_write_limit << 28));
1115 tmp = (
REG_SET(RADEON_RB_BUFSZ, rb_bufsz) |
1116 REG_SET(RADEON_RB_BLKSZ, rb_blksz) |
1117 REG_SET(RADEON_MAX_FETCH, max_fetch));
1124 DRM_INFO(
"radeon: ring at 0x%016lX\n", (
unsigned long)ring->
gpu_addr);
1137 if (rdev->
wb.enabled)
1149 REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
1150 REG_SET(RADEON_INDIRECT1_START, indirect1_start));
1161 DRM_ERROR(
"radeon: cp isn't working (%d).\n", r);
1171 DRM_ERROR(
"failed to get scratch reg for rptr save (%d).\n", r);
1180 if (r100_cp_wait_for_idle(rdev)) {
1181 DRM_ERROR(
"Wait for CP idle timeout, shutting down CP.\n");
1187 DRM_INFO(
"radeon: cp finalized\n");
1200 "programming pipes. Bad things might happen.\n");
1220 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1227 tmp = value & 0x003fffff;
1228 tmp += (((
u32)reloc->
lobj.gpu_offset) >> 10);
1235 DRM_ERROR(
"Cannot src blit from microtiled surface\n");
1243 p->
ib.ptr[
idx] = (value & 0x3fc00000) | tmp;
1245 p->
ib.ptr[
idx] = (value & 0xffc00000) | tmp;
1264 DRM_ERROR(
"Only 16 vertex buffers are allowed %d\n",
1270 for (i = 0; i < (c - 1); i+=2, idx+=3) {
1273 DRM_ERROR(
"No reloc for packet3 %d\n",
1281 track->
arrays[i + 0].esize = idx_value >> 8;
1283 track->
arrays[i + 0].esize &= 0x7F;
1286 DRM_ERROR(
"No reloc for packet3 %d\n",
1293 track->
arrays[i + 1].esize = idx_value >> 24;
1294 track->
arrays[i + 1].esize &= 0x7F;
1299 DRM_ERROR(
"No reloc for packet3 %d\n",
1307 track->
arrays[i + 0].esize = idx_value >> 8;
1308 track->
arrays[i + 0].esize &= 0x7F;
1315 const unsigned *
auth,
unsigned n,
1330 if ((reg >> 7) > n) {
1334 if (((reg + (pkt->
count << 2)) >> 7) > n) {
1338 for (i = 0; i <= pkt->
count; i++, idx++) {
1340 m = 1 << ((reg >> 2) & 31);
1342 r =
check(p, pkt, idx, reg);
1348 if (!(auth[j] & m)) {
1367 for (i = 0; i <= (pkt->
count + 1); i++, idx++) {
1368 DRM_INFO(
"ib[%d]=0x%08X\n", idx, ib[idx]);
1388 DRM_ERROR(
"Can not parse packet at %d after CS end %d !\n",
1396 switch (pkt->
type) {
1408 DRM_ERROR(
"Unknown packet type %d at %d !\n", pkt->
type, idx);
1412 DRM_ERROR(
"Packet (%d:%d:%d) end after CS buffer (%d) !\n",
1453 waitreloc.
count != 0) {
1454 DRM_ERROR(
"vline wait had illegal wait until segment\n");
1459 DRM_ERROR(
"vline wait had illegal wait until\n");
1477 DRM_ERROR(
"cannot find crtc %d\n", crtc_id);
1482 crtc_id = radeon_crtc->
crtc_id;
1488 }
else if (crtc_id == 1) {
1499 DRM_ERROR(
"unknown crtc reloc\n");
1529 DRM_ERROR(
"No relocation chunk !\n");
1540 DRM_ERROR(
"No packet3 for relocation for packet at %d.\n",
1547 DRM_ERROR(
"Relocs at %d after relocations chunk end %d !\n",
1557 static int r100_get_vtx_size(
uint32_t vtx_fmt)
1593 if (vtx_fmt & (0x7 << 15))
1594 vtx_size += (vtx_fmt >> 15) & 0x7;
1612 unsigned idx,
unsigned reg)
1632 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1649 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1654 track->
zb.robj = reloc->
robj;
1655 track->
zb.offset = idx_value;
1657 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1662 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1667 track->
cb[0].robj = reloc->
robj;
1668 track->
cb[0].offset = idx_value;
1670 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1678 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1689 tmp = idx_value & ~(0x7 << 2);
1691 ib[
idx] = tmp + ((
u32)reloc->
lobj.gpu_offset);
1693 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1705 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1710 track->
textures[0].cube_info[
i].offset = idx_value;
1711 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1723 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1728 track->
textures[1].cube_info[
i].offset = idx_value;
1729 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1741 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1746 track->
textures[2].cube_info[
i].offset = idx_value;
1747 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1752 track->
maxy = ((idx_value >> 16) & 0x7FF);
1759 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1770 tmp = idx_value & ~(0x7 << 16);
1774 ib[
idx] = idx_value;
1790 track->
cb[0].cpp = 1;
1795 track->
cb[0].cpp = 2;
1798 track->
cb[0].cpp = 4;
1801 DRM_ERROR(
"Invalid color buffer format (%d) !\n",
1810 switch (idx_value & 0xf) {
1830 DRM_ERROR(
"No reloc for ib[%d]=0x%04X\n",
1835 ib[
idx] = idx_value + ((
u32)reloc->
lobj.gpu_offset);
1841 track->
textures[i].enabled = !!(temp & (1 << i));
1849 track->
vtx_size = r100_get_vtx_size(idx_value);
1863 track->
textures[
i].pitch = idx_value + 32;
1872 tmp = (idx_value >> 23) & 0x7;
1873 if (tmp == 2 || tmp == 6)
1875 tmp = (idx_value >> 27) & 0x7;
1876 if (tmp == 2 || tmp == 6)
1929 track->
textures[
i].cube_info[4].width = 1 << ((idx_value >> 16) & 0xf);
1930 track->
textures[
i].cube_info[4].height = 1 << ((idx_value >> 20) & 0xf);
1938 for (face = 0; face < 4; face++) {
1939 track->
textures[
i].cube_info[face].width = 1 << ((tmp >> (face * 8)) & 0xf);
1940 track->
textures[
i].cube_info[face].height = 1 << ((tmp >> ((face * 8) + 4)) & 0xf);
1960 if ((value + 1) > radeon_bo_size(robj)) {
1961 DRM_ERROR(
"[drm] Buffer too small for PACKET3 INDX_BUFFER "
1962 "(need %u have %lu) !\n",
1964 radeon_bo_size(robj));
1991 DRM_ERROR(
"No reloc for packet3 %d\n", pkt->
opcode);
2005 DRM_ERROR(
"No reloc for packet3 %d\n", pkt->
opcode);
2026 DRM_ERROR(
"PRIM_WALK must be 3 for IMMD draw\n");
2039 DRM_ERROR(
"PRIM_WALK must be 3 for IMMD draw\n");
2079 if (p->
rdev->hyperz_filp != p->
filp)
2085 DRM_ERROR(
"Packet3 opcode %x not supported\n", pkt->
opcode);
2112 p->
rdev->config.r100.reg_safe_bm,
2113 p->
rdev->config.r100.reg_safe_bm_size,
2117 p->
rdev->config.r100.reg_safe_bm,
2118 p->
rdev->config.r100.reg_safe_bm_size,
2119 &r100_packet0_check);
2124 r = r100_packet3_check(p, &pkt);
2127 DRM_ERROR(
"Unknown packet type %d !\n",
2140 DRM_ERROR(
"pitch %d\n", t->
pitch);
2141 DRM_ERROR(
"use_pitch %d\n", t->
use_pitch);
2142 DRM_ERROR(
"width %d\n", t->
width);
2143 DRM_ERROR(
"width_11 %d\n", t->
width_11);
2144 DRM_ERROR(
"height %d\n", t->
height);
2145 DRM_ERROR(
"height_11 %d\n", t->
height_11);
2147 DRM_ERROR(
"depth %d\n", t->
txdepth);
2148 DRM_ERROR(
"bpp %d\n", t->
cpp);
2150 DRM_ERROR(
"width round to power of 2 %d\n", t->
roundup_w);
2151 DRM_ERROR(
"height round to power of 2 %d\n", t->
roundup_h);
2157 int block_width, block_height, block_bytes;
2158 int wblocks, hblocks;
2165 switch (compress_format) {
2177 hblocks = (h + block_height - 1) / block_height;
2178 wblocks = (w + block_width - 1) / block_width;
2179 if (wblocks < min_wblocks)
2180 wblocks = min_wblocks;
2181 sz = wblocks * hblocks * block_bytes;
2188 unsigned face,
w,
h;
2191 unsigned compress_format = track->
textures[
idx].compress_format;
2193 for (face = 0; face < 5; face++) {
2194 cube_robj = track->
textures[
idx].cube_info[face].robj;
2198 if (compress_format) {
2199 size = r100_track_compress_size(compress_format, w, h);
2204 size += track->
textures[
idx].cube_info[face].offset;
2206 if (size > radeon_bo_size(cube_robj)) {
2207 DRM_ERROR(
"Cube texture offset greater than object size %lu %lu\n",
2208 size, radeon_bo_size(cube_robj));
2209 r100_cs_track_texture_print(&track->
textures[idx]);
2216 static int r100_cs_track_texture_check(
struct radeon_device *rdev,
2221 unsigned u,
i,
w,
h,
d;
2227 if (track->
textures[u].lookup_disable)
2231 DRM_ERROR(
"No texture bound to unit %u\n", u);
2235 for (i = 0; i <= track->
textures[
u].num_levels; i++) {
2236 if (track->
textures[u].use_pitch) {
2255 if (track->
textures[u].tex_coord_type == 1) {
2256 d = (1 << track->
textures[
u].txdepth) / (1 << i);
2262 if (track->
textures[u].compress_format) {
2264 size += r100_track_compress_size(track->
textures[u].compress_format, w, h) *
d;
2271 switch (track->
textures[u].tex_coord_type) {
2277 ret = r100_cs_track_cube(rdev, track, u);
2284 DRM_ERROR(
"Invalid texture coordinate type %u for unit "
2285 "%u\n", track->
textures[u].tex_coord_type, u);
2288 if (size > radeon_bo_size(robj)) {
2289 DRM_ERROR(
"Texture of unit %u needs %lu bytes but is "
2290 "%lu\n", u, size, radeon_bo_size(robj));
2291 r100_cs_track_texture_print(&track->
textures[u]);
2310 for (i = 0; i < num_cb; i++) {
2311 if (track->
cb[i].robj ==
NULL) {
2312 DRM_ERROR(
"[drm] No buffer for color buffer %d !\n", i);
2315 size = track->
cb[
i].pitch * track->
cb[
i].cpp * track->
maxy;
2316 size += track->
cb[
i].offset;
2317 if (size > radeon_bo_size(track->
cb[i].robj)) {
2318 DRM_ERROR(
"[drm] Buffer too small for color buffer %d "
2319 "(need %lu have %lu) !\n", i, size,
2320 radeon_bo_size(track->
cb[i].robj));
2321 DRM_ERROR(
"[drm] color buffer %d (%u %u %u %u)\n",
2322 i, track->
cb[i].pitch, track->
cb[i].cpp,
2323 track->
cb[i].offset, track->
maxy);
2330 if (track->
zb.robj ==
NULL) {
2331 DRM_ERROR(
"[drm] No buffer for z buffer !\n");
2334 size = track->
zb.pitch * track->
zb.cpp * track->
maxy;
2335 size += track->
zb.offset;
2336 if (size > radeon_bo_size(track->
zb.robj)) {
2337 DRM_ERROR(
"[drm] Buffer too small for z buffer "
2338 "(need %lu have %lu) !\n", size,
2339 radeon_bo_size(track->
zb.robj));
2340 DRM_ERROR(
"[drm] zbuffer (%u %u %u %u)\n",
2341 track->
zb.pitch, track->
zb.cpp,
2342 track->
zb.offset, track->
maxy);
2349 if (track->
aa.robj ==
NULL) {
2350 DRM_ERROR(
"[drm] No buffer for AA resolve buffer %d !\n", i);
2354 size = track->
aa.pitch * track->
cb[0].cpp * track->
maxy;
2355 size += track->
aa.offset;
2356 if (size > radeon_bo_size(track->
aa.robj)) {
2357 DRM_ERROR(
"[drm] Buffer too small for AA resolve buffer %d "
2358 "(need %lu have %lu) !\n", i, size,
2359 radeon_bo_size(track->
aa.robj));
2360 DRM_ERROR(
"[drm] AA resolve buffer %d (%u %u %u %u)\n",
2361 i, track->
aa.pitch, track->
cb[0].cpp,
2362 track->
aa.offset, track->
maxy);
2374 switch (prim_walk) {
2379 DRM_ERROR(
"(PW %u) Vertex array %u no buffer "
2380 "bound\n", prim_walk, i);
2383 if (size > radeon_bo_size(track->
arrays[i].robj)) {
2384 dev_err(rdev->
dev,
"(PW %u) Vertex array %u "
2385 "need %lu dwords have %lu dwords\n",
2386 prim_walk, i, size >> 2,
2387 radeon_bo_size(track->
arrays[i].robj)
2389 DRM_ERROR(
"Max indices %u\n", track->
max_indx);
2396 size = track->
arrays[
i].esize * (nverts - 1) * 4;
2398 DRM_ERROR(
"(PW %u) Vertex array %u no buffer "
2399 "bound\n", prim_walk, i);
2402 if (size > radeon_bo_size(track->
arrays[i].robj)) {
2403 dev_err(rdev->
dev,
"(PW %u) Vertex array %u "
2404 "need %lu dwords have %lu dwords\n",
2405 prim_walk, i, size >> 2,
2406 radeon_bo_size(track->
arrays[i].robj)
2415 DRM_ERROR(
"IMMD draw %u dwors but needs %lu dwords\n",
2417 DRM_ERROR(
"VAP_VF_CNTL.NUM_VERTICES %u, VTX_SIZE %u\n",
2423 DRM_ERROR(
"[drm] Invalid primitive walk %d for VAP_VF_CNTL\n",
2430 return r100_cs_track_texture_check(rdev, track);
2461 for (i = 0; i < track->
num_cb; i++) {
2463 track->
cb[
i].pitch = 8192;
2464 track->
cb[
i].cpp = 16;
2465 track->
cb[
i].offset = 0;
2469 track->
zb.pitch = 8192;
2471 track->
zb.offset = 0;
2478 track->
arrays[
i].esize = 0x7F;
2499 track->
textures[
i].lookup_disable =
false;
2503 for (face = 0; face < 5; face++) {
2505 track->
textures[
i].cube_info[face].width = 16536;
2506 track->
textures[
i].cube_info[face].height = 16536;
2507 track->
textures[
i].cube_info[face].offset = 0;
2530 static int r100_rbbm_fifo_wait_for_entry(
struct radeon_device *rdev,
unsigned n)
2550 if (r100_rbbm_fifo_wait_for_entry(rdev, 64)) {
2552 " Bad things might happen.\n");
2632 dev_info(rdev->
dev,
"(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
2653 dev_info(rdev->
dev,
"(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
2661 dev_info(rdev->
dev,
"(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
2679 bool force_dac2 =
false;
2696 switch (dev->pdev->device) {
2706 if ((dev->pdev->subsystem_vendor == 0x1028 ) &&
2707 ((dev->pdev->subsystem_device == 0x016c) ||
2708 (dev->pdev->subsystem_device == 0x016d) ||
2709 (dev->pdev->subsystem_device == 0x016e) ||
2710 (dev->pdev->subsystem_device == 0x016f) ||
2711 (dev->pdev->subsystem_device == 0x0170) ||
2712 (dev->pdev->subsystem_device == 0x017d) ||
2713 (dev->pdev->subsystem_device == 0x017e) ||
2714 (dev->pdev->subsystem_device == 0x0183) ||
2715 (dev->pdev->subsystem_device == 0x018a) ||
2716 (dev->pdev->subsystem_device == 0x019a)))
2767 rdev->
mc.vram_is_ddr =
false;
2769 rdev->
mc.vram_is_ddr =
true;
2771 rdev->
mc.vram_is_ddr =
true;
2777 rdev->
mc.vram_width = 32;
2779 rdev->
mc.vram_width = 64;
2782 rdev->
mc.vram_width /= 4;
2783 rdev->
mc.vram_is_ddr =
true;
2788 rdev->
mc.vram_width = 128;
2790 rdev->
mc.vram_width = 64;
2794 rdev->
mc.vram_width = 128;
2812 DRM_INFO(
"Generation 2 PCI interface, using max accessible memory\n");
2813 return aper_size * 2;
2820 pci_read_config_byte(rdev->
pdev, 0
xe, &byte);
2822 DRM_INFO(
"Generation 1 PCI interface in multifunction mode\n");
2823 DRM_INFO(
"Limiting VRAM to one aperture\n");
2832 return aper_size * 2;
2838 u64 config_aper_size;
2843 rdev->
mc.visible_vram_size = r100_get_accessible_vram(rdev);
2845 if (rdev->
mc.visible_vram_size > rdev->
mc.aper_size)
2846 rdev->
mc.visible_vram_size = rdev->
mc.aper_size;
2852 rdev->
mc.real_vram_size = (((tom >> 16) - (tom & 0xffff) + 1) << 16);
2854 rdev->
mc.mc_vram_size = rdev->
mc.real_vram_size;
2860 if (rdev->
mc.real_vram_size == 0) {
2861 rdev->
mc.real_vram_size = 8192 * 1024;
2867 if (rdev->
mc.aper_size > config_aper_size)
2868 config_aper_size = rdev->
mc.aper_size;
2870 if (config_aper_size > rdev->
mc.real_vram_size)
2871 rdev->
mc.mc_vram_size = config_aper_size;
2873 rdev->
mc.mc_vram_size = rdev->
mc.real_vram_size;
2882 if (state ==
false) {
2895 r100_vram_get_type(rdev);
2897 base = rdev->
mc.aper_base;
2901 rdev->
mc.gtt_base_align = 0;
2919 static void r100_pll_errata_after_data(
struct radeon_device *rdev)
2951 r100_pll_errata_after_data(rdev);
2960 r100_pll_errata_after_data(rdev);
2963 static void r100_set_safe_registers(
struct radeon_device *rdev)
2966 rdev->
config.
r100.reg_safe_bm = rn50_reg_safe_bm;
2969 rdev->
config.
r100.reg_safe_bm = r100_reg_safe_bm;
2979 #if defined(CONFIG_DEBUG_FS)
2980 static int r100_debugfs_rbbm_info(
struct seq_file *
m,
void *
data)
2982 struct drm_info_node *
node = (
struct drm_info_node *) m->
private;
2991 for (i = 0; i < 64; i++) {
3001 static int r100_debugfs_cp_ring_info(
struct seq_file *m,
void *data)
3003 struct drm_info_node *node = (
struct drm_info_node *) m->
private;
3013 count = (rdp +
ring->ring_size - wdp) &
ring->ptr_mask;
3020 i = (rdp +
j) &
ring->ptr_mask;
3027 static int r100_debugfs_cp_csq_fifo(
struct seq_file *m,
void *data)
3029 struct drm_info_node *node = (
struct drm_info_node *) m->
private;
3033 unsigned r_rptr, r_wptr, ib1_rptr, ib1_wptr, ib2_rptr, ib2_wptr;
3040 r_rptr = (csq_stat >> 0) & 0x3ff;
3041 r_wptr = (csq_stat >> 10) & 0x3ff;
3042 ib1_rptr = (csq_stat >> 20) & 0x3ff;
3043 ib1_wptr = (csq2_stat >> 0) & 0x3ff;
3044 ib2_rptr = (csq2_stat >> 10) & 0x3ff;
3045 ib2_wptr = (csq2_stat >> 20) & 0x3ff;
3046 seq_printf(m,
"CP_CSQ_STAT 0x%08x\n", csq_stat);
3047 seq_printf(m,
"CP_CSQ2_STAT 0x%08x\n", csq2_stat);
3050 seq_printf(m,
"Indirect1 rptr %u\n", ib1_rptr);
3051 seq_printf(m,
"Indirect1 wptr %u\n", ib1_wptr);
3052 seq_printf(m,
"Indirect2 rptr %u\n", ib2_rptr);
3053 seq_printf(m,
"Indirect2 wptr %u\n", ib2_wptr);
3057 for (i = 0; i < 256; i++) {
3060 seq_printf(m,
"rfifo[%04d]=0x%08X\n", i, tmp);
3063 for (i = 256; i <= 512; i++) {
3066 seq_printf(m,
"ib1fifo[%04d]=0x%08X\n", i, tmp);
3069 for (i = 640; i < ib1_wptr; i++) {
3072 seq_printf(m,
"ib2fifo[%04d]=0x%08X\n", i, tmp);
3077 static int r100_debugfs_mc_info(
struct seq_file *m,
void *data)
3079 struct drm_info_node *node = (
struct drm_info_node *) m->
private;
3085 seq_printf(m,
"CONFIG_MEMSIZE 0x%08x\n", tmp);
3087 seq_printf(m,
"MC_FB_LOCATION 0x%08x\n", tmp);
3091 seq_printf(m,
"MC_AGP_LOCATION 0x%08x\n", tmp);
3095 seq_printf(m,
"HOST_PATH_CNTL 0x%08x\n", tmp);
3107 static struct drm_info_list r100_debugfs_rbbm_list[] = {
3108 {
"r100_rbbm_info", r100_debugfs_rbbm_info, 0,
NULL},
3111 static struct drm_info_list r100_debugfs_cp_list[] = {
3112 {
"r100_cp_ring_info", r100_debugfs_cp_ring_info, 0,
NULL},
3113 {
"r100_cp_csq_fifo", r100_debugfs_cp_csq_fifo, 0,
NULL},
3116 static struct drm_info_list r100_debugfs_mc_info_list[] = {
3117 {
"r100_mc_info", r100_debugfs_mc_info, 0,
NULL},
3123 #if defined(CONFIG_DEBUG_FS)
3132 #if defined(CONFIG_DEBUG_FS)
3141 #if defined(CONFIG_DEBUG_FS)
3152 int surf_index = reg * 16;
3179 if (tiling_flags & (RADEON_TILING_SWAP_16BIT | RADEON_TILING_SWAP_32BIT)) {
3187 flags |= pitch / 16;
3192 DRM_DEBUG_KMS(
"writing surface %d %d %x %x\n", reg, flags, offset, offset+obj_size-1);
3201 int surf_index = reg * 16;
3207 fixed20_12 trcd_ff, trp_ff, tras_ff, trbs_ff, tcas_ff;
3208 fixed20_12 sclk_ff, mclk_ff, sclk_eff_ff, sclk_delay_ff;
3209 fixed20_12 peak_disp_bw, mem_bw, pix_clk, pix_clk2, temp_ff, crit_point_ff;
3262 fixed20_12 cur_latency_mclk, cur_latency_sclk;
3263 fixed20_12 disp_latency, disp_latency_overhead, disp_drain_rate,
3264 disp_drain_rate2, read_return_rate;
3268 int critical_point = 0, critical_point2;
3270 int stop_req, max_stop_req;
3278 if (rdev->
mode_info.crtcs[0]->base.enabled) {
3279 mode1 = &rdev->
mode_info.crtcs[0]->base.mode;
3280 pixel_bytes1 = rdev->
mode_info.crtcs[0]->base.fb->bits_per_pixel / 8;
3283 if (rdev->
mode_info.crtcs[1]->base.enabled) {
3284 mode2 = &rdev->
mode_info.crtcs[1]->base.mode;
3285 pixel_bytes2 = rdev->
mode_info.crtcs[1]->base.fb->bits_per_pixel / 8;
3306 sclk_ff = rdev->
pm.sclk;
3307 mclk_ff = rdev->
pm.mclk;
3309 temp = (rdev->
mc.vram_width / 8) * (rdev->
mc.vram_is_ddr ? 2 : 1);
3315 peak_disp_bw.
full = 0;
3319 pix_clk.
full = dfixed_div(pix_clk, temp_ff);
3326 pix_clk2.
full = dfixed_div(pix_clk2, temp_ff);
3332 if (peak_disp_bw.
full >= mem_bw.
full) {
3333 DRM_ERROR(
"You may not have enough display bandwidth for current mode\n"
3334 "If you have flickering problem, try to lower resolution, refresh rate, or color depth\n");
3340 mem_trcd = ((temp >> 2) & 0x3) + 1;
3341 mem_trp = ((temp & 0x3)) + 1;
3342 mem_tras = ((temp & 0x70) >> 4) + 1;
3345 mem_trcd = (temp & 0x7) + 1;
3346 mem_trp = ((temp >> 8) & 0x7) + 1;
3347 mem_tras = ((temp >> 11) & 0xf) + 4;
3351 mem_trcd = (temp & 0x7) + 3;
3352 mem_trp = ((temp >> 8) & 0x7) + 3;
3353 mem_tras = ((temp >> 11) & 0xf) + 6;
3358 mem_trcd = (temp & 0xf) + 3;
3361 mem_trp = ((temp >> 8) & 0xf) + 3;
3364 mem_tras = ((temp >> 12) & 0x1f) + 6;
3368 mem_trcd = (temp & 0x7) + 1;
3369 mem_trp = ((temp >> 8) & 0x7) + 1;
3370 mem_tras = ((temp >> 12) & 0xf) + 4;
3379 data = (temp & (7 << 20)) >> 20;
3382 tcas_ff = memtcas_rs480_ff[
data];
3384 tcas_ff = memtcas_ff[
data];
3386 tcas_ff = memtcas2_ff[
data];
3391 data = (temp >> 23) & 0x7;
3420 trbs_ff = memtrbs_r4xx[
data];
3422 trbs_ff = memtrbs[
data];
3441 if (rdev->
mc.vram_is_ddr)
3446 if (rdev->
mc.vram_width == 128)
3453 mc_latency_sclk.
full = dfixed_div(sclk_delay_ff, sclk_eff_ff);
3455 if (rdev->
mc.vram_is_ddr) {
3456 if (rdev->
mc.vram_width == 32) {
3477 mc_latency_mclk.
full = dfixed_div(mc_latency_mclk, mclk_ff);
3478 mc_latency_mclk.
full += dfixed_div(temp_ff, sclk_eff_ff);
3487 cur_latency_mclk.
full = dfixed_div(temp_ff, mclk_ff);
3490 cur_latency_sclk.
full = dfixed_div(temp_ff, sclk_eff_ff);
3495 disp_latency_overhead.
full = dfixed_div(disp_latency_overhead, sclk_ff);
3496 mc_latency_mclk.
full += disp_latency_overhead.
full + cur_latency_mclk.
full;
3497 mc_latency_sclk.
full += disp_latency_overhead.
full + cur_latency_sclk.
full;
3499 if (mc_latency_mclk.
full > mc_latency_sclk.
full)
3500 disp_latency.
full = mc_latency_mclk.
full;
3502 disp_latency.
full = mc_latency_sclk.
full;
3506 max_stop_req = 0x5c;
3508 max_stop_req = 0x7c;
3515 stop_req = mode1->
hdisplay * pixel_bytes1 / 16;
3517 if (stop_req > max_stop_req)
3518 stop_req = max_stop_req;
3524 disp_drain_rate.
full = dfixed_div(pix_clk, temp_ff);
3542 if (max_stop_req - critical_point < 4)
3547 critical_point = 0x10;
3555 (stop_req > 0x15)) {
3573 temp =
RREG32(RS400_DISP1_REG_CNTL);
3588 DRM_DEBUG_KMS(
"GRPH_BUFFER_CNTL from to %x\n",
3595 stop_req = mode2->
hdisplay * pixel_bytes2 / 16;
3597 if (stop_req > max_stop_req)
3598 stop_req = max_stop_req;
3604 disp_drain_rate2.
full = dfixed_div(pix_clk2, temp_ff);
3611 (stop_req > 0x15)) {
3622 critical_point2 = 0;
3624 temp = (rdev->
mc.vram_width * rdev->
mc.vram_is_ddr + 1)/128;
3630 read_return_rate.
full = temp_ff.
full;
3633 temp_ff.
full = read_return_rate.
full - disp_drain_rate.
full;
3634 time_disp1_drop_priority.
full = dfixed_div(crit_point_ff, temp_ff);
3636 time_disp1_drop_priority.
full = 0;
3638 crit_point_ff.
full = disp_latency.
full + time_disp1_drop_priority.
full + disp_latency.
full;
3639 crit_point_ff.
full =
dfixed_mul(crit_point_ff, disp_drain_rate2);
3645 critical_point2 = 0;
3648 if (max_stop_req - critical_point2 < 4)
3649 critical_point2 = 0;
3655 critical_point2 = 0x10;
3684 DRM_DEBUG_KMS(
"GRPH2_BUFFER_CNTL from to %x\n",
3698 DRM_ERROR(
"radeon: cp failed to get scratch reg (%d).\n", r);
3701 WREG32(scratch, 0xCAFEDEAD);
3704 DRM_ERROR(
"radeon: cp failed to lock ring (%d).\n", r);
3713 if (tmp == 0xDEADBEEF) {
3718 if (i < rdev->usec_timeout) {
3719 DRM_INFO(
"ring test succeeded in %d usecs\n", i);
3721 DRM_ERROR(
"radeon: ring test failed (scratch(0x%04X)=0x%08X)\n",
3734 u32 next_rptr = ring->
wptr + 2 + 3;
3754 DRM_ERROR(
"radeon: failed to get scratch reg (%d).\n", r);
3757 WREG32(scratch, 0xCAFEDEAD);
3760 DRM_ERROR(
"radeon: failed to get ib (%d).\n", r);
3764 ib.
ptr[1] = 0xDEADBEEF;
3774 DRM_ERROR(
"radeon: failed to schedule ib (%d).\n", r);
3779 DRM_ERROR(
"radeon: fence wait failed (%d).\n", r);
3784 if (tmp == 0xDEADBEEF) {
3789 if (i < rdev->usec_timeout) {
3790 DRM_INFO(
"ib test succeeded in %u usecs\n", i);
3792 DRM_ERROR(
"radeon: ib test failed (scratch(0x%04X)=0x%08X)\n",
3875 dev_warn(rdev->
dev,
"Failed to create r100_mc debugfs file.\n");
3900 dev_warn(rdev->
dev,
"Wait for MC idle timeout.\n");
3929 r100_mc_program(rdev);
3931 r100_clock_startup(rdev);
3948 dev_err(rdev->
dev,
"failed initializing CP fences (%d).\n", r);
3958 dev_err(rdev->
dev,
"failed initializing CP (%d).\n", r);
3964 dev_err(rdev->
dev,
"IB initialization failed (%d).\n", r);
3979 r100_clock_startup(rdev);
3982 dev_warn(rdev->
dev,
"GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
3989 r100_clock_startup(rdev);
3994 r = r100_startup(rdev);
4074 dev_err(rdev->
dev,
"Expecting combios for RS400/RS480 GPU\n");
4084 "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
4120 r100_set_safe_registers(rdev);
4123 r = r100_startup(rdev);
4126 dev_err(rdev->
dev,
"Disabling GPU acceleration\n");