From patchwork Fri Dec 6 22:12: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: 13897858 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 5C4E9E77173 for ; Fri, 6 Dec 2024 22:15:18 +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=C7rXiwNlneTt0S3Im0z7iFr8r3P4BVASAMn47K57uCI=; b=HlACz88VNSgaOVpWs1wHIK6Amb 5NcvuUGUMW2GGEo//egqsBfG/87Cpb0MW4J9U1bBEfq/GWdXNTamBqxhxyrTpKZu1G6hWqSQRsy7J G4c++h/Lh9GN05y8Zyagpn+yGq3iv9/+o0BQvkWRppgSHHQD8yBjXKGOmc5HnNNVbx82z5toWzEP3 +7ZHjZSnj1PAB1Jm1z9MuROJ9RGO5cPBEgHzDfIx259nHXEcdVO5xk+ROCQa1jshcTfyTIOm/7d+K 2/Cs73oRZ4M9w4T+l4x3aAYlPWOmjlBF6MqroGqzb1wNUZZOQ0X/ZdOTVoJnNMU00UqOVQOZ3OeZ3 kQbVe1gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJgbK-00000002sPo-1eFT; Fri, 06 Dec 2024 22:15:06 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJgZL-00000002rwi-2GP3 for linux-arm-kernel@lists.infradead.org; Fri, 06 Dec 2024 22:13:04 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7242f559a9fso2759425b3a.1 for ; Fri, 06 Dec 2024 14:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1733523182; x=1734127982; 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=C7rXiwNlneTt0S3Im0z7iFr8r3P4BVASAMn47K57uCI=; b=SRHNrsUllpC6fHpKJzHfMa2ar0ApXSAWaV6NlW+MkiF8c1QC20oGwxOJyYexqYMcGA pTOg3e6YUSejiR60PlNkBQkxIgvw8nWwmLBqhKmAftqkQEB4TzUBbBpYg/DK/e0AIv5D NT0v8FG6aKWXGYNAfm0ddi2+dVILpJxOHKrddrZ1NTWBxQ3WO5vqLJqtrPydpFZA2MpO 3enZEklrl54SBQgWHZ7qvnaIil2fS5gNTMYamfucapxu0Coq4+BJhxGj+Y5nA8uE/rAC NWiY4p+eQKqJIBp1AdMnLktTli2/bEMEySO9Habvuq0D24jJx8w6+1bjjWBIkGQnjXa4 M+2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733523182; x=1734127982; 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=C7rXiwNlneTt0S3Im0z7iFr8r3P4BVASAMn47K57uCI=; b=ITCd6OYzhqdUP4shYlAwObgWCuj78GFM4sxzIjc4KjCHezdgX3QffnSBcBYZUd4KXj AUsRftuTaS+xfxIIhgoqGenDKGNyVeWtMEpxMWZi+sDU6D64cqKUfcbIpRATGLylUkqS MecEA42wobHeA1pwrDzt9AC4C0hOxwseR6SjKyDnnNStOXJjmtTkVCEoIsMx/6sjAtVX UX3cb6LQEJ+3KnevZgYxKN+Kv7/90A6OXK2iBnzvUCh40w/eNUHAamVbWOEtO3SbKFWf mLGc40yiVwcMlkqmT+i7qruX0UMb7DdffvT2r+qWG3sq7Wxj1V9YpG7Qt9bFy2NbQKWP cCcA== X-Forwarded-Encrypted: i=1; AJvYcCXW+mZYp2X753gNLOchM4FRW0N0skueBG5J+i2hDK1es105YbDST4+uc7HzZiRLAB7H9xyfvb4jrM3k0tQZbmHF@lists.infradead.org X-Gm-Message-State: AOJu0YxOGnx9uBrqJotQDAcwVgyFS8JhKYxwlCkeNXsgkGHvp6NNfQ5G kavVnJ/mQHjb9KPNgyICjAMHOKDb+L86iwHNEhA5a1XnvPgBpkkwCBJOe9mmxfg= X-Gm-Gg: ASbGncv4z885fdMUIy+JfWbDW7le5xZBjm8h9KlHrKc2FJZ6uZ6aMA3A0r/PPYMIzuR Dkd0FrKOMR5y1gWobz782FYaq5C8MEunwVVFDMePnOVv53kM5o7eS6nIE91LnyGEo+5tIUZpDrq k/F3BorGot5OyUCnkBZc38PuDC/Y8VuZ5ONH1FKxbFSafWcovTNOLL/s1xOnzKTf1Enmbps7KTG f8LUEMqPQT/y0PJ/b8LZD3MkSSsVtGIBWVw6TYSP6kdjv0c X-Google-Smtp-Source: AGHT+IEfJ6mTFHdobaZb1oZ2zV41f+MLXhV0wfwqztWK6BVWpG2aRCtQVIyY2AfpGqUSf7Ysz3ATBA== X-Received: by 2002:a05:6a00:994:b0:724:ed8f:4d35 with SMTP id d2e1a72fcca58-725b81a9cebmr6601983b3a.26.1733523182698; Fri, 06 Dec 2024 14:13:02 -0800 (PST) Received: from localhost ([97.126.182.119]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725a27e9193sm3435675b3a.0.2024.12.06.14.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 14:13:02 -0800 (PST) From: Kevin Hilman Date: Fri, 06 Dec 2024 14:12:50 -0800 Subject: [PATCH v6 1/3] pmdomain: ti_sci: add per-device latency constraint management MIME-Version: 1.0 Message-Id: <20241206-lpm-v6-10-constraints-pmdomain-v6-1-833980158c68@baylibre.com> References: <20241206-lpm-v6-10-constraints-pmdomain-v6-0-833980158c68@baylibre.com> In-Reply-To: <20241206-lpm-v6-10-constraints-pmdomain-v6-0-833980158c68@baylibre.com> To: Ulf Hansson , linux-pm@vger.kernel.org Cc: Nishanth Menon , 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.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=4286; i=khilman@baylibre.com; h=from:subject:message-id; bh=j0AdB2Ec/r7btTrtPaxqZvIVKLQ2BqKv+VHDX0Y86Yk=; b=owEBbQKS/ZANAwAIAVk3GJrT+8ZlAcsmYgBnU3bs+JJtfkcVGHUhIAcSaWpLkYXr8u3NXouG5 4fGc5caxX6JAjMEAAEIAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZ1N27AAKCRBZNxia0/vG ZfnwD/0StIlo35PDhUGEwnfZ+Rydqy8cNKGKRhQb5KzUsyiuOL4ELlJa5D33A8NB2a75+95dlsg gzK1uGvwIdqpVGPEq6kzS+6+66g7gKkGprQ3Mt1pFHFMBhA2cb+8NMzPHxNUxBjcq2CqTL4lMaM 1aeQ5YlLV3GTpJg7ec0WmleQRWkSY5XouNK3GFSSqCwFSYy9s7dri1gBDuzPy/ZP9HfEK7FoBA/ 3P5NITclzhBf0OuMF3qmDhQFC7TYX+CSXxKQFQl950y9xpy2zOuKRPWYO0XEqJfHvzWA9Wz/xGi ujsnul6qP8wqGyjbkWZNGHQK6lq2ryliZRnDPhB686kUFKNf6iFdTRISMa7TLHBkMoC6AGL4f+o 3NB5yrgWOjEItFozVTrPtZSt37pQgCRkww7gFaE7EFPt1EfLXkclTZAjWjodA2U7ndDG3DgMUmq 1jcKS7HMQH0iJfAcwDQKpPOZLaakslLctyRlsaBG+duSUZY4moA49Ork4iUCUJObMSpi3zBDDDv wWNjirwjI6iGIrTw/R+v9Xkc9mJzZZQSGm/J+Py5lPrJqiDHI4EgSkBuCJoG2nfoHQg9qJ8vsX4 ijrbm+t0IDGLqpMgS+qFX0ViTMvxFy6qMkuCiNCji7qFNIVQhop1ioKJ68eU6Po1/wD3XpUlu0a SKtqsstaZbro8JQ== 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-20241206_141303_609368_CBAC26D4 X-CRM114-Status: GOOD ( 17.55 ) 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. Also note that the PM QoS framework uses usecs as the units for latency whereas the TI SCI firmware uses msecs, so a conversion is needed before passing to TI SCI. 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 Reviewed-by: Dhruva Gole --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 0e4bd749d067309654307484c5bb98711bf06daf..963fe1901c959197d5d8b5d34fd8420dfb180087 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,32 @@ 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; +} + +#ifdef CONFIG_PM_SLEEP +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; + u16 val_ms; + int ret; + + /* PM QoS latency unit is usecs, TI SCI uses msecs */ + val_ms = val / USEC_PER_MSEC; + ret = ti_sci->ops.pm_ops.set_latency_constraint(ti_sci, val_ms, 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); +} +#endif + /* * ti_sci_pd_power_off(): genpd power down hook * @domain: pointer to the powerdomain to power off @@ -79,6 +107,26 @@ static int ti_sci_pd_power_on(struct generic_pm_domain *domain) return ti_sci->ops.dev_ops.get_device(ti_sci, pd->idx); } +#ifdef CONFIG_PM_SLEEP +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; +} +#else +#define ti_sci_pd_suspend NULL +#endif + /* * ti_sci_pd_xlate(): translation service for TI SCI genpds * @genpdspec: DT identification data for the genpd @@ -182,6 +230,13 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) pd->pd.flags |= GENPD_FLAG_ACTIVE_WAKEUP; 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 Dec 6 22:12: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: 13897860 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 60F53E77173 for ; Fri, 6 Dec 2024 22:17:21 +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=gO297//2n/rgfagI213U6eCWKlgwMp68Rn9iCoz6hZE=; b=rlAO2uILAp589upjVmOlva16n/ w5uyLsnayhW+npk7zhu994+UXXfm4NqRq13S7wzirtTqq790PEH10pCPsgG6QYac0ScUkM+7DK9A1 X8xGwqvJH/JLCyO92Tnsd3KoNnDu6lpTdqPYCxFdKamp3eK/eStiaD6+5t8fnPD1rkonBwMOsIy0D CeIIrnDQ5tTVNHSkht5Bmp2jM/Mgqyq/A54I0whF4OF6Pg0T4Wc2KM7NSxfZhbGQwHsobZY0JfHRB 2syQ4e0EWjxTlweSm/STVWIjd3OKIGELlefy7oK50N2e5zRrrOqri/so3Y60QS3cs2PM0XiAey0mm GmBAeXxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJgdJ-00000002snK-2xxb; Fri, 06 Dec 2024 22:17:09 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJgZM-00000002rxJ-1WOY for linux-arm-kernel@lists.infradead.org; Fri, 06 Dec 2024 22:13:06 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-215d92702feso22246695ad.1 for ; Fri, 06 Dec 2024 14:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1733523183; x=1734127983; 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=gO297//2n/rgfagI213U6eCWKlgwMp68Rn9iCoz6hZE=; b=1PN2iqH8LfFzo+KiFCBS9oOz423oHHA1ffpr1Qv2urfP+QjkNbbjwygvTJvvDfJGsJ UC3AJHARvJR/a6NMpkN4m9FSSeH2bCcCdrG2+DvBZe88nETlB9UyJT8Li3Lfz+fYBYAv xwP4fpb6nQBOU/ShFWN2+DxZieXeH4h0yKycb8IspBuTIkKThI6xmUXOqBV4Z0iioxOf 1GUx5mT09HKgt4GRpT7KI+XnPuRQ+H6Tck7a7XAaFaesrh+QPe+SYUAk8Qsorc3812N3 ly9GXkXZH71oKzbuagxknkK/D93Bffl+fVpfW9Apf1rjOUseWgtytwTPW3Rer2No9INe bo7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733523183; x=1734127983; 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=gO297//2n/rgfagI213U6eCWKlgwMp68Rn9iCoz6hZE=; b=WSIOiNGAJ4k0RbnzzPWD1I27g95PbJ+cCn56kEZg0NI8eJbfDSqZUeAitpvB5ANbA7 yX3gfqQgRLrih26PLxC2cXjtuEVaVbUvE+8Vk5GOslxnbA0hnJUG2zka1JSDhR8T0KX2 B+wE2wLmlv0W5zN7TvLml/biWoR6ggyhF6AUJKypbZt8OD7Z7+gF/EMic48kN99mTB4u ayrqxD1Cdhcle7qzZxI3wEm/+/ZZiajRn/TVhyGnoQ1ScXCuqmwp0sJ+PjfgGevTG/hf WEjGQO0vI1y6ehQgjdyOS7wUOAACzMZvmmsWzqZsbuwB0UvYBysZvlwZG77+GM0F2OXv XiNg== X-Forwarded-Encrypted: i=1; AJvYcCVavrItXFYvVdqdx36q5JcaZPL0XShoVg4YvaNKersFfYZZPuF6VDLUmI8BEC516RLepCeWcsLY8Oe7pYPBEdSB@lists.infradead.org X-Gm-Message-State: AOJu0YyYsf0eD8lARL8U6rspP0EcGGEdDPPbYn/H7lO1kIH+ugp3/rnB mxioreOljOWta12QyNfkYslz2yRlE0w89rMFIfxHsOpUex0+8n7/TAGe4tSN+as= X-Gm-Gg: ASbGncsVmRcDshqKkYQYhqjckRpfsf9OlPY5jPDss9kJBARvBm4eeqFr9HJ7qlwgJRV fhhRfEfhKWOLuagIPl8Hnjci9TpFcUOf6XTMMVJl7N9WjZs6DQbMjcR0EPWIzpFXhY/vykBfOqy 4rcNHfYuEo71cw1OoE5okdZFGOYKvbt+lIfsnqa/FhAYdxlQDMGbY6JlbjrOhTi/G4dxwu5/ZtU 1PfMpfO9SdbTnnU3unTnbgcHuQtL53Fove7vgSoH0/aUJHm X-Google-Smtp-Source: AGHT+IEV5xymYqZ1yJV9BrjFB0Nh2Eg2LOwsypkmTdkIep4O1iPhv+s2TJ3JIQRJlUDRcRjBY3qeBw== X-Received: by 2002:a17:902:f54d:b0:212:68e2:6c81 with SMTP id d9443c01a7336-21614d4ac70mr65378675ad.24.1733523183496; Fri, 06 Dec 2024 14:13:03 -0800 (PST) Received: from localhost ([97.126.182.119]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f31a87sm33273575ad.268.2024.12.06.14.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 14:13:03 -0800 (PST) From: Kevin Hilman Date: Fri, 06 Dec 2024 14:12:51 -0800 Subject: [PATCH v6 2/3] pmdomain: ti_sci: add wakeup constraint management MIME-Version: 1.0 Message-Id: <20241206-lpm-v6-10-constraints-pmdomain-v6-2-833980158c68@baylibre.com> References: <20241206-lpm-v6-10-constraints-pmdomain-v6-0-833980158c68@baylibre.com> In-Reply-To: <20241206-lpm-v6-10-constraints-pmdomain-v6-0-833980158c68@baylibre.com> To: Ulf Hansson , linux-pm@vger.kernel.org Cc: Nishanth Menon , 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.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1817; i=khilman@baylibre.com; h=from:subject:message-id; bh=UYKwDCjPt0Pb4J8LYvmA473uK8bBnXmKBatytxsKAXw=; b=owEBbQKS/ZANAwAIAVk3GJrT+8ZlAcsmYgBnU3bsqDLxWO2AWpws47wAA/jFbeDffWrz4qPsb SyYgMi7CCaJAjMEAAEIAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZ1N27AAKCRBZNxia0/vG ZRrND/4xtabQMPgyDLpYgMJPS1c2LUeKnOTWkJ83z8YH1AJs8pNydn7rBCna/HveiMWUjn7DPkE KKjuHB+QYLsgb94migpG4raM9BQZK3UVq5Vv08t7RT8UtHiwo7OTJj2DIPhXk/U+ic7dmaFjD5u yDFV0bFWqpRXJ9oHvLvS7yCWjQy/U7jJxQKVMUQT53bQ9rDXdewLkUzf5A6lwtPodtCArIZnYb0 OhbDVEfLGmcRMBVjYsQKYXHRCbCsucsAvqB2quIcXCKrLewvW3dyfsCuJQ74kWnTjccm/hXToSo MQmwb2jaRhnuUDS2TYZq3y8pkiGM6obB910shrpH8UrZqdHwDlzhahtBnvbE0gk3tkC+LfUJIr9 PE5ciY2YECShjBF4B33L5g+4cIngkCf+Em49mC8LJKf4ETH3rac8WXlgcMHS4NfaAbvzeXiphbH T+qnxrpBzYPUkTAmkj+Iffpmjf2oGsbILBNduO/ep9k87AbAoVe1W3jZxjUUiqa56o1rNN6JjS/ Gfb+K9K6+UA9ipYUJc+bQDtSaeFArjOtcjDKKt+8NDeK6asdGBb0r6RiPId1HLPfe+IZcoxY1ay QeyzotFYL8gGZxyh3wpDySjl+gEVhMUHtI/AfAebsDjUEBM5fUE+puI97FJnlCZUo3fKYudUuqJ 4TCOKcNnemEYO8g== 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-20241206_141304_421606_55DC572E X-CRM114-Status: GOOD ( 13.08 ) 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: Dhruva Gole --- 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 963fe1901c959197d5d8b5d34fd8420dfb180087..587961519dcc9e13c32efe76cdaf801281f72f67 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -79,6 +79,21 @@ static void ti_sci_pd_set_lat_constraint(struct device *dev, s32 val) } #endif +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 @@ -121,6 +136,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; } #else From patchwork Fri Dec 6 22:12:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13897861 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 2A780E77173 for ; Fri, 6 Dec 2024 22:18:21 +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=k1Ep2O9wbC6ZlfsCLYQrAmWucAGOrIVsXyOuKD+Yvgc=; b=sTtYC0nUyVgfGRSgGk7539upxM ifoH3D3PHWkofC4A82051EJ2dDklk/fQQDSAhuqAFYaJDZrxn9O7ucSj5lG21Vjbkz+J5CTPHMVuH 9MUkacOMU2tjbwcZ4mPEDYNM4f9whWRDmE2Setdh1oO6JpNRQpbOGhNBhHyGgIcBXRTfA671zeIXV ZpryY8iidndswxIIjXiCzOIrANCQrranRqH02jyG6hM1zPrPyTH8Tx8iCeeKcvbz1SpS0pqx3r1dD 5O5AbobEh8kujyjXaWkQ/xlL9pGOLICYl6qCnyd+g2opsRQsnhX9+UI356B+bpkCRkGB4fnQ/kkTO RTtxZmsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJgeJ-00000002stN-1tlM; Fri, 06 Dec 2024 22:18:11 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJgZN-00000002rxb-0ZOa for linux-arm-kernel@lists.infradead.org; Fri, 06 Dec 2024 22:13:06 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-215348d1977so21642965ad.3 for ; Fri, 06 Dec 2024 14:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1733523184; x=1734127984; 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=k1Ep2O9wbC6ZlfsCLYQrAmWucAGOrIVsXyOuKD+Yvgc=; b=cexxNts7vm5T3PYbONT88FGLKi06Hg6iujcqWfAHCWpSF+a1ivcfQVMb/dFn8QAKF2 hGeAkYOHE5Ci47q7VmcSUdnIy/OsQmjr4K0+/tEZZbl19BLquapg955SawQxOeKCk7WL PI8Xr/8jfCZCAFI30v4PdJ0kLqfAY/RrYEt8rMEjssm4I7syj4SzbFYkE/72hWaqzHfk /EGHIUCnJQ+SABXgPKvBoNDkCQq1ODTxUcSmi7CzZ6Mtd+EgUToKCbr94uP+i6KKeVmU ADpG7BW8tZ4Scf6I/ue9/kT7x0cTTiN/P80n5KsZ7ust6Yr6AHdI6AM2b+glMcevD70g LIpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733523184; x=1734127984; 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=k1Ep2O9wbC6ZlfsCLYQrAmWucAGOrIVsXyOuKD+Yvgc=; b=TiceEb2uGO6uesUy02UvGT6y7W0MkhaIltpT1Ry1xnoK2J854fh5leu/rhzsDaFFk8 JkcZqG73Y/P1MC1Cuz0xq2HwUD4+wsTBxsyFigDn6cIOEQCj2dslnn4xL60xjGrysXRn 6EtRC+DJqLkDhIKfsrnz6Il4M8dT/hukM5WslXzlh1OjnLqVR+uz/ZviPPK1SqPiw5jk wMQy/jHgY+75rbuKHV6KfNO4jtK+VHuSQrA+7gQK7U12qLQatqKqAm+/Zj7JvknzfVgu q3FwXJx0npNo25IApzltujl9no3NfKDk+L2R0PIACrz3G2nGyoBLQz0+tV+R6hWLmaBI Gf6Q== X-Forwarded-Encrypted: i=1; AJvYcCWvpptxxYPvQGXOvFor/tFrHoRpy4DWjW9wpfqzvTpWjFmZapVDJpZzDEM/Z7oqn2cgRE54uC/+a/LwZeqZEWP4@lists.infradead.org X-Gm-Message-State: AOJu0Yx10VisTqdJ13mD/LXPvzDluufysNYrRdm1o0swhSyr8UzcEi3e wb0J93Gb9Exe9xQntp4Fv6jj6rFx36tqjJEUPpFzcJ9l9SayWNattUiXGT6oibM= X-Gm-Gg: ASbGnctqYb3RG9MtNpibKVjqgBPTOk/arSltY4cOcNaykYRhgZmFtMxQ2P1WX4kxt7O 3Ej5PGnxfI670vDYGwx6oYUCiVsgC84QHGNnMSbP/H2Wm4oZ8buHLptASoQAsGpE3zISVM6BIdG mLd+G1tyca5gmgkhpT5n9QCZg/jhIL0zwH084IltzApA7FzkxUtEzvbRZ+lAYvIWfTlTp4MDfOA 8qeCMSJQWqPPIQlaiRDKBFyvl8q+UcxpNaYq3KaZOXwQZRR X-Google-Smtp-Source: AGHT+IHV64TQ1MOmZpTLIsCVD0ziIh77UI09rSBXDq+X4jwn5nrPeDN6Vm4VrpDkqcW6GWDyrxNBiQ== X-Received: by 2002:a17:903:249:b0:205:4721:19c with SMTP id d9443c01a7336-21614dcda61mr70577895ad.37.1733523184271; Fri, 06 Dec 2024 14:13:04 -0800 (PST) Received: from localhost ([97.126.182.119]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f09120sm33444155ad.177.2024.12.06.14.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 14:13:03 -0800 (PST) From: Kevin Hilman Date: Fri, 06 Dec 2024 14:12:52 -0800 Subject: [PATCH v6 3/3] pmdomain: ti_sci: handle wake IRQs for IO daisy chain wakeups MIME-Version: 1.0 Message-Id: <20241206-lpm-v6-10-constraints-pmdomain-v6-3-833980158c68@baylibre.com> References: <20241206-lpm-v6-10-constraints-pmdomain-v6-0-833980158c68@baylibre.com> In-Reply-To: <20241206-lpm-v6-10-constraints-pmdomain-v6-0-833980158c68@baylibre.com> To: Ulf Hansson , linux-pm@vger.kernel.org Cc: Nishanth Menon , 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.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1635; i=khilman@baylibre.com; h=from:subject:message-id; bh=MvYLl1dkczYVZlHhGI19Lnk7zfxJItmwrZlS8xz45cc=; b=owEBbQKS/ZANAwAIAVk3GJrT+8ZlAcsmYgBnU3bsod2B2Q8ODRoP42LqdWQ/Hgb2ui7QUvDSt j6QUnJ9692JAjMEAAEIAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZ1N27AAKCRBZNxia0/vG ZWpiD/wN88P5QYO0MxFMU/+oEkdJG9BPIJa59vyGq6XcClgTY3P1szdPJum+NRMgyjYE8GeXT9F Ou6dZP5N/1KV8FAnqUkVJI4kuopqiGzO/F2jW6vY047ixx6MQrpBuhIDKowMEzItRjJxfZMRb4X AvOJhHUihsPkVHICxUdUYEoaKpdlbPl7NFTDuzLM5eoOFbmtwl5riyz8q9tnKsKC79nwBJ6o4Ko avT8z9TAefa3XBuOMrI9M2LYMA+bua+Yh5VYLHYmm1Vs3VdIowjoKPJ0ThUMz4OFq8sEbBspG5i 24O25Zd+q+dqR3xflEDHcVhxkb/VYlmGqkIY/awyW3IsMFiPgoPb2c2FJYktQVl/wjJfnVb/4UX PoINOLb+w7juAtJKByKaUxvUQBd4Z6U1m3ePJVfqXAik5KvUX/3jo2JpGoJozlMxppAxp66NpTn GwK4Yj8hCtPd2ELxnYpPv5y1c3IFZ495IjzVbemGzHjHWQ3PnjcLZv7KcDZdkoZYc9I2ljyoZV6 ew5zdI4DBoZ4eIhajTwKrekEHg6LEqJJhjwFYyZ7N1+gTum/WH1wZXGtePL5OE6oEPIr2nquWTn HZQaMqJdLZ2es2OZP+MGBkXEBWVhOfCBjdzQN67NQk7qLd0L0/CY5bo4d/CoL+nu5/q3apBAvc9 L4PxM9YgNeY4bIQ== 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-20241206_141305_224919_12994644 X-CRM114-Status: GOOD ( 13.03 ) 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: Dhruva Gole --- 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 587961519dcc9e13c32efe76cdaf801281f72f67..3fb78343d4388a7087dab5061c1127586968ef19 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -87,6 +87,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)