12832a81dSGeoff Levand /* 22832a81dSGeoff Levand * PS3 interrupt routines. 32832a81dSGeoff Levand * 42832a81dSGeoff Levand * Copyright (C) 2006 Sony Computer Entertainment Inc. 52832a81dSGeoff Levand * Copyright 2006 Sony Corp. 62832a81dSGeoff Levand * 72832a81dSGeoff Levand * This program is free software; you can redistribute it and/or modify 82832a81dSGeoff Levand * it under the terms of the GNU General Public License as published by 92832a81dSGeoff Levand * the Free Software Foundation; version 2 of the License. 102832a81dSGeoff Levand * 112832a81dSGeoff Levand * This program is distributed in the hope that it will be useful, 122832a81dSGeoff Levand * but WITHOUT ANY WARRANTY; without even the implied warranty of 132832a81dSGeoff Levand * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 142832a81dSGeoff Levand * GNU General Public License for more details. 152832a81dSGeoff Levand * 162832a81dSGeoff Levand * You should have received a copy of the GNU General Public License 172832a81dSGeoff Levand * along with this program; if not, write to the Free Software 182832a81dSGeoff Levand * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 192832a81dSGeoff Levand */ 202832a81dSGeoff Levand 212832a81dSGeoff Levand #include <linux/kernel.h> 222832a81dSGeoff Levand #include <linux/module.h> 232832a81dSGeoff Levand #include <linux/irq.h> 242832a81dSGeoff Levand 252832a81dSGeoff Levand #include <asm/machdep.h> 262832a81dSGeoff Levand #include <asm/udbg.h> 272832a81dSGeoff Levand #include <asm/lv1call.h> 2842d284bcSStephen Rothwell #include <asm/smp.h> 292832a81dSGeoff Levand 302832a81dSGeoff Levand #include "platform.h" 312832a81dSGeoff Levand 322832a81dSGeoff Levand #if defined(DEBUG) 3383bb643dSGeert Uytterhoeven #define DBG udbg_printf 342832a81dSGeoff Levand #else 3583bb643dSGeert Uytterhoeven #define DBG pr_debug 362832a81dSGeoff Levand #endif 372832a81dSGeoff Levand 382832a81dSGeoff Levand /** 39861be32cSGeoff Levand * struct ps3_bmp - a per cpu irq status and mask bitmap structure 40861be32cSGeoff Levand * @status: 256 bit status bitmap indexed by plug 41861be32cSGeoff Levand * @unused_1: 42861be32cSGeoff Levand * @mask: 256 bit mask bitmap indexed by plug 43861be32cSGeoff Levand * @unused_2: 44861be32cSGeoff Levand * @lock: 45861be32cSGeoff Levand * @ipi_debug_brk_mask: 46861be32cSGeoff Levand * 47b595076aSUwe Kleine-König * The HV maintains per SMT thread mappings of HV outlet to HV plug on 48861be32cSGeoff Levand * behalf of the guest. These mappings are implemented as 256 bit guest 49861be32cSGeoff Levand * supplied bitmaps indexed by plug number. The addresses of the bitmaps 50861be32cSGeoff Levand * are registered with the HV through lv1_configure_irq_state_bitmap(). 5157715765SGeoff Levand * The HV requires that the 512 bits of status + mask not cross a page 5257715765SGeoff Levand * boundary. PS3_BMP_MINALIGN is used to define this minimal 64 byte 5357715765SGeoff Levand * alignment. 54861be32cSGeoff Levand * 55861be32cSGeoff Levand * The HV supports 256 plugs per thread, assigned as {0..255}, for a total 56861be32cSGeoff Levand * of 512 plugs supported on a processor. To simplify the logic this 57861be32cSGeoff Levand * implementation equates HV plug value to Linux virq value, constrains each 58861be32cSGeoff Levand * interrupt to have a system wide unique plug number, and limits the range 59861be32cSGeoff Levand * of the plug values to map into the first dword of the bitmaps. This 60861be32cSGeoff Levand * gives a usable range of plug values of {NUM_ISA_INTERRUPTS..63}. Note 61861be32cSGeoff Levand * that there is no constraint on how many in this set an individual thread 62861be32cSGeoff Levand * can acquire. 6346ca0d15SStephen Rothwell * 6446ca0d15SStephen Rothwell * The mask is declared as unsigned long so we can use set/clear_bit on it. 65861be32cSGeoff Levand */ 66861be32cSGeoff Levand 6757715765SGeoff Levand #define PS3_BMP_MINALIGN 64 6857715765SGeoff Levand 69861be32cSGeoff Levand struct ps3_bmp { 70861be32cSGeoff Levand struct { 71861be32cSGeoff Levand u64 status; 72861be32cSGeoff Levand u64 unused_1[3]; 7346ca0d15SStephen Rothwell unsigned long mask; 74861be32cSGeoff Levand u64 unused_2[3]; 75861be32cSGeoff Levand }; 76861be32cSGeoff Levand u64 ipi_debug_brk_mask; 77861be32cSGeoff Levand spinlock_t lock; 78861be32cSGeoff Levand }; 79861be32cSGeoff Levand 80861be32cSGeoff Levand /** 81861be32cSGeoff Levand * struct ps3_private - a per cpu data structure 82861be32cSGeoff Levand * @bmp: ps3_bmp structure 83aab83500SGeoff Levand * @ppe_id: HV logical_ppe_id 84aab83500SGeoff Levand * @thread_id: HV thread_id 85861be32cSGeoff Levand */ 86861be32cSGeoff Levand 87861be32cSGeoff Levand struct ps3_private { 8857715765SGeoff Levand struct ps3_bmp bmp __attribute__ ((aligned (PS3_BMP_MINALIGN))); 89aab83500SGeoff Levand u64 ppe_id; 90aab83500SGeoff Levand u64 thread_id; 91861be32cSGeoff Levand }; 92861be32cSGeoff Levand 93861be32cSGeoff Levand static DEFINE_PER_CPU(struct ps3_private, ps3_private); 94861be32cSGeoff Levand 95dc4f60c2SGeoff Levand /** 96743c1bb0SGeoff Levand * ps3_chip_mask - Set an interrupt mask bit in ps3_bmp. 97743c1bb0SGeoff Levand * @virq: The assigned Linux virq. 98743c1bb0SGeoff Levand * 99743c1bb0SGeoff Levand * Sets ps3_bmp.mask and calls lv1_did_update_interrupt_mask(). 100743c1bb0SGeoff Levand */ 101743c1bb0SGeoff Levand 102*8126708aSLennert Buytenhek static void ps3_chip_mask(struct irq_data *d) 103743c1bb0SGeoff Levand { 104*8126708aSLennert Buytenhek struct ps3_private *pd = irq_data_get_irq_chip_data(d); 105743c1bb0SGeoff Levand unsigned long flags; 106743c1bb0SGeoff Levand 1075c949070SStephen Rothwell pr_debug("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 108*8126708aSLennert Buytenhek pd->thread_id, d->irq); 109743c1bb0SGeoff Levand 110743c1bb0SGeoff Levand local_irq_save(flags); 111*8126708aSLennert Buytenhek clear_bit(63 - d->irq, &pd->bmp.mask); 112aab83500SGeoff Levand lv1_did_update_interrupt_mask(pd->ppe_id, pd->thread_id); 113743c1bb0SGeoff Levand local_irq_restore(flags); 114743c1bb0SGeoff Levand } 115743c1bb0SGeoff Levand 116743c1bb0SGeoff Levand /** 117743c1bb0SGeoff Levand * ps3_chip_unmask - Clear an interrupt mask bit in ps3_bmp. 118743c1bb0SGeoff Levand * @virq: The assigned Linux virq. 119743c1bb0SGeoff Levand * 120743c1bb0SGeoff Levand * Clears ps3_bmp.mask and calls lv1_did_update_interrupt_mask(). 121743c1bb0SGeoff Levand */ 122743c1bb0SGeoff Levand 123*8126708aSLennert Buytenhek static void ps3_chip_unmask(struct irq_data *d) 124743c1bb0SGeoff Levand { 125*8126708aSLennert Buytenhek struct ps3_private *pd = irq_data_get_irq_chip_data(d); 126743c1bb0SGeoff Levand unsigned long flags; 127743c1bb0SGeoff Levand 1285c949070SStephen Rothwell pr_debug("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 129*8126708aSLennert Buytenhek pd->thread_id, d->irq); 130743c1bb0SGeoff Levand 131743c1bb0SGeoff Levand local_irq_save(flags); 132*8126708aSLennert Buytenhek set_bit(63 - d->irq, &pd->bmp.mask); 133aab83500SGeoff Levand lv1_did_update_interrupt_mask(pd->ppe_id, pd->thread_id); 134743c1bb0SGeoff Levand local_irq_restore(flags); 135743c1bb0SGeoff Levand } 136743c1bb0SGeoff Levand 137743c1bb0SGeoff Levand /** 138743c1bb0SGeoff Levand * ps3_chip_eoi - HV end-of-interrupt. 139743c1bb0SGeoff Levand * @virq: The assigned Linux virq. 140743c1bb0SGeoff Levand * 141743c1bb0SGeoff Levand * Calls lv1_end_of_interrupt_ext(). 142743c1bb0SGeoff Levand */ 143743c1bb0SGeoff Levand 144*8126708aSLennert Buytenhek static void ps3_chip_eoi(struct irq_data *d) 145743c1bb0SGeoff Levand { 146*8126708aSLennert Buytenhek const struct ps3_private *pd = irq_data_get_irq_chip_data(d); 147*8126708aSLennert Buytenhek lv1_end_of_interrupt_ext(pd->ppe_id, pd->thread_id, d->irq); 148743c1bb0SGeoff Levand } 149743c1bb0SGeoff Levand 150743c1bb0SGeoff Levand /** 151743c1bb0SGeoff Levand * ps3_irq_chip - Represents the ps3_bmp as a Linux struct irq_chip. 152743c1bb0SGeoff Levand */ 153743c1bb0SGeoff Levand 154743c1bb0SGeoff Levand static struct irq_chip ps3_irq_chip = { 155b27df672SThomas Gleixner .name = "ps3", 156*8126708aSLennert Buytenhek .irq_mask = ps3_chip_mask, 157*8126708aSLennert Buytenhek .irq_unmask = ps3_chip_unmask, 158*8126708aSLennert Buytenhek .irq_eoi = ps3_chip_eoi, 159743c1bb0SGeoff Levand }; 160743c1bb0SGeoff Levand 161743c1bb0SGeoff Levand /** 162dc4f60c2SGeoff Levand * ps3_virq_setup - virq related setup. 163dc4f60c2SGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 164dc4f60c2SGeoff Levand * serviced on. 165dc4f60c2SGeoff Levand * @outlet: The HV outlet from the various create outlet routines. 166dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 167dc4f60c2SGeoff Levand * 168dc4f60c2SGeoff Levand * Calls irq_create_mapping() to get a virq and sets the chip data to 169dc4f60c2SGeoff Levand * ps3_private data. 170dc4f60c2SGeoff Levand */ 171dc4f60c2SGeoff Levand 172fdedb4caSGeert Uytterhoeven static int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet, 173861be32cSGeoff Levand unsigned int *virq) 174861be32cSGeoff Levand { 175861be32cSGeoff Levand int result; 176861be32cSGeoff Levand struct ps3_private *pd; 177861be32cSGeoff Levand 178861be32cSGeoff Levand /* This defines the default interrupt distribution policy. */ 179861be32cSGeoff Levand 180861be32cSGeoff Levand if (cpu == PS3_BINDING_CPU_ANY) 181861be32cSGeoff Levand cpu = 0; 182861be32cSGeoff Levand 183861be32cSGeoff Levand pd = &per_cpu(ps3_private, cpu); 184861be32cSGeoff Levand 185861be32cSGeoff Levand *virq = irq_create_mapping(NULL, outlet); 186861be32cSGeoff Levand 187861be32cSGeoff Levand if (*virq == NO_IRQ) { 188861be32cSGeoff Levand pr_debug("%s:%d: irq_create_mapping failed: outlet %lu\n", 189861be32cSGeoff Levand __func__, __LINE__, outlet); 190861be32cSGeoff Levand result = -ENOMEM; 191861be32cSGeoff Levand goto fail_create; 192861be32cSGeoff Levand } 193861be32cSGeoff Levand 194861be32cSGeoff Levand pr_debug("%s:%d: outlet %lu => cpu %u, virq %u\n", __func__, __LINE__, 195861be32cSGeoff Levand outlet, cpu, *virq); 196861be32cSGeoff Levand 197861be32cSGeoff Levand result = set_irq_chip_data(*virq, pd); 198861be32cSGeoff Levand 199861be32cSGeoff Levand if (result) { 200861be32cSGeoff Levand pr_debug("%s:%d: set_irq_chip_data failed\n", 201861be32cSGeoff Levand __func__, __LINE__); 202861be32cSGeoff Levand goto fail_set; 203861be32cSGeoff Levand } 204861be32cSGeoff Levand 205*8126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(*virq)); 2069263e85aSGeoff Levand 207861be32cSGeoff Levand return result; 208861be32cSGeoff Levand 209861be32cSGeoff Levand fail_set: 210861be32cSGeoff Levand irq_dispose_mapping(*virq); 211861be32cSGeoff Levand fail_create: 212861be32cSGeoff Levand return result; 213861be32cSGeoff Levand } 214861be32cSGeoff Levand 215dc4f60c2SGeoff Levand /** 216dc4f60c2SGeoff Levand * ps3_virq_destroy - virq related teardown. 217dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 218dc4f60c2SGeoff Levand * 219dc4f60c2SGeoff Levand * Clears chip data and calls irq_dispose_mapping() for the virq. 220dc4f60c2SGeoff Levand */ 221dc4f60c2SGeoff Levand 222fdedb4caSGeert Uytterhoeven static int ps3_virq_destroy(unsigned int virq) 223dc4f60c2SGeoff Levand { 224dc4f60c2SGeoff Levand const struct ps3_private *pd = get_irq_chip_data(virq); 225dc4f60c2SGeoff Levand 2265c949070SStephen Rothwell pr_debug("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 227aab83500SGeoff Levand __LINE__, pd->ppe_id, pd->thread_id, virq); 228dc4f60c2SGeoff Levand 229dc4f60c2SGeoff Levand set_irq_chip_data(virq, NULL); 230dc4f60c2SGeoff Levand irq_dispose_mapping(virq); 231dc4f60c2SGeoff Levand 232dc4f60c2SGeoff Levand pr_debug("%s:%d <-\n", __func__, __LINE__); 233dc4f60c2SGeoff Levand return 0; 234dc4f60c2SGeoff Levand } 235dc4f60c2SGeoff Levand 236dc4f60c2SGeoff Levand /** 237dc4f60c2SGeoff Levand * ps3_irq_plug_setup - Generic outlet and virq related setup. 238dc4f60c2SGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 239dc4f60c2SGeoff Levand * serviced on. 240dc4f60c2SGeoff Levand * @outlet: The HV outlet from the various create outlet routines. 241dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 242dc4f60c2SGeoff Levand * 243dc4f60c2SGeoff Levand * Sets up virq and connects the irq plug. 244dc4f60c2SGeoff Levand */ 245dc4f60c2SGeoff Levand 246dc4f60c2SGeoff Levand int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet, 247dc4f60c2SGeoff Levand unsigned int *virq) 248dc4f60c2SGeoff Levand { 249dc4f60c2SGeoff Levand int result; 250dc4f60c2SGeoff Levand struct ps3_private *pd; 251dc4f60c2SGeoff Levand 252dc4f60c2SGeoff Levand result = ps3_virq_setup(cpu, outlet, virq); 253dc4f60c2SGeoff Levand 254dc4f60c2SGeoff Levand if (result) { 255dc4f60c2SGeoff Levand pr_debug("%s:%d: ps3_virq_setup failed\n", __func__, __LINE__); 256dc4f60c2SGeoff Levand goto fail_setup; 257dc4f60c2SGeoff Levand } 258dc4f60c2SGeoff Levand 259dc4f60c2SGeoff Levand pd = get_irq_chip_data(*virq); 260dc4f60c2SGeoff Levand 261dc4f60c2SGeoff Levand /* Binds outlet to cpu + virq. */ 262dc4f60c2SGeoff Levand 263aab83500SGeoff Levand result = lv1_connect_irq_plug_ext(pd->ppe_id, pd->thread_id, *virq, 264aab83500SGeoff Levand outlet, 0); 265dc4f60c2SGeoff Levand 266dc4f60c2SGeoff Levand if (result) { 267dc4f60c2SGeoff Levand pr_info("%s:%d: lv1_connect_irq_plug_ext failed: %s\n", 268dc4f60c2SGeoff Levand __func__, __LINE__, ps3_result(result)); 269dc4f60c2SGeoff Levand result = -EPERM; 270dc4f60c2SGeoff Levand goto fail_connect; 271dc4f60c2SGeoff Levand } 272dc4f60c2SGeoff Levand 273dc4f60c2SGeoff Levand return result; 274dc4f60c2SGeoff Levand 275dc4f60c2SGeoff Levand fail_connect: 276dc4f60c2SGeoff Levand ps3_virq_destroy(*virq); 277dc4f60c2SGeoff Levand fail_setup: 278dc4f60c2SGeoff Levand return result; 279dc4f60c2SGeoff Levand } 280dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_irq_plug_setup); 281dc4f60c2SGeoff Levand 282dc4f60c2SGeoff Levand /** 283dc4f60c2SGeoff Levand * ps3_irq_plug_destroy - Generic outlet and virq related teardown. 284dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 285dc4f60c2SGeoff Levand * 286dc4f60c2SGeoff Levand * Disconnects the irq plug and tears down virq. 287dc4f60c2SGeoff Levand * Do not call for system bus event interrupts setup with 288dc4f60c2SGeoff Levand * ps3_sb_event_receive_port_setup(). 289dc4f60c2SGeoff Levand */ 290dc4f60c2SGeoff Levand 291dc4f60c2SGeoff Levand int ps3_irq_plug_destroy(unsigned int virq) 292861be32cSGeoff Levand { 293861be32cSGeoff Levand int result; 294861be32cSGeoff Levand const struct ps3_private *pd = get_irq_chip_data(virq); 295861be32cSGeoff Levand 2965c949070SStephen Rothwell pr_debug("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 297aab83500SGeoff Levand __LINE__, pd->ppe_id, pd->thread_id, virq); 298861be32cSGeoff Levand 299*8126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 3009263e85aSGeoff Levand 301aab83500SGeoff Levand result = lv1_disconnect_irq_plug_ext(pd->ppe_id, pd->thread_id, virq); 302861be32cSGeoff Levand 303861be32cSGeoff Levand if (result) 304861be32cSGeoff Levand pr_info("%s:%d: lv1_disconnect_irq_plug_ext failed: %s\n", 305861be32cSGeoff Levand __func__, __LINE__, ps3_result(result)); 306861be32cSGeoff Levand 307dc4f60c2SGeoff Levand ps3_virq_destroy(virq); 308dc4f60c2SGeoff Levand 309b1eeb38eSGeert Uytterhoeven return result; 310861be32cSGeoff Levand } 311dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_irq_plug_destroy); 312861be32cSGeoff Levand 313861be32cSGeoff Levand /** 314dc4f60c2SGeoff Levand * ps3_event_receive_port_setup - Setup an event receive port. 315861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 316861be32cSGeoff Levand * serviced on. 3172832a81dSGeoff Levand * @virq: The assigned Linux virq. 3182832a81dSGeoff Levand * 3192832a81dSGeoff Levand * The virq can be used with lv1_connect_interrupt_event_receive_port() to 320dc4f60c2SGeoff Levand * arrange to receive interrupts from system-bus devices, or with 321dc4f60c2SGeoff Levand * ps3_send_event_locally() to signal events. 3222832a81dSGeoff Levand */ 3232832a81dSGeoff Levand 324dc4f60c2SGeoff Levand int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq) 3252832a81dSGeoff Levand { 3262832a81dSGeoff Levand int result; 327b17b3df1SStephen Rothwell u64 outlet; 3282832a81dSGeoff Levand 3292832a81dSGeoff Levand result = lv1_construct_event_receive_port(&outlet); 3302832a81dSGeoff Levand 3312832a81dSGeoff Levand if (result) { 3322832a81dSGeoff Levand pr_debug("%s:%d: lv1_construct_event_receive_port failed: %s\n", 3332832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 3342832a81dSGeoff Levand *virq = NO_IRQ; 3352832a81dSGeoff Levand return result; 3362832a81dSGeoff Levand } 3372832a81dSGeoff Levand 338dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 339861be32cSGeoff Levand BUG_ON(result); 3402832a81dSGeoff Levand 341861be32cSGeoff Levand return result; 3422832a81dSGeoff Levand } 343dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_event_receive_port_setup); 3442832a81dSGeoff Levand 345dc4f60c2SGeoff Levand /** 346dc4f60c2SGeoff Levand * ps3_event_receive_port_destroy - Destroy an event receive port. 347dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 348dc4f60c2SGeoff Levand * 349dc4f60c2SGeoff Levand * Since ps3_event_receive_port_destroy destroys the receive port outlet, 350dc4f60c2SGeoff Levand * SB devices need to call disconnect_interrupt_event_receive_port() before 351dc4f60c2SGeoff Levand * this. 352dc4f60c2SGeoff Levand */ 353dc4f60c2SGeoff Levand 354dc4f60c2SGeoff Levand int ps3_event_receive_port_destroy(unsigned int virq) 3552832a81dSGeoff Levand { 3562832a81dSGeoff Levand int result; 3572832a81dSGeoff Levand 3589263e85aSGeoff Levand pr_debug(" -> %s:%d virq %u\n", __func__, __LINE__, virq); 3599263e85aSGeoff Levand 360*8126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 3612832a81dSGeoff Levand 3622832a81dSGeoff Levand result = lv1_destruct_event_receive_port(virq_to_hw(virq)); 3632832a81dSGeoff Levand 3642832a81dSGeoff Levand if (result) 3652832a81dSGeoff Levand pr_debug("%s:%d: lv1_destruct_event_receive_port failed: %s\n", 3662832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 3672832a81dSGeoff Levand 3689263e85aSGeoff Levand /* 3699263e85aSGeoff Levand * Don't call ps3_virq_destroy() here since ps3_smp_cleanup_cpu() 3709263e85aSGeoff Levand * calls from interrupt context (smp_call_function) when kexecing. 371dc4f60c2SGeoff Levand */ 372dc4f60c2SGeoff Levand 3732832a81dSGeoff Levand pr_debug(" <- %s:%d\n", __func__, __LINE__); 3742832a81dSGeoff Levand return result; 3752832a81dSGeoff Levand } 3762832a81dSGeoff Levand 3772832a81dSGeoff Levand int ps3_send_event_locally(unsigned int virq) 3782832a81dSGeoff Levand { 3792832a81dSGeoff Levand return lv1_send_event_locally(virq_to_hw(virq)); 3802832a81dSGeoff Levand } 3812832a81dSGeoff Levand 3822832a81dSGeoff Levand /** 383dc4f60c2SGeoff Levand * ps3_sb_event_receive_port_setup - Setup a system bus event receive port. 384861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 385861be32cSGeoff Levand * serviced on. 3866bb5cf10SGeoff Levand * @dev: The system bus device instance. 3872832a81dSGeoff Levand * @virq: The assigned Linux virq. 3882832a81dSGeoff Levand * 3892832a81dSGeoff Levand * An event irq represents a virtual device interrupt. The interrupt_id 3902832a81dSGeoff Levand * coresponds to the software interrupt number. 3912832a81dSGeoff Levand */ 3922832a81dSGeoff Levand 3936bb5cf10SGeoff Levand int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev, 3946bb5cf10SGeoff Levand enum ps3_cpu_binding cpu, unsigned int *virq) 3952832a81dSGeoff Levand { 396dc4f60c2SGeoff Levand /* this should go in system-bus.c */ 397dc4f60c2SGeoff Levand 3982832a81dSGeoff Levand int result; 3992832a81dSGeoff Levand 400dc4f60c2SGeoff Levand result = ps3_event_receive_port_setup(cpu, virq); 4012832a81dSGeoff Levand 4022832a81dSGeoff Levand if (result) 4032832a81dSGeoff Levand return result; 4042832a81dSGeoff Levand 4056bb5cf10SGeoff Levand result = lv1_connect_interrupt_event_receive_port(dev->bus_id, 4066bb5cf10SGeoff Levand dev->dev_id, virq_to_hw(*virq), dev->interrupt_id); 4072832a81dSGeoff Levand 4082832a81dSGeoff Levand if (result) { 4092832a81dSGeoff Levand pr_debug("%s:%d: lv1_connect_interrupt_event_receive_port" 4102832a81dSGeoff Levand " failed: %s\n", __func__, __LINE__, 4112832a81dSGeoff Levand ps3_result(result)); 412dc4f60c2SGeoff Levand ps3_event_receive_port_destroy(*virq); 4132832a81dSGeoff Levand *virq = NO_IRQ; 4142832a81dSGeoff Levand return result; 4152832a81dSGeoff Levand } 4162832a81dSGeoff Levand 4172832a81dSGeoff Levand pr_debug("%s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 4186bb5cf10SGeoff Levand dev->interrupt_id, *virq); 4192832a81dSGeoff Levand 4202832a81dSGeoff Levand return 0; 4212832a81dSGeoff Levand } 422dc4f60c2SGeoff Levand EXPORT_SYMBOL(ps3_sb_event_receive_port_setup); 4232832a81dSGeoff Levand 4246bb5cf10SGeoff Levand int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev, 4256bb5cf10SGeoff Levand unsigned int virq) 4262832a81dSGeoff Levand { 427dc4f60c2SGeoff Levand /* this should go in system-bus.c */ 428dc4f60c2SGeoff Levand 4292832a81dSGeoff Levand int result; 4302832a81dSGeoff Levand 4312832a81dSGeoff Levand pr_debug(" -> %s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 4326bb5cf10SGeoff Levand dev->interrupt_id, virq); 4332832a81dSGeoff Levand 4346bb5cf10SGeoff Levand result = lv1_disconnect_interrupt_event_receive_port(dev->bus_id, 4356bb5cf10SGeoff Levand dev->dev_id, virq_to_hw(virq), dev->interrupt_id); 4362832a81dSGeoff Levand 4372832a81dSGeoff Levand if (result) 4382832a81dSGeoff Levand pr_debug("%s:%d: lv1_disconnect_interrupt_event_receive_port" 4392832a81dSGeoff Levand " failed: %s\n", __func__, __LINE__, 4402832a81dSGeoff Levand ps3_result(result)); 4412832a81dSGeoff Levand 442dc4f60c2SGeoff Levand result = ps3_event_receive_port_destroy(virq); 443dc4f60c2SGeoff Levand BUG_ON(result); 4442832a81dSGeoff Levand 4459263e85aSGeoff Levand /* 4469263e85aSGeoff Levand * ps3_event_receive_port_destroy() destroys the IRQ plug, 4479263e85aSGeoff Levand * so don't call ps3_irq_plug_destroy() here. 4489263e85aSGeoff Levand */ 4499263e85aSGeoff Levand 4509263e85aSGeoff Levand result = ps3_virq_destroy(virq); 4519263e85aSGeoff Levand BUG_ON(result); 4529263e85aSGeoff Levand 4532832a81dSGeoff Levand pr_debug(" <- %s:%d\n", __func__, __LINE__); 4542832a81dSGeoff Levand return result; 4552832a81dSGeoff Levand } 456dc4f60c2SGeoff Levand EXPORT_SYMBOL(ps3_sb_event_receive_port_destroy); 4572832a81dSGeoff Levand 4582832a81dSGeoff Levand /** 459dc4f60c2SGeoff Levand * ps3_io_irq_setup - Setup a system bus io irq. 460dc4f60c2SGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 461dc4f60c2SGeoff Levand * serviced on. 462dc4f60c2SGeoff Levand * @interrupt_id: The device interrupt id read from the system repository. 463dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 464dc4f60c2SGeoff Levand * 465dc4f60c2SGeoff Levand * An io irq represents a non-virtualized device interrupt. interrupt_id 466dc4f60c2SGeoff Levand * coresponds to the interrupt number of the interrupt controller. 467dc4f60c2SGeoff Levand */ 468dc4f60c2SGeoff Levand 469dc4f60c2SGeoff Levand int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id, 470dc4f60c2SGeoff Levand unsigned int *virq) 471dc4f60c2SGeoff Levand { 472dc4f60c2SGeoff Levand int result; 473b17b3df1SStephen Rothwell u64 outlet; 474dc4f60c2SGeoff Levand 475dc4f60c2SGeoff Levand result = lv1_construct_io_irq_outlet(interrupt_id, &outlet); 476dc4f60c2SGeoff Levand 477dc4f60c2SGeoff Levand if (result) { 478dc4f60c2SGeoff Levand pr_debug("%s:%d: lv1_construct_io_irq_outlet failed: %s\n", 479dc4f60c2SGeoff Levand __func__, __LINE__, ps3_result(result)); 480dc4f60c2SGeoff Levand return result; 481dc4f60c2SGeoff Levand } 482dc4f60c2SGeoff Levand 483dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 484dc4f60c2SGeoff Levand BUG_ON(result); 485dc4f60c2SGeoff Levand 486dc4f60c2SGeoff Levand return result; 487dc4f60c2SGeoff Levand } 488dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_io_irq_setup); 489dc4f60c2SGeoff Levand 490dc4f60c2SGeoff Levand int ps3_io_irq_destroy(unsigned int virq) 491dc4f60c2SGeoff Levand { 492dc4f60c2SGeoff Levand int result; 4939263e85aSGeoff Levand unsigned long outlet = virq_to_hw(virq); 494dc4f60c2SGeoff Levand 495*8126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 4969263e85aSGeoff Levand 4979263e85aSGeoff Levand /* 4989263e85aSGeoff Levand * lv1_destruct_io_irq_outlet() will destroy the IRQ plug, 4999263e85aSGeoff Levand * so call ps3_irq_plug_destroy() first. 5009263e85aSGeoff Levand */ 5019263e85aSGeoff Levand 5029263e85aSGeoff Levand result = ps3_irq_plug_destroy(virq); 5039263e85aSGeoff Levand BUG_ON(result); 5049263e85aSGeoff Levand 5059263e85aSGeoff Levand result = lv1_destruct_io_irq_outlet(outlet); 506dc4f60c2SGeoff Levand 507dc4f60c2SGeoff Levand if (result) 508dc4f60c2SGeoff Levand pr_debug("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n", 509dc4f60c2SGeoff Levand __func__, __LINE__, ps3_result(result)); 510dc4f60c2SGeoff Levand 511dc4f60c2SGeoff Levand return result; 512dc4f60c2SGeoff Levand } 513dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_io_irq_destroy); 514dc4f60c2SGeoff Levand 515dc4f60c2SGeoff Levand /** 516dc4f60c2SGeoff Levand * ps3_vuart_irq_setup - Setup the system virtual uart virq. 517861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 518861be32cSGeoff Levand * serviced on. 5192832a81dSGeoff Levand * @virt_addr_bmp: The caller supplied virtual uart interrupt bitmap. 5202832a81dSGeoff Levand * @virq: The assigned Linux virq. 5212832a81dSGeoff Levand * 5222832a81dSGeoff Levand * The system supports only a single virtual uart, so multiple calls without 5232832a81dSGeoff Levand * freeing the interrupt will return a wrong state error. 5242832a81dSGeoff Levand */ 5252832a81dSGeoff Levand 526dc4f60c2SGeoff Levand int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp, 527861be32cSGeoff Levand unsigned int *virq) 5282832a81dSGeoff Levand { 5292832a81dSGeoff Levand int result; 530b17b3df1SStephen Rothwell u64 outlet; 531861be32cSGeoff Levand u64 lpar_addr; 5322832a81dSGeoff Levand 533861be32cSGeoff Levand BUG_ON(!is_kernel_addr((u64)virt_addr_bmp)); 5342832a81dSGeoff Levand 5352832a81dSGeoff Levand lpar_addr = ps3_mm_phys_to_lpar(__pa(virt_addr_bmp)); 5362832a81dSGeoff Levand 5372832a81dSGeoff Levand result = lv1_configure_virtual_uart_irq(lpar_addr, &outlet); 5382832a81dSGeoff Levand 5392832a81dSGeoff Levand if (result) { 5402832a81dSGeoff Levand pr_debug("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 5412832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 5422832a81dSGeoff Levand return result; 5432832a81dSGeoff Levand } 5442832a81dSGeoff Levand 545dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 546861be32cSGeoff Levand BUG_ON(result); 5472832a81dSGeoff Levand 548861be32cSGeoff Levand return result; 5492832a81dSGeoff Levand } 5507626e78dSGeoff Levand EXPORT_SYMBOL_GPL(ps3_vuart_irq_setup); 5512832a81dSGeoff Levand 552dc4f60c2SGeoff Levand int ps3_vuart_irq_destroy(unsigned int virq) 5532832a81dSGeoff Levand { 5542832a81dSGeoff Levand int result; 5552832a81dSGeoff Levand 556*8126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 5572832a81dSGeoff Levand result = lv1_deconfigure_virtual_uart_irq(); 5582832a81dSGeoff Levand 5592832a81dSGeoff Levand if (result) { 5602832a81dSGeoff Levand pr_debug("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 5612832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 5622832a81dSGeoff Levand return result; 5632832a81dSGeoff Levand } 5642832a81dSGeoff Levand 565dc4f60c2SGeoff Levand result = ps3_irq_plug_destroy(virq); 566dc4f60c2SGeoff Levand BUG_ON(result); 5672832a81dSGeoff Levand 5682832a81dSGeoff Levand return result; 5692832a81dSGeoff Levand } 5707626e78dSGeoff Levand EXPORT_SYMBOL_GPL(ps3_vuart_irq_destroy); 5712832a81dSGeoff Levand 5722832a81dSGeoff Levand /** 573dc4f60c2SGeoff Levand * ps3_spe_irq_setup - Setup an spe virq. 574861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 575861be32cSGeoff Levand * serviced on. 5762832a81dSGeoff Levand * @spe_id: The spe_id returned from lv1_construct_logical_spe(). 5772832a81dSGeoff Levand * @class: The spe interrupt class {0,1,2}. 5782832a81dSGeoff Levand * @virq: The assigned Linux virq. 5792832a81dSGeoff Levand * 5802832a81dSGeoff Levand */ 5812832a81dSGeoff Levand 582dc4f60c2SGeoff Levand int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id, 583861be32cSGeoff Levand unsigned int class, unsigned int *virq) 5842832a81dSGeoff Levand { 5852832a81dSGeoff Levand int result; 586b17b3df1SStephen Rothwell u64 outlet; 5872832a81dSGeoff Levand 5882832a81dSGeoff Levand BUG_ON(class > 2); 5892832a81dSGeoff Levand 5902832a81dSGeoff Levand result = lv1_get_spe_irq_outlet(spe_id, class, &outlet); 5912832a81dSGeoff Levand 5922832a81dSGeoff Levand if (result) { 5932832a81dSGeoff Levand pr_debug("%s:%d: lv1_get_spe_irq_outlet failed: %s\n", 5942832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 5952832a81dSGeoff Levand return result; 5962832a81dSGeoff Levand } 5972832a81dSGeoff Levand 598dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 599861be32cSGeoff Levand BUG_ON(result); 6002832a81dSGeoff Levand 601861be32cSGeoff Levand return result; 6022832a81dSGeoff Levand } 6032832a81dSGeoff Levand 604dc4f60c2SGeoff Levand int ps3_spe_irq_destroy(unsigned int virq) 6052832a81dSGeoff Levand { 6069263e85aSGeoff Levand int result; 6079263e85aSGeoff Levand 608*8126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 6099263e85aSGeoff Levand 6109263e85aSGeoff Levand result = ps3_irq_plug_destroy(virq); 611dc4f60c2SGeoff Levand BUG_ON(result); 6129263e85aSGeoff Levand 6139263e85aSGeoff Levand return result; 6142832a81dSGeoff Levand } 6152832a81dSGeoff Levand 616b1eeb38eSGeert Uytterhoeven 6172832a81dSGeoff Levand #define PS3_INVALID_OUTLET ((irq_hw_number_t)-1) 6182832a81dSGeoff Levand #define PS3_PLUG_MAX 63 6192832a81dSGeoff Levand 6202832a81dSGeoff Levand #if defined(DEBUG) 621861be32cSGeoff Levand static void _dump_64_bmp(const char *header, const u64 *p, unsigned cpu, 6222832a81dSGeoff Levand const char* func, int line) 6232832a81dSGeoff Levand { 6242832a81dSGeoff Levand pr_debug("%s:%d: %s %u {%04lx_%04lx_%04lx_%04lx}\n", 6252832a81dSGeoff Levand func, line, header, cpu, 6262832a81dSGeoff Levand *p >> 48, (*p >> 32) & 0xffff, (*p >> 16) & 0xffff, 6272832a81dSGeoff Levand *p & 0xffff); 6282832a81dSGeoff Levand } 6292832a81dSGeoff Levand 630848cfdc5SGeoff Levand static void __maybe_unused _dump_256_bmp(const char *header, 631861be32cSGeoff Levand const u64 *p, unsigned cpu, const char* func, int line) 6322832a81dSGeoff Levand { 6332832a81dSGeoff Levand pr_debug("%s:%d: %s %u {%016lx:%016lx:%016lx:%016lx}\n", 6342832a81dSGeoff Levand func, line, header, cpu, p[0], p[1], p[2], p[3]); 6352832a81dSGeoff Levand } 6362832a81dSGeoff Levand 6372832a81dSGeoff Levand #define dump_bmp(_x) _dump_bmp(_x, __func__, __LINE__) 6389633ac8dSGeoff Levand static void _dump_bmp(struct ps3_private* pd, const char* func, int line) 6392832a81dSGeoff Levand { 6402832a81dSGeoff Levand unsigned long flags; 6412832a81dSGeoff Levand 6422832a81dSGeoff Levand spin_lock_irqsave(&pd->bmp.lock, flags); 643aab83500SGeoff Levand _dump_64_bmp("stat", &pd->bmp.status, pd->thread_id, func, line); 644aab83500SGeoff Levand _dump_64_bmp("mask", &pd->bmp.mask, pd->thread_id, func, line); 6452832a81dSGeoff Levand spin_unlock_irqrestore(&pd->bmp.lock, flags); 6462832a81dSGeoff Levand } 6472832a81dSGeoff Levand 6482832a81dSGeoff Levand #define dump_mask(_x) _dump_mask(_x, __func__, __LINE__) 649848cfdc5SGeoff Levand static void __maybe_unused _dump_mask(struct ps3_private *pd, 6502832a81dSGeoff Levand const char* func, int line) 6512832a81dSGeoff Levand { 6522832a81dSGeoff Levand unsigned long flags; 6532832a81dSGeoff Levand 6542832a81dSGeoff Levand spin_lock_irqsave(&pd->bmp.lock, flags); 655aab83500SGeoff Levand _dump_64_bmp("mask", &pd->bmp.mask, pd->thread_id, func, line); 6562832a81dSGeoff Levand spin_unlock_irqrestore(&pd->bmp.lock, flags); 6572832a81dSGeoff Levand } 6582832a81dSGeoff Levand #else 6599633ac8dSGeoff Levand static void dump_bmp(struct ps3_private* pd) {}; 6602832a81dSGeoff Levand #endif /* defined(DEBUG) */ 6612832a81dSGeoff Levand 6629633ac8dSGeoff Levand static void ps3_host_unmap(struct irq_host *h, unsigned int virq) 6632832a81dSGeoff Levand { 664861be32cSGeoff Levand set_irq_chip_data(virq, NULL); 6652832a81dSGeoff Levand } 6662832a81dSGeoff Levand 6679633ac8dSGeoff Levand static int ps3_host_map(struct irq_host *h, unsigned int virq, 6682832a81dSGeoff Levand irq_hw_number_t hwirq) 6692832a81dSGeoff Levand { 670861be32cSGeoff Levand pr_debug("%s:%d: hwirq %lu, virq %u\n", __func__, __LINE__, hwirq, 671861be32cSGeoff Levand virq); 6722832a81dSGeoff Levand 6739263e85aSGeoff Levand set_irq_chip_and_handler(virq, &ps3_irq_chip, handle_fasteoi_irq); 6742832a81dSGeoff Levand 675861be32cSGeoff Levand return 0; 6762832a81dSGeoff Levand } 6772832a81dSGeoff Levand 6788528ab84SMichael Ellerman static int ps3_host_match(struct irq_host *h, struct device_node *np) 6798528ab84SMichael Ellerman { 6808528ab84SMichael Ellerman /* Match all */ 6818528ab84SMichael Ellerman return 1; 6828528ab84SMichael Ellerman } 6838528ab84SMichael Ellerman 6849633ac8dSGeoff Levand static struct irq_host_ops ps3_host_ops = { 6859633ac8dSGeoff Levand .map = ps3_host_map, 6869633ac8dSGeoff Levand .unmap = ps3_host_unmap, 6878528ab84SMichael Ellerman .match = ps3_host_match, 6882832a81dSGeoff Levand }; 6892832a81dSGeoff Levand 6902832a81dSGeoff Levand void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq) 6912832a81dSGeoff Levand { 6929633ac8dSGeoff Levand struct ps3_private *pd = &per_cpu(ps3_private, cpu); 6932832a81dSGeoff Levand 6942832a81dSGeoff Levand pd->bmp.ipi_debug_brk_mask = 0x8000000000000000UL >> virq; 6952832a81dSGeoff Levand 6965c949070SStephen Rothwell pr_debug("%s:%d: cpu %u, virq %u, mask %llxh\n", __func__, __LINE__, 6972832a81dSGeoff Levand cpu, virq, pd->bmp.ipi_debug_brk_mask); 6982832a81dSGeoff Levand } 6992832a81dSGeoff Levand 7009263e85aSGeoff Levand static unsigned int ps3_get_irq(void) 7012832a81dSGeoff Levand { 7029cf9e196SBenjamin Herrenschmidt struct ps3_private *pd = &__get_cpu_var(ps3_private); 703861be32cSGeoff Levand u64 x = (pd->bmp.status & pd->bmp.mask); 7049cf9e196SBenjamin Herrenschmidt unsigned int plug; 7052832a81dSGeoff Levand 7062832a81dSGeoff Levand /* check for ipi break first to stop this cpu ASAP */ 7072832a81dSGeoff Levand 7089cf9e196SBenjamin Herrenschmidt if (x & pd->bmp.ipi_debug_brk_mask) 7099cf9e196SBenjamin Herrenschmidt x &= pd->bmp.ipi_debug_brk_mask; 7102832a81dSGeoff Levand 7119cf9e196SBenjamin Herrenschmidt asm volatile("cntlzd %0,%1" : "=r" (plug) : "r" (x)); 7129cf9e196SBenjamin Herrenschmidt plug &= 0x3f; 7132832a81dSGeoff Levand 714ad18c3dbSRoel Kluin if (unlikely(plug == NO_IRQ)) { 7155c949070SStephen Rothwell pr_debug("%s:%d: no plug found: thread_id %llu\n", __func__, 716aab83500SGeoff Levand __LINE__, pd->thread_id); 7179633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 0)); 7189633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 1)); 7192832a81dSGeoff Levand return NO_IRQ; 7202832a81dSGeoff Levand } 7212832a81dSGeoff Levand 7222832a81dSGeoff Levand #if defined(DEBUG) 7239cf9e196SBenjamin Herrenschmidt if (unlikely(plug < NUM_ISA_INTERRUPTS || plug > PS3_PLUG_MAX)) { 7249633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 0)); 7259633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 1)); 7262832a81dSGeoff Levand BUG(); 7272832a81dSGeoff Levand } 7282832a81dSGeoff Levand #endif 7292832a81dSGeoff Levand return plug; 7302832a81dSGeoff Levand } 7312832a81dSGeoff Levand 7322832a81dSGeoff Levand void __init ps3_init_IRQ(void) 7332832a81dSGeoff Levand { 7342832a81dSGeoff Levand int result; 7352832a81dSGeoff Levand unsigned cpu; 7362832a81dSGeoff Levand struct irq_host *host; 7372832a81dSGeoff Levand 73852964f87SMichael Ellerman host = irq_alloc_host(NULL, IRQ_HOST_MAP_NOMAP, 0, &ps3_host_ops, 7392832a81dSGeoff Levand PS3_INVALID_OUTLET); 7402832a81dSGeoff Levand irq_set_default_host(host); 7412832a81dSGeoff Levand irq_set_virq_count(PS3_PLUG_MAX + 1); 7422832a81dSGeoff Levand 7432832a81dSGeoff Levand for_each_possible_cpu(cpu) { 7449633ac8dSGeoff Levand struct ps3_private *pd = &per_cpu(ps3_private, cpu); 7452832a81dSGeoff Levand 746aab83500SGeoff Levand lv1_get_logical_ppe_id(&pd->ppe_id); 747aab83500SGeoff Levand pd->thread_id = get_hard_smp_processor_id(cpu); 7482832a81dSGeoff Levand spin_lock_init(&pd->bmp.lock); 7492832a81dSGeoff Levand 7505c949070SStephen Rothwell pr_debug("%s:%d: ppe_id %llu, thread_id %llu, bmp %lxh\n", 751aab83500SGeoff Levand __func__, __LINE__, pd->ppe_id, pd->thread_id, 752407e24a0SGeoff Levand ps3_mm_phys_to_lpar(__pa(&pd->bmp))); 753407e24a0SGeoff Levand 754aab83500SGeoff Levand result = lv1_configure_irq_state_bitmap(pd->ppe_id, 755aab83500SGeoff Levand pd->thread_id, ps3_mm_phys_to_lpar(__pa(&pd->bmp))); 7562832a81dSGeoff Levand 7572832a81dSGeoff Levand if (result) 7582832a81dSGeoff Levand pr_debug("%s:%d: lv1_configure_irq_state_bitmap failed:" 7592832a81dSGeoff Levand " %s\n", __func__, __LINE__, 7602832a81dSGeoff Levand ps3_result(result)); 7612832a81dSGeoff Levand } 7622832a81dSGeoff Levand 7632832a81dSGeoff Levand ppc_md.get_irq = ps3_get_irq; 7642832a81dSGeoff Levand } 7659263e85aSGeoff Levand 7669263e85aSGeoff Levand void ps3_shutdown_IRQ(int cpu) 7679263e85aSGeoff Levand { 7689263e85aSGeoff Levand int result; 7699263e85aSGeoff Levand u64 ppe_id; 7709263e85aSGeoff Levand u64 thread_id = get_hard_smp_processor_id(cpu); 7719263e85aSGeoff Levand 7729263e85aSGeoff Levand lv1_get_logical_ppe_id(&ppe_id); 7739263e85aSGeoff Levand result = lv1_configure_irq_state_bitmap(ppe_id, thread_id, 0); 7749263e85aSGeoff Levand 7755c949070SStephen Rothwell DBG("%s:%d: lv1_configure_irq_state_bitmap (%llu:%llu/%d) %s\n", __func__, 7769263e85aSGeoff Levand __LINE__, ppe_id, thread_id, cpu, ps3_result(result)); 7779263e85aSGeoff Levand } 778