aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/armada/armada_crtc.c21
-rw-r--r--drivers/gpu/drm/armada/armada_drv.c3
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_drv.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_dp_core.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dpi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c43
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c6
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c19
-rw-r--r--drivers/gpu/drm/i915/intel_display.c41
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c24
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h3
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c5
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnv50.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_chan.c12
-rw-r--r--drivers/gpu/drm/qxl/qxl_display.c16
-rw-r--r--drivers/gpu/drm/radeon/btc_dpm.c18
-rw-r--r--drivers/gpu/drm/radeon/btc_dpm.h2
-rw-r--r--drivers/gpu/drm/radeon/ci_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/cik_sdma.c21
-rw-r--r--drivers/gpu/drm/radeon/cypress_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/dce3_1_afmt.c6
-rw-r--r--drivers/gpu/drm/radeon/dce6_afmt.c8
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c4
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c8
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c19
-rw-r--r--drivers/gpu/drm/radeon/ni_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/r600_dma.c21
-rw-r--r--drivers/gpu/drm/radeon/r600_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_vm.c4
-rw-r--r--drivers/gpu/drm/radeon/rs780_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/rv6xx_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c27
-rw-r--r--drivers/gpu/drm/radeon/sumo_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/trinity_dpm.c1
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c28
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c24
47 files changed, 292 insertions, 159 deletions
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 9a0cc09e6653..e4a1490b42c2 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -260,7 +260,7 @@ static void armada_drm_vblank_off(struct armada_crtc *dcrtc)
260 * Tell the DRM core that vblank IRQs aren't going to happen for 260 * Tell the DRM core that vblank IRQs aren't going to happen for
261 * a while. This cleans up any pending vblank events for us. 261 * a while. This cleans up any pending vblank events for us.
262 */ 262 */
263 drm_vblank_off(dev, dcrtc->num); 263 drm_crtc_vblank_off(&dcrtc->crtc);
264 264
265 /* Handle any pending flip event. */ 265 /* Handle any pending flip event. */
266 spin_lock_irq(&dev->event_lock); 266 spin_lock_irq(&dev->event_lock);
@@ -289,6 +289,8 @@ static void armada_drm_crtc_dpms(struct drm_crtc *crtc, int dpms)
289 armada_drm_crtc_update(dcrtc); 289 armada_drm_crtc_update(dcrtc);
290 if (dpms_blanked(dpms)) 290 if (dpms_blanked(dpms))
291 armada_drm_vblank_off(dcrtc); 291 armada_drm_vblank_off(dcrtc);
292 else
293 drm_crtc_vblank_on(&dcrtc->crtc);
292 } 294 }
293} 295}
294 296
@@ -526,7 +528,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
526 /* Wait for pending flips to complete */ 528 /* Wait for pending flips to complete */
527 wait_event(dcrtc->frame_wait, !dcrtc->frame_work); 529 wait_event(dcrtc->frame_wait, !dcrtc->frame_work);
528 530
529 drm_vblank_pre_modeset(crtc->dev, dcrtc->num); 531 drm_crtc_vblank_off(crtc);
530 532
531 crtc->mode = *adj; 533 crtc->mode = *adj;
532 534
@@ -617,7 +619,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
617 619
618 armada_drm_crtc_update(dcrtc); 620 armada_drm_crtc_update(dcrtc);
619 621
620 drm_vblank_post_modeset(crtc->dev, dcrtc->num); 622 drm_crtc_vblank_on(crtc);
621 armada_drm_crtc_finish_fb(dcrtc, old_fb, dpms_blanked(dcrtc->dpms)); 623 armada_drm_crtc_finish_fb(dcrtc, old_fb, dpms_blanked(dcrtc->dpms));
622 624
623 return 0; 625 return 0;
@@ -945,18 +947,15 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
945 armada_reg_queue_end(work->regs, i); 947 armada_reg_queue_end(work->regs, i);
946 948
947 /* 949 /*
948 * Hold the old framebuffer for the work - DRM appears to drop our 950 * Ensure that we hold a reference on the new framebuffer.
949 * reference to the old framebuffer in drm_mode_page_flip_ioctl(). 951 * This has to match the behaviour in mode_set.
950 */ 952 */
951 drm_framebuffer_reference(work->old_fb); 953 drm_framebuffer_reference(fb);
952 954
953 ret = armada_drm_crtc_queue_frame_work(dcrtc, work); 955 ret = armada_drm_crtc_queue_frame_work(dcrtc, work);
954 if (ret) { 956 if (ret) {
955 /* 957 /* Undo our reference above */
956 * Undo our reference above; DRM does not drop the reference 958 drm_framebuffer_unreference(fb);
957 * to this object on error, so that's okay.
958 */
959 drm_framebuffer_unreference(work->old_fb);
960 kfree(work); 959 kfree(work);
961 return ret; 960 return ret;
962 } 961 }
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index f672e6ad8afa..908e5316eac4 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -190,6 +190,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
190 if (ret) 190 if (ret)
191 goto err_comp; 191 goto err_comp;
192 192
193 dev->irq_enabled = true;
193 dev->vblank_disable_allowed = 1; 194 dev->vblank_disable_allowed = 1;
194 195
195 ret = armada_fbdev_init(dev); 196 ret = armada_fbdev_init(dev);
@@ -331,7 +332,7 @@ static struct drm_driver armada_drm_driver = {
331 .desc = "Armada SoC DRM", 332 .desc = "Armada SoC DRM",
332 .date = "20120730", 333 .date = "20120730",
333 .driver_features = DRIVER_GEM | DRIVER_MODESET | 334 .driver_features = DRIVER_GEM | DRIVER_MODESET |
334 DRIVER_PRIME, 335 DRIVER_HAVE_IRQ | DRIVER_PRIME,
335 .ioctls = armada_ioctls, 336 .ioctls = armada_ioctls,
336 .fops = &armada_drm_fops, 337 .fops = &armada_drm_fops,
337}; 338};
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index e705335101a5..c2a1cba1e984 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -32,6 +32,8 @@ static struct drm_driver driver;
32static const struct pci_device_id pciidlist[] = { 32static const struct pci_device_id pciidlist[] = {
33 { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, 0x1af4, 0x1100, 0, 33 { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, 0x1af4, 0x1100, 0,
34 0, 0 }, 34 0, 0 },
35 { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, PCI_VENDOR_ID_XEN,
36 0x0001, 0, 0, 0 },
35 {0,} 37 {0,}
36}; 38};
37 39
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index cd50ece31601..6adb1e5cfb08 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -1355,13 +1355,8 @@ static void exynos_dp_unbind(struct device *dev, struct device *master,
1355 void *data) 1355 void *data)
1356{ 1356{
1357 struct exynos_drm_display *display = dev_get_drvdata(dev); 1357 struct exynos_drm_display *display = dev_get_drvdata(dev);
1358 struct exynos_dp_device *dp = display->ctx;
1359 struct drm_encoder *encoder = dp->encoder;
1360 1358
1361 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); 1359 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
1362
1363 exynos_dp_connector_destroy(&dp->connector);
1364 encoder->funcs->destroy(encoder);
1365} 1360}
1366 1361
1367static const struct component_ops exynos_dp_ops = { 1362static const struct component_ops exynos_dp_ops = {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 8e38e9f8e542..45026e693225 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -71,13 +71,16 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
71 !atomic_read(&exynos_crtc->pending_flip), 71 !atomic_read(&exynos_crtc->pending_flip),
72 HZ/20)) 72 HZ/20))
73 atomic_set(&exynos_crtc->pending_flip, 0); 73 atomic_set(&exynos_crtc->pending_flip, 0);
74 drm_vblank_off(crtc->dev, exynos_crtc->pipe); 74 drm_crtc_vblank_off(crtc);
75 } 75 }
76 76
77 if (manager->ops->dpms) 77 if (manager->ops->dpms)
78 manager->ops->dpms(manager, mode); 78 manager->ops->dpms(manager, mode);
79 79
80 exynos_crtc->dpms = mode; 80 exynos_crtc->dpms = mode;
81
82 if (mode == DRM_MODE_DPMS_ON)
83 drm_crtc_vblank_on(crtc);
81} 84}
82 85
83static void exynos_drm_crtc_prepare(struct drm_crtc *crtc) 86static void exynos_drm_crtc_prepare(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 96c87db388fb..3dc678ed9949 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -338,14 +338,10 @@ err_del_component:
338 338
339int exynos_dpi_remove(struct device *dev) 339int exynos_dpi_remove(struct device *dev)
340{ 340{
341 struct drm_encoder *encoder = exynos_dpi_display.encoder;
342 struct exynos_dpi *ctx = exynos_dpi_display.ctx; 341 struct exynos_dpi *ctx = exynos_dpi_display.ctx;
343 342
344 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF); 343 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF);
345 344
346 exynos_dpi_connector_destroy(&ctx->connector);
347 encoder->funcs->destroy(encoder);
348
349 if (ctx->panel) 345 if (ctx->panel)
350 drm_panel_detach(ctx->panel); 346 drm_panel_detach(ctx->panel);
351 347
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 443a2069858a..c57466edf45b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -87,16 +87,12 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
87 87
88 plane = exynos_plane_init(dev, possible_crtcs, 88 plane = exynos_plane_init(dev, possible_crtcs,
89 DRM_PLANE_TYPE_OVERLAY); 89 DRM_PLANE_TYPE_OVERLAY);
90 if (IS_ERR(plane)) 90 if (!IS_ERR(plane))
91 goto err_mode_config_cleanup; 91 continue;
92 }
93
94 /* init kms poll for handling hpd */
95 drm_kms_helper_poll_init(dev);
96 92
97 ret = drm_vblank_init(dev, MAX_CRTC); 93 ret = PTR_ERR(plane);
98 if (ret)
99 goto err_mode_config_cleanup; 94 goto err_mode_config_cleanup;
95 }
100 96
101 /* setup possible_clones. */ 97 /* setup possible_clones. */
102 exynos_drm_encoder_setup(dev); 98 exynos_drm_encoder_setup(dev);
@@ -106,15 +102,16 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
106 /* Try to bind all sub drivers. */ 102 /* Try to bind all sub drivers. */
107 ret = component_bind_all(dev->dev, dev); 103 ret = component_bind_all(dev->dev, dev);
108 if (ret) 104 if (ret)
109 goto err_cleanup_vblank; 105 goto err_mode_config_cleanup;
110 106
111 /* Probe non kms sub drivers and virtual display driver. */ 107 ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
112 ret = exynos_drm_device_subdrv_probe(dev);
113 if (ret) 108 if (ret)
114 goto err_unbind_all; 109 goto err_unbind_all;
115 110
116 /* force connectors detection */ 111 /* Probe non kms sub drivers and virtual display driver. */
117 drm_helper_hpd_irq_event(dev); 112 ret = exynos_drm_device_subdrv_probe(dev);
113 if (ret)
114 goto err_cleanup_vblank;
118 115
119 /* 116 /*
120 * enable drm irq mode. 117 * enable drm irq mode.
@@ -133,12 +130,18 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
133 */ 130 */
134 dev->vblank_disable_allowed = true; 131 dev->vblank_disable_allowed = true;
135 132
133 /* init kms poll for handling hpd */
134 drm_kms_helper_poll_init(dev);
135
136 /* force connectors detection */
137 drm_helper_hpd_irq_event(dev);
138
136 return 0; 139 return 0;
137 140
138err_unbind_all:
139 component_unbind_all(dev->dev, dev);
140err_cleanup_vblank: 141err_cleanup_vblank:
141 drm_vblank_cleanup(dev); 142 drm_vblank_cleanup(dev);
143err_unbind_all:
144 component_unbind_all(dev->dev, dev);
142err_mode_config_cleanup: 145err_mode_config_cleanup:
143 drm_mode_config_cleanup(dev); 146 drm_mode_config_cleanup(dev);
144 drm_release_iommu_mapping(dev); 147 drm_release_iommu_mapping(dev);
@@ -155,8 +158,8 @@ static int exynos_drm_unload(struct drm_device *dev)
155 exynos_drm_fbdev_fini(dev); 158 exynos_drm_fbdev_fini(dev);
156 drm_kms_helper_poll_fini(dev); 159 drm_kms_helper_poll_fini(dev);
157 160
158 component_unbind_all(dev->dev, dev);
159 drm_vblank_cleanup(dev); 161 drm_vblank_cleanup(dev);
162 component_unbind_all(dev->dev, dev);
160 drm_mode_config_cleanup(dev); 163 drm_mode_config_cleanup(dev);
161 drm_release_iommu_mapping(dev); 164 drm_release_iommu_mapping(dev);
162 165
@@ -191,8 +194,12 @@ static int exynos_drm_resume(struct drm_device *dev)
191 194
192 drm_modeset_lock_all(dev); 195 drm_modeset_lock_all(dev);
193 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 196 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
194 if (connector->funcs->dpms) 197 if (connector->funcs->dpms) {
195 connector->funcs->dpms(connector, connector->dpms); 198 int dpms = connector->dpms;
199
200 connector->dpms = DRM_MODE_DPMS_OFF;
201 connector->funcs->dpms(connector, dpms);
202 }
196 } 203 }
197 drm_modeset_unlock_all(dev); 204 drm_modeset_unlock_all(dev);
198 205
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 24741d8758e8..acf7e9e39dcd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1660,13 +1660,9 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master,
1660 void *data) 1660 void *data)
1661{ 1661{
1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx; 1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx;
1663 struct drm_encoder *encoder = dsi->encoder;
1664 1663
1665 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF); 1664 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF);
1666 1665
1667 exynos_dsi_connector_destroy(&dsi->connector);
1668 encoder->funcs->destroy(encoder);
1669
1670 mipi_dsi_host_unregister(&dsi->dsi_host); 1666 mipi_dsi_host_unregister(&dsi->dsi_host);
1671} 1667}
1672 1668
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index d565207040a2..50faf913e574 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -630,7 +630,6 @@ static int vidi_remove(struct platform_device *pdev)
630{ 630{
631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev); 631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev);
632 struct vidi_context *ctx = mgr->ctx; 632 struct vidi_context *ctx = mgr->ctx;
633 struct drm_encoder *encoder = ctx->encoder;
634 633
635 if (ctx->raw_edid != (struct edid *)fake_edid_info) { 634 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
636 kfree(ctx->raw_edid); 635 kfree(ctx->raw_edid);
@@ -639,9 +638,6 @@ static int vidi_remove(struct platform_device *pdev)
639 return -EINVAL; 638 return -EINVAL;
640 } 639 }
641 640
642 encoder->funcs->destroy(encoder);
643 drm_connector_cleanup(&ctx->connector);
644
645 return 0; 641 return 0;
646} 642}
647 643
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 7910fb37d9bb..563a19e62eb2 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2312,12 +2312,6 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
2312 2312
2313static void hdmi_unbind(struct device *dev, struct device *master, void *data) 2313static void hdmi_unbind(struct device *dev, struct device *master, void *data)
2314{ 2314{
2315 struct exynos_drm_display *display = get_hdmi_display(dev);
2316 struct drm_encoder *encoder = display->encoder;
2317 struct hdmi_context *hdata = display->ctx;
2318
2319 hdmi_connector_destroy(&hdata->connector);
2320 encoder->funcs->destroy(encoder);
2321} 2315}
2322 2316
2323static const struct component_ops hdmi_component_ops = { 2317static const struct component_ops hdmi_component_ops = {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 3201986bf25e..f66392b6e287 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1711,7 +1711,7 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
1711#define HPD_STORM_DETECT_PERIOD 1000 1711#define HPD_STORM_DETECT_PERIOD 1000
1712#define HPD_STORM_THRESHOLD 5 1712#define HPD_STORM_THRESHOLD 5
1713 1713
1714static int ilk_port_to_hotplug_shift(enum port port) 1714static int pch_port_to_hotplug_shift(enum port port)
1715{ 1715{
1716 switch (port) { 1716 switch (port) {
1717 case PORT_A: 1717 case PORT_A:
@@ -1727,7 +1727,7 @@ static int ilk_port_to_hotplug_shift(enum port port)
1727 } 1727 }
1728} 1728}
1729 1729
1730static int g4x_port_to_hotplug_shift(enum port port) 1730static int i915_port_to_hotplug_shift(enum port port)
1731{ 1731{
1732 switch (port) { 1732 switch (port) {
1733 case PORT_A: 1733 case PORT_A:
@@ -1785,12 +1785,12 @@ static inline void intel_hpd_irq_handler(struct drm_device *dev,
1785 if (port && dev_priv->hpd_irq_port[port]) { 1785 if (port && dev_priv->hpd_irq_port[port]) {
1786 bool long_hpd; 1786 bool long_hpd;
1787 1787
1788 if (IS_G4X(dev)) { 1788 if (HAS_PCH_SPLIT(dev)) {
1789 dig_shift = g4x_port_to_hotplug_shift(port); 1789 dig_shift = pch_port_to_hotplug_shift(port);
1790 long_hpd = (hotplug_trigger >> dig_shift) & PORTB_HOTPLUG_LONG_DETECT;
1791 } else {
1792 dig_shift = ilk_port_to_hotplug_shift(port);
1793 long_hpd = (dig_hotplug_reg >> dig_shift) & PORTB_HOTPLUG_LONG_DETECT; 1790 long_hpd = (dig_hotplug_reg >> dig_shift) & PORTB_HOTPLUG_LONG_DETECT;
1791 } else {
1792 dig_shift = i915_port_to_hotplug_shift(port);
1793 long_hpd = (hotplug_trigger >> dig_shift) & PORTB_HOTPLUG_LONG_DETECT;
1794 } 1794 }
1795 1795
1796 DRM_DEBUG_DRIVER("digital hpd port %c - %s\n", 1796 DRM_DEBUG_DRIVER("digital hpd port %c - %s\n",
@@ -3458,12 +3458,13 @@ static void gen8_irq_reset(struct drm_device *dev)
3458void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv) 3458void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv)
3459{ 3459{
3460 unsigned long irqflags; 3460 unsigned long irqflags;
3461 uint32_t extra_ier = GEN8_PIPE_VBLANK | GEN8_PIPE_FIFO_UNDERRUN;
3461 3462
3462 spin_lock_irqsave(&dev_priv->irq_lock, irqflags); 3463 spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
3463 GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_B, dev_priv->de_irq_mask[PIPE_B], 3464 GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_B, dev_priv->de_irq_mask[PIPE_B],
3464 ~dev_priv->de_irq_mask[PIPE_B]); 3465 ~dev_priv->de_irq_mask[PIPE_B] | extra_ier);
3465 GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_C, dev_priv->de_irq_mask[PIPE_C], 3466 GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_C, dev_priv->de_irq_mask[PIPE_C],
3466 ~dev_priv->de_irq_mask[PIPE_C]); 3467 ~dev_priv->de_irq_mask[PIPE_C] | extra_ier);
3467 spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); 3468 spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
3468} 3469}
3469 3470
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 507370513f3d..f0a1a56406eb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -73,9 +73,6 @@ static const uint32_t intel_cursor_formats[] = {
73 DRM_FORMAT_ARGB8888, 73 DRM_FORMAT_ARGB8888,
74}; 74};
75 75
76#define DIV_ROUND_CLOSEST_ULL(ll, d) \
77({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; })
78
79static void intel_increase_pllclock(struct drm_device *dev, 76static void intel_increase_pllclock(struct drm_device *dev,
80 enum pipe pipe); 77 enum pipe pipe);
81static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on); 78static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on);
@@ -4588,7 +4585,7 @@ static void vlv_update_cdclk(struct drm_device *dev)
4588 * BSpec erroneously claims we should aim for 4MHz, but 4585 * BSpec erroneously claims we should aim for 4MHz, but
4589 * in fact 1MHz is the correct frequency. 4586 * in fact 1MHz is the correct frequency.
4590 */ 4587 */
4591 I915_WRITE(GMBUSFREQ_VLV, dev_priv->vlv_cdclk_freq); 4588 I915_WRITE(GMBUSFREQ_VLV, DIV_ROUND_UP(dev_priv->vlv_cdclk_freq, 1000));
4592} 4589}
4593 4590
4594/* Adjust CDclk dividers to allow high res or save power if possible */ 4591/* Adjust CDclk dividers to allow high res or save power if possible */
@@ -12357,27 +12354,36 @@ static void intel_setup_outputs(struct drm_device *dev)
12357 if (I915_READ(PCH_DP_D) & DP_DETECTED) 12354 if (I915_READ(PCH_DP_D) & DP_DETECTED)
12358 intel_dp_init(dev, PCH_DP_D, PORT_D); 12355 intel_dp_init(dev, PCH_DP_D, PORT_D);
12359 } else if (IS_VALLEYVIEW(dev)) { 12356 } else if (IS_VALLEYVIEW(dev)) {
12360 if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) { 12357 /*
12358 * The DP_DETECTED bit is the latched state of the DDC
12359 * SDA pin at boot. However since eDP doesn't require DDC
12360 * (no way to plug in a DP->HDMI dongle) the DDC pins for
12361 * eDP ports may have been muxed to an alternate function.
12362 * Thus we can't rely on the DP_DETECTED bit alone to detect
12363 * eDP ports. Consult the VBT as well as DP_DETECTED to
12364 * detect eDP ports.
12365 */
12366 if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED)
12361 intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB, 12367 intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB,
12362 PORT_B); 12368 PORT_B);
12363 if (I915_READ(VLV_DISPLAY_BASE + DP_B) & DP_DETECTED) 12369 if (I915_READ(VLV_DISPLAY_BASE + DP_B) & DP_DETECTED ||
12364 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_B, PORT_B); 12370 intel_dp_is_edp(dev, PORT_B))
12365 } 12371 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_B, PORT_B);
12366 12372
12367 if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED) { 12373 if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED)
12368 intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, 12374 intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC,
12369 PORT_C); 12375 PORT_C);
12370 if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED) 12376 if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED ||
12371 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C); 12377 intel_dp_is_edp(dev, PORT_C))
12372 } 12378 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C);
12373 12379
12374 if (IS_CHERRYVIEW(dev)) { 12380 if (IS_CHERRYVIEW(dev)) {
12375 if (I915_READ(VLV_DISPLAY_BASE + CHV_HDMID) & SDVO_DETECTED) { 12381 if (I915_READ(VLV_DISPLAY_BASE + CHV_HDMID) & SDVO_DETECTED)
12376 intel_hdmi_init(dev, VLV_DISPLAY_BASE + CHV_HDMID, 12382 intel_hdmi_init(dev, VLV_DISPLAY_BASE + CHV_HDMID,
12377 PORT_D); 12383 PORT_D);
12378 if (I915_READ(VLV_DISPLAY_BASE + DP_D) & DP_DETECTED) 12384 /* eDP not supported on port D, so don't check VBT */
12379 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_D, PORT_D); 12385 if (I915_READ(VLV_DISPLAY_BASE + DP_D) & DP_DETECTED)
12380 } 12386 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_D, PORT_D);
12381 } 12387 }
12382 12388
12383 intel_dsi_init(dev); 12389 intel_dsi_init(dev);
@@ -12879,6 +12885,9 @@ static struct intel_quirk intel_quirks[] = {
12879 /* Acer C720 Chromebook (Core i3 4005U) */ 12885 /* Acer C720 Chromebook (Core i3 4005U) */
12880 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present }, 12886 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present },
12881 12887
12888 /* Apple Macbook 2,1 (Core 2 T7400) */
12889 { 0x27a2, 0x8086, 0x7270, quirk_backlight_present },
12890
12882 /* Toshiba CB35 Chromebook (Celeron 2955U) */ 12891 /* Toshiba CB35 Chromebook (Celeron 2955U) */
12883 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, 12892 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present },
12884 12893
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f6a3fdd5589e..5ad45bfff3fe 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2806,6 +2806,13 @@ intel_dp_dpcd_read_wake(struct drm_dp_aux *aux, unsigned int offset,
2806 ssize_t ret; 2806 ssize_t ret;
2807 int i; 2807 int i;
2808 2808
2809 /*
2810 * Sometime we just get the same incorrect byte repeated
2811 * over the entire buffer. Doing just one throw away read
2812 * initially seems to "solve" it.
2813 */
2814 drm_dp_dpcd_read(aux, DP_DPCD_REV, buffer, 1);
2815
2809 for (i = 0; i < 3; i++) { 2816 for (i = 0; i < 3; i++) {
2810 ret = drm_dp_dpcd_read(aux, offset, buffer, size); 2817 ret = drm_dp_dpcd_read(aux, offset, buffer, size);
2811 if (ret == size) 2818 if (ret == size)
@@ -3724,9 +3731,10 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
3724 } 3731 }
3725 } 3732 }
3726 3733
3727 /* Training Pattern 3 support */ 3734 /* Training Pattern 3 support, both source and sink */
3728 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x12 && 3735 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x12 &&
3729 intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED) { 3736 intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED &&
3737 (IS_HASWELL(dev_priv) || INTEL_INFO(dev_priv)->gen >= 8)) {
3730 intel_dp->use_tps3 = true; 3738 intel_dp->use_tps3 = true;
3731 DRM_DEBUG_KMS("Displayport TPS3 supported\n"); 3739 DRM_DEBUG_KMS("Displayport TPS3 supported\n");
3732 } else 3740 } else
@@ -4491,6 +4499,18 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
4491 if (intel_dig_port->base.type != INTEL_OUTPUT_EDP) 4499 if (intel_dig_port->base.type != INTEL_OUTPUT_EDP)
4492 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT; 4500 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT;
4493 4501
4502 if (long_hpd && intel_dig_port->base.type == INTEL_OUTPUT_EDP) {
4503 /*
4504 * vdd off can generate a long pulse on eDP which
4505 * would require vdd on to handle it, and thus we
4506 * would end up in an endless cycle of
4507 * "vdd off -> long hpd -> vdd on -> detect -> vdd off -> ..."
4508 */
4509 DRM_DEBUG_KMS("ignoring long hpd on eDP port %c\n",
4510 port_name(intel_dig_port->port));
4511 return false;
4512 }
4513
4494 DRM_DEBUG_KMS("got hpd irq on port %c - %s\n", 4514 DRM_DEBUG_KMS("got hpd irq on port %c - %s\n",
4495 port_name(intel_dig_port->port), 4515 port_name(intel_dig_port->port),
4496 long_hpd ? "long" : "short"); 4516 long_hpd ? "long" : "short");
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 07ce04683c30..ba715229a540 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -35,6 +35,9 @@
35#include <drm/drm_fb_helper.h> 35#include <drm/drm_fb_helper.h>
36#include <drm/drm_dp_mst_helper.h> 36#include <drm/drm_dp_mst_helper.h>
37 37
38#define DIV_ROUND_CLOSEST_ULL(ll, d) \
39({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; })
40
38/** 41/**
39 * _wait_for - magic (register) wait macro 42 * _wait_for - magic (register) wait macro
40 * 43 *
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 18784470a760..0e018cb49147 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -419,9 +419,8 @@ static uint32_t scale(uint32_t source_val,
419 source_val = clamp(source_val, source_min, source_max); 419 source_val = clamp(source_val, source_min, source_max);
420 420
421 /* avoid overflows */ 421 /* avoid overflows */
422 target_val = (uint64_t)(source_val - source_min) * 422 target_val = DIV_ROUND_CLOSEST_ULL((uint64_t)(source_val - source_min) *
423 (target_max - target_min); 423 (target_max - target_min), source_max - source_min);
424 do_div(target_val, source_max - source_min);
425 target_val += target_min; 424 target_val += target_min;
426 425
427 return target_val; 426 return target_val;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv50.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv50.c
index 552fdbd45ebe..1d0e33fb5f61 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv50.c
@@ -113,6 +113,8 @@
113#define IS_NVA3F(x) (((x) > 0xa0 && (x) < 0xaa) || (x) == 0xaf) 113#define IS_NVA3F(x) (((x) > 0xa0 && (x) < 0xaa) || (x) == 0xaf)
114#define IS_NVAAF(x) ((x) >= 0xaa && (x) <= 0xac) 114#define IS_NVAAF(x) ((x) >= 0xaa && (x) <= 0xac)
115 115
116#include <subdev/fb.h>
117
116/* 118/*
117 * This code deals with PGRAPH contexts on NV50 family cards. Like NV40, it's 119 * This code deals with PGRAPH contexts on NV50 family cards. Like NV40, it's
118 * the GPU itself that does context-switching, but it needs a special 120 * the GPU itself that does context-switching, but it needs a special
@@ -569,8 +571,12 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
569 gr_def(ctx, 0x407d08, 0x00010040); 571 gr_def(ctx, 0x407d08, 0x00010040);
570 else if (device->chipset < 0xa0) 572 else if (device->chipset < 0xa0)
571 gr_def(ctx, 0x407d08, 0x00390040); 573 gr_def(ctx, 0x407d08, 0x00390040);
572 else 574 else {
573 gr_def(ctx, 0x407d08, 0x003d0040); 575 if (nouveau_fb(device)->ram->type != NV_MEM_TYPE_GDDR5)
576 gr_def(ctx, 0x407d08, 0x003d0040);
577 else
578 gr_def(ctx, 0x407d08, 0x003c0040);
579 }
574 gr_def(ctx, 0x407d0c, 0x00000022); 580 gr_def(ctx, 0x407d0c, 0x00000022);
575 } 581 }
576 582
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 589dbb582da2..fd3dbd59d73e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -400,15 +400,20 @@ nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
400 struct nouveau_channel **pchan) 400 struct nouveau_channel **pchan)
401{ 401{
402 struct nouveau_cli *cli = (void *)nvif_client(&device->base); 402 struct nouveau_cli *cli = (void *)nvif_client(&device->base);
403 bool super;
403 int ret; 404 int ret;
404 405
406 /* hack until fencenv50 is fixed, and agp access relaxed */
407 super = cli->base.super;
408 cli->base.super = true;
409
405 ret = nouveau_channel_ind(drm, device, handle, arg0, pchan); 410 ret = nouveau_channel_ind(drm, device, handle, arg0, pchan);
406 if (ret) { 411 if (ret) {
407 NV_PRINTK(debug, cli, "ib channel create, %d\n", ret); 412 NV_PRINTK(debug, cli, "ib channel create, %d\n", ret);
408 ret = nouveau_channel_dma(drm, device, handle, pchan); 413 ret = nouveau_channel_dma(drm, device, handle, pchan);
409 if (ret) { 414 if (ret) {
410 NV_PRINTK(debug, cli, "dma channel create, %d\n", ret); 415 NV_PRINTK(debug, cli, "dma channel create, %d\n", ret);
411 return ret; 416 goto done;
412 } 417 }
413 } 418 }
414 419
@@ -416,8 +421,9 @@ nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
416 if (ret) { 421 if (ret) {
417 NV_PRINTK(error, cli, "channel failed to initialise, %d\n", ret); 422 NV_PRINTK(error, cli, "channel failed to initialise, %d\n", ret);
418 nouveau_channel_del(pchan); 423 nouveau_channel_del(pchan);
419 return ret;
420 } 424 }
421 425
422 return 0; 426done:
427 cli->base.super = super;
428 return ret;
423} 429}
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index af9e78546688..0d1396266857 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -572,7 +572,6 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
572 struct qxl_framebuffer *qfb; 572 struct qxl_framebuffer *qfb;
573 struct qxl_bo *bo, *old_bo = NULL; 573 struct qxl_bo *bo, *old_bo = NULL;
574 struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); 574 struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
575 uint32_t width, height, base_offset;
576 bool recreate_primary = false; 575 bool recreate_primary = false;
577 int ret; 576 int ret;
578 int surf_id; 577 int surf_id;
@@ -602,9 +601,10 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
602 if (qcrtc->index == 0) 601 if (qcrtc->index == 0)
603 recreate_primary = true; 602 recreate_primary = true;
604 603
605 width = mode->hdisplay; 604 if (bo->surf.stride * bo->surf.height > qdev->vram_size) {
606 height = mode->vdisplay; 605 DRM_ERROR("Mode doesn't fit in vram size (vgamem)");
607 base_offset = 0; 606 return -EINVAL;
607 }
608 608
609 ret = qxl_bo_reserve(bo, false); 609 ret = qxl_bo_reserve(bo, false);
610 if (ret != 0) 610 if (ret != 0)
@@ -618,10 +618,10 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
618 if (recreate_primary) { 618 if (recreate_primary) {
619 qxl_io_destroy_primary(qdev); 619 qxl_io_destroy_primary(qdev);
620 qxl_io_log(qdev, 620 qxl_io_log(qdev,
621 "recreate primary: %dx%d (was %dx%d,%d,%d)\n", 621 "recreate primary: %dx%d,%d,%d\n",
622 width, height, bo->surf.width, 622 bo->surf.width, bo->surf.height,
623 bo->surf.height, bo->surf.stride, bo->surf.format); 623 bo->surf.stride, bo->surf.format);
624 qxl_io_create_primary(qdev, base_offset, bo); 624 qxl_io_create_primary(qdev, 0, bo);
625 bo->is_primary = true; 625 bo->is_primary = true;
626 } 626 }
627 627
diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c
index 300d971187c4..0b2929de9f41 100644
--- a/drivers/gpu/drm/radeon/btc_dpm.c
+++ b/drivers/gpu/drm/radeon/btc_dpm.c
@@ -24,6 +24,7 @@
24 24
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "btcd.h" 28#include "btcd.h"
28#include "r600_dpm.h" 29#include "r600_dpm.h"
29#include "cypress_dpm.h" 30#include "cypress_dpm.h"
@@ -1170,6 +1171,23 @@ static const struct radeon_blacklist_clocks btc_blacklist_clocks[] =
1170 { 25000, 30000, RADEON_SCLK_UP } 1171 { 25000, 30000, RADEON_SCLK_UP }
1171}; 1172};
1172 1173
1174void btc_get_max_clock_from_voltage_dependency_table(struct radeon_clock_voltage_dependency_table *table,
1175 u32 *max_clock)
1176{
1177 u32 i, clock = 0;
1178
1179 if ((table == NULL) || (table->count == 0)) {
1180 *max_clock = clock;
1181 return;
1182 }
1183
1184 for (i = 0; i < table->count; i++) {
1185 if (clock < table->entries[i].clk)
1186 clock = table->entries[i].clk;
1187 }
1188 *max_clock = clock;
1189}
1190
1173void btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table, 1191void btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table,
1174 u32 clock, u16 max_voltage, u16 *voltage) 1192 u32 clock, u16 max_voltage, u16 *voltage)
1175{ 1193{
diff --git a/drivers/gpu/drm/radeon/btc_dpm.h b/drivers/gpu/drm/radeon/btc_dpm.h
index 1a15e0e41950..3b6f12b7760b 100644
--- a/drivers/gpu/drm/radeon/btc_dpm.h
+++ b/drivers/gpu/drm/radeon/btc_dpm.h
@@ -46,6 +46,8 @@ void btc_adjust_clock_combinations(struct radeon_device *rdev,
46 struct rv7xx_pl *pl); 46 struct rv7xx_pl *pl);
47void btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table, 47void btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table,
48 u32 clock, u16 max_voltage, u16 *voltage); 48 u32 clock, u16 max_voltage, u16 *voltage);
49void btc_get_max_clock_from_voltage_dependency_table(struct radeon_clock_voltage_dependency_table *table,
50 u32 *max_clock);
49void btc_apply_voltage_delta_rules(struct radeon_device *rdev, 51void btc_apply_voltage_delta_rules(struct radeon_device *rdev,
50 u16 max_vddc, u16 max_vddci, 52 u16 max_vddc, u16 max_vddci,
51 u16 *vddc, u16 *vddci); 53 u16 *vddc, u16 *vddci);
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index f5c8c0445a94..11a55e9dad7f 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -24,6 +24,7 @@
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "radeon_ucode.h" 28#include "radeon_ucode.h"
28#include "cikd.h" 29#include "cikd.h"
29#include "r600_dpm.h" 30#include "r600_dpm.h"
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c
index c77dad1a4576..4e8432d07f15 100644
--- a/drivers/gpu/drm/radeon/cik_sdma.c
+++ b/drivers/gpu/drm/radeon/cik_sdma.c
@@ -611,16 +611,19 @@ int cik_sdma_ring_test(struct radeon_device *rdev,
611{ 611{
612 unsigned i; 612 unsigned i;
613 int r; 613 int r;
614 void __iomem *ptr = (void *)rdev->vram_scratch.ptr; 614 unsigned index;
615 u32 tmp; 615 u32 tmp;
616 u64 gpu_addr;
616 617
617 if (!ptr) { 618 if (ring->idx == R600_RING_TYPE_DMA_INDEX)
618 DRM_ERROR("invalid vram scratch pointer\n"); 619 index = R600_WB_DMA_RING_TEST_OFFSET;
619 return -EINVAL; 620 else
620 } 621 index = CAYMAN_WB_DMA1_RING_TEST_OFFSET;
622
623 gpu_addr = rdev->wb.gpu_addr + index;
621 624
622 tmp = 0xCAFEDEAD; 625 tmp = 0xCAFEDEAD;
623 writel(tmp, ptr); 626 rdev->wb.wb[index/4] = cpu_to_le32(tmp);
624 627
625 r = radeon_ring_lock(rdev, ring, 5); 628 r = radeon_ring_lock(rdev, ring, 5);
626 if (r) { 629 if (r) {
@@ -628,14 +631,14 @@ int cik_sdma_ring_test(struct radeon_device *rdev,
628 return r; 631 return r;
629 } 632 }
630 radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0)); 633 radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0));
631 radeon_ring_write(ring, rdev->vram_scratch.gpu_addr & 0xfffffffc); 634 radeon_ring_write(ring, lower_32_bits(gpu_addr));
632 radeon_ring_write(ring, upper_32_bits(rdev->vram_scratch.gpu_addr)); 635 radeon_ring_write(ring, upper_32_bits(gpu_addr));
633 radeon_ring_write(ring, 1); /* number of DWs to follow */ 636 radeon_ring_write(ring, 1); /* number of DWs to follow */
634 radeon_ring_write(ring, 0xDEADBEEF); 637 radeon_ring_write(ring, 0xDEADBEEF);
635 radeon_ring_unlock_commit(rdev, ring, false); 638 radeon_ring_unlock_commit(rdev, ring, false);
636 639
637 for (i = 0; i < rdev->usec_timeout; i++) { 640 for (i = 0; i < rdev->usec_timeout; i++) {
638 tmp = readl(ptr); 641 tmp = le32_to_cpu(rdev->wb.wb[index/4]);
639 if (tmp == 0xDEADBEEF) 642 if (tmp == 0xDEADBEEF)
640 break; 643 break;
641 DRM_UDELAY(1); 644 DRM_UDELAY(1);
diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c
index 47d31e915758..9aad0327e4d1 100644
--- a/drivers/gpu/drm/radeon/cypress_dpm.c
+++ b/drivers/gpu/drm/radeon/cypress_dpm.c
@@ -24,6 +24,7 @@
24 24
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "evergreend.h" 28#include "evergreend.h"
28#include "r600_dpm.h" 29#include "r600_dpm.h"
29#include "cypress_dpm.h" 30#include "cypress_dpm.h"
diff --git a/drivers/gpu/drm/radeon/dce3_1_afmt.c b/drivers/gpu/drm/radeon/dce3_1_afmt.c
index 950af153f30e..2fe8cfc966d9 100644
--- a/drivers/gpu/drm/radeon/dce3_1_afmt.c
+++ b/drivers/gpu/drm/radeon/dce3_1_afmt.c
@@ -32,7 +32,7 @@ static void dce3_2_afmt_write_speaker_allocation(struct drm_encoder *encoder)
32 struct drm_connector *connector; 32 struct drm_connector *connector;
33 struct radeon_connector *radeon_connector = NULL; 33 struct radeon_connector *radeon_connector = NULL;
34 u32 tmp; 34 u32 tmp;
35 u8 *sadb; 35 u8 *sadb = NULL;
36 int sad_count; 36 int sad_count;
37 37
38 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { 38 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) {
@@ -49,8 +49,8 @@ static void dce3_2_afmt_write_speaker_allocation(struct drm_encoder *encoder)
49 49
50 sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); 50 sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb);
51 if (sad_count < 0) { 51 if (sad_count < 0) {
52 DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); 52 DRM_DEBUG("Couldn't read Speaker Allocation Data Block: %d\n", sad_count);
53 return; 53 sad_count = 0;
54 } 54 }
55 55
56 /* program the speaker allocation */ 56 /* program the speaker allocation */
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c
index c0bbf68dbc27..f312edf4d50e 100644
--- a/drivers/gpu/drm/radeon/dce6_afmt.c
+++ b/drivers/gpu/drm/radeon/dce6_afmt.c
@@ -155,7 +155,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)
155 struct drm_connector *connector; 155 struct drm_connector *connector;
156 struct radeon_connector *radeon_connector = NULL; 156 struct radeon_connector *radeon_connector = NULL;
157 u32 offset, tmp; 157 u32 offset, tmp;
158 u8 *sadb; 158 u8 *sadb = NULL;
159 int sad_count; 159 int sad_count;
160 160
161 if (!dig || !dig->afmt || !dig->afmt->pin) 161 if (!dig || !dig->afmt || !dig->afmt->pin)
@@ -176,9 +176,9 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)
176 } 176 }
177 177
178 sad_count = drm_edid_to_speaker_allocation(radeon_connector_edid(connector), &sadb); 178 sad_count = drm_edid_to_speaker_allocation(radeon_connector_edid(connector), &sadb);
179 if (sad_count <= 0) { 179 if (sad_count < 0) {
180 DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); 180 DRM_DEBUG("Couldn't read Speaker Allocation Data Block: %d\n", sad_count);
181 return; 181 sad_count = 0;
182 } 182 }
183 183
184 /* program the speaker allocation */ 184 /* program the speaker allocation */
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a31f1ca40c6a..f37d39d2bbbc 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3005,7 +3005,7 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3005 u32 vgt_cache_invalidation; 3005 u32 vgt_cache_invalidation;
3006 u32 hdp_host_path_cntl, tmp; 3006 u32 hdp_host_path_cntl, tmp;
3007 u32 disabled_rb_mask; 3007 u32 disabled_rb_mask;
3008 int i, j, num_shader_engines, ps_thread_count; 3008 int i, j, ps_thread_count;
3009 3009
3010 switch (rdev->family) { 3010 switch (rdev->family) {
3011 case CHIP_CYPRESS: 3011 case CHIP_CYPRESS:
@@ -3303,8 +3303,6 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3303 rdev->config.evergreen.tile_config |= 3303 rdev->config.evergreen.tile_config |=
3304 ((gb_addr_config & 0x30000000) >> 28) << 12; 3304 ((gb_addr_config & 0x30000000) >> 28) << 12;
3305 3305
3306 num_shader_engines = (gb_addr_config & NUM_SHADER_ENGINES(3) >> 12) + 1;
3307
3308 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) { 3306 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) {
3309 u32 efuse_straps_4; 3307 u32 efuse_straps_4;
3310 u32 efuse_straps_3; 3308 u32 efuse_straps_3;
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index 2514d659b1ba..53abd9b17a50 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -133,7 +133,7 @@ static void dce4_afmt_write_speaker_allocation(struct drm_encoder *encoder)
133 struct drm_connector *connector; 133 struct drm_connector *connector;
134 struct radeon_connector *radeon_connector = NULL; 134 struct radeon_connector *radeon_connector = NULL;
135 u32 tmp; 135 u32 tmp;
136 u8 *sadb; 136 u8 *sadb = NULL;
137 int sad_count; 137 int sad_count;
138 138
139 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { 139 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) {
@@ -149,9 +149,9 @@ static void dce4_afmt_write_speaker_allocation(struct drm_encoder *encoder)
149 } 149 }
150 150
151 sad_count = drm_edid_to_speaker_allocation(radeon_connector_edid(connector), &sadb); 151 sad_count = drm_edid_to_speaker_allocation(radeon_connector_edid(connector), &sadb);
152 if (sad_count <= 0) { 152 if (sad_count < 0) {
153 DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); 153 DRM_DEBUG("Couldn't read Speaker Allocation Data Block: %d\n", sad_count);
154 return; 154 sad_count = 0;
155 } 155 }
156 156
157 /* program the speaker allocation */ 157 /* program the speaker allocation */
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index 1dd976f447fa..9b42001295ba 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -2725,7 +2725,11 @@ int kv_dpm_init(struct radeon_device *rdev)
2725 2725
2726 pi->sram_end = SMC_RAM_END; 2726 pi->sram_end = SMC_RAM_END;
2727 2727
2728 pi->enable_nb_dpm = true; 2728 /* Enabling nb dpm on an asrock system prevents dpm from working */
2729 if (rdev->pdev->subsystem_vendor == 0x1849)
2730 pi->enable_nb_dpm = false;
2731 else
2732 pi->enable_nb_dpm = true;
2729 2733
2730 pi->caps_power_containment = true; 2734 pi->caps_power_containment = true;
2731 pi->caps_cac = true; 2735 pi->caps_cac = true;
@@ -2740,10 +2744,19 @@ int kv_dpm_init(struct radeon_device *rdev)
2740 pi->caps_sclk_ds = true; 2744 pi->caps_sclk_ds = true;
2741 pi->enable_auto_thermal_throttling = true; 2745 pi->enable_auto_thermal_throttling = true;
2742 pi->disable_nb_ps3_in_battery = false; 2746 pi->disable_nb_ps3_in_battery = false;
2743 if (radeon_bapm == 0) 2747 if (radeon_bapm == -1) {
2748 /* There are stability issues reported on with
2749 * bapm enabled on an asrock system.
2750 */
2751 if (rdev->pdev->subsystem_vendor == 0x1849)
2752 pi->bapm_enable = false;
2753 else
2754 pi->bapm_enable = true;
2755 } else if (radeon_bapm == 0) {
2744 pi->bapm_enable = false; 2756 pi->bapm_enable = false;
2745 else 2757 } else {
2746 pi->bapm_enable = true; 2758 pi->bapm_enable = true;
2759 }
2747 pi->voltage_drop_t = 0; 2760 pi->voltage_drop_t = 0;
2748 pi->caps_sclk_throttle_low_notification = false; 2761 pi->caps_sclk_throttle_low_notification = false;
2749 pi->caps_fps = false; /* true? */ 2762 pi->caps_fps = false; /* true? */
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index 715b181c6243..6d2f16cf2c1c 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -23,6 +23,7 @@
23 23
24#include "drmP.h" 24#include "drmP.h"
25#include "radeon.h" 25#include "radeon.h"
26#include "radeon_asic.h"
26#include "nid.h" 27#include "nid.h"
27#include "r600_dpm.h" 28#include "r600_dpm.h"
28#include "ni_dpm.h" 29#include "ni_dpm.h"
diff --git a/drivers/gpu/drm/radeon/r600_dma.c b/drivers/gpu/drm/radeon/r600_dma.c
index 100189ec5fa8..aabc343b9a8f 100644
--- a/drivers/gpu/drm/radeon/r600_dma.c
+++ b/drivers/gpu/drm/radeon/r600_dma.c
@@ -232,16 +232,19 @@ int r600_dma_ring_test(struct radeon_device *rdev,
232{ 232{
233 unsigned i; 233 unsigned i;
234 int r; 234 int r;
235 void __iomem *ptr = (void *)rdev->vram_scratch.ptr; 235 unsigned index;
236 u32 tmp; 236 u32 tmp;
237 u64 gpu_addr;
237 238
238 if (!ptr) { 239 if (ring->idx == R600_RING_TYPE_DMA_INDEX)
239 DRM_ERROR("invalid vram scratch pointer\n"); 240 index = R600_WB_DMA_RING_TEST_OFFSET;
240 return -EINVAL; 241 else
241 } 242 index = CAYMAN_WB_DMA1_RING_TEST_OFFSET;
243
244 gpu_addr = rdev->wb.gpu_addr + index;
242 245
243 tmp = 0xCAFEDEAD; 246 tmp = 0xCAFEDEAD;
244 writel(tmp, ptr); 247 rdev->wb.wb[index/4] = cpu_to_le32(tmp);
245 248
246 r = radeon_ring_lock(rdev, ring, 4); 249 r = radeon_ring_lock(rdev, ring, 4);
247 if (r) { 250 if (r) {
@@ -249,13 +252,13 @@ int r600_dma_ring_test(struct radeon_device *rdev,
249 return r; 252 return r;
250 } 253 }
251 radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 1)); 254 radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 1));
252 radeon_ring_write(ring, rdev->vram_scratch.gpu_addr & 0xfffffffc); 255 radeon_ring_write(ring, lower_32_bits(gpu_addr));
253 radeon_ring_write(ring, upper_32_bits(rdev->vram_scratch.gpu_addr) & 0xff); 256 radeon_ring_write(ring, upper_32_bits(gpu_addr) & 0xff);
254 radeon_ring_write(ring, 0xDEADBEEF); 257 radeon_ring_write(ring, 0xDEADBEEF);
255 radeon_ring_unlock_commit(rdev, ring, false); 258 radeon_ring_unlock_commit(rdev, ring, false);
256 259
257 for (i = 0; i < rdev->usec_timeout; i++) { 260 for (i = 0; i < rdev->usec_timeout; i++) {
258 tmp = readl(ptr); 261 tmp = le32_to_cpu(rdev->wb.wb[index/4]);
259 if (tmp == 0xDEADBEEF) 262 if (tmp == 0xDEADBEEF)
260 break; 263 break;
261 DRM_UDELAY(1); 264 DRM_UDELAY(1);
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index 9c61b74ef441..f6309bd23e01 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -24,6 +24,7 @@
24 24
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "r600d.h" 28#include "r600d.h"
28#include "r600_dpm.h" 29#include "r600_dpm.h"
29#include "atom.h" 30#include "atom.h"
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index f7c4b226a284..a9717b3fbf1b 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1133,6 +1133,8 @@ struct radeon_wb {
1133#define R600_WB_EVENT_OFFSET 3072 1133#define R600_WB_EVENT_OFFSET 3072
1134#define CIK_WB_CP1_WPTR_OFFSET 3328 1134#define CIK_WB_CP1_WPTR_OFFSET 3328
1135#define CIK_WB_CP2_WPTR_OFFSET 3584 1135#define CIK_WB_CP2_WPTR_OFFSET 3584
1136#define R600_WB_DMA_RING_TEST_OFFSET 3588
1137#define CAYMAN_WB_DMA1_RING_TEST_OFFSET 3592
1136 1138
1137/** 1139/**
1138 * struct radeon_pm - power management datas 1140 * struct radeon_pm - power management datas
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 6a03624fadaa..63ccb8fa799c 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -658,12 +658,10 @@ bool radeon_get_bios(struct radeon_device *rdev)
658 r = igp_read_bios_from_vram(rdev); 658 r = igp_read_bios_from_vram(rdev);
659 if (r == false) 659 if (r == false)
660 r = radeon_read_bios(rdev); 660 r = radeon_read_bios(rdev);
661 if (r == false) { 661 if (r == false)
662 r = radeon_read_disabled_bios(rdev); 662 r = radeon_read_disabled_bios(rdev);
663 } 663 if (r == false)
664 if (r == false) {
665 r = radeon_read_platform_bios(rdev); 664 r = radeon_read_platform_bios(rdev);
666 }
667 if (r == false || rdev->bios == NULL) { 665 if (r == false || rdev->bios == NULL) {
668 DRM_ERROR("Unable to locate a BIOS ROM\n"); 666 DRM_ERROR("Unable to locate a BIOS ROM\n");
669 rdev->bios = NULL; 667 rdev->bios = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 1c893447d7cd..a3e7aed7e680 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -450,7 +450,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo
450 kfree(parser->track); 450 kfree(parser->track);
451 kfree(parser->relocs); 451 kfree(parser->relocs);
452 kfree(parser->relocs_ptr); 452 kfree(parser->relocs_ptr);
453 kfree(parser->vm_bos); 453 drm_free_large(parser->vm_bos);
454 for (i = 0; i < parser->nchunks; i++) 454 for (i = 0; i < parser->nchunks; i++)
455 drm_free_large(parser->chunks[i].kdata); 455 drm_free_large(parser->chunks[i].kdata);
456 kfree(parser->chunks); 456 kfree(parser->chunks);
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index f41cc1538e48..ea2676954dde 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1130,7 +1130,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
1130 if (radeon_vm_block_size == -1) { 1130 if (radeon_vm_block_size == -1) {
1131 1131
1132 /* Total bits covered by PD + PTs */ 1132 /* Total bits covered by PD + PTs */
1133 unsigned bits = ilog2(radeon_vm_size) + 17; 1133 unsigned bits = ilog2(radeon_vm_size) + 18;
1134 1134
1135 /* Make sure the PD is 4K in size up to 8GB address space. 1135 /* Make sure the PD is 4K in size up to 8GB address space.
1136 Above that split equal between PD and PTs */ 1136 Above that split equal between PD and PTs */
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 3d17af34afa7..2456f69efd23 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -314,7 +314,7 @@ unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring
314 } 314 }
315 315
316 /* and then save the content of the ring */ 316 /* and then save the content of the ring */
317 *data = kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); 317 *data = drm_malloc_ab(size, sizeof(uint32_t));
318 if (!*data) { 318 if (!*data) {
319 mutex_unlock(&rdev->ring_lock); 319 mutex_unlock(&rdev->ring_lock);
320 return 0; 320 return 0;
@@ -356,7 +356,7 @@ int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
356 } 356 }
357 357
358 radeon_ring_unlock_commit(rdev, ring, false); 358 radeon_ring_unlock_commit(rdev, ring, false);
359 kfree(data); 359 drm_free_large(data);
360 return 0; 360 return 0;
361} 361}
362 362
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index 4532cc76a0a6..dfde266529e2 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -132,8 +132,8 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev,
132 struct radeon_cs_reloc *list; 132 struct radeon_cs_reloc *list;
133 unsigned i, idx; 133 unsigned i, idx;
134 134
135 list = kmalloc_array(vm->max_pde_used + 2, 135 list = drm_malloc_ab(vm->max_pde_used + 2,
136 sizeof(struct radeon_cs_reloc), GFP_KERNEL); 136 sizeof(struct radeon_cs_reloc));
137 if (!list) 137 if (!list)
138 return NULL; 138 return NULL;
139 139
diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c
index 02f7710de470..9031f4b69824 100644
--- a/drivers/gpu/drm/radeon/rs780_dpm.c
+++ b/drivers/gpu/drm/radeon/rs780_dpm.c
@@ -24,6 +24,7 @@
24 24
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "rs780d.h" 28#include "rs780d.h"
28#include "r600_dpm.h" 29#include "r600_dpm.h"
29#include "rs780_dpm.h" 30#include "rs780_dpm.h"
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index e7045b085715..6a5c233361e9 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -24,6 +24,7 @@
24 24
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "rv6xxd.h" 28#include "rv6xxd.h"
28#include "r600_dpm.h" 29#include "r600_dpm.h"
29#include "rv6xx_dpm.h" 30#include "rv6xx_dpm.h"
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index 3c76e1dcdf04..755a8f96fe46 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -24,6 +24,7 @@
24 24
25#include "drmP.h" 25#include "drmP.h"
26#include "radeon.h" 26#include "radeon.h"
27#include "radeon_asic.h"
27#include "rv770d.h" 28#include "rv770d.h"
28#include "r600_dpm.h" 29#include "r600_dpm.h"
29#include "rv770_dpm.h" 30#include "rv770_dpm.h"
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 9e4d5d7d348f..676e6c2ba90a 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -23,6 +23,7 @@
23 23
24#include "drmP.h" 24#include "drmP.h"
25#include "radeon.h" 25#include "radeon.h"
26#include "radeon_asic.h"
26#include "sid.h" 27#include "sid.h"
27#include "r600_dpm.h" 28#include "r600_dpm.h"
28#include "si_dpm.h" 29#include "si_dpm.h"
@@ -2916,6 +2917,7 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2916 bool disable_sclk_switching = false; 2917 bool disable_sclk_switching = false;
2917 u32 mclk, sclk; 2918 u32 mclk, sclk;
2918 u16 vddc, vddci; 2919 u16 vddc, vddci;
2920 u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
2919 int i; 2921 int i;
2920 2922
2921 if ((rdev->pm.dpm.new_active_crtc_count > 1) || 2923 if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
@@ -2949,6 +2951,29 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2949 } 2951 }
2950 } 2952 }
2951 2953
2954 /* limit clocks to max supported clocks based on voltage dependency tables */
2955 btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
2956 &max_sclk_vddc);
2957 btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
2958 &max_mclk_vddci);
2959 btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
2960 &max_mclk_vddc);
2961
2962 for (i = 0; i < ps->performance_level_count; i++) {
2963 if (max_sclk_vddc) {
2964 if (ps->performance_levels[i].sclk > max_sclk_vddc)
2965 ps->performance_levels[i].sclk = max_sclk_vddc;
2966 }
2967 if (max_mclk_vddci) {
2968 if (ps->performance_levels[i].mclk > max_mclk_vddci)
2969 ps->performance_levels[i].mclk = max_mclk_vddci;
2970 }
2971 if (max_mclk_vddc) {
2972 if (ps->performance_levels[i].mclk > max_mclk_vddc)
2973 ps->performance_levels[i].mclk = max_mclk_vddc;
2974 }
2975 }
2976
2952 /* XXX validate the min clocks required for display */ 2977 /* XXX validate the min clocks required for display */
2953 2978
2954 if (disable_mclk_switching) { 2979 if (disable_mclk_switching) {
@@ -6231,7 +6256,7 @@ static void si_parse_pplib_clock_info(struct radeon_device *rdev,
6231 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) && 6256 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
6232 index == 0) { 6257 index == 0) {
6233 /* XXX disable for A0 tahiti */ 6258 /* XXX disable for A0 tahiti */
6234 si_pi->ulv.supported = true; 6259 si_pi->ulv.supported = false;
6235 si_pi->ulv.pl = *pl; 6260 si_pi->ulv.pl = *pl;
6236 si_pi->ulv.one_pcie_lane_in_ulv = false; 6261 si_pi->ulv.one_pcie_lane_in_ulv = false;
6237 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT; 6262 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c
index 3f0e8d7b8dbe..1f8a8833e1be 100644
--- a/drivers/gpu/drm/radeon/sumo_dpm.c
+++ b/drivers/gpu/drm/radeon/sumo_dpm.c
@@ -23,6 +23,7 @@
23 23
24#include "drmP.h" 24#include "drmP.h"
25#include "radeon.h" 25#include "radeon.h"
26#include "radeon_asic.h"
26#include "sumod.h" 27#include "sumod.h"
27#include "r600_dpm.h" 28#include "r600_dpm.h"
28#include "cypress_dpm.h" 29#include "cypress_dpm.h"
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c
index 57f780053b3e..b4ec5c4e7969 100644
--- a/drivers/gpu/drm/radeon/trinity_dpm.c
+++ b/drivers/gpu/drm/radeon/trinity_dpm.c
@@ -23,6 +23,7 @@
23 23
24#include "drmP.h" 24#include "drmP.h"
25#include "radeon.h" 25#include "radeon.h"
26#include "radeon_asic.h"
26#include "trinityd.h" 27#include "trinityd.h"
27#include "r600_dpm.h" 28#include "r600_dpm.h"
28#include "trinity_dpm.h" 29#include "trinity_dpm.h"
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8f5cec67c47d..d395b0bef73b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -709,6 +709,7 @@ out:
709 709
710static int ttm_mem_evict_first(struct ttm_bo_device *bdev, 710static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
711 uint32_t mem_type, 711 uint32_t mem_type,
712 const struct ttm_place *place,
712 bool interruptible, 713 bool interruptible,
713 bool no_wait_gpu) 714 bool no_wait_gpu)
714{ 715{
@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
720 spin_lock(&glob->lru_lock); 721 spin_lock(&glob->lru_lock);
721 list_for_each_entry(bo, &man->lru, lru) { 722 list_for_each_entry(bo, &man->lru, lru) {
722 ret = __ttm_bo_reserve(bo, false, true, false, NULL); 723 ret = __ttm_bo_reserve(bo, false, true, false, NULL);
723 if (!ret) 724 if (!ret) {
725 if (place && (place->fpfn || place->lpfn)) {
726 /* Don't evict this BO if it's outside of the
727 * requested placement range
728 */
729 if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
730 (place->lpfn && place->lpfn <= bo->mem.start)) {
731 __ttm_bo_unreserve(bo);
732 ret = -EBUSY;
733 continue;
734 }
735 }
736
724 break; 737 break;
738 }
725 } 739 }
726 740
727 if (ret) { 741 if (ret) {
@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
782 return ret; 796 return ret;
783 if (mem->mm_node) 797 if (mem->mm_node)
784 break; 798 break;
785 ret = ttm_mem_evict_first(bdev, mem_type, 799 ret = ttm_mem_evict_first(bdev, mem_type, place,
786 interruptible, no_wait_gpu); 800 interruptible, no_wait_gpu);
787 if (unlikely(ret != 0)) 801 if (unlikely(ret != 0))
788 return ret; 802 return ret;
@@ -994,9 +1008,9 @@ static bool ttm_bo_mem_compat(struct ttm_placement *placement,
994 1008
995 for (i = 0; i < placement->num_placement; i++) { 1009 for (i = 0; i < placement->num_placement; i++) {
996 const struct ttm_place *heap = &placement->placement[i]; 1010 const struct ttm_place *heap = &placement->placement[i];
997 if (mem->mm_node && heap->lpfn != 0 && 1011 if (mem->mm_node &&
998 (mem->start < heap->fpfn || 1012 (mem->start < heap->fpfn ||
999 mem->start + mem->num_pages > heap->lpfn)) 1013 (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
1000 continue; 1014 continue;
1001 1015
1002 *new_flags = heap->flags; 1016 *new_flags = heap->flags;
@@ -1007,9 +1021,9 @@ static bool ttm_bo_mem_compat(struct ttm_placement *placement,
1007 1021
1008 for (i = 0; i < placement->num_busy_placement; i++) { 1022 for (i = 0; i < placement->num_busy_placement; i++) {
1009 const struct ttm_place *heap = &placement->busy_placement[i]; 1023 const struct ttm_place *heap = &placement->busy_placement[i];
1010 if (mem->mm_node && heap->lpfn != 0 && 1024 if (mem->mm_node &&
1011 (mem->start < heap->fpfn || 1025 (mem->start < heap->fpfn ||
1012 mem->start + mem->num_pages > heap->lpfn)) 1026 (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
1013 continue; 1027 continue;
1014 1028
1015 *new_flags = heap->flags; 1029 *new_flags = heap->flags;
@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
1233 spin_lock(&glob->lru_lock); 1247 spin_lock(&glob->lru_lock);
1234 while (!list_empty(&man->lru)) { 1248 while (!list_empty(&man->lru)) {
1235 spin_unlock(&glob->lru_lock); 1249 spin_unlock(&glob->lru_lock);
1236 ret = ttm_mem_evict_first(bdev, mem_type, false, false); 1250 ret = ttm_mem_evict_first(bdev, mem_type, NULL, false, false);
1237 if (ret) { 1251 if (ret) {
1238 if (allow_errors) { 1252 if (allow_errors) {
1239 return ret; 1253 return ret;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
index bfeb4b1f2acf..21e9b7f8dad0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
@@ -246,7 +246,8 @@ int vmw_cmdbuf_res_remove(struct vmw_cmdbuf_res_manager *man,
246 struct drm_hash_item *hash; 246 struct drm_hash_item *hash;
247 int ret; 247 int ret;
248 248
249 ret = drm_ht_find_item(&man->resources, user_key, &hash); 249 ret = drm_ht_find_item(&man->resources, user_key | (res_type << 24),
250 &hash);
250 if (likely(ret != 0)) 251 if (likely(ret != 0))
251 return -EINVAL; 252 return -EINVAL;
252 253
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 7197af157313..25f3c250fd98 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -688,7 +688,11 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
688 goto out_err0; 688 goto out_err0;
689 } 689 }
690 690
691 if (unlikely(dev_priv->prim_bb_mem < dev_priv->vram_size)) 691 /*
692 * Limit back buffer size to VRAM size. Remove this once
693 * screen targets are implemented.
694 */
695 if (dev_priv->prim_bb_mem > dev_priv->vram_size)
692 dev_priv->prim_bb_mem = dev_priv->vram_size; 696 dev_priv->prim_bb_mem = dev_priv->vram_size;
693 697
694 mutex_unlock(&dev_priv->hw_mutex); 698 mutex_unlock(&dev_priv->hw_mutex);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index d2bc2b03d4c6..941a7bc0b791 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -187,7 +187,7 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
187 * can do this since the caller in the drm core doesn't check anything 187 * can do this since the caller in the drm core doesn't check anything
188 * which is protected by any looks. 188 * which is protected by any looks.
189 */ 189 */
190 drm_modeset_unlock(&crtc->mutex); 190 drm_modeset_unlock_crtc(crtc);
191 drm_modeset_lock_all(dev_priv->dev); 191 drm_modeset_lock_all(dev_priv->dev);
192 192
193 /* A lot of the code assumes this */ 193 /* A lot of the code assumes this */
@@ -252,7 +252,7 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
252 ret = 0; 252 ret = 0;
253out: 253out:
254 drm_modeset_unlock_all(dev_priv->dev); 254 drm_modeset_unlock_all(dev_priv->dev);
255 drm_modeset_lock(&crtc->mutex, NULL); 255 drm_modeset_lock_crtc(crtc);
256 256
257 return ret; 257 return ret;
258} 258}
@@ -273,7 +273,7 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
273 * can do this since the caller in the drm core doesn't check anything 273 * can do this since the caller in the drm core doesn't check anything
274 * which is protected by any looks. 274 * which is protected by any looks.
275 */ 275 */
276 drm_modeset_unlock(&crtc->mutex); 276 drm_modeset_unlock_crtc(crtc);
277 drm_modeset_lock_all(dev_priv->dev); 277 drm_modeset_lock_all(dev_priv->dev);
278 278
279 vmw_cursor_update_position(dev_priv, shown, 279 vmw_cursor_update_position(dev_priv, shown,
@@ -281,7 +281,7 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
281 du->cursor_y + du->hotspot_y); 281 du->cursor_y + du->hotspot_y);
282 282
283 drm_modeset_unlock_all(dev_priv->dev); 283 drm_modeset_unlock_all(dev_priv->dev);
284 drm_modeset_lock(&crtc->mutex, NULL); 284 drm_modeset_lock_crtc(crtc);
285 285
286 return 0; 286 return 0;
287} 287}
@@ -1950,6 +1950,14 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1950 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) 1950 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
1951 }; 1951 };
1952 int i; 1952 int i;
1953 u32 assumed_bpp = 2;
1954
1955 /*
1956 * If using screen objects, then assume 32-bpp because that's what the
1957 * SVGA device is assuming
1958 */
1959 if (dev_priv->sou_priv)
1960 assumed_bpp = 4;
1953 1961
1954 /* Add preferred mode */ 1962 /* Add preferred mode */
1955 { 1963 {
@@ -1960,8 +1968,9 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1960 mode->vdisplay = du->pref_height; 1968 mode->vdisplay = du->pref_height;
1961 vmw_guess_mode_timing(mode); 1969 vmw_guess_mode_timing(mode);
1962 1970
1963 if (vmw_kms_validate_mode_vram(dev_priv, mode->hdisplay * 2, 1971 if (vmw_kms_validate_mode_vram(dev_priv,
1964 mode->vdisplay)) { 1972 mode->hdisplay * assumed_bpp,
1973 mode->vdisplay)) {
1965 drm_mode_probed_add(connector, mode); 1974 drm_mode_probed_add(connector, mode);
1966 } else { 1975 } else {
1967 drm_mode_destroy(dev, mode); 1976 drm_mode_destroy(dev, mode);
@@ -1983,7 +1992,8 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1983 bmode->vdisplay > max_height) 1992 bmode->vdisplay > max_height)
1984 continue; 1993 continue;
1985 1994
1986 if (!vmw_kms_validate_mode_vram(dev_priv, bmode->hdisplay * 2, 1995 if (!vmw_kms_validate_mode_vram(dev_priv,
1996 bmode->hdisplay * assumed_bpp,
1987 bmode->vdisplay)) 1997 bmode->vdisplay))
1988 continue; 1998 continue;
1989 1999