lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1475239256-16083-2-git-send-email-wzz@rock-chips.com>
Date:   Fri, 30 Sep 2016 20:40:53 +0800
From:   zain wang <wzz@...k-chips.com>
To:     Sean Paul <seanpaul@...omium.org>,
        Daniel Vetter <daniel.vetter@...ll.ch>,
        Inki Dae <inki.dae@...sung.com>,
        David Airlie <airlied@...ux.ie>
Cc:     Tomeu Vizoso <tomeu.vizoso@...labora.com>,
        Mika Kahola <mika.kahola@...el.com>,
        Stéphane Marchesin <marcheu@...omium.org>,
        Tomasz Figa <tfiga@...omium.org>, dianders@...omium.org,
        Thierry Reding <treding@...dia.com>,
        Krzysztof Kozlowski <k.kozlowski@...sung.com>,
        Heiko Stuebner <heiko@...ech.de>,
        Jingoo Han <jingoohan1@...il.com>,
        Javier Martinez Canillas <javier@....samsung.com>,
        linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
        linux-samsung-soc@...r.kernel.org,
        linux-rockchip@...ts.infradead.org, zain wang <wzz@...k-chips.com>
Subject: [PATCH v2 1/4] drm/bridge: analogix_dp: prevent runing enable_psr when disabled bridge.

When disabled bridge, analogix_dp_enable_psr() may run due to timer was set
by rockchip_drm_do_flush(), in this case we should return -EBUSY.

Signed-off-by: zain wang <wzz@...k-chips.com>

---

Changes in v2:
- add spin_lock to protect dpms_mode

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 43 +++++++++++++++++++---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.h |  1 +
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 0f2e423..b4ce16a 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -98,6 +98,29 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
 	return 0;
 }
 
+static void analogix_dp_set_dpms_mode(struct analogix_dp_device *dp, int mode)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&dp->dpms_mode_lock, flags);
+	dp->dpms_mode = mode;
+	spin_unlock_irqrestore(&dp->dpms_mode_lock, flags);
+
+}
+
+static int analogix_dp_get_dpms_mode(struct analogix_dp_device *dp)
+{
+	unsigned long flags;
+	int mode;
+
+	spin_lock_irqsave(&dp->dpms_mode_lock, flags);
+	mode = dp->dpms_mode;
+	spin_unlock_irqrestore(&dp->dpms_mode_lock, flags);
+
+	return mode;
+}
+
+
 int analogix_dp_enable_psr(struct device *dev)
 {
 	struct analogix_dp_device *dp = dev_get_drvdata(dev);
@@ -106,6 +129,9 @@ int analogix_dp_enable_psr(struct device *dev)
 	if (!dp->psr_support)
 		return -EINVAL;
 
+	if (analogix_dp_get_dpms_mode(dp) != DRM_MODE_DPMS_ON)
+		return -EBUSY;
+
 	/* Prepare VSC packet as per EDP 1.4 spec, Table 6.9 */
 	memset(&psr_vsc, 0, sizeof(psr_vsc));
 	psr_vsc.sdp_header.HB0 = 0;
@@ -129,6 +155,9 @@ int analogix_dp_disable_psr(struct device *dev)
 	if (!dp->psr_support)
 		return -EINVAL;
 
+	if (analogix_dp_get_dpms_mode(dp) != DRM_MODE_DPMS_ON)
+		return -EBUSY;
+
 	/* Prepare VSC packet as per EDP 1.4 spec, Table 6.9 */
 	memset(&psr_vsc, 0, sizeof(psr_vsc));
 	psr_vsc.sdp_header.HB0 = 0;
@@ -1073,7 +1102,7 @@ static void analogix_dp_bridge_enable(struct drm_bridge *bridge)
 {
 	struct analogix_dp_device *dp = bridge->driver_private;
 
-	if (dp->dpms_mode == DRM_MODE_DPMS_ON)
+	if (analogix_dp_get_dpms_mode(dp) == DRM_MODE_DPMS_ON)
 		return;
 
 	pm_runtime_get_sync(dp->dev);
@@ -1086,7 +1115,7 @@ static void analogix_dp_bridge_enable(struct drm_bridge *bridge)
 	enable_irq(dp->irq);
 	analogix_dp_commit(dp);
 
-	dp->dpms_mode = DRM_MODE_DPMS_ON;
+	analogix_dp_set_dpms_mode(dp, DRM_MODE_DPMS_ON);
 }
 
 static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
@@ -1094,9 +1123,11 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
 	struct analogix_dp_device *dp = bridge->driver_private;
 	int ret;
 
-	if (dp->dpms_mode != DRM_MODE_DPMS_ON)
+	if (analogix_dp_get_dpms_mode(dp) != DRM_MODE_DPMS_ON)
 		return;
 
+	analogix_dp_set_dpms_mode(dp, DRM_MODE_DPMS_OFF);
+
 	if (dp->plat_data->panel) {
 		if (drm_panel_disable(dp->plat_data->panel)) {
 			DRM_ERROR("failed to disable the panel\n");
@@ -1115,8 +1146,6 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
 	ret = analogix_dp_prepare_panel(dp, false, true);
 	if (ret)
 		DRM_ERROR("failed to setup the panel ret = %d\n", ret);
-
-	dp->dpms_mode = DRM_MODE_DPMS_OFF;
 }
 
 static void analogix_dp_bridge_mode_set(struct drm_bridge *bridge,
@@ -1299,7 +1328,9 @@ int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
 	dev_set_drvdata(dev, dp);
 
 	dp->dev = &pdev->dev;
-	dp->dpms_mode = DRM_MODE_DPMS_OFF;
+
+	spin_lock_init(&dp->dpms_mode_lock);
+	analogix_dp_set_dpms_mode(dp, DRM_MODE_DPMS_OFF);
 
 	mutex_init(&dp->panel_lock);
 	dp->panel_is_modeset = false;
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index 5c6a288..776c844 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -166,6 +166,7 @@ struct analogix_dp_device {
 	struct link_train	link_train;
 	struct phy		*phy;
 	int			dpms_mode;
+	spinlock_t		dpms_mode_lock;
 	int			hpd_gpio;
 	bool                    force_hpd;
 	bool			psr_support;
-- 
1.9.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ