cregit-Linux how code gets into the kernel

Release 4.14 arch/powerpc/sysdev/mpic.c

/*
 *  arch/powerpc/kernel/mpic.c
 *
 *  Driver for interrupt controllers following the OpenPIC standard, the
 *  common implementation being IBM's MPIC. This driver also can deal
 *  with various broken implementations of this HW.
 *
 *  Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
 *  Copyright 2010-2012 Freescale Semiconductor, Inc.
 *
 *  This file is subject to the terms and conditions of the GNU General Public
 *  License.  See the file COPYING in the main directory of this archive
 *  for more details.
 */


#undef DEBUG

#undef DEBUG_IPI

#undef DEBUG_IRQ

#undef DEBUG_LOW

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/smp.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/syscore_ops.h>
#include <linux/ratelimit.h>

#include <asm/ptrace.h>
#include <asm/signal.h>
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/irq.h>
#include <asm/machdep.h>
#include <asm/mpic.h>
#include <asm/smp.h>

#include "mpic.h"

#ifdef DEBUG

#define DBG(fmt...) printk(fmt)
#else

#define DBG(fmt...)
#endif


struct bus_type mpic_subsys = {
	.name = "mpic",
	.dev_name = "mpic",
};

EXPORT_SYMBOL_GPL(mpic_subsys);


static struct mpic *mpics;

static struct mpic *mpic_primary;
static DEFINE_RAW_SPINLOCK(mpic_lock);

#ifdef CONFIG_PPC32	/* XXX for now */
#ifdef CONFIG_IRQ_ALL_CPUS

#define distribute_irqs	(1)
#else

#define distribute_irqs	(0)
#endif
#endif

#ifdef CONFIG_MPIC_WEIRD

static u32 mpic_infos[][MPIC_IDX_END] = {
	[0] = {	/* Original OpenPIC compatible MPIC */
		MPIC_GREG_BASE,
		MPIC_GREG_FEATURE_0,
		MPIC_GREG_GLOBAL_CONF_0,
		MPIC_GREG_VENDOR_ID,
		MPIC_GREG_IPI_VECTOR_PRI_0,
		MPIC_GREG_IPI_STRIDE,
		MPIC_GREG_SPURIOUS,
		MPIC_GREG_TIMER_FREQ,

		MPIC_TIMER_BASE,
		MPIC_TIMER_STRIDE,
		MPIC_TIMER_CURRENT_CNT,
		MPIC_TIMER_BASE_CNT,
		MPIC_TIMER_VECTOR_PRI,
		MPIC_TIMER_DESTINATION,

		MPIC_CPU_BASE,
		MPIC_CPU_STRIDE,
		MPIC_CPU_IPI_DISPATCH_0,
		MPIC_CPU_IPI_DISPATCH_STRIDE,
		MPIC_CPU_CURRENT_TASK_PRI,
		MPIC_CPU_WHOAMI,
		MPIC_CPU_INTACK,
		MPIC_CPU_EOI,
		MPIC_CPU_MCACK,

		MPIC_IRQ_BASE,
		MPIC_IRQ_STRIDE,
		MPIC_IRQ_VECTOR_PRI,
		MPIC_VECPRI_VECTOR_MASK,
		MPIC_VECPRI_POLARITY_POSITIVE,
		MPIC_VECPRI_POLARITY_NEGATIVE,
		MPIC_VECPRI_SENSE_LEVEL,
		MPIC_VECPRI_SENSE_EDGE,
		MPIC_VECPRI_POLARITY_MASK,
		MPIC_VECPRI_SENSE_MASK,
		MPIC_IRQ_DESTINATION
	},
	[1] = {	/* Tsi108/109 PIC */
		TSI108_GREG_BASE,
		TSI108_GREG_FEATURE_0,
		TSI108_GREG_GLOBAL_CONF_0,
		TSI108_GREG_VENDOR_ID,
		TSI108_GREG_IPI_VECTOR_PRI_0,
		TSI108_GREG_IPI_STRIDE,
		TSI108_GREG_SPURIOUS,
		TSI108_GREG_TIMER_FREQ,

		TSI108_TIMER_BASE,
		TSI108_TIMER_STRIDE,
		TSI108_TIMER_CURRENT_CNT,
		TSI108_TIMER_BASE_CNT,
		TSI108_TIMER_VECTOR_PRI,
		TSI108_TIMER_DESTINATION,

		TSI108_CPU_BASE,
		TSI108_CPU_STRIDE,
		TSI108_CPU_IPI_DISPATCH_0,
		TSI108_CPU_IPI_DISPATCH_STRIDE,
		TSI108_CPU_CURRENT_TASK_PRI,
		TSI108_CPU_WHOAMI,
		TSI108_CPU_INTACK,
		TSI108_CPU_EOI,
		TSI108_CPU_MCACK,

		TSI108_IRQ_BASE,
		TSI108_IRQ_STRIDE,
		TSI108_IRQ_VECTOR_PRI,
		TSI108_VECPRI_VECTOR_MASK,
		TSI108_VECPRI_POLARITY_POSITIVE,
		TSI108_VECPRI_POLARITY_NEGATIVE,
		TSI108_VECPRI_SENSE_LEVEL,
		TSI108_VECPRI_SENSE_EDGE,
		TSI108_VECPRI_POLARITY_MASK,
		TSI108_VECPRI_SENSE_MASK,
		TSI108_IRQ_DESTINATION
	},
};


#define MPIC_INFO(name) mpic->hw_set[MPIC_IDX_##name]

#else /* CONFIG_MPIC_WEIRD */


#define MPIC_INFO(name) MPIC_##name

#endif /* CONFIG_MPIC_WEIRD */


static inline unsigned int mpic_processor_id(struct mpic *mpic) { unsigned int cpu = 0; if (!(mpic->flags & MPIC_SECONDARY)) cpu = hard_smp_processor_id(); return cpu; }

Contributors

PersonTokensPropCommitsCommitProp
Meador Inge3489.47%150.00%
Kyle Moffett410.53%150.00%
Total38100.00%2100.00%

/* * Register accessor functions */
static inline u32 _mpic_read(enum mpic_reg_type type, struct mpic_reg_bank *rb, unsigned int reg) { switch(type) { #ifdef CONFIG_PPC_DCR case mpic_access_dcr: return dcr_read(rb->dhost, reg); #endif case mpic_access_mmio_be: return in_be32(rb->base + (reg >> 2)); case mpic_access_mmio_le: default: return in_le32(rb->base + (reg >> 2)); } }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras4050.63%150.00%
Benjamin Herrenschmidt3949.37%150.00%
Total79100.00%2100.00%


static inline void _mpic_write(enum mpic_reg_type type, struct mpic_reg_bank *rb, unsigned int reg, u32 value) { switch(type) { #ifdef CONFIG_PPC_DCR case mpic_access_dcr: dcr_write(rb->dhost, reg, value); break; #endif case mpic_access_mmio_be: out_be32(rb->base + (reg >> 2), value); break; case mpic_access_mmio_le: default: out_le32(rb->base + (reg >> 2), value); break; } }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras4348.86%133.33%
Benjamin Herrenschmidt3944.32%133.33%
Johannes Berg66.82%133.33%
Total88100.00%3100.00%


static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi) { enum mpic_reg_type type = mpic->reg_type; unsigned int offset = MPIC_INFO(GREG_IPI_VECTOR_PRI_0) + (ipi * MPIC_INFO(GREG_IPI_STRIDE)); if ((mpic->flags & MPIC_BROKEN_IPI) && type == mpic_access_mmio_le) type = mpic_access_mmio_be; return _mpic_read(type, &mpic->gregs, offset); }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras5169.86%133.33%
Benjamin Herrenschmidt1419.18%133.33%
Roy Zang810.96%133.33%
Total73100.00%3100.00%


static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value) { unsigned int offset = MPIC_INFO(GREG_IPI_VECTOR_PRI_0) + (ipi * MPIC_INFO(GREG_IPI_STRIDE)); _mpic_write(mpic->reg_type, &mpic->gregs, offset, value); }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras4381.13%133.33%
Roy Zang815.09%133.33%
Benjamin Herrenschmidt23.77%133.33%
Total53100.00%3100.00%


static inline unsigned int mpic_tm_offset(struct mpic *mpic, unsigned int tm) { return (tm >> 2) * MPIC_TIMER_GROUP_STRIDE + (tm & 3) * MPIC_INFO(TIMER_STRIDE); }

Contributors

PersonTokensPropCommitsCommitProp
Varun Sethi37100.00%1100.00%
Total37100.00%1100.00%


static inline u32 _mpic_tm_read(struct mpic *mpic, unsigned int tm) { unsigned int offset = mpic_tm_offset(mpic, tm) + MPIC_INFO(TIMER_VECTOR_PRI); return _mpic_read(mpic->reg_type, &mpic->tmregs, offset); }

Contributors

PersonTokensPropCommitsCommitProp
Scott Wood4289.36%150.00%
Varun Sethi510.64%150.00%
Total47100.00%2100.00%


static inline void _mpic_tm_write(struct mpic *mpic, unsigned int tm, u32 value) { unsigned int offset = mpic_tm_offset(mpic, tm) + MPIC_INFO(TIMER_VECTOR_PRI); _mpic_write(mpic->reg_type, &mpic->tmregs, offset, value); }

Contributors

PersonTokensPropCommitsCommitProp
Scott Wood4690.20%150.00%
Varun Sethi59.80%150.00%
Total51100.00%2100.00%


static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) { unsigned int cpu = mpic_processor_id(mpic); return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg); }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras3786.05%133.33%
Meador Inge49.30%133.33%
Benjamin Herrenschmidt24.65%133.33%
Total43100.00%3100.00%


static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) { unsigned int cpu = mpic_processor_id(mpic); _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value); }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras4187.23%133.33%
Meador Inge48.51%133.33%
Benjamin Herrenschmidt24.26%133.33%
Total47100.00%3100.00%


static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg) { unsigned int isu = src_no >> mpic->isu_shift; unsigned int idx = src_no & mpic->isu_mask; unsigned int val; val = _mpic_read(mpic->reg_type, &mpic->isus[isu], reg + (idx * MPIC_INFO(IRQ_STRIDE))); #ifdef CONFIG_MPIC_BROKEN_REGREAD if (reg == 0) val = (val & (MPIC_VECPRI_MASK | MPIC_VECPRI_ACTIVITY)) | mpic->isu_reg0_shadow[src_no]; #endif return val; }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras6057.14%125.00%
Michael Ellerman3937.14%125.00%
Roy Zang43.81%125.00%
Benjamin Herrenschmidt21.90%125.00%
Total105100.00%4100.00%


static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no, unsigned int reg, u32 value) { unsigned int isu = src_no >> mpic->isu_shift; unsigned int idx = src_no & mpic->isu_mask; _mpic_write(mpic->reg_type, &mpic->isus[isu], reg + (idx * MPIC_INFO(IRQ_STRIDE)), value); #ifdef CONFIG_MPIC_BROKEN_REGREAD if (reg == 0) mpic->isu_reg0_shadow[src_no] = value & ~(MPIC_VECPRI_MASK | MPIC_VECPRI_ACTIVITY); #endif }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras6566.33%120.00%
Olof Johansson1919.39%120.00%
Michael Ellerman88.16%120.00%
Roy Zang44.08%120.00%
Benjamin Herrenschmidt22.04%120.00%
Total98100.00%5100.00%

#define mpic_read(b,r) _mpic_read(mpic->reg_type,&(b),(r)) #define mpic_write(b,r,v) _mpic_write(mpic->reg_type,&(b),(r),(v)) #define mpic_ipi_read(i) _mpic_ipi_read(mpic,(i)) #define mpic_ipi_write(i,v) _mpic_ipi_write(mpic,(i),(v)) #define mpic_tm_read(i) _mpic_tm_read(mpic,(i)) #define mpic_tm_write(i,v) _mpic_tm_write(mpic,(i),(v)) #define mpic_cpu_read(i) _mpic_cpu_read(mpic,(i)) #define mpic_cpu_write(i,v) _mpic_cpu_write(mpic,(i),(v)) #define mpic_irq_read(s,r) _mpic_irq_read(mpic,(s),(r)) #define mpic_irq_write(s,r,v) _mpic_irq_write(mpic,(s),(r),(v)) /* * Low level utility functions */
static void _mpic_map_mmio(struct mpic *mpic, phys_addr_t phys_addr, struct mpic_reg_bank *rb, unsigned int offset, unsigned int size) { rb->base = ioremap(phys_addr + offset, size); BUG_ON(rb->base == NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt4897.96%150.00%
Becky Bruce12.04%150.00%
Total49100.00%2100.00%

#ifdef CONFIG_PPC_DCR
static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb, unsigned int offset, unsigned int size) { phys_addr_t phys_addr = dcr_resource_start(mpic->node, 0); rb->dhost = dcr_map(mpic->node, phys_addr + offset, size); BUG_ON(!DCR_MAP_OK(rb->dhost)); }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt4976.56%240.00%
Kyle Moffett1117.19%240.00%
Michael Ellerman46.25%120.00%
Total64100.00%5100.00%


static inline void mpic_map(struct mpic *mpic, phys_addr_t phys_addr, struct mpic_reg_bank *rb, unsigned int offset, unsigned int size) { if (mpic->flags & MPIC_USES_DCR) _mpic_map_dcr(mpic, rb, offset, size); else _mpic_map_mmio(mpic, phys_addr, rb, offset, size); }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt6098.36%150.00%
Becky Bruce11.64%150.00%
Total61100.00%2100.00%

#else /* CONFIG_PPC_DCR */ #define mpic_map(m,p,b,o,s) _mpic_map_mmio(m,p,b,o,s) #endif /* !CONFIG_PPC_DCR */ /* Check if we have one of those nice broken MPICs with a flipped endian on * reads from IPI registers */
static void __init mpic_test_broken_ipi(struct mpic *mpic) { u32 r; mpic_write(mpic->gregs, MPIC_INFO(GREG_IPI_VECTOR_PRI_0), MPIC_VECPRI_MASK); r = mpic_read(mpic->gregs, MPIC_INFO(GREG_IPI_VECTOR_PRI_0)); if (r == le32_to_cpu(MPIC_VECPRI_MASK)) { printk(KERN_INFO "mpic: Detected reversed IPI registers\n"); mpic->flags |= MPIC_BROKEN_IPI; } }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras5887.88%150.00%
Roy Zang812.12%150.00%
Total66100.00%2100.00%

#ifdef CONFIG_MPIC_U3_HT_IRQS /* Test if an interrupt is sourced from HyperTransport (used on broken U3s) * to force the edge setting on the MPIC and do the ack workaround. */
static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source) { if (source >= 128 || !mpic->fixups) return 0; return mpic->fixups[source].base != NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras3992.86%150.00%
Benjamin Herrenschmidt37.14%150.00%
Total42100.00%2100.00%


static inline void mpic_ht_end_irq(struct mpic *mpic, unsigned int source) { struct mpic_irq_fixup *fixup = &mpic->fixups[source]; if (fixup->applebase) { unsigned int soff = (fixup->index >> 3) & ~3; unsigned int mask = 1U << (fixup->index & 0x1f); writel(mask, fixup->applebase + soff); } else { raw_spin_lock(&mpic->fixup_lock); writeb(0x11 + 2 * fixup->index, fixup->base + 2); writel(fixup->data, fixup->base + 4); raw_spin_unlock(&mpic->fixup_lock); } }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras6652.38%125.00%
Benjamin Herrenschmidt5543.65%125.00%
Segher Boessenkool32.38%125.00%
Thomas Gleixner21.59%125.00%
Total126100.00%4100.00%


static void mpic_startup_ht_interrupt(struct mpic *mpic, unsigned int source, bool level) { struct mpic_irq_fixup *fixup = &mpic->fixups[source]; unsigned long flags; u32 tmp; if (fixup->base == NULL) return; DBG("startup_ht_interrupt(0x%x) index: %d\n", source, fixup->index); raw_spin_lock_irqsave(&mpic->fixup_lock, flags); /* Enable and configure */ writeb(0x10 + 2 * fixup->index, fixup->base + 2); tmp = readl(fixup->base + 4); tmp &= ~(0x23U); if (level) tmp |= 0x22; writel(tmp, fixup->base + 4); raw_spin_unlock_irqrestore(&mpic->fixup_lock, flags); #ifdef CONFIG_PM /* use the lowest bit inverted to the actual HW, * set if this fixup was enabled, clear otherwise */ mpic->save_data[source].fixup_data = tmp | 1; #endif }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt12783.55%125.00%
Johannes Berg1912.50%125.00%
Thomas Gleixner63.95%250.00%
Total152100.00%4100.00%


static void mpic_shutdown_ht_interrupt(struct mpic *mpic, unsigned int source) { struct mpic_irq_fixup *fixup = &mpic->fixups[source]; unsigned long flags; u32 tmp; if (fixup->base == NULL) return; DBG("shutdown_ht_interrupt(0x%x)\n", source); /* Disable */ raw_spin_lock_irqsave(&mpic->fixup_lock, flags); writeb(0x10 + 2 * fixup->index, fixup->base + 2); tmp = readl(fixup->base + 4); tmp |= 1; writel(tmp, fixup->base + 4); raw_spin_unlock_irqrestore(&mpic->fixup_lock, flags); #ifdef CONFIG_PM /* use the lowest bit inverted to the actual HW, * set if this fixup was enabled, clear otherwise */ mpic->save_data[source].fixup_data = tmp & ~1; #endif }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt11081.48%120.00%
Johannes Berg2014.81%120.00%
Thomas Gleixner32.22%240.00%
Segher Boessenkool21.48%120.00%
Total135100.00%5100.00%

#ifdef CONFIG_PCI_MSI
static void __init mpic_scan_ht_msi(struct mpic *mpic, u8 __iomem *devbase, unsigned int devfn) { u8 __iomem *base; u8 pos, flags; u64 addr = 0; for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0; pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) { u8 id = readb(devbase + pos + PCI_CAP_LIST_ID); if (id == PCI_CAP_ID_HT) { id = readb(devbase + pos + 3); if ((id & HT_5BIT_CAP_MASK) == HT_CAPTYPE_MSI_MAPPING) break; } } if (pos == 0) return; base = devbase + pos; flags = readb(base + HT_MSI_FLAGS); if (!(flags & HT_MSI_FLAGS_FIXED)) { addr = readl(base + HT_MSI_ADDR_LO) & HT_MSI_ADDR_LO_MASK; addr = addr | ((u64)readl(base + HT_MSI_ADDR_HI) << 32); } printk(KERN_DEBUG "mpic: - HT:%02x.%x %s MSI mapping found @ 0x%llx\n", PCI_SLOT(devfn), PCI_FUNC(devfn), flags & HT_MSI_FLAGS_ENABLE ? "enabled" : "disabled", addr); if (!(flags & HT_MSI_FLAGS_ENABLE)) writeb(flags | HT_MSI_FLAGS_ENABLE, base + HT_MSI_FLAGS); }

Contributors

PersonTokensPropCommitsCommitProp
Michael Ellerman21399.53%150.00%
Ingo Molnar10.47%150.00%
Total214100.00%2100.00%

#else
static void __init mpic_scan_ht_msi(struct mpic *mpic, u8 __iomem *devbase, unsigned int devfn) { return; }

Contributors

PersonTokensPropCommitsCommitProp
Michael Ellerman22100.00%1100.00%
Total22100.00%1100.00%

#endif
static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase, unsigned int devfn, u32 vdid) { int i, irq, n; u8 __iomem *base; u32 tmp; u8 pos; for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0; pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) { u8 id = readb(devbase + pos + PCI_CAP_LIST_ID); if (id == PCI_CAP_ID_HT) { id = readb(devbase + pos + 3); if ((id & HT_5BIT_CAP_MASK) == HT_CAPTYPE_IRQ) break; } } if (pos == 0) return; base = devbase + pos; writeb(0x01, base + 2); n = (readl(base + 4) >> 16) & 0xff; printk(KERN_INFO "mpic: - HT:%02x.%x [0x%02x] vendor %04x device %04x" " has %d irqs\n", devfn >> 3, devfn & 0x7, pos, vdid & 0xffff, vdid >> 16, n + 1); for (i = 0; i <= n; i++) { writeb(0x10 + 2 * i, base + 2); tmp = readl(base + 4); irq = (tmp >> 16) & 0xff; DBG("HT PIC index 0x%x, irq 0x%x, tmp: %08x\n", i, irq, tmp); /* mask it , will be unmasked later */ tmp |= 0x1; writel(tmp, base + 4); mpic->fixups[irq].index = i; mpic->fixups[irq].base = base; /* Apple HT PIC has a non-standard way of doing EOIs */ if ((vdid & 0xffff) == 0x106b) mpic->fixups[irq].applebase = devbase + 0x60; else mpic->fixups[irq].applebase = NULL; writeb(0x11 + 2 * i, base + 2); mpic->fixups[irq].data = readl(base + 4) | 0x80000000; } }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt11935.10%116.67%
Paul Mackerras11233.04%116.67%
Segher Boessenkool10230.09%116.67%
Michael Ellerman41.18%116.67%
Brice Goglin10.29%116.67%
Eric W. Biedermann10.29%116.67%
Total339100.00%6100.00%


static void __init mpic_scan_ht_pics(struct mpic *mpic) { unsigned int devfn; u8 __iomem *cfgspace; printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n"); /* Allocate fixups array */ mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL); BUG_ON(mpic->fixups == NULL); /* Init spinlock */ raw_spin_lock_init(&mpic->fixup_lock); /* Map U3 config space. We assume all IO-APICs are on the primary bus * so we only need to map 64kB. */ cfgspace = ioremap(0xf2000000, 0x10000); BUG_ON(cfgspace == NULL); /* Now we scan all slots. We do a very quick scan, we read the header * type, vendor ID and device ID only, that's plenty enough */ for (devfn = 0; devfn < 0x100; devfn++) { u8 __iomem *devbase = cfgspace + (devfn << 8); u8 hdr_type = readb(devbase + PCI_HEADER_TYPE); u32 l = readl(devbase + PCI_VENDOR_ID); u16 s; DBG("devfn %x, l: %x\n", devfn, l); /* If no device, skip */ if (l == 0xffffffff || l == 0x00000000 || l == 0x0000ffff || l == 0xffff0000) goto next; /* Check if is supports capability lists */ s = readw(devbase + PCI_STATUS); if (!(s & PCI_STATUS_CAP_LIST)) goto next; mpic_scan_ht_pic(mpic, devbase, devfn, l); mpic_scan_ht_msi(mpic, devbase, devfn); next: /* next device, if function 0 */ if (PCI_FUNC(devfn) == 0 && (hdr_type & 0x80) == 0) devfn += 7; } }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras17174.03%116.67%
Benjamin Herrenschmidt3314.29%116.67%
Segher Boessenkool104.33%116.67%
Michael Ellerman93.90%116.67%
Anton Vorontsov73.03%116.67%
Thomas Gleixner10.43%116.67%
Total231100.00%6100.00%

#else /* CONFIG_MPIC_U3_HT_IRQS */
static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source) { return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt19100.00%1100.00%
Total19100.00%1100.00%


static void __init mpic_scan_ht_pics(struct mpic *mpic) { }

Contributors

PersonTokensPropCommitsCommitProp
Benjamin Herrenschmidt11100.00%1100.00%
Total11100.00%1100.00%

#endif /* CONFIG_MPIC_U3_HT_IRQS */ /* Find an mpic associated with a given linux interrupt */
static struct mpic *mpic_find(unsigned int irq) { if (irq < NUM_ISA_INTERRUPTS) return NULL; return irq_get_chip_data(irq); }

Contributors

PersonTokensPropCommitsCommitProp
Paul Mackerras1659.26%116.67%
Benjamin Herrenschmidt414.81%116.67%
Tony Breeds311.11%116.67%
Michael Ellerman27.41%116.67%
Thomas Gleixner13.70%116.67%
Olof Johansson13.70%116.67%
Total27100.00%6100.00%

/* Determine if the linux irq is an IPI */
static unsigned int mpic_is_ipi(struct mpic *mpic, unsigned int src) { return (src >= mpic->ipi_vecs[0] && src <= mpic->ipi_vecs[3]); }

Contributors

PersonTokensPropCommitsCommitProp
Tony Breeds1540.54%120.00%
Olof Johansson1232.43%120.00%
Benjamin Herrenschmidt513.51%240.00%
Paul Mackerras513.51%120.00%
Total37100.00%5100.00%

/* Determine if the linux irq is a timer */
static unsigned int mpic_is_tm(struct mpic *mpic, unsigned int src) { return (src >= mpic->timer_vecs[0] && src <= mpic->timer_vecs[7]); }

Contributors

PersonTokensPropCommitsCommitProp
Scott Wood3697.30%150.00%
Benjamin Herrenschmidt12.70%150.00%
Total37100.00%2100.00%

/* Convert a cpu mask from logical to physical cpu numbers. */
static inline u32 mpic_physmask(u32 cpumask) { int i; u32 mask = 0; for (i =