2019-05-27 06:55:15 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2006-11-22 23:46:51 +00:00
|
|
|
/*
|
|
|
|
* PS3 SMP routines.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Sony Computer Entertainment Inc.
|
|
|
|
* Copyright 2006 Sony Corp.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/udbg.h>
|
|
|
|
|
|
|
|
#include "platform.h"
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2007-06-15 21:19:23 +00:00
|
|
|
#define DBG udbg_printf
|
2006-11-22 23:46:51 +00:00
|
|
|
#else
|
2007-06-15 21:19:23 +00:00
|
|
|
#define DBG pr_debug
|
2006-11-22 23:46:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2007-06-15 21:17:42 +00:00
|
|
|
* ps3_ipi_virqs - a per cpu array of virqs for ipi use
|
2006-11-22 23:46:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define MSG_COUNT 4
|
2009-06-24 06:13:45 +00:00
|
|
|
static DEFINE_PER_CPU(unsigned int [MSG_COUNT], ps3_ipi_virqs);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-05-10 19:29:10 +00:00
|
|
|
static void ps3_smp_message_pass(int cpu, int msg)
|
2006-11-22 23:46:51 +00:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
unsigned int virq;
|
|
|
|
|
|
|
|
if (msg >= MSG_COUNT) {
|
|
|
|
DBG("%s:%d: bad msg: %d\n", __func__, __LINE__, msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-10 19:29:10 +00:00
|
|
|
virq = per_cpu(ps3_ipi_virqs, cpu)[msg];
|
2006-11-22 23:46:51 +00:00
|
|
|
result = ps3_send_event_locally(virq);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
DBG("%s:%d: ps3_send_event_locally(%d, %d) failed"
|
2011-05-10 19:29:10 +00:00
|
|
|
" (%d)\n", __func__, __LINE__, cpu, msg, result);
|
2006-11-22 23:46:51 +00:00
|
|
|
}
|
|
|
|
|
2015-04-04 08:28:50 +00:00
|
|
|
static void __init ps3_smp_probe(void)
|
2006-11-22 23:46:51 +00:00
|
|
|
{
|
2011-11-08 12:38:21 +00:00
|
|
|
int cpu;
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
for (cpu = 0; cpu < 2; cpu++) {
|
|
|
|
int result;
|
|
|
|
unsigned int *virqs = per_cpu(ps3_ipi_virqs, cpu);
|
|
|
|
int i;
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
/*
|
|
|
|
* Check assumptions on ps3_ipi_virqs[] indexing. If this
|
|
|
|
* check fails, then a different mapping of PPC_MSG_
|
|
|
|
* to index needs to be setup.
|
|
|
|
*/
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
BUILD_BUG_ON(PPC_MSG_CALL_FUNCTION != 0);
|
|
|
|
BUILD_BUG_ON(PPC_MSG_RESCHEDULE != 1);
|
2014-02-26 00:07:43 +00:00
|
|
|
BUILD_BUG_ON(PPC_MSG_TICK_BROADCAST != 2);
|
2016-12-19 18:30:08 +00:00
|
|
|
BUILD_BUG_ON(PPC_MSG_NMI_IPI != 3);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
for (i = 0; i < MSG_COUNT; i++) {
|
|
|
|
result = ps3_event_receive_port_setup(cpu, &virqs[i]);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
if (result)
|
|
|
|
continue;
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
DBG("%s:%d: (%d, %d) => virq %u\n",
|
|
|
|
__func__, __LINE__, cpu, i, virqs[i]);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
result = smp_request_message_ipi(virqs[i], i);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
if (result)
|
2016-09-06 11:53:24 +00:00
|
|
|
virqs[i] = 0;
|
2011-11-08 12:38:21 +00:00
|
|
|
else
|
|
|
|
ps3_register_ipi_irq(cpu, virqs[i]);
|
|
|
|
}
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2016-12-19 18:30:08 +00:00
|
|
|
ps3_register_ipi_debug_brk(cpu, virqs[PPC_MSG_NMI_IPI]);
|
2006-11-22 23:46:51 +00:00
|
|
|
|
2011-11-08 12:38:21 +00:00
|
|
|
DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);
|
|
|
|
}
|
2006-11-22 23:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ps3_smp_cleanup_cpu(int cpu)
|
|
|
|
{
|
2007-06-15 21:17:42 +00:00
|
|
|
unsigned int *virqs = per_cpu(ps3_ipi_virqs, cpu);
|
2006-11-22 23:46:51 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
|
2007-04-30 21:01:01 +00:00
|
|
|
|
2006-11-22 23:46:51 +00:00
|
|
|
for (i = 0; i < MSG_COUNT; i++) {
|
2007-06-15 21:19:32 +00:00
|
|
|
/* Can't call free_irq from interrupt context. */
|
2007-04-30 21:01:01 +00:00
|
|
|
ps3_event_receive_port_destroy(virqs[i]);
|
2016-09-06 11:53:24 +00:00
|
|
|
virqs[i] = 0;
|
2006-11-22 23:46:51 +00:00
|
|
|
}
|
2007-04-30 21:01:01 +00:00
|
|
|
|
2006-11-22 23:46:51 +00:00
|
|
|
DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct smp_ops_t ps3_smp_ops = {
|
|
|
|
.probe = ps3_smp_probe,
|
|
|
|
.message_pass = ps3_smp_message_pass,
|
|
|
|
.kick_cpu = smp_generic_kick_cpu,
|
|
|
|
};
|
|
|
|
|
2021-12-16 22:00:28 +00:00
|
|
|
void __init smp_init_ps3(void)
|
2006-11-22 23:46:51 +00:00
|
|
|
{
|
|
|
|
DBG(" -> %s\n", __func__);
|
|
|
|
smp_ops = &ps3_smp_ops;
|
|
|
|
DBG(" <- %s\n", __func__);
|
|
|
|
}
|