aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c1
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c14
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c42
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c27
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c14
-rw-r--r--drivers/gpu/drm/i915/i915_gem_stolen.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gpu_error.c22
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h15
-rw-r--r--drivers/gpu/drm/i915/intel_display.c32
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c43
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_opregion.c10
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c6
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c10
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c18
-rw-r--r--drivers/gpu/drm/i915/intel_uncore.c2
-rw-r--r--include/uapi/drm/i915_drm.h2
18 files changed, 170 insertions, 92 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index e177d021c444..15a74f979b4b 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1685,6 +1685,7 @@ out_gem_unload:
1685 1685
1686 intel_teardown_gmbus(dev); 1686 intel_teardown_gmbus(dev);
1687 intel_teardown_mchbar(dev); 1687 intel_teardown_mchbar(dev);
1688 pm_qos_remove_request(&dev_priv->pm_qos);
1688 destroy_workqueue(dev_priv->wq); 1689 destroy_workqueue(dev_priv->wq);
1689out_mtrrfree: 1690out_mtrrfree:
1690 arch_phys_wc_del(dev_priv->gtt.mtrr); 1691 arch_phys_wc_del(dev_priv->gtt.mtrr);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 43245b3fd2a2..04f1f02c4019 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -59,7 +59,7 @@ MODULE_PARM_DESC(powersave,
59 "Enable powersavings, fbc, downclocking, etc. (default: true)"); 59 "Enable powersavings, fbc, downclocking, etc. (default: true)");
60 60
61int i915_semaphores __read_mostly = -1; 61int i915_semaphores __read_mostly = -1;
62module_param_named(semaphores, i915_semaphores, int, 0600); 62module_param_named(semaphores, i915_semaphores, int, 0400);
63MODULE_PARM_DESC(semaphores, 63MODULE_PARM_DESC(semaphores,
64 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))"); 64 "Use semaphores for inter-ring sync (default: -1 (use per-chip defaults))");
65 65
@@ -341,7 +341,6 @@ static const struct intel_device_info intel_haswell_m_info = {
341}; 341};
342 342
343static const struct intel_device_info intel_broadwell_d_info = { 343static const struct intel_device_info intel_broadwell_d_info = {
344 .is_preliminary = 1,
345 .gen = 8, .num_pipes = 3, 344 .gen = 8, .num_pipes = 3,
346 .need_gfx_hws = 1, .has_hotplug = 1, 345 .need_gfx_hws = 1, .has_hotplug = 1,
347 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, 346 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
@@ -350,7 +349,6 @@ static const struct intel_device_info intel_broadwell_d_info = {
350}; 349};
351 350
352static const struct intel_device_info intel_broadwell_m_info = { 351static const struct intel_device_info intel_broadwell_m_info = {
353 .is_preliminary = 1,
354 .gen = 8, .is_mobile = 1, .num_pipes = 3, 352 .gen = 8, .is_mobile = 1, .num_pipes = 3,
355 .need_gfx_hws = 1, .has_hotplug = 1, 353 .need_gfx_hws = 1, .has_hotplug = 1,
356 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, 354 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
@@ -924,7 +922,15 @@ static int i915_runtime_suspend(struct device *device)
924 922
925 del_timer_sync(&dev_priv->gpu_error.hangcheck_timer); 923 del_timer_sync(&dev_priv->gpu_error.hangcheck_timer);
926 dev_priv->pm.suspended = true; 924 dev_priv->pm.suspended = true;
927 intel_opregion_notify_adapter(dev, PCI_D3cold); 925
926 /*
927 * current versions of firmware which depend on this opregion
928 * notification have repurposed the D1 definition to mean
929 * "runtime suspended" vs. what you would normally expect (D3)
930 * to distinguish it from notifications that might be sent
931 * via the suspend path.
932 */
933 intel_opregion_notify_adapter(dev, PCI_D1);
928 934
929 return 0; 935 return 0;
930} 936}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ff6f870d6621..98322053eb2a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -330,6 +330,7 @@ struct drm_i915_error_state {
330 u64 fence[I915_MAX_NUM_FENCES]; 330 u64 fence[I915_MAX_NUM_FENCES];
331 struct timeval time; 331 struct timeval time;
332 struct drm_i915_error_ring { 332 struct drm_i915_error_ring {
333 bool valid;
333 struct drm_i915_error_object { 334 struct drm_i915_error_object {
334 int page_count; 335 int page_count;
335 u32 gtt_offset; 336 u32 gtt_offset;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 32636a470367..00c836154725 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2330,7 +2330,7 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring,
2330 2330
2331 if (ring->hangcheck.action != HANGCHECK_WAIT && 2331 if (ring->hangcheck.action != HANGCHECK_WAIT &&
2332 i915_request_guilty(request, acthd, &inside)) { 2332 i915_request_guilty(request, acthd, &inside)) {
2333 DRM_ERROR("%s hung %s bo (0x%lx ctx %d) at 0x%x\n", 2333 DRM_DEBUG("%s hung %s bo (0x%lx ctx %d) at 0x%x\n",
2334 ring->name, 2334 ring->name,
2335 inside ? "inside" : "flushing", 2335 inside ? "inside" : "flushing",
2336 offset, 2336 offset,
@@ -2388,16 +2388,6 @@ static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv,
2388static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, 2388static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
2389 struct intel_ring_buffer *ring) 2389 struct intel_ring_buffer *ring)
2390{ 2390{
2391 while (!list_empty(&ring->request_list)) {
2392 struct drm_i915_gem_request *request;
2393
2394 request = list_first_entry(&ring->request_list,
2395 struct drm_i915_gem_request,
2396 list);
2397
2398 i915_gem_free_request(request);
2399 }
2400
2401 while (!list_empty(&ring->active_list)) { 2391 while (!list_empty(&ring->active_list)) {
2402 struct drm_i915_gem_object *obj; 2392 struct drm_i915_gem_object *obj;
2403 2393
@@ -2407,6 +2397,23 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
2407 2397
2408 i915_gem_object_move_to_inactive(obj); 2398 i915_gem_object_move_to_inactive(obj);
2409 } 2399 }
2400
2401 /*
2402 * We must free the requests after all the corresponding objects have
2403 * been moved off active lists. Which is the same order as the normal
2404 * retire_requests function does. This is important if object hold
2405 * implicit references on things like e.g. ppgtt address spaces through
2406 * the request.
2407 */
2408 while (!list_empty(&ring->request_list)) {
2409 struct drm_i915_gem_request *request;
2410
2411 request = list_first_entry(&ring->request_list,
2412 struct drm_i915_gem_request,
2413 list);
2414
2415 i915_gem_free_request(request);
2416 }
2410} 2417}
2411 2418
2412void i915_gem_restore_fences(struct drm_device *dev) 2419void i915_gem_restore_fences(struct drm_device *dev)
@@ -3099,7 +3106,7 @@ i915_find_fence_reg(struct drm_device *dev)
3099 } 3106 }
3100 3107
3101 if (avail == NULL) 3108 if (avail == NULL)
3102 return NULL; 3109 goto deadlock;
3103 3110
3104 /* None available, try to steal one or wait for a user to finish */ 3111 /* None available, try to steal one or wait for a user to finish */
3105 list_for_each_entry(reg, &dev_priv->mm.fence_list, lru_list) { 3112 list_for_each_entry(reg, &dev_priv->mm.fence_list, lru_list) {
@@ -3109,7 +3116,12 @@ i915_find_fence_reg(struct drm_device *dev)
3109 return reg; 3116 return reg;
3110 } 3117 }
3111 3118
3112 return NULL; 3119deadlock:
3120 /* Wait for completion of pending flips which consume fences */
3121 if (intel_has_pending_fb_unpin(dev))
3122 return ERR_PTR(-EAGAIN);
3123
3124 return ERR_PTR(-EDEADLK);
3113} 3125}
3114 3126
3115/** 3127/**
@@ -3154,8 +3166,8 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
3154 } 3166 }
3155 } else if (enable) { 3167 } else if (enable) {
3156 reg = i915_find_fence_reg(dev); 3168 reg = i915_find_fence_reg(dev);
3157 if (reg == NULL) 3169 if (IS_ERR(reg))
3158 return -EDEADLK; 3170 return PTR_ERR(reg);
3159 3171
3160 if (reg->obj) { 3172 if (reg->obj) {
3161 struct drm_i915_gem_object *old = reg->obj; 3173 struct drm_i915_gem_object *old = reg->obj;
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 8f3adc7d0dc8..2ca280f9ee53 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -27,8 +27,10 @@
27 */ 27 */
28 28
29#include <drm/drmP.h> 29#include <drm/drmP.h>
30#include "i915_drv.h"
31#include <drm/i915_drm.h> 30#include <drm/i915_drm.h>
31
32#include "i915_drv.h"
33#include "intel_drv.h"
32#include "i915_trace.h" 34#include "i915_trace.h"
33 35
34static bool 36static bool
@@ -53,6 +55,7 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,
53 struct list_head eviction_list, unwind_list; 55 struct list_head eviction_list, unwind_list;
54 struct i915_vma *vma; 56 struct i915_vma *vma;
55 int ret = 0; 57 int ret = 0;
58 int pass = 0;
56 59
57 trace_i915_gem_evict(dev, min_size, alignment, mappable); 60 trace_i915_gem_evict(dev, min_size, alignment, mappable);
58 61
@@ -119,14 +122,24 @@ none:
119 /* Can we unpin some objects such as idle hw contents, 122 /* Can we unpin some objects such as idle hw contents,
120 * or pending flips? 123 * or pending flips?
121 */ 124 */
122 ret = nonblocking ? -ENOSPC : i915_gpu_idle(dev); 125 if (nonblocking)
123 if (ret) 126 return -ENOSPC;
124 return ret;
125 127
126 /* Only idle the GPU and repeat the search once */ 128 /* Only idle the GPU and repeat the search once */
127 i915_gem_retire_requests(dev); 129 if (pass++ == 0) {
128 nonblocking = true; 130 ret = i915_gpu_idle(dev);
129 goto search_again; 131 if (ret)
132 return ret;
133
134 i915_gem_retire_requests(dev);
135 goto search_again;
136 }
137
138 /* If we still have pending pageflip completions, drop
139 * back to userspace to give our workqueues time to
140 * acquire our locks and unpin the old scanouts.
141 */
142 return intel_has_pending_fb_unpin(dev) ? -EAGAIN : -ENOSPC;
130 143
131found: 144found:
132 /* drm_mm doesn't allow any other other operations while 145 /* drm_mm doesn't allow any other other operations while
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 8d795626a25e..d269ecf46e26 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -252,7 +252,7 @@ relocate_entry_cpu(struct drm_i915_gem_object *obj,
252 struct drm_device *dev = obj->base.dev; 252 struct drm_device *dev = obj->base.dev;
253 uint32_t page_offset = offset_in_page(reloc->offset); 253 uint32_t page_offset = offset_in_page(reloc->offset);
254 char *vaddr; 254 char *vaddr;
255 int ret = -EINVAL; 255 int ret;
256 256
257 ret = i915_gem_object_set_to_cpu_domain(obj, true); 257 ret = i915_gem_object_set_to_cpu_domain(obj, true);
258 if (ret) 258 if (ret)
@@ -287,7 +287,7 @@ relocate_entry_gtt(struct drm_i915_gem_object *obj,
287 struct drm_i915_private *dev_priv = dev->dev_private; 287 struct drm_i915_private *dev_priv = dev->dev_private;
288 uint32_t __iomem *reloc_entry; 288 uint32_t __iomem *reloc_entry;
289 void __iomem *reloc_page; 289 void __iomem *reloc_page;
290 int ret = -EINVAL; 290 int ret;
291 291
292 ret = i915_gem_object_set_to_gtt_domain(obj, true); 292 ret = i915_gem_object_set_to_gtt_domain(obj, true);
293 if (ret) 293 if (ret)
@@ -335,7 +335,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
335 struct drm_i915_gem_object *target_i915_obj; 335 struct drm_i915_gem_object *target_i915_obj;
336 struct i915_vma *target_vma; 336 struct i915_vma *target_vma;
337 uint32_t target_offset; 337 uint32_t target_offset;
338 int ret = -EINVAL; 338 int ret;
339 339
340 /* we've already hold a reference to all valid objects */ 340 /* we've already hold a reference to all valid objects */
341 target_vma = eb_get_vma(eb, reloc->target_handle); 341 target_vma = eb_get_vma(eb, reloc->target_handle);
@@ -365,7 +365,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
365 (int) reloc->offset, 365 (int) reloc->offset,
366 reloc->read_domains, 366 reloc->read_domains,
367 reloc->write_domain); 367 reloc->write_domain);
368 return ret; 368 return -EINVAL;
369 } 369 }
370 if (unlikely((reloc->write_domain | reloc->read_domains) 370 if (unlikely((reloc->write_domain | reloc->read_domains)
371 & ~I915_GEM_GPU_DOMAINS)) { 371 & ~I915_GEM_GPU_DOMAINS)) {
@@ -376,7 +376,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
376 (int) reloc->offset, 376 (int) reloc->offset,
377 reloc->read_domains, 377 reloc->read_domains,
378 reloc->write_domain); 378 reloc->write_domain);
379 return ret; 379 return -EINVAL;
380 } 380 }
381 381
382 target_obj->pending_read_domains |= reloc->read_domains; 382 target_obj->pending_read_domains |= reloc->read_domains;
@@ -396,14 +396,14 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
396 obj, reloc->target_handle, 396 obj, reloc->target_handle,
397 (int) reloc->offset, 397 (int) reloc->offset,
398 (int) obj->base.size); 398 (int) obj->base.size);
399 return ret; 399 return -EINVAL;
400 } 400 }
401 if (unlikely(reloc->offset & 3)) { 401 if (unlikely(reloc->offset & 3)) {
402 DRM_DEBUG("Relocation not 4-byte aligned: " 402 DRM_DEBUG("Relocation not 4-byte aligned: "
403 "obj %p target %d offset %d.\n", 403 "obj %p target %d offset %d.\n",
404 obj, reloc->target_handle, 404 obj, reloc->target_handle,
405 (int) reloc->offset); 405 (int) reloc->offset);
406 return ret; 406 return -EINVAL;
407 } 407 }
408 408
409 /* We can't wait for rendering with pagefaults disabled */ 409 /* We can't wait for rendering with pagefaults disabled */
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index fed87ec17211..1a24e84f2315 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -250,7 +250,7 @@ i915_pages_create_for_stolen(struct drm_device *dev,
250 } 250 }
251 251
252 sg = st->sgl; 252 sg = st->sgl;
253 sg->offset = offset; 253 sg->offset = 0;
254 sg->length = size; 254 sg->length = size;
255 255
256 sg_dma_address(sg) = (dma_addr_t)dev_priv->mm.stolen_base + offset; 256 sg_dma_address(sg) = (dma_addr_t)dev_priv->mm.stolen_base + offset;
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index a707cca692e4..d7fd2fd2f0a5 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -239,6 +239,9 @@ static void i915_ring_error_state(struct drm_i915_error_state_buf *m,
239 unsigned ring) 239 unsigned ring)
240{ 240{
241 BUG_ON(ring >= I915_NUM_RINGS); /* shut up confused gcc */ 241 BUG_ON(ring >= I915_NUM_RINGS); /* shut up confused gcc */
242 if (!error->ring[ring].valid)
243 return;
244
242 err_printf(m, "%s command stream:\n", ring_str(ring)); 245 err_printf(m, "%s command stream:\n", ring_str(ring));
243 err_printf(m, " HEAD: 0x%08x\n", error->head[ring]); 246 err_printf(m, " HEAD: 0x%08x\n", error->head[ring]);
244 err_printf(m, " TAIL: 0x%08x\n", error->tail[ring]); 247 err_printf(m, " TAIL: 0x%08x\n", error->tail[ring]);
@@ -293,7 +296,6 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
293 struct drm_device *dev = error_priv->dev; 296 struct drm_device *dev = error_priv->dev;
294 drm_i915_private_t *dev_priv = dev->dev_private; 297 drm_i915_private_t *dev_priv = dev->dev_private;
295 struct drm_i915_error_state *error = error_priv->error; 298 struct drm_i915_error_state *error = error_priv->error;
296 struct intel_ring_buffer *ring;
297 int i, j, page, offset, elt; 299 int i, j, page, offset, elt;
298 300
299 if (!error) { 301 if (!error) {
@@ -328,7 +330,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
328 if (INTEL_INFO(dev)->gen == 7) 330 if (INTEL_INFO(dev)->gen == 7)
329 err_printf(m, "ERR_INT: 0x%08x\n", error->err_int); 331 err_printf(m, "ERR_INT: 0x%08x\n", error->err_int);
330 332
331 for_each_ring(ring, dev_priv, i) 333 for (i = 0; i < ARRAY_SIZE(error->ring); i++)
332 i915_ring_error_state(m, dev, error, i); 334 i915_ring_error_state(m, dev, error, i);
333 335
334 if (error->active_bo) 336 if (error->active_bo)
@@ -385,8 +387,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
385 } 387 }
386 } 388 }
387 389
388 obj = error->ring[i].ctx; 390 if ((obj = error->ring[i].ctx)) {
389 if (obj) {
390 err_printf(m, "%s --- HW Context = 0x%08x\n", 391 err_printf(m, "%s --- HW Context = 0x%08x\n",
391 dev_priv->ring[i].name, 392 dev_priv->ring[i].name,
392 obj->gtt_offset); 393 obj->gtt_offset);
@@ -667,7 +668,8 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
667 return NULL; 668 return NULL;
668 669
669 obj = ring->scratch.obj; 670 obj = ring->scratch.obj;
670 if (acthd >= i915_gem_obj_ggtt_offset(obj) && 671 if (obj != NULL &&
672 acthd >= i915_gem_obj_ggtt_offset(obj) &&
671 acthd < i915_gem_obj_ggtt_offset(obj) + obj->base.size) 673 acthd < i915_gem_obj_ggtt_offset(obj) + obj->base.size)
672 return i915_error_object_create(dev_priv, obj); 674 return i915_error_object_create(dev_priv, obj);
673 } 675 }
@@ -775,11 +777,17 @@ static void i915_gem_record_rings(struct drm_device *dev,
775 struct drm_i915_error_state *error) 777 struct drm_i915_error_state *error)
776{ 778{
777 struct drm_i915_private *dev_priv = dev->dev_private; 779 struct drm_i915_private *dev_priv = dev->dev_private;
778 struct intel_ring_buffer *ring;
779 struct drm_i915_gem_request *request; 780 struct drm_i915_gem_request *request;
780 int i, count; 781 int i, count;
781 782
782 for_each_ring(ring, dev_priv, i) { 783 for (i = 0; i < I915_NUM_RINGS; i++) {
784 struct intel_ring_buffer *ring = &dev_priv->ring[i];
785
786 if (ring->dev == NULL)
787 continue;
788
789 error->ring[i].valid = true;
790
783 i915_record_ring_state(dev, error, ring); 791 i915_record_ring_state(dev, error, ring);
784 792
785 error->ring[i].batchbuffer = 793 error->ring[i].batchbuffer =
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 76126e0ae609..a48b7cad6f11 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2122,9 +2122,13 @@
2122 * Please check the detailed lore in the commit message for for experimental 2122 * Please check the detailed lore in the commit message for for experimental
2123 * evidence. 2123 * evidence.
2124 */ 2124 */
2125#define PORTD_HOTPLUG_LIVE_STATUS (1 << 29) 2125#define PORTD_HOTPLUG_LIVE_STATUS_G4X (1 << 29)
2126#define PORTC_HOTPLUG_LIVE_STATUS (1 << 28) 2126#define PORTC_HOTPLUG_LIVE_STATUS_G4X (1 << 28)
2127#define PORTB_HOTPLUG_LIVE_STATUS (1 << 27) 2127#define PORTB_HOTPLUG_LIVE_STATUS_G4X (1 << 27)
2128/* VLV DP/HDMI bits again match Bspec */
2129#define PORTD_HOTPLUG_LIVE_STATUS_VLV (1 << 27)
2130#define PORTC_HOTPLUG_LIVE_STATUS_VLV (1 << 28)
2131#define PORTB_HOTPLUG_LIVE_STATUS_VLV (1 << 29)
2128#define PORTD_HOTPLUG_INT_STATUS (3 << 21) 2132#define PORTD_HOTPLUG_INT_STATUS (3 << 21)
2129#define PORTC_HOTPLUG_INT_STATUS (3 << 19) 2133#define PORTC_HOTPLUG_INT_STATUS (3 << 19)
2130#define PORTB_HOTPLUG_INT_STATUS (3 << 17) 2134#define PORTB_HOTPLUG_INT_STATUS (3 << 17)
@@ -2138,7 +2142,8 @@
2138#define DP_AUX_CHANNEL_D_INT_STATUS_G4X (1 << 6) 2142#define DP_AUX_CHANNEL_D_INT_STATUS_G4X (1 << 6)
2139#define DP_AUX_CHANNEL_C_INT_STATUS_G4X (1 << 5) 2143#define DP_AUX_CHANNEL_C_INT_STATUS_G4X (1 << 5)
2140#define DP_AUX_CHANNEL_B_INT_STATUS_G4X (1 << 4) 2144#define DP_AUX_CHANNEL_B_INT_STATUS_G4X (1 << 4)
2141#define DP_AUX_CHANNEL_MASK_INT_STATUS_G4X (1 << 4) 2145#define DP_AUX_CHANNEL_MASK_INT_STATUS_G4X (7 << 4)
2146
2142/* SDVO is different across gen3/4 */ 2147/* SDVO is different across gen3/4 */
2143#define SDVOC_HOTPLUG_INT_STATUS_G4X (1 << 3) 2148#define SDVOC_HOTPLUG_INT_STATUS_G4X (1 << 3)
2144#define SDVOB_HOTPLUG_INT_STATUS_G4X (1 << 2) 2149#define SDVOB_HOTPLUG_INT_STATUS_G4X (1 << 2)
@@ -3573,8 +3578,6 @@
3573#define DISP_BASEADDR_MASK (0xfffff000) 3578#define DISP_BASEADDR_MASK (0xfffff000)
3574#define I915_LO_DISPBASE(val) (val & ~DISP_BASEADDR_MASK) 3579#define I915_LO_DISPBASE(val) (val & ~DISP_BASEADDR_MASK)
3575#define I915_HI_DISPBASE(val) (val & DISP_BASEADDR_MASK) 3580#define I915_HI_DISPBASE(val) (val & DISP_BASEADDR_MASK)
3576#define I915_MODIFY_DISPBASE(reg, gfx_addr) \
3577 (I915_WRITE((reg), (gfx_addr) | I915_LO_DISPBASE(I915_READ(reg))))
3578 3581
3579/* VBIOS flags */ 3582/* VBIOS flags */
3580#define SWF00 (dev_priv->info->display_mmio_offset + 0x71410) 3583#define SWF00 (dev_priv->info->display_mmio_offset + 0x71410)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 14b024becb91..40a9338ad54f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2114,8 +2114,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
2114 fb->pitches[0]); 2114 fb->pitches[0]);
2115 I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]); 2115 I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
2116 if (INTEL_INFO(dev)->gen >= 4) { 2116 if (INTEL_INFO(dev)->gen >= 4) {
2117 I915_MODIFY_DISPBASE(DSPSURF(plane), 2117 I915_WRITE(DSPSURF(plane),
2118 i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset); 2118 i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
2119 I915_WRITE(DSPTILEOFF(plane), (y << 16) | x); 2119 I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
2120 I915_WRITE(DSPLINOFF(plane), linear_offset); 2120 I915_WRITE(DSPLINOFF(plane), linear_offset);
2121 } else 2121 } else
@@ -2205,8 +2205,8 @@ static int ironlake_update_plane(struct drm_crtc *crtc,
2205 i915_gem_obj_ggtt_offset(obj), linear_offset, x, y, 2205 i915_gem_obj_ggtt_offset(obj), linear_offset, x, y,
2206 fb->pitches[0]); 2206 fb->pitches[0]);
2207 I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]); 2207 I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
2208 I915_MODIFY_DISPBASE(DSPSURF(plane), 2208 I915_WRITE(DSPSURF(plane),
2209 i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset); 2209 i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
2210 if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { 2210 if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
2211 I915_WRITE(DSPOFFSET(plane), (y << 16) | x); 2211 I915_WRITE(DSPOFFSET(plane), (y << 16) | x);
2212 } else { 2212 } else {
@@ -2982,6 +2982,30 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
2982 return pending; 2982 return pending;
2983} 2983}
2984 2984
2985bool intel_has_pending_fb_unpin(struct drm_device *dev)
2986{
2987 struct intel_crtc *crtc;
2988
2989 /* Note that we don't need to be called with mode_config.lock here
2990 * as our list of CRTC objects is static for the lifetime of the
2991 * device and so cannot disappear as we iterate. Similarly, we can
2992 * happily treat the predicates as racy, atomic checks as userspace
2993 * cannot claim and pin a new fb without at least acquring the
2994 * struct_mutex and so serialising with us.
2995 */
2996 list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
2997 if (atomic_read(&crtc->unpin_work_count) == 0)
2998 continue;
2999
3000 if (crtc->unpin_work)
3001 intel_wait_for_vblank(dev, crtc->pipe);
3002
3003 return true;
3004 }
3005
3006 return false;
3007}
3008
2985static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) 3009static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
2986{ 3010{
2987 struct drm_device *dev = crtc->dev; 3011 struct drm_device *dev = crtc->dev;
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 7df5085973e9..5ede4e8e290d 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2638,7 +2638,6 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp)
2638 2638
2639 if (cr_tries > 5) { 2639 if (cr_tries > 5) {
2640 DRM_ERROR("failed to train DP, aborting\n"); 2640 DRM_ERROR("failed to train DP, aborting\n");
2641 intel_dp_link_down(intel_dp);
2642 break; 2641 break;
2643 } 2642 }
2644 2643
@@ -2891,13 +2890,11 @@ intel_dp_check_link_status(struct intel_dp *intel_dp)
2891 2890
2892 /* Try to read receiver status if the link appears to be up */ 2891 /* Try to read receiver status if the link appears to be up */
2893 if (!intel_dp_get_link_status(intel_dp, link_status)) { 2892 if (!intel_dp_get_link_status(intel_dp, link_status)) {
2894 intel_dp_link_down(intel_dp);
2895 return; 2893 return;
2896 } 2894 }
2897 2895
2898 /* Now read the DPCD to see if it's actually running */ 2896 /* Now read the DPCD to see if it's actually running */
2899 if (!intel_dp_get_dpcd(intel_dp)) { 2897 if (!intel_dp_get_dpcd(intel_dp)) {
2900 intel_dp_link_down(intel_dp);
2901 return; 2898 return;
2902 } 2899 }
2903 2900
@@ -3012,18 +3009,34 @@ g4x_dp_detect(struct intel_dp *intel_dp)
3012 return status; 3009 return status;
3013 } 3010 }
3014 3011
3015 switch (intel_dig_port->port) { 3012 if (IS_VALLEYVIEW(dev)) {
3016 case PORT_B: 3013 switch (intel_dig_port->port) {
3017 bit = PORTB_HOTPLUG_LIVE_STATUS; 3014 case PORT_B:
3018 break; 3015 bit = PORTB_HOTPLUG_LIVE_STATUS_VLV;
3019 case PORT_C: 3016 break;
3020 bit = PORTC_HOTPLUG_LIVE_STATUS; 3017 case PORT_C:
3021 break; 3018 bit = PORTC_HOTPLUG_LIVE_STATUS_VLV;
3022 case PORT_D: 3019 break;
3023 bit = PORTD_HOTPLUG_LIVE_STATUS; 3020 case PORT_D:
3024 break; 3021 bit = PORTD_HOTPLUG_LIVE_STATUS_VLV;
3025 default: 3022 break;
3026 return connector_status_unknown; 3023 default:
3024 return connector_status_unknown;
3025 }
3026 } else {
3027 switch (intel_dig_port->port) {
3028 case PORT_B:
3029 bit = PORTB_HOTPLUG_LIVE_STATUS_G4X;
3030 break;
3031 case PORT_C:
3032 bit = PORTC_HOTPLUG_LIVE_STATUS_G4X;
3033 break;
3034 case PORT_D:
3035 bit = PORTD_HOTPLUG_LIVE_STATUS_G4X;
3036 break;
3037 default:
3038 return connector_status_unknown;
3039 }
3027 } 3040 }
3028 3041
3029 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) == 0) 3042 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) == 0)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8754db9e3d52..fbfaaba5cc3b 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -626,6 +626,7 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
626 626
627/* intel_display.c */ 627/* intel_display.c */
628const char *intel_output_name(int output); 628const char *intel_output_name(int output);
629bool intel_has_pending_fb_unpin(struct drm_device *dev);
629int intel_pch_rawclk(struct drm_device *dev); 630int intel_pch_rawclk(struct drm_device *dev);
630void intel_mark_busy(struct drm_device *dev); 631void intel_mark_busy(struct drm_device *dev);
631void intel_mark_fb_busy(struct drm_i915_gem_object *obj, 632void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index 3da259e280ba..37e9a96777ef 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -396,9 +396,7 @@ int intel_opregion_notify_adapter(struct drm_device *dev, pci_power_t state)
396static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) 396static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
397{ 397{
398 struct drm_i915_private *dev_priv = dev->dev_private; 398 struct drm_i915_private *dev_priv = dev->dev_private;
399 struct drm_connector *connector;
400 struct intel_connector *intel_connector; 399 struct intel_connector *intel_connector;
401 struct intel_panel *panel;
402 struct opregion_asle __iomem *asle = dev_priv->opregion.asle; 400 struct opregion_asle __iomem *asle = dev_priv->opregion.asle;
403 401
404 DRM_DEBUG_DRIVER("bclp = 0x%08x\n", bclp); 402 DRM_DEBUG_DRIVER("bclp = 0x%08x\n", bclp);
@@ -417,12 +415,8 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
417 * only one). 415 * only one).
418 */ 416 */
419 DRM_DEBUG_KMS("updating opregion backlight %d/255\n", bclp); 417 DRM_DEBUG_KMS("updating opregion backlight %d/255\n", bclp);
420 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 418 list_for_each_entry(intel_connector, &dev->mode_config.connector_list, base.head)
421 intel_connector = to_intel_connector(connector); 419 intel_panel_set_backlight(intel_connector, bclp, 255);
422 panel = &intel_connector->panel;
423 if (panel->backlight.present)
424 intel_panel_set_backlight(intel_connector, bclp, 255);
425 }
426 iowrite32(DIV_ROUND_UP(bclp * 100, 255) | ASLE_CBLV_VALID, &asle->cblv); 420 iowrite32(DIV_ROUND_UP(bclp * 100, 255) | ASLE_CBLV_VALID, &asle->cblv);
427 421
428 mutex_unlock(&dev->mode_config.mutex); 422 mutex_unlock(&dev->mode_config.mutex);
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 20ebc3e83d39..350de359123a 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -502,7 +502,7 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
502 u32 freq; 502 u32 freq;
503 unsigned long flags; 503 unsigned long flags;
504 504
505 if (pipe == INVALID_PIPE) 505 if (!panel->backlight.present || pipe == INVALID_PIPE)
506 return; 506 return;
507 507
508 spin_lock_irqsave(&dev_priv->backlight_lock, flags); 508 spin_lock_irqsave(&dev_priv->backlight_lock, flags);
@@ -579,7 +579,7 @@ void intel_panel_disable_backlight(struct intel_connector *connector)
579 enum pipe pipe = intel_get_pipe_from_connector(connector); 579 enum pipe pipe = intel_get_pipe_from_connector(connector);
580 unsigned long flags; 580 unsigned long flags;
581 581
582 if (pipe == INVALID_PIPE) 582 if (!panel->backlight.present || pipe == INVALID_PIPE)
583 return; 583 return;
584 584
585 /* 585 /*
@@ -782,7 +782,7 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
782 enum pipe pipe = intel_get_pipe_from_connector(connector); 782 enum pipe pipe = intel_get_pipe_from_connector(connector);
783 unsigned long flags; 783 unsigned long flags;
784 784
785 if (pipe == INVALID_PIPE) 785 if (!panel->backlight.present || pipe == INVALID_PIPE)
786 return; 786 return;
787 787
788 DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe)); 788 DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 8fcb32a02cb4..b7f1742caf87 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -673,10 +673,12 @@ gen6_add_request(struct intel_ring_buffer *ring)
673 if (ret) 673 if (ret)
674 return ret; 674 return ret;
675 675
676 for_each_ring(useless, dev_priv, i) { 676 if (i915_semaphore_is_enabled(dev)) {
677 u32 mbox_reg = ring->signal_mbox[i]; 677 for_each_ring(useless, dev_priv, i) {
678 if (mbox_reg != GEN6_NOSYNC) 678 u32 mbox_reg = ring->signal_mbox[i];
679 update_mboxes(ring, mbox_reg); 679 if (mbox_reg != GEN6_NOSYNC)
680 update_mboxes(ring, mbox_reg);
681 }
680 } 682 }
681 683
682 intel_ring_emit(ring, MI_STORE_DWORD_INDEX); 684 intel_ring_emit(ring, MI_STORE_DWORD_INDEX);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index fe4de89c374c..716a3c9c0751 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -141,8 +141,8 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
141 141
142 I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w); 142 I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w);
143 I915_WRITE(SPCNTR(pipe, plane), sprctl); 143 I915_WRITE(SPCNTR(pipe, plane), sprctl);
144 I915_MODIFY_DISPBASE(SPSURF(pipe, plane), i915_gem_obj_ggtt_offset(obj) + 144 I915_WRITE(SPSURF(pipe, plane), i915_gem_obj_ggtt_offset(obj) +
145 sprsurf_offset); 145 sprsurf_offset);
146 POSTING_READ(SPSURF(pipe, plane)); 146 POSTING_READ(SPSURF(pipe, plane));
147} 147}
148 148
@@ -158,7 +158,7 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)
158 I915_WRITE(SPCNTR(pipe, plane), I915_READ(SPCNTR(pipe, plane)) & 158 I915_WRITE(SPCNTR(pipe, plane), I915_READ(SPCNTR(pipe, plane)) &
159 ~SP_ENABLE); 159 ~SP_ENABLE);
160 /* Activate double buffered register update */ 160 /* Activate double buffered register update */
161 I915_MODIFY_DISPBASE(SPSURF(pipe, plane), 0); 161 I915_WRITE(SPSURF(pipe, plane), 0);
162 POSTING_READ(SPSURF(pipe, plane)); 162 POSTING_READ(SPSURF(pipe, plane));
163 163
164 intel_update_sprite_watermarks(dplane, crtc, 0, 0, false, false); 164 intel_update_sprite_watermarks(dplane, crtc, 0, 0, false, false);
@@ -315,8 +315,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
315 if (intel_plane->can_scale) 315 if (intel_plane->can_scale)
316 I915_WRITE(SPRSCALE(pipe), sprscale); 316 I915_WRITE(SPRSCALE(pipe), sprscale);
317 I915_WRITE(SPRCTL(pipe), sprctl); 317 I915_WRITE(SPRCTL(pipe), sprctl);
318 I915_MODIFY_DISPBASE(SPRSURF(pipe), 318 I915_WRITE(SPRSURF(pipe),
319 i915_gem_obj_ggtt_offset(obj) + sprsurf_offset); 319 i915_gem_obj_ggtt_offset(obj) + sprsurf_offset);
320 POSTING_READ(SPRSURF(pipe)); 320 POSTING_READ(SPRSURF(pipe));
321} 321}
322 322
@@ -333,7 +333,7 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)
333 if (intel_plane->can_scale) 333 if (intel_plane->can_scale)
334 I915_WRITE(SPRSCALE(pipe), 0); 334 I915_WRITE(SPRSCALE(pipe), 0);
335 /* Activate double buffered register update */ 335 /* Activate double buffered register update */
336 I915_MODIFY_DISPBASE(SPRSURF(pipe), 0); 336 I915_WRITE(SPRSURF(pipe), 0);
337 POSTING_READ(SPRSURF(pipe)); 337 POSTING_READ(SPRSURF(pipe));
338 338
339 /* 339 /*
@@ -489,8 +489,8 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
489 I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w); 489 I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w);
490 I915_WRITE(DVSSCALE(pipe), dvsscale); 490 I915_WRITE(DVSSCALE(pipe), dvsscale);
491 I915_WRITE(DVSCNTR(pipe), dvscntr); 491 I915_WRITE(DVSCNTR(pipe), dvscntr);
492 I915_MODIFY_DISPBASE(DVSSURF(pipe), 492 I915_WRITE(DVSSURF(pipe),
493 i915_gem_obj_ggtt_offset(obj) + dvssurf_offset); 493 i915_gem_obj_ggtt_offset(obj) + dvssurf_offset);
494 POSTING_READ(DVSSURF(pipe)); 494 POSTING_READ(DVSSURF(pipe));
495} 495}
496 496
@@ -506,7 +506,7 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)
506 /* Disable the scaler */ 506 /* Disable the scaler */
507 I915_WRITE(DVSSCALE(pipe), 0); 507 I915_WRITE(DVSSCALE(pipe), 0);
508 /* Flush double buffered register updates */ 508 /* Flush double buffered register updates */
509 I915_MODIFY_DISPBASE(DVSSURF(pipe), 0); 509 I915_WRITE(DVSSURF(pipe), 0);
510 POSTING_READ(DVSSURF(pipe)); 510 POSTING_READ(DVSSURF(pipe));
511 511
512 /* 512 /*
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 2c8143c37de3..87df68f5f504 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -805,7 +805,7 @@ static const struct register_whitelist {
805 uint32_t size; 805 uint32_t size;
806 uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */ 806 uint32_t gen_bitmask; /* support gens, 0x10 for 4, 0x30 for 4 and 5, etc. */
807} whitelist[] = { 807} whitelist[] = {
808 { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0xF0 }, 808 { RING_TIMESTAMP(RENDER_RING_BASE), 8, 0x1F0 },
809}; 809};
810 810
811int i915_reg_read_ioctl(struct drm_device *dev, 811int i915_reg_read_ioctl(struct drm_device *dev,
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 52aed893710a..126bfaa8bb6b 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -721,7 +721,7 @@ struct drm_i915_gem_execbuffer2 {
721 */ 721 */
722#define I915_EXEC_IS_PINNED (1<<10) 722#define I915_EXEC_IS_PINNED (1<<10)
723 723
724/** Provide a hint to the kernel that the command stream and auxilliary 724/** Provide a hint to the kernel that the command stream and auxiliary
725 * state buffers already holds the correct presumed addresses and so the 725 * state buffers already holds the correct presumed addresses and so the
726 * relocation process may be skipped if no buffers need to be moved in 726 * relocation process may be skipped if no buffers need to be moved in
727 * preparation for the execbuffer. 727 * preparation for the execbuffer.