[v3,2/4] spi: cadence-qspi: remove system-wide suspend helper calls from runtime PM hooks
Message ID | 20240209-cdns-qspi-pm-fix-v3-2-540ac222f26b@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-59392-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp866223dyd; Fri, 9 Feb 2024 05:57:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+zavmHxjOmrxRv6HbUeIqu7YY4NBefjaU8cnlf78d6QVYNeGFEeC9MAUOKXpEVpxXp0fc X-Received: by 2002:a17:902:ced1:b0:1d9:a2d3:8127 with SMTP id d17-20020a170902ced100b001d9a2d38127mr1888072plg.52.1707487036822; Fri, 09 Feb 2024 05:57:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487036; cv=pass; d=google.com; s=arc-20160816; b=Bpk4JiEt+RrXwwqA1qTAMGMjW4piAuBvSqLAPuxsQ2koozOR/wtJYXVjUbz6iaWeX/ /02jZYRj52KXJoIB2uJMI7xB+yAAi4Cov2awtbXhIaudejsxcxIIzKbszL8lUQXHbRyI I5YCus7J+P/7MufDv0gnmWKiWJ4414TQVTRiouiOrCtT/X7fY9dGc6WmxPBaAwZvfKEy vk4SUXUB8Lv0vCnSsyXQu9zVQyEhV7Ib2CVxESRvJI9GOa+HDHfzuXjGSRM0N7r3eLYH XtrVWcFGWTtVJElzvzEAsGfc6eEuh/6MosT8gjdomip9o1A/1TR7w+75DH3hBOKBuV3V 8BvQ== 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=mHHh5pthlaRvRNGcIbfyZm+1KloZJQv9bQbNMTFQ/6M=; fh=lOQjaiTfZf/2p20dt4L/h0FI2KzLuV4HmG/08hCUGKw=; b=EtrJXLBInFGcCdHjxfMncp4uX3Bx18yD3eEQ1Cl5p4HxWkWAlVTeOGAzLWoBnz2axv ltpSk+27AZsaZbb8JmVpQi7TJvXSDapQs1Q804mUG8AFL5aKBkkPNGuJMhI6OhzIOaXh MuTH0o/2p0QO1UJ7DI5M1RQNRCQTyrQaKImi7OdKpNaMCtcDr3wh4DUgCEEDqB/42/J9 g8ve2I0jt/oieb9mG0I76SJIC7GVfI+aujK/9Us7N+DUtUFi8zIT8w2FjQSgxIsdRkYR NsCJPxnh9biPf+PBVhxuvDpJwJV9IK/+DSgm1UjqIdXoVEpq2BgQbyX70/VTKMdA0dPX cV0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VOlPNAV+; 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-59392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCWlHbNIP/zUzWLyd7iFaEqOyqKZBOIBamzY1IBaSUUb50k/r4uVrtO8tSHRl0k8IwWtANy8ElFpxdhd6RF2BQVFd/ELzg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g7-20020a1709029f8700b001d95cfcac8csi1690042plq.193.2024.02.09.05.57.16 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 05:57:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VOlPNAV+; 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-59392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59392-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 99280282BEE for <ouuuleilei@gmail.com>; Fri, 9 Feb 2024 13:57:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8C74664A2; Fri, 9 Feb 2024 13:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="VOlPNAV+" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 C561B286AF; Fri, 9 Feb 2024 13:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707486976; cv=none; b=oviaPrGKTr92sc4z4+Pxc3/D4HtT5RVvkEmhpuZm/oU24LPbmC/Tnsuiab2VmY9b/7CU6X/awQ4tdDbgK6C3euGqwqfhtn/e2BDyO49CyBdHHFbbVR02fGprV4UL411h6uS4uygc5gly07Jfn1RSxtaTa9GOtcSqmOwI0uCfg8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707486976; c=relaxed/simple; bh=MJODknsNdPWKKihYzzcpVIfotVeSxNrGrwbmt2FA684=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y6JwHb3WmsuQbIwmmcD+YIMsboiYxkouMVy7ytm0inFL4e/IlvBbv7aaQ10gCYTE9LwP2gVZ5oKL0WfTwJx0sSzQL1wQANFZvD1zErzGhfpkZ0XqjxUbg5kFQ4IMbH+mCA9xSba931REHO3OOlXEezi/uxXxu/BSE3fsJUv0qas= 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=VOlPNAV+; arc=none smtp.client-ip=217.70.183.201 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 3393D1BF20A; Fri, 9 Feb 2024 13:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707486965; 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=mHHh5pthlaRvRNGcIbfyZm+1KloZJQv9bQbNMTFQ/6M=; b=VOlPNAV+tLPiurdzfe97v46AUhH37VsDMw1b/jI6cao5J1q0Kp5XtEJtH7jsDKnozdlOg/ DKyakZx3/Y02haNkXr8PaUtg1obtMx81vPp0ZRAb3zbymAod1GTg+fSrAx5gilmbU1vdy2 EWuW14fIZB31iqm31NFrLyIGG0xAgVM5EgrmkYFXYJ4/vNbqvr5aZa0glNeMW6cC63DQPh M3W4gY8wZdQ8mhLVDkRbCvgck34H5fKTyf4eu4iaSzrdk6LAKdk8KlpVekSoHgr42QSQqn V0NKiQWm+uMZbDUFhdcZ8E07HQaSDe7cLVjukk2mR1nTv+aJus4/xIVALJDaIw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= <theo.lebrun@bootlin.com> Date: Fri, 09 Feb 2024 14:55:51 +0100 Subject: [PATCH v3 2/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: <20240209-cdns-qspi-pm-fix-v3-2-540ac222f26b@bootlin.com> References: <20240209-cdns-qspi-pm-fix-v3-0-540ac222f26b@bootlin.com> In-Reply-To: <20240209-cdns-qspi-pm-fix-v3-0-540ac222f26b@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: 1790429926829549438 X-GMAIL-MSGID: 1790429926829549438 |
Series |
spi: cadence-qspi: Fix runtime PM and system-wide suspend
|
|
Commit Message
Théo Lebrun
Feb. 9, 2024, 1:55 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 d19ba024c80b..809bbbb876ad 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_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_resume(struct device *dev) @@ -1950,8 +1946,7 @@ static int cqspi_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_suspend,