drm/radeon: convert to pmops
This is a pre-requisite for runtime pm on powerxpress systems. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Родитель
6214bb7487
Коммит
7473e830c4
|
@ -2673,8 +2673,8 @@ extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
|
|||
extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
|
||||
extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
|
||||
extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
|
||||
extern int radeon_resume_kms(struct drm_device *dev);
|
||||
extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
|
||||
extern int radeon_resume_kms(struct drm_device *dev, bool resume);
|
||||
extern int radeon_suspend_kms(struct drm_device *dev, bool suspend);
|
||||
extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size);
|
||||
extern void radeon_program_register_sequence(struct radeon_device *rdev,
|
||||
const u32 *registers,
|
||||
|
|
|
@ -1076,7 +1076,6 @@ static bool radeon_switcheroo_quirk_long_wakeup(struct pci_dev *pdev)
|
|||
static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
|
||||
{
|
||||
struct drm_device *dev = pci_get_drvdata(pdev);
|
||||
pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
|
||||
if (state == VGA_SWITCHEROO_ON) {
|
||||
unsigned d3_delay = dev->pdev->d3_delay;
|
||||
|
||||
|
@ -1087,7 +1086,7 @@ static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
|
|||
if (d3_delay < 20 && radeon_switcheroo_quirk_long_wakeup(pdev))
|
||||
dev->pdev->d3_delay = 20;
|
||||
|
||||
radeon_resume_kms(dev);
|
||||
radeon_resume_kms(dev, 1);
|
||||
|
||||
dev->pdev->d3_delay = d3_delay;
|
||||
|
||||
|
@ -1097,7 +1096,7 @@ static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
|
|||
printk(KERN_INFO "radeon: switched off\n");
|
||||
drm_kms_helper_poll_disable(dev);
|
||||
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
|
||||
radeon_suspend_kms(dev, pmm);
|
||||
radeon_suspend_kms(dev, 1);
|
||||
dev->switch_power_state = DRM_SWITCH_POWER_OFF;
|
||||
}
|
||||
}
|
||||
|
@ -1383,7 +1382,7 @@ void radeon_device_fini(struct radeon_device *rdev)
|
|||
* Returns 0 for success or an error on failure.
|
||||
* Called at driver suspend.
|
||||
*/
|
||||
int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
|
||||
int radeon_suspend_kms(struct drm_device *dev, bool suspend)
|
||||
{
|
||||
struct radeon_device *rdev;
|
||||
struct drm_crtc *crtc;
|
||||
|
@ -1394,9 +1393,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
|
|||
if (dev == NULL || dev->dev_private == NULL) {
|
||||
return -ENODEV;
|
||||
}
|
||||
if (state.event == PM_EVENT_PRETHAW) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rdev = dev->dev_private;
|
||||
|
||||
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
|
||||
|
@ -1455,7 +1452,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
|
|||
radeon_agp_suspend(rdev);
|
||||
|
||||
pci_save_state(dev->pdev);
|
||||
if (state.event == PM_EVENT_SUSPEND) {
|
||||
if (suspend) {
|
||||
/* Shut down the device */
|
||||
pci_disable_device(dev->pdev);
|
||||
pci_set_power_state(dev->pdev, PCI_D3hot);
|
||||
|
@ -1475,7 +1472,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
|
|||
* Returns 0 for success or an error on failure.
|
||||
* Called at driver resume.
|
||||
*/
|
||||
int radeon_resume_kms(struct drm_device *dev)
|
||||
int radeon_resume_kms(struct drm_device *dev, bool resume)
|
||||
{
|
||||
struct drm_connector *connector;
|
||||
struct radeon_device *rdev = dev->dev_private;
|
||||
|
@ -1485,11 +1482,13 @@ int radeon_resume_kms(struct drm_device *dev)
|
|||
return 0;
|
||||
|
||||
console_lock();
|
||||
pci_set_power_state(dev->pdev, PCI_D0);
|
||||
pci_restore_state(dev->pdev);
|
||||
if (pci_enable_device(dev->pdev)) {
|
||||
console_unlock();
|
||||
return -1;
|
||||
if (resume) {
|
||||
pci_set_power_state(dev->pdev, PCI_D0);
|
||||
pci_restore_state(dev->pdev);
|
||||
if (pci_enable_device(dev->pdev)) {
|
||||
console_unlock();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* resume AGP if in use */
|
||||
radeon_agp_resume(rdev);
|
||||
|
|
|
@ -87,8 +87,8 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
|
|||
struct drm_file *file_priv);
|
||||
void radeon_driver_preclose_kms(struct drm_device *dev,
|
||||
struct drm_file *file_priv);
|
||||
int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
|
||||
int radeon_resume_kms(struct drm_device *dev);
|
||||
int radeon_suspend_kms(struct drm_device *dev, bool suspend);
|
||||
int radeon_resume_kms(struct drm_device *dev, bool resume);
|
||||
u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc);
|
||||
int radeon_enable_vblank_kms(struct drm_device *dev, int crtc);
|
||||
void radeon_disable_vblank_kms(struct drm_device *dev, int crtc);
|
||||
|
@ -352,20 +352,43 @@ radeon_pci_remove(struct pci_dev *pdev)
|
|||
drm_put_dev(dev);
|
||||
}
|
||||
|
||||
static int
|
||||
radeon_pci_suspend(struct pci_dev *pdev, pm_message_t state)
|
||||
static int radeon_pmops_suspend(struct device *dev)
|
||||
{
|
||||
struct drm_device *dev = pci_get_drvdata(pdev);
|
||||
return radeon_suspend_kms(dev, state);
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
||||
return radeon_suspend_kms(drm_dev, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
radeon_pci_resume(struct pci_dev *pdev)
|
||||
static int radeon_pmops_resume(struct device *dev)
|
||||
{
|
||||
struct drm_device *dev = pci_get_drvdata(pdev);
|
||||
return radeon_resume_kms(dev);
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
||||
return radeon_resume_kms(drm_dev, 1);
|
||||
}
|
||||
|
||||
static int radeon_pmops_freeze(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
||||
return radeon_suspend_kms(drm_dev, 0);
|
||||
}
|
||||
|
||||
static int radeon_pmops_thaw(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
||||
return radeon_resume_kms(drm_dev, 0);
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops radeon_pm_ops = {
|
||||
.suspend = radeon_pmops_suspend,
|
||||
.resume = radeon_pmops_resume,
|
||||
.freeze = radeon_pmops_freeze,
|
||||
.thaw = radeon_pmops_thaw,
|
||||
.poweroff = radeon_pmops_freeze,
|
||||
.restore = radeon_pmops_resume,
|
||||
};
|
||||
|
||||
static const struct file_operations radeon_driver_kms_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
|
@ -391,8 +414,6 @@ static struct drm_driver kms_driver = {
|
|||
.postclose = radeon_driver_postclose_kms,
|
||||
.lastclose = radeon_driver_lastclose_kms,
|
||||
.unload = radeon_driver_unload_kms,
|
||||
.suspend = radeon_suspend_kms,
|
||||
.resume = radeon_resume_kms,
|
||||
.get_vblank_counter = radeon_get_vblank_counter_kms,
|
||||
.enable_vblank = radeon_enable_vblank_kms,
|
||||
.disable_vblank = radeon_disable_vblank_kms,
|
||||
|
@ -449,8 +470,7 @@ static struct pci_driver radeon_kms_pci_driver = {
|
|||
.id_table = pciidlist,
|
||||
.probe = radeon_pci_probe,
|
||||
.remove = radeon_pci_remove,
|
||||
.suspend = radeon_pci_suspend,
|
||||
.resume = radeon_pci_resume,
|
||||
.driver.pm = &radeon_pm_ops,
|
||||
};
|
||||
|
||||
static int __init radeon_init(void)
|
||||
|
|
Загрузка…
Ссылка в новой задаче