Skip to content

Commit e7cc9a7

Browse files
papadammpmundt
authored andcommitted
sh: trapped io support V2
The idea is that we want to get rid of the in/out/readb/writeb callbacks from the machvec and replace that with simple inline read and write operations to memory. Fast and simple for most hardware devices (think pci). Some devices require special treatment though - like 16-bit only CF devices - so we need to have some method to hook in callbacks. This patch makes it possible to add a per-device trap generating filter. This way we can get maximum performance of sane hardware - which doesn't need this filter - and crappy hardware works but gets punished by a performance hit. V2 changes things around a bit and replaces io access callbacks with a simple minimum_bus_width value. In the future we can add stride as well. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 2ade1a9 commit e7cc9a7

12 files changed

Lines changed: 406 additions & 38 deletions

File tree

‎arch/sh/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ config ARCH_NO_VIRT_TO_BUS
9393
config ARCH_SUPPORTS_AOUT
9494
def_bool y
9595

96+
config IO_TRAPPED
97+
bool
98+
9699
source "init/Kconfig"
97100

98101
menu "System type"

‎arch/sh/kernel/Makefile_32‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
2222
obj-$(CONFIG_PM) += pm.o
2323
obj-$(CONFIG_STACKTRACE) += stacktrace.o
2424
obj-$(CONFIG_BINFMT_ELF) += dump_task.o
25+
obj-$(CONFIG_IO_TRAPPED) += io_trapped.o
2526

2627
EXTRA_CFLAGS += -Werror

‎arch/sh/kernel/Makefile_64‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
1818
obj-$(CONFIG_PM) += pm.o
1919
obj-$(CONFIG_STACKTRACE) += stacktrace.o
2020
obj-$(CONFIG_BINFMT_ELF) += dump_task.o
21+
obj-$(CONFIG_IO_TRAPPED) += io_trapped.o
2122

2223
EXTRA_CFLAGS += -Werror

‎arch/sh/kernel/io.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ EXPORT_SYMBOL(memset_io);
6363

6464
void __iomem *ioport_map(unsigned long port, unsigned int nr)
6565
{
66-
return sh_mv.mv_ioport_map(port, nr);
66+
void __iomem *ret;
67+
68+
ret = __ioport_map_trapped(port, nr);
69+
if (ret)
70+
return ret;
71+
72+
return __ioport_map(port, nr);
6773
}
6874
EXPORT_SYMBOL(ioport_map);
6975

‎arch/sh/kernel/io_generic.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ static inline void delay(void)
3333

3434
u8 generic_inb(unsigned long port)
3535
{
36-
return ctrl_inb((unsigned long __force)ioport_map(port, 1));
36+
return ctrl_inb((unsigned long __force)__ioport_map(port, 1));
3737
}
3838

3939
u16 generic_inw(unsigned long port)
4040
{
41-
return ctrl_inw((unsigned long __force)ioport_map(port, 2));
41+
return ctrl_inw((unsigned long __force)__ioport_map(port, 2));
4242
}
4343

4444
u32 generic_inl(unsigned long port)
4545
{
46-
return ctrl_inl((unsigned long __force)ioport_map(port, 4));
46+
return ctrl_inl((unsigned long __force)__ioport_map(port, 4));
4747
}
4848

4949
u8 generic_inb_p(unsigned long port)
@@ -81,7 +81,7 @@ void generic_insb(unsigned long port, void *dst, unsigned long count)
8181
volatile u8 *port_addr;
8282
u8 *buf = dst;
8383

84-
port_addr = (volatile u8 *)ioport_map(port, 1);
84+
port_addr = (volatile u8 *)__ioport_map(port, 1);
8585
while (count--)
8686
*buf++ = *port_addr;
8787
}
@@ -91,7 +91,7 @@ void generic_insw(unsigned long port, void *dst, unsigned long count)
9191
volatile u16 *port_addr;
9292
u16 *buf = dst;
9393

94-
port_addr = (volatile u16 *)ioport_map(port, 2);
94+
port_addr = (volatile u16 *)__ioport_map(port, 2);
9595
while (count--)
9696
*buf++ = *port_addr;
9797

@@ -103,7 +103,7 @@ void generic_insl(unsigned long port, void *dst, unsigned long count)
103103
volatile u32 *port_addr;
104104
u32 *buf = dst;
105105

106-
port_addr = (volatile u32 *)ioport_map(port, 4);
106+
port_addr = (volatile u32 *)__ioport_map(port, 4);
107107
while (count--)
108108
*buf++ = *port_addr;
109109

@@ -112,17 +112,17 @@ void generic_insl(unsigned long port, void *dst, unsigned long count)
112112

113113
void generic_outb(u8 b, unsigned long port)
114114
{
115-
ctrl_outb(b, (unsigned long __force)ioport_map(port, 1));
115+
ctrl_outb(b, (unsigned long __force)__ioport_map(port, 1));
116116
}
117117

118118
void generic_outw(u16 b, unsigned long port)
119119
{
120-
ctrl_outw(b, (unsigned long __force)ioport_map(port, 2));
120+
ctrl_outw(b, (unsigned long __force)__ioport_map(port, 2));
121121
}
122122

123123
void generic_outl(u32 b, unsigned long port)
124124
{
125-
ctrl_outl(b, (unsigned long __force)ioport_map(port, 4));
125+
ctrl_outl(b, (unsigned long __force)__ioport_map(port, 4));
126126
}
127127

128128
void generic_outb_p(u8 b, unsigned long port)
@@ -153,7 +153,7 @@ void generic_outsb(unsigned long port, const void *src, unsigned long count)
153153
volatile u8 *port_addr;
154154
const u8 *buf = src;
155155

156-
port_addr = (volatile u8 __force *)ioport_map(port, 1);
156+
port_addr = (volatile u8 __force *)__ioport_map(port, 1);
157157

158158
while (count--)
159159
*port_addr = *buf++;
@@ -164,7 +164,7 @@ void generic_outsw(unsigned long port, const void *src, unsigned long count)
164164
volatile u16 *port_addr;
165165
const u16 *buf = src;
166166

167-
port_addr = (volatile u16 __force *)ioport_map(port, 2);
167+
port_addr = (volatile u16 __force *)__ioport_map(port, 2);
168168

169169
while (count--)
170170
*port_addr = *buf++;
@@ -177,7 +177,7 @@ void generic_outsl(unsigned long port, const void *src, unsigned long count)
177177
volatile u32 *port_addr;
178178
const u32 *buf = src;
179179

180-
port_addr = (volatile u32 __force *)ioport_map(port, 4);
180+
port_addr = (volatile u32 __force *)__ioport_map(port, 4);
181181
while (count--)
182182
*port_addr = *buf++;
183183

0 commit comments

Comments
 (0)