From nobody Mon Dec 1 22:06:13 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AB38322DD4; Thu, 27 Nov 2025 08:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232760; cv=none; b=EFequt7/u9Y6La+E59cXKvQ42PXEu73ZhGn0TeLnQkhJktSO7DSY/hSwz4YWJpaWoPYcVCciw7rdRgMYgCwYJJv5OJfSK+LPiSPaHIwZ9xOLp+puC9VNqORhompn5YcAuX4pz/Kl4Jtc9oNVUIUj8hCheTO4ycv4enPssHHLr4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232760; c=relaxed/simple; bh=ZUioTVBthdgmRBP7GEsGgxhi5knAOAe82w+wuzPc49U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aYAK+0w0jmc1JNW35Nia55aIDW8bKQyXU+PV8Sit4aXSoKh9+MeCUYqcEQ3OK6KhNNLjHOTSheidpI1FCYh8Af176RziMK0TYuYEc/LGmcFQWukAxMitzIohR+GipsR6dJ3rIB2d2snmOzupZwqnlqc8pxnqO7X6/YC3pSm2uqI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=J/xFbqtS; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="J/xFbqtS" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id CF38B1A1DBC; Thu, 27 Nov 2025 08:39:15 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A539B6068C; Thu, 27 Nov 2025 08:39:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D59A8102F260E; Thu, 27 Nov 2025 09:39:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764232754; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=tT5X9D++8AQ5f39cwRsCj5QQMa94hrAR/HjLCHFeZLs=; b=J/xFbqtSBCNdGXWh5+pFiJO8MuCNgFiQWQn0NYIaS1buaZ8WRW7z3T6c051cj8NLfTLbVD gy/bN1BfCO6xA9Gp3KqA7xqMYCzNRDiQwwO+p9EG113e7IjFilghEidtPm5QQjGQbq6dMB gV6rsp7sLLIio4SmAfKU3glLbYVvG7sDv70O4AZ+IjZelsQ45xlnblwHswxLT8RGnJIr4A bWoW9jtbL91ZGK6zQBDtNip/AbRMjYqV1ScJuG6bp0s6BNbOUcQC3yrHe1UlUSxJcKQr0a qOf1NDIpZJpRo2KDJ5JM0Lu44Z1mi/j0QS7z2Pr3qRzWNtZjxwY9cQsWvZSJGw== From: "Thomas Richard (TI.com)" Date: Thu, 27 Nov 2025 09:38:55 +0100 Subject: [PATCH RFC v2 1/4] firmware: ti_sci: add BOARDCFG_MANAGED mode support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-1-a487fa3ff221@bootlin.com> References: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> In-Reply-To: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Prasanth Mantena , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI.com)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 In BOARDCFG_MANAGED mode, the low power mode configuration is done statically for the DM via the boardcfg. Constraints are not supported, and prepare_sleep() is not needed. Signed-off-by: Thomas Richard (TI.com) --- drivers/firmware/ti_sci.c | 10 +++++++--- drivers/firmware/ti_sci.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index d1faa47576199..4afe1c4872ff8 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3693,8 +3693,11 @@ static int ti_sci_prepare_system_suspend(struct ti_s= ci_info *info) return ti_sci_cmd_prepare_sleep(&info->handle, TISCI_MSG_VALUE_SLEEP_MODE_DM_MANAGED, 0, 0, 0); + } else if (info->fw_caps & MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED) { + /* Nothing to do in the BOARDCFG_MANAGED mode */ + return 0; } else { - /* DM Managed is not supported by the firmware. */ + /* DM Managed and BoardCfg Managed are not supported by the firmware. */ dev_err(info->dev, "Suspend to memory is not supported by the firmware\= n"); return -EOPNOTSUPP; } @@ -3932,12 +3935,13 @@ static int ti_sci_probe(struct platform_device *pde= v) } =20 ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps); - dev_dbg(dev, "Detected firmware capabilities: %s%s%s%s%s\n", + dev_dbg(dev, "Detected firmware capabilities: %s%s%s%s%s%s\n", info->fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "", info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "", info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : "", info->fw_caps & MSG_FLAG_CAPS_LPM_ABORT ? " LPM-Abort" : "", - info->fw_caps & MSG_FLAG_CAPS_IO_ISOLATION ? " IO-Isolation" : "" + info->fw_caps & MSG_FLAG_CAPS_IO_ISOLATION ? " IO-Isolation" : "", + info->fw_caps & MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED ? " BoardConfig-Manag= ed" : "" ); =20 ti_sci_setup_ops(info); diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index 7559cde17b6cc..3638c68351705 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -150,6 +150,7 @@ struct ti_sci_msg_req_reboot { * MSG_FLAG_CAPS_LPM_DM_MANAGED: LPM can be managed by DM * MSG_FLAG_CAPS_LPM_ABORT: Abort entry to LPM * MSG_FLAG_CAPS_IO_ISOLATION: IO Isolation support + * MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED: LPM config done statically for the= DM via boardcfg * * Response to a generic message with message type TI_SCI_MSG_QUERY_FW_CAPS * providing currently available SOC/firmware capabilities. SoC that don't @@ -162,6 +163,7 @@ struct ti_sci_msg_resp_query_fw_caps { #define MSG_FLAG_CAPS_LPM_DM_MANAGED TI_SCI_MSG_FLAG(5) #define MSG_FLAG_CAPS_LPM_ABORT TI_SCI_MSG_FLAG(9) #define MSG_FLAG_CAPS_IO_ISOLATION TI_SCI_MSG_FLAG(7) +#define MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED TI_SCI_MSG_FLAG(10) #define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1) u64 fw_caps; } __packed; --=20 2.51.0 From nobody Mon Dec 1 22:06:13 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57DAE31B137 for ; Thu, 27 Nov 2025 08:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232763; cv=none; b=Vd5eEEIBDWlWCGidnO2TSJ+2qJPVSxjZcs5rf3yWS7uH9B2oBG1oVwL0vr1tbgm8PkxqOwzAv8dRi9VJBbO5ld3GV0iIu2CiqiI5uJP8Z8FMaGlOXePVFTLuJaZBH1ZIDhiu+rWO4vUjy2CdIIsZAvQUqPhElVCiT9XZrshlX0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232763; c=relaxed/simple; bh=wEtd8FwUwuMEajP78DG7SGel1OCCfX0I4cQb4b32MHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U3L0JTIs2rJ/27FxRco8XISj3w/r8Zn6XVG3ywSna13+Gam7SJNFusLd/OnAtnsrgfW3WJyxecVdAg6Tyygq/KlZLp29CjqqeyHy/ANj1LRn1AdRnNHGujeRXWNP2aYhMXiInlzy/4I44JwL9E75JGTNz2KjqcODVZADsLzkmDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nWBIAIC4; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="nWBIAIC4" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id F35201A1DBD; Thu, 27 Nov 2025 08:39:16 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C95466068C; Thu, 27 Nov 2025 08:39:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0A44C102F2750; Thu, 27 Nov 2025 09:39:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764232756; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Vgi5wrrdV1ygbhZyb38shFie4x9TYtnZLYRYrla8kxQ=; b=nWBIAIC4vi683ZtYZ/BHzJS+AVicNwyF82A74nKdKfPiRFhJMIdoubYBoN0YHy02w37H/j AAq8Zm8K1IhzZtF560QQxx1/UpaO/tVHqVr6askqpST04OObBJdeqm/gPFaoqWp2hsot3G BY2YzM5m/iopQHYZ6EW7Zo9laYBfN6SMEudnWBeX6IphvDgmq6YOSTrMV+eqElQe3GqbHE 5hJIWxWq31uuOBALj4sp2VQGM8H9YuAUhzPKFC85A1IudmK2hjWeCJnwppFlCqzY7eKuLl d3+tfKn0WARy45XgVpiPoXQWAshMj8GjZ5N0O7KwFiDnwcIwQ8kmOq0vjiA0hg== From: "Thomas Richard (TI.com)" Date: Thu, 27 Nov 2025 09:38:56 +0100 Subject: [PATCH RFC v2 2/4] firmware: ti_sci: handle IRQ restore in BOARDCFG_MANAGED mode during resume Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-2-a487fa3ff221@bootlin.com> References: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> In-Reply-To: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Prasanth Mantena , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI.com)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 In BOARDCFG_MANAGED mode, the firmware cannot restore IRQs during resume. This responsibility is delegated to the ti_sci driver, which maintains an internal list of all requested IRQs. This list is updated on each set/free operation, and all IRQs are restored during the resume_noirq() phase. Signed-off-by: Thomas Richard (TI.com) --- drivers/firmware/ti_sci.c | 147 ++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 138 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 4afe1c4872ff8..a4d28f37b58ae 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,16 @@ struct ti_sci_desc { int max_msg_size; }; =20 +/** + * struct ti_sci_irq - Description of allocated irqs + * @node: Link to hash table + * @desc: Description of the irq + */ +struct ti_sci_irq { + struct hlist_node node; + struct ti_sci_msg_req_manage_irq desc; +}; + /** * struct ti_sci_info - Structure representing a TI SCI instance * @dev: Device pointer @@ -101,6 +112,7 @@ struct ti_sci_desc { * @chan_rx: Receive mailbox channel * @minfo: Message info * @node: list head + * @irqs: List of allocated irqs * @host_id: Host ID * @fw_caps: FW/SoC low power capabilities * @users: Number of users of this instance @@ -117,6 +129,7 @@ struct ti_sci_info { struct mbox_chan *chan_tx; struct mbox_chan *chan_rx; struct ti_sci_xfers_info minfo; + DECLARE_HASHTABLE(irqs, 8); struct list_head node; u8 host_id; u64 fw_caps; @@ -2294,6 +2307,32 @@ static int ti_sci_manage_irq(const struct ti_sci_han= dle *handle, return ret; } =20 +/** + * ti_sci_irq_hash() - Helper API to compute irq hash for the hash table. + * @irq: irq to hash + * + * Return: the computed hash value. + */ +static int ti_sci_irq_hash(struct ti_sci_msg_req_manage_irq *irq) +{ + return irq->src_id ^ irq->src_index; +} + +/** + * ti_sci_irq_equal() - Helper API to compare two irqs (generic headers ar= e not + * compared) + * @irq_a: irq_a to compare + * @irq_b: irq_b to compare + * + * Return: true if the two irqs are equal, else false. + */ +static bool ti_sci_irq_equal(struct ti_sci_msg_req_manage_irq *irq_a, + struct ti_sci_msg_req_manage_irq *irq_b) +{ + return !memcmp(&irq_a->valid_params, &irq_b->valid_params, + sizeof(*irq_a) - sizeof(irq_a->hdr)); +} + /** * ti_sci_set_irq() - Helper api to configure the irq route between the * requested source and destination @@ -2317,15 +2356,43 @@ static int ti_sci_set_irq(const struct ti_sci_handl= e *handle, u32 valid_params, u16 dst_host_irq, u16 ia_id, u16 vint, u16 global_event, u8 vint_status_bit, u8 s_host) { + struct ti_sci_info *info =3D handle_to_ti_sci_info(handle); + struct ti_sci_msg_req_manage_irq *desc; + struct ti_sci_irq *irq; + int ret; + pr_debug("%s: IRQ set with valid_params =3D 0x%x from src =3D %d, index = =3D %d, to dst =3D %d, irq =3D %d,via ia_id =3D %d, vint =3D %d, global eve= nt =3D %d,status_bit =3D %d\n", __func__, valid_params, src_id, src_index, dst_id, dst_host_irq, ia_id, vint, global_event, vint_status_bit); =20 - return ti_sci_manage_irq(handle, valid_params, src_id, src_index, - dst_id, dst_host_irq, ia_id, vint, - global_event, vint_status_bit, s_host, - TI_SCI_MSG_SET_IRQ); + ret =3D ti_sci_manage_irq(handle, valid_params, src_id, src_index, + dst_id, dst_host_irq, ia_id, vint, + global_event, vint_status_bit, s_host, + TI_SCI_MSG_SET_IRQ); + + if (ret) + return ret; + + irq =3D kzalloc(sizeof(*irq), GFP_KERNEL); + if (!irq) + return -ENOMEM; + + desc =3D &irq->desc; + desc->valid_params =3D valid_params; + desc->src_id =3D src_id; + desc->src_index =3D src_index; + desc->dst_id =3D dst_id; + desc->dst_host_irq =3D dst_host_irq; + desc->ia_id =3D ia_id; + desc->vint =3D vint; + desc->global_event =3D global_event; + desc->vint_status_bit =3D vint_status_bit; + desc->secondary_host =3D s_host; + + hash_add(info->irqs, &irq->node, ti_sci_irq_hash(desc)); + + return 0; } =20 /** @@ -2351,15 +2418,46 @@ static int ti_sci_free_irq(const struct ti_sci_hand= le *handle, u32 valid_params, u16 dst_host_irq, u16 ia_id, u16 vint, u16 global_event, u8 vint_status_bit, u8 s_host) { + struct ti_sci_info *info =3D handle_to_ti_sci_info(handle); + struct ti_sci_msg_req_manage_irq irq_desc; + struct ti_sci_irq *this_irq; + struct hlist_node *tmp_node; + int ret; + pr_debug("%s: IRQ release with valid_params =3D 0x%x from src =3D %d, ind= ex =3D %d, to dst =3D %d, irq =3D %d,via ia_id =3D %d, vint =3D %d, global = event =3D %d,status_bit =3D %d\n", __func__, valid_params, src_id, src_index, dst_id, dst_host_irq, ia_id, vint, global_event, vint_status_bit); =20 - return ti_sci_manage_irq(handle, valid_params, src_id, src_index, - dst_id, dst_host_irq, ia_id, vint, - global_event, vint_status_bit, s_host, - TI_SCI_MSG_FREE_IRQ); + ret =3D ti_sci_manage_irq(handle, valid_params, src_id, src_index, + dst_id, dst_host_irq, ia_id, vint, + global_event, vint_status_bit, s_host, + TI_SCI_MSG_FREE_IRQ); + + if (ret) + return ret; + + irq_desc.valid_params =3D valid_params; + irq_desc.src_id =3D src_id; + irq_desc.src_index =3D src_index; + irq_desc.dst_id =3D dst_id; + irq_desc.dst_host_irq =3D dst_host_irq; + irq_desc.ia_id =3D ia_id; + irq_desc.vint =3D vint; + irq_desc.global_event =3D global_event; + irq_desc.vint_status_bit =3D vint_status_bit; + irq_desc.secondary_host =3D s_host; + + hash_for_each_possible_safe(info->irqs, this_irq, tmp_node, node, + ti_sci_irq_hash(&irq_desc)) { + if (ti_sci_irq_equal(&irq_desc, &this_irq->desc)) { + hlist_del(&this_irq->node); + kfree(this_irq); + return 0; + } + } + + return 0; } =20 /** @@ -3768,7 +3866,10 @@ static int ti_sci_suspend_noirq(struct device *dev) static int ti_sci_resume_noirq(struct device *dev) { struct ti_sci_info *info =3D dev_get_drvdata(dev); - int ret =3D 0; + struct ti_sci_msg_req_manage_irq *irq_desc; + struct ti_sci_irq *irq; + struct hlist_node *tmp_node; + int ret =3D 0, i; u32 source; u64 time; u8 pin; @@ -3780,6 +3881,32 @@ static int ti_sci_resume_noirq(struct device *dev) return ret; } =20 + switch (pm_suspend_target_state) { + case PM_SUSPEND_MEM: + if (info->fw_caps & MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED) { + hash_for_each_safe(info->irqs, i, tmp_node, irq, node) { + irq_desc =3D &irq->desc; + ret =3D ti_sci_manage_irq(&info->handle, + irq_desc->valid_params, + irq_desc->src_id, + irq_desc->src_index, + irq_desc->dst_id, + irq_desc->dst_host_irq, + irq_desc->ia_id, + irq_desc->vint, + irq_desc->global_event, + irq_desc->vint_status_bit, + irq_desc->secondary_host, + TI_SCI_MSG_SET_IRQ); + if (ret) + return ret; + } + } + break; + default: + break; + } + ret =3D ti_sci_msg_cmd_lpm_wake_reason(&info->handle, &source, &time, &pi= n, &mode); /* Do not fail to resume on error as the wake reason is not critical */ if (!ret) @@ -3961,6 +4088,8 @@ static int ti_sci_probe(struct platform_device *pdev) list_add_tail(&info->node, &ti_sci_list); mutex_unlock(&ti_sci_list_mutex); =20 + hash_init(info->irqs); + return of_platform_populate(dev->of_node, NULL, NULL, dev); out: if (!IS_ERR(info->chan_tx)) --=20 2.51.0 From nobody Mon Dec 1 22:06:13 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C96C3242D8 for ; Thu, 27 Nov 2025 08:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232764; cv=none; b=u3Axdx1ks9Q7IjdXlYvUaI24d8q70+Q9+EcJ7G++ytxWWKMI+PR45dnHmiErhxU1MlX79D2xonQNwKrvNLv0V31SHWsnrE4XYj05uLTcYYp32ox5u32aVdt5+7GfB/Uav1RHBpa6lYGr+95KFEt9dqsaBv6nPAUC22JTgbIoSMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232764; c=relaxed/simple; bh=aProAx5VL9C8t/GV0kAIP1skLnL0Hs664rC2YSLwxNs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ho+Pxc16IUGynn0uBXWQBI8LUk2X91G5X1YVeyKqPUif+r1qYAPaZ+MpdfY8bJ2zil6kescMWzrcfs+9bCqRb1IkApxnnhiA6SW7T5/hkATizzqAqeN8ll6yqSjZTui/SEkrqtqXkObr9B55OXKmy6XWV9frbZspeNEgftiW8oU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GDSY87Dh; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GDSY87Dh" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 854004E41919; Thu, 27 Nov 2025 08:39:18 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5AF106068C; Thu, 27 Nov 2025 08:39:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 77E1D102F2751; Thu, 27 Nov 2025 09:39:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764232757; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XxlcfNeRaRWZTwXU0NT8kH+GHpvE/vl/i3zb2pJZvTQ=; b=GDSY87DhyMjqWSjbdiANf57fcC8hDx8BNRcoDp9crZ/ex1R+DePu29R+7pG0nEAKRHwkiA +sPsEeSscmiQz5QvJhccnAp4lnceRs5FXiZHFneHOQWognVetSNohaHUHcHyAXsQPJ0WrC +Jj1O0rHW0rEe2tTefEidFjAR4BQHowsUOkdsFsmKlfzoF+yEx0Xu+Y5s8VPULt21eOeS0 Er6ZgUAkGB1+6rl/0An0eaq3XvG/Qg5MKtKe+Ipxe4i7cc2Yz8YJXTrNqU14vkJlwbEyBZ nXdEFk4Pe4Rr1q4kpiYXsuWMnP/EavHqeQ8FAdcqAkXFUTT5QFX/tPdBfAa/EQ== From: "Thomas Richard (TI.com)" Date: Thu, 27 Nov 2025 09:38:57 +0100 Subject: [PATCH RFC v2 3/4] clk: keystone: sci-clk: add restore_context() operation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-3-a487fa3ff221@bootlin.com> References: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> In-Reply-To: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Prasanth Mantena , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI.com)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Implement the restore_context() operation to restore the clock parent state. The parent index is saved in sci_clk struct during set_parent(). During clock registration, the core retrieves each clock=E2=80=99s parent u= sing get_parent() operation to ensure the internal clock tree reflects the actual hardware state, including any configurations made by the bootloader. So we also save the parent index in get_parent(). Signed-off-by: Thomas Richard (TI.com) --- drivers/clk/keystone/sci-clk.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index a4b42811de55d..1e5dd01484d1c 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -47,6 +47,7 @@ struct sci_clk_provider { * @node: Link for handling clocks probed via DT * @cached_req: Cached requested freq for determine rate calls * @cached_res: Cached result freq for determine rate calls + * @parent_id: Parent index for this clock */ struct sci_clk { struct clk_hw hw; @@ -58,6 +59,7 @@ struct sci_clk { struct list_head node; unsigned long cached_req; unsigned long cached_res; + u8 parent_id; }; =20 #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw) @@ -237,9 +239,9 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) return 0; } =20 - parent_id =3D parent_id - clk->clk_id - 1; + clk->parent_id =3D (u8)(parent_id - clk->clk_id - 1); =20 - return (u8)parent_id; + return clk->parent_id; } =20 /** @@ -252,12 +254,24 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) static int sci_clk_set_parent(struct clk_hw *hw, u8 index) { struct sci_clk *clk =3D to_sci_clk(hw); + int ret; =20 clk->cached_req =3D 0; =20 - return clk->provider->ops->set_parent(clk->provider->sci, clk->dev_id, - clk->clk_id, - index + 1 + clk->clk_id); + ret =3D clk->provider->ops->set_parent(clk->provider->sci, clk->dev_id, + clk->clk_id, + index + 1 + clk->clk_id); + if (!ret) + clk->parent_id =3D index; + + return ret; +} + +static void sci_clk_restore_context(struct clk_hw *hw) +{ + struct sci_clk *clk =3D to_sci_clk(hw); + + sci_clk_set_parent(hw, clk->parent_id); } =20 static const struct clk_ops sci_clk_ops =3D { @@ -269,6 +283,7 @@ static const struct clk_ops sci_clk_ops =3D { .set_rate =3D sci_clk_set_rate, .get_parent =3D sci_clk_get_parent, .set_parent =3D sci_clk_set_parent, + .restore_context =3D sci_clk_restore_context, }; =20 /** --=20 2.51.0 From nobody Mon Dec 1 22:06:13 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CD3C31D39F for ; Thu, 27 Nov 2025 08:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232764; cv=none; b=Brf+vurtkx/etQpXIP4QB0w/hOD/FPMd5eR9LFQh7vysu6o0kwTIwWTyrmQbgua1bKoVghtVwaZGbJG9Fyw8dM1dPD0QecLvGE0qmTKnMbeIPUOoG3g67h4IHA0oDB0ibgkCgqeZnRCd6bdZZBkRwte2b4Of0njn2+/sHKiYWtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764232764; c=relaxed/simple; bh=XvO8WdPb9Dh+HMrGLdgEGRGU/kywwObZJsmvRiDTIsc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZeRpuRoOSdXlrCUUQhOZTRzm+Ar3FEQh5j0ByARbFbMjO+UJwSj7IaNtCsSvKktqOaEMo4Ksvjfm5jpgTJpnR4UcQlJY6CzfycpIPuOthYKEMOP711oHuiDtQCU9y8IRNgOorM+b1BgB5Spo22naJgj//9aaPPROt61GIz+n29k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=n1lK/gI/; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="n1lK/gI/" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 120E9C16A1A; Thu, 27 Nov 2025 08:38:57 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D9FF36068C; Thu, 27 Nov 2025 08:39:19 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B470F102F1A6A; Thu, 27 Nov 2025 09:39:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764232759; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=uGUB311hgWAyFRUuNDLWLmnmEe9k7c0Q1RMUsTuYHcw=; b=n1lK/gI/ZWefv9D3rq/z16Z4OmDsaSOdN7WJxw+1To5hlI0jyfodUScvXR5zIV+LyMbcsA hIKf555N5KfxeazGBpzXws0TIc5AQoZONVoQcXdv1pLG0wGVy8O3/OYeoH0ZNLQpJNo3va OSzx6W1og/5lfvKN+7rRNGYYLg/t4zHjPcxCKxRk8oq+AWksVIpPsBg4K07VFvAe0A/vG6 4OXtn+A5WD8nrA+XIbMWlahn3Lkia0nVTwr8603QIuflhYCnDLKFpEyex0Nm4S2E7vDBjq Zvx7hWpzV/93lQNClNb3LYY+LB9IjLfRtGarsgS7bN8bulnan7CWO3u/Bid4pA== From: "Thomas Richard (TI.com)" Date: Thu, 27 Nov 2025 09:38:58 +0100 Subject: [PATCH RFC v2 4/4] firmware: ti_sci: restore clock context during resume in BOARDCFG_MANAGED mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-4-a487fa3ff221@bootlin.com> References: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> In-Reply-To: <20251127-ti-sci-jacinto-s2r-restore-irq-v2-0-a487fa3ff221@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Prasanth Mantena , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI.com)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 In BOARDCFG_MANAGED mode, the firmware cannot restore the clock parents. This responsibility is therefore delegated to the ti_sci driver, which uses clk_restore_context() to trigger the context_restore() operation for all registered clocks, including those managed by the sci-clk driver. The sci-clk driver implements the context_restore() operation to ensure clock parents are correctly restored. Signed-off-by: Thomas Richard (TI.com) --- drivers/firmware/ti_sci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index a4d28f37b58ae..1e3fe00ff9109 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ =20 #include +#include #include #include #include @@ -3901,6 +3902,8 @@ static int ti_sci_resume_noirq(struct device *dev) if (ret) return ret; } + + clk_restore_context(); } break; default: --=20 2.51.0