Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4667157rdh; Wed, 29 Nov 2023 07:32:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYUnFa/JMCdZh8yc0Bh13wEmSwC/S2FeKW6qNexDwam5RnvnvWT+r8OiwHHXhR2AkM2gUr X-Received: by 2002:a05:6870:9e06:b0:1f9:f5c5:c023 with SMTP id ps6-20020a0568709e0600b001f9f5c5c023mr27857540oab.57.1701271926078; Wed, 29 Nov 2023 07:32:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271926; cv=none; d=google.com; s=arc-20160816; b=AFPVrk2dWmxJHx2JwrLjdAO/8TKPvPr2d5Z2MnTlEJePTq605bvpJ23o8B5YDzsA5r WcmF4LL+h//v2MLhrSaBFRASmKMczvjz38QyXuhAaGAV024nScDkHe7Yu6dKLCY5efp/ /U4Mp8n/4KcZwgGefWc8pz0PPj1H+QDzi9rqfkiesLW00Vled7O6oI7JA8wtobHf+fRZ A4K3UoMnSMipgzN7YjG5gWijz4RHgAmDRGVyAuR9PFtsrxoR5PqHMlCNCnCPI+NKxu2U oeW+WNygqPHOOFNVw74WvnyeN09wF2tb2xQHZMKqSQmx3e+sMDMPAAGHR13LO4Z4iOaq 10cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ONeuGYPs2IMgsIBQkR63Bawpq/9TA/sG6QW/wej75m4=; fh=qiuiZXOuSBoCezToil2F5RBR95PkXWcuBaEpicqga+E=; b=kxNaZ03qq0W584Himspg3GTK1af4K6J7GuppEKZzyZEsQnyR4ErW82bF1/gLcz3vvJ YW97rs2DiQwiMLNMZX83NO7IKFfWkUbyGi7XA28ECr/dTPoxYwGsF4k6ng7Qox/Fxo2G vbXU52ulS6Rr7SwtHSl7Ocs59KuuMoTEwRKgMttCj460ObF5U0z3IlK59ohIUPQQjSvM M4H7/1aBv/0YLySkfvwMRObjnUTjJviRXBmUWfbXWSiYFoHwn61GywGfMIzzr1oxeSCA RIOlhCkVuOtWn0UsSBHN15woTQMFm1O8x22vV286Zo1avlbe++7dVQZAETcmuGCOAZwW BV2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="BO10/zqY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ec22-20020a0568306e1600b006d8017dcdaasi5970809otb.140.2023.11.29.07.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:32:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="BO10/zqY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B39AD802857B; Wed, 29 Nov 2023 07:32:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343739AbjK2Pbb (ORCPT + 99 others); Wed, 29 Nov 2023 10:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbjK2PbV (ORCPT ); Wed, 29 Nov 2023 10:31:21 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D02CD6E; Wed, 29 Nov 2023 07:31:27 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 980B2E0012; Wed, 29 Nov 2023 15:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701271886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONeuGYPs2IMgsIBQkR63Bawpq/9TA/sG6QW/wej75m4=; b=BO10/zqYJKqTCTIriRT9JmPYFVTsWtcA7KqYL7K/1BHkPPd1Xn0YV9WLZVcrbte4oXJ2t5 3yPSNaxWnpuWxT/A/2D2eVv/dIWO5zasx3T0t64s3Yj6FmsKEAE9y5lN+X7hL+eZrye8NF xkapT2x0QOo5fK3O2yfX6sJo38ukCLlKiAf2Y7brH8S8iwQC2oH8hgCG4TXlO4V72aIQsd roI5ybfc38SLcyjs2xBIR2XOgXfHQtbegtMgxm+pcQNyM8DNq2Qa6Yt5psl0+3Qt7agspG vwaOIprv1oFe5JB3R6Mwc5LCySr4SG8rjNzBhjIWr1LzOig16YdDNBxyDGLmLQ== From: Thomas Richard Date: Wed, 29 Nov 2023 16:31:20 +0100 Subject: [PATCH 4/5] firmware: ti-sci: for j7200 before suspend check the reserved memory for lpm MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231129-j7200-tisci-s2r-v1-4-c1d5964ed574@bootlin.com> References: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> In-Reply-To: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:32:00 -0800 (PST) On j7200, a reserved memory region is needed for TF-A to save its context during suspend to ram. In ti-sci suspend, check if the region was defined, if not return an error. Signed-off-by: Thomas Richard --- drivers/firmware/ti_sci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index c26ec86a5ff2..deaca17322df 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -77,6 +77,8 @@ struct ti_sci_xfers_info { * simultaneously in the system * @max_msg_size: Maximum size of data per message that can be handled. * @restore_irqs: Set to true if allocated irqs shall be restored at resume + * @lpm_region: Set to true if a reserved memory region is needed for suspend to + * ram */ struct ti_sci_desc { u8 default_host_id; @@ -84,6 +86,7 @@ struct ti_sci_desc { int max_msgs; int max_msg_size; bool restore_irqs; + bool lpm_region; }; /** @@ -3359,6 +3362,32 @@ static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode, return NOTIFY_BAD; } +static bool ti_sci_check_lpm_region(void) +{ + struct device_node *parent, *node; + + parent = of_find_node_by_path("/reserved-memory"); + for_each_child_of_node(parent, node) { + if (of_node_name_eq(node, "lpm-memory")) + return true; + } + + return false; +} + +static int __maybe_unused ti_sci_suspend(struct device *dev) +{ + const struct ti_sci_desc *desc = device_get_match_data(dev); + + if (pm_suspend_target_state == PM_SUSPEND_MEM && + desc->lpm_region && !ti_sci_check_lpm_region()) { + dev_err(dev, "lpm region is required for suspend to ram but is not provided\n"); + return -EINVAL; + } + + return 0; +} + static int __maybe_unused ti_sci_resume_noirq(struct device *dev) { const struct ti_sci_desc *desc = device_get_match_data(dev); @@ -3387,6 +3416,7 @@ static int __maybe_unused ti_sci_resume_noirq(struct device *dev) } static const struct dev_pm_ops ti_sci_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(ti_sci_suspend, NULL) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, ti_sci_resume_noirq) }; @@ -3419,6 +3449,7 @@ static const struct ti_sci_desc ti_sci_pmmc_j7200_desc = { .max_msgs = 20, .max_msg_size = 64, .restore_irqs = true, + .lpm_region = true, }; static const struct of_device_id ti_sci_of_match[] = { @@ -3546,6 +3577,11 @@ static int ti_sci_probe(struct platform_device *pdev) } } +#ifdef CONFIG_PM_SLEEP + if (desc->lpm_region && !ti_sci_check_lpm_region()) + dev_warn(dev, "lpm region is required for suspend to ram but is not provided\n"); +#endif + dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n", info->handle.version.abi_major, info->handle.version.abi_minor, info->handle.version.firmware_revision, -- 2.39.2