Skip to content

Commit cc0cc23

Browse files
covanammaddy-kerneldev
authored andcommitted
powerpc/xive: Untangle xive from child interrupt controller drivers
xive-specific data is stored in handler_data. This creates a mess, as xive has to rely on child interrupt controller drivers to clean up this data, as was done by 9a014f4 ("powerpc/pseries/pci: Add a msi_free() handler to clear XIVE data"). Instead, store xive-specific data in chip_data and untangle the child drivers. Signed-off-by: Nam Cao <namcao@linutronix.de> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/83968073022a4cc211dcbd0faccd20ec05e58c3e.1754903590.git.namcao@linutronix.de
1 parent b034baf commit cc0cc23

File tree

4 files changed

+33
-70
lines changed

4 files changed

+33
-70
lines changed

arch/powerpc/include/asm/xive.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ 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);
115114
void xive_native_free_irq(u32 irq);
116115
int xive_native_configure_irq(u32 hw_irq, u32 target, u8 prio, u32 sw_irq);
117116

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <asm/firmware.h>
3838
#include <asm/pnv-pci.h>
3939
#include <asm/mmzone.h>
40-
#include <asm/xive.h>
4140

4241
#include "powernv.h"
4342
#include "pci.h"
@@ -1707,23 +1706,6 @@ static int __pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
17071706
return 0;
17081707
}
17091708

1710-
/*
1711-
* The msi_free() op is called before irq_domain_free_irqs_top() when
1712-
* the handler data is still available. Use that to clear the XIVE
1713-
* controller.
1714-
*/
1715-
static void pnv_msi_ops_msi_free(struct irq_domain *domain,
1716-
struct msi_domain_info *info,
1717-
unsigned int irq)
1718-
{
1719-
if (xive_enabled())
1720-
xive_irq_free_data(irq);
1721-
}
1722-
1723-
static struct msi_domain_ops pnv_pci_msi_domain_ops = {
1724-
.msi_free = pnv_msi_ops_msi_free,
1725-
};
1726-
17271709
static void pnv_msi_shutdown(struct irq_data *d)
17281710
{
17291711
d = d->parent_data;
@@ -1754,7 +1736,6 @@ static struct irq_chip pnv_pci_msi_irq_chip = {
17541736
static struct msi_domain_info pnv_msi_domain_info = {
17551737
.flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
17561738
MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX),
1757-
.ops = &pnv_pci_msi_domain_ops,
17581739
.chip = &pnv_pci_msi_irq_chip,
17591740
};
17601741

@@ -1870,7 +1851,7 @@ static void pnv_irq_domain_free(struct irq_domain *domain, unsigned int virq,
18701851
virq, d->hwirq, nr_irqs);
18711852

18721853
msi_bitmap_free_hwirqs(&phb->msi_bmp, d->hwirq, nr_irqs);
1873-
/* XIVE domain is cleared through ->msi_free() */
1854+
irq_domain_free_irqs_parent(domain, virq, nr_irqs);
18741855
}
18751856

18761857
static const struct irq_domain_ops pnv_irq_domain_ops = {

arch/powerpc/platforms/pseries/msi.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <asm/hw_irq.h>
1616
#include <asm/ppc-pci.h>
1717
#include <asm/machdep.h>
18-
#include <asm/xive.h>
1918

2019
#include "pseries.h"
2120

@@ -436,19 +435,6 @@ static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *dev
436435
return rtas_prepare_msi_irqs(pdev, nvec, type, arg);
437436
}
438437

439-
/*
440-
* ->msi_free() is called before irq_domain_free_irqs_top() when the
441-
* handler data is still available. Use that to clear the XIVE
442-
* controller data.
443-
*/
444-
static void pseries_msi_ops_msi_free(struct irq_domain *domain,
445-
struct msi_domain_info *info,
446-
unsigned int irq)
447-
{
448-
if (xive_enabled())
449-
xive_irq_free_data(irq);
450-
}
451-
452438
/*
453439
* RTAS can not disable one MSI at a time. It's all or nothing. Do it
454440
* at the end after all IRQs have been freed.
@@ -463,7 +449,6 @@ static void pseries_msi_post_free(struct irq_domain *domain, struct device *dev)
463449

464450
static struct msi_domain_ops pseries_pci_msi_domain_ops = {
465451
.msi_prepare = pseries_msi_ops_prepare,
466-
.msi_free = pseries_msi_ops_msi_free,
467452
.msi_post_free = pseries_msi_post_free,
468453
};
469454

@@ -604,8 +589,7 @@ static void pseries_irq_domain_free(struct irq_domain *domain, unsigned int virq
604589
struct pci_controller *phb = irq_data_get_irq_chip_data(d);
605590

606591
pr_debug("%s bridge %pOF %d #%d\n", __func__, phb->dn, virq, nr_irqs);
607-
608-
/* XIVE domain data is cleared through ->msi_free() */
592+
irq_domain_free_irqs_parent(domain, virq, nr_irqs);
609593
}
610594

611595
static const struct irq_domain_ops pseries_irq_domain_ops = {

arch/powerpc/sysdev/xive/common.c

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ int xmon_xive_get_irq_config(u32 hw_irq, struct irq_data *d)
317317
if (d) {
318318
char buffer[128];
319319

320-
xive_irq_data_dump(irq_data_get_irq_handler_data(d),
320+
xive_irq_data_dump(irq_data_get_irq_chip_data(d),
321321
buffer, sizeof(buffer));
322322
xmon_printf("%s", buffer);
323323
}
@@ -437,7 +437,7 @@ static void xive_do_source_eoi(struct xive_irq_data *xd)
437437
/* irq_chip eoi callback, called with irq descriptor lock held */
438438
static void xive_irq_eoi(struct irq_data *d)
439439
{
440-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
440+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
441441
struct xive_cpu *xc = __this_cpu_read(xive_cpu);
442442

443443
DBG_VERBOSE("eoi_irq: irq=%d [0x%lx] pending=%02x\n",
@@ -595,7 +595,7 @@ static int xive_pick_irq_target(struct irq_data *d,
595595
const struct cpumask *affinity)
596596
{
597597
static unsigned int fuzz;
598-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
598+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
599599
cpumask_var_t mask;
600600
int cpu = -1;
601601

@@ -628,7 +628,7 @@ static int xive_pick_irq_target(struct irq_data *d,
628628

629629
static unsigned int xive_irq_startup(struct irq_data *d)
630630
{
631-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
631+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
632632
unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d);
633633
int target, rc;
634634

@@ -673,7 +673,7 @@ static unsigned int xive_irq_startup(struct irq_data *d)
673673
/* called with irq descriptor lock held */
674674
static void xive_irq_shutdown(struct irq_data *d)
675675
{
676-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
676+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
677677
unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d);
678678

679679
pr_debug("%s: irq %d [0x%x] data @%p\n", __func__, d->irq, hw_irq, d);
@@ -698,7 +698,7 @@ static void xive_irq_shutdown(struct irq_data *d)
698698

699699
static void xive_irq_unmask(struct irq_data *d)
700700
{
701-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
701+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
702702

703703
pr_debug("%s: irq %d data @%p\n", __func__, d->irq, xd);
704704

@@ -707,7 +707,7 @@ static void xive_irq_unmask(struct irq_data *d)
707707

708708
static void xive_irq_mask(struct irq_data *d)
709709
{
710-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
710+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
711711

712712
pr_debug("%s: irq %d data @%p\n", __func__, d->irq, xd);
713713

@@ -718,7 +718,7 @@ static int xive_irq_set_affinity(struct irq_data *d,
718718
const struct cpumask *cpumask,
719719
bool force)
720720
{
721-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
721+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
722722
unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d);
723723
u32 target, old_target;
724724
int rc = 0;
@@ -776,7 +776,7 @@ static int xive_irq_set_affinity(struct irq_data *d,
776776

777777
static int xive_irq_set_type(struct irq_data *d, unsigned int flow_type)
778778
{
779-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
779+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
780780

781781
/*
782782
* We only support these. This has really no effect other than setting
@@ -815,7 +815,7 @@ static int xive_irq_set_type(struct irq_data *d, unsigned int flow_type)
815815

816816
static int xive_irq_retrigger(struct irq_data *d)
817817
{
818-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
818+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
819819

820820
/* This should be only for MSIs */
821821
if (WARN_ON(xd->flags & XIVE_IRQ_FLAG_LSI))
@@ -837,7 +837,7 @@ static int xive_irq_retrigger(struct irq_data *d)
837837
*/
838838
static int xive_irq_set_vcpu_affinity(struct irq_data *d, void *state)
839839
{
840-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
840+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(d);
841841
unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d);
842842
int rc;
843843
u8 pq;
@@ -951,7 +951,7 @@ static int xive_irq_set_vcpu_affinity(struct irq_data *d, void *state)
951951
static int xive_get_irqchip_state(struct irq_data *data,
952952
enum irqchip_irq_state which, bool *state)
953953
{
954-
struct xive_irq_data *xd = irq_data_get_irq_handler_data(data);
954+
struct xive_irq_data *xd = irq_data_get_irq_chip_data(data);
955955
u8 pq;
956956

957957
switch (which) {
@@ -1011,21 +1011,20 @@ void xive_cleanup_irq_data(struct xive_irq_data *xd)
10111011
}
10121012
EXPORT_SYMBOL_GPL(xive_cleanup_irq_data);
10131013

1014-
static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
1014+
static struct xive_irq_data *xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
10151015
{
10161016
struct xive_irq_data *xd;
10171017
int rc;
10181018

10191019
xd = kzalloc(sizeof(struct xive_irq_data), GFP_KERNEL);
10201020
if (!xd)
1021-
return -ENOMEM;
1021+
return ERR_PTR(-ENOMEM);
10221022
rc = xive_ops->populate_irq_data(hw, xd);
10231023
if (rc) {
10241024
kfree(xd);
1025-
return rc;
1025+
return ERR_PTR(rc);
10261026
}
10271027
xd->target = XIVE_INVALID_TARGET;
1028-
irq_set_handler_data(virq, xd);
10291028

10301029
/*
10311030
* Turn OFF by default the interrupt being mapped. A side
@@ -1036,20 +1035,19 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
10361035
*/
10371036
xive_esb_read(xd, XIVE_ESB_SET_PQ_01);
10381037

1039-
return 0;
1038+
return xd;
10401039
}
10411040

1042-
void xive_irq_free_data(unsigned int virq)
1041+
static void xive_irq_free_data(unsigned int virq)
10431042
{
1044-
struct xive_irq_data *xd = irq_get_handler_data(virq);
1043+
struct xive_irq_data *xd = irq_get_chip_data(virq);
10451044

10461045
if (!xd)
10471046
return;
1048-
irq_set_handler_data(virq, NULL);
1047+
irq_set_chip_data(virq, NULL);
10491048
xive_cleanup_irq_data(xd);
10501049
kfree(xd);
10511050
}
1052-
EXPORT_SYMBOL_GPL(xive_irq_free_data);
10531051

10541052
#ifdef CONFIG_SMP
10551053

@@ -1286,19 +1284,20 @@ void __init xive_smp_probe(void)
12861284
static int xive_irq_domain_map(struct irq_domain *h, unsigned int virq,
12871285
irq_hw_number_t hw)
12881286
{
1289-
int rc;
1287+
struct xive_irq_data *xd;
12901288

12911289
/*
12921290
* Mark interrupts as edge sensitive by default so that resend
12931291
* actually works. Will fix that up below if needed.
12941292
*/
12951293
irq_clear_status_flags(virq, IRQ_LEVEL);
12961294

1297-
rc = xive_irq_alloc_data(virq, hw);
1298-
if (rc)
1299-
return rc;
1295+
xd = xive_irq_alloc_data(virq, hw);
1296+
if (IS_ERR(xd))
1297+
return PTR_ERR(xd);
13001298

13011299
irq_set_chip_and_handler(virq, &xive_irq_chip, handle_fasteoi_irq);
1300+
irq_set_chip_data(virq, xd);
13021301

13031302
return 0;
13041303
}
@@ -1366,7 +1365,7 @@ static void xive_irq_domain_debug_show(struct seq_file *m, struct irq_domain *d,
13661365
seq_printf(m, "%*sXIVE:\n", ind, "");
13671366
ind++;
13681367

1369-
xd = irq_data_get_irq_handler_data(irqd);
1368+
xd = irq_data_get_irq_chip_data(irqd);
13701369
if (!xd) {
13711370
seq_printf(m, "%*snot assigned\n", ind, "");
13721371
return;
@@ -1403,6 +1402,7 @@ static int xive_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
14031402
unsigned int nr_irqs, void *arg)
14041403
{
14051404
struct irq_fwspec *fwspec = arg;
1405+
struct xive_irq_data *xd;
14061406
irq_hw_number_t hwirq;
14071407
unsigned int type = IRQ_TYPE_NONE;
14081408
int i, rc;
@@ -1423,12 +1423,11 @@ static int xive_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
14231423
irq_clear_status_flags(virq, IRQ_LEVEL);
14241424

14251425
/* allocates and sets handler data */
1426-
rc = xive_irq_alloc_data(virq + i, hwirq + i);
1427-
if (rc)
1428-
return rc;
1426+
xd = xive_irq_alloc_data(virq + i, hwirq + i);
1427+
if (IS_ERR(xd))
1428+
return PTR_ERR(xd);
14291429

1430-
irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
1431-
&xive_irq_chip, domain->host_data);
1430+
irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i, &xive_irq_chip, xd);
14321431
irq_set_handler(virq + i, handle_fasteoi_irq);
14331432
}
14341433

@@ -1764,7 +1763,7 @@ static void xive_debug_show_irq(struct seq_file *m, struct irq_data *d)
17641763
seq_printf(m, "IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ",
17651764
hw_irq, target, prio, lirq);
17661765

1767-
xive_irq_data_dump(irq_data_get_irq_handler_data(d), buffer, sizeof(buffer));
1766+
xive_irq_data_dump(irq_data_get_irq_chip_data(d), buffer, sizeof(buffer));
17681767
seq_puts(m, buffer);
17691768
seq_puts(m, "\n");
17701769
}

0 commit comments

Comments
 (0)