FROMLIST: drm/rockchip: cdn-dp: Do not run worker while suspended
authorGuenter Roeck <groeck@chromium.org>
Tue, 22 Nov 2016 20:50:07 +0000 (15:50 -0500)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 20 Dec 2016 11:58:04 +0000 (19:58 +0800)
If the driver is in suspended mode, the dp block may be disabled, and
chip registers may not be accessible. Yet, the worker may be triggered
in this situation by an extcon event. If that happens, the following crash
will be seen.

cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] *ERROR* Enable dp failed -19
cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Connected, not enabled. Enabling cdn
Bad mode in Error handler detected, code 0xbf000002 -- SError
CPU: 1 PID: 10357 Comm: kworker/1:2 Not tainted 4.4.21-05903-ge0514ea #1
Hardware name: Google Kevin (DT)
Workqueue: events cdn_dp_pd_event_work
task: ffffffc0cda67080 ti: ffffffc0b9b80000 task.ti: ffffffc0b9b80000
PC is at cdn_dp_clock_reset+0x30/0xa8
LR is at cdn_dp_enable+0x1e0/0x69c
...
Call trace:
[<ffffffc0005a7e24>] cdn_dp_pd_event_work+0x58/0x3f4
[<ffffffc0002397f0>] process_one_work+0x240/0x424
[<ffffffc00023a28c>] worker_thread+0x2fc/0x424
[<ffffffc00023f5fc>] kthread+0x10c/0x114
[<ffffffc000203dd0>] ret_from_fork+0x10/0x40

Problem is two-fold: The worker should not run while suspended, and the
suspend function should not call cdn_dp_disable() while the worker is
running.

Signed-off-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
(am from https://patchwork.kernel.org/patch/9442149)
Change-Id: Ic01c6f793281a47c36a90c1be34a5e479ebabb3e

drivers/gpu/drm/rockchip/cdn-dp-core.c
drivers/gpu/drm/rockchip/cdn-dp-core.h

index be86fd982b9308eee65e879ef2d87d3b9855d38a..316a7ca26b0a162f6577b86556fc4a999e22d3fc 100644 (file)
@@ -932,6 +932,10 @@ static void cdn_dp_pd_event_work(struct work_struct *work)
        u8 sink_count;
 
        mutex_lock(&dp->lock);
+
+       if (dp->suspended)
+               goto out;
+
        ret = cdn_dp_request_firmware(dp);
        if (ret)
                goto out;
@@ -1116,19 +1120,26 @@ static const struct component_ops cdn_dp_component_ops = {
 int cdn_dp_suspend(struct device *dev)
 {
        struct cdn_dp_device *dp = dev_get_drvdata(dev);
+       int ret = 0;
 
+       mutex_lock(&dp->lock);
        if (dp->active)
-               return cdn_dp_disable(dp);
+               ret = cdn_dp_disable(dp);
+       dp->suspended = true;
+       mutex_unlock(&dp->lock);
 
-       return 0;
+       return ret;
 }
 
 int cdn_dp_resume(struct device *dev)
 {
        struct cdn_dp_device *dp = dev_get_drvdata(dev);
 
+       mutex_lock(&dp->lock);
+       dp->suspended = false;
        if (dp->fw_loaded)
                schedule_work(&dp->event_work);
+       mutex_unlock(&dp->lock);
 
        return 0;
 }
index 3bea4b8d265ff3ac0bdd3fb52fbc4b355ea84fb6..7d48661362c8982f31666a459f801b2e4fb7d797 100644 (file)
@@ -82,6 +82,7 @@ struct cdn_dp_device {
        struct mutex lock;
        bool connected;
        bool active;
+       bool suspended;
 
        const struct firmware *fw;      /* cdn dp firmware */
        unsigned int fw_version;        /* cdn fw version */