mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity
@ 2025-08-11  0:26 Inochi Amaoto
  2025-08-21  6:37 ` Chen Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Inochi Amaoto @ 2025-08-11  0:26 UTC (permalink / raw)
  To: Thomas Gleixner, Paul Walmsley, Samuel Holland
  Cc: Inochi Amaoto, linux-kernel, linux-riscv, Yixun Lan, Longbin Li, Nam Cao

The plic_set_affinity always call plic_irq_enable(), which clears up
the priority setting even the irq is only masked. This make the irq
unmasked unexpectly.

Replace the plic_irq_enable/disable() with plic_irq_toggle() to
avoid changing priority setting.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Nam Cao <namcao@linutronix.de>
Tested-by: Nam Cao <namcao@linutronix.de> # VisionFive 2
---
Change from v1:
1. apply Nam's tag
2. remove unnecessary off-topic change in plic_irq_disable()
---
 drivers/irqchip/irq-sifive-plic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index bf69a4802b71..866e38612b94 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -179,12 +179,14 @@ static int plic_set_affinity(struct irq_data *d,
 	if (cpu >= nr_cpu_ids)
 		return -EINVAL;

-	plic_irq_disable(d);
+	/* Invalidate the original routing entry */
+	plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0);

 	irq_data_update_effective_affinity(d, cpumask_of(cpu));

+	/* Setting the new routing entry if irq is enabled */
 	if (!irqd_irq_disabled(d))
-		plic_irq_enable(d);
+		plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1);

 	return IRQ_SET_MASK_OK_DONE;
 }
--
2.50.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity
  2025-08-11  0:26 [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity Inochi Amaoto
@ 2025-08-21  6:37 ` Chen Wang
  2025-08-24  0:40 ` Chen Wang
  2025-08-24 10:33 ` [tip: irq/drivers] " tip-bot2 for Inochi Amaoto
  2 siblings, 0 replies; 4+ messages in thread
From: Chen Wang @ 2025-08-21  6:37 UTC (permalink / raw)
  To: Inochi Amaoto, Thomas Gleixner, Paul Walmsley, Samuel Holland
  Cc: linux-kernel, linux-riscv, Yixun Lan, Longbin Li, Nam Cao


On 8/11/2025 8:26 AM, Inochi Amaoto wrote:
> The plic_set_affinity always call plic_irq_enable(), which clears up
> the priority setting even the irq is only masked. This make the irq
> unmasked unexpectly.
>
> Replace the plic_irq_enable/disable() with plic_irq_toggle() to
> avoid changing priority setting.
>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> Reviewed-by: Nam Cao <namcao@linutronix.de>
> Tested-by: Nam Cao <namcao@linutronix.de> # VisionFive 2

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>

It is recommended to add the following email link about the relevant 
discussion in the commit message for quich reference when there is a 
revision or merge:

https://lore.kernel.org/lkml/20250722224513.22125-1-inochiama@gmail.com/

Tested-by: Chen Wang <unicorn_wang@outlook.com> # Pioneerbox

> ---
> Change from v1:
> 1. apply Nam's tag
> 2. remove unnecessary off-topic change in plic_irq_disable()
> ---
>   drivers/irqchip/irq-sifive-plic.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index bf69a4802b71..866e38612b94 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -179,12 +179,14 @@ static int plic_set_affinity(struct irq_data *d,
>   	if (cpu >= nr_cpu_ids)
>   		return -EINVAL;
>
> -	plic_irq_disable(d);
> +	/* Invalidate the original routing entry */
> +	plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0);
>
>   	irq_data_update_effective_affinity(d, cpumask_of(cpu));
>
> +	/* Setting the new routing entry if irq is enabled */
>   	if (!irqd_irq_disabled(d))
> -		plic_irq_enable(d);
> +		plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1);
>
>   	return IRQ_SET_MASK_OK_DONE;
>   }
> --
> 2.50.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity
  2025-08-11  0:26 [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity Inochi Amaoto
  2025-08-21  6:37 ` Chen Wang
@ 2025-08-24  0:40 ` Chen Wang
  2025-08-24 10:33 ` [tip: irq/drivers] " tip-bot2 for Inochi Amaoto
  2 siblings, 0 replies; 4+ messages in thread
From: Chen Wang @ 2025-08-24  0:40 UTC (permalink / raw)
  To: Inochi Amaoto, Thomas Gleixner, Paul Walmsley, Samuel Holland
  Cc: linux-kernel, linux-riscv, Yixun Lan, Longbin Li, Nam Cao

Hi, Thomas, will you merge this? I see you have picked another related 
patchset [1].

Link: 
https://lore.kernel.org/lkml/20250813232835.43458-1-inochiama@gmail.com/ 
[1].

Thanks,

Chen

On 8/11/2025 8:26 AM, Inochi Amaoto wrote:
> The plic_set_affinity always call plic_irq_enable(), which clears up
> the priority setting even the irq is only masked. This make the irq
> unmasked unexpectly.
>
> Replace the plic_irq_enable/disable() with plic_irq_toggle() to
> avoid changing priority setting.
>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> Reviewed-by: Nam Cao <namcao@linutronix.de>
> Tested-by: Nam Cao <namcao@linutronix.de> # VisionFive 2
> ---
> Change from v1:
> 1. apply Nam's tag
> 2. remove unnecessary off-topic change in plic_irq_disable()
> ---
>   drivers/irqchip/irq-sifive-plic.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index bf69a4802b71..866e38612b94 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -179,12 +179,14 @@ static int plic_set_affinity(struct irq_data *d,
>   	if (cpu >= nr_cpu_ids)
>   		return -EINVAL;
>
> -	plic_irq_disable(d);
> +	/* Invalidate the original routing entry */
> +	plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0);
>
>   	irq_data_update_effective_affinity(d, cpumask_of(cpu));
>
> +	/* Setting the new routing entry if irq is enabled */
>   	if (!irqd_irq_disabled(d))
> -		plic_irq_enable(d);
> +		plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1);
>
>   	return IRQ_SET_MASK_OK_DONE;
>   }
> --
> 2.50.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: irq/drivers] irqchip/sifive-plic: Respect mask state when setting affinity
  2025-08-11  0:26 [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity Inochi Amaoto
  2025-08-21  6:37 ` Chen Wang
  2025-08-24  0:40 ` Chen Wang
@ 2025-08-24 10:33 ` tip-bot2 for Inochi Amaoto
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Inochi Amaoto @ 2025-08-24 10:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Thomas Gleixner, Inochi Amaoto, Nam Cao, Chen Wang, x86, linux-kernel

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     adecf78df945f4c7a1d29111b0002827f487df51
Gitweb:        https://git.kernel.org/tip/adecf78df945f4c7a1d29111b0002827f487df51
Author:        Inochi Amaoto <inochiama@gmail.com>
AuthorDate:    Mon, 11 Aug 2025 08:26:32 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Sun, 24 Aug 2025 12:20:18 +02:00

irqchip/sifive-plic: Respect mask state when setting affinity

plic_set_affinity() always calls plic_irq_enable(), which clears up the
priority setting even the interrupt is only masked. This unmasks the
interrupt unexpectly.

Replace the plic_irq_enable/disable() with plic_irq_toggle() to avoid
changing the priority setting.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nam Cao <namcao@linutronix.de> # VisionFive 2
Tested-by: Chen Wang <unicorn_wang@outlook.com> # Pioneerbox
Reviewed-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Link: https://lore.kernel.org/all/20250811002633.55275-1-inochiama@gmail.com
Link: https://lore.kernel.org/lkml/20250722224513.22125-1-inochiama@gmail.com/
---
 drivers/irqchip/irq-sifive-plic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index 3de5460..559fda8 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -179,12 +179,14 @@ static int plic_set_affinity(struct irq_data *d,
 	if (cpu >= nr_cpu_ids)
 		return -EINVAL;
 
-	plic_irq_disable(d);
+	/* Invalidate the original routing entry */
+	plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0);
 
 	irq_data_update_effective_affinity(d, cpumask_of(cpu));
 
+	/* Setting the new routing entry if irq is enabled */
 	if (!irqd_irq_disabled(d))
-		plic_irq_enable(d);
+		plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1);
 
 	return IRQ_SET_MASK_OK_DONE;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-24 10:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-11  0:26 [PATCH v2] irqchip/sifive-plic: Respect mask state when setting affinity Inochi Amaoto
2025-08-21  6:37 ` Chen Wang
2025-08-24  0:40 ` Chen Wang
2025-08-24 10:33 ` [tip: irq/drivers] " tip-bot2 for Inochi Amaoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®