Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1918217lqg; Mon, 4 Mar 2024 07:37:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV5n/GwaCVyiL76YoVPiZH585pbGqazTmkiTogkWnkMyoYFzwt5ieTykF+yJ+Vi7Vnyn5eUIJtTv9KFutBs4WJ5Xe8nZvWMdRtoNvAhrg== X-Google-Smtp-Source: AGHT+IGh6KR5o+d/z3lQFdUNtU/lURkfZGslM6AzeL5a0BYHut5IoKzEU1pHn/jIAejlk2e9uYnM X-Received: by 2002:ac8:59c8:0:b0:42e:e0c0:af1e with SMTP id f8-20020ac859c8000000b0042ee0c0af1emr7708398qtf.10.1709566669130; Mon, 04 Mar 2024 07:37:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566669; cv=pass; d=google.com; s=arc-20160816; b=ID9aMfHGWQt5bz5ki53oGKZ9xUJk74oK5MKr9fPJPWE2o8XYbTTrcCB3tpA1/DRK+4 moKDioMG0yyWNztwFbbRud/tzQbjl7PxleceZGjC6VNJHtByT8sgR0qSWy6dkPBVq6zH 1BCR3OaAaHPDR2e+myXkULMVA5FJSPbSSgC9l0nBl1kaH0a9jMNehvwaSSvMar6OvTr4 QOW5vEtJEcy42hv9Q9BJOI9FZEHlj4VKtB4Ag9+dViBl+iVJzd/7MLyXafBTiWjsqYyX pNRZOasGEX09b5hkU0f+PuqPJoTzHhBhq3QMdlGgrFTv/MNfaNBLkBg2ixBlsbVllOjz epuA== 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=gl1VkLUtlzwgjyFHXIWhWfMxiJmBAtrbqfGEcOsrt6A=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=gY68idVJAWk6Pp3QuusDyUuRXx5qtqM625grE+5Kf4nQlgwZIgJFIF0uvxzcPtwJEE nnvyQE1SgOMJ+ol5ueb/Njy9MTT3etBEHqEThT7LmUco2EsHLCIYX38eaD2l4wG1uM/c iRJAAC+ztgHyMmIJRms/6TXbRZR0Ne5PH9tfOr9/iIjSruHlSxRO+oEWrii8azEQV84V +53Zr4TgGoV4rjmqyN+GAm/Vc+4BaXU6q0Tccm/SDoD43TWbrntLD182BRe3BhH1mbdT Hyb/WcDuOyQewn6P2qi2iFiD9hO0B6QDzAApFiTvTX63jVZmAcBURYImFcGzBQVE73FT jxtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KEWC1IKF; 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-90842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g17-20020ac87d11000000b0042ef5ff8d69si1460828qtb.459.2024.03.04.07.37.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:37:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90842-linux.lists.archive=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=KEWC1IKF; 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-90842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90842-linux.lists.archive=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 EB2841C237A3 for ; Mon, 4 Mar 2024 15:37:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABF7E4D5B5; Mon, 4 Mar 2024 15:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KEWC1IKF" 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 679C8487AE; Mon, 4 Mar 2024 15:36:16 +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=1709566578; cv=none; b=nfUTMv73tLndztqcLkIyonpIm2LvUn3ghKywhM6vrz3BkyeI2+BJEAoOD0TiPswmKxcqSrDXstwmtcJQP02MHUz2wmfYzrco5x+82iMdhFD8fgyn75h9nZdhKP4MXkXOiw+aSJt3f3MYPqs2hIFh2vrz5BG5QUXsCzeLioTtAc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566578; c=relaxed/simple; bh=Ff5habTJBwpnMGCWcJcXduOtk4oykNyYJ1ARoENGFO4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L8JZb2u0jY6P4VBVMX98e/k1NBP38UzEIDH0LwY9u1It0DX6LZWBqUnCmoLEDW/6l8zJyUe95WbdVf6t661c72jmpAD5yxcUrOM5nQ7ppC8Tnv+oMqWhZky4T92a7bWUHCYU1eX8SDck65A8vpqbynFPohsbtW+rpYYMg7JShI0= 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=KEWC1IKF; 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 0A9B61BF20A; Mon, 4 Mar 2024 15:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566574; 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=gl1VkLUtlzwgjyFHXIWhWfMxiJmBAtrbqfGEcOsrt6A=; b=KEWC1IKFF6+WH764Ea9IkJgO1K0u3tppkwQfA0RE2+3oC4gLo8ZNlA2jHd4/2XDAe4PmK0 TMiqXGm31hhI4L5f7IOPlKybsmyogXbRtpAQaI3hwmg0ibql2l4y7t3NmeUdGGFoQkFwM1 tIEszKtCKzxUKAVMKyy1Qam5JZwCrUDzidj0FFO+ZFhBbhXgEJMHIaJF0+nWSZoJ32pdh3 N2cNG9JALpmFvLzLB0Nf9aP3kgiFHcVK/4aWQ0ULdXTXW/6VX8D6FZ3UEWEXTSGRYbBGsM rZ0om+g5FXbQDL5fk4mi4A6muXj3dpVWn1V+wqf867eqall84fE/FZ2xC7aObA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:46 +0100 Subject: [PATCH v4 03/18] i2c: omap: wakeup the controller during suspend() callback Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240102-j7200-pcie-s2r-v4-3-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com A device may need the controller up during suspend_noirq() or resume_noirq(). But if the controller is autosuspended, there is no way to wakeup it during suspend_noirq() or resume_noirq() because runtime pm is disabled at this time. The suspend() callback wakes up the controller, so it is available until its suspend_noirq() callback (pm_runtime_force_suspend()). During the resume, it's restored by resume_noirq() callback (pm_runtime_force_resume()). Then resume() callback enables autosuspend. So the controller is up during a little time slot in suspend and resume sequences even if it's not used. Signed-off-by: Thomas Richard --- drivers/i2c/busses/i2c-omap.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 42165ef57946..28417b2a18b0 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1575,9 +1575,31 @@ static int __maybe_unused omap_i2c_runtime_resume(struct device *dev) return 0; } +static int omap_i2c_suspend(struct device *dev) +{ + /* + * If the controller is autosuspended, there is no way to wakeup it once + * runtime pm is disabled (in suspend_late()). + * But a device may need the controller up during suspend_noirq() or + * resume_noirq(). + * Wakeup the controller while runtime pm is enabled, so it is available + * until its suspend_noirq(), and from resume_noirq(). + */ + return pm_runtime_resume_and_get(dev); +} + +static int omap_i2c_resume(struct device *dev) +{ + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return 0; +} + static const struct dev_pm_ops omap_i2c_pm_ops = { SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(omap_i2c_suspend, omap_i2c_resume) SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, omap_i2c_runtime_resume, NULL) }; -- 2.39.2