From patchwork Tue Nov 22 20:50:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9442139 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 1BBF360235 for ; Tue, 22 Nov 2016 20:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC2D1FEC1 for ; Tue, 22 Nov 2016 20:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00BE71FF60; Tue, 22 Nov 2016 20:51:20 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6ABA01FEC1 for ; Tue, 22 Nov 2016 20:51:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F40D899B7; Tue, 22 Nov 2016 20:51:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x22d.google.com (mail-qk0-x22d.google.com [IPv6:2607:f8b0:400d:c09::22d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3BEC96E68A for ; Tue, 22 Nov 2016 20:51:17 +0000 (UTC) Received: by mail-qk0-x22d.google.com with SMTP id n21so42538982qka.3 for ; Tue, 22 Nov 2016 12:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KWfBCMI5XMR8YCnUSZLF3TnZ0nIlZE0w8TjpzKnF9Ec=; b=USfklb+4VME24JyMDSHbsJfOaCI9ux3JKreI494QDPcHHidwIm8bE76AY5pZfnJEOZ FhrHxH+gSdkwOKrHxTxG2KI3OfR9jrth3ZPHGZwgPghOpkJ/kzfOh/Nnpw7gRgWH+27t GZXn6eKSI1V0V2GtjZgCMTFai0xF8LmFysiGQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KWfBCMI5XMR8YCnUSZLF3TnZ0nIlZE0w8TjpzKnF9Ec=; b=XJdOXIw5RHVdkpXX5InI1aZ1UsBw7HXKjTHqdk6j1EtyeiIVOwzDJqWNroYZpB07xX qSWsPFs32kBAkzRxixZ5k4HucUuV4C4L5WZ4dWIiD2kbyHf6jlDuye35q8bycIUKFPhQ DiyICKaipVWlwEX3fi+WGGp00r8naZ4Ijc+gIoEOtQRxOB4LoBZp3aq2U6EdYO+fdZi5 BCNqdxVfm77ASgq0xtCjwllCDi+IGyvsK+Xar4UWJKdq8nzUa+5CHu3vWPfT4gnTK20q 47gRkw2IufWvx4SZZfOgVg0gL2VEcc4UP77z7iNwRqF10jEKkRhrpIeYCkeizFv2FoWg 3zCA== X-Gm-Message-State: AKaTC01P2UHxeFl3BPOlkMasqRBis3lTUjbHytcMUxHBIIUTkRL/DcLSi9dC7TQgS/M4IHvo X-Received: by 10.55.154.205 with SMTP id c196mr22920330qke.25.1479847876283; Tue, 22 Nov 2016 12:51:16 -0800 (PST) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id r8sm14618010qtc.32.2016.11.22.12.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 12:51:15 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org Subject: [PATCH 3/3] drm/rockchip: cdn-dp: Do not run worker while suspended Date: Tue, 22 Nov 2016 15:50:07 -0500 Message-Id: <1479847815-30750-4-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1479847815-30750-1-git-send-email-seanpaul@chromium.org> References: <1479847815-30750-1-git-send-email-seanpaul@chromium.org> Cc: zyw@rock-chips.com, groeck@chromium.org, linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 f78cdaf..adc4235 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 */