aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-24 20:27:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-24 20:27:20 -0400
commite285c1746accb80620e511f9c72e9893beeedc0e (patch)
tree9d9a67a306ff19d6ef6c3982c1bc00cecc69bd70 /drivers/gpu
parent6c5103890057b1bb781b26b7aae38d33e4c517d8 (diff)
parent51eab416c9b4b3ed16553d405ec4a5f67daa34cf (diff)
Merge branch 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: drm/vblank: update recently added vbl interface to be more future proof. drm radeon: Return -EINVAL on wrong pm sysfs access drm/radeon/kms: fix hardcoded EDID handling Revert "drm/i915: Don't save/restore hardware status page address register" drm/i915: Avoid unmapping pages from a NULL address space drm/i915: Fix use after free within tracepoint drm/i915: Restore missing command flush before interrupt on BLT ring drm/i915: Disable pagefaults along execbuffer relocation fast path drm/i915: Fix computation of pitch for dumb bo creator drm/i915: report correct render clock frequencies on SNB drm/i915/dp: Correct the order of deletion for ghost eDP devices drm/i915: Fix tiling corruption from pipelined fencing drm/i915: Re-enable self-refresh drm/i915: Prevent racy removal of request from client list drm/i915: skip redundant operations whilst enabling pipes and planes drm/i915: Remove surplus POSTING_READs before wait_for_vblank drm/radeon/kms: prefer legacy pll algo for tv-out drm: check for modesetting on modeset ioctls drm/kernel: vblank wait on crtc > 1 drm: Fix use-after-free in drm_gem_vm_close()
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_crtc.c51
-rw-r--r--drivers/gpu/drm/drm_gem.c5
-rw-r--r--drivers/gpu/drm/drm_ioctl.c3
-rw-r--r--drivers/gpu/drm/drm_irq.c15
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c8
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c70
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c21
-rw-r--r--drivers/gpu/drm/i915/intel_display.c39
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c4
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c109
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c21
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c30
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c8
15 files changed, 246 insertions, 145 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4c95b5fd9df3..799e1490cf24 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1073,6 +1073,9 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
1073 uint32_t __user *encoder_id; 1073 uint32_t __user *encoder_id;
1074 struct drm_mode_group *mode_group; 1074 struct drm_mode_group *mode_group;
1075 1075
1076 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1077 return -EINVAL;
1078
1076 mutex_lock(&dev->mode_config.mutex); 1079 mutex_lock(&dev->mode_config.mutex);
1077 1080
1078 /* 1081 /*
@@ -1244,6 +1247,9 @@ int drm_mode_getcrtc(struct drm_device *dev,
1244 struct drm_mode_object *obj; 1247 struct drm_mode_object *obj;
1245 int ret = 0; 1248 int ret = 0;
1246 1249
1250 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1251 return -EINVAL;
1252
1247 mutex_lock(&dev->mode_config.mutex); 1253 mutex_lock(&dev->mode_config.mutex);
1248 1254
1249 obj = drm_mode_object_find(dev, crtc_resp->crtc_id, 1255 obj = drm_mode_object_find(dev, crtc_resp->crtc_id,
@@ -1312,6 +1318,9 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
1312 uint64_t __user *prop_values; 1318 uint64_t __user *prop_values;
1313 uint32_t __user *encoder_ptr; 1319 uint32_t __user *encoder_ptr;
1314 1320
1321 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1322 return -EINVAL;
1323
1315 memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); 1324 memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
1316 1325
1317 DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id); 1326 DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id);
@@ -1431,6 +1440,9 @@ int drm_mode_getencoder(struct drm_device *dev, void *data,
1431 struct drm_encoder *encoder; 1440 struct drm_encoder *encoder;
1432 int ret = 0; 1441 int ret = 0;
1433 1442
1443 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1444 return -EINVAL;
1445
1434 mutex_lock(&dev->mode_config.mutex); 1446 mutex_lock(&dev->mode_config.mutex);
1435 obj = drm_mode_object_find(dev, enc_resp->encoder_id, 1447 obj = drm_mode_object_find(dev, enc_resp->encoder_id,
1436 DRM_MODE_OBJECT_ENCODER); 1448 DRM_MODE_OBJECT_ENCODER);
@@ -1486,6 +1498,9 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
1486 int ret = 0; 1498 int ret = 0;
1487 int i; 1499 int i;
1488 1500
1501 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1502 return -EINVAL;
1503
1489 mutex_lock(&dev->mode_config.mutex); 1504 mutex_lock(&dev->mode_config.mutex);
1490 obj = drm_mode_object_find(dev, crtc_req->crtc_id, 1505 obj = drm_mode_object_find(dev, crtc_req->crtc_id,
1491 DRM_MODE_OBJECT_CRTC); 1506 DRM_MODE_OBJECT_CRTC);
@@ -1603,6 +1618,9 @@ int drm_mode_cursor_ioctl(struct drm_device *dev,
1603 struct drm_crtc *crtc; 1618 struct drm_crtc *crtc;
1604 int ret = 0; 1619 int ret = 0;
1605 1620
1621 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1622 return -EINVAL;
1623
1606 if (!req->flags) { 1624 if (!req->flags) {
1607 DRM_ERROR("no operation set\n"); 1625 DRM_ERROR("no operation set\n");
1608 return -EINVAL; 1626 return -EINVAL;
@@ -1667,6 +1685,9 @@ int drm_mode_addfb(struct drm_device *dev,
1667 struct drm_framebuffer *fb; 1685 struct drm_framebuffer *fb;
1668 int ret = 0; 1686 int ret = 0;
1669 1687
1688 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1689 return -EINVAL;
1690
1670 if ((config->min_width > r->width) || (r->width > config->max_width)) { 1691 if ((config->min_width > r->width) || (r->width > config->max_width)) {
1671 DRM_ERROR("mode new framebuffer width not within limits\n"); 1692 DRM_ERROR("mode new framebuffer width not within limits\n");
1672 return -EINVAL; 1693 return -EINVAL;
@@ -1724,6 +1745,9 @@ int drm_mode_rmfb(struct drm_device *dev,
1724 int ret = 0; 1745 int ret = 0;
1725 int found = 0; 1746 int found = 0;
1726 1747
1748 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1749 return -EINVAL;
1750
1727 mutex_lock(&dev->mode_config.mutex); 1751 mutex_lock(&dev->mode_config.mutex);
1728 obj = drm_mode_object_find(dev, *id, DRM_MODE_OBJECT_FB); 1752 obj = drm_mode_object_find(dev, *id, DRM_MODE_OBJECT_FB);
1729 /* TODO check that we realy get a framebuffer back. */ 1753 /* TODO check that we realy get a framebuffer back. */
@@ -1780,6 +1804,9 @@ int drm_mode_getfb(struct drm_device *dev,
1780 struct drm_framebuffer *fb; 1804 struct drm_framebuffer *fb;
1781 int ret = 0; 1805 int ret = 0;
1782 1806
1807 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1808 return -EINVAL;
1809
1783 mutex_lock(&dev->mode_config.mutex); 1810 mutex_lock(&dev->mode_config.mutex);
1784 obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); 1811 obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB);
1785 if (!obj) { 1812 if (!obj) {
@@ -1813,6 +1840,9 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
1813 int num_clips; 1840 int num_clips;
1814 int ret = 0; 1841 int ret = 0;
1815 1842
1843 if (!drm_core_check_feature(dev, DRIVER_MODESET))
1844 return -EINVAL;
1845
1816 mutex_lock(&dev->mode_config.mutex); 1846 mutex_lock(&dev->mode_config.mutex);
1817 obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); 1847 obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB);
1818 if (!obj) { 1848 if (!obj) {
@@ -1996,6 +2026,9 @@ int drm_mode_attachmode_ioctl(struct drm_device *dev,
1996 struct drm_mode_modeinfo *umode = &mode_cmd->mode; 2026 struct drm_mode_modeinfo *umode = &mode_cmd->mode;
1997 int ret = 0; 2027 int ret = 0;
1998 2028
2029 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2030 return -EINVAL;
2031
1999 mutex_lock(&dev->mode_config.mutex); 2032 mutex_lock(&dev->mode_config.mutex);
2000 2033
2001 obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR); 2034 obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR);
@@ -2042,6 +2075,9 @@ int drm_mode_detachmode_ioctl(struct drm_device *dev,
2042 struct drm_mode_modeinfo *umode = &mode_cmd->mode; 2075 struct drm_mode_modeinfo *umode = &mode_cmd->mode;
2043 int ret = 0; 2076 int ret = 0;
2044 2077
2078 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2079 return -EINVAL;
2080
2045 mutex_lock(&dev->mode_config.mutex); 2081 mutex_lock(&dev->mode_config.mutex);
2046 2082
2047 obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR); 2083 obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR);
@@ -2211,6 +2247,9 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
2211 uint64_t __user *values_ptr; 2247 uint64_t __user *values_ptr;
2212 uint32_t __user *blob_length_ptr; 2248 uint32_t __user *blob_length_ptr;
2213 2249
2250 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2251 return -EINVAL;
2252
2214 mutex_lock(&dev->mode_config.mutex); 2253 mutex_lock(&dev->mode_config.mutex);
2215 obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); 2254 obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY);
2216 if (!obj) { 2255 if (!obj) {
@@ -2333,6 +2372,9 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
2333 int ret = 0; 2372 int ret = 0;
2334 void *blob_ptr; 2373 void *blob_ptr;
2335 2374
2375 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2376 return -EINVAL;
2377
2336 mutex_lock(&dev->mode_config.mutex); 2378 mutex_lock(&dev->mode_config.mutex);
2337 obj = drm_mode_object_find(dev, out_resp->blob_id, DRM_MODE_OBJECT_BLOB); 2379 obj = drm_mode_object_find(dev, out_resp->blob_id, DRM_MODE_OBJECT_BLOB);
2338 if (!obj) { 2380 if (!obj) {
@@ -2393,6 +2435,9 @@ int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
2393 int ret = -EINVAL; 2435 int ret = -EINVAL;
2394 int i; 2436 int i;
2395 2437
2438 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2439 return -EINVAL;
2440
2396 mutex_lock(&dev->mode_config.mutex); 2441 mutex_lock(&dev->mode_config.mutex);
2397 2442
2398 obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR); 2443 obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR);
@@ -2509,6 +2554,9 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
2509 int size; 2554 int size;
2510 int ret = 0; 2555 int ret = 0;
2511 2556
2557 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2558 return -EINVAL;
2559
2512 mutex_lock(&dev->mode_config.mutex); 2560 mutex_lock(&dev->mode_config.mutex);
2513 obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); 2561 obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC);
2514 if (!obj) { 2562 if (!obj) {
@@ -2560,6 +2608,9 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
2560 int size; 2608 int size;
2561 int ret = 0; 2609 int ret = 0;
2562 2610
2611 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2612 return -EINVAL;
2613
2563 mutex_lock(&dev->mode_config.mutex); 2614 mutex_lock(&dev->mode_config.mutex);
2564 obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); 2615 obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC);
2565 if (!obj) { 2616 if (!obj) {
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 57ce27c9a747..74e4ff578017 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -499,11 +499,12 @@ EXPORT_SYMBOL(drm_gem_vm_open);
499void drm_gem_vm_close(struct vm_area_struct *vma) 499void drm_gem_vm_close(struct vm_area_struct *vma)
500{ 500{
501 struct drm_gem_object *obj = vma->vm_private_data; 501 struct drm_gem_object *obj = vma->vm_private_data;
502 struct drm_device *dev = obj->dev;
502 503
503 mutex_lock(&obj->dev->struct_mutex); 504 mutex_lock(&dev->struct_mutex);
504 drm_vm_close_locked(vma); 505 drm_vm_close_locked(vma);
505 drm_gem_object_unreference(obj); 506 drm_gem_object_unreference(obj);
506 mutex_unlock(&obj->dev->struct_mutex); 507 mutex_unlock(&dev->struct_mutex);
507} 508}
508EXPORT_SYMBOL(drm_gem_vm_close); 509EXPORT_SYMBOL(drm_gem_vm_close);
509 510
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 7f6912a16761..904d7e9c8e47 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -280,6 +280,9 @@ int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
280 if (dev->driver->dumb_create) 280 if (dev->driver->dumb_create)
281 req->value = 1; 281 req->value = 1;
282 break; 282 break;
283 case DRM_CAP_VBLANK_HIGH_CRTC:
284 req->value = 1;
285 break;
283 default: 286 default:
284 return -EINVAL; 287 return -EINVAL;
285 } 288 }
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a34ef97d3c81..741457bd1c46 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1125,7 +1125,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
1125{ 1125{
1126 union drm_wait_vblank *vblwait = data; 1126 union drm_wait_vblank *vblwait = data;
1127 int ret = 0; 1127 int ret = 0;
1128 unsigned int flags, seq, crtc; 1128 unsigned int flags, seq, crtc, high_crtc;
1129 1129
1130 if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled)) 1130 if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled))
1131 return -EINVAL; 1131 return -EINVAL;
@@ -1134,16 +1134,21 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
1134 return -EINVAL; 1134 return -EINVAL;
1135 1135
1136 if (vblwait->request.type & 1136 if (vblwait->request.type &
1137 ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) { 1137 ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK |
1138 _DRM_VBLANK_HIGH_CRTC_MASK)) {
1138 DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n", 1139 DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n",
1139 vblwait->request.type, 1140 vblwait->request.type,
1140 (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)); 1141 (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK |
1142 _DRM_VBLANK_HIGH_CRTC_MASK));
1141 return -EINVAL; 1143 return -EINVAL;
1142 } 1144 }
1143 1145
1144 flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK; 1146 flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK;
1145 crtc = flags & _DRM_VBLANK_SECONDARY ? 1 : 0; 1147 high_crtc = (vblwait->request.type & _DRM_VBLANK_HIGH_CRTC_MASK);
1146 1148 if (high_crtc)
1149 crtc = high_crtc >> _DRM_VBLANK_HIGH_CRTC_SHIFT;
1150 else
1151 crtc = flags & _DRM_VBLANK_SECONDARY ? 1 : 0;
1147 if (crtc >= dev->num_crtcs) 1152 if (crtc >= dev->num_crtcs)
1148 return -EINVAL; 1153 return -EINVAL;
1149 1154
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 09e0327fc6ce..87c8e29465e3 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -892,7 +892,7 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused)
892 seq_printf(m, "Render p-state limit: %d\n", 892 seq_printf(m, "Render p-state limit: %d\n",
893 rp_state_limits & 0xff); 893 rp_state_limits & 0xff);
894 seq_printf(m, "CAGF: %dMHz\n", ((rpstat & GEN6_CAGF_MASK) >> 894 seq_printf(m, "CAGF: %dMHz\n", ((rpstat & GEN6_CAGF_MASK) >>
895 GEN6_CAGF_SHIFT) * 100); 895 GEN6_CAGF_SHIFT) * 50);
896 seq_printf(m, "RP CUR UP EI: %dus\n", rpupei & 896 seq_printf(m, "RP CUR UP EI: %dus\n", rpupei &
897 GEN6_CURICONT_MASK); 897 GEN6_CURICONT_MASK);
898 seq_printf(m, "RP CUR UP: %dus\n", rpcurup & 898 seq_printf(m, "RP CUR UP: %dus\n", rpcurup &
@@ -908,15 +908,15 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused)
908 908
909 max_freq = (rp_state_cap & 0xff0000) >> 16; 909 max_freq = (rp_state_cap & 0xff0000) >> 16;
910 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", 910 seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
911 max_freq * 100); 911 max_freq * 50);
912 912
913 max_freq = (rp_state_cap & 0xff00) >> 8; 913 max_freq = (rp_state_cap & 0xff00) >> 8;
914 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", 914 seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
915 max_freq * 100); 915 max_freq * 50);
916 916
917 max_freq = rp_state_cap & 0xff; 917 max_freq = rp_state_cap & 0xff;
918 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", 918 seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
919 max_freq * 100); 919 max_freq * 50);
920 920
921 __gen6_gt_force_wake_put(dev_priv); 921 __gen6_gt_force_wake_put(dev_priv);
922 } else { 922 } else {
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c4c2855d002d..7ce3f353af33 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -224,7 +224,7 @@ i915_gem_dumb_create(struct drm_file *file,
224 struct drm_mode_create_dumb *args) 224 struct drm_mode_create_dumb *args)
225{ 225{
226 /* have to work out size/pitch and return them */ 226 /* have to work out size/pitch and return them */
227 args->pitch = ALIGN(args->width & ((args->bpp + 1) / 8), 64); 227 args->pitch = ALIGN(args->width * ((args->bpp + 7) / 8), 64);
228 args->size = args->pitch * args->height; 228 args->size = args->pitch * args->height;
229 return i915_gem_create(file, dev, 229 return i915_gem_create(file, dev,
230 args->size, &args->handle); 230 args->size, &args->handle);
@@ -1356,9 +1356,10 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj)
1356 if (!obj->fault_mappable) 1356 if (!obj->fault_mappable)
1357 return; 1357 return;
1358 1358
1359 unmap_mapping_range(obj->base.dev->dev_mapping, 1359 if (obj->base.dev->dev_mapping)
1360 (loff_t)obj->base.map_list.hash.key<<PAGE_SHIFT, 1360 unmap_mapping_range(obj->base.dev->dev_mapping,
1361 obj->base.size, 1); 1361 (loff_t)obj->base.map_list.hash.key<<PAGE_SHIFT,
1362 obj->base.size, 1);
1362 1363
1363 obj->fault_mappable = false; 1364 obj->fault_mappable = false;
1364} 1365}
@@ -1796,8 +1797,10 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
1796 return; 1797 return;
1797 1798
1798 spin_lock(&file_priv->mm.lock); 1799 spin_lock(&file_priv->mm.lock);
1799 list_del(&request->client_list); 1800 if (request->file_priv) {
1800 request->file_priv = NULL; 1801 list_del(&request->client_list);
1802 request->file_priv = NULL;
1803 }
1801 spin_unlock(&file_priv->mm.lock); 1804 spin_unlock(&file_priv->mm.lock);
1802} 1805}
1803 1806
@@ -2217,13 +2220,18 @@ i915_gem_flush_ring(struct intel_ring_buffer *ring,
2217{ 2220{
2218 int ret; 2221 int ret;
2219 2222
2223 if (((invalidate_domains | flush_domains) & I915_GEM_GPU_DOMAINS) == 0)
2224 return 0;
2225
2220 trace_i915_gem_ring_flush(ring, invalidate_domains, flush_domains); 2226 trace_i915_gem_ring_flush(ring, invalidate_domains, flush_domains);
2221 2227
2222 ret = ring->flush(ring, invalidate_domains, flush_domains); 2228 ret = ring->flush(ring, invalidate_domains, flush_domains);
2223 if (ret) 2229 if (ret)
2224 return ret; 2230 return ret;
2225 2231
2226 i915_gem_process_flushing_list(ring, flush_domains); 2232 if (flush_domains & I915_GEM_GPU_DOMAINS)
2233 i915_gem_process_flushing_list(ring, flush_domains);
2234
2227 return 0; 2235 return 0;
2228} 2236}
2229 2237
@@ -2579,8 +2587,23 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj,
2579 reg = &dev_priv->fence_regs[obj->fence_reg]; 2587 reg = &dev_priv->fence_regs[obj->fence_reg];
2580 list_move_tail(&reg->lru_list, &dev_priv->mm.fence_list); 2588 list_move_tail(&reg->lru_list, &dev_priv->mm.fence_list);
2581 2589
2582 if (!obj->fenced_gpu_access && !obj->last_fenced_seqno) 2590 if (obj->tiling_changed) {
2583 pipelined = NULL; 2591 ret = i915_gem_object_flush_fence(obj, pipelined);
2592 if (ret)
2593 return ret;
2594
2595 if (!obj->fenced_gpu_access && !obj->last_fenced_seqno)
2596 pipelined = NULL;
2597
2598 if (pipelined) {
2599 reg->setup_seqno =
2600 i915_gem_next_request_seqno(pipelined);
2601 obj->last_fenced_seqno = reg->setup_seqno;
2602 obj->last_fenced_ring = pipelined;
2603 }
2604
2605 goto update;
2606 }
2584 2607
2585 if (!pipelined) { 2608 if (!pipelined) {
2586 if (reg->setup_seqno) { 2609 if (reg->setup_seqno) {
@@ -2599,31 +2622,6 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj,
2599 ret = i915_gem_object_flush_fence(obj, pipelined); 2622 ret = i915_gem_object_flush_fence(obj, pipelined);
2600 if (ret) 2623 if (ret)
2601 return ret; 2624 return ret;
2602 } else if (obj->tiling_changed) {
2603 if (obj->fenced_gpu_access) {
2604 if (obj->base.write_domain & I915_GEM_GPU_DOMAINS) {
2605 ret = i915_gem_flush_ring(obj->ring,
2606 0, obj->base.write_domain);
2607 if (ret)
2608 return ret;
2609 }
2610
2611 obj->fenced_gpu_access = false;
2612 }
2613 }
2614
2615 if (!obj->fenced_gpu_access && !obj->last_fenced_seqno)
2616 pipelined = NULL;
2617 BUG_ON(!pipelined && reg->setup_seqno);
2618
2619 if (obj->tiling_changed) {
2620 if (pipelined) {
2621 reg->setup_seqno =
2622 i915_gem_next_request_seqno(pipelined);
2623 obj->last_fenced_seqno = reg->setup_seqno;
2624 obj->last_fenced_ring = pipelined;
2625 }
2626 goto update;
2627 } 2625 }
2628 2626
2629 return 0; 2627 return 0;
@@ -3606,6 +3604,8 @@ static void i915_gem_free_object_tail(struct drm_i915_gem_object *obj)
3606 return; 3604 return;
3607 } 3605 }
3608 3606
3607 trace_i915_gem_object_destroy(obj);
3608
3609 if (obj->base.map_list.map) 3609 if (obj->base.map_list.map)
3610 i915_gem_free_mmap_offset(obj); 3610 i915_gem_free_mmap_offset(obj);
3611 3611
@@ -3615,8 +3615,6 @@ static void i915_gem_free_object_tail(struct drm_i915_gem_object *obj)
3615 kfree(obj->page_cpu_valid); 3615 kfree(obj->page_cpu_valid);
3616 kfree(obj->bit_17); 3616 kfree(obj->bit_17);
3617 kfree(obj); 3617 kfree(obj);
3618
3619 trace_i915_gem_object_destroy(obj);
3620} 3618}
3621 3619
3622void i915_gem_free_object(struct drm_gem_object *gem_obj) 3620void i915_gem_free_object(struct drm_gem_object *gem_obj)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 7ff7f933ddf1..20a4cc5b818f 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -367,6 +367,10 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
367 uint32_t __iomem *reloc_entry; 367 uint32_t __iomem *reloc_entry;
368 void __iomem *reloc_page; 368 void __iomem *reloc_page;
369 369
370 /* We can't wait for rendering with pagefaults disabled */
371 if (obj->active && in_atomic())
372 return -EFAULT;
373
370 ret = i915_gem_object_set_to_gtt_domain(obj, 1); 374 ret = i915_gem_object_set_to_gtt_domain(obj, 1);
371 if (ret) 375 if (ret)
372 return ret; 376 return ret;
@@ -440,15 +444,24 @@ i915_gem_execbuffer_relocate(struct drm_device *dev,
440 struct list_head *objects) 444 struct list_head *objects)
441{ 445{
442 struct drm_i915_gem_object *obj; 446 struct drm_i915_gem_object *obj;
443 int ret; 447 int ret = 0;
444 448
449 /* This is the fast path and we cannot handle a pagefault whilst
450 * holding the struct mutex lest the user pass in the relocations
451 * contained within a mmaped bo. For in such a case we, the page
452 * fault handler would call i915_gem_fault() and we would try to
453 * acquire the struct mutex again. Obviously this is bad and so
454 * lockdep complains vehemently.
455 */
456 pagefault_disable();
445 list_for_each_entry(obj, objects, exec_list) { 457 list_for_each_entry(obj, objects, exec_list) {
446 ret = i915_gem_execbuffer_relocate_object(obj, eb); 458 ret = i915_gem_execbuffer_relocate_object(obj, eb);
447 if (ret) 459 if (ret)
448 return ret; 460 break;
449 } 461 }
462 pagefault_enable();
450 463
451 return 0; 464 return ret;
452} 465}
453 466
454static int 467static int
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3106c0dc8389..432fc04c6bff 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1516,9 +1516,10 @@ static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
1516 1516
1517 reg = PIPECONF(pipe); 1517 reg = PIPECONF(pipe);
1518 val = I915_READ(reg); 1518 val = I915_READ(reg);
1519 val |= PIPECONF_ENABLE; 1519 if (val & PIPECONF_ENABLE)
1520 I915_WRITE(reg, val); 1520 return;
1521 POSTING_READ(reg); 1521
1522 I915_WRITE(reg, val | PIPECONF_ENABLE);
1522 intel_wait_for_vblank(dev_priv->dev, pipe); 1523 intel_wait_for_vblank(dev_priv->dev, pipe);
1523} 1524}
1524 1525
@@ -1552,9 +1553,10 @@ static void intel_disable_pipe(struct drm_i915_private *dev_priv,
1552 1553
1553 reg = PIPECONF(pipe); 1554 reg = PIPECONF(pipe);
1554 val = I915_READ(reg); 1555 val = I915_READ(reg);
1555 val &= ~PIPECONF_ENABLE; 1556 if ((val & PIPECONF_ENABLE) == 0)
1556 I915_WRITE(reg, val); 1557 return;
1557 POSTING_READ(reg); 1558
1559 I915_WRITE(reg, val & ~PIPECONF_ENABLE);
1558 intel_wait_for_pipe_off(dev_priv->dev, pipe); 1560 intel_wait_for_pipe_off(dev_priv->dev, pipe);
1559} 1561}
1560 1562
@@ -1577,9 +1579,10 @@ static void intel_enable_plane(struct drm_i915_private *dev_priv,
1577 1579
1578 reg = DSPCNTR(plane); 1580 reg = DSPCNTR(plane);
1579 val = I915_READ(reg); 1581 val = I915_READ(reg);
1580 val |= DISPLAY_PLANE_ENABLE; 1582 if (val & DISPLAY_PLANE_ENABLE)
1581 I915_WRITE(reg, val); 1583 return;
1582 POSTING_READ(reg); 1584
1585 I915_WRITE(reg, val | DISPLAY_PLANE_ENABLE);
1583 intel_wait_for_vblank(dev_priv->dev, pipe); 1586 intel_wait_for_vblank(dev_priv->dev, pipe);
1584} 1587}
1585 1588
@@ -1610,9 +1613,10 @@ static void intel_disable_plane(struct drm_i915_private *dev_priv,
1610 1613
1611 reg = DSPCNTR(plane); 1614 reg = DSPCNTR(plane);
1612 val = I915_READ(reg); 1615 val = I915_READ(reg);
1613 val &= ~DISPLAY_PLANE_ENABLE; 1616 if ((val & DISPLAY_PLANE_ENABLE) == 0)
1614 I915_WRITE(reg, val); 1617 return;
1615 POSTING_READ(reg); 1618
1619 I915_WRITE(reg, val & ~DISPLAY_PLANE_ENABLE);
1616 intel_flush_display_plane(dev_priv, plane); 1620 intel_flush_display_plane(dev_priv, plane);
1617 intel_wait_for_vblank(dev_priv->dev, pipe); 1621 intel_wait_for_vblank(dev_priv->dev, pipe);
1618} 1622}
@@ -1769,7 +1773,6 @@ static void g4x_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1769 return; 1773 return;
1770 1774
1771 I915_WRITE(DPFC_CONTROL, dpfc_ctl & ~DPFC_CTL_EN); 1775 I915_WRITE(DPFC_CONTROL, dpfc_ctl & ~DPFC_CTL_EN);
1772 POSTING_READ(DPFC_CONTROL);
1773 intel_wait_for_vblank(dev, intel_crtc->pipe); 1776 intel_wait_for_vblank(dev, intel_crtc->pipe);
1774 } 1777 }
1775 1778
@@ -1861,7 +1864,6 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1861 return; 1864 return;
1862 1865
1863 I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl & ~DPFC_CTL_EN); 1866 I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl & ~DPFC_CTL_EN);
1864 POSTING_READ(ILK_DPFC_CONTROL);
1865 intel_wait_for_vblank(dev, intel_crtc->pipe); 1867 intel_wait_for_vblank(dev, intel_crtc->pipe);
1866 } 1868 }
1867 1869
@@ -3883,10 +3885,7 @@ static bool g4x_compute_srwm(struct drm_device *dev,
3883 display, cursor); 3885 display, cursor);
3884} 3886}
3885 3887
3886static inline bool single_plane_enabled(unsigned int mask) 3888#define single_plane_enabled(mask) is_power_of_2(mask)
3887{
3888 return mask && (mask & -mask) == 0;
3889}
3890 3889
3891static void g4x_update_wm(struct drm_device *dev) 3890static void g4x_update_wm(struct drm_device *dev)
3892{ 3891{
@@ -5777,7 +5776,6 @@ static void intel_increase_pllclock(struct drm_crtc *crtc)
5777 5776
5778 dpll &= ~DISPLAY_RATE_SELECT_FPA1; 5777 dpll &= ~DISPLAY_RATE_SELECT_FPA1;
5779 I915_WRITE(dpll_reg, dpll); 5778 I915_WRITE(dpll_reg, dpll);
5780 POSTING_READ(dpll_reg);
5781 intel_wait_for_vblank(dev, pipe); 5779 intel_wait_for_vblank(dev, pipe);
5782 5780
5783 dpll = I915_READ(dpll_reg); 5781 dpll = I915_READ(dpll_reg);
@@ -5821,7 +5819,6 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc)
5821 5819
5822 dpll |= DISPLAY_RATE_SELECT_FPA1; 5820 dpll |= DISPLAY_RATE_SELECT_FPA1;
5823 I915_WRITE(dpll_reg, dpll); 5821 I915_WRITE(dpll_reg, dpll);
5824 dpll = I915_READ(dpll_reg);
5825 intel_wait_for_vblank(dev, pipe); 5822 intel_wait_for_vblank(dev, pipe);
5826 dpll = I915_READ(dpll_reg); 5823 dpll = I915_READ(dpll_reg);
5827 if (!(dpll & DISPLAY_RATE_SELECT_FPA1)) 5824 if (!(dpll & DISPLAY_RATE_SELECT_FPA1))
@@ -6933,7 +6930,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
6933 DRM_ERROR("timeout waiting for pcode mailbox to finish\n"); 6930 DRM_ERROR("timeout waiting for pcode mailbox to finish\n");
6934 if (pcu_mbox & (1<<31)) { /* OC supported */ 6931 if (pcu_mbox & (1<<31)) { /* OC supported */
6935 max_freq = pcu_mbox & 0xff; 6932 max_freq = pcu_mbox & 0xff;
6936 DRM_DEBUG_DRIVER("overclocking supported, adjusting frequency max to %dMHz\n", pcu_mbox * 100); 6933 DRM_DEBUG_DRIVER("overclocking supported, adjusting frequency max to %dMHz\n", pcu_mbox * 50);
6937 } 6934 }
6938 6935
6939 /* In units of 100MHz */ 6936 /* In units of 100MHz */
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d29e33f815d7..0daefca5cbb8 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1957,9 +1957,9 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1957 DP_NO_AUX_HANDSHAKE_LINK_TRAINING; 1957 DP_NO_AUX_HANDSHAKE_LINK_TRAINING;
1958 } else { 1958 } else {
1959 /* if this fails, presume the device is a ghost */ 1959 /* if this fails, presume the device is a ghost */
1960 DRM_ERROR("failed to retrieve link info\n"); 1960 DRM_INFO("failed to retrieve link info, disabling eDP\n");
1961 intel_dp_destroy(&intel_connector->base);
1962 intel_dp_encoder_destroy(&intel_dp->base.base); 1961 intel_dp_encoder_destroy(&intel_dp->base.base);
1962 intel_dp_destroy(&intel_connector->base);
1963 return; 1963 return;
1964 } 1964 }
1965 } 1965 }
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 789c47801ba8..e9e6f71418a4 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -65,62 +65,60 @@ render_ring_flush(struct intel_ring_buffer *ring,
65 u32 cmd; 65 u32 cmd;
66 int ret; 66 int ret;
67 67
68 if ((invalidate_domains | flush_domains) & I915_GEM_GPU_DOMAINS) { 68 /*
69 * read/write caches:
70 *
71 * I915_GEM_DOMAIN_RENDER is always invalidated, but is
72 * only flushed if MI_NO_WRITE_FLUSH is unset. On 965, it is
73 * also flushed at 2d versus 3d pipeline switches.
74 *
75 * read-only caches:
76 *
77 * I915_GEM_DOMAIN_SAMPLER is flushed on pre-965 if
78 * MI_READ_FLUSH is set, and is always flushed on 965.
79 *
80 * I915_GEM_DOMAIN_COMMAND may not exist?
81 *
82 * I915_GEM_DOMAIN_INSTRUCTION, which exists on 965, is
83 * invalidated when MI_EXE_FLUSH is set.
84 *
85 * I915_GEM_DOMAIN_VERTEX, which exists on 965, is
86 * invalidated with every MI_FLUSH.
87 *
88 * TLBs:
89 *
90 * On 965, TLBs associated with I915_GEM_DOMAIN_COMMAND
91 * and I915_GEM_DOMAIN_CPU in are invalidated at PTE write and
92 * I915_GEM_DOMAIN_RENDER and I915_GEM_DOMAIN_SAMPLER
93 * are flushed at any MI_FLUSH.
94 */
95
96 cmd = MI_FLUSH | MI_NO_WRITE_FLUSH;
97 if ((invalidate_domains|flush_domains) &
98 I915_GEM_DOMAIN_RENDER)
99 cmd &= ~MI_NO_WRITE_FLUSH;
100 if (INTEL_INFO(dev)->gen < 4) {
69 /* 101 /*
70 * read/write caches: 102 * On the 965, the sampler cache always gets flushed
71 * 103 * and this bit is reserved.
72 * I915_GEM_DOMAIN_RENDER is always invalidated, but is
73 * only flushed if MI_NO_WRITE_FLUSH is unset. On 965, it is
74 * also flushed at 2d versus 3d pipeline switches.
75 *
76 * read-only caches:
77 *
78 * I915_GEM_DOMAIN_SAMPLER is flushed on pre-965 if
79 * MI_READ_FLUSH is set, and is always flushed on 965.
80 *
81 * I915_GEM_DOMAIN_COMMAND may not exist?
82 *
83 * I915_GEM_DOMAIN_INSTRUCTION, which exists on 965, is
84 * invalidated when MI_EXE_FLUSH is set.
85 *
86 * I915_GEM_DOMAIN_VERTEX, which exists on 965, is
87 * invalidated with every MI_FLUSH.
88 *
89 * TLBs:
90 *
91 * On 965, TLBs associated with I915_GEM_DOMAIN_COMMAND
92 * and I915_GEM_DOMAIN_CPU in are invalidated at PTE write and
93 * I915_GEM_DOMAIN_RENDER and I915_GEM_DOMAIN_SAMPLER
94 * are flushed at any MI_FLUSH.
95 */ 104 */
105 if (invalidate_domains & I915_GEM_DOMAIN_SAMPLER)
106 cmd |= MI_READ_FLUSH;
107 }
108 if (invalidate_domains & I915_GEM_DOMAIN_INSTRUCTION)
109 cmd |= MI_EXE_FLUSH;
96 110
97 cmd = MI_FLUSH | MI_NO_WRITE_FLUSH; 111 if (invalidate_domains & I915_GEM_DOMAIN_COMMAND &&
98 if ((invalidate_domains|flush_domains) & 112 (IS_G4X(dev) || IS_GEN5(dev)))
99 I915_GEM_DOMAIN_RENDER) 113 cmd |= MI_INVALIDATE_ISP;
100 cmd &= ~MI_NO_WRITE_FLUSH;
101 if (INTEL_INFO(dev)->gen < 4) {
102 /*
103 * On the 965, the sampler cache always gets flushed
104 * and this bit is reserved.
105 */
106 if (invalidate_domains & I915_GEM_DOMAIN_SAMPLER)
107 cmd |= MI_READ_FLUSH;
108 }
109 if (invalidate_domains & I915_GEM_DOMAIN_INSTRUCTION)
110 cmd |= MI_EXE_FLUSH;
111
112 if (invalidate_domains & I915_GEM_DOMAIN_COMMAND &&
113 (IS_G4X(dev) || IS_GEN5(dev)))
114 cmd |= MI_INVALIDATE_ISP;
115 114
116 ret = intel_ring_begin(ring, 2); 115 ret = intel_ring_begin(ring, 2);
117 if (ret) 116 if (ret)
118 return ret; 117 return ret;
119 118
120 intel_ring_emit(ring, cmd); 119 intel_ring_emit(ring, cmd);
121 intel_ring_emit(ring, MI_NOOP); 120 intel_ring_emit(ring, MI_NOOP);
122 intel_ring_advance(ring); 121 intel_ring_advance(ring);
123 }
124 122
125 return 0; 123 return 0;
126} 124}
@@ -568,9 +566,6 @@ bsd_ring_flush(struct intel_ring_buffer *ring,
568{ 566{
569 int ret; 567 int ret;
570 568
571 if ((flush_domains & I915_GEM_DOMAIN_RENDER) == 0)
572 return 0;
573
574 ret = intel_ring_begin(ring, 2); 569 ret = intel_ring_begin(ring, 2);
575 if (ret) 570 if (ret)
576 return ret; 571 return ret;
@@ -1056,9 +1051,6 @@ static int gen6_ring_flush(struct intel_ring_buffer *ring,
1056 uint32_t cmd; 1051 uint32_t cmd;
1057 int ret; 1052 int ret;
1058 1053
1059 if (((invalidate | flush) & I915_GEM_GPU_DOMAINS) == 0)
1060 return 0;
1061
1062 ret = intel_ring_begin(ring, 4); 1054 ret = intel_ring_begin(ring, 4);
1063 if (ret) 1055 if (ret)
1064 return ret; 1056 return ret;
@@ -1230,9 +1222,6 @@ static int blt_ring_flush(struct intel_ring_buffer *ring,
1230 uint32_t cmd; 1222 uint32_t cmd;
1231 int ret; 1223 int ret;
1232 1224
1233 if (((invalidate | flush) & I915_GEM_DOMAIN_RENDER) == 0)
1234 return 0;
1235
1236 ret = blt_ring_begin(ring, 4); 1225 ret = blt_ring_begin(ring, 4);
1237 if (ret) 1226 if (ret)
1238 return ret; 1227 return ret;
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 3cd3234ba0af..10e41af6b026 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -957,7 +957,11 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
957 /* adjust pixel clock as needed */ 957 /* adjust pixel clock as needed */
958 adjusted_clock = atombios_adjust_pll(crtc, mode, pll, ss_enabled, &ss); 958 adjusted_clock = atombios_adjust_pll(crtc, mode, pll, ss_enabled, &ss);
959 959
960 if (ASIC_IS_AVIVO(rdev)) 960 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
961 /* TV seems to prefer the legacy algo on some boards */
962 radeon_compute_pll_legacy(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
963 &ref_div, &post_div);
964 else if (ASIC_IS_AVIVO(rdev))
961 radeon_compute_pll_avivo(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, 965 radeon_compute_pll_avivo(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div,
962 &ref_div, &post_div); 966 &ref_div, &post_div);
963 else 967 else
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index cf7c8d5b4ec2..cf602e2d0718 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -448,7 +448,7 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
448 448
449bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 449bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
450{ 450{
451 int edid_info; 451 int edid_info, size;
452 struct edid *edid; 452 struct edid *edid;
453 unsigned char *raw; 453 unsigned char *raw;
454 edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE); 454 edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE);
@@ -456,11 +456,12 @@ bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
456 return false; 456 return false;
457 457
458 raw = rdev->bios + edid_info; 458 raw = rdev->bios + edid_info;
459 edid = kmalloc(EDID_LENGTH * (raw[0x7e] + 1), GFP_KERNEL); 459 size = EDID_LENGTH * (raw[0x7e] + 1);
460 edid = kmalloc(size, GFP_KERNEL);
460 if (edid == NULL) 461 if (edid == NULL)
461 return false; 462 return false;
462 463
463 memcpy((unsigned char *)edid, raw, EDID_LENGTH * (raw[0x7e] + 1)); 464 memcpy((unsigned char *)edid, raw, size);
464 465
465 if (!drm_edid_is_valid(edid)) { 466 if (!drm_edid_is_valid(edid)) {
466 kfree(edid); 467 kfree(edid);
@@ -468,6 +469,7 @@ bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
468 } 469 }
469 470
470 rdev->mode_info.bios_hardcoded_edid = edid; 471 rdev->mode_info.bios_hardcoded_edid = edid;
472 rdev->mode_info.bios_hardcoded_edid_size = size;
471 return true; 473 return true;
472} 474}
473 475
@@ -475,8 +477,17 @@ bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
475struct edid * 477struct edid *
476radeon_bios_get_hardcoded_edid(struct radeon_device *rdev) 478radeon_bios_get_hardcoded_edid(struct radeon_device *rdev)
477{ 479{
478 if (rdev->mode_info.bios_hardcoded_edid) 480 struct edid *edid;
479 return rdev->mode_info.bios_hardcoded_edid; 481
482 if (rdev->mode_info.bios_hardcoded_edid) {
483 edid = kmalloc(rdev->mode_info.bios_hardcoded_edid_size, GFP_KERNEL);
484 if (edid) {
485 memcpy((unsigned char *)edid,
486 (unsigned char *)rdev->mode_info.bios_hardcoded_edid,
487 rdev->mode_info.bios_hardcoded_edid_size);
488 return edid;
489 }
490 }
480 return NULL; 491 return NULL;
481} 492}
482 493
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 28c7961cd19b..2ef6d5135064 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -633,6 +633,8 @@ static int radeon_vga_mode_valid(struct drm_connector *connector,
633static enum drm_connector_status 633static enum drm_connector_status
634radeon_vga_detect(struct drm_connector *connector, bool force) 634radeon_vga_detect(struct drm_connector *connector, bool force)
635{ 635{
636 struct drm_device *dev = connector->dev;
637 struct radeon_device *rdev = dev->dev_private;
636 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 638 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
637 struct drm_encoder *encoder; 639 struct drm_encoder *encoder;
638 struct drm_encoder_helper_funcs *encoder_funcs; 640 struct drm_encoder_helper_funcs *encoder_funcs;
@@ -683,6 +685,17 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
683 685
684 if (ret == connector_status_connected) 686 if (ret == connector_status_connected)
685 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); 687 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true);
688
689 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
690 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
691 * by other means, assume the CRT is connected and use that EDID.
692 */
693 if ((!rdev->is_atom_bios) &&
694 (ret == connector_status_disconnected) &&
695 rdev->mode_info.bios_hardcoded_edid_size) {
696 ret = connector_status_connected;
697 }
698
686 radeon_connector_update_scratch_regs(connector, ret); 699 radeon_connector_update_scratch_regs(connector, ret);
687 return ret; 700 return ret;
688} 701}
@@ -794,6 +807,8 @@ static int radeon_dvi_get_modes(struct drm_connector *connector)
794static enum drm_connector_status 807static enum drm_connector_status
795radeon_dvi_detect(struct drm_connector *connector, bool force) 808radeon_dvi_detect(struct drm_connector *connector, bool force)
796{ 809{
810 struct drm_device *dev = connector->dev;
811 struct radeon_device *rdev = dev->dev_private;
797 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 812 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
798 struct drm_encoder *encoder = NULL; 813 struct drm_encoder *encoder = NULL;
799 struct drm_encoder_helper_funcs *encoder_funcs; 814 struct drm_encoder_helper_funcs *encoder_funcs;
@@ -833,8 +848,6 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
833 * you don't really know what's connected to which port as both are digital. 848 * you don't really know what's connected to which port as both are digital.
834 */ 849 */
835 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { 850 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) {
836 struct drm_device *dev = connector->dev;
837 struct radeon_device *rdev = dev->dev_private;
838 struct drm_connector *list_connector; 851 struct drm_connector *list_connector;
839 struct radeon_connector *list_radeon_connector; 852 struct radeon_connector *list_radeon_connector;
840 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { 853 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) {
@@ -899,6 +912,19 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
899 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); 912 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true);
900 } 913 }
901 914
915 /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the
916 * vbios to deal with KVMs. If we have one and are not able to detect a monitor
917 * by other means, assume the DFP is connected and use that EDID. In most
918 * cases the DVI port is actually a virtual KVM port connected to the service
919 * processor.
920 */
921 if ((!rdev->is_atom_bios) &&
922 (ret == connector_status_disconnected) &&
923 rdev->mode_info.bios_hardcoded_edid_size) {
924 radeon_connector->use_digital = true;
925 ret = connector_status_connected;
926 }
927
902out: 928out:
903 /* updated in get modes as well since we need to know if it's analog or digital */ 929 /* updated in get modes as well since we need to know if it's analog or digital */
904 radeon_connector_update_scratch_regs(connector, ret); 930 radeon_connector_update_scratch_regs(connector, ret);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index e4582814bb78..9c57538231d5 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -239,6 +239,7 @@ struct radeon_mode_info {
239 struct drm_property *underscan_vborder_property; 239 struct drm_property *underscan_vborder_property;
240 /* hardcoded DFP edid from BIOS */ 240 /* hardcoded DFP edid from BIOS */
241 struct edid *bios_hardcoded_edid; 241 struct edid *bios_hardcoded_edid;
242 int bios_hardcoded_edid_size;
242 243
243 /* pointer to fbdev info structure */ 244 /* pointer to fbdev info structure */
244 struct radeon_fbdev *rfbdev; 245 struct radeon_fbdev *rfbdev;
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 2aed03bde4b2..08de669e025a 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -365,12 +365,14 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
365 else if (strncmp("high", buf, strlen("high")) == 0) 365 else if (strncmp("high", buf, strlen("high")) == 0)
366 rdev->pm.profile = PM_PROFILE_HIGH; 366 rdev->pm.profile = PM_PROFILE_HIGH;
367 else { 367 else {
368 DRM_ERROR("invalid power profile!\n"); 368 count = -EINVAL;
369 goto fail; 369 goto fail;
370 } 370 }
371 radeon_pm_update_profile(rdev); 371 radeon_pm_update_profile(rdev);
372 radeon_pm_set_clocks(rdev); 372 radeon_pm_set_clocks(rdev);
373 } 373 } else
374 count = -EINVAL;
375
374fail: 376fail:
375 mutex_unlock(&rdev->pm.mutex); 377 mutex_unlock(&rdev->pm.mutex);
376 378
@@ -413,7 +415,7 @@ static ssize_t radeon_set_pm_method(struct device *dev,
413 mutex_unlock(&rdev->pm.mutex); 415 mutex_unlock(&rdev->pm.mutex);
414 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work); 416 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work);
415 } else { 417 } else {
416 DRM_ERROR("invalid power method!\n"); 418 count = -EINVAL;
417 goto fail; 419 goto fail;
418 } 420 }
419 radeon_pm_compute_clocks(rdev); 421 radeon_pm_compute_clocks(rdev);