From patchwork Mon Oct 7 06:08:58 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: 13824099 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 6C786CFB442 for ; Mon, 7 Oct 2024 06:23:24 +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=UJT6fTnyK7gt6GR+f50pMFXilJq+FtbxEdBurZINfZs=; b=0dfXbfzaqA81TXTxwSSkPDnsyt v/GVsKNhrOAhm9O85VElo+npWBlHiLDhaIjN93VgafdYm4TxcFm1vOxa85yGEHsfqTO3fmKImymOs fySupJq0tequqCevDV2OFUtYyN9fIoaoQGQiich92Y/wwtodRDIX92lfSR/yScuc3RuiToBZl28Bc LQDJeRzxQWI6fSn9d42FwYExG3PRsdy01XkF89EjSk0PVppSphiycDvvTCQ20PwKWrfWMVBbil7lr frn+bC238w9mlQg1Pf5CkmXSBuoU1QEF3IVU8IdixwbYxALLuDxxXCn52z7C7lKoPrhNq8NLkfkyO QC7A5bGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxh9G-00000001PPF-2uK6; Mon, 07 Oct 2024 06:23:14 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxgwK-00000001NQv-3W83 for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2024 06:09:54 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2fadc95ccfcso41636091fa.1 for ; Sun, 06 Oct 2024 23:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1728281391; x=1728886191; 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=UJT6fTnyK7gt6GR+f50pMFXilJq+FtbxEdBurZINfZs=; b=NELOaJQCYqeZX3b00I8wzpuOWtUYUI24cyiuATZg6wJUBTeFiioAfRNDxwlOdNa+pG 6odky2taKIU/cc7sDJ0eMA13O28Eq9AtveRRFiokv+gL/KaIPQx8kpQ43yeB+dgD+Osw ERlaf0tkJ8Q6BsPqizcqPi726lBJtAK4H9gnVPZCzG8H7FY0ENrYodWtzOfdl+DK8fx6 sSzvf5VVDs/0KDYT4F1j0s17GmQxNhwJK/UzFCeGsTrFMTTZjwQGry4Ka2miKBWnryls UNpU9KP6GDeL0tDct2igJnGYlrWgJf+j9APOO/7FBfhWtHUViYzTmPQz9FbqFLeu9FYb EgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728281391; x=1728886191; 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=UJT6fTnyK7gt6GR+f50pMFXilJq+FtbxEdBurZINfZs=; b=fMw84KZBATtvOggBUpI4hz7rVGkV2kvWpVZG3ZOxQg8FWvdfd+MDpCo/wE35xiFwZZ qbJjzNcupoDFlXttPlT1EJLnf27S3VzabRNtNzERkJYk58kVGOw/Uh4Ex0UK2OsZajRQ AUlm9NFO0IX7yJhB8Arn3oMlNhjLNavyBX7+N1mS3X4sMQ3S2XLRhKrZKeCfn7DTL46W 5oSKgjsobX/40cX0+VNCjAirVDm7uqiDAurqr8EOdcPH7xNzUcEgZqR+lsu6UJ2Yteq8 ijhnChT2uSIgIrN/vev6uSqA7hk0pIJJo/XEGoF+2oQmwcKlQNfJ7ZevixXhoE4MAGUk SJyg== X-Forwarded-Encrypted: i=1; AJvYcCVZN7J0FsHFuOk5RdgH2Kkz9bSczi9502/W2eZyX6UL9H5APRztU/PDXp4DoBENCsryAL3CIjfpHxjw4OrVZbdq@lists.infradead.org X-Gm-Message-State: AOJu0YzgoqJ0KA+A9Icd66DccoVJhcc5cxn6uGOY/mItGad+7Iu8SfHx F/o+a8bN9DdKdAZjNn3csoXUfDlmAEbZ+yTcL815iOtska7cwCmFWciWmgm9o2k= X-Google-Smtp-Source: AGHT+IHtE2q22c15mrUYBlM+XI4odC6qvh6wx9Y3PGlMgpn4Cp7+WRFxPbnEvB1ZDfNUB5pdtDtNEg== X-Received: by 2002:a2e:be83:0:b0:2fa:bb65:801f with SMTP id 38308e7fff4ca-2faf3c5e66bmr50601771fa.10.1728281390896; Sun, 06 Oct 2024 23:09:50 -0700 (PDT) Received: from localhost ([2001:4090:a244:83ae:2517:2666:43c9:d0d3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05acccbsm2780061a12.32.2024.10.06.23.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 23:09:50 -0700 (PDT) From: Markus Schneider-Pargmann Date: Mon, 07 Oct 2024 08:08:58 +0200 Subject: [PATCH v13 5/5] firmware: ti_sci: add CPU latency constraint management MIME-Version: 1.0 Message-Id: <20241007-tisci-syssuspendresume-v13-5-ed54cd659a49@baylibre.com> References: <20241007-tisci-syssuspendresume-v13-0-ed54cd659a49@baylibre.com> In-Reply-To: <20241007-tisci-syssuspendresume-v13-0-ed54cd659a49@baylibre.com> To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Nishanth Menon , Tero Kristo , Santosh Shilimkar Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamlesh Gurudasani , Kevin Hilman , Dhruva Gole , Vishal Mahaveer , Markus Schneider-Pargmann X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2464; i=msp@baylibre.com; h=from:subject:message-id; bh=NmQkSN4+LhFVHdywGiboPnzzPp0wfB+96FsAiBdv9Qw=; b=owGbwMvMwCGm0rPl0RXRdfaMp9WSGNKZqxUvCp2K/vhz+/eUX41npyxZLcdVcG3OoumNm+2+s W3gFNeW6ihlYRDjYJAVU2S5+2Hhuzq56wsi1j1yhJnDygQyhIGLUwAmEv6V4X/FxGWnbquJz/vg JWZx+/jUtczageXbGK0Nor9nZuVeaZJj+B9vfGb+CbPq/0o9s75t9Z8ePZHn7bqoJXPfvw1nt+N tWs0JAA== X-Developer-Key: i=msp@baylibre.com; a=openpgp; fpr=BADD88DB889FDC3E8A3D5FE612FA6A01E0A45B41 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241006_230952_928817_8D0EC007 X-CRM114-Status: GOOD ( 16.04 ) 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 b67c35c93802b50ed3ba7b97a216fb39d6c46ebc..555e41cc08080c78b3991a8d6c06f5030a576d72 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 @@ -3666,7 +3668,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)