From patchwork Thu Aug 29 20:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13783806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A53ABC87FD2 for ; Thu, 29 Aug 2024 20:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JWfsv29r3VhWhUdf7/jPyF2un00LRMtxeQCEnGIAQLs=; b=Y92/sbfC0TF+R51/PmsjBj6idf vAiFJ2ODt40EAygGfDuoKGXPmbCy1C97ui6rui7pisYNwrqwg6FyVoz+kDee9L/NKzU1PtmdpGW7U I+1UwrMpNCRi1bTuXGs/BPM00+J8PKGtKCsvx4xSCRQ1HwEeOWO9wjp8mxmKHSpuJa31D8DTpgCai W+DCiZKB1Bb1t4+jqEDsE3Ydg76l5m/Visb1iArDYqFdf7bV7OSeWPnjqe+HRuUyGyHC0/9i7ucES +VCFLu6GDnLs+aOA8HfurDNK7EpooF7GlMpH1YYCbdB9V0wyp3yuD+1LUxi1rjVHNGnKFNyWQHvye gPYqulpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjldD-00000003WUh-1s85; Thu, 29 Aug 2024 20:20:35 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlZ6-00000003VXK-2KxW for linux-arm-kernel@lists.infradead.org; Thu, 29 Aug 2024 20:16:21 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42bb6d3e260so9424425e9.1 for ; Thu, 29 Aug 2024 13:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1724962579; x=1725567379; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JWfsv29r3VhWhUdf7/jPyF2un00LRMtxeQCEnGIAQLs=; b=0/vUbGL1p9+JvO+csCVPBYWvwcvjhnhccEbr9JXL2TWcrDOBc/0YRvhnrCT41sbSvQ 9cRBaiRnYxbwKmTeYXGj2Mx0RlTIlIryXrj/Y4u8/TAApX+Y3yJMQ5IgE6pR0HJA7YDH tHuv8OZBPc+0BkB5ej85CS2qmhO4vhyHWluaAsJBAKE3UwrUWm/w3Y2D+YUwaiAdbPhY 5iBWRrZOLwo+e1FpmOXxDFKFINvaDU9ZWTRgiP9JnGepmzTtBl4Cc1vJhOf7zbF+sYnw R4qTk17pHumirDa5dR6EMS1KPf/qoMyTqIMDVwGbE1l4LfQ9w2EQ1RBPfvJoM/396uCn 4MGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724962579; x=1725567379; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JWfsv29r3VhWhUdf7/jPyF2un00LRMtxeQCEnGIAQLs=; b=HOSCujZaUmlFqO/O1qcnNQsA7Uk3BnX9t7e2b7pUKylct1j/0V6I9pBr+qLH8QnyUw RVEwXqwH0d8bj1bXtG+Shg7/34Sun4uEZ+r0Z4l6FBXdiXVVtfUzBD3E8Ec+4o7d61N6 YzLFcSDbiA9r7FDF3oFqtVqssh/GbnlkhKVR3AoAsFBgZ+FaAX3dhrJOVl1NSSu43vES tZI200mzkO9lT/ovSGubQjET4wg3F++MSLfdzKzqPytQZDtHK4Wkf8KaXoMEqn0fynpU m4vqw2G0TQJd9kD4t8qchdr26o5azB+AGul6oPZKF2v2JrEDUbqWMGTZb7tJcoRUBieb AmHg== X-Forwarded-Encrypted: i=1; AJvYcCV6wo2gFGU34RajxAe+i2rrp1Zvm6VorAs9OlMhnFDvZ6xS9jDLHr+G6+Q243EDL8VTeOwJAl6NJVSnTdjRpTk9@lists.infradead.org X-Gm-Message-State: AOJu0YyzG7OJLnoEGZ7dNmhsYjefpepjUy7hOK36SEX5M8omvJbiRmQd yuFayly20IIHwWpPfof13Vwg5ODNa0vZ5oBx8OFDmZgvIq4dvpnzsxwhA06gzik= X-Google-Smtp-Source: AGHT+IENmqCm1q5qqRQc1yXcMb059f8u73uG8GUWYmbtJQbfirOWVwNs39SXI20l1WQ9ce5IcIBbGQ== X-Received: by 2002:a05:600c:3b11:b0:426:6667:5c42 with SMTP id 5b1f17b1804b1-42bb023cdc0mr33044905e9.4.1724962578764; Thu, 29 Aug 2024 13:16:18 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:802f:3a47:b29:5530:28a2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6deb303sm26681385e9.9.2024.08.29.13.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 13:16:18 -0700 (PDT) From: Markus Schneider-Pargmann To: Nishanth Menon , Tero Kristo , Santosh Shilimkar Cc: Vibhore Vardhan , Kevin Hilman , Dhruva Gole , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH v11 4/4] firmware: ti_sci: add CPU latency constraint management Date: Thu, 29 Aug 2024 22:16:05 +0200 Message-ID: <20240829201606.1407773-5-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240829201606.1407773-1-msp@baylibre.com> References: <20240829201606.1407773-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_131620_709264_402BDFA0 X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Kevin Hilman During system-wide suspend, check if any of the CPUs have PM QoS resume latency constraints set. If so, set TI SCI constraint. TI SCI has a single system-wide latency constraint, so use the max of any of the CPU latencies as the system-wide value. Note: DM firmware clears all constraints at resume time, so constraints need to be checked/updated/sent at each system suspend. Co-developed-by: Vibhore Vardhan Signed-off-by: Vibhore Vardhan Reviewed-by: Dhruva Gole Signed-off-by: Dhruva Gole Signed-off-by: Kevin Hilman Tested-by: Dhruva Gole Signed-off-by: Markus Schneider-Pargmann --- drivers/firmware/ti_sci.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 8482b7077eef..d5d64e5ffbd7 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -3669,7 +3671,27 @@ static int ti_sci_prepare_system_suspend(struct ti_sci_info *info) static int __maybe_unused ti_sci_suspend(struct device *dev) { struct ti_sci_info *info = dev_get_drvdata(dev); - int ret; + struct device *cpu_dev, *cpu_dev_max = NULL; + s32 val, cpu_lat = 0; + int i, ret; + + if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) { + for_each_possible_cpu(i) { + cpu_dev = get_cpu_device(i); + val = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_RESUME_LATENCY); + if (val != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) { + cpu_lat = max(cpu_lat, val); + cpu_dev_max = cpu_dev; + } + } + if (cpu_dev_max) { + dev_dbg(cpu_dev_max, "%s: sending max CPU latency=%u\n", __func__, cpu_lat); + ret = ti_sci_cmd_set_latency_constraint(&info->handle, + cpu_lat, TISCI_MSG_CONSTRAINT_SET); + if (ret) + return ret; + } + } ret = ti_sci_prepare_system_suspend(info); if (ret)