Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7cc9a73 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt
Browse files

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: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 2ade1a9b
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -93,6 +93,9 @@ config ARCH_NO_VIRT_TO_BUS
config ARCH_SUPPORTS_AOUT
config ARCH_SUPPORTS_AOUT
	def_bool y
	def_bool y


config IO_TRAPPED
	bool

source "init/Kconfig"
source "init/Kconfig"


menu "System type"
menu "System type"
+1 −0
Original line number Original line Diff line number Diff line
@@ -22,5 +22,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_PM)		+= pm.o
obj-$(CONFIG_PM)		+= pm.o
obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
obj-$(CONFIG_BINFMT_ELF)	+= dump_task.o
obj-$(CONFIG_BINFMT_ELF)	+= dump_task.o
obj-$(CONFIG_IO_TRAPPED)	+= io_trapped.o


EXTRA_CFLAGS += -Werror
EXTRA_CFLAGS += -Werror
+1 −0
Original line number Original line Diff line number Diff line
@@ -18,5 +18,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_PM)		+= pm.o
obj-$(CONFIG_PM)		+= pm.o
obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
obj-$(CONFIG_BINFMT_ELF)	+= dump_task.o
obj-$(CONFIG_BINFMT_ELF)	+= dump_task.o
obj-$(CONFIG_IO_TRAPPED)	+= io_trapped.o


EXTRA_CFLAGS += -Werror
EXTRA_CFLAGS += -Werror
+7 −1
Original line number Original line Diff line number Diff line
@@ -63,7 +63,13 @@ EXPORT_SYMBOL(memset_io);


void __iomem *ioport_map(unsigned long port, unsigned int nr)
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);
EXPORT_SYMBOL(ioport_map);


+12 −12
Original line number Original line Diff line number Diff line
@@ -33,17 +33,17 @@ static inline void delay(void)


u8 generic_inb(unsigned long port)
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)
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)
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)
u8 generic_inb_p(unsigned long port)
@@ -81,7 +81,7 @@ void generic_insb(unsigned long port, void *dst, unsigned long count)
	volatile u8 *port_addr;
	volatile u8 *port_addr;
	u8 *buf = dst;
	u8 *buf = dst;


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


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


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


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


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


void generic_outb(u8 b, unsigned long port)
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)
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)
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)
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)
	volatile u8 *port_addr;
	volatile u8 *port_addr;
	const u8 *buf = src;
	const u8 *buf = src;


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


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


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


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


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


Loading