The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa@csail.mit.edu>
To: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
Cc: jassisinghbrar@gmail.com, michal.simek@amd.com,
	tanmay.shah@amd.com, saeed.nowshadi@amd.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	ssengar@linux.microsoft.com, tgopinath@linux.microsoft.com,
	tejas.patel@xilinx.com, rajan.vaja@xilinx.com,
	abhyuday.godhasara@xilinx.com, gregkh@linuxfoundation.org
Subject: Re: [PATCH v2 1/2] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup
Date: Wed, 2 Dec 2026 16:11:30 +0530	[thread overview]
Message-ID: <aw_12jdtVmgAGpqZ@csail.mit.edu> (raw)
In-Reply-To: <20261130094513.2454356-2-ptsm@linux.microsoft.com>

Hi Prasanna,

On Mon, Nov 30, 2026 at 01:45:12AM -0800, Prasanna Kumar T S M wrote:
> On driver removal, the CPUHP_AP_ONLINE_DYN CPU hotplug state is removed
> instead of its actual state. This can leave the mailbox driver callbacks
> dangling. Use the actual CPU hotplug state during driver removal.
> 
> Hotplug registration failures are also ignored, allowing probe to
> succeed without the callbacks needed to enable interrupts on CPUs
> brought online later.
> 
> This is found by code inspection.

Minor nit: This bit of detail doesn't feel necessary to capture in the commit
message. On the other hand, if you had used a script or some automation tool
(ex: coccinelle) to find such issues, its corresponding snippet would have been
useful to include.
> 
> Fixes: 6ffb1635341b ("mailbox: zynqmp: handle SGI for shared IPI")
> Cc: stable@vger.kernel.org
> Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
> ---
>  drivers/mailbox/zynqmp-ipi-mailbox.c | 29 ++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
> index 42d2583e44ca..843b5ecc905a 100644
> --- a/drivers/mailbox/zynqmp-ipi-mailbox.c
> +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
> @@ -126,6 +126,7 @@ struct zynqmp_ipi_mbox {
>   * @method:               IPI SMC or HVC is going to be used
>   * @local_id:             local IPI agent ID
>   * @virq_sgi:             IRQ number mapped to SGI
> + * @hp_state:             CPU hotplug state for SGI callbacks
>   * @num_mboxes:           number of mailboxes of this IPI agent
>   * @ipi_mboxes:           IPI mailboxes of this IPI agent
>   */

The hp_state variable appears to be only added to the comment, and not the
actual zynqmp_ipi_pdata struct. So, how did this even build?

> @@ -136,6 +137,7 @@ struct zynqmp_ipi_pdata {
>  	unsigned int method;
>  	u32 local_id;
>  	int virq_sgi;
> +	enum cpuhp_state hp_state;
>  	int num_mboxes;
>  	struct zynqmp_ipi_mbox ipi_mboxes[] __counted_by(num_mboxes);
>  };
> @@ -863,21 +865,32 @@ static int xlnx_mbox_init_sgi(struct platform_device *pdev,
>  	irq_set_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
>  
>  	/* Setup function for the CPU hot-plug cases */
> -	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mailbox/sgi:starting",
> -			  xlnx_mbox_cpuhp_start, xlnx_mbox_cpuhp_down);
> +	pdata->hp_state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
> +					    "mailbox/sgi:starting",
> +					    xlnx_mbox_cpuhp_start,
> +					    xlnx_mbox_cpuhp_down);
> +	if (pdata->hp_state < 0) {
> +		irq_clear_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
> +		free_percpu_irq(pdata->virq_sgi, &per_cpu_pdata);
> +		irq_dispose_mapping(pdata->virq_sgi);
> +		pdata->virq_sgi = 0;
> +		return pdata->hp_state;
> +	}
>  

I thought we agreed on a simpler cleanup in the discussion on the v1 patch [1]
but this v2 changes a lot more instead in both xlnx_mbox_init_sgi() and
xlnx_mbox_cleanup_sgi(). Would you mind sharing your thoughts on why this
approach is better than leaving the cleanup to the caller?
 
>  	return ret;
>  }
>  
>  static void xlnx_mbox_cleanup_sgi(struct zynqmp_ipi_pdata *pdata)
>  {
> -	cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
> -
> -	on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
> +	if (pdata->hp_state >= CPUHP_AP_ONLINE_DYN)
> +		cpuhp_remove_state(pdata->hp_state);
>  
> -	irq_clear_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
> -	free_percpu_irq(pdata->virq_sgi, &per_cpu_pdata);
> -	irq_dispose_mapping(pdata->virq_sgi);
> +	if (pdata->virq_sgi) {
> +		on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
> +		irq_clear_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
> +		free_percpu_irq(pdata->virq_sgi, &per_cpu_pdata);
> +		irq_dispose_mapping(pdata->virq_sgi);
> +	}
>  }
>  
> 

[1]. https://lore.kernel.org/all/3a44999e-655b-409a-8806-cd434722ff45@linux.microsoft.com/

Regards,
Srivatsa

  reply	other threads:[~2026-12-02 10:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:45 [PATCH v2 0/2] Fix CPU hotplug state cleanup in Xilinx drivers Prasanna Kumar T S M
2026-11-30  9:45 ` [PATCH v2 1/2] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup Prasanna Kumar T S M
2026-12-02 10:41   ` Srivatsa S. Bhat [this message]
2026-12-02 10:43     ` Srivatsa S. Bhat
2026-12-02 14:04     ` Prasanna Kumar T S M
2026-11-30  9:45 ` [PATCH v2 2/2] soc: xilinx: Fix event manager " Prasanna Kumar T S M
2026-12-02 10:48   ` Srivatsa S. Bhat
2026-12-02 12:37     ` Prasanna Kumar T S M

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=aw_12jdtVmgAGpqZ@csail.mit.edu \
    --to=srivatsa@csail.mit.edu \
    --cc=abhyuday.godhasara@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=ptsm@linux.microsoft.com \
    --cc=rajan.vaja@xilinx.com \
    --cc=saeed.nowshadi@amd.com \
    --cc=ssengar@linux.microsoft.com \
    --cc=tanmay.shah@amd.com \
    --cc=tejas.patel@xilinx.com \
    --cc=tgopinath@linux.microsoft.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