From patchwork Thu Sep 5 22:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13793035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C050ACE7A9F for ; Thu, 5 Sep 2024 22:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0dnpXOu3Zyeo2ogS49DXnfXg2JaQ5OAoSQd/Cck+x1g=; b=dz8A5Dt5oVtPS39deGC6LAhvbu AWixAcGnlxQGNO8wsNtub+ZMwutax5rIDrjFS+pYGQFOMrVdlsal1O8xw4dSvILDgbhPNLv+gTGOA 5dc7J5HJeThSLWgAhdklWHRvy38sdO1O2ZwWME5x7dGVNpOtrsrp4zR/yNPS8yTb/svvBaxRy8+9P bRSQegfwKiJKw6Z4LW4nGVQQ+8kBrSdvvrdvnVc3MqM7OLVZX/6fTNIKFHl3f8CLnJ6V4O0T14SUh OqvmD7x9LuA8aNYxqPPLSBBSjL0KiIT+paaVrGqevid7eeupHGQx47eTd/FwpxLh7f9K128U6TrG/ nZ6N/OmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smKch-00000009xq5-0p8M; Thu, 05 Sep 2024 22:06:39 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smKZs-00000009xP1-3Eo6 for linux-arm-kernel@bombadil.infradead.org; Thu, 05 Sep 2024 22:03:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=0dnpXOu3Zyeo2ogS49DXnfXg2JaQ5OAoSQd/Cck+x1g=; b=Gph8twOmq67iG55vPEETOBzGzp /s/kNUFhwC7IjSAQ6aqBgUl2zIYXwloKEA9ugD9TUpteRZLjfnWDTBEDIoFR7M87jeQhSkn5Xyqhx MxMQpmWGRbNjrot6qJoRP/C0eO1kaRjXP8RDXwQ5zO7DD0iyYSZN2Q7og8GF2RkBhZceGZGsQNoxM djMbHw54w1C2D7D//ipjo793eUQR0JSgUReHCPEAnHdLC4zrCXTvozkd8uPemi9BWRBpPPJjqfX+l O1c5ZbJr/CyFa/qMw0C+815BhgTRCo3YAEyC3wvcao6OiFPC1I7dMUeDMjHhpSOYBtzjeQ8lXEz+u grchQSNw==; Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1smKZb-00000000Yrn-2Ck8 for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 22:03:42 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2d87f34a650so940350a91.1 for ; Thu, 05 Sep 2024 15:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725573803; x=1726178603; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0dnpXOu3Zyeo2ogS49DXnfXg2JaQ5OAoSQd/Cck+x1g=; b=AIn+kzvkIsXl213zZd7FmSsJM9MERA+/IYYijRFZcSh951mWpd8Rj8aKkVSVkayTHq 266qnzobJvMZXWfwM4vifq1XUducWQV4O+9dDIfNX4u+uHRBJ/VcnJrtiVJaZSTCRRTi t4cVvD6VFQ3Rl/ogqD7pgQoAtKu1CeFydcOqg0BtzB5jmVMlqzHovgOofV7xsSTzqOqm baPbBnO5873kvPgrN4P7vAoEe6cLTT5xWaObaODA8a4bvTBxvdvdd58yjMWtKMSWR5IK UZ0Zed7d055qXhVjYNcHRq+z7/InRaGJn7axp/2mSH7FgK//0yvOY9nIxhSasklsY3Xe s/Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725573803; x=1726178603; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0dnpXOu3Zyeo2ogS49DXnfXg2JaQ5OAoSQd/Cck+x1g=; b=I9zOs8XK/M1wVyMy5QDP/u2/t6MkK4jja9MBEnRbRsgNa9ESJrKCjrLKpNsYKWa64n hrP5NM/BxleLBFtAd3YU2hmxqX8zINymXeA1dJmD1NAi2/FPETG0KApCS1AU2DcI9ZnK Uy5Gyioj3eB2XvXiD1q9OCqXunfzAzrMcWN2ULO2+eur4VTczu2YLjRmpjx4663nMHrm qQveR43ASHW892/2ODJLr2KvkHh/YEuw5/8VRgsQW5VfUCE0IKLffsCCuYkiCcnmSwVm cp8H49RohYm91Y3Zic0xVyjYBOgE/Om2yIcPObd4BXqP92IZpFxSXqYtUido9NtP9WZT GJyw== X-Forwarded-Encrypted: i=1; AJvYcCUty1aTDMoPfFP0fQdPNs7En1KULAfZfTzoMJY1UGB15IEbC2CtamGn0FMwdQrjCDJsQRMWfe0UhLXvnteVyqVm@lists.infradead.org X-Gm-Message-State: AOJu0YzZuTAWyXMsNu8ebIh3lUWroPGROdv7YR2OMYBkPNG9GfNL/dQT OAHWnaRcHCK/re+ocrZBTHds+i9TSNctstbLfbRQU6d++wfvsKDPNGywD5Duba8= X-Google-Smtp-Source: AGHT+IFAOmsjDchvyfmMDfyN7DLMT/o9DCSeWaPD7WLIQHvg3YDxCAVww3yIkyRqm8MsQ8qITK6spw== X-Received: by 2002:a17:90b:3881:b0:2c9:5a71:1500 with SMTP id 98e67ed59e1d1-2dad4bfb4c2mr1243813a91.0.1725573802747; Thu, 05 Sep 2024 15:03:22 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadc0213a7sm11715a91.18.2024.09.05.15.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 15:03:22 -0700 (PDT) From: Kevin Hilman Date: Thu, 05 Sep 2024 15:02:49 -0700 Subject: [PATCH v3 1/3] pmdomain: ti_sci: add per-device latency constraint management MIME-Version: 1.0 Message-Id: <20240905-lpm-v6-10-constraints-pmdomain-v3-1-e359cbb39654@baylibre.com> References: <20240905-lpm-v6-10-constraints-pmdomain-v3-0-e359cbb39654@baylibre.com> In-Reply-To: <20240905-lpm-v6-10-constraints-pmdomain-v3-0-e359cbb39654@baylibre.com> To: Ulf Hansson , linux-pm@vger.kernel.org Cc: Nishanth Menon , Vibhore Vardhan , Dhruva Gole , Akashdeep Kaur , Sebin Francis , Markus Schneider-Pargmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3724; i=khilman@baylibre.com; h=from:subject:message-id; bh=OTRIi3ecXXaMLiOVU6kmi/0lN9C40N50eKF9jB9sXbI=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBm2iqotPkPjLYhJaKyF10Ks4uB4RC0mn6OaGP/d jObvk4gU5eJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZtoqqAAKCRBZNxia0/vG ZfCFD/9rYJGVAeDL1KqsXoiEj8HP5ckh18dNXheF8ASrqNHiZtM//IAiZpD8/d5g3h6KM6Q4qai k96wlkJEew6XU8mI3bsjINc4Q/1NEO/SzzEJQmEpB1Ieh/xsGAhQuFrLhycYX/Tq8PkWMuySYr1 AT+/jo7jqDrvEqRP3cdUyucWWAnZOFuKgni9PGjBTHFkZN442tDCd5zAoYY404rbtT1FsusNwh9 0k/aJXU7CFjNEStTVrgAmavqCZ1vQvK/3hl39Lp4HEcCc9O++v9EqI+2r0Tvj+FTDl6npotEax6 qbmV0tf5VwpTIAvXeH7WrpZYb69ZiGyAhWjUdiY+Ekia64fAK1Zq3FZKU9MzlWR6cX1rlhm4KLw 8RatpDZbNAMuRTEnYkLxOlHbjMod8/IzOyobB+bSEQ4x0902TkUuvccX0ri2OQ6beNP1t+Fl3lS DC8dT5J7RKGtv2Vqm3TOcMIVion/v5/WQBTTwmtDAKyYNCvNIIsiqkRZDFSnX/BN9ELblC/c3x5 CtVxBRkFuGMAo+hO4RlD6ZgvTOCVc1TzThr2b/CASkV1x+MV+zoZcE/m2kLbw6pRfPro7SuNyG8 lXdQg9tZoGj2X/FYb5CNQWYDVTbpO5BbRY4wVHyyPF5vmeR/85Z8dV6/eX6Pidd84W5rrbugfnS ifR21xvqZ5OYyWQ== X-Developer-Key: i=khilman@baylibre.com; a=openpgp; fpr=7B87460E16927FA9F5BFF10C5937189AD3FBC665 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_230334_670107_90113796 X-CRM114-Status: GOOD ( 17.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For each device in a TI SCI PM domain, check whether the device has any resume latency constraints set via per-device PM QoS. If constraints are set, send them to DM via the new SCI constraints API. Checking for constraints happen for each device before system-wide suspend (via ->suspend() hook.) An important detail here is that the PM domain driver inserts itself into the path of both the ->suspend() and ->resume() hook path of *all* devices in the PM domain. This allows generic PM domain code to handle the constraint management and communication with TI SCI. Further, this allows device drivers to use existing PM QoS APIs to add/update constraints. DM firmware clears constraints during its resume, so Linux has to check/update/send constraints each time system suspends. Co-developed-by: Vibhore Vardhan Signed-off-by: Vibhore Vardhan Signed-off-by: Kevin Hilman Signed-off-by: Dhruva Gole Reviewed-by: Ulf Hansson --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 1510d5ddae3d..bb95c40ab3ea 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -51,6 +53,27 @@ struct ti_sci_pm_domain { #define genpd_to_ti_sci_pd(gpd) container_of(gpd, struct ti_sci_pm_domain, pd) +static inline bool ti_sci_pd_is_valid_constraint(s32 val) +{ + return val != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; +} + +static void ti_sci_pd_set_lat_constraint(struct device *dev, s32 val) +{ + struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain); + struct ti_sci_pm_domain *pd = genpd_to_ti_sci_pd(genpd); + const struct ti_sci_handle *ti_sci = pd->parent->ti_sci; + int ret; + + ret = ti_sci->ops.pm_ops.set_latency_constraint(ti_sci, val, TISCI_MSG_CONSTRAINT_SET); + if (ret) + dev_err(dev, "ti_sci_pd: set latency constraint failed: ret=%d\n", + ret); + else + dev_dbg(dev, "ti_sci_pd: ID:%d set latency constraint %d\n", + pd->idx, val); +} + /* * ti_sci_pd_power_off(): genpd power down hook * @domain: pointer to the powerdomain to power off @@ -79,6 +102,22 @@ static int ti_sci_pd_power_on(struct generic_pm_domain *domain) return ti_sci->ops.dev_ops.get_device(ti_sci, pd->idx); } +static int ti_sci_pd_suspend(struct device *dev) +{ + int ret; + s32 val; + + ret = pm_generic_suspend(dev); + if (ret) + return ret; + + val = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); + if (ti_sci_pd_is_valid_constraint(val)) + ti_sci_pd_set_lat_constraint(dev, val); + + return 0; +} + /* * ti_sci_pd_xlate(): translation service for TI SCI genpds * @genpdspec: DT identification data for the genpd @@ -188,6 +227,13 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) pd->pd.power_on = ti_sci_pd_power_on; pd->idx = args.args[0]; pd->parent = pd_provider; + /* + * If SCI constraint functions are present, then firmware + * supports the constraints API. + */ + if (pd_provider->ti_sci->ops.pm_ops.set_device_constraint && + pd_provider->ti_sci->ops.pm_ops.set_latency_constraint) + pd->pd.domain.ops.suspend = ti_sci_pd_suspend; pm_genpd_init(&pd->pd, NULL, true); From patchwork Thu Sep 5 22:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13793012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 566C0CE7A9F for ; Thu, 5 Sep 2024 22:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sc6ykz7pAchdOMHhEbbrDf/awas5HhLjGMs4xS7f/rM=; b=TdNmh4GsTYQ+eSkRTqKOmVQfrW nLgPWw3hIdUe2j4bhjz2xpZBn4YkTcibON0T5JuwToXMf+HKvXtvIGMK0jNI1Rw215n34kSsVcLim 4dJcgIDuPayXkGgjAPDAav7kuWuZvdiWLgOijZtXPrS332CK3048N9dK4jaypekOylBA1fxd7mAmJ TrnFzCQxJ1V1jLt3WTP3AIgkHsEeWJI4B3uAiKs57oxgYDqKt62D8YyaarlrmTWseDgsg30Kq9nGO W+PoOnpMLmP2kibUlkyNa7ACz076jl3Yfql0ys/tLtwDApgI4d9lx9JI6iHV5wk6mFIrXvtXWRNVj o458d4gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smKbk-00000009xgX-3jXb; Thu, 05 Sep 2024 22:05:40 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smKZq-00000009xOD-1mol for linux-arm-kernel@bombadil.infradead.org; Thu, 05 Sep 2024 22:03:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=sc6ykz7pAchdOMHhEbbrDf/awas5HhLjGMs4xS7f/rM=; b=lJ0ByPB18XCLrrVtRCxRI9ivgr FJnaHqMCG52E0iqtjCRGwbopL/tiyFjCaud5kv1urk/1HDDwYucPMWu0mAMnfS91wLLH8e+nXXt/K WcWZa7ig1G0GWoweotDL1IMumcIabr2xLUnKTHgOO7XCwyf2OeKjNDVM79ccMQCrG0IJc6B3lECYn gETPyUf8OihdVL5edZnIlB1vw+NtobSOm7wNz3dMC0oGmLCkKq4NqOJrnwA+vUFadylizFKNaVpMM dJzW+EAc5ZgVviRhQQoSd2CUxgFdY2GUqr8fFpYiqkOOcbELKY37cTW19fVI6zR0V+b97yxBsku6z sDCJP1fA==; Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1smKZa-00000000YsH-3J5U for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 22:03:40 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70cec4aa1e4so954142b3a.1 for ; Thu, 05 Sep 2024 15:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725573804; x=1726178604; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sc6ykz7pAchdOMHhEbbrDf/awas5HhLjGMs4xS7f/rM=; b=M9PldPROKzhqMH8MCmv6QvTtkswZgmEWfc7XhBj1zvf2gQuRx5dahyQ+yVV0R7i7Ra 7cs+Ny7O8dTziUg+P9QSLtUfMpb2fKgQdfhjl5XjquotNX7mDMZEC5lJsi0bTgcU1vcD AD0kjIWpCHBsS37eHEGuwxpmQhvNK29JfqrcMteVoakDsaJ5G3X+bmCHldO9viUxsmYZ UaSPtM9wGEnjEEJmQTCQz4nJv2QBiL8Y3sp51wGCWw3Og1ky4hg/qhRP/S2MeZwYjPmV HgbxC7CEc/CYi39fg6LGA9bBp4mHNAj1ieAZzTUyUMpaw77XKimgRJm9v0op7TiruGU+ IjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725573804; x=1726178604; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sc6ykz7pAchdOMHhEbbrDf/awas5HhLjGMs4xS7f/rM=; b=mlxmquNsbCLqmoelump8aawD7DKCcP39MhAxkVj+p+UQNNG582+rGJoyXccuCQcfL6 Ws6vIH7kQHyjol27GsAh/XBNP43hJYTv5kqzEBwuePuQUmXgAebbNQMEZWZ2bKYal4cB WGovjmluqF4O7arbiOMTZAOkH4PVloHTKCHMpfwuuRAYrBFeR7BD1nAeR437eST7jhgg XdfjivRGIeb5tXYaC+1Rr1vlnaa16o3ZVc6PVPGKo9kqec6tLkGgcn/4kl/v5J4FP4yz BkaHqfT6VjhOdHH7dlFAke+k5kygMtVJl8Bry7dBgTWeggb0fnjkfM9p9clFGPOeNx5j 06oQ== X-Forwarded-Encrypted: i=1; AJvYcCXLcR+r1EDK0z9ZjGPKEdSEFKcDK63m8hr1LOcSd5EJC6rS6C6SnYqhWUL1Z0fIajJIY3S7xDxc3ZSP4LGq8yNd@lists.infradead.org X-Gm-Message-State: AOJu0YwYD2/gv/oNwvew2gaf1L/UsphzsjD9sCOd7TGCrhxKQZPD/NoN ssn3UnzCKGy51NChjkxaDOYTUeHEBSPq81f1f9XnpU/+T86rj9nkPXWfn5/ZYP0= X-Google-Smtp-Source: AGHT+IHFrsZBGQdJYYGOPjjjAC19zc1JTjaAGcw/Wmj4frCMa9mnrDm/wtLkyPcB7KXhhAbpzOir+Q== X-Received: by 2002:a17:902:e54e:b0:206:c5cf:9721 with SMTP id d9443c01a7336-206c5cf99f7mr71822995ad.1.1725573803768; Thu, 05 Sep 2024 15:03:23 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae913363sm33104195ad.6.2024.09.05.15.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 15:03:23 -0700 (PDT) From: Kevin Hilman Date: Thu, 05 Sep 2024 15:02:50 -0700 Subject: [PATCH v3 2/3] pmdomain: ti_sci: add wakeup constraint management MIME-Version: 1.0 Message-Id: <20240905-lpm-v6-10-constraints-pmdomain-v3-2-e359cbb39654@baylibre.com> References: <20240905-lpm-v6-10-constraints-pmdomain-v3-0-e359cbb39654@baylibre.com> In-Reply-To: <20240905-lpm-v6-10-constraints-pmdomain-v3-0-e359cbb39654@baylibre.com> To: Ulf Hansson , linux-pm@vger.kernel.org Cc: Nishanth Menon , Vibhore Vardhan , Dhruva Gole , Akashdeep Kaur , Sebin Francis , Markus Schneider-Pargmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1720; i=khilman@baylibre.com; h=from:subject:message-id; bh=swZQv+32F9CI/ZQkJsomr4F+HEjzkbq8crWIZokZMtI=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBm2iqpHOswXF88oDhZOs6DJGg50D+JNq/25gzHA NomnGVbc0eJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZtoqqQAKCRBZNxia0/vG ZQZnD/sGt1adz0t+vhx0pzyqXNQn/9PwpwDm35NLi5FZQD8hwPalQ3gUqacez00E0OV3+61thCk 7Phdb0Ri5qPXZsghfFrqP2KKrvpq8lW831JPhsla1l1OrGEwl53d2YSSRBk4L+D1LGqxaIccO2e MqU+PJXkv+OnCOUMuWOP5bPKN6Z80Mlwb8ElGWeRRDJyFN1pH0BrgFhSi7+Ti52u2RZlJNHNVsU N2w33NNK2Icrvg1/NaSC8sZeipc0ywsu1ortTIrjRxcLyRuUqojHGqIKwBLzSR26PabjFvzNYOa QvDARWLaEnQNcNr1OaGE9lIrPnKufbxzJ544TaIsTHh0mv26/hKIyCPU17H4Uzkt2WSb8L0Ph0X aNyJPs58xLsSS+jTZ0P/jOEgmkPH3VWwVDhgirQ3kfd6ztnp0TsveG/WqTFH7lisLWYFw8Xs65G cifEprKq+NxRLXflwObxKynW6Wdq8jEBK6p9d9N23iz/7DyVlZwAo+r4jnnkmCrqpoXvA9A8E+V dD9MCCX04YR0WCrnnlLcoEIYtY+YObkpn8q5wnQhLquN1a729LUPxFCe041TPqORI9J0YylN7ca KHzSWhC4gjZ/p19Khaz8Dwzd5BA/5ltpEDjJVTyXfLQ8uD/J0mV+l/kCmBaiAZ+xDO1puT7I8z7 6Vx/0kQxtIPGBpA== X-Developer-Key: i=khilman@baylibre.com; a=openpgp; fpr=7B87460E16927FA9F5BFF10C5937189AD3FBC665 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_230334_537964_53973ED2 X-CRM114-Status: GOOD ( 14.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org During system-wide suspend, check all devices connected to PM domain to see if they are wakeup-enabled. If so, set a TI SCI device constraint. Note: DM firmware clears all constraints on resume. Co-developed-by: Vibhore Vardhan Signed-off-by: Vibhore Vardhan Signed-off-by: Kevin Hilman Signed-off-by: Dhruva Gole Reviewed-by: Ulf Hansson --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index bb95c40ab3ea..1ab1e46924ab 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -74,6 +74,21 @@ static void ti_sci_pd_set_lat_constraint(struct device *dev, s32 val) pd->idx, val); } +static inline void ti_sci_pd_set_wkup_constraint(struct device *dev) +{ + struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain); + struct ti_sci_pm_domain *pd = genpd_to_ti_sci_pd(genpd); + const struct ti_sci_handle *ti_sci = pd->parent->ti_sci; + int ret; + + if (device_may_wakeup(dev)) { + ret = ti_sci->ops.pm_ops.set_device_constraint(ti_sci, pd->idx, + TISCI_MSG_CONSTRAINT_SET); + if (!ret) + dev_dbg(dev, "ti_sci_pd: ID:%d set device constraint.\n", pd->idx); + } +} + /* * ti_sci_pd_power_off(): genpd power down hook * @domain: pointer to the powerdomain to power off @@ -115,6 +130,8 @@ static int ti_sci_pd_suspend(struct device *dev) if (ti_sci_pd_is_valid_constraint(val)) ti_sci_pd_set_lat_constraint(dev, val); + ti_sci_pd_set_wkup_constraint(dev); + return 0; } From patchwork Thu Sep 5 22:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13793037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17F6DCE7A9F for ; Thu, 5 Sep 2024 22:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FGF3ZvR6Fk1EmILbsDBIodK1mVWIH3FK2lGT48LkIFc=; b=lInSpx8cOzoMZevxBmoln6/xht WMDylOci4UtdE+5r6VZwIGP3ZEZnJ09hxPjqlXMcewrJEo5H1oFXJydpBJjMeaOoxLSZ0IQITznIE /vSzebs3Dc01k2IHxEHbjyD6mIbge/xFwXoNGbN0bjvro4MZYS2qjvmilbfzpJ46j9YrZ4+EQKRB9 RQUcITbKc0Wd5VaWBISBwZjRxxMZfBVsPAZ8Ijdy1O2eia7cMFY6cGYC+YyjKmqucRj+WYZyDogBQ 8+1bDIAKLRSB52M71hJd2SD9bt1/f6eBtZh5NtOuSZJK7F/42jf31it8Tg0chu1cVezxNNn/okNEZ TDMyClFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smKeX-00000009y4B-3DF3; Thu, 05 Sep 2024 22:08:33 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smKZt-00000009xP6-0uJI for linux-arm-kernel@bombadil.infradead.org; Thu, 05 Sep 2024 22:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=FGF3ZvR6Fk1EmILbsDBIodK1mVWIH3FK2lGT48LkIFc=; b=TFu1eklfdDf1TmoYPW7W7JM7v1 lcL90FFyLA1Jh5HkpLkhxs5j4PI5DqfmmV5ScvtoRXg6KW0gtQ2hpHaaeByNf+PQVmVrydfEuVdXA CF4Ol9TYzNfFINXCxdMwmitZzUv6mgAb0DzVqF0anUKzHQAjKvDH6fscNJj0AwNbf5DrgVcgirETq yVGExqMFSxZ38GUY8P7W2Zs1PHjL7QMo29KVQ6TZSsV90cvgM2iMHFD3Sw9+RUjOEII7+7AtoF5UM Hjpmd1FQzv8xwkwPvKtN2ddfz6lrvYREcPLfc3sKyE+RxFb0Gm7woZ+/6fhxma7w+GO9xprfm9xXW Z8SxgTNA==; Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1smKZb-00000000Yso-2CzC for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 22:03:42 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-7d4fbe62bf5so1017424a12.0 for ; Thu, 05 Sep 2024 15:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725573805; x=1726178605; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FGF3ZvR6Fk1EmILbsDBIodK1mVWIH3FK2lGT48LkIFc=; b=Tb3ksvT3zrWClHa8J0xgpi7BpLtHXGLKh2OlbuB8pvzH6BhF/wHKpweH0PHbPzX5+C 1HKmHmUjig3+NPtrmkyL6+IzVwT8UAW2q7W+xrq/G9xOHuSt9HdP096FbumVP+JoplPJ irqnFDVTFoVwpSaL64JqKbIgMFS+/LNFc7ljS6aIpQKroiTE/iouP/e6jK2OPiwQpBsI vBKtEcKuzmNmIaqxQkx1G4InYWrJWRNYBUbWr7hcgHu1JQjQ4O2JYKtZixWLcCS5tS26 jlX9K2ASUW8vOD0UQaez5HB0xm1pfXYYqi1xW7tcaBK+lfTPQJyCGkOk893LDB8lRIkE 1k3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725573805; x=1726178605; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FGF3ZvR6Fk1EmILbsDBIodK1mVWIH3FK2lGT48LkIFc=; b=mQXr6eVPguL1JdqV46fB3ikQfp+6qadl/0VbTjR+kY3kPS224ohcDHY/SDOqwz5xVe SZN05fj9v697CgcEhANeQShIzjGTWZ6vC7muSPzFjfPCiBngLNCe4Z3BI8OaJZ6LU4DS dMr8+YJpO/wd+i7l3fBNjooT6IYhi7BWW6i1zoQTEpT2SOtzwbf6pzAKfI48ML0QloHL 9VuEuRDkfUIi17PR9kbcHEz4jIUH2LwUoHYM0skth51zmggEyUAnCh/8/myi3DPNPUaa 0RNR/TTVgUd1NkiwUjqsGggUBn0JbnBdGQ1nXwCgB20TvQaxDOeu3JMJ0jo+MjHbS8So Ppnw== X-Forwarded-Encrypted: i=1; AJvYcCWLGhL/BK16a/4mhJm90rx9KiZB9dy+/M2yzzM2KupJ+kmfpfB19AOBc0TZoA24REcJ7+gFISaFKjTW4gtKvMD5@lists.infradead.org X-Gm-Message-State: AOJu0YwpGMooDPzFviDyNMGh4WMJDmQfMdvJol5KeaQXA6v2t59oPMrJ i829DyiXJfZk8TJxy42g/szZhjeQ94F1VvARahtFTJDouOVwQC5vRtESO7Uc2a4= X-Google-Smtp-Source: AGHT+IEEZQJ3BYRsD9DEp8JNQ2/hJbu7/Bjm8uuHapoacYf7CN7DfNZaZ1J2hXEGctMGI+oUfBCHvA== X-Received: by 2002:a17:90b:2315:b0:2cc:f538:7cf0 with SMTP id 98e67ed59e1d1-2dad4de4cf2mr938741a91.4.1725573804645; Thu, 05 Sep 2024 15:03:24 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadc110c90sm5156a91.41.2024.09.05.15.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 15:03:24 -0700 (PDT) From: Kevin Hilman Date: Thu, 05 Sep 2024 15:02:51 -0700 Subject: [PATCH v3 3/3] pmdomain: ti_sci: handle wake IRQs for IO daisy chain wakeups MIME-Version: 1.0 Message-Id: <20240905-lpm-v6-10-constraints-pmdomain-v3-3-e359cbb39654@baylibre.com> References: <20240905-lpm-v6-10-constraints-pmdomain-v3-0-e359cbb39654@baylibre.com> In-Reply-To: <20240905-lpm-v6-10-constraints-pmdomain-v3-0-e359cbb39654@baylibre.com> To: Ulf Hansson , linux-pm@vger.kernel.org Cc: Nishanth Menon , Vibhore Vardhan , Dhruva Gole , Akashdeep Kaur , Sebin Francis , Markus Schneider-Pargmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1516; i=khilman@baylibre.com; h=from:subject:message-id; bh=19dVWBfAz2qQyZpfPFRGd9UeDDF7grrhUskEDkVzmzY=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBm2iqp5OPapR5bQHp7ItAEA/sVZFXbOQcpAExfx 4p/eKOdq/WJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZtoqqQAKCRBZNxia0/vG Ze+kD/9kvy4WEnApYeODVoUBr1Mgsmt5CwDgDFM8VvblBDeepFM2EET3Dx2SlF1wzOh5BhlfFJ5 N8AOOchs1mCxPNBao6sIHxiShE+aKu5BFmcvJHGrvaPoxkLSvFYI9Y4sKUCmg9jlxkN/cbIEhGr 1OsJpFaZaXZDEzJc0yj5Xk0Vym9eV6F8wpGCtZRj53XSXwizvc7oL3kVXasfokc80hNDdLo70fH eJ4TSihviTqFEEfNSPfp1jPLwRTX4vYoxAa4OgdVeyWINN+9ActgTmrX85VuG6rbqg7aDAUluNA btUoLoiEjTLRAxLJhLpVY7fE9PhygcTXAaIbS6GB4R0E2mEIEP00F92Lk9KuCV09SKLcIhrc66x poPC5s++GKwQUUGJqIf7Wub8Q5gp6msOeZYkTzCgPlj36usjFLdPQKMYHEkvw+CxVuIazRQUeHc 7SGlKiU1rU7Wa6rwvr5olf5krLoUipV8dDFiEu3YGkb0tnLKGnbi5npa201SBjnxmCI9IHjm6kI cgFqsOOFPM9sgDy4YYfZYPwhdJlehRsq2kxWNjxyqELEpF5NZRG3BjS8Nd4u9y8YMVxZjmbdQrZ /SwLnGzrdUXfGOp3L2NYwnTPAmKCxb+vVXWDWwSyu/lUDxcVmyP97+HTjnErXYZCWN1fNt0Mq2m OJhwciWUdKdq5og== X-Developer-Key: i=khilman@baylibre.com; a=openpgp; fpr=7B87460E16927FA9F5BFF10C5937189AD3FBC665 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_230334_559319_2A2E19CE X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When a device supports IO daisy-chain wakeups, it uses a dedicated wake IRQ. Devices with IO daisy-chain wakeups enabled should not set wakeup constraints since these can happen even from deep power states, so should not prevent the DM from picking deep power states. Wake IRQs are set with dev_pm_set_wake_irq() or dev_pm_set_dedicated_wake_irq(). The latter is used by the serial driver used on K3 platforms (drivers/tty/serial/8250/8250_omap.c) when the interrupts-extended property is used to describe the dedicated wakeup interrupt. Detect these wake IRQs in the suspend path, and if set, skip sending constraint. Signed-off-by: Kevin Hilman --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 1ab1e46924ab..747a7a33c0a9 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -82,6 +82,13 @@ static inline void ti_sci_pd_set_wkup_constraint(struct device *dev) int ret; if (device_may_wakeup(dev)) { + /* + * If device can wakeup using IO daisy chain wakeups, + * we do not want to set a constraint. + */ + if (dev->power.wakeirq) + dev_dbg(dev, "%s: has wake IRQ, not setting constraints\n", __func__); + ret = ti_sci->ops.pm_ops.set_device_constraint(ti_sci, pd->idx, TISCI_MSG_CONSTRAINT_SET); if (!ret)