Skip to content

Commit

Permalink
[POWERPC] Make mmiowb's io_sync preempt safe
Browse files Browse the repository at this point in the history
If mmiowb() is always used prior to releasing spinlock as Doc suggests,
then it's safe against preemption; but I'm not convinced that's always
the case.  If preemption occurs between sync and get_paca()->io_sync = 0,
I believe there's no problem.  But in the unlikely event that gcc does
the store relative to another register than r13 (as it did with current),
then there's a small danger of setting another cpu's io_sync to 0, after
it had just set it to 1.  Rewrite ppc64 mmiowb to prevent that.

The remaining io_sync assignments in io.h all get_paca()->io_sync = 1,
which is harmless even if preempted to the wrong cpu (the context switch
itself syncs); and those in spinlock.h are while preemption is disabled.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Hugh Dickins authored and Paul Mackerras committed Nov 1, 2006
1 parent 9626888 commit 292f86f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/asm-powerpc/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);

static inline void mmiowb(void)
{
__asm__ __volatile__ ("sync" : : : "memory");
get_paca()->io_sync = 0;
unsigned long tmp;

__asm__ __volatile__("sync; li %0,0; stb %0,%1(13)"
: "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync))
: "memory");
}

/*
Expand Down

0 comments on commit 292f86f

Please sign in to comment.