aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c5
-rw-r--r--drivers/gpu/drm/drm_edid.c55
-rw-r--r--drivers/gpu/drm/drm_gem_shmem_helper.c3
-rw-r--r--drivers/gpu/drm/drm_panel_orientation_quirks.c32
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c7
-rw-r--r--drivers/gpu/drm/i915/i915_perf.c1
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_csr.c18
-rw-r--r--drivers/gpu/drm/i915/intel_display.c14
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_dsi_vbt.c11
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c58
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo_regs.h3
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_crtc.c30
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_drv.c8
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_gem.c7
-rw-r--r--drivers/gpu/drm/mediatek/mtk_dsi.c12
-rw-r--r--drivers/gpu/drm/meson/meson_crtc.c6
-rw-r--r--drivers/gpu/drm/meson/meson_plane.c8
-rw-r--r--drivers/gpu/drm/meson/meson_vclk.c13
-rw-r--r--drivers/gpu/drm/meson/meson_viu.c3
-rw-r--r--drivers/gpu/drm/panfrost/Kconfig1
-rw-r--r--drivers/gpu/drm/panfrost/panfrost_devfreq.c13
-rw-r--r--include/drm/drm_edid.h1
28 files changed, 253 insertions, 73 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 039cfa2ec89d..abeaab4bf1bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -2492,7 +2492,7 @@ void amdgpu_pm_print_power_states(struct amdgpu_device *adev)
2492 2492
2493int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_version) 2493int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_version)
2494{ 2494{
2495 int r = -EINVAL; 2495 int r;
2496 2496
2497 if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->load_firmware) { 2497 if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->load_firmware) {
2498 r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle); 2498 r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
@@ -2502,7 +2502,7 @@ int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_versio
2502 } 2502 }
2503 *smu_version = adev->pm.fw_version; 2503 *smu_version = adev->pm.fw_version;
2504 } 2504 }
2505 return r; 2505 return 0;
2506} 2506}
2507 2507
2508int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) 2508int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
index eaef5edefc34..24c6e5fcda86 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
@@ -172,6 +172,8 @@ static inline int amdgpu_ras_is_supported(struct amdgpu_device *adev,
172{ 172{
173 struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); 173 struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
174 174
175 if (block >= AMDGPU_RAS_BLOCK_COUNT)
176 return 0;
175 return ras && (ras->supported & (1 << block)); 177 return ras && (ras->supported & (1 << block));
176} 178}
177 179
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index ecf6f96df2ad..e6b07ece3910 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -594,7 +594,7 @@ error:
594int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring) 594int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring)
595{ 595{
596 struct amdgpu_device *adev = ring->adev; 596 struct amdgpu_device *adev = ring->adev;
597 uint32_t rptr = amdgpu_ring_get_rptr(ring); 597 uint32_t rptr;
598 unsigned i; 598 unsigned i;
599 int r; 599 int r;
600 600
@@ -602,6 +602,8 @@ int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring)
602 if (r) 602 if (r)
603 return r; 603 return r;
604 604
605 rptr = amdgpu_ring_get_rptr(ring);
606
605 amdgpu_ring_write(ring, VCN_ENC_CMD_END); 607 amdgpu_ring_write(ring, VCN_ENC_CMD_END);
606 amdgpu_ring_commit(ring); 608 amdgpu_ring_commit(ring);
607 609
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index c9edddf9f88a..be70e6e5f9df 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -170,13 +170,16 @@ static void uvd_v6_0_enc_ring_set_wptr(struct amdgpu_ring *ring)
170static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring) 170static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring)
171{ 171{
172 struct amdgpu_device *adev = ring->adev; 172 struct amdgpu_device *adev = ring->adev;
173 uint32_t rptr = amdgpu_ring_get_rptr(ring); 173 uint32_t rptr;
174 unsigned i; 174 unsigned i;
175 int r; 175 int r;
176 176
177 r = amdgpu_ring_alloc(ring, 16); 177 r = amdgpu_ring_alloc(ring, 16);
178 if (r) 178 if (r)
179 return r; 179 return r;
180
181 rptr = amdgpu_ring_get_rptr(ring);
182
180 amdgpu_ring_write(ring, HEVC_ENC_CMD_END); 183 amdgpu_ring_write(ring, HEVC_ENC_CMD_END);
181 amdgpu_ring_commit(ring); 184 amdgpu_ring_commit(ring);
182 185
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index 2191d3d0a219..fc4f0bb9a2e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -175,7 +175,7 @@ static void uvd_v7_0_enc_ring_set_wptr(struct amdgpu_ring *ring)
175static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring) 175static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
176{ 176{
177 struct amdgpu_device *adev = ring->adev; 177 struct amdgpu_device *adev = ring->adev;
178 uint32_t rptr = amdgpu_ring_get_rptr(ring); 178 uint32_t rptr;
179 unsigned i; 179 unsigned i;
180 int r; 180 int r;
181 181
@@ -185,6 +185,9 @@ static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
185 r = amdgpu_ring_alloc(ring, 16); 185 r = amdgpu_ring_alloc(ring, 16);
186 if (r) 186 if (r)
187 return r; 187 return r;
188
189 rptr = amdgpu_ring_get_rptr(ring);
190
188 amdgpu_ring_write(ring, HEVC_ENC_CMD_END); 191 amdgpu_ring_write(ring, HEVC_ENC_CMD_END);
189 amdgpu_ring_commit(ring); 192 amdgpu_ring_commit(ring);
190 193
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 649cfd8b4200..e804ac5dec02 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1570,6 +1570,50 @@ static void connector_bad_edid(struct drm_connector *connector,
1570 } 1570 }
1571} 1571}
1572 1572
1573/* Get override or firmware EDID */
1574static struct edid *drm_get_override_edid(struct drm_connector *connector)
1575{
1576 struct edid *override = NULL;
1577
1578 if (connector->override_edid)
1579 override = drm_edid_duplicate(connector->edid_blob_ptr->data);
1580
1581 if (!override)
1582 override = drm_load_edid_firmware(connector);
1583
1584 return IS_ERR(override) ? NULL : override;
1585}
1586
1587/**
1588 * drm_add_override_edid_modes - add modes from override/firmware EDID
1589 * @connector: connector we're probing
1590 *
1591 * Add modes from the override/firmware EDID, if available. Only to be used from
1592 * drm_helper_probe_single_connector_modes() as a fallback for when DDC probe
1593 * failed during drm_get_edid() and caused the override/firmware EDID to be
1594 * skipped.
1595 *
1596 * Return: The number of modes added or 0 if we couldn't find any.
1597 */
1598int drm_add_override_edid_modes(struct drm_connector *connector)
1599{
1600 struct edid *override;
1601 int num_modes = 0;
1602
1603 override = drm_get_override_edid(connector);
1604 if (override) {
1605 drm_connector_update_edid_property(connector, override);
1606 num_modes = drm_add_edid_modes(connector, override);
1607 kfree(override);
1608
1609 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] adding %d modes via fallback override/firmware EDID\n",
1610 connector->base.id, connector->name, num_modes);
1611 }
1612
1613 return num_modes;
1614}
1615EXPORT_SYMBOL(drm_add_override_edid_modes);
1616
1573/** 1617/**
1574 * drm_do_get_edid - get EDID data using a custom EDID block read function 1618 * drm_do_get_edid - get EDID data using a custom EDID block read function
1575 * @connector: connector we're probing 1619 * @connector: connector we're probing
@@ -1597,15 +1641,10 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
1597{ 1641{
1598 int i, j = 0, valid_extensions = 0; 1642 int i, j = 0, valid_extensions = 0;
1599 u8 *edid, *new; 1643 u8 *edid, *new;
1600 struct edid *override = NULL; 1644 struct edid *override;
1601
1602 if (connector->override_edid)
1603 override = drm_edid_duplicate(connector->edid_blob_ptr->data);
1604
1605 if (!override)
1606 override = drm_load_edid_firmware(connector);
1607 1645
1608 if (!IS_ERR_OR_NULL(override)) 1646 override = drm_get_override_edid(connector);
1647 if (override)
1609 return override; 1648 return override;
1610 1649
1611 if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) 1650 if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 1ee208c2c85e..472ea5d81f82 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -255,7 +255,8 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem)
255 if (obj->import_attach) 255 if (obj->import_attach)
256 shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf); 256 shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
257 else 257 else
258 shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, VM_MAP, PAGE_KERNEL); 258 shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
259 VM_MAP, pgprot_writecombine(PAGE_KERNEL));
259 260
260 if (!shmem->vaddr) { 261 if (!shmem->vaddr) {
261 DRM_DEBUG_KMS("Failed to vmap pages\n"); 262 DRM_DEBUG_KMS("Failed to vmap pages\n");
diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 521aff99b08a..d8a0bcd02f34 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -42,6 +42,14 @@ static const struct drm_dmi_panel_orientation_data asus_t100ha = {
42 .orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP, 42 .orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP,
43}; 43};
44 44
45static const struct drm_dmi_panel_orientation_data gpd_micropc = {
46 .width = 720,
47 .height = 1280,
48 .bios_dates = (const char * const []){ "04/26/2019",
49 NULL },
50 .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
51};
52
45static const struct drm_dmi_panel_orientation_data gpd_pocket = { 53static const struct drm_dmi_panel_orientation_data gpd_pocket = {
46 .width = 1200, 54 .width = 1200,
47 .height = 1920, 55 .height = 1920,
@@ -50,6 +58,14 @@ static const struct drm_dmi_panel_orientation_data gpd_pocket = {
50 .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, 58 .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
51}; 59};
52 60
61static const struct drm_dmi_panel_orientation_data gpd_pocket2 = {
62 .width = 1200,
63 .height = 1920,
64 .bios_dates = (const char * const []){ "06/28/2018", "08/28/2018",
65 "12/07/2018", NULL },
66 .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
67};
68
53static const struct drm_dmi_panel_orientation_data gpd_win = { 69static const struct drm_dmi_panel_orientation_data gpd_win = {
54 .width = 720, 70 .width = 720,
55 .height = 1280, 71 .height = 1280,
@@ -99,6 +115,14 @@ static const struct dmi_system_id orientation_data[] = {
99 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100HAN"), 115 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100HAN"),
100 }, 116 },
101 .driver_data = (void *)&asus_t100ha, 117 .driver_data = (void *)&asus_t100ha,
118 }, { /* GPD MicroPC (generic strings, also match on bios date) */
119 .matches = {
120 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Default string"),
121 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"),
122 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
123 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"),
124 },
125 .driver_data = (void *)&gpd_micropc,
102 }, { /* 126 }, { /*
103 * GPD Pocket, note that the the DMI data is less generic then 127 * GPD Pocket, note that the the DMI data is less generic then
104 * it seems, devices with a board-vendor of "AMI Corporation" 128 * it seems, devices with a board-vendor of "AMI Corporation"
@@ -112,6 +136,14 @@ static const struct dmi_system_id orientation_data[] = {
112 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"), 136 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"),
113 }, 137 },
114 .driver_data = (void *)&gpd_pocket, 138 .driver_data = (void *)&gpd_pocket,
139 }, { /* GPD Pocket 2 (generic strings, also match on bios date) */
140 .matches = {
141 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Default string"),
142 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"),
143 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
144 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"),
145 },
146 .driver_data = (void *)&gpd_pocket2,
115 }, { /* GPD Win (same note on DMI match as GPD Pocket) */ 147 }, { /* GPD Win (same note on DMI match as GPD Pocket) */
116 .matches = { 148 .matches = {
117 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 149 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 6fd08e04b323..dd427c7ff967 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -479,6 +479,13 @@ retry:
479 479
480 count = (*connector_funcs->get_modes)(connector); 480 count = (*connector_funcs->get_modes)(connector);
481 481
482 /*
483 * Fallback for when DDC probe failed in drm_get_edid() and thus skipped
484 * override/firmware EDID.
485 */
486 if (count == 0 && connector->status == connector_status_connected)
487 count = drm_add_override_edid_modes(connector);
488
482 if (count == 0 && connector->status == connector_status_connected) 489 if (count == 0 && connector->status == connector_status_connected)
483 count = drm_add_modes_noedid(connector, 1024, 768); 490 count = drm_add_modes_noedid(connector, 1024, 768);
484 count += drm_helper_probe_add_cmdline_mode(connector); 491 count += drm_helper_probe_add_cmdline_mode(connector);
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 39a4804091d7..dc4ce694c06a 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -3005,6 +3005,7 @@ static bool gen8_is_valid_mux_addr(struct drm_i915_private *dev_priv, u32 addr)
3005static bool gen10_is_valid_mux_addr(struct drm_i915_private *dev_priv, u32 addr) 3005static bool gen10_is_valid_mux_addr(struct drm_i915_private *dev_priv, u32 addr)
3006{ 3006{
3007 return gen8_is_valid_mux_addr(dev_priv, addr) || 3007 return gen8_is_valid_mux_addr(dev_priv, addr) ||
3008 addr == i915_mmio_reg_offset(GEN10_NOA_WRITE_HIGH) ||
3008 (addr >= i915_mmio_reg_offset(OA_PERFCNT3_LO) && 3009 (addr >= i915_mmio_reg_offset(OA_PERFCNT3_LO) &&
3009 addr <= i915_mmio_reg_offset(OA_PERFCNT4_HI)); 3010 addr <= i915_mmio_reg_offset(OA_PERFCNT4_HI));
3010} 3011}
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 2aa69d347ec4..13d6bd4e17b2 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1062,6 +1062,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
1062 1062
1063#define NOA_DATA _MMIO(0x986C) 1063#define NOA_DATA _MMIO(0x986C)
1064#define NOA_WRITE _MMIO(0x9888) 1064#define NOA_WRITE _MMIO(0x9888)
1065#define GEN10_NOA_WRITE_HIGH _MMIO(0x9884)
1065 1066
1066#define _GEN7_PIPEA_DE_LOAD_SL 0x70068 1067#define _GEN7_PIPEA_DE_LOAD_SL 0x70068
1067#define _GEN7_PIPEB_DE_LOAD_SL 0x71068 1068#define _GEN7_PIPEB_DE_LOAD_SL 0x71068
diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
index f43c2a2563a5..96618af47088 100644
--- a/drivers/gpu/drm/i915/intel_csr.c
+++ b/drivers/gpu/drm/i915/intel_csr.c
@@ -303,10 +303,17 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
303 u32 dmc_offset = CSR_DEFAULT_FW_OFFSET, readcount = 0, nbytes; 303 u32 dmc_offset = CSR_DEFAULT_FW_OFFSET, readcount = 0, nbytes;
304 u32 i; 304 u32 i;
305 u32 *dmc_payload; 305 u32 *dmc_payload;
306 size_t fsize;
306 307
307 if (!fw) 308 if (!fw)
308 return NULL; 309 return NULL;
309 310
311 fsize = sizeof(struct intel_css_header) +
312 sizeof(struct intel_package_header) +
313 sizeof(struct intel_dmc_header);
314 if (fsize > fw->size)
315 goto error_truncated;
316
310 /* Extract CSS Header information*/ 317 /* Extract CSS Header information*/
311 css_header = (struct intel_css_header *)fw->data; 318 css_header = (struct intel_css_header *)fw->data;
312 if (sizeof(struct intel_css_header) != 319 if (sizeof(struct intel_css_header) !=
@@ -366,6 +373,9 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
366 /* Convert dmc_offset into number of bytes. By default it is in dwords*/ 373 /* Convert dmc_offset into number of bytes. By default it is in dwords*/
367 dmc_offset *= 4; 374 dmc_offset *= 4;
368 readcount += dmc_offset; 375 readcount += dmc_offset;
376 fsize += dmc_offset;
377 if (fsize > fw->size)
378 goto error_truncated;
369 379
370 /* Extract dmc_header information. */ 380 /* Extract dmc_header information. */
371 dmc_header = (struct intel_dmc_header *)&fw->data[readcount]; 381 dmc_header = (struct intel_dmc_header *)&fw->data[readcount];
@@ -397,6 +407,10 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
397 407
398 /* fw_size is in dwords, so multiplied by 4 to convert into bytes. */ 408 /* fw_size is in dwords, so multiplied by 4 to convert into bytes. */
399 nbytes = dmc_header->fw_size * 4; 409 nbytes = dmc_header->fw_size * 4;
410 fsize += nbytes;
411 if (fsize > fw->size)
412 goto error_truncated;
413
400 if (nbytes > csr->max_fw_size) { 414 if (nbytes > csr->max_fw_size) {
401 DRM_ERROR("DMC FW too big (%u bytes)\n", nbytes); 415 DRM_ERROR("DMC FW too big (%u bytes)\n", nbytes);
402 return NULL; 416 return NULL;
@@ -410,6 +424,10 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
410 } 424 }
411 425
412 return memcpy(dmc_payload, &fw->data[readcount], nbytes); 426 return memcpy(dmc_payload, &fw->data[readcount], nbytes);
427
428error_truncated:
429 DRM_ERROR("Truncated DMC firmware, rejecting.\n");
430 return NULL;
413} 431}
414 432
415static void intel_csr_runtime_pm_get(struct drm_i915_private *dev_priv) 433static void intel_csr_runtime_pm_get(struct drm_i915_private *dev_priv)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5098228f1302..b69440cf41ea 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2432,10 +2432,14 @@ static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
2432 * main surface. 2432 * main surface.
2433 */ 2433 */
2434static const struct drm_format_info ccs_formats[] = { 2434static const struct drm_format_info ccs_formats[] = {
2435 { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, }, 2435 { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2,
2436 { .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, }, 2436 .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, },
2437 { .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, }, 2437 { .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2,
2438 { .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, }, 2438 .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, },
2439 { .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2,
2440 .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, .has_alpha = true, },
2441 { .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2,
2442 .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, .has_alpha = true, },
2439}; 2443};
2440 2444
2441static const struct drm_format_info * 2445static const struct drm_format_info *
@@ -11942,7 +11946,7 @@ encoder_retry:
11942 return 0; 11946 return 0;
11943} 11947}
11944 11948
11945static bool intel_fuzzy_clock_check(int clock1, int clock2) 11949bool intel_fuzzy_clock_check(int clock1, int clock2)
11946{ 11950{
11947 int diff; 11951 int diff;
11948 11952
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index a38b9cff5cd0..e85cd377a652 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1742,6 +1742,7 @@ int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe,
1742 const struct dpll *dpll); 1742 const struct dpll *dpll);
1743void vlv_force_pll_off(struct drm_i915_private *dev_priv, enum pipe pipe); 1743void vlv_force_pll_off(struct drm_i915_private *dev_priv, enum pipe pipe);
1744int lpt_get_iclkip(struct drm_i915_private *dev_priv); 1744int lpt_get_iclkip(struct drm_i915_private *dev_priv);
1745bool intel_fuzzy_clock_check(int clock1, int clock2);
1745 1746
1746/* modesetting asserts */ 1747/* modesetting asserts */
1747void assert_panel_unlocked(struct drm_i915_private *dev_priv, 1748void assert_panel_unlocked(struct drm_i915_private *dev_priv,
diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c
index 3074448446bc..4b8e48db1843 100644
--- a/drivers/gpu/drm/i915/intel_dsi_vbt.c
+++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c
@@ -853,6 +853,17 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)
853 if (mipi_config->target_burst_mode_freq) { 853 if (mipi_config->target_burst_mode_freq) {
854 u32 bitrate = intel_dsi_bitrate(intel_dsi); 854 u32 bitrate = intel_dsi_bitrate(intel_dsi);
855 855
856 /*
857 * Sometimes the VBT contains a slightly lower clock,
858 * then the bitrate we have calculated, in this case
859 * just replace it with the calculated bitrate.
860 */
861 if (mipi_config->target_burst_mode_freq < bitrate &&
862 intel_fuzzy_clock_check(
863 mipi_config->target_burst_mode_freq,
864 bitrate))
865 mipi_config->target_burst_mode_freq = bitrate;
866
856 if (mipi_config->target_burst_mode_freq < bitrate) { 867 if (mipi_config->target_burst_mode_freq < bitrate) {
857 DRM_ERROR("Burst mode freq is less than computed\n"); 868 DRM_ERROR("Burst mode freq is less than computed\n");
858 return false; 869 return false;
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 0e3d91d9ef13..9ecfba0a54a1 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -916,6 +916,13 @@ static bool intel_sdvo_set_colorimetry(struct intel_sdvo *intel_sdvo,
916 return intel_sdvo_set_value(intel_sdvo, SDVO_CMD_SET_COLORIMETRY, &mode, 1); 916 return intel_sdvo_set_value(intel_sdvo, SDVO_CMD_SET_COLORIMETRY, &mode, 1);
917} 917}
918 918
919static bool intel_sdvo_set_audio_state(struct intel_sdvo *intel_sdvo,
920 u8 audio_state)
921{
922 return intel_sdvo_set_value(intel_sdvo, SDVO_CMD_SET_AUDIO_STAT,
923 &audio_state, 1);
924}
925
919#if 0 926#if 0
920static void intel_sdvo_dump_hdmi_buf(struct intel_sdvo *intel_sdvo) 927static void intel_sdvo_dump_hdmi_buf(struct intel_sdvo *intel_sdvo)
921{ 928{
@@ -1487,11 +1494,6 @@ static void intel_sdvo_pre_enable(struct intel_encoder *intel_encoder,
1487 else 1494 else
1488 sdvox |= SDVO_PIPE_SEL(crtc->pipe); 1495 sdvox |= SDVO_PIPE_SEL(crtc->pipe);
1489 1496
1490 if (crtc_state->has_audio) {
1491 WARN_ON_ONCE(INTEL_GEN(dev_priv) < 4);
1492 sdvox |= SDVO_AUDIO_ENABLE;
1493 }
1494
1495 if (INTEL_GEN(dev_priv) >= 4) { 1497 if (INTEL_GEN(dev_priv) >= 4) {
1496 /* done in crtc_mode_set as the dpll_md reg must be written early */ 1498 /* done in crtc_mode_set as the dpll_md reg must be written early */
1497 } else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) || 1499 } else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) ||
@@ -1635,8 +1637,13 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
1635 if (sdvox & HDMI_COLOR_RANGE_16_235) 1637 if (sdvox & HDMI_COLOR_RANGE_16_235)
1636 pipe_config->limited_color_range = true; 1638 pipe_config->limited_color_range = true;
1637 1639
1638 if (sdvox & SDVO_AUDIO_ENABLE) 1640 if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_AUDIO_STAT,
1639 pipe_config->has_audio = true; 1641 &val, 1)) {
1642 u8 mask = SDVO_AUDIO_ELD_VALID | SDVO_AUDIO_PRESENCE_DETECT;
1643
1644 if ((val & mask) == mask)
1645 pipe_config->has_audio = true;
1646 }
1640 1647
1641 if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_ENCODE, 1648 if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_ENCODE,
1642 &val, 1)) { 1649 &val, 1)) {
@@ -1647,6 +1654,32 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
1647 intel_sdvo_get_avi_infoframe(intel_sdvo, pipe_config); 1654 intel_sdvo_get_avi_infoframe(intel_sdvo, pipe_config);
1648} 1655}
1649 1656
1657static void intel_sdvo_disable_audio(struct intel_sdvo *intel_sdvo)
1658{
1659 intel_sdvo_set_audio_state(intel_sdvo, 0);
1660}
1661
1662static void intel_sdvo_enable_audio(struct intel_sdvo *intel_sdvo,
1663 const struct intel_crtc_state *crtc_state,
1664 const struct drm_connector_state *conn_state)
1665{
1666 const struct drm_display_mode *adjusted_mode =
1667 &crtc_state->base.adjusted_mode;
1668 struct drm_connector *connector = conn_state->connector;
1669 u8 *eld = connector->eld;
1670
1671 eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2;
1672
1673 intel_sdvo_set_audio_state(intel_sdvo, 0);
1674
1675 intel_sdvo_write_infoframe(intel_sdvo, SDVO_HBUF_INDEX_ELD,
1676 SDVO_HBUF_TX_DISABLED,
1677 eld, drm_eld_size(eld));
1678
1679 intel_sdvo_set_audio_state(intel_sdvo, SDVO_AUDIO_ELD_VALID |
1680 SDVO_AUDIO_PRESENCE_DETECT);
1681}
1682
1650static void intel_disable_sdvo(struct intel_encoder *encoder, 1683static void intel_disable_sdvo(struct intel_encoder *encoder,
1651 const struct intel_crtc_state *old_crtc_state, 1684 const struct intel_crtc_state *old_crtc_state,
1652 const struct drm_connector_state *conn_state) 1685 const struct drm_connector_state *conn_state)
@@ -1656,6 +1689,9 @@ static void intel_disable_sdvo(struct intel_encoder *encoder,
1656 struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc); 1689 struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
1657 u32 temp; 1690 u32 temp;
1658 1691
1692 if (old_crtc_state->has_audio)
1693 intel_sdvo_disable_audio(intel_sdvo);
1694
1659 intel_sdvo_set_active_outputs(intel_sdvo, 0); 1695 intel_sdvo_set_active_outputs(intel_sdvo, 0);
1660 if (0) 1696 if (0)
1661 intel_sdvo_set_encoder_power_state(intel_sdvo, 1697 intel_sdvo_set_encoder_power_state(intel_sdvo,
@@ -1741,6 +1777,9 @@ static void intel_enable_sdvo(struct intel_encoder *encoder,
1741 intel_sdvo_set_encoder_power_state(intel_sdvo, 1777 intel_sdvo_set_encoder_power_state(intel_sdvo,
1742 DRM_MODE_DPMS_ON); 1778 DRM_MODE_DPMS_ON);
1743 intel_sdvo_set_active_outputs(intel_sdvo, intel_sdvo->attached_output); 1779 intel_sdvo_set_active_outputs(intel_sdvo, intel_sdvo->attached_output);
1780
1781 if (pipe_config->has_audio)
1782 intel_sdvo_enable_audio(intel_sdvo, pipe_config, conn_state);
1744} 1783}
1745 1784
1746static enum drm_mode_status 1785static enum drm_mode_status
@@ -2603,7 +2642,6 @@ static bool
2603intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) 2642intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2604{ 2643{
2605 struct drm_encoder *encoder = &intel_sdvo->base.base; 2644 struct drm_encoder *encoder = &intel_sdvo->base.base;
2606 struct drm_i915_private *dev_priv = to_i915(encoder->dev);
2607 struct drm_connector *connector; 2645 struct drm_connector *connector;
2608 struct intel_encoder *intel_encoder = to_intel_encoder(encoder); 2646 struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
2609 struct intel_connector *intel_connector; 2647 struct intel_connector *intel_connector;
@@ -2640,9 +2678,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2640 encoder->encoder_type = DRM_MODE_ENCODER_TMDS; 2678 encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
2641 connector->connector_type = DRM_MODE_CONNECTOR_DVID; 2679 connector->connector_type = DRM_MODE_CONNECTOR_DVID;
2642 2680
2643 /* gen3 doesn't do the hdmi bits in the SDVO register */ 2681 if (intel_sdvo_is_hdmi_connector(intel_sdvo, device)) {
2644 if (INTEL_GEN(dev_priv) >= 4 &&
2645 intel_sdvo_is_hdmi_connector(intel_sdvo, device)) {
2646 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; 2682 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA;
2647 intel_sdvo_connector->is_hdmi = true; 2683 intel_sdvo_connector->is_hdmi = true;
2648 } 2684 }
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h
index db0ed499268a..e9ba3b047f93 100644
--- a/drivers/gpu/drm/i915/intel_sdvo_regs.h
+++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h
@@ -707,6 +707,9 @@ struct intel_sdvo_enhancements_arg {
707#define SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER 0x90 707#define SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER 0x90
708#define SDVO_CMD_SET_AUDIO_STAT 0x91 708#define SDVO_CMD_SET_AUDIO_STAT 0x91
709#define SDVO_CMD_GET_AUDIO_STAT 0x92 709#define SDVO_CMD_GET_AUDIO_STAT 0x92
710 #define SDVO_AUDIO_ELD_VALID (1 << 0)
711 #define SDVO_AUDIO_PRESENCE_DETECT (1 << 1)
712 #define SDVO_AUDIO_CP_READY (1 << 2)
710#define SDVO_CMD_SET_HBUF_INDEX 0x93 713#define SDVO_CMD_SET_HBUF_INDEX 0x93
711 #define SDVO_HBUF_INDEX_ELD 0 714 #define SDVO_HBUF_INDEX_ELD 0
712 #define SDVO_HBUF_INDEX_AVI_IF 1 715 #define SDVO_HBUF_INDEX_AVI_IF 1
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index f426dfdfb418..a9007210dda1 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -90,10 +90,6 @@ static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
90static void mtk_drm_crtc_destroy(struct drm_crtc *crtc) 90static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
91{ 91{
92 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); 92 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
93 int i;
94
95 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
96 clk_unprepare(mtk_crtc->ddp_comp[i]->clk);
97 93
98 mtk_disp_mutex_put(mtk_crtc->mutex); 94 mtk_disp_mutex_put(mtk_crtc->mutex);
99 95
@@ -186,7 +182,7 @@ static int mtk_crtc_ddp_clk_enable(struct mtk_drm_crtc *mtk_crtc)
186 182
187 DRM_DEBUG_DRIVER("%s\n", __func__); 183 DRM_DEBUG_DRIVER("%s\n", __func__);
188 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { 184 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
189 ret = clk_enable(mtk_crtc->ddp_comp[i]->clk); 185 ret = clk_prepare_enable(mtk_crtc->ddp_comp[i]->clk);
190 if (ret) { 186 if (ret) {
191 DRM_ERROR("Failed to enable clock %d: %d\n", i, ret); 187 DRM_ERROR("Failed to enable clock %d: %d\n", i, ret);
192 goto err; 188 goto err;
@@ -196,7 +192,7 @@ static int mtk_crtc_ddp_clk_enable(struct mtk_drm_crtc *mtk_crtc)
196 return 0; 192 return 0;
197err: 193err:
198 while (--i >= 0) 194 while (--i >= 0)
199 clk_disable(mtk_crtc->ddp_comp[i]->clk); 195 clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk);
200 return ret; 196 return ret;
201} 197}
202 198
@@ -206,7 +202,7 @@ static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc)
206 202
207 DRM_DEBUG_DRIVER("%s\n", __func__); 203 DRM_DEBUG_DRIVER("%s\n", __func__);
208 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) 204 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
209 clk_disable(mtk_crtc->ddp_comp[i]->clk); 205 clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk);
210} 206}
211 207
212static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) 208static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc)
@@ -577,15 +573,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
577 if (!comp) { 573 if (!comp) {
578 dev_err(dev, "Component %pOF not initialized\n", node); 574 dev_err(dev, "Component %pOF not initialized\n", node);
579 ret = -ENODEV; 575 ret = -ENODEV;
580 goto unprepare; 576 return ret;
581 }
582
583 ret = clk_prepare(comp->clk);
584 if (ret) {
585 dev_err(dev,
586 "Failed to prepare clock for component %pOF: %d\n",
587 node, ret);
588 goto unprepare;
589 } 577 }
590 578
591 mtk_crtc->ddp_comp[i] = comp; 579 mtk_crtc->ddp_comp[i] = comp;
@@ -603,23 +591,17 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
603 ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos], 591 ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos],
604 BIT(pipe), type); 592 BIT(pipe), type);
605 if (ret) 593 if (ret)
606 goto unprepare; 594 return ret;
607 } 595 }
608 596
609 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0], 597 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
610 mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] : 598 mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
611 NULL, pipe); 599 NULL, pipe);
612 if (ret < 0) 600 if (ret < 0)
613 goto unprepare; 601 return ret;
614 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE); 602 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE);
615 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE); 603 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE);
616 priv->num_pipes++; 604 priv->num_pipes++;
617 605
618 return 0; 606 return 0;
619
620unprepare:
621 while (--i >= 0)
622 clk_unprepare(mtk_crtc->ddp_comp[i]->clk);
623
624 return ret;
625} 607}
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 7fcb7407096f..95fdbd0fbcac 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -303,6 +303,7 @@ err_config_cleanup:
303static void mtk_drm_kms_deinit(struct drm_device *drm) 303static void mtk_drm_kms_deinit(struct drm_device *drm)
304{ 304{
305 drm_kms_helper_poll_fini(drm); 305 drm_kms_helper_poll_fini(drm);
306 drm_atomic_helper_shutdown(drm);
306 307
307 component_unbind_all(drm->dev, drm); 308 component_unbind_all(drm->dev, drm);
308 drm_mode_config_cleanup(drm); 309 drm_mode_config_cleanup(drm);
@@ -389,7 +390,9 @@ static void mtk_drm_unbind(struct device *dev)
389 struct mtk_drm_private *private = dev_get_drvdata(dev); 390 struct mtk_drm_private *private = dev_get_drvdata(dev);
390 391
391 drm_dev_unregister(private->drm); 392 drm_dev_unregister(private->drm);
393 mtk_drm_kms_deinit(private->drm);
392 drm_dev_put(private->drm); 394 drm_dev_put(private->drm);
395 private->num_pipes = 0;
393 private->drm = NULL; 396 private->drm = NULL;
394} 397}
395 398
@@ -560,13 +563,8 @@ err_node:
560static int mtk_drm_remove(struct platform_device *pdev) 563static int mtk_drm_remove(struct platform_device *pdev)
561{ 564{
562 struct mtk_drm_private *private = platform_get_drvdata(pdev); 565 struct mtk_drm_private *private = platform_get_drvdata(pdev);
563 struct drm_device *drm = private->drm;
564 int i; 566 int i;
565 567
566 drm_dev_unregister(drm);
567 mtk_drm_kms_deinit(drm);
568 drm_dev_put(drm);
569
570 component_master_del(&pdev->dev, &mtk_drm_ops); 568 component_master_del(&pdev->dev, &mtk_drm_ops);
571 pm_runtime_disable(&pdev->dev); 569 pm_runtime_disable(&pdev->dev);
572 of_node_put(private->mutex_node); 570 of_node_put(private->mutex_node);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index 3eefb22206c7..0d69698f8173 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -136,7 +136,6 @@ static int mtk_drm_gem_object_mmap(struct drm_gem_object *obj,
136 * VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap(). 136 * VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap().
137 */ 137 */
138 vma->vm_flags &= ~VM_PFNMAP; 138 vma->vm_flags &= ~VM_PFNMAP;
139 vma->vm_pgoff = 0;
140 139
141 ret = dma_mmap_attrs(priv->dma_dev, vma, mtk_gem->cookie, 140 ret = dma_mmap_attrs(priv->dma_dev, vma, mtk_gem->cookie,
142 mtk_gem->dma_addr, obj->size, mtk_gem->dma_attrs); 141 mtk_gem->dma_addr, obj->size, mtk_gem->dma_attrs);
@@ -168,6 +167,12 @@ int mtk_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
168 167
169 obj = vma->vm_private_data; 168 obj = vma->vm_private_data;
170 169
170 /*
171 * Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the
172 * whole buffer from the start.
173 */
174 vma->vm_pgoff = 0;
175
171 return mtk_drm_gem_object_mmap(obj, vma); 176 return mtk_drm_gem_object_mmap(obj, vma);
172} 177}
173 178
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 4a0b9150a7bb..b91c4616644a 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -622,6 +622,15 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
622 if (--dsi->refcount != 0) 622 if (--dsi->refcount != 0)
623 return; 623 return;
624 624
625 /*
626 * mtk_dsi_stop() and mtk_dsi_start() is asymmetric, since
627 * mtk_dsi_stop() should be called after mtk_drm_crtc_atomic_disable(),
628 * which needs irq for vblank, and mtk_dsi_stop() will disable irq.
629 * mtk_dsi_start() needs to be called in mtk_output_dsi_enable(),
630 * after dsi is fully set.
631 */
632 mtk_dsi_stop(dsi);
633
625 if (!mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500)) { 634 if (!mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500)) {
626 if (dsi->panel) { 635 if (dsi->panel) {
627 if (drm_panel_unprepare(dsi->panel)) { 636 if (drm_panel_unprepare(dsi->panel)) {
@@ -688,7 +697,6 @@ static void mtk_output_dsi_disable(struct mtk_dsi *dsi)
688 } 697 }
689 } 698 }
690 699
691 mtk_dsi_stop(dsi);
692 mtk_dsi_poweroff(dsi); 700 mtk_dsi_poweroff(dsi);
693 701
694 dsi->enabled = false; 702 dsi->enabled = false;
@@ -836,6 +844,8 @@ static void mtk_dsi_destroy_conn_enc(struct mtk_dsi *dsi)
836 /* Skip connector cleanup if creation was delegated to the bridge */ 844 /* Skip connector cleanup if creation was delegated to the bridge */
837 if (dsi->conn.dev) 845 if (dsi->conn.dev)
838 drm_connector_cleanup(&dsi->conn); 846 drm_connector_cleanup(&dsi->conn);
847 if (dsi->panel)
848 drm_panel_detach(dsi->panel);
839} 849}
840 850
841static void mtk_dsi_ddp_start(struct mtk_ddp_comp *comp) 851static void mtk_dsi_ddp_start(struct mtk_ddp_comp *comp)
diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
index 685715144156..aa8ea107524e 100644
--- a/drivers/gpu/drm/meson/meson_crtc.c
+++ b/drivers/gpu/drm/meson/meson_crtc.c
@@ -107,8 +107,6 @@ static void meson_g12a_crtc_atomic_enable(struct drm_crtc *crtc,
107 priv->io_base + _REG(VPP_OUT_H_V_SIZE)); 107 priv->io_base + _REG(VPP_OUT_H_V_SIZE));
108 108
109 drm_crtc_vblank_on(crtc); 109 drm_crtc_vblank_on(crtc);
110
111 priv->viu.osd1_enabled = true;
112} 110}
113 111
114static void meson_crtc_atomic_enable(struct drm_crtc *crtc, 112static void meson_crtc_atomic_enable(struct drm_crtc *crtc,
@@ -137,8 +135,6 @@ static void meson_crtc_atomic_enable(struct drm_crtc *crtc,
137 priv->io_base + _REG(VPP_MISC)); 135 priv->io_base + _REG(VPP_MISC));
138 136
139 drm_crtc_vblank_on(crtc); 137 drm_crtc_vblank_on(crtc);
140
141 priv->viu.osd1_enabled = true;
142} 138}
143 139
144static void meson_g12a_crtc_atomic_disable(struct drm_crtc *crtc, 140static void meson_g12a_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -256,6 +252,8 @@ static void meson_g12a_crtc_enable_osd1(struct meson_drm *priv)
256 writel_relaxed(priv->viu.osb_blend1_size, 252 writel_relaxed(priv->viu.osb_blend1_size,
257 priv->io_base + 253 priv->io_base +
258 _REG(VIU_OSD_BLEND_BLEND1_SIZE)); 254 _REG(VIU_OSD_BLEND_BLEND1_SIZE));
255 writel_bits_relaxed(3 << 8, 3 << 8,
256 priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
259} 257}
260 258
261static void meson_crtc_enable_vd1(struct meson_drm *priv) 259static void meson_crtc_enable_vd1(struct meson_drm *priv)
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index 22490047932e..d90427b93a51 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -305,6 +305,8 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
305 meson_plane->enabled = true; 305 meson_plane->enabled = true;
306 } 306 }
307 307
308 priv->viu.osd1_enabled = true;
309
308 spin_unlock_irqrestore(&priv->drm->event_lock, flags); 310 spin_unlock_irqrestore(&priv->drm->event_lock, flags);
309} 311}
310 312
@@ -316,14 +318,14 @@ static void meson_plane_atomic_disable(struct drm_plane *plane,
316 318
317 /* Disable OSD1 */ 319 /* Disable OSD1 */
318 if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) 320 if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu"))
319 writel_bits_relaxed(BIT(0) | BIT(21), 0, 321 writel_bits_relaxed(3 << 8, 0,
320 priv->io_base + _REG(VIU_OSD1_CTRL_STAT)); 322 priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
321 else 323 else
322 writel_bits_relaxed(VPP_OSD1_POSTBLEND, 0, 324 writel_bits_relaxed(VPP_OSD1_POSTBLEND, 0,
323 priv->io_base + _REG(VPP_MISC)); 325 priv->io_base + _REG(VPP_MISC));
324 326
325 meson_plane->enabled = false; 327 meson_plane->enabled = false;
326 328 priv->viu.osd1_enabled = false;
327} 329}
328 330
329static const struct drm_plane_helper_funcs meson_plane_helper_funcs = { 331static const struct drm_plane_helper_funcs meson_plane_helper_funcs = {
diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c
index 58b4af5fbb6d..26732f038d19 100644
--- a/drivers/gpu/drm/meson/meson_vclk.c
+++ b/drivers/gpu/drm/meson/meson_vclk.c
@@ -503,8 +503,17 @@ void meson_hdmi_pll_set_params(struct meson_drm *priv, unsigned int m,
503 503
504 /* G12A HDMI PLL Needs specific parameters for 5.4GHz */ 504 /* G12A HDMI PLL Needs specific parameters for 5.4GHz */
505 if (m >= 0xf7) { 505 if (m >= 0xf7) {
506 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL4, 0xea68dc00); 506 if (frac < 0x10000) {
507 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL5, 0x65771290); 507 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL4,
508 0x6a685c00);
509 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL5,
510 0x11551293);
511 } else {
512 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL4,
513 0xea68dc00);
514 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL5,
515 0x65771290);
516 }
508 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL6, 0x39272000); 517 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL6, 0x39272000);
509 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL7, 0x55540000); 518 regmap_write(priv->hhi, HHI_HDMI_PLL_CNTL7, 0x55540000);
510 } else { 519 } else {
diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c
index 462c7cb3e1bd..4b2b3024d371 100644
--- a/drivers/gpu/drm/meson/meson_viu.c
+++ b/drivers/gpu/drm/meson/meson_viu.c
@@ -405,8 +405,7 @@ void meson_viu_init(struct meson_drm *priv)
405 0 << 16 | 405 0 << 16 |
406 1, 406 1,
407 priv->io_base + _REG(VIU_OSD_BLEND_CTRL)); 407 priv->io_base + _REG(VIU_OSD_BLEND_CTRL));
408 writel_relaxed(3 << 8 | 408 writel_relaxed(1 << 20,
409 1 << 20,
410 priv->io_base + _REG(OSD1_BLEND_SRC_CTRL)); 409 priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
411 writel_relaxed(1 << 20, 410 writel_relaxed(1 << 20,
412 priv->io_base + _REG(OSD2_BLEND_SRC_CTRL)); 411 priv->io_base + _REG(OSD2_BLEND_SRC_CTRL));
diff --git a/drivers/gpu/drm/panfrost/Kconfig b/drivers/gpu/drm/panfrost/Kconfig
index 81963e964b0f..86cdc0ce79e6 100644
--- a/drivers/gpu/drm/panfrost/Kconfig
+++ b/drivers/gpu/drm/panfrost/Kconfig
@@ -10,6 +10,7 @@ config DRM_PANFROST
10 select IOMMU_IO_PGTABLE_LPAE 10 select IOMMU_IO_PGTABLE_LPAE
11 select DRM_GEM_SHMEM_HELPER 11 select DRM_GEM_SHMEM_HELPER
12 select PM_DEVFREQ 12 select PM_DEVFREQ
13 select DEVFREQ_GOV_SIMPLE_ONDEMAND
13 help 14 help
14 DRM driver for ARM Mali Midgard (T6xx, T7xx, T8xx) and 15 DRM driver for ARM Mali Midgard (T6xx, T7xx, T8xx) and
15 Bifrost (G3x, G5x, G7x) GPUs. 16 Bifrost (G3x, G5x, G7x) GPUs.
diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 29fcffdf2d57..db798532b0b6 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -140,7 +140,9 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
140 return 0; 140 return 0;
141 141
142 ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev); 142 ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev);
143 if (ret) 143 if (ret == -ENODEV) /* Optional, continue without devfreq */
144 return 0;
145 else if (ret)
144 return ret; 146 return ret;
145 147
146 panfrost_devfreq_reset(pfdev); 148 panfrost_devfreq_reset(pfdev);
@@ -170,6 +172,9 @@ void panfrost_devfreq_resume(struct panfrost_device *pfdev)
170{ 172{
171 int i; 173 int i;
172 174
175 if (!pfdev->devfreq.devfreq)
176 return;
177
173 panfrost_devfreq_reset(pfdev); 178 panfrost_devfreq_reset(pfdev);
174 for (i = 0; i < NUM_JOB_SLOTS; i++) 179 for (i = 0; i < NUM_JOB_SLOTS; i++)
175 pfdev->devfreq.slot[i].busy = false; 180 pfdev->devfreq.slot[i].busy = false;
@@ -179,6 +184,9 @@ void panfrost_devfreq_resume(struct panfrost_device *pfdev)
179 184
180void panfrost_devfreq_suspend(struct panfrost_device *pfdev) 185void panfrost_devfreq_suspend(struct panfrost_device *pfdev)
181{ 186{
187 if (!pfdev->devfreq.devfreq)
188 return;
189
182 devfreq_suspend_device(pfdev->devfreq.devfreq); 190 devfreq_suspend_device(pfdev->devfreq.devfreq);
183} 191}
184 192
@@ -188,6 +196,9 @@ static void panfrost_devfreq_update_utilization(struct panfrost_device *pfdev, i
188 ktime_t now; 196 ktime_t now;
189 ktime_t last; 197 ktime_t last;
190 198
199 if (!pfdev->devfreq.devfreq)
200 return;
201
191 now = ktime_get(); 202 now = ktime_get();
192 last = pfdev->devfreq.slot[slot].time_last_update; 203 last = pfdev->devfreq.slot[slot].time_last_update;
193 204
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 9d3b5b93102c..c9ca0be54d9a 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -471,6 +471,7 @@ struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
471 struct i2c_adapter *adapter); 471 struct i2c_adapter *adapter);
472struct edid *drm_edid_duplicate(const struct edid *edid); 472struct edid *drm_edid_duplicate(const struct edid *edid);
473int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); 473int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
474int drm_add_override_edid_modes(struct drm_connector *connector);
474 475
475u8 drm_match_cea_mode(const struct drm_display_mode *to_match); 476u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
476enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); 477enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);