From patchwork Tue Aug 20 00:00:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 821211 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 A81C038F9C for ; Tue, 20 Aug 2024 00:00:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724112031; cv=none; b=ZsFpjH8Uy15gO9E9cQewrRiStUG117XW2CGd/j8bsh0BMXyrudIpjLqNIKO3boJnReC2TePPvAKwBHYN3jgsUAWcyeWlfSH619dA0/cA5zRFgC3zxLJaM4diwWhrsvhABIx6zHuaZNWXjHvLj5Plw4pCVsBWvFTme3zaA25sIXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724112031; c=relaxed/simple; bh=EsyOvHfUW/kIQJ0oYk1mZTfySSyGRxhdYE3KKRCGBak=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RUjwWe0y+9nfp58ClCHQThKYTuQMO1IpYJL2+a8Hmq4iug3fbS6PwmlveOrNkrxGaKYuaAjvo//FPLojk/eY105pJkfHdzoU93EsAI9gaKXe+yDvI4DzKuE+Adn5OQFfaKuMwM25JyR69S/Ls83/RS+vhiMLRqoNs7a5SXl6lQs= 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=ga4R5Zgb; arc=none smtp.client-ip=209.85.216.53 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="ga4R5Zgb" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2d3bd8784d3so3587673a91.3 for ; Mon, 19 Aug 2024 17:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1724112029; x=1724716829; 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=sLE5hAB62v7p1beN0KLDfInOowT8azj61EJTe8F9z3I=; b=ga4R5ZgbC5k/fm1bfryHvI/cKMGyd8/Jn2HT9i8mIa+WPIfcZXxF6U4SwY8QivOQku Ob5d+tIJRcLSRg/hui/c/mBC2yKJ2VcJEJrVpiJOETM8HYo/TOk91eufmUFml0LdB2ff znPD4DAoSeFwnIQ3bBvapzUNKFVnq5MTA1Nv7eb1rbKxbAkyAmlnbeusBWGdw5wi86Zh fSaqrtcuQPFI7wGU2M8zTwGvSrFajzjMQkWma39z9NoQRrVfrShxlu1E7PvnhF2d+aYQ JqrSg+/lrS469hgcCstEYgBJ5g9/NS2gbeubTl+D5OXtz4piOjDI1IDN1hih7DJeq+78 l9Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724112029; x=1724716829; 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=sLE5hAB62v7p1beN0KLDfInOowT8azj61EJTe8F9z3I=; b=rc3dpCThW9gmPUTAt2gtyLfr0GguFnaZn5bih/S46FD40YOnssQnF/xOBNVBWy/FQF bkoejQrBs0bsDAMWte5hxqErxj88FvIZE+B03kYEuvzoA8Wnhimj8cMlOtq+ay6t78VW j+ateCS32Y/hn8Oks5muBJvKoTBlsQAnHnpwbtn3ai08sl5KgLGY2a/OJk8G2f0slM9d 1SKbm/lOHy5Vnel8T/HLl0GQdyLXqvOU1Fqk06LDLfNXGfYwJBWWlRR2sCdqMPvY2+xL mPtl4kW9CwR6xQGGy4n+bDuL/vibrrbnBL4uRJ9BVz09vYYoTtqAmgWHS2zCekG3da2+ wQbQ== X-Forwarded-Encrypted: i=1; AJvYcCXhtahvd476Xh0rg+2Z20uSXic0kwM+3pOFno3Ist8xhrMsmzpUGvHf8aSJpfHSgrr8aZtaz74RVQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyS67bikONICzNJn4e4gtyGxtK3eLJXnqw67t4Dq9WR1+Mjia1f wVjO34HEdQ1zxoUyCuVBjLB9Q5fVKz2kPOnXCRDI6pLy3wH7WnBfC/dzyWmaY0Y= X-Google-Smtp-Source: AGHT+IF3qZLIeCayxsLpMAWoTFuVPjgH1YPTWPIw/WqvEfRwrWzcax1rN4IpM+MAAYfrKW8qcN1A4w== X-Received: by 2002:a17:90b:33c2:b0:2d3:da6d:8330 with SMTP id 98e67ed59e1d1-2d5c0d79fe4mr726670a91.4.1724112028390; Mon, 19 Aug 2024 17:00:28 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3e3076130sm7955195a91.29.2024.08.19.17.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 17:00:28 -0700 (PDT) From: Kevin Hilman Date: Mon, 19 Aug 2024 17:00:11 -0700 Subject: [PATCH v2 1/3] pmdomain: ti_sci: add per-device latency constraint management Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-lpm-v6-10-constraints-pmdomain-v2-1-461325a6008f@baylibre.com> References: <20240819-lpm-v6-10-constraints-pmdomain-v2-0-461325a6008f@baylibre.com> In-Reply-To: <20240819-lpm-v6-10-constraints-pmdomain-v2-0-461325a6008f@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=3743; i=khilman@baylibre.com; h=from:subject:message-id; bh=EsyOvHfUW/kIQJ0oYk1mZTfySSyGRxhdYE3KKRCGBak=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBmw9yavh3GVW7GdVcsaxRa3+zt6YHIUgUUkm+PB xaznFP/seGJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZsPcmgAKCRBZNxia0/vG ZXaqD/9kEDcKjRDUuwAvfCW4lDul+xVVGKxjHy87Bc/XdpCDVJpMhCgaPnmwPaNZahraaii+WDc A/ikrbMk9jpbcRYi7RxIge80STHu3Re5Pk3OqI9flWtuQ4gCt8gAnXkPG8PYLvbsOIvG5XcuVs9 S30gGsGoQAUpJodgGrAIKNr/9TFhTFO6jGnFvWmXZ/BuGoRg73H2rXhTkrBHq2iYcfYQwcJH69d bPOMIGkk5eWMBspqH9pkvoqmR31aHUol5vro5ANeCMTvt7etKD/ug2qa6H9xkxMLxAQDP/vADXZ qevQIIw64jReIj8qbmjACgu2gyBLHqvsfjGDo3zEEKMzjFQz7iEV4D8njkqtdCy7FNgwsu9lDXG GkYgV0/ecBT+HMg9rn0TSkeQ3RjSmryLWbk2vmTQUwYrkM4plp67a3Az3xugrFsUW1VIc/LKO3X z3WXnnBuU7/BGZYNFWgrh6luqGgFhiiwxOTfmdtYgkIp8XF6lY0a3TeVTv6bL8PxjHlGcrdWct6 qrQFvxRyjh+6lalWWO72eHaBduZr6plINvEPjfwH34RhjO3ysRojgOwA+oop9KO54SsmfgkAyFa y2S3L5R6zC4pahzXCS/qTYy95trffxQg7Nq0Vg3XYvxh5ZZuyKPJIvecc9vCXR0arF6in5lDCYN cBBvQIb14J/+Iig== 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 --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 1510d5ddae3d..963272fa387b 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,29 @@ 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 int 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); + + return ret; +} + /* * ti_sci_pd_power_off(): genpd power down hook * @domain: pointer to the powerdomain to power off @@ -79,6 +104,22 @@ static int ti_sci_pd_power_on(struct generic_pm_domain *domain) return ti_sci->ops.dev_ops.get_device(ti_sci, pd->idx); } +static int ti_sci_pd_suspend(struct device *dev) +{ + int ret; + s32 val; + + ret = pm_generic_suspend(dev); + if (ret) + return ret; + + val = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); + if (ti_sci_pd_is_valid_constraint(val)) + ti_sci_pd_set_lat_constraint(dev, val); + + return 0; +} + /* * ti_sci_pd_xlate(): translation service for TI SCI genpds * @genpdspec: DT identification data for the genpd @@ -188,6 +229,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 Tue Aug 20 00:00:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 821210 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 6FCB0148FF0 for ; Tue, 20 Aug 2024 00:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724112033; cv=none; b=O8cgvkgzYxXVVzXH6WJqT79DdkjczoPQTn/1cKFLfVDaoMRUvMcQWmJdyikb0HKLmLnWsyxrYOjkuH9Y4JdXUXllfkk7UmkekKsippKfYo4BRHub+V2Qp89UF8VbcHb9wWNoyOd9B7akf4uQQ7LqFunXMJTE0iTLomaEd1fNCI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724112033; c=relaxed/simple; bh=tUlhhvUzqEYQ9xxjHzkEQgHRjJRMt3U1MS2Dj9MMzKs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aZfhitdPR8vLsYDCKjM6JvVwdrrrS3iZyJT2BGwkirzIiELs++FQK1r3nDrD0Kl4x+wff+ynYmcsnRL5M03ad841yrHpEgUcwGqeujNiegU5aoWTiO/ZSNH9furcuPP0kO0hcbtevhzyoRdXI0SKDOSs+8sTEno4HusfHvCqNp8= 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=JDiNM9ey; arc=none smtp.client-ip=209.85.216.42 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="JDiNM9ey" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2d3ce556df9so2927749a91.0 for ; Mon, 19 Aug 2024 17:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1724112031; x=1724716831; 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=hrn9kJswz7J5k2KMeEwoyClXwEGKchhZrenYjTvg6wc=; b=JDiNM9eyOKaYju9rkVJnvdpn+cIiCfCBWXbjd5KFrnLiqWm4uf25tWp6ducjrS5KF2 1fCLDJEpmdNHFfaP9cvoSzp1IVqJpKaSYS41V3ZQwFkbpCX3OlgWdMY/crO1PIgauHvk rq7itCLFRwCUiuSo8mywUdeC+U4lRh0ffKHgCIFDRLrPJcthygdOI6e9GvOoKmWIAN/v Js1IhSD2YMcae9eo1Pxigw2r7tzjdTmwucPCODSrWSm9vnAko/VRlY5NX/PHhCQdVYAK TBwRykFT/q2duqqOAumNQ+tdTdhsPeRK3mhfu6bdMjLIvNvfMh3scyOPqF7xsgG3nUJP tkTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724112031; x=1724716831; 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=hrn9kJswz7J5k2KMeEwoyClXwEGKchhZrenYjTvg6wc=; b=ecKk/BK0Sv1hIPmoSKJN3ESp4LYqzCcnXY3/GjOQWypD6sSv7GHWEmLdcfxq/feICb iPfjqYBIKtFceXX8hbOYzNqgP0JinwzYu3VoyGy4qxSQrUZAzhGnepH5M1G+7DOPN1No UzQ7GFSblCDsORPcGMs+JVPxqL3nHqasazIVArT0VM8g7xmieq3kZuYbXuVcBb09d/E5 rrLoUIf++4pwCld7Vr/jpItlogAqJEg7ef4An/ZqVQahki6qSbdZI38T1csJuvrD0gl2 kzZQoSG/LJ29iC+G11IKipDv8PgI09DGtD/k5VFZXS2J8zHYLtI0YB/+h6fzPKSTcTGI kEkg== X-Forwarded-Encrypted: i=1; AJvYcCU5BR0frF24uw3sW9awN0FarnJuWrKfYY2kY9QZ/odHjPCcz5jjKtn5CnG6UBxw4SL62HAFTsHku9OsPg24jbGq6kzehImHzKs= X-Gm-Message-State: AOJu0Yw5jKL+bI8G1EFyT29Y5GVFYvdm+W97ybTllGfQpDvQe+QfNOXs kWIbtdB0SB1qPY9E0S494jehqYe+/gi/O2j0ybtpTbji6ApBfptHY4sgvR7ksOUJEwWCwVBY1Zn j X-Google-Smtp-Source: AGHT+IF1NfWUZbWpyfpHlbAfLpF5uRsQsGKCgn3DKqKJAf6OPFuUxpR9lOOfUl3xYac/G25kixBBow== X-Received: by 2002:a17:90a:9ec:b0:2c9:6514:39ff with SMTP id 98e67ed59e1d1-2d3e076c66amr10858991a91.33.1724112029182; Mon, 19 Aug 2024 17:00:29 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3e3c7502csm7857404a91.40.2024.08.19.17.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 17:00:28 -0700 (PDT) From: Kevin Hilman Date: Mon, 19 Aug 2024 17:00:12 -0700 Subject: [PATCH v2 2/3] pmdomain: ti_sci: add wakeup constraint management Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-lpm-v6-10-constraints-pmdomain-v2-2-461325a6008f@baylibre.com> References: <20240819-lpm-v6-10-constraints-pmdomain-v2-0-461325a6008f@baylibre.com> In-Reply-To: <20240819-lpm-v6-10-constraints-pmdomain-v2-0-461325a6008f@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=1735; i=khilman@baylibre.com; h=from:subject:message-id; bh=tUlhhvUzqEYQ9xxjHzkEQgHRjJRMt3U1MS2Dj9MMzKs=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBmw9yaw4z8Tn2b14jGRvuZX85gZ7ivnQCQWDNjy eJOyqKt2oqJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZsPcmgAKCRBZNxia0/vG Zaa9D/0T7h6tsTpPWJ/ttDQEwpzwuZgC0zUMUYapMHQMP+3gx1wS03bIEiCPiWYukJKn6Zu5G4j TwPRwPah8RJeC7muQk3sJNH2SCaI8pJb+QsYuVyTWKJ7x0Rl1XhZFpJzDze//8o0oAoPF1jGTrB O+8PMibGcfTv8rmiljFBwTyx52J8JGXdYXVPV9gw6G66TIpiiQW/dnGXqXEwhtAMH+3cAaKeusD 87bQ7zYcLtu++AgSIFmdU8G+UNxc8BoDcnEpnk1ToBVXCgZoXaWwztIW8Mow8Yl8EwAIi8TdZm7 CSXZhfkQbwYNBJWOQ6nE3rDaQNyaTRbfT0D+6sXeFaunQNqUrIN9M8rznM/aCzEUd+7lcHBM1eJ pRbEuKLjhHj+g+qzfHlPJ31F1RQ7eh5U9/Fu+C1pGcfzz4nawTx4/ViuPNP1KTN6ZbYPanIcrLF 3/F8/V6ZWZPH5DcciGWnTtR6N1R2R1+o68EXROklT1sq/pq+DN8l4z6vzMN+a5I8YoyzmiRRIBy w38cEq8seTPnFvlMx8e4PuqKRgHjhIcqxHXg3t+qwXjAJpmkVPFy+J/YO4m6sS9LCeLABn5gG/i luhEZyvX98OTmDRoK69HGHI7QDZR0fZszgX93Hhy/ILwfxO8ztS6xP6Cq/aTZcp2nHrnPe9HNFM gepXr4pmMzQgkZg== 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 --- drivers/pmdomain/ti/ti_sci_pm_domains.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c index 963272fa387b..8af907579152 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -76,6 +76,23 @@ static int ti_sci_pd_set_lat_constraint(struct device *dev, s32 val) return ret; } +static inline bool 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); + } + + return true; +} + /* * ti_sci_pd_power_off(): genpd power down hook * @domain: pointer to the powerdomain to power off @@ -117,6 +134,8 @@ static int ti_sci_pd_suspend(struct device *dev) if (ti_sci_pd_is_valid_constraint(val)) ti_sci_pd_set_lat_constraint(dev, val); + ti_sci_pd_set_wkup_constraint(dev); + return 0; } From patchwork Tue Aug 20 00:00:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 820523 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 F2B85158540 for ; Tue, 20 Aug 2024 00:00:30 +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=1724112034; cv=none; b=tYRrbJDzEG8RnSB2zvW/Iqftd+2hEaItHXEJhxjnVO1ObZ0Q0Awu/V/MUOPwH+fnt2OlPUOJurilakxh9uA+lIxMT/ueYvkOwB+/4aaDDbqjfqAlLnskXcSE5LHkcdiDS8i69K3R4RfvaTOhCwJ/Kbk5eA87DyaKCjJlOhkCaKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724112034; c=relaxed/simple; bh=L4fq2gAJAjxK1sLC9lcg4L6kyHQ2+G8MiyoeO5HwSb8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZeFeErF+gnyvqPPsqkbjzHro2LquHV+XUPcRe2/4Lxb3SvFRt5hPkXozSmTS2L5CRn+NjtO3wL2qkNXw+uad1bl4rNmZbnlxeJRVW0TQR/Q80SM8pmYxRkVyKJZ/e+lsSm3w1VirfzqFfKA/4xO8/1ztvvWtQWu1Z03CH7PfsOk= 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=c9figtNB; 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="c9figtNB" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-713f3b4c9f7so1204860b3a.2 for ; Mon, 19 Aug 2024 17:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1724112030; x=1724716830; 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=hfJuZFlwIrV/yx/dP7X0WZTWclq0poFO0QEtz4ByiOo=; b=c9figtNB2zBG5Ua6Rd2KmxIpQFYnnkLDrPGDIc9EsyPMHR2BFIvJ8pGD0D0y+FmVO6 GZlw0JG0ZLkf4EOC/29WGyHao8AnLbsjVI44zcSmCs58B45M9xrtLxdoC7bNF/D11QrG 0nGhxaQp5wRs2J2RNcPVPWH7rQZVJZsExBREgzgOJHm7LU1CFprOPB9xqwMNMem2Q2TT YKfTThUMEnUPnDVqnQHXxCjO2u3Qjcda1219hd4ghGVpoBAPkJBK+veG0lSbUFE+kjSN JmB4amPWKEeoVVUzVjMB3NIzD1nTJJQTvrkDgPY/3Zs0COJXkuOHfHMTP1mqdSs/4KOP FwEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724112030; x=1724716830; 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=hfJuZFlwIrV/yx/dP7X0WZTWclq0poFO0QEtz4ByiOo=; b=k3scRXdRcQJIYSrU/RxLmu8+BN9+3yxSEG2hzo+YgcMQC0ML4KP4zHEqiExYQVQJGN eufodRkIX91SonkdmFpxwRJKJXRvM94F4hkls5V9tyPs1YaJZdJ1CrbLg+D3MCGV2DyT 3JppK/tEu6qtGtt9DZbOafBx2IAPmCL2GQcuJ0iYDMKYk8x9EEY5NuxxDmMy1zd0Iqsk klyv+rPcgDDt4MVa/nNOoX4YtIa9M66ypId/520t3TcgC4SYIFvKRYpr2u6IRRRxP63J K3XnssBDEx+z1k8Wp1Wz5Vlltv+Ss12eOCcUmh0zzbHxk42xI8l9K0S4pXu7VroiGL9Z emZw== X-Forwarded-Encrypted: i=1; AJvYcCWb9fjScdTqgPYDxHwrJ61iLSauMApr+UqG5VmIs+9XQ5Cyz4sVj3ZWnwTgooU2cCiAhkZEg00hyg==@vger.kernel.org X-Gm-Message-State: AOJu0YxXCJ93R7Iow6WnEcBQXm4AmLLUW5HJl1Yo1AHYPOFGRVMGMgEM 9sAaxCQlZKDaJ9jv29GxJHzvvHEzEunRpVAGZu4a/XY/h9fqc/UTsEc0xACwi28= X-Google-Smtp-Source: AGHT+IEjigYtUu+PbI7wCwmy0Ii9OICfFb3avBHTHKA3P6Hw3f5ftxJbKPUF8yyUXK/WBPt5jDQEfg== X-Received: by 2002:a05:6a00:2e99:b0:713:e70e:f7db with SMTP id d2e1a72fcca58-713e70f02damr7068548b3a.18.1724112030040; Mon, 19 Aug 2024 17:00:30 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127ae0739dsm7115321b3a.61.2024.08.19.17.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 17:00:29 -0700 (PDT) From: Kevin Hilman Date: Mon, 19 Aug 2024 17:00:13 -0700 Subject: [PATCH v2 3/3] pmdomain: ti_sci: handle wake IRQs for IO daisy chain wakeups Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240819-lpm-v6-10-constraints-pmdomain-v2-3-461325a6008f@baylibre.com> References: <20240819-lpm-v6-10-constraints-pmdomain-v2-0-461325a6008f@baylibre.com> In-Reply-To: <20240819-lpm-v6-10-constraints-pmdomain-v2-0-461325a6008f@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=1545; i=khilman@baylibre.com; h=from:subject:message-id; bh=L4fq2gAJAjxK1sLC9lcg4L6kyHQ2+G8MiyoeO5HwSb8=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBmw9yaIa+swVNTOJfnTzx2jNlfK8fU9hmVzvfkW YvGVUUN02WJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZsPcmgAKCRBZNxia0/vG ZbHqD/9AOVXyi2FjVlLWmnOgTyw/r/8682U5ynfjVoIEs65YqH3/oEsnehsr/kj12+uZT+/Ryq9 UlKviY1R9vBFUihHTR4o0s93HKbqsdM1Pv+J6AA9j1u9nOKapr2aDoOn8CRMkeTZKUGXkHqF8cj GH/HFug511+/BRfu8QetRE9K99DRodxTYIrPuITvQFFGq4GYO4jPZunFD9hzHKAmuB3w1IzZA/I C/+BryWDW7B1Q4Ax1LJVun9jywG4CTFBNOn5/mkpDSNdx1vp4T/GePnLGwP/OiCn3lDHnKcBEAC 9DXHx5PMWMIqvmPO3TnKg2bzJlmLW2VkyaYYbaac9JzPuPJkriIRTfZ+4pHle+RpA8nucH6EExQ 7KdK5Wxtr6AhSmW0RtIW9bDQHSMfzI/+5C3grmCQ1iDBMI8kbMoew5zt4nioHXM3rBIuE5LDZkP KZ1sgXaTuGwb9L/WmPwCZWes/gkGd3Ra+022fQ8kfnpbXw9I9Xb3/R3dQufV5Wb3jvPpMTRgrCm gwu6H3ceeRU4PBigHyGFlnbdWZIHMp2Wi1dOa4/oKpR3fGftRnWVgu0rbmh/ypVFW9rHrrvYQge lnJ0iNs4wN3AczLWtwz/m2J5R8hDs60skpG7k62B/H0pYmR5njtmQTBOUU6OpJA6mANCsIeYBZP Z6LIyKQO3Ag3JOw== 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 | 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 8af907579152..f7c327cb059c 100644 --- a/drivers/pmdomain/ti/ti_sci_pm_domains.c +++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c @@ -84,6 +84,15 @@ static inline bool 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 false; + } + ret = ti_sci->ops.pm_ops.set_device_constraint(ti_sci, pd->idx, TISCI_MSG_CONSTRAINT_SET); if (!ret)