Skip to content

Commit

Permalink
powerpc/pasemi: Use raw spinlock in SMP TB sync
Browse files Browse the repository at this point in the history
spin_lock() can hang if called while the timebase is frozen,
so use a raw lock instead, also disable interrupts while
at it.

Signed-off-by: Benjamin Herrenschmidt <[email protected]>
  • Loading branch information
ozbenh committed Jun 26, 2009
1 parent c4007a2 commit 6893ce6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions arch/powerpc/platforms/pasemi/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,36 @@ static void pas_restart(char *cmd)
}

#ifdef CONFIG_SMP
static DEFINE_SPINLOCK(timebase_lock);
static raw_spinlock_t timebase_lock;
static unsigned long timebase;

static void __devinit pas_give_timebase(void)
{
spin_lock(&timebase_lock);
unsigned long flags;

local_irq_save(flags);
hard_irq_disable();
__raw_spin_lock(&timebase_lock);
mtspr(SPRN_TBCTL, TBCTL_FREEZE);
isync();
timebase = get_tb();
spin_unlock(&timebase_lock);
__raw_spin_unlock(&timebase_lock);

while (timebase)
barrier();
mtspr(SPRN_TBCTL, TBCTL_RESTART);
local_irq_restore(flags);
}

static void __devinit pas_take_timebase(void)
{
while (!timebase)
smp_rmb();

spin_lock(&timebase_lock);
__raw_spin_lock(&timebase_lock);
set_tb(timebase >> 32, timebase & 0xffffffff);
timebase = 0;
spin_unlock(&timebase_lock);
__raw_spin_unlock(&timebase_lock);
}

struct smp_ops_t pas_smp_ops = {
Expand Down

0 comments on commit 6893ce6

Please sign in to comment.