Skip to content

Commit

Permalink
sh: trapped io support V2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Feb 14, 2008
1 parent 2ade1a9 commit e7cc9a7
Show file tree
Hide file tree
Showing 12 changed files with 406 additions and 38 deletions.
3 changes: 3 additions & 0 deletions arch/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ config ARCH_NO_VIRT_TO_BUS
config ARCH_SUPPORTS_AOUT
def_bool y

config IO_TRAPPED
bool

source "init/Kconfig"

menu "System type"
Expand Down
1 change: 1 addition & 0 deletions arch/sh/kernel/Makefile_32
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_PM) += pm.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-$(CONFIG_BINFMT_ELF) += dump_task.o
obj-$(CONFIG_IO_TRAPPED) += io_trapped.o

EXTRA_CFLAGS += -Werror
1 change: 1 addition & 0 deletions arch/sh/kernel/Makefile_64
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_PM) += pm.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-$(CONFIG_BINFMT_ELF) += dump_task.o
obj-$(CONFIG_IO_TRAPPED) += io_trapped.o

EXTRA_CFLAGS += -Werror
8 changes: 7 additions & 1 deletion arch/sh/kernel/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ EXPORT_SYMBOL(memset_io);

void __iomem *ioport_map(unsigned long port, unsigned int nr)
{
return sh_mv.mv_ioport_map(port, nr);
void __iomem *ret;

ret = __ioport_map_trapped(port, nr);
if (ret)
return ret;

return __ioport_map(port, nr);
}
EXPORT_SYMBOL(ioport_map);

Expand Down
24 changes: 12 additions & 12 deletions arch/sh/kernel/io_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ static inline void delay(void)

u8 generic_inb(unsigned long port)
{
return ctrl_inb((unsigned long __force)ioport_map(port, 1));
return ctrl_inb((unsigned long __force)__ioport_map(port, 1));
}

u16 generic_inw(unsigned long port)
{
return ctrl_inw((unsigned long __force)ioport_map(port, 2));
return ctrl_inw((unsigned long __force)__ioport_map(port, 2));
}

u32 generic_inl(unsigned long port)
{
return ctrl_inl((unsigned long __force)ioport_map(port, 4));
return ctrl_inl((unsigned long __force)__ioport_map(port, 4));
}

u8 generic_inb_p(unsigned long port)
Expand Down Expand Up @@ -81,7 +81,7 @@ void generic_insb(unsigned long port, void *dst, unsigned long count)
volatile u8 *port_addr;
u8 *buf = dst;

port_addr = (volatile u8 *)ioport_map(port, 1);
port_addr = (volatile u8 *)__ioport_map(port, 1);
while (count--)
*buf++ = *port_addr;
}
Expand All @@ -91,7 +91,7 @@ void generic_insw(unsigned long port, void *dst, unsigned long count)
volatile u16 *port_addr;
u16 *buf = dst;

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

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

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

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

void generic_outb(u8 b, unsigned long port)
{
ctrl_outb(b, (unsigned long __force)ioport_map(port, 1));
ctrl_outb(b, (unsigned long __force)__ioport_map(port, 1));
}

void generic_outw(u16 b, unsigned long port)
{
ctrl_outw(b, (unsigned long __force)ioport_map(port, 2));
ctrl_outw(b, (unsigned long __force)__ioport_map(port, 2));
}

void generic_outl(u32 b, unsigned long port)
{
ctrl_outl(b, (unsigned long __force)ioport_map(port, 4));
ctrl_outl(b, (unsigned long __force)__ioport_map(port, 4));
}

void generic_outb_p(u8 b, unsigned long port)
Expand Down Expand Up @@ -153,7 +153,7 @@ void generic_outsb(unsigned long port, const void *src, unsigned long count)
volatile u8 *port_addr;
const u8 *buf = src;

port_addr = (volatile u8 __force *)ioport_map(port, 1);
port_addr = (volatile u8 __force *)__ioport_map(port, 1);

while (count--)
*port_addr = *buf++;
Expand All @@ -164,7 +164,7 @@ void generic_outsw(unsigned long port, const void *src, unsigned long count)
volatile u16 *port_addr;
const u16 *buf = src;

port_addr = (volatile u16 __force *)ioport_map(port, 2);
port_addr = (volatile u16 __force *)__ioport_map(port, 2);

while (count--)
*port_addr = *buf++;
Expand All @@ -177,7 +177,7 @@ void generic_outsl(unsigned long port, const void *src, unsigned long count)
volatile u32 *port_addr;
const u32 *buf = src;

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

Expand Down
Loading

0 comments on commit e7cc9a7

Please sign in to comment.