mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm/amdgpu: add a dev_pm_ops prepare callback (v2)
as per: https://www.kernel.org/doc/html/latest/driver-api/pm/devices.html The prepare callback is required to support the DPM_FLAG_SMART_SUSPEND driver flag. This allows runtime pm to auto complete when the system goes into suspend avoiding a wake up on suspend and on resume. Apply this for hybrid gfx and BOCO systems where d3cold is provided by the ACPI platform. v2: check if device is runtime suspended in prepare. Reviewed-by: Evan Quan <evan.quan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
		
							parent
							
								
									ed098aa34c
								
							
						
					
					
						commit
						e25443d276
					
				
					 1 changed files with 24 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -36,6 +36,7 @@
 | 
			
		|||
#include <linux/vga_switcheroo.h>
 | 
			
		||||
#include <drm/drm_probe_helper.h>
 | 
			
		||||
#include <linux/mmu_notifier.h>
 | 
			
		||||
#include <linux/suspend.h>
 | 
			
		||||
 | 
			
		||||
#include "amdgpu.h"
 | 
			
		||||
#include "amdgpu_irq.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -1403,6 +1404,27 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work)
 | 
			
		|||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int amdgpu_pmops_prepare(struct device *dev)
 | 
			
		||||
{
 | 
			
		||||
	struct drm_device *drm_dev = dev_get_drvdata(dev);
 | 
			
		||||
 | 
			
		||||
	/* Return a positive number here so
 | 
			
		||||
	 * DPM_FLAG_SMART_SUSPEND works properly
 | 
			
		||||
	 */
 | 
			
		||||
	if ((amdgpu_device_supports_atpx(drm_dev) &&
 | 
			
		||||
	    amdgpu_is_atpx_hybrid()) ||
 | 
			
		||||
	    amdgpu_device_supports_boco(drm_dev))
 | 
			
		||||
		return pm_runtime_suspended(dev) &&
 | 
			
		||||
			pm_suspend_via_firmware();
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void amdgpu_pmops_complete(struct device *dev)
 | 
			
		||||
{
 | 
			
		||||
	/* nothing to do */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int amdgpu_pmops_suspend(struct device *dev)
 | 
			
		||||
{
 | 
			
		||||
	struct drm_device *drm_dev = dev_get_drvdata(dev);
 | 
			
		||||
| 
						 | 
				
			
			@ -1621,6 +1643,8 @@ long amdgpu_drm_ioctl(struct file *filp,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static const struct dev_pm_ops amdgpu_pm_ops = {
 | 
			
		||||
	.prepare = amdgpu_pmops_prepare,
 | 
			
		||||
	.complete = amdgpu_pmops_complete,
 | 
			
		||||
	.suspend = amdgpu_pmops_suspend,
 | 
			
		||||
	.resume = amdgpu_pmops_resume,
 | 
			
		||||
	.freeze = amdgpu_pmops_freeze,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue