From: Mark Yao Date: Mon, 23 Jan 2017 08:20:08 +0000 (+0800) Subject: drm/rockchip: fix race with kms hotplug and fbdev X-Git-Tag: firefly_0821_release~685 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c73632c3549c9af75968876abac449bad7185045;p=firefly-linux-kernel-4.4.55.git drm/rockchip: fix race with kms hotplug and fbdev Kms hotplug event may race into fbdev helper initial, that would cause the bug: [ 0.735411] [00000200] *pgd=00000000f6ffe003, *pud=00000000f6ffe003, *pmd=0000000000000000 [ 0.736156] Internal error: Oops: 96000005 [#1] PREEMPT SMP [ 0.736648] Modules linked in: [ 0.736930] CPU: 2 PID: 20 Comm: kworker/2:0 Not tainted 4.4.41 #20 [ 0.737480] Hardware name: Rockchip RK3399 Board rev2 (BOX) (DT) [ 0.738020] Workqueue: events cdn_dp_pd_event_work [ 0.738447] task: ffffffc0f21f3100 ti: ffffffc0f2218000 task.ti: ffffffc0f2218000 [ 0.739109] PC is at mutex_lock+0x14/0x44 [ 0.739469] LR is at drm_fb_helper_hotplug_event+0x30/0x114 [ 0.756253] [] mutex_lock+0x14/0x44 [ 0.756260] [] drm_fb_helper_hotplug_event+0x30/0x114 [ 0.756271] [] rockchip_drm_output_poll_changed+0x18/0x20 [ 0.756280] [] drm_kms_helper_hotplug_event+0x28/0x34 [ 0.756286] [] cdn_dp_pd_event_work+0x394/0x3c4 [ 0.756295] [] process_one_work+0x218/0x3e0 [ 0.756302] [] worker_thread+0x2e8/0x404 [ 0.756308] [] kthread+0xe8/0xf0 [ 0.756316] [] ret_from_fork+0x10/0x40 Change-Id: I8d594183cf8187131418a0096dde840cbf01ed6b Signed-off-by: Mark Yao --- diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c index 6b50dfae4ad4..8c9fa5a7c9de 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c @@ -141,8 +141,6 @@ int rockchip_drm_fbdev_init(struct drm_device *dev) if (!helper) return -ENOMEM; - private->fbdev_helper = helper; - drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs); ret = drm_fb_helper_init(dev, helper, num_crtc, ROCKCHIP_MAX_CONNECTOR); @@ -165,6 +163,8 @@ int rockchip_drm_fbdev_init(struct drm_device *dev) goto err_drm_fb_helper_fini; } + private->fbdev_helper = helper; + return 0; err_drm_fb_helper_fini: