Skip to content

Commit f009c89

Browse files
John Garryjoyxu
authored andcommitted
io: Provide _inX() and _outX()
Since commit a7851aa ("io: change outX() to have their own IO barrier overrides") and commit 87fe2d5 ("io: change inX() to have their own IO barrier overrides"), the outX and inX functions have memory barriers which can be overridden. However, the generic logic_pio lib has continued to use readl/writel et al for IO port accesses, which has weaker barriers on arm64. Provide generic _inX() and _outX(), which can be used by logic pio. For consistency, we check for !defined({in,out}X) && !defined(_{in,out}X), for defining _{in,out}X, while a check for just !defined({in,out}X) should suffice. Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Wei Xu <[email protected]>
1 parent 8f3d9f3 commit f009c89

File tree

1 file changed

+44
-20
lines changed
  • include/asm-generic

1 file changed

+44
-20
lines changed

include/asm-generic/io.h

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,15 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
448448
#define IO_SPACE_LIMIT 0xffff
449449
#endif
450450

451-
#include <linux/logic_pio.h>
452-
453451
/*
454452
* {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
455453
* implemented on hardware that needs an additional delay for I/O accesses to
456454
* take effect.
457455
*/
458456

459-
#ifndef inb
460-
#define inb inb
461-
static inline u8 inb(unsigned long addr)
457+
#if !defined(inb) && !defined(_inb)
458+
#define _inb _inb
459+
static inline u16 _inb(unsigned long addr)
462460
{
463461
u8 val;
464462

@@ -469,9 +467,9 @@ static inline u8 inb(unsigned long addr)
469467
}
470468
#endif
471469

472-
#ifndef inw
473-
#define inw inw
474-
static inline u16 inw(unsigned long addr)
470+
#if !defined(inw) && !defined(_inw)
471+
#define _inw _inw
472+
static inline u16 _inw(unsigned long addr)
475473
{
476474
u16 val;
477475

@@ -482,9 +480,9 @@ static inline u16 inw(unsigned long addr)
482480
}
483481
#endif
484482

485-
#ifndef inl
486-
#define inl inl
487-
static inline u32 inl(unsigned long addr)
483+
#if !defined(inl) && !defined(_inl)
484+
#define _inl _inl
485+
static inline u16 _inl(unsigned long addr)
488486
{
489487
u32 val;
490488

@@ -495,36 +493,62 @@ static inline u32 inl(unsigned long addr)
495493
}
496494
#endif
497495

498-
#ifndef outb
499-
#define outb outb
500-
static inline void outb(u8 value, unsigned long addr)
496+
#if !defined(outb) && !defined(_outb)
497+
#define _outb _outb
498+
static inline void _outb(u8 value, unsigned long addr)
501499
{
502500
__io_pbw();
503501
__raw_writeb(value, PCI_IOBASE + addr);
504502
__io_paw();
505503
}
506504
#endif
507505

508-
#ifndef outw
509-
#define outw outw
510-
static inline void outw(u16 value, unsigned long addr)
506+
#if !defined(outw) && !defined(_outw)
507+
#define _outw _outw
508+
static inline void _outw(u16 value, unsigned long addr)
511509
{
512510
__io_pbw();
513511
__raw_writew(cpu_to_le16(value), PCI_IOBASE + addr);
514512
__io_paw();
515513
}
516514
#endif
517515

518-
#ifndef outl
519-
#define outl outl
520-
static inline void outl(u32 value, unsigned long addr)
516+
#if !defined(outl) && !defined(_outl)
517+
#define _outl _outl
518+
static inline void _outl(u32 value, unsigned long addr)
521519
{
522520
__io_pbw();
523521
__raw_writel(cpu_to_le32(value), PCI_IOBASE + addr);
524522
__io_paw();
525523
}
526524
#endif
527525

526+
#include <linux/logic_pio.h>
527+
528+
#ifndef inb
529+
#define inb _inb
530+
#endif
531+
532+
#ifndef inw
533+
#define inw _inw
534+
#endif
535+
536+
#ifndef inl
537+
#define inl _inl
538+
#endif
539+
540+
#ifndef outb
541+
#define outb _outb
542+
#endif
543+
544+
#ifndef outw
545+
#define outw _outw
546+
#endif
547+
548+
#ifndef outl
549+
#define outl _outl
550+
#endif
551+
528552
#ifndef inb_p
529553
#define inb_p inb_p
530554
static inline u8 inb_p(unsigned long addr)

0 commit comments

Comments
 (0)