public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: "Thomas Richard (TI)" <thomas.richard@bootlin.com>
Cc: Tero Kristo <kristo@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Gregory CLEMENT <gregory.clement@bootlin.com>,
	<richard.genoud@bootlin.com>, Udit Kumar <u-kumar1@ti.com>,
	Abhash Kumar <a-kumar2@ti.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	Dhruva Gole <d-gole@ti.com>, Kendall Willis <k-willis@ti.com>
Subject: Re: [PATCH v6 2/4] firmware: ti_sci: add support for restoring IRQs during resume
Date: Tue, 5 May 2026 06:32:13 -0500	[thread overview]
Message-ID: <20260505113213.fz7qrovpgn4lbesn@zodiac> (raw)
In-Reply-To: <20260427-ti-sci-jacinto-s2r-restore-irq-v6-2-72c6468cb2ab@bootlin.com>

On 14:21-20260427, Thomas Richard (TI) wrote:

[..]

>  /**
>   * 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_handle *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 = 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 = 0x%x from src = %d, index = %d, to dst = %d, irq = %d,via ia_id = %d, vint = %d, global event = %d,status_bit = %d\n",
>  		 __func__, valid_params, src_id, src_index,
>  		 dst_id, dst_host_irq, ia_id, vint, global_event,
>  		 vint_status_bit);
>  
> -	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 = 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 = kzalloc_obj(*irq, GFP_KERNEL);
> +	if (!irq)
> +		return -ENOMEM;

Do we need to handle cleanup of ti_sci_manage_irq if the allocation fails?

> +
> +	desc = &irq->desc;
> +	desc->valid_params = valid_params;
> +	desc->src_id = src_id;
> +	desc->src_index = src_index;
> +	desc->dst_id = dst_id;
> +	desc->dst_host_irq = dst_host_irq;
> +	desc->ia_id = ia_id;
> +	desc->vint = vint;
> +	desc->global_event = global_event;
> +	desc->vint_status_bit = vint_status_bit;
> +	desc->secondary_host = s_host;
> +
> +	hash_add(info->irqs, &irq->node, ti_sci_irq_hash(desc));

No locking? set_irq can be invoked in parallel paths, no?
Further, should'nt we check if the same src_id and src_index is already
present before adding to hash list?

> +
> +	return 0;
>  }
>  
>  /**
> @@ -2358,15 +2425,46 @@ static int ti_sci_free_irq(const struct ti_sci_handle *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 = 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 = 0x%x from src = %d, index = %d, to dst = %d, irq = %d,via ia_id = %d, vint = %d, global event = %d,status_bit = %d\n",
>  		 __func__, valid_params, src_id, src_index,
>  		 dst_id, dst_host_irq, ia_id, vint, global_event,
>  		 vint_status_bit);
>  
> -	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 = 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 = valid_params;
> +	irq_desc.src_id = src_id;
> +	irq_desc.src_index = src_index;
> +	irq_desc.dst_id = dst_id;
> +	irq_desc.dst_host_irq = dst_host_irq;
> +	irq_desc.ia_id = ia_id;
> +	irq_desc.vint = vint;
> +	irq_desc.global_event = global_event;
> +	irq_desc.vint_status_bit = vint_status_bit;
> +	irq_desc.secondary_host = 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;
> +		}
> +	}
> +

We should ideally not be here, correct? Add a dev_warn?

> +	return 0;
>  }
>  
>  /**
> @@ -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 = dev_get_drvdata(dev);
> -	int ret = 0;
> +	struct ti_sci_msg_req_manage_irq *irq_desc;
> +	struct ti_sci_irq *irq;
> +	struct hlist_node *tmp_node;
> +	int ret = 0, i;
>  	u32 source;
>  	u64 time;
>  	u8 pin;
> @@ -3859,6 +3960,32 @@ static int ti_sci_resume_noirq(struct device *dev)
>  			return ret;
>  	}
>  
> +	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 = &irq->desc;
> +				ret = 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;

Do you want to attempt to restore the rest of the entries rather than give
up on the first fail? Maybe just log the error for debug and attempt the
rest?

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
https://ti.com/opensource


  reply	other threads:[~2026-05-05 11:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 12:21 [PATCH v6 0/4] firmware: ti_sci: Introduce BOARDCFG_MANAGED mode for Jacinto family Thomas Richard (TI)
2026-04-27 12:21 ` [PATCH v6 1/4] firmware: ti_sci: add BOARDCFG_MANAGED mode support Thomas Richard (TI)
2026-04-27 12:21 ` [PATCH v6 2/4] firmware: ti_sci: add support for restoring IRQs during resume Thomas Richard (TI)
2026-05-05 11:32   ` Nishanth Menon [this message]
2026-05-05 13:16     ` Thomas Richard
2026-05-05 13:20       ` Nishanth Menon
2026-04-27 12:21 ` [PATCH v6 3/4] clk: keystone: sci-clk: add restore_context() operation Thomas Richard (TI)
2026-04-27 15:08   ` Brian Masney
2026-04-29  3:57   ` Stephen Boyd
2026-05-05 11:42   ` Nishanth Menon
2026-05-05 15:14     ` Thomas Richard
2026-04-27 12:21 ` [PATCH v6 4/4] firmware: ti_sci: add support for restoring clock context during resume Thomas Richard (TI)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260505113213.fz7qrovpgn4lbesn@zodiac \
    --to=nm@ti.com \
    --cc=a-kumar2@ti.com \
    --cc=d-gole@ti.com \
    --cc=gregory.clement@bootlin.com \
    --cc=k-willis@ti.com \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=richard.genoud@bootlin.com \
    --cc=sboyd@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@bootlin.com \
    --cc=u-kumar1@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox