From patchwork Fri Sep 6 16:14: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: 13794442 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 69CD8E6FE2F for ; Fri, 6 Sep 2024 16:23:19 +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=M23QSkkmj0U8+DRFhBewDD71q06y3alOAwKMp01rg4o=; b=ZsMjqksVNczJdzj2r/OpS1/rDm 62YlfgaMhKU6I+LrGkpaLr+WSUSJEI83JevEX/CWWG4fH/epAsgqJwYAryEBtN1y7wtPb8Ho5pOFA B+jR+mE39eyh7H6aHE3fqx3MdTeYY7xnSwFIcQSEqc8uVhtboOhS4GCXxsYFhO9Y7YsE0acfUpxr/ Jwl1a+fbtgu3G4QFr/1VjVCpnMs9fKcix/FB3CmogOHdhXRKSD7R7b+SNUQ8BYh4v0pS9ti0nJJ6Q 1vs2WqabMr3fP6fYtmw3Lp8muXZjwFAVzNndbZ8c/G8+A84LGKijvpnTCnzqRO+YD8jveQ/knLCdA ejRuqiTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbjm-0000000Cx2v-2KtE; Fri, 06 Sep 2024 16:23:06 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbc6-0000000Cv00-3YCa for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 16:15:13 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-718d6ad6050so708552b3a.0 for ; Fri, 06 Sep 2024 09:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725639310; x=1726244110; 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=M23QSkkmj0U8+DRFhBewDD71q06y3alOAwKMp01rg4o=; b=mdq77FGXAUpnbjFofBbP9nxDYse4CGAfmT5EPG6kbMdKhmnTymRV/pytcxsVxlxr5+ p8WJjcWuV4qrD1+hsqGBEiMhTVeMAEujgVF6jKnSvNYP5AD9az/V0YARyJ/cHYZLikjL gJw3n3fYXip+41GxGHJx/AMzfjMovQxC5gkSyZmLRTudwtAXaZQILhlI3I2N65oELviG DF8Kt1OKmdNTXSexizMn8DoQ0lC5vrnwnnWsQsc0PnHHcQ9aOTD42vLWpdCylQj3WQF4 NHvd+VK/HVeN16h4oWi8kGRtVqUSjZuk0harVekkiSg3q0IbutG77liVfeXO90AJUfBF Q94Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725639310; x=1726244110; 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=M23QSkkmj0U8+DRFhBewDD71q06y3alOAwKMp01rg4o=; b=XXAS34+c3vIhFu2dfQA7mFCoQ02aOkHd0++iBMMYHS6z0uukUvonmPKfPCT16ezqe+ 9n5JKF9Lw+SaG5WMHZ/j2lP/QZBfjFYmrWzA0QagAwhQ80PxnDXuQ7EhNJ8+M81PpodH Xiaurj+6WBanoFYnZKxIQbWJ47G0USCOLa1CaAE851iVAKCaOmN4JW6pwczU7Ll2uePy c/2mfIstbQKz9Crnsq3vynXWGmAOlGWh92PNoGiScVmBNNs+XcPyFE9HxVVnB5HDHjMS 88C3qKtvtO02XDaixAXY+qjvalYXuI1cnxgdu4DdKsWFxEp+f+ZT893bpOXSl31R78gq MjzA== X-Forwarded-Encrypted: i=1; AJvYcCU6ddoXI8mU+R2xp1MbVwj5eyxgocpXUetQUesbNejrJq9AMUCN0FuVGhaK1uQ8/g3lqIL8NA1wRAv84ed47/IN@lists.infradead.org X-Gm-Message-State: AOJu0YzCBXJSNF7lahcEKQd0qv3cabfgGJgvT47y6Q1pAuF4LwEWjQwL RMzAmrir3j0lXaaGa6UmVDFzPEjRCeYgeu8RztLjuBVGIeQf9wOsORi8GWV7eu+PCCt7jYHBBzk d X-Google-Smtp-Source: AGHT+IG42XDdUECXdsVsjNHnNCea/VVAWmmRze3BgvuQbgKT9T3nq0761gcMU17mf5578jJTNXnTdA== X-Received: by 2002:a05:6a20:ac44:b0:1cc:9ff8:eb3a with SMTP id adf61e73a8af0-1cf1d059a66mr3145797637.4.1725639309783; Fri, 06 Sep 2024 09:15:09 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-717c95c5d4bsm1861053b3a.102.2024.09.06.09.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 09:15:09 -0700 (PDT) From: Kevin Hilman Date: Fri, 06 Sep 2024 09:14:49 -0700 Subject: [PATCH v4 1/3] pmdomain: ti_sci: add per-device latency constraint management MIME-Version: 1.0 Message-Id: <20240906-lpm-v6-10-constraints-pmdomain-v4-1-4055557fafbc@baylibre.com> References: <20240906-lpm-v6-10-constraints-pmdomain-v4-0-4055557fafbc@baylibre.com> In-Reply-To: <20240906-lpm-v6-10-constraints-pmdomain-v4-0-4055557fafbc@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, Kevin Hilman X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3830; i=khilman@baylibre.com; h=from:subject:message-id; bh=Z30ieLDM06mHqkwlhFkl2a4vKxiH7HFPI0x22ElrwLA=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBm2yqLeioEVn+N9TW7gc9VPGmGj/Eky5GN6PguO KOykfS2nTWJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZtsqiwAKCRBZNxia0/vG ZTM+D/oCriCt5fa8AcDFmDrbjCQCyI9IRqkn4tSiSYkSKsTPyY/fQglGec2YE5LyH94QgtSWOcT NvLxvQbBD2FoRtzgzaKJUAfxi2FIXNwK6uJlwFkSaebQMcjh5GXNKrijTD2EbgS2fBaTVoRME/u dLD0x1Yr9ZgrB2tmdsnPObD6pEIrHSk2oUaRUVqIgYPZ5l/I3/eXWWPfix5PiZHdBFgVC0b6JZS NiQ5s6x2BFI2SNOl0fFdWZkXS77zjSmRp2v2DtUZ/A6vzPa2/HWaEB4GfwcJEhmLtwaEwHRG9yX Tq5aFuJElx/ezGE4rnvGrkOcKDskhme5nIa6gfqjjdJu6lmzDowtDxjXFC9EkXG4zkhMF0aRLMC 9t5S9YvWW5yzgB5FSLOn6Z9dnEUUCGiZR/MbNNAocRbxFECjLsTdRsO+QHaZ8Bq5ui+qzoBBjpB H1uI1ycR+kphQCzryIxKd2nxXViIPU50iL9n3VJgL2e/IoK9vKn/pPKhvckcnhXU5cy46i0bR0E XKaDARGTcc78FER5LhrSNc6vqvjyOVIrUs9gdlThAS2cBGIg6C+ri3xB+ZAA8lbt5NfcLHyeSAb 1xoeETY7VCgXg6XQjb1UEelyudDQ4U5AFUZXkTnu5KXXi7YdVEBhhPReuaLzmF2zS2oACqYle/c DKCoED/lAEL3czA== 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-20240906_091510_936543_47515B48 X-CRM114-Status: GOOD ( 17.20 ) 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 Reviewed-by: Markus Schneider-Pargmann Reviewed-by: Ulf Hansson Tested-by: Dhruva Gole Signed-off-by: Kevin Hilman --- 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 Fri Sep 6 16:14: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: 13794443 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 0ABA2CE7B0C for ; Fri, 6 Sep 2024 16:24:16 +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=+2aRXAwD8KrJpuKg+9Kk7rgQMra5BG+HeEZO3HX3uDc=; b=EObqc6H9w05ZvRNhFgT7h0CAbq XWPSUtDSZpZrXBXogFbGa1XYNsVWONK2n8nT662o0I5depjRZVHqBjiMPsP+4WTtK3tSpeRm6ew5c tdyMLLjhg0oyVH7CzY0mZ/V3PCnQfKbQF8IrfxFm/7WLTuZEqFuawD0VHiN5FiCfiCemEq6rkYhlX PRf0VQsKmTNeoiUjQXsqt7sgEjqMHKun0S+zxjGDY6acIgMQjH278sdMKvGDTZFbC/9hp3TMim/e3 Dia7nQhcKonKuwNlMw/VMvwyEfEHsRP/PON0YMJzVHthwm+jtau0OYM+XRZr/sydKN+Z5JPRtORcS aRxAO8IA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbkk-0000000CxGT-1TG1; Fri, 06 Sep 2024 16:24:06 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbc7-0000000Cv0K-35Oh for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 16:15:14 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2053a0bd0a6so23920955ad.3 for ; Fri, 06 Sep 2024 09:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725639311; x=1726244111; 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=+2aRXAwD8KrJpuKg+9Kk7rgQMra5BG+HeEZO3HX3uDc=; b=bWGwQVSgGi3VdVZ6b3ruKN6OgkMIdoDayMph+HDB7C4ceNJHHxm8cy1ak8lNDlAdG7 EhwmNSqndlhbMhYhh8U/AUptaAJYE2ySZzq0g2npCqn0gJ0ZIYv/zto8vy5NBaR/hrcq zzJEZWyx792QHZkojLvB5+AqPYs47+F1tSjcjZUd0hDo4Z/mCGOC2glXhtTBqRIoMoSt ed6GcuMuLAILonN03waVcaoXU7HhG/U+wyWQeoV+CuSmlKBaChk39LNFMhXWIEWUPtVn xhAkka8szrWkapa4X1uor9WZSkeUtIUP4QttiUcZ5ssX5TYXO8XepC8JdP9Ssjant/ae C3sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725639311; x=1726244111; 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=+2aRXAwD8KrJpuKg+9Kk7rgQMra5BG+HeEZO3HX3uDc=; b=Y3hTlTT7zpQ/Jn6dsdDdW6IpwKKKmdiZD7WOe1DxhRdyowOb7qOHuc/0F+x9GRNtQL MqKJv6SrX37CINIsPbsWnXaDpqa3RNonaHNmVkgYW3m1sVArgpF5vTWSVaMNXaB2VFuH tO//SZiyB2gvpbBQEWTIURFDu/rMuW4/rlrNxhvdKYUzy9Gu3DI7A6jgIC0sAvteB+Pl +a5l5py7fkXG6aw0xCfiCgn2vcwiNvLXQyM+RoMovqY/4/iUfxsZPe3EgBeMIF7gc1id 7jdWffqBwUd9D/Bns870B+woE31zx5htQ8UwulmD6rlvJZMM6YqTewVoKiH+zo8dd6Uh dniQ== X-Forwarded-Encrypted: i=1; AJvYcCXRe8eBvMXj2Iiewc6c29Gxywpz+QjHNOPG/CXZ8t9kW8kyEbF5FE/WPrZXtDnzQ3+QEOVTHeJWeDCSOk72uNNb@lists.infradead.org X-Gm-Message-State: AOJu0YyouDpfKfDBrLreb8MAyb4rUS6MxX2uUQzGhRpginwKeSzbKYdR 3Lsdl2MJRG/g8D7bk8DmxdXBMJbPq9DbM6zbjcbpqknglJCngh49YPKbsskPOCKNE+1X6mBlsiw H X-Google-Smtp-Source: AGHT+IHRAWOqa4vtw51vHKymkcBna51OsZjUMFHA5+x4d7b3lyErQUCwhi/Zf1+52AB9PHN69BgAZg== X-Received: by 2002:a17:902:cf0a:b0:205:6d54:1ce6 with SMTP id d9443c01a7336-206f065b9afmr40654155ad.57.1725639310751; Fri, 06 Sep 2024 09:15:10 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea333dasm44777155ad.163.2024.09.06.09.15.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 09:15:10 -0700 (PDT) From: Kevin Hilman Date: Fri, 06 Sep 2024 09:14:50 -0700 Subject: [PATCH v4 2/3] pmdomain: ti_sci: add wakeup constraint management MIME-Version: 1.0 Message-Id: <20240906-lpm-v6-10-constraints-pmdomain-v4-2-4055557fafbc@baylibre.com> References: <20240906-lpm-v6-10-constraints-pmdomain-v4-0-4055557fafbc@baylibre.com> In-Reply-To: <20240906-lpm-v6-10-constraints-pmdomain-v4-0-4055557fafbc@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, Kevin Hilman X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1767; i=khilman@baylibre.com; h=from:subject:message-id; bh=W1HLvNNrQ5aRbDnCoPuDJ9mQXm5CPHYILEXs8vfWbg0=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBm2yqLsdfADWbiS7a65KXGYejPWS4mVPwOv9Z37 CdRwYoZ9AeJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZtsqiwAKCRBZNxia0/vG ZSlpD/4g0D6USz6yaus/cIGpB9stTfudQwizKsEkI7rgMBhQtGFHYKpx8BRaIOVShQpNLJqm2g5 xminiI4LrPPru1vNYBLrVb9tsLbtejG9/w7XFxv3P56LYdOdyCZ6amGsez8lZZ7QJIcaKSWJYl/ /vST951zmhT6NZZoratDwIbxflkz62dLjVKF9MKxJfF3Q3DLcBQ8N/+f4mdnU4KuqfFaEAmRNjX 5RlJ+l4reF9zSbahjP630qCQ0gnXIhfTYqZbu9zky9pw0SYTmt5GRQucfJee+kgSRA7HT8XtWc/ dae0VG/ZjwL4eK0ekdcx9R9pZCfYvzDTm3YmPCrnZn3ylj7fuYaMQXG0ENODmvOc8y8ecBbUFTW lok/oOBlD94p7P+4KDGFzIfAXKTBoCghVTC2br2nHKyT+7zbxVwlk8ZBCVPIzklKjA6y/zgLSZ9 KfcsRj5Q+XkRWu5W27p0du/guhlBPLnJZaZ47D6BgcrstGzH3H3JV2hF26YwsI/IBqFtiewEYUF f0AkaW5G87N5ie9+XZll6o1mJb0x6tV9EFEm2g0tuJDBC1YTEvuWVmyeCfcRC3/ntDoj9GAgh5P O2xo5H7sVfn2cUpkSOT/gN3tIhcl4+WDDlMlrVsggWlabpv+PTNcSyRYlp+vAYnplztlc4Ehpzt WKYKkXG5FhQK3EQ== 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-20240906_091511_813175_AE5F9B61 X-CRM114-Status: GOOD ( 13.86 ) 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 Reviewed-by: Ulf Hansson Tested-by: Dhruva Gole Signed-off-by: Kevin Hilman Reviewed-by: Markus Schneider-Pargmann --- 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 Fri Sep 6 16:14: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: 13794444 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 82FB4E6FE2F for ; Fri, 6 Sep 2024 16:25:15 +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=wHpYPG0F7ARkJaF7S/WPtuawc45vlNVeHmm3gtL++pA=; b=itJ/y+Pk3o+TkLRLVQtwAyBJd6 /ApkhQmlkNIk2t2y51w2XktaX78zCJ+406Cvb6gMgt/CITLtSNWg/WMcs57KJTTJCPy/o+jyh2Kzf RyY/jwK2NVER6JG8dmz6KBUB84X0nIv5cjYjxjapfGhiM/tiYLKRkjh4ZokMxD+qo838g3t/lt//L JkD9M4PLiTPvwsYZ7BGsZQtNjY6DKWlr6iUHTpdpq6GAZyTvmILWlmmNtwIFGWFgLm7ikd8+B0ueW Xb7e5EQdgiw/eILv9uoZHbjcsltu33TuMIBqJF5YCGxAp54+TP3hbV5PjpjkQBzz+VIM200wwhcjl BfM/bqjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smblg-0000000CxRK-1eLZ; Fri, 06 Sep 2024 16:25:04 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbc9-0000000Cv0e-0YGB for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 16:15:14 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-201d5af11a4so21133835ad.3 for ; Fri, 06 Sep 2024 09:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725639312; x=1726244112; 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=wHpYPG0F7ARkJaF7S/WPtuawc45vlNVeHmm3gtL++pA=; b=WiVYdcdcZPU/1ruNL6lxumhFyYVxv41ntco/1tk8kZuQm1v0Sun9+Sj9A0YohA6eLR F06Z8conRpWIdT35SclmiaoFwNNfMjuOUxRHC6+Gr95P1YIrlo1Mmwxp+CtfM+fggfxa EVC5pRdo2Swi7CdgQW9l/DYKhXlA9JMtyn8emYvBDtdxmrhnbLsKrMdUB36vKkj8p7Pq UuVPOtxfhSwLlNaD/S9AbPTACWkWyDisb2rP30RRX9oYw6qTCX7jS4rtG+GgF1kVl/5h lpeBboJElBo+mVPAZXW7hybmSBcHuHOqNY5+ftjScCEajU4hW9m7x2iwW8Bi5rc0nZ3E kjxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725639312; x=1726244112; 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=wHpYPG0F7ARkJaF7S/WPtuawc45vlNVeHmm3gtL++pA=; b=wtgCcXrxh/n9lxJv++KGduB8RQ8AjSEtyvzMnkWnzT4J5Aok3xnkjwPLPHapNHpeFz fdeUA0G5f4LqG00ZIPHtXIYwtjV8jUqxDHbLVlcID4vl51NTRaOCpG7Ormqsy9Cryd8N g5S4TgYSzIxwFZQAdiHZCCOBSCzmCqEBhwWFUgGqqjZghoNxgRSAmQQtAkL8wBGqY1NO yrcJ3QqaZfN7r7S0zlxtFtej93H8ldYILRggqtGwJ5d5USeZe8Lo3wDNOn49xyBPNJG6 iGpt4SlIjj8WqMNzztCgix6HfMGUzbt4rzZxz+azk+EUC1DWmyyrL03jjtgiTjzwjRcS B9Iw== X-Forwarded-Encrypted: i=1; AJvYcCUn2qfYHI/5Ro59VmSak/y3rs0Ve/IOM9YIJ1JINU3ac+xzB6a6z4MSslYpcdgukegZKipAlqKxMQ+9Vrlc2o9g@lists.infradead.org X-Gm-Message-State: AOJu0YwBf2K+V4dztOz3uErCLaNhGnAt348YW1nc4nF4xhaasfX6jB/N ihTegrynLdQrEwJLd7QLQRe102myiF1Ule87qwhufv2eQTOJU9f5j47peH/7x66PG02KZlNtKca o X-Google-Smtp-Source: AGHT+IESwuJ5dl0Z6KD7hUnigeZrm7cUkuRf9V0jjKkRN2+AzCtxauGn4MqXh2z3XQDnxgcU4F8gcw== X-Received: by 2002:a17:902:f709:b0:206:cc5b:ad0c with SMTP id d9443c01a7336-206f053479amr36155775ad.28.1725639311833; Fri, 06 Sep 2024 09:15:11 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea54e7bsm44826065ad.183.2024.09.06.09.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 09:15:11 -0700 (PDT) From: Kevin Hilman Date: Fri, 06 Sep 2024 09:14:51 -0700 Subject: [PATCH v4 3/3] pmdomain: ti_sci: handle wake IRQs for IO daisy chain wakeups MIME-Version: 1.0 Message-Id: <20240906-lpm-v6-10-constraints-pmdomain-v4-3-4055557fafbc@baylibre.com> References: <20240906-lpm-v6-10-constraints-pmdomain-v4-0-4055557fafbc@baylibre.com> In-Reply-To: <20240906-lpm-v6-10-constraints-pmdomain-v4-0-4055557fafbc@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, Kevin Hilman X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1579; i=khilman@baylibre.com; h=from:subject:message-id; bh=9FdOyIfVNqdxWITOueSVvAjoQfrL1FwTK+07Gro9K44=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBm2yqL/PIURu2uNA/h3Fwo/1sgpktG8Pixx/6mQ DAnA057AgGJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZtsqiwAKCRBZNxia0/vG ZWE8D/wIk6Ofc+XVqFuDQ0NyitdIu9sTbMxYy2i+0cqK1UaRlvQ3Jk0fNkebAHDh03LT0y2OKbu UpUdE6GUxbfPx32hl4Xlq4OmowhHI8SVOzW5VoCrqPhf6H1gCgL2cBp9sMlXfAMX9/1MMOKxX9W K1eQNh8BlZp/xjhU+jKY2GEw0h7uhb/dCC9Sr/YjHng/LIwFK50wJghGLf5ce/krvwSjBEjJ2xB hRKhbmzV8Wm6Kb276Afm31RPPuW59JI2BwtGPR7GxBhFIXg5wPKlXaqawt1mol76ErBE7EH5YsE oa6EwAgpI+RAgSjUPSjYT8r/PQryjwEYeRe98O1hot4r5kuIoLpKUhm9aYRW/djKuXR5KzAWtif /FZWROQDFCvyYyR9liyjiex88DIOdeL9ywLDvwNUtTYrxjmk9Kxq0LDgCl9Apvww0xJnifCzT1U f8xOpc4YTgKdor1/d+pK8czdxq8JBKRgqAuyqHjWfZkCkbnNK2cN7hn4/du6O/90aqzpLR6a+58 FUaASt50dqSLB5p5qZbQg7z3TD0fQHTVQlp8zgjJbN4mjF4jzmjjWHqwcrLNehFv751mOS0bgxb zBdBE5nMU0CKYhAir9AZewEg7SCS+tJ806Rkg1TYKzIjjNSZ5v0vjRgKUhSKpSGsnc9fwbWV4pS 2XF7jXvOcur+sVw== 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-20240906_091513_358895_CEBD1F09 X-CRM114-Status: GOOD ( 13.69 ) 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. Tested-by: Dhruva Gole Signed-off-by: Kevin Hilman Reviewed-by: Ulf Hansson Reviewed-by: Markus Schneider-Pargmann --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 1ab1e46924ab..566af9f055b8 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -82,6 +82,15 @@ 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__); + return; + } + ret = ti_sci->ops.pm_ops.set_device_constraint(ti_sci, pd->idx, TISCI_MSG_CONSTRAINT_SET); if (!ret)