From patchwork Wed Dec 27 22:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13505508 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 6D0DCC46CD4 for ; Wed, 27 Dec 2023 22:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=4GQvG1LuOjH+WXZoMf0hXGj0Cj3bpkhclHonyj9TxOY=; b=w4RD1YHyXO21i9 aLnq5n5S9WHzvZ3DP9nJgtMJltQXlvPldFkanjMR2sf0GWyuzxUb8xu6K/zawJz5MdPsOMYYV577x RJMJ2SVcoCvtAc1w9uUo1115zwNbAdoLJ6jDHyzvadY2XpUcrrGZkbeLBr5sJyC9JVGt+JF8II5nn 1bs9exMpEhnyrxkKN9ilW5af3W3Wpvm2Ezxl+eKJBYGnCLDnC5Y2PALYuoQBiR02veJHmvM9ZiUcU LggU45cpTjgbWvv5KBac52XRjHPMLD94ANMbox0wC93NoYBbq53AVP0mKx7XXVgUQfDxOEFHlYb3F /sxiN9XpOpn/LF8Ekl3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIcC0-00Fa15-0s; Wed, 27 Dec 2023 22:16:00 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIcBt-00FZzv-06 for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 22:15:54 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a22f59c6ae6so671942166b.1 for ; Wed, 27 Dec 2023 14:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703715349; x=1704320149; 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=QF50W+U9K2q+OXtEuQkW7nHtEV7kil/7qyeX3qRNKd4=; b=FNnsbkkHH1x+DFK5zc884dGhOeHa+boqlcf+ZIQ3hwTr/zbKubCITamasYCRUZydss C8ZRvwE4wOw9m7V44Fdgp+sVHjxGzyewfovkTS41w/rvmnhkNhfohFYwCo5eDNj+TthC gDwV2se/6j8mD//TyruIYSH1xqcOctJ1qlZ7Q7HQhrXZNoC8MZ4xx17q0/j9MmLlCdST zMdqEcWTnfu5sLkZlh5774V2reIFkqF7sqp+vght8Qr7TFFFM1xW9ZoLK1ZKPE+kFodn TJF7KWHgGFa1yCe2gMIc+WG6Pvrj7TCKpgs7zbLrRYycv7sXwMvOZWcvfJ9dnbyTqFRa O2Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703715349; x=1704320149; 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=QF50W+U9K2q+OXtEuQkW7nHtEV7kil/7qyeX3qRNKd4=; b=FHLGPFQc3/dmE4102ySaTdl87hC9tjiuUlOYGnsRSUZXUyaXAblBBOeUfnNuG5Ypln fhUNmkBAf3KUH6cLVVfMtcX2Co5YaDR6mdPkEVWgor/Qk5543lJVfsyXAJVo+oJ1OHSB r4/4IFfn2z6jo/7TB4FfZjt7gq9QGJETs4K6vQd+tuIzbAZlnHZN0lbEmBlJzOZhLRsq s74EcfCjtZIitDfPBIMTryv0R+DDCGi9oY8MPIk5aYIw14gva6fP6bk1mcW6/pDzjXPh fh9FY48mke1cPH8efG3hhMEyfsoaQJzlD0cTMD+RVYDX5oVNDGcaZHrNkURrLaGMrVmm ddzA== X-Gm-Message-State: AOJu0Yxz1ZD5t08E+30qAFEqIATNZmenLmieUkmfgTbOwb3Bh3PW1mcO J6hQoLyj05bJUaLx3w7UGUAimTUu5GLL3w== X-Google-Smtp-Source: AGHT+IE8u8NcolYC9CAgacNBPSEa/rRVqoJKk6Yds8s8XyKxpSPEgcmBrYMh794UszMqjYcJGZcBoA== X-Received: by 2002:a17:906:768d:b0:a23:713d:57c0 with SMTP id o13-20020a170906768d00b00a23713d57c0mr1984365ejm.234.1703715349284; Wed, 27 Dec 2023 14:15:49 -0800 (PST) Received: from [10.167.154.1] (178235179028.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.28]) by smtp.gmail.com with ESMTPSA id vw17-20020a170907059100b00a26f3d6062csm2821501ejb.50.2023.12.27.14.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 14:15:49 -0800 (PST) From: Konrad Dybcio Date: Wed, 27 Dec 2023 23:15:30 +0100 Subject: [PATCH 1/2] firmware/psci: Set pm_set_resume/suspend_via_firmware() for SYSTEM_SUSPEND MIME-Version: 1.0 Message-Id: <20231227-topic-psci_fw_sus-v1-1-6910add70bf3@linaro.org> References: <20231227-topic-psci_fw_sus-v1-0-6910add70bf3@linaro.org> In-Reply-To: <20231227-topic-psci_fw_sus-v1-0-6910add70bf3@linaro.org> To: Mark Rutland , Lorenzo Pieralisi Cc: Marijn Suijten , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703715346; l=1200; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=BOcN6TOkFupHjjux6yybqx6vqjcZtP/Ge6E7xFQ3Z1Y=; b=VqjR+6LtgrQAcFZLsGBSO7LUmQI+i23yymh1HGczYfwmvtx9rhxhsZTc5WKsyY/cald/Wznu4 dssyitvO+fmAE6L1tdpTAk5ZzwxVPqDLF3ouBmxVNbIdfCWRCKgI9pA X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_141553_076424_BD2713EA X-CRM114-Status: GOOD ( 11.10 ) 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 Some device drivers are curious to know whether "the firmware" (which is often assumed to be ACPI) takes care of suspending or resuming the platform. Set the flag that reports this behavior if SYSTEM_SUSPEND is implemented. Signed-off-by: Konrad Dybcio Reviewed-by: Sudeep Holla --- drivers/firmware/psci/psci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index d9629ff87861..1bcb752977b1 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -505,12 +505,22 @@ static int psci_system_suspend(unsigned long unused) static int psci_system_suspend_enter(suspend_state_t state) { + pm_set_resume_via_firmware(); + return cpu_suspend(0, psci_system_suspend); } +static int psci_system_suspend_begin(suspend_state_t state) +{ + pm_set_suspend_via_firmware(); + + return 0; +} + static const struct platform_suspend_ops psci_suspend_ops = { .valid = suspend_valid_only_mem, .enter = psci_system_suspend_enter, + .begin = psci_system_suspend_begin, }; static void __init psci_init_system_reset2(void) From patchwork Wed Dec 27 22:15:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13505509 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 0B87CC46CD2 for ; Wed, 27 Dec 2023 22:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=saGHkpdLY9idbHFOrlqINsCoRwUiVMkmkDy8ugBUfA8=; b=D0OJTCtGslzifv mwhCyFmpbk0KD4T2bXPzwdrXlCEhdxy/AC2pETY4d8C3CcS/1t2vJqjy+d+GMMGhymyYX4eLQHAWm a5QyB2N/2gusLhirFeOt9RDztivCVTOOqHvF34vUQPm06SUaMOKWV75w75Qid/zDsk/ZodE9cjQ7y WZIlrg/hfDahKLir0oBsu7rIiJo953gVGOqJgF04qesU8L+Fr0Vgj6NfF2y6xg3mAIqg8/0Wc2vVD VprMSzoEpUvvrUVcZCGEkQEpn1Mi4Sg6rVTDx9vDOlR57Yylhw14HmryPJzLF1sbH3tqfCsK1hpG3 e2zQgajHVP3gh9/GhNug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIcC0-00Fa1L-2i; Wed, 27 Dec 2023 22:16:00 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIcBt-00FZzw-0a for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 22:15:54 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a235eb41251so629214566b.3 for ; Wed, 27 Dec 2023 14:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703715350; x=1704320150; 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=DM4CXwvWCS9WJcPPk5LYsBDY7vznKyyVFP9Y3rGVGSA=; b=MqsAi99buZzq8/k5Z4JLRDynPQoiqU/xhqTeG8vZ8HzfKXcTGcYSXdU31l1DUYUa1D zyfUOiLsTuxGfSmjFsOP9RAtNc3ou7TUsmXYhNg89MfrHBFWWs7Y/H/FElqUrOGlErgR +PXe8YBE6qrPCzUppfzC4/0hD5jNuMTwu3OSwFbmg/GDE2ZBs0Xj57ioWBch4MXvmyrB SjwYE3abeO1TOSuNRATDiGRUYV1N1YDjtVbTBP58Ed5fecpfSU84vhTP5IZFgw7IBIiZ TQuCjddqxYj6NdAwfSHoyHuJKrJ/zv45PCpYBcPBdtXcTgd+pW28r+WRP6CR65a91LVE gWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703715350; x=1704320150; 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=DM4CXwvWCS9WJcPPk5LYsBDY7vznKyyVFP9Y3rGVGSA=; b=gcubuZZo0GwIwVpXVJs0O6V8Dz6z1ehG6p+j/ZjZ1LGLokqmaTUjcgSBNlqlxgZ5j8 TiyxQTIvmDKCBCIzAA3WaRsgWpDYulSr/E6cJ56NXZlP8dQy7kAVQbB1pvhmTuTvp68I z66eTSoP8j5K9D5/iDN/zacgZF/8NWIUM605JzAoGBzWnSr8M+LisjsMk2utyTNo72w1 IT2iDAZL4pjpPSpoaFnd0SO505R2F+F5XlRaQfFEaMf5yOhTJYzZ8LYG98oluCoTbMiA Fa2e7i1ewwMDAO/cLnZxbagDV1fCHD4iZrfgS1L/AXd+DR4ngyyBSkuN8v6x7qXZeqQ6 ZjLA== X-Gm-Message-State: AOJu0YyGaKGh0vVaE9U2MhDNX1uT66rVPCwomVHvb9W285ZY6JWtOJsW RvAC5MKhs7bvcNDU05PikpaZIF9x/B5hag== X-Google-Smtp-Source: AGHT+IHb3i7zrOCE9dus7HdyD0r11qGjZT/lVPCmvxmqEPH98DLPQF0l8rTAJ7Iq27OsSbhi+H3pjQ== X-Received: by 2002:a17:907:91d1:b0:a26:93d9:eb6a with SMTP id h17-20020a17090791d100b00a2693d9eb6amr2433282ejz.44.1703715350572; Wed, 27 Dec 2023 14:15:50 -0800 (PST) Received: from [10.167.154.1] (178235179028.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.28]) by smtp.gmail.com with ESMTPSA id vw17-20020a170907059100b00a26f3d6062csm2821501ejb.50.2023.12.27.14.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 14:15:50 -0800 (PST) From: Konrad Dybcio Date: Wed, 27 Dec 2023 23:15:31 +0100 Subject: [PATCH 2/2] firmware/psci: Set pm_set_resume/suspend_via_firmware() on qcom MIME-Version: 1.0 Message-Id: <20231227-topic-psci_fw_sus-v1-2-6910add70bf3@linaro.org> References: <20231227-topic-psci_fw_sus-v1-0-6910add70bf3@linaro.org> In-Reply-To: <20231227-topic-psci_fw_sus-v1-0-6910add70bf3@linaro.org> To: Mark Rutland , Lorenzo Pieralisi Cc: Marijn Suijten , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703715346; l=3395; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=JzsZaTg1IMKhIfK68jHfV873UZDk10Nbu4hj2+1j2fg=; b=Mw5QVXoHdGheLV+1bzxTtADhkn/zaPQU1MbgFoSVA89LnbIQtJJVihIi5J3WuZYWxQindrXvB sUzNfSt1TuTDktJtJD/hPUp1yX52useQnsRzz4Dywpgok07cbtfO0Wk X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_141553_223897_79126556 X-CRM114-Status: GOOD ( 16.56 ) 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 Most Qualcomm platforms implementing PSCI (ab)use CPU_SUSPEND for entering various stages of suspend, across the SoC. These range from a simple WFI to a full-fledged power collapse of the entire chip (mostly, anyway). Some device drivers are curious to know whether "the firmware" (which is often assumed to be ACPI) takes care of suspending or resuming the platform. Set the flag that reports this behavior on the aforementioned chips. Some newer Qualcomm chips ship with firmware that actually advertises PSCI SYSTEM_SUSPEND, so the compatible list should only grow slightly. Signed-off-by: Konrad Dybcio --- drivers/firmware/psci/psci.c | 57 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 1bcb752977b1..ddfdc14e2423 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -523,6 +523,30 @@ static const struct platform_suspend_ops psci_suspend_ops = { .begin = psci_system_suspend_begin, }; +/* + * Some PSCI implementations (particularly on Qualcomm platforms) silently + * sneak in SoC-wide power collapse through CPU_SUSPEND, while advertising no + * support for SYSTEM_SUSPEND. + */ + +static int psci_cpu_as_system_suspend_enter(suspend_state_t state) +{ + pm_set_resume_via_firmware(); + + return 0; +} + +static int suspend_valid_all(suspend_state_t state) +{ + return state == PM_SUSPEND_TO_IDLE; +} + +static const struct platform_suspend_ops psci_cpu_as_system_suspend_ops = { + .valid = suspend_valid_all, + .enter = psci_cpu_as_system_suspend_enter, + .begin = psci_system_suspend_begin, +}; + static void __init psci_init_system_reset2(void) { int ret; @@ -533,8 +557,33 @@ static void __init psci_init_system_reset2(void) psci_system_reset2_supported = true; } + +static const struct of_device_id cpu_as_system_suspend_match_table[] = { + { .compatible = "qcom,msm8998" }, + { .compatible = "qcom,qcm2290" }, + { .compatible = "qcom,sa8775p" }, + { .compatible = "qcom,sc7180" }, + { .compatible = "qcom,sc7280" }, + { .compatible = "qcom,sc8180x" }, + { .compatible = "qcom,sc8280xp" }, + { .compatible = "qcom,sdm630" }, + { .compatible = "qcom,sdm670" }, + { .compatible = "qcom,sdm845" }, + { .compatible = "qcom,sm4450" }, + { .compatible = "qcom,sm6115" }, + { .compatible = "qcom,sm6125" }, + { .compatible = "qcom,sm6350" }, + { .compatible = "qcom,sm6375" }, + { .compatible = "qcom,sm7125" }, + { .compatible = "qcom,sm8150" }, + { .compatible = "qcom,sm8250" }, + { .compatible = "qcom,sm8350" }, + { } +}; + static void __init psci_init_system_suspend(void) { + struct device_node *np = of_find_node_by_path("/"); int ret; if (!IS_ENABLED(CONFIG_SUSPEND)) @@ -542,8 +591,14 @@ static void __init psci_init_system_suspend(void) ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND)); - if (ret != PSCI_RET_NOT_SUPPORTED) + if (ret == PSCI_RET_NOT_SUPPORTED) { + if (of_match_node(cpu_as_system_suspend_match_table, np)) + suspend_set_ops(&psci_cpu_as_system_suspend_ops); + } else { suspend_set_ops(&psci_suspend_ops); + } + + of_node_put(np); } static void __init psci_init_cpu_suspend(void)