aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 17:34:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 17:34:42 -0500
commitf6705bf959efac87bca76d40050d342f1d212587 (patch)
treee199b124c6067a92be7f4727538ffc721670fc28 /drivers/gpu/drm/amd/amdgpu
parentbec04432cb9036dedf89140c102b5ac03e4b3626 (diff)
parent49e37ba07a3ae697086c0a1a32c113a1f177d138 (diff)
Merge tag 'drm-for-v4.15-amd-dc' of git://people.freedesktop.org/~airlied/linux
Pull amdgpu DC display code for Vega from Dave Airlie: "This is the pull request for the AMD DC (display code) layer which is a requirement to program the display engines on the new Vega and Raven based GPUs. It also contains support for all amdgpu supported GPUs (CIK, VI, Polaris), which has to be enabled. It is also a kms atomic modesetting compatible driver (unlike the current in-tree display code). I've kept it separate from drm-next because it may have some things that cause you to reject it. Background story: AMD have an internal team creating a shared OS codebase for display at hw bring up time using information from their hardware teams. This process doesn't lead to the most Linux friendly/looking code but we have worked together on cleaning a lot of it up and dealing with sparse/smatch/checkpatch, and having their team internally adhere to Linux coding standards. This tree is a complete history rebased since they started opening it, we decided not to squash it down as the history may have some value. Some of the commits therefore might not reach kernel standards, and we are steadily training people in AMD to better write commit msgs. There is a major bunch of generated bandwidth calculation and verification code that comes from their hardware team. On Vega and before this is float calculations, on Raven (DCN10) this is double based. They do the required things to do FP in the kernel, and I could understand this might raise some issues. Rewriting the bandwidth would be a major undertaken in reverification, it's non-trivial to work out if a display can handle the complete set of mode information thrown at it. Future story: There is a TODO list with this, and it address most of the remaining things that would be nice to refine/remove. The DCN10 code is still under development internally and they push out a lot of patches quite regularly and are supporting this code base with their display team. I think we've reached the point where keeping it out of tree is going to motivate distributions to start carrying the code, so I'd prefer we get it in tree. I think this code is slightly better than STAGING quality but not massively so, I'd really like to see that float/double magic gone and fixed point used, but AMD don't seem to think the accuracy and revalidation of the code is worth the effort" * tag 'drm-for-v4.15-amd-dc' of git://people.freedesktop.org/~airlied/linux: (1110 commits) drm/amd/display: fix MST link training fail division by 0 drm/amd/display: Fix formatting for null pointer dereference fix drm/amd/display: Remove dangling planes on dc commit state drm/amd/display: add flip_immediate to commit update for stream drm/amd/display: Miss register MST encoder cbs drm/amd/display: Fix warnings on S3 resume drm/amd/display: use num_timing_generator instead of pipe_count drm/amd/display: use configurable FBC option in dm drm/amd/display: fix AZ clock not enabled before program AZ endpoint amdgpu/dm: Don't use DRM_ERROR in amdgpu_dm_atomic_check amd/display: Fix potential null dereference in dce_calcs.c amdgpu/dm: Remove unused forward declaration drm/amdgpu: Remove unused dc_stream from amdgpu_crtc amdgpu/dc: Fix double unlock in amdgpu_dm_commit_planes amdgpu/dc: Fix missing null checks in amdgpu_dm.c amdgpu/dc: Fix potential null dereferences in amdgpu_dm.c amdgpu/dc: fix more indentation warnings amdgpu/dc: handle allocation failures in dc_commit_planes_to_stream. amdgpu/dc: fix indentation warning from smatch. amdgpu/dc: fix non-ansi function decls. ...
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/Kconfig1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/Makefile17
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h16
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c59
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c105
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_display.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_display.h33
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c26
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c29
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h97
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cik.c17
-rw-r--r--drivers/gpu/drm/amd/amdgpu/soc15.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vi.c21
17 files changed, 376 insertions, 75 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
index 26682454a446..e8af1f5e8a79 100644
--- a/drivers/gpu/drm/amd/amdgpu/Kconfig
+++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
@@ -41,3 +41,4 @@ config DRM_AMDGPU_GART_DEBUGFS
41 pages. Uses more memory for housekeeping, enable only for debugging. 41 pages. Uses more memory for housekeeping, enable only for debugging.
42 42
43source "drivers/gpu/drm/amd/acp/Kconfig" 43source "drivers/gpu/drm/amd/acp/Kconfig"
44source "drivers/gpu/drm/amd/display/Kconfig"
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index 7fc42e077770..78d609123420 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -4,13 +4,19 @@
4# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. 4# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
5 5
6FULL_AMD_PATH=$(src)/.. 6FULL_AMD_PATH=$(src)/..
7DISPLAY_FOLDER_NAME=display
8FULL_AMD_DISPLAY_PATH = $(FULL_AMD_PATH)/$(DISPLAY_FOLDER_NAME)
7 9
8ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ 10ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
9 -I$(FULL_AMD_PATH)/include \ 11 -I$(FULL_AMD_PATH)/include \
10 -I$(FULL_AMD_PATH)/amdgpu \ 12 -I$(FULL_AMD_PATH)/amdgpu \
11 -I$(FULL_AMD_PATH)/scheduler \ 13 -I$(FULL_AMD_PATH)/scheduler \
12 -I$(FULL_AMD_PATH)/powerplay/inc \ 14 -I$(FULL_AMD_PATH)/powerplay/inc \
13 -I$(FULL_AMD_PATH)/acp/include 15 -I$(FULL_AMD_PATH)/acp/include \
16 -I$(FULL_AMD_DISPLAY_PATH) \
17 -I$(FULL_AMD_DISPLAY_PATH)/include \
18 -I$(FULL_AMD_DISPLAY_PATH)/dc \
19 -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm
14 20
15amdgpu-y := amdgpu_drv.o 21amdgpu-y := amdgpu_drv.o
16 22
@@ -133,4 +139,13 @@ include $(FULL_AMD_PATH)/powerplay/Makefile
133 139
134amdgpu-y += $(AMD_POWERPLAY_FILES) 140amdgpu-y += $(AMD_POWERPLAY_FILES)
135 141
142ifneq ($(CONFIG_DRM_AMD_DC),)
143
144RELATIVE_AMD_DISPLAY_PATH = ../$(DISPLAY_FOLDER_NAME)
145include $(FULL_AMD_DISPLAY_PATH)/Makefile
146
147amdgpu-y += $(AMD_DISPLAY_FILES)
148
149endif
150
136obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o 151obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index cbcb6a153aba..5afaf6016b4a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -66,6 +66,7 @@
66#include "amdgpu_vce.h" 66#include "amdgpu_vce.h"
67#include "amdgpu_vcn.h" 67#include "amdgpu_vcn.h"
68#include "amdgpu_mn.h" 68#include "amdgpu_mn.h"
69#include "amdgpu_dm.h"
69 70
70#include "gpu_scheduler.h" 71#include "gpu_scheduler.h"
71#include "amdgpu_virt.h" 72#include "amdgpu_virt.h"
@@ -101,6 +102,8 @@ extern int amdgpu_vm_fragment_size;
101extern int amdgpu_vm_fault_stop; 102extern int amdgpu_vm_fault_stop;
102extern int amdgpu_vm_debug; 103extern int amdgpu_vm_debug;
103extern int amdgpu_vm_update_mode; 104extern int amdgpu_vm_update_mode;
105extern int amdgpu_dc;
106extern int amdgpu_dc_log;
104extern int amdgpu_sched_jobs; 107extern int amdgpu_sched_jobs;
105extern int amdgpu_sched_hw_submission; 108extern int amdgpu_sched_hw_submission;
106extern int amdgpu_no_evict; 109extern int amdgpu_no_evict;
@@ -1535,6 +1538,7 @@ struct amdgpu_device {
1535 /* display */ 1538 /* display */
1536 bool enable_virtual_display; 1539 bool enable_virtual_display;
1537 struct amdgpu_mode_info mode_info; 1540 struct amdgpu_mode_info mode_info;
1541 /* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
1538 struct work_struct hotplug_work; 1542 struct work_struct hotplug_work;
1539 struct amdgpu_irq_src crtc_irq; 1543 struct amdgpu_irq_src crtc_irq;
1540 struct amdgpu_irq_src pageflip_irq; 1544 struct amdgpu_irq_src pageflip_irq;
@@ -1590,6 +1594,9 @@ struct amdgpu_device {
1590 /* GDS */ 1594 /* GDS */
1591 struct amdgpu_gds gds; 1595 struct amdgpu_gds gds;
1592 1596
1597 /* display related functionality */
1598 struct amdgpu_display_manager dm;
1599
1593 struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM]; 1600 struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM];
1594 int num_ip_blocks; 1601 int num_ip_blocks;
1595 struct mutex mn_lock; 1602 struct mutex mn_lock;
@@ -1653,6 +1660,9 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v);
1653u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index); 1660u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index);
1654void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v); 1661void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v);
1655 1662
1663bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type);
1664bool amdgpu_device_has_dc_support(struct amdgpu_device *adev);
1665
1656/* 1666/*
1657 * Registers read & write functions. 1667 * Registers read & write functions.
1658 */ 1668 */
@@ -1911,5 +1921,11 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
1911 uint64_t addr, struct amdgpu_bo **bo, 1921 uint64_t addr, struct amdgpu_bo **bo,
1912 struct amdgpu_bo_va_mapping **mapping); 1922 struct amdgpu_bo_va_mapping **mapping);
1913 1923
1924#if defined(CONFIG_DRM_AMD_DC)
1925int amdgpu_dm_display_resume(struct amdgpu_device *adev );
1926#else
1927static inline int amdgpu_dm_display_resume(struct amdgpu_device *adev) { return 0; }
1928#endif
1929
1914#include "amdgpu_object.h" 1930#include "amdgpu_object.h"
1915#endif 1931#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index a7afe553e0a1..f2b72c7c6857 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -911,10 +911,6 @@ static int amdgpu_cgs_get_active_displays_info(struct cgs_device *cgs_device,
911 struct cgs_display_info *info) 911 struct cgs_display_info *info)
912{ 912{
913 CGS_FUNC_ADEV; 913 CGS_FUNC_ADEV;
914 struct amdgpu_crtc *amdgpu_crtc;
915 struct drm_device *ddev = adev->ddev;
916 struct drm_crtc *crtc;
917 uint32_t line_time_us, vblank_lines;
918 struct cgs_mode_info *mode_info; 914 struct cgs_mode_info *mode_info;
919 915
920 if (info == NULL) 916 if (info == NULL)
@@ -928,30 +924,43 @@ static int amdgpu_cgs_get_active_displays_info(struct cgs_device *cgs_device,
928 mode_info->ref_clock = adev->clock.spll.reference_freq; 924 mode_info->ref_clock = adev->clock.spll.reference_freq;
929 } 925 }
930 926
931 if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { 927 if (!amdgpu_device_has_dc_support(adev)) {
932 list_for_each_entry(crtc, 928 struct amdgpu_crtc *amdgpu_crtc;
933 &ddev->mode_config.crtc_list, head) { 929 struct drm_device *ddev = adev->ddev;
934 amdgpu_crtc = to_amdgpu_crtc(crtc); 930 struct drm_crtc *crtc;
935 if (crtc->enabled) { 931 uint32_t line_time_us, vblank_lines;
936 info->active_display_mask |= (1 << amdgpu_crtc->crtc_id); 932
937 info->display_count++; 933 if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
938 } 934 list_for_each_entry(crtc,
939 if (mode_info != NULL && 935 &ddev->mode_config.crtc_list, head) {
940 crtc->enabled && amdgpu_crtc->enabled && 936 amdgpu_crtc = to_amdgpu_crtc(crtc);
941 amdgpu_crtc->hw_mode.clock) { 937 if (crtc->enabled) {
942 line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) / 938 info->active_display_mask |= (1 << amdgpu_crtc->crtc_id);
943 amdgpu_crtc->hw_mode.clock; 939 info->display_count++;
944 vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end - 940 }
945 amdgpu_crtc->hw_mode.crtc_vdisplay + 941 if (mode_info != NULL &&
946 (amdgpu_crtc->v_border * 2); 942 crtc->enabled && amdgpu_crtc->enabled &&
947 mode_info->vblank_time_us = vblank_lines * line_time_us; 943 amdgpu_crtc->hw_mode.clock) {
948 mode_info->refresh_rate = drm_mode_vrefresh(&amdgpu_crtc->hw_mode); 944 line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) /
949 mode_info->ref_clock = adev->clock.spll.reference_freq; 945 amdgpu_crtc->hw_mode.clock;
950 mode_info = NULL; 946 vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end -
947 amdgpu_crtc->hw_mode.crtc_vdisplay +
948 (amdgpu_crtc->v_border * 2);
949 mode_info->vblank_time_us = vblank_lines * line_time_us;
950 mode_info->refresh_rate = drm_mode_vrefresh(&amdgpu_crtc->hw_mode);
951 mode_info->ref_clock = adev->clock.spll.reference_freq;
952 mode_info = NULL;
953 }
951 } 954 }
952 } 955 }
956 } else {
957 info->display_count = adev->pm.pm_display_cfg.num_display;
958 if (mode_info != NULL) {
959 mode_info->vblank_time_us = adev->pm.pm_display_cfg.min_vblank_time;
960 mode_info->refresh_rate = adev->pm.pm_display_cfg.vrefresh;
961 mode_info->ref_clock = adev->clock.spll.reference_freq;
962 }
953 } 963 }
954
955 return 0; 964 return 0;
956} 965}
957 966
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index efcacb827de7..2d792cdc094c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -31,6 +31,7 @@
31#include <linux/debugfs.h> 31#include <linux/debugfs.h>
32#include <drm/drmP.h> 32#include <drm/drmP.h>
33#include <drm/drm_crtc_helper.h> 33#include <drm/drm_crtc_helper.h>
34#include <drm/drm_atomic_helper.h>
34#include <drm/amdgpu_drm.h> 35#include <drm/amdgpu_drm.h>
35#include <linux/vgaarb.h> 36#include <linux/vgaarb.h>
36#include <linux/vga_switcheroo.h> 37#include <linux/vga_switcheroo.h>
@@ -2046,6 +2047,52 @@ static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev)
2046 } 2047 }
2047} 2048}
2048 2049
2050bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
2051{
2052 switch (asic_type) {
2053#if defined(CONFIG_DRM_AMD_DC)
2054 case CHIP_BONAIRE:
2055 case CHIP_HAWAII:
2056 case CHIP_KAVERI:
2057 case CHIP_CARRIZO:
2058 case CHIP_STONEY:
2059 case CHIP_POLARIS11:
2060 case CHIP_POLARIS10:
2061 case CHIP_POLARIS12:
2062 case CHIP_TONGA:
2063 case CHIP_FIJI:
2064#if defined(CONFIG_DRM_AMD_DC_PRE_VEGA)
2065 return amdgpu_dc != 0;
2066#endif
2067 case CHIP_KABINI:
2068 case CHIP_MULLINS:
2069 return amdgpu_dc > 0;
2070 case CHIP_VEGA10:
2071#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
2072 case CHIP_RAVEN:
2073#endif
2074 return amdgpu_dc != 0;
2075#endif
2076 default:
2077 return false;
2078 }
2079}
2080
2081/**
2082 * amdgpu_device_has_dc_support - check if dc is supported
2083 *
2084 * @adev: amdgpu_device_pointer
2085 *
2086 * Returns true for supported, false for not supported
2087 */
2088bool amdgpu_device_has_dc_support(struct amdgpu_device *adev)
2089{
2090 if (amdgpu_sriov_vf(adev))
2091 return false;
2092
2093 return amdgpu_device_asic_has_dc_support(adev->asic_type);
2094}
2095
2049/** 2096/**
2050 * amdgpu_device_init - initialize the driver 2097 * amdgpu_device_init - initialize the driver
2051 * 2098 *
@@ -2100,7 +2147,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
2100 adev->audio_endpt_rreg = &amdgpu_block_invalid_rreg; 2147 adev->audio_endpt_rreg = &amdgpu_block_invalid_rreg;
2101 adev->audio_endpt_wreg = &amdgpu_block_invalid_wreg; 2148 adev->audio_endpt_wreg = &amdgpu_block_invalid_wreg;
2102 2149
2103
2104 DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X).\n", 2150 DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X).\n",
2105 amdgpu_asic_name[adev->asic_type], pdev->vendor, pdev->device, 2151 amdgpu_asic_name[adev->asic_type], pdev->vendor, pdev->device,
2106 pdev->subsystem_vendor, pdev->subsystem_device, pdev->revision); 2152 pdev->subsystem_vendor, pdev->subsystem_device, pdev->revision);
@@ -2242,7 +2288,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
2242 goto failed; 2288 goto failed;
2243 } 2289 }
2244 /* init i2c buses */ 2290 /* init i2c buses */
2245 amdgpu_atombios_i2c_init(adev); 2291 if (!amdgpu_device_has_dc_support(adev))
2292 amdgpu_atombios_i2c_init(adev);
2246 } 2293 }
2247 2294
2248 /* Fence driver */ 2295 /* Fence driver */
@@ -2378,7 +2425,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
2378 adev->accel_working = false; 2425 adev->accel_working = false;
2379 cancel_delayed_work_sync(&adev->late_init_work); 2426 cancel_delayed_work_sync(&adev->late_init_work);
2380 /* free i2c buses */ 2427 /* free i2c buses */
2381 amdgpu_i2c_fini(adev); 2428 if (!amdgpu_device_has_dc_support(adev))
2429 amdgpu_i2c_fini(adev);
2382 amdgpu_atombios_fini(adev); 2430 amdgpu_atombios_fini(adev);
2383 kfree(adev->bios); 2431 kfree(adev->bios);
2384 adev->bios = NULL; 2432 adev->bios = NULL;
@@ -2429,12 +2477,14 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
2429 2477
2430 drm_kms_helper_poll_disable(dev); 2478 drm_kms_helper_poll_disable(dev);
2431 2479
2432 /* turn off display hw */ 2480 if (!amdgpu_device_has_dc_support(adev)) {
2433 drm_modeset_lock_all(dev); 2481 /* turn off display hw */
2434 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 2482 drm_modeset_lock_all(dev);
2435 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 2483 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2484 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2485 }
2486 drm_modeset_unlock_all(dev);
2436 } 2487 }
2437 drm_modeset_unlock_all(dev);
2438 2488
2439 amdgpu_amdkfd_suspend(adev); 2489 amdgpu_amdkfd_suspend(adev);
2440 2490
@@ -2577,13 +2627,25 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
2577 2627
2578 /* blat the mode back in */ 2628 /* blat the mode back in */
2579 if (fbcon) { 2629 if (fbcon) {
2580 drm_helper_resume_force_mode(dev); 2630 if (!amdgpu_device_has_dc_support(adev)) {
2581 /* turn on display hw */ 2631 /* pre DCE11 */
2582 drm_modeset_lock_all(dev); 2632 drm_helper_resume_force_mode(dev);
2583 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 2633
2584 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); 2634 /* turn on display hw */
2635 drm_modeset_lock_all(dev);
2636 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2637 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
2638 }
2639 drm_modeset_unlock_all(dev);
2640 } else {
2641 /*
2642 * There is no equivalent atomic helper to turn on
2643 * display, so we defined our own function for this,
2644 * once suspend resume is supported by the atomic
2645 * framework this will be reworked
2646 */
2647 amdgpu_dm_display_resume(adev);
2585 } 2648 }
2586 drm_modeset_unlock_all(dev);
2587 } 2649 }
2588 2650
2589 drm_kms_helper_poll_enable(dev); 2651 drm_kms_helper_poll_enable(dev);
@@ -2600,7 +2662,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
2600#ifdef CONFIG_PM 2662#ifdef CONFIG_PM
2601 dev->dev->power.disable_depth++; 2663 dev->dev->power.disable_depth++;
2602#endif 2664#endif
2603 drm_helper_hpd_irq_event(dev); 2665 if (!amdgpu_device_has_dc_support(adev))
2666 drm_helper_hpd_irq_event(dev);
2667 else
2668 drm_kms_helper_hotplug_event(dev);
2604#ifdef CONFIG_PM 2669#ifdef CONFIG_PM
2605 dev->dev->power.disable_depth--; 2670 dev->dev->power.disable_depth--;
2606#endif 2671#endif
@@ -2900,6 +2965,7 @@ give_up_reset:
2900 */ 2965 */
2901int amdgpu_gpu_reset(struct amdgpu_device *adev) 2966int amdgpu_gpu_reset(struct amdgpu_device *adev)
2902{ 2967{
2968 struct drm_atomic_state *state = NULL;
2903 int i, r; 2969 int i, r;
2904 int resched; 2970 int resched;
2905 bool need_full_reset, vram_lost = false; 2971 bool need_full_reset, vram_lost = false;
@@ -2913,6 +2979,9 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
2913 2979
2914 /* block TTM */ 2980 /* block TTM */
2915 resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); 2981 resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
2982 /* store modesetting */
2983 if (amdgpu_device_has_dc_support(adev))
2984 state = drm_atomic_helper_suspend(adev->ddev);
2916 2985
2917 /* block scheduler */ 2986 /* block scheduler */
2918 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { 2987 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
@@ -3029,7 +3098,11 @@ out:
3029 } 3098 }
3030 } 3099 }
3031 3100
3032 drm_helper_resume_force_mode(adev->ddev); 3101 if (amdgpu_device_has_dc_support(adev)) {
3102 r = drm_atomic_helper_resume(adev->ddev, state);
3103 amdgpu_dm_display_resume(adev);
3104 } else
3105 drm_helper_resume_force_mode(adev->ddev);
3033 3106
3034 ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched); 3107 ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
3035 if (r) { 3108 if (r) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 6ad243293a78..138beb550a58 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -518,7 +518,7 @@ amdgpu_framebuffer_init(struct drm_device *dev,
518 return 0; 518 return 0;
519} 519}
520 520
521static struct drm_framebuffer * 521struct drm_framebuffer *
522amdgpu_user_framebuffer_create(struct drm_device *dev, 522amdgpu_user_framebuffer_create(struct drm_device *dev,
523 struct drm_file *file_priv, 523 struct drm_file *file_priv,
524 const struct drm_mode_fb_cmd2 *mode_cmd) 524 const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -556,7 +556,7 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,
556 return &amdgpu_fb->base; 556 return &amdgpu_fb->base;
557} 557}
558 558
559static void amdgpu_output_poll_changed(struct drm_device *dev) 559void amdgpu_output_poll_changed(struct drm_device *dev)
560{ 560{
561 struct amdgpu_device *adev = dev->dev_private; 561 struct amdgpu_device *adev = dev->dev_private;
562 amdgpu_fb_output_poll_changed(adev); 562 amdgpu_fb_output_poll_changed(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
new file mode 100644
index 000000000000..3cc0ef0c055e
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright 2017 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
23#ifndef __AMDGPU_DISPLAY_H__
24#define __AMDGPU_DISPLAY_H__
25
26struct drm_framebuffer *
27amdgpu_user_framebuffer_create(struct drm_device *dev,
28 struct drm_file *file_priv,
29 const struct drm_mode_fb_cmd2 *mode_cmd);
30
31void amdgpu_output_poll_changed(struct drm_device *dev);
32
33#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
index 7279fb5c3abc..56caaeee6fea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
@@ -433,7 +433,7 @@ struct amdgpu_pm {
433 uint32_t fw_version; 433 uint32_t fw_version;
434 uint32_t pcie_gen_mask; 434 uint32_t pcie_gen_mask;
435 uint32_t pcie_mlw_mask; 435 uint32_t pcie_mlw_mask;
436 struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */ 436 struct amd_pp_display_configuration pm_display_cfg;/* set by dc */
437}; 437};
438 438
439#define R600_SSTU_DFLT 0 439#define R600_SSTU_DFLT 0
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index dd2f060d62a8..ec96bb1f9eaf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -106,6 +106,8 @@ int amdgpu_vm_debug = 0;
106int amdgpu_vram_page_split = 512; 106int amdgpu_vram_page_split = 512;
107int amdgpu_vm_update_mode = -1; 107int amdgpu_vm_update_mode = -1;
108int amdgpu_exp_hw_support = 0; 108int amdgpu_exp_hw_support = 0;
109int amdgpu_dc = -1;
110int amdgpu_dc_log = 0;
109int amdgpu_sched_jobs = 32; 111int amdgpu_sched_jobs = 32;
110int amdgpu_sched_hw_submission = 2; 112int amdgpu_sched_hw_submission = 2;
111int amdgpu_no_evict = 0; 113int amdgpu_no_evict = 0;
@@ -211,6 +213,12 @@ module_param_named(vram_page_split, amdgpu_vram_page_split, int, 0444);
211MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))"); 213MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))");
212module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444); 214module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444);
213 215
216MODULE_PARM_DESC(dc, "Display Core driver (1 = enable, 0 = disable, -1 = auto (default))");
217module_param_named(dc, amdgpu_dc, int, 0444);
218
219MODULE_PARM_DESC(dc, "Display Core Log Level (0 = minimal (default), 1 = chatty");
220module_param_named(dc_log, amdgpu_dc_log, int, 0444);
221
214MODULE_PARM_DESC(sched_jobs, "the max number of jobs supported in the sw queue (default 32)"); 222MODULE_PARM_DESC(sched_jobs, "the max number of jobs supported in the sw queue (default 32)");
215module_param_named(sched_jobs, amdgpu_sched_jobs, int, 0444); 223module_param_named(sched_jobs, amdgpu_sched_jobs, int, 0444);
216 224
@@ -518,15 +526,15 @@ static const struct pci_device_id pciidlist[] = {
518 {0x1002, 0x6997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12}, 526 {0x1002, 0x6997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
519 {0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12}, 527 {0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
520 /* Vega 10 */ 528 /* Vega 10 */
521 {0x1002, 0x6860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 529 {0x1002, 0x6860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
522 {0x1002, 0x6861, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 530 {0x1002, 0x6861, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
523 {0x1002, 0x6862, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 531 {0x1002, 0x6862, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
524 {0x1002, 0x6863, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 532 {0x1002, 0x6863, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
525 {0x1002, 0x6864, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 533 {0x1002, 0x6864, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
526 {0x1002, 0x6867, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 534 {0x1002, 0x6867, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
527 {0x1002, 0x6868, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 535 {0x1002, 0x6868, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
528 {0x1002, 0x686c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 536 {0x1002, 0x686c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
529 {0x1002, 0x687f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, 537 {0x1002, 0x687f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
530 /* Raven */ 538 /* Raven */
531 {0x1002, 0x15dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU|AMD_EXP_HW_SUPPORT}, 539 {0x1002, 0x15dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU|AMD_EXP_HW_SUPPORT},
532 540
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 562930b17a6d..90fa8e8bc6fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -42,11 +42,6 @@
42 this contains a helper + a amdgpu fb 42 this contains a helper + a amdgpu fb
43 the helper contains a pointer to amdgpu framebuffer baseclass. 43 the helper contains a pointer to amdgpu framebuffer baseclass.
44*/ 44*/
45struct amdgpu_fbdev {
46 struct drm_fb_helper helper;
47 struct amdgpu_framebuffer rfb;
48 struct amdgpu_device *adev;
49};
50 45
51static int 46static int
52amdgpufb_open(struct fb_info *info, int user) 47amdgpufb_open(struct fb_info *info, int user)
@@ -353,7 +348,8 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev)
353 drm_fb_helper_single_add_all_connectors(&rfbdev->helper); 348 drm_fb_helper_single_add_all_connectors(&rfbdev->helper);
354 349
355 /* disable all the possible outputs/crtcs before entering KMS mode */ 350 /* disable all the possible outputs/crtcs before entering KMS mode */
356 drm_helper_disable_unused_functions(adev->ddev); 351 if (!amdgpu_device_has_dc_support(adev))
352 drm_helper_disable_unused_functions(adev->ddev);
357 353
358 drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel); 354 drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel);
359 return 0; 355 return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 538e5f27d120..47c5ce9807db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -37,6 +37,10 @@
37 37
38#include <linux/pm_runtime.h> 38#include <linux/pm_runtime.h>
39 39
40#ifdef CONFIG_DRM_AMD_DC
41#include "amdgpu_dm_irq.h"
42#endif
43
40#define AMDGPU_WAIT_IDLE_TIMEOUT 200 44#define AMDGPU_WAIT_IDLE_TIMEOUT 200
41 45
42/* 46/*
@@ -221,15 +225,6 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
221 225
222 spin_lock_init(&adev->irq.lock); 226 spin_lock_init(&adev->irq.lock);
223 227
224 if (!adev->enable_virtual_display)
225 /* Disable vblank irqs aggressively for power-saving */
226 adev->ddev->vblank_disable_immediate = true;
227
228 r = drm_vblank_init(adev->ddev, adev->mode_info.num_crtc);
229 if (r) {
230 return r;
231 }
232
233 /* enable msi */ 228 /* enable msi */
234 adev->irq.msi_enabled = false; 229 adev->irq.msi_enabled = false;
235 230
@@ -241,7 +236,21 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
241 } 236 }
242 } 237 }
243 238
244 INIT_WORK(&adev->hotplug_work, amdgpu_hotplug_work_func); 239 if (!amdgpu_device_has_dc_support(adev)) {
240 if (!adev->enable_virtual_display)
241 /* Disable vblank irqs aggressively for power-saving */
242 /* XXX: can this be enabled for DC? */
243 adev->ddev->vblank_disable_immediate = true;
244
245 r = drm_vblank_init(adev->ddev, adev->mode_info.num_crtc);
246 if (r)
247 return r;
248
249 /* pre DCE11 */
250 INIT_WORK(&adev->hotplug_work,
251 amdgpu_hotplug_work_func);
252 }
253
245 INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func); 254 INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func);
246 255
247 adev->irq.installed = true; 256 adev->irq.installed = true;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 6f0b26dae3b0..720139e182a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1030,7 +1030,7 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
1030 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW), 1030 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
1031 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW), 1031 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
1032 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW), 1032 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
1033 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW), 1033 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW)
1034}; 1034};
1035const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms); 1035const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
1036 1036
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index 2af2678ddaf6..ffde1e9666e8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -38,11 +38,15 @@
38#include <drm/drm_crtc_helper.h> 38#include <drm/drm_crtc_helper.h>
39#include <drm/drm_fb_helper.h> 39#include <drm/drm_fb_helper.h>
40#include <drm/drm_plane_helper.h> 40#include <drm/drm_plane_helper.h>
41#include <drm/drm_fb_helper.h>
41#include <linux/i2c.h> 42#include <linux/i2c.h>
42#include <linux/i2c-algo-bit.h> 43#include <linux/i2c-algo-bit.h>
43#include <linux/hrtimer.h> 44#include <linux/hrtimer.h>
44#include "amdgpu_irq.h" 45#include "amdgpu_irq.h"
45 46
47#include <drm/drm_dp_mst_helper.h>
48#include "modules/inc/mod_freesync.h"
49
46struct amdgpu_bo; 50struct amdgpu_bo;
47struct amdgpu_device; 51struct amdgpu_device;
48struct amdgpu_encoder; 52struct amdgpu_encoder;
@@ -53,9 +57,13 @@ struct amdgpu_hpd;
53#define to_amdgpu_connector(x) container_of(x, struct amdgpu_connector, base) 57#define to_amdgpu_connector(x) container_of(x, struct amdgpu_connector, base)
54#define to_amdgpu_encoder(x) container_of(x, struct amdgpu_encoder, base) 58#define to_amdgpu_encoder(x) container_of(x, struct amdgpu_encoder, base)
55#define to_amdgpu_framebuffer(x) container_of(x, struct amdgpu_framebuffer, base) 59#define to_amdgpu_framebuffer(x) container_of(x, struct amdgpu_framebuffer, base)
60#define to_amdgpu_plane(x) container_of(x, struct amdgpu_plane, base)
61
62#define to_dm_plane_state(x) container_of(x, struct dm_plane_state, base);
56 63
57#define AMDGPU_MAX_HPD_PINS 6 64#define AMDGPU_MAX_HPD_PINS 6
58#define AMDGPU_MAX_CRTCS 6 65#define AMDGPU_MAX_CRTCS 6
66#define AMDGPU_MAX_PLANES 6
59#define AMDGPU_MAX_AFMT_BLOCKS 9 67#define AMDGPU_MAX_AFMT_BLOCKS 9
60 68
61enum amdgpu_rmx_type { 69enum amdgpu_rmx_type {
@@ -292,6 +300,30 @@ struct amdgpu_display_funcs {
292 uint16_t connector_object_id, 300 uint16_t connector_object_id,
293 struct amdgpu_hpd *hpd, 301 struct amdgpu_hpd *hpd,
294 struct amdgpu_router *router); 302 struct amdgpu_router *router);
303 /* it is used to enter or exit into free sync mode */
304 int (*notify_freesync)(struct drm_device *dev, void *data,
305 struct drm_file *filp);
306 /* it is used to allow enablement of freesync mode */
307 int (*set_freesync_property)(struct drm_connector *connector,
308 struct drm_property *property,
309 uint64_t val);
310
311
312};
313
314struct amdgpu_framebuffer {
315 struct drm_framebuffer base;
316 struct drm_gem_object *obj;
317
318 /* caching for later use */
319 uint64_t address;
320};
321
322struct amdgpu_fbdev {
323 struct drm_fb_helper helper;
324 struct amdgpu_framebuffer rfb;
325 struct list_head fbdev_list;
326 struct amdgpu_device *adev;
295}; 327};
296 328
297struct amdgpu_mode_info { 329struct amdgpu_mode_info {
@@ -299,6 +331,7 @@ struct amdgpu_mode_info {
299 struct card_info *atom_card_info; 331 struct card_info *atom_card_info;
300 bool mode_config_initialized; 332 bool mode_config_initialized;
301 struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS]; 333 struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS];
334 struct amdgpu_plane *planes[AMDGPU_MAX_PLANES];
302 struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS]; 335 struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS];
303 /* DVI-I properties */ 336 /* DVI-I properties */
304 struct drm_property *coherent_mode_property; 337 struct drm_property *coherent_mode_property;
@@ -328,6 +361,7 @@ struct amdgpu_mode_info {
328 int num_dig; /* number of dig blocks */ 361 int num_dig; /* number of dig blocks */
329 int disp_priority; 362 int disp_priority;
330 const struct amdgpu_display_funcs *funcs; 363 const struct amdgpu_display_funcs *funcs;
364 const enum drm_plane_type *plane_type;
331}; 365};
332 366
333#define AMDGPU_MAX_BL_LEVEL 0xFF 367#define AMDGPU_MAX_BL_LEVEL 0xFF
@@ -400,6 +434,14 @@ struct amdgpu_crtc {
400 /* for virtual dce */ 434 /* for virtual dce */
401 struct hrtimer vblank_timer; 435 struct hrtimer vblank_timer;
402 enum amdgpu_interrupt_state vsync_timer_enabled; 436 enum amdgpu_interrupt_state vsync_timer_enabled;
437
438 int otg_inst;
439 struct drm_pending_vblank_event *event;
440};
441
442struct amdgpu_plane {
443 struct drm_plane base;
444 enum drm_plane_type plane_type;
403}; 445};
404 446
405struct amdgpu_encoder_atom_dig { 447struct amdgpu_encoder_atom_dig {
@@ -489,6 +531,19 @@ enum amdgpu_connector_dither {
489 AMDGPU_FMT_DITHER_ENABLE = 1, 531 AMDGPU_FMT_DITHER_ENABLE = 1,
490}; 532};
491 533
534struct amdgpu_dm_dp_aux {
535 struct drm_dp_aux aux;
536 struct ddc_service *ddc_service;
537};
538
539struct amdgpu_i2c_adapter {
540 struct i2c_adapter base;
541
542 struct ddc_service *ddc_service;
543};
544
545#define TO_DM_AUX(x) container_of((x), struct amdgpu_dm_dp_aux, aux)
546
492struct amdgpu_connector { 547struct amdgpu_connector {
493 struct drm_connector base; 548 struct drm_connector base;
494 uint32_t connector_id; 549 uint32_t connector_id;
@@ -500,6 +555,14 @@ struct amdgpu_connector {
500 /* we need to mind the EDID between detect 555 /* we need to mind the EDID between detect
501 and get modes due to analog/digital/tvencoder */ 556 and get modes due to analog/digital/tvencoder */
502 struct edid *edid; 557 struct edid *edid;
558 /* number of modes generated from EDID at 'dc_sink' */
559 int num_modes;
560 /* The 'old' sink - before an HPD.
561 * The 'current' sink is in dc_link->sink. */
562 struct dc_sink *dc_sink;
563 struct dc_link *dc_link;
564 struct dc_sink *dc_em_sink;
565 const struct dc_stream *stream;
503 void *con_priv; 566 void *con_priv;
504 bool dac_load_detect; 567 bool dac_load_detect;
505 bool detected_by_load; /* if the connection status was determined by load */ 568 bool detected_by_load; /* if the connection status was determined by load */
@@ -510,11 +573,39 @@ struct amdgpu_connector {
510 enum amdgpu_connector_audio audio; 573 enum amdgpu_connector_audio audio;
511 enum amdgpu_connector_dither dither; 574 enum amdgpu_connector_dither dither;
512 unsigned pixelclock_for_modeset; 575 unsigned pixelclock_for_modeset;
576
577 struct drm_dp_mst_topology_mgr mst_mgr;
578 struct amdgpu_dm_dp_aux dm_dp_aux;
579 struct drm_dp_mst_port *port;
580 struct amdgpu_connector *mst_port;
581 struct amdgpu_encoder *mst_encoder;
582 struct semaphore mst_sem;
583
584 /* TODO see if we can merge with ddc_bus or make a dm_connector */
585 struct amdgpu_i2c_adapter *i2c;
586
587 /* Monitor range limits */
588 int min_vfreq ;
589 int max_vfreq ;
590 int pixel_clock_mhz;
591
592 /*freesync caps*/
593 struct mod_freesync_caps caps;
594
595 struct mutex hpd_lock;
596
513}; 597};
514 598
515struct amdgpu_framebuffer { 599/* TODO: start to use this struct and remove same field from base one */
516 struct drm_framebuffer base; 600struct amdgpu_mst_connector {
517 struct drm_gem_object *obj; 601 struct amdgpu_connector base;
602
603 struct drm_dp_mst_topology_mgr mst_mgr;
604 struct amdgpu_dm_dp_aux dm_dp_aux;
605 struct drm_dp_mst_port *port;
606 struct amdgpu_connector *mst_port;
607 bool is_mst_connector;
608 struct amdgpu_encoder *mst_encoder;
518}; 609};
519 610
520#define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \ 611#define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index a59e04f3eeba..d6df5728df7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1466,7 +1466,7 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
1466 list_for_each_entry(crtc, 1466 list_for_each_entry(crtc,
1467 &ddev->mode_config.crtc_list, head) { 1467 &ddev->mode_config.crtc_list, head) {
1468 amdgpu_crtc = to_amdgpu_crtc(crtc); 1468 amdgpu_crtc = to_amdgpu_crtc(crtc);
1469 if (crtc->enabled) { 1469 if (amdgpu_crtc->enabled) {
1470 adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id); 1470 adev->pm.dpm.new_active_crtcs |= (1 << amdgpu_crtc->crtc_id);
1471 adev->pm.dpm.new_active_crtc_count++; 1471 adev->pm.dpm.new_active_crtc_count++;
1472 } 1472 }
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c
index 567c4a5cf90c..793b1470284d 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik.c
@@ -65,6 +65,7 @@
65#include "oss/oss_2_0_d.h" 65#include "oss/oss_2_0_d.h"
66#include "oss/oss_2_0_sh_mask.h" 66#include "oss/oss_2_0_sh_mask.h"
67 67
68#include "amdgpu_dm.h"
68#include "amdgpu_amdkfd.h" 69#include "amdgpu_amdkfd.h"
69#include "amdgpu_powerplay.h" 70#include "amdgpu_powerplay.h"
70#include "dce_virtual.h" 71#include "dce_virtual.h"
@@ -1900,6 +1901,10 @@ int cik_set_ip_blocks(struct amdgpu_device *adev)
1900 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1901 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1901 if (adev->enable_virtual_display) 1902 if (adev->enable_virtual_display)
1902 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1903 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1904#if defined(CONFIG_DRM_AMD_DC)
1905 else if (amdgpu_device_has_dc_support(adev))
1906 amdgpu_ip_block_add(adev, &dm_ip_block);
1907#endif
1903 else 1908 else
1904 amdgpu_ip_block_add(adev, &dce_v8_2_ip_block); 1909 amdgpu_ip_block_add(adev, &dce_v8_2_ip_block);
1905 amdgpu_ip_block_add(adev, &gfx_v7_2_ip_block); 1910 amdgpu_ip_block_add(adev, &gfx_v7_2_ip_block);
@@ -1914,6 +1919,10 @@ int cik_set_ip_blocks(struct amdgpu_device *adev)
1914 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1919 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1915 if (adev->enable_virtual_display) 1920 if (adev->enable_virtual_display)
1916 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1921 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1922#if defined(CONFIG_DRM_AMD_DC)
1923 else if (amdgpu_device_has_dc_support(adev))
1924 amdgpu_ip_block_add(adev, &dm_ip_block);
1925#endif
1917 else 1926 else
1918 amdgpu_ip_block_add(adev, &dce_v8_5_ip_block); 1927 amdgpu_ip_block_add(adev, &dce_v8_5_ip_block);
1919 amdgpu_ip_block_add(adev, &gfx_v7_3_ip_block); 1928 amdgpu_ip_block_add(adev, &gfx_v7_3_ip_block);
@@ -1928,6 +1937,10 @@ int cik_set_ip_blocks(struct amdgpu_device *adev)
1928 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1937 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1929 if (adev->enable_virtual_display) 1938 if (adev->enable_virtual_display)
1930 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1939 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1940#if defined(CONFIG_DRM_AMD_DC)
1941 else if (amdgpu_device_has_dc_support(adev))
1942 amdgpu_ip_block_add(adev, &dm_ip_block);
1943#endif
1931 else 1944 else
1932 amdgpu_ip_block_add(adev, &dce_v8_1_ip_block); 1945 amdgpu_ip_block_add(adev, &dce_v8_1_ip_block);
1933 amdgpu_ip_block_add(adev, &gfx_v7_1_ip_block); 1946 amdgpu_ip_block_add(adev, &gfx_v7_1_ip_block);
@@ -1943,6 +1956,10 @@ int cik_set_ip_blocks(struct amdgpu_device *adev)
1943 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1956 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1944 if (adev->enable_virtual_display) 1957 if (adev->enable_virtual_display)
1945 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1958 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1959#if defined(CONFIG_DRM_AMD_DC)
1960 else if (amdgpu_device_has_dc_support(adev))
1961 amdgpu_ip_block_add(adev, &dm_ip_block);
1962#endif
1946 else 1963 else
1947 amdgpu_ip_block_add(adev, &dce_v8_3_ip_block); 1964 amdgpu_ip_block_add(adev, &dce_v8_3_ip_block);
1948 amdgpu_ip_block_add(adev, &gfx_v7_2_ip_block); 1965 amdgpu_ip_block_add(adev, &gfx_v7_2_ip_block);
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 3ca9d114f630..4e67fe1e7955 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -532,6 +532,12 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
532 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 532 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
533 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 533 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
534 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 534 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
535#if defined(CONFIG_DRM_AMD_DC)
536 else if (amdgpu_device_has_dc_support(adev))
537 amdgpu_ip_block_add(adev, &dm_ip_block);
538#else
539# warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15."
540#endif
535 amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block); 541 amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block);
536 amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block); 542 amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block);
537 amdgpu_ip_block_add(adev, &uvd_v7_0_ip_block); 543 amdgpu_ip_block_add(adev, &uvd_v7_0_ip_block);
@@ -545,6 +551,12 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
545 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 551 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
546 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 552 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
547 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 553 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
554#if defined(CONFIG_DRM_AMD_DC)
555 else if (amdgpu_device_has_dc_support(adev))
556 amdgpu_ip_block_add(adev, &dm_ip_block);
557#else
558# warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15."
559#endif
548 amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block); 560 amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block);
549 amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block); 561 amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block);
550 amdgpu_ip_block_add(adev, &vcn_v1_0_ip_block); 562 amdgpu_ip_block_add(adev, &vcn_v1_0_ip_block);
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index f3cfef48aa99..3a4c2fa7e36d 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -77,6 +77,7 @@
77#endif 77#endif
78#include "dce_virtual.h" 78#include "dce_virtual.h"
79#include "mxgpu_vi.h" 79#include "mxgpu_vi.h"
80#include "amdgpu_dm.h"
80 81
81/* 82/*
82 * Indirect registers accessor 83 * Indirect registers accessor
@@ -1502,6 +1503,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
1502 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1503 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1503 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 1504 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
1504 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1505 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1506#if defined(CONFIG_DRM_AMD_DC)
1507 else if (amdgpu_device_has_dc_support(adev))
1508 amdgpu_ip_block_add(adev, &dm_ip_block);
1509#endif
1505 else 1510 else
1506 amdgpu_ip_block_add(adev, &dce_v10_1_ip_block); 1511 amdgpu_ip_block_add(adev, &dce_v10_1_ip_block);
1507 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); 1512 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
@@ -1518,6 +1523,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
1518 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1523 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1519 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 1524 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
1520 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1525 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1526#if defined(CONFIG_DRM_AMD_DC)
1527 else if (amdgpu_device_has_dc_support(adev))
1528 amdgpu_ip_block_add(adev, &dm_ip_block);
1529#endif
1521 else 1530 else
1522 amdgpu_ip_block_add(adev, &dce_v10_0_ip_block); 1531 amdgpu_ip_block_add(adev, &dce_v10_0_ip_block);
1523 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); 1532 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
@@ -1536,6 +1545,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
1536 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1545 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1537 if (adev->enable_virtual_display) 1546 if (adev->enable_virtual_display)
1538 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1547 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1548#if defined(CONFIG_DRM_AMD_DC)
1549 else if (amdgpu_device_has_dc_support(adev))
1550 amdgpu_ip_block_add(adev, &dm_ip_block);
1551#endif
1539 else 1552 else
1540 amdgpu_ip_block_add(adev, &dce_v11_2_ip_block); 1553 amdgpu_ip_block_add(adev, &dce_v11_2_ip_block);
1541 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); 1554 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
@@ -1550,6 +1563,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
1550 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1563 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1551 if (adev->enable_virtual_display) 1564 if (adev->enable_virtual_display)
1552 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1565 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1566#if defined(CONFIG_DRM_AMD_DC)
1567 else if (amdgpu_device_has_dc_support(adev))
1568 amdgpu_ip_block_add(adev, &dm_ip_block);
1569#endif
1553 else 1570 else
1554 amdgpu_ip_block_add(adev, &dce_v11_0_ip_block); 1571 amdgpu_ip_block_add(adev, &dce_v11_0_ip_block);
1555 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); 1572 amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block);
@@ -1567,6 +1584,10 @@ int vi_set_ip_blocks(struct amdgpu_device *adev)
1567 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); 1584 amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
1568 if (adev->enable_virtual_display) 1585 if (adev->enable_virtual_display)
1569 amdgpu_ip_block_add(adev, &dce_virtual_ip_block); 1586 amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
1587#if defined(CONFIG_DRM_AMD_DC)
1588 else if (amdgpu_device_has_dc_support(adev))
1589 amdgpu_ip_block_add(adev, &dm_ip_block);
1590#endif
1570 else 1591 else
1571 amdgpu_ip_block_add(adev, &dce_v11_0_ip_block); 1592 amdgpu_ip_block_add(adev, &dce_v11_0_ip_block);
1572 amdgpu_ip_block_add(adev, &gfx_v8_1_ip_block); 1593 amdgpu_ip_block_add(adev, &gfx_v8_1_ip_block);