提交 f97bb36f 编写于 作者: B Benjamin Herrenschmidt

powerpc/rtas: Turn rtas lock into a raw spinlock

RTAS currently uses a normal spinlock. However it can be called from
contexts where this is not necessarily a good idea. For example, it
can be called while syncing timebases, with the core timebase being
frozen. Unfortunately, that will deadlock in case of lock contention
when spinlock debugging is enabled as the spin lock debugging code
will try to use __delay() which ... relies on the timebase being
enabled.

Also RTAS can be used in some low level IRQ handling code path so it
may as well be a raw spinlock for -rt sake.
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
上级 5d38902c
...@@ -58,7 +58,7 @@ struct rtas_t { ...@@ -58,7 +58,7 @@ struct rtas_t {
unsigned long entry; /* physical address pointer */ unsigned long entry; /* physical address pointer */
unsigned long base; /* physical address pointer */ unsigned long base; /* physical address pointer */
unsigned long size; unsigned long size;
spinlock_t lock; raw_spinlock_t lock;
struct rtas_args args; struct rtas_args args;
struct device_node *dev; /* virtual address pointer */ struct device_node *dev; /* virtual address pointer */
}; };
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <asm/atomic.h> #include <asm/atomic.h>
struct rtas_t rtas = { struct rtas_t rtas = {
.lock = SPIN_LOCK_UNLOCKED .lock = __RAW_SPIN_LOCK_UNLOCKED
}; };
EXPORT_SYMBOL(rtas); EXPORT_SYMBOL(rtas);
...@@ -67,6 +67,28 @@ unsigned long rtas_rmo_buf; ...@@ -67,6 +67,28 @@ unsigned long rtas_rmo_buf;
void (*rtas_flash_term_hook)(int); void (*rtas_flash_term_hook)(int);
EXPORT_SYMBOL(rtas_flash_term_hook); EXPORT_SYMBOL(rtas_flash_term_hook);
/* RTAS use home made raw locking instead of spin_lock_irqsave
* because those can be called from within really nasty contexts
* such as having the timebase stopped which would lockup with
* normal locks and spinlock debugging enabled
*/
static unsigned long lock_rtas(void)
{
unsigned long flags;
local_irq_save(flags);
preempt_disable();
__raw_spin_lock_flags(&rtas.lock, flags);
return flags;
}
static void unlock_rtas(unsigned long flags)
{
__raw_spin_unlock(&rtas.lock);
local_irq_restore(flags);
preempt_enable();
}
/* /*
* call_rtas_display_status and call_rtas_display_status_delay * call_rtas_display_status and call_rtas_display_status_delay
* are designed only for very early low-level debugging, which * are designed only for very early low-level debugging, which
...@@ -79,7 +101,7 @@ static void call_rtas_display_status(char c) ...@@ -79,7 +101,7 @@ static void call_rtas_display_status(char c)
if (!rtas.base) if (!rtas.base)
return; return;
spin_lock_irqsave(&rtas.lock, s); s = lock_rtas();
args->token = 10; args->token = 10;
args->nargs = 1; args->nargs = 1;
...@@ -89,7 +111,7 @@ static void call_rtas_display_status(char c) ...@@ -89,7 +111,7 @@ static void call_rtas_display_status(char c)
enter_rtas(__pa(args)); enter_rtas(__pa(args));
spin_unlock_irqrestore(&rtas.lock, s); unlock_rtas(s);
} }
static void call_rtas_display_status_delay(char c) static void call_rtas_display_status_delay(char c)
...@@ -411,8 +433,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...) ...@@ -411,8 +433,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
return -1; return -1;
/* Gotta do something different here, use global lock for now... */ s = lock_rtas();
spin_lock_irqsave(&rtas.lock, s);
rtas_args = &rtas.args; rtas_args = &rtas.args;
rtas_args->token = token; rtas_args->token = token;
...@@ -439,8 +460,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...) ...@@ -439,8 +460,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
outputs[i] = rtas_args->rets[i+1]; outputs[i] = rtas_args->rets[i+1];
ret = (nret > 0)? rtas_args->rets[0]: 0; ret = (nret > 0)? rtas_args->rets[0]: 0;
/* Gotta do something different here, use global lock for now... */ unlock_rtas(s);
spin_unlock_irqrestore(&rtas.lock, s);
if (buff_copy) { if (buff_copy) {
log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0); log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0);
...@@ -837,7 +857,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs) ...@@ -837,7 +857,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
buff_copy = get_errorlog_buffer(); buff_copy = get_errorlog_buffer();
spin_lock_irqsave(&rtas.lock, flags); flags = lock_rtas();
rtas.args = args; rtas.args = args;
enter_rtas(__pa(&rtas.args)); enter_rtas(__pa(&rtas.args));
...@@ -848,7 +868,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs) ...@@ -848,7 +868,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
if (args.rets[0] == -1) if (args.rets[0] == -1)
errbuf = __fetch_rtas_last_error(buff_copy); errbuf = __fetch_rtas_last_error(buff_copy);
spin_unlock_irqrestore(&rtas.lock, flags); unlock_rtas(flags);
if (buff_copy) { if (buff_copy) {
if (errbuf) if (errbuf)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册