Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering

memory-barriers.txt has been updated with the following requirement.

"When using writel(), a prior wmb() is not needed to guarantee that the
cache coherent memory writes have completed before writing to the MMIO
region."

Current writeX() and iowriteX() implementations on alpha are not
satisfying this requirement as the barrier is after the register write.

Move mb() in writeX() and iowriteX() functions to guarantee that HW
observes memory changes before performing register operations.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Turner <mattst88@gmail.com>

authored by

Sinan Kaya and committed by
Matt Turner
cd0e00c1 6fd16ce5

+7 -7
+7 -7
arch/alpha/include/asm/io.h
··· 341 341 342 342 extern inline void iowrite8(u8 b, void __iomem *addr) 343 343 { 344 - IO_CONCAT(__IO_PREFIX,iowrite8)(b, addr); 345 344 mb(); 345 + IO_CONCAT(__IO_PREFIX, iowrite8)(b, addr); 346 346 } 347 347 348 348 extern inline void iowrite16(u16 b, void __iomem *addr) 349 349 { 350 - IO_CONCAT(__IO_PREFIX,iowrite16)(b, addr); 351 350 mb(); 351 + IO_CONCAT(__IO_PREFIX, iowrite16)(b, addr); 352 352 } 353 353 354 354 extern inline u8 inb(unsigned long port) ··· 382 382 383 383 extern inline void iowrite32(u32 b, void __iomem *addr) 384 384 { 385 - IO_CONCAT(__IO_PREFIX,iowrite32)(b, addr); 386 385 mb(); 386 + IO_CONCAT(__IO_PREFIX, iowrite32)(b, addr); 387 387 } 388 388 389 389 extern inline u32 inl(unsigned long port) ··· 434 434 435 435 extern inline void writeb(u8 b, volatile void __iomem *addr) 436 436 { 437 - __raw_writeb(b, addr); 438 437 mb(); 438 + __raw_writeb(b, addr); 439 439 } 440 440 441 441 extern inline void writew(u16 b, volatile void __iomem *addr) 442 442 { 443 - __raw_writew(b, addr); 444 443 mb(); 444 + __raw_writew(b, addr); 445 445 } 446 446 #endif 447 447 ··· 482 482 483 483 extern inline void writel(u32 b, volatile void __iomem *addr) 484 484 { 485 - __raw_writel(b, addr); 486 485 mb(); 486 + __raw_writel(b, addr); 487 487 } 488 488 489 489 extern inline void writeq(u64 b, volatile void __iomem *addr) 490 490 { 491 - __raw_writeq(b, addr); 492 491 mb(); 492 + __raw_writeq(b, addr); 493 493 } 494 494 #endif 495 495