Skip to content

Commit 9a014f4

Browse files
legoatermpe
authored andcommitted
powerpc/pseries/pci: Add a msi_free() handler to clear XIVE data
The MSI domain clears the IRQ with msi_domain_free(), which calls irq_domain_free_irqs_top(), which clears the handler data. This is a problem for the XIVE controller since we need to unmap MMIO pages and free a specific XIVE structure. The 'msi_free()' handler is called before irq_domain_free_irqs_top() when the handler data is still available. Use that to clear the XIVE controller data. Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210701132750.1475580-10-clg@kaod.org
1 parent 07817a5 commit 9a014f4

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

arch/powerpc/include/asm/xive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void xive_native_free_vp_block(u32 vp_base);
111111
int xive_native_populate_irq_data(u32 hw_irq,
112112
struct xive_irq_data *data);
113113
void xive_cleanup_irq_data(struct xive_irq_data *xd);
114+
void xive_irq_free_data(unsigned int virq);
114115
void xive_native_free_irq(u32 irq);
115116
int xive_native_configure_irq(u32 hw_irq, u32 target, u8 prio, u32 sw_irq);
116117

arch/powerpc/platforms/pseries/msi.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,19 @@ static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *dev
529529
return rtas_prepare_msi_irqs(pdev, nvec, type, arg);
530530
}
531531

532+
/*
533+
* ->msi_free() is called before irq_domain_free_irqs_top() when the
534+
* handler data is still available. Use that to clear the XIVE
535+
* controller data.
536+
*/
537+
static void pseries_msi_ops_msi_free(struct irq_domain *domain,
538+
struct msi_domain_info *info,
539+
unsigned int irq)
540+
{
541+
if (xive_enabled())
542+
xive_irq_free_data(irq);
543+
}
544+
532545
/*
533546
* RTAS can not disable one MSI at a time. It's all or nothing. Do it
534547
* at the end after all IRQs have been freed.
@@ -546,6 +559,7 @@ static void pseries_msi_domain_free_irqs(struct irq_domain *domain,
546559

547560
static struct msi_domain_ops pseries_pci_msi_domain_ops = {
548561
.msi_prepare = pseries_msi_ops_prepare,
562+
.msi_free = pseries_msi_ops_msi_free,
549563
.domain_free_irqs = pseries_msi_domain_free_irqs,
550564
};
551565

@@ -660,7 +674,7 @@ static void pseries_irq_domain_free(struct irq_domain *domain, unsigned int virq
660674

661675
pr_debug("%s bridge %pOF %d #%d\n", __func__, phb->dn, virq, nr_irqs);
662676

663-
irq_domain_free_irqs_parent(domain, virq, nr_irqs);
677+
/* XIVE domain data is cleared through ->msi_free() */
664678
}
665679

666680
static const struct irq_domain_ops pseries_irq_domain_ops = {

arch/powerpc/sysdev/xive/common.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ EXPORT_SYMBOL_GPL(is_xive_irq);
975975

976976
void xive_cleanup_irq_data(struct xive_irq_data *xd)
977977
{
978+
pr_debug("%s for HW %x\n", __func__, xd->hw_irq);
979+
978980
if (xd->eoi_mmio) {
979981
iounmap(xd->eoi_mmio);
980982
if (xd->eoi_mmio == xd->trig_mmio)
@@ -1016,7 +1018,7 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
10161018
return 0;
10171019
}
10181020

1019-
static void xive_irq_free_data(unsigned int virq)
1021+
void xive_irq_free_data(unsigned int virq)
10201022
{
10211023
struct xive_irq_data *xd = irq_get_handler_data(virq);
10221024

@@ -1026,6 +1028,7 @@ static void xive_irq_free_data(unsigned int virq)
10261028
xive_cleanup_irq_data(xd);
10271029
kfree(xd);
10281030
}
1031+
EXPORT_SYMBOL_GPL(xive_irq_free_data);
10291032

10301033
#ifdef CONFIG_SMP
10311034

0 commit comments

Comments
 (0)