From patchwork Mon Jul 31 09:50:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yao mark X-Patchwork-Id: 9871359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECD9A603B4 for ; Mon, 31 Jul 2017 09:50:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E075928516 for ; Mon, 31 Jul 2017 09:50:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D598328533; Mon, 31 Jul 2017 09:50:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3F43F2852D for ; Mon, 31 Jul 2017 09:50:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9608D6E5B7; Mon, 31 Jul 2017 09:50:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.135]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01AAC6E5B7 for ; Mon, 31 Jul 2017 09:50:08 +0000 (UTC) Received: from mark.yao?rock-chips.com (unknown [192.168.167.232]) by regular1.263xmail.com (Postfix) with ESMTP id E34051DE86; Mon, 31 Jul 2017 17:50:04 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from yaozq-pc.lan (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id E37FC3AA; Mon, 31 Jul 2017 17:50:03 +0800 (CST) X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: mark.yao@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: <5ddb67ae24b45b171782f372a447eea3> X-ATTACHMENT-NUM: 0 X-SENDER: yzq@rock-chips.com X-DNS-TYPE: 0 Received: from yaozq-pc.lan (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 24966RE0M6I; Mon, 31 Jul 2017 17:50:06 +0800 (CST) From: Mark Yao To: Mark Yao , David Airlie , Heiko Stuebner Subject: [PATCH 6/6] drm/rockchip: fix race with kms hotplug and fbdev Date: Mon, 31 Jul 2017 17:50:00 +0800 Message-Id: <1501494601-7140-1-git-send-email-mark.yao@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501494569-6825-1-git-send-email-mark.yao@rock-chips.com> References: <1501494569-6825-1-git-send-email-mark.yao@rock-chips.com> Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since fb_helper is not a pointer on rockchip_drm_private, it's no need to check pointer. Kms hotplug event may race into fbdev helper initial, and fb_helper->dev may be NULL pointer, 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 Signed-off-by: Mark Yao --- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index 81f9548..e6bd0f4 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -170,7 +170,7 @@ static void rockchip_drm_output_poll_changed(struct drm_device *dev) struct rockchip_drm_private *private = dev->dev_private; struct drm_fb_helper *fb_helper = &private->fbdev_helper; - if (fb_helper) + if (fb_helper->dev) drm_fb_helper_hotplug_event(fb_helper); }