Path: blob/master/arch/powerpc/platforms/ps3/smp.c
10818 views
/*1* PS3 SMP routines.2*3* Copyright (C) 2006 Sony Computer Entertainment Inc.4* Copyright 2006 Sony Corp.5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; version 2 of the License.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920#include <linux/kernel.h>21#include <linux/smp.h>2223#include <asm/machdep.h>24#include <asm/udbg.h>2526#include "platform.h"2728#if defined(DEBUG)29#define DBG udbg_printf30#else31#define DBG pr_debug32#endif3334/**35* ps3_ipi_virqs - a per cpu array of virqs for ipi use36*/3738#define MSG_COUNT 439static DEFINE_PER_CPU(unsigned int [MSG_COUNT], ps3_ipi_virqs);4041static void ps3_smp_message_pass(int cpu, int msg)42{43int result;44unsigned int virq;4546if (msg >= MSG_COUNT) {47DBG("%s:%d: bad msg: %d\n", __func__, __LINE__, msg);48return;49}5051virq = per_cpu(ps3_ipi_virqs, cpu)[msg];52result = ps3_send_event_locally(virq);5354if (result)55DBG("%s:%d: ps3_send_event_locally(%d, %d) failed"56" (%d)\n", __func__, __LINE__, cpu, msg, result);57}5859static int ps3_smp_probe(void)60{61return 2;62}6364static void __init ps3_smp_setup_cpu(int cpu)65{66int result;67unsigned int *virqs = per_cpu(ps3_ipi_virqs, cpu);68int i;6970DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);7172/*73* Check assumptions on ps3_ipi_virqs[] indexing. If this74* check fails, then a different mapping of PPC_MSG_75* to index needs to be setup.76*/7778BUILD_BUG_ON(PPC_MSG_CALL_FUNCTION != 0);79BUILD_BUG_ON(PPC_MSG_RESCHEDULE != 1);80BUILD_BUG_ON(PPC_MSG_CALL_FUNC_SINGLE != 2);81BUILD_BUG_ON(PPC_MSG_DEBUGGER_BREAK != 3);8283for (i = 0; i < MSG_COUNT; i++) {84result = ps3_event_receive_port_setup(cpu, &virqs[i]);8586if (result)87continue;8889DBG("%s:%d: (%d, %d) => virq %u\n",90__func__, __LINE__, cpu, i, virqs[i]);9192result = smp_request_message_ipi(virqs[i], i);9394if (result)95virqs[i] = NO_IRQ;96}9798ps3_register_ipi_debug_brk(cpu, virqs[PPC_MSG_DEBUGGER_BREAK]);99100DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);101}102103void ps3_smp_cleanup_cpu(int cpu)104{105unsigned int *virqs = per_cpu(ps3_ipi_virqs, cpu);106int i;107108DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);109110for (i = 0; i < MSG_COUNT; i++) {111/* Can't call free_irq from interrupt context. */112ps3_event_receive_port_destroy(virqs[i]);113virqs[i] = NO_IRQ;114}115116DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);117}118119static struct smp_ops_t ps3_smp_ops = {120.probe = ps3_smp_probe,121.message_pass = ps3_smp_message_pass,122.kick_cpu = smp_generic_kick_cpu,123.setup_cpu = ps3_smp_setup_cpu,124};125126void smp_init_ps3(void)127{128DBG(" -> %s\n", __func__);129smp_ops = &ps3_smp_ops;130DBG(" <- %s\n", __func__);131}132133134