[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] m68k: Atari io.h fixes for EtherNAT driver

Here goes ...

On Wed, Jul 16, 2008 at 11:59:53PM +0200, Michael Schmitz wrote:
We should close it with the next kernel upload... with any luck, I'll
have the SMC91C111 driver working by then (it did finally own up to
detecting the proper hardware, instead of stuffing up the ROM-port card
or just hanging the kernel).

Does Geert have this in his queue yet?

No. Where's the patch?

This patch fixes errors I introduced in preparing the io.h code for ROM port ISA access (for the EtherNEC driver, originally).

My assumption was that insb/outsb and friends should be mapped to the ROM port accessors unconditionally, and the read*/write* functions should behave like regular ISA accesses. As it turned out, it's just the other way 'round. "Regular" ISA readb would apply the ROM port address mapping without actually using the correct access function.

ins*/outs* are conditionalized now (port < 1024 goes to the ROM port, all else via MMIO), read*/write* use straight MMIO no questions asked.

This fixes register access problems for the EtherNAT (SMC91C111) when used together with the EtherNEC (ROM port NE2k clone). Tested on my Falcon.

Applies after Geert's linux-m68k-patches-2.6/atari-rom-isa.diff .... should integrate accordingly in the Debian kernel source.

Signed-off-by: Michael Schmitz <schmitz@debian.org>
 io.h |   45 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 13 deletions(-)

--- a/include/asm-m68k/io.h
+++ b/include/asm-m68k/io.h
@@ -429,8 +429,8 @@
  * kernel with both ROM port ISA and IDE compiled in, those have
  * conflicting defs for in/out. Simply consider port < 1024
- * ROM port ISA and everything else regular ISA for IDE. read,write not defined
- * in this case
+ * ROM port ISA and everything else regular ISA for IDE. read,write defined
+ * below.
 #define inb(port)	((port) < 1024 ? isa_rom_inb(port) : in_8(port))
 #define inb_p(port)	((port) < 1024 ? isa_rom_inb_p(port) : in_8(port))
@@ -446,17 +446,36 @@
 #define outl(val, port)	((port) < 1024 ? isa_rom_outl((val), (port)) : out_le32((port), (val)))
 #define outl_p(val, port) ((port) < 1024 ? isa_rom_outl_p((val), (port)) : out_le32((port), (val)))

-#define insb    isa_rom_insb
-#define insw    isa_rom_insw
-#define insl    isa_rom_insl
-#define outsb   isa_rom_outsb
-#define outsw   isa_rom_outsw
-#define outsl   isa_rom_outsl
-#define readb   isa_readb
-#define readw   isa_readw
-#define writeb  isa_writeb
-#define writew  isa_writew
+ * Originally, insb/outsb and insw/outsw were set to the ROM variants in 2.6.19
+ * insl/outsl not used. isa_ins* and isa_outs* do the Right Thing so this is OK.
+ */
+#define insb(port, buf, nr)	((port) < 1024 ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	((port) < 1024 ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
+#define insl(port, buf, nr)	((port) < 1024 ? isa_rom_insl((port), (buf), (nr)) : isa_insl((port), (buf), (nr)))
+#define outsb(port, buf, nr)	((port) < 1024 ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	((port) < 1024 ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
+#define outsl(port, buf, nr)	((port) < 1024 ? isa_rom_outsl((port), (buf), (nr)) : isa_outsl((port), (buf), (nr)))
+ * Previously, read* / write* used the isa_ variants here.
+ * This is absolutely deadly: with CONFIG_ATARI_ROM_ISA defined, isa_readb + * will use the ROM port space mtb translation, but at the same time, uses + * plain old in_8() instead of the ROM port access code. So that'll bang + * on the ROM port using invalid addresses, actually. Mayhem ensues.
+ *
+ * Using in_* / out_*, both EtherNEC and EtherNAT work. If things get more + * complex than that, I'll have to make the ENEC_ISA_* mappings conditional + * on the 'port' addresses, perhaps. + * First try to make read[bw]/write[bw] conditional, though. + */
+#define readb(addr)      in_8(addr)
+#define writeb(val,addr) out_8((addr),(val))
+#define readw(addr)      in_le16(addr)
+#define writew(val,addr) out_le16((addr),(val))
+#define readsw  raw_insw
+#define writesw raw_outsw
 #define readsl  raw_insl
 #define writesl raw_outsl

Reply to: