From nobody Wed Jan 15 11:11:40 2025 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F2C815532A for ; Thu, 5 Sep 2024 22:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573806; cv=none; b=Zp8SCg99CY97hHiCQvjNY521UuF4qbgDjwo8Kuher0CgVtqdd3CFJ/C8yU2ZulD0iIWMpwSVubfhCwf9bvfsPHTEuTBPzRgrRzps8yAs4peIuXB6yMrjpBYpkOH6hkSrRQI/MeVTq88z8A63G/SAM1uPTJCnZOfvnJgGevc+19I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573806; c=relaxed/simple; bh=OTRIi3ecXXaMLiOVU6kmi/0lN9C40N50eKF9jB9sXbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OL+fo5sPE7UxZgqTYIRGIC++HT1aqYLPKq8J0Z7wCJOwTHFKdT8Xj7XIsVs1jYfVONvlN/0vVKS24QsN+iBZTUMvKEKOJ6mm3C7XKqcCMe0vfijtH/S8MhVwPwgOAcJcB8GxUmb8sxV2aizkJu0SwAhmxov7mxgEFCLC926XJdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=IhWa4/Ry; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="IhWa4/Ry" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2d8818337a5so1823704a91.1 for ; Thu, 05 Sep 2024 15:03:23 -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=vger.kernel.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=IhWa4/Ry5jZt7Y5gI2gDGxi4Ze+6AmovJf23UUa6EDpdr938H/SUUh/RJdKNXKFhE7 OfwSMeoxdK3Qikf7HZDvVLnRxvox66iWaGJYV4MNY/KFuyp2WOgTRYcI1gDifbyTwXM1 3/uQ+xWNz/uQWKglBeZkXKmyO+VYtd/8Z9jwsohfFxkUOUgQD6TynEJ8nNLvnWCK4Gqg NaAc2u/YWMQv047IqLyougOTCzfx3uISbKZSyZJWSyOi32MqvtJXfyAJbqlJJOuRpL8e N9DBplTE0D0C4EY+9FkVEum5V69KOx2lzWtPUphj7YGgE/9b119tb+M+EW5VazopVV8L 1DWQ== 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=sOURbjEIfbt2Ph3SOFovy8xmgy8GlKnmI2PpLyG3cSI2CY6ZCfMoDytEbWmRYqOKiT w3TjDrDoLdyhvd3ehBxm8C+IZbzqt7/GElX4bgCBqwRQAfGcvrkgRXHWnDDADevF3jdc fskBjxbX0hTMzeU+IJfPBNIyxmw/9QrSH8h5fXzXjcjmS/l5PHaPgyi/8h1e8cCzvVrQ ojVX529y+ME0YA01Lb7YaLh2gozo5WMMxI9nVgU6DcFjeTE/tBfspG9dINEpxh+timQ3 3nJPqpcJEnDJFi+neUHN8Jxv7gQK6Gm/VMJl1MCDBCfxoCxjKo/wqIEZcE2v7NEKmIFA W4cA== X-Forwarded-Encrypted: i=1; AJvYcCWrpnc1oY7cqYFrvZ7sI7i++/FARNWxHqtJkNpy+H7ReYyk8G+eeVgtro44lZselOtQBN+uSU+CsnxQY8k=@vger.kernel.org X-Gm-Message-State: AOJu0YxXhIeKO+6QuC0aoiURMKGrP4qe7aMVJZqQ51jCLzAttit1GeGJ 4scLXTbTisxqDD0gKbLQA+2M+idiJRbPz7J9N9ic5JymYt7PhIVo3WIIJZhN5d3aDhIUWZKX0Fz dIFc= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 =20 @@ -51,6 +53,27 @@ struct ti_sci_pm_domain { =20 #define genpd_to_ti_sci_pd(gpd) container_of(gpd, struct ti_sci_pm_domain,= pd) =20 +static inline bool ti_sci_pd_is_valid_constraint(s32 val) +{ + return val !=3D PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; +} + +static void ti_sci_pd_set_lat_constraint(struct device *dev, s32 val) +{ + struct generic_pm_domain *genpd =3D pd_to_genpd(dev->pm_domain); + struct ti_sci_pm_domain *pd =3D genpd_to_ti_sci_pd(genpd); + const struct ti_sci_handle *ti_sci =3D pd->parent->ti_sci; + int ret; + + ret =3D 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=3D%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); } =20 +static int ti_sci_pd_suspend(struct device *dev) +{ + int ret; + s32 val; + + ret =3D pm_generic_suspend(dev); + if (ret) + return ret; + + val =3D 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_devi= ce *pdev) pd->pd.power_on =3D ti_sci_pd_power_on; pd->idx =3D args.args[0]; pd->parent =3D 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 =3D ti_sci_pd_suspend; =20 pm_genpd_init(&pd->pd, NULL, true); =20 --=20 2.46.0 From nobody Wed Jan 15 11:11:40 2025 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC01197A9F for ; Thu, 5 Sep 2024 22:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573806; cv=none; b=qq1+CXVoJOUgKyKW7q76IqThiW2cZr2LSyGuX9/cThi5yRWl/umRu23mR8frEDGJVLwcwOYvAjnDtMRFjEgSCWI/GNssbT64dVL522wbEHc9jodZz4zLokVitb5c2aRP6fMeAgQk0gTrHTCCj3yEiom6hchF/niRhjp4432wFOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573806; c=relaxed/simple; bh=swZQv+32F9CI/ZQkJsomr4F+HEjzkbq8crWIZokZMtI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RCI8yEz31b+bEtSelPuSaCXXOMrnSnpaV+fkckatAgQjpNjm8Hb253GFbmGNlFl9oeVyR4P4S4l6gHYILp/YGWHp4Tih+1lkqn2lS+LUlJq0J6ala3TZfZS2ai+mbnxMOqCSBRWbHknaGjE5mT6oIOvilgJ1r00EAEnpRL+Rd+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Q20Pk5bA; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Q20Pk5bA" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-717986530ddso660864b3a.0 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=1725573804; x=1726178604; darn=vger.kernel.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=Q20Pk5bAeN2V5eWyxjyvPDpKSopnIKPepQYhqpNAFHiYVVL3ohIgfP0/XM4ePsOhmu G9WrN5SjBiyNMld1+EOuKTs2u3hUCKpXFJA0LTTrRofUAWPmuNjmoIfvSHFAtS7+/tzY 16Nz8dZox0heVzKbS7I87usirM/KH4iIh/J/ldZ3JI/Ovi0FC45xZIdfS8Xr50ktsUvR VYCUf0FLi4S4nQQlfj0SHbvBbTb0ARHJgc0Rej2cFKWjXtwdQBJV5hNbgHNvNGCgYLXC iB1k/1QJX6D8W5ZtbEOKt7SGveNArtXCXABfZjXfLJ+skqhDN/aHWmWNR+vNMTGw+ebe 5G6g== 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=ejqHuePsWl+i99ge4d25RVEFU1eenTA0q8FrFPjPg0u+z0qtaL2xf36MQ08VU7dkK/ OMNqlCX7YpBZxPCnv9p3JYPY0PEJHuXV+1wHTSRop2PaXG7RrcfthgTRQNyCuiWf32ki jmKLATZVEBIwkQfBHkvaEGsgOU545Ame8d0gQ2lUUI3+uJY9ZeO3vsGSmoArwl4Pc7+O dFbaUp3ZtjQD4FAnCbI2ewj3rodsh83AKghk1fQx1m/rDbzxsHmJpZM3NKLCr9ce7krg ettRaEbVGFqG3v/H+e4AWzkUZrVLywZRIM/llFqqEYAp4sMrgBTj3kEcaId3GkSd4uV6 v4mA== X-Forwarded-Encrypted: i=1; AJvYcCVzJBZ6v/Kyg3O8j07unn1InotjGNRtdvCpsE0l/r/7IVIVivJF3SOOLF9PdwBjNnq/ciDB5RW5V85ncO8=@vger.kernel.org X-Gm-Message-State: AOJu0YwOz1qw/JZjlQh/CFwIyEGn9j1w6YTdMr3sOLWs8DngVrA6eMP3 p+P46lryhaMZoyHPxsJ0Jx4go7KRCrpslK+h3z89oAdKp0Yq7voFlqmCsgk07aswcMkub1QgFAJ SSjo= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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); } =20 +static inline void ti_sci_pd_set_wkup_constraint(struct device *dev) +{ + struct generic_pm_domain *genpd =3D pd_to_genpd(dev->pm_domain); + struct ti_sci_pm_domain *pd =3D genpd_to_ti_sci_pd(genpd); + const struct ti_sci_handle *ti_sci =3D pd->parent->ti_sci; + int ret; + + if (device_may_wakeup(dev)) { + ret =3D 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); =20 + ti_sci_pd_set_wkup_constraint(dev); + return 0; } =20 --=20 2.46.0 From nobody Wed Jan 15 11:11:40 2025 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 924B81B12CD for ; Thu, 5 Sep 2024 22:03:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573807; cv=none; b=HKXaBu52weXJFddLOT/kgAzXNeH3HDopWsarEJFKVVQjBCF08eFU3tIcIeYjC9r0QUvvZ5LeqbNqDQ6WbWjcczNvDzDfmfE5/P4F+VeuzsOXY1/mH7lIg2fbGSrshdZM8wmr6v7GtZV9nfT8LD35repF625uGawuFrquUT3BC7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725573807; c=relaxed/simple; bh=19dVWBfAz2qQyZpfPFRGd9UeDDF7grrhUskEDkVzmzY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XJu5fxg0hCzeKaLBiy+aNVvzCnXQH07+vBGJ8i1M7QFGKWTPbSYRYDCMHHcePbpJ7hMjVnKjZAZ5wasNsuiCreCIR9OfDylnh5Gg6RMxm0aWz/NRV1Nkd/BTNvYyHkrQEe/Nlq752jNepMjmfAxp5cLpDRYfXMlPTXojJziS0w0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=qRpLy/JU; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="qRpLy/JU" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7d4fbe62bf5so1017428a12.0 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=1725573805; x=1726178605; darn=vger.kernel.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=qRpLy/JUO7HI7kozWpdEFNvConhf/2e6PUOrULTrZ8swKv6Zn31hRMP62Pjg34MJgU nZAJPuftKFpEavQYFINdc0KNA37iQXeNeSeAycwAppjDyLFILldynUnwvpj4nayq6+G3 X4mGbWQJ4iycm5+kXEYuwtAgSSyVvprhjqcGEcqGkzKru/BEDkJOZ0dfDkPSmY5XdOQP J14dM+mXbeOL2LuGlX1Yj5+5ebOtrKGkXUvUVL7vh6ViRwouiXwmzqYppZotY0GgimzQ FreivmfUvtBiMUPrRJAw+oTPfbFMoD/7V1IGT7w2gDzXidNUUQlN2DFPx0pmmD0w/bYN l3uQ== 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=FS3dy5IY7QP5Qnn57v+smsT++7OObiq9yutYtSFWVdoNzHhbLJNWYpmSKQGwC1GJ73 QyRKmj59pdieM6eS/LQs2g0wqP72VZEOTC3jfa/+PCyW3ccCPRfWZcuK6cFhZmD8oq+T SgEqiFqOKxtvFFET7ONVvjhJaxUGLZDhYXyja8UoBrtu0MkEAP4QKpMIOhL5r1cA5+u5 mJhtAi2D9LaDakaFeK7SGxP4G3lwCbwmA+d1Zn5TOW37h3mgmM77GuS3aeH/3Z9O3e4I 1NxqrnGTlKct0kkVY5XMfRuzJPFaOopz08fNC6yrWJj14NHxwlHr1jUORibHVQvMwbxu f1nQ== X-Forwarded-Encrypted: i=1; AJvYcCUjHI9G08KlAeE1hGuZ/L1OK/z548Vnh1lTGgogyfyQcsb96gkZHvPrxd6IzYecUN4HaX972iHOYnozjGg=@vger.kernel.org X-Gm-Message-State: AOJu0Yzq7A3BFNzsS1h2XdleBuEMsIfubIUI60s4Wghq7j9PYSc8Wgjy J+W34691ApDP21qjOJifEK00IFeiwS4Z6WzgCXOiyWgJSEzGYgo/lKV9MScfpC7vCroAljCaiKg pEcg= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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; =20 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 =3D ti_sci->ops.pm_ops.set_device_constraint(ti_sci, pd->idx, TISCI_MSG_CONSTRAINT_SET); if (!ret) --=20 2.46.0