From patchwork Fri Feb 9 13:55:53 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: 198879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp866231dyd; Fri, 9 Feb 2024 05:57:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjKXsweEiRca4RCvaJspVs7O0M4UkZvujr3oWsS1+DXB7jq/W8eyGzwO5i8TEJqv6juWCWCBYLrKGrZQaABCyMgLVDMw== X-Google-Smtp-Source: AGHT+IG1/gHCZizjsRAnNSiik05hvukoFFDRL6K3rTiM12yrr7YZfSLjoT+q1veodeWCf5RyOLy3 X-Received: by 2002:a05:6214:27c2:b0:68c:aa51:9037 with SMTP id ge2-20020a05621427c200b0068caa519037mr1854676qvb.22.1707487037644; Fri, 09 Feb 2024 05:57:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487037; cv=pass; d=google.com; s=arc-20160816; b=eh/ECNvj4OGlN6ffBAS2siuImdF9vSfwIsJ3pdAfiE80dltI8mA6lCJ1HlPqThPNW4 Wepfsm3ULZuJxfkq/ugAkixE0ydkzKxHgQrC/IOPOuoyG7i3zWH5goWegLAyn/VJt8Ot UFGeEYS5l9GBUAr1FhBnrLdE/uz1NxtbN2M1SyIHELsyc4AmbCOCyv8HkDhLODYPUqh7 uod8KC7eTa6IaQ+1bZB4fwvy89zZnmqODTrcwxy5P6YPSFsMkHBCrRiTJ3Y47p7wLnIa Udrv2ZebSWJpBlwM4elYmzSYS4LYhz/qg6iKk6pGpxP9zIP1j7TeryfxJSioHNTMqHn/ h8Gw== 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=RqketI7LTDXTpTwWPnxjrx3WSm2BtW9HamRjcUb4AQk=; fh=uXFqExTSvSWDIF6zgElRuXAj39E7UbIjj91kEPKlfpc=; b=pdIgGxi8hbxA5ozcYlh5VfSgrk1DX3VgvrSlS66ye8tK4V8j9KszBMvDU3Ejd78Ayw Zzz3c6VQHonrspQCuKKqd4daVHrG3pSTNUftA/fvkUtD/opE0uy1GxiSNHDS3JYBAum+ jgeMZIKm32RtBG6nllpt876vtru6aDAV4ocXpt2d7L+pPskwMN+2m14d9trBzwtfj0pG GcpndE67SHJWUIzfv8Hph32r6tanS3I50CdAuzUfiAadqpn7/Bg4vRqHY4khUKTX9RmD I/YFpp0WYh1U1nqJmVIyCoTmkpMcBsNpesVFbf+zcwWuuZT9AoTpqrN9JmkqDUAjqAZf xAoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jzWFemig; 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-59393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCW8h2HErbCbT6FFFkm7+5SyaL7ik/hskxBcSLTQK/e4vEfSLGE8VmHVz6Olmh0EEArZCKY/+qk5yQ3FjClXMlS7PZHyWQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fn9-20020ad45d69000000b0068064f2dc53si2035383qvb.434.2024.02.09.05.57.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 05:57:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59393-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=jzWFemig; 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-59393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59393-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 6FA3B1C21752 for ; Fri, 9 Feb 2024 13:57:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8DB8664A3; 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="jzWFemig" 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 7C67A4D135; Fri, 9 Feb 2024 13:56:14 +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=T8uHrgxDEbMdQerTVl7NsO6NjHtFlAFnlJFyfj1CcmJwrreZji5yDFFyM8eGkIIj9KnJPt/m4oCoSQpB3WROAivFZ0aDFaZ65aLxUL/J5j0ePZQNzkJEAdU8eZjVDE6E4lni2Gpp7fPTRT3+OWBbTYdnyvEDffaJ0LDb3tWpvZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707486976; c=relaxed/simple; bh=cstpzce+J+7b1urmkwA3P0JVejglpP3nSE1z8JR3RxA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O9rrIz4bzKLEq1Eczh0lDGs4PCkLnnRHWHjJxaczPjXVwvbJJ7rpoAAvLwTjdUZlIwK8HQoTvTf6Klri6WnQ6Lxgwv8c3WNPDrGI3IGiWyt4OENKChcn22RlpDxJas2KgaBysxazBwCAF8KjQjZWVnafgpLe/2g1hudVM2a0KkU= 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=jzWFemig; 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 D3D5F1BF20E; Fri, 9 Feb 2024 13:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707486967; 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=RqketI7LTDXTpTwWPnxjrx3WSm2BtW9HamRjcUb4AQk=; b=jzWFemigIBN7tkr2IC/YavhPwPGsVSUWlXGPvdXKNdRDGHcLAKcnSS+n7JY+e7eFS0u5bY 89OPpQ9TxcURK7NssrfPQ/TkCsNmqMc5c9hVljDKS9N9upPZFMVLb8sfbo49mMDSuqoDv3 pbYb5civJ76rq2a8LtiSXC5oGPONX2Hity5DSJxBJM/xxARh9+VTqGy86dVwa96xby5KSx VEsJayEtd0xaP4fuH3CktvM8WSKc87UPY2Igo7MHccdW0pCqtK9L3bxQDz4RQoOlPvBg4d nXaDeFPX+frH581MyBvxGxEDza7nKxeDaF2z+rDkTx8NdPgbYGH61BRNx2z94g== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Fri, 09 Feb 2024 14:55:53 +0100 Subject: [PATCH v3 4/4] spi: cadence-qspi: add system-wide suspend and resume callbacks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240209-cdns-qspi-pm-fix-v3-4-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 , 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.12.4 X-GND-Sasl: theo.lebrun@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790429928294059567 X-GMAIL-MSGID: 1790429928294059567 Each SPI controller is expected to call the spi_controller_suspend() and spi_controller_resume() callbacks at system-wide suspend and resume. It (1) handles the kthread worker for queued controllers and (2) marks the controller as suspended to have spi_sync() fail while the controller is unavailable. Those two operations do not require the controller to be active, we do not need to increment the runtime PM usage counter. Signed-off-by: Théo Lebrun --- drivers/spi/spi-cadence-quadspi.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index ee14965142ba..f976681187b0 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1949,8 +1949,24 @@ static int cqspi_runtime_resume(struct device *dev) return 0; } -static DEFINE_RUNTIME_DEV_PM_OPS(cqspi_dev_pm_ops, cqspi_runtime_suspend, - cqspi_runtime_resume, NULL); +static int cqspi_suspend(struct device *dev) +{ + struct cqspi_st *cqspi = dev_get_drvdata(dev); + + return spi_controller_suspend(cqspi->host); +} + +static int cqspi_resume(struct device *dev) +{ + struct cqspi_st *cqspi = dev_get_drvdata(dev); + + return spi_controller_resume(cqspi->host); +} + +static const struct dev_pm_ops cqspi_dev_pm_ops = { + SET_RUNTIME_PM_OPS(cqspi_runtime_suspend, cqspi_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(cqspi_suspend, cqspi_resume) +}; static const struct cqspi_driver_platdata cdns_qspi = { .quirks = CQSPI_DISABLE_DAC_MODE,