Index: drmP.h =================================================================== RCS file: /home/ncvs/src/sys/dev/drm/drmP.h,v retrieving revision 1.47.2.1 diff -u -r1.47.2.1 drmP.h --- drmP.h 23 Sep 2011 00:51:37 -0000 1.47.2.1 +++ drmP.h 22 Jun 2012 22:23:29 -0000 @@ -731,7 +731,8 @@ d_poll_t drm_poll; d_mmap_t drm_mmap; extern drm_local_map_t *drm_getsarea(struct drm_device *dev); - +extern struct drm_file *drm_find_file_by_proc(struct drm_device *dev, + DRM_STRUCTPROC *p); /* File operations helpers (drm_fops.c) */ extern int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, Index: drm_fops.c =================================================================== RCS file: /home/ncvs/src/sys/dev/drm/drm_fops.c,v retrieving revision 1.8.2.1 diff -u -r1.8.2.1 drm_fops.c --- drm_fops.c 23 Sep 2011 00:51:37 -0000 1.8.2.1 +++ drm_fops.c 22 Jun 2012 22:22:10 -0000 @@ -39,6 +39,23 @@ #include "dev/drm/drmP.h" +struct drm_file * +drm_find_file_by_proc(struct drm_device *dev, DRM_STRUCTPROC *p) +{ + uid_t uid = p->td_ucred->cr_svuid; + pid_t pid = p->td_proc->p_pid; + struct drm_file *priv; + + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + + TAILQ_FOREACH(priv, &dev->files, link) { + if (priv->pid == pid && priv->uid == uid) + return priv; + } + + return NULL; +} + /* drm_open_helper is called whenever a process opens /dev/drm. */ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, struct drm_device *dev) Index: radeon_drv.c =================================================================== RCS file: /home/ncvs/src/sys/dev/drm/radeon_drv.c,v retrieving revision 1.20.4.1 diff -u -r1.20.4.1 radeon_drv.c --- radeon_drv.c 23 Sep 2011 00:51:37 -0000 1.20.4.1 +++ radeon_drv.c 22 Jun 2012 22:34:07 -0000 @@ -99,6 +99,36 @@ } static int +radeon_suspend(device_t kdev) +{ + struct drm_device *dev = device_get_softc(kdev); + drm_radeon_cp_stop_t stop_args; + + stop_args.flush = stop_args.idle = 0; + DRM_LOCK(); + if (drm_find_file_by_proc(dev, DRM_CURPROC) && + radeon_cp_stop(dev, &stop_args, dev->lock.file_priv) != 0) + return (EBUSY); + DRM_UNLOCK(); + + return (bus_generic_suspend(kdev)); +} + +static int +radeon_resume(device_t kdev) +{ + struct drm_device *dev = device_get_softc(kdev); + + DRM_LOCK(); + if (drm_find_file_by_proc(dev, DRM_CURPROC) && + radeon_cp_resume(dev, NULL, NULL) != 0) + return (EBUSY); + DRM_UNLOCK(); + + return (bus_generic_resume(kdev)); +} + +static int radeon_detach(device_t kdev) { struct drm_device *dev = device_get_softc(kdev); @@ -115,6 +145,8 @@ /* Device interface */ DEVMETHOD(device_probe, radeon_probe), DEVMETHOD(device_attach, radeon_attach), + DEVMETHOD(device_suspend, radeon_suspend), + DEVMETHOD(device_resume, radeon_resume), DEVMETHOD(device_detach, radeon_detach), { 0, 0 }