From patchwork Sun Feb 5 07:54:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9555985 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 CAF47604DA for ; Sun, 5 Feb 2017 07:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAF8323E64 for ; Sun, 5 Feb 2017 07:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF90126CFF; Sun, 5 Feb 2017 07:57:17 +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=-1.4 required=2.0 tests=BAYES_00, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E73623E64 for ; Sun, 5 Feb 2017 07:57:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1caHhE-0004dp-Sx; Sun, 05 Feb 2017 07:57:16 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1caHgm-0003ug-MW; Sun, 05 Feb 2017 07:56:52 +0000 Received: by mail-pg0-f66.google.com with SMTP id 75so6099154pgf.3; Sat, 04 Feb 2017 23:56:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AXNC/Z7pZslC/R/u2tcT3rhnxa1i6pZ6bFdw4vWNQws=; b=uaqFcFU6YwyJS9tuYyHJ6BTL/oL8+ehYu97TGdKb8FKzOPoSgxILiJiYOqd7OHucgX 8hegadPKmA185Dy+2t+fjq0fMk7m50j4hzrralC8oMNg8m1hW6xLd01OS8oD6WxiFnco aeNdzcFSueiuAchVgcpT1Jaanc3cLcwYxd8JBv7LkBnW5bJbz1Etw0c72eYqoGT07MfA 7x4BudsTS++S5NP59SbobkaelFJuOGqgX7z20AP4TRppZG0ZCcic03dve5+ezv3e89rg IWq0MtC1WBs5IMB3AeGNMvoTuxTUhcrUMsaw9LcjU74vy5geh4DnC6TOSKTSNeziePxA qQOw== X-Gm-Message-State: AIkVDXI5sWiAhN7Zczndgx6lJNFwDXnrVRf+iUGUI2JztcmedT50+fvIApTVETAsqB/KXg== X-Received: by 10.84.142.101 with SMTP id 92mr8629229plw.66.1486281387893; Sat, 04 Feb 2017 23:56:27 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id o18sm80321582pgn.36.2017.02.04.23.56.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 04 Feb 2017 23:56:27 -0800 (PST) From: Chris Zhong To: dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org Subject: [PATCH v17 3/7] drm/rockchip: cdn-dp: Do not run worker while suspended Date: Sun, 5 Feb 2017 15:54:58 +0800 Message-Id: <1486281302-28200-4-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1486281302-28200-1-git-send-email-zyw@rock-chips.com> References: <1486281302-28200-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170204_235649_255315_E8ED22F3 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , David Airlie , linux-kernel@vger.kernel.org, zyw@rock-chips.com, seanpaul@chromium.org, groeck@chromium.org, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Guenter Roeck 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: [] cdn_dp_pd_event_work+0x58/0x3f4 [] process_one_work+0x240/0x424 [] worker_thread+0x2fc/0x424 [] kthread+0x10c/0x114 [] 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 Signed-off-by: Sean Paul Signed-off-by: Chris Zhong --- Changes in v17: None drivers/gpu/drm/rockchip/cdn-dp-core.c | 15 +++++++++++++-- drivers/gpu/drm/rockchip/cdn-dp-core.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c index b8d0dd7..a70eedc 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c @@ -939,6 +939,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; @@ -1123,19 +1127,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; } diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.h b/drivers/gpu/drm/rockchip/cdn-dp-core.h index 3bea4b8..7d48661 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.h +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.h @@ -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 */