From patchwork Thu Oct 13 01:50:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: yao mark X-Patchwork-Id: 9374135 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 0140A60839 for ; Thu, 13 Oct 2016 01:51:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7205297BD for ; Thu, 13 Oct 2016 01:51:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7319297CF; Thu, 13 Oct 2016 01:51:37 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E8D4297BD for ; Thu, 13 Oct 2016 01:51:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1buVBH-0007Lb-Tl; Thu, 13 Oct 2016 01:51:35 +0000 Received: from regular1.263xmail.com ([211.150.99.136]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1buVAz-0007Iw-E7; Thu, 13 Oct 2016 01:51:18 +0000 Received: from mark.yao?rock-chips.com (unknown [192.168.167.172]) by regular1.263xmail.com (Postfix) with ESMTP id E4CB491; Thu, 13 Oct 2016 09:50:50 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED4: 1 Received: from yaozq-pc.lan (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id F3A5C308; Thu, 13 Oct 2016 09:50:45 +0800 (CST) X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: airlied@linux.ie X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: <2fc572b650339980606d1786a6a46c95> 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 17088G69Q91; Thu, 13 Oct 2016 09:50:49 +0800 (CST) From: Mark Yao To: David Airlie , Heiko Stuebner , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/bridge: analogix: protect power when get_modes or detect Date: Thu, 13 Oct 2016 09:50:38 +0800 Message-Id: <1476323438-8435-1-git-send-email-mark.yao@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476266442-29803-1-git-send-email-mark.yao@rock-chips.com> References: <1476266442-29803-1-git-send-email-mark.yao@rock-chips.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161012_185118_000954_768C690D X-CRM114-Status: UNSURE ( 7.39 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Inki Dae , Gustavo Padovan , Sean Paul , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Mark Yao Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The drm callback ->detect and ->get_modes seems is not power safe, they may be called when device is power off, do register access on detect or get_modes will cause system die. Here is the path call ->detect before analogix_dp power on [] analogix_dp_detect+0x44/0xdc [] drm_helper_probe_single_connector_modes_merge_bits+0xe8/0x41c [] drm_helper_probe_single_connector_modes+0x10/0x18 [] drm_mode_getconnector+0xf4/0x304 [] drm_ioctl+0x23c/0x390 [] do_vfs_ioctl+0x4b8/0x58c [] SyS_ioctl+0x60/0x88 Cc: Inki Dae Cc: Sean Paul Cc: Gustavo Padovan Cc: "Ville Syrjälä" Signed-off-by: Mark Yao Reviewed-by: Sean Paul --- Changes in v2: - remove sub device power on/off callback, use pm_runtime_get/put is enough to fix my problem, so will can avoid race to dpms. drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index efac8ab..ff2d328 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1062,11 +1062,15 @@ int analogix_dp_get_modes(struct drm_connector *connector) return 0; } + pm_runtime_get_sync(dp->dev); + if (analogix_dp_handle_edid(dp) == 0) { drm_mode_connector_update_edid_property(&dp->connector, edid); num_modes += drm_add_edid_modes(&dp->connector, edid); } + pm_runtime_put(dp->dev); + if (dp->plat_data->panel) num_modes += drm_panel_get_modes(dp->plat_data->panel); @@ -1106,9 +1110,13 @@ analogix_dp_detect(struct drm_connector *connector, bool force) return connector_status_disconnected; } + pm_runtime_get_sync(dp->dev); + if (!analogix_dp_detect_hpd(dp)) status = connector_status_connected; + pm_runtime_put(dp->dev); + ret = analogix_dp_prepare_panel(dp, false, false); if (ret) DRM_ERROR("Failed to unprepare panel (%d)\n", ret);