]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/nouveau: punt fbcon resume out to a workqueue
authorBen Skeggs <bskeggs@redhat.com>
Wed, 1 Oct 2014 01:11:25 +0000 (11:11 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 2 Oct 2014 03:32:24 +0000 (13:32 +1000)
Preparation for some runtime pm fixes.  Currently we skip over fbcon
suspend/resume in the runtime path, which causes issues on resume if
fbcon tries to write to the framebuffer before the BAR subdev has
been resumed to restore the BAR1 VM setup.

As we might be woken up via a sysfs connector, we are unable to call
fb_set_suspend() in the resume path as it could make its way down to
a modeset and cause all sorts of locking hilarity.

To solve this, we'll just delay the fbcon resume to a workqueue.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_fbcon.c
drivers/gpu/drm/nouveau/nouveau_fbcon.h

index 8bdd27091db8fd1aa7a34a3174b625c6a6d2a830..49fe6075cc7c50c79d47d2ac24c273e536ac3159 100644 (file)
@@ -486,6 +486,16 @@ static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
        .fb_probe = nouveau_fbcon_create,
 };
 
+static void
+nouveau_fbcon_set_suspend_work(struct work_struct *work)
+{
+       struct nouveau_fbdev *fbcon = container_of(work, typeof(*fbcon), work);
+       console_lock();
+       nouveau_fbcon_accel_restore(fbcon->dev);
+       nouveau_fbcon_zfill(fbcon->dev, fbcon);
+       fb_set_suspend(fbcon->helper.fbdev, FBINFO_STATE_RUNNING);
+       console_unlock();
+}
 
 int
 nouveau_fbcon_init(struct drm_device *dev)
@@ -503,6 +513,7 @@ nouveau_fbcon_init(struct drm_device *dev)
        if (!fbcon)
                return -ENOMEM;
 
+       INIT_WORK(&fbcon->work, nouveau_fbcon_set_suspend_work);
        fbcon->dev = dev;
        drm->fbcon = fbcon;
 
@@ -551,14 +562,14 @@ nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
 {
        struct nouveau_drm *drm = nouveau_drm(dev);
        if (drm->fbcon) {
-               console_lock();
-               if (state == 0) {
-                       nouveau_fbcon_accel_restore(dev);
-                       nouveau_fbcon_zfill(dev, drm->fbcon);
+               if (state == FBINFO_STATE_RUNNING) {
+                       schedule_work(&drm->fbcon->work);
+                       return;
                }
+               flush_work(&drm->fbcon->work);
+               console_lock();
                fb_set_suspend(drm->fbcon->helper.fbdev, state);
-               if (state == 1)
-                       nouveau_fbcon_accel_save_disable(dev);
+               nouveau_fbcon_accel_save_disable(dev);
                console_unlock();
        }
 }
index 34658cfa8f5d4219c6bbc86bc04abf165271e9bd..0b465c7d3907cb1a07667b667032dbe3b052c71b 100644 (file)
@@ -36,6 +36,7 @@ struct nouveau_fbdev {
        struct nouveau_framebuffer nouveau_fb;
        struct list_head fbdev_list;
        struct drm_device *dev;
+       struct work_struct work;
        unsigned int saved_flags;
        struct nvif_object surf2d;
        struct nvif_object clip;