1 From 2a596fc9d974bb040eda9ab70bf8756fcaaa6afe Mon Sep 17 00:00:00 2001
2 From: Jonathan Liu <net147@gmail.com>
3 Date: Mon, 10 Jul 2017 16:55:04 +1000
4 Subject: drm/sun4i: Implement drm_driver lastclose to restore fbdev console
6 From: Jonathan Liu <net147@gmail.com>
8 commit 2a596fc9d974bb040eda9ab70bf8756fcaaa6afe upstream.
10 The drm_driver lastclose callback is called when the last userspace
11 DRM client has closed. Call drm_fbdev_cma_restore_mode to restore
12 the fbdev console otherwise the fbdev console will stop working.
14 Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
15 Tested-by: Olliver Schinagl <oliver@schinagl.nl>
16 Reviewed-by: Chen-Yu Tsai <wens@csie.org>
17 Signed-off-by: Jonathan Liu <net147@gmail.com>
18 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
19 [net147@gmail.com: Backport to 4.9, minor context change]
20 Signed-off-by: Jonathan Liu <net147@gmail.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 drivers/gpu/drm/sun4i/sun4i_drv.c | 8 ++++++++
26 1 file changed, 8 insertions(+)
28 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
29 +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
30 @@ -47,6 +47,13 @@ static void sun4i_drv_disable_vblank(str
31 sun4i_tcon_enable_vblank(tcon, false);
34 +static void sun4i_drv_lastclose(struct drm_device *dev)
36 + struct sun4i_drv *drv = dev->dev_private;
38 + drm_fbdev_cma_restore_mode(drv->fbdev);
41 static const struct file_operations sun4i_drv_fops = {
44 @@ -65,6 +72,7 @@ static struct drm_driver sun4i_drv_drive
45 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
47 /* Generic Operations */
48 + .lastclose = sun4i_drv_lastclose,
49 .fops = &sun4i_drv_fops,
51 .desc = "Allwinner sun4i Display Engine",