Skip to content

Commit f6705bf

Browse files
committed
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. ...
2 parents bec0443 + 49e37ba commit f6705bf

File tree

368 files changed

+132395
-75
lines changed

Some content is hidden

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

368 files changed

+132395
-75
lines changed

Documentation/gpu/todo.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,5 +409,15 @@ those drivers as simple as possible, so lots of room for refactoring:
409409

410410
Contact: Noralf Trønnes, Daniel Vetter
411411

412+
AMD DC Display Driver
413+
---------------------
414+
415+
AMD DC is the display driver for AMD devices starting with Vega. There has been
416+
a bunch of progress cleaning it up but there's still plenty of work to be done.
417+
418+
See drivers/gpu/drm/amd/display/TODO for tasks.
419+
420+
Contact: Harry Wentland, Alex Deucher
421+
412422
Outside DRM
413423
===========

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
@@ -4,13 +4,19 @@
44
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
55

66
FULL_AMD_PATH=$(src)/..
7+
DISPLAY_FOLDER_NAME=display
8+
FULL_AMD_DISPLAY_PATH = $(FULL_AMD_PATH)/$(DISPLAY_FOLDER_NAME)
79

810
ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
911
-I$(FULL_AMD_PATH)/include \
1012
-I$(FULL_AMD_PATH)/amdgpu \
1113
-I$(FULL_AMD_PATH)/scheduler \
1214
-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
1420

1521
amdgpu-y := amdgpu_drv.o
1622

@@ -133,4 +139,13 @@ include $(FULL_AMD_PATH)/powerplay/Makefile
133139

134140
amdgpu-y += $(AMD_POWERPLAY_FILES)
135141

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

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

Lines changed: 16 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,8 @@ 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;
106+
extern int amdgpu_dc_log;
104107
extern int amdgpu_sched_jobs;
105108
extern int amdgpu_sched_hw_submission;
106109
extern int amdgpu_no_evict;
@@ -1535,6 +1538,7 @@ struct amdgpu_device {
15351538
/* display */
15361539
bool enable_virtual_display;
15371540
struct amdgpu_mode_info mode_info;
1541+
/* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
15381542
struct work_struct hotplug_work;
15391543
struct amdgpu_irq_src crtc_irq;
15401544
struct amdgpu_irq_src pageflip_irq;
@@ -1590,6 +1594,9 @@ struct amdgpu_device {
15901594
/* GDS */
15911595
struct amdgpu_gds gds;
15921596

1597+
/* display related functionality */
1598+
struct amdgpu_display_manager dm;
1599+
15931600
struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM];
15941601
int num_ip_blocks;
15951602
struct mutex mn_lock;
@@ -1653,6 +1660,9 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v);
16531660
u64 amdgpu_mm_rdoorbell64(struct amdgpu_device *adev, u32 index);
16541661
void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v);
16551662

1663+
bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type);
1664+
bool amdgpu_device_has_dc_support(struct amdgpu_device *adev);
1665+
16561666
/*
16571667
* Registers read & write functions.
16581668
*/
@@ -1911,5 +1921,11 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
19111921
uint64_t addr, struct amdgpu_bo **bo,
19121922
struct amdgpu_bo_va_mapping **mapping);
19131923

1924+
#if defined(CONFIG_DRM_AMD_DC)
1925+
int amdgpu_dm_display_resume(struct amdgpu_device *adev );
1926+
#else
1927+
static inline int amdgpu_dm_display_resume(struct amdgpu_device *adev) { return 0; }
1928+
#endif
1929+
19141930
#include "amdgpu_object.h"
19151931
#endif

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

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,6 @@ static int amdgpu_cgs_get_active_displays_info(struct cgs_device *cgs_device,
911911
struct cgs_display_info *info)
912912
{
913913
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;
918914
struct cgs_mode_info *mode_info;
919915

920916
if (info == NULL)
@@ -928,30 +924,43 @@ static int amdgpu_cgs_get_active_displays_info(struct cgs_device *cgs_device,
928924
mode_info->ref_clock = adev->clock.spll.reference_freq;
929925
}
930926

931-
if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
932-
list_for_each_entry(crtc,
933-
&ddev->mode_config.crtc_list, head) {
934-
amdgpu_crtc = to_amdgpu_crtc(crtc);
935-
if (crtc->enabled) {
936-
info->active_display_mask |= (1 << amdgpu_crtc->crtc_id);
937-
info->display_count++;
938-
}
939-
if (mode_info != NULL &&
940-
crtc->enabled && amdgpu_crtc->enabled &&
941-
amdgpu_crtc->hw_mode.clock) {
942-
line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) /
943-
amdgpu_crtc->hw_mode.clock;
944-
vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end -
945-
amdgpu_crtc->hw_mode.crtc_vdisplay +
946-
(amdgpu_crtc->v_border * 2);
947-
mode_info->vblank_time_us = vblank_lines * line_time_us;
948-
mode_info->refresh_rate = drm_mode_vrefresh(&amdgpu_crtc->hw_mode);
949-
mode_info->ref_clock = adev->clock.spll.reference_freq;
950-
mode_info = NULL;
927+
if (!amdgpu_device_has_dc_support(adev)) {
928+
struct amdgpu_crtc *amdgpu_crtc;
929+
struct drm_device *ddev = adev->ddev;
930+
struct drm_crtc *crtc;
931+
uint32_t line_time_us, vblank_lines;
932+
933+
if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) {
934+
list_for_each_entry(crtc,
935+
&ddev->mode_config.crtc_list, head) {
936+
amdgpu_crtc = to_amdgpu_crtc(crtc);
937+
if (crtc->enabled) {
938+
info->active_display_mask |= (1 << amdgpu_crtc->crtc_id);
939+
info->display_count++;
940+
}
941+
if (mode_info != NULL &&
942+
crtc->enabled && amdgpu_crtc->enabled &&
943+
amdgpu_crtc->hw_mode.clock) {
944+
line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) /
945+
amdgpu_crtc->hw_mode.clock;
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+
}
951954
}
952955
}
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+
}
953963
}
954-
955964
return 0;
956965
}
957966

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

Lines changed: 89 additions & 16 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>
@@ -2046,6 +2047,52 @@ static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev)
20462047
}
20472048
}
20482049

2050+
bool 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+
*/
2088+
bool 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+
20492096
/**
20502097
* amdgpu_device_init - initialize the driver
20512098
*
@@ -2100,7 +2147,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
21002147
adev->audio_endpt_rreg = &amdgpu_block_invalid_rreg;
21012148
adev->audio_endpt_wreg = &amdgpu_block_invalid_wreg;
21022149

2103-
21042150
DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X).\n",
21052151
amdgpu_asic_name[adev->asic_type], pdev->vendor, pdev->device,
21062152
pdev->subsystem_vendor, pdev->subsystem_device, pdev->revision);
@@ -2242,7 +2288,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
22422288
goto failed;
22432289
}
22442290
/* init i2c buses */
2245-
amdgpu_atombios_i2c_init(adev);
2291+
if (!amdgpu_device_has_dc_support(adev))
2292+
amdgpu_atombios_i2c_init(adev);
22462293
}
22472294

22482295
/* Fence driver */
@@ -2378,7 +2425,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
23782425
adev->accel_working = false;
23792426
cancel_delayed_work_sync(&adev->late_init_work);
23802427
/* free i2c buses */
2381-
amdgpu_i2c_fini(adev);
2428+
if (!amdgpu_device_has_dc_support(adev))
2429+
amdgpu_i2c_fini(adev);
23822430
amdgpu_atombios_fini(adev);
23832431
kfree(adev->bios);
23842432
adev->bios = NULL;
@@ -2429,12 +2477,14 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
24292477

24302478
drm_kms_helper_poll_disable(dev);
24312479

2432-
/* turn off display hw */
2433-
drm_modeset_lock_all(dev);
2434-
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2435-
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2480+
if (!amdgpu_device_has_dc_support(adev)) {
2481+
/* turn off display hw */
2482+
drm_modeset_lock_all(dev);
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);
24362487
}
2437-
drm_modeset_unlock_all(dev);
24382488

24392489
amdgpu_amdkfd_suspend(adev);
24402490

@@ -2577,13 +2627,25 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
25772627

25782628
/* blat the mode back in */
25792629
if (fbcon) {
2580-
drm_helper_resume_force_mode(dev);
2581-
/* turn on display hw */
2582-
drm_modeset_lock_all(dev);
2583-
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2584-
drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
2630+
if (!amdgpu_device_has_dc_support(adev)) {
2631+
/* pre DCE11 */
2632+
drm_helper_resume_force_mode(dev);
2633+
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);
25852648
}
2586-
drm_modeset_unlock_all(dev);
25872649
}
25882650

25892651
drm_kms_helper_poll_enable(dev);
@@ -2600,7 +2662,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
26002662
#ifdef CONFIG_PM
26012663
dev->dev->power.disable_depth++;
26022664
#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);
26042669
#ifdef CONFIG_PM
26052670
dev->dev->power.disable_depth--;
26062671
#endif
@@ -2900,6 +2965,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, struct amdgpu_job *job)
29002965
*/
29012966
int amdgpu_gpu_reset(struct amdgpu_device *adev)
29022967
{
2968+
struct drm_atomic_state *state = NULL;
29032969
int i, r;
29042970
int resched;
29052971
bool need_full_reset, vram_lost = false;
@@ -2913,6 +2979,9 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
29132979

29142980
/* block TTM */
29152981
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);
29162985

29172986
/* block scheduler */
29182987
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
@@ -3029,7 +3098,11 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
30293098
}
30303099
}
30313100

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);
30333106

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ amdgpu_framebuffer_init(struct drm_device *dev,
518518
return 0;
519519
}
520520

521-
static struct drm_framebuffer *
521+
struct drm_framebuffer *
522522
amdgpu_user_framebuffer_create(struct drm_device *dev,
523523
struct drm_file *file_priv,
524524
const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -556,7 +556,7 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,
556556
return &amdgpu_fb->base;
557557
}
558558

559-
static void amdgpu_output_poll_changed(struct drm_device *dev)
559+
void amdgpu_output_poll_changed(struct drm_device *dev)
560560
{
561561
struct amdgpu_device *adev = dev->dev_private;
562562
amdgpu_fb_output_poll_changed(adev);

0 commit comments

Comments
 (0)