Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3209143lqo; Wed, 15 May 2024 03:07:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/QoDbtEeD7BbSKRoMHlougHRtUKhPg0MdkL3u58Wo3NjMzFmxsm4D/TKCWfmMZqoVFC7VJhuQ1LOKrQDUvA3KY4AMZdGXDZtWBpgs9g== X-Google-Smtp-Source: AGHT+IEUsqfqMDjIeqz++JBquY5BoLfHeLzBHtDmn1HWuDwjfG+ugL4LFL0+UJOTVc1VUvb26CLs X-Received: by 2002:a05:6358:27a3:b0:18f:81e1:c4e5 with SMTP id e5c5f4694b2df-193bb3f8d2dmr1178528255d.5.1715767639104; Wed, 15 May 2024 03:07:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715767639; cv=pass; d=google.com; s=arc-20160816; b=ISe7lneqemCZgCcDlEnM1b/KqKkfgYQK5CajCHElUoYPrHrGLzVChQ0cc0clSZpX3t fVKbqekGrmbeq8aBhi8STlc7uiTJ3GKCHEOOrj4BSeOrmUHBRMIMl6m8R+w8pGVWg0w7 MAdoIoG+yTgur0YBJY7O2GoZjHo8oG67SGHEwbCTASbGXqBnhXy2/CHNBgXnr1VydhRk SpBahXtxWo1nZZdIZhJ3disg/knBzx7mi/OTJhu4WAJOAO7TBetKY2phOC8JYM7Ho3Z5 yPleqj/tLggJm1Bxid1TWQeNGeQT9OVbEJY6RX0E+6pPPTG2Yk0LMTW5iGNZKhQo7uZN NMLg== 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=nJsk01g8PFOtWZ8YN5wBqGOjLENbNBCD6D5JYLiJQjE=; fh=s4mRjdA/BHAg0FOUg/yMio/WRPnFXhgrkZ9VDpg0yo0=; b=kquhJhCV80BJoXS3ShPlZkU51aH8xX4Tf+KuDdALdC0r3KINQ4fD0Puucfs/AoVz1x OosoKUK+19svwgUl70Ez4XUjD9oT7SZNzPSeG0uCKZ4rTQ6u6/5vJU2RK8pQsZdAOYHU 8TGRthqbHKCf2xgrR1grRxIHNJWxzuIjCs4pYG7vLGK0XjZJiBgHXBSWMafiMWlBtlxD YM/2e5TYyYd3Ti6LkcC0uYrsD4jc4260D/JA9t2wwzMjaQgM8eXCqbq2pkBY0fATMLn9 /nmj8oZbaXBp2DGcG4bpcVFZzKqDRoB/K3ztntGqQfp7iJYyg9e4sACrVvLom4R5ynvV Obiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="mYHu/lBe"; 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-179737-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6341180ead4si13393868a12.589.2024.05.15.03.07.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 03:07:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179737-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="mYHu/lBe"; 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-179737-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179737-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 31250B23381 for ; Wed, 15 May 2024 10:02:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D1225C61C; Wed, 15 May 2024 10:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mYHu/lBe" 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 289BD54645; Wed, 15 May 2024 10:01:29 +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=1715767293; cv=none; b=kE1US/I+S9CI4RAoLDz4EkQPLf5/umafy5+093mCY36i2wzEI262EUvIWBWWFE7CJU2ZOXuval/9RfSCCz4s2cwajKdWyzzIG7i/WhHTFN1YyJGFsHs4+2olmTa46uVdt4PxWPaV8hSb5JSv4D+raCFiT/WaCY3R+jCTTQG/0TI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715767293; c=relaxed/simple; bh=Xx+vayIh82SAtHVXudYjPk1zPq0B929fRjdBosiyvNs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KFgaWwjytVxET2apF+ewVh6tBykn13OujXXTLl7/6uFck4aRnZRGOz3k29dxa7cp+xehkgS/IzGbC91PbWlDJPMzD3R3y9qOdiS/UY5EFRim4sxXO0zCMIPyAAzm3AHIOl+XKRdQy3gqMWwzVGdKrDILGe5RRYt0860fmHisiZI= 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=mYHu/lBe; 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 C446B1BF212; Wed, 15 May 2024 10:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715767288; 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=nJsk01g8PFOtWZ8YN5wBqGOjLENbNBCD6D5JYLiJQjE=; b=mYHu/lBeHXPTuT2pLodznqLS/H8Xpzf7PcFP7oEulgPVaU7eloHBM+U/WwP50U0e0zE4kP a3rBE/qGlBNcqSpy3gGmeyH1R7KfHIeb0LlxLnkOcdezN9UUMqVfenrEd7yxCgIlxHZMNl cMNj9Uya1uI3ro8LdBeIdnAvxKiwIAnpf8yWpR2Gt1uT1KjvUsR6uR8l+yitAqJYpMlhUD OADsJMDD5jW6jeW7rQ4DNmL5jrrtGnUU6JMZTFC0KPutYiAdpOV2MyeEa/DjrdimxizSs/ VUHVqubHB4IaBawDYggmKsrf0zLF6hmkkR9pfQNGEN0xx9XNlU+C6RW3Vrlt3g== From: Thomas Richard Date: Wed, 15 May 2024 12:01:04 +0200 Subject: [PATCH v6 03/12] 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-v6-3-4656ef6e6d66@bootlin.com> References: <20240102-j7200-pcie-s2r-v6-0-4656ef6e6d66@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v6-0-4656ef6e6d66@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Tony Lindgren , Aaro Koskinen , Janusz Krzysztofik , Vignesh R , Andi Shyti , Peter Rosin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Siddharth Vadapalli Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Wolfram Sang 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. Reviewed-by: Andi Shyti Acked-by: Wolfram Sang Reviewed-by: Tony Lindgren 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 258839845b12..c767a6418962 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1575,9 +1575,31 @@ static int 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 = { NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + SYSTEM_SLEEP_PM_OPS(omap_i2c_suspend, omap_i2c_resume) RUNTIME_PM_OPS(omap_i2c_runtime_suspend, omap_i2c_runtime_resume, NULL) }; -- 2.39.2