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 */
28152870int 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 ) {
0 commit comments