Skip to content

Commit

Permalink
irqchip/riscv-imsic: Set irq_set_affinity() for IMSIC base
Browse files Browse the repository at this point in the history
The IMSIC driver assigns the IMSIC domain specific imsic_irq_set_affinity()
callback to the per device leaf MSI domain. That's a layering violation as
it is called with the leaf domain data and not with the IMSIC domain
data. This prevents moving the IMSIC driver to the common MSI library which
uses the generic msi_domain_set_affinity() callback for device MSI domains.

Instead of using imsic_irq_set_affinity() for leaf MSI domains, use
imsic_irq_set_affinity() for the non-leaf IMSIC base domain and use
irq_chip_set_affinity_parent() for leaf MSI domains.

[ tglx: Massaged change log ]

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250217085657.789309-2-apatel@ventanamicro.com
  • Loading branch information
Andrew Jones authored and Thomas Gleixner committed Feb 18, 2025
1 parent 0699e57 commit 999f458
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions drivers/irqchip/irq-riscv-imsic-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask
bool force)
{
struct imsic_vector *old_vec, *new_vec;
struct irq_data *pd = d->parent_data;

old_vec = irq_data_get_irq_chip_data(pd);
old_vec = irq_data_get_irq_chip_data(d);
if (WARN_ON(!old_vec))
return -ENOENT;

Expand All @@ -116,13 +115,13 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask
return -ENOSPC;

/* Point device to the new vector */
imsic_msi_update_msg(d, new_vec);
imsic_msi_update_msg(irq_get_irq_data(d->irq), new_vec);

/* Update irq descriptors with the new vector */
pd->chip_data = new_vec;
d->chip_data = new_vec;

/* Update effective affinity of parent irq data */
irq_data_update_effective_affinity(pd, cpumask_of(new_vec->cpu));
/* Update effective affinity */
irq_data_update_effective_affinity(d, cpumask_of(new_vec->cpu));

/* Move state of the old vector to the new vector */
imsic_vector_move(old_vec, new_vec);
Expand All @@ -135,6 +134,9 @@ static struct irq_chip imsic_irq_base_chip = {
.name = "IMSIC",
.irq_mask = imsic_irq_mask,
.irq_unmask = imsic_irq_unmask,
#ifdef CONFIG_SMP
.irq_set_affinity = imsic_irq_set_affinity,
#endif
.irq_retrigger = imsic_irq_retrigger,
.irq_compose_msi_msg = imsic_irq_compose_msg,
.flags = IRQCHIP_SKIP_SET_WAKE |
Expand Down Expand Up @@ -245,7 +247,7 @@ static bool imsic_init_dev_msi_info(struct device *dev,
if (WARN_ON_ONCE(domain != real_parent))
return false;
#ifdef CONFIG_SMP
info->chip->irq_set_affinity = imsic_irq_set_affinity;
info->chip->irq_set_affinity = irq_chip_set_affinity_parent;
#endif
break;
default:
Expand Down

0 comments on commit 999f458

Please sign in to comment.