From patchwork Wed Oct 4 17:53:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 9985237 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 3D40B602B8 for ; Wed, 4 Oct 2017 17:54:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27A07287CF for ; Wed, 4 Oct 2017 17:54:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1967728B75; Wed, 4 Oct 2017 17:54: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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham 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 517A0287CF for ; Wed, 4 Oct 2017 17:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=fcFsOV5AXeVp27FLLMigjo4NqoYESOszJBTtDEnNgCI=; b=lch Avu945gXGOr5vmQOlpEGrsAPRX9SHQpQKEhMxaGzrkZokLcY6QXai7J/p9ckCcPnfNr3gCUlPOXAC qU2L1gq7Fhj+lw43Gd4QFYoXN8zmm6eAQHulCyPYuhqAypNSUUxr2KE3vGNsxigyR95DdtqJWlkR7 d7Zh2htnsWYwLwCv6T5sMpQVXP/EB7j/+ZWuLRoos9JIJk3AfaYP5PmvhUZ3pUMDluFIEbptJ+8d8 uCQ9IqE7DOh3v3q90Isa9Ob2W29HNp2lS5dE2kV4Pk/FTqOixwhCI0G3LnrnMYjtJKUHuXdnXk+qh fYeajnLUSwx7TA2Kj6fBOXwmC5Xn6jQ==; 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 1dznsA-0005Oi-8w; Wed, 04 Oct 2017 17:54:18 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzns6-0005Mc-LG for linux-rockchip@lists.infradead.org; Wed, 04 Oct 2017 17:54:16 +0000 Received: by mail-lf0-x242.google.com with SMTP id m199so14297179lfe.3 for ; Wed, 04 Oct 2017 10:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=wE9w5w8Xi3byJPOoUXQs3AOPPeByD3LDJNX2IV/MgAQ=; b=X4v1Io4UpVAsTW0zTSrLChRU5nxItoFBvvhKmcrWULuUIyqLfevjJcocbY8+ath4wg mlDTme+V7Pj9wpBDcvBWuanhiqLHn45R3iEjeVA8/6dzdFNwwz7U/1KbKp/qf9m3Q217 bfTsVhBmw3LAa+RAg6OrzLuIMI0c/tKt7y7/Hbln+6AsbHQl4fU1usAgwdNoWe6jgyTk gSxC+A00uh4uCqG4Znbq4E1J2GKDwBdwigW97YTV+kCCJQpJdG2Wh2fDfJlmcms12Ap/ 1/HgYwE93QqHselIM97NvG1w5N5F+ivO1NuUf+8PXzmVmtzCI8Ia8wxluL05E7lBf9HF sR+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=wE9w5w8Xi3byJPOoUXQs3AOPPeByD3LDJNX2IV/MgAQ=; b=b01PLx/q5gc2yi4XFkf3fQ6iueld/J6+behjmKv+ZAu4Ub9SLF0bj0KSQsGT1EhIVf GndixboXBPEVR613tJeUbVrGrA6dTMl8aJncqOdIi1J39JfzQugyoB5AvURaIcNH0FKZ OjdU4xvqIHX77KMVtp+PbasdIs4RAypm0joqsNrMaUwqa9obS6BZSBI0++pVJ2O92M+W TDRLt6oTPyC5XaaJZKPTFU1rhEcEAQ9qdjRnWv1LjRx0WzOpnoHE4Usk8Rr9t8/CZyj0 P1SOJPvRVm1UqQ6qHxHm1yoh5yi8vghY/r8v6bJR4BncHFf/I/T/EMwyS8f81FsKngcH zEHQ== X-Gm-Message-State: AMCzsaXPyAP7OFEgs69FK9BAdPzcTBMSPv61SQ8Sjxu5mkCkHro6Nr3u s16DC80oOyMNcHrDZUYv218= X-Google-Smtp-Source: AOwi7QDPMNK2H7RmwYy1h8y446+GyGo6tRjlBxIH9NsekXtn+X+VihRd7RnLKObMzPB2kl+J7Ikuyw== X-Received: by 10.25.242.65 with SMTP id d1mr3431626lfk.82.1507139632451; Wed, 04 Oct 2017 10:53:52 -0700 (PDT) Received: from localhost.localdomain (0173002341.0.fullrate.ninja. [90.184.117.6]) by smtp.gmail.com with ESMTPSA id r2sm3551089lja.32.2017.10.04.10.53.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 10:53:51 -0700 (PDT) From: Emil Renner Berthing To: Mark Yao Subject: [PATCH] drm/rockchip: analogix_dp: Use mutex rather than spinlock Date: Wed, 4 Oct 2017 19:53:46 +0200 Message-Id: <20171004175346.11956-1-kernel@esmil.dk> X-Mailer: git-send-email 2.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171004_105414_892056_078D1CA8 X-CRM114-Status: GOOD ( 10.65 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, Emil Renner Berthing , Heiko Stuebner , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On the Samsung Chromebook Plus I get this error with 4.14-rc3: BUG: scheduling while atomic: kworker/3:1/50/0x00000002 Modules linked in: CPU: 3 PID: 50 Comm: kworker/3:1 Not tainted 4.14.0-0.rc3-kevin #2 Hardware name: Google Kevin (DT) Workqueue: events analogix_dp_psr_work Call trace: [] dump_backtrace+0x0/0x320 [] show_stack+0x14/0x20 [] dump_stack+0x9c/0xbc [] __schedule_bug+0x4c/0x70 [] __schedule+0x3f0/0x458 [] schedule+0x38/0xa0 [] schedule_hrtimeout_range_clock+0x84/0xe8 [] schedule_hrtimeout_range+0x10/0x18 [] usleep_range+0x64/0x78 [] analogix_dp_transfer+0x16c/0x340 [] analogix_dpaux_transfer+0x10/0x18 [] drm_dp_dpcd_access+0x4c/0xf0 [] drm_dp_dpcd_write+0x1c/0x28 [] analogix_dp_disable_psr+0x60/0xa8 [] analogix_dp_psr_work+0x4c/0x90 [] process_one_work+0x1d4/0x348 [] worker_thread+0x48/0x478 [] kthread+0x12c/0x130 [] ret_from_fork+0x10/0x18 Changing rockchip_dp_device::psr_lock to a mutex rather than spinlock seems to fix the issue. Signed-off-by: Emil Renner Berthing Tested-by: Enric Balletbo i Serra --- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index 9606121fa185..d8f72d87ef08 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -72,7 +72,7 @@ struct rockchip_dp_device { struct reset_control *rst; struct work_struct psr_work; - spinlock_t psr_lock; + struct mutex psr_lock; unsigned int psr_state; const struct rockchip_dp_chip_data *data; @@ -83,21 +83,20 @@ struct rockchip_dp_device { static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) { struct rockchip_dp_device *dp = to_dp(encoder); - unsigned long flags; if (!analogix_dp_psr_supported(dp->dev)) return; dev_dbg(dp->dev, "%s PSR...\n", enabled ? "Entry" : "Exit"); - spin_lock_irqsave(&dp->psr_lock, flags); + mutex_lock(&dp->psr_lock); if (enabled) dp->psr_state = EDP_VSC_PSR_STATE_ACTIVE; else dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE; schedule_work(&dp->psr_work); - spin_unlock_irqrestore(&dp->psr_lock, flags); + mutex_unlock(&dp->psr_lock); } static void analogix_dp_psr_work(struct work_struct *work) @@ -105,7 +104,6 @@ static void analogix_dp_psr_work(struct work_struct *work) struct rockchip_dp_device *dp = container_of(work, typeof(*dp), psr_work); int ret; - unsigned long flags; ret = rockchip_drm_wait_vact_end(dp->encoder.crtc, PSR_WAIT_LINE_FLAG_TIMEOUT_MS); @@ -114,12 +112,12 @@ static void analogix_dp_psr_work(struct work_struct *work) return; } - spin_lock_irqsave(&dp->psr_lock, flags); + mutex_lock(&dp->psr_lock); if (dp->psr_state == EDP_VSC_PSR_STATE_ACTIVE) analogix_dp_enable_psr(dp->dev); else analogix_dp_disable_psr(dp->dev); - spin_unlock_irqrestore(&dp->psr_lock, flags); + mutex_unlock(&dp->psr_lock); } static int rockchip_dp_pre_init(struct rockchip_dp_device *dp) @@ -381,7 +379,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, dp->plat_data.power_off = rockchip_dp_powerdown; dp->plat_data.get_modes = rockchip_dp_get_modes; - spin_lock_init(&dp->psr_lock); + mutex_init(&dp->psr_lock); dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE; INIT_WORK(&dp->psr_work, analogix_dp_psr_work);