Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp14636imu; Thu, 8 Nov 2018 13:57:42 -0800 (PST) X-Google-Smtp-Source: AJdET5cPkIj+H/bOILBRbWBk+wDC3sfXnX9yMjicXjuNz9/SqN2ZU/Ht/23akjXxBwEWth2zFSjX X-Received: by 2002:a63:fd53:: with SMTP id m19mr5296938pgj.340.1541714262362; Thu, 08 Nov 2018 13:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541714262; cv=none; d=google.com; s=arc-20160816; b=Df4u91UZAjVy2++ZntihERA/3vsW7UH3dqN7FgU1N6b2vyxDRbWzJvbIGoK3Zx8YQk cXbTy7+vrOUkH6S12Eop26eXsQSwijeVQB6aU0Y0tYUQ50pE2NqAQaDXxq6s1W2+K2Up w+8c1DiEFKOPGcSbBnJuyzPuQ2yKeQLJJg7QUiJejGwYRZOoL6MIpGiMBLAaeOR+BAuh kfeyKmAhuTjyDgFGczdEIsBly82W2b4Fx81KWcdquXId+2faLQ09GUnWQu63g2jttmVF VkyOjc/tgyyfbGWZt0jHnpp8mlswFnhUzoAjXovlLLCH1jfhGriL2SD5AXbMr7U1A2xe 2sTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A5vl8sIz9P9TdLRx8cEhBn/3velQ0lpJFuK8VGxsBxw=; b=MdTFI/1DN/sQvS1l/IpIZ0wLsnLBzPKDYUkhU8qdOP1YuvIrP+kKBm0CBTJ10FHJxJ vguVlwkEMhxQc9AHRpYzCoHoR/zVSrdxRyhty70hv+Wlb4XpQC3OGobVVJMZWAb9OVbh YsGhw7dGa1uwKC07isC2CmyP716JvLu0H8qMinIsrPTSsdm4rDcOygIITfxLYv3E5TPt xtg0F0wH8sdl7euqjwOYWwAg2dodr9+7z4sWPCxaUeq2KL4cpUTBlYDYbTBSst3IuL/b Ra2H8b33lwVxrsKxUG3vvRf2s6xQaX5pPrfOCMM9v51fVR40a2jX7m4i2IKXefxFnoQ4 C5Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ck8+O/DS"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si4743039pgk.405.2018.11.08.13.57.26; Thu, 08 Nov 2018 13:57:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Ck8+O/DS"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729099AbeKIHdo (ORCPT + 99 others); Fri, 9 Nov 2018 02:33:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:49744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729035AbeKIHdn (ORCPT ); Fri, 9 Nov 2018 02:33:43 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09EB921479; Thu, 8 Nov 2018 21:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714175; bh=jeSS1fh388oTuNBSX4IRZnmetc6p+5YOgSMUnQo90bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ck8+O/DSORx4LLXVRiqoAplF54WJwL0I/HpYFnd/cYDzo902Ym/GtzctC+a5WfZEL WRFDzBRPFHw7+GPZMCRY152gy2agEVusPMJwEUclAlM9mAEBtQoKhUjCPdNzyqzdyP Ih+yYsnZCE1SvJkwHGLqnNdsrJbSsGdmyconjSxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Stuebner , Doug Anderson , Michael Turquette , Sasha Levin Subject: [PATCH 3.18 080/144] clk: rockchip: fix deadlock possibility in cpuclk Date: Thu, 8 Nov 2018 13:50:51 -0800 Message-Id: <20181108215101.127234986@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit a5e1baf7dca10f8cf945394034013260297bc416 ] Lockdep reported a possible deadlock between the cpuclk lock and for example the i2c driver. CPU0 CPU1 ---- ---- lock(clk_lock); local_irq_disable(); lock(&(&i2c->lock)->rlock); lock(clk_lock); lock(&(&i2c->lock)->rlock); *** DEADLOCK *** The generic clock-types of the core ccf already use spin_lock_irqsave when touching clock registers, so do the same for the cpuclk. Signed-off-by: Heiko Stuebner Reviewed-by: Doug Anderson Signed-off-by: Michael Turquette [mturquette@linaro.org: removed initialization of "flags"] Signed-off-by: Sasha Levin --- drivers/clk/rockchip/clk-cpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c index 75c8c45ef728..8539c4fd34cc 100644 --- a/drivers/clk/rockchip/clk-cpu.c +++ b/drivers/clk/rockchip/clk-cpu.c @@ -124,10 +124,11 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk, { const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data; unsigned long alt_prate, alt_div; + unsigned long flags; alt_prate = clk_get_rate(cpuclk->alt_parent); - spin_lock(cpuclk->lock); + spin_lock_irqsave(cpuclk->lock, flags); /* * If the old parent clock speed is less than the clock speed @@ -164,7 +165,7 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk, cpuclk->reg_base + reg_data->core_reg); } - spin_unlock(cpuclk->lock); + spin_unlock_irqrestore(cpuclk->lock, flags); return 0; } @@ -173,6 +174,7 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk, { const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data; const struct rockchip_cpuclk_rate_table *rate; + unsigned long flags; rate = rockchip_get_cpuclk_settings(cpuclk, ndata->new_rate); if (!rate) { @@ -181,7 +183,7 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk, return -EINVAL; } - spin_lock(cpuclk->lock); + spin_lock_irqsave(cpuclk->lock, flags); if (ndata->old_rate < ndata->new_rate) rockchip_cpuclk_set_dividers(cpuclk, rate); @@ -201,7 +203,7 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk, if (ndata->old_rate > ndata->new_rate) rockchip_cpuclk_set_dividers(cpuclk, rate); - spin_unlock(cpuclk->lock); + spin_unlock_irqrestore(cpuclk->lock, flags); return 0; } -- 2.17.1