From patchwork Mon Feb 5 14:57:32 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: 196857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp928586dyb; Mon, 5 Feb 2024 07:00:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhQFND5WZIIXDzabv3SUtkg/jGXdpCF/v0T+5O3ib9RPOK/5w8zu9fSRV6iIi9KPRVVVm0 X-Received: by 2002:a05:6a00:3cd2:b0:6e0:41f0:f6ac with SMTP id ln18-20020a056a003cd200b006e041f0f6acmr3697513pfb.10.1707145249621; Mon, 05 Feb 2024 07:00:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707145249; cv=pass; d=google.com; s=arc-20160816; b=jcYpUisODXi4F/NUkkrcRWWyT8Yzkcsa3cRB9xaiX9g2AAQPtAFkE/g8buUZIIxf4E /d+rF+joMs6aYWs+9wFWAyUI6b5UIeV/emCBEtjug4JJas5UIw70J5ybhtWzKiQ4G6o+ JGbZGLmMJClAVjrBrOr8tL9QzdclRiSKnEJJTi0uP3p3W3tsoBaikr84WqlRSEC3qgjV D00Zat28Q7EQ23JfDrr71OyIE1+Bkx9teMgSWYkEVSJDXNyKX8LmK9W5B5h6tQdEJx20 vCGtvSJN0Tz6cZU5jc4h8eTEuntTZw7PhwAMCSAvUpVWqEX421ieP2CDH4n3PosEpdlt dnOw== 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=PrEL7acHDCbp2I+1KWFfcR3xiMWqHydc9Be63lmuf00=; b=vBQqqGFFNkQj1P1X938xtp1bqXfCKeGMTInnUTu2jdGT60AoJ5irEDleBpnnzx/5gI u1Y88Ji3OgRqFza9a11amYDhvtd+sA907EFt/9d8AplsT9sfb2d8op8iofzCoU3fLg9e QdqnQTuSIgK7H4CWwOItxzxRXkj0nHrdfLYPjMj9y5OCHFEJuN4QFY3/v3Kr3EN3qP4D Yx2S+q0ebia/M5n6n32MUGtGwMlxOeULOs0stv7UxrTyCCFhRq72tV4QptYy5vyKT8QE XE6prO77LS0Ss29tgIskSd96YsRziig1ayhZ/YCeens+IEHGZqkVCrOJw689cljVnP6y lCEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bqC4KiMd; 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-52861-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52861-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=1; AJvYcCXvip5jr8Ib+sDRtJHbHB/hK+6sBC+Lg0j1Zhjnlcs5Yg0QEZB1niFWpYVml0xqe8J56I8sjLldADHgFi8wBUwdb7qjaQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t1-20020a63dd01000000b005dbddc1aec0si6111305pgg.527.2024.02.05.07.00.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:00:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52861-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bqC4KiMd; 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-52861-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52861-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 56EA2285D84 for ; Mon, 5 Feb 2024 14:59:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DDE140BE3; 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="bqC4KiMd" 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 709272D607; 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=MOQUHSwYrjIolx3XX5c/JIGCW5ppOpYkqarnWXyScVGhfwASwJ5ozjlmfh4eNz5xeTa+Z+vWDJ6IwjLCjJLnqIBSMs6jXtwDQdK6b7/koH5G3PaRI17mT4ttMzJtR4ThttT8YvcRhcz0aY48a7ywlTRjOTE3/+HkYNXzuXh1lNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707145061; c=relaxed/simple; bh=cstpzce+J+7b1urmkwA3P0JVejglpP3nSE1z8JR3RxA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f8WCThDIq0gTT3P5uHFg8ufBbtZjt5YPv/x57Y3erBAxEC7dm3H9IjxIm/vomTba1/+tRQHxayHm1dsRewJp8x7w+rxhsJkPcPYooZD/k3phMoXq2JB1FpZ4lUC0+RYGnWN/G7x88V8WECwlW43EPlNYKryGVt2FeDvRkdleUIQ= 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=bqC4KiMd; 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 0E51A2000F; Mon, 5 Feb 2024 14:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707145052; 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=bqC4KiMdfymIvbi/PG+BDj33Q8eJ4s2v+BfhsI02Q9bYVMCXh9FLDiiwjqSHzOkR+c2uti YlTQqD4JuqvOUOJszNbmBRwmztc0joTBsXatNC43dal/y/HrVLjDAccxh2gI6j42H1QK9V iWYhdYrJl4cKxv2ZFo7my4osnMVK1WJcWbkDhOi2gPs7e+i6h9hSgIVvzn+LN6jxtl+5wT xkZQKhaz4cFGThnNCetNQT2EZJDDyGaDYNzYWLibM2o0DolK0SosnE45Blfd0JRcRqMd0y HyOE5JaMQMVsNZQ7qNqQojBTDJmvnyz21aGaay4TzXBBUWqhbIqmvPFKXe0ATg== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Mon, 05 Feb 2024 15:57:32 +0100 Subject: [PATCH v2 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: <20240205-cdns-qspi-pm-fix-v2-4-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 , 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: 1790071537140129292 X-GMAIL-MSGID: 1790071537140129292 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,