From patchwork Thu Feb 22 10:12:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 204667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp153529dyb; Thu, 22 Feb 2024 02:13:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUnkSoL/mGIwJTdGZW6AGV+V9eiwwiNfOMbi/XYGbW1d3fjN+QV4bylEQ5yeTDY/rjWNRp0I91eZX3ZcpruMOOed5Gn/w== X-Google-Smtp-Source: AGHT+IGyZDZuPGBaMizqgN8fEOlNk2EQO/0y8N6mh/BlnnDvDD0+1I21gZfpHE1jPWf/XZg+snLd X-Received: by 2002:a05:6512:951:b0:512:b914:7d6f with SMTP id u17-20020a056512095100b00512b9147d6fmr6020993lft.65.1708596822326; Thu, 22 Feb 2024 02:13:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708596822; cv=pass; d=google.com; s=arc-20160816; b=ylL/8FcXc+t7kd24H06g2qm2kB+XyBDCgvvFik7dOWGex+E24JoZr8HouVsHn+5/KY /TZrkUAHJ9FmBGtSq+RjrmwbxP3Om5O5kXJ2dbrPvpADEBN7FU32MJNmzdOUfaaeDtXD EU59wkEnxvM/aDYyvIGoL/ZcfjfVt7EpPkJDKy6IjD3uo2LF70+kCTxBvLlv2eVAYOcG syOqtly8bGGuYm/TFh1uWI2XGXgCsCgyaGdn+U5r4QaofUspznPPQP4A97bXBLUmH4kF YJ+epUchPDIkzfTZsAJgfGDMUVNZN2mcPhzPwPeTs1wdOrHd78bBqhoE4n9AfxhrRvnf vtow== 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=Kr+jGKZ7wa4euSb09lk+qCqBrZfe1hy6OrbVIm5KELU=; fh=Oc81uuoSiCYmWPIZrJKh6tUWDhA09tD21Re6ielkk1Y=; b=YlHm+fREVePQHzc8OmbzIUvEts8hmp8vlg+b6hjVoBE3mnvSEwAetwOHI4ZurhAI44 pkz/RByVQ7JmjXPCViRY286aMJMradEPmTu1tQ7aybY6rfG1+Ktw73I7m9t7Cw8nlQhf N9sGQQrNqWQy5h2lchGejeUdn/4ef4BF/lg1IVume9IBLp2iBOPYNimP7a8+IcTkxCiG hro7mxDN6D+tzcJPk7AqQJA40fADGMC4e6E8mDCPBItifhYlZbG0UqajMaU+uKN4oY9l T4YNfFeOP2fIpcOkWr08KDIBdGjkChkMs/z+2bS2rtfJ2OkbWZUaUKH/QymQI9MCR6/f e3Ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dsw6aMVe; 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-76300-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76300-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i9-20020a05640242c900b005650584775fsi1182002edc.188.2024.02.22.02.13.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76300-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dsw6aMVe; 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-76300-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76300-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A5BA81F22AEF for ; Thu, 22 Feb 2024 10:13:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 903B23F9C0; Thu, 22 Feb 2024 10:12:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dsw6aMVe" 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 ADB343987A; Thu, 22 Feb 2024 10:12:34 +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=1708596758; cv=none; b=CPbwKFM/GgQGFsiuOXCPdVpNtiB9SpJTetLd+qdguv5qF1tduXq6C3rYMXUlII2RbNOBNB9BHJ+bnTGNlZBb5T3sjen9KbVdV1FxmLUrXAGcXOzu1PHkAIdnltHFQj9i3bqNKy+D+snMZHVMy/trSRYU/8lyR6FJvxtWMP1toIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596758; c=relaxed/simple; bh=U+gzS1ckVJjVA+ftOBxZZr+oCPKKnY2akQ+FTUE4Vlo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JimIglmSvNhdVYyTGbFWrp98VTI8397ueBQi9hXVABdFLl8F/mqyqIrRymuhGwtd7urMrXbmw3BxT+bF+lAkVY5rUw86EHautfhaapToPBYZwMnndauHdY+FwJcWV5qtoTFugSo7gzHAA3KRmz8pZGOPddlp2Hllfd1THCNfJa0= 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=dsw6aMVe; 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 538872000D; Thu, 22 Feb 2024 10:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708596751; 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=Kr+jGKZ7wa4euSb09lk+qCqBrZfe1hy6OrbVIm5KELU=; b=dsw6aMVe503SzQB89/ddzyuJ08+ZL7xstYhTijpcje0Wv9Zr92DVNUljvFTlOHNMCg0TFY NSDq8XEDWEvjkbsXHhxTXNBHcGwmwLH9CRFP17TfJVWJZ12xX/oyKLs3NwcFgu0Gnvlwpm ft6uzCM7UCQ96ffobAChRCH1vFNm6YyukGTRAZZ/TRnXboUVmFN38QcZ6CWVvVK0FcF+0h fFtlhR14w0ApR5fUA58MefDhqH5oeFxBkGhZ8XAs5VdPLEpYU57EGuwTZiZsft+4mEVvyT ZvsFuIk4OQ4FsvaOWA4Tlu7lQaU38ZKCUbrV8RNoQhFHL5ev2LL6ZuWqvDX7BQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 22 Feb 2024 11:12:30 +0100 Subject: [PATCH v4 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240222-cdns-qspi-pm-fix-v4-2-6b6af8bcbf59@bootlin.com> References: <20240222-cdns-qspi-pm-fix-v4-0-6b6af8bcbf59@bootlin.com> In-Reply-To: <20240222-cdns-qspi-pm-fix-v4-0-6b6af8bcbf59@bootlin.com> To: Mark Brown , Apurva Nandan , Dhruva Gole Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Gregory CLEMENT , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.13.0 X-GND-Sasl: theo.lebrun@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791593621247512828 X-GMAIL-MSGID: 1791593621247512828 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 --- 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,