aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c7
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_topology.c8
-rw-r--r--drivers/gpu/drm/drm_irq.c9
-rw-r--r--drivers/gpu/drm/drm_plane_helper.c3
-rw-r--r--drivers/gpu/drm/drm_sysfs.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos7_drm_decon.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_dp_core.c13
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c10
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.h10
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h20
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fb.c39
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c53
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.h15
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c72
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c5
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c13
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c3
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c3
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c14
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c20
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c6
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c26
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c24
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c14
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c2
-rw-r--r--drivers/gpu/drm/i915/intel_uncore.c8
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c2
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi.c10
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_host.c21
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_manager.c6
-rw-r--r--drivers/gpu/drm/msm/edp/edp_aux.c4
-rw-r--r--drivers/gpu/drm/msm/edp/edp_connector.c2
-rw-r--r--drivers/gpu/drm/msm/edp/edp_ctrl.c3
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c34
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.h9
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c12
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c2
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c24
-rw-r--r--drivers/gpu/drm/msm/msm_fb.c7
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c2
-rw-r--r--drivers/gpu/drm/msm/msm_iommu.c4
-rw-r--r--drivers/gpu/drm/msm/msm_ringbuffer.c2
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/class.h2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm107.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm204.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.h3
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c20
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c6
-rw-r--r--drivers/gpu/drm/radeon/cik.c2
-rw-r--r--drivers/gpu/drm/radeon/dce3_1_afmt.c2
-rw-r--r--drivers/gpu/drm/radeon/dce6_afmt.c25
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c54
-rw-r--r--drivers/gpu/drm/radeon/ni.c3
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c9
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h4
-rw-r--r--drivers/gpu/drm/radeon/radeon_audio.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c15
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_auxch.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_mst.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_mn.c13
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c144
-rw-r--r--drivers/gpu/drm/radeon/radeon_vce.c65
-rw-r--r--drivers/gpu/drm/radeon/radeon_vm.c51
-rw-r--r--drivers/gpu/drm/radeon/rv770d.h3
-rw-r--r--drivers/gpu/drm/radeon/si.c2
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c1
-rw-r--r--drivers/gpu/drm/radeon/uvd_v1_0.c14
-rw-r--r--drivers/gpu/drm/radeon/uvd_v2_2.c29
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_vop.c9
-rw-r--r--drivers/gpu/drm/tegra/drm.c1
-rw-r--r--drivers/gpu/drm/vgem/Makefile2
-rw-r--r--drivers/gpu/drm/vgem/vgem_dma_buf.c94
-rw-r--r--drivers/gpu/drm/vgem/vgem_drv.c11
-rw-r--r--drivers/gpu/drm/vgem/vgem_drv.h11
83 files changed, 607 insertions, 580 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 69af73f15310..596ee5cd3b84 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -430,9 +430,10 @@ static int unregister_process_nocpsch(struct device_queue_manager *dqm,
430 430
431 BUG_ON(!dqm || !qpd); 431 BUG_ON(!dqm || !qpd);
432 432
433 BUG_ON(!list_empty(&qpd->queues_list)); 433 pr_debug("In func %s\n", __func__);
434 434
435 pr_debug("kfd: In func %s\n", __func__); 435 pr_debug("qpd->queues_list is %s\n",
436 list_empty(&qpd->queues_list) ? "empty" : "not empty");
436 437
437 retval = 0; 438 retval = 0;
438 mutex_lock(&dqm->lock); 439 mutex_lock(&dqm->lock);
@@ -882,6 +883,8 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
882 return -ENOMEM; 883 return -ENOMEM;
883 } 884 }
884 885
886 init_sdma_vm(dqm, q, qpd);
887
885 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj, 888 retval = mqd->init_mqd(mqd, &q->mqd, &q->mqd_mem_obj,
886 &q->gart_mqd_addr, &q->properties); 889 &q->gart_mqd_addr, &q->properties);
887 if (retval != 0) 890 if (retval != 0)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 661c6605d31b..c25728bc388a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -684,8 +684,6 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
684 dev->node_props.cpu_core_id_base); 684 dev->node_props.cpu_core_id_base);
685 sysfs_show_32bit_prop(buffer, "simd_id_base", 685 sysfs_show_32bit_prop(buffer, "simd_id_base",
686 dev->node_props.simd_id_base); 686 dev->node_props.simd_id_base);
687 sysfs_show_32bit_prop(buffer, "capability",
688 dev->node_props.capability);
689 sysfs_show_32bit_prop(buffer, "max_waves_per_simd", 687 sysfs_show_32bit_prop(buffer, "max_waves_per_simd",
690 dev->node_props.max_waves_per_simd); 688 dev->node_props.max_waves_per_simd);
691 sysfs_show_32bit_prop(buffer, "lds_size_in_kb", 689 sysfs_show_32bit_prop(buffer, "lds_size_in_kb",
@@ -728,14 +726,16 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
728 sysfs_show_32bit_prop(buffer, "max_engine_clk_fcompute", 726 sysfs_show_32bit_prop(buffer, "max_engine_clk_fcompute",
729 dev->gpu->kfd2kgd->get_max_engine_clock_in_mhz( 727 dev->gpu->kfd2kgd->get_max_engine_clock_in_mhz(
730 dev->gpu->kgd)); 728 dev->gpu->kgd));
729
731 sysfs_show_64bit_prop(buffer, "local_mem_size", 730 sysfs_show_64bit_prop(buffer, "local_mem_size",
732 dev->gpu->kfd2kgd->get_vmem_size( 731 (unsigned long long int) 0);
733 dev->gpu->kgd));
734 732
735 sysfs_show_32bit_prop(buffer, "fw_version", 733 sysfs_show_32bit_prop(buffer, "fw_version",
736 dev->gpu->kfd2kgd->get_fw_version( 734 dev->gpu->kfd2kgd->get_fw_version(
737 dev->gpu->kgd, 735 dev->gpu->kgd,
738 KGD_ENGINE_MEC1)); 736 KGD_ENGINE_MEC1));
737 sysfs_show_32bit_prop(buffer, "capability",
738 dev->node_props.capability);
739 } 739 }
740 740
741 return sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute", 741 return sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute",
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c8a34476570a..af9662e58272 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -131,12 +131,11 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc)
131 131
132 /* Reinitialize corresponding vblank timestamp if high-precision query 132 /* Reinitialize corresponding vblank timestamp if high-precision query
133 * available. Skip this step if query unsupported or failed. Will 133 * available. Skip this step if query unsupported or failed. Will
134 * reinitialize delayed at next vblank interrupt in that case. 134 * reinitialize delayed at next vblank interrupt in that case and
135 * assign 0 for now, to mark the vblanktimestamp as invalid.
135 */ 136 */
136 if (rc) { 137 tslot = atomic_read(&vblank->count) + diff;
137 tslot = atomic_read(&vblank->count) + diff; 138 vblanktimestamp(dev, crtc, tslot) = rc ? t_vblank : (struct timeval) {0, 0};
138 vblanktimestamp(dev, crtc, tslot) = t_vblank;
139 }
140 139
141 smp_mb__before_atomic(); 140 smp_mb__before_atomic();
142 atomic_add(diff, &vblank->count); 141 atomic_add(diff, &vblank->count);
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 40c1db9ad7c3..2f0ed11024eb 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -465,6 +465,9 @@ int drm_plane_helper_commit(struct drm_plane *plane,
465 if (!crtc[i]) 465 if (!crtc[i])
466 continue; 466 continue;
467 467
468 if (crtc[i]->cursor == plane)
469 continue;
470
468 /* There's no other way to figure out whether the crtc is running. */ 471 /* There's no other way to figure out whether the crtc is running. */
469 ret = drm_crtc_vblank_get(crtc[i]); 472 ret = drm_crtc_vblank_get(crtc[i]);
470 if (ret == 0) { 473 if (ret == 0) {
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index ffc305fc2076..eb7e61078a5b 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -217,7 +217,7 @@ static ssize_t status_store(struct device *device,
217 217
218 mutex_unlock(&dev->mode_config.mutex); 218 mutex_unlock(&dev->mode_config.mutex);
219 219
220 return ret; 220 return ret ? ret : count;
221} 221}
222 222
223static ssize_t status_show(struct device *device, 223static ssize_t status_show(struct device *device,
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 1f7e33f59de6..6714e5b193ea 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -91,7 +91,7 @@ static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc)
91 91
92static void decon_clear_channel(struct decon_context *ctx) 92static void decon_clear_channel(struct decon_context *ctx)
93{ 93{
94 int win, ch_enabled = 0; 94 unsigned int win, ch_enabled = 0;
95 95
96 DRM_DEBUG_KMS("%s\n", __FILE__); 96 DRM_DEBUG_KMS("%s\n", __FILE__);
97 97
@@ -710,7 +710,7 @@ static void decon_dpms(struct exynos_drm_crtc *crtc, int mode)
710 } 710 }
711} 711}
712 712
713static struct exynos_drm_crtc_ops decon_crtc_ops = { 713static const struct exynos_drm_crtc_ops decon_crtc_ops = {
714 .dpms = decon_dpms, 714 .dpms = decon_dpms,
715 .mode_fixup = decon_mode_fixup, 715 .mode_fixup = decon_mode_fixup,
716 .commit = decon_commit, 716 .commit = decon_commit,
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index 1dbfba58f909..30feb7d06624 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -32,7 +32,6 @@
32#include <drm/bridge/ptn3460.h> 32#include <drm/bridge/ptn3460.h>
33 33
34#include "exynos_dp_core.h" 34#include "exynos_dp_core.h"
35#include "exynos_drm_fimd.h"
36 35
37#define ctx_from_connector(c) container_of(c, struct exynos_dp_device, \ 36#define ctx_from_connector(c) container_of(c, struct exynos_dp_device, \
38 connector) 37 connector)
@@ -196,7 +195,7 @@ static int exynos_dp_read_edid(struct exynos_dp_device *dp)
196 } 195 }
197 } 196 }
198 197
199 dev_err(dp->dev, "EDID Read success!\n"); 198 dev_dbg(dp->dev, "EDID Read success!\n");
200 return 0; 199 return 0;
201} 200}
202 201
@@ -1066,6 +1065,8 @@ static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
1066 1065
1067static void exynos_dp_poweron(struct exynos_dp_device *dp) 1066static void exynos_dp_poweron(struct exynos_dp_device *dp)
1068{ 1067{
1068 struct exynos_drm_crtc *crtc = dp_to_crtc(dp);
1069
1069 if (dp->dpms_mode == DRM_MODE_DPMS_ON) 1070 if (dp->dpms_mode == DRM_MODE_DPMS_ON)
1070 return; 1071 return;
1071 1072
@@ -1076,7 +1077,8 @@ static void exynos_dp_poweron(struct exynos_dp_device *dp)
1076 } 1077 }
1077 } 1078 }
1078 1079
1079 fimd_dp_clock_enable(dp_to_crtc(dp), true); 1080 if (crtc->ops->clock_enable)
1081 crtc->ops->clock_enable(dp_to_crtc(dp), true);
1080 1082
1081 clk_prepare_enable(dp->clock); 1083 clk_prepare_enable(dp->clock);
1082 exynos_dp_phy_init(dp); 1084 exynos_dp_phy_init(dp);
@@ -1087,6 +1089,8 @@ static void exynos_dp_poweron(struct exynos_dp_device *dp)
1087 1089
1088static void exynos_dp_poweroff(struct exynos_dp_device *dp) 1090static void exynos_dp_poweroff(struct exynos_dp_device *dp)
1089{ 1091{
1092 struct exynos_drm_crtc *crtc = dp_to_crtc(dp);
1093
1090 if (dp->dpms_mode != DRM_MODE_DPMS_ON) 1094 if (dp->dpms_mode != DRM_MODE_DPMS_ON)
1091 return; 1095 return;
1092 1096
@@ -1102,7 +1106,8 @@ static void exynos_dp_poweroff(struct exynos_dp_device *dp)
1102 exynos_dp_phy_exit(dp); 1106 exynos_dp_phy_exit(dp);
1103 clk_disable_unprepare(dp->clock); 1107 clk_disable_unprepare(dp->clock);
1104 1108
1105 fimd_dp_clock_enable(dp_to_crtc(dp), false); 1109 if (crtc->ops->clock_enable)
1110 crtc->ops->clock_enable(dp_to_crtc(dp), false);
1106 1111
1107 if (dp->panel) { 1112 if (dp->panel) {
1108 if (drm_panel_unprepare(dp->panel)) 1113 if (drm_panel_unprepare(dp->panel))
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index eb49195cec5c..9006b947e03c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -238,11 +238,11 @@ static struct drm_crtc_funcs exynos_crtc_funcs = {
238}; 238};
239 239
240struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, 240struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
241 struct drm_plane *plane, 241 struct drm_plane *plane,
242 int pipe, 242 int pipe,
243 enum exynos_drm_output_type type, 243 enum exynos_drm_output_type type,
244 struct exynos_drm_crtc_ops *ops, 244 const struct exynos_drm_crtc_ops *ops,
245 void *ctx) 245 void *ctx)
246{ 246{
247 struct exynos_drm_crtc *exynos_crtc; 247 struct exynos_drm_crtc *exynos_crtc;
248 struct exynos_drm_private *private = drm_dev->dev_private; 248 struct exynos_drm_private *private = drm_dev->dev_private;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 0ecd8fc45cff..0f3aa70818e3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -18,11 +18,11 @@
18#include "exynos_drm_drv.h" 18#include "exynos_drm_drv.h"
19 19
20struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, 20struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
21 struct drm_plane *plane, 21 struct drm_plane *plane,
22 int pipe, 22 int pipe,
23 enum exynos_drm_output_type type, 23 enum exynos_drm_output_type type,
24 struct exynos_drm_crtc_ops *ops, 24 const struct exynos_drm_crtc_ops *ops,
25 void *context); 25 void *context);
26int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe); 26int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe);
27void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe); 27void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe);
28void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe); 28void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index e12ecb5d5d9a..29e3fb78c615 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -71,13 +71,6 @@ enum exynos_drm_output_type {
71 * @dma_addr: array of bus(accessed by dma) address to the memory region 71 * @dma_addr: array of bus(accessed by dma) address to the memory region
72 * allocated for a overlay. 72 * allocated for a overlay.
73 * @zpos: order of overlay layer(z position). 73 * @zpos: order of overlay layer(z position).
74 * @index_color: if using color key feature then this value would be used
75 * as index color.
76 * @default_win: a window to be enabled.
77 * @color_key: color key on or off.
78 * @local_path: in case of lcd type, local path mode on or off.
79 * @transparency: transparency on or off.
80 * @activated: activated or not.
81 * @enabled: enabled or not. 74 * @enabled: enabled or not.
82 * @resume: to resume or not. 75 * @resume: to resume or not.
83 * 76 *
@@ -108,13 +101,7 @@ struct exynos_drm_plane {
108 uint32_t pixel_format; 101 uint32_t pixel_format;
109 dma_addr_t dma_addr[MAX_FB_BUFFER]; 102 dma_addr_t dma_addr[MAX_FB_BUFFER];
110 unsigned int zpos; 103 unsigned int zpos;
111 unsigned int index_color;
112 104
113 bool default_win:1;
114 bool color_key:1;
115 bool local_path:1;
116 bool transparency:1;
117 bool activated:1;
118 bool enabled:1; 105 bool enabled:1;
119 bool resume:1; 106 bool resume:1;
120}; 107};
@@ -181,6 +168,10 @@ struct exynos_drm_display {
181 * @win_disable: disable hardware specific overlay. 168 * @win_disable: disable hardware specific overlay.
182 * @te_handler: trigger to transfer video image at the tearing effect 169 * @te_handler: trigger to transfer video image at the tearing effect
183 * synchronization signal if there is a page flip request. 170 * synchronization signal if there is a page flip request.
171 * @clock_enable: optional function enabling/disabling display domain clock,
172 * called from exynos-dp driver before powering up (with
173 * 'enable' argument as true) and after powering down (with
174 * 'enable' as false).
184 */ 175 */
185struct exynos_drm_crtc; 176struct exynos_drm_crtc;
186struct exynos_drm_crtc_ops { 177struct exynos_drm_crtc_ops {
@@ -195,6 +186,7 @@ struct exynos_drm_crtc_ops {
195 void (*win_commit)(struct exynos_drm_crtc *crtc, unsigned int zpos); 186 void (*win_commit)(struct exynos_drm_crtc *crtc, unsigned int zpos);
196 void (*win_disable)(struct exynos_drm_crtc *crtc, unsigned int zpos); 187 void (*win_disable)(struct exynos_drm_crtc *crtc, unsigned int zpos);
197 void (*te_handler)(struct exynos_drm_crtc *crtc); 188 void (*te_handler)(struct exynos_drm_crtc *crtc);
189 void (*clock_enable)(struct exynos_drm_crtc *crtc, bool enable);
198}; 190};
199 191
200/* 192/*
@@ -221,7 +213,7 @@ struct exynos_drm_crtc {
221 unsigned int dpms; 213 unsigned int dpms;
222 wait_queue_head_t pending_flip_queue; 214 wait_queue_head_t pending_flip_queue;
223 struct drm_pending_vblank_event *event; 215 struct drm_pending_vblank_event *event;
224 struct exynos_drm_crtc_ops *ops; 216 const struct exynos_drm_crtc_ops *ops;
225 void *ctx; 217 void *ctx;
226}; 218};
227 219
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 929cb03a8eab..142eb4e3f59e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -171,43 +171,6 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
171 return &exynos_fb->fb; 171 return &exynos_fb->fb;
172} 172}
173 173
174static u32 exynos_drm_format_num_buffers(struct drm_mode_fb_cmd2 *mode_cmd)
175{
176 unsigned int cnt = 0;
177
178 if (mode_cmd->pixel_format != DRM_FORMAT_NV12)
179 return drm_format_num_planes(mode_cmd->pixel_format);
180
181 while (cnt != MAX_FB_BUFFER) {
182 if (!mode_cmd->handles[cnt])
183 break;
184 cnt++;
185 }
186
187 /*
188 * check if NV12 or NV12M.
189 *
190 * NV12
191 * handles[0] = base1, offsets[0] = 0
192 * handles[1] = base1, offsets[1] = Y_size
193 *
194 * NV12M
195 * handles[0] = base1, offsets[0] = 0
196 * handles[1] = base2, offsets[1] = 0
197 */
198 if (cnt == 2) {
199 /*
200 * in case of NV12 format, offsets[1] is not 0 and
201 * handles[0] is same as handles[1].
202 */
203 if (mode_cmd->offsets[1] &&
204 mode_cmd->handles[0] == mode_cmd->handles[1])
205 cnt = 1;
206 }
207
208 return cnt;
209}
210
211static struct drm_framebuffer * 174static struct drm_framebuffer *
212exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, 175exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
213 struct drm_mode_fb_cmd2 *mode_cmd) 176 struct drm_mode_fb_cmd2 *mode_cmd)
@@ -230,7 +193,7 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
230 193
231 drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); 194 drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd);
232 exynos_fb->exynos_gem_obj[0] = to_exynos_gem_obj(obj); 195 exynos_fb->exynos_gem_obj[0] = to_exynos_gem_obj(obj);
233 exynos_fb->buf_cnt = exynos_drm_format_num_buffers(mode_cmd); 196 exynos_fb->buf_cnt = drm_format_num_planes(mode_cmd->pixel_format);
234 197
235 DRM_DEBUG_KMS("buf_cnt = %d\n", exynos_fb->buf_cnt); 198 DRM_DEBUG_KMS("buf_cnt = %d\n", exynos_fb->buf_cnt);
236 199
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 9819fa6a9e2a..a0edab833148 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -33,7 +33,6 @@
33#include "exynos_drm_crtc.h" 33#include "exynos_drm_crtc.h"
34#include "exynos_drm_plane.h" 34#include "exynos_drm_plane.h"
35#include "exynos_drm_iommu.h" 35#include "exynos_drm_iommu.h"
36#include "exynos_drm_fimd.h"
37 36
38/* 37/*
39 * FIMD stands for Fully Interactive Mobile Display and 38 * FIMD stands for Fully Interactive Mobile Display and
@@ -216,7 +215,7 @@ static void fimd_wait_for_vblank(struct exynos_drm_crtc *crtc)
216 DRM_DEBUG_KMS("vblank wait timed out.\n"); 215 DRM_DEBUG_KMS("vblank wait timed out.\n");
217} 216}
218 217
219static void fimd_enable_video_output(struct fimd_context *ctx, int win, 218static void fimd_enable_video_output(struct fimd_context *ctx, unsigned int win,
220 bool enable) 219 bool enable)
221{ 220{
222 u32 val = readl(ctx->regs + WINCON(win)); 221 u32 val = readl(ctx->regs + WINCON(win));
@@ -229,7 +228,8 @@ static void fimd_enable_video_output(struct fimd_context *ctx, int win,
229 writel(val, ctx->regs + WINCON(win)); 228 writel(val, ctx->regs + WINCON(win));
230} 229}
231 230
232static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, int win, 231static void fimd_enable_shadow_channel_path(struct fimd_context *ctx,
232 unsigned int win,
233 bool enable) 233 bool enable)
234{ 234{
235 u32 val = readl(ctx->regs + SHADOWCON); 235 u32 val = readl(ctx->regs + SHADOWCON);
@@ -244,7 +244,7 @@ static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, int win,
244 244
245static void fimd_clear_channel(struct fimd_context *ctx) 245static void fimd_clear_channel(struct fimd_context *ctx)
246{ 246{
247 int win, ch_enabled = 0; 247 unsigned int win, ch_enabled = 0;
248 248
249 DRM_DEBUG_KMS("%s\n", __FILE__); 249 DRM_DEBUG_KMS("%s\n", __FILE__);
250 250
@@ -946,7 +946,24 @@ static void fimd_te_handler(struct exynos_drm_crtc *crtc)
946 drm_handle_vblank(ctx->drm_dev, ctx->pipe); 946 drm_handle_vblank(ctx->drm_dev, ctx->pipe);
947} 947}
948 948
949static struct exynos_drm_crtc_ops fimd_crtc_ops = { 949static void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable)
950{
951 struct fimd_context *ctx = crtc->ctx;
952 u32 val;
953
954 /*
955 * Only Exynos 5250, 5260, 5410 and 542x requires enabling DP/MIE
956 * clock. On these SoCs the bootloader may enable it but any
957 * power domain off/on will reset it to disable state.
958 */
959 if (ctx->driver_data != &exynos5_fimd_driver_data)
960 return;
961
962 val = enable ? DP_MIE_CLK_DP_ENABLE : DP_MIE_CLK_DISABLE;
963 writel(DP_MIE_CLK_DP_ENABLE, ctx->regs + DP_MIE_CLKCON);
964}
965
966static const struct exynos_drm_crtc_ops fimd_crtc_ops = {
950 .dpms = fimd_dpms, 967 .dpms = fimd_dpms,
951 .mode_fixup = fimd_mode_fixup, 968 .mode_fixup = fimd_mode_fixup,
952 .commit = fimd_commit, 969 .commit = fimd_commit,
@@ -956,6 +973,7 @@ static struct exynos_drm_crtc_ops fimd_crtc_ops = {
956 .win_commit = fimd_win_commit, 973 .win_commit = fimd_win_commit,
957 .win_disable = fimd_win_disable, 974 .win_disable = fimd_win_disable,
958 .te_handler = fimd_te_handler, 975 .te_handler = fimd_te_handler,
976 .clock_enable = fimd_dp_clock_enable,
959}; 977};
960 978
961static irqreturn_t fimd_irq_handler(int irq, void *dev_id) 979static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
@@ -1025,12 +1043,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)
1025 if (ctx->display) 1043 if (ctx->display)
1026 exynos_drm_create_enc_conn(drm_dev, ctx->display); 1044 exynos_drm_create_enc_conn(drm_dev, ctx->display);
1027 1045
1028 ret = fimd_iommu_attach_devices(ctx, drm_dev); 1046 return fimd_iommu_attach_devices(ctx, drm_dev);
1029 if (ret)
1030 return ret;
1031
1032 return 0;
1033
1034} 1047}
1035 1048
1036static void fimd_unbind(struct device *dev, struct device *master, 1049static void fimd_unbind(struct device *dev, struct device *master,
@@ -1192,24 +1205,6 @@ static int fimd_remove(struct platform_device *pdev)
1192 return 0; 1205 return 0;
1193} 1206}
1194 1207
1195void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable)
1196{
1197 struct fimd_context *ctx = crtc->ctx;
1198 u32 val;
1199
1200 /*
1201 * Only Exynos 5250, 5260, 5410 and 542x requires enabling DP/MIE
1202 * clock. On these SoCs the bootloader may enable it but any
1203 * power domain off/on will reset it to disable state.
1204 */
1205 if (ctx->driver_data != &exynos5_fimd_driver_data)
1206 return;
1207
1208 val = enable ? DP_MIE_CLK_DP_ENABLE : DP_MIE_CLK_DISABLE;
1209 writel(DP_MIE_CLK_DP_ENABLE, ctx->regs + DP_MIE_CLKCON);
1210}
1211EXPORT_SYMBOL_GPL(fimd_dp_clock_enable);
1212
1213struct platform_driver fimd_driver = { 1208struct platform_driver fimd_driver = {
1214 .probe = fimd_probe, 1209 .probe = fimd_probe,
1215 .remove = fimd_remove, 1210 .remove = fimd_remove,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.h b/drivers/gpu/drm/exynos/exynos_drm_fimd.h
deleted file mode 100644
index b4fcaa568456..000000000000
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#ifndef _EXYNOS_DRM_FIMD_H_
11#define _EXYNOS_DRM_FIMD_H_
12
13extern void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable);
14
15#endif /* _EXYNOS_DRM_FIMD_H_ */
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 13ea3349363b..b1180fbe7546 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -76,7 +76,7 @@ int exynos_check_plane(struct drm_plane *plane, struct drm_framebuffer *fb)
76 return -EFAULT; 76 return -EFAULT;
77 } 77 }
78 78
79 exynos_plane->dma_addr[i] = buffer->dma_addr; 79 exynos_plane->dma_addr[i] = buffer->dma_addr + fb->offsets[i];
80 80
81 DRM_DEBUG_KMS("buffer: %d, dma_addr = 0x%lx\n", 81 DRM_DEBUG_KMS("buffer: %d, dma_addr = 0x%lx\n",
82 i, (unsigned long)exynos_plane->dma_addr[i]); 82 i, (unsigned long)exynos_plane->dma_addr[i]);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 27e84ec21694..1b3479a8db5f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -217,7 +217,7 @@ static int vidi_ctx_initialize(struct vidi_context *ctx,
217 return 0; 217 return 0;
218} 218}
219 219
220static struct exynos_drm_crtc_ops vidi_crtc_ops = { 220static const struct exynos_drm_crtc_ops vidi_crtc_ops = {
221 .dpms = vidi_dpms, 221 .dpms = vidi_dpms,
222 .enable_vblank = vidi_enable_vblank, 222 .enable_vblank = vidi_enable_vblank,
223 .disable_vblank = vidi_disable_vblank, 223 .disable_vblank = vidi_disable_vblank,
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index fbec750574e6..8874c1fcb3ab 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -44,6 +44,12 @@
44#define MIXER_WIN_NR 3 44#define MIXER_WIN_NR 3
45#define MIXER_DEFAULT_WIN 0 45#define MIXER_DEFAULT_WIN 0
46 46
47/* The pixelformats that are natively supported by the mixer. */
48#define MXR_FORMAT_RGB565 4
49#define MXR_FORMAT_ARGB1555 5
50#define MXR_FORMAT_ARGB4444 6
51#define MXR_FORMAT_ARGB8888 7
52
47struct mixer_resources { 53struct mixer_resources {
48 int irq; 54 int irq;
49 void __iomem *mixer_regs; 55 void __iomem *mixer_regs;
@@ -327,7 +333,8 @@ static void mixer_cfg_rgb_fmt(struct mixer_context *ctx, unsigned int height)
327 mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK); 333 mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK);
328} 334}
329 335
330static void mixer_cfg_layer(struct mixer_context *ctx, int win, bool enable) 336static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int win,
337 bool enable)
331{ 338{
332 struct mixer_resources *res = &ctx->mixer_res; 339 struct mixer_resources *res = &ctx->mixer_res;
333 u32 val = enable ? ~0 : 0; 340 u32 val = enable ? ~0 : 0;
@@ -359,8 +366,6 @@ static void mixer_run(struct mixer_context *ctx)
359 struct mixer_resources *res = &ctx->mixer_res; 366 struct mixer_resources *res = &ctx->mixer_res;
360 367
361 mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_REG_RUN); 368 mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_REG_RUN);
362
363 mixer_regs_dump(ctx);
364} 369}
365 370
366static void mixer_stop(struct mixer_context *ctx) 371static void mixer_stop(struct mixer_context *ctx)
@@ -373,16 +378,13 @@ static void mixer_stop(struct mixer_context *ctx)
373 while (!(mixer_reg_read(res, MXR_STATUS) & MXR_STATUS_REG_IDLE) && 378 while (!(mixer_reg_read(res, MXR_STATUS) & MXR_STATUS_REG_IDLE) &&
374 --timeout) 379 --timeout)
375 usleep_range(10000, 12000); 380 usleep_range(10000, 12000);
376
377 mixer_regs_dump(ctx);
378} 381}
379 382
380static void vp_video_buffer(struct mixer_context *ctx, int win) 383static void vp_video_buffer(struct mixer_context *ctx, unsigned int win)
381{ 384{
382 struct mixer_resources *res = &ctx->mixer_res; 385 struct mixer_resources *res = &ctx->mixer_res;
383 unsigned long flags; 386 unsigned long flags;
384 struct exynos_drm_plane *plane; 387 struct exynos_drm_plane *plane;
385 unsigned int buf_num = 1;
386 dma_addr_t luma_addr[2], chroma_addr[2]; 388 dma_addr_t luma_addr[2], chroma_addr[2];
387 bool tiled_mode = false; 389 bool tiled_mode = false;
388 bool crcb_mode = false; 390 bool crcb_mode = false;
@@ -393,27 +395,18 @@ static void vp_video_buffer(struct mixer_context *ctx, int win)
393 switch (plane->pixel_format) { 395 switch (plane->pixel_format) {
394 case DRM_FORMAT_NV12: 396 case DRM_FORMAT_NV12:
395 crcb_mode = false; 397 crcb_mode = false;
396 buf_num = 2;
397 break; 398 break;
398 /* TODO: single buffer format NV12, NV21 */ 399 case DRM_FORMAT_NV21:
400 crcb_mode = true;
401 break;
399 default: 402 default:
400 /* ignore pixel format at disable time */
401 if (!plane->dma_addr[0])
402 break;
403
404 DRM_ERROR("pixel format for vp is wrong [%d].\n", 403 DRM_ERROR("pixel format for vp is wrong [%d].\n",
405 plane->pixel_format); 404 plane->pixel_format);
406 return; 405 return;
407 } 406 }
408 407
409 if (buf_num == 2) { 408 luma_addr[0] = plane->dma_addr[0];
410 luma_addr[0] = plane->dma_addr[0]; 409 chroma_addr[0] = plane->dma_addr[1];
411 chroma_addr[0] = plane->dma_addr[1];
412 } else {
413 luma_addr[0] = plane->dma_addr[0];
414 chroma_addr[0] = plane->dma_addr[0]
415 + (plane->pitch * plane->fb_height);
416 }
417 410
418 if (plane->scan_flag & DRM_MODE_FLAG_INTERLACE) { 411 if (plane->scan_flag & DRM_MODE_FLAG_INTERLACE) {
419 ctx->interlace = true; 412 ctx->interlace = true;
@@ -484,6 +477,7 @@ static void vp_video_buffer(struct mixer_context *ctx, int win)
484 mixer_vsync_set_update(ctx, true); 477 mixer_vsync_set_update(ctx, true);
485 spin_unlock_irqrestore(&res->reg_slock, flags); 478 spin_unlock_irqrestore(&res->reg_slock, flags);
486 479
480 mixer_regs_dump(ctx);
487 vp_regs_dump(ctx); 481 vp_regs_dump(ctx);
488} 482}
489 483
@@ -518,7 +512,7 @@ fail:
518 return -ENOTSUPP; 512 return -ENOTSUPP;
519} 513}
520 514
521static void mixer_graph_buffer(struct mixer_context *ctx, int win) 515static void mixer_graph_buffer(struct mixer_context *ctx, unsigned int win)
522{ 516{
523 struct mixer_resources *res = &ctx->mixer_res; 517 struct mixer_resources *res = &ctx->mixer_res;
524 unsigned long flags; 518 unsigned long flags;
@@ -531,20 +525,27 @@ static void mixer_graph_buffer(struct mixer_context *ctx, int win)
531 525
532 plane = &ctx->planes[win]; 526 plane = &ctx->planes[win];
533 527
534 #define RGB565 4 528 switch (plane->pixel_format) {
535 #define ARGB1555 5 529 case DRM_FORMAT_XRGB4444:
536 #define ARGB4444 6 530 fmt = MXR_FORMAT_ARGB4444;
537 #define ARGB8888 7 531 break;
538 532
539 switch (plane->bpp) { 533 case DRM_FORMAT_XRGB1555:
540 case 16: 534 fmt = MXR_FORMAT_ARGB1555;
541 fmt = ARGB4444;
542 break; 535 break;
543 case 32: 536
544 fmt = ARGB8888; 537 case DRM_FORMAT_RGB565:
538 fmt = MXR_FORMAT_RGB565;
539 break;
540
541 case DRM_FORMAT_XRGB8888:
542 case DRM_FORMAT_ARGB8888:
543 fmt = MXR_FORMAT_ARGB8888;
545 break; 544 break;
545
546 default: 546 default:
547 fmt = ARGB8888; 547 DRM_DEBUG_KMS("pixelformat unsupported by mixer\n");
548 return;
548 } 549 }
549 550
550 /* check if mixer supports requested scaling setup */ 551 /* check if mixer supports requested scaling setup */
@@ -617,6 +618,8 @@ static void mixer_graph_buffer(struct mixer_context *ctx, int win)
617 618
618 mixer_vsync_set_update(ctx, true); 619 mixer_vsync_set_update(ctx, true);
619 spin_unlock_irqrestore(&res->reg_slock, flags); 620 spin_unlock_irqrestore(&res->reg_slock, flags);
621
622 mixer_regs_dump(ctx);
620} 623}
621 624
622static void vp_win_reset(struct mixer_context *ctx) 625static void vp_win_reset(struct mixer_context *ctx)
@@ -1070,6 +1073,7 @@ static void mixer_poweroff(struct mixer_context *ctx)
1070 mutex_unlock(&ctx->mixer_mutex); 1073 mutex_unlock(&ctx->mixer_mutex);
1071 1074
1072 mixer_stop(ctx); 1075 mixer_stop(ctx);
1076 mixer_regs_dump(ctx);
1073 mixer_window_suspend(ctx); 1077 mixer_window_suspend(ctx);
1074 1078
1075 ctx->int_en = mixer_reg_read(res, MXR_INT_EN); 1079 ctx->int_en = mixer_reg_read(res, MXR_INT_EN);
@@ -1126,7 +1130,7 @@ int mixer_check_mode(struct drm_display_mode *mode)
1126 return -EINVAL; 1130 return -EINVAL;
1127} 1131}
1128 1132
1129static struct exynos_drm_crtc_ops mixer_crtc_ops = { 1133static const struct exynos_drm_crtc_ops mixer_crtc_ops = {
1130 .dpms = mixer_dpms, 1134 .dpms = mixer_dpms,
1131 .enable_vblank = mixer_enable_vblank, 1135 .enable_vblank = mixer_enable_vblank,
1132 .disable_vblank = mixer_disable_vblank, 1136 .disable_vblank = mixer_disable_vblank,
@@ -1156,7 +1160,7 @@ static struct mixer_drv_data exynos4210_mxr_drv_data = {
1156 .has_sclk = 1, 1160 .has_sclk = 1,
1157}; 1161};
1158 1162
1159static struct platform_device_id mixer_driver_types[] = { 1163static const struct platform_device_id mixer_driver_types[] = {
1160 { 1164 {
1161 .name = "s5p-mixer", 1165 .name = "s5p-mixer",
1162 .driver_data = (unsigned long)&exynos4210_mxr_drv_data, 1166 .driver_data = (unsigned long)&exynos4210_mxr_drv_data,
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 007c7d7d8295..dc55c51964ab 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1667,12 +1667,15 @@ static int i915_sr_status(struct seq_file *m, void *unused)
1667 1667
1668 if (HAS_PCH_SPLIT(dev)) 1668 if (HAS_PCH_SPLIT(dev))
1669 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN; 1669 sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
1670 else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev)) 1670 else if (IS_CRESTLINE(dev) || IS_G4X(dev) ||
1671 IS_I945G(dev) || IS_I945GM(dev))
1671 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN; 1672 sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
1672 else if (IS_I915GM(dev)) 1673 else if (IS_I915GM(dev))
1673 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN; 1674 sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
1674 else if (IS_PINEVIEW(dev)) 1675 else if (IS_PINEVIEW(dev))
1675 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN; 1676 sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
1677 else if (IS_VALLEYVIEW(dev))
1678 sr_enabled = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
1676 1679
1677 intel_runtime_pm_put(dev_priv); 1680 intel_runtime_pm_put(dev_priv);
1678 1681
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index c302ffb5a168..a19d2c71e205 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -699,6 +699,16 @@ static int i915_drm_resume(struct drm_device *dev)
699 intel_init_pch_refclk(dev); 699 intel_init_pch_refclk(dev);
700 drm_mode_config_reset(dev); 700 drm_mode_config_reset(dev);
701 701
702 /*
703 * Interrupts have to be enabled before any batches are run. If not the
704 * GPU will hang. i915_gem_init_hw() will initiate batches to
705 * update/restore the context.
706 *
707 * Modeset enabling in intel_modeset_init_hw() also needs working
708 * interrupts.
709 */
710 intel_runtime_pm_enable_interrupts(dev_priv);
711
702 mutex_lock(&dev->struct_mutex); 712 mutex_lock(&dev->struct_mutex);
703 if (i915_gem_init_hw(dev)) { 713 if (i915_gem_init_hw(dev)) {
704 DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n"); 714 DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n");
@@ -706,9 +716,6 @@ static int i915_drm_resume(struct drm_device *dev)
706 } 716 }
707 mutex_unlock(&dev->struct_mutex); 717 mutex_unlock(&dev->struct_mutex);
708 718
709 /* We need working interrupts for modeset enabling ... */
710 intel_runtime_pm_enable_interrupts(dev_priv);
711
712 intel_modeset_init_hw(dev); 719 intel_modeset_init_hw(dev);
713 720
714 spin_lock_irq(&dev_priv->irq_lock); 721 spin_lock_irq(&dev_priv->irq_lock);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 53394f998a1f..851b585987f9 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2656,9 +2656,6 @@ void i915_gem_reset(struct drm_device *dev)
2656void 2656void
2657i915_gem_retire_requests_ring(struct intel_engine_cs *ring) 2657i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
2658{ 2658{
2659 if (list_empty(&ring->request_list))
2660 return;
2661
2662 WARN_ON(i915_verify_lists(ring->dev)); 2659 WARN_ON(i915_verify_lists(ring->dev));
2663 2660
2664 /* Retire requests first as we use it above for the early return. 2661 /* Retire requests first as we use it above for the early return.
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 3da1af46625c..773d1d24e604 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -6074,6 +6074,8 @@ enum skl_disp_power_wells {
6074#define GTFIFOCTL 0x120008 6074#define GTFIFOCTL 0x120008
6075#define GT_FIFO_FREE_ENTRIES_MASK 0x7f 6075#define GT_FIFO_FREE_ENTRIES_MASK 0x7f
6076#define GT_FIFO_NUM_RESERVED_ENTRIES 20 6076#define GT_FIFO_NUM_RESERVED_ENTRIES 20
6077#define GT_FIFO_CTL_BLOCK_ALL_POLICY_STALL (1 << 12)
6078#define GT_FIFO_CTL_RC6_POLICY_STALL (1 << 11)
6077 6079
6078#define HSW_IDICR 0x9008 6080#define HSW_IDICR 0x9008
6079#define IDIHASHMSK(x) (((x) & 0x3f) << 16) 6081#define IDIHASHMSK(x) (((x) & 0x3f) << 16)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d547d9c8dda2..d0f3cbc87474 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13635,9 +13635,6 @@ static const struct intel_dmi_quirk intel_dmi_quirks[] = {
13635}; 13635};
13636 13636
13637static struct intel_quirk intel_quirks[] = { 13637static struct intel_quirk intel_quirks[] = {
13638 /* HP Mini needs pipe A force quirk (LP: #322104) */
13639 { 0x27ae, 0x103c, 0x361a, quirk_pipea_force },
13640
13641 /* Toshiba Protege R-205, S-209 needs pipe A force quirk */ 13638 /* Toshiba Protege R-205, S-209 needs pipe A force quirk */
13642 { 0x2592, 0x1179, 0x0001, quirk_pipea_force }, 13639 { 0x2592, 0x1179, 0x0001, quirk_pipea_force },
13643 13640
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d0237102c27e..d714a4b5711e 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -880,10 +880,8 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
880 DP_AUX_CH_CTL_RECEIVE_ERROR)) 880 DP_AUX_CH_CTL_RECEIVE_ERROR))
881 continue; 881 continue;
882 if (status & DP_AUX_CH_CTL_DONE) 882 if (status & DP_AUX_CH_CTL_DONE)
883 break; 883 goto done;
884 } 884 }
885 if (status & DP_AUX_CH_CTL_DONE)
886 break;
887 } 885 }
888 886
889 if ((status & DP_AUX_CH_CTL_DONE) == 0) { 887 if ((status & DP_AUX_CH_CTL_DONE) == 0) {
@@ -892,6 +890,7 @@ intel_dp_aux_ch(struct intel_dp *intel_dp,
892 goto out; 890 goto out;
893 } 891 }
894 892
893done:
895 /* Check for timeout or receive error. 894 /* Check for timeout or receive error.
896 * Timeouts occur when the sink is not connected 895 * Timeouts occur when the sink is not connected
897 */ 896 */
@@ -1348,7 +1347,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
1348 1347
1349 pipe_config->has_dp_encoder = true; 1348 pipe_config->has_dp_encoder = true;
1350 pipe_config->has_drrs = false; 1349 pipe_config->has_drrs = false;
1351 pipe_config->has_audio = intel_dp->has_audio; 1350 pipe_config->has_audio = intel_dp->has_audio && port != PORT_A;
1352 1351
1353 if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) { 1352 if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
1354 intel_fixed_panel_mode(intel_connector->panel.fixed_mode, 1353 intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
@@ -2211,8 +2210,8 @@ static void intel_dp_get_config(struct intel_encoder *encoder,
2211 int dotclock; 2210 int dotclock;
2212 2211
2213 tmp = I915_READ(intel_dp->output_reg); 2212 tmp = I915_READ(intel_dp->output_reg);
2214 if (tmp & DP_AUDIO_OUTPUT_ENABLE) 2213
2215 pipe_config->has_audio = true; 2214 pipe_config->has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE && port != PORT_A;
2216 2215
2217 if ((port == PORT_A) || !HAS_PCH_CPT(dev)) { 2216 if ((port == PORT_A) || !HAS_PCH_CPT(dev)) {
2218 if (tmp & DP_SYNC_HS_HIGH) 2217 if (tmp & DP_SYNC_HS_HIGH)
@@ -3812,7 +3811,8 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
3812 if (val == 0) 3811 if (val == 0)
3813 break; 3812 break;
3814 3813
3815 intel_dp->sink_rates[i] = val * 200; 3814 /* Value read is in kHz while drm clock is saved in deca-kHz */
3815 intel_dp->sink_rates[i] = (val * 200) / 10;
3816 } 3816 }
3817 intel_dp->num_sink_rates = i; 3817 intel_dp->num_sink_rates = i;
3818 } 3818 }
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 56e437e31580..ae628001fd97 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -435,7 +435,7 @@ gmbus_xfer(struct i2c_adapter *adapter,
435 struct intel_gmbus, 435 struct intel_gmbus,
436 adapter); 436 adapter);
437 struct drm_i915_private *dev_priv = bus->dev_priv; 437 struct drm_i915_private *dev_priv = bus->dev_priv;
438 int i, reg_offset; 438 int i = 0, inc, try = 0, reg_offset;
439 int ret = 0; 439 int ret = 0;
440 440
441 intel_aux_display_runtime_get(dev_priv); 441 intel_aux_display_runtime_get(dev_priv);
@@ -448,12 +448,14 @@ gmbus_xfer(struct i2c_adapter *adapter,
448 448
449 reg_offset = dev_priv->gpio_mmio_base; 449 reg_offset = dev_priv->gpio_mmio_base;
450 450
451retry:
451 I915_WRITE(GMBUS0 + reg_offset, bus->reg0); 452 I915_WRITE(GMBUS0 + reg_offset, bus->reg0);
452 453
453 for (i = 0; i < num; i++) { 454 for (; i < num; i += inc) {
455 inc = 1;
454 if (gmbus_is_index_read(msgs, i, num)) { 456 if (gmbus_is_index_read(msgs, i, num)) {
455 ret = gmbus_xfer_index_read(dev_priv, &msgs[i]); 457 ret = gmbus_xfer_index_read(dev_priv, &msgs[i]);
456 i += 1; /* set i to the index of the read xfer */ 458 inc = 2; /* an index read is two msgs */
457 } else if (msgs[i].flags & I2C_M_RD) { 459 } else if (msgs[i].flags & I2C_M_RD) {
458 ret = gmbus_xfer_read(dev_priv, &msgs[i], 0); 460 ret = gmbus_xfer_read(dev_priv, &msgs[i], 0);
459 } else { 461 } else {
@@ -525,6 +527,18 @@ clear_err:
525 adapter->name, msgs[i].addr, 527 adapter->name, msgs[i].addr,
526 (msgs[i].flags & I2C_M_RD) ? 'r' : 'w', msgs[i].len); 528 (msgs[i].flags & I2C_M_RD) ? 'r' : 'w', msgs[i].len);
527 529
530 /*
531 * Passive adapters sometimes NAK the first probe. Retry the first
532 * message once on -ENXIO for GMBUS transfers; the bit banging algorithm
533 * has retries internally. See also the retry loop in
534 * drm_do_probe_ddc_edid, which bails out on the first -ENXIO.
535 */
536 if (ret == -ENXIO && i == 0 && try++ == 0) {
537 DRM_DEBUG_KMS("GMBUS [%s] NAK on first message, retry\n",
538 adapter->name);
539 goto retry;
540 }
541
528 goto out; 542 goto out;
529 543
530timeout: 544timeout:
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 09df74b8e917..424e62197787 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1134,6 +1134,12 @@ static int gen8_init_common_ring(struct intel_engine_cs *ring)
1134 I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask)); 1134 I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask));
1135 I915_WRITE(RING_HWSTAM(ring->mmio_base), 0xffffffff); 1135 I915_WRITE(RING_HWSTAM(ring->mmio_base), 0xffffffff);
1136 1136
1137 if (ring->status_page.obj) {
1138 I915_WRITE(RING_HWS_PGA(ring->mmio_base),
1139 (u32)ring->status_page.gfx_addr);
1140 POSTING_READ(RING_HWS_PGA(ring->mmio_base));
1141 }
1142
1137 I915_WRITE(RING_MODE_GEN7(ring), 1143 I915_WRITE(RING_MODE_GEN7(ring),
1138 _MASKED_BIT_DISABLE(GFX_REPLAY_MODE) | 1144 _MASKED_BIT_DISABLE(GFX_REPLAY_MODE) |
1139 _MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE)); 1145 _MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE));
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 5abda1d2c018..fbcc7dff0d63 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -813,12 +813,28 @@ static int intel_dual_link_lvds_callback(const struct dmi_system_id *id)
813static const struct dmi_system_id intel_dual_link_lvds[] = { 813static const struct dmi_system_id intel_dual_link_lvds[] = {
814 { 814 {
815 .callback = intel_dual_link_lvds_callback, 815 .callback = intel_dual_link_lvds_callback,
816 .ident = "Apple MacBook Pro (Core i5/i7 Series)", 816 .ident = "Apple MacBook Pro 15\" (2010)",
817 .matches = {
818 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
819 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro6,2"),
820 },
821 },
822 {
823 .callback = intel_dual_link_lvds_callback,
824 .ident = "Apple MacBook Pro 15\" (2011)",
817 .matches = { 825 .matches = {
818 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 826 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
819 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"), 827 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
820 }, 828 },
821 }, 829 },
830 {
831 .callback = intel_dual_link_lvds_callback,
832 .ident = "Apple MacBook Pro 15\" (2012)",
833 .matches = {
834 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
835 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro9,1"),
836 },
837 },
822 { } /* terminating entry */ 838 { } /* terminating entry */
823}; 839};
824 840
@@ -848,6 +864,11 @@ static bool compute_is_dual_link_lvds(struct intel_lvds_encoder *lvds_encoder)
848 if (i915.lvds_channel_mode > 0) 864 if (i915.lvds_channel_mode > 0)
849 return i915.lvds_channel_mode == 2; 865 return i915.lvds_channel_mode == 2;
850 866
867 /* single channel LVDS is limited to 112 MHz */
868 if (lvds_encoder->attached_connector->base.panel.fixed_mode->clock
869 > 112999)
870 return true;
871
851 if (dmi_check_system(intel_dual_link_lvds)) 872 if (dmi_check_system(intel_dual_link_lvds))
852 return true; 873 return true;
853 874
@@ -1111,6 +1132,8 @@ void intel_lvds_init(struct drm_device *dev)
1111out: 1132out:
1112 mutex_unlock(&dev->mode_config.mutex); 1133 mutex_unlock(&dev->mode_config.mutex);
1113 1134
1135 intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
1136
1114 lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder); 1137 lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
1115 DRM_DEBUG_KMS("detected %s-link lvds configuration\n", 1138 DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
1116 lvds_encoder->is_dual_link ? "dual" : "single"); 1139 lvds_encoder->is_dual_link ? "dual" : "single");
@@ -1125,7 +1148,6 @@ out:
1125 } 1148 }
1126 drm_connector_register(connector); 1149 drm_connector_register(connector);
1127 1150
1128 intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
1129 intel_panel_setup_backlight(connector, INVALID_PIPE); 1151 intel_panel_setup_backlight(connector, INVALID_PIPE);
1130 1152
1131 return; 1153 return;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index fa4ccb346389..555b896d2bda 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2045,22 +2045,20 @@ static void ilk_compute_wm_parameters(struct drm_crtc *crtc,
2045 p->pipe_htotal = intel_crtc->config->base.adjusted_mode.crtc_htotal; 2045 p->pipe_htotal = intel_crtc->config->base.adjusted_mode.crtc_htotal;
2046 p->pixel_rate = ilk_pipe_pixel_rate(dev, crtc); 2046 p->pixel_rate = ilk_pipe_pixel_rate(dev, crtc);
2047 2047
2048 if (crtc->primary->state->fb) { 2048 if (crtc->primary->state->fb)
2049 p->pri.enabled = true;
2050 p->pri.bytes_per_pixel = 2049 p->pri.bytes_per_pixel =
2051 crtc->primary->state->fb->bits_per_pixel / 8; 2050 crtc->primary->state->fb->bits_per_pixel / 8;
2052 } else { 2051 else
2053 p->pri.enabled = false; 2052 p->pri.bytes_per_pixel = 4;
2054 p->pri.bytes_per_pixel = 0; 2053
2055 } 2054 p->cur.bytes_per_pixel = 4;
2055 /*
2056 * TODO: for now, assume primary and cursor planes are always enabled.
2057 * Setting them to false makes the screen flicker.
2058 */
2059 p->pri.enabled = true;
2060 p->cur.enabled = true;
2056 2061
2057 if (crtc->cursor->state->fb) {
2058 p->cur.enabled = true;
2059 p->cur.bytes_per_pixel = 4;
2060 } else {
2061 p->cur.enabled = false;
2062 p->cur.bytes_per_pixel = 0;
2063 }
2064 p->pri.horiz_pixels = intel_crtc->config->pipe_src_w; 2062 p->pri.horiz_pixels = intel_crtc->config->pipe_src_w;
2065 p->cur.horiz_pixels = intel_crtc->base.cursor->state->crtc_w; 2063 p->cur.horiz_pixels = intel_crtc->base.cursor->state->crtc_w;
2066 2064
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 441e2502b889..005b5e04de4d 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -901,13 +901,6 @@ static int chv_init_workarounds(struct intel_engine_cs *ring)
901 GEN6_WIZ_HASHING_MASK, 901 GEN6_WIZ_HASHING_MASK,
902 GEN6_WIZ_HASHING_16x4); 902 GEN6_WIZ_HASHING_16x4);
903 903
904 if (INTEL_REVID(dev) == SKL_REVID_C0 ||
905 INTEL_REVID(dev) == SKL_REVID_D0)
906 /* WaBarrierPerformanceFixDisable:skl */
907 WA_SET_BIT_MASKED(HDC_CHICKEN0,
908 HDC_FENCE_DEST_SLM_DISABLE |
909 HDC_BARRIER_PERFORMANCE_DISABLE);
910
911 return 0; 904 return 0;
912} 905}
913 906
@@ -1024,6 +1017,13 @@ static int skl_init_workarounds(struct intel_engine_cs *ring)
1024 WA_SET_BIT_MASKED(HIZ_CHICKEN, 1017 WA_SET_BIT_MASKED(HIZ_CHICKEN,
1025 BDW_HIZ_POWER_COMPILER_CLOCK_GATING_DISABLE); 1018 BDW_HIZ_POWER_COMPILER_CLOCK_GATING_DISABLE);
1026 1019
1020 if (INTEL_REVID(dev) == SKL_REVID_C0 ||
1021 INTEL_REVID(dev) == SKL_REVID_D0)
1022 /* WaBarrierPerformanceFixDisable:skl */
1023 WA_SET_BIT_MASKED(HDC_CHICKEN0,
1024 HDC_FENCE_DEST_SLM_DISABLE |
1025 HDC_BARRIER_PERFORMANCE_DISABLE);
1026
1027 return skl_tune_iz_hashing(ring); 1027 return skl_tune_iz_hashing(ring);
1028} 1028}
1029 1029
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index e87d2f418de4..987b81f31b0e 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2550,7 +2550,7 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
2550 2550
2551 DRM_DEBUG_KMS("initialising analog device %d\n", device); 2551 DRM_DEBUG_KMS("initialising analog device %d\n", device);
2552 2552
2553 intel_sdvo_connector = kzalloc(sizeof(*intel_sdvo_connector), GFP_KERNEL); 2553 intel_sdvo_connector = intel_sdvo_connector_alloc();
2554 if (!intel_sdvo_connector) 2554 if (!intel_sdvo_connector)
2555 return false; 2555 return false;
2556 2556
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index ab5cc94588e1..ff2a74651dd4 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -360,6 +360,14 @@ static void __intel_uncore_early_sanitize(struct drm_device *dev,
360 __raw_i915_write32(dev_priv, GTFIFODBG, 360 __raw_i915_write32(dev_priv, GTFIFODBG,
361 __raw_i915_read32(dev_priv, GTFIFODBG)); 361 __raw_i915_read32(dev_priv, GTFIFODBG));
362 362
363 /* WaDisableShadowRegForCpd:chv */
364 if (IS_CHERRYVIEW(dev)) {
365 __raw_i915_write32(dev_priv, GTFIFOCTL,
366 __raw_i915_read32(dev_priv, GTFIFOCTL) |
367 GT_FIFO_CTL_BLOCK_ALL_POLICY_STALL |
368 GT_FIFO_CTL_RC6_POLICY_STALL);
369 }
370
363 intel_uncore_forcewake_reset(dev, restore_forcewake); 371 intel_uncore_forcewake_reset(dev, restore_forcewake);
364} 372}
365 373
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 94a5bee69fe7..bbdcab0a56c1 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -384,7 +384,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *gpu)
384 if (gpu->memptrs_bo) { 384 if (gpu->memptrs_bo) {
385 if (gpu->memptrs_iova) 385 if (gpu->memptrs_iova)
386 msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id); 386 msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
387 drm_gem_object_unreference(gpu->memptrs_bo); 387 drm_gem_object_unreference_unlocked(gpu->memptrs_bo);
388 } 388 }
389 release_firmware(gpu->pm4); 389 release_firmware(gpu->pm4);
390 release_firmware(gpu->pfp); 390 release_firmware(gpu->pfp);
diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 28d1f95a90cc..ad50b80225f5 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -177,6 +177,11 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
177 goto fail; 177 goto fail;
178 } 178 }
179 179
180 for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) {
181 encoders[i]->bridge = msm_dsi->bridge;
182 msm_dsi->encoders[i] = encoders[i];
183 }
184
180 msm_dsi->connector = msm_dsi_manager_connector_init(msm_dsi->id); 185 msm_dsi->connector = msm_dsi_manager_connector_init(msm_dsi->id);
181 if (IS_ERR(msm_dsi->connector)) { 186 if (IS_ERR(msm_dsi->connector)) {
182 ret = PTR_ERR(msm_dsi->connector); 187 ret = PTR_ERR(msm_dsi->connector);
@@ -185,11 +190,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
185 goto fail; 190 goto fail;
186 } 191 }
187 192
188 for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) {
189 encoders[i]->bridge = msm_dsi->bridge;
190 msm_dsi->encoders[i] = encoders[i];
191 }
192
193 priv->bridges[priv->num_bridges++] = msm_dsi->bridge; 193 priv->bridges[priv->num_bridges++] = msm_dsi->bridge;
194 priv->connectors[priv->num_connectors++] = msm_dsi->connector; 194 priv->connectors[priv->num_connectors++] = msm_dsi->connector;
195 195
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 956b22492c9a..649d20d29f92 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1023,7 +1023,7 @@ static int dsi_short_read1_resp(u8 *buf, const struct mipi_dsi_msg *msg)
1023 *data = buf[1]; /* strip out dcs type */ 1023 *data = buf[1]; /* strip out dcs type */
1024 return 1; 1024 return 1;
1025 } else { 1025 } else {
1026 pr_err("%s: read data does not match with rx_buf len %d\n", 1026 pr_err("%s: read data does not match with rx_buf len %zu\n",
1027 __func__, msg->rx_len); 1027 __func__, msg->rx_len);
1028 return -EINVAL; 1028 return -EINVAL;
1029 } 1029 }
@@ -1040,7 +1040,7 @@ static int dsi_short_read2_resp(u8 *buf, const struct mipi_dsi_msg *msg)
1040 data[1] = buf[2]; 1040 data[1] = buf[2];
1041 return 2; 1041 return 2;
1042 } else { 1042 } else {
1043 pr_err("%s: read data does not match with rx_buf len %d\n", 1043 pr_err("%s: read data does not match with rx_buf len %zu\n",
1044 __func__, msg->rx_len); 1044 __func__, msg->rx_len);
1045 return -EINVAL; 1045 return -EINVAL;
1046 } 1046 }
@@ -1093,7 +1093,6 @@ static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host,
1093{ 1093{
1094 u32 *lp, *temp, data; 1094 u32 *lp, *temp, data;
1095 int i, j = 0, cnt; 1095 int i, j = 0, cnt;
1096 bool ack_error = false;
1097 u32 read_cnt; 1096 u32 read_cnt;
1098 u8 reg[16]; 1097 u8 reg[16];
1099 int repeated_bytes = 0; 1098 int repeated_bytes = 0;
@@ -1105,15 +1104,10 @@ static int dsi_cmd_dma_rx(struct msm_dsi_host *msm_host,
1105 if (cnt > 4) 1104 if (cnt > 4)
1106 cnt = 4; /* 4 x 32 bits registers only */ 1105 cnt = 4; /* 4 x 32 bits registers only */
1107 1106
1108 /* Calculate real read data count */ 1107 if (rx_byte == 4)
1109 read_cnt = dsi_read(msm_host, 0x1d4) >> 16; 1108 read_cnt = 4;
1110 1109 else
1111 ack_error = (rx_byte == 4) ? 1110 read_cnt = pkt_size + 6;
1112 (read_cnt == 8) : /* short pkt + 4-byte error pkt */
1113 (read_cnt == (pkt_size + 6 + 4)); /* long pkt+4-byte error pkt*/
1114
1115 if (ack_error)
1116 read_cnt -= 4; /* Remove 4 byte error pkt */
1117 1111
1118 /* 1112 /*
1119 * In case of multiple reads from the panel, after the first read, there 1113 * In case of multiple reads from the panel, after the first read, there
@@ -1215,7 +1209,7 @@ static void dsi_err_worker(struct work_struct *work)
1215 container_of(work, struct msm_dsi_host, err_work); 1209 container_of(work, struct msm_dsi_host, err_work);
1216 u32 status = msm_host->err_work_state; 1210 u32 status = msm_host->err_work_state;
1217 1211
1218 pr_err("%s: status=%x\n", __func__, status); 1212 pr_err_ratelimited("%s: status=%x\n", __func__, status);
1219 if (status & DSI_ERR_STATE_MDP_FIFO_UNDERFLOW) 1213 if (status & DSI_ERR_STATE_MDP_FIFO_UNDERFLOW)
1220 dsi_sw_reset_restore(msm_host); 1214 dsi_sw_reset_restore(msm_host);
1221 1215
@@ -1797,6 +1791,7 @@ int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
1797 case MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT: 1791 case MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT:
1798 pr_err("%s: rx ACK_ERR_PACLAGE\n", __func__); 1792 pr_err("%s: rx ACK_ERR_PACLAGE\n", __func__);
1799 ret = 0; 1793 ret = 0;
1794 break;
1800 case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE: 1795 case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE:
1801 case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE: 1796 case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
1802 ret = dsi_short_read1_resp(buf, msg); 1797 ret = dsi_short_read1_resp(buf, msg);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index ee3ebcaa33f5..0a40f3c64e8b 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -462,7 +462,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
462 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); 462 struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
463 struct drm_connector *connector = NULL; 463 struct drm_connector *connector = NULL;
464 struct dsi_connector *dsi_connector; 464 struct dsi_connector *dsi_connector;
465 int ret; 465 int ret, i;
466 466
467 dsi_connector = devm_kzalloc(msm_dsi->dev->dev, 467 dsi_connector = devm_kzalloc(msm_dsi->dev->dev,
468 sizeof(*dsi_connector), GFP_KERNEL); 468 sizeof(*dsi_connector), GFP_KERNEL);
@@ -495,6 +495,10 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
495 if (ret) 495 if (ret)
496 goto fail; 496 goto fail;
497 497
498 for (i = 0; i < MSM_DSI_ENCODER_NUM; i++)
499 drm_mode_connector_attach_encoder(connector,
500 msm_dsi->encoders[i]);
501
498 return connector; 502 return connector;
499 503
500fail: 504fail:
diff --git a/drivers/gpu/drm/msm/edp/edp_aux.c b/drivers/gpu/drm/msm/edp/edp_aux.c
index 5f5a84f6074c..208f9d47f82e 100644
--- a/drivers/gpu/drm/msm/edp/edp_aux.c
+++ b/drivers/gpu/drm/msm/edp/edp_aux.c
@@ -132,7 +132,7 @@ ssize_t edp_aux_transfer(struct drm_dp_aux *drm_aux, struct drm_dp_aux_msg *msg)
132 /* msg sanity check */ 132 /* msg sanity check */
133 if ((native && (msg->size > AUX_CMD_NATIVE_MAX)) || 133 if ((native && (msg->size > AUX_CMD_NATIVE_MAX)) ||
134 (msg->size > AUX_CMD_I2C_MAX)) { 134 (msg->size > AUX_CMD_I2C_MAX)) {
135 pr_err("%s: invalid msg: size(%d), request(%x)\n", 135 pr_err("%s: invalid msg: size(%zu), request(%x)\n",
136 __func__, msg->size, msg->request); 136 __func__, msg->size, msg->request);
137 return -EINVAL; 137 return -EINVAL;
138 } 138 }
@@ -155,7 +155,7 @@ ssize_t edp_aux_transfer(struct drm_dp_aux *drm_aux, struct drm_dp_aux_msg *msg)
155 */ 155 */
156 edp_write(aux->base + REG_EDP_AUX_TRANS_CTRL, 0); 156 edp_write(aux->base + REG_EDP_AUX_TRANS_CTRL, 0);
157 msm_edp_aux_ctrl(aux, 1); 157 msm_edp_aux_ctrl(aux, 1);
158 pr_err("%s: aux timeout, %d\n", __func__, ret); 158 pr_err("%s: aux timeout, %zd\n", __func__, ret);
159 goto unlock_exit; 159 goto unlock_exit;
160 } 160 }
161 DBG("completion"); 161 DBG("completion");
diff --git a/drivers/gpu/drm/msm/edp/edp_connector.c b/drivers/gpu/drm/msm/edp/edp_connector.c
index d8812e84da54..b4d1b469862a 100644
--- a/drivers/gpu/drm/msm/edp/edp_connector.c
+++ b/drivers/gpu/drm/msm/edp/edp_connector.c
@@ -151,6 +151,8 @@ struct drm_connector *msm_edp_connector_init(struct msm_edp *edp)
151 if (ret) 151 if (ret)
152 goto fail; 152 goto fail;
153 153
154 drm_mode_connector_attach_encoder(connector, edp->encoder);
155
154 return connector; 156 return connector;
155 157
156fail: 158fail:
diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 0ec5abdba5c4..29e52d7c61c0 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1149,12 +1149,13 @@ int msm_edp_ctrl_init(struct msm_edp *edp)
1149 ctrl->aux = msm_edp_aux_init(dev, ctrl->base, &ctrl->drm_aux); 1149 ctrl->aux = msm_edp_aux_init(dev, ctrl->base, &ctrl->drm_aux);
1150 if (!ctrl->aux || !ctrl->drm_aux) { 1150 if (!ctrl->aux || !ctrl->drm_aux) {
1151 pr_err("%s:failed to init aux\n", __func__); 1151 pr_err("%s:failed to init aux\n", __func__);
1152 return ret; 1152 return -ENOMEM;
1153 } 1153 }
1154 1154
1155 ctrl->phy = msm_edp_phy_init(dev, ctrl->base); 1155 ctrl->phy = msm_edp_phy_init(dev, ctrl->base);
1156 if (!ctrl->phy) { 1156 if (!ctrl->phy) {
1157 pr_err("%s:failed to init phy\n", __func__); 1157 pr_err("%s:failed to init phy\n", __func__);
1158 ret = -ENOMEM;
1158 goto err_destory_aux; 1159 goto err_destory_aux;
1159 } 1160 }
1160 1161
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
index e001e6b2296a..8b9a7931b162 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
@@ -72,14 +72,13 @@ const struct mdp5_cfg_hw msm8x74_config = {
72 .base = { 0x12d00, 0x12e00, 0x12f00 }, 72 .base = { 0x12d00, 0x12e00, 0x12f00 },
73 }, 73 },
74 .intf = { 74 .intf = {
75 .count = 4,
76 .base = { 0x12500, 0x12700, 0x12900, 0x12b00 }, 75 .base = { 0x12500, 0x12700, 0x12900, 0x12b00 },
77 }, 76 .connect = {
78 .intfs = { 77 [0] = INTF_eDP,
79 [0] = INTF_eDP, 78 [1] = INTF_DSI,
80 [1] = INTF_DSI, 79 [2] = INTF_DSI,
81 [2] = INTF_DSI, 80 [3] = INTF_HDMI,
82 [3] = INTF_HDMI, 81 },
83 }, 82 },
84 .max_clk = 200000000, 83 .max_clk = 200000000,
85}; 84};
@@ -142,14 +141,13 @@ const struct mdp5_cfg_hw apq8084_config = {
142 .base = { 0x12f00, 0x13000, 0x13100, 0x13200 }, 141 .base = { 0x12f00, 0x13000, 0x13100, 0x13200 },
143 }, 142 },
144 .intf = { 143 .intf = {
145 .count = 5,
146 .base = { 0x12500, 0x12700, 0x12900, 0x12b00, 0x12d00 }, 144 .base = { 0x12500, 0x12700, 0x12900, 0x12b00, 0x12d00 },
147 }, 145 .connect = {
148 .intfs = { 146 [0] = INTF_eDP,
149 [0] = INTF_eDP, 147 [1] = INTF_DSI,
150 [1] = INTF_DSI, 148 [2] = INTF_DSI,
151 [2] = INTF_DSI, 149 [3] = INTF_HDMI,
152 [3] = INTF_HDMI, 150 },
153 }, 151 },
154 .max_clk = 320000000, 152 .max_clk = 320000000,
155}; 153};
@@ -196,10 +194,12 @@ const struct mdp5_cfg_hw msm8x16_config = {
196 194
197 }, 195 },
198 .intf = { 196 .intf = {
199 .count = 1, /* INTF_1 */ 197 .base = { 0x00000, 0x6b800 },
200 .base = { 0x6B800 }, 198 .connect = {
199 [0] = INTF_DISABLED,
200 [1] = INTF_DSI,
201 },
201 }, 202 },
202 /* TODO enable .intfs[] with [1] = INTF_DSI, once DSI is implemented */
203 .max_clk = 320000000, 203 .max_clk = 320000000,
204}; 204};
205 205
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.h
index 3a551b0892d8..69349abe59f2 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.h
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.h
@@ -59,6 +59,11 @@ struct mdp5_smp_block {
59 59
60#define MDP5_INTF_NUM_MAX 5 60#define MDP5_INTF_NUM_MAX 5
61 61
62struct mdp5_intf_block {
63 uint32_t base[MAX_BASES];
64 u32 connect[MDP5_INTF_NUM_MAX]; /* array of enum mdp5_intf_type */
65};
66
62struct mdp5_cfg_hw { 67struct mdp5_cfg_hw {
63 char *name; 68 char *name;
64 69
@@ -72,9 +77,7 @@ struct mdp5_cfg_hw {
72 struct mdp5_sub_block dspp; 77 struct mdp5_sub_block dspp;
73 struct mdp5_sub_block ad; 78 struct mdp5_sub_block ad;
74 struct mdp5_sub_block pp; 79 struct mdp5_sub_block pp;
75 struct mdp5_sub_block intf; 80 struct mdp5_intf_block intf;
76
77 u32 intfs[MDP5_INTF_NUM_MAX]; /* array of enum mdp5_intf_type */
78 81
79 uint32_t max_clk; 82 uint32_t max_clk;
80}; 83};
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index dfa8beb9343a..bbacf9d2b738 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -206,8 +206,8 @@ static struct drm_encoder *construct_encoder(struct mdp5_kms *mdp5_kms,
206 206
207static int get_dsi_id_from_intf(const struct mdp5_cfg_hw *hw_cfg, int intf_num) 207static int get_dsi_id_from_intf(const struct mdp5_cfg_hw *hw_cfg, int intf_num)
208{ 208{
209 const int intf_cnt = hw_cfg->intf.count; 209 const enum mdp5_intf_type *intfs = hw_cfg->intf.connect;
210 const u32 *intfs = hw_cfg->intfs; 210 const int intf_cnt = ARRAY_SIZE(hw_cfg->intf.connect);
211 int id = 0, i; 211 int id = 0, i;
212 212
213 for (i = 0; i < intf_cnt; i++) { 213 for (i = 0; i < intf_cnt; i++) {
@@ -228,7 +228,7 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num)
228 struct msm_drm_private *priv = dev->dev_private; 228 struct msm_drm_private *priv = dev->dev_private;
229 const struct mdp5_cfg_hw *hw_cfg = 229 const struct mdp5_cfg_hw *hw_cfg =
230 mdp5_cfg_get_hw_config(mdp5_kms->cfg); 230 mdp5_cfg_get_hw_config(mdp5_kms->cfg);
231 enum mdp5_intf_type intf_type = hw_cfg->intfs[intf_num]; 231 enum mdp5_intf_type intf_type = hw_cfg->intf.connect[intf_num];
232 struct drm_encoder *encoder; 232 struct drm_encoder *encoder;
233 int ret = 0; 233 int ret = 0;
234 234
@@ -365,7 +365,7 @@ static int modeset_init(struct mdp5_kms *mdp5_kms)
365 /* Construct encoders and modeset initialize connector devices 365 /* Construct encoders and modeset initialize connector devices
366 * for each external display interface. 366 * for each external display interface.
367 */ 367 */
368 for (i = 0; i < ARRAY_SIZE(hw_cfg->intfs); i++) { 368 for (i = 0; i < ARRAY_SIZE(hw_cfg->intf.connect); i++) {
369 ret = modeset_init_intf(mdp5_kms, i); 369 ret = modeset_init_intf(mdp5_kms, i);
370 if (ret) 370 if (ret)
371 goto fail; 371 goto fail;
@@ -514,8 +514,8 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
514 */ 514 */
515 mdp5_enable(mdp5_kms); 515 mdp5_enable(mdp5_kms);
516 for (i = 0; i < MDP5_INTF_NUM_MAX; i++) { 516 for (i = 0; i < MDP5_INTF_NUM_MAX; i++) {
517 if (!config->hw->intf.base[i] || 517 if (mdp5_cfg_intf_is_virtual(config->hw->intf.connect[i]) ||
518 mdp5_cfg_intf_is_virtual(config->hw->intfs[i])) 518 !config->hw->intf.base[i])
519 continue; 519 continue;
520 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(i), 0); 520 mdp5_write(mdp5_kms, REG_MDP5_INTF_TIMING_ENGINE_EN(i), 0);
521 } 521 }
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 18a3d203b174..57b8f56ae9d0 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -273,7 +273,7 @@ static void set_scanout_locked(struct drm_plane *plane,
273 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC2_ADDR(pipe), 273 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC2_ADDR(pipe),
274 msm_framebuffer_iova(fb, mdp5_kms->id, 2)); 274 msm_framebuffer_iova(fb, mdp5_kms->id, 2));
275 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC3_ADDR(pipe), 275 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC3_ADDR(pipe),
276 msm_framebuffer_iova(fb, mdp5_kms->id, 4)); 276 msm_framebuffer_iova(fb, mdp5_kms->id, 3));
277 277
278 plane->fb = fb; 278 plane->fb = fb;
279} 279}
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 47f4dd407671..c80a6bee2b18 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -21,9 +21,11 @@
21 21
22static void msm_fb_output_poll_changed(struct drm_device *dev) 22static void msm_fb_output_poll_changed(struct drm_device *dev)
23{ 23{
24#ifdef CONFIG_DRM_MSM_FBDEV
24 struct msm_drm_private *priv = dev->dev_private; 25 struct msm_drm_private *priv = dev->dev_private;
25 if (priv->fbdev) 26 if (priv->fbdev)
26 drm_fb_helper_hotplug_event(priv->fbdev); 27 drm_fb_helper_hotplug_event(priv->fbdev);
28#endif
27} 29}
28 30
29static const struct drm_mode_config_funcs mode_config_funcs = { 31static const struct drm_mode_config_funcs mode_config_funcs = {
@@ -94,7 +96,7 @@ void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
94 } 96 }
95 97
96 if (reglog) 98 if (reglog)
97 printk(KERN_DEBUG "IO:region %s %08x %08lx\n", dbgname, (u32)ptr, size); 99 printk(KERN_DEBUG "IO:region %s %p %08lx\n", dbgname, ptr, size);
98 100
99 return ptr; 101 return ptr;
100} 102}
@@ -102,7 +104,7 @@ void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
102void msm_writel(u32 data, void __iomem *addr) 104void msm_writel(u32 data, void __iomem *addr)
103{ 105{
104 if (reglog) 106 if (reglog)
105 printk(KERN_DEBUG "IO:W %08x %08x\n", (u32)addr, data); 107 printk(KERN_DEBUG "IO:W %p %08x\n", addr, data);
106 writel(data, addr); 108 writel(data, addr);
107} 109}
108 110
@@ -110,7 +112,7 @@ u32 msm_readl(const void __iomem *addr)
110{ 112{
111 u32 val = readl(addr); 113 u32 val = readl(addr);
112 if (reglog) 114 if (reglog)
113 printk(KERN_ERR "IO:R %08x %08x\n", (u32)addr, val); 115 printk(KERN_ERR "IO:R %p %08x\n", addr, val);
114 return val; 116 return val;
115} 117}
116 118
@@ -143,8 +145,8 @@ static int msm_unload(struct drm_device *dev)
143 if (gpu) { 145 if (gpu) {
144 mutex_lock(&dev->struct_mutex); 146 mutex_lock(&dev->struct_mutex);
145 gpu->funcs->pm_suspend(gpu); 147 gpu->funcs->pm_suspend(gpu);
146 gpu->funcs->destroy(gpu);
147 mutex_unlock(&dev->struct_mutex); 148 mutex_unlock(&dev->struct_mutex);
149 gpu->funcs->destroy(gpu);
148 } 150 }
149 151
150 if (priv->vram.paddr) { 152 if (priv->vram.paddr) {
@@ -177,7 +179,7 @@ static int get_mdp_ver(struct platform_device *pdev)
177 const struct of_device_id *match; 179 const struct of_device_id *match;
178 match = of_match_node(match_types, dev->of_node); 180 match = of_match_node(match_types, dev->of_node);
179 if (match) 181 if (match)
180 return (int)match->data; 182 return (int)(unsigned long)match->data;
181#endif 183#endif
182 return 4; 184 return 4;
183} 185}
@@ -216,7 +218,7 @@ static int msm_init_vram(struct drm_device *dev)
216 if (ret) 218 if (ret)
217 return ret; 219 return ret;
218 size = r.end - r.start; 220 size = r.end - r.start;
219 DRM_INFO("using VRAM carveout: %lx@%08x\n", size, r.start); 221 DRM_INFO("using VRAM carveout: %lx@%pa\n", size, &r.start);
220 } else 222 } else
221#endif 223#endif
222 224
@@ -283,10 +285,6 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
283 285
284 drm_mode_config_init(dev); 286 drm_mode_config_init(dev);
285 287
286 ret = msm_init_vram(dev);
287 if (ret)
288 goto fail;
289
290 platform_set_drvdata(pdev, dev); 288 platform_set_drvdata(pdev, dev);
291 289
292 /* Bind all our sub-components: */ 290 /* Bind all our sub-components: */
@@ -294,6 +292,10 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
294 if (ret) 292 if (ret)
295 return ret; 293 return ret;
296 294
295 ret = msm_init_vram(dev);
296 if (ret)
297 goto fail;
298
297 switch (get_mdp_ver(pdev)) { 299 switch (get_mdp_ver(pdev)) {
298 case 4: 300 case 4:
299 kms = mdp4_kms_init(dev); 301 kms = mdp4_kms_init(dev);
@@ -419,9 +421,11 @@ static void msm_preclose(struct drm_device *dev, struct drm_file *file)
419 421
420static void msm_lastclose(struct drm_device *dev) 422static void msm_lastclose(struct drm_device *dev)
421{ 423{
424#ifdef CONFIG_DRM_MSM_FBDEV
422 struct msm_drm_private *priv = dev->dev_private; 425 struct msm_drm_private *priv = dev->dev_private;
423 if (priv->fbdev) 426 if (priv->fbdev)
424 drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev); 427 drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev);
428#endif
425} 429}
426 430
427static irqreturn_t msm_irq(int irq, void *arg) 431static irqreturn_t msm_irq(int irq, void *arg)
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index 6b573e612f27..121713281417 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -172,8 +172,8 @@ struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
172{ 172{
173 struct msm_drm_private *priv = dev->dev_private; 173 struct msm_drm_private *priv = dev->dev_private;
174 struct msm_kms *kms = priv->kms; 174 struct msm_kms *kms = priv->kms;
175 struct msm_framebuffer *msm_fb; 175 struct msm_framebuffer *msm_fb = NULL;
176 struct drm_framebuffer *fb = NULL; 176 struct drm_framebuffer *fb;
177 const struct msm_format *format; 177 const struct msm_format *format;
178 int ret, i, n; 178 int ret, i, n;
179 unsigned int hsub, vsub; 179 unsigned int hsub, vsub;
@@ -239,8 +239,7 @@ struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
239 return fb; 239 return fb;
240 240
241fail: 241fail:
242 if (fb) 242 kfree(msm_fb);
243 msm_framebuffer_destroy(fb);
244 243
245 return ERR_PTR(ret); 244 return ERR_PTR(ret);
246} 245}
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 479d8af72bcb..52839769eb6c 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -483,7 +483,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
483 uint64_t off = drm_vma_node_start(&obj->vma_node); 483 uint64_t off = drm_vma_node_start(&obj->vma_node);
484 484
485 WARN_ON(!mutex_is_locked(&dev->struct_mutex)); 485 WARN_ON(!mutex_is_locked(&dev->struct_mutex));
486 seq_printf(m, "%08x: %c(r=%u,w=%u) %2d (%2d) %08llx %p %d\n", 486 seq_printf(m, "%08x: %c(r=%u,w=%u) %2d (%2d) %08llx %p %zu\n",
487 msm_obj->flags, is_active(msm_obj) ? 'A' : 'I', 487 msm_obj->flags, is_active(msm_obj) ? 'A' : 'I',
488 msm_obj->read_fence, msm_obj->write_fence, 488 msm_obj->read_fence, msm_obj->write_fence,
489 obj->name, obj->refcount.refcount.counter, 489 obj->name, obj->refcount.refcount.counter,
diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index 7acdaa5688b7..7ac2f1997e4a 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -60,7 +60,7 @@ static int msm_iommu_map(struct msm_mmu *mmu, uint32_t iova,
60 u32 pa = sg_phys(sg) - sg->offset; 60 u32 pa = sg_phys(sg) - sg->offset;
61 size_t bytes = sg->length + sg->offset; 61 size_t bytes = sg->length + sg->offset;
62 62
63 VERB("map[%d]: %08x %08x(%x)", i, iova, pa, bytes); 63 VERB("map[%d]: %08x %08x(%zx)", i, iova, pa, bytes);
64 64
65 ret = iommu_map(domain, da, pa, bytes, prot); 65 ret = iommu_map(domain, da, pa, bytes, prot);
66 if (ret) 66 if (ret)
@@ -99,7 +99,7 @@ static int msm_iommu_unmap(struct msm_mmu *mmu, uint32_t iova,
99 if (unmapped < bytes) 99 if (unmapped < bytes)
100 return unmapped; 100 return unmapped;
101 101
102 VERB("unmap[%d]: %08x(%x)", i, iova, bytes); 102 VERB("unmap[%d]: %08x(%zx)", i, iova, bytes);
103 103
104 BUG_ON(!PAGE_ALIGNED(bytes)); 104 BUG_ON(!PAGE_ALIGNED(bytes));
105 105
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 8171537dd7d1..1f14b908b221 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -56,6 +56,6 @@ fail:
56void msm_ringbuffer_destroy(struct msm_ringbuffer *ring) 56void msm_ringbuffer_destroy(struct msm_ringbuffer *ring)
57{ 57{
58 if (ring->bo) 58 if (ring->bo)
59 drm_gem_object_unreference(ring->bo); 59 drm_gem_object_unreference_unlocked(ring->bo);
60 kfree(ring); 60 kfree(ring);
61} 61}
diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index 0b5af0fe8659..64f8b2f687d2 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -14,7 +14,7 @@
14 14
15#define FERMI_TWOD_A 0x0000902d 15#define FERMI_TWOD_A 0x0000902d
16 16
17#define FERMI_MEMORY_TO_MEMORY_FORMAT_A 0x0000903d 17#define FERMI_MEMORY_TO_MEMORY_FORMAT_A 0x00009039
18 18
19#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040 19#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040
20#define KEPLER_INLINE_TO_MEMORY_B 0x0000a140 20#define KEPLER_INLINE_TO_MEMORY_B 0x0000a140
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c
index 2f5eadd12a9b..fdb1dcf16a59 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c
@@ -329,7 +329,6 @@ gm204_gr_init(struct nvkm_object *object)
329 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008); 329 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008);
330 330
331 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 331 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
332 printk(KERN_ERR "ppc %d %d\n", gpc, priv->ppc_nr[gpc]);
333 for (ppc = 0; ppc < priv->ppc_nr[gpc]; ppc++) 332 for (ppc = 0; ppc < priv->ppc_nr[gpc]; ppc++)
334 nv_wr32(priv, PPC_UNIT(gpc, ppc, 0x038), 0xc0000000); 333 nv_wr32(priv, PPC_UNIT(gpc, ppc, 0x038), 0xc0000000);
335 nv_wr32(priv, GPC_UNIT(gpc, 0x0420), 0xc0000000); 334 nv_wr32(priv, GPC_UNIT(gpc, 0x0420), 0xc0000000);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c
index e8778c67578e..c61102f70805 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c
@@ -90,12 +90,14 @@ gf100_devinit_disable(struct nvkm_devinit *devinit)
90 return disable; 90 return disable;
91} 91}
92 92
93static int 93int
94gf100_devinit_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 94gf100_devinit_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
95 struct nvkm_oclass *oclass, void *data, u32 size, 95 struct nvkm_oclass *oclass, void *data, u32 size,
96 struct nvkm_object **pobject) 96 struct nvkm_object **pobject)
97{ 97{
98 struct nvkm_devinit_impl *impl = (void *)oclass;
98 struct nv50_devinit_priv *priv; 99 struct nv50_devinit_priv *priv;
100 u64 disable;
99 int ret; 101 int ret;
100 102
101 ret = nvkm_devinit_create(parent, engine, oclass, &priv); 103 ret = nvkm_devinit_create(parent, engine, oclass, &priv);
@@ -103,7 +105,8 @@ gf100_devinit_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
103 if (ret) 105 if (ret)
104 return ret; 106 return ret;
105 107
106 if (nv_rd32(priv, 0x022500) & 0x00000001) 108 disable = impl->disable(&priv->base);
109 if (disable & (1ULL << NVDEV_ENGINE_DISP))
107 priv->base.post = true; 110 priv->base.post = true;
108 111
109 return 0; 112 return 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm107.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm107.c
index b345a53e881d..87ca0ece37b4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm107.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm107.c
@@ -48,7 +48,7 @@ struct nvkm_oclass *
48gm107_devinit_oclass = &(struct nvkm_devinit_impl) { 48gm107_devinit_oclass = &(struct nvkm_devinit_impl) {
49 .base.handle = NV_SUBDEV(DEVINIT, 0x07), 49 .base.handle = NV_SUBDEV(DEVINIT, 0x07),
50 .base.ofuncs = &(struct nvkm_ofuncs) { 50 .base.ofuncs = &(struct nvkm_ofuncs) {
51 .ctor = nv50_devinit_ctor, 51 .ctor = gf100_devinit_ctor,
52 .dtor = _nvkm_devinit_dtor, 52 .dtor = _nvkm_devinit_dtor,
53 .init = nv50_devinit_init, 53 .init = nv50_devinit_init,
54 .fini = _nvkm_devinit_fini, 54 .fini = _nvkm_devinit_fini,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm204.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm204.c
index 535172c5f1ad..1076fcf0d716 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm204.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm204.c
@@ -161,7 +161,7 @@ struct nvkm_oclass *
161gm204_devinit_oclass = &(struct nvkm_devinit_impl) { 161gm204_devinit_oclass = &(struct nvkm_devinit_impl) {
162 .base.handle = NV_SUBDEV(DEVINIT, 0x07), 162 .base.handle = NV_SUBDEV(DEVINIT, 0x07),
163 .base.ofuncs = &(struct nvkm_ofuncs) { 163 .base.ofuncs = &(struct nvkm_ofuncs) {
164 .ctor = nv50_devinit_ctor, 164 .ctor = gf100_devinit_ctor,
165 .dtor = _nvkm_devinit_dtor, 165 .dtor = _nvkm_devinit_dtor,
166 .init = nv50_devinit_init, 166 .init = nv50_devinit_init,
167 .fini = _nvkm_devinit_fini, 167 .fini = _nvkm_devinit_fini,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.h b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.h
index b882b65ff3cd..9243521c80ac 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.h
@@ -15,6 +15,9 @@ int nv50_devinit_pll_set(struct nvkm_devinit *, u32, u32);
15 15
16int gt215_devinit_pll_set(struct nvkm_devinit *, u32, u32); 16int gt215_devinit_pll_set(struct nvkm_devinit *, u32, u32);
17 17
18int gf100_devinit_ctor(struct nvkm_object *, struct nvkm_object *,
19 struct nvkm_oclass *, void *, u32,
20 struct nvkm_object **);
18int gf100_devinit_pll_set(struct nvkm_devinit *, u32, u32); 21int gf100_devinit_pll_set(struct nvkm_devinit *, u32, u32);
19 22
20u64 gm107_devinit_disable(struct nvkm_devinit *); 23u64 gm107_devinit_disable(struct nvkm_devinit *);
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 3e3290c203c6..b435c859dcbc 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -421,19 +421,21 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector)
421{ 421{
422 struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv; 422 struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv;
423 u8 msg[DP_DPCD_SIZE]; 423 u8 msg[DP_DPCD_SIZE];
424 int ret; 424 int ret, i;
425 425
426 ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg, 426 for (i = 0; i < 7; i++) {
427 DP_DPCD_SIZE); 427 ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg,
428 if (ret > 0) { 428 DP_DPCD_SIZE);
429 memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); 429 if (ret == DP_DPCD_SIZE) {
430 memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
430 431
431 DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd), 432 DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
432 dig_connector->dpcd); 433 dig_connector->dpcd);
433 434
434 radeon_dp_probe_oui(radeon_connector); 435 radeon_dp_probe_oui(radeon_connector);
435 436
436 return true; 437 return true;
438 }
437 } 439 }
438 dig_connector->dpcd[0] = 0; 440 dig_connector->dpcd[0] = 0;
439 return false; 441 return false;
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index f57c1ab617bc..dd39f434b4a7 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -1761,17 +1761,15 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1761 struct drm_device *dev = encoder->dev; 1761 struct drm_device *dev = encoder->dev;
1762 struct radeon_device *rdev = dev->dev_private; 1762 struct radeon_device *rdev = dev->dev_private;
1763 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1763 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1764 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1765 int encoder_mode = atombios_get_encoder_mode(encoder); 1764 int encoder_mode = atombios_get_encoder_mode(encoder);
1766 1765
1767 DRM_DEBUG_KMS("encoder dpms %d to mode %d, devices %08x, active_devices %08x\n", 1766 DRM_DEBUG_KMS("encoder dpms %d to mode %d, devices %08x, active_devices %08x\n",
1768 radeon_encoder->encoder_id, mode, radeon_encoder->devices, 1767 radeon_encoder->encoder_id, mode, radeon_encoder->devices,
1769 radeon_encoder->active_device); 1768 radeon_encoder->active_device);
1770 1769
1771 if (connector && (radeon_audio != 0) && 1770 if ((radeon_audio != 0) &&
1772 ((encoder_mode == ATOM_ENCODER_MODE_HDMI) || 1771 ((encoder_mode == ATOM_ENCODER_MODE_HDMI) ||
1773 (ENCODER_MODE_IS_DP(encoder_mode) && 1772 ENCODER_MODE_IS_DP(encoder_mode)))
1774 drm_detect_monitor_audio(radeon_connector_edid(connector)))))
1775 radeon_audio_dpms(encoder, mode); 1773 radeon_audio_dpms(encoder, mode);
1776 1774
1777 switch (radeon_encoder->encoder_id) { 1775 switch (radeon_encoder->encoder_id) {
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 28faea9996f9..ba50f3c1c2e0 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -5837,7 +5837,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
5837 /* restore context1-15 */ 5837 /* restore context1-15 */
5838 /* set vm size, must be a multiple of 4 */ 5838 /* set vm size, must be a multiple of 4 */
5839 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); 5839 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
5840 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); 5840 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn - 1);
5841 for (i = 1; i < 16; i++) { 5841 for (i = 1; i < 16; i++) {
5842 if (i < 8) 5842 if (i < 8)
5843 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 5843 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
diff --git a/drivers/gpu/drm/radeon/dce3_1_afmt.c b/drivers/gpu/drm/radeon/dce3_1_afmt.c
index f04205170b8a..cfa3a84a2af0 100644
--- a/drivers/gpu/drm/radeon/dce3_1_afmt.c
+++ b/drivers/gpu/drm/radeon/dce3_1_afmt.c
@@ -173,7 +173,7 @@ void dce3_2_hdmi_update_acr(struct drm_encoder *encoder, long offset,
173 struct drm_device *dev = encoder->dev; 173 struct drm_device *dev = encoder->dev;
174 struct radeon_device *rdev = dev->dev_private; 174 struct radeon_device *rdev = dev->dev_private;
175 175
176 WREG32(HDMI0_ACR_PACKET_CONTROL + offset, 176 WREG32(DCE3_HDMI0_ACR_PACKET_CONTROL + offset,
177 HDMI0_ACR_SOURCE | /* select SW CTS value */ 177 HDMI0_ACR_SOURCE | /* select SW CTS value */
178 HDMI0_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */ 178 HDMI0_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */
179 179
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c
index 3adc2afe32aa..68fd9fc677e3 100644
--- a/drivers/gpu/drm/radeon/dce6_afmt.c
+++ b/drivers/gpu/drm/radeon/dce6_afmt.c
@@ -295,28 +295,3 @@ void dce6_dp_audio_set_dto(struct radeon_device *rdev,
295 WREG32(DCCG_AUDIO_DTO1_MODULE, clock); 295 WREG32(DCCG_AUDIO_DTO1_MODULE, clock);
296 } 296 }
297} 297}
298
299void dce6_dp_enable(struct drm_encoder *encoder, bool enable)
300{
301 struct drm_device *dev = encoder->dev;
302 struct radeon_device *rdev = dev->dev_private;
303 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
304 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
305
306 if (!dig || !dig->afmt)
307 return;
308
309 if (enable) {
310 WREG32(EVERGREEN_DP_SEC_TIMESTAMP + dig->afmt->offset,
311 EVERGREEN_DP_SEC_TIMESTAMP_MODE(1));
312 WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset,
313 EVERGREEN_DP_SEC_ASP_ENABLE | /* Audio packet transmission */
314 EVERGREEN_DP_SEC_ATP_ENABLE | /* Audio timestamp packet transmission */
315 EVERGREEN_DP_SEC_AIP_ENABLE | /* Audio infoframe packet transmission */
316 EVERGREEN_DP_SEC_STREAM_ENABLE); /* Master enable for secondary stream engine */
317 } else {
318 WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset, 0);
319 }
320
321 dig->afmt->enabled = enable;
322}
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index c18d4ecbd95d..9953356fe263 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -219,13 +219,9 @@ void evergreen_set_avi_packet(struct radeon_device *rdev, u32 offset,
219 WREG32(AFMT_AVI_INFO3 + offset, 219 WREG32(AFMT_AVI_INFO3 + offset,
220 frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24)); 220 frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24));
221 221
222 WREG32_OR(HDMI_INFOFRAME_CONTROL0 + offset,
223 HDMI_AVI_INFO_SEND | /* enable AVI info frames */
224 HDMI_AVI_INFO_CONT); /* required for audio info values to be updated */
225
226 WREG32_P(HDMI_INFOFRAME_CONTROL1 + offset, 222 WREG32_P(HDMI_INFOFRAME_CONTROL1 + offset,
227 HDMI_AVI_INFO_LINE(2), /* anything other than 0 */ 223 HDMI_AVI_INFO_LINE(2), /* anything other than 0 */
228 ~HDMI_AVI_INFO_LINE_MASK); 224 ~HDMI_AVI_INFO_LINE_MASK);
229} 225}
230 226
231void dce4_hdmi_audio_set_dto(struct radeon_device *rdev, 227void dce4_hdmi_audio_set_dto(struct radeon_device *rdev,
@@ -370,9 +366,13 @@ void dce4_set_audio_packet(struct drm_encoder *encoder, u32 offset)
370 WREG32(AFMT_AUDIO_PACKET_CONTROL2 + offset, 366 WREG32(AFMT_AUDIO_PACKET_CONTROL2 + offset,
371 AFMT_AUDIO_CHANNEL_ENABLE(0xff)); 367 AFMT_AUDIO_CHANNEL_ENABLE(0xff));
372 368
369 WREG32(HDMI_AUDIO_PACKET_CONTROL + offset,
370 HDMI_AUDIO_DELAY_EN(1) | /* set the default audio delay */
371 HDMI_AUDIO_PACKETS_PER_LINE(3)); /* should be suffient for all audio modes and small enough for all hblanks */
372
373 /* allow 60958 channel status and send audio packets fields to be updated */ 373 /* allow 60958 channel status and send audio packets fields to be updated */
374 WREG32(AFMT_AUDIO_PACKET_CONTROL + offset, 374 WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + offset,
375 AFMT_AUDIO_SAMPLE_SEND | AFMT_RESET_FIFO_WHEN_AUDIO_DIS | AFMT_60958_CS_UPDATE); 375 AFMT_RESET_FIFO_WHEN_AUDIO_DIS | AFMT_60958_CS_UPDATE);
376} 376}
377 377
378 378
@@ -398,17 +398,26 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
398 return; 398 return;
399 399
400 if (enable) { 400 if (enable) {
401 WREG32(HDMI_INFOFRAME_CONTROL1 + dig->afmt->offset, 401 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
402 HDMI_AUDIO_INFO_LINE(2)); /* anything other than 0 */
403
404 WREG32(HDMI_AUDIO_PACKET_CONTROL + dig->afmt->offset,
405 HDMI_AUDIO_DELAY_EN(1) | /* set the default audio delay */
406 HDMI_AUDIO_PACKETS_PER_LINE(3)); /* should be suffient for all audio modes and small enough for all hblanks */
407 402
408 WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, 403 if (connector && drm_detect_monitor_audio(radeon_connector_edid(connector))) {
409 HDMI_AUDIO_INFO_SEND | /* enable audio info frames (frames won't be set until audio is enabled) */ 404 WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
410 HDMI_AUDIO_INFO_CONT); /* required for audio info values to be updated */ 405 HDMI_AVI_INFO_SEND | /* enable AVI info frames */
406 HDMI_AVI_INFO_CONT | /* required for audio info values to be updated */
407 HDMI_AUDIO_INFO_SEND | /* enable audio info frames (frames won't be set until audio is enabled) */
408 HDMI_AUDIO_INFO_CONT); /* required for audio info values to be updated */
409 WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
410 AFMT_AUDIO_SAMPLE_SEND);
411 } else {
412 WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
413 HDMI_AVI_INFO_SEND | /* enable AVI info frames */
414 HDMI_AVI_INFO_CONT); /* required for audio info values to be updated */
415 WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
416 ~AFMT_AUDIO_SAMPLE_SEND);
417 }
411 } else { 418 } else {
419 WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
420 ~AFMT_AUDIO_SAMPLE_SEND);
412 WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, 0); 421 WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, 0);
413 } 422 }
414 423
@@ -424,20 +433,25 @@ void evergreen_dp_enable(struct drm_encoder *encoder, bool enable)
424 struct radeon_device *rdev = dev->dev_private; 433 struct radeon_device *rdev = dev->dev_private;
425 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 434 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
426 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 435 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
436 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
427 437
428 if (!dig || !dig->afmt) 438 if (!dig || !dig->afmt)
429 return; 439 return;
430 440
431 if (enable) { 441 if (enable && connector &&
442 drm_detect_monitor_audio(radeon_connector_edid(connector))) {
432 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 443 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
433 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 444 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
434 struct radeon_connector_atom_dig *dig_connector; 445 struct radeon_connector_atom_dig *dig_connector;
435 uint32_t val; 446 uint32_t val;
436 447
448 WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
449 AFMT_AUDIO_SAMPLE_SEND);
450
437 WREG32(EVERGREEN_DP_SEC_TIMESTAMP + dig->afmt->offset, 451 WREG32(EVERGREEN_DP_SEC_TIMESTAMP + dig->afmt->offset,
438 EVERGREEN_DP_SEC_TIMESTAMP_MODE(1)); 452 EVERGREEN_DP_SEC_TIMESTAMP_MODE(1));
439 453
440 if (radeon_connector->con_priv) { 454 if (!ASIC_IS_DCE6(rdev) && radeon_connector->con_priv) {
441 dig_connector = radeon_connector->con_priv; 455 dig_connector = radeon_connector->con_priv;
442 val = RREG32(EVERGREEN_DP_SEC_AUD_N + dig->afmt->offset); 456 val = RREG32(EVERGREEN_DP_SEC_AUD_N + dig->afmt->offset);
443 val &= ~EVERGREEN_DP_SEC_N_BASE_MULTIPLE(0xf); 457 val &= ~EVERGREEN_DP_SEC_N_BASE_MULTIPLE(0xf);
@@ -457,6 +471,8 @@ void evergreen_dp_enable(struct drm_encoder *encoder, bool enable)
457 EVERGREEN_DP_SEC_STREAM_ENABLE); /* Master enable for secondary stream engine */ 471 EVERGREEN_DP_SEC_STREAM_ENABLE); /* Master enable for secondary stream engine */
458 } else { 472 } else {
459 WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset, 0); 473 WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset, 0);
474 WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
475 ~AFMT_AUDIO_SAMPLE_SEND);
460 } 476 }
461 477
462 dig->afmt->enabled = enable; 478 dig->afmt->enabled = enable;
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index e8a496ff007e..64d3a771920d 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1301,7 +1301,8 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev)
1301 */ 1301 */
1302 for (i = 1; i < 8; i++) { 1302 for (i = 1; i < 8; i++) {
1303 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0); 1303 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0);
1304 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), rdev->vm_manager.max_pfn); 1304 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2),
1305 rdev->vm_manager.max_pfn - 1);
1305 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 1306 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
1306 rdev->vm_manager.saved_table_addr[i]); 1307 rdev->vm_manager.saved_table_addr[i]);
1307 } 1308 }
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index dd6606b8e23c..e85894ade95c 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -228,12 +228,13 @@ void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
228 WREG32(HDMI0_AVI_INFO3 + offset, 228 WREG32(HDMI0_AVI_INFO3 + offset,
229 frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24)); 229 frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24));
230 230
231 WREG32_OR(HDMI0_INFOFRAME_CONTROL1 + offset,
232 HDMI0_AVI_INFO_LINE(2)); /* anything other than 0 */
233
231 WREG32_OR(HDMI0_INFOFRAME_CONTROL0 + offset, 234 WREG32_OR(HDMI0_INFOFRAME_CONTROL0 + offset,
232 HDMI0_AVI_INFO_SEND | /* enable AVI info frames */ 235 HDMI0_AVI_INFO_SEND | /* enable AVI info frames */
233 HDMI0_AVI_INFO_CONT); /* send AVI info frames every frame/field */ 236 HDMI0_AVI_INFO_CONT); /* send AVI info frames every frame/field */
234 237
235 WREG32_OR(HDMI0_INFOFRAME_CONTROL1 + offset,
236 HDMI0_AVI_INFO_LINE(2)); /* anything other than 0 */
237} 238}
238 239
239/* 240/*
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index d2abe481954f..46eb0fa75a61 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1673,7 +1673,6 @@ struct radeon_uvd {
1673 struct radeon_bo *vcpu_bo; 1673 struct radeon_bo *vcpu_bo;
1674 void *cpu_addr; 1674 void *cpu_addr;
1675 uint64_t gpu_addr; 1675 uint64_t gpu_addr;
1676 void *saved_bo;
1677 atomic_t handles[RADEON_MAX_UVD_HANDLES]; 1676 atomic_t handles[RADEON_MAX_UVD_HANDLES];
1678 struct drm_file *filp[RADEON_MAX_UVD_HANDLES]; 1677 struct drm_file *filp[RADEON_MAX_UVD_HANDLES];
1679 unsigned img_size[RADEON_MAX_UVD_HANDLES]; 1678 unsigned img_size[RADEON_MAX_UVD_HANDLES];
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
index fafd8ce4d58f..8dbf5083c4ff 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -1202,7 +1202,7 @@ static struct radeon_asic rs780_asic = {
1202static struct radeon_asic_ring rv770_uvd_ring = { 1202static struct radeon_asic_ring rv770_uvd_ring = {
1203 .ib_execute = &uvd_v1_0_ib_execute, 1203 .ib_execute = &uvd_v1_0_ib_execute,
1204 .emit_fence = &uvd_v2_2_fence_emit, 1204 .emit_fence = &uvd_v2_2_fence_emit,
1205 .emit_semaphore = &uvd_v1_0_semaphore_emit, 1205 .emit_semaphore = &uvd_v2_2_semaphore_emit,
1206 .cs_parse = &radeon_uvd_cs_parse, 1206 .cs_parse = &radeon_uvd_cs_parse,
1207 .ring_test = &uvd_v1_0_ring_test, 1207 .ring_test = &uvd_v1_0_ring_test,
1208 .ib_test = &uvd_v1_0_ib_test, 1208 .ib_test = &uvd_v1_0_ib_test,
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index cf0a90bb61ca..a3ca8cd305c5 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -949,6 +949,10 @@ void uvd_v1_0_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
949int uvd_v2_2_resume(struct radeon_device *rdev); 949int uvd_v2_2_resume(struct radeon_device *rdev);
950void uvd_v2_2_fence_emit(struct radeon_device *rdev, 950void uvd_v2_2_fence_emit(struct radeon_device *rdev,
951 struct radeon_fence *fence); 951 struct radeon_fence *fence);
952bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
953 struct radeon_ring *ring,
954 struct radeon_semaphore *semaphore,
955 bool emit_wait);
952 956
953/* uvd v3.1 */ 957/* uvd v3.1 */
954bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev, 958bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c
index 48d49e651a30..25191f126f3b 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -102,7 +102,6 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder,
102void r600_hdmi_enable(struct drm_encoder *encoder, bool enable); 102void r600_hdmi_enable(struct drm_encoder *encoder, bool enable);
103void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable); 103void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable);
104void evergreen_dp_enable(struct drm_encoder *encoder, bool enable); 104void evergreen_dp_enable(struct drm_encoder *encoder, bool enable);
105void dce6_dp_enable(struct drm_encoder *encoder, bool enable);
106 105
107static const u32 pin_offsets[7] = 106static const u32 pin_offsets[7] =
108{ 107{
@@ -240,7 +239,7 @@ static struct radeon_audio_funcs dce6_dp_funcs = {
240 .set_avi_packet = evergreen_set_avi_packet, 239 .set_avi_packet = evergreen_set_avi_packet,
241 .set_audio_packet = dce4_set_audio_packet, 240 .set_audio_packet = dce4_set_audio_packet,
242 .mode_set = radeon_audio_dp_mode_set, 241 .mode_set = radeon_audio_dp_mode_set,
243 .dpms = dce6_dp_enable, 242 .dpms = evergreen_dp_enable,
244}; 243};
245 244
246static void radeon_audio_interface_init(struct radeon_device *rdev) 245static void radeon_audio_interface_init(struct radeon_device *rdev)
@@ -462,6 +461,10 @@ void radeon_audio_detect(struct drm_connector *connector,
462 return; 461 return;
463 462
464 rdev = connector->encoder->dev->dev_private; 463 rdev = connector->encoder->dev->dev_private;
464
465 if (!radeon_audio_chipset_supported(rdev))
466 return;
467
465 radeon_encoder = to_radeon_encoder(connector->encoder); 468 radeon_encoder = to_radeon_encoder(connector->encoder);
466 dig = radeon_encoder->enc_priv; 469 dig = radeon_encoder->enc_priv;
467 470
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 4d0f96cc3da4..ab39b85e0f76 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -88,7 +88,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
88 p->dma_reloc_idx = 0; 88 p->dma_reloc_idx = 0;
89 /* FIXME: we assume that each relocs use 4 dwords */ 89 /* FIXME: we assume that each relocs use 4 dwords */
90 p->nrelocs = chunk->length_dw / 4; 90 p->nrelocs = chunk->length_dw / 4;
91 p->relocs = kcalloc(p->nrelocs, sizeof(struct radeon_bo_list), GFP_KERNEL); 91 p->relocs = drm_calloc_large(p->nrelocs, sizeof(struct radeon_bo_list));
92 if (p->relocs == NULL) { 92 if (p->relocs == NULL) {
93 return -ENOMEM; 93 return -ENOMEM;
94 } 94 }
@@ -428,7 +428,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo
428 } 428 }
429 } 429 }
430 kfree(parser->track); 430 kfree(parser->track);
431 kfree(parser->relocs); 431 drm_free_large(parser->relocs);
432 drm_free_large(parser->vm_bos); 432 drm_free_large(parser->vm_bos);
433 for (i = 0; i < parser->nchunks; i++) 433 for (i = 0; i < parser->nchunks; i++)
434 drm_free_large(parser->chunks[i].kdata); 434 drm_free_large(parser->chunks[i].kdata);
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index b7ca4c514621..a7fdfa4f0857 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1463,6 +1463,21 @@ int radeon_device_init(struct radeon_device *rdev,
1463 if (r) 1463 if (r)
1464 DRM_ERROR("ib ring test failed (%d).\n", r); 1464 DRM_ERROR("ib ring test failed (%d).\n", r);
1465 1465
1466 /*
1467 * Turks/Thames GPU will freeze whole laptop if DPM is not restarted
1468 * after the CP ring have chew one packet at least. Hence here we stop
1469 * and restart DPM after the radeon_ib_ring_tests().
1470 */
1471 if (rdev->pm.dpm_enabled &&
1472 (rdev->pm.pm_method == PM_METHOD_DPM) &&
1473 (rdev->family == CHIP_TURKS) &&
1474 (rdev->flags & RADEON_IS_MOBILITY)) {
1475 mutex_lock(&rdev->pm.mutex);
1476 radeon_dpm_disable(rdev);
1477 radeon_dpm_enable(rdev);
1478 mutex_unlock(&rdev->pm.mutex);
1479 }
1480
1466 if ((radeon_testing & 1)) { 1481 if ((radeon_testing & 1)) {
1467 if (rdev->accel_working) 1482 if (rdev->accel_working)
1468 radeon_test_moves(rdev); 1483 radeon_test_moves(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_dp_auxch.c b/drivers/gpu/drm/radeon/radeon_dp_auxch.c
index bf1fecc6cceb..fcbd60bb0349 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_auxch.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_auxch.c
@@ -30,8 +30,6 @@
30 AUX_SW_RX_HPD_DISCON | \ 30 AUX_SW_RX_HPD_DISCON | \
31 AUX_SW_RX_PARTIAL_BYTE | \ 31 AUX_SW_RX_PARTIAL_BYTE | \
32 AUX_SW_NON_AUX_MODE | \ 32 AUX_SW_NON_AUX_MODE | \
33 AUX_SW_RX_MIN_COUNT_VIOL | \
34 AUX_SW_RX_INVALID_STOP | \
35 AUX_SW_RX_SYNC_INVALID_L | \ 33 AUX_SW_RX_SYNC_INVALID_L | \
36 AUX_SW_RX_SYNC_INVALID_H | \ 34 AUX_SW_RX_SYNC_INVALID_H | \
37 AUX_SW_RX_INVALID_START | \ 35 AUX_SW_RX_INVALID_START | \
diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c
index 1017338a49d9..2b98ed3e684d 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
@@ -666,6 +666,9 @@ radeon_dp_mst_probe(struct radeon_connector *radeon_connector)
666 int ret; 666 int ret;
667 u8 msg[1]; 667 u8 msg[1];
668 668
669 if (!radeon_mst)
670 return 0;
671
669 if (dig_connector->dpcd[DP_DPCD_REV] < 0x12) 672 if (dig_connector->dpcd[DP_DPCD_REV] < 0x12)
670 return 0; 673 return 0;
671 674
diff --git a/drivers/gpu/drm/radeon/radeon_mn.c b/drivers/gpu/drm/radeon/radeon_mn.c
index 01701376b239..eef006c48584 100644
--- a/drivers/gpu/drm/radeon/radeon_mn.c
+++ b/drivers/gpu/drm/radeon/radeon_mn.c
@@ -135,28 +135,31 @@ static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
135 while (it) { 135 while (it) {
136 struct radeon_mn_node *node; 136 struct radeon_mn_node *node;
137 struct radeon_bo *bo; 137 struct radeon_bo *bo;
138 int r; 138 long r;
139 139
140 node = container_of(it, struct radeon_mn_node, it); 140 node = container_of(it, struct radeon_mn_node, it);
141 it = interval_tree_iter_next(it, start, end); 141 it = interval_tree_iter_next(it, start, end);
142 142
143 list_for_each_entry(bo, &node->bos, mn_list) { 143 list_for_each_entry(bo, &node->bos, mn_list) {
144 144
145 if (!bo->tbo.ttm || bo->tbo.ttm->state != tt_bound)
146 continue;
147
145 r = radeon_bo_reserve(bo, true); 148 r = radeon_bo_reserve(bo, true);
146 if (r) { 149 if (r) {
147 DRM_ERROR("(%d) failed to reserve user bo\n", r); 150 DRM_ERROR("(%ld) failed to reserve user bo\n", r);
148 continue; 151 continue;
149 } 152 }
150 153
151 r = reservation_object_wait_timeout_rcu(bo->tbo.resv, 154 r = reservation_object_wait_timeout_rcu(bo->tbo.resv,
152 true, false, MAX_SCHEDULE_TIMEOUT); 155 true, false, MAX_SCHEDULE_TIMEOUT);
153 if (r) 156 if (r <= 0)
154 DRM_ERROR("(%d) failed to wait for user bo\n", r); 157 DRM_ERROR("(%ld) failed to wait for user bo\n", r);
155 158
156 radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_CPU); 159 radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_CPU);
157 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 160 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
158 if (r) 161 if (r)
159 DRM_ERROR("(%d) failed to validate user bo\n", r); 162 DRM_ERROR("(%ld) failed to validate user bo\n", r);
160 163
161 radeon_bo_unreserve(bo); 164 radeon_bo_unreserve(bo);
162 } 165 }
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index b292aca0f342..edafd3c2b170 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -591,8 +591,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
591{ 591{
592 struct radeon_device *rdev = radeon_get_rdev(ttm->bdev); 592 struct radeon_device *rdev = radeon_get_rdev(ttm->bdev);
593 struct radeon_ttm_tt *gtt = (void *)ttm; 593 struct radeon_ttm_tt *gtt = (void *)ttm;
594 struct scatterlist *sg; 594 struct sg_page_iter sg_iter;
595 int i;
596 595
597 int write = !(gtt->userflags & RADEON_GEM_USERPTR_READONLY); 596 int write = !(gtt->userflags & RADEON_GEM_USERPTR_READONLY);
598 enum dma_data_direction direction = write ? 597 enum dma_data_direction direction = write ?
@@ -605,9 +604,8 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
605 /* free the sg table and pages again */ 604 /* free the sg table and pages again */
606 dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction); 605 dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
607 606
608 for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) { 607 for_each_sg_page(ttm->sg->sgl, &sg_iter, ttm->sg->nents, 0) {
609 struct page *page = sg_page(sg); 608 struct page *page = sg_page_iter_page(&sg_iter);
610
611 if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY)) 609 if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
612 set_page_dirty(page); 610 set_page_dirty(page);
613 611
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index c10b2aec6450..6edcb5485092 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -204,28 +204,32 @@ void radeon_uvd_fini(struct radeon_device *rdev)
204 204
205int radeon_uvd_suspend(struct radeon_device *rdev) 205int radeon_uvd_suspend(struct radeon_device *rdev)
206{ 206{
207 unsigned size; 207 int i, r;
208 void *ptr;
209 int i;
210 208
211 if (rdev->uvd.vcpu_bo == NULL) 209 if (rdev->uvd.vcpu_bo == NULL)
212 return 0; 210 return 0;
213 211
214 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) 212 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
215 if (atomic_read(&rdev->uvd.handles[i])) 213 uint32_t handle = atomic_read(&rdev->uvd.handles[i]);
216 break; 214 if (handle != 0) {
215 struct radeon_fence *fence;
217 216
218 if (i == RADEON_MAX_UVD_HANDLES) 217 radeon_uvd_note_usage(rdev);
219 return 0;
220 218
221 size = radeon_bo_size(rdev->uvd.vcpu_bo); 219 r = radeon_uvd_get_destroy_msg(rdev,
222 size -= rdev->uvd_fw->size; 220 R600_RING_TYPE_UVD_INDEX, handle, &fence);
221 if (r) {
222 DRM_ERROR("Error destroying UVD (%d)!\n", r);
223 continue;
224 }
223 225
224 ptr = rdev->uvd.cpu_addr; 226 radeon_fence_wait(fence, false);
225 ptr += rdev->uvd_fw->size; 227 radeon_fence_unref(&fence);
226 228
227 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); 229 rdev->uvd.filp[i] = NULL;
228 memcpy(rdev->uvd.saved_bo, ptr, size); 230 atomic_set(&rdev->uvd.handles[i], 0);
231 }
232 }
229 233
230 return 0; 234 return 0;
231} 235}
@@ -246,12 +250,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)
246 ptr = rdev->uvd.cpu_addr; 250 ptr = rdev->uvd.cpu_addr;
247 ptr += rdev->uvd_fw->size; 251 ptr += rdev->uvd_fw->size;
248 252
249 if (rdev->uvd.saved_bo != NULL) { 253 memset(ptr, 0, size);
250 memcpy(ptr, rdev->uvd.saved_bo, size);
251 kfree(rdev->uvd.saved_bo);
252 rdev->uvd.saved_bo = NULL;
253 } else
254 memset(ptr, 0, size);
255 254
256 return 0; 255 return 0;
257} 256}
@@ -396,6 +395,29 @@ static int radeon_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[])
396 return 0; 395 return 0;
397} 396}
398 397
398static int radeon_uvd_validate_codec(struct radeon_cs_parser *p,
399 unsigned stream_type)
400{
401 switch (stream_type) {
402 case 0: /* H264 */
403 case 1: /* VC1 */
404 /* always supported */
405 return 0;
406
407 case 3: /* MPEG2 */
408 case 4: /* MPEG4 */
409 /* only since UVD 3 */
410 if (p->rdev->family >= CHIP_PALM)
411 return 0;
412
413 /* fall through */
414 default:
415 DRM_ERROR("UVD codec not supported by hardware %d!\n",
416 stream_type);
417 return -EINVAL;
418 }
419}
420
399static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo, 421static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
400 unsigned offset, unsigned buf_sizes[]) 422 unsigned offset, unsigned buf_sizes[])
401{ 423{
@@ -436,50 +458,70 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
436 return -EINVAL; 458 return -EINVAL;
437 } 459 }
438 460
439 if (msg_type == 1) { 461 switch (msg_type) {
440 /* it's a decode msg, calc buffer sizes */ 462 case 0:
441 r = radeon_uvd_cs_msg_decode(msg, buf_sizes); 463 /* it's a create msg, calc image size (width * height) */
442 /* calc image size (width * height) */ 464 img_size = msg[7] * msg[8];
443 img_size = msg[6] * msg[7]; 465
466 r = radeon_uvd_validate_codec(p, msg[4]);
444 radeon_bo_kunmap(bo); 467 radeon_bo_kunmap(bo);
445 if (r) 468 if (r)
446 return r; 469 return r;
447 470
448 } else if (msg_type == 2) { 471 /* try to alloc a new handle */
472 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
473 if (atomic_read(&p->rdev->uvd.handles[i]) == handle) {
474 DRM_ERROR("Handle 0x%x already in use!\n", handle);
475 return -EINVAL;
476 }
477
478 if (!atomic_cmpxchg(&p->rdev->uvd.handles[i], 0, handle)) {
479 p->rdev->uvd.filp[i] = p->filp;
480 p->rdev->uvd.img_size[i] = img_size;
481 return 0;
482 }
483 }
484
485 DRM_ERROR("No more free UVD handles!\n");
486 return -EINVAL;
487
488 case 1:
489 /* it's a decode msg, validate codec and calc buffer sizes */
490 r = radeon_uvd_validate_codec(p, msg[4]);
491 if (!r)
492 r = radeon_uvd_cs_msg_decode(msg, buf_sizes);
493 radeon_bo_kunmap(bo);
494 if (r)
495 return r;
496
497 /* validate the handle */
498 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
499 if (atomic_read(&p->rdev->uvd.handles[i]) == handle) {
500 if (p->rdev->uvd.filp[i] != p->filp) {
501 DRM_ERROR("UVD handle collision detected!\n");
502 return -EINVAL;
503 }
504 return 0;
505 }
506 }
507
508 DRM_ERROR("Invalid UVD handle 0x%x!\n", handle);
509 return -ENOENT;
510
511 case 2:
449 /* it's a destroy msg, free the handle */ 512 /* it's a destroy msg, free the handle */
450 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) 513 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i)
451 atomic_cmpxchg(&p->rdev->uvd.handles[i], handle, 0); 514 atomic_cmpxchg(&p->rdev->uvd.handles[i], handle, 0);
452 radeon_bo_kunmap(bo); 515 radeon_bo_kunmap(bo);
453 return 0; 516 return 0;
454 } else {
455 /* it's a create msg, calc image size (width * height) */
456 img_size = msg[7] * msg[8];
457 radeon_bo_kunmap(bo);
458 517
459 if (msg_type != 0) { 518 default:
460 DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
461 return -EINVAL;
462 }
463
464 /* it's a create msg, no special handling needed */
465 }
466
467 /* create or decode, validate the handle */
468 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
469 if (atomic_read(&p->rdev->uvd.handles[i]) == handle)
470 return 0;
471 }
472 519
473 /* handle not found try to alloc a new one */ 520 DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
474 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { 521 return -EINVAL;
475 if (!atomic_cmpxchg(&p->rdev->uvd.handles[i], 0, handle)) {
476 p->rdev->uvd.filp[i] = p->filp;
477 p->rdev->uvd.img_size[i] = img_size;
478 return 0;
479 }
480 } 522 }
481 523
482 DRM_ERROR("No more free UVD handles!\n"); 524 BUG();
483 return -EINVAL; 525 return -EINVAL;
484} 526}
485 527
diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c
index 24f849f888bb..0de5711ac508 100644
--- a/drivers/gpu/drm/radeon/radeon_vce.c
+++ b/drivers/gpu/drm/radeon/radeon_vce.c
@@ -493,18 +493,27 @@ int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi,
493 * 493 *
494 * @p: parser context 494 * @p: parser context
495 * @handle: handle to validate 495 * @handle: handle to validate
496 * @allocated: allocated a new handle?
496 * 497 *
497 * Validates the handle and return the found session index or -EINVAL 498 * Validates the handle and return the found session index or -EINVAL
498 * we we don't have another free session index. 499 * we we don't have another free session index.
499 */ 500 */
500int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle) 501static int radeon_vce_validate_handle(struct radeon_cs_parser *p,
502 uint32_t handle, bool *allocated)
501{ 503{
502 unsigned i; 504 unsigned i;
503 505
506 *allocated = false;
507
504 /* validate the handle */ 508 /* validate the handle */
505 for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) { 509 for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) {
506 if (atomic_read(&p->rdev->vce.handles[i]) == handle) 510 if (atomic_read(&p->rdev->vce.handles[i]) == handle) {
511 if (p->rdev->vce.filp[i] != p->filp) {
512 DRM_ERROR("VCE handle collision detected!\n");
513 return -EINVAL;
514 }
507 return i; 515 return i;
516 }
508 } 517 }
509 518
510 /* handle not found try to alloc a new one */ 519 /* handle not found try to alloc a new one */
@@ -512,6 +521,7 @@ int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle)
512 if (!atomic_cmpxchg(&p->rdev->vce.handles[i], 0, handle)) { 521 if (!atomic_cmpxchg(&p->rdev->vce.handles[i], 0, handle)) {
513 p->rdev->vce.filp[i] = p->filp; 522 p->rdev->vce.filp[i] = p->filp;
514 p->rdev->vce.img_size[i] = 0; 523 p->rdev->vce.img_size[i] = 0;
524 *allocated = true;
515 return i; 525 return i;
516 } 526 }
517 } 527 }
@@ -529,10 +539,10 @@ int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle)
529int radeon_vce_cs_parse(struct radeon_cs_parser *p) 539int radeon_vce_cs_parse(struct radeon_cs_parser *p)
530{ 540{
531 int session_idx = -1; 541 int session_idx = -1;
532 bool destroyed = false; 542 bool destroyed = false, created = false, allocated = false;
533 uint32_t tmp, handle = 0; 543 uint32_t tmp, handle = 0;
534 uint32_t *size = &tmp; 544 uint32_t *size = &tmp;
535 int i, r; 545 int i, r = 0;
536 546
537 while (p->idx < p->chunk_ib->length_dw) { 547 while (p->idx < p->chunk_ib->length_dw) {
538 uint32_t len = radeon_get_ib_value(p, p->idx); 548 uint32_t len = radeon_get_ib_value(p, p->idx);
@@ -540,18 +550,21 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
540 550
541 if ((len < 8) || (len & 3)) { 551 if ((len < 8) || (len & 3)) {
542 DRM_ERROR("invalid VCE command length (%d)!\n", len); 552 DRM_ERROR("invalid VCE command length (%d)!\n", len);
543 return -EINVAL; 553 r = -EINVAL;
554 goto out;
544 } 555 }
545 556
546 if (destroyed) { 557 if (destroyed) {
547 DRM_ERROR("No other command allowed after destroy!\n"); 558 DRM_ERROR("No other command allowed after destroy!\n");
548 return -EINVAL; 559 r = -EINVAL;
560 goto out;
549 } 561 }
550 562
551 switch (cmd) { 563 switch (cmd) {
552 case 0x00000001: // session 564 case 0x00000001: // session
553 handle = radeon_get_ib_value(p, p->idx + 2); 565 handle = radeon_get_ib_value(p, p->idx + 2);
554 session_idx = radeon_vce_validate_handle(p, handle); 566 session_idx = radeon_vce_validate_handle(p, handle,
567 &allocated);
555 if (session_idx < 0) 568 if (session_idx < 0)
556 return session_idx; 569 return session_idx;
557 size = &p->rdev->vce.img_size[session_idx]; 570 size = &p->rdev->vce.img_size[session_idx];
@@ -561,6 +574,13 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
561 break; 574 break;
562 575
563 case 0x01000001: // create 576 case 0x01000001: // create
577 created = true;
578 if (!allocated) {
579 DRM_ERROR("Handle already in use!\n");
580 r = -EINVAL;
581 goto out;
582 }
583
564 *size = radeon_get_ib_value(p, p->idx + 8) * 584 *size = radeon_get_ib_value(p, p->idx + 8) *
565 radeon_get_ib_value(p, p->idx + 10) * 585 radeon_get_ib_value(p, p->idx + 10) *
566 8 * 3 / 2; 586 8 * 3 / 2;
@@ -578,12 +598,12 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
578 r = radeon_vce_cs_reloc(p, p->idx + 10, p->idx + 9, 598 r = radeon_vce_cs_reloc(p, p->idx + 10, p->idx + 9,
579 *size); 599 *size);
580 if (r) 600 if (r)
581 return r; 601 goto out;
582 602
583 r = radeon_vce_cs_reloc(p, p->idx + 12, p->idx + 11, 603 r = radeon_vce_cs_reloc(p, p->idx + 12, p->idx + 11,
584 *size / 3); 604 *size / 3);
585 if (r) 605 if (r)
586 return r; 606 goto out;
587 break; 607 break;
588 608
589 case 0x02000001: // destroy 609 case 0x02000001: // destroy
@@ -594,7 +614,7 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
594 r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2, 614 r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2,
595 *size * 2); 615 *size * 2);
596 if (r) 616 if (r)
597 return r; 617 goto out;
598 break; 618 break;
599 619
600 case 0x05000004: // video bitstream buffer 620 case 0x05000004: // video bitstream buffer
@@ -602,36 +622,47 @@ int radeon_vce_cs_parse(struct radeon_cs_parser *p)
602 r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2, 622 r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2,
603 tmp); 623 tmp);
604 if (r) 624 if (r)
605 return r; 625 goto out;
606 break; 626 break;
607 627
608 case 0x05000005: // feedback buffer 628 case 0x05000005: // feedback buffer
609 r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2, 629 r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2,
610 4096); 630 4096);
611 if (r) 631 if (r)
612 return r; 632 goto out;
613 break; 633 break;
614 634
615 default: 635 default:
616 DRM_ERROR("invalid VCE command (0x%x)!\n", cmd); 636 DRM_ERROR("invalid VCE command (0x%x)!\n", cmd);
617 return -EINVAL; 637 r = -EINVAL;
638 goto out;
618 } 639 }
619 640
620 if (session_idx == -1) { 641 if (session_idx == -1) {
621 DRM_ERROR("no session command at start of IB\n"); 642 DRM_ERROR("no session command at start of IB\n");
622 return -EINVAL; 643 r = -EINVAL;
644 goto out;
623 } 645 }
624 646
625 p->idx += len / 4; 647 p->idx += len / 4;
626 } 648 }
627 649
628 if (destroyed) { 650 if (allocated && !created) {
629 /* IB contains a destroy msg, free the handle */ 651 DRM_ERROR("New session without create command!\n");
652 r = -ENOENT;
653 }
654
655out:
656 if ((!r && destroyed) || (r && allocated)) {
657 /*
658 * IB contains a destroy msg or we have allocated an
659 * handle and got an error, anyway free the handle
660 */
630 for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) 661 for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i)
631 atomic_cmpxchg(&p->rdev->vce.handles[i], handle, 0); 662 atomic_cmpxchg(&p->rdev->vce.handles[i], handle, 0);
632 } 663 }
633 664
634 return 0; 665 return r;
635} 666}
636 667
637/** 668/**
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index 2a5a4a9e772d..9c3377ca17b7 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -458,14 +458,16 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
458 /* make sure object fit at this offset */ 458 /* make sure object fit at this offset */
459 eoffset = soffset + size; 459 eoffset = soffset + size;
460 if (soffset >= eoffset) { 460 if (soffset >= eoffset) {
461 return -EINVAL; 461 r = -EINVAL;
462 goto error_unreserve;
462 } 463 }
463 464
464 last_pfn = eoffset / RADEON_GPU_PAGE_SIZE; 465 last_pfn = eoffset / RADEON_GPU_PAGE_SIZE;
465 if (last_pfn > rdev->vm_manager.max_pfn) { 466 if (last_pfn > rdev->vm_manager.max_pfn) {
466 dev_err(rdev->dev, "va above limit (0x%08X > 0x%08X)\n", 467 dev_err(rdev->dev, "va above limit (0x%08X > 0x%08X)\n",
467 last_pfn, rdev->vm_manager.max_pfn); 468 last_pfn, rdev->vm_manager.max_pfn);
468 return -EINVAL; 469 r = -EINVAL;
470 goto error_unreserve;
469 } 471 }
470 472
471 } else { 473 } else {
@@ -473,6 +475,24 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
473 } 475 }
474 476
475 mutex_lock(&vm->mutex); 477 mutex_lock(&vm->mutex);
478 soffset /= RADEON_GPU_PAGE_SIZE;
479 eoffset /= RADEON_GPU_PAGE_SIZE;
480 if (soffset || eoffset) {
481 struct interval_tree_node *it;
482 it = interval_tree_iter_first(&vm->va, soffset, eoffset - 1);
483 if (it && it != &bo_va->it) {
484 struct radeon_bo_va *tmp;
485 tmp = container_of(it, struct radeon_bo_va, it);
486 /* bo and tmp overlap, invalid offset */
487 dev_err(rdev->dev, "bo %p va 0x%010Lx conflict with "
488 "(bo %p 0x%010lx 0x%010lx)\n", bo_va->bo,
489 soffset, tmp->bo, tmp->it.start, tmp->it.last);
490 mutex_unlock(&vm->mutex);
491 r = -EINVAL;
492 goto error_unreserve;
493 }
494 }
495
476 if (bo_va->it.start || bo_va->it.last) { 496 if (bo_va->it.start || bo_va->it.last) {
477 if (bo_va->addr) { 497 if (bo_va->addr) {
478 /* add a clone of the bo_va to clear the old address */ 498 /* add a clone of the bo_va to clear the old address */
@@ -480,7 +500,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
480 tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL); 500 tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL);
481 if (!tmp) { 501 if (!tmp) {
482 mutex_unlock(&vm->mutex); 502 mutex_unlock(&vm->mutex);
483 return -ENOMEM; 503 r = -ENOMEM;
504 goto error_unreserve;
484 } 505 }
485 tmp->it.start = bo_va->it.start; 506 tmp->it.start = bo_va->it.start;
486 tmp->it.last = bo_va->it.last; 507 tmp->it.last = bo_va->it.last;
@@ -490,6 +511,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
490 spin_lock(&vm->status_lock); 511 spin_lock(&vm->status_lock);
491 list_add(&tmp->vm_status, &vm->freed); 512 list_add(&tmp->vm_status, &vm->freed);
492 spin_unlock(&vm->status_lock); 513 spin_unlock(&vm->status_lock);
514
515 bo_va->addr = 0;
493 } 516 }
494 517
495 interval_tree_remove(&bo_va->it, &vm->va); 518 interval_tree_remove(&bo_va->it, &vm->va);
@@ -497,21 +520,7 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
497 bo_va->it.last = 0; 520 bo_va->it.last = 0;
498 } 521 }
499 522
500 soffset /= RADEON_GPU_PAGE_SIZE;
501 eoffset /= RADEON_GPU_PAGE_SIZE;
502 if (soffset || eoffset) { 523 if (soffset || eoffset) {
503 struct interval_tree_node *it;
504 it = interval_tree_iter_first(&vm->va, soffset, eoffset - 1);
505 if (it) {
506 struct radeon_bo_va *tmp;
507 tmp = container_of(it, struct radeon_bo_va, it);
508 /* bo and tmp overlap, invalid offset */
509 dev_err(rdev->dev, "bo %p va 0x%010Lx conflict with "
510 "(bo %p 0x%010lx 0x%010lx)\n", bo_va->bo,
511 soffset, tmp->bo, tmp->it.start, tmp->it.last);
512 mutex_unlock(&vm->mutex);
513 return -EINVAL;
514 }
515 bo_va->it.start = soffset; 524 bo_va->it.start = soffset;
516 bo_va->it.last = eoffset - 1; 525 bo_va->it.last = eoffset - 1;
517 interval_tree_insert(&bo_va->it, &vm->va); 526 interval_tree_insert(&bo_va->it, &vm->va);
@@ -550,7 +559,6 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
550 r = radeon_vm_clear_bo(rdev, pt); 559 r = radeon_vm_clear_bo(rdev, pt);
551 if (r) { 560 if (r) {
552 radeon_bo_unref(&pt); 561 radeon_bo_unref(&pt);
553 radeon_bo_reserve(bo_va->bo, false);
554 return r; 562 return r;
555 } 563 }
556 564
@@ -570,6 +578,10 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
570 578
571 mutex_unlock(&vm->mutex); 579 mutex_unlock(&vm->mutex);
572 return 0; 580 return 0;
581
582error_unreserve:
583 radeon_bo_unreserve(bo_va->bo);
584 return r;
573} 585}
574 586
575/** 587/**
@@ -1107,7 +1119,8 @@ void radeon_vm_bo_rmv(struct radeon_device *rdev,
1107 list_del(&bo_va->bo_list); 1119 list_del(&bo_va->bo_list);
1108 1120
1109 mutex_lock(&vm->mutex); 1121 mutex_lock(&vm->mutex);
1110 interval_tree_remove(&bo_va->it, &vm->va); 1122 if (bo_va->it.start || bo_va->it.last)
1123 interval_tree_remove(&bo_va->it, &vm->va);
1111 spin_lock(&vm->status_lock); 1124 spin_lock(&vm->status_lock);
1112 list_del(&bo_va->vm_status); 1125 list_del(&bo_va->vm_status);
1113 1126
diff --git a/drivers/gpu/drm/radeon/rv770d.h b/drivers/gpu/drm/radeon/rv770d.h
index 3cf1e2921545..9ef2064b1c9c 100644
--- a/drivers/gpu/drm/radeon/rv770d.h
+++ b/drivers/gpu/drm/radeon/rv770d.h
@@ -989,6 +989,9 @@
989 ((n) & 0x3FFF) << 16) 989 ((n) & 0x3FFF) << 16)
990 990
991/* UVD */ 991/* UVD */
992#define UVD_SEMA_ADDR_LOW 0xef00
993#define UVD_SEMA_ADDR_HIGH 0xef04
994#define UVD_SEMA_CMD 0xef08
992#define UVD_GPCOM_VCPU_CMD 0xef0c 995#define UVD_GPCOM_VCPU_CMD 0xef0c
993#define UVD_GPCOM_VCPU_DATA0 0xef10 996#define UVD_GPCOM_VCPU_DATA0 0xef10
994#define UVD_GPCOM_VCPU_DATA1 0xef14 997#define UVD_GPCOM_VCPU_DATA1 0xef14
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index b1d74bc375d8..4c679b802bc8 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -4318,7 +4318,7 @@ static int si_pcie_gart_enable(struct radeon_device *rdev)
4318 /* empty context1-15 */ 4318 /* empty context1-15 */
4319 /* set vm size, must be a multiple of 4 */ 4319 /* set vm size, must be a multiple of 4 */
4320 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); 4320 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
4321 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); 4321 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn - 1);
4322 /* Assign the pt base to something valid for now; the pts used for 4322 /* Assign the pt base to something valid for now; the pts used for
4323 * the VMs are determined by the application and setup and assigned 4323 * the VMs are determined by the application and setup and assigned
4324 * on the fly in the vm part of radeon_gart.c 4324 * on the fly in the vm part of radeon_gart.c
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index b35bccfeef79..ff8b83f5e929 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2924,6 +2924,7 @@ struct si_dpm_quirk {
2924static struct si_dpm_quirk si_dpm_quirk_list[] = { 2924static struct si_dpm_quirk si_dpm_quirk_list[] = {
2925 /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */ 2925 /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */
2926 { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 }, 2926 { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 },
2927 { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 },
2927 { 0, 0, 0, 0 }, 2928 { 0, 0, 0, 0 },
2928}; 2929};
2929 2930
diff --git a/drivers/gpu/drm/radeon/uvd_v1_0.c b/drivers/gpu/drm/radeon/uvd_v1_0.c
index e72b3cb59358..c6b1cbca47fc 100644
--- a/drivers/gpu/drm/radeon/uvd_v1_0.c
+++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
@@ -466,18 +466,8 @@ bool uvd_v1_0_semaphore_emit(struct radeon_device *rdev,
466 struct radeon_semaphore *semaphore, 466 struct radeon_semaphore *semaphore,
467 bool emit_wait) 467 bool emit_wait)
468{ 468{
469 uint64_t addr = semaphore->gpu_addr; 469 /* disable semaphores for UVD V1 hardware */
470 470 return false;
471 radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
472 radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
473
474 radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
475 radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
476
477 radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
478 radeon_ring_write(ring, emit_wait ? 1 : 0);
479
480 return true;
481} 471}
482 472
483/** 473/**
diff --git a/drivers/gpu/drm/radeon/uvd_v2_2.c b/drivers/gpu/drm/radeon/uvd_v2_2.c
index 89193519f8a1..7ed778cec7c6 100644
--- a/drivers/gpu/drm/radeon/uvd_v2_2.c
+++ b/drivers/gpu/drm/radeon/uvd_v2_2.c
@@ -60,6 +60,35 @@ void uvd_v2_2_fence_emit(struct radeon_device *rdev,
60} 60}
61 61
62/** 62/**
63 * uvd_v2_2_semaphore_emit - emit semaphore command
64 *
65 * @rdev: radeon_device pointer
66 * @ring: radeon_ring pointer
67 * @semaphore: semaphore to emit commands for
68 * @emit_wait: true if we should emit a wait command
69 *
70 * Emit a semaphore command (either wait or signal) to the UVD ring.
71 */
72bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
73 struct radeon_ring *ring,
74 struct radeon_semaphore *semaphore,
75 bool emit_wait)
76{
77 uint64_t addr = semaphore->gpu_addr;
78
79 radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
80 radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
81
82 radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
83 radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
84
85 radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
86 radeon_ring_write(ring, emit_wait ? 1 : 0);
87
88 return true;
89}
90
91/**
63 * uvd_v2_2_resume - memory controller programming 92 * uvd_v2_2_resume - memory controller programming
64 * 93 *
65 * @rdev: radeon_device pointer 94 * @rdev: radeon_device pointer
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index ccb0ce073ef2..4557f335a8a5 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1409,7 +1409,7 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
1409 struct vop *vop; 1409 struct vop *vop;
1410 struct resource *res; 1410 struct resource *res;
1411 size_t alloc_size; 1411 size_t alloc_size;
1412 int ret; 1412 int ret, irq;
1413 1413
1414 of_id = of_match_device(vop_driver_dt_match, dev); 1414 of_id = of_match_device(vop_driver_dt_match, dev);
1415 vop_data = of_id->data; 1415 vop_data = of_id->data;
@@ -1445,11 +1445,12 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
1445 return ret; 1445 return ret;
1446 } 1446 }
1447 1447
1448 vop->irq = platform_get_irq(pdev, 0); 1448 irq = platform_get_irq(pdev, 0);
1449 if (vop->irq < 0) { 1449 if (irq < 0) {
1450 dev_err(dev, "cannot find irq for vop\n"); 1450 dev_err(dev, "cannot find irq for vop\n");
1451 return vop->irq; 1451 return irq;
1452 } 1452 }
1453 vop->irq = (unsigned int)irq;
1453 1454
1454 spin_lock_init(&vop->reg_lock); 1455 spin_lock_init(&vop->reg_lock);
1455 spin_lock_init(&vop->irq_lock); 1456 spin_lock_init(&vop->irq_lock);
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 1833abd7d3aa..bfad15a913a0 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -173,7 +173,6 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
173 drm->irq_enabled = true; 173 drm->irq_enabled = true;
174 174
175 /* syncpoints are used for full 32-bit hardware VBLANK counters */ 175 /* syncpoints are used for full 32-bit hardware VBLANK counters */
176 drm->vblank_disable_immediate = true;
177 drm->max_vblank_count = 0xffffffff; 176 drm->max_vblank_count = 0xffffffff;
178 177
179 err = drm_vblank_init(drm, drm->mode_config.num_crtc); 178 err = drm_vblank_init(drm, drm->mode_config.num_crtc);
diff --git a/drivers/gpu/drm/vgem/Makefile b/drivers/gpu/drm/vgem/Makefile
index 1055cb79096c..3f4c7b842028 100644
--- a/drivers/gpu/drm/vgem/Makefile
+++ b/drivers/gpu/drm/vgem/Makefile
@@ -1,4 +1,4 @@
1ccflags-y := -Iinclude/drm 1ccflags-y := -Iinclude/drm
2vgem-y := vgem_drv.o vgem_dma_buf.o 2vgem-y := vgem_drv.o
3 3
4obj-$(CONFIG_DRM_VGEM) += vgem.o 4obj-$(CONFIG_DRM_VGEM) += vgem.o
diff --git a/drivers/gpu/drm/vgem/vgem_dma_buf.c b/drivers/gpu/drm/vgem/vgem_dma_buf.c
deleted file mode 100644
index 0254438ad1a6..000000000000
--- a/drivers/gpu/drm/vgem/vgem_dma_buf.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/*
2 * Copyright © 2012 Intel Corporation
3 * Copyright © 2014 The Chromium OS Authors
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 *
24 * Authors:
25 * Ben Widawsky <ben@bwidawsk.net>
26 *
27 */
28
29#include <linux/dma-buf.h>
30#include "vgem_drv.h"
31
32struct sg_table *vgem_gem_prime_get_sg_table(struct drm_gem_object *gobj)
33{
34 struct drm_vgem_gem_object *obj = to_vgem_bo(gobj);
35 BUG_ON(obj->pages == NULL);
36
37 return drm_prime_pages_to_sg(obj->pages, obj->base.size / PAGE_SIZE);
38}
39
40int vgem_gem_prime_pin(struct drm_gem_object *gobj)
41{
42 struct drm_vgem_gem_object *obj = to_vgem_bo(gobj);
43 return vgem_gem_get_pages(obj);
44}
45
46void vgem_gem_prime_unpin(struct drm_gem_object *gobj)
47{
48 struct drm_vgem_gem_object *obj = to_vgem_bo(gobj);
49 vgem_gem_put_pages(obj);
50}
51
52void *vgem_gem_prime_vmap(struct drm_gem_object *gobj)
53{
54 struct drm_vgem_gem_object *obj = to_vgem_bo(gobj);
55 BUG_ON(obj->pages == NULL);
56
57 return vmap(obj->pages, obj->base.size / PAGE_SIZE, 0, PAGE_KERNEL);
58}
59
60void vgem_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
61{
62 vunmap(vaddr);
63}
64
65struct drm_gem_object *vgem_gem_prime_import(struct drm_device *dev,
66 struct dma_buf *dma_buf)
67{
68 struct drm_vgem_gem_object *obj = NULL;
69 int ret;
70
71 obj = kzalloc(sizeof(*obj), GFP_KERNEL);
72 if (obj == NULL) {
73 ret = -ENOMEM;
74 goto fail;
75 }
76
77 ret = drm_gem_object_init(dev, &obj->base, dma_buf->size);
78 if (ret) {
79 ret = -ENOMEM;
80 goto fail_free;
81 }
82
83 get_dma_buf(dma_buf);
84
85 obj->base.dma_buf = dma_buf;
86 obj->use_dma_buf = true;
87
88 return &obj->base;
89
90fail_free:
91 kfree(obj);
92fail:
93 return ERR_PTR(ret);
94}
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index cb3b43525b2d..7a207ca547be 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -302,22 +302,13 @@ static const struct file_operations vgem_driver_fops = {
302}; 302};
303 303
304static struct drm_driver vgem_driver = { 304static struct drm_driver vgem_driver = {
305 .driver_features = DRIVER_GEM | DRIVER_PRIME, 305 .driver_features = DRIVER_GEM,
306 .gem_free_object = vgem_gem_free_object, 306 .gem_free_object = vgem_gem_free_object,
307 .gem_vm_ops = &vgem_gem_vm_ops, 307 .gem_vm_ops = &vgem_gem_vm_ops,
308 .ioctls = vgem_ioctls, 308 .ioctls = vgem_ioctls,
309 .fops = &vgem_driver_fops, 309 .fops = &vgem_driver_fops,
310 .dumb_create = vgem_gem_dumb_create, 310 .dumb_create = vgem_gem_dumb_create,
311 .dumb_map_offset = vgem_gem_dumb_map, 311 .dumb_map_offset = vgem_gem_dumb_map,
312 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
313 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
314 .gem_prime_export = drm_gem_prime_export,
315 .gem_prime_import = vgem_gem_prime_import,
316 .gem_prime_pin = vgem_gem_prime_pin,
317 .gem_prime_unpin = vgem_gem_prime_unpin,
318 .gem_prime_get_sg_table = vgem_gem_prime_get_sg_table,
319 .gem_prime_vmap = vgem_gem_prime_vmap,
320 .gem_prime_vunmap = vgem_gem_prime_vunmap,
321 .name = DRIVER_NAME, 312 .name = DRIVER_NAME,
322 .desc = DRIVER_DESC, 313 .desc = DRIVER_DESC,
323 .date = DRIVER_DATE, 314 .date = DRIVER_DATE,
diff --git a/drivers/gpu/drm/vgem/vgem_drv.h b/drivers/gpu/drm/vgem/vgem_drv.h
index 57ab4d8f41f9..e9f92f7ee275 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.h
+++ b/drivers/gpu/drm/vgem/vgem_drv.h
@@ -43,15 +43,4 @@ struct drm_vgem_gem_object {
43extern void vgem_gem_put_pages(struct drm_vgem_gem_object *obj); 43extern void vgem_gem_put_pages(struct drm_vgem_gem_object *obj);
44extern int vgem_gem_get_pages(struct drm_vgem_gem_object *obj); 44extern int vgem_gem_get_pages(struct drm_vgem_gem_object *obj);
45 45
46/* vgem_dma_buf.c */
47extern struct sg_table *vgem_gem_prime_get_sg_table(
48 struct drm_gem_object *gobj);
49extern int vgem_gem_prime_pin(struct drm_gem_object *gobj);
50extern void vgem_gem_prime_unpin(struct drm_gem_object *gobj);
51extern void *vgem_gem_prime_vmap(struct drm_gem_object *gobj);
52extern void vgem_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
53extern struct drm_gem_object *vgem_gem_prime_import(struct drm_device *dev,
54 struct dma_buf *dma_buf);
55
56
57#endif 46#endif