Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Convert drm class driver from legacy pm ops to dev_pm_ops

Convert drivers/gpu/drm class to use dev_pm_ops for power management and
remove Legacy PM ops hooks. With this change, drm class registers
suspend/resume callbacks via class->pm (dev_pm_ops) instead of Legacy
class->suspend/resume. When __device_suspend() runs call-backs, it will
find class->pm ops for the drm class.

drm_class_suspend() hook calls driver legacy ops with the state information.
e.g: drm_class_suspend() calls into driver suspend routines
via drm_dev->driver->suspend(drm_dev, state).

Once drm_class_suspend() is converted to dev_pm_ops, it will no longer
have access to pm_transition which it has to pass into driver legacy
suspend calls. A new freeze and suspend hooks are added to address the not
having access to the state information. The new freeze and suspend hooks
simply call __drm_class_suspend() with the appropriate pm state information.
__drm_class_suspend() is the original suspend hook with a new name.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

Shuah Khan and committed by
Dave Airlie
cf4b91f2 d0aaa283

+29 -4
+29 -4
drivers/gpu/drm/drm_sysfs.c
··· 30 30 }; 31 31 32 32 /** 33 - * drm_class_suspend - DRM class suspend hook 33 + * __drm_class_suspend - internal DRM class suspend routine 34 34 * @dev: Linux device to suspend 35 35 * @state: power state to enter 36 36 * 37 37 * Just figures out what the actual struct drm_device associated with 38 38 * @dev is and calls its suspend hook, if present. 39 39 */ 40 - static int drm_class_suspend(struct device *dev, pm_message_t state) 40 + static int __drm_class_suspend(struct device *dev, pm_message_t state) 41 41 { 42 42 if (dev->type == &drm_sysfs_device_minor) { 43 43 struct drm_minor *drm_minor = to_drm_minor(dev); ··· 49 49 return drm_dev->driver->suspend(drm_dev, state); 50 50 } 51 51 return 0; 52 + } 53 + 54 + /** 55 + * drm_class_suspend - internal DRM class suspend hook. Simply calls 56 + * __drm_class_suspend() with the correct pm state. 57 + * @dev: Linux device to suspend 58 + */ 59 + static int drm_class_suspend(struct device *dev) 60 + { 61 + return __drm_class_suspend(dev, PMSG_SUSPEND); 62 + } 63 + 64 + /** 65 + * drm_class_freeze - internal DRM class freeze hook. Simply calls 66 + * __drm_class_suspend() with the correct pm state. 67 + * @dev: Linux device to freeze 68 + */ 69 + static int drm_class_freeze(struct device *dev) 70 + { 71 + return __drm_class_suspend(dev, PMSG_FREEZE); 52 72 } 53 73 54 74 /** ··· 91 71 } 92 72 return 0; 93 73 } 74 + 75 + static const struct dev_pm_ops drm_class_dev_pm_ops = { 76 + .suspend = drm_class_suspend, 77 + .resume = drm_class_resume, 78 + .freeze = drm_class_freeze, 79 + }; 94 80 95 81 static char *drm_devnode(struct device *dev, umode_t *mode) 96 82 { ··· 132 106 goto err_out; 133 107 } 134 108 135 - class->suspend = drm_class_suspend; 136 - class->resume = drm_class_resume; 109 + class->pm = &drm_class_dev_pm_ops; 137 110 138 111 err = class_create_file(class, &class_attr_version.attr); 139 112 if (err)