aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2011-10-18 05:54:30 -0400
committerDave Airlie <airlied@redhat.com>2011-10-18 05:54:30 -0400
commit017ed8012e74ca15748863f45d2c078453026a0a (patch)
tree7071171a06de4e93fc890e0afce5c23596a26619 /drivers/gpu/drm
parent80d9b24a658c83602aea66e45e2347c5bb3cbd47 (diff)
parent899e3ee404961a90b828ad527573aaaac39f0ab1 (diff)
Merge tag 'v3.1-rc10' into drm-core-next
There are a number of fixes in mainline required for code in -next, also there was a few conflicts I'd rather resolve myself. Signed-off-by: Dave Airlie <airlied@redhat.com> Conflicts: drivers/gpu/drm/radeon/evergreen.c drivers/gpu/drm/radeon/r600.c drivers/gpu/drm/radeon/radeon_asic.h
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c4
-rw-r--r--drivers/gpu/drm/i915/intel_display.c12
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h3
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c88
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c28
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c48
-rw-r--r--drivers/gpu/drm/radeon/ni.c44
-rw-r--r--drivers/gpu/drm/radeon/r100.c22
-rw-r--r--drivers/gpu/drm/radeon/r200.c4
-rw-r--r--drivers/gpu/drm/radeon/r600.c14
-rw-r--r--drivers/gpu/drm/radeon/radeon.h7
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h6
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c29
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c40
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c18
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c7
-rw-r--r--drivers/gpu/drm/radeon/rv770.c51
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c3
19 files changed, 147 insertions, 283 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index b79c6f14fb72..c96b019a3b76 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -67,11 +67,11 @@ module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600);
67MODULE_PARM_DESC(i915_enable_rc6, 67MODULE_PARM_DESC(i915_enable_rc6,
68 "Enable power-saving render C-state 6 (default: true)"); 68 "Enable power-saving render C-state 6 (default: true)");
69 69
70unsigned int i915_enable_fbc __read_mostly = 1; 70unsigned int i915_enable_fbc __read_mostly = -1;
71module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600); 71module_param_named(i915_enable_fbc, i915_enable_fbc, int, 0600);
72MODULE_PARM_DESC(i915_enable_fbc, 72MODULE_PARM_DESC(i915_enable_fbc,
73 "Enable frame buffer compression for power savings " 73 "Enable frame buffer compression for power savings "
74 "(default: false)"); 74 "(default: -1 (use per-chip default))");
75 75
76unsigned int i915_lvds_downclock __read_mostly = 0; 76unsigned int i915_lvds_downclock __read_mostly = 0;
77module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400); 77module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f0e5f9f32aa8..8230cf54cc8d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1800,6 +1800,7 @@ static void intel_update_fbc(struct drm_device *dev)
1800 struct drm_framebuffer *fb; 1800 struct drm_framebuffer *fb;
1801 struct intel_framebuffer *intel_fb; 1801 struct intel_framebuffer *intel_fb;
1802 struct drm_i915_gem_object *obj; 1802 struct drm_i915_gem_object *obj;
1803 int enable_fbc;
1803 1804
1804 DRM_DEBUG_KMS("\n"); 1805 DRM_DEBUG_KMS("\n");
1805 1806
@@ -1840,8 +1841,15 @@ static void intel_update_fbc(struct drm_device *dev)
1840 intel_fb = to_intel_framebuffer(fb); 1841 intel_fb = to_intel_framebuffer(fb);
1841 obj = intel_fb->obj; 1842 obj = intel_fb->obj;
1842 1843
1843 if (!i915_enable_fbc) { 1844 enable_fbc = i915_enable_fbc;
1844 DRM_DEBUG_KMS("fbc disabled per module param (default off)\n"); 1845 if (enable_fbc < 0) {
1846 DRM_DEBUG_KMS("fbc set to per-chip default\n");
1847 enable_fbc = 1;
1848 if (INTEL_INFO(dev)->gen <= 5)
1849 enable_fbc = 0;
1850 }
1851 if (!enable_fbc) {
1852 DRM_DEBUG_KMS("fbc disabled per module param\n");
1845 dev_priv->no_fbc_reason = FBC_MODULE_PARAM; 1853 dev_priv->no_fbc_reason = FBC_MODULE_PARAM;
1846 goto out_disable; 1854 goto out_disable;
1847 } 1855 }
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b7e718639b13..98044d626a8d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -337,9 +337,6 @@ extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
337 struct drm_connector *connector, 337 struct drm_connector *connector,
338 struct intel_load_detect_pipe *old); 338 struct intel_load_detect_pipe *old);
339 339
340extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);
341extern int intel_sdvo_supports_hotplug(struct drm_connector *connector);
342extern void intel_sdvo_set_hotplug(struct drm_connector *connector, int enable);
343extern void intelfb_restore(void); 340extern void intelfb_restore(void);
344extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, 341extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
345 u16 blue, int regno); 342 u16 blue, int regno);
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index aa94110f0be4..731200243219 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -92,6 +92,11 @@ struct intel_sdvo {
92 */ 92 */
93 uint16_t attached_output; 93 uint16_t attached_output;
94 94
95 /*
96 * Hotplug activation bits for this device
97 */
98 uint8_t hotplug_active[2];
99
95 /** 100 /**
96 * This is used to select the color range of RBG outputs in HDMI mode. 101 * This is used to select the color range of RBG outputs in HDMI mode.
97 * It is only valid when using TMDS encoding and 8 bit per color mode. 102 * It is only valid when using TMDS encoding and 8 bit per color mode.
@@ -1208,74 +1213,20 @@ static bool intel_sdvo_get_capabilities(struct intel_sdvo *intel_sdvo, struct in
1208 return true; 1213 return true;
1209} 1214}
1210 1215
1211/* No use! */ 1216static int intel_sdvo_supports_hotplug(struct intel_sdvo *intel_sdvo)
1212#if 0
1213struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB)
1214{
1215 struct drm_connector *connector = NULL;
1216 struct intel_sdvo *iout = NULL;
1217 struct intel_sdvo *sdvo;
1218
1219 /* find the sdvo connector */
1220 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1221 iout = to_intel_sdvo(connector);
1222
1223 if (iout->type != INTEL_OUTPUT_SDVO)
1224 continue;
1225
1226 sdvo = iout->dev_priv;
1227
1228 if (sdvo->sdvo_reg == SDVOB && sdvoB)
1229 return connector;
1230
1231 if (sdvo->sdvo_reg == SDVOC && !sdvoB)
1232 return connector;
1233
1234 }
1235
1236 return NULL;
1237}
1238
1239int intel_sdvo_supports_hotplug(struct drm_connector *connector)
1240{ 1217{
1241 u8 response[2]; 1218 u8 response[2];
1242 u8 status;
1243 struct intel_sdvo *intel_sdvo;
1244 DRM_DEBUG_KMS("\n");
1245
1246 if (!connector)
1247 return 0;
1248
1249 intel_sdvo = to_intel_sdvo(connector);
1250 1219
1251 return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, 1220 return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
1252 &response, 2) && response[0]; 1221 &response, 2) && response[0];
1253} 1222}
1254 1223
1255void intel_sdvo_set_hotplug(struct drm_connector *connector, int on) 1224static void intel_sdvo_enable_hotplug(struct intel_encoder *encoder)
1256{ 1225{
1257 u8 response[2]; 1226 struct intel_sdvo *intel_sdvo = to_intel_sdvo(&encoder->base);
1258 u8 status;
1259 struct intel_sdvo *intel_sdvo = to_intel_sdvo(connector);
1260
1261 intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
1262 intel_sdvo_read_response(intel_sdvo, &response, 2);
1263
1264 if (on) {
1265 intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0);
1266 status = intel_sdvo_read_response(intel_sdvo, &response, 2);
1267
1268 intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
1269 } else {
1270 response[0] = 0;
1271 response[1] = 0;
1272 intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
1273 }
1274 1227
1275 intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); 1228 intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &intel_sdvo->hotplug_active, 2);
1276 intel_sdvo_read_response(intel_sdvo, &response, 2);
1277} 1229}
1278#endif
1279 1230
1280static bool 1231static bool
1281intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo) 1232intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo)
@@ -2045,6 +1996,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2045{ 1996{
2046 struct drm_encoder *encoder = &intel_sdvo->base.base; 1997 struct drm_encoder *encoder = &intel_sdvo->base.base;
2047 struct drm_connector *connector; 1998 struct drm_connector *connector;
1999 struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
2048 struct intel_connector *intel_connector; 2000 struct intel_connector *intel_connector;
2049 struct intel_sdvo_connector *intel_sdvo_connector; 2001 struct intel_sdvo_connector *intel_sdvo_connector;
2050 2002
@@ -2062,7 +2014,17 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2062 2014
2063 intel_connector = &intel_sdvo_connector->base; 2015 intel_connector = &intel_sdvo_connector->base;
2064 connector = &intel_connector->base; 2016 connector = &intel_connector->base;
2065 connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; 2017 if (intel_sdvo_supports_hotplug(intel_sdvo) & (1 << device)) {
2018 connector->polled = DRM_CONNECTOR_POLL_HPD;
2019 intel_sdvo->hotplug_active[0] |= 1 << device;
2020 /* Some SDVO devices have one-shot hotplug interrupts.
2021 * Ensure that they get re-enabled when an interrupt happens.
2022 */
2023 intel_encoder->hot_plug = intel_sdvo_enable_hotplug;
2024 intel_sdvo_enable_hotplug(intel_encoder);
2025 }
2026 else
2027 connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
2066 encoder->encoder_type = DRM_MODE_ENCODER_TMDS; 2028 encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
2067 connector->connector_type = DRM_MODE_CONNECTOR_DVID; 2029 connector->connector_type = DRM_MODE_CONNECTOR_DVID;
2068 2030
@@ -2569,6 +2531,14 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
2569 if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps)) 2531 if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps))
2570 goto err; 2532 goto err;
2571 2533
2534 /* Set up hotplug command - note paranoia about contents of reply.
2535 * We assume that the hardware is in a sane state, and only touch
2536 * the bits we think we understand.
2537 */
2538 intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG,
2539 &intel_sdvo->hotplug_active, 2);
2540 intel_sdvo->hotplug_active[0] &= ~0x3;
2541
2572 if (intel_sdvo_output_setup(intel_sdvo, 2542 if (intel_sdvo_output_setup(intel_sdvo,
2573 intel_sdvo->caps.output_flags) != true) { 2543 intel_sdvo->caps.output_flags) != true) {
2574 DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n", 2544 DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 7ad43c6b1db7..79e8ebc05307 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -115,6 +115,7 @@ static int radeon_dp_aux_native_write(struct radeon_connector *radeon_connector,
115 u8 msg[20]; 115 u8 msg[20];
116 int msg_bytes = send_bytes + 4; 116 int msg_bytes = send_bytes + 4;
117 u8 ack; 117 u8 ack;
118 unsigned retry;
118 119
119 if (send_bytes > 16) 120 if (send_bytes > 16)
120 return -1; 121 return -1;
@@ -125,20 +126,22 @@ static int radeon_dp_aux_native_write(struct radeon_connector *radeon_connector,
125 msg[3] = (msg_bytes << 4) | (send_bytes - 1); 126 msg[3] = (msg_bytes << 4) | (send_bytes - 1);
126 memcpy(&msg[4], send, send_bytes); 127 memcpy(&msg[4], send, send_bytes);
127 128
128 while (1) { 129 for (retry = 0; retry < 4; retry++) {
129 ret = radeon_process_aux_ch(dig_connector->dp_i2c_bus, 130 ret = radeon_process_aux_ch(dig_connector->dp_i2c_bus,
130 msg, msg_bytes, NULL, 0, delay, &ack); 131 msg, msg_bytes, NULL, 0, delay, &ack);
131 if (ret < 0) 132 if (ret == -EBUSY)
133 continue;
134 else if (ret < 0)
132 return ret; 135 return ret;
133 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) 136 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK)
134 break; 137 return send_bytes;
135 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) 138 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER)
136 udelay(400); 139 udelay(400);
137 else 140 else
138 return -EIO; 141 return -EIO;
139 } 142 }
140 143
141 return send_bytes; 144 return -EIO;
142} 145}
143 146
144static int radeon_dp_aux_native_read(struct radeon_connector *radeon_connector, 147static int radeon_dp_aux_native_read(struct radeon_connector *radeon_connector,
@@ -149,26 +152,31 @@ static int radeon_dp_aux_native_read(struct radeon_connector *radeon_connector,
149 int msg_bytes = 4; 152 int msg_bytes = 4;
150 u8 ack; 153 u8 ack;
151 int ret; 154 int ret;
155 unsigned retry;
152 156
153 msg[0] = address; 157 msg[0] = address;
154 msg[1] = address >> 8; 158 msg[1] = address >> 8;
155 msg[2] = AUX_NATIVE_READ << 4; 159 msg[2] = AUX_NATIVE_READ << 4;
156 msg[3] = (msg_bytes << 4) | (recv_bytes - 1); 160 msg[3] = (msg_bytes << 4) | (recv_bytes - 1);
157 161
158 while (1) { 162 for (retry = 0; retry < 4; retry++) {
159 ret = radeon_process_aux_ch(dig_connector->dp_i2c_bus, 163 ret = radeon_process_aux_ch(dig_connector->dp_i2c_bus,
160 msg, msg_bytes, recv, recv_bytes, delay, &ack); 164 msg, msg_bytes, recv, recv_bytes, delay, &ack);
161 if (ret == 0) 165 if (ret == -EBUSY)
162 return -EPROTO; 166 continue;
163 if (ret < 0) 167 else if (ret < 0)
164 return ret; 168 return ret;
165 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) 169 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK)
166 return ret; 170 return ret;
167 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER) 171 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER)
168 udelay(400); 172 udelay(400);
173 else if (ret == 0)
174 return -EPROTO;
169 else 175 else
170 return -EIO; 176 return -EIO;
171 } 177 }
178
179 return -EIO;
172} 180}
173 181
174static void radeon_write_dpcd_reg(struct radeon_connector *radeon_connector, 182static void radeon_write_dpcd_reg(struct radeon_connector *radeon_connector,
@@ -232,7 +240,9 @@ int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
232 for (retry = 0; retry < 4; retry++) { 240 for (retry = 0; retry < 4; retry++) {
233 ret = radeon_process_aux_ch(auxch, 241 ret = radeon_process_aux_ch(auxch,
234 msg, msg_bytes, reply, reply_bytes, 0, &ack); 242 msg, msg_bytes, reply, reply_bytes, 0, &ack);
235 if (ret < 0) { 243 if (ret == -EBUSY)
244 continue;
245 else if (ret < 0) {
236 DRM_DEBUG_KMS("aux_ch failed %d\n", ret); 246 DRM_DEBUG_KMS("aux_ch failed %d\n", ret);
237 return ret; 247 return ret;
238 } 248 }
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 35b5673d432d..ed406e8404a3 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1407,7 +1407,8 @@ int evergreen_cp_resume(struct radeon_device *rdev)
1407 /* Initialize the ring buffer's read and write pointers */ 1407 /* Initialize the ring buffer's read and write pointers */
1408 WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA); 1408 WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA);
1409 WREG32(CP_RB_RPTR_WR, 0); 1409 WREG32(CP_RB_RPTR_WR, 0);
1410 WREG32(CP_RB_WPTR, 0); 1410 rdev->cp.wptr = 0;
1411 WREG32(CP_RB_WPTR, rdev->cp.wptr);
1411 1412
1412 /* set the wb address wether it's enabled or not */ 1413 /* set the wb address wether it's enabled or not */
1413 WREG32(CP_RB_RPTR_ADDR, 1414 WREG32(CP_RB_RPTR_ADDR,
@@ -1429,7 +1430,6 @@ int evergreen_cp_resume(struct radeon_device *rdev)
1429 WREG32(CP_DEBUG, (1 << 27) | (1 << 28)); 1430 WREG32(CP_DEBUG, (1 << 27) | (1 << 28));
1430 1431
1431 rdev->cp.rptr = RREG32(CP_RB_RPTR); 1432 rdev->cp.rptr = RREG32(CP_RB_RPTR);
1432 rdev->cp.wptr = RREG32(CP_RB_WPTR);
1433 1433
1434 evergreen_cp_start(rdev); 1434 evergreen_cp_start(rdev);
1435 rdev->cp.ready = true; 1435 rdev->cp.ready = true;
@@ -1593,48 +1593,6 @@ static u32 evergreen_get_tile_pipe_to_backend_map(struct radeon_device *rdev,
1593 return backend_map; 1593 return backend_map;
1594} 1594}
1595 1595
1596static void evergreen_program_channel_remap(struct radeon_device *rdev)
1597{
1598 u32 tcp_chan_steer_lo, tcp_chan_steer_hi, mc_shared_chremap, tmp;
1599
1600 tmp = RREG32(MC_SHARED_CHMAP);
1601 switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) {
1602 case 0:
1603 case 1:
1604 case 2:
1605 case 3:
1606 default:
1607 /* default mapping */
1608 mc_shared_chremap = 0x00fac688;
1609 break;
1610 }
1611
1612 switch (rdev->family) {
1613 case CHIP_HEMLOCK:
1614 case CHIP_CYPRESS:
1615 case CHIP_BARTS:
1616 tcp_chan_steer_lo = 0x54763210;
1617 tcp_chan_steer_hi = 0x0000ba98;
1618 break;
1619 case CHIP_JUNIPER:
1620 case CHIP_REDWOOD:
1621 case CHIP_CEDAR:
1622 case CHIP_PALM:
1623 case CHIP_SUMO:
1624 case CHIP_SUMO2:
1625 case CHIP_TURKS:
1626 case CHIP_CAICOS:
1627 default:
1628 tcp_chan_steer_lo = 0x76543210;
1629 tcp_chan_steer_hi = 0x0000ba98;
1630 break;
1631 }
1632
1633 WREG32(TCP_CHAN_STEER_LO, tcp_chan_steer_lo);
1634 WREG32(TCP_CHAN_STEER_HI, tcp_chan_steer_hi);
1635 WREG32(MC_SHARED_CHREMAP, mc_shared_chremap);
1636}
1637
1638static void evergreen_gpu_init(struct radeon_device *rdev) 1596static void evergreen_gpu_init(struct radeon_device *rdev)
1639{ 1597{
1640 u32 cc_rb_backend_disable = 0; 1598 u32 cc_rb_backend_disable = 0;
@@ -2081,8 +2039,6 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
2081 WREG32(DMIF_ADDR_CONFIG, gb_addr_config); 2039 WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
2082 WREG32(HDP_ADDR_CONFIG, gb_addr_config); 2040 WREG32(HDP_ADDR_CONFIG, gb_addr_config);
2083 2041
2084 evergreen_program_channel_remap(rdev);
2085
2086 num_shader_engines = ((RREG32(GB_ADDR_CONFIG) & NUM_SHADER_ENGINES(3)) >> 12) + 1; 2042 num_shader_engines = ((RREG32(GB_ADDR_CONFIG) & NUM_SHADER_ENGINES(3)) >> 12) + 1;
2087 grbm_gfx_index = INSTANCE_BROADCAST_WRITES; 2043 grbm_gfx_index = INSTANCE_BROADCAST_WRITES;
2088 2044
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 770cc2ab088a..556b7bc3418b 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -570,36 +570,6 @@ static u32 cayman_get_tile_pipe_to_backend_map(struct radeon_device *rdev,
570 return backend_map; 570 return backend_map;
571} 571}
572 572
573static void cayman_program_channel_remap(struct radeon_device *rdev)
574{
575 u32 tcp_chan_steer_lo, tcp_chan_steer_hi, mc_shared_chremap, tmp;
576
577 tmp = RREG32(MC_SHARED_CHMAP);
578 switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) {
579 case 0:
580 case 1:
581 case 2:
582 case 3:
583 default:
584 /* default mapping */
585 mc_shared_chremap = 0x00fac688;
586 break;
587 }
588
589 switch (rdev->family) {
590 case CHIP_CAYMAN:
591 default:
592 //tcp_chan_steer_lo = 0x54763210
593 tcp_chan_steer_lo = 0x76543210;
594 tcp_chan_steer_hi = 0x0000ba98;
595 break;
596 }
597
598 WREG32(TCP_CHAN_STEER_LO, tcp_chan_steer_lo);
599 WREG32(TCP_CHAN_STEER_HI, tcp_chan_steer_hi);
600 WREG32(MC_SHARED_CHREMAP, mc_shared_chremap);
601}
602
603static u32 cayman_get_disable_mask_per_asic(struct radeon_device *rdev, 573static u32 cayman_get_disable_mask_per_asic(struct radeon_device *rdev,
604 u32 disable_mask_per_se, 574 u32 disable_mask_per_se,
605 u32 max_disable_mask_per_se, 575 u32 max_disable_mask_per_se,
@@ -843,8 +813,6 @@ static void cayman_gpu_init(struct radeon_device *rdev)
843 WREG32(DMIF_ADDR_CONFIG, gb_addr_config); 813 WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
844 WREG32(HDP_ADDR_CONFIG, gb_addr_config); 814 WREG32(HDP_ADDR_CONFIG, gb_addr_config);
845 815
846 cayman_program_channel_remap(rdev);
847
848 /* primary versions */ 816 /* primary versions */
849 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable); 817 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
850 WREG32(CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable); 818 WREG32(CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable);
@@ -1191,7 +1159,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
1191 1159
1192 /* Initialize the ring buffer's read and write pointers */ 1160 /* Initialize the ring buffer's read and write pointers */
1193 WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA); 1161 WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA);
1194 WREG32(CP_RB0_WPTR, 0); 1162 rdev->cp.wptr = 0;
1163 WREG32(CP_RB0_WPTR, rdev->cp.wptr);
1195 1164
1196 /* set the wb address wether it's enabled or not */ 1165 /* set the wb address wether it's enabled or not */
1197 WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC); 1166 WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC);
@@ -1211,7 +1180,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
1211 WREG32(CP_RB0_BASE, rdev->cp.gpu_addr >> 8); 1180 WREG32(CP_RB0_BASE, rdev->cp.gpu_addr >> 8);
1212 1181
1213 rdev->cp.rptr = RREG32(CP_RB0_RPTR); 1182 rdev->cp.rptr = RREG32(CP_RB0_RPTR);
1214 rdev->cp.wptr = RREG32(CP_RB0_WPTR);
1215 1183
1216 /* ring1 - compute only */ 1184 /* ring1 - compute only */
1217 /* Set ring buffer size */ 1185 /* Set ring buffer size */
@@ -1224,7 +1192,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
1224 1192
1225 /* Initialize the ring buffer's read and write pointers */ 1193 /* Initialize the ring buffer's read and write pointers */
1226 WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA); 1194 WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA);
1227 WREG32(CP_RB1_WPTR, 0); 1195 rdev->cp1.wptr = 0;
1196 WREG32(CP_RB1_WPTR, rdev->cp1.wptr);
1228 1197
1229 /* set the wb address wether it's enabled or not */ 1198 /* set the wb address wether it's enabled or not */
1230 WREG32(CP_RB1_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFFFFFFFC); 1199 WREG32(CP_RB1_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFFFFFFFC);
@@ -1236,7 +1205,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
1236 WREG32(CP_RB1_BASE, rdev->cp1.gpu_addr >> 8); 1205 WREG32(CP_RB1_BASE, rdev->cp1.gpu_addr >> 8);
1237 1206
1238 rdev->cp1.rptr = RREG32(CP_RB1_RPTR); 1207 rdev->cp1.rptr = RREG32(CP_RB1_RPTR);
1239 rdev->cp1.wptr = RREG32(CP_RB1_WPTR);
1240 1208
1241 /* ring2 - compute only */ 1209 /* ring2 - compute only */
1242 /* Set ring buffer size */ 1210 /* Set ring buffer size */
@@ -1249,7 +1217,8 @@ int cayman_cp_resume(struct radeon_device *rdev)
1249 1217
1250 /* Initialize the ring buffer's read and write pointers */ 1218 /* Initialize the ring buffer's read and write pointers */
1251 WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA); 1219 WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA);
1252 WREG32(CP_RB2_WPTR, 0); 1220 rdev->cp2.wptr = 0;
1221 WREG32(CP_RB2_WPTR, rdev->cp2.wptr);
1253 1222
1254 /* set the wb address wether it's enabled or not */ 1223 /* set the wb address wether it's enabled or not */
1255 WREG32(CP_RB2_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFFFFFFFC); 1224 WREG32(CP_RB2_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFFFFFFFC);
@@ -1261,7 +1230,6 @@ int cayman_cp_resume(struct radeon_device *rdev)
1261 WREG32(CP_RB2_BASE, rdev->cp2.gpu_addr >> 8); 1230 WREG32(CP_RB2_BASE, rdev->cp2.gpu_addr >> 8);
1262 1231
1263 rdev->cp2.rptr = RREG32(CP_RB2_RPTR); 1232 rdev->cp2.rptr = RREG32(CP_RB2_RPTR);
1264 rdev->cp2.wptr = RREG32(CP_RB2_WPTR);
1265 1233
1266 /* start the rings */ 1234 /* start the rings */
1267 cayman_cp_start(rdev); 1235 cayman_cp_start(rdev);
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index e108f265882a..8f8b8fa14357 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -826,11 +826,11 @@ void r100_fence_ring_emit(struct radeon_device *rdev,
826int r100_copy_blit(struct radeon_device *rdev, 826int r100_copy_blit(struct radeon_device *rdev,
827 uint64_t src_offset, 827 uint64_t src_offset,
828 uint64_t dst_offset, 828 uint64_t dst_offset,
829 unsigned num_pages, 829 unsigned num_gpu_pages,
830 struct radeon_fence *fence) 830 struct radeon_fence *fence)
831{ 831{
832 uint32_t cur_pages; 832 uint32_t cur_pages;
833 uint32_t stride_bytes = PAGE_SIZE; 833 uint32_t stride_bytes = RADEON_GPU_PAGE_SIZE;
834 uint32_t pitch; 834 uint32_t pitch;
835 uint32_t stride_pixels; 835 uint32_t stride_pixels;
836 unsigned ndw; 836 unsigned ndw;
@@ -842,7 +842,7 @@ int r100_copy_blit(struct radeon_device *rdev,
842 /* radeon pitch is /64 */ 842 /* radeon pitch is /64 */
843 pitch = stride_bytes / 64; 843 pitch = stride_bytes / 64;
844 stride_pixels = stride_bytes / 4; 844 stride_pixels = stride_bytes / 4;
845 num_loops = DIV_ROUND_UP(num_pages, 8191); 845 num_loops = DIV_ROUND_UP(num_gpu_pages, 8191);
846 846
847 /* Ask for enough room for blit + flush + fence */ 847 /* Ask for enough room for blit + flush + fence */
848 ndw = 64 + (10 * num_loops); 848 ndw = 64 + (10 * num_loops);
@@ -851,12 +851,12 @@ int r100_copy_blit(struct radeon_device *rdev,
851 DRM_ERROR("radeon: moving bo (%d) asking for %u dw.\n", r, ndw); 851 DRM_ERROR("radeon: moving bo (%d) asking for %u dw.\n", r, ndw);
852 return -EINVAL; 852 return -EINVAL;
853 } 853 }
854 while (num_pages > 0) { 854 while (num_gpu_pages > 0) {
855 cur_pages = num_pages; 855 cur_pages = num_gpu_pages;
856 if (cur_pages > 8191) { 856 if (cur_pages > 8191) {
857 cur_pages = 8191; 857 cur_pages = 8191;
858 } 858 }
859 num_pages -= cur_pages; 859 num_gpu_pages -= cur_pages;
860 860
861 /* pages are in Y direction - height 861 /* pages are in Y direction - height
862 page width in X direction - width */ 862 page width in X direction - width */
@@ -878,8 +878,8 @@ int r100_copy_blit(struct radeon_device *rdev,
878 radeon_ring_write(rdev, (0x1fff) | (0x1fff << 16)); 878 radeon_ring_write(rdev, (0x1fff) | (0x1fff << 16));
879 radeon_ring_write(rdev, 0); 879 radeon_ring_write(rdev, 0);
880 radeon_ring_write(rdev, (0x1fff) | (0x1fff << 16)); 880 radeon_ring_write(rdev, (0x1fff) | (0x1fff << 16));
881 radeon_ring_write(rdev, num_pages); 881 radeon_ring_write(rdev, num_gpu_pages);
882 radeon_ring_write(rdev, num_pages); 882 radeon_ring_write(rdev, num_gpu_pages);
883 radeon_ring_write(rdev, cur_pages | (stride_pixels << 16)); 883 radeon_ring_write(rdev, cur_pages | (stride_pixels << 16));
884 } 884 }
885 radeon_ring_write(rdev, PACKET0(RADEON_DSTCACHE_CTLSTAT, 0)); 885 radeon_ring_write(rdev, PACKET0(RADEON_DSTCACHE_CTLSTAT, 0));
@@ -1095,7 +1095,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
1095 /* Force read & write ptr to 0 */ 1095 /* Force read & write ptr to 0 */
1096 WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA | RADEON_RB_NO_UPDATE); 1096 WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA | RADEON_RB_NO_UPDATE);
1097 WREG32(RADEON_CP_RB_RPTR_WR, 0); 1097 WREG32(RADEON_CP_RB_RPTR_WR, 0);
1098 WREG32(RADEON_CP_RB_WPTR, 0); 1098 rdev->cp.wptr = 0;
1099 WREG32(RADEON_CP_RB_WPTR, rdev->cp.wptr);
1099 1100
1100 /* set the wb address whether it's enabled or not */ 1101 /* set the wb address whether it's enabled or not */
1101 WREG32(R_00070C_CP_RB_RPTR_ADDR, 1102 WREG32(R_00070C_CP_RB_RPTR_ADDR,
@@ -1112,9 +1113,6 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
1112 WREG32(RADEON_CP_RB_CNTL, tmp); 1113 WREG32(RADEON_CP_RB_CNTL, tmp);
1113 udelay(10); 1114 udelay(10);
1114 rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR); 1115 rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR);
1115 rdev->cp.wptr = RREG32(RADEON_CP_RB_WPTR);
1116 /* protect against crazy HW on resume */
1117 rdev->cp.wptr &= rdev->cp.ptr_mask;
1118 /* Set cp mode to bus mastering & enable cp*/ 1116 /* Set cp mode to bus mastering & enable cp*/
1119 WREG32(RADEON_CP_CSQ_MODE, 1117 WREG32(RADEON_CP_CSQ_MODE,
1120 REG_SET(RADEON_INDIRECT2_START, indirect2_start) | 1118 REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
diff --git a/drivers/gpu/drm/radeon/r200.c b/drivers/gpu/drm/radeon/r200.c
index f24058300413..a1f3ba063c2d 100644
--- a/drivers/gpu/drm/radeon/r200.c
+++ b/drivers/gpu/drm/radeon/r200.c
@@ -84,7 +84,7 @@ static int r200_get_vtx_size_0(uint32_t vtx_fmt_0)
84int r200_copy_dma(struct radeon_device *rdev, 84int r200_copy_dma(struct radeon_device *rdev,
85 uint64_t src_offset, 85 uint64_t src_offset,
86 uint64_t dst_offset, 86 uint64_t dst_offset,
87 unsigned num_pages, 87 unsigned num_gpu_pages,
88 struct radeon_fence *fence) 88 struct radeon_fence *fence)
89{ 89{
90 uint32_t size; 90 uint32_t size;
@@ -93,7 +93,7 @@ int r200_copy_dma(struct radeon_device *rdev,
93 int r = 0; 93 int r = 0;
94 94
95 /* radeon pitch is /64 */ 95 /* radeon pitch is /64 */
96 size = num_pages << PAGE_SHIFT; 96 size = num_gpu_pages << RADEON_GPU_PAGE_SHIFT;
97 num_loops = DIV_ROUND_UP(size, 0x1FFFFF); 97 num_loops = DIV_ROUND_UP(size, 0x1FFFFF);
98 r = radeon_ring_lock(rdev, num_loops * 4 + 64); 98 r = radeon_ring_lock(rdev, num_loops * 4 + 64);
99 if (r) { 99 if (r) {
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index e87f5662a104..12470b090ddf 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2212,7 +2212,8 @@ int r600_cp_resume(struct radeon_device *rdev)
2212 /* Initialize the ring buffer's read and write pointers */ 2212 /* Initialize the ring buffer's read and write pointers */
2213 WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA); 2213 WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA);
2214 WREG32(CP_RB_RPTR_WR, 0); 2214 WREG32(CP_RB_RPTR_WR, 0);
2215 WREG32(CP_RB_WPTR, 0); 2215 rdev->cp.wptr = 0;
2216 WREG32(CP_RB_WPTR, rdev->cp.wptr);
2216 2217
2217 /* set the wb address whether it's enabled or not */ 2218 /* set the wb address whether it's enabled or not */
2218 WREG32(CP_RB_RPTR_ADDR, 2219 WREG32(CP_RB_RPTR_ADDR,
@@ -2234,7 +2235,6 @@ int r600_cp_resume(struct radeon_device *rdev)
2234 WREG32(CP_DEBUG, (1 << 27) | (1 << 28)); 2235 WREG32(CP_DEBUG, (1 << 27) | (1 << 28));
2235 2236
2236 rdev->cp.rptr = RREG32(CP_RB_RPTR); 2237 rdev->cp.rptr = RREG32(CP_RB_RPTR);
2237 rdev->cp.wptr = RREG32(CP_RB_WPTR);
2238 2238
2239 r600_cp_start(rdev); 2239 r600_cp_start(rdev);
2240 rdev->cp.ready = true; 2240 rdev->cp.ready = true;
@@ -2356,21 +2356,23 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
2356} 2356}
2357 2357
2358int r600_copy_blit(struct radeon_device *rdev, 2358int r600_copy_blit(struct radeon_device *rdev,
2359 uint64_t src_offset, uint64_t dst_offset, 2359 uint64_t src_offset,
2360 unsigned num_pages, struct radeon_fence *fence) 2360 uint64_t dst_offset,
2361 unsigned num_gpu_pages,
2362 struct radeon_fence *fence)
2361{ 2363{
2362 int r; 2364 int r;
2363 2365
2364 mutex_lock(&rdev->r600_blit.mutex); 2366 mutex_lock(&rdev->r600_blit.mutex);
2365 rdev->r600_blit.vb_ib = NULL; 2367 rdev->r600_blit.vb_ib = NULL;
2366 r = r600_blit_prepare_copy(rdev, num_pages); 2368 r = r600_blit_prepare_copy(rdev, num_gpu_pages);
2367 if (r) { 2369 if (r) {
2368 if (rdev->r600_blit.vb_ib) 2370 if (rdev->r600_blit.vb_ib)
2369 radeon_ib_free(rdev, &rdev->r600_blit.vb_ib); 2371 radeon_ib_free(rdev, &rdev->r600_blit.vb_ib);
2370 mutex_unlock(&rdev->r600_blit.mutex); 2372 mutex_unlock(&rdev->r600_blit.mutex);
2371 return r; 2373 return r;
2372 } 2374 }
2373 r600_kms_blit_copy(rdev, src_offset, dst_offset, num_pages); 2375 r600_kms_blit_copy(rdev, src_offset, dst_offset, num_gpu_pages);
2374 r600_blit_done_copy(rdev, fence); 2376 r600_blit_done_copy(rdev, fence);
2375 mutex_unlock(&rdev->r600_blit.mutex); 2377 mutex_unlock(&rdev->r600_blit.mutex);
2376 return 0; 2378 return 0;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 3cf983c5243f..156b8b7e028e 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -322,6 +322,7 @@ union radeon_gart_table {
322 322
323#define RADEON_GPU_PAGE_SIZE 4096 323#define RADEON_GPU_PAGE_SIZE 4096
324#define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1) 324#define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
325#define RADEON_GPU_PAGE_SHIFT 12
325 326
326struct radeon_gart { 327struct radeon_gart {
327 dma_addr_t table_addr; 328 dma_addr_t table_addr;
@@ -912,17 +913,17 @@ struct radeon_asic {
912 int (*copy_blit)(struct radeon_device *rdev, 913 int (*copy_blit)(struct radeon_device *rdev,
913 uint64_t src_offset, 914 uint64_t src_offset,
914 uint64_t dst_offset, 915 uint64_t dst_offset,
915 unsigned num_pages, 916 unsigned num_gpu_pages,
916 struct radeon_fence *fence); 917 struct radeon_fence *fence);
917 int (*copy_dma)(struct radeon_device *rdev, 918 int (*copy_dma)(struct radeon_device *rdev,
918 uint64_t src_offset, 919 uint64_t src_offset,
919 uint64_t dst_offset, 920 uint64_t dst_offset,
920 unsigned num_pages, 921 unsigned num_gpu_pages,
921 struct radeon_fence *fence); 922 struct radeon_fence *fence);
922 int (*copy)(struct radeon_device *rdev, 923 int (*copy)(struct radeon_device *rdev,
923 uint64_t src_offset, 924 uint64_t src_offset,
924 uint64_t dst_offset, 925 uint64_t dst_offset,
925 unsigned num_pages, 926 unsigned num_gpu_pages,
926 struct radeon_fence *fence); 927 struct radeon_fence *fence);
927 uint32_t (*get_engine_clock)(struct radeon_device *rdev); 928 uint32_t (*get_engine_clock)(struct radeon_device *rdev);
928 void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock); 929 void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index e040de3e8cc7..85f14f0337e4 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -75,7 +75,7 @@ uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg);
75int r100_copy_blit(struct radeon_device *rdev, 75int r100_copy_blit(struct radeon_device *rdev,
76 uint64_t src_offset, 76 uint64_t src_offset,
77 uint64_t dst_offset, 77 uint64_t dst_offset,
78 unsigned num_pages, 78 unsigned num_gpu_pages,
79 struct radeon_fence *fence); 79 struct radeon_fence *fence);
80int r100_set_surface_reg(struct radeon_device *rdev, int reg, 80int r100_set_surface_reg(struct radeon_device *rdev, int reg,
81 uint32_t tiling_flags, uint32_t pitch, 81 uint32_t tiling_flags, uint32_t pitch,
@@ -143,7 +143,7 @@ extern void r100_post_page_flip(struct radeon_device *rdev, int crtc);
143extern int r200_copy_dma(struct radeon_device *rdev, 143extern int r200_copy_dma(struct radeon_device *rdev,
144 uint64_t src_offset, 144 uint64_t src_offset,
145 uint64_t dst_offset, 145 uint64_t dst_offset,
146 unsigned num_pages, 146 unsigned num_gpu_pages,
147 struct radeon_fence *fence); 147 struct radeon_fence *fence);
148void r200_set_safe_registers(struct radeon_device *rdev); 148void r200_set_safe_registers(struct radeon_device *rdev);
149 149
@@ -311,7 +311,7 @@ void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
311int r600_ring_test(struct radeon_device *rdev); 311int r600_ring_test(struct radeon_device *rdev);
312int r600_copy_blit(struct radeon_device *rdev, 312int r600_copy_blit(struct radeon_device *rdev,
313 uint64_t src_offset, uint64_t dst_offset, 313 uint64_t src_offset, uint64_t dst_offset,
314 unsigned num_pages, struct radeon_fence *fence); 314 unsigned num_gpu_pages, struct radeon_fence *fence);
315void r600_hpd_init(struct radeon_device *rdev); 315void r600_hpd_init(struct radeon_device *rdev);
316void r600_hpd_fini(struct radeon_device *rdev); 316void r600_hpd_fini(struct radeon_device *rdev);
317bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); 317bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 9b5b3e4d2386..dec6cbe6a0a6 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -68,11 +68,11 @@ void radeon_connector_hotplug(struct drm_connector *connector)
68 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { 68 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
69 int saved_dpms = connector->dpms; 69 int saved_dpms = connector->dpms;
70 70
71 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd) && 71 /* Only turn off the display it it's physically disconnected */
72 radeon_dp_needs_link_train(radeon_connector)) 72 if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
73 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
74 else
75 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 73 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
74 else if (radeon_dp_needs_link_train(radeon_connector))
75 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
76 connector->dpms = saved_dpms; 76 connector->dpms = saved_dpms;
77 } 77 }
78} 78}
@@ -1325,23 +1325,14 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1325 /* get the DPCD from the bridge */ 1325 /* get the DPCD from the bridge */
1326 radeon_dp_getdpcd(radeon_connector); 1326 radeon_dp_getdpcd(radeon_connector);
1327 1327
1328 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) 1328 if (encoder) {
1329 ret = connector_status_connected; 1329 /* setup ddc on the bridge */
1330 else { 1330 radeon_atom_ext_encoder_setup_ddc(encoder);
1331 /* need to setup ddc on the bridge */
1332 if (encoder)
1333 radeon_atom_ext_encoder_setup_ddc(encoder);
1334 if (radeon_ddc_probe(radeon_connector, 1331 if (radeon_ddc_probe(radeon_connector,
1335 radeon_connector->requires_extended_probe)) 1332 radeon_connector->requires_extended_probe)) /* try DDC */
1336 ret = connector_status_connected; 1333 ret = connector_status_connected;
1337 } 1334 else if (radeon_connector->dac_load_detect) { /* try load detection */
1338 1335 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
1339 if ((ret == connector_status_disconnected) &&
1340 radeon_connector->dac_load_detect) {
1341 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1342 struct drm_encoder_helper_funcs *encoder_funcs;
1343 if (encoder) {
1344 encoder_funcs = encoder->helper_private;
1345 ret = encoder_funcs->detect(encoder, connector); 1336 ret = encoder_funcs->detect(encoder, connector);
1346 } 1337 }
1347 } 1338 }
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index 3189a7efb2e9..fde25c0d65a0 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -208,23 +208,25 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
208 int xorigin = 0, yorigin = 0; 208 int xorigin = 0, yorigin = 0;
209 int w = radeon_crtc->cursor_width; 209 int w = radeon_crtc->cursor_width;
210 210
211 if (x < 0)
212 xorigin = -x + 1;
213 if (y < 0)
214 yorigin = -y + 1;
215 if (xorigin >= CURSOR_WIDTH)
216 xorigin = CURSOR_WIDTH - 1;
217 if (yorigin >= CURSOR_HEIGHT)
218 yorigin = CURSOR_HEIGHT - 1;
219
220 if (ASIC_IS_AVIVO(rdev)) { 211 if (ASIC_IS_AVIVO(rdev)) {
221 int i = 0;
222 struct drm_crtc *crtc_p;
223
224 /* avivo cursor are offset into the total surface */ 212 /* avivo cursor are offset into the total surface */
225 x += crtc->x; 213 x += crtc->x;
226 y += crtc->y; 214 y += crtc->y;
227 DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y); 215 }
216 DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y);
217
218 if (x < 0) {
219 xorigin = min(-x, CURSOR_WIDTH - 1);
220 x = 0;
221 }
222 if (y < 0) {
223 yorigin = min(-y, CURSOR_HEIGHT - 1);
224 y = 0;
225 }
226
227 if (ASIC_IS_AVIVO(rdev)) {
228 int i = 0;
229 struct drm_crtc *crtc_p;
228 230
229 /* avivo cursor image can't end on 128 pixel boundary or 231 /* avivo cursor image can't end on 128 pixel boundary or
230 * go past the end of the frame if both crtcs are enabled 232 * go past the end of the frame if both crtcs are enabled
@@ -253,16 +255,12 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
253 255
254 radeon_lock_cursor(crtc, true); 256 radeon_lock_cursor(crtc, true);
255 if (ASIC_IS_DCE4(rdev)) { 257 if (ASIC_IS_DCE4(rdev)) {
256 WREG32(EVERGREEN_CUR_POSITION + radeon_crtc->crtc_offset, 258 WREG32(EVERGREEN_CUR_POSITION + radeon_crtc->crtc_offset, (x << 16) | y);
257 ((xorigin ? 0 : x) << 16) |
258 (yorigin ? 0 : y));
259 WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin); 259 WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin);
260 WREG32(EVERGREEN_CUR_SIZE + radeon_crtc->crtc_offset, 260 WREG32(EVERGREEN_CUR_SIZE + radeon_crtc->crtc_offset,
261 ((w - 1) << 16) | (radeon_crtc->cursor_height - 1)); 261 ((w - 1) << 16) | (radeon_crtc->cursor_height - 1));
262 } else if (ASIC_IS_AVIVO(rdev)) { 262 } else if (ASIC_IS_AVIVO(rdev)) {
263 WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, 263 WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, (x << 16) | y);
264 ((xorigin ? 0 : x) << 16) |
265 (yorigin ? 0 : y));
266 WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin); 264 WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset, (xorigin << 16) | yorigin);
267 WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset, 265 WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset,
268 ((w - 1) << 16) | (radeon_crtc->cursor_height - 1)); 266 ((w - 1) << 16) | (radeon_crtc->cursor_height - 1));
@@ -276,8 +274,8 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
276 | yorigin)); 274 | yorigin));
277 WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset, 275 WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset,
278 (RADEON_CUR_LOCK 276 (RADEON_CUR_LOCK
279 | ((xorigin ? 0 : x) << 16) 277 | (x << 16)
280 | (yorigin ? 0 : y))); 278 | y));
281 /* offset is from DISP(2)_BASE_ADDRESS */ 279 /* offset is from DISP(2)_BASE_ADDRESS */
282 WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, (radeon_crtc->legacy_cursor_offset + 280 WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, (radeon_crtc->legacy_cursor_offset +
283 (yorigin * 256))); 281 (yorigin * 256)));
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 6cc17fb96a57..6adb3e58affd 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -473,8 +473,8 @@ pflip_cleanup:
473 spin_lock_irqsave(&dev->event_lock, flags); 473 spin_lock_irqsave(&dev->event_lock, flags);
474 radeon_crtc->unpin_work = NULL; 474 radeon_crtc->unpin_work = NULL;
475unlock_free: 475unlock_free:
476 drm_gem_object_unreference_unlocked(old_radeon_fb->obj);
477 spin_unlock_irqrestore(&dev->event_lock, flags); 476 spin_unlock_irqrestore(&dev->event_lock, flags);
477 drm_gem_object_unreference_unlocked(old_radeon_fb->obj);
478 radeon_fence_unref(&work->fence); 478 radeon_fence_unref(&work->fence);
479 kfree(work); 479 kfree(work);
480 480
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 319d85d7e759..8a171b21b453 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -1507,7 +1507,14 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1507 switch (mode) { 1507 switch (mode) {
1508 case DRM_MODE_DPMS_ON: 1508 case DRM_MODE_DPMS_ON:
1509 args.ucAction = ATOM_ENABLE; 1509 args.ucAction = ATOM_ENABLE;
1510 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 1510 /* workaround for DVOOutputControl on some RS690 systems */
1511 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_DDI) {
1512 u32 reg = RREG32(RADEON_BIOS_3_SCRATCH);
1513 WREG32(RADEON_BIOS_3_SCRATCH, reg & ~ATOM_S3_DFP2I_ACTIVE);
1514 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1515 WREG32(RADEON_BIOS_3_SCRATCH, reg);
1516 } else
1517 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1511 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 1518 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
1512 args.ucAction = ATOM_LCD_BLON; 1519 args.ucAction = ATOM_LCD_BLON;
1513 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 1520 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
@@ -1748,9 +1755,12 @@ static int radeon_atom_pick_dig_encoder(struct drm_encoder *encoder)
1748 /* DCE4/5 */ 1755 /* DCE4/5 */
1749 if (ASIC_IS_DCE4(rdev)) { 1756 if (ASIC_IS_DCE4(rdev)) {
1750 dig = radeon_encoder->enc_priv; 1757 dig = radeon_encoder->enc_priv;
1751 if (ASIC_IS_DCE41(rdev)) 1758 if (ASIC_IS_DCE41(rdev)) {
1752 return radeon_crtc->crtc_id; 1759 if (dig->linkb)
1753 else { 1760 return 1;
1761 else
1762 return 0;
1763 } else {
1754 switch (radeon_encoder->encoder_id) { 1764 switch (radeon_encoder->encoder_id) {
1755 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 1765 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1756 if (dig->linkb) 1766 if (dig->linkb)
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 9b86fb0e4122..0b5468bfaf54 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -277,7 +277,12 @@ static int radeon_move_blit(struct ttm_buffer_object *bo,
277 DRM_ERROR("Trying to move memory with CP turned off.\n"); 277 DRM_ERROR("Trying to move memory with CP turned off.\n");
278 return -EINVAL; 278 return -EINVAL;
279 } 279 }
280 r = radeon_copy(rdev, old_start, new_start, new_mem->num_pages, fence); 280
281 BUILD_BUG_ON((PAGE_SIZE % RADEON_GPU_PAGE_SIZE) != 0);
282
283 r = radeon_copy(rdev, old_start, new_start,
284 new_mem->num_pages * (PAGE_SIZE / RADEON_GPU_PAGE_SIZE), /* GPU pages */
285 fence);
281 /* FIXME: handle copy error */ 286 /* FIXME: handle copy error */
282 r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL, 287 r = ttm_bo_move_accel_cleanup(bo, (void *)fence, NULL,
283 evict, no_wait_reserve, no_wait_gpu, new_mem); 288 evict, no_wait_reserve, no_wait_gpu, new_mem);
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 298feaec6d56..87cc1feee3ac 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -539,55 +539,6 @@ static u32 r700_get_tile_pipe_to_backend_map(struct radeon_device *rdev,
539 return backend_map; 539 return backend_map;
540} 540}
541 541
542static void rv770_program_channel_remap(struct radeon_device *rdev)
543{
544 u32 tcp_chan_steer, mc_shared_chremap, tmp;
545 bool force_no_swizzle;
546
547 switch (rdev->family) {
548 case CHIP_RV770:
549 case CHIP_RV730:
550 force_no_swizzle = false;
551 break;
552 case CHIP_RV710:
553 case CHIP_RV740:
554 default:
555 force_no_swizzle = true;
556 break;
557 }
558
559 tmp = RREG32(MC_SHARED_CHMAP);
560 switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) {
561 case 0:
562 case 1:
563 default:
564 /* default mapping */
565 mc_shared_chremap = 0x00fac688;
566 break;
567 case 2:
568 case 3:
569 if (force_no_swizzle)
570 mc_shared_chremap = 0x00fac688;
571 else
572 mc_shared_chremap = 0x00bbc298;
573 break;
574 }
575
576 if (rdev->family == CHIP_RV740)
577 tcp_chan_steer = 0x00ef2a60;
578 else
579 tcp_chan_steer = 0x00fac688;
580
581 /* RV770 CE has special chremap setup */
582 if (rdev->pdev->device == 0x944e) {
583 tcp_chan_steer = 0x00b08b08;
584 mc_shared_chremap = 0x00b08b08;
585 }
586
587 WREG32(TCP_CHAN_STEER, tcp_chan_steer);
588 WREG32(MC_SHARED_CHREMAP, mc_shared_chremap);
589}
590
591static void rv770_gpu_init(struct radeon_device *rdev) 542static void rv770_gpu_init(struct radeon_device *rdev)
592{ 543{
593 int i, j, num_qd_pipes; 544 int i, j, num_qd_pipes;
@@ -788,8 +739,6 @@ static void rv770_gpu_init(struct radeon_device *rdev)
788 WREG32(DCP_TILING_CONFIG, (gb_tiling_config & 0xffff)); 739 WREG32(DCP_TILING_CONFIG, (gb_tiling_config & 0xffff));
789 WREG32(HDP_TILING_CONFIG, (gb_tiling_config & 0xffff)); 740 WREG32(HDP_TILING_CONFIG, (gb_tiling_config & 0xffff));
790 741
791 rv770_program_channel_remap(rdev);
792
793 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable); 742 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
794 WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config); 743 WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
795 WREG32(GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config); 744 WREG32(GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 6e96c85b70da..50fc8e4c9a31 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -394,7 +394,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
394 394
395 if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) { 395 if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) {
396 if (bo->ttm == NULL) { 396 if (bo->ttm == NULL) {
397 ret = ttm_bo_add_ttm(bo, false); 397 bool zero = !(old_man->flags & TTM_MEMTYPE_FLAG_FIXED);
398 ret = ttm_bo_add_ttm(bo, zero);
398 if (ret) 399 if (ret)
399 goto out_err; 400 goto out_err;
400 } 401 }