lkml.org 
[lkml]   [2018]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] ARC: io.h: Implement reads{x}()/writes{x}()
Date
From: Jose Abreu
> Sent: 29 November 2018 14:29
>
> Some ARC CPU's do not support unaligned loads/stores. Currently, generic
> implementation of reads{b/w/l}()/writes{b/w/l}() is being used with ARC.
> This can lead to misfunction of some drivers as generic functions do a
> plain dereference of a pointer that can be unaligned.
>
> Let's use {get/put}_unaligned() helper instead of plain dereference of
> pointer in order to fix this.
...
> +#define __raw_readsx(t,f) \
> +static inline void __raw_reads##f(const volatile void __iomem *addr, \
> + void *buffer, unsigned int count) \
> +{ \
> + if (count) { \
> + const unsigned long bptr = (unsigned long)buffer; \
> + u##t *buf = buffer; \
> +\
> + do { \
> + u##t x = __raw_read##f(addr); \
> +\
> + /* Some ARC CPU's don't support unaligned accesses */ \
> + if (bptr % ((t) / 8)) { \
> + put_unaligned(x, buf++); \
> + } else { \
> + *buf++ = x; \
> + } \
> + } while (--count); \
> + } \
> +}

Does the compiler move the alignment test outside the loop?
You really want two copies of the loop body.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2018-11-29 15:40    [W:0.111 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site