From patchwork Fri Nov 1 15:36:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13859554 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 056FBE6F069 for ; Fri, 1 Nov 2024 15:45:23 +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=k3idRexV6BiHXZ5h21OJlIktjbdShqDapELZrhtrPoA=; b=3f8htrBXLlSb5UBH+p6pkNiZyH K8+4IIW3Ewh9YJNPzzkF6yxzgRkqHDcUBDfGKiFgffbqo10iZQgf7GupqO2dBCbiU/G/DTu2LLGK/ h5dVkbOop5ojYjYeZUdS2B2pzdo0bU5xHetZggeMVbVqtg1h+mR2uV3FtofAYHv8Y5uUtiurPWU85 0Q2CmBsTpA4Ks8+A9tNuQ0qV+YZZwVsqUQYtFTnSBCCvqw/GHXokws3+veWX+GaPZKeYLRC82Pht2 jYTmXBhIzS5en3ryAT8K4dbdviiRCz6rBpEpLUvm0mi41SjqyjjwA9X9Aw6hD0jWCt8aJndx8bvIg 2AljZ3vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6tpl-00000007YJN-0lTh; Fri, 01 Nov 2024 15:45:09 +0000 Received: from mail-pl1-f177.google.com ([209.85.214.177]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6thg-00000007Wys-0AX8 for linux-arm-kernel@lists.infradead.org; Fri, 01 Nov 2024 15:36:49 +0000 Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-207115e3056so20884345ad.2 for ; Fri, 01 Nov 2024 08:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730475406; x=1731080206; 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=k3idRexV6BiHXZ5h21OJlIktjbdShqDapELZrhtrPoA=; b=QJbtpKmQY6pQM61/tdk4c8iwVBaUMZB31lGX3CpCUMP88Wd55XqAslOcNncZmdg6kN xFTueduByz9c7APbYNXVweRL+9LECwlGvICUZELoA5d5QJaS7bAfW5ihSZS1U6Q+xsbB txmumpfu0gTLx27x0w2Az776soSPT0snzubUfLJX9S2dEFhPKiSnA0aIbG0KZgFWEMTy HwvGEEKlrcy/rJ5UzJON+chyK9buUev7f1X+xYedbtIZPBeJufqXLBBM8ESa7OqbP84U QlB4lTgqWrKrJbPjG4Wt7Bf0B+FalQW63DiZt/tLX8IkGhQl0zU02aBHOuhfYGDF4oJp +NSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730475406; x=1731080206; 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=k3idRexV6BiHXZ5h21OJlIktjbdShqDapELZrhtrPoA=; b=DIaWQs7hUcoGmaos0AeEzsC5AlS17RVq5BKFzTBwRGCJv+hxJtOEWdrjkLw97gJy4m LTbpOd3vWfMM66fwUslAKwY4XwFB14Sct4rbvuBVxk9y0GtrqzoJfxS6hWaIBSsRsUbn 2dCZd1WNHhuIksjRZcRpqR+n2gvLQ3PiFEuvMOFHoCyhmSJUBzNnIl006n4L9jGmpaBd AHLUU4xR2r39TyRBpfYTrs3+WP1WPVVgR+1uaUQKujpaZZdIb9h29pyqSMt/UZYkHlik x4joGv9Xmkx8XEaeRGNh7yGW+A6kBJu4WHjsO7f6DeJ4PllSo9WcTDoRKzsOzp3oWcqy CQVQ== X-Forwarded-Encrypted: i=1; AJvYcCX4x7S/PT0LzqbN+UN/iI17kr6qkw9a5pU6Noxpzj/he91pJs6+JWRGQxZl6TmBVN2zFYJibpuIz6iusVCU/Zzz@lists.infradead.org X-Gm-Message-State: AOJu0Yz/uyXShfp0aXqdM23z+vaGQ1AuEfLjuY4pnDxHOd+rpnqoOmjZ Bfo+aPq1cFyzhTYyDg6270fURBerAXTAqXaQHrEqnYjt+fUGXT4vxP0MxB5WG5U= X-Google-Smtp-Source: AGHT+IGY/08HilcbZmR1lKyyTr906chNTawpACDKuD2s3QhEtikW9I1wYr4l+lhIq37jX+2CszHKmg== X-Received: by 2002:a17:903:11cd:b0:20c:f0dd:c408 with SMTP id d9443c01a7336-210c6897f24mr302882505ad.20.1730475406525; Fri, 01 Nov 2024 08:36:46 -0700 (PDT) Received: from localhost ([97.126.177.194]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057c1189sm22803555ad.204.2024.11.01.08.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 08:36:46 -0700 (PDT) From: Kevin Hilman Date: Fri, 01 Nov 2024 08:36:20 -0700 Subject: [PATCH v5 1/3] pmdomain: ti_sci: add per-device latency constraint management MIME-Version: 1.0 Message-Id: <20241101-lpm-v6-10-constraints-pmdomain-v5-1-3011aa04622f@baylibre.com> References: <20241101-lpm-v6-10-constraints-pmdomain-v5-0-3011aa04622f@baylibre.com> In-Reply-To: <20241101-lpm-v6-10-constraints-pmdomain-v5-0-3011aa04622f@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 X-Mailer: b4 0.15-dev-cb14d X-Developer-Signature: v=1; a=openpgp-sha256; l=3966; i=khilman@baylibre.com; h=from:subject:message-id; bh=Ewuo8tkZRIPnXmWm+AAeqen1P+AccwVWLIprM0pWxB8=; b=owEBbQKS/ZANAwAIAVk3GJrT+8ZlAcsmYgBnJPWMo1qK7rflgRga9T/TyTsA7X95SDxo2qEx3 XJ5U8aE5veJAjMEAAEIAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZyT1jAAKCRBZNxia0/vG ZfTJD/97EoOKKx2D/jgBRXrjpmjWbT2pCWYpAORn4EPRLgpHjzYeqnJbXXTDyPv5LwBDVQ0svyY /1R8Me7OjWOmjdHWyfAwOJZLVGQq22/B7pSfLJbjfaLQ7HvkxtB0qbcWFS/hjbI9osjSS1sTK7o 2h8Enq+TNtzgqAX+7Q/zp57hCn2KwXNNDpgFQBSk7K3KpupCgNwUlM2faqLGPwlqEyTMUErWBCv DETk1E/RGFQEOX04q1mt6Etjuh/dxDzNzZYShU0X2Icn3isEtAnaYgE9c1l4Qr/qfGXRZjAI+FV AUQKl2BXfW3ylqH2ycOub+jmie1yf5OxygCWbKwt9B0s6in0moZgaBLnbVwWxUbvgYeDTanCSqx dHriZzlHlFVtIYee8KblIl/0fh4qCpzjfNT7L+Igm6U4TjWuSZZRfclIa/YNM3ejzXjaasVMj4B gVC+UNOXUDqO1REpYRN2hFjm4clV+wogBxM4awCvXbXjUBz6IK+OipP7DP9i1JOWiCUQWZSuMRP Jqarclr/xN1uUXq1l1ilzgQkEoPBP93K4xgjXyXvisyEG4Ql3N2LFKE1w6CaQHvsXxCndK6B4ra NENxt2+KIm9MxpPT+fgTjqZwNNihsyCd6aCUX2fb4c1/q0Od3gw+YZPtbbY2Y3rteNa+RYLHPGd wEsoQj61WEHQpGA== 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-20241101_083648_119646_B8D25FF0 X-CRM114-Status: GOOD ( 17.22 ) 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 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 1510d5ddae3decd5b70f835338ed4e0b2a3c9373..c976a382d64c807daea72fa1ea9d6c11c8773762 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,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 @@ -188,6 +231,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 Nov 1 15:36:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13859556 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 D7C30E6F06C for ; Fri, 1 Nov 2024 15:48:52 +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=ZAkCsjd64377nzOHo9/POEtdFNrxXL0RDJBoIc/E4JI=; b=H4s9VfswaV4rBREw9gwrY2RF+z 0wrAAOmEzcnneA4hYQaEU/IcxntqMeAj89YJSi219E70TD0GnQzcB9Y8QH57XbNYW+z2lWLb+QUCA CaWwH+Wvyd6NWpQfQJ5hDTbXhTnP3eQdF2kqYoHHD/dwNiPIeccY/4EZAXlMijB21QYKNeLyyGYo9 9dbtsCFd9Pt4pboMM7ah9tAgmL0TajaLer2Sgoh49P7qU1Ux9QvfMsXbmtYLHF/EPsM4GXFfVRx7b PPv3nqnJQ/opz2D2qdwe2Db8Q6/zRURQ2zjUn59Sld9k73+NyJN9t+47ae6ZDosjuay0cEbe567/M fl/Fv5Qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6tt8-00000007YlW-3JDx; Fri, 01 Nov 2024 15:48:38 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6thl-00000007Wza-0uQc for linux-arm-kernel@bombadil.infradead.org; Fri, 01 Nov 2024 15:36:53 +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=ZAkCsjd64377nzOHo9/POEtdFNrxXL0RDJBoIc/E4JI=; b=qUPT9Hw772m1WmcOwDMuEyEs/7 BSWbjIntKFzYc5OQVfSIGUIWRT5PhPyw9+6xsLPbeLe08gTSvQ/1+0k8RXV+vGHJQcHuVANEkoruP BJTyItWVCvJGcqIPFdJ2i8zcZP39yVYCyCOSi5p+wZ+Ety2q/5YS/jZRrA5tsBS0duyexHszNh8zP gsMvTz9rqs+AfYwpB4Osl/YWIx3SWOVFNNByd5a9yXW37I/rjMhsylaGjez1vP9+iB7lPmYxjrxwa fGnRA2VPMXX2/duyJMk9L314/t7//YDklnLgy+btvrcBBUZV+Yp8L3Rvvp4f+t26J1voCtMtnhhuK w/bhnIrQ==; 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 1t6thi-0000000AlAu-0ZqV for linux-arm-kernel@lists.infradead.org; Fri, 01 Nov 2024 15:36:52 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-71e4244fdc6so1733620b3a.0 for ; Fri, 01 Nov 2024 08:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730475407; x=1731080207; 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=ZAkCsjd64377nzOHo9/POEtdFNrxXL0RDJBoIc/E4JI=; b=TUi3ORllD38bmefuvnKWvuxXejLB/M0wAYJyZHJl/aqU1p+EtTHJ3QW+OrbLuIvcKj DhgCNACo7TRLRUY6OCHPtNq9DjbGzyf0k4oA4wcsb+n06r1kDSOqTVmx8FC8l4SGCp97 iw2Se0FicjH2bAZm7/9sf6aHciW5WMLp2uGvNgsqiYCrnyh/P8CjXrEKt93qKx1GKjDJ dcPxPB9F8xqT2j9vMiTmW9NXhbU74/osewaXc01hyHSmO2mxs/kdLT9+UV0hBx+vsYLe vxvVjGCiEIXasDSIj0aHatABVJNaSpmjI22ddcbClesdjFRdOlCbFL3Rytl4iDQ1ef7i Hxhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730475407; x=1731080207; 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=ZAkCsjd64377nzOHo9/POEtdFNrxXL0RDJBoIc/E4JI=; b=bKTuNMoJJfBtwCo8QkeHkkzUjEsV3d4tg6FaV/02Zd31subcgrdtoXXRHs9mUW5ve0 t6Gn0EcVnoIotoOv2pkFEMXE0bRA2VKf9+sF1gCdIcbcTQiI8RYtuJLGDwm+DtqeXI/o aVvIt1wwENtBEQ8XLaaTnJQOvE7aygrN9J8RV+UfjvesUJZQdt4zQYOBwHkM4qU2mc8w KaJo/n1eVMIlzrZw46XyqrD0+/1SMv9evutrcJgIk4Q46d1mVL/gnRkiYYwwb7TixNnk JgUuNoLyBNWVqLWM478bAny8rM+cCWZE2YQ8k15N5szEEUEBQoxRjqFO8L8NHruklVfL CGqw== X-Forwarded-Encrypted: i=1; AJvYcCUiFn7HOVgcEGizM4GO/5LARODD7haBhCwKEfsTqkG23qX9wJjhyz2gCOFbmKL3VhlnJEqQzq5sJsMuUxfmrb0s@lists.infradead.org X-Gm-Message-State: AOJu0Yx2rZQGeP399u0N+c8TWBzHo0iHMSPH4zefcFygH0oQpuIJ170o tn6KOtm7MPpToyKhFWiHNMkmYCl2kdO7+LH1K9By6I+fANEgN8xn4XSc3ld08jI= X-Google-Smtp-Source: AGHT+IEFdgOZoHFIXn49wGqPLZ3SYk/IIboTgwbEWgDk6aBN4zZ9JHMpc9Eu70cGhL1y3h2fXMaZ2A== X-Received: by 2002:a05:6a21:6e41:b0:1cf:38cf:df92 with SMTP id adf61e73a8af0-1dba54358b0mr5218831637.30.1730475407408; Fri, 01 Nov 2024 08:36:47 -0700 (PDT) Received: from localhost ([97.126.177.194]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ee452b1643sm2605552a12.38.2024.11.01.08.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 08:36:46 -0700 (PDT) From: Kevin Hilman Date: Fri, 01 Nov 2024 08:36:21 -0700 Subject: [PATCH v5 2/3] pmdomain: ti_sci: add wakeup constraint management MIME-Version: 1.0 Message-Id: <20241101-lpm-v6-10-constraints-pmdomain-v5-2-3011aa04622f@baylibre.com> References: <20241101-lpm-v6-10-constraints-pmdomain-v5-0-3011aa04622f@baylibre.com> In-Reply-To: <20241101-lpm-v6-10-constraints-pmdomain-v5-0-3011aa04622f@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 X-Mailer: b4 0.15-dev-cb14d X-Developer-Signature: v=1; a=openpgp-sha256; l=1828; i=khilman@baylibre.com; h=from:subject:message-id; bh=j2mcJH9DFAs4uPVxByFXW0cY1Bip8MTsLuwf/lpgjjg=; b=owEBbQKS/ZANAwAIAVk3GJrT+8ZlAcsmYgBnJPWMwEgrEwQIThMQCDH53Co+Dy+UFgtBlPq02 yv5jNKxjgmJAjMEAAEIAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZyT1jAAKCRBZNxia0/vG ZVatD/9PIphhgrCdu4GvT0ZcoFVEWMYN/GveHyxQaVTgA7X8q9UnYzf4iDUabsgz2qdYYSriQJ4 LY9xLT5hNSDxrWndcYZWxPKlUY8LuFEnObdQgxSkF5ZIPQmZJDN67Aod2KvBS3eAE5R8oy5mg5m ztXHqiCZQLWsDmDrcIDn/tjPKJsbKsW6DJInNMWJE9lZxA1LUKU+zTttiVgdV98s+Ru/PniTjj4 heSjrtcAhLdbIE9g9V6beNrAoZef121yLyLGP9AqvtLz8DviR8uzHCxlSBuLdynS6WIzanAyNlt ijhsBPK/VaS2MM4IKHuNEI7ANMn8KFRG5ei6zCecMhtFKB0YUemewj6a+TvytfAosgoJmsa17xH 1dE387VUYyG/uxpPRRCLe3xEwAKx6O5N0ns9PM5eXngnq012v5Y9n+HlI5v8yQ4/rGMCaBbyCHj SPznTY2WdHrxB3FdhZPRz24njIsujGuZAFTaFzTfW/cHe7BABPQ2K+pAgMWWpeO1WCFsxWebf/9 EFm6sla20f+w/sUAQEV6FYK8HKTWD+iQxOqfo7ba4fhgAv2zLQoVXkc+4uBjgcxJ1P7tsK+pM3z B9Il7J3Kkv6vQniLQ59Uvq7ko8/Zy9c5R/0NZXOb+JS/Wu/MBxK5FipqemkpKR37ROfqBqyCPXS 3VBbw8YpsedLQTg== 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-20241101_153650_515093_33D13A36 X-CRM114-Status: GOOD ( 13.91 ) 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 --- 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 c976a382d64c807daea72fa1ea9d6c11c8773762..ff529fa2d6135cc2fb32ae8a3ca26ac055f66cf5 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 @@ -116,6 +131,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 Nov 1 15:36:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13859557 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 ABD01E6F06D for ; Fri, 1 Nov 2024 15:50:29 +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=Ke4bvOR1ARJKXE6dRhRI5chunW+2b5MmRjCBBzyOcvk=; b=nOOD3HqjBk4a8Yh0SEAdnHWgcz 8x6lYKN0nwUf9wzEbxoMbxV+oJbrD7WkxcQmXKjwZpQDEEc20hgzD05MI4T1lKII+D5zsu6lHTHIY 3XoVKJXEhYq6mFmgg83TdPoa/cows2ECDX3gtui8zRUmXeSCfEA/PTRbhlQ1xaBmpmFn0JS/VIz78 B27gUV5ymedIh5yO2U0mk9IlQW3MwsmjxcAypkbdn8jHjMdLrpI1sS3VCx3AP+EyABRmTLBJSlFys x45a4YernBPcRde9GrnzWcKZFHImG3+WlFPd0fUqt0b6Ruc2zV7mORuRv1vSsYFipdV1xzk2rRLSM kkLpJguw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6tum-00000007Z2R-0F7q; Fri, 01 Nov 2024 15:50:20 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6thl-00000007Wzm-45zV for linux-arm-kernel@bombadil.infradead.org; Fri, 01 Nov 2024 15:36:54 +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=Ke4bvOR1ARJKXE6dRhRI5chunW+2b5MmRjCBBzyOcvk=; b=cl3nGO85yqeFz6v1/V0efMuLxn FwkyYLGoyyYuGuQ6fpeKIL4aWF5U2C4shk8medILONrYSLDih4OztxsbdaoDr6rq8jYbwfNtRD/Aj oA3/85FWsnIP76z1cuDc0ypr/tGczpf73ybldt+mU2YeKKWnYWqT/nLj04G0Gk+fYfrBD8sU5Xl5h i05PeeNobZzuDR9mIO6zcRqi5jYl2pimGFyl/hM4ef/XovTLMH5FIOrC1iz4dpleK46mA4Oz3dzTs jHeSpnDdODd81NZFt7MboHSpwoPYSyhnAQAvkA8iBugbqbg17yvfZi3ePRPfgy0it7YjHHAoVf9TV SFUcvmtw==; Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6thj-0000000AlAv-02Xq for linux-arm-kernel@lists.infradead.org; Fri, 01 Nov 2024 15:36:52 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-20c8c50fdd9so21955775ad.0 for ; Fri, 01 Nov 2024 08:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730475408; x=1731080208; 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=Ke4bvOR1ARJKXE6dRhRI5chunW+2b5MmRjCBBzyOcvk=; b=K1dsu1nnpXWk8GQVf1jOPe0pxJWCBNT+mNiP/WaiOGuH6Y1tkNqjsoUjzs0my+sykt TkiYj6kTof9tsGT5EKx07CP45pnr+7Ut92rSCMTAzXbiR5mQq3/xSrLXNUOg16HOpay0 k2YD3Wite5O1IyKbc7eL/HSJvWNAk+nKL+twOPXjXhRLW9zRCCFSCOuBSS7V1YyBZbwM xst+PJX3sPIVS4Awu2IFl6gOVSWzTMd1kfcmCZxMQo2oKjHArFyztPNCcZzv64Z5oO9B gNI0QAIBAO6t/rmksKuJ0x3dCsWDPnxC2QSecHUHc9EyMUYWkeJWNKeCGpTtiaGrc7Dw KtQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730475408; x=1731080208; 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=Ke4bvOR1ARJKXE6dRhRI5chunW+2b5MmRjCBBzyOcvk=; b=JpxyhQ4kwjKFNOdSsbZSSdQ8lTTlJN0DUcBUIAw/cExpmnOq2zZ/Dl0nANsNb+tiqQ pOI8XJLm5T4zRacTH+KltMdNkkKSoI/mok1wr6NmInW/dTFTNbKHIYIXJnbeVkZDvyOv n4v94VupUL6P8qsKDK1uZE0vB9VoSCrDY1SSnDsJ2bBItbHvfkzEFqKbbVpM7TIYlS/Z rcWLBCp0I+7Ae+irRH4O2KQDaMBvsUP2aLy+HKqNWezIzt/VrdGfIp+Xg1VXbzNROgB/ i0zBn0HoD55NwWZdAUxzm8mBfddScJHb+qvdT0yQcmVcnoAW6aKfHPX7hFnG4dggEA12 UJoQ== X-Forwarded-Encrypted: i=1; AJvYcCUqwuvOIgzpGXSqKgn+AoJOpX1S72whwvn6tk7Aoeo2SgEE5IjpjuLsXj19VGWw9yUPC0URqsE8pFIYPBWNpFvq@lists.infradead.org X-Gm-Message-State: AOJu0YwzhoVs6cjKtWUhDzfIFoTw8yrhC6CdHdHlAK2dy9Zea74M3Wod Z1Jhjh/RoxvzkACFZpYvLmBtNtG4zrI2tUs0/sTq86MaYoQCcj8OofQ8MZWHRGw= X-Google-Smtp-Source: AGHT+IG/l+yDbRhZEjiD8rTuwk+Sm1zndokY3M0MeOuQu/ZKMTOJSdasBgYBgyc864NCeM2KcYX6rw== X-Received: by 2002:a17:902:d481:b0:20c:b3ea:9006 with SMTP id d9443c01a7336-2111938d4f1mr60409805ad.6.1730475408251; Fri, 01 Nov 2024 08:36:48 -0700 (PDT) Received: from localhost ([97.126.177.194]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057c1117sm22363545ad.224.2024.11.01.08.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 08:36:47 -0700 (PDT) From: Kevin Hilman Date: Fri, 01 Nov 2024 08:36:22 -0700 Subject: [PATCH v5 3/3] pmdomain: ti_sci: handle wake IRQs for IO daisy chain wakeups MIME-Version: 1.0 Message-Id: <20241101-lpm-v6-10-constraints-pmdomain-v5-3-3011aa04622f@baylibre.com> References: <20241101-lpm-v6-10-constraints-pmdomain-v5-0-3011aa04622f@baylibre.com> In-Reply-To: <20241101-lpm-v6-10-constraints-pmdomain-v5-0-3011aa04622f@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 X-Mailer: b4 0.15-dev-cb14d X-Developer-Signature: v=1; a=openpgp-sha256; l=1635; i=khilman@baylibre.com; h=from:subject:message-id; bh=xhPvgmqbX1LH74jmdbMgtdutexJPgNxRb87XIYrFvw0=; b=owEBbQKS/ZANAwAIAVk3GJrT+8ZlAcsmYgBnJPWMXtH5x8ZpT2datlNjpCsnJlX4SCLuKATpJ 3kgHjSOs9eJAjMEAAEIAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZyT1jAAKCRBZNxia0/vG ZUyPD/0SCDrZfCLPdsvedTVTqaRMR5mj5eDMnG6FkO1ciyUAcuO+putYwuhHhwRO1Aqs3/ZKdLf i6PBtuQOIC+eZO9emjOp8dYnBbxSLcuKLTRB0cZm+6oCb+eoMsjwaZjI35cD9VY49nZcU97x0kr +Go35m4aHJL/Hg9jhx1oJvth37B4kbl6SFJCtHNlGw3mnGBY25kU40H0bABOURDMeFYbpEXjc5Y kjMDsGE1H+r+s64wERgBNlE/cSYeNiLzNW5wNi+TQq49Ny6zMFxRk7j/8TvPee0rbR8HrUmzbgx 8MVDt73UR+rLmWMPf+ysyvXfKlNv96D1tlzv85OlERbFBGekt4tUD23FwZ4W+5vYJ4+S0myyVFu 6nbpBt2cBAMRLlMSohljYIKqiM9N62G+OLAlUvuEKSnKlZnFUkREq3d/RlO/7IPuw0m4DJqzCIT 1ci7p8KFmFnse9mlljjaHIVe9BK98xiVJkXR6CUyzDDhtDu5AtU/pMGyx4USAoTxarSI8b/LxMz PAMxc0Hlq+dPh6QbV8ryKUcnp3IbP/S56sCnr20ONCuHpLMgYn4az8Yh3WXmMoB+MDEocJgV+J/ JGLpJsTXbuHFsJC3gvV0g9gYmj2LiG+JOqwSwH1W4kLK811GMRoOJlOzz5HhkK3tKsNLStHsJyN 82/t/LK+VRSl6ng== 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-20241101_153651_221026_FC16795B X-CRM114-Status: GOOD ( 13.76 ) 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 --- 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 ff529fa2d6135cc2fb32ae8a3ca26ac055f66cf5..8c46ca428f60b3d42a5a43488538f16b7ffaa3ac 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)