Skip to contentSkip to conversation

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

PATCH Applied Inochi Amaoto 3 participants 4 messages Aug 11, 2025 – Aug 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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.

---
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(-)
drivers/irqchip/irq-sifive-plic.c +4 -2
index bf69a4802b71..866e38612b94 100644
@@ -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

Reviewed-by Tested-by on v2 1/1
#1 lore raw
Quoted 11 lines · Inochi Amaoto

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.

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/[email protected]/

Quoted 37 lines

---
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(-)
drivers/irqchip/irq-sifive-plic.c +4 -3
index bf69a4802b71..866e38612b94 100644
@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#2 lore raw
In reply to Inochi Amaoto

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

Thanks,

Chen

Quoted 48 lines · Inochi Amaoto

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.

---
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(-)
drivers/irqchip/irq-sifive-plic.c +4 -3
index bf69a4802b71..866e38612b94 100644
@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

merge bot Applied
#3 lore raw
In reply to Inochi Amaoto
The following commit has been merged into the irq/drivers branch of tip:

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 <[email protected]>
AuthorDate:    Mon, 11 Aug 2025 08:26:32 +08:00
Committer:     Thomas Gleixner <[email protected]>
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.

---
 drivers/irqchip/irq-sifive-plic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/irqchip/irq-sifive-plic.c +4 -2
index 3de5460..559fda8 100644
@@ -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;
 }