From nobody Sun Nov 24 20:37:03 2024 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 3D5741C2DB2 for ; Fri, 1 Nov 2024 15:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730475409; cv=none; b=qCdrURuqLloeMf9T39C21G8LVfWkFQgvzYwfftPMbtd2gnF5fnBKtp7T7JY3NBpzbjYAV/fHFb+57RLL9DHJoXIlpb+rxbcC3iuiUHkkV8cupyJ/iCHIqgjLBiUpLI+Q1RfFIkx34S76jCPEA1nYeYcM9ThsLMuelZXFqQ9vVKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730475409; c=relaxed/simple; bh=Ewuo8tkZRIPnXmWm+AAeqen1P+AccwVWLIprM0pWxB8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Qjh1jYMleyGQeoNsyPHeiahreYUzmuQ76GAKN8PaB7fNvpEOm1pqJFt7EDyQ4PKezeeF0zfBQnrWKjrSVsuTGJxO+rD0TgpKtXpvxn8zzmIZOSQ6DeGROLbD0qjxX73BFuiIros6QZAGcnJzns3TuOs+AkedeXdJ4MwgnHwD4s0= 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=GlavWRV8; arc=none smtp.client-ip=209.85.214.175 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="GlavWRV8" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-207115e3056so20884335ad.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=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=k3idRexV6BiHXZ5h21OJlIktjbdShqDapELZrhtrPoA=; b=GlavWRV8rj5M4yaCSuCrWwPaud8GoNysP1nIGG+1r/0TMjkG448geV46cT068HyWKi VXr3AyvpY+W6AuN7fvgLxi2Cmx5AYDQD/qglirSNikCqJoZs98zQGY8TnDy051qCMYPS PdsbOSBWWsTM+1b6IhTSuvDkI33R5dvHXG3WjmQGTZ03XF6nq13PsF2M6/u2zbR3zuaE xIlhqJqSdGzSmCkMbNpLMdqAnx54zui/FvsLVvgiLESF6YN8oGOl03pB77tYgznATQAP mRnsavRWWCViyJk2YwitAo73N24aAD7Wb20K8W8WBz0Y+a0sBNDhOM++akFQlETJewpT nesg== 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=Hlyv1mSB5ziVeftfguKw+A1X4F/2M3XiSYJc4wu+lWw34cLqPZ1Er3upcT79xi3H/9 8MnUhw/dJHEeVQ0kTFGqYS5iSAHlqnJ8QGsuQ4DvEHc/PiE/Xj+4b7FG8QwnLYqlNVTL 4zS4BPlKyPuYDPcdSmnic9UKjQ9g/eTOpN1vTxm8/zDkN2H/kW6EI+HeUzd9AAUsOZCE pkapUDsR8XqzdyUMtnmauzE0LFlm0fPowzkFlN2tTQ5IQFCgiqGjWXwAVvi4RvKu+/iR e0lUEmDXZkhxCVemBtB3DHMd0H0SIS5LpfgEYBXINwx1PaqTDhdiDUwYaPv6Cx4jD8oi kedA== X-Forwarded-Encrypted: i=1; AJvYcCXy8aknbh/BiU52BjYCj8N4AIGiu46wBbEnpjVH8WQRKq3iqzTTatn+9/t+Q1Cfajsc3+0Cv6tMM9rZUUw=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5UTK7f47inlXXFNt6O0VINtDmMtfFDSBjNIqAj95E2EBBiom0 2fMhTkv6KwTLgXHqaOP+Kf3Wmr710jy+WwNH/n7QRSZLG33GQaS4nN5U4XjitF0= 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 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: <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 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..c976a382d64c807daea72fa1ea9= d6c11c8773762 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,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 @@ -188,6 +231,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.2 From nobody Sun Nov 24 20:37:03 2024 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 1C7311C68A6 for ; Fri, 1 Nov 2024 15:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730475410; cv=none; b=CtRFkfvJmrx3/q/veC7t3WuxXj0Nf4YwZUVG35LjCbfGtR+evzBMENPF0+DTjSuztaLw7kAWg6+4WKXqQa+jaJdhQyNvw7UCYCU3QJgwRkNHmL0cF5EeKBWFBa0zYjuAymOaI/OQRBvEhRiQt7Nr9oxuD7lEFQqqRzG1b8q8aNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730475410; c=relaxed/simple; bh=j2mcJH9DFAs4uPVxByFXW0cY1Bip8MTsLuwf/lpgjjg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rs9YcZwwPvgzNKDd30JLoyKyH3vZ/LTqDG88+phqqPl+ebv8jzqhSRG/afUkguZud/70Go3JGLjHHCEwgBxG52kf4df3KeNJaHdlJx6NnRtmJYCkCKG3q5Et7v5oHuckSEUlzxihXHCRy5W8DfJynCEVQhLf0C2tlP1PZm7WOfM= 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=oSh9/6T3; arc=none smtp.client-ip=209.85.210.169 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="oSh9/6T3" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-71e5a62031aso1717731b3a.1 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=1730475407; x=1731080207; 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=ZAkCsjd64377nzOHo9/POEtdFNrxXL0RDJBoIc/E4JI=; b=oSh9/6T3bbWlMTZ2Mo07IcEwzYaYR3LY6TZ/xL3hf23BG8NAT9gtumPayPxgAMpyv1 A5CZjS51XUC17bap4+XsCxTTCzDAbyo1x+tyeONAB4SZZ2uVb0f+Pvah9oR98fTsJUR8 ED5hlREjz43DT7IlxjYcShu3LE6luGu7vdlwbIzZftDH4kmsqtyWovfcTin7qEK/zZ8h QDVbSMuqguPxACBRxrceAIbiTfYTMy0EKK9QLfT05OFIS2LBVBd+lWAuHk7ASOC6xMOs MdTXEco1DPWRA1fa5FSioglNFIZvY3ySaWjYBdK+X1FU0kZD78nY088JApB3/7vnB4ko DOcg== 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=l7+eOF3H4jWvai7MUQrlbqPI8b6ncM4a8x60/wh/Yeld8RnKNoxswaGx9NE/q2CWUb P2lOamb86FJdcVkIPBS3J0wojwOAGhEgdoIa4349Jzx+WT2xxdHWDvGzsowgE6V9NuK+ VzEm6YDVldejdwWArqA6ELmCXLHSZUL1/Chzf67L7/hkjfrZzFK3op0Y5gyHLYIonOSg CgWUTQMUu9KNk8T5PX60M5Rjw4PoGTyCcjXU6UNTHIpxkhR0/pRVuaw9DM1tTSbhfY7E fMyTDTTzZgMdcsKnjfTm9e/ZG3nXqYYPik9uDWgFMAS3g9JLHA3iT0S75nzXOmFHSbBl wNyQ== X-Forwarded-Encrypted: i=1; AJvYcCUmmT/xEsx53t94Wwc99QXP4/8ybjQO5MzgTJ1Dmz+rzk0YeYQ/x6tW3e/4iw1GXDZ3FhZxjYmD9OitQws=@vger.kernel.org X-Gm-Message-State: AOJu0YyphEOR2AYEZy3JOWe4fM+rLbttlo3H8ViGLa8UhMymoAjNUcNc SycFN+9MNfhTjv8Udfd2sgpO/7SjVc2BmpYeMfZ0+MHvdQYqR8cDw+m+U3IKDiZ+RUnugx/xGbM OWopZEg== 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 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: <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 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..ff529fa2d6135cc2fb32ae8a3ca= 26ac055f66cf5 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 @@ -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); =20 + ti_sci_pd_set_wkup_constraint(dev); + return 0; } #else --=20 2.46.2 From nobody Sun Nov 24 20:37:03 2024 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 3420D1C6F71 for ; Fri, 1 Nov 2024 15:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730475411; cv=none; b=HWq5+vsPsYmr2x3UUIDIMcEXFhP9WKoj9gvRym8oNJMx5J54rN3Nt1KROM1hwqz0xutOS6gPF//6wr1dzAg3YbweqD23wIkhJo5zDWFoWnZCWdgKElDUC2a6rDh4SQ3CUMPqaskxmFcN0OR0Q+8aEmvLpgBg4nSoXFRtbjztExc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730475411; c=relaxed/simple; bh=xhPvgmqbX1LH74jmdbMgtdutexJPgNxRb87XIYrFvw0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uIyzn5cPOqfXw4rcRQbx4RMhKNDP3fNWDML/Nl1q9u9d/PBOHCfv2fYg7rhkX0+f7zzuiI/yivmgunGQtWZ8F+cI62oV4/UiIZt/3mKa4L/WbmAIW0Wool19cmMdERJor4paUCj+dQzIoIaGI2CNLTpb0nBLWPsktXsPJVGr3ZQ= 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=KgHoo3oE; arc=none smtp.client-ip=209.85.214.176 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="KgHoo3oE" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-20cceb8d8b4so13678205ad.1 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=1730475408; x=1731080208; 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=Ke4bvOR1ARJKXE6dRhRI5chunW+2b5MmRjCBBzyOcvk=; b=KgHoo3oEKNkEZOVE0YYoB7nkNvsNCgGr3UDU6nYrhwxDU80qS+vVpCIrueW1xmvRrb Awc/oRlAtRSfaDaza2BMhAXtRMAuXfXBKqs0Uhd0i8QpVyYhEfi3QI8smTRWnpUiWNRi pF7vGyDZcyMnVXKfqpquu4Y+z+1zUCL9yp56H5fkF1ChvS7QsrryUpWrkH9XE9F5YPzJ ZVB+WWsvVGNa39RmFHwebbbHPei246fymVxd/O1qIiyFjzs4woxuAijDf/9Iat9U136/ +X4ohdHRqZnLpa3fX+Il0BtBcFYJYwGrooslYEWezgcJFkbNjIeUP6XwGtxgSWgAwA9y XMmg== 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=uJDsO5dcUbXAo5M5qmDRP6C3pEdKZ0hxcE6L65cVP/PZel0xz7hECQh9wsgWwa54TU hF/ZlZ8SW75RJ+/gwwwogsIdWhnQnUqP/C4GONevLURVdGxVCyMdVBKurS6dRGVLBrhd wiOZuWqPqpQOPfNIha+B6+2fJUwB64mib1ezaeafyCFBNQRSP5G+qrqchmflf7fNItlg i7tL0wrjXTiJWpZ7noeG+l3CMwDNhmCFc+8Z0+T7yAq5x0M3EREECXr8b9iTXUgqVihM 2iTIhclbQK8CSqmLhR7pMQKK2P6dXVg8v2AsiXHSlieohVHoIwe9daerMU5B8rIkbWLd C3uA== X-Forwarded-Encrypted: i=1; AJvYcCUENdHJpiZCZYQKPFH6af6rK+Qwb1O447yyVRYxPfbON/OJOXYmw81kpTPHLlW4TpBogyWUygja2jTDHkg=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu6Su+xksgD+Nq4Gaps4f0cfhG3yfrZOVlZ92J3RdN1SoWgC3k fL6E7V1D/ru0oS3JlrYBsk0KzAOkAtVofKuhcV/n56v0Sm4WmB2XJoukCOeuPzixZq3T5cPesEx 42gkl3Q== 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 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: <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 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..8c46ca428f60b3d42a5a4348853= 8f16b7ffaa3ac 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; =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