From nobody Wed Jan 15 17:40:13 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 60FB51F6671 for ; Fri, 6 Dec 2024 22:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733523185; cv=none; b=nD2rZKFhp+55Xjg4snmMgRaws0l5K0tEKApnaM9hrtykFdkmYqW3zO/BCjWGI+Udva+Tu1t4khg3KbjYHAmdyMC+bBngWnucP4yQXNMmC46+CjAPsUpPfW3lTilImXKyaSz/sku7aQ877b8xSFwz3vTntuTHJ5nMKM0WSWZeSGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733523185; c=relaxed/simple; bh=j0AdB2Ec/r7btTrtPaxqZvIVKLQ2BqKv+VHDX0Y86Yk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OYk4lNk+0gzN0e6UTQEoMKIoGZNZ676j40Kfb0OGnlrpXfPD9Zy28/XrgFNYAu64l/k56wKLxtAsccNZDCK/bWqxHZOIAwHGEn6OcR/q+iZTQa6brr3wp96CQN+QeeGORP03rbNixZF2s40feYNX7ihLo/4rl5yAU7zOJF1dbOU= 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=fU5Ijtjn; arc=none smtp.client-ip=209.85.210.172 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="fU5Ijtjn" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-725c0dd1fbcso1035485b3a.0 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=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=C7rXiwNlneTt0S3Im0z7iFr8r3P4BVASAMn47K57uCI=; b=fU5Ijtjnj4I/HGitItmoePlQnHEfNSlw/E7x40SUnMzLP94sAI0I5C3N1maZmuWUFW g1zwSvcNSM9WFWCIsm+4Y2FhiYMX0Ovmied/8iaVDWNXHFb7TfL46qS7Wj/pgALPoB7r Ihh+2gt+TMILxdXb+9x/Ex813v3yeeazBtc9nAPC+4MaIO7UoonKMNNOIUfZJq7FQefB MuYgtQqvucUtxcnXEPQs5Zp09RCZQK/tJCy7+oTL6S/IilrgEkGLTLvrr0O5pcOZNv3e 2Y4KdtFB4Y8fNKQdHjNcR4sIwj1Q7dwb6XsJaiH/ASxto+VIW7LwX8Ufngjhw6sYgjk1 w5mg== 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=YiPpsVGH3qRCH60SQPzxBZz5+rIKRUy/F07qvbn9yRbO7tXzsjpcop0kk8y7C27z9t g9Y/WpCX2wXJYFIR7g9X4B/HnZx2+mtbVnhK0VRyKuQAs9OGUe8AYjEHAoRjuyxm00vM C70xkjnp5BU6qSGwD8K6lwLNy25tl0jr7ENqMy1+utemctBM5WcVMj9ER8xp6G6rAy7i pTnKvEPWjPL9gqj+iLMU6QeYwi8dHsGwXnsJ9/yXQnKnmPW+i3XK6xuDbj1fFsJPI/BB gEiWVxQrrQhJJejUcELFGHzzUC+Vlg0J0w4W/363Ee5PmZvl/Iaz9pWyuw0SvYspOVVA iW8A== X-Forwarded-Encrypted: i=1; AJvYcCW5HWX/RQMtGmYpuEaPp/ysM/vv5lxUUAFfbcgzj1kx1X/sotwOrTh3HH97NmrvVjNHWGNIvRy85kQEE7E=@vger.kernel.org X-Gm-Message-State: AOJu0YyZBt5qKWEPMK+E8VPhuYOMyQkUehWDXrVUaxbX8RLOMexKcok6 2RbHIm5mc+PJUHSSrfKY595K/Bp7LT4M+/Vm2RdhNx6G1JYayolL8a/RG0AAHvc= X-Gm-Gg: ASbGncsXV2OUpOB2684r1JbZRx98WBa3YDUyufO4HXO7Fdeu18OXZZI5f6WN3f4Yn/5 sFrby6Gqu/HnI+iopFsOcyWctYa8Os9eWvmX1/YSbVhcxcZO6/F2RlAh7uXjPoSZfplDlgQHyh5 0AGM3yHRXvYmuyv7Ns6y4I1MQE/CMINt1V6qE/QsUamGEhxVYfcOp5f6ZUTPw0S8x3hJkqVzK+r vCDoi9VVkPTURXCLItdcNPAbjpTNLNNdh+/SGk0pWHSW0MY 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 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: <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 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..963fe1901c959197d5d8b5d34fd= 8420dfb180087 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,32 @@ 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; +} + +#ifdef CONFIG_PM_SLEEP +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; + u16 val_ms; + int ret; + + /* PM QoS latency unit is usecs, TI SCI uses msecs */ + val_ms =3D val / USEC_PER_MSEC; + ret =3D ti_sci->ops.pm_ops.set_latency_constraint(ti_sci, val_ms, TISCI_M= SG_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); +} +#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); } =20 +#ifdef CONFIG_PM_SLEEP +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; +} +#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_devi= ce *pdev) pd->pd.flags |=3D GENPD_FLAG_ACTIVE_WAKEUP; 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.2 From nobody Wed Jan 15 17:40:13 2025 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 3C326204575 for ; Fri, 6 Dec 2024 22:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733523186; cv=none; b=cNjEF5eX2Fm52ZzCCEOA/NTvxMNMmVF4iW22KqBO0GN8tmU90iaL29rDZa0j1gOTQ41vnAdifzxsVvZ9rVs2KKBJ2qMTFMxlXrFSTgkkE86o7rF0XOnLNtkVa3qDjPp0OTZkkVIQjYOL6y1THIvE/7yq6qPq97ZyUo2O3dimaU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733523186; c=relaxed/simple; bh=UYKwDCjPt0Pb4J8LYvmA473uK8bBnXmKBatytxsKAXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jEDCXQqE0Ouku1D0BiasQsf4GPMFHzQo7bEmncaKWR3cfpZgogb1QUOtNgsfygruiKJT9aLY7dJ9DV2VWQi0AMzG67WChaDBwYJQefT4Hj4yrAcQPgKkcQmpwoUhbgNBr8iMiQXnGxVwKJYG5n5thuDsHuM0lVauXHib7CB/SU4= 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=E17rPUO5; arc=none smtp.client-ip=209.85.214.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="E17rPUO5" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21619108a6bso8529115ad.3 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=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=gO297//2n/rgfagI213U6eCWKlgwMp68Rn9iCoz6hZE=; b=E17rPUO52OOsS8h8eIj0qqMPydIHKDWtywMlgJUSVjgU0voEmwGl1ShzoAyr42HoLO GjWeBKdLzg5rGUHQxzBEs5Pe4Z8cwlJn6vqZKKBt8bN2Y5DUJU61BGQynstE0SKdmxaB PudlAA6UvPShVjhxYw2it9OnVGq7zYM/1bkiBoCxsl9uaf4TpJvQei1DXrEj1UI9hBMj QpWYP41/e8PemK2gGBxLlqjuhMBRb/gLIeGD3RaDbQb4wd1w0ebc1dWSOZBpESrxOXc0 7RketTi76eBeieCqx74NKpD+Drq3DrQ1eHgNLBSiS0o+1aBmXFDZWNz/57YfuUJ4HE12 fVIw== 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=sJoOFnoMCs0eCxNmgCvhGlk96pd6UWbhhcbDFITSvltf06KaNmEKOgVchQ25yvJKGG 1vabYRqYBoan0AOxmIFJq5o2SM8s6+nBTgyGBXYUXwjkxcx/Bw5Sg0qrX2+0aia4jAZE d+bwp/XTXLp2s038iodlU/wzblVeUdSmAfliPmqZdcxuniRmhwny70XsfFwUPAEhP6sP qw+1j9OdYeSTBZlB3BP2Lkozxx80+D/91V0+2bjTQPXpuRKYFFdVxon/eV8GVZQ2xLPX YmVLkoo3V5hcoEKFHGZB/A5Snq9dOOei3N8P78yTuizyhKtCTSjkuFsvqGHF7SBBNWiI ZMiA== X-Forwarded-Encrypted: i=1; AJvYcCULXQdpZg7UzKgtkUUyoF0y3OfrPr8+b5PbF1AvY2Z+R3t+EPNz5JMnyjxMB+NcOLeTotG8glxfuZ37uuo=@vger.kernel.org X-Gm-Message-State: AOJu0YxsZJ7p5AZMHNHED5hTeI4QhRnduLB+DiCR2lRYskYi+JbEfm8u +j3jmxduwfib2XgHrqrgXix/AzKkks5phUgHck0lDY2xcVCOXI8TAocRwxX6sW4= X-Gm-Gg: ASbGncvguQFxYVvXzo7Yfg4qG3jJz/qsgW8/akrv7NvA/MVIGM3Mu4+CBc82/6wk92X RXF3RFn/mQLbdhbFtjmyFn+i0WA+8d3cONkBugJL+M3mhuNf+xOR7txEGX8llW8G/G+Ovpm+czC 78JY2NerA68MHe8lvDCLqI6mb7v3S7JJbU6j+7xXNkrHwq85t3027N02eZls8b5QYGdQ+N2854+ zaascdN5rLnyTih3Y5MY37k/plsxwQNl+7+fsL6p9VgMmaW 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 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: <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 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..587961519dcc9e13c32efe76cda= f801281f72f67 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 =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 @@ -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); =20 + ti_sci_pd_set_wkup_constraint(dev); + return 0; } #else --=20 2.46.2 From nobody Wed Jan 15 17:40:13 2025 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 D68921C303E for ; Fri, 6 Dec 2024 22:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733523186; cv=none; b=Fu3IcNzRvlnK4oHlb+mwMygJOi6eu+Id8h+yeApDL9YEizR8buW4vsxC0dvsUoCN35a4qi8i8nWIjYXRCJ46CvlyRsqUZPLbxE1WFUMm5vr5vrkbHHvRXMnprh/3xzS4FtczgYauxBv6/Q1NJLPDh4T7zPk4QY9EM2+d0aN6EYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733523186; c=relaxed/simple; bh=MvYLl1dkczYVZlHhGI19Lnk7zfxJItmwrZlS8xz45cc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cl6eTiB/VMOy9UuM/SWDE40LFWHRtZuZhIw5YMDjPv7Nj86Q6MDbhNxKc1KLTGIyORY0OaWBq6ukmAebznKBjk3W0eOCzDIcD1TqXzvkyCYJoYT5OrjuN3TYxYrTn2paD6p5OfPVu1eeC8lBou6PMkJTkJIDrmQMj2YB4eNthck= 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=mw4URXdL; arc=none smtp.client-ip=209.85.214.171 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="mw4URXdL" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-215a7e487bfso22660775ad.2 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=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=k1Ep2O9wbC6ZlfsCLYQrAmWucAGOrIVsXyOuKD+Yvgc=; b=mw4URXdLte/tCwznxgayVRACMg0HUt4ycrYtdboh8tlkc6cI1Uh6c6yB3Pq+843fKJ Vouo6BC1ajc9MWDNDIHusskdhPX9OzO0jOhgiONKQ31U+Mb8eynMLOCOmYPUaDDzy9i8 U8JKm9OEJMOoOThmQksouMtq+E8esnXIqcXlBYgOXJcNBY1l5eSg7728Srgca5bw5Aby 8xmHbOGwUK/ZQwkXBDwAC6gRVZba0eWMxSyVO9oDbr4uyjt14DyCUUMiYLPju2v40+Fa Jm5FqX6bqgcOHK+2tsu8qNIe1Txd3MoQ6jovZmmpb07j0GArDfLp7vNvKSxP5/hGuC8a BenQ== 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=F/uLdMVA+0SxYrWnB37xAwXX0sKTzZezPK2R9aEYfL/hjZ/j3GzNUSLK/87ZEQzycn cWfQ9K2AoDW514pzZOxt8LCSmd/IIew5ED3ieMghmy9YObOnwhcUHRLhr7itNuoUzrv/ t2ocRUNjQ8/tuc2ytcpN1MpC7VTgrf3/KFnAFmofryL9lvUQH4nlQfTrGtNIVo7STk0u UH2899sWtDez+rdxXFMoI8Ie2OmzomLfuB5fIWYapVKrT/N0kgUKZZyutwFRe647DnnZ tGsxhhbaDn1DSBJ1VRBp6LH/4X8neDf1dG0lX7+xio+yVdNiFRs41IkgNesCI64v+0V0 P3ow== X-Forwarded-Encrypted: i=1; AJvYcCWzpTUtKVRziMioN5Jcd5vH5I2fLHDKXzAUgJzQIWjetIMuRQj7RwRGURb2WxP5+1VKhpCa3r0lKErpj3A=@vger.kernel.org X-Gm-Message-State: AOJu0YyAie/ByXVGHnqE2EkpOqUoGbJnBL7/aI9uSqQmjFIdJAYCa5jW VYibDp5KmFT5/wl1QoWzIWC+TNnoRTzuUAI192wWdaHe4wLsngTdA5fos0bG/us= X-Gm-Gg: ASbGncucuLo5lMr7L1qLEngoSXMp+aAosxnIFnVRuMo8TaXoRmJPcYZdY4y046sp6UN Hgt16hGOZZeWpuhffAw57CY3hBQ54vU/bmXxwAlOQcN8ZYSUzWO4AiLB5Z1w4O6kngCmvi+lJnt 25lB1e/srBvy1UMDqwjxGWSdWldvu4tybsZttsXgbZmKfmep7cehjUg5m0vl+vp6toum3ugxdVm k/H7aTOzPeLkHPf6DGCz2P4jIa9p0mpKteJc/eWegx7Y8CE 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 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: <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 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..3fb78343d4388a7087dab5061c1= 127586968ef19 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; =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__); + return; + } + ret =3D ti_sci->ops.pm_ops.set_device_constraint(ti_sci, pd->idx, TISCI_MSG_CONSTRAINT_SET); if (!ret) --=20 2.46.2