FreeBSD/sys/dev/drm2/radeon/radeon_device.c
/**
 * radeon_suspend_kms - initiate device suspend
 *
 * @pdev: drm dev pointer
 * @state: suspend state
 *
 * Puts the hw in the suspend state (all asics).
 * Returns 0 for success or an error on failure.
 * Called at driver suspend.
 */
initiate device suspend
@pdev: drm dev pointer
@state: suspend state

Puts the hw in the suspend state (all asics).
Returns 0 for success or an error on failure.
Called at driver suspend.
initiate device suspend @pdev : drm dev pointer @state : suspend state Puts the hw in the suspend state ( all asics ) . Returns 0 for success or an error on failure . Called at driver suspend .
int radeon_suspend_kms(struct drm_device *dev)
{
	struct radeon_device *rdev;
	struct drm_crtc *crtc;
	struct drm_connector *connector;
	int i, r;
	bool force_completion = false;
	if (dev == NULL || dev->dev_private == NULL) {
		return -ENODEV;
	}
#ifdef FREEBSD_WIP
	if (state.event == PM_EVENT_PRETHAW) {
		return 0;
	}
#endif 
	rdev = dev->dev_private;
	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
		return 0;
	drm_kms_helper_poll_disable(dev);
	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
		drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
	}
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
		struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->fb);
		struct radeon_bo *robj;
		if (rfb == NULL || rfb->obj == NULL) {
			continue;
		}
		robj = gem_to_radeon_bo(rfb->obj);
		if (!radeon_fbdev_robj_is_fb(rdev, robj)) {
			r = radeon_bo_reserve(robj, false);
			if (r == 0) {
				radeon_bo_unpin(robj);
				radeon_bo_unreserve(robj);
			}
		}
	}
	radeon_bo_evict_vram(rdev);
	sx_xlock(&rdev->ring_lock);
	for (i = 0; i < RADEON_NUM_RINGS; i++) {
		r = radeon_fence_wait_empty_locked(rdev, i);
		if (r) {
			force_completion = true;
		}
	}
	if (force_completion) {
		radeon_fence_driver_force_completion(rdev);
	}
	sx_xunlock(&rdev->ring_lock);
	radeon_save_bios_scratch_regs(rdev);
	radeon_pm_suspend(rdev);
	radeon_suspend(rdev);
	radeon_hpd_fini(rdev);
	radeon_bo_evict_vram(rdev);
	radeon_agp_suspend(rdev);
#ifdef FREEBSD_WIP
	if (state.event == PM_EVENT_SUSPEND) {
		pci_disable_device(dev->pdev);
	}
	console_lock();
#endif 
	radeon_fbdev_set_suspend(rdev, 1);
#ifdef FREEBSD_WIP
	console_unlock();
#endif 
	return 0;
}
int radeon_suspend_kms ( struct drm_device * dev ) { struct radeon_device * rdev ; struct drm_crtc * crtc ; struct drm_connector * connector ; int i , r ; bool force_completion = false ; if ( dev == NULL || dev -> dev_private == NULL ) { return - ENODEV ; } #ifdef FREEBSD_WIP if ( state . event == PM_EVENT_PRETHAW ) { return 0 ; } #endif rdev = dev -> dev_private ; if ( dev -> switch_power_state == DRM_SWITCH_POWER_OFF ) return 0 ; drm_kms_helper_poll_disable ( dev ) ; list_for_each_entry ( connector , & dev -> mode_config . connector_list , head ) { drm_helper_connector_dpms ( connector , DRM_MODE_DPMS_OFF ) ; } list_for_each_entry ( crtc , & dev -> mode_config . crtc_list , head ) { struct radeon_framebuffer * rfb = to_radeon_framebuffer ( crtc -> fb ) ; struct radeon_bo * robj ; if ( rfb == NULL || rfb -> obj == NULL ) { continue ; } robj = gem_to_radeon_bo ( rfb -> obj ) ; if ( ! radeon_fbdev_robj_is_fb ( rdev , robj ) ) { r = radeon_bo_reserve ( robj , false ) ; if ( r == 0 ) { radeon_bo_unpin ( robj ) ; radeon_bo_unreserve ( robj ) ; } } } radeon_bo_evict_vram ( rdev ) ; sx_xlock ( & rdev -> ring_lock ) ; for ( i = 0 ; i < RADEON_NUM_RINGS ; i ++ ) { r = radeon_fence_wait_empty_locked ( rdev , i ) ; if ( r ) { force_completion = true ; } } if ( force_completion ) { radeon_fence_driver_force_completion ( rdev ) ; } sx_xunlock ( & rdev -> ring_lock ) ; radeon_save_bios_scratch_regs ( rdev ) ; radeon_pm_suspend ( rdev ) ; radeon_suspend ( rdev ) ; radeon_hpd_fini ( rdev ) ; radeon_bo_evict_vram ( rdev ) ; radeon_agp_suspend ( rdev ) ; #ifdef FREEBSD_WIP if ( state . event == PM_EVENT_SUSPEND ) { pci_disable_device ( dev -> pdev ) ; } console_lock ( ) ; #endif radeon_fbdev_set_suspend ( rdev , 1 ) ; #ifdef FREEBSD_WIP console_unlock ( ) ; #endif return 0 ; }
radeon_suspend_kms - initiate device suspend
 @pdev: drm dev pointer
 @state: suspend state
radeon_suspend_kms - initiate device suspend @pdev : drm dev pointer @state : suspend state
/* FREEBSD_WIP */ /* turn off display hw */ /* unpin the front buffers */ /* don't unpin kernel fb objects */ /* evict vram memory */ /* wait for gpu to finish processing current batch */ /* delay GPU reset to resume */ /* evict remaining vram memory */ /* Shut down the device */ /* FREEBSD_WIP */ /* FREEBSD_WIP */