aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-09-11 12:35:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-11 12:35:56 -0400
commit04d78e39ee1a7aa3712fce016b37b43a03f810c1 (patch)
treedbce2b55fd58e1afa9940e45ee3f1e841bb35e8b
parentb0a1ea51bda4c2bcdde460221e1772f3a4f8c44f (diff)
parent9fbcc7c007ea200357e2453c6b2b153646fbc165 (diff)
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "Just a bunch of fixes to squeeze in before -rc1: - three nouveau regression fixes - one qxl regression fix - a bunch of i915 fixes ... and some core displayport/atomic fixes" * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: drm/nouveau/device: enable c800 quirk for tecra w50 drm/nouveau/clk/gt215: Unbreak engine pausing for GT21x/MCP7x drm/nouveau/gr/nv04: fix big endian setting on gr context drm/qxl: validate monitors config modes drm/i915: Allow DSI dual link to be configured on any pipe drm/i915: Don't try to use DDR DVFS on CHV when disabled in the BIOS drm/i915: Fix CSR MMIO address check drm/i915: Limit the number of loops for reading a split 64bit register drm/i915: Fix broken mst get_hw_state. drm/i915: Pass hpd_status_i915[] to intel_get_hpd_pins() in pre-g4x uapi/drm/i915_drm.h: fix userspace compilation. drm/i915: Always mark the object as dirty when used by the GPU drm/dp: Add dp_aux_i2c_speed_khz module param to set the assume i2c bus speed drm/dp: Adjust i2c-over-aux retry count based on message size and i2c bus speed drm/dp: Define AUX_RETRY_INTERVAL as 500 us drm/atomic: Fix bookkeeping with TEST_ONLY, v3.
-rw-r--r--drivers/gpu/drm/drm_atomic.c39
-rw-r--r--drivers/gpu/drm/drm_dp_helper.c99
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h12
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c2
-rw-r--r--drivers/gpu/drm/i915/intel_csr.c2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c8
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c7
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.c9
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c42
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/nv04.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c2
-rw-r--r--drivers/gpu/drm/qxl/qxl_display.c66
-rw-r--r--drivers/gpu/drm/qxl/qxl_drv.h2
-rw-r--r--include/uapi/drm/i915_drm.h2
16 files changed, 218 insertions, 83 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 434915448ea0..f7d5166f89b2 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1515,7 +1515,8 @@ retry:
1515 copied_props++; 1515 copied_props++;
1516 } 1516 }
1517 1517
1518 if (obj->type == DRM_MODE_OBJECT_PLANE && count_props) { 1518 if (obj->type == DRM_MODE_OBJECT_PLANE && count_props &&
1519 !(arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
1519 plane = obj_to_plane(obj); 1520 plane = obj_to_plane(obj);
1520 plane_mask |= (1 << drm_plane_index(plane)); 1521 plane_mask |= (1 << drm_plane_index(plane));
1521 plane->old_fb = plane->fb; 1522 plane->old_fb = plane->fb;
@@ -1537,10 +1538,11 @@ retry:
1537 } 1538 }
1538 1539
1539 if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) { 1540 if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) {
1541 /*
1542 * Unlike commit, check_only does not clean up state.
1543 * Below we call drm_atomic_state_free for it.
1544 */
1540 ret = drm_atomic_check_only(state); 1545 ret = drm_atomic_check_only(state);
1541 /* _check_only() does not free state, unlike _commit() */
1542 if (!ret)
1543 drm_atomic_state_free(state);
1544 } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) { 1546 } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) {
1545 ret = drm_atomic_async_commit(state); 1547 ret = drm_atomic_async_commit(state);
1546 } else { 1548 } else {
@@ -1567,25 +1569,30 @@ out:
1567 plane->old_fb = NULL; 1569 plane->old_fb = NULL;
1568 } 1570 }
1569 1571
1572 if (ret && arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
1573 /*
1574 * TEST_ONLY and PAGE_FLIP_EVENT are mutually exclusive,
1575 * if they weren't, this code should be called on success
1576 * for TEST_ONLY too.
1577 */
1578
1579 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1580 if (!crtc_state->event)
1581 continue;
1582
1583 destroy_vblank_event(dev, file_priv,
1584 crtc_state->event);
1585 }
1586 }
1587
1570 if (ret == -EDEADLK) { 1588 if (ret == -EDEADLK) {
1571 drm_atomic_state_clear(state); 1589 drm_atomic_state_clear(state);
1572 drm_modeset_backoff(&ctx); 1590 drm_modeset_backoff(&ctx);
1573 goto retry; 1591 goto retry;
1574 } 1592 }
1575 1593
1576 if (ret) { 1594 if (ret || arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
1577 if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
1578 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1579 if (!crtc_state->event)
1580 continue;
1581
1582 destroy_vblank_event(dev, file_priv,
1583 crtc_state->event);
1584 }
1585 }
1586
1587 drm_atomic_state_free(state); 1595 drm_atomic_state_free(state);
1588 }
1589 1596
1590 drm_modeset_drop_locks(&ctx); 1597 drm_modeset_drop_locks(&ctx);
1591 drm_modeset_acquire_fini(&ctx); 1598 drm_modeset_acquire_fini(&ctx);
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 80a02a412607..291734e87fca 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -159,6 +159,8 @@ int drm_dp_bw_code_to_link_rate(u8 link_bw)
159} 159}
160EXPORT_SYMBOL(drm_dp_bw_code_to_link_rate); 160EXPORT_SYMBOL(drm_dp_bw_code_to_link_rate);
161 161
162#define AUX_RETRY_INTERVAL 500 /* us */
163
162/** 164/**
163 * DOC: dp helpers 165 * DOC: dp helpers
164 * 166 *
@@ -213,7 +215,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
213 return -EIO; 215 return -EIO;
214 216
215 case DP_AUX_NATIVE_REPLY_DEFER: 217 case DP_AUX_NATIVE_REPLY_DEFER:
216 usleep_range(400, 500); 218 usleep_range(AUX_RETRY_INTERVAL, AUX_RETRY_INTERVAL + 100);
217 break; 219 break;
218 } 220 }
219 } 221 }
@@ -422,6 +424,90 @@ static u32 drm_dp_i2c_functionality(struct i2c_adapter *adapter)
422 I2C_FUNC_10BIT_ADDR; 424 I2C_FUNC_10BIT_ADDR;
423} 425}
424 426
427#define AUX_PRECHARGE_LEN 10 /* 10 to 16 */
428#define AUX_SYNC_LEN (16 + 4) /* preamble + AUX_SYNC_END */
429#define AUX_STOP_LEN 4
430#define AUX_CMD_LEN 4
431#define AUX_ADDRESS_LEN 20
432#define AUX_REPLY_PAD_LEN 4
433#define AUX_LENGTH_LEN 8
434
435/*
436 * Calculate the duration of the AUX request/reply in usec. Gives the
437 * "best" case estimate, ie. successful while as short as possible.
438 */
439static int drm_dp_aux_req_duration(const struct drm_dp_aux_msg *msg)
440{
441 int len = AUX_PRECHARGE_LEN + AUX_SYNC_LEN + AUX_STOP_LEN +
442 AUX_CMD_LEN + AUX_ADDRESS_LEN + AUX_LENGTH_LEN;
443
444 if ((msg->request & DP_AUX_I2C_READ) == 0)
445 len += msg->size * 8;
446
447 return len;
448}
449
450static int drm_dp_aux_reply_duration(const struct drm_dp_aux_msg *msg)
451{
452 int len = AUX_PRECHARGE_LEN + AUX_SYNC_LEN + AUX_STOP_LEN +
453 AUX_CMD_LEN + AUX_REPLY_PAD_LEN;
454
455 /*
456 * For read we expect what was asked. For writes there will
457 * be 0 or 1 data bytes. Assume 0 for the "best" case.
458 */
459 if (msg->request & DP_AUX_I2C_READ)
460 len += msg->size * 8;
461
462 return len;
463}
464
465#define I2C_START_LEN 1
466#define I2C_STOP_LEN 1
467#define I2C_ADDR_LEN 9 /* ADDRESS + R/W + ACK/NACK */
468#define I2C_DATA_LEN 9 /* DATA + ACK/NACK */
469
470/*
471 * Calculate the length of the i2c transfer in usec, assuming
472 * the i2c bus speed is as specified. Gives the the "worst"
473 * case estimate, ie. successful while as long as possible.
474 * Doesn't account the the "MOT" bit, and instead assumes each
475 * message includes a START, ADDRESS and STOP. Neither does it
476 * account for additional random variables such as clock stretching.
477 */
478static int drm_dp_i2c_msg_duration(const struct drm_dp_aux_msg *msg,
479 int i2c_speed_khz)
480{
481 /* AUX bitrate is 1MHz, i2c bitrate as specified */
482 return DIV_ROUND_UP((I2C_START_LEN + I2C_ADDR_LEN +
483 msg->size * I2C_DATA_LEN +
484 I2C_STOP_LEN) * 1000, i2c_speed_khz);
485}
486
487/*
488 * Deterine how many retries should be attempted to successfully transfer
489 * the specified message, based on the estimated durations of the
490 * i2c and AUX transfers.
491 */
492static int drm_dp_i2c_retry_count(const struct drm_dp_aux_msg *msg,
493 int i2c_speed_khz)
494{
495 int aux_time_us = drm_dp_aux_req_duration(msg) +
496 drm_dp_aux_reply_duration(msg);
497 int i2c_time_us = drm_dp_i2c_msg_duration(msg, i2c_speed_khz);
498
499 return DIV_ROUND_UP(i2c_time_us, aux_time_us + AUX_RETRY_INTERVAL);
500}
501
502/*
503 * FIXME currently assumes 10 kHz as some real world devices seem
504 * to require it. We should query/set the speed via DPCD if supported.
505 */
506static int dp_aux_i2c_speed_khz __read_mostly = 10;
507module_param_unsafe(dp_aux_i2c_speed_khz, int, 0644);
508MODULE_PARM_DESC(dp_aux_i2c_speed_khz,
509 "Assumed speed of the i2c bus in kHz, (1-400, default 10)");
510
425/* 511/*
426 * Transfer a single I2C-over-AUX message and handle various error conditions, 512 * Transfer a single I2C-over-AUX message and handle various error conditions,
427 * retrying the transaction as appropriate. It is assumed that the 513 * retrying the transaction as appropriate. It is assumed that the
@@ -434,13 +520,16 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
434{ 520{
435 unsigned int retry, defer_i2c; 521 unsigned int retry, defer_i2c;
436 int ret; 522 int ret;
437
438 /* 523 /*
439 * DP1.2 sections 2.7.7.1.5.6.1 and 2.7.7.1.6.6.1: A DP Source device 524 * DP1.2 sections 2.7.7.1.5.6.1 and 2.7.7.1.6.6.1: A DP Source device
440 * is required to retry at least seven times upon receiving AUX_DEFER 525 * is required to retry at least seven times upon receiving AUX_DEFER
441 * before giving up the AUX transaction. 526 * before giving up the AUX transaction.
527 *
528 * We also try to account for the i2c bus speed.
442 */ 529 */
443 for (retry = 0, defer_i2c = 0; retry < (7 + defer_i2c); retry++) { 530 int max_retries = max(7, drm_dp_i2c_retry_count(msg, dp_aux_i2c_speed_khz));
531
532 for (retry = 0, defer_i2c = 0; retry < (max_retries + defer_i2c); retry++) {
444 mutex_lock(&aux->hw_mutex); 533 mutex_lock(&aux->hw_mutex);
445 ret = aux->transfer(aux, msg); 534 ret = aux->transfer(aux, msg);
446 mutex_unlock(&aux->hw_mutex); 535 mutex_unlock(&aux->hw_mutex);
@@ -476,7 +565,7 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
476 * For now just defer for long enough to hopefully be 565 * For now just defer for long enough to hopefully be
477 * safe for all use-cases. 566 * safe for all use-cases.
478 */ 567 */
479 usleep_range(500, 600); 568 usleep_range(AUX_RETRY_INTERVAL, AUX_RETRY_INTERVAL + 100);
480 continue; 569 continue;
481 570
482 default: 571 default:
@@ -506,7 +595,7 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
506 aux->i2c_defer_count++; 595 aux->i2c_defer_count++;
507 if (defer_i2c < 7) 596 if (defer_i2c < 7)
508 defer_i2c++; 597 defer_i2c++;
509 usleep_range(400, 500); 598 usleep_range(AUX_RETRY_INTERVAL, AUX_RETRY_INTERVAL + 100);
510 continue; 599 continue;
511 600
512 default: 601 default:
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 81adf89b92f1..e1db8de52851 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1929,6 +1929,8 @@ struct drm_i915_private {
1929 struct skl_wm_values skl_hw; 1929 struct skl_wm_values skl_hw;
1930 struct vlv_wm_values vlv; 1930 struct vlv_wm_values vlv;
1931 }; 1931 };
1932
1933 uint8_t max_level;
1932 } wm; 1934 } wm;
1933 1935
1934 struct i915_runtime_pm pm; 1936 struct i915_runtime_pm pm;
@@ -3384,13 +3386,13 @@ int intel_freq_opcode(struct drm_i915_private *dev_priv, int val);
3384#define I915_READ64(reg) dev_priv->uncore.funcs.mmio_readq(dev_priv, (reg), true) 3386#define I915_READ64(reg) dev_priv->uncore.funcs.mmio_readq(dev_priv, (reg), true)
3385 3387
3386#define I915_READ64_2x32(lower_reg, upper_reg) ({ \ 3388#define I915_READ64_2x32(lower_reg, upper_reg) ({ \
3387 u32 upper, lower, tmp; \ 3389 u32 upper, lower, old_upper, loop = 0; \
3388 tmp = I915_READ(upper_reg); \ 3390 upper = I915_READ(upper_reg); \
3389 do { \ 3391 do { \
3390 upper = tmp; \ 3392 old_upper = upper; \
3391 lower = I915_READ(lower_reg); \ 3393 lower = I915_READ(lower_reg); \
3392 tmp = I915_READ(upper_reg); \ 3394 upper = I915_READ(upper_reg); \
3393 } while (upper != tmp); \ 3395 } while (upper != old_upper && loop++ < 2); \
3394 (u64)upper << 32 | lower; }) 3396 (u64)upper << 32 | lower; })
3395 3397
3396#define POSTING_READ(reg) (void)I915_READ_NOTRACE(reg) 3398#define POSTING_READ(reg) (void)I915_READ_NOTRACE(reg)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 923a3c4bf0b7..a953d4975b8c 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1032,6 +1032,7 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
1032 u32 old_read = obj->base.read_domains; 1032 u32 old_read = obj->base.read_domains;
1033 u32 old_write = obj->base.write_domain; 1033 u32 old_write = obj->base.write_domain;
1034 1034
1035 obj->dirty = 1; /* be paranoid */
1035 obj->base.write_domain = obj->base.pending_write_domain; 1036 obj->base.write_domain = obj->base.pending_write_domain;
1036 if (obj->base.write_domain == 0) 1037 if (obj->base.write_domain == 0)
1037 obj->base.pending_read_domains |= obj->base.read_domains; 1038 obj->base.pending_read_domains |= obj->base.read_domains;
@@ -1039,7 +1040,6 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
1039 1040
1040 i915_vma_move_to_active(vma, req); 1041 i915_vma_move_to_active(vma, req);
1041 if (obj->base.write_domain) { 1042 if (obj->base.write_domain) {
1042 obj->dirty = 1;
1043 i915_gem_request_assign(&obj->last_write_req, req); 1043 i915_gem_request_assign(&obj->last_write_req, req);
1044 1044
1045 intel_fb_obj_invalidate(obj, ORIGIN_CS); 1045 intel_fb_obj_invalidate(obj, ORIGIN_CS);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b5fb1430c1d7..5a244ab9395b 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1558,7 +1558,7 @@ static void i9xx_hpd_irq_handler(struct drm_device *dev)
1558 u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915; 1558 u32 hotplug_trigger = hotplug_status & HOTPLUG_INT_STATUS_I915;
1559 1559
1560 intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, 1560 intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger,
1561 hotplug_trigger, hpd_status_g4x, 1561 hotplug_trigger, hpd_status_i915,
1562 i9xx_port_hotplug_long_detect); 1562 i9xx_port_hotplug_long_detect);
1563 intel_hpd_irq_handler(dev, pin_mask, long_mask); 1563 intel_hpd_irq_handler(dev, pin_mask, long_mask);
1564 } 1564 }
diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
index ba1ae031e6fd..d0f1b8d833cd 100644
--- a/drivers/gpu/drm/i915/intel_csr.c
+++ b/drivers/gpu/drm/i915/intel_csr.c
@@ -350,7 +350,7 @@ static void finish_csr_load(const struct firmware *fw, void *context)
350 } 350 }
351 csr->mmio_count = dmc_header->mmio_count; 351 csr->mmio_count = dmc_header->mmio_count;
352 for (i = 0; i < dmc_header->mmio_count; i++) { 352 for (i = 0; i < dmc_header->mmio_count; i++) {
353 if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE && 353 if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
354 dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) { 354 dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
355 DRM_ERROR(" Firmware has wrong mmio address 0x%x\n", 355 DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
356 dmc_header->mmioaddr[i]); 356 dmc_header->mmioaddr[i]);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index ca9278be49f7..8cc9264f7809 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6305,7 +6305,7 @@ static void intel_connector_check_state(struct intel_connector *connector)
6305 connector->base.name); 6305 connector->base.name);
6306 6306
6307 if (connector->get_hw_state(connector)) { 6307 if (connector->get_hw_state(connector)) {
6308 struct drm_encoder *encoder = &connector->encoder->base; 6308 struct intel_encoder *encoder = connector->encoder;
6309 struct drm_connector_state *conn_state = connector->base.state; 6309 struct drm_connector_state *conn_state = connector->base.state;
6310 6310
6311 I915_STATE_WARN(!crtc, 6311 I915_STATE_WARN(!crtc,
@@ -6317,13 +6317,13 @@ static void intel_connector_check_state(struct intel_connector *connector)
6317 I915_STATE_WARN(!crtc->state->active, 6317 I915_STATE_WARN(!crtc->state->active,
6318 "connector is active, but attached crtc isn't\n"); 6318 "connector is active, but attached crtc isn't\n");
6319 6319
6320 if (!encoder) 6320 if (!encoder || encoder->type == INTEL_OUTPUT_DP_MST)
6321 return; 6321 return;
6322 6322
6323 I915_STATE_WARN(conn_state->best_encoder != encoder, 6323 I915_STATE_WARN(conn_state->best_encoder != &encoder->base,
6324 "atomic encoder doesn't match attached encoder\n"); 6324 "atomic encoder doesn't match attached encoder\n");
6325 6325
6326 I915_STATE_WARN(conn_state->crtc != encoder->crtc, 6326 I915_STATE_WARN(conn_state->crtc != encoder->base.crtc,
6327 "attached encoder crtc differs from connector crtc\n"); 6327 "attached encoder crtc differs from connector crtc\n");
6328 } else { 6328 } else {
6329 I915_STATE_WARN(crtc && crtc->state->active, 6329 I915_STATE_WARN(crtc && crtc->state->active,
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index 983553cf8b74..3e4be5a3becd 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -173,6 +173,11 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
173 return; 173 return;
174 } 174 }
175 175
176 /* MST encoders are bound to a crtc, not to a connector,
177 * force the mapping here for get_hw_state.
178 */
179 found->encoder = encoder;
180
176 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links); 181 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
177 intel_mst->port = found->port; 182 intel_mst->port = found->port;
178 183
@@ -400,7 +405,7 @@ static const struct drm_encoder_funcs intel_dp_mst_enc_funcs = {
400 405
401static bool intel_dp_mst_get_hw_state(struct intel_connector *connector) 406static bool intel_dp_mst_get_hw_state(struct intel_connector *connector)
402{ 407{
403 if (connector->encoder) { 408 if (connector->encoder && connector->base.state->crtc) {
404 enum pipe pipe; 409 enum pipe pipe;
405 if (!connector->encoder->get_hw_state(connector->encoder, &pipe)) 410 if (!connector->encoder->get_hw_state(connector->encoder, &pipe))
406 return false; 411 return false;
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 4a601cf90f16..32a6c7184ca4 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -1048,11 +1048,7 @@ void intel_dsi_init(struct drm_device *dev)
1048 intel_connector->unregister = intel_connector_unregister; 1048 intel_connector->unregister = intel_connector_unregister;
1049 1049
1050 /* Pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI port C */ 1050 /* Pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI port C */
1051 if (dev_priv->vbt.dsi.config->dual_link) { 1051 if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIA) {
1052 /* XXX: does dual link work on either pipe? */
1053 intel_encoder->crtc_mask = (1 << PIPE_A);
1054 intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
1055 } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIA) {
1056 intel_encoder->crtc_mask = (1 << PIPE_A); 1052 intel_encoder->crtc_mask = (1 << PIPE_A);
1057 intel_dsi->ports = (1 << PORT_A); 1053 intel_dsi->ports = (1 << PORT_A);
1058 } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIC) { 1054 } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIC) {
@@ -1060,6 +1056,9 @@ void intel_dsi_init(struct drm_device *dev)
1060 intel_dsi->ports = (1 << PORT_C); 1056 intel_dsi->ports = (1 << PORT_C);
1061 } 1057 }
1062 1058
1059 if (dev_priv->vbt.dsi.config->dual_link)
1060 intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
1061
1063 /* Create a DSI host (and a device) for each port. */ 1062 /* Create a DSI host (and a device) for each port. */
1064 for_each_dsi_port(port, intel_dsi->ports) { 1063 for_each_dsi_port(port, intel_dsi->ports) {
1065 struct intel_dsi_host *host; 1064 struct intel_dsi_host *host;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index fff0c22682ee..ddbb7ed0a193 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -955,8 +955,6 @@ enum vlv_wm_level {
955 VLV_WM_LEVEL_PM2, 955 VLV_WM_LEVEL_PM2,
956 VLV_WM_LEVEL_PM5, 956 VLV_WM_LEVEL_PM5,
957 VLV_WM_LEVEL_DDR_DVFS, 957 VLV_WM_LEVEL_DDR_DVFS,
958 CHV_WM_NUM_LEVELS,
959 VLV_WM_NUM_LEVELS = 1,
960}; 958};
961 959
962/* latency must be in 0.1us units. */ 960/* latency must be in 0.1us units. */
@@ -982,9 +980,13 @@ static void vlv_setup_wm_latency(struct drm_device *dev)
982 /* all latencies in usec */ 980 /* all latencies in usec */
983 dev_priv->wm.pri_latency[VLV_WM_LEVEL_PM2] = 3; 981 dev_priv->wm.pri_latency[VLV_WM_LEVEL_PM2] = 3;
984 982
983 dev_priv->wm.max_level = VLV_WM_LEVEL_PM2;
984
985 if (IS_CHERRYVIEW(dev_priv)) { 985 if (IS_CHERRYVIEW(dev_priv)) {
986 dev_priv->wm.pri_latency[VLV_WM_LEVEL_PM5] = 12; 986 dev_priv->wm.pri_latency[VLV_WM_LEVEL_PM5] = 12;
987 dev_priv->wm.pri_latency[VLV_WM_LEVEL_DDR_DVFS] = 33; 987 dev_priv->wm.pri_latency[VLV_WM_LEVEL_DDR_DVFS] = 33;
988
989 dev_priv->wm.max_level = VLV_WM_LEVEL_DDR_DVFS;
988 } 990 }
989} 991}
990 992
@@ -1137,10 +1139,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
1137 memset(wm_state, 0, sizeof(*wm_state)); 1139 memset(wm_state, 0, sizeof(*wm_state));
1138 1140
1139 wm_state->cxsr = crtc->pipe != PIPE_C && crtc->wm.cxsr_allowed; 1141 wm_state->cxsr = crtc->pipe != PIPE_C && crtc->wm.cxsr_allowed;
1140 if (IS_CHERRYVIEW(dev)) 1142 wm_state->num_levels = to_i915(dev)->wm.max_level + 1;
1141 wm_state->num_levels = CHV_WM_NUM_LEVELS;
1142 else
1143 wm_state->num_levels = VLV_WM_NUM_LEVELS;
1144 1143
1145 wm_state->num_active_planes = 0; 1144 wm_state->num_active_planes = 0;
1146 1145
@@ -1220,7 +1219,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
1220 } 1219 }
1221 1220
1222 /* clear any (partially) filled invalid levels */ 1221 /* clear any (partially) filled invalid levels */
1223 for (level = wm_state->num_levels; level < CHV_WM_NUM_LEVELS; level++) { 1222 for (level = wm_state->num_levels; level < to_i915(dev)->wm.max_level + 1; level++) {
1224 memset(&wm_state->wm[level], 0, sizeof(wm_state->wm[level])); 1223 memset(&wm_state->wm[level], 0, sizeof(wm_state->wm[level]));
1225 memset(&wm_state->sr[level], 0, sizeof(wm_state->sr[level])); 1224 memset(&wm_state->sr[level], 0, sizeof(wm_state->sr[level]));
1226 } 1225 }
@@ -1324,10 +1323,7 @@ static void vlv_merge_wm(struct drm_device *dev,
1324 struct intel_crtc *crtc; 1323 struct intel_crtc *crtc;
1325 int num_active_crtcs = 0; 1324 int num_active_crtcs = 0;
1326 1325
1327 if (IS_CHERRYVIEW(dev)) 1326 wm->level = to_i915(dev)->wm.max_level;
1328 wm->level = VLV_WM_LEVEL_DDR_DVFS;
1329 else
1330 wm->level = VLV_WM_LEVEL_PM2;
1331 wm->cxsr = true; 1327 wm->cxsr = true;
1332 1328
1333 for_each_intel_crtc(dev, crtc) { 1329 for_each_intel_crtc(dev, crtc) {
@@ -4083,9 +4079,29 @@ void vlv_wm_get_hw_state(struct drm_device *dev)
4083 if (val & DSP_MAXFIFO_PM5_ENABLE) 4079 if (val & DSP_MAXFIFO_PM5_ENABLE)
4084 wm->level = VLV_WM_LEVEL_PM5; 4080 wm->level = VLV_WM_LEVEL_PM5;
4085 4081
4082 /*
4083 * If DDR DVFS is disabled in the BIOS, Punit
4084 * will never ack the request. So if that happens
4085 * assume we don't have to enable/disable DDR DVFS
4086 * dynamically. To test that just set the REQ_ACK
4087 * bit to poke the Punit, but don't change the
4088 * HIGH/LOW bits so that we don't actually change
4089 * the current state.
4090 */
4086 val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2); 4091 val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2);
4087 if ((val & FORCE_DDR_HIGH_FREQ) == 0) 4092 val |= FORCE_DDR_FREQ_REQ_ACK;
4088 wm->level = VLV_WM_LEVEL_DDR_DVFS; 4093 vlv_punit_write(dev_priv, PUNIT_REG_DDR_SETUP2, val);
4094
4095 if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2) &
4096 FORCE_DDR_FREQ_REQ_ACK) == 0, 3)) {
4097 DRM_DEBUG_KMS("Punit not acking DDR DVFS request, "
4098 "assuming DDR DVFS is disabled\n");
4099 dev_priv->wm.max_level = VLV_WM_LEVEL_PM5;
4100 } else {
4101 val = vlv_punit_read(dev_priv, PUNIT_REG_DDR_SETUP2);
4102 if ((val & FORCE_DDR_HIGH_FREQ) == 0)
4103 wm->level = VLV_WM_LEVEL_DDR_DVFS;
4104 }
4089 4105
4090 mutex_unlock(&dev_priv->rps.hw_lock); 4106 mutex_unlock(&dev_priv->rps.hw_lock);
4091 } 4107 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
index 9dd1cac81e80..e8eb14e438f4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
@@ -689,6 +689,7 @@ nvkm_device_pci_10de_11e3[] = {
689 689
690static const struct nvkm_device_pci_vendor 690static const struct nvkm_device_pci_vendor
691nvkm_device_pci_10de_11fc[] = { 691nvkm_device_pci_10de_11fc[] = {
692 { 0x1179, 0x0001, NULL, { .War00C800_0 = true } }, /* Toshiba Tecra W50 */
692 { 0x17aa, 0x2211, NULL, { .War00C800_0 = true } }, /* Lenovo W541 */ 693 { 0x17aa, 0x2211, NULL, { .War00C800_0 = true } }, /* Lenovo W541 */
693 { 0x17aa, 0x221e, NULL, { .War00C800_0 = true } }, /* Lenovo W541 */ 694 { 0x17aa, 0x221e, NULL, { .War00C800_0 = true } }, /* Lenovo W541 */
694 {} 695 {}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv04.c
index 426ba0025a8d..85c5b7fea5f5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/nv04.c
@@ -1048,11 +1048,11 @@ nv04_gr_object_bind(struct nvkm_object *object, struct nvkm_gpuobj *parent,
1048 if (ret == 0) { 1048 if (ret == 0) {
1049 nvkm_kmap(*pgpuobj); 1049 nvkm_kmap(*pgpuobj);
1050 nvkm_wo32(*pgpuobj, 0x00, object->oclass); 1050 nvkm_wo32(*pgpuobj, 0x00, object->oclass);
1051 nvkm_wo32(*pgpuobj, 0x04, 0x00000000);
1052 nvkm_wo32(*pgpuobj, 0x08, 0x00000000);
1053#ifdef __BIG_ENDIAN 1051#ifdef __BIG_ENDIAN
1054 nvkm_mo32(*pgpuobj, 0x08, 0x00080000, 0x00080000); 1052 nvkm_mo32(*pgpuobj, 0x00, 0x00080000, 0x00080000);
1055#endif 1053#endif
1054 nvkm_wo32(*pgpuobj, 0x04, 0x00000000);
1055 nvkm_wo32(*pgpuobj, 0x08, 0x00000000);
1056 nvkm_wo32(*pgpuobj, 0x0c, 0x00000000); 1056 nvkm_wo32(*pgpuobj, 0x0c, 0x00000000);
1057 nvkm_done(*pgpuobj); 1057 nvkm_done(*pgpuobj);
1058 } 1058 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
index 07feae620c8d..c233e3f653ce 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
@@ -326,7 +326,7 @@ gt215_clk_pre(struct nvkm_clk *clk, unsigned long *flags)
326 return -EIO; 326 return -EIO;
327 327
328 if (nvkm_msec(device, 2000, 328 if (nvkm_msec(device, 2000,
329 u32 tmp = nvkm_rd32(device, 0x002504) & 0x0000003f; 329 u32 tmp = nvkm_rd32(device, 0x00251c) & 0x0000003f;
330 if (tmp == 0x0000003f) 330 if (tmp == 0x0000003f)
331 break; 331 break;
332 ) < 0) 332 ) < 0)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index a8dbb3ef4e3c..7c6225c84ba6 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -160,9 +160,35 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,
160 *pwidth = head->width; 160 *pwidth = head->width;
161 *pheight = head->height; 161 *pheight = head->height;
162 drm_mode_probed_add(connector, mode); 162 drm_mode_probed_add(connector, mode);
163 /* remember the last custom size for mode validation */
164 qdev->monitors_config_width = mode->hdisplay;
165 qdev->monitors_config_height = mode->vdisplay;
163 return 1; 166 return 1;
164} 167}
165 168
169static struct mode_size {
170 int w;
171 int h;
172} common_modes[] = {
173 { 640, 480},
174 { 720, 480},
175 { 800, 600},
176 { 848, 480},
177 {1024, 768},
178 {1152, 768},
179 {1280, 720},
180 {1280, 800},
181 {1280, 854},
182 {1280, 960},
183 {1280, 1024},
184 {1440, 900},
185 {1400, 1050},
186 {1680, 1050},
187 {1600, 1200},
188 {1920, 1080},
189 {1920, 1200}
190};
191
166static int qxl_add_common_modes(struct drm_connector *connector, 192static int qxl_add_common_modes(struct drm_connector *connector,
167 unsigned pwidth, 193 unsigned pwidth,
168 unsigned pheight) 194 unsigned pheight)
@@ -170,29 +196,6 @@ static int qxl_add_common_modes(struct drm_connector *connector,
170 struct drm_device *dev = connector->dev; 196 struct drm_device *dev = connector->dev;
171 struct drm_display_mode *mode = NULL; 197 struct drm_display_mode *mode = NULL;
172 int i; 198 int i;
173 struct mode_size {
174 int w;
175 int h;
176 } common_modes[] = {
177 { 640, 480},
178 { 720, 480},
179 { 800, 600},
180 { 848, 480},
181 {1024, 768},
182 {1152, 768},
183 {1280, 720},
184 {1280, 800},
185 {1280, 854},
186 {1280, 960},
187 {1280, 1024},
188 {1440, 900},
189 {1400, 1050},
190 {1680, 1050},
191 {1600, 1200},
192 {1920, 1080},
193 {1920, 1200}
194 };
195
196 for (i = 0; i < ARRAY_SIZE(common_modes); i++) { 199 for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
197 mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 200 mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h,
198 60, false, false, false); 201 60, false, false, false);
@@ -823,11 +826,22 @@ static int qxl_conn_get_modes(struct drm_connector *connector)
823static int qxl_conn_mode_valid(struct drm_connector *connector, 826static int qxl_conn_mode_valid(struct drm_connector *connector,
824 struct drm_display_mode *mode) 827 struct drm_display_mode *mode)
825{ 828{
829 struct drm_device *ddev = connector->dev;
830 struct qxl_device *qdev = ddev->dev_private;
831 int i;
832
826 /* TODO: is this called for user defined modes? (xrandr --add-mode) 833 /* TODO: is this called for user defined modes? (xrandr --add-mode)
827 * TODO: check that the mode fits in the framebuffer */ 834 * TODO: check that the mode fits in the framebuffer */
828 DRM_DEBUG("%s: %dx%d status=%d\n", mode->name, mode->hdisplay, 835
829 mode->vdisplay, mode->status); 836 if(qdev->monitors_config_width == mode->hdisplay &&
830 return MODE_OK; 837 qdev->monitors_config_height == mode->vdisplay)
838 return MODE_OK;
839
840 for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
841 if (common_modes[i].w == mode->hdisplay && common_modes[i].h == mode->vdisplay)
842 return MODE_OK;
843 }
844 return MODE_BAD;
831} 845}
832 846
833static struct drm_encoder *qxl_best_encoder(struct drm_connector *connector) 847static struct drm_encoder *qxl_best_encoder(struct drm_connector *connector)
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index d8549690801d..01a86948eb8c 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -325,6 +325,8 @@ struct qxl_device {
325 struct work_struct fb_work; 325 struct work_struct fb_work;
326 326
327 struct drm_property *hotplug_mode_update_property; 327 struct drm_property *hotplug_mode_update_property;
328 int monitors_config_width;
329 int monitors_config_height;
328}; 330};
329 331
330/* forward declaration for QXL_INFO_IO */ 332/* forward declaration for QXL_INFO_IO */
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index dbd16a2d37db..fd5aa47bd689 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -358,7 +358,7 @@ typedef struct drm_i915_irq_wait {
358#define I915_PARAM_HAS_RESOURCE_STREAMER 36 358#define I915_PARAM_HAS_RESOURCE_STREAMER 36
359 359
360typedef struct drm_i915_getparam { 360typedef struct drm_i915_getparam {
361 s32 param; 361 __s32 param;
362 /* 362 /*
363 * WARNING: Using pointers instead of fixed-size u64 means we need to write 363 * WARNING: Using pointers instead of fixed-size u64 means we need to write
364 * compat32 code. Don't repeat this mistake. 364 * compat32 code. Don't repeat this mistake.