On Mon, Feb 3, 2025, at 11:21, Julian Vetter wrote: > On 1/31/25 08:28, Arnd Bergmann wrote: >> Those functions have been unchanged since before the git >> history and there are some comments that I don't find helpful. >> One thing they do is to deal with unaligned memory buffers, >> which the generic ones don't, but that could be easily added >> using get_unaligned/put_unaligned, expecting the compiler >> to optimize the memory side of the transfer. > > I'm not sure what you suggest. Do you mean adding > get_unaligned/put_unaligned in the generic include/asm-generic/io.h > functions, or just adding get_unaligned/put_unaligned to the body of the > parisc specific functions? Instead of all the "switch... case 0x2..." code? I meant adding put_unaligned/get_unaligned like this: --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -422,7 +422,8 @@ static inline void readsw(const volatile void __iomem *addr, void *buffer, do { u16 x = __raw_readw(addr); - *buf++ = x; + put_unaligned(x, buf); + buf++; } while (--count); } } This has no effect on architectures that can handle unaligned load/store on memory, and should behave the same way as the parisc code otherwise. On powerpc and possibly others, there needs to be a barrier (eieio() on powerpc) inside of the loop, according to Segher's earlier comments. Arnd