From patchwork Wed Aug 14 15:39:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 13763661 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 5C508C52D7B for ; Wed, 14 Aug 2024 15:43:14 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=y2mHcNudHQ2J7KK+PvZEplwN1eJNrfpSWSE1XYB762U=; b=X4pJ4cNk+KoRwZ+dLlCfNQ0vl1 AnhI/Q5YmysEcZ59++EwWmHBGnx5SdB1gPbF71D+P5ioIOB8ImHtPklaZ7iGSEeSqlcNCm5JPM/JI HXIjxFg27QZWF9B0Th+BAFDK/vWs/vMb4+SJCieuJwjwqtO7c5cchIDDow6n8BMRS4sk26vRR/tKM a8VhyYSqLCpXo0U7ICkSQnVgCkXNHIYh6xajFieiYt9gDrkRs9GEUc2lYZzMPM8GWftSTLQ8XrDZT 9/hkULalBU8/ASfWx1Ggrcyk2klRdzosJ+2ODkM0ryjQSZqupbS6MQ9m5lFMmscJRhY7hcboGhJnr /N3JZV/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seG9P-00000007Vcq-0akY; Wed, 14 Aug 2024 15:43:03 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seG6R-00000007UxC-19zP for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:40:00 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1fd70ba6a15so52935575ad.0 for ; Wed, 14 Aug 2024 08:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723649998; x=1724254798; darn=lists.infradead.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=y2mHcNudHQ2J7KK+PvZEplwN1eJNrfpSWSE1XYB762U=; b=SnpcTFfu8IEIRL6CcOqaUNOcTFphsQ8iLJmheKNuNe5nh2GDyalTVlj9sgUC6KhXn4 ybNl8TSFUzKFrctAkBKzN3KKbI+bBA11GgJWwqimXQaG4B4W1ldM/U71fi2zX5nx+m0l 5ICplOogaFzsT8uQFjpBWszVrTCryDP7xftPaJqo6MIYMofz+1nadj02WC8fk/2BQfS8 fvXs9pP1zZoEAIn7WKseWIhMmitOGWT3KDRaoL7E1O94nmghDlGckJ/FkS3MStzZhjVo CcT/xxUjipi+CFAaLIDzNHsR/LE+2QMPDkoaKDnxt/Y/LUNrg12yom8wWYhu0JxeBEgd XPxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723649998; x=1724254798; 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=y2mHcNudHQ2J7KK+PvZEplwN1eJNrfpSWSE1XYB762U=; b=JpcElqUndN++ujcj7J1e5wVS5SfbbCI8mwotA9H29gO8lewS8Yzz+3jC10HOoLAeR2 mcrH5ktwJxSfpHXhGwJVafQGpxUHw1tqWN3yh/gMzS0m+iXvLdZ588fRutfDxX2YddXk 5ze063JahLO9H4L+Ao5qvM47ZNiODIUEJI+7l+5SdS0j3wRnuIQhFxfrBYy10NRq/xG0 FnchP5Oo+DJX7A2jDw/tJe3iH9zDNIP/lUlalJE0TpJ8uIrhnoCZKVInKMq/ZvOwEFGo fvt8qeimg6dUp3hRCkzPYGinNsAYc0Gj1Ln5kEMeJK4gWp7+PdZQy+CO8xE1RewFfri7 aWVw== X-Gm-Message-State: AOJu0YyCpWOH/d+87qUwYsQCCvZ39VkEHD8BKngpQj3A4M30K0d82B9p hBaRbZ5iuG7crncEEFH+FH4QG9aoT8E1GlB8l8t7ZSYFL/Yeft/Fk5rq54N/LBg= X-Google-Smtp-Source: AGHT+IFFuFlXHcCpgUXl2SWCuQLztcXNYrz5ohSNtrXnZ2RsGSm/ZnWNqQZ7tX0OfV01B0yJywvE6g== X-Received: by 2002:a17:902:dac3:b0:1fd:6c5b:afbc with SMTP id d9443c01a7336-201d64b075amr39750105ad.49.1723649997979; Wed, 14 Aug 2024 08:39:57 -0700 (PDT) Received: from localhost ([71.212.170.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201cd1e2947sm30963465ad.306.2024.08.14.08.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:39:57 -0700 (PDT) From: Kevin Hilman Date: Wed, 14 Aug 2024 08:39:31 -0700 Subject: [PATCH v10 4/4] firmware: ti_sci: add CPU latency constraint management MIME-Version: 1.0 Message-Id: <20240814-lpm-constraints-firmware-msp-v10-4-bee4314bbdc8@baylibre.com> References: <20240814-lpm-constraints-firmware-msp-v10-0-bee4314bbdc8@baylibre.com> In-Reply-To: <20240814-lpm-constraints-firmware-msp-v10-0-bee4314bbdc8@baylibre.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Vibhore Vardhan , Dhruva Gole , Akashdeep Kaur , Markus Schneider-Pargmann X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2353; i=khilman@baylibre.com; h=from:subject:message-id; bh=KJIXodqaL/PlsDNGovQcl2iggmyHiixGfjVtxIDXn9g=; b=owEBbQKS/ZANAwAKAVk3GJrT+8ZlAcsmYgBmvM/Io/sKs8c84RWhexj+Zi6QBwTej+YUooUjb s97x27p1lOJAjMEAAEKAB0WIQR7h0YOFpJ/qfW/8QxZNxia0/vGZQUCZrzPyAAKCRBZNxia0/vG Zbj3D/9C07sip72O4Z5THjZtYagRVIR6SubwIE6eJYGg/7jzPwBA/CNELi2giSqGsSVsRNCRF9r HUKM+fzJapObF5XTNoJYRD8KcxNhAvQdXZcB+y+29jcnrw2GPH6Go3+Rb1MDXkI288gXSbUolpW hKWU1bN1B894RlxHQJa9jvrs5DT00kZzF4xjM67h7q4aI1LE/tnuXCLtlG7llK/KImGUp297WhG YE26VWO9fTwOsboD9t/fsjRHH7rpw0wYJXKYi16Ei0kKC0kGPumYtSl64nqYkKnVUzGn2opz0w8 7vJjKRGooIwZOdSRPY2EO2IgVqGssgm+8fDPOIdEBBTVgbfoukyrOBxXQGq8gdNqCt6YJ1jgaE7 eY+qyjImHQYAScEa0JqRFYJvMgTebgsfY6K/fVs7AZ5ptN+iHGPXFUsHj58LeGg7suQSu8IrBBg ad4f9PiW8r194/lvYEqYlzPfIR070N3+wR+2IVjVEs1D/DNVmhVUfT/9T4mQCnymGwxtkDSPdh6 tGQycTDPSs5rpyAs1Z7mZ71Li6g9YoQ2T1rasfUMxID2E1+zcUUBQ5ZJ9mtr3xP1TAGjxMiKkTV zgQ6+CMzN4iqW7naaYkBJeYsPl/eUjP76+jCqKWYUImnLSv2omR/KnZb31N1wnMEydl2HTenJ/+ 3wXwJlCd5vnMpeA== X-Developer-Key: i=khilman@baylibre.com; a=openpgp; fpr=7B87460E16927FA9F5BFF10C5937189AD3FBC665 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_083959_354953_E3CB1CA7 X-CRM114-Status: GOOD ( 16.20 ) 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 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: Markus Schneider-Pargmann Signed-off-by: Kevin Hilman --- 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 107494406fa5..e0b11ca30af5 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -3645,7 +3647,27 @@ static int ti_sci_prepare_system_suspend(struct ti_sci_info *info) static int 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)