From patchwork Fri Aug 9 13:53:47 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: 13758842 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 4815BC52D7C for ; Fri, 9 Aug 2024 13:57:31 +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=pcd0Lyz5JwSqZfd6Y5W712pL2iousIM4OAnnr2KOowM=; b=tIe7rYtF3pPuxEgTG/amMQOVuP gyoJRmXSUfyym/AAoTuAvsZwrmZLaw+zDANSoQafDjkw2khoyrOGvrYNsRhIfbn+KFLdLw/Ucghh+ +xdT7pqCqamB2YQOd5Aiqk+Ebe0beiGrQYLXAMtdzdtaINrr9lN4s3yIPoPVHBn9N1kOBG0E4RLK5 RZu3KkVTEPBYx2IAR15i8NpSh+XR88gSj4zx1w7pOuxyUA6ibqvjaKkVXch8WeS0s4PibYX6pUUuK AhaMCda9wNKiA7rpciQJrJ4LRQ5CPNLtrB4452+nxw3PG0nRBr7ac0Xlk5o1p8PvKcE6Ts6vgLo6V qyCGYB+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scQ7M-0000000BQpR-29Ex; Fri, 09 Aug 2024 13:57:20 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1scQ4F-0000000BQ1X-0PUQ for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 13:54:09 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-7091558067eso1074378a34.3 for ; Fri, 09 Aug 2024 06:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723211646; x=1723816446; 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=pcd0Lyz5JwSqZfd6Y5W712pL2iousIM4OAnnr2KOowM=; b=u/cRajgFJnvoye8xoKSMCky88w6B9loocjYGAtJxyaE4qoM5id+A8v+c5r4ymlp9Bl AGYmJkQUhkXlrV/A2xaFdu7wFhJBsuNb0toK1oLuVDy9vz0JHxkemI6EbIyjgQGOHlUm EIPEx1D4Xd269VJB9Zcni0quiJxpef9z0AbR01idVi5w7Mvtkoh79fZuJacW+BHUsduL 2HzADbk3kpwrUxxH/zWOM+SzCa1Ou+Qkvmy7D3XVnWM3JOwxIeZ2jZwYHxJl3xt9JcCW mq8BTdSXtRZlP5zcMP7mjOqm0oF2FJD7Zqz8QLr9ZesokBgZ+vIxgZMafwx5fl+kMGSK 0fuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723211646; x=1723816446; 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=pcd0Lyz5JwSqZfd6Y5W712pL2iousIM4OAnnr2KOowM=; b=AqBNkazdyYy41fCeVHY193eMFmaX21oknDKMID1S0SsT0VNuSCPvD6az4yNjjTX6RJ 4V608YiGGj3zuRO63LHVGM7h+BleobUXk1A5cWy6UlfKTt6dIGVql+jOTPAqzNa9/Hrd 2HxL6rc4gNdI6VY+bC229DFt4FcXuKrmJYCZ3aakkl/xx6nhWSkWKUGaOt0nenFsVlCx Gky8TE0xyjdWRNaXLBuH84zblFhTOUW/WF/QG2lK9ujZJaswaZFgKpQ2CTCw2Sz9xOMg u9gWQB4nxq/Rwyib7EUx32juhuwhSrwzkW3uAObW0T371IzfiK4/XHYQvK+ALr3GePU7 uw6A== X-Forwarded-Encrypted: i=1; AJvYcCWNYVQzf8Om/WCu37qRa7thCFtzNxscrrRalWX2iPnY2thCLwofcDPIJ21ARJFKsFtnT/eg4YqoBWalfYT65WBJYvZkC235W4iXkyM5cK3YP+kRdPg= X-Gm-Message-State: AOJu0Yw7a/2G85/lunDPy3Z3OTug3BFzkF4ZndVqLQb7Bgk4M30T9Zff IEGfEVwJoC7kvvBavNMXQiE6y9FSaV6+g9F8aCX3CuOkm88LceVAOl9KVJTvDSI= X-Google-Smtp-Source: AGHT+IGxziKJpCJ3mF7dRPKIDKXl3jdK0ixQw2TmnjOWrBNN31EoWUD8HkNBvokPEvqccdQBDsGsUQ== X-Received: by 2002:a05:6830:620f:b0:70b:2aaa:4bd4 with SMTP id 46e09a7af769-70b747318cdmr2155508a34.19.1723211646327; Fri, 09 Aug 2024 06:54:06 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d6a2728bsm4158640173.103.2024.08.09.06.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 06:54:05 -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 v9 4/4] firmware: ti_sci: add CPU latency constraint management Date: Fri, 9 Aug 2024 15:53:47 +0200 Message-ID: <20240809135347.2112634-5-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240809135347.2112634-1-msp@baylibre.com> References: <20240809135347.2112634-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_065407_173261_188EC5CC X-CRM114-Status: GOOD ( 15.75 ) 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 Signed-off-by: Kevin Hilman Reviewed-by: Dhruva Gole Signed-off-by: Dhruva Gole Signed-off-by: Markus Schneider-Pargmann --- drivers/firmware/ti_sci.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 5cbeca5df313..481b7649fde1 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 @@ -3639,7 +3641,25 @@ 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; + 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); + } + if (cpu_lat && cpu_lat != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) { + dev_dbg(cpu_dev, "%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)