1*873e65bcSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 22832a81dSGeoff Levand /* 32832a81dSGeoff Levand * PS3 interrupt routines. 42832a81dSGeoff Levand * 52832a81dSGeoff Levand * Copyright (C) 2006 Sony Computer Entertainment Inc. 62832a81dSGeoff Levand * Copyright 2006 Sony Corp. 72832a81dSGeoff Levand */ 82832a81dSGeoff Levand 92832a81dSGeoff Levand #include <linux/kernel.h> 104b16f8e2SPaul Gortmaker #include <linux/export.h> 112832a81dSGeoff Levand #include <linux/irq.h> 122832a81dSGeoff Levand 132832a81dSGeoff Levand #include <asm/machdep.h> 142832a81dSGeoff Levand #include <asm/udbg.h> 152832a81dSGeoff Levand #include <asm/lv1call.h> 1642d284bcSStephen Rothwell #include <asm/smp.h> 172832a81dSGeoff Levand 182832a81dSGeoff Levand #include "platform.h" 192832a81dSGeoff Levand 202832a81dSGeoff Levand #if defined(DEBUG) 2183bb643dSGeert Uytterhoeven #define DBG udbg_printf 2232b9074bSGeoff Levand #define FAIL udbg_printf 232832a81dSGeoff Levand #else 2432b9074bSGeoff Levand #define DBG pr_devel 2532b9074bSGeoff Levand #define FAIL pr_debug 262832a81dSGeoff Levand #endif 272832a81dSGeoff Levand 282832a81dSGeoff Levand /** 29861be32cSGeoff Levand * struct ps3_bmp - a per cpu irq status and mask bitmap structure 30861be32cSGeoff Levand * @status: 256 bit status bitmap indexed by plug 3132b9074bSGeoff Levand * @unused_1: Alignment 32861be32cSGeoff Levand * @mask: 256 bit mask bitmap indexed by plug 3332b9074bSGeoff Levand * @unused_2: Alignment 34861be32cSGeoff Levand * 35b595076aSUwe Kleine-König * The HV maintains per SMT thread mappings of HV outlet to HV plug on 36861be32cSGeoff Levand * behalf of the guest. These mappings are implemented as 256 bit guest 37861be32cSGeoff Levand * supplied bitmaps indexed by plug number. The addresses of the bitmaps 38861be32cSGeoff Levand * are registered with the HV through lv1_configure_irq_state_bitmap(). 3957715765SGeoff Levand * The HV requires that the 512 bits of status + mask not cross a page 4057715765SGeoff Levand * boundary. PS3_BMP_MINALIGN is used to define this minimal 64 byte 4157715765SGeoff Levand * alignment. 42861be32cSGeoff Levand * 43861be32cSGeoff Levand * The HV supports 256 plugs per thread, assigned as {0..255}, for a total 44861be32cSGeoff Levand * of 512 plugs supported on a processor. To simplify the logic this 45861be32cSGeoff Levand * implementation equates HV plug value to Linux virq value, constrains each 46861be32cSGeoff Levand * interrupt to have a system wide unique plug number, and limits the range 47861be32cSGeoff Levand * of the plug values to map into the first dword of the bitmaps. This 48861be32cSGeoff Levand * gives a usable range of plug values of {NUM_ISA_INTERRUPTS..63}. Note 49861be32cSGeoff Levand * that there is no constraint on how many in this set an individual thread 50861be32cSGeoff Levand * can acquire. 5146ca0d15SStephen Rothwell * 5246ca0d15SStephen Rothwell * The mask is declared as unsigned long so we can use set/clear_bit on it. 53861be32cSGeoff Levand */ 54861be32cSGeoff Levand 5557715765SGeoff Levand #define PS3_BMP_MINALIGN 64 5657715765SGeoff Levand 57861be32cSGeoff Levand struct ps3_bmp { 58861be32cSGeoff Levand struct { 59861be32cSGeoff Levand u64 status; 60861be32cSGeoff Levand u64 unused_1[3]; 6146ca0d15SStephen Rothwell unsigned long mask; 62861be32cSGeoff Levand u64 unused_2[3]; 63861be32cSGeoff Levand }; 64861be32cSGeoff Levand }; 65861be32cSGeoff Levand 66861be32cSGeoff Levand /** 67861be32cSGeoff Levand * struct ps3_private - a per cpu data structure 68861be32cSGeoff Levand * @bmp: ps3_bmp structure 69446957baSAdam Buchbinder * @bmp_lock: Synchronize access to bmp. 7032b9074bSGeoff Levand * @ipi_debug_brk_mask: Mask for debug break IPIs 71aab83500SGeoff Levand * @ppe_id: HV logical_ppe_id 72aab83500SGeoff Levand * @thread_id: HV thread_id 7332b9074bSGeoff Levand * @ipi_mask: Mask of IPI virqs 74861be32cSGeoff Levand */ 75861be32cSGeoff Levand 76861be32cSGeoff Levand struct ps3_private { 7757715765SGeoff Levand struct ps3_bmp bmp __attribute__ ((aligned (PS3_BMP_MINALIGN))); 7832b9074bSGeoff Levand spinlock_t bmp_lock; 79aab83500SGeoff Levand u64 ppe_id; 80aab83500SGeoff Levand u64 thread_id; 8132b9074bSGeoff Levand unsigned long ipi_debug_brk_mask; 8272f3bea0SGeoff Levand unsigned long ipi_mask; 83861be32cSGeoff Levand }; 84861be32cSGeoff Levand 85861be32cSGeoff Levand static DEFINE_PER_CPU(struct ps3_private, ps3_private); 86861be32cSGeoff Levand 87dc4f60c2SGeoff Levand /** 88743c1bb0SGeoff Levand * ps3_chip_mask - Set an interrupt mask bit in ps3_bmp. 89743c1bb0SGeoff Levand * @virq: The assigned Linux virq. 90743c1bb0SGeoff Levand * 91743c1bb0SGeoff Levand * Sets ps3_bmp.mask and calls lv1_did_update_interrupt_mask(). 92743c1bb0SGeoff Levand */ 93743c1bb0SGeoff Levand 948126708aSLennert Buytenhek static void ps3_chip_mask(struct irq_data *d) 95743c1bb0SGeoff Levand { 968126708aSLennert Buytenhek struct ps3_private *pd = irq_data_get_irq_chip_data(d); 97743c1bb0SGeoff Levand unsigned long flags; 98743c1bb0SGeoff Levand 9932b9074bSGeoff Levand DBG("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 1008126708aSLennert Buytenhek pd->thread_id, d->irq); 101743c1bb0SGeoff Levand 102743c1bb0SGeoff Levand local_irq_save(flags); 1038126708aSLennert Buytenhek clear_bit(63 - d->irq, &pd->bmp.mask); 104aab83500SGeoff Levand lv1_did_update_interrupt_mask(pd->ppe_id, pd->thread_id); 105743c1bb0SGeoff Levand local_irq_restore(flags); 106743c1bb0SGeoff Levand } 107743c1bb0SGeoff Levand 108743c1bb0SGeoff Levand /** 109743c1bb0SGeoff Levand * ps3_chip_unmask - Clear an interrupt mask bit in ps3_bmp. 110743c1bb0SGeoff Levand * @virq: The assigned Linux virq. 111743c1bb0SGeoff Levand * 112743c1bb0SGeoff Levand * Clears ps3_bmp.mask and calls lv1_did_update_interrupt_mask(). 113743c1bb0SGeoff Levand */ 114743c1bb0SGeoff Levand 1158126708aSLennert Buytenhek static void ps3_chip_unmask(struct irq_data *d) 116743c1bb0SGeoff Levand { 1178126708aSLennert Buytenhek struct ps3_private *pd = irq_data_get_irq_chip_data(d); 118743c1bb0SGeoff Levand unsigned long flags; 119743c1bb0SGeoff Levand 12032b9074bSGeoff Levand DBG("%s:%d: thread_id %llu, virq %d\n", __func__, __LINE__, 1218126708aSLennert Buytenhek pd->thread_id, d->irq); 122743c1bb0SGeoff Levand 123743c1bb0SGeoff Levand local_irq_save(flags); 1248126708aSLennert Buytenhek set_bit(63 - d->irq, &pd->bmp.mask); 125aab83500SGeoff Levand lv1_did_update_interrupt_mask(pd->ppe_id, pd->thread_id); 126743c1bb0SGeoff Levand local_irq_restore(flags); 127743c1bb0SGeoff Levand } 128743c1bb0SGeoff Levand 129743c1bb0SGeoff Levand /** 130743c1bb0SGeoff Levand * ps3_chip_eoi - HV end-of-interrupt. 131743c1bb0SGeoff Levand * @virq: The assigned Linux virq. 132743c1bb0SGeoff Levand * 133743c1bb0SGeoff Levand * Calls lv1_end_of_interrupt_ext(). 134743c1bb0SGeoff Levand */ 135743c1bb0SGeoff Levand 1368126708aSLennert Buytenhek static void ps3_chip_eoi(struct irq_data *d) 137743c1bb0SGeoff Levand { 1388126708aSLennert Buytenhek const struct ps3_private *pd = irq_data_get_irq_chip_data(d); 13972f3bea0SGeoff Levand 14072f3bea0SGeoff Levand /* non-IPIs are EOIed here. */ 14172f3bea0SGeoff Levand 14272f3bea0SGeoff Levand if (!test_bit(63 - d->irq, &pd->ipi_mask)) 1438126708aSLennert Buytenhek lv1_end_of_interrupt_ext(pd->ppe_id, pd->thread_id, d->irq); 144743c1bb0SGeoff Levand } 145743c1bb0SGeoff Levand 146743c1bb0SGeoff Levand /** 147743c1bb0SGeoff Levand * ps3_irq_chip - Represents the ps3_bmp as a Linux struct irq_chip. 148743c1bb0SGeoff Levand */ 149743c1bb0SGeoff Levand 150743c1bb0SGeoff Levand static struct irq_chip ps3_irq_chip = { 151b27df672SThomas Gleixner .name = "ps3", 1528126708aSLennert Buytenhek .irq_mask = ps3_chip_mask, 1538126708aSLennert Buytenhek .irq_unmask = ps3_chip_unmask, 1548126708aSLennert Buytenhek .irq_eoi = ps3_chip_eoi, 155743c1bb0SGeoff Levand }; 156743c1bb0SGeoff Levand 157743c1bb0SGeoff Levand /** 158dc4f60c2SGeoff Levand * ps3_virq_setup - virq related setup. 159dc4f60c2SGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 160dc4f60c2SGeoff Levand * serviced on. 161dc4f60c2SGeoff Levand * @outlet: The HV outlet from the various create outlet routines. 162dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 163dc4f60c2SGeoff Levand * 164dc4f60c2SGeoff Levand * Calls irq_create_mapping() to get a virq and sets the chip data to 165dc4f60c2SGeoff Levand * ps3_private data. 166dc4f60c2SGeoff Levand */ 167dc4f60c2SGeoff Levand 168fdedb4caSGeert Uytterhoeven static int ps3_virq_setup(enum ps3_cpu_binding cpu, unsigned long outlet, 169861be32cSGeoff Levand unsigned int *virq) 170861be32cSGeoff Levand { 171861be32cSGeoff Levand int result; 172861be32cSGeoff Levand struct ps3_private *pd; 173861be32cSGeoff Levand 174861be32cSGeoff Levand /* This defines the default interrupt distribution policy. */ 175861be32cSGeoff Levand 176861be32cSGeoff Levand if (cpu == PS3_BINDING_CPU_ANY) 177861be32cSGeoff Levand cpu = 0; 178861be32cSGeoff Levand 179861be32cSGeoff Levand pd = &per_cpu(ps3_private, cpu); 180861be32cSGeoff Levand 181861be32cSGeoff Levand *virq = irq_create_mapping(NULL, outlet); 182861be32cSGeoff Levand 183ef24ba70SMichael Ellerman if (!*virq) { 18432b9074bSGeoff Levand FAIL("%s:%d: irq_create_mapping failed: outlet %lu\n", 185861be32cSGeoff Levand __func__, __LINE__, outlet); 186861be32cSGeoff Levand result = -ENOMEM; 187861be32cSGeoff Levand goto fail_create; 188861be32cSGeoff Levand } 189861be32cSGeoff Levand 19032b9074bSGeoff Levand DBG("%s:%d: outlet %lu => cpu %u, virq %u\n", __func__, __LINE__, 191861be32cSGeoff Levand outlet, cpu, *virq); 192861be32cSGeoff Levand 193ec775d0eSThomas Gleixner result = irq_set_chip_data(*virq, pd); 194861be32cSGeoff Levand 195861be32cSGeoff Levand if (result) { 19632b9074bSGeoff Levand FAIL("%s:%d: irq_set_chip_data failed\n", 197861be32cSGeoff Levand __func__, __LINE__); 198861be32cSGeoff Levand goto fail_set; 199861be32cSGeoff Levand } 200861be32cSGeoff Levand 2018126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(*virq)); 2029263e85aSGeoff Levand 203861be32cSGeoff Levand return result; 204861be32cSGeoff Levand 205861be32cSGeoff Levand fail_set: 206861be32cSGeoff Levand irq_dispose_mapping(*virq); 207861be32cSGeoff Levand fail_create: 208861be32cSGeoff Levand return result; 209861be32cSGeoff Levand } 210861be32cSGeoff Levand 211dc4f60c2SGeoff Levand /** 212dc4f60c2SGeoff Levand * ps3_virq_destroy - virq related teardown. 213dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 214dc4f60c2SGeoff Levand * 215dc4f60c2SGeoff Levand * Clears chip data and calls irq_dispose_mapping() for the virq. 216dc4f60c2SGeoff Levand */ 217dc4f60c2SGeoff Levand 218fdedb4caSGeert Uytterhoeven static int ps3_virq_destroy(unsigned int virq) 219dc4f60c2SGeoff Levand { 220ec775d0eSThomas Gleixner const struct ps3_private *pd = irq_get_chip_data(virq); 221dc4f60c2SGeoff Levand 22232b9074bSGeoff Levand DBG("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 223aab83500SGeoff Levand __LINE__, pd->ppe_id, pd->thread_id, virq); 224dc4f60c2SGeoff Levand 225ec775d0eSThomas Gleixner irq_set_chip_data(virq, NULL); 226dc4f60c2SGeoff Levand irq_dispose_mapping(virq); 227dc4f60c2SGeoff Levand 22832b9074bSGeoff Levand DBG("%s:%d <-\n", __func__, __LINE__); 229dc4f60c2SGeoff Levand return 0; 230dc4f60c2SGeoff Levand } 231dc4f60c2SGeoff Levand 232dc4f60c2SGeoff Levand /** 233dc4f60c2SGeoff Levand * ps3_irq_plug_setup - Generic outlet and virq related setup. 234dc4f60c2SGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 235dc4f60c2SGeoff Levand * serviced on. 236dc4f60c2SGeoff Levand * @outlet: The HV outlet from the various create outlet routines. 237dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 238dc4f60c2SGeoff Levand * 239dc4f60c2SGeoff Levand * Sets up virq and connects the irq plug. 240dc4f60c2SGeoff Levand */ 241dc4f60c2SGeoff Levand 242dc4f60c2SGeoff Levand int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet, 243dc4f60c2SGeoff Levand unsigned int *virq) 244dc4f60c2SGeoff Levand { 245dc4f60c2SGeoff Levand int result; 246dc4f60c2SGeoff Levand struct ps3_private *pd; 247dc4f60c2SGeoff Levand 248dc4f60c2SGeoff Levand result = ps3_virq_setup(cpu, outlet, virq); 249dc4f60c2SGeoff Levand 250dc4f60c2SGeoff Levand if (result) { 25132b9074bSGeoff Levand FAIL("%s:%d: ps3_virq_setup failed\n", __func__, __LINE__); 252dc4f60c2SGeoff Levand goto fail_setup; 253dc4f60c2SGeoff Levand } 254dc4f60c2SGeoff Levand 255ec775d0eSThomas Gleixner pd = irq_get_chip_data(*virq); 256dc4f60c2SGeoff Levand 257dc4f60c2SGeoff Levand /* Binds outlet to cpu + virq. */ 258dc4f60c2SGeoff Levand 259aab83500SGeoff Levand result = lv1_connect_irq_plug_ext(pd->ppe_id, pd->thread_id, *virq, 260aab83500SGeoff Levand outlet, 0); 261dc4f60c2SGeoff Levand 262dc4f60c2SGeoff Levand if (result) { 26332b9074bSGeoff Levand FAIL("%s:%d: lv1_connect_irq_plug_ext failed: %s\n", 264dc4f60c2SGeoff Levand __func__, __LINE__, ps3_result(result)); 265dc4f60c2SGeoff Levand result = -EPERM; 266dc4f60c2SGeoff Levand goto fail_connect; 267dc4f60c2SGeoff Levand } 268dc4f60c2SGeoff Levand 269dc4f60c2SGeoff Levand return result; 270dc4f60c2SGeoff Levand 271dc4f60c2SGeoff Levand fail_connect: 272dc4f60c2SGeoff Levand ps3_virq_destroy(*virq); 273dc4f60c2SGeoff Levand fail_setup: 274dc4f60c2SGeoff Levand return result; 275dc4f60c2SGeoff Levand } 276dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_irq_plug_setup); 277dc4f60c2SGeoff Levand 278dc4f60c2SGeoff Levand /** 279dc4f60c2SGeoff Levand * ps3_irq_plug_destroy - Generic outlet and virq related teardown. 280dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 281dc4f60c2SGeoff Levand * 282dc4f60c2SGeoff Levand * Disconnects the irq plug and tears down virq. 283dc4f60c2SGeoff Levand * Do not call for system bus event interrupts setup with 284dc4f60c2SGeoff Levand * ps3_sb_event_receive_port_setup(). 285dc4f60c2SGeoff Levand */ 286dc4f60c2SGeoff Levand 287dc4f60c2SGeoff Levand int ps3_irq_plug_destroy(unsigned int virq) 288861be32cSGeoff Levand { 289861be32cSGeoff Levand int result; 290ec775d0eSThomas Gleixner const struct ps3_private *pd = irq_get_chip_data(virq); 291861be32cSGeoff Levand 29232b9074bSGeoff Levand DBG("%s:%d: ppe_id %llu, thread_id %llu, virq %u\n", __func__, 293aab83500SGeoff Levand __LINE__, pd->ppe_id, pd->thread_id, virq); 294861be32cSGeoff Levand 2958126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 2969263e85aSGeoff Levand 297aab83500SGeoff Levand result = lv1_disconnect_irq_plug_ext(pd->ppe_id, pd->thread_id, virq); 298861be32cSGeoff Levand 299861be32cSGeoff Levand if (result) 30032b9074bSGeoff Levand FAIL("%s:%d: lv1_disconnect_irq_plug_ext failed: %s\n", 301861be32cSGeoff Levand __func__, __LINE__, ps3_result(result)); 302861be32cSGeoff Levand 303dc4f60c2SGeoff Levand ps3_virq_destroy(virq); 304dc4f60c2SGeoff Levand 305b1eeb38eSGeert Uytterhoeven return result; 306861be32cSGeoff Levand } 307dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_irq_plug_destroy); 308861be32cSGeoff Levand 309861be32cSGeoff Levand /** 310dc4f60c2SGeoff Levand * ps3_event_receive_port_setup - Setup an event receive port. 311861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 312861be32cSGeoff Levand * serviced on. 3132832a81dSGeoff Levand * @virq: The assigned Linux virq. 3142832a81dSGeoff Levand * 3152832a81dSGeoff Levand * The virq can be used with lv1_connect_interrupt_event_receive_port() to 316dc4f60c2SGeoff Levand * arrange to receive interrupts from system-bus devices, or with 317dc4f60c2SGeoff Levand * ps3_send_event_locally() to signal events. 3182832a81dSGeoff Levand */ 3192832a81dSGeoff Levand 320dc4f60c2SGeoff Levand int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq) 3212832a81dSGeoff Levand { 3222832a81dSGeoff Levand int result; 323b17b3df1SStephen Rothwell u64 outlet; 3242832a81dSGeoff Levand 3252832a81dSGeoff Levand result = lv1_construct_event_receive_port(&outlet); 3262832a81dSGeoff Levand 3272832a81dSGeoff Levand if (result) { 32832b9074bSGeoff Levand FAIL("%s:%d: lv1_construct_event_receive_port failed: %s\n", 3292832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 330ef24ba70SMichael Ellerman *virq = 0; 3312832a81dSGeoff Levand return result; 3322832a81dSGeoff Levand } 3332832a81dSGeoff Levand 334dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 335861be32cSGeoff Levand BUG_ON(result); 3362832a81dSGeoff Levand 337861be32cSGeoff Levand return result; 3382832a81dSGeoff Levand } 339dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_event_receive_port_setup); 3402832a81dSGeoff Levand 341dc4f60c2SGeoff Levand /** 342dc4f60c2SGeoff Levand * ps3_event_receive_port_destroy - Destroy an event receive port. 343dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 344dc4f60c2SGeoff Levand * 345dc4f60c2SGeoff Levand * Since ps3_event_receive_port_destroy destroys the receive port outlet, 346dc4f60c2SGeoff Levand * SB devices need to call disconnect_interrupt_event_receive_port() before 347dc4f60c2SGeoff Levand * this. 348dc4f60c2SGeoff Levand */ 349dc4f60c2SGeoff Levand 350dc4f60c2SGeoff Levand int ps3_event_receive_port_destroy(unsigned int virq) 3512832a81dSGeoff Levand { 3522832a81dSGeoff Levand int result; 3532832a81dSGeoff Levand 35432b9074bSGeoff Levand DBG(" -> %s:%d virq %u\n", __func__, __LINE__, virq); 3559263e85aSGeoff Levand 3568126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 3572832a81dSGeoff Levand 3582832a81dSGeoff Levand result = lv1_destruct_event_receive_port(virq_to_hw(virq)); 3592832a81dSGeoff Levand 3602832a81dSGeoff Levand if (result) 36132b9074bSGeoff Levand FAIL("%s:%d: lv1_destruct_event_receive_port failed: %s\n", 3622832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 3632832a81dSGeoff Levand 3649263e85aSGeoff Levand /* 3659263e85aSGeoff Levand * Don't call ps3_virq_destroy() here since ps3_smp_cleanup_cpu() 3669263e85aSGeoff Levand * calls from interrupt context (smp_call_function) when kexecing. 367dc4f60c2SGeoff Levand */ 368dc4f60c2SGeoff Levand 36932b9074bSGeoff Levand DBG(" <- %s:%d\n", __func__, __LINE__); 3702832a81dSGeoff Levand return result; 3712832a81dSGeoff Levand } 3722832a81dSGeoff Levand 3732832a81dSGeoff Levand int ps3_send_event_locally(unsigned int virq) 3742832a81dSGeoff Levand { 3752832a81dSGeoff Levand return lv1_send_event_locally(virq_to_hw(virq)); 3762832a81dSGeoff Levand } 3772832a81dSGeoff Levand 3782832a81dSGeoff Levand /** 379dc4f60c2SGeoff Levand * ps3_sb_event_receive_port_setup - Setup a system bus event receive port. 380861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 381861be32cSGeoff Levand * serviced on. 3826bb5cf10SGeoff Levand * @dev: The system bus device instance. 3832832a81dSGeoff Levand * @virq: The assigned Linux virq. 3842832a81dSGeoff Levand * 3852832a81dSGeoff Levand * An event irq represents a virtual device interrupt. The interrupt_id 3862832a81dSGeoff Levand * coresponds to the software interrupt number. 3872832a81dSGeoff Levand */ 3882832a81dSGeoff Levand 3896bb5cf10SGeoff Levand int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev, 3906bb5cf10SGeoff Levand enum ps3_cpu_binding cpu, unsigned int *virq) 3912832a81dSGeoff Levand { 392dc4f60c2SGeoff Levand /* this should go in system-bus.c */ 393dc4f60c2SGeoff Levand 3942832a81dSGeoff Levand int result; 3952832a81dSGeoff Levand 396dc4f60c2SGeoff Levand result = ps3_event_receive_port_setup(cpu, virq); 3972832a81dSGeoff Levand 3982832a81dSGeoff Levand if (result) 3992832a81dSGeoff Levand return result; 4002832a81dSGeoff Levand 4016bb5cf10SGeoff Levand result = lv1_connect_interrupt_event_receive_port(dev->bus_id, 4026bb5cf10SGeoff Levand dev->dev_id, virq_to_hw(*virq), dev->interrupt_id); 4032832a81dSGeoff Levand 4042832a81dSGeoff Levand if (result) { 40532b9074bSGeoff Levand FAIL("%s:%d: lv1_connect_interrupt_event_receive_port" 4062832a81dSGeoff Levand " failed: %s\n", __func__, __LINE__, 4072832a81dSGeoff Levand ps3_result(result)); 408dc4f60c2SGeoff Levand ps3_event_receive_port_destroy(*virq); 409ef24ba70SMichael Ellerman *virq = 0; 4102832a81dSGeoff Levand return result; 4112832a81dSGeoff Levand } 4122832a81dSGeoff Levand 41332b9074bSGeoff Levand DBG("%s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 4146bb5cf10SGeoff Levand dev->interrupt_id, *virq); 4152832a81dSGeoff Levand 4162832a81dSGeoff Levand return 0; 4172832a81dSGeoff Levand } 418dc4f60c2SGeoff Levand EXPORT_SYMBOL(ps3_sb_event_receive_port_setup); 4192832a81dSGeoff Levand 4206bb5cf10SGeoff Levand int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev, 4216bb5cf10SGeoff Levand unsigned int virq) 4222832a81dSGeoff Levand { 423dc4f60c2SGeoff Levand /* this should go in system-bus.c */ 424dc4f60c2SGeoff Levand 4252832a81dSGeoff Levand int result; 4262832a81dSGeoff Levand 42732b9074bSGeoff Levand DBG(" -> %s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__, 4286bb5cf10SGeoff Levand dev->interrupt_id, virq); 4292832a81dSGeoff Levand 4306bb5cf10SGeoff Levand result = lv1_disconnect_interrupt_event_receive_port(dev->bus_id, 4316bb5cf10SGeoff Levand dev->dev_id, virq_to_hw(virq), dev->interrupt_id); 4322832a81dSGeoff Levand 4332832a81dSGeoff Levand if (result) 43432b9074bSGeoff Levand FAIL("%s:%d: lv1_disconnect_interrupt_event_receive_port" 4352832a81dSGeoff Levand " failed: %s\n", __func__, __LINE__, 4362832a81dSGeoff Levand ps3_result(result)); 4372832a81dSGeoff Levand 438dc4f60c2SGeoff Levand result = ps3_event_receive_port_destroy(virq); 439dc4f60c2SGeoff Levand BUG_ON(result); 4402832a81dSGeoff Levand 4419263e85aSGeoff Levand /* 4429263e85aSGeoff Levand * ps3_event_receive_port_destroy() destroys the IRQ plug, 4439263e85aSGeoff Levand * so don't call ps3_irq_plug_destroy() here. 4449263e85aSGeoff Levand */ 4459263e85aSGeoff Levand 4469263e85aSGeoff Levand result = ps3_virq_destroy(virq); 4479263e85aSGeoff Levand BUG_ON(result); 4489263e85aSGeoff Levand 44932b9074bSGeoff Levand DBG(" <- %s:%d\n", __func__, __LINE__); 4502832a81dSGeoff Levand return result; 4512832a81dSGeoff Levand } 452dc4f60c2SGeoff Levand EXPORT_SYMBOL(ps3_sb_event_receive_port_destroy); 4532832a81dSGeoff Levand 4542832a81dSGeoff Levand /** 455dc4f60c2SGeoff Levand * ps3_io_irq_setup - Setup a system bus io irq. 456dc4f60c2SGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 457dc4f60c2SGeoff Levand * serviced on. 458dc4f60c2SGeoff Levand * @interrupt_id: The device interrupt id read from the system repository. 459dc4f60c2SGeoff Levand * @virq: The assigned Linux virq. 460dc4f60c2SGeoff Levand * 461dc4f60c2SGeoff Levand * An io irq represents a non-virtualized device interrupt. interrupt_id 462dc4f60c2SGeoff Levand * coresponds to the interrupt number of the interrupt controller. 463dc4f60c2SGeoff Levand */ 464dc4f60c2SGeoff Levand 465dc4f60c2SGeoff Levand int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id, 466dc4f60c2SGeoff Levand unsigned int *virq) 467dc4f60c2SGeoff Levand { 468dc4f60c2SGeoff Levand int result; 469b17b3df1SStephen Rothwell u64 outlet; 470dc4f60c2SGeoff Levand 471dc4f60c2SGeoff Levand result = lv1_construct_io_irq_outlet(interrupt_id, &outlet); 472dc4f60c2SGeoff Levand 473dc4f60c2SGeoff Levand if (result) { 47432b9074bSGeoff Levand FAIL("%s:%d: lv1_construct_io_irq_outlet failed: %s\n", 475dc4f60c2SGeoff Levand __func__, __LINE__, ps3_result(result)); 476dc4f60c2SGeoff Levand return result; 477dc4f60c2SGeoff Levand } 478dc4f60c2SGeoff Levand 479dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 480dc4f60c2SGeoff Levand BUG_ON(result); 481dc4f60c2SGeoff Levand 482dc4f60c2SGeoff Levand return result; 483dc4f60c2SGeoff Levand } 484dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_io_irq_setup); 485dc4f60c2SGeoff Levand 486dc4f60c2SGeoff Levand int ps3_io_irq_destroy(unsigned int virq) 487dc4f60c2SGeoff Levand { 488dc4f60c2SGeoff Levand int result; 4899263e85aSGeoff Levand unsigned long outlet = virq_to_hw(virq); 490dc4f60c2SGeoff Levand 4918126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 4929263e85aSGeoff Levand 4939263e85aSGeoff Levand /* 4949263e85aSGeoff Levand * lv1_destruct_io_irq_outlet() will destroy the IRQ plug, 4959263e85aSGeoff Levand * so call ps3_irq_plug_destroy() first. 4969263e85aSGeoff Levand */ 4979263e85aSGeoff Levand 4989263e85aSGeoff Levand result = ps3_irq_plug_destroy(virq); 4999263e85aSGeoff Levand BUG_ON(result); 5009263e85aSGeoff Levand 5019263e85aSGeoff Levand result = lv1_destruct_io_irq_outlet(outlet); 502dc4f60c2SGeoff Levand 503dc4f60c2SGeoff Levand if (result) 50432b9074bSGeoff Levand FAIL("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n", 505dc4f60c2SGeoff Levand __func__, __LINE__, ps3_result(result)); 506dc4f60c2SGeoff Levand 507dc4f60c2SGeoff Levand return result; 508dc4f60c2SGeoff Levand } 509dc4f60c2SGeoff Levand EXPORT_SYMBOL_GPL(ps3_io_irq_destroy); 510dc4f60c2SGeoff Levand 511dc4f60c2SGeoff Levand /** 512dc4f60c2SGeoff Levand * ps3_vuart_irq_setup - Setup the system virtual uart virq. 513861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 514861be32cSGeoff Levand * serviced on. 5152832a81dSGeoff Levand * @virt_addr_bmp: The caller supplied virtual uart interrupt bitmap. 5162832a81dSGeoff Levand * @virq: The assigned Linux virq. 5172832a81dSGeoff Levand * 5182832a81dSGeoff Levand * The system supports only a single virtual uart, so multiple calls without 5192832a81dSGeoff Levand * freeing the interrupt will return a wrong state error. 5202832a81dSGeoff Levand */ 5212832a81dSGeoff Levand 522dc4f60c2SGeoff Levand int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp, 523861be32cSGeoff Levand unsigned int *virq) 5242832a81dSGeoff Levand { 5252832a81dSGeoff Levand int result; 526b17b3df1SStephen Rothwell u64 outlet; 527861be32cSGeoff Levand u64 lpar_addr; 5282832a81dSGeoff Levand 529861be32cSGeoff Levand BUG_ON(!is_kernel_addr((u64)virt_addr_bmp)); 5302832a81dSGeoff Levand 5312832a81dSGeoff Levand lpar_addr = ps3_mm_phys_to_lpar(__pa(virt_addr_bmp)); 5322832a81dSGeoff Levand 5332832a81dSGeoff Levand result = lv1_configure_virtual_uart_irq(lpar_addr, &outlet); 5342832a81dSGeoff Levand 5352832a81dSGeoff Levand if (result) { 53632b9074bSGeoff Levand FAIL("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 5372832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 5382832a81dSGeoff Levand return result; 5392832a81dSGeoff Levand } 5402832a81dSGeoff Levand 541dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 542861be32cSGeoff Levand BUG_ON(result); 5432832a81dSGeoff Levand 544861be32cSGeoff Levand return result; 5452832a81dSGeoff Levand } 5467626e78dSGeoff Levand EXPORT_SYMBOL_GPL(ps3_vuart_irq_setup); 5472832a81dSGeoff Levand 548dc4f60c2SGeoff Levand int ps3_vuart_irq_destroy(unsigned int virq) 5492832a81dSGeoff Levand { 5502832a81dSGeoff Levand int result; 5512832a81dSGeoff Levand 5528126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 5532832a81dSGeoff Levand result = lv1_deconfigure_virtual_uart_irq(); 5542832a81dSGeoff Levand 5552832a81dSGeoff Levand if (result) { 55632b9074bSGeoff Levand FAIL("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n", 5572832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 5582832a81dSGeoff Levand return result; 5592832a81dSGeoff Levand } 5602832a81dSGeoff Levand 561dc4f60c2SGeoff Levand result = ps3_irq_plug_destroy(virq); 562dc4f60c2SGeoff Levand BUG_ON(result); 5632832a81dSGeoff Levand 5642832a81dSGeoff Levand return result; 5652832a81dSGeoff Levand } 5667626e78dSGeoff Levand EXPORT_SYMBOL_GPL(ps3_vuart_irq_destroy); 5672832a81dSGeoff Levand 5682832a81dSGeoff Levand /** 569dc4f60c2SGeoff Levand * ps3_spe_irq_setup - Setup an spe virq. 570861be32cSGeoff Levand * @cpu: enum ps3_cpu_binding indicating the cpu the interrupt should be 571861be32cSGeoff Levand * serviced on. 5722832a81dSGeoff Levand * @spe_id: The spe_id returned from lv1_construct_logical_spe(). 5732832a81dSGeoff Levand * @class: The spe interrupt class {0,1,2}. 5742832a81dSGeoff Levand * @virq: The assigned Linux virq. 5752832a81dSGeoff Levand * 5762832a81dSGeoff Levand */ 5772832a81dSGeoff Levand 578dc4f60c2SGeoff Levand int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id, 579861be32cSGeoff Levand unsigned int class, unsigned int *virq) 5802832a81dSGeoff Levand { 5812832a81dSGeoff Levand int result; 582b17b3df1SStephen Rothwell u64 outlet; 5832832a81dSGeoff Levand 5842832a81dSGeoff Levand BUG_ON(class > 2); 5852832a81dSGeoff Levand 5862832a81dSGeoff Levand result = lv1_get_spe_irq_outlet(spe_id, class, &outlet); 5872832a81dSGeoff Levand 5882832a81dSGeoff Levand if (result) { 58932b9074bSGeoff Levand FAIL("%s:%d: lv1_get_spe_irq_outlet failed: %s\n", 5902832a81dSGeoff Levand __func__, __LINE__, ps3_result(result)); 5912832a81dSGeoff Levand return result; 5922832a81dSGeoff Levand } 5932832a81dSGeoff Levand 594dc4f60c2SGeoff Levand result = ps3_irq_plug_setup(cpu, outlet, virq); 595861be32cSGeoff Levand BUG_ON(result); 5962832a81dSGeoff Levand 597861be32cSGeoff Levand return result; 5982832a81dSGeoff Levand } 5992832a81dSGeoff Levand 600dc4f60c2SGeoff Levand int ps3_spe_irq_destroy(unsigned int virq) 6012832a81dSGeoff Levand { 6029263e85aSGeoff Levand int result; 6039263e85aSGeoff Levand 6048126708aSLennert Buytenhek ps3_chip_mask(irq_get_irq_data(virq)); 6059263e85aSGeoff Levand 6069263e85aSGeoff Levand result = ps3_irq_plug_destroy(virq); 607dc4f60c2SGeoff Levand BUG_ON(result); 6089263e85aSGeoff Levand 6099263e85aSGeoff Levand return result; 6102832a81dSGeoff Levand } 6112832a81dSGeoff Levand 612b1eeb38eSGeert Uytterhoeven 6132832a81dSGeoff Levand #define PS3_INVALID_OUTLET ((irq_hw_number_t)-1) 6142832a81dSGeoff Levand #define PS3_PLUG_MAX 63 6152832a81dSGeoff Levand 6162832a81dSGeoff Levand #if defined(DEBUG) 617861be32cSGeoff Levand static void _dump_64_bmp(const char *header, const u64 *p, unsigned cpu, 6182832a81dSGeoff Levand const char* func, int line) 6192832a81dSGeoff Levand { 62032b9074bSGeoff Levand pr_debug("%s:%d: %s %u {%04llx_%04llx_%04llx_%04llx}\n", 6212832a81dSGeoff Levand func, line, header, cpu, 6222832a81dSGeoff Levand *p >> 48, (*p >> 32) & 0xffff, (*p >> 16) & 0xffff, 6232832a81dSGeoff Levand *p & 0xffff); 6242832a81dSGeoff Levand } 6252832a81dSGeoff Levand 626848cfdc5SGeoff Levand static void __maybe_unused _dump_256_bmp(const char *header, 627861be32cSGeoff Levand const u64 *p, unsigned cpu, const char* func, int line) 6282832a81dSGeoff Levand { 62932b9074bSGeoff Levand pr_debug("%s:%d: %s %u {%016llx:%016llx:%016llx:%016llx}\n", 6302832a81dSGeoff Levand func, line, header, cpu, p[0], p[1], p[2], p[3]); 6312832a81dSGeoff Levand } 6322832a81dSGeoff Levand 6332832a81dSGeoff Levand #define dump_bmp(_x) _dump_bmp(_x, __func__, __LINE__) 6349633ac8dSGeoff Levand static void _dump_bmp(struct ps3_private* pd, const char* func, int line) 6352832a81dSGeoff Levand { 6362832a81dSGeoff Levand unsigned long flags; 6372832a81dSGeoff Levand 63832b9074bSGeoff Levand spin_lock_irqsave(&pd->bmp_lock, flags); 639aab83500SGeoff Levand _dump_64_bmp("stat", &pd->bmp.status, pd->thread_id, func, line); 64032b9074bSGeoff Levand _dump_64_bmp("mask", (u64*)&pd->bmp.mask, pd->thread_id, func, line); 64132b9074bSGeoff Levand spin_unlock_irqrestore(&pd->bmp_lock, flags); 6422832a81dSGeoff Levand } 6432832a81dSGeoff Levand 6442832a81dSGeoff Levand #define dump_mask(_x) _dump_mask(_x, __func__, __LINE__) 645848cfdc5SGeoff Levand static void __maybe_unused _dump_mask(struct ps3_private *pd, 6462832a81dSGeoff Levand const char* func, int line) 6472832a81dSGeoff Levand { 6482832a81dSGeoff Levand unsigned long flags; 6492832a81dSGeoff Levand 65032b9074bSGeoff Levand spin_lock_irqsave(&pd->bmp_lock, flags); 65132b9074bSGeoff Levand _dump_64_bmp("mask", (u64*)&pd->bmp.mask, pd->thread_id, func, line); 65232b9074bSGeoff Levand spin_unlock_irqrestore(&pd->bmp_lock, flags); 6532832a81dSGeoff Levand } 6542832a81dSGeoff Levand #else 6559633ac8dSGeoff Levand static void dump_bmp(struct ps3_private* pd) {}; 6562832a81dSGeoff Levand #endif /* defined(DEBUG) */ 6572832a81dSGeoff Levand 658bae1d8f1SGrant Likely static int ps3_host_map(struct irq_domain *h, unsigned int virq, 6592832a81dSGeoff Levand irq_hw_number_t hwirq) 6602832a81dSGeoff Levand { 66132b9074bSGeoff Levand DBG("%s:%d: hwirq %lu, virq %u\n", __func__, __LINE__, hwirq, 662861be32cSGeoff Levand virq); 6632832a81dSGeoff Levand 664ec775d0eSThomas Gleixner irq_set_chip_and_handler(virq, &ps3_irq_chip, handle_fasteoi_irq); 6652832a81dSGeoff Levand 666861be32cSGeoff Levand return 0; 6672832a81dSGeoff Levand } 6682832a81dSGeoff Levand 669ad3aedfbSMarc Zyngier static int ps3_host_match(struct irq_domain *h, struct device_node *np, 670ad3aedfbSMarc Zyngier enum irq_domain_bus_token bus_token) 6718528ab84SMichael Ellerman { 6728528ab84SMichael Ellerman /* Match all */ 6738528ab84SMichael Ellerman return 1; 6748528ab84SMichael Ellerman } 6758528ab84SMichael Ellerman 6769f70b8ebSGrant Likely static const struct irq_domain_ops ps3_host_ops = { 6779633ac8dSGeoff Levand .map = ps3_host_map, 6788528ab84SMichael Ellerman .match = ps3_host_match, 6792832a81dSGeoff Levand }; 6802832a81dSGeoff Levand 6812832a81dSGeoff Levand void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq) 6822832a81dSGeoff Levand { 6839633ac8dSGeoff Levand struct ps3_private *pd = &per_cpu(ps3_private, cpu); 6842832a81dSGeoff Levand 68532b9074bSGeoff Levand set_bit(63 - virq, &pd->ipi_debug_brk_mask); 6862832a81dSGeoff Levand 68732b9074bSGeoff Levand DBG("%s:%d: cpu %u, virq %u, mask %lxh\n", __func__, __LINE__, 68832b9074bSGeoff Levand cpu, virq, pd->ipi_debug_brk_mask); 6892832a81dSGeoff Levand } 6902832a81dSGeoff Levand 69172f3bea0SGeoff Levand void __init ps3_register_ipi_irq(unsigned int cpu, unsigned int virq) 69272f3bea0SGeoff Levand { 69372f3bea0SGeoff Levand struct ps3_private *pd = &per_cpu(ps3_private, cpu); 69472f3bea0SGeoff Levand 69572f3bea0SGeoff Levand set_bit(63 - virq, &pd->ipi_mask); 69672f3bea0SGeoff Levand 69772f3bea0SGeoff Levand DBG("%s:%d: cpu %u, virq %u, ipi_mask %lxh\n", __func__, __LINE__, 69872f3bea0SGeoff Levand cpu, virq, pd->ipi_mask); 69972f3bea0SGeoff Levand } 70072f3bea0SGeoff Levand 7019263e85aSGeoff Levand static unsigned int ps3_get_irq(void) 7022832a81dSGeoff Levand { 70369111bacSChristoph Lameter struct ps3_private *pd = this_cpu_ptr(&ps3_private); 704861be32cSGeoff Levand u64 x = (pd->bmp.status & pd->bmp.mask); 7059cf9e196SBenjamin Herrenschmidt unsigned int plug; 7062832a81dSGeoff Levand 7072832a81dSGeoff Levand /* check for ipi break first to stop this cpu ASAP */ 7082832a81dSGeoff Levand 70932b9074bSGeoff Levand if (x & pd->ipi_debug_brk_mask) 71032b9074bSGeoff Levand x &= pd->ipi_debug_brk_mask; 7112832a81dSGeoff Levand 7129cf9e196SBenjamin Herrenschmidt asm volatile("cntlzd %0,%1" : "=r" (plug) : "r" (x)); 7139cf9e196SBenjamin Herrenschmidt plug &= 0x3f; 7142832a81dSGeoff Levand 715ef24ba70SMichael Ellerman if (unlikely(!plug)) { 71632b9074bSGeoff Levand DBG("%s:%d: no plug found: thread_id %llu\n", __func__, 717aab83500SGeoff Levand __LINE__, pd->thread_id); 7189633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 0)); 7199633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 1)); 720ef24ba70SMichael Ellerman return 0; 7212832a81dSGeoff Levand } 7222832a81dSGeoff Levand 7232832a81dSGeoff Levand #if defined(DEBUG) 7249cf9e196SBenjamin Herrenschmidt if (unlikely(plug < NUM_ISA_INTERRUPTS || plug > PS3_PLUG_MAX)) { 7259633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 0)); 7269633ac8dSGeoff Levand dump_bmp(&per_cpu(ps3_private, 1)); 7272832a81dSGeoff Levand BUG(); 7282832a81dSGeoff Levand } 7292832a81dSGeoff Levand #endif 73072f3bea0SGeoff Levand 73172f3bea0SGeoff Levand /* IPIs are EOIed here. */ 73272f3bea0SGeoff Levand 73372f3bea0SGeoff Levand if (test_bit(63 - plug, &pd->ipi_mask)) 73472f3bea0SGeoff Levand lv1_end_of_interrupt_ext(pd->ppe_id, pd->thread_id, plug); 73572f3bea0SGeoff Levand 7362832a81dSGeoff Levand return plug; 7372832a81dSGeoff Levand } 7382832a81dSGeoff Levand 7392832a81dSGeoff Levand void __init ps3_init_IRQ(void) 7402832a81dSGeoff Levand { 7412832a81dSGeoff Levand int result; 7422832a81dSGeoff Levand unsigned cpu; 743bae1d8f1SGrant Likely struct irq_domain *host; 7442832a81dSGeoff Levand 7456fa6c8e2SGrant Likely host = irq_domain_add_nomap(NULL, PS3_PLUG_MAX + 1, &ps3_host_ops, NULL); 7462832a81dSGeoff Levand irq_set_default_host(host); 7472832a81dSGeoff Levand 7482832a81dSGeoff Levand for_each_possible_cpu(cpu) { 7499633ac8dSGeoff Levand struct ps3_private *pd = &per_cpu(ps3_private, cpu); 7502832a81dSGeoff Levand 751aab83500SGeoff Levand lv1_get_logical_ppe_id(&pd->ppe_id); 752aab83500SGeoff Levand pd->thread_id = get_hard_smp_processor_id(cpu); 75332b9074bSGeoff Levand spin_lock_init(&pd->bmp_lock); 7542832a81dSGeoff Levand 75532b9074bSGeoff Levand DBG("%s:%d: ppe_id %llu, thread_id %llu, bmp %lxh\n", 756aab83500SGeoff Levand __func__, __LINE__, pd->ppe_id, pd->thread_id, 757407e24a0SGeoff Levand ps3_mm_phys_to_lpar(__pa(&pd->bmp))); 758407e24a0SGeoff Levand 759aab83500SGeoff Levand result = lv1_configure_irq_state_bitmap(pd->ppe_id, 760aab83500SGeoff Levand pd->thread_id, ps3_mm_phys_to_lpar(__pa(&pd->bmp))); 7612832a81dSGeoff Levand 7622832a81dSGeoff Levand if (result) 76332b9074bSGeoff Levand FAIL("%s:%d: lv1_configure_irq_state_bitmap failed:" 7642832a81dSGeoff Levand " %s\n", __func__, __LINE__, 7652832a81dSGeoff Levand ps3_result(result)); 7662832a81dSGeoff Levand } 7672832a81dSGeoff Levand 7682832a81dSGeoff Levand ppc_md.get_irq = ps3_get_irq; 7692832a81dSGeoff Levand } 7709263e85aSGeoff Levand 7719263e85aSGeoff Levand void ps3_shutdown_IRQ(int cpu) 7729263e85aSGeoff Levand { 7739263e85aSGeoff Levand int result; 7749263e85aSGeoff Levand u64 ppe_id; 7759263e85aSGeoff Levand u64 thread_id = get_hard_smp_processor_id(cpu); 7769263e85aSGeoff Levand 7779263e85aSGeoff Levand lv1_get_logical_ppe_id(&ppe_id); 7789263e85aSGeoff Levand result = lv1_configure_irq_state_bitmap(ppe_id, thread_id, 0); 7799263e85aSGeoff Levand 7805c949070SStephen Rothwell DBG("%s:%d: lv1_configure_irq_state_bitmap (%llu:%llu/%d) %s\n", __func__, 7819263e85aSGeoff Levand __LINE__, ppe_id, thread_id, cpu, ps3_result(result)); 7829263e85aSGeoff Levand } 783