Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp149382lqs; Thu, 13 Jun 2024 06:35:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVY0kte5P+kLau0OtXb0yDmh8naiBtxv/8leeflp3Z6rvdcCMaFN8uTak0vJayL5VkBW+z5HjbavCCVfU4mPwR+o9xuqZ7gMZQv8Zo9cA== X-Google-Smtp-Source: AGHT+IFqJ9bAkH3u/hiLIpTZsoKNgorcM0PqBTvAQbFThNLhlvnpkiIODOPKCLc/W9HXXoLMB/P3 X-Received: by 2002:a05:6a21:3991:b0:1b8:498e:4e34 with SMTP id adf61e73a8af0-1b8a9bd5f3fmr5010235637.34.1718285733771; Thu, 13 Jun 2024 06:35:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718285733; cv=pass; d=google.com; s=arc-20160816; b=MH05Mz08cfzbNAyyCha2ISIMpe9qVQVWuXC3xREyzFcMi8Otv7wOFnqzkZ26mzqENT ZNpX1VfQLRDGB5/DPachYHOZqQ9MQja9OJ9YF7P3OuheBC95Trzf3O72bqPPBrUEJ1Xu 5Kw/kMv//QZCaxEdtMqh2rQIIeIwLI56CkvwUXyJ7VXPURU7sGbrKNjJpEIBA5cVIRjR qSAK9wMV5uvs0efA0zfQIJFoE6fn4EOMVbL/aEOZf2h0lv2QOcflC1p7Kl59E/soHqPu HR0YqVl+7TQMuamO8mRT6115K4dNDXgQQXW350ejtKLvF00tp8RkuzWNv/biqG3tfMTK BqHw== 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=NnXBYdyT0gNgWX4/GEGtMkJeHalCuEmPx0jaEIE6hhg=; fh=sqFAVdECSYB736Et2lmfYm2VY5P+RGzVMRK9jrHpPuc=; b=VtQAuUUH84+l6Hci8ZSQPCBFv48jl2XDQ31nbpzi5BOn420IHcQeT1ex/z5qkwr7ar CZ2p4ATPAYzM9P6WYQr87nnyEZPu710BUiFrZjnEd5a1XSgHMtKbDj7uBZF4HlB5K9YL S8ZP7M8gMGv5SoKunFx5oZ/pZUfUeBrsQDFvILBzmPQSNNCJ+yX+UmftuAPqN4YrD1f1 3lTKB3QUilI38y714qf9ju2SeY447keBtjFa4SnZ/omQH3S+4DtWPmtjifY/nBxymDtI Uw6bzXUigJE/ENgPMIAb5yDzsw5peZH21fA4N72Zfz+YHZu7u0AfzoOe4zG9FAc2a0fR VFOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oXZS6Y03; 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-213263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213263-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-6fee3108ad2si1348715a12.304.2024.06.13.06.35.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 06:35:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213263-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=oXZS6Y03; 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-213263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213263-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 E3839B25093 for ; Thu, 13 Jun 2024 13:14:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2557E144303; Thu, 13 Jun 2024 13:13:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="oXZS6Y03" 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 CD835143C46; Thu, 13 Jun 2024 13:13: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=1718284422; cv=none; b=bORedvrdwVY2j7Lz7X8fd0At+ekkPlLBUJ/x+tbRzu9Vwbqe9K/uKmAuFxm9fSJqsWDLsDyycbu7oKd7q9gh/BsefODe7ElGZz4H5NfACSY+S74qiFWEVZ//o0IxDBivM7chzr6FESNTO1IER/MArIAyMj6H4TiRB12pIj76Klo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718284422; c=relaxed/simple; bh=Ty2UCqUCB0l7oVWoD5eKOXaiKOi1EakKfeomsmmXcoU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n8ZJ3WUkLFxHADkOGrmOxE1tRkBGW7aduu9kQzuo5IbqmVZrz/QPhR3ZpJlAUL66DYaf5hFR2w2BYbdTg3PoES3Krkc2mDiDjcV7Ovgym37R3RIZVQkJ4ajMgqpYBPUg8CMw025B89dI3CB/UBiDq+oQVIyyexm+T59OX7IaGcI= 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=oXZS6Y03; 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 A012720003; Thu, 13 Jun 2024 13:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718284418; 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=NnXBYdyT0gNgWX4/GEGtMkJeHalCuEmPx0jaEIE6hhg=; b=oXZS6Y03Py2abvBDLCedfdQ9y7RgtZWBDeY21qzLJK5MmtDCtpZP9WO0Yeibpug5vd9D9T JhhcFZ0Xj86WrJ9C4OwAXxW1+v/0limydcCxwt5XnGYcAffUjWuGOl0Odc0xHGgpKG+CsM v7vResNn1d6LrTDfTM+DBCPRNP3XyMzlo752JQBEsl3R9h1Q4gIeXJY2hXDQiamAm/aox5 QL3ivUvV/hoekJgSxe7BHmhDXcWAeMut8aPJJcCTWh+wDYOCByj2Qp/6yejU3pqaTGGR15 7xiTmZ6Vtr7nT8DBNDXcfpbrmprD7NaQh0iuraIMskpaKd39Tr67Nl5rSWfSlQ== From: Thomas Richard Date: Thu, 13 Jun 2024 15:13:28 +0200 Subject: [PATCH 2/2] 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: <20240613-i2c-omap-wakeup-controller-during-suspend-v1-2-aab001eb1ad1@bootlin.com> References: <20240613-i2c-omap-wakeup-controller-during-suspend-v1-0-aab001eb1ad1@bootlin.com> In-Reply-To: <20240613-i2c-omap-wakeup-controller-during-suspend-v1-0-aab001eb1ad1@bootlin.com> To: Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Andi Shyti Cc: linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.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 410c8b37f768..35a3f0a64986 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1574,9 +1574,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