mips: octeon: final tweaks
cover mips: octeon: final tweaks
David,
I decided to move the state bits DISABLED, MASKED and INPROGRESS into irq_data status. I need that for some other cleanups as well.
I added the masked check to the disabled check in the affinity setters, so that should solve your problem hopefully.
Thanks,
tglx
.
PATCH 1/3 genirq: Move INPROGRESS, MASKED and DISABLED state flags to irq_data
We really need these flags for some of the interrupt chips. Move it from internal state to irq_data and provide proper accessors.
--- include/linux/irq.h | 17 +++++++++++++++-- kernel/irq/chip.c | 40 +++++++++++++++++++--------------------- kernel/irq/debug.h | 10 +++++++--- kernel/irq/handle.c | 4 ++-- kernel/irq/internals.h | 6 ------ kernel/irq/irqdesc.c | 2 -- kernel/irq/manage.c | 30 ++++++++++++++---------------- kernel/irq/migration.c | 4 ++-- kernel/irq/spurious.c | 10 +++++----- 9 files changed, 64 insertions(+), 59 deletions(-)
include/linux/irq.h +15 -2
@@ -174,8 +174,9 @@ struct irq_data {* from suspend * IRDQ_MOVE_PCNTXT - Interrupt can be moved in process * context -* IRQD_IRQ_DISABLED - Some chip function need to know the -* disabled state. +* IRQD_IRQ_DISABLED - Disabled state of the interrupt +* IRQD_IRQ_MASKED - Masked state of the interrupt +* IRQD_IRQ_INPROGRESS - In progress state of the interrupt */ enum {IRQD_TRIGGER_MASK =0xf ,
@@ -187,6 +188,8 @@ enum {IRQD_WAKEUP_STATE = (1 <<14 ),IRQD_MOVE_PCNTXT = (1 <<15 ),IRQD_IRQ_DISABLED = (1 <<16 ), +IRQD_IRQ_MASKED = (1 <<17 ), + IRQD_IRQ_INPROGRESS = (1 << 18), };static inline bool irqd_is_setaffinity_pending (struct irq_data *d)
@@ -243,6 +246,16 @@ static inline bool irqd_irq_disabled(strreturn d->state_use_accessors &IRQD_IRQ_DISABLED ; } +static inline bool irqd_irq_masked (struct irq_data *d) +{ +return d->state_use_accessors &IRQD_IRQ_MASKED ; +} + +static inline bool irqd_irq_inprogress (struct irq_data *d) +{ +return d->state_use_accessors &IRQD_IRQ_INPROGRESS ; +} +/** * struct irq_chip - hardware interrupt chip descriptor *
kernel/irq/chip.c +19 -21
@@ -140,27 +140,25 @@ EXPORT_SYMBOL_GPL(irq_get_irq_data);static void irq_state_clr_disabled (struct irq_desc *desc) { - desc->istate &= ~IRQS_DISABLED ;irqd_clear (&desc->irq_data,IRQD_IRQ_DISABLED );irq_compat_clr_disabled (desc); }static void irq_state_set_disabled (struct irq_desc *desc) { - desc->istate |=IRQS_DISABLED ;irqd_set (&desc->irq_data,IRQD_IRQ_DISABLED );irq_compat_set_disabled (desc); }static void irq_state_clr_masked (struct irq_desc *desc) { - desc->istate &= ~IRQS_MASKED ; +irqd_clear (&desc->irq_data,IRQD_IRQ_MASKED );irq_compat_clr_masked (desc); }static void irq_state_set_masked (struct irq_desc *desc) { - desc->istate |=IRQS_MASKED ; +irqd_set (&desc->irq_data,IRQD_IRQ_MASKED );irq_compat_set_masked (desc); }
@@ -380,11 +378,11 @@ void handle_nested_irq(unsigned int irq)kstat_incr_irqs_this_cpu (irq, desc); action = desc->action; -if (unlikely (!action || (desc->istate &IRQS_DISABLED ))) +if (unlikely (!action ||irqd_irq_disabled (&desc->irq_data))) goto out_unlock;irq_compat_set_progress (desc); - desc->istate |=IRQS_INPROGRESS ; +irqd_set (&desc->irq_data,IRQD_IRQ_INPROGRESS );raw_spin_unlock_irq (&desc->lock); action_ret = action->thread_fn (action->irq, action->dev_id);
@@ -392,7 +390,7 @@ void handle_nested_irq(unsigned int irq)note_interrupt (irq, desc, action_ret);raw_spin_lock_irq (&desc->lock); - desc->istate &= ~IRQS_INPROGRESS ; +irqd_clear (&desc->irq_data,IRQD_IRQ_INPROGRESS );irq_compat_clr_progress (desc); out_unlock:
@@ -424,14 +422,14 @@ handle_simple_irq(unsigned int irq, stru {raw_spin_lock (&desc->lock); -if (unlikely (desc->istate &IRQS_INPROGRESS )) +if (unlikely (irqd_irq_inprogress (&desc->irq_data)))if (!irq_check_poll (desc)) goto out_unlock; desc->istate &= ~(IRQS_REPLAY |IRQS_WAITING );kstat_incr_irqs_this_cpu (irq, desc); -if (unlikely (!desc->action || (desc->istate &IRQS_DISABLED ))) +if (unlikely (!desc->action ||irqd_irq_disabled (&desc->irq_data))) goto out_unlock;handle_irq_event (desc);
@@ -456,7 +454,7 @@ handle_level_irq(unsigned int irq, strucraw_spin_lock (&desc->lock);mask_ack_irq (desc); -if (unlikely (desc->istate &IRQS_INPROGRESS )) +if (unlikely (irqd_irq_inprogress (&desc->irq_data)))if (!irq_check_poll (desc)) goto out_unlock;
@@ -467,12 +465,12 @@ handle_level_irq(unsigned int irq, struc* If its disabled or no action available * keep it masked and get out of here */ -if (unlikely (!desc->action || (desc->istate &IRQS_DISABLED ))) +if (unlikely (!desc->action ||irqd_irq_disabled (&desc->irq_data))) goto out_unlock;handle_irq_event (desc); -if (!(desc->istate & (IRQS_DISABLED |IRQS_ONESHOT ))) +if (!irqd_irq_disabled (&desc->irq_data) && !(desc->istate &IRQS_ONESHOT ))unmask_irq (desc); out_unlock:raw_spin_unlock (&desc->lock);
@@ -504,7 +502,7 @@ handle_fasteoi_irq(unsigned int irq, str {raw_spin_lock (&desc->lock); -if (unlikely (desc->istate &IRQS_INPROGRESS )) +if (unlikely (irqd_irq_inprogress (&desc->irq_data)))if (!irq_check_poll (desc)) goto out;
@@ -515,7 +513,7 @@ handle_fasteoi_irq(unsigned int irq, str* If its disabled or no action available * then mask it and get out of here: */ -if (unlikely (!desc->action || (desc->istate &IRQS_DISABLED ))) { +if (unlikely (!desc->action ||irqd_irq_disabled (&desc->irq_data))) {irq_compat_set_pending (desc); desc->istate |=IRQS_PENDING ;mask_irq (desc);
@@ -566,8 +564,8 @@ handle_edge_irq(unsigned int irq, struct* we shouldn't process the IRQ. Mark it pending, handle * the necessary masking and go out */ -if (unlikely ((desc->istate & (IRQS_DISABLED |IRQS_INPROGRESS ) || - !desc->action))) { +if (unlikely (irqd_irq_disabled (&desc->irq_data) || +irqd_irq_inprogress (&desc->irq_data) || !desc->action)) {if (!irq_check_poll (desc)) {irq_compat_set_pending (desc); desc->istate |=IRQS_PENDING ;
@@ -592,15 +590,15 @@ handle_edge_irq(unsigned int irq, struct* Renable it, if it was not disabled in meantime. */ if (unlikely (desc->istate &IRQS_PENDING )) { -if (!(desc->istate &IRQS_DISABLED ) && - (desc->istate &IRQS_MASKED )) +if (!irqd_irq_disabled (&desc->irq_data) && +irqd_irq_masked (&desc->irq_data))unmask_irq (desc); }handle_irq_event (desc); }while ((desc->istate &IRQS_PENDING ) && - !(desc->istate &IRQS_DISABLED )); + !irqd_irq_disabled (&desc->irq_data)); out_unlock:raw_spin_unlock (&desc->lock);
@@ -720,7 +718,7 @@ void irq_cpu_online(void) chip =irq_data_get_irq_chip (&desc->irq_data);if (chip && chip->irq_cpu_online && (!(chip->flags &IRQCHIP_ONOFFLINE_ENABLED ) || - !(desc->istate &IRQS_DISABLED ))) + !irqd_irq_disabled (&desc->irq_data))) chip->irq_cpu_online (&desc->irq_data);raw_spin_unlock_irqrestore (&desc->lock, flags);
@@ -750,7 +748,7 @@ void irq_cpu_offline(void) chip =irq_data_get_irq_chip (&desc->irq_data);if (chip && chip->irq_cpu_offline && (!(chip->flags &IRQCHIP_ONOFFLINE_ENABLED ) || - !(desc->istate &IRQS_DISABLED ))) + !irqd_irq_disabled (&desc->irq_data))) chip->irq_cpu_offline (&desc->irq_data);raw_spin_unlock_irqrestore (&desc->lock, flags);
kernel/irq/debug.h +7 -3
@@ -6,6 +6,8 @@#define P (f) if (desc->status & f) printk("%14s set\n", #f)#define PS (f) if (desc->istate & f) printk("%14s set\n", #f) +/* FIXME */ +#define PD (f) do { } while (0)static inline void print_irq_desc (unsigned int irq,struct irq_desc *desc) {
@@ -28,13 +30,15 @@ static inline void print_irq_desc(unsignP (IRQ_NOAUTOEN );PS (IRQS_AUTODETECT ); -PS (IRQS_INPROGRESS );PS (IRQS_REPLAY );PS (IRQS_WAITING ); -PS (IRQS_DISABLED );PS (IRQS_PENDING ); -PS (IRQS_MASKED ); + +PD (IRQS_INPROGRESS ); +PD (IRQS_DISABLED ); +PD (IRQS_MASKED ); }#undef P#undef PS +#undef PD
kernel/irq/handle.c +2 -2
@@ -178,13 +178,13 @@ irqreturn_t handle_irq_event(struct irq_irq_compat_clr_pending (desc); desc->istate &= ~IRQS_PENDING ;irq_compat_set_progress (desc); - desc->istate |=IRQS_INPROGRESS ; +irqd_set (&desc->irq_data,IRQD_IRQ_INPROGRESS );raw_spin_unlock (&desc->lock); ret =handle_irq_event_percpu (desc, action);raw_spin_lock (&desc->lock); - desc->istate &= ~IRQS_INPROGRESS ; +irqd_clear (&desc->irq_data,IRQD_IRQ_INPROGRESS );irq_compat_clr_progress (desc);return ret; }
kernel/irq/internals.h +0 -6
@@ -44,26 +44,20 @@ enum {* IRQS_SPURIOUS_DISABLED - was disabled due to spurious interrupt * detection * IRQS_POLL_INPROGRESS - polling in progress -* IRQS_INPROGRESS - Interrupt in progress * IRQS_ONESHOT - irq is not unmasked in primary handler * IRQS_REPLAY - irq is replayed * IRQS_WAITING - irq is waiting -* IRQS_DISABLED - irq is disabled * IRQS_PENDING - irq is pending and replayed later -* IRQS_MASKED - irq is masked * IRQS_SUSPENDED - irq is suspended */ enum {IRQS_AUTODETECT =0x00000001 ,IRQS_SPURIOUS_DISABLED =0x00000002 ,IRQS_POLL_INPROGRESS =0x00000008 , -IRQS_INPROGRESS =0x00000010 ,IRQS_ONESHOT =0x00000020 ,IRQS_REPLAY =0x00000040 ,IRQS_WAITING =0x00000080 , -IRQS_DISABLED =0x00000100 ,IRQS_PENDING =0x00000200 , -IRQS_MASKED =0x00000400 ,IRQS_SUSPENDED =0x00000800 , };
kernel/irq/irqdesc.c +0 -2
@@ -81,7 +81,6 @@ static void desc_set_defaults(unsigned i desc->irq_data.msi_desc =NULL ;irq_settings_clr_and_set (desc, ~0 , _IRQ_DEFAULT_INIT_FLAGS);irqd_set (&desc->irq_data,IRQD_IRQ_DISABLED ); - desc->istate =IRQS_DISABLED ; desc->handle_irq = handle_bad_irq; desc->depth =1 ; desc->irq_count =0 ;
@@ -239,7 +238,6 @@ int __init early_irq_init(void) struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = { [0 ...NR_IRQS -1 ] = { - .istate =IRQS_DISABLED , .handle_irq = handle_bad_irq, .depth =1 , .lock =__RAW_SPIN_LOCK_UNLOCKED (irq_desc->lock),
kernel/irq/manage.c +14 -16
@@ -41,7 +41,7 @@ early_param("threadirqs", setup_forced_ivoid synchronize_irq (unsigned int irq) {struct irq_desc *desc =irq_to_desc (irq); -unsigned int state; +bool inprogress;if (!desc)return ;
@@ -53,16 +53,16 @@ void synchronize_irq(unsigned int irq)* Wait until we're out of the critical section. This might * give the wrong answer due to the lack of memory barriers. */ -while (desc->istate &IRQS_INPROGRESS ) +while (irqd_irq_inprogress (&desc->irq_data))cpu_relax ();/* Ok, that indicated we're done: double-check carefully. */ raw_spin_lock_irqsave (&desc->lock, flags); - state = desc->istate; + inprogress =irqd_irq_inprogress (&desc->irq_data);raw_spin_unlock_irqrestore (&desc->lock, flags);/* Oops, that failed? */ - }while (state &IRQS_INPROGRESS ); + }while (inprogress);/* * We made sure that no hardirq handler is running. Now verify
@@ -563,9 +563,9 @@ int __irq_set_trigger(struct irq_desc *d flags &=IRQ_TYPE_SENSE_MASK ;if (chip->flags &IRQCHIP_SET_TYPE_MASKED ) { -if (!(desc->istate &IRQS_MASKED )) +if (!irqd_irq_masked (&desc->irq_data))mask_irq (desc); -if (!(desc->istate &IRQS_DISABLED )) +if (!irqd_irq_disabled (&desc->irq_data)) unmask =1 ; }
@@ -663,7 +663,7 @@ again:* irq_wake_thread(). See the comment there which explains the * serialization. */ -if (unlikely (desc->istate &IRQS_INPROGRESS )) { +if (unlikely (irqd_irq_inprogress (&desc->irq_data))) {raw_spin_unlock_irq (&desc->lock);chip_bus_sync_unlock (desc);cpu_relax ();
@@ -680,12 +680,10 @@ again: desc->threads_oneshot &= ~action->thread_mask; -if (!desc->threads_oneshot && !(desc->istate &IRQS_DISABLED ) && - (desc->istate &IRQS_MASKED )) { -irq_compat_clr_masked (desc); - desc->istate &= ~IRQS_MASKED ; - desc->irq_data.chip->irq_unmask (&desc->irq_data); - } +if (!desc->threads_oneshot && !irqd_irq_disabled (&desc->irq_data) && +irqd_irq_masked (&desc->irq_data)) +unmask_irq (desc); + out_unlock:raw_spin_unlock_irq (&desc->lock);chip_bus_sync_unlock (desc);
@@ -779,7 +777,7 @@ static int irq_thread(void *data)atomic_inc (&desc->threads_active);raw_spin_lock_irq (&desc->lock); -if (unlikely (desc->istate &IRQS_DISABLED )) { +if (unlikely (irqd_irq_disabled (&desc->irq_data))) {/* * CHECKME: We might need a dedicated * IRQ_THREAD_PENDING flag here, which
@@ -997,8 +995,8 @@ __setup_irq(unsigned int irq, struct irq } desc->istate &= ~(IRQS_AUTODETECT |IRQS_SPURIOUS_DISABLED | \ -IRQS_INPROGRESS |IRQS_ONESHOT | \ -IRQS_WAITING ); +IRQS_ONESHOT |IRQS_WAITING ); +irqd_clear (&desc->irq_data,IRQD_IRQ_INPROGRESS );if (new->flags &IRQF_PERCPU ) {irqd_set (&desc->irq_data,IRQD_PER_CPU );
kernel/irq/migration.c +2 -2
@@ -66,7 +66,7 @@ void irq_move_irq(struct irq_data *idataif (likely (!irqd_is_setaffinity_pending (idata)))return ; -if (unlikely (desc->istate &IRQS_DISABLED )) +if (unlikely (irqd_irq_disabled (idata)))return ;/*
@@ -74,7 +74,7 @@ void irq_move_irq(struct irq_data *idata* threaded interrupt with ONESHOT set, we can end up with an * interrupt storm. */ - masked = desc->istate &IRQS_MASKED ; + masked =irqd_irq_masked (idata);if (!masked) idata->chip->irq_mask (idata);irq_move_masked_irq (idata);
kernel/irq/spurious.c +5 -5
@@ -45,12 +45,12 @@ bool irq_wait_for_poll(struct irq_desc * #ifdef CONFIG_SMP do { raw_spin_unlock(&desc->lock); -while (desc->istate &IRQS_INPROGRESS ) + while (irqd_irq_inprogress(&desc->irq_data)) cpu_relax(); raw_spin_lock(&desc->lock); - }while (desc->istate &IRQS_INPROGRESS ); + } while irqd_irq_inprogress(&desc->irq_data); /* Might have been disabled in meantime */ -return !(desc->istate &IRQS_DISABLED ) && desc->action; + return !irqd_irq_disabled(&desc->irq_data) && desc->action; #else return false; #endif
@@ -75,7 +75,7 @@ static int try_one_irq(int irq, struct i* Do not poll disabled interrupts unless the spurious * disabled poller asks explicitely. */ -if ((desc->istate &IRQS_DISABLED ) && !force) +if (irqd_irq_disabled (&desc->irq_data) && !force) goto out;/*
@@ -88,7 +88,7 @@ static int try_one_irq(int irq, struct i goto out;/* Already running on another processor */ -if (desc->istate &IRQS_INPROGRESS ) { +if (irqd_irq_inprogress (&desc->irq_data)) {/* * Already running: If it is shared get the other * CPU to go looking for our mystery interrupt too
PATCH 2/3 MIPS: Octeon: Rewrite interrupt handling code.
In reply to Thomas GleixnerFrom: David Daney <[email protected]>
This includes conversion to new style irq_chip functions, and correctly enabling/disabling per-CPU interrupts.
The hardware interrupt bit to irq number mapping is now done with a flexible map, instead of by bit twiddling the irq number.
[ tglx: Adjusted to new irq_cpu_on/offline callbacks and
__irq_set_affinity_lock ]
LKML-Reference: <[email protected]>
--- arch/mips/cavium-octeon/octeon-irq.c | 1410 ++++++++++++++----------- arch/mips/cavium-octeon/setup.c | 12 arch/mips/cavium-octeon/smp.c | 39 arch/mips/include/asm/mach-cavium-octeon/irq.h | 243 +--- arch/mips/include/asm/octeon/octeon.h | 2 arch/mips/pci/msi-octeon.c | 20 6 files changed, 915 insertions(+), 811 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +809 -601
@@ -3,10 +3,13 @@* License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 2004-2008, 2009, 2010 Cavium Networks +* Copyright (C) 2004-2008, 2009, 2010, 2011 Cavium Networks */ -#include <linux/irq.h> +#include <linux/interrupt.h> +#include <linux/bitops.h> +#include <linux/percpu.h> +#include <linux/irq.h> #include <linux/smp.h> #include <asm/octeon/octeon.h>
@@ -14,6 +17,47 @@static DEFINE_RAW_SPINLOCK (octeon_irq_ciu0_lock);static DEFINE_RAW_SPINLOCK (octeon_irq_ciu1_lock); +static DEFINE_PER_CPU(unsigned long, octeon_irq_ciu0_en_mirror); +static DEFINE_PER_CPU(unsigned long, octeon_irq_ciu1_en_mirror); + +static __read_mostly u8 octeon_irq_ciu_to_irq[8 ][64 ]; + +union octeon_ciu_chip_data { +void *p; +unsigned long l; +struct { +unsigned int line:6 ; +unsigned int bit:6 ; + } s; +}; + +struct octeon_core_chip_data { +struct mutex core_irq_mutex; +bool current_en; +bool desired_en; +u8 bit; +}; + +#define MIPS_CORE_IRQ_LINES 8 + +static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES ]; + +static void __init octeon_irq_set_ciu_mapping (int irq,int line,int bit, +struct irq_chip *chip, +irq_flow_handler_t handler) +{ +union octeon_ciu_chip_data cd; + +irq_set_chip_and_handler (irq, chip, handler); + + cd.l =0 ; + cd.s.line = line; + cd.s.bit = bit; + +irq_set_chip_data (irq, cd.p); + octeon_irq_ciu_to_irq[line][bit] = irq; +} +static int octeon_coreid_for_cpu (int cpu) {#ifdef CONFIG_SMP
@@ -23,9 +67,20 @@ static int octeon_coreid_for_cpu(int cpu#endif } -static void octeon_irq_core_ack (unsigned int irq) +static int octeon_cpu_for_coreid (int coreid) +{ +#ifdef CONFIG_SMP +return cpu_number_map (coreid); +#else +return smp_processor_id (); +#endif +} + +static void octeon_irq_core_ack (struct irq_data *data) { -unsigned int bit = irq -OCTEON_IRQ_SW0 ; +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); +unsigned int bit = cd->bit; +/* * We don't need to disable IRQs to make these atomic since * they are already disabled earlier in the low level
@@ -37,131 +92,133 @@ static void octeon_irq_core_ack(unsignedclear_c0_cause (0x100 << bit); } -static void octeon_irq_core_eoi (unsigned int irq) +static void octeon_irq_core_eoi (struct irq_data *data) { -struct irq_desc *desc =irq_to_desc (irq); -unsigned int bit = irq -OCTEON_IRQ_SW0 ; -/* -* If an IRQ is being processed while we are disabling it the -* handler will attempt to unmask the interrupt after it has -* been disabled. -*/ -if ((unlikely (desc->status &IRQ_DISABLED ))) -return ; +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); +/* * We don't need to disable IRQs to make these atomic since * they are already disabled earlier in the low level * interrupt code. */ -set_c0_status (0x100 << bit); +set_c0_status (0x100 << cd->bit); } -static void octeon_irq_core_enable (unsigned int irq) +static void octeon_irq_core_set_enable_local (void *arg) { -unsigned long flags; -unsigned int bit = irq -OCTEON_IRQ_SW0 ; +struct irq_data *data = arg; +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); +unsigned int mask =0x100 << cd->bit;/* -* We need to disable interrupts to make sure our updates are -* atomic. +* Interrupts are already disabled, so these are atomic. */ -local_irq_save (flags); -set_c0_status (0x100 << bit); -local_irq_restore (flags); +if (cd->desired_en) +set_c0_status (mask); +else +clear_c0_status (mask); + } -static void octeon_irq_core_disable_local (unsigned int irq) +static void octeon_irq_core_disable (struct irq_data *data) { -unsigned long flags; -unsigned int bit = irq -OCTEON_IRQ_SW0 ; -/* -* We need to disable interrupts to make sure our updates are -* atomic. -*/ -local_irq_save (flags); -clear_c0_status (0x100 << bit); -local_irq_restore (flags); +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); + cd->desired_en = false; } -static void octeon_irq_core_disable (unsigned int irq) +static void octeon_irq_core_enable (struct irq_data *data) { -#ifdef CONFIG_SMP -on_each_cpu ((void (*)(void *)) octeon_irq_core_disable_local, - (void *) (long ) irq,1 ); -#else -octeon_irq_core_disable_local (irq); -#endif +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); + cd->desired_en = true; } -static struct irq_chip octeon_irq_chip_core = { - .name ="Core" , - .enable = octeon_irq_core_enable, - .disable = octeon_irq_core_disable, - .ack = octeon_irq_core_ack, - .eoi = octeon_irq_core_eoi, -}; +static void octeon_irq_core_bus_lock (struct irq_data *data) +{ +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); +mutex_lock (&cd->core_irq_mutex); +} -static void octeon_irq_ciu0_ack (unsigned int irq) -{ -switch (irq) { -case OCTEON_IRQ_GMX_DRP0 : -case OCTEON_IRQ_GMX_DRP1 : -case OCTEON_IRQ_IPD_DRP : -case OCTEON_IRQ_KEY_ZERO : -case OCTEON_IRQ_TIMER0 : -case OCTEON_IRQ_TIMER1 : -case OCTEON_IRQ_TIMER2 : -case OCTEON_IRQ_TIMER3 : - { -int index =cvmx_get_core_num () *2 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); -/* -* CIU timer type interrupts must be acknoleged by -* writing a '1' bit to their sum0 bit. -*/ -cvmx_write_csr (CVMX_CIU_INTX_SUM0 (index), mask); -break ; - } -default : -break ; +static void octeon_irq_core_bus_sync_unlock (struct irq_data *data) +{ +struct octeon_core_chip_data *cd =irq_data_get_irq_chip_data (data); + +if (cd->desired_en != cd->current_en) { +on_each_cpu (octeon_irq_core_set_enable_local, data,1 ); + + cd->current_en = cd->desired_en; } -/* -* In order to avoid any locking accessing the CIU, we -* acknowledge CIU interrupts by disabling all of them. This -* way we can use a per core register and avoid any out of -* core locking requirements. This has the side affect that -* CIU interrupts can't be processed recursively. -* -* We don't need to disable IRQs to make these atomic since -* they are already disabled earlier in the low level -* interrupt code. -*/ -clear_c0_status (0x100 <<2 ); +mutex_unlock (&cd->core_irq_mutex); } -static void octeon_irq_ciu0_eoi (unsigned int irq) + +static void octeon_irq_core_cpu_online (struct irq_data *data) { -/* -* Enable all CIU interrupts again. We don't need to disable -* IRQs to make these atomic since they are already disabled -* earlier in the low level interrupt code. -*/ -set_c0_status (0x100 <<2 ); +if (irqd_irq_disabled (data)) +octeon_irq_core_eoi (data); +} + +static void octeon_irq_core_cpu_offline (struct irq_data *data) +{ +if (irqd_irq_disabled (data)) +octeon_irq_core_ack (data); +} + +static struct irq_chip octeon_irq_chip_core = { + .name ="Core" , + .irq_enable = octeon_irq_core_enable, + .irq_disable = octeon_irq_core_disable, + .irq_ack = octeon_irq_core_ack, + .irq_eoi = octeon_irq_core_eoi, + .irq_bus_lock = octeon_irq_core_bus_lock, + .irq_bus_sync_unlock = octeon_irq_core_bus_sync_unlock, + + .irq_cpu_online = octeon_irq_core_cpu_online, + .irq_cpu_offline = octeon_irq_core_cpu_offline, +}; + +static void __init octeon_irq_init_core (void ) +{ +int i; +int irq; +struct octeon_core_chip_data *cd; + +for (i =0 ; i <MIPS_CORE_IRQ_LINES ; i++) { + cd = &octeon_irq_core_chip_data[i]; + cd->current_en = false; + cd->desired_en = false; + cd->bit = i; +mutex_init (&cd->core_irq_mutex); + + irq =OCTEON_IRQ_SW0 + i; +switch (irq) { +case OCTEON_IRQ_TIMER : +case OCTEON_IRQ_SW0 : +case OCTEON_IRQ_SW1 : +case OCTEON_IRQ_5 : +case OCTEON_IRQ_PERF : +irq_set_chip_data (irq, cd); +irq_set_chip_and_handler (irq, &octeon_irq_chip_core, + handle_percpu_irq); +break ; +default : +break ; + } + } } -static int next_coreid_for_irq (struct irq_desc *desc) +static int next_cpu_for_irq (struct irq_data *data) {#ifdef CONFIG_SMP -int coreid; -int weight =cpumask_weight (desc->affinity); +int cpu; +int weight =cpumask_weight (data->affinity);if (weight >1 ) { -int cpu =smp_processor_id (); + cpu =smp_processor_id ();for (;;) { - cpu =cpumask_next (cpu, desc->affinity); + cpu =cpumask_next (cpu, data->affinity);if (cpu >= nr_cpu_ids) { cpu =-1 ;continue ;
@@ -169,83 +226,175 @@ static int next_coreid_for_irq(struct ir break; } } - coreid =octeon_coreid_for_cpu (cpu); }else if (weight ==1 ) { - coreid =octeon_coreid_for_cpu (cpumask_first (desc->affinity)); + cpu =cpumask_first (data->affinity); }else { - coreid =cvmx_get_core_num (); + cpu =smp_processor_id (); } -return coreid; +return cpu;#else -return cvmx_get_core_num (); +return smp_processor_id ();#endif } -static void octeon_irq_ciu0_enable (unsigned int irq) +static void octeon_irq_ciu_enable (struct irq_data *data) { -struct irq_desc *desc =irq_to_desc (irq); -int coreid =next_coreid_for_irq (desc); +int cpu =next_cpu_for_irq (data); +int coreid =octeon_coreid_for_cpu (cpu); +unsigned long *pen;unsigned long flags; -uint64_t en0; -int bit = irq -OCTEON_IRQ_WORKQ0 ;/* Bit 0-63 of EN0 */ +union octeon_ciu_chip_data cd; + + cd.p =irq_data_get_irq_chip_data (data); -raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); - en0 =cvmx_read_csr (CVMX_CIU_INTX_EN0 (coreid *2 )); - en0 |=1ull << bit; -cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), en0); -cvmx_read_csr (CVMX_CIU_INTX_EN0 (coreid *2 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); +if (cd.s.line ==0 ) { +raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); + pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu); +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), *pen); +raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); + }else { +raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); + pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu); +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), *pen); +raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); + } } -static void octeon_irq_ciu0_enable_mbox (unsigned int irq) +static void octeon_irq_ciu_enable_local (struct irq_data *data) { -int coreid =cvmx_get_core_num (); +unsigned long *pen;unsigned long flags; -uint64_t en0; -int bit = irq -OCTEON_IRQ_WORKQ0 ;/* Bit 0-63 of EN0 */ +union octeon_ciu_chip_data cd; + + cd.p =irq_data_get_irq_chip_data (data); -raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); - en0 =cvmx_read_csr (CVMX_CIU_INTX_EN0 (coreid *2 )); - en0 |=1ull << bit; -cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), en0); -cvmx_read_csr (CVMX_CIU_INTX_EN0 (coreid *2 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); +if (cd.s.line ==0 ) { +raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); + pen = &__get_cpu_var (octeon_irq_ciu0_en_mirror); +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0 (cvmx_get_core_num () *2 ), *pen); +raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); + }else { +raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); + pen = &__get_cpu_var (octeon_irq_ciu1_en_mirror); +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1 (cvmx_get_core_num () *2 +1 ), *pen); +raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); + } } -static void octeon_irq_ciu0_disable (unsigned int irq) +static void octeon_irq_ciu_disable_local (struct irq_data *data) { -int bit = irq -OCTEON_IRQ_WORKQ0 ;/* Bit 0-63 of EN0 */ +unsigned long *pen;unsigned long flags; -uint64_t en0; +union octeon_ciu_chip_data cd; + + cd.p =irq_data_get_irq_chip_data (data); + +if (cd.s.line ==0 ) { +raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); + pen = &__get_cpu_var (octeon_irq_ciu0_en_mirror); +clear_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0 (cvmx_get_core_num () *2 ), *pen); +raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); + }else { +raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); + pen = &__get_cpu_var (octeon_irq_ciu1_en_mirror); +clear_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1 (cvmx_get_core_num () *2 +1 ), *pen); +raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); + } +} + +static void octeon_irq_ciu_disable_all (struct irq_data *data) +{ +unsigned long flags; +unsigned long *pen;int cpu; -raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); -for_each_online_cpu (cpu) { -int coreid =octeon_coreid_for_cpu (cpu); - en0 =cvmx_read_csr (CVMX_CIU_INTX_EN0 (coreid *2 )); - en0 &= ~(1ull << bit); -cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), en0); +union octeon_ciu_chip_data cd; + +wmb ();/* Make sure flag changes arrive before register updates. */ + + cd.p =irq_data_get_irq_chip_data (data); + +if (cd.s.line ==0 ) { +raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); +for_each_online_cpu (cpu) { +int coreid =octeon_coreid_for_cpu (cpu); + pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu); +clear_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), *pen); + } +raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); + }else { +raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); +for_each_online_cpu (cpu) { +int coreid =octeon_coreid_for_cpu (cpu); + pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu); +clear_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), *pen); + } +raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); + } +} + +static void octeon_irq_ciu_enable_all (struct irq_data *data) +{ +unsigned long flags; +unsigned long *pen; +int cpu; +union octeon_ciu_chip_data cd; + + cd.p =irq_data_get_irq_chip_data (data); + +if (cd.s.line ==0 ) { +raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); +for_each_online_cpu (cpu) { +int coreid =octeon_coreid_for_cpu (cpu); + pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu); +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), *pen); + } +raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); + }else { +raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); +for_each_online_cpu (cpu) { +int coreid =octeon_coreid_for_cpu (cpu); + pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu); +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), *pen); + } +raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); } -/* -* We need to do a read after the last update to make sure all -* of them are done. -*/ -cvmx_read_csr (CVMX_CIU_INTX_EN0 (cvmx_get_core_num () *2 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); }/* * Enable the irq on the next core in the affinity set for chips that * have the EN*_W1{S,C} registers. */ -static void octeon_irq_ciu0_enable_v2 (unsigned int irq) +static void octeon_irq_ciu_enable_v2 (struct irq_data *data) { -int index; -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); -struct irq_desc *desc =irq_to_desc (irq); +u64 mask; +int cpu =next_cpu_for_irq (data); +union octeon_ciu_chip_data cd; -if ((desc->status &IRQ_DISABLED ) ==0 ) { - index =next_coreid_for_irq (desc) *2 ; + cd.p =irq_data_get_irq_chip_data (data); + mask =1ull << (cd.s.bit); + +/* +* Called under the desc lock, so these should never get out +* of sync. +*/ +if (cd.s.line ==0 ) { +int index =octeon_coreid_for_cpu (cpu) *2 ; +set_bit (cd.s.bit, &per_cpu (octeon_irq_ciu0_en_mirror, cpu));cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); + }else { +int index =octeon_coreid_for_cpu (cpu) *2 +1 ; +set_bit (cd.s.bit, &per_cpu (octeon_irq_ciu1_en_mirror, cpu)); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); } }
@@ -253,83 +402,180 @@ static void octeon_irq_ciu0_enable_v2(un* Enable the irq on the current CPU for chips that * have the EN*_W1{S,C} registers. */ -static void octeon_irq_ciu0_enable_mbox_v2 (unsigned int irq) +static void octeon_irq_ciu_enable_local_v2 (struct irq_data *data) { -int index; -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); +u64 mask; +union octeon_ciu_chip_data cd; - index =cvmx_get_core_num () *2 ; -cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); + cd.p =irq_data_get_irq_chip_data (data); + mask =1ull << (cd.s.bit); + +if (cd.s.line ==0 ) { +int index =cvmx_get_core_num () *2 ; +set_bit (cd.s.bit, &__get_cpu_var (octeon_irq_ciu0_en_mirror)); +cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); + }else { +int index =cvmx_get_core_num () *2 +1 ; +set_bit (cd.s.bit, &__get_cpu_var (octeon_irq_ciu1_en_mirror)); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); + } +} + +static void octeon_irq_ciu_disable_local_v2 (struct irq_data *data) +{ +u64 mask; +union octeon_ciu_chip_data cd; + + cd.p =irq_data_get_irq_chip_data (data); + mask =1ull << (cd.s.bit); + +if (cd.s.line ==0 ) { +int index =cvmx_get_core_num () *2 ; +clear_bit (cd.s.bit, &__get_cpu_var (octeon_irq_ciu0_en_mirror)); +cvmx_write_csr (CVMX_CIU_INTX_EN0_W1C (index), mask); + }else { +int index =cvmx_get_core_num () *2 +1 ; +clear_bit (cd.s.bit, &__get_cpu_var (octeon_irq_ciu1_en_mirror)); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1C (index), mask); + } }/* -* Disable the irq on the current core for chips that have the EN*_W1{S,C} -* registers. +* Write to the W1C bit in CVMX_CIU_INTX_SUM0 to clear the irq. */ -static void octeon_irq_ciu0_ack_v2 (unsigned int irq) +static void octeon_irq_ciu_ack (struct irq_data *data) { -int index =cvmx_get_core_num () *2 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); +u64 mask; +union octeon_ciu_chip_data cd; -switch (irq) { -case OCTEON_IRQ_GMX_DRP0 : -case OCTEON_IRQ_GMX_DRP1 : -case OCTEON_IRQ_IPD_DRP : -case OCTEON_IRQ_KEY_ZERO : -case OCTEON_IRQ_TIMER0 : -case OCTEON_IRQ_TIMER1 : -case OCTEON_IRQ_TIMER2 : -case OCTEON_IRQ_TIMER3 : -/* -* CIU timer type interrupts must be acknoleged by -* writing a '1' bit to their sum0 bit. -*/ + cd.p = data->chip_data; + mask =1ull << (cd.s.bit); + +if (cd.s.line ==0 ) { +int index =cvmx_get_core_num () *2 ;cvmx_write_csr (CVMX_CIU_INTX_SUM0 (index), mask); -break ; -default : -break ; + }else { +cvmx_write_csr (CVMX_CIU_INT_SUM1 , mask); } - -cvmx_write_csr (CVMX_CIU_INTX_EN0_W1C (index), mask); }/* -* Enable the irq on the current core for chips that have the EN*_W1{S,C} +* Disable the irq on the all cores for chips that have the EN*_W1{S,C} * registers. */ -static void octeon_irq_ciu0_eoi_mbox_v2 (unsigned int irq) +static void octeon_irq_ciu_disable_all_v2 (struct irq_data *data) { -struct irq_desc *desc =irq_to_desc (irq); -int index =cvmx_get_core_num () *2 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); +int cpu; +u64 mask; +union octeon_ciu_chip_data cd; -if (likely ((desc->status &IRQ_DISABLED ) ==0 )) -cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); +wmb ();/* Make sure flag changes arrive before register updates. */ + + cd.p = data->chip_data; + mask =1ull << (cd.s.bit); + +if (cd.s.line ==0 ) { +for_each_online_cpu (cpu) { +int index =octeon_coreid_for_cpu (cpu) *2 ; +clear_bit (cd.s.bit, &per_cpu (octeon_irq_ciu0_en_mirror, cpu)); +cvmx_write_csr (CVMX_CIU_INTX_EN0_W1C (index), mask); + } + }else { +for_each_online_cpu (cpu) { +int index =octeon_coreid_for_cpu (cpu) *2 +1 ; +clear_bit (cd.s.bit, &per_cpu (octeon_irq_ciu1_en_mirror, cpu)); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1C (index), mask); + } + } }/* -* Disable the irq on the all cores for chips that have the EN*_W1{S,C} +* Enable the irq on the all cores for chips that have the EN*_W1{S,C} * registers. */ -static void octeon_irq_ciu0_disable_all_v2 (unsigned int irq) +static void octeon_irq_ciu_enable_all_v2 (struct irq_data *data) { -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); -int index;int cpu; -for_each_online_cpu (cpu) { - index =octeon_coreid_for_cpu (cpu) *2 ; -cvmx_write_csr (CVMX_CIU_INTX_EN0_W1C (index), mask); +u64 mask; +union octeon_ciu_chip_data cd; + + cd.p = data->chip_data; + mask =1ull << (cd.s.bit); + +if (cd.s.line ==0 ) { +for_each_online_cpu (cpu) { +int index =octeon_coreid_for_cpu (cpu) *2 ; +set_bit (cd.s.bit, &per_cpu (octeon_irq_ciu0_en_mirror, cpu)); +cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); + } + }else { +for_each_online_cpu (cpu) { +int index =octeon_coreid_for_cpu (cpu) *2 +1 ; +set_bit (cd.s.bit, &per_cpu (octeon_irq_ciu1_en_mirror, cpu)); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); + } } } +static void octeon_irq_cpu_online_mbox (struct irq_data *data) +{ +if (irqd_irq_disabled (data)) +octeon_irq_ciu_enable_local (data); +} + +static void octeon_irq_cpu_online_mbox_v2 (struct irq_data *data) +{ +if (irqd_irq_disabled (data)) +octeon_irq_ciu_enable_local_v2 (data); +} + +static void octeon_irq_cpu_offline_mbox (struct irq_data *data) +{ +if (irqd_irq_disabled (data)) +octeon_irq_ciu_disable_local (data); +} + +static void octeon_irq_cpu_offline_mbox_v2 (struct irq_data *data) +{ +if (irqd_irq_disabled (data)) +octeon_irq_ciu_disable_local_v2 (data); +} +#ifdef CONFIG_SMP -static int octeon_irq_ciu0_set_affinity (unsigned int irq,const struct cpumask *dest) + +static void octeon_irq_cpu_offline_ciu (struct irq_data *data) +{ +int cpu =smp_processor_id (); +cpumask_t new_affinity; + +if (!cpumask_test_cpu (cpu, data->affinity)) +return ; + +if (cpumask_weight (data->affinity) >1 ) { +/* +* It has multi CPU affinity, just remove this CPU +* from the affinity set. +*/ +cpumask_copy (&new_affinity, data->affinity); +cpumask_clear_cpu (cpu, &new_affinity); + }else { +/* Otherwise, put it on lowest numbered online CPU. */ +cpumask_clear (&new_affinity); +cpumask_set_cpu (cpumask_first (cpu_online_mask), &new_affinity); + } +__irq_set_affinity_locked (data, &new_affinity); +} + +static int octeon_irq_ciu_set_affinity (struct irq_data *data, +const struct cpumask *dest,bool force) {int cpu; -struct irq_desc *desc =irq_to_desc (irq); +struct irq_desc *desc =irq_to_desc (data->irq);int enable_one = (desc->status &IRQ_DISABLED ) ==0 ;unsigned long flags; -int bit = irq -OCTEON_IRQ_WORKQ0 ;/* Bit 0-63 of EN0 */ +union octeon_ciu_chip_data cd; + + cd.p = data->chip_data;/* * For non-v2 CIU, we will allow only single CPU affinity.
@@ -339,26 +585,40 @@ static int octeon_irq_ciu0_set_affinity(if (cpumask_weight (dest) !=1 )return -EINVAL ; -raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); -for_each_online_cpu (cpu) { -int coreid =octeon_coreid_for_cpu (cpu); -uint64_t en0 = -cvmx_read_csr (CVMX_CIU_INTX_EN0 (coreid *2 )); -if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; - en0 |=1ull << bit; - }else { - en0 &= ~(1ull << bit); +if (desc->status &IRQ_DISABLED ) +return 0 ; + +if (cd.s.line ==0 ) { +raw_spin_lock_irqsave (&octeon_irq_ciu0_lock, flags); +for_each_online_cpu (cpu) { +int coreid =octeon_coreid_for_cpu (cpu); +unsigned long *pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu); + +if (cpumask_test_cpu (cpu, dest) && enable_one) { + enable_one =0 ; +set_bit (cd.s.bit, pen); + }else { +clear_bit (cd.s.bit, pen); + } +cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), *pen); + } +raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); + }else { +raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); +for_each_online_cpu (cpu) { +int coreid =octeon_coreid_for_cpu (cpu); +unsigned long *pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu); + +if (cpumask_test_cpu (cpu, dest) && enable_one) { + enable_one =0 ; +set_bit (cd.s.bit, pen); + }else { +clear_bit (cd.s.bit, pen); + } +cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), *pen); } -cvmx_write_csr (CVMX_CIU_INTX_EN0 (coreid *2 ), en0); +raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); } -/* -* We need to do a read after the last update to make sure all -* of them are done. -*/ -cvmx_read_csr (CVMX_CIU_INTX_EN0 (cvmx_get_core_num () *2 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu0_lock, flags); -return 0 ; }
@@ -366,22 +626,47 @@ static int octeon_irq_ciu0_set_affinity(* Set affinity for the irq for chips that have the EN*_W1{S,C} * registers. */ -static int octeon_irq_ciu0_set_affinity_v2 (unsigned int irq, -const struct cpumask *dest) +static int octeon_irq_ciu_set_affinity_v2 (struct irq_data *data, +const struct cpumask *dest, +bool force) {int cpu; -int index; -struct irq_desc *desc =irq_to_desc (irq); +struct irq_desc *desc =irq_to_desc (data->irq);int enable_one = (desc->status &IRQ_DISABLED ) ==0 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WORKQ0 ); +u64 mask; +union octeon_ciu_chip_data cd; -for_each_online_cpu (cpu) { - index =octeon_coreid_for_cpu (cpu) *2 ; -if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; -cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); - }else { -cvmx_write_csr (CVMX_CIU_INTX_EN0_W1C (index), mask); +if (desc->status &IRQ_DISABLED ) +return 0 ; + + cd.p = data->chip_data; + mask =1ull << cd.s.bit; + +if (cd.s.line ==0 ) { +for_each_online_cpu (cpu) { +unsigned long *pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu); +int index =octeon_coreid_for_cpu (cpu) *2 ; +if (cpumask_test_cpu (cpu, dest) && enable_one) { + enable_one =0 ; +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); + }else { +clear_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN0_W1C (index), mask); + } + } + }else { +for_each_online_cpu (cpu) { +unsigned long *pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu); +int index =octeon_coreid_for_cpu (cpu) *2 +1 ; +if (cpumask_test_cpu (cpu, dest) && enable_one) { + enable_one =0 ; +set_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); + }else { +clear_bit (cd.s.bit, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1C (index), mask); + } } }return 0 ;
@@ -389,80 +674,101 @@ static int octeon_irq_ciu0_set_affinity_#endif /* +* The v1 CIU code already masks things, so supply a dummy version to +* the core chip code. +*/ +static void octeon_irq_dummy_mask (struct irq_data *data) +{ +return ; +} + +/* * Newer octeon chips have support for lockless CIU operation. */ -static struct irq_chip octeon_irq_chip_ciu0_v2 = { - .name ="CIU0" , - .enable = octeon_irq_ciu0_enable_v2, - .disable = octeon_irq_ciu0_disable_all_v2, - .eoi = octeon_irq_ciu0_enable_v2, +static struct irq_chip octeon_irq_chip_ciu_v2 = { + .name ="CIU" , + .irq_enable = octeon_irq_ciu_enable_v2, + .irq_disable = octeon_irq_ciu_disable_all_v2, + .irq_mask = octeon_irq_ciu_disable_local_v2, + .irq_unmask = octeon_irq_ciu_enable_v2, #ifdef CONFIG_SMP - .set_affinity = octeon_irq_ciu0_set_affinity_v2, + .irq_set_affinity = octeon_irq_ciu_set_affinity_v2, + .irq_cpu_offline = octeon_irq_cpu_offline_ciu, #endif }; -static struct irq_chip octeon_irq_chip_ciu0 = { - .name ="CIU0" , - .enable = octeon_irq_ciu0_enable, - .disable = octeon_irq_ciu0_disable, - .eoi = octeon_irq_ciu0_eoi, +static struct irq_chip octeon_irq_chip_ciu_edge_v2 = { + .name ="CIU-E" , + .irq_enable = octeon_irq_ciu_enable_v2, + .irq_disable = octeon_irq_ciu_disable_all_v2, + .irq_ack = octeon_irq_ciu_ack, + .irq_mask = octeon_irq_ciu_disable_local_v2, + .irq_unmask = octeon_irq_ciu_enable_v2, #ifdef CONFIG_SMP - .set_affinity = octeon_irq_ciu0_set_affinity, + .irq_set_affinity = octeon_irq_ciu_set_affinity_v2, + .irq_cpu_offline = octeon_irq_cpu_offline_ciu, #endif }; -/* The mbox versions don't do any affinity or round-robin. */ -static struct irq_chip octeon_irq_chip_ciu0_mbox_v2 = { - .name ="CIU0-M" , - .enable = octeon_irq_ciu0_enable_mbox_v2, - .disable = octeon_irq_ciu0_disable, - .eoi = octeon_irq_ciu0_eoi_mbox_v2, +static struct irq_chip octeon_irq_chip_ciu = { + .name ="CIU" , + .irq_enable = octeon_irq_ciu_enable, + .irq_disable = octeon_irq_ciu_disable_all, + .irq_mask = octeon_irq_dummy_mask, +#ifdef CONFIG_SMP + .irq_set_affinity = octeon_irq_ciu_set_affinity, + .irq_cpu_offline = octeon_irq_cpu_offline_ciu, +#endif }; -static struct irq_chip octeon_irq_chip_ciu0_mbox = { - .name ="CIU0-M" , - .enable = octeon_irq_ciu0_enable_mbox, - .disable = octeon_irq_ciu0_disable, - .eoi = octeon_irq_ciu0_eoi, +static struct irq_chip octeon_irq_chip_ciu_edge = { + .name ="CIU-E" , + .irq_enable = octeon_irq_ciu_enable, + .irq_disable = octeon_irq_ciu_disable_all, + .irq_mask = octeon_irq_dummy_mask, + .irq_ack = octeon_irq_ciu_ack, +#ifdef CONFIG_SMP + .irq_set_affinity = octeon_irq_ciu_set_affinity, + .irq_cpu_offline = octeon_irq_cpu_offline_ciu, +#endif }; -static void octeon_irq_ciu1_ack (unsigned int irq) -{ -/* -* In order to avoid any locking accessing the CIU, we -* acknowledge CIU interrupts by disabling all of them. This -* way we can use a per core register and avoid any out of -* core locking requirements. This has the side affect that -* CIU interrupts can't be processed recursively. We don't -* need to disable IRQs to make these atomic since they are -* already disabled earlier in the low level interrupt code. -*/ -clear_c0_status (0x100 <<3 ); -} +/* The mbox versions don't do any affinity or round-robin. */ +static struct irq_chip octeon_irq_chip_ciu_mbox_v2 = { + .name ="CIU-M" , + .irq_enable = octeon_irq_ciu_enable_all_v2, + .irq_disable = octeon_irq_ciu_disable_all_v2, + .irq_ack = octeon_irq_ciu_disable_local_v2, + .irq_eoi = octeon_irq_ciu_enable_local_v2, -static void octeon_irq_ciu1_eoi (unsigned int irq) -{ -/* -* Enable all CIU interrupts again. We don't need to disable -* IRQs to make these atomic since they are already disabled -* earlier in the low level interrupt code. -*/ -set_c0_status (0x100 <<3 ); -} + .irq_cpu_online = octeon_irq_cpu_online_mbox_v2, + .irq_cpu_offline = octeon_irq_cpu_offline_mbox_v2, +}; + +static struct irq_chip octeon_irq_chip_ciu_mbox = { + .name ="CIU-M" , + .irq_enable = octeon_irq_ciu_enable_all, + .irq_disable = octeon_irq_ciu_disable_all, -static void octeon_irq_ciu1_enable (unsigned int irq) + .irq_cpu_online = octeon_irq_cpu_online_mbox, + .irq_cpu_offline = octeon_irq_cpu_offline_mbox, +}; + +/* +* Watchdog interrupts are special. They are associated with a single +* core, so we hardwire the affinity to that core. +*/ +static void octeon_irq_ciu_wd_enable (struct irq_data *data) { -struct irq_desc *desc =irq_to_desc (irq); -int coreid =next_coreid_for_irq (desc);unsigned long flags; -uint64_t en1; -int bit = irq -OCTEON_IRQ_WDOG0 ;/* Bit 0-63 of EN1 */ +unsigned long *pen; +int coreid = data->irq -OCTEON_IRQ_WDOG0 ;/* Bit 0-63 of EN1 */ +int cpu =octeon_cpu_for_coreid (coreid);raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); - en1 =cvmx_read_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 )); - en1 |=1ull << bit; -cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), en1); -cvmx_read_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 )); + pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu); +set_bit (coreid, pen); +cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), *pen);raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); }
@@ -470,286 +776,281 @@ static void octeon_irq_ciu1_enable(unsig* Watchdog interrupts are special. They are associated with a single * core, so we hardwire the affinity to that core. */ -static void octeon_irq_ciu1_wd_enable (unsigned int irq) +static void octeon_irq_ciu1_wd_enable_v2 (struct irq_data *data) { -unsigned long flags; -uint64_t en1; -int bit = irq -OCTEON_IRQ_WDOG0 ;/* Bit 0-63 of EN1 */ -int coreid = bit; +int coreid = data->irq -OCTEON_IRQ_WDOG0 ; +int cpu =octeon_cpu_for_coreid (coreid); -raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); - en1 =cvmx_read_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 )); - en1 |=1ull << bit; -cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), en1); -cvmx_read_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); +set_bit (coreid, &per_cpu (octeon_irq_ciu1_en_mirror, cpu)); +cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (coreid *2 +1 ),1ull << coreid); } -static void octeon_irq_ciu1_disable (unsigned int irq) + +static struct irq_chip octeon_irq_chip_ciu_wd_v2 = { + .name ="CIU-W" , + .irq_enable = octeon_irq_ciu1_wd_enable_v2, + .irq_disable = octeon_irq_ciu_disable_all_v2, + .irq_mask = octeon_irq_ciu_disable_local_v2, + .irq_unmask = octeon_irq_ciu_enable_local_v2, +}; + +static struct irq_chip octeon_irq_chip_ciu_wd = { + .name ="CIU-W" , + .irq_enable = octeon_irq_ciu_wd_enable, + .irq_disable = octeon_irq_ciu_disable_all, + .irq_mask = octeon_irq_dummy_mask, +}; + +static void octeon_irq_ip2_v1 (void ) { -int bit = irq -OCTEON_IRQ_WDOG0 ;/* Bit 0-63 of EN1 */ -unsigned long flags; -uint64_t en1; -int cpu; -raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); -for_each_online_cpu (cpu) { -int coreid =octeon_coreid_for_cpu (cpu); - en1 =cvmx_read_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 )); - en1 &= ~(1ull << bit); -cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), en1); +const unsigned long core_id =cvmx_get_core_num (); +u64 ciu_sum =cvmx_read_csr (CVMX_CIU_INTX_SUM0 (core_id *2 )); + + ciu_sum &=__get_cpu_var (octeon_irq_ciu0_en_mirror); +clear_c0_status (STATUSF_IP2 ); +if (likely (ciu_sum)) { +int bit =fls64 (ciu_sum) -1 ; +int irq = octeon_irq_ciu_to_irq[0 ][bit]; +if (likely (irq)) +do_IRQ (irq); +else +spurious_interrupt (); + }else { +spurious_interrupt (); } -/* -* We need to do a read after the last update to make sure all -* of them are done. -*/ -cvmx_read_csr (CVMX_CIU_INTX_EN1 (cvmx_get_core_num () *2 +1 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); +set_c0_status (STATUSF_IP2 ); } -/* -* Enable the irq on the current core for chips that have the EN*_W1{S,C} -* registers. -*/ -static void octeon_irq_ciu1_enable_v2 (unsigned int irq) +static void octeon_irq_ip2_v2 (void ) { -int index; -u64 mask =1ull << (irq -OCTEON_IRQ_WDOG0 ); -struct irq_desc *desc =irq_to_desc (irq); +const unsigned long core_id =cvmx_get_core_num (); +u64 ciu_sum =cvmx_read_csr (CVMX_CIU_INTX_SUM0 (core_id *2 )); -if ((desc->status &IRQ_DISABLED ) ==0 ) { - index =next_coreid_for_irq (desc) *2 +1 ; -cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); + ciu_sum &=__get_cpu_var (octeon_irq_ciu0_en_mirror); +if (likely (ciu_sum)) { +int bit =fls64 (ciu_sum) -1 ; +int irq = octeon_irq_ciu_to_irq[0 ][bit]; +if (likely (irq)) +do_IRQ (irq); +else +spurious_interrupt (); + }else { +spurious_interrupt (); } } - -/* -* Watchdog interrupts are special. They are associated with a single -* core, so we hardwire the affinity to that core. -*/ -static void octeon_irq_ciu1_wd_enable_v2 (unsigned int irq) +static void octeon_irq_ip3_v1 (void ) { -int index; -int coreid = irq -OCTEON_IRQ_WDOG0 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WDOG0 ); -struct irq_desc *desc =irq_to_desc (irq); +u64 ciu_sum =cvmx_read_csr (CVMX_CIU_INT_SUM1 ); -if ((desc->status &IRQ_DISABLED ) ==0 ) { - index = coreid *2 +1 ; -cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); + ciu_sum &=__get_cpu_var (octeon_irq_ciu1_en_mirror); +clear_c0_status (STATUSF_IP3 ); +if (likely (ciu_sum)) { +int bit =fls64 (ciu_sum) -1 ; +int irq = octeon_irq_ciu_to_irq[1 ][bit]; +if (likely (irq)) +do_IRQ (irq); +else +spurious_interrupt (); + }else { +spurious_interrupt (); } +set_c0_status (STATUSF_IP3 ); } -/* -* Disable the irq on the current core for chips that have the EN*_W1{S,C} -* registers. -*/ -static void octeon_irq_ciu1_ack_v2 (unsigned int irq) +static void octeon_irq_ip3_v2 (void ) { -int index =cvmx_get_core_num () *2 +1 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WDOG0 ); +u64 ciu_sum =cvmx_read_csr (CVMX_CIU_INT_SUM1 ); -cvmx_write_csr (CVMX_CIU_INTX_EN1_W1C (index), mask); + ciu_sum &=__get_cpu_var (octeon_irq_ciu1_en_mirror); +if (likely (ciu_sum)) { +int bit =fls64 (ciu_sum) -1 ; +int irq = octeon_irq_ciu_to_irq[1 ][bit]; +if (likely (irq)) +do_IRQ (irq); +else +spurious_interrupt (); + }else { +spurious_interrupt (); + } } -/* -* Disable the irq on the all cores for chips that have the EN*_W1{S,C} -* registers. -*/ -static void octeon_irq_ciu1_disable_all_v2 (unsigned int irq) +static void octeon_irq_ip4_mask (void ) { -u64 mask =1ull << (irq -OCTEON_IRQ_WDOG0 ); -int index; -int cpu; -for_each_online_cpu (cpu) { - index =octeon_coreid_for_cpu (cpu) *2 +1 ; -cvmx_write_csr (CVMX_CIU_INTX_EN1_W1C (index), mask); - } +clear_c0_status (STATUSF_IP4 ); +spurious_interrupt (); } -#ifdef CONFIG_SMP -static int octeon_irq_ciu1_set_affinity (unsigned int irq, -const struct cpumask *dest) +static void (*octeon_irq_ip2)(void ); +static void (*octeon_irq_ip3)(void ); +static void (*octeon_irq_ip4)(void ); + +void __cpuinitdata (*octeon_irq_setup_secondary)(void ); + +static void __cpuinit octeon_irq_percpu_enable (void ) { -int cpu; -struct irq_desc *desc =irq_to_desc (irq); -int enable_one = (desc->status &IRQ_DISABLED ) ==0 ; -unsigned long flags; -int bit = irq -OCTEON_IRQ_WDOG0 ;/* Bit 0-63 of EN1 */ +irq_cpu_online (); +} +static void __cpuinit octeon_irq_init_ciu_percpu (void ) +{ +int coreid =cvmx_get_core_num ();/* -* For non-v2 CIU, we will allow only single CPU affinity. -* This removes the need to do locking in the .ack/.eoi -* functions. +* Disable All CIU Interrupts. The ones we need will be +* enabled later. Read the SUM register so we know the write +* completed. */ -if (cpumask_weight (dest) !=1 ) -return -EINVAL ; +cvmx_write_csr (CVMX_CIU_INTX_EN0 ((coreid *2 )),0 ); +cvmx_write_csr (CVMX_CIU_INTX_EN0 ((coreid *2 +1 )),0 ); +cvmx_write_csr (CVMX_CIU_INTX_EN1 ((coreid *2 )),0 ); +cvmx_write_csr (CVMX_CIU_INTX_EN1 ((coreid *2 +1 )),0 ); +cvmx_read_csr (CVMX_CIU_INTX_SUM0 ((coreid *2 ))); +} -raw_spin_lock_irqsave (&octeon_irq_ciu1_lock, flags); -for_each_online_cpu (cpu) { -int coreid =octeon_coreid_for_cpu (cpu); -uint64_t en1 = -cvmx_read_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 )); -if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; - en1 |=1ull << bit; - }else { - en1 &= ~(1ull << bit); - } -cvmx_write_csr (CVMX_CIU_INTX_EN1 (coreid *2 +1 ), en1); - } -/* -* We need to do a read after the last update to make sure all -* of them are done. -*/ -cvmx_read_csr (CVMX_CIU_INTX_EN1 (cvmx_get_core_num () *2 +1 )); -raw_spin_unlock_irqrestore (&octeon_irq_ciu1_lock, flags); +static void __cpuinit octeon_irq_setup_secondary_ciu (void ) +{ -return 0 ; +__get_cpu_var (octeon_irq_ciu0_en_mirror) =0 ; +__get_cpu_var (octeon_irq_ciu1_en_mirror) =0 ; + +octeon_irq_init_ciu_percpu (); +octeon_irq_percpu_enable (); + +/* Enable the CIU lines */ +set_c0_status (STATUSF_IP3 |STATUSF_IP2 ); +clear_c0_status (STATUSF_IP4 ); } -/* -* Set affinity for the irq for chips that have the EN*_W1{S,C} -* registers. -*/ -static int octeon_irq_ciu1_set_affinity_v2 (unsigned int irq, -const struct cpumask *dest) +static void __init octeon_irq_init_ciu (void ) { -int cpu; -int index; -struct irq_desc *desc =irq_to_desc (irq); -int enable_one = (desc->status &IRQ_DISABLED ) ==0 ; -u64 mask =1ull << (irq -OCTEON_IRQ_WDOG0 ); -for_each_online_cpu (cpu) { - index =octeon_coreid_for_cpu (cpu) *2 +1 ; -if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; -cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); - }else { -cvmx_write_csr (CVMX_CIU_INTX_EN1_W1C (index), mask); - } - } -return 0 ; -} -#endif +unsigned int i; +struct irq_chip *chip; +struct irq_chip *chip_edge; +struct irq_chip *chip_mbox; +struct irq_chip *chip_wd; -/* -* Newer octeon chips have support for lockless CIU operation. -*/ -static struct irq_chip octeon_irq_chip_ciu1_v2 = { - .name ="CIU1" , - .enable = octeon_irq_ciu1_enable_v2, - .disable = octeon_irq_ciu1_disable_all_v2, - .eoi = octeon_irq_ciu1_enable_v2, -#ifdef CONFIG_SMP - .set_affinity = octeon_irq_ciu1_set_affinity_v2, -#endif -}; +octeon_irq_init_ciu_percpu (); + octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu; -static struct irq_chip octeon_irq_chip_ciu1 = { - .name ="CIU1" , - .enable = octeon_irq_ciu1_enable, - .disable = octeon_irq_ciu1_disable, - .eoi = octeon_irq_ciu1_eoi, -#ifdef CONFIG_SMP - .set_affinity = octeon_irq_ciu1_set_affinity, -#endif -}; +if (OCTEON_IS_MODEL (OCTEON_CN58XX_PASS2_X ) || +OCTEON_IS_MODEL (OCTEON_CN56XX_PASS2_X ) || +OCTEON_IS_MODEL (OCTEON_CN52XX_PASS2_X ) || +OCTEON_IS_MODEL (OCTEON_CN6XXX )) { + octeon_irq_ip2 = octeon_irq_ip2_v2; + octeon_irq_ip3 = octeon_irq_ip3_v2; + chip = &octeon_irq_chip_ciu_v2; + chip_edge = &octeon_irq_chip_ciu_edge_v2; + chip_mbox = &octeon_irq_chip_ciu_mbox_v2; + chip_wd = &octeon_irq_chip_ciu_wd_v2; + }else { + octeon_irq_ip2 = octeon_irq_ip2_v1; + octeon_irq_ip3 = octeon_irq_ip3_v1; + chip = &octeon_irq_chip_ciu; + chip_edge = &octeon_irq_chip_ciu_edge; + chip_mbox = &octeon_irq_chip_ciu_mbox; + chip_wd = &octeon_irq_chip_ciu_wd; + } + octeon_irq_ip4 = octeon_irq_ip4_mask; -static struct irq_chip octeon_irq_chip_ciu1_wd_v2 = { - .name ="CIU1-W" , - .enable = octeon_irq_ciu1_wd_enable_v2, - .disable = octeon_irq_ciu1_disable_all_v2, - .eoi = octeon_irq_ciu1_wd_enable_v2, -}; - -static struct irq_chip octeon_irq_chip_ciu1_wd = { - .name ="CIU1-W" , - .enable = octeon_irq_ciu1_wd_enable, - .disable = octeon_irq_ciu1_disable, - .eoi = octeon_irq_ciu1_eoi, -}; +/* Mips internal */ +octeon_irq_init_core (); -static void (*octeon_ciu0_ack)(unsigned int ); -static void (*octeon_ciu1_ack)(unsigned int ); +/* CIU_0 */ +for (i =0 ; i <16 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WORKQ0 ,0 , i +0 , chip, handle_level_irq); +for (i =0 ; i <16 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GPIO0 ,0 , i +16 , chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , chip_mbox, handle_percpu_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , chip_mbox, handle_percpu_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART0 ,0 ,34 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART1 ,0 ,35 , chip, handle_level_irq); + +for (i =0 ; i <4 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_INT0 ,0 , i +36 , chip, handle_level_irq); +for (i =0 ; i <4 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_MSI0 ,0 , i +40 , chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI ,0 ,45 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RML ,0 ,46 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TRACE0 ,0 ,47 , chip, handle_level_irq); + +for (i =0 ; i <2 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_GMX_DRP0 ,0 , i +48 , chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD_DRP ,0 ,50 , chip_edge, handle_edge_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY_ZERO ,0 ,51 , chip_edge, handle_edge_irq); + +for (i =0 ; i <4 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PCM ,0 ,57 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MPI ,0 ,58 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_POWIQ ,0 ,60 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPDPPTHR ,0 ,61 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , chip, handle_level_irq); + +/* CIU_1 */ +for (i =0 ; i <16 ; i++) +octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WDOG0 ,1 , i +0 , chip_wd, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII1 ,1 ,18 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_NAND ,1 ,19 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_MIO ,1 ,20 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IOB ,1 ,21 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_FPA ,1 ,22 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_POW ,1 ,23 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_L2C ,1 ,24 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_IPD ,1 ,25 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PIP ,1 ,26 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PKO ,1 ,27 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_ZIP ,1 ,28 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_TIM ,1 ,29 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RAD ,1 ,30 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_KEY ,1 ,31 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFA ,1 ,32 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_USBCTL ,1 ,33 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SLI ,1 ,34 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DPI ,1 ,35 , chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGX0 ,1 ,36 , chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_AGL ,1 ,46 , chip, handle_level_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PTP ,1 ,47 , chip_edge, handle_edge_irq); + +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM0 ,1 ,48 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_PEM1 ,1 ,49 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO0 ,1 ,50 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_SRIO1 ,1 ,51 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_LMC0 ,1 ,52 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_DFM ,1 ,56 , chip, handle_level_irq); +octeon_irq_set_ciu_mapping (OCTEON_IRQ_RST ,1 ,63 , chip, handle_level_irq); + +/* Enable the CIU lines */ +set_c0_status (STATUSF_IP3 |STATUSF_IP2 ); +clear_c0_status (STATUSF_IP4 ); +}void __init arch_init_irq (void ) { -unsigned int irq; -struct irq_chip *chip0; -struct irq_chip *chip0_mbox; -struct irq_chip *chip1; -struct irq_chip *chip1_wd; -#ifdef CONFIG_SMP /* Set the default affinity to the boot cpu. */ cpumask_clear (irq_default_affinity);cpumask_set_cpu (smp_processor_id (), irq_default_affinity);#endif - -if (NR_IRQS <OCTEON_IRQ_LAST ) -pr_err ("octeon_irq_init: NR_IRQS is set too low\n" ); - -if (OCTEON_IS_MODEL (OCTEON_CN58XX_PASS2_X ) || -OCTEON_IS_MODEL (OCTEON_CN56XX_PASS2_X ) || -OCTEON_IS_MODEL (OCTEON_CN52XX_PASS2_X )) { - octeon_ciu0_ack = octeon_irq_ciu0_ack_v2; - octeon_ciu1_ack = octeon_irq_ciu1_ack_v2; - chip0 = &octeon_irq_chip_ciu0_v2; - chip0_mbox = &octeon_irq_chip_ciu0_mbox_v2; - chip1 = &octeon_irq_chip_ciu1_v2; - chip1_wd = &octeon_irq_chip_ciu1_wd_v2; - }else { - octeon_ciu0_ack = octeon_irq_ciu0_ack; - octeon_ciu1_ack = octeon_irq_ciu1_ack; - chip0 = &octeon_irq_chip_ciu0; - chip0_mbox = &octeon_irq_chip_ciu0_mbox; - chip1 = &octeon_irq_chip_ciu1; - chip1_wd = &octeon_irq_chip_ciu1_wd; - } - -/* 0 - 15 reserved for i8259 master and slave controller. */ - -/* 17 - 23 Mips internal */ -for (irq =OCTEON_IRQ_SW0 ; irq <=OCTEON_IRQ_TIMER ; irq++) { -set_irq_chip_and_handler (irq, &octeon_irq_chip_core, - handle_percpu_irq); - } - -/* 24 - 87 CIU_INT_SUM0 */ -for (irq =OCTEON_IRQ_WORKQ0 ; irq <=OCTEON_IRQ_BOOTDMA ; irq++) { -switch (irq) { -case OCTEON_IRQ_MBOX0 : -case OCTEON_IRQ_MBOX1 : -set_irq_chip_and_handler (irq, chip0_mbox, handle_percpu_irq); -break ; -default : -set_irq_chip_and_handler (irq, chip0, handle_fasteoi_irq); -break ; - } - } - -/* 88 - 151 CIU_INT_SUM1 */ -for (irq =OCTEON_IRQ_WDOG0 ; irq <=OCTEON_IRQ_WDOG15 ; irq++) -set_irq_chip_and_handler (irq, chip1_wd, handle_fasteoi_irq); - -for (irq =OCTEON_IRQ_UART2 ; irq <=OCTEON_IRQ_RESERVED151 ; irq++) -set_irq_chip_and_handler (irq, chip1, handle_fasteoi_irq); - -set_c0_status (0x300 <<2 ); +octeon_irq_init_ciu (); } asmlinkage void plat_irq_dispatch(void) { -const unsigned long core_id =cvmx_get_core_num (); -const uint64_t ciu_sum0_address =CVMX_CIU_INTX_SUM0 (core_id *2 ); -const uint64_t ciu_en0_address =CVMX_CIU_INTX_EN0 (core_id *2 ); -const uint64_t ciu_sum1_address =CVMX_CIU_INT_SUM1 ; -const uint64_t ciu_en1_address =CVMX_CIU_INTX_EN1 (core_id *2 +1 );unsigned long cop0_cause;unsigned long cop0_status; -uint64_t ciu_en; -uint64_t ciu_sum; -unsigned int irq;while (1 ) { cop0_cause =read_c0_cause ();
@@ -757,33 +1058,16 @@ asmlinkage void plat_irq_dispatch(void) cop0_cause &= cop0_status; cop0_cause &=ST0_IM ; -if (unlikely (cop0_cause &STATUSF_IP2 )) { - ciu_sum =cvmx_read_csr (ciu_sum0_address); - ciu_en =cvmx_read_csr (ciu_en0_address); - ciu_sum &= ciu_en; -if (likely (ciu_sum)) { - irq =fls64 (ciu_sum) +OCTEON_IRQ_WORKQ0 -1 ; -octeon_ciu0_ack (irq); -do_IRQ (irq); - }else { -spurious_interrupt (); - } - }else if (unlikely (cop0_cause &STATUSF_IP3 )) { - ciu_sum =cvmx_read_csr (ciu_sum1_address); - ciu_en =cvmx_read_csr (ciu_en1_address); - ciu_sum &= ciu_en; -if (likely (ciu_sum)) { - irq =fls64 (ciu_sum) +OCTEON_IRQ_WDOG0 -1 ; -octeon_ciu1_ack (irq); -do_IRQ (irq); - }else { -spurious_interrupt (); - } - }else if (likely (cop0_cause)) { +if (unlikely (cop0_cause &STATUSF_IP2 )) +octeon_irq_ip2 (); +else if (unlikely (cop0_cause &STATUSF_IP3 )) +octeon_irq_ip3 (); +else if (unlikely (cop0_cause &STATUSF_IP4 )) +octeon_irq_ip4 (); +else if (likely (cop0_cause))do_IRQ (fls (cop0_cause) -9 +MIPS_CPU_IRQ_BASE ); - }else { +else break ; - } } }
@@ -791,83 +1075,7 @@ asmlinkage void plat_irq_dispatch(void)void fixup_irqs (void ) { -int irq; -struct irq_desc *desc; -cpumask_t new_affinity; -unsigned long flags; -int do_set_affinity; -int cpu; - - cpu =smp_processor_id (); - -for (irq =OCTEON_IRQ_SW0 ; irq <=OCTEON_IRQ_TIMER ; irq++) -octeon_irq_core_disable_local (irq); - -for (irq =OCTEON_IRQ_WORKQ0 ; irq <OCTEON_IRQ_LAST ; irq++) { - desc =irq_to_desc (irq); -switch (irq) { -case OCTEON_IRQ_MBOX0 : -case OCTEON_IRQ_MBOX1 : -/* The eoi function will disable them on this CPU. */ - desc->chip->eoi (irq); -break ; -case OCTEON_IRQ_WDOG0 : -case OCTEON_IRQ_WDOG1 : -case OCTEON_IRQ_WDOG2 : -case OCTEON_IRQ_WDOG3 : -case OCTEON_IRQ_WDOG4 : -case OCTEON_IRQ_WDOG5 : -case OCTEON_IRQ_WDOG6 : -case OCTEON_IRQ_WDOG7 : -case OCTEON_IRQ_WDOG8 : -case OCTEON_IRQ_WDOG9 : -case OCTEON_IRQ_WDOG10 : -case OCTEON_IRQ_WDOG11 : -case OCTEON_IRQ_WDOG12 : -case OCTEON_IRQ_WDOG13 : -case OCTEON_IRQ_WDOG14 : -case OCTEON_IRQ_WDOG15 : -/* -* These have special per CPU semantics and -* are handled in the watchdog driver. -*/ -break ; -default : -raw_spin_lock_irqsave (&desc->lock, flags); -/* -* If this irq has an action, it is in use and -* must be migrated if it has affinity to this -* cpu. -*/ -if (desc->action &&cpumask_test_cpu (cpu, desc->affinity)) { -if (cpumask_weight (desc->affinity) >1 ) { -/* -* It has multi CPU affinity, -* just remove this CPU from -* the affinity set. -*/ -cpumask_copy (&new_affinity, desc->affinity); -cpumask_clear_cpu (cpu, &new_affinity); - }else { -/* -* Otherwise, put it on lowest -* numbered online CPU. -*/ -cpumask_clear (&new_affinity); -cpumask_set_cpu (cpumask_first (cpu_online_mask), &new_affinity); - } - do_set_affinity =1 ; - }else { - do_set_affinity =0 ; - } -raw_spin_unlock_irqrestore (&desc->lock, flags); - -if (do_set_affinity) -irq_set_affinity (irq, &new_affinity); - -break ; - } - } +irq_cpu_offline (); }#endif /* CONFIG_HOTPLUG_CPU */
arch/mips/cavium-octeon/setup.c +0 -12
@@ -420,7 +420,6 @@ void octeon_user_io_init(void)void __init prom_init (void ) {struct cvmx_sysinfo *sysinfo; -const int coreid =cvmx_get_core_num ();int i;int argc;#ifdef CONFIG_CAVIUM_RESERVE32
@@ -537,17 +536,6 @@ void __init prom_init(void) octeon_uart =octeon_get_boot_uart (); -/* -* Disable All CIU Interrupts. The ones we need will be -* enabled later. Read the SUM register so we know the write -* completed. -*/ -cvmx_write_csr (CVMX_CIU_INTX_EN0 ((coreid *2 )),0 ); -cvmx_write_csr (CVMX_CIU_INTX_EN0 ((coreid *2 +1 )),0 ); -cvmx_write_csr (CVMX_CIU_INTX_EN1 ((coreid *2 )),0 ); -cvmx_write_csr (CVMX_CIU_INTX_EN1 ((coreid *2 +1 )),0 ); -cvmx_read_csr (CVMX_CIU_INTX_SUM0 ((coreid *2 ))); -#ifdef CONFIG_SMP octeon_write_lcd ("LinuxSMP" );#else
arch/mips/cavium-octeon/smp.c +13 -26
@@ -171,41 +171,19 @@ static void octeon_boot_secondary(int cp* After we've done initial boot, this function is called to allow the * board code to clean up state, if needed */ -static void octeon_init_secondary (void ) +static void __cpuinit octeon_init_secondary (void ) { -const int coreid =cvmx_get_core_num (); -union cvmx_ciu_intx_sum0 interrupt_enable;unsigned int sr; -#ifdef CONFIG_HOTPLUG_CPU -struct linux_app_boot_info *labi; - - labi = (struct linux_app_boot_info *)PHYS_TO_XKSEG_CACHED (LABI_ADDR_IN_BOOTLOADER ); - -if (labi->labi_signature !=LABI_SIGNATURE ) -panic ("The bootloader version on this board is incorrect." ); -#endif - sr =set_c0_status (ST0_BEV );write_c0_ebase ((u32 )ebase);write_c0_status (sr);octeon_check_cpu_bist ();octeon_init_cvmcount (); -/* -pr_info("SMP: CPU%d (CoreId %lu) started\n", cpu, coreid); -*/ -/* Enable Mailbox interrupts to this core. These are the only -interrupts allowed on line 3 */ -cvmx_write_csr (CVMX_CIU_MBOX_CLRX (coreid),0xffffffff ); - interrupt_enable.u64 =0 ; - interrupt_enable.s.mbox =0x3 ; -cvmx_write_csr (CVMX_CIU_INTX_EN0 ((coreid *2 )), interrupt_enable.u64); -cvmx_write_csr (CVMX_CIU_INTX_EN0 ((coreid *2 +1 )),0 ); -cvmx_write_csr (CVMX_CIU_INTX_EN1 ((coreid *2 )),0 ); -cvmx_write_csr (CVMX_CIU_INTX_EN1 ((coreid *2 +1 )),0 ); -/* Enable core interrupt processing for 2,3 and 7 */ -set_c0_status (0x8c01 ); + +octeon_irq_setup_secondary (); +raw_local_irq_enable (); }/**
@@ -214,6 +192,15 @@ static void octeon_init_secondary(void)*/ void octeon_prepare_cpus (unsigned int max_cpus) { +#ifdef CONFIG_HOTPLUG_CPU +struct linux_app_boot_info *labi; + + labi = (struct linux_app_boot_info *)PHYS_TO_XKSEG_CACHED (LABI_ADDR_IN_BOOTLOADER ); + +if (labi->labi_signature !=LABI_SIGNATURE ) +panic ("The bootloader version on this board is incorrect." ); +#endif +cvmx_write_csr (CVMX_CIU_MBOX_CLRX (cvmx_get_core_num ()),0xffffffff );if (request_irq (OCTEON_IRQ_MBOX0 , mailbox_interrupt,IRQF_DISABLED ,"mailbox0" , mailbox_interrupt)) {
arch/mips/include/asm/mach-cavium-octeon/irq.h +81 -162
253 lines not on this page · raw message
arch/mips/include/asm/octeon/octeon.h +2 -0
@@ -257,4 +257,6 @@ extern struct cvmx_bootinfo *octeon_bootextern uint64_t octeon_bootloader_entry_addr; +extern void (*octeon_irq_setup_secondary)(void ); +#endif /* __ASM_OCTEON_OCTEON_H */
arch/mips/pci/msi-octeon.c +10 -10
@@ -259,11 +259,11 @@ static DEFINE_RAW_SPINLOCK(octeon_irq_msstatic u64 msi_rcv_reg[4 ];static u64 mis_ena_reg[4 ]; -static void octeon_irq_msi_enable_pcie (unsigned int irq) +static void octeon_irq_msi_enable_pcie (struct irq_data *data) {u64 en;unsigned long flags; -int msi_number = irq -OCTEON_IRQ_MSI_BIT0 ; +int msi_number = data->irq -OCTEON_IRQ_MSI_BIT0 ;int irq_index = msi_number >>6 ;int irq_bit = msi_number &0x3f ;
@@ -275,11 +275,11 @@ static void octeon_irq_msi_enable_pcie(uraw_spin_unlock_irqrestore (&octeon_irq_msi_lock, flags); } -static void octeon_irq_msi_disable_pcie (unsigned int irq) +static void octeon_irq_msi_disable_pcie (struct irq_data *data) {u64 en;unsigned long flags; -int msi_number = irq -OCTEON_IRQ_MSI_BIT0 ; +int msi_number = data->irq -OCTEON_IRQ_MSI_BIT0 ;int irq_index = msi_number >>6 ;int irq_bit = msi_number &0x3f ;
@@ -293,11 +293,11 @@ static void octeon_irq_msi_disable_pcie(static struct irq_chip octeon_irq_chip_msi_pcie = { .name ="MSI" , - .enable = octeon_irq_msi_enable_pcie, - .disable = octeon_irq_msi_disable_pcie, + .irq_enable = octeon_irq_msi_enable_pcie, + .irq_disable = octeon_irq_msi_disable_pcie, }; -static void octeon_irq_msi_enable_pci (unsigned int irq) +static void octeon_irq_msi_enable_pci (struct irq_data *data) {/* * Octeon PCI doesn't have the ability to mask/unmask MSI
@@ -308,15 +308,15 @@ static void octeon_irq_msi_enable_pci(un*/ } -static void octeon_irq_msi_disable_pci (unsigned int irq) +static void octeon_irq_msi_disable_pci (struct irq_data *data) {/* See comment in enable */ }static struct irq_chip octeon_irq_chip_msi_pci = { .name ="MSI" , - .enable = octeon_irq_msi_enable_pci, - .disable = octeon_irq_msi_disable_pci, + .irq_enable = octeon_irq_msi_enable_pci, + .irq_disable = octeon_irq_msi_disable_pci, };/*
Re: [patch 2/3] MIPS: Octeon: Rewrite interrupt handling code.
Quoted 16 lines · Thomas Gleixner
From: David Daney<[email protected]>
This includes conversion to new style
irq_chipfunctions, and correctly enabling/disabling per-CPU interrupts.The hardware interrupt bit to irq number mapping is now done with a flexible map, instead of by bit twiddling the irq number.
[ tglx: Adjusted to new irq_cpu_on/offline callbacks and
__irq_set_affinity_lock]LKML-Reference:<[email protected]>
Signed-off-by Thomas Gleixner<[email protected]>
Quoted 9 lines
--- arch/mips/cavium-octeon/octeon-irq.c | 1410 ++++++++++++++----------- arch/mips/cavium-octeon/setup.c | 12 arch/mips/cavium-octeon/smp.c | 39 arch/mips/include/asm/mach-cavium-octeon/irq.h | 243 +--- arch/mips/include/asm/octeon/octeon.h | 2 arch/mips/pci/msi-octeon.c | 20 6 files changed, 915 insertions(+), 811 deletions(-)
Well tglx modified my patch slightly, but it still works. So this one is OK too.
David Daney
PATCH 3/3 MIPS: Octeon: Simplify irq_cpu_on/offline irq chip functions
In reply to Thomas GleixnerMake use of the IRQCHIP_ONOFFLINE_ENABLED flag and remove the wrappers. Use irqd_irq_disabled() instead of desc->status, which will go away.
--- arch/mips/cavium-octeon/octeon-irq.c | 71 ++++++++--------------------------- 1 file changed, 17 insertions(+), 54 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +17 -54
@@ -152,19 +152,6 @@ static void octeon_irq_core_bus_sync_unlmutex_unlock (&cd->core_irq_mutex); } - -static void octeon_irq_core_cpu_online (struct irq_data *data) -{ -if (irqd_irq_disabled (data)) -octeon_irq_core_eoi (data); -} - -static void octeon_irq_core_cpu_offline (struct irq_data *data) -{ -if (irqd_irq_disabled (data)) -octeon_irq_core_ack (data); -} -static struct irq_chip octeon_irq_chip_core = { .name ="Core" , .irq_enable = octeon_irq_core_enable,
@@ -174,8 +161,9 @@ static struct irq_chip octeon_irq_chip_c .irq_bus_lock = octeon_irq_core_bus_lock, .irq_bus_sync_unlock = octeon_irq_core_bus_sync_unlock, - .irq_cpu_online = octeon_irq_core_cpu_online, - .irq_cpu_offline = octeon_irq_core_cpu_offline, + .irq_cpu_online = octeon_irq_core_eoi, + .irq_cpu_offline = octeon_irq_core_ack, + .flags = IRQCHIP_ONOFFLINE_ENABLED, };static void __init octeon_irq_init_core (void )
@@ -517,30 +505,6 @@ static void octeon_irq_ciu_enable_all_v2 } } -static void octeon_irq_cpu_online_mbox (struct irq_data *data) -{ -if (irqd_irq_disabled (data)) -octeon_irq_ciu_enable_local (data); -} - -static void octeon_irq_cpu_online_mbox_v2 (struct irq_data *data) -{ -if (irqd_irq_disabled (data)) -octeon_irq_ciu_enable_local_v2 (data); -} - -static void octeon_irq_cpu_offline_mbox (struct irq_data *data) -{ -if (irqd_irq_disabled (data)) -octeon_irq_ciu_disable_local (data); -} - -static void octeon_irq_cpu_offline_mbox_v2 (struct irq_data *data) -{ -if (irqd_irq_disabled (data)) -octeon_irq_ciu_disable_local_v2 (data); -} -#ifdef CONFIG_SMP static void octeon_irq_cpu_offline_ciu (struct irq_data *data)
@@ -570,8 +534,7 @@ static int octeon_irq_ciu_set_affinity(s const struct cpumask *dest, bool force) { int cpu; -struct irq_desc *desc =irq_to_desc (data->irq); -int enable_one = (desc->status &IRQ_DISABLED ) ==0 ; +bool enable_one = !irqd_irq_disabled (data) && !irqd_irq_masked (data);unsigned long flags;union octeon_ciu_chip_data cd;
@@ -585,7 +548,7 @@ static int octeon_irq_ciu_set_affinity(sif (cpumask_weight (dest) !=1 )return -EINVAL ; -if (desc->status &IRQ_DISABLED ) +if (!enable_one)return 0 ;if (cd.s.line ==0 ) {
@@ -595,7 +558,7 @@ static int octeon_irq_ciu_set_affinity(sunsigned long *pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu);if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; + enable_one = false;set_bit (cd.s.bit, pen); }else {clear_bit (cd.s.bit, pen);
@@ -610,7 +573,7 @@ static int octeon_irq_ciu_set_affinity(sunsigned long *pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu);if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; + enable_one = false;set_bit (cd.s.bit, pen); }else {clear_bit (cd.s.bit, pen);
@@ -631,12 +594,11 @@ static int octeon_irq_ciu_set_affinity_v bool force) {int cpu; -struct irq_desc *desc =irq_to_desc (data->irq); -int enable_one = (desc->status &IRQ_DISABLED ) ==0 ; +bool enable_one = !irqd_irq_disabled (data) && !irqd_irq_masked (data);u64 mask;union octeon_ciu_chip_data cd; -if (desc->status &IRQ_DISABLED ) +if (!enable_one)return 0 ; cd.p = data->chip_data;
@@ -647,7 +609,7 @@ static int octeon_irq_ciu_set_affinity_vunsigned long *pen = &per_cpu (octeon_irq_ciu0_en_mirror, cpu);int index =octeon_coreid_for_cpu (cpu) *2 ;if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; + enable_one = false;set_bit (cd.s.bit, pen);cvmx_write_csr (CVMX_CIU_INTX_EN0_W1S (index), mask); }else {
@@ -660,7 +622,7 @@ static int octeon_irq_ciu_set_affinity_vunsigned long *pen = &per_cpu (octeon_irq_ciu1_en_mirror, cpu);int index =octeon_coreid_for_cpu (cpu) *2 +1 ;if (cpumask_test_cpu (cpu, dest) && enable_one) { - enable_one =0 ; + enable_one = false;set_bit (cd.s.bit, pen);cvmx_write_csr (CVMX_CIU_INTX_EN1_W1S (index), mask); }else {
@@ -679,7 +641,6 @@ static int octeon_irq_ciu_set_affinity_v*/ static void octeon_irq_dummy_mask (struct irq_data *data) { -return ; }/*
@@ -741,8 +702,9 @@ static struct irq_chip octeon_irq_chip_c .irq_ack = octeon_irq_ciu_disable_local_v2, .irq_eoi = octeon_irq_ciu_enable_local_v2, - .irq_cpu_online = octeon_irq_cpu_online_mbox_v2, - .irq_cpu_offline = octeon_irq_cpu_offline_mbox_v2, + .irq_cpu_online = octeon_irq_ciu_enable_local_v2, + .irq_cpu_offline = octeon_irq_ciu_disable_local_v2, + .flags = IRQCHIP_ONOFFLINE_ENABLED, };static struct irq_chip octeon_irq_chip_ciu_mbox = {
@@ -750,8 +712,9 @@ static struct irq_chip octeon_irq_chip_c .irq_enable = octeon_irq_ciu_enable_all, .irq_disable = octeon_irq_ciu_disable_all, - .irq_cpu_online = octeon_irq_cpu_online_mbox, - .irq_cpu_offline = octeon_irq_cpu_offline_mbox, + .irq_cpu_online = octeon_irq_ciu_enable_local, + .irq_cpu_offline = octeon_irq_ciu_disable_local, + .flags = IRQCHIP_ONOFFLINE_ENABLED, };/*
Re: [patch 3/3] MIPS: Octeon: Simplify irq_cpu_on/offline irq chip functions
Quoted 6 lines · Thomas Gleixner
Make use of the
IRQCHIP_ONOFFLINE_ENABLEDflag and remove the wrappers. Useirqd_irq_disabled()instead ofdesc->status, which will go away.Signed-off-by Thomas Gleixner<[email protected]>Cc David Daney<[email protected]>
Tested by: David Daney<[email protected]>
This seems good to me.
Quoted 4 lines
--- arch/mips/cavium-octeon/octeon-irq.c | 71 ++++++++--------------------------- 1 file changed, 17 insertions(+), 54 deletions(-)
.
.
.