Skip to content

Commit

Permalink
xtensa: ISS: fix specific simcalls
Browse files Browse the repository at this point in the history
Simcalls that take memory buffer definitely need wmb or rmb to make sure
gcc doesn't optimize away code that fills the buffer.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Chris Zankel <chris@zankel.net>
  • Loading branch information
Max Filippov authored and Chris Zankel committed Oct 16, 2012
1 parent ddffeb8 commit 50c08f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions arch/xtensa/platforms/iss/include/platform/simcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ static inline int __simc(int a, int b, int c, int d, int e, int f)
return ret;
}

static inline int simc_open(char *file, int flags, int mode)
static inline int simc_open(const char *file, int flags, int mode)
{
wmb();
return __simc(SYS_open, (int) file, flags, mode, 0, 0);
}

Expand All @@ -90,23 +91,27 @@ static inline int simc_close(int fd)

static inline int simc_ioctl(int fd, int request, void *arg)
{
wmb();
return __simc(SYS_ioctl, fd, request, (int) arg, 0, 0);
}

static inline int simc_read(int fd, void *buf, size_t count)
{
rmb();
return __simc(SYS_read, fd, (int) buf, count, 0, 0);
}

static inline int simc_write(int fd, void *buf, size_t count)
static inline int simc_write(int fd, const void *buf, size_t count)
{
wmb();
return __simc(SYS_write, fd, (int) buf, count, 0, 0);
}

static inline int simc_poll(int fd)
{
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };

wmb();
return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&tv,
0, 0);
}
Expand Down

0 comments on commit 50c08f8

Please sign in to comment.