[v2,3/4] spi: cadence-qspi: remove system-wide suspend helper calls from runtime PM hooks
Message ID | 20240205-cdns-qspi-pm-fix-v2-3-2e7bbad49a46@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-52863-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp927666dyb; Mon, 5 Feb 2024 06:59:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEh1HyYKWkhmcvLU4YDLLyjgCJNXFUhumpb/JmaxkiPnkgclVKCRsThBAsc00nPJwNPoWZS X-Received: by 2002:ac8:782:0:b0:42c:26d0:bb2c with SMTP id l2-20020ac80782000000b0042c26d0bb2cmr2225508qth.63.1707145174969; Mon, 05 Feb 2024 06:59:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707145174; cv=pass; d=google.com; s=arc-20160816; b=xSp9bv7VxqJju4hUBC5OGWd7QhbYtNrcgWuKF3l9IAfbfRqpVq5wDUIZ3Xi7XVB6W1 6b56dK9+rNjCSFuQy1tSMRWu2yE+9Ve+jeqhf2KIsL/lj6H/bnNMqKgJEJj9vzOgwLtm fH+ZwWy5AAUM+FMdlas2oSs0AYHjgaQF70G/vVeZEwho4NSsom+SqIhIScxkXQt/u3im oQvmCmsVMJGAExpfC9SojOVxtgPZMtTLTSszXCVv2a3y3jAl6Pget3nnnF9E8R7t4Cpk +wuleYSje17++JCCR2pMa2Ve0hxcMGLTHZtwW0lASgg/mCwcdwBVCU/ItTSDXEDPs//0 oRpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=r4OQzcLAofPBxtpl+SThQ0jsbUehiX/Q8NETsj1jEIk=; fh=VkCyFRldYwsGD92jUf9aJr0lat63SQ1oAiEedS0KE+w=; b=qnd7WiFT2YDyDop7Kxz9gwhXajeehy0F/DqxZwD+Rr1sYolAh/IxO46zGotbrKUiOp P/RHsPiw3ZZ+44mScvioHHgWWoIEbR3hQDWFuCtK9mhXvtpttKA27UpvQE0eVpcUY3eO RwjdIbGtIFaAWt/yH6Hm1HF0qpoPelXYtbP/ZAkazi949yMPWA+/3CAovAoIzik1IhHw yx3NFC+ldm3tHK800rLUXv/yl0AjxQnjILezm4n1oCD3NwgPKc6UkaWnIlb53AfSvUQ1 s0g9ii6Hx3ZUauFKKoAG62HFbFuANwqHkL9mOSSw3qOkWQzo3koC4pz9OqRV+N8pMs4K QazQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=g9KSmxUv; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-52863-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52863-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=1; AJvYcCVp+IXixI53MJpmhe1S4Fj/GIRslPTRYtqZcfTi/MBq4dmVXmomvM/fYEnIpPvDaVge3DfW5P4skF1inxJxh6SPQ91cHg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o22-20020ac87c56000000b0042c28da72e2si9089qtv.341.2024.02.05.06.59.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 06:59:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52863-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=g9KSmxUv; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-52863-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52863-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C12B61C22C44 for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 14:59:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0CB640C0C; Mon, 5 Feb 2024 14:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="g9KSmxUv" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 709552D608; Mon, 5 Feb 2024 14:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707145061; cv=none; b=dVtv4UONLpqyAZVvIO21LQ6OW2yZvjAwiYAL2V38+ASlx47wbkZ379eftmHJGVczM9d/hJjvXUsvo1Oto9+r0p09MLX/0lp2Y/yqnDWbYjaWm3TrLPnoSp/nCFr2juUo098cgGFwmpjUnWnlv/UiqZstpEMzXujo6NGvZyyhIuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707145061; c=relaxed/simple; bh=JMbhlud7refefepc6cbZbO1h9xgdtvzBjl+BpdUwOjs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H5K2+kq6D4IKTt/A0hIY8UMPK2S+Ur/fsDSPU4RQzIAH3SF8wXDik13jQDMaK4Jr8Utri4UUekUi1oHeaWEM+fDUC352g7uia9gCRE1D8h1rpwJvFVjBQBiyimZFTDRODzfjGcedPJl6FIcDL2mi+VU79t051ob4etetrjNUlG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=g9KSmxUv; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 8DA612000A; Mon, 5 Feb 2024 14:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707145051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r4OQzcLAofPBxtpl+SThQ0jsbUehiX/Q8NETsj1jEIk=; b=g9KSmxUvJv9MIFtkvV5a5uGHLifTWOtHoD5jHFbj0uYp57gcoPoA8Rfw1g4ZOYbyWCf/pD 7ItfRjRHVhnprJEGxW/xwMaEG0FWRvcC8SkncfeIyHkd5pnaZh+T9opoXpPddLG3uoxEm1 YsB8MWInPq4QoZVsguPKdxLZlfBB+xmKhDJjPUr5AmnN3/79YQp/auCJuAiWqpePyuR39P INmIDdIoC3udR989OppJNOZtNeEbZZEkhusai3+8rWW10zI1f2UqH7L/AN2JX5iB414jGC U3NjgoD3tfI13G+NWwoAB95DwDseaOgxavQLFoTSzoUsyYjRpOopqFbweL4kjA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= <theo.lebrun@bootlin.com> Date: Mon, 05 Feb 2024 15:57:31 +0100 Subject: [PATCH v2 3/4] spi: cadence-qspi: remove system-wide suspend helper calls from runtime PM hooks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240205-cdns-qspi-pm-fix-v2-3-2e7bbad49a46@bootlin.com> References: <20240205-cdns-qspi-pm-fix-v2-0-2e7bbad49a46@bootlin.com> In-Reply-To: <20240205-cdns-qspi-pm-fix-v2-0-2e7bbad49a46@bootlin.com> To: Mark Brown <broonie@kernel.org>, Apurva Nandan <a-nandan@ti.com>, Dhruva Gole <d-gole@ti.com> Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Gregory CLEMENT <gregory.clement@bootlin.com>, Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Tawfik Bayouk <tawfik.bayouk@mobileye.com>, =?utf-8?q?Th=C3=A9o_Lebrun?= <theo.lebrun@bootlin.com> X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790071458832778914 X-GMAIL-MSGID: 1790071458832778914 |
Series |
spi: cadence-qspi: Fix runtime PM and system-wide suspend
|
|
Commit Message
Théo Lebrun
Feb. 5, 2024, 2:57 p.m. UTC
The ->runtime_suspend() and ->runtime_resume() callbacks are not
expected to call spi_controller_suspend() and spi_controller_resume().
Remove calls to those in the cadence-qspi driver.
Those helpers have two roles currently:
- They stop/start the queue, including dealing with the kworker.
- They toggle the SPI controller SPI_CONTROLLER_SUSPENDED flag. It
requires acquiring ctlr->bus_lock_mutex.
Step one is irrelevant because cadence-qspi is not queued. Step two
however has two implications:
- A deadlock occurs, because ->runtime_resume() is called in a context
where the lock is already taken (in the ->exec_op() callback, where
the usage count is incremented).
- It would disallow all operations once the device is auto-suspended.
Here is a brief call tree highlighting the mutex deadlock:
spi_mem_exec_op()
...
spi_mem_access_start()
mutex_lock(&ctlr->bus_lock_mutex)
cqspi_exec_mem_op()
pm_runtime_resume_and_get()
cqspi_resume()
spi_controller_resume()
mutex_lock(&ctlr->bus_lock_mutex)
...
spi_mem_access_end()
mutex_unlock(&ctlr->bus_lock_mutex)
...
Fixes: 0578a6dbfe75 ("spi: spi-cadence-quadspi: add runtime pm support")
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/spi/spi-cadence-quadspi.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 1a27987638f0..ee14965142ba 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1930,14 +1930,10 @@ static void cqspi_remove(struct platform_device *pdev) static int cqspi_runtime_suspend(struct device *dev) { struct cqspi_st *cqspi = dev_get_drvdata(dev); - int ret; - ret = spi_controller_suspend(cqspi->host); cqspi_controller_enable(cqspi, 0); - clk_disable_unprepare(cqspi->clk); - - return ret; + return 0; } static int cqspi_runtime_resume(struct device *dev) @@ -1950,8 +1946,7 @@ static int cqspi_runtime_resume(struct device *dev) cqspi->current_cs = -1; cqspi->sclk = 0; - - return spi_controller_resume(cqspi->host); + return 0; } static DEFINE_RUNTIME_DEV_PM_OPS(cqspi_dev_pm_ops, cqspi_runtime_suspend,