From: Mark Yao Date: Wed, 12 Oct 2016 10:03:08 +0000 (+0800) Subject: FROMLIST: drm/bridge: analogix: protect power when get_modes or detect X-Git-Tag: firefly_0821_release~1420 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=22e5631e6317f91a286be17d940efbb2563171f4;p=firefly-linux-kernel-4.4.55.git FROMLIST: drm/bridge: analogix: protect power when get_modes or detect 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 Change-Id: Ica3fda1f22f903ee9ba2f0caed40cdae9bdfa32b Signed-off-by: Mark Yao (am from https://patchwork.kernel.org/patch/9374135) --- diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index 01afc8a0da63..5216d0496b0d 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -929,6 +929,8 @@ int analogix_dp_get_modes(struct drm_connector *connector) struct edid *edid = (struct edid *)dp->edid; int num_modes = 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); @@ -940,6 +942,8 @@ int analogix_dp_get_modes(struct drm_connector *connector) if (dp->plat_data->get_modes) num_modes += dp->plat_data->get_modes(dp->plat_data, connector); + pm_runtime_put(dp->dev); + return num_modes; } @@ -960,11 +964,16 @@ enum drm_connector_status analogix_dp_detect(struct drm_connector *connector, bool force) { struct analogix_dp_device *dp = to_dp(connector); + enum drm_connector_status status = connector_status_connected; + + pm_runtime_get_sync(dp->dev); if (analogix_dp_detect_hpd(dp)) - return connector_status_disconnected; + status = connector_status_disconnected; + + pm_runtime_put(dp->dev); - return connector_status_connected; + return status; } static void analogix_dp_connector_destroy(struct drm_connector *connector)