USB: xHCI: prevent infinite loop when processing MSE event
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / powerpc / platforms / ps3 / smp.c
blob4c44794faac0b344ac50663ed12122519c37b53d
1 /*
2 * PS3 SMP routines.
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/kernel.h>
22 #include <linux/smp.h>
24 #include <asm/machdep.h>
25 #include <asm/udbg.h>
27 #include "platform.h"
29 #if defined(DEBUG)
30 #define DBG udbg_printf
31 #else
32 #define DBG pr_debug
33 #endif
35 /**
36 * ps3_ipi_virqs - a per cpu array of virqs for ipi use
39 #define MSG_COUNT 4
40 static DEFINE_PER_CPU(unsigned int [MSG_COUNT], ps3_ipi_virqs);
42 static void ps3_smp_message_pass(int cpu, int msg)
44 int result;
45 unsigned int virq;
47 if (msg >= MSG_COUNT) {
48 DBG("%s:%d: bad msg: %d\n", __func__, __LINE__, msg);
49 return;
52 virq = per_cpu(ps3_ipi_virqs, cpu)[msg];
53 result = ps3_send_event_locally(virq);
55 if (result)
56 DBG("%s:%d: ps3_send_event_locally(%d, %d) failed"
57 " (%d)\n", __func__, __LINE__, cpu, msg, result);
60 static int ps3_smp_probe(void)
62 return 2;
65 static void __init ps3_smp_setup_cpu(int cpu)
67 int result;
68 unsigned int *virqs = per_cpu(ps3_ipi_virqs, cpu);
69 int i;
71 DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
74 * Check assumptions on ps3_ipi_virqs[] indexing. If this
75 * check fails, then a different mapping of PPC_MSG_
76 * to index needs to be setup.
79 BUILD_BUG_ON(PPC_MSG_CALL_FUNCTION != 0);
80 BUILD_BUG_ON(PPC_MSG_RESCHEDULE != 1);
81 BUILD_BUG_ON(PPC_MSG_CALL_FUNC_SINGLE != 2);
82 BUILD_BUG_ON(PPC_MSG_DEBUGGER_BREAK != 3);
84 for (i = 0; i < MSG_COUNT; i++) {
85 result = ps3_event_receive_port_setup(cpu, &virqs[i]);
87 if (result)
88 continue;
90 DBG("%s:%d: (%d, %d) => virq %u\n",
91 __func__, __LINE__, cpu, i, virqs[i]);
93 result = smp_request_message_ipi(virqs[i], i);
95 if (result)
96 virqs[i] = NO_IRQ;
99 ps3_register_ipi_debug_brk(cpu, virqs[PPC_MSG_DEBUGGER_BREAK]);
101 DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);
104 void ps3_smp_cleanup_cpu(int cpu)
106 unsigned int *virqs = per_cpu(ps3_ipi_virqs, cpu);
107 int i;
109 DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
111 for (i = 0; i < MSG_COUNT; i++) {
112 /* Can't call free_irq from interrupt context. */
113 ps3_event_receive_port_destroy(virqs[i]);
114 virqs[i] = NO_IRQ;
117 DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);
120 static struct smp_ops_t ps3_smp_ops = {
121 .probe = ps3_smp_probe,
122 .message_pass = ps3_smp_message_pass,
123 .kick_cpu = smp_generic_kick_cpu,
124 .setup_cpu = ps3_smp_setup_cpu,
127 void smp_init_ps3(void)
129 DBG(" -> %s\n", __func__);
130 smp_ops = &ps3_smp_ops;
131 DBG(" <- %s\n", __func__);