Skip to content

Commit 4562236

Browse files
Harry Wentlandalexdeucher
authored andcommitted
drm/amd/dc: Add dc display driver (v2)
Supported DCE versions: 8.0, 10.0, 11.0, 11.2 v2: rebase against 4.11 Signed-off-by: Harry Wentland <harry.wentland@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 9c5b2b0 commit 4562236

File tree

315 files changed

+99491
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+99491
-37
lines changed

drivers/gpu/drm/amd/amdgpu/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ config DRM_AMDGPU_GART_DEBUGFS
4141
pages. Uses more memory for housekeeping, enable only for debugging.
4242

4343
source "drivers/gpu/drm/amd/acp/Kconfig"
44+
source "drivers/gpu/drm/amd/display/Kconfig"

drivers/gpu/drm/amd/amdgpu/Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
44

55
FULL_AMD_PATH=$(src)/..
6+
DISPLAY_FOLDER_NAME=display
7+
FULL_AMD_DISPLAY_PATH = $(FULL_AMD_PATH)/$(DISPLAY_FOLDER_NAME)
68

79
ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
810
-I$(FULL_AMD_PATH)/include \
911
-I$(FULL_AMD_PATH)/amdgpu \
1012
-I$(FULL_AMD_PATH)/scheduler \
1113
-I$(FULL_AMD_PATH)/powerplay/inc \
12-
-I$(FULL_AMD_PATH)/acp/include
14+
-I$(FULL_AMD_PATH)/acp/include \
15+
-I$(FULL_AMD_DISPLAY_PATH) \
16+
-I$(FULL_AMD_DISPLAY_PATH)/include \
17+
-I$(FULL_AMD_DISPLAY_PATH)/dc \
18+
-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm
1319

1420
amdgpu-y := amdgpu_drv.o
1521

@@ -132,4 +138,13 @@ include $(FULL_AMD_PATH)/powerplay/Makefile
132138

133139
amdgpu-y += $(AMD_POWERPLAY_FILES)
134140

141+
ifneq ($(CONFIG_DRM_AMD_DC),)
142+
143+
RELATIVE_AMD_DISPLAY_PATH = ../$(DISPLAY_FOLDER_NAME)
144+
include $(FULL_AMD_DISPLAY_PATH)/Makefile
145+
146+
amdgpu-y += $(AMD_DISPLAY_FILES)
147+
148+
endif
149+
135150
obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o

drivers/gpu/drm/amd/amdgpu/amdgpu.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "amdgpu_vce.h"
6767
#include "amdgpu_vcn.h"
6868
#include "amdgpu_mn.h"
69+
#include "amdgpu_dm.h"
6970

7071
#include "gpu_scheduler.h"
7172
#include "amdgpu_virt.h"
@@ -101,6 +102,7 @@ extern int amdgpu_vm_fragment_size;
101102
extern int amdgpu_vm_fault_stop;
102103
extern int amdgpu_vm_debug;
103104
extern int amdgpu_vm_update_mode;
105+
extern int amdgpu_dc;
104106
extern int amdgpu_sched_jobs;
105107
extern int amdgpu_sched_hw_submission;
106108
extern int amdgpu_no_evict;
@@ -1507,6 +1509,7 @@ struct amdgpu_device {
15071509
/* display */
15081510
bool enable_virtual_display;
15091511
struct amdgpu_mode_info mode_info;
1512+
/* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
15101513
struct work_struct hotplug_work;
15111514
struct amdgpu_irq_src crtc_irq;
15121515
struct amdgpu_irq_src pageflip_irq;
@@ -1563,6 +1566,9 @@ struct amdgpu_device {
15631566
/* GDS */
15641567
struct amdgpu_gds gds;
15651568

1569+
/* display related functionality */
1570+
struct amdgpu_display_manager dm;
1571+
15661572
struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM];
15671573
int num_ip_blocks;
15681574
struct mutex mn_lock;
@@ -1624,6 +1630,9 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v);
16241630
u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index);
16251631
void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v);
16261632

1633+
bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type);
1634+
bool amdgpu_device_has_dc_support(struct amdgpu_device *adev);
1635+
16271636
/*
16281637
* Registers read & write functions.
16291638
*/
@@ -1884,5 +1893,11 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
18841893
uint64_t addr, struct amdgpu_bo **bo,
18851894
struct amdgpu_bo_va_mapping **mapping);
18861895

1896+
#if defined(CONFIG_DRM_AMD_DC)
1897+
int amdgpu_dm_display_resume(struct amdgpu_device *adev );
1898+
#else
1899+
static inline int amdgpu_dm_display_resume(struct amdgpu_device *adev) { return 0; }
1900+
#endif
1901+
18871902
#include "amdgpu_object.h"
18881903
#endif

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/debugfs.h>
3232
#include <drm/drmP.h>
3333
#include <drm/drm_crtc_helper.h>
34+
#include <drm/drm_atomic_helper.h>
3435
#include <drm/amdgpu_drm.h>
3536
#include <linux/vgaarb.h>
3637
#include <linux/vga_switcheroo.h>
@@ -1973,6 +1974,41 @@ static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev)
19731974
}
19741975
}
19751976

1977+
bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
1978+
{
1979+
switch (asic_type) {
1980+
#if defined(CONFIG_DRM_AMD_DC)
1981+
case CHIP_BONAIRE:
1982+
case CHIP_HAWAII:
1983+
case CHIP_CARRIZO:
1984+
case CHIP_STONEY:
1985+
case CHIP_POLARIS11:
1986+
case CHIP_POLARIS10:
1987+
case CHIP_TONGA:
1988+
case CHIP_FIJI:
1989+
#if defined(CONFIG_DRM_AMD_DC_PRE_VEGA)
1990+
return amdgpu_dc != 0;
1991+
#else
1992+
return amdgpu_dc > 0;
1993+
#endif
1994+
#endif
1995+
default:
1996+
return false;
1997+
}
1998+
}
1999+
2000+
/**
2001+
* amdgpu_device_has_dc_support - check if dc is supported
2002+
*
2003+
* @adev: amdgpu_device_pointer
2004+
*
2005+
* Returns true for supported, false for not supported
2006+
*/
2007+
bool amdgpu_device_has_dc_support(struct amdgpu_device *adev)
2008+
{
2009+
return amdgpu_device_asic_has_dc_support(adev->asic_type);
2010+
}
2011+
19762012
/**
19772013
* amdgpu_device_init - initialize the driver
19782014
*
@@ -2168,7 +2204,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
21682204
goto failed;
21692205
}
21702206
/* init i2c buses */
2171-
amdgpu_atombios_i2c_init(adev);
2207+
if (!amdgpu_device_has_dc_support(adev))
2208+
amdgpu_atombios_i2c_init(adev);
21722209
}
21732210

21742211
/* Fence driver */
@@ -2296,7 +2333,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
22962333
adev->accel_working = false;
22972334
cancel_delayed_work_sync(&adev->late_init_work);
22982335
/* free i2c buses */
2299-
amdgpu_i2c_fini(adev);
2336+
if (!amdgpu_device_has_dc_support(adev))
2337+
amdgpu_i2c_fini(adev);
23002338
amdgpu_atombios_fini(adev);
23012339
kfree(adev->bios);
23022340
adev->bios = NULL;
@@ -2346,12 +2384,14 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
23462384

23472385
drm_kms_helper_poll_disable(dev);
23482386

2349-
/* turn off display hw */
2350-
drm_modeset_lock_all(dev);
2351-
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2352-
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2387+
if (!amdgpu_device_has_dc_support(adev)) {
2388+
/* turn off display hw */
2389+
drm_modeset_lock_all(dev);
2390+
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2391+
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2392+
}
2393+
drm_modeset_unlock_all(dev);
23532394
}
2354-
drm_modeset_unlock_all(dev);
23552395

23562396
amdgpu_amdkfd_suspend(adev);
23572397

@@ -2494,13 +2534,25 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
24942534

24952535
/* blat the mode back in */
24962536
if (fbcon) {
2497-
drm_helper_resume_force_mode(dev);
2498-
/* turn on display hw */
2499-
drm_modeset_lock_all(dev);
2500-
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2501-
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
2537+
if (!amdgpu_device_has_dc_support(adev)) {
2538+
/* pre DCE11 */
2539+
drm_helper_resume_force_mode(dev);
2540+
2541+
/* turn on display hw */
2542+
drm_modeset_lock_all(dev);
2543+
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2544+
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
2545+
}
2546+
drm_modeset_unlock_all(dev);
2547+
} else {
2548+
/*
2549+
* There is no equivalent atomic helper to turn on
2550+
* display, so we defined our own function for this,
2551+
* once suspend resume is supported by the atomic
2552+
* framework this will be reworked
2553+
*/
2554+
amdgpu_dm_display_resume(adev);
25022555
}
2503-
drm_modeset_unlock_all(dev);
25042556
}
25052557

25062558
drm_kms_helper_poll_enable(dev);
@@ -2517,7 +2569,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
25172569
#ifdef CONFIG_PM
25182570
dev->dev->power.disable_depth++;
25192571
#endif
2520-
drm_helper_hpd_irq_event(dev);
2572+
if (!amdgpu_device_has_dc_support(adev))
2573+
drm_helper_hpd_irq_event(dev);
2574+
else
2575+
drm_kms_helper_hotplug_event(dev);
25212576
#ifdef CONFIG_PM
25222577
dev->dev->power.disable_depth--;
25232578
#endif
@@ -2814,6 +2869,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, struct amdgpu_job *job)
28142869
*/
28152870
int amdgpu_gpu_reset(struct amdgpu_device *adev)
28162871
{
2872+
struct drm_atomic_state *state = NULL;
28172873
int i, r;
28182874
int resched;
28192875
bool need_full_reset, vram_lost = false;
@@ -2827,6 +2883,9 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
28272883

28282884
/* block TTM */
28292885
resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
2886+
/* store modesetting */
2887+
if (amdgpu_device_has_dc_support(adev))
2888+
state = drm_atomic_helper_suspend(adev->ddev);
28302889

28312890
/* block scheduler */
28322891
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
@@ -2944,7 +3003,11 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
29443003
}
29453004
}
29463005

2947-
drm_helper_resume_force_mode(adev->ddev);
3006+
if (amdgpu_device_has_dc_support(adev)) {
3007+
r = drm_atomic_helper_resume(adev->ddev, state);
3008+
amdgpu_dm_display_resume(adev);
3009+
} else
3010+
drm_helper_resume_force_mode(adev->ddev);
29483011

29493012
ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
29503013
if (r) {

drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ struct amdgpu_pm {
429429
uint32_t fw_version;
430430
uint32_t pcie_gen_mask;
431431
uint32_t pcie_mlw_mask;
432-
struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */
432+
struct amd_pp_display_configuration pm_display_cfg;/* set by dc */
433433
};
434434

435435
#define R600_SSTU_DFLT 0

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ int amdgpu_vm_debug = 0;
103103
int amdgpu_vram_page_split = 512;
104104
int amdgpu_vm_update_mode = -1;
105105
int amdgpu_exp_hw_support = 0;
106+
int amdgpu_dc = -1;
106107
int amdgpu_sched_jobs = 32;
107108
int amdgpu_sched_hw_submission = 2;
108109
int amdgpu_no_evict = 0;
@@ -207,6 +208,9 @@ module_param_named(vram_page_split, amdgpu_vram_page_split, int, 0444);
207208
MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))");
208209
module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444);
209210

211+
MODULE_PARM_DESC(dc, "Display Core driver (1 = enable, 0 = disable, -1 = auto (default))");
212+
module_param_named(dc, amdgpu_dc, int, 0444);
213+
210214
MODULE_PARM_DESC(sched_jobs, "the max number of jobs supported in the sw queue (default 32)");
211215
module_param_named(sched_jobs, amdgpu_sched_jobs, int, 0444);
212216

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
this contains a helper + a amdgpu fb
4343
the helper contains a pointer to amdgpu framebuffer baseclass.
4444
*/
45-
struct amdgpu_fbdev {
46-
struct drm_fb_helper helper;
47-
struct amdgpu_framebuffer rfb;
48-
struct amdgpu_device *adev;
49-
};
5045

5146
static int
5247
amdgpufb_open(struct fb_info *info, int user)

drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
#include <linux/pm_runtime.h>
3939

40+
#ifdef CONFIG_DRM_AMD_DC
41+
#include "amdgpu_dm_irq.h"
42+
#endif
43+
4044
#define AMDGPU_WAIT_IDLE_TIMEOUT 200
4145

4246
/*
@@ -221,15 +225,6 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
221225

222226
spin_lock_init(&adev->irq.lock);
223227

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-
233228
/* enable msi */
234229
adev->irq.msi_enabled = false;
235230

@@ -241,7 +236,21 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
241236
}
242237
}
243238

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+
245254
INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func);
246255

247256
adev->irq.installed = true;

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
10341034
DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
10351035
DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
10361036
DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
1037-
DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
1037+
DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW)
10381038
};
10391039
const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
10401040

0 commit comments

Comments
 (0)