From nobody Wed Jun 17 06:12:56 2026 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 248CF3ACEF4 for ; Mon, 27 Apr 2026 12:22:10 +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=1777292533; cv=none; b=Xi110dSwcERTzAQJixB1bZsSfUKnJNySn2+z6WuYrlNwYciBaJDvCojGjJMM54PRfAqibWeZZyoJoIvCp09gWlpkYEfSu/jLB2h/l+UVevSxwNaVO05wXK3jEpcsWgV+XiC0D75XO9r77RneCd9e+4+dGZfDWRGyBB2dkx5btJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777292533; c=relaxed/simple; bh=xukevdXgi6GVwbJNIknM0BoHOMRB7Xpw+fbA9TVmZXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hOUd+okvamo8jo4NgIGXgJxdslZGRo6DlTzHc7UBURQOiIo8TJs+jyGpYXfPkgOkbqI90mg96BtnqGiPq5Epex65FDhqfJWdUnNWzOtcHehBqw90MC5GSVyzZmTAr8S79U6LzItkRgNrVrG0nE9qcoEMJTqPv7Mn/Bk+2FengIE= 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=Gn7MmSbf; 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="Gn7MmSbf" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id B12EFC5CD47; Mon, 27 Apr 2026 12:22:51 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8BE97600D1; Mon, 27 Apr 2026 12:22:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4C18310728075; Mon, 27 Apr 2026 14:22:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777292527; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=EoSUrC855M/XF5ZpUwRLFgoMp2B5bjW75xWj0tol++g=; b=Gn7MmSbfcIPmFM3W3984hCbun0n3Uyy+xLMXRc6e8uqNgxQVW7KkQib6t/Yx73t87gc22F S9Qn+wHEV7UZ/SXa9sT+wV0dydm4NxhvRks8aI74BkHLw0ejKv5vCDTdLGTgHbXnHNOb3e p91GuFuaNGfvaMjnyPb79qdHDvNe/wQemu1DlOF/cT3TiUXfntUdCErvwkdpHl/zu5maHD VezPRFr4O9mCcubVJriO/jqa/DEQvTh8w5yTcM/VZ4DH0gI9dRBkq5SikiA9EZmwBdwoEU bqp4NEFbjbyZAEl7A7bZjSMchichwkvDeN+4sad+lBedoiWB3vxxS9jS4goqyA== From: "Thomas Richard (TI)" Date: Mon, 27 Apr 2026 14:21:34 +0200 Subject: [PATCH v6 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: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-1-72c6468cb2ab@bootlin.com> References: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> In-Reply-To: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI)" , Dhruva Gole , Kendall Willis 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. Reviewed-by: Dhruva Gole Reviewed-by: Kendall Willis Signed-off-by: Thomas Richard (TI) --- 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 dd9911b1cc11..eaeaaae94142 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3772,8 +3772,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; } @@ -4011,12 +4014,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 4616127e33ff..d90de59e29eb 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(12) #define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1) u64 fw_caps; } __packed; --=20 2.53.0 From nobody Wed Jun 17 06:12:56 2026 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 A73BF3B6C04 for ; Mon, 27 Apr 2026 12:22:11 +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=1777292533; cv=none; b=LbytUO5remKk4lDpcjcWwO+k8nUID9wPJJjwAsCM2uwwWfmiBjTH5W60s84P3NBE+Khv+lT/FSVFEnA1r1rFSzVqR711kZLEV+U7LIiXD5UwJuCEGqnzj5f8d5CJHY8soLU+pLiCCGVqK28AKY8WPSlxDtnPj/RknlIRxSw6JEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777292533; c=relaxed/simple; bh=89dPXqib8tqgmGrMm4t7O2ZfVtP3oqKLZZ4d4Ve97cI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EaU8QqyqEhIPfS3Ffc9YKUQ/63QZUD4ROOC1sUS15aGMjPeqLTSTvV59etSExto6aRuiCWYPwsu2VsfAinfpYqAlaH09OY2e7o62eQv8k8MwxEhRkhzJe1SNbJ62DxFskl3a9Gd1BX+atFaLeZ4jnlj4xJMZ6Xfivjdr0tM5pUs= 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=0MQHZd6i; 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="0MQHZd6i" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 94B28C5CD48; Mon, 27 Apr 2026 12:22:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6EB3A600D1; Mon, 27 Apr 2026 12:22:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EB3311072817F; Mon, 27 Apr 2026 14:22:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777292529; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=fzHenwIFL/4A3zUPbf1sIT4qv7NMkBda9mROzOugGJ0=; b=0MQHZd6ip5lvDI8tVhfRpoSvg4e3HtXuz87Gle6XRleHD9GQCaaEJR50kRfEbhXLlQ3qbo bG+QMqioGoMxPDLenoemfd24ffGrDYIRj+yk6dyEN0uofOO7VgS3qmI5RgCnQKX7pCuIgT hUtaRiUidDKTRKJy+N6B+Scvsxgbgy2OU132Q40iyZsD97hfx8W/zI6AH/fcRc1c3+jyl3 SJyqgLn02yqjMoFMOjHXvxRMc7XP3gDhbxFl42HfaofUMjdIgutoI36gJJ60WhJwmWXm0g ViJzr5KuoGgs8qUgIl3YPc6PP53JoAYmUSCilp2eOGe0SHibqivO5OvXfg1C6g== From: "Thomas Richard (TI)" Date: Mon, 27 Apr 2026 14:21:35 +0200 Subject: [PATCH v6 2/4] firmware: ti_sci: add support for restoring IRQs 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: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-2-72c6468cb2ab@bootlin.com> References: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> In-Reply-To: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI)" , Dhruva Gole , Kendall Willis X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Some DM-Firmware are not able to restore the IRQ context after a suspend-resume. The IRQ_CONTEXT_LOST firmware capability has been introduced to identify this characteristic. In this case the 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. Reviewed-by: Dhruva Gole Reviewed-by: Kendall Willis Signed-off-by: Thomas Richard (TI) --- drivers/firmware/ti_sci.c | 153 ++++++++++++++++++++++++++++++++++++++++++= ---- drivers/firmware/ti_sci.h | 2 + 2 files changed, 144 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index eaeaaae94142..b5c4324287b0 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; @@ -2301,6 +2314,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 @@ -2324,15 +2363,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 || !(info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST)) + return ret; + + irq =3D kzalloc_obj(*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 /** @@ -2358,15 +2425,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 || !(info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST)) + 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 /** @@ -3847,7 +3945,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; @@ -3859,6 +3960,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_IRQ_CONTEXT_LOST) { + 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) @@ -4014,13 +4141,14 @@ 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%s\n", + dev_dbg(dev, "Detected firmware capabilities: %s%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_LPM_BOARDCFG_MANAGED ? " BoardConfig-Manag= ed" : "" + info->fw_caps & MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED ? " BoardConfig-Manag= ed" : "", + info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST ? " IRQ-Context-Lost"= : "" ); =20 ti_sci_setup_ops(info); @@ -4053,6 +4181,9 @@ static int ti_sci_probe(struct platform_device *pdev) list_add_tail(&info->node, &ti_sci_list); mutex_unlock(&ti_sci_list_mutex); =20 + if (info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST) + hash_init(info->irqs); + ret =3D of_platform_populate(dev->of_node, NULL, NULL, dev); if (ret) { dev_err(dev, "platform_populate failed %pe\n", ERR_PTR(ret)); diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index d90de59e29eb..67f16e8c69a1 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -151,6 +151,7 @@ struct ti_sci_msg_req_reboot { * 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 + * MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST: DM is not able to restore IRQ cont= ext * * Response to a generic message with message type TI_SCI_MSG_QUERY_FW_CAPS * providing currently available SOC/firmware capabilities. SoC that don't @@ -164,6 +165,7 @@ struct ti_sci_msg_resp_query_fw_caps { #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(12) +#define MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST TI_SCI_MSG_FLAG(14) #define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1) u64 fw_caps; } __packed; --=20 2.53.0 From nobody Wed Jun 17 06:12:56 2026 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 A036A3B8BCC; Mon, 27 Apr 2026 12:22:13 +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=1777292535; cv=none; b=BrGAqmU5Bx8C3ADqiNVbEQE8b1Uyt6UnREiYUyv7K3Oc+6N4ZNfeweF4VWisA7hI91iptKDxbopSQ1m3CX0w9VGsqLimISEO1nob/ZyDp792UO1j0B7nus9jEMXrLjHIsct4qFerSEwrdW42Y6QoR9tFUMFGe09wQ1jlouoqnPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777292535; c=relaxed/simple; bh=DqMpZ8kN4PDFQO4B7V/w6uSvOD8a0KC4skXweBAh5BY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MHozZd90UyRQIevDqiZlXrlgTYkkvNJcZoszFyvRpEoepV0qbELdTCtkY0PMD87UmOJnggsGbV8bHfeiTbfx7tCX2TYZynCbKVZg5oKujf9jtIM1nXy2ohncOSqMN+iAQsQ0Ae6haCzSEbK1JszfeSm2l0u0wuQTaWBs3wB8zlw= 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=DwXSaNox; 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="DwXSaNox" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 3C36C1A3443; Mon, 27 Apr 2026 12:22:12 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0BF2B600D1; Mon, 27 Apr 2026 12:22:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9667710728133; Mon, 27 Apr 2026 14:22:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777292531; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wUmdevwfCoWoFUn7JL36Dqo76mbXUo2IQXHp86RucIw=; b=DwXSaNoxz9tbuJBIvtMxsIe3oW2BAFLME2NzK5ggLM+uHBI0gU8F2dAO2uLDXH0Yo5E0kL pvy2fc2JV5CqhwUHKu/e3EJv0ml2b9+823hoZUVIZjysEx/OFrCrvPxA1L6859jItYm12F ht7k/wIC+tE+2zr5QbS5KnjM8f9fdMC9wwv7oKmq0pF548qZk/PPXkI32SomptgSpHIGXO 83U9kWm81+XZvHdLYdAd8KPXKXO24tW3omslRpTXdH8N/sB7mjJmT9I6ey55y2DBgTRnt/ Qs0QPh5hKnlwo2t+h2/VXXYUuhHI/12dZejkOwJjICXC0YZQdx1/663Sm0Ix6A== From: "Thomas Richard (TI)" Date: Mon, 27 Apr 2026 14:21:36 +0200 Subject: [PATCH v6 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: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-3-72c6468cb2ab@bootlin.com> References: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> In-Reply-To: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI)" , Dhruva Gole , Kendall Willis X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Implement the restore_context() operation to restore the clock rate and the clock parent state. The clock rate is saved in sci_clk struct during set_rate() and recalc_rate() operations. The parent index is saved in sci_clk struct during set_parent() operation. During clock registration, the core retrieves each clock=E2=80=99s parent using 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(). Reviewed-by: Dhruva Gole Reviewed-by: Kendall Willis Signed-off-by: Thomas Richard (TI) Acked-by: Stephen Boyd Reviewed-by: Brian Masney --- drivers/clk/keystone/sci-clk.c | 44 ++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 9d5071223f4c..b090edf5f82e 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -47,6 +47,8 @@ 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 + * @rate: Clock rate */ struct sci_clk { struct clk_hw hw; @@ -58,6 +60,8 @@ struct sci_clk { struct list_head node; unsigned long cached_req; unsigned long cached_res; + u8 parent_id; + unsigned long rate; }; =20 #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw) @@ -150,6 +154,8 @@ static unsigned long sci_clk_recalc_rate(struct clk_hw = *hw, return 0; } =20 + clk->rate =3D freq; + return freq; } =20 @@ -210,10 +216,15 @@ static int sci_clk_set_rate(struct clk_hw *hw, unsign= ed long rate, unsigned long parent_rate) { struct sci_clk *clk =3D to_sci_clk(hw); + int ret; =20 - return clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id, - clk->clk_id, rate / 10 * 9, rate, - rate / 10 * 11); + ret =3D clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id, + clk->clk_id, rate / 10 * 9, rate, + rate / 10 * 11); + if (!ret) + clk->rate =3D rate; + + return ret; } =20 /** @@ -237,9 +248,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 +263,28 @@ 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); + + if (clk->num_parents > 1) + sci_clk_set_parent(hw, clk->parent_id); + + if (clk->rate) + sci_clk_set_rate(hw, clk->rate, 0); } =20 static const struct clk_ops sci_clk_ops =3D { @@ -269,6 +296,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.53.0 From nobody Wed Jun 17 06:12:56 2026 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 621653B8BA4 for ; Mon, 27 Apr 2026 12:22:15 +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=1777292538; cv=none; b=iEHzzMv52Ue5aklT+lfOx9Z4dEcUgKlVJ1QNfG7oEP4iM1iWIizmg9sWmhGna3pjHyROX1SwZnzOlvdO37dBojMKn1M3uzFaHtXRguS+yaNeViUFfO7ToeX3ozz4r9oZuIfyAZefF0FWt0KMeRZdyXCF4fJ2ms6lQatyW2zitpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777292538; c=relaxed/simple; bh=oXVtB1MHVyNfIAcPEGhS+DDpnBEv72EApmOvB7fad04=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SvS1w2BT27SZD5GxYz8GDbWA+jvuisIpaYODmj9oy8wva+bhS1R1daiXS6N8tsVOvYF0VpLIyCTg2owziJB8I47gnMZ7U6PJUkX09RK6nqHzldCkMtiCWmB5C3eLxBhjFZb1mn/9JMnmZGUO2G1BqiaQf4swebPXUM0280sGVmE= 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=OX8ZVFXs; 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="OX8ZVFXs" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id A01911A343B; Mon, 27 Apr 2026 12:22:13 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 77518600D1; Mon, 27 Apr 2026 12:22:13 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 73912107281E7; Mon, 27 Apr 2026 14:22:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777292532; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=jFyrs6lUhNgn0hslaSxpK5st+YRph0Cs5Kl50CzvG84=; b=OX8ZVFXsyS0ElbT1MvmaGSbPybe2baADZg1oBG2+e4XbpPydGsO7JU6jvbyBYS728owTkl zCziZ7fERdbESBzl/VNgKfAD4S4nZjW8cUt7tYy+ANgZ7ZxZg24L0L7snA2Hi5qowTqh3c wlmvNdzRcVtqE/pvtUoD9ztL6XYHyhGPS7lPLugpPyjo+gwZgy2/B3Hj389VIT5b87A9px HnceHayg14w11PLYI/KlLKIZjazmP7MOy9+O6o3NpDt28bdrnURiZDNuxzQIZca+x2XePz 2aInlEaLyPhjmTI1ekGMvhKLS2m5NTIFH4iv/0ZBwS3ij2lGUmeoZicGC/RREA== From: "Thomas Richard (TI)" Date: Mon, 27 Apr 2026 14:21:37 +0200 Subject: [PATCH v6 4/4] firmware: ti_sci: add support for restoring clock context 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: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-4-72c6468cb2ab@bootlin.com> References: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> In-Reply-To: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-0-72c6468cb2ab@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd Cc: Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, "Thomas Richard (TI)" , Dhruva Gole , Kendall Willis X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Some DM-Firmware are not able to restore the clock rates and the clock parents after a suspend-resume. The CLK_CONTEXT_LOST firmware capability has been introduced to identify this characteristic. In this case the 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. The sci-clk driver implements the context_restore() operation to ensure rates and clock parents are correctly restored. Reviewed-by: Dhruva Gole Reviewed-by: Kendall Willis Signed-off-by: Thomas Richard (TI) --- drivers/firmware/ti_sci.c | 9 +++++++-- drivers/firmware/ti_sci.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index b5c4324287b0..0148bafd71a0 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 @@ -3981,6 +3982,9 @@ static int ti_sci_resume_noirq(struct device *dev) return ret; } } + + if (info->fw_caps & MSG_FLAG_CAPS_LPM_CLK_CONTEXT_LOST) + clk_restore_context(); break; default: break; @@ -4141,14 +4145,15 @@ 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%s%s\n", + dev_dbg(dev, "Detected firmware capabilities: %s%s%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_LPM_BOARDCFG_MANAGED ? " BoardConfig-Manag= ed" : "", - info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST ? " IRQ-Context-Lost"= : "" + info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST ? " IRQ-Context-Lost"= : "", + info->fw_caps & MSG_FLAG_CAPS_LPM_CLK_CONTEXT_LOST ? " Clk-Context-Lost"= : "" ); =20 ti_sci_setup_ops(info); diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index 67f16e8c69a1..2d75667a6723 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -152,6 +152,7 @@ struct ti_sci_msg_req_reboot { * MSG_FLAG_CAPS_IO_ISOLATION: IO Isolation support * MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED: LPM config done statically for the= DM via boardcfg * MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST: DM is not able to restore IRQ cont= ext + * MSG_FLAG_CAPS_LPM_CLK_CONTEXT_LOST: DM is not able to restore Clock co= ntext * * Response to a generic message with message type TI_SCI_MSG_QUERY_FW_CAPS * providing currently available SOC/firmware capabilities. SoC that don't @@ -166,6 +167,7 @@ struct ti_sci_msg_resp_query_fw_caps { #define MSG_FLAG_CAPS_IO_ISOLATION TI_SCI_MSG_FLAG(7) #define MSG_FLAG_CAPS_LPM_BOARDCFG_MANAGED TI_SCI_MSG_FLAG(12) #define MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST TI_SCI_MSG_FLAG(14) +#define MSG_FLAG_CAPS_LPM_CLK_CONTEXT_LOST TI_SCI_MSG_FLAG(15) #define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1) u64 fw_caps; } __packed; --=20 2.53.0