Re: [PATCH v3] ARC: io.h: Implement reads{x}()/writes{x}()

From: Vineet Gupta
Date: Fri Nov 30 2018 - 14:29:47 EST


On 11/30/18 1:47 AM, Jose Abreu wrote:
> 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() helpers instead of plain dereference of
> pointer in order to fix. The helpers allow to get and store data from an
> unaligned address whilst preserving the CPU internal alignment.
> According to [1], the use of these helpers are costly in terms of
> performance so we added an initial check for a buffer already aligned so
> that the usage of the helpers can be avoided, when possible.
>
> [1] Documentation/unaligned-memory-access.txt
>
> Changes from v2:
> - Rework commit msg (Vineet)
> - Check if count is 0 and return (Vineet)
> - Use two different loops (Vineet)
>
> Changes from v1:
> - Check if buffer is already aligned (David)
> - Remove 64 bit mention (Alexey)
>
> Signed-off-by: Jose Abreu <joabreu@xxxxxxxxxxxx>
> Tested-by: Vitor Soares <soares@xxxxxxxxxxxx>
> Cc: Vineet Gupta <vgupta@xxxxxxxxxxxx>
> Cc: Alexey Brodkin <abrodkin@xxxxxxxxxxxx>
> Cc: Joao Pinto <jpinto@xxxxxxxxxxxx>
> Cc: Vitor Soares <soares@xxxxxxxxxxxx>
> Cc: David Laight <David.Laight@xxxxxxxxxx>

Applied to for-curr after some minor chg (added a comment about accessor)

Thx,
-Vineet