Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From c50c188c5c2c12d1cbf0d71d624850f984a13619 Mon Sep 17 00:00:00 2001
- From: Mike Lothian <mike@fireburn.co.uk>
- Date: Thu, 5 Sep 2013 23:38:45 +0000
- Subject: [PATCH] radeon: initial runtime poweroff support
- ---
- drivers/gpu/drm/radeon/radeon.h | 6 +-
- drivers/gpu/drm/radeon/radeon.h.rej | 12 +++
- drivers/gpu/drm/radeon/radeon_connectors.c | 63 +++++++++++++--
- drivers/gpu/drm/radeon/radeon_device.c | 52 +++++++-----
- drivers/gpu/drm/radeon/radeon_display.c | 47 ++++++++++-
- drivers/gpu/drm/radeon/radeon_drv.c | 124 +++++++++++++++++++++++++----
- drivers/gpu/drm/radeon/radeon_irq_kms.c | 8 +-
- drivers/gpu/drm/radeon/radeon_kms.c | 24 +++++-
- 8 files changed, 284 insertions(+), 52 deletions(-)
- create mode 100644 drivers/gpu/drm/radeon/radeon.h.rej
- diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
- index ff8b564..cb8c164 100644
- --- a/drivers/gpu/drm/radeon/radeon.h
- +++ b/drivers/gpu/drm/radeon/radeon.h
- @@ -2184,6 +2184,8 @@ struct radeon_device {
- /* ACPI interface */
- struct radeon_atif atif;
- struct radeon_atcs atcs;
- + struct dev_pm_domain vga_pm_domain;
- + bool have_disp_power_ref;
- /* srbm instance registers */
- struct mutex srbm_mutex;
- /* clock, powergating flags */
- @@ -2593,8 +2595,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, bool fbcon);
- +extern int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
- 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,
- diff --git a/drivers/gpu/drm/radeon/radeon.h.rej b/drivers/gpu/drm/radeon/radeon.h.rej
- new file mode 100644
- index 0000000..4cb2b21
- --- /dev/null
- +++ b/drivers/gpu/drm/radeon/radeon.h.rej
- @@ -0,0 +1,12 @@
- +--- drivers/gpu/drm/radeon/radeon.h
- ++++ drivers/gpu/drm/radeon/radeon.h
- +@@ -2092,6 +2092,9 @@
- + /* ACPI interface */
- + struct radeon_atif atif;
- + struct radeon_atcs atcs;
- ++
- ++ struct dev_pm_domain vga_pm_domain;
- ++ bool have_disp_power_ref;
- + };
- +
- + int radeon_device_init(struct radeon_device *rdev,
- diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
- index 2399f25..f5a525b 100644
- --- a/drivers/gpu/drm/radeon/radeon_connectors.c
- +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
- @@ -31,6 +31,8 @@
- #include "radeon.h"
- #include "atom.h"
- +#include <linux/pm_runtime.h>
- +
- extern void
- radeon_combios_connected_scratch_regs(struct drm_connector *connector,
- struct drm_encoder *encoder,
- @@ -611,6 +613,11 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
- struct radeon_connector *radeon_connector = to_radeon_connector(connector);
- struct drm_encoder *encoder = radeon_best_single_encoder(connector);
- enum drm_connector_status ret = connector_status_disconnected;
- + int r;
- +
- + r = pm_runtime_get_sync(connector->dev->dev);
- + if (r < 0)
- + return connector_status_disconnected;
- if (encoder) {
- struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
- @@ -636,6 +643,8 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
- /* check acpi lid status ??? */
- radeon_connector_update_scratch_regs(connector, ret);
- + pm_runtime_mark_last_busy(connector->dev->dev);
- + pm_runtime_put_autosuspend(connector->dev->dev);
- return ret;
- }
- @@ -735,6 +744,11 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
- struct drm_encoder_helper_funcs *encoder_funcs;
- bool dret = false;
- enum drm_connector_status ret = connector_status_disconnected;
- + int r;
- +
- + r = pm_runtime_get_sync(connector->dev->dev);
- + if (r < 0)
- + return connector_status_disconnected;
- encoder = radeon_best_single_encoder(connector);
- if (!encoder)
- @@ -775,9 +789,8 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
- * detected a monitor via load.
- */
- if (radeon_connector->detected_by_load)
- - return connector->status;
- - else
- - return ret;
- + ret = connector->status;
- + goto out;
- }
- if (radeon_connector->dac_load_detect && encoder) {
- @@ -802,6 +815,11 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
- }
- radeon_connector_update_scratch_regs(connector, ret);
- +
- +out:
- + pm_runtime_mark_last_busy(connector->dev->dev);
- + pm_runtime_put_autosuspend(connector->dev->dev);
- +
- return ret;
- }
- @@ -858,10 +876,15 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
- struct drm_encoder_helper_funcs *encoder_funcs;
- struct radeon_connector *radeon_connector = to_radeon_connector(connector);
- enum drm_connector_status ret = connector_status_disconnected;
- + int r;
- if (!radeon_connector->dac_load_detect)
- return ret;
- + r = pm_runtime_get_sync(connector->dev->dev);
- + if (r < 0)
- + return connector_status_disconnected;
- +
- encoder = radeon_best_single_encoder(connector);
- if (!encoder)
- ret = connector_status_disconnected;
- @@ -872,6 +895,8 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
- if (ret == connector_status_connected)
- ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false);
- radeon_connector_update_scratch_regs(connector, ret);
- + pm_runtime_mark_last_busy(connector->dev->dev);
- + pm_runtime_put_autosuspend(connector->dev->dev);
- return ret;
- }
- @@ -939,12 +964,18 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
- struct drm_encoder *encoder = NULL;
- struct drm_encoder_helper_funcs *encoder_funcs;
- struct drm_mode_object *obj;
- - int i;
- + int i, r;
- enum drm_connector_status ret = connector_status_disconnected;
- bool dret = false, broken_edid = false;
- - if (!force && radeon_check_hpd_status_unchanged(connector))
- - return connector->status;
- + r = pm_runtime_get_sync(connector->dev->dev);
- + if (r < 0)
- + return connector_status_disconnected;
- +
- + if (!force && radeon_check_hpd_status_unchanged(connector)) {
- + ret = connector->status;
- + goto exit;
- + }
- if (radeon_connector->ddc_bus)
- dret = radeon_ddc_probe(radeon_connector, false);
- @@ -1095,6 +1126,11 @@ out:
- /* updated in get modes as well since we need to know if it's analog or digital */
- radeon_connector_update_scratch_regs(connector, ret);
- +
- +exit:
- + pm_runtime_mark_last_busy(connector->dev->dev);
- + pm_runtime_put_autosuspend(connector->dev->dev);
- +
- return ret;
- }
- @@ -1362,9 +1398,16 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
- enum drm_connector_status ret = connector_status_disconnected;
- struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
- struct drm_encoder *encoder = radeon_best_single_encoder(connector);
- + int r;
- - if (!force && radeon_check_hpd_status_unchanged(connector))
- - return connector->status;
- + r = pm_runtime_get_sync(connector->dev->dev);
- + if (r < 0)
- + return connector_status_disconnected;
- +
- + if (!force && radeon_check_hpd_status_unchanged(connector)) {
- + ret = connector->status;
- + goto out;
- + }
- if (radeon_connector->edid) {
- kfree(radeon_connector->edid);
- @@ -1428,6 +1471,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
- }
- radeon_connector_update_scratch_regs(connector, ret);
- +out:
- + pm_runtime_mark_last_busy(connector->dev->dev);
- + pm_runtime_put_autosuspend(connector->dev->dev);
- +
- return ret;
- }
- diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
- index 16cb879..0e4796d 100644
- --- a/drivers/gpu/drm/radeon/radeon_device.c
- +++ b/drivers/gpu/drm/radeon/radeon_device.c
- @@ -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, true, true);
- 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, true, true);
- dev->switch_power_state = DRM_SWITCH_POWER_OFF;
- }
- }
- @@ -1282,7 +1281,8 @@ int radeon_device_init(struct radeon_device *rdev,
- /* this will fail for cards that aren't VGA class devices, just
- * ignore it */
- vga_client_register(rdev->pdev, rdev, NULL, radeon_vga_set_decode);
- - vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops, false);
- + vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops, true);
- + vga_switcheroo_init_domain_pm_ops(rdev->dev, &rdev->vga_pm_domain);
- r = radeon_init(rdev);
- if (r)
- @@ -1363,7 +1363,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, bool fbcon)
- {
- struct radeon_device *rdev;
- struct drm_crtc *crtc;
- @@ -1374,9 +1374,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)
- @@ -1435,14 +1433,17 @@ 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);
- }
- - console_lock();
- - radeon_fbdev_set_suspend(rdev, 1);
- - console_unlock();
- +
- + if (fbcon) {
- + console_lock();
- + radeon_fbdev_set_suspend(rdev, 1);
- + console_unlock();
- + }
- return 0;
- }
- @@ -1455,7 +1456,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, bool fbcon)
- {
- struct drm_connector *connector;
- struct radeon_device *rdev = dev->dev_private;
- @@ -1464,12 +1465,17 @@ int radeon_resume_kms(struct drm_device *dev)
- if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
- 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 (fbcon) {
- + console_lock();
- + }
- + if (resume) {
- + pci_set_power_state(dev->pdev, PCI_D0);
- + pci_restore_state(dev->pdev);
- + if (pci_enable_device(dev->pdev)) {
- + if (fbcon)
- + console_unlock();
- + return -1;
- + }
- }
- /* resume AGP if in use */
- radeon_agp_resume(rdev);
- @@ -1482,9 +1488,11 @@ int radeon_resume_kms(struct drm_device *dev)
- radeon_pm_resume(rdev);
- radeon_restore_bios_scratch_regs(rdev);
- - radeon_fbdev_set_suspend(rdev, 0);
- - console_unlock();
- -
- + if (fbcon) {
- + radeon_fbdev_set_suspend(rdev, 0);
- + console_unlock();
- + }
- +
- /* init dig PHYs, disp eng pll */
- if (rdev->is_atom_bios) {
- radeon_atom_encoder_init(rdev);
- diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
- index b055bdd..246c7a8 100644
- --- a/drivers/gpu/drm/radeon/radeon_display.c
- +++ b/drivers/gpu/drm/radeon/radeon_display.c
- @@ -30,6 +30,7 @@
- #include "atom.h"
- #include <asm/div64.h>
- +#include <linux/pm_runtime.h>
- #include <drm/drm_crtc_helper.h>
- #include <drm/drm_edid.h>
- @@ -494,11 +495,55 @@ unlock_free:
- return r;
- }
- +static int
- +radeon_crtc_set_config(struct drm_mode_set *set)
- +{
- + struct drm_device *dev;
- + struct radeon_device *rdev;
- + struct drm_crtc *crtc;
- + bool active = false;
- + int ret;
- +
- + if (!set || !set->crtc)
- + return -EINVAL;
- +
- + dev = set->crtc->dev;
- +
- + ret = pm_runtime_get_sync(dev->dev);
- + if (ret < 0)
- + return ret;
- +
- + ret = drm_crtc_helper_set_config(set);
- +
- + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
- + if (crtc->enabled)
- + active = true;
- +
- + pm_runtime_mark_last_busy(dev->dev);
- +
- + rdev = dev->dev_private;
- + /* if we have active crtcs and we don't have a power ref,
- + take the current one */
- + if (active && !rdev->have_disp_power_ref) {
- + rdev->have_disp_power_ref = true;
- + return ret;
- + }
- + /* if we have no active crtcs, then drop the power ref
- + we got before */
- + if (!active && rdev->have_disp_power_ref) {
- + pm_runtime_put_autosuspend(dev->dev);
- + rdev->have_disp_power_ref = false;
- + }
- +
- + /* drop the power reference we got coming in here */
- + pm_runtime_put_autosuspend(dev->dev);
- + return ret;
- +}
- static const struct drm_crtc_funcs radeon_crtc_funcs = {
- .cursor_set = radeon_crtc_cursor_set,
- .cursor_move = radeon_crtc_cursor_move,
- .gamma_set = radeon_crtc_gamma_set,
- - .set_config = drm_crtc_helper_set_config,
- + .set_config = radeon_crtc_set_config,
- .destroy = radeon_crtc_destroy,
- .page_flip = radeon_crtc_page_flip,
- };
- diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
- index cb4445f..4379eed 100644
- --- a/drivers/gpu/drm/radeon/radeon_drv.c
- +++ b/drivers/gpu/drm/radeon/radeon_drv.c
- @@ -36,8 +36,9 @@
- #include <drm/drm_pciids.h>
- #include <linux/console.h>
- #include <linux/module.h>
- -
- -
- +#include <linux/pm_runtime.h>
- +#include <linux/vga_switcheroo.h>
- +#include "drm_crtc_helper.h"
- /*
- * KMS wrapper.
- * - 2.0.0 - initial interface
- @@ -87,8 +88,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, bool fbcon);
- +int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
- 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);
- @@ -259,6 +260,7 @@ static int radeon_resume(struct drm_device *dev)
- return 0;
- }
- +
- static const struct file_operations radeon_driver_old_fops = {
- .owner = THIS_MODULE,
- .open = drm_open,
- @@ -353,25 +355,116 @@ 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, true, true);
- }
- -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, true, true);
- +}
- +
- +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, false, true);
- +}
- +
- +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, false, true);
- +}
- +
- +static int radeon_pmops_runtime_suspend(struct device *dev)
- +{
- + struct pci_dev *pdev = to_pci_dev(dev);
- + struct drm_device *drm_dev = pci_get_drvdata(pdev);
- + int ret;
- +
- + drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
- + drm_kms_helper_poll_disable(drm_dev);
- + vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
- +
- + ret = radeon_suspend_kms(drm_dev, false, false);
- + pci_save_state(pdev);
- + pci_disable_device(pdev);
- + pci_set_power_state(pdev, PCI_D3cold);
- + drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
- +
- + return 0;
- +}
- +
- +static int radeon_pmops_runtime_resume(struct device *dev)
- +{
- + struct pci_dev *pdev = to_pci_dev(dev);
- + struct drm_device *drm_dev = pci_get_drvdata(pdev);
- + int ret;
- +
- + drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
- +
- + pci_set_power_state(pdev, PCI_D0);
- + pci_restore_state(pdev);
- + ret = pci_enable_device(pdev);
- + if (ret)
- + return ret;
- + pci_set_master(pdev);
- +
- + ret = radeon_resume_kms(drm_dev, false, false);
- + drm_kms_helper_poll_enable(drm_dev);
- + vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
- + drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
- + return 0;
- +}
- +
- +static int radeon_pmops_runtime_idle(struct device *dev)
- +{
- + pm_runtime_autosuspend(dev);
- + return 1;
- +}
- +
- +static long radeon_drm_ioctl(struct file *filp,
- + unsigned int cmd, unsigned long arg)
- +{
- + struct drm_file *file_priv = filp->private_data;
- + struct drm_device *dev;
- + long ret;
- + dev = file_priv->minor->dev;
- + ret = pm_runtime_get_sync(dev->dev);
- + if (ret < 0)
- + return ret;
- +
- + ret = drm_ioctl(filp, cmd, arg);
- +
- + pm_runtime_mark_last_busy(dev->dev);
- + pm_runtime_put_autosuspend(dev->dev);
- + return ret;
- }
- +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,
- + .runtime_suspend = radeon_pmops_runtime_suspend,
- + .runtime_resume = radeon_pmops_runtime_resume,
- + .runtime_idle = radeon_pmops_runtime_idle,
- +};
- +
- static const struct file_operations radeon_driver_kms_fops = {
- .owner = THIS_MODULE,
- .open = drm_open,
- .release = drm_release,
- - .unlocked_ioctl = drm_ioctl,
- + .unlocked_ioctl = radeon_drm_ioctl,
- .mmap = radeon_mmap,
- .poll = drm_poll,
- .read = drm_read,
- @@ -392,8 +485,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,
- @@ -451,8 +542,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)
- diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
- index cc9e848..ec6240b 100644
- --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
- +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
- @@ -32,6 +32,8 @@
- #include "radeon.h"
- #include "atom.h"
- +#include <linux/pm_runtime.h>
- +
- #define RADEON_WAIT_IDLE_TIMEOUT 200
- /**
- @@ -47,8 +49,12 @@ irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS)
- {
- struct drm_device *dev = (struct drm_device *) arg;
- struct radeon_device *rdev = dev->dev_private;
- + irqreturn_t ret;
- - return radeon_irq_process(rdev);
- + ret = radeon_irq_process(rdev);
- + if (ret == IRQ_HANDLED)
- + pm_runtime_mark_last_busy(dev->dev);
- + return ret;
- }
- /*
- diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
- index 61580dd..2b63461 100644
- --- a/drivers/gpu/drm/radeon/radeon_kms.c
- +++ b/drivers/gpu/drm/radeon/radeon_kms.c
- @@ -32,7 +32,7 @@
- #include <linux/vga_switcheroo.h>
- #include <linux/slab.h>
- -
- +#include <linux/pm_runtime.h>
- /**
- * radeon_driver_unload_kms - Main unload function for KMS.
- *
- @@ -50,9 +50,14 @@ int radeon_driver_unload_kms(struct drm_device *dev)
- if (rdev == NULL)
- return 0;
- +
- if (rdev->rmmio == NULL)
- goto done_free;
- +
- + pm_runtime_get_sync(dev->dev);
- +
- radeon_acpi_fini(rdev);
- +
- radeon_modeset_fini(rdev);
- radeon_device_fini(rdev);
- @@ -125,9 +130,18 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
- "Error during ACPI methods call\n");
- }
- + pm_runtime_use_autosuspend(dev->dev);
- + pm_runtime_set_autosuspend_delay(dev->dev, 5000);
- + pm_runtime_set_active(dev->dev);
- + pm_runtime_allow(dev->dev);
- + pm_runtime_mark_last_busy(dev->dev);
- + pm_runtime_put_autosuspend(dev->dev);
- +
- out:
- if (r)
- radeon_driver_unload_kms(dev);
- +
- +
- return r;
- }
- @@ -475,9 +489,14 @@ void radeon_driver_lastclose_kms(struct drm_device *dev)
- int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
- {
- struct radeon_device *rdev = dev->dev_private;
- + int r;
- file_priv->driver_priv = NULL;
- + r = pm_runtime_get_sync(dev->dev);
- + if (r < 0)
- + return r;
- +
- /* new gpu have virtual address space support */
- if (rdev->family >= CHIP_CAYMAN) {
- struct radeon_fpriv *fpriv;
- @@ -506,6 +525,9 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
- file_priv->driver_priv = fpriv;
- }
- +
- + pm_runtime_mark_last_busy(dev->dev);
- + pm_runtime_put_autosuspend(dev->dev);
- return 0;
- }
- --
- 1.8.3.2
Advertisement
Add Comment
Please, Sign In to add comment