Skip to contentSkip to conversation

m68k/mac: Replace macide driver with generic platform driver

PATCH In review Finn Thain 11 participants 86 messages Apr 25, 2021 – Jun 17, 2021

Subsystems (5)
lore
Share & tools
lore

Finn Thain

author
#0 lore raw

PATCH 1/1 m68k/mac: Replace macide driver with generic platform driver

This was tested on my Quadra 630. I haven't tested it on my PowerBook 150 because I don't have a RAM adapter board for it.

Apparently, the hardware I tested doesn't need macide_clear_irq() or macide_test_irq() -- if it did, the generic driver would not have worked. It's possible that those routines are needed for the PowerBook 150 but we can cross that bridge if and when we come to it.

BTW, macide_clear_irq() appears to suffer from a race condition. The write to the interrupt flags register could easily have unintended side effects as it may alter other flag bits. Fortunately, all of the other bits are unused by Linux. Moreover, when tested on my Quadra 630, that assignment (*ide_ifr &= ~0x20) was observed to have no effect on bit 5.

Cc Michael Schmitz <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Joshua Thompson <[email protected]>
Cc "David S. Miller" <[email protected]>
---
 arch/m68k/configs/mac_defconfig   |   1 -
 arch/m68k/configs/multi_defconfig |   1 -
 arch/m68k/mac/config.c            |  24 +++--
 drivers/ide/Kconfig               |  14 ---
 drivers/ide/Makefile              |   1 -
 drivers/ide/macide.c              | 161 ------------------------------
 6 files changed, 14 insertions(+), 188 deletions(-)
 delete mode 100644 drivers/ide/macide.c
arch/m68k/configs/mac_defconfig +0 -1
index f6d50b3fe8c2..252596991e4f 100644
@@ -318,7 +318,6 @@ CONFIG_IDE=y
 CONFIG_IDE_GD_ATAPI=y
 CONFIG_BLK_DEV_IDECD=y
 CONFIG_BLK_DEV_PLATFORM=y
-CONFIG_BLK_DEV_MAC_IDE=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
arch/m68k/configs/multi_defconfig +0 -1
index 0e067b4320cd..697030472a83 100644
@@ -350,7 +350,6 @@ CONFIG_BLK_DEV_PLATFORM=y
 CONFIG_BLK_DEV_GAYLE=y
 CONFIG_BLK_DEV_BUDDHA=y
 CONFIG_BLK_DEV_FALCON_IDE=y
-CONFIG_BLK_DEV_MAC_IDE=y
 CONFIG_BLK_DEV_Q40IDE=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
arch/m68k/mac/config.c +14 -10
index 1cdac959bd91..5d16f9b47aa9 100644
@@ -933,13 +933,15 @@ static const struct resource mac_scsi_ccl_rsrc[] __initconst = {
 	},
 };
 
-static const struct resource mac_ide_quadra_rsrc[] __initconst = {
-	DEFINE_RES_MEM(0x50F1A000, 0x104),
+static const struct resource mac_pata_quadra_rsrc[] __initconst = {
+	DEFINE_RES_MEM(0x50F1A000, 0x38),
+	DEFINE_RES_MEM(0x50F1A038, 0x04),
 	DEFINE_RES_IRQ(IRQ_NUBUS_F),
 };
 
-static const struct resource mac_ide_pb_rsrc[] __initconst = {
-	DEFINE_RES_MEM(0x50F1A000, 0x104),
+static const struct resource mac_pata_pb_rsrc[] __initconst = {
+	DEFINE_RES_MEM(0x50F1A000, 0x38),
+	DEFINE_RES_MEM(0x50F1A038, 0x04),
 	DEFINE_RES_IRQ(IRQ_NUBUS_C),
 };
 
@@ -949,7 +951,7 @@ static const struct resource mac_pata_baboon_rsrc[] __initconst = {
 	DEFINE_RES_IRQ(IRQ_BABOON_1),
 };
 
-static const struct pata_platform_info mac_pata_baboon_data __initconst = {
+static const struct pata_platform_info mac_pata_data __initconst = {
 	.ioport_shift = 2,
 };
 
@@ -1067,17 +1069,19 @@ int __init mac_platform_init(void)
 
 	switch (macintosh_config->ide_type) {
 	case MAC_IDE_QUADRA:
-		platform_device_register_simple("mac_ide", -1,
-			mac_ide_quadra_rsrc, ARRAY_SIZE(mac_ide_quadra_rsrc));
+		platform_device_register_resndata(NULL, "pata_platform", -1,
+			mac_pata_quadra_rsrc, ARRAY_SIZE(mac_pata_quadra_rsrc),
+			&mac_pata_data, sizeof(mac_pata_data));
 		break;
 	case MAC_IDE_PB:
-		platform_device_register_simple("mac_ide", -1,
-			mac_ide_pb_rsrc, ARRAY_SIZE(mac_ide_pb_rsrc));
+		platform_device_register_resndata(NULL, "pata_platform", -1,
+			mac_pata_pb_rsrc, ARRAY_SIZE(mac_pata_pb_rsrc),
+			&mac_pata_data, sizeof(mac_pata_data));
 		break;
 	case MAC_IDE_BABOON:
 		platform_device_register_resndata(NULL, "pata_platform", -1,
 			mac_pata_baboon_rsrc, ARRAY_SIZE(mac_pata_baboon_rsrc),
-			&mac_pata_baboon_data, sizeof(mac_pata_baboon_data));
+			&mac_pata_data, sizeof(mac_pata_data));
 		break;
 	}
 
drivers/ide/Kconfig +0 -14
index 19abf11c84c8..8ce4a5878d0c 100644
@@ -739,20 +739,6 @@ config BLK_DEV_FALCON_IDE
 	  disks, CD-ROM drives, etc.) that are connected to the on-board IDE
 	  interface.
 
-config BLK_DEV_MAC_IDE
-	tristate "Macintosh Quadra/Powerbook IDE interface support"
-	depends on MAC
-	help
-	  This is the IDE driver for the on-board IDE interface on some m68k
-	  Macintosh models, namely Quadra/Centris 630, Performa 588 and
-	  Powerbook 150. The IDE interface on the Powerbook 190 is not
-	  supported by this driver and requires BLK_DEV_PLATFORM or
-	  PATA_PLATFORM.
-
-	  Say Y if you have such an Macintosh model and want to use IDE
-	  devices (hard disks, CD-ROM drives, etc.) that are connected to the
-	  on-board IDE interface.
-
 config BLK_DEV_Q40IDE
 	tristate "Q40/Q60 IDE interface support"
 	depends on Q40
drivers/ide/Makefile +0 -1
index 2605b3cdaf47..45a1c0463bed 100644
@@ -29,7 +29,6 @@ obj-$(CONFIG_BLK_DEV_4DRIVES)		+= ide-4drives.o
 
 obj-$(CONFIG_BLK_DEV_GAYLE)		+= gayle.o
 obj-$(CONFIG_BLK_DEV_FALCON_IDE)	+= falconide.o
-obj-$(CONFIG_BLK_DEV_MAC_IDE)		+= macide.o
 obj-$(CONFIG_BLK_DEV_Q40IDE)		+= q40ide.o
 obj-$(CONFIG_BLK_DEV_BUDDHA)		+= buddha.o
 
drivers/ide/macide.c deleted +0 -161

161 lines not on this page · raw message

Signature · 1 line
2.26.3
#1 lore raw
Quoted 8 lines · Finn Thain

This was tested on my Quadra 630. I haven't tested it on my PowerBook 150 because I don't have a RAM adapter board for it.

Apparently, the hardware I tested doesn't need macide_clear_irq() or macide_test_irq() -- if it did, the generic driver would not have worked. It's possible that those routines are needed for the PowerBook 150 but we can cross that bridge if and when we come to it.

Quoted 5 lines

BTW, macide_clear_irq() appears to suffer from a race condition. The write to the interrupt flags register could easily have unintended side effects as it may alter other flag bits. Fortunately, all of the other bits are unused by Linux. Moreover, when tested on my Quadra 630, that assignment (*ide_ifr &= ~0x20) was observed to have no effect on bit 5.

Shouldn't we switch to a libata driver instead with legacy IDE been slated for removal from the Linux kernel?

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#2 lore raw
Quoted 9 lines · John Paul Adrian Glaubitz
Quoted 8 lines · Finn Thain

This was tested on my Quadra 630. I haven't tested it on my PowerBook 150 because I don't have a RAM adapter board for it.

Apparently, the hardware I tested doesn't need macide_clear_irq() or macide_test_irq() -- if it did, the generic driver would not have worked. It's possible that those routines are needed for the PowerBook 150 but we can cross that bridge if and when we come to it.

Quoted 9 lines
Quoted 5 lines

BTW, macide_clear_irq() appears to suffer from a race condition. The write to the interrupt flags register could easily have unintended side effects as it may alter other flag bits. Fortunately, all of the other bits are unused by Linux. Moreover, when tested on my Quadra 630, that assignment (*ide_ifr &= ~0x20) was observed to have no effect on bit 5.

Shouldn't we switch to a libata driver instead with legacy IDE been slated for removal from the Linux kernel?

This patch means that the Quadra 630/580 config will work the same as the Powerbook 190 config. Please see commit 50c5feeea0af ("ide/macide: Convert Mac IDE driver to platform driver") for some background.

This patch also means that the kernel/drivers/ide/macide.ko driver module will disappear completely. The module that will replace it is up to you.

If you enable CONFIG_IDE and CONFIG_BLK_DEV_PLATFORM, Quadras and Powerbooks will use the kernel/drivers/ide/ide_platform.ko module.

If you enable CONFIG_ATA and CONFIG_PATA_PLATFORM, Quadras and Powerbooks will use the kernel/drivers/ata/pata_platform.ko module.

(If you enable all of the above, you may need to use a blacklist to ensure that the preferred driver module gets loaded.)

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

Quoted 8 lines

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#3 lore raw

On 4/26/21 9:37 AM, Finn Thain wrote:> If you enable CONFIG_IDE and CONFIG_BLK_DEV_PLATFORM, Quadras and

Quoted 10 lines

Powerbooks will use the kernel/drivers/ide/ide_platform.ko module.

If you enable CONFIG_ATA and CONFIG_PATA_PLATFORM, Quadras and Powerbooks will use the kernel/drivers/ata/pata_platform.ko module.

(If you enable all of the above, you may need to use a blacklist to ensure that the preferred driver module gets loaded.)

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

That's great to hear. It means that systems using the Mac IDE drivers will survive the legacy IDE removal if it ever comes.

So, thanks a lot for addressing this!

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#4 lore raw
In reply to Finn Thain

Hi Finn,

Quoted 3 lines · Finn Thain

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

Cheers,

    Michael

#5 lore raw
Quoted 9 lines · Michael Schmitz
Quoted 4 lines · Finn Thain

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

AIUI, q40 support is not included in Debian/m68k kernel builds.

I wonder whether q40 could re-use the pata_falcon driver . I suppose pata_falcon_set_mode() would be undesirable on q40 (?) It could be made optional using the data parameter passed to platform_device_register_resndata().

#6 lore raw

Hi Finn,

Quoted 7 lines · Finn Thain
Quoted 5 lines · Michael Schmitz
Quoted 4 lines · Finn Thain

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

Quoted 5 lines
Quoted 4 lines

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

AIUI, q40 support is not included in Debian/m68k kernel builds.

I see.

Quoted 1 line

I wonder whether q40 could re-use the pata_falcon driver . I suppose

I'm pretty sure it could, but there is no reason why it would have to be crippled in that way. Interrupts should work perfectly fine with IDE on Q40.

There is another reason why using the same module binary for both might fail - the awkward address translation code in io_mm.h. Not certain at all whether we can even have Q40 and Atari in the same kernel binary...

Quoted 1 line

pata_falcon_set_mode() would be undesirable on q40 (?) It could be made

Not sure what the defaults are - pata_buddha.c and pata_gayle.c use the same code in their _set_mode(). I suspect we'd need it for Q40, too.

Cheers,

    Michael

#7 lore raw

Hi Michael,

Quoted 15 lines · Michael Schmitz
Quoted 11 lines · Finn Thain
Quoted 9 lines · Michael Schmitz
Quoted 4 lines · Finn Thain

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

AIUI, q40 support is not included in Debian/m68k kernel builds.

I see.

Quoted 1 line

I wonder whether q40 could re-use the pata_falcon driver . I suppose

Quoted 7 lines

I'm pretty sure it could, but there is no reason why it would have to be crippled in that way. Interrupts should work perfectly fine with IDE on Q40.

There is another reason why using the same module binary for both might fail - the awkward address translation code in io_mm.h. Not certain at all whether we can even have Q40 and Atari in the same kernel binary...

That's supposed to work, else our multi_defconfig is broken.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw

Hi Geert,

Am 28.04.2021 um 18:53 schrieb Geert Uytterhoeven:

Quoted 11 lines
Quoted 9 lines
Quoted 1 line

I wonder whether q40 could re-use the pata_falcon driver . I suppose

I'm pretty sure it could, but there is no reason why it would have to be crippled in that way. Interrupts should work perfectly fine with IDE on Q40.

There is another reason why using the same module binary for both might fail - the awkward address translation code in io_mm.h. Not certain at all whether we can even have Q40 and Atari in the same kernel binary...

That's supposed to work, else our multi_defconfig is broken.

Took a while to get back to this, but I believe unless this configuration sets CONFIG_ISA && !CONFIG_ATARI_ROM_ISA, Q40 ISA support will indeed be broken, due to

#define inb(port) ((port) < 1024 ? isa_rom_inb(port) : in_8(port))

using incorrect address translation on Q40 (either that for the Atari ROM port, or none)? Not entirely sure what I had been smoking when writing that ...

Conversely, if that combination _is_ set, neither ROM port access nor IDE access on Atari will work (again due to incorrect address translation - indiscriminately applying the one required for the ROM port in that case, which is inappropriate for Atari IDE).

I'm currently considering a fix that does conditional address translation in isa_itb() and its buddys, and replaces in_8() by isa_inb() in the definition above (and equivalent changes elsewhere).

Can you see anything wrong with that, just off the bat?

Cheers,

Michael

(CC: trimmed a little to cut down on spam to the general lists...)

#9 lore raw

Hi Geert,

Am 01.06.2021 um 15:32 schrieb Michael Schmitz:

Quoted 12 lines
Quoted 1 line

That's supposed to work, else our multi_defconfig is broken.

Took a while to get back to this, but I believe unless this configuration sets CONFIG_ISA && !CONFIG_ATARI_ROM_ISA, Q40 ISA support will indeed be broken, due to

#define inb(port) ((port) < 1024 ? isa_rom_inb(port) : in_8(port))

using incorrect address translation on Q40 (either that for the Atari ROM port, or none)? Not entirely sure what I had been smoking when writing that ...

Quoted 8 lines

Conversely, if that combination _is_ set, neither ROM port access nor IDE access on Atari will work (again due to incorrect address translation - indiscriminately applying the one required for the ROM port in that case, which is inappropriate for Atari IDE).

I'm currently considering a fix that does conditional address translation in isa_itb() and its buddys, and replaces in_8() by isa_inb() in the definition above (and equivalent changes elsewhere).

Untested (and mangled formatting, sorry):

Quoted 71 lines
arch/m68k/include/asm/io_mm.h +20 -10
index d41fa48..aaae12f 100644
@@ -135,7 +135,10 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+                       else
+                               return (u8 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -151,7 +154,10 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+                       else
+                               return (u16 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -177,7 +183,10 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+                       else
+                               return (u8 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -193,7 +202,10 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+                       else
+                               return (u16 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -344,17 +356,17 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)      ((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)    ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)      ((port) < 1024 ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)    ((port) < 1024 ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)      ((port) < 1024 ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)    ((port) < 1024 ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl            isa_inl
 #define inl_p          isa_inl_p
 
-#define outb(val, port)        ((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))

arch/m68k/include/asm/io_mm.h static inline void isa_delay(void) · line 372

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +4 -3
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)        ((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)        ((port) < 1024 ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)        ((port) < 1024 ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl           isa_outl
 #define outl_p         isa_outl_p
 

Could that have any new side effects on multiplatform kernels (other than addresses < 1024 still mangled by wrong translation and IO primitive on non-Atari platforms)?

Cheers,

Michael

#10 lore raw

Hi Michael,

Quoted 24 lines · Michael Schmitz

Am 01.06.2021 um 15:32 schrieb Michael Schmitz:

Quoted 12 lines
Quoted 1 line

That's supposed to work, else our multi_defconfig is broken.

Took a while to get back to this, but I believe unless this configuration sets CONFIG_ISA && !CONFIG_ATARI_ROM_ISA, Q40 ISA support will indeed be broken, due to

#define inb(port) ((port) < 1024 ? isa_rom_inb(port) : in_8(port))

using incorrect address translation on Q40 (either that for the Atari ROM port, or none)? Not entirely sure what I had been smoking when writing that ...

Quoted 8 lines

Conversely, if that combination _is_ set, neither ROM port access nor IDE access on Atari will work (again due to incorrect address translation - indiscriminately applying the one required for the ROM port in that case, which is inappropriate for Atari IDE).

I'm currently considering a fix that does conditional address translation in isa_itb() and its buddys, and replaces in_8() by isa_inb() in the definition above (and equivalent changes elsewhere).

Untested (and mangled formatting, sorry):

Quoted 10 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 138

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +0 -1
index d41fa48..aaae12f 100644
@@ -135,7 +135,10 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
 #endif

Bogus hunk?

Quoted 60 lines
Quoted 60 lines
arch/m68k/include/asm/io_mm.h +20 -8
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+                       else
+                               return (u8 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -151,7 +154,10 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+                       else
+                               return (u16 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -177,7 +183,10 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+                       else
+                               return (u8 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -193,7 +202,10 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+                       else
+                               return (u16 __iomem *)(addr);
 #endif
     default: return NULL; /* avoid warnings, just in case */
     }
@@ -344,17 +356,17 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)      ((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)    ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)      ((port) < 1024 ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)    ((port) < 1024 ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)      ((port) < 1024 ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)    ((port) < 1024 ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl            isa_inl
 #define inl_p          isa_inl_p
 
Quoted 13 lines

arch/m68k/include/asm/io_mm.h static inline void isa_delay(void) · line 372

Quoted 11 lines
arch/m68k/include/asm/io_mm.h +4 -4
-#define outb(val, port)        ((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)        ((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)        ((port) < 1024 ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)        ((port) < 1024 ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl           isa_outl
 #define outl_p         isa_outl_p
 

Could that have any new side effects on multiplatform kernels (other

Sorry, being an Amiga MMIO user, I don't know my way through the maze of ISA I/O accessors...

Quoted 2 lines

than addresses < 1024 still mangled by wrong translation and IO primitive on non-Atari platforms)?

Hence q40ide is still broken on Q40 in multi-platform kernels?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#11 lore raw

Hi Geert,

Quoted 14 lines · Geert Uytterhoeven
Quoted 13 lines

Untested (and mangled formatting, sorry):

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 138

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +0 -1
index d41fa48..aaae12f 100644
@@ -135,7 +135,10 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
  #endif

Bogus hunk?

Copy&paste error, more likely. What I have is:

@@ -135,7 +135,10 @@ static inline u8 __iomem *isa_itb(unsigned long addr) case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr); #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr); +    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr); +                       else
+                               return (u8 __iomem *)(addr); #endif
     default: return NULL; /* avoid warnings, just in case */ }

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/m68k/include/asm/io_mm.h +0 -0
@@ -344,17 +356,17 @@ static inline void isa_delay(void)
   * ROM port ISA and everything else regular ISA for IDE. read,write defined
   * below.
   */
Quoted 8 lines
Quoted 8 lines

arch/m68k/include/asm/io_mm.h static inline void isa_delay(void) · line 362

Quoted 8 lines
arch/m68k/include/asm/io_mm.h +4 -4
-#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))
-#define inw(port)      ((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)    ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)      ((port) < 1024 ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)    ((port) < 1024 ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)      ((port) < 1024 ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)    ((port) < 1024 ? isa_rom_inw_p(port) : isa_inw_p(port))

Turns out this still won't work on Q40 - the IDE port addresses are 0x1f0 and 0x170 there. This should do:

#define inb(port)       (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port)) #define inb_p(port)     (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port)) #define inw(port)       (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port)) #define inw_p(port)     (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))

Quoted 3 lines
Quoted 1 line

Could that have any new side effects on multiplatform kernels (other

Sorry, being an Amiga MMIO user, I don't know my way through the maze of ISA I/O accessors...

'Maze' is putting it politely indeed.

Quoted 4 lines
Quoted 3 lines

than addresses < 1024 still mangled by wrong translation and IO primitive on non-Atari platforms)?

Hence q40ide is still broken on Q40 in multi-platform kernels?

That's what I _think_.

Finn found out that Atari IDE is broken if setting CONFIG_IDE only but not CONFIG_ATARI_ROM_ISA. It's hard to test Q40 these days, but I am quite sure that as soon as CONFIG_ATARI_ROM_ISA is defined, Q40 IDE register access does not use address translation, and will fail.

I blame that on using isa_inb() over in_8(), but I may be wrong and it's isa_readb() vs  in_8() instead (m68k IDE drivers should use MMIO I/O accessors after all). In that case, we must stop defining the special readb()/writeb() and readw()/writew() in the CONFIG_ATARI_ROM_ISA section, and use generic CONFIG_ISA variants instead.

That would require a different default address translation to catch the !CONFIG_ATARI_ROM_ISA case on Atari though (i.e. return (addr), not NULL). Not sure this will much improve the stability of the code.

I'll give this a spin on ARAnyM to explore the ramifications.

Cheers,

    Michael

#12 lore raw

cover Fix m68k multiplatform ISA support

In reply to Geert Uytterhoeven

Finn Thain found out that our multiplatform support is broken when attempting to build a kernel with support for both Q40 and Atari (when setting CONFIG_ISA through CONFIG_Q40, but not CONFIG_ATARI_ROM_ISA).

Inspection of the code in io_mm.h reveals that in that case, ISA I/O accessors with address translation are used for the Atari IDE driver, where MMIO accessors with no address translation would have been appropriate.

Setting CONFIG_ATARI_ROM_ISA will fix the issue for Atari, but then force the use of I/O accessors without address translation for Q40. The code in io_mm.h is fundamentally broken for kernels that have both Q40 and Atari support.

Address this by adding a check for address < 1024 to the Atari address translation case, changing the default address translation to return the untranslated address, and changing the CONFIG_ATARI_ROM_ISA section to use ISA I/O accessors for addresses > 1024 (i.e., those not intended to map to the ROM port).

Tested on ARAnyM with all combinations of CONFIG_ATARI_ROM_ISA and CONFIG_ISA. Earlier versions tested on my Falcon hardware, all using pata_falcon.

A thorough review in particular in regard to ramifications for Q40 and Amiga would be welcome. If there is a better way to implement these changes, I'd appreciate a hint. This is all academic as long as support for Q40 and Atari in the same kernel image is not needed, of course.

I suspect patch 2 may not be needed, since the isa_sex variable should always be zero?

Cheers,

Michael

#13 lore raw

RFC PATCH 1/2 m68k: io_mm.h: conditionalize ISA address translation on Atari

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

---
 arch/m68k/include/asm/io_mm.h | 64 +++++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 24 deletions(-)
arch/m68k/include/asm/io_mm.h +40 -24
index d41fa48..2275e54 100644
@@ -52,7 +52,11 @@
 #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
 #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1
+#else
 #define MULTI_ISA 0
+#endif /* Atari */
 #endif /* Q40 */
 
 #ifdef CONFIG_AMIGA_PCMCIA
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024) 
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+			else
+				return (u8 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u16 __iomem *isa_itw(unsigned long addr)
@@ -151,9 +158,12 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+			else
+				return (u16 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u32 __iomem *isa_itl(unsigned long addr)
@@ -177,9 +187,12 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+			else
+				return (u8 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u16 __iomem *isa_mtw(unsigned long addr)
@@ -193,9 +206,12 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+			else
+				return (u16 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 
@@ -344,31 +360,31 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)	((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)	((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl		isa_inl
 #define inl_p		isa_inl_p
 
-#define outb(val, port)	((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)	((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl		isa_outl
 #define outl_p		isa_outl_p
 
-#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 insb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
 #define insl			isa_insl
-#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 outsb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
 #define outsl			isa_outsl
 
-#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 readb   isa_readb
+#define readw   isa_readw
+#define writeb  isa_writeb
+#define writew  isa_writew
 #endif /* CONFIG_ATARI_ROM_ISA */
 
 #define readl(addr)      in_le32(addr)
Signature · 1 line
2.7.4
#14 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 12 lines · Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Quoted 6 lines

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Thanks, this does fix the problem I had with CONFIG_ATARI && CONFIG_ISA.

Quoted 1 line

Checkpatch points out a typo here.

Also, I think this should get a 'Fixes' tag so it will be backported.

Quoted 9 lines
---
 arch/m68k/include/asm/io_mm.h | 64 +++++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 24 deletions(-)
arch/m68k/include/asm/io_mm.h +0 -0
index d41fa48..2275e54 100644

arch/m68k/include/asm/io_mm.h line 61

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +4 -0
@@ -52,7 +52,11 @@
 #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
 #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1
+#else
 #define MULTI_ISA 0
+#endif /* Atari */
 #endif /* Q40 */
 

I have to wonder whether there is a nice simple definition for MULTI_ISA. Such a definition would make this file a lot more easily understood. Maybe that flag could be implemented as a Kconfig symbol. I guess that's out of scope though.

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +4 -1
 #ifdef CONFIG_AMIGA_PCMCIA
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024) 
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+			else
+				return (u8 __iomem *)(addr);

There is some trailing whitespace added here that 'git am' complains about.

Also, I think a 'fallthrough' statement would be better than adding a new else branch that duplicates the new default case below.

Quoted 8 lines
arch/m68k/include/asm/io_mm.h +1 -1
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u16 __iomem *isa_itw(unsigned long addr)
@@ -151,9 +158,12 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_itw(unsigned long addr) · line 166

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -2
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+			else
+				return (u16 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */

Same here.

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +0 -0
     }
 }
 static inline u32 __iomem *isa_itl(unsigned long addr)
@@ -177,9 +187,12 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_mtb(unsigned long addr) · line 195

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -2
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+			else
+				return (u8 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */

And here.

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +0 -0
     }
 }
 static inline u16 __iomem *isa_mtw(unsigned long addr)
@@ -193,9 +206,12 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 214

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -2
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+			else
+				return (u16 __iomem *)(addr);
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */

And here.

Quoted 52 lines
arch/m68k/include/asm/io_mm.h +16 -16
     }
 }
 
@@ -344,31 +360,31 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)	((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)	((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl		isa_inl
 #define inl_p		isa_inl_p
 
-#define outb(val, port)	((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)	((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl		isa_outl
 #define outl_p		isa_outl_p
 
-#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 insb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
 #define insl			isa_insl
-#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 outsb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
 #define outsl			isa_outsl
 
-#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 readb   isa_readb
+#define readw   isa_readw
+#define writeb  isa_writeb
+#define writew  isa_writew
 #endif /* CONFIG_ATARI_ROM_ISA */
 
 #define readl(addr)      in_le32(addr)
#15 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Finn,

thanks for your review!

Quoted 20 lines · Finn Thain
Quoted 12 lines · Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Quoted 6 lines

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Quoted 4 lines

Thanks, this does fix the problem I had with CONFIG_ATARI && CONFIG_ISA.

Quoted 1 line

Checkpatch points out a typo here.

I noticed :-) Fat-fingered the commit in a hurry (and didn't run checkpatch).

Quoted 2 lines

Also, I think this should get a 'Fixes' tag so it will be backported.

I wasn't sure what to use as commit ID to be fixed ... Looks like 84b16b7b0d5c818fadc731a69965dc76dce0c91e is the one to blame. Hmm - I thought that code was older than that...

Quoted 13 lines
Quoted 13 lines
---
  arch/m68k/include/asm/io_mm.h | 64 +++++++++++++++++++++++++++----------------
  1 file changed, 40 insertions(+), 24 deletions(-)
arch/m68k/include/asm/io_mm.h +0 -0
index d41fa48..2275e54 100644
@@ -52,7 +52,11 @@
  #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
  #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
Quoted 8 lines

arch/m68k/include/asm/io_mm.h line 61

Quoted 7 lines
arch/m68k/include/asm/io_mm.h +4 -0
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1
+#else
  #define MULTI_ISA 0
+#endif /* Atari */
  #endif /* Q40 */
 

I have to wonder whether there is a nice simple definition for MULTI_ISA.

As I understand it, MULTI_ISA means that different byte orders and/or different address translations need to be used in the same kernel, so all that cannot be decided at build time.

As long as there is only a single platform that will use this code (ISA only used on a single platform, and neither Atari IDE nor EtherNEC used), MULTI_ISA is not needed.

If we have Kconfig symbols for 'single platform only', and 'multi-platform ISA use', that might be shorter to write and easier to understand. Geert?

Quoted 3 lines

Such a definition would make this file a lot more easily understood. Maybe that flag could be implemented as a Kconfig symbol. I guess that's out of scope though.

That Kconfig symbol would best sit in Kconfig.machine but have to be aware of definitions in a number of driver Kconfigs. Haven't tried if that works. But I agree it is out of scope for now.

The question then becomes - should I move the MULTI_ISA definitions out of the Q40 branch and out of the later Amiga Gayle PCMCIA branch to the head of the file and add a comment explaining the rationale? Too much churn for now?

Quoted 14 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 11 lines
arch/m68k/include/asm/io_mm.h +4 -1
  #ifdef CONFIG_AMIGA_PCMCIA
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+			else
+				return (u8 __iomem *)(addr);

There is some trailing whitespace added here that 'git am' complains about.

Quoted 2 lines

Also, I think a 'fallthrough' statement would be better than adding a new else branch that duplicates the new default case below.

I'm still unsure whether changing the default branch for the sake of fixing Atari behaviour is a sane idea - I was hoping for comments either way.

But if it's changed, you are correct that having the control flow fall through instead of taking a redundant else branch is better.

Essentially, changing that hunk to

#ifdef CONFIG_ATARI_ROM_ISA
- case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+ case ISA_TYPE_ENEC: if (addr < 1024)
+ return (u8 __iomem *)ENEC_ISA_IO_B(addr);

here (and elsewhere below)?

Cheers,

    Michael

Quoted 107 lines
Quoted 9 lines
arch/m68k/include/asm/io_mm.h +1 -1
  #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
      }
  }
  static inline u16 __iomem *isa_itw(unsigned long addr)
@@ -151,9 +158,12 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
      case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_itw(unsigned long addr) · line 166

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -2
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+			else
+				return (u16 __iomem *)(addr);
  #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */

Same here.

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +0 -0
      }
  }
  static inline u32 __iomem *isa_itl(unsigned long addr)
@@ -177,9 +187,12 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
      case ISA_TYPE_AG: return (u8 __iomem *)addr;

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_mtb(unsigned long addr) · line 195

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -2
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+			else
+				return (u8 __iomem *)(addr);
  #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */

And here.

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +0 -0
      }
  }
  static inline u16 __iomem *isa_mtw(unsigned long addr)
@@ -193,9 +206,12 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
      case ISA_TYPE_AG: return (u16 __iomem *)addr;

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 214

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -2
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+			else
+				return (u16 __iomem *)(addr);
  #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */

And here.

Quoted 52 lines
arch/m68k/include/asm/io_mm.h +16 -16
      }
  }
 
@@ -344,31 +360,31 @@ static inline void isa_delay(void)
   * 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))
-#define inw(port)	((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)	((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))
  #define inl		isa_inl
  #define inl_p		isa_inl_p
 
-#define outb(val, port)	((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)	((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
  #define outl		isa_outl
  #define outl_p		isa_outl_p
 
-#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 insb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
  #define insl			isa_insl
-#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 outsb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
  #define outsl			isa_outsl
 
-#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 readb   isa_readb
+#define readw   isa_readw
+#define writeb  isa_writeb
+#define writew  isa_writew
  #endif /* CONFIG_ATARI_ROM_ISA */
 
  #define readl(addr)      in_le32(addr)
#16 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 4 lines · Michael Schmitz

of the Q40 branch and out of the later Amiga Gayle PCMCIA branch to the head of the file and add a comment explaining the rationale? Too much churn for now?

Right, it could be too much churn for a bug-fix patch.

Quoted 14 lines
Quoted 14 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 11 lines
  #ifdef CONFIG_AMIGA_PCMCIA
arch/m68k/include/asm/io_mm.h +4 -1
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+			else
+				return (u8 __iomem *)(addr);

There is some trailing whitespace added here that 'git am' complains about.

Quoted 7 lines
Quoted 2 lines

Also, I think a 'fallthrough' statement would be better than adding a new else branch that duplicates the new default case below.

I'm still unsure whether changing the default branch for the sake of fixing Atari behaviour is a sane idea - I was hoping for comments either way.

You mean, what happens if a random m68k platform (other than amiga, atari and q40) were to adopt CONFIG_ISA? I guess it would be nice if that would 'just work' but it's probably never going to be needed.

Quoted 10 lines

But if it's changed, you are correct that having the control flow fall through instead of taking a redundant else branch is better.

Essentially, changing that hunk to

#ifdef CONFIG_ATARI_ROM_ISA

arch/m68k/include/asm/io_mm.h +2 -1
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
Quoted 2 lines

here (and elsewhere below)?

I worry about the static checkers that look for missing 'fallthrough' and 'break' statements. So I was thinking of something like this:

static inline u8 __iomem *isa_itb(unsigned long addr) {
switch(ISA_TYPE)

    {
#ifdef CONFIG_Q40
    case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
#endif
#ifdef CONFIG_AMIGA_PCMCIA
    case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
#endif
#ifdef CONFIG_ATARI_ROM_ISA
    case ISA_TYPE_ENEC: 
        if (addr < 1024)
            return (u8 __iomem *)ENEC_ISA_IO_B(addr);
        fallthrough;
#endif
    default: return (u8 __iomem *)(addr);
    }
}

Alternatively you could just move the default out of the switch:

static inline u8 __iomem *isa_itb(unsigned long addr) {
switch(ISA_TYPE)

    {
#ifdef CONFIG_Q40
    case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
#endif
#ifdef CONFIG_AMIGA_PCMCIA
    case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
#endif
#ifdef CONFIG_ATARI_ROM_ISA
    case ISA_TYPE_ENEC:
        if (addr < 1024)
            return (u8 __iomem *)ENEC_ISA_IO_B(addr);
        break;
#endif
    }
    return (u8 __iomem *)(addr);
}

The latter is probably the more flexible style because 'break' doesn't care about the order of case labels.

#17 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Finn,

Am 04.06.2021 um 17:55 schrieb Finn Thain:

Quoted 8 lines · Michael Schmitz
Quoted 5 lines

of the Q40 branch and out of the later Amiga Gayle PCMCIA branch to the head of the file and add a comment explaining the rationale? Too much churn for now?

Right, it could be too much churn for a bug-fix patch.

I'll leave that for later (but add a comment in the lines inserted).

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 11 lines
  #ifdef CONFIG_AMIGA_PCMCIA
arch/m68k/include/asm/io_mm.h +4 -1
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+			else
+				return (u8 __iomem *)(addr);

There is some trailing whitespace added here that 'git am' complains about.

Also, I think a 'fallthrough' statement would be better than adding a new else branch that duplicates the new default case below.

Quoted 8 lines
Quoted 4 lines

I'm still unsure whether changing the default branch for the sake of fixing Atari behaviour is a sane idea - I was hoping for comments either way.

You mean, what happens if a random m68k platform (other than amiga, atari and q40) were to adopt CONFIG_ISA? I guess it would be nice if that would 'just work' but it's probably never going to be needed.

The NULL default was meant to catch incorrect use of config options related to CONFIG_ISA. My repurposing the default branch for Atari's needs (no translation for IDE) defeats that. But the chance that we run into such incorrect use in the future are pretty slim indeed.

Still, my patch changes behaviour in existing drivers. We're quite certain it does not matter, but is that good enough to be accepted?

Quoted 11 lines
Quoted 11 lines

But if it's changed, you are correct that having the control flow fall through instead of taking a redundant else branch is better.

Essentially, changing that hunk to

#ifdef CONFIG_ATARI_ROM_ISA

arch/m68k/include/asm/io_mm.h +2 -1
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
Quoted 4 lines
Quoted 2 lines

here (and elsewhere below)?

I worry about the static checkers that look for missing 'fallthrough' and

Never ran into 'fallthrough' except as comment annotation, but I now see that really is a thing these days. Amazing.

Quoted 5 lines

'break' statements. So I was thinking of something like this:

static inline u8 __iomem *isa_itb(unsigned long addr) {
switch(ISA_TYPE)

Quoted 16 lines
    {
#ifdef CONFIG_Q40
    case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
#endif
#ifdef CONFIG_AMIGA_PCMCIA
    case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
#endif
#ifdef CONFIG_ATARI_ROM_ISA
    case ISA_TYPE_ENEC:
        if (addr < 1024)
            return (u8 __iomem *)ENEC_ISA_IO_B(addr);
        fallthrough;
#endif
    default: return (u8 __iomem *)(addr);
    }
}

This one makes it easy to eventually add another ISA_TYPE_ATARI case before the default case (which could then revert to NULL if desired).

Quoted 25 lines

Alternatively you could just move the default out of the switch:

static inline u8 __iomem *isa_itb(unsigned long addr) {
switch(ISA_TYPE)

    {
#ifdef CONFIG_Q40
    case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
#endif
#ifdef CONFIG_AMIGA_PCMCIA
    case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
#endif
#ifdef CONFIG_ATARI_ROM_ISA
    case ISA_TYPE_ENEC:
        if (addr < 1024)
            return (u8 __iomem *)ENEC_ISA_IO_B(addr);
        break;
#endif
    }
    return (u8 __iomem *)(addr);
}
Quoted 2 lines

The latter is probably the more flexible style because 'break' doesn't care about the order of case labels.

Yes, but it rules out reverting the default case to NULL.

On balance, I'll go with the fallback (and will annotate that other Atari drivers fall back to the clause below on purpose).

Cheers,

Michael

#18 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 5 lines · Michael Schmitz
Quoted 5 lines
Quoted 4 lines

I'm still unsure whether changing the default branch for the sake of fixing Atari behaviour is a sane idea - I was hoping for comments either way.

Quoted 8 lines
Quoted 3 lines

You mean, what happens if a random m68k platform (other than amiga, atari and q40) were to adopt CONFIG_ISA? I guess it would be nice if that would 'just work' but it's probably never going to be needed.

The NULL default was meant to catch incorrect use of config options related to CONFIG_ISA. My repurposing the default branch for Atari's needs (no translation for IDE) defeats that. But the chance that we run into such incorrect use in the future are pretty slim indeed.

Well, we could in theory add a trex socket driver to get PCMCIA support for the PowerBook 190 hardware. There was a driver for that in ppc for the PowerBook 5300 which uses the same chipset. I believe the PCMCIA drivers use these same macros in spite of not being considered ISA. I don't see anything in drivers/pcmcia that is obviously an m68k system even though I'm pretty sure I remember discussions of supporting such hardware in the past.

Is PCMCIA support something we should also consider in all of this?

Brad Boyer
[email protected]

#19 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Brad,

Am 05.06.2021 um 10:49 schrieb Brad Boyer:

Quoted 15 lines · Michael Schmitz
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I'm still unsure whether changing the default branch for the sake of fixing Atari behaviour is a sane idea - I was hoping for comments either way.

Quoted 8 lines
Quoted 3 lines

You mean, what happens if a random m68k platform (other than amiga, atari and q40) were to adopt CONFIG_ISA? I guess it would be nice if that would 'just work' but it's probably never going to be needed.

The NULL default was meant to catch incorrect use of config options related to CONFIG_ISA. My repurposing the default branch for Atari's needs (no translation for IDE) defeats that. But the chance that we run into such incorrect use in the future are pretty slim indeed.

Quoted 4 lines

Well, we could in theory add a trex socket driver to get PCMCIA support for the PowerBook 190 hardware. There was a driver for that in ppc for the PowerBook 5300 which uses the same chipset. I believe the PCMCIA drivers use these same macros in spite of not being considered ISA.

Correct - the PCMCIA device drivers use IO port addresses in the ISA port range.

Quoted 3 lines

I don't see anything in drivers/pcmcia that is obviously an m68k system even though I'm pretty sure I remember discussions of supporting such hardware in the past.

There's the APNE driver (Amiga PCMCIA NE2000 clone), which is already catered for by the current code in io_mm.h. I remember seeing patches for that driver that would allow support of a variant of the APNE card that were hard to integrate in the current NE clone code framework. Didn't consider adding another isa_type for that card at the time - I'll revisit these patches if I can find them again.

Supporting PB190 PCMCIA hardware requires adding a new isa_type and the corresponding IO translation cases. Not much more, for all I can see. Existing chipset drivers from other architectures ought to work already. Maybe add a specific block_input() hook as for APNE (but I surmise that might just be code duplication from generic code in lib8390.c - didn't check).

Not sure what card socket code the APNE driver uses - must be one of the generic variants from drivers/pcmcia. If your PB190 needs something not already in there, we'd need to add that as well.

Quoted 1 line

Is PCMCIA support something we should also consider in all of this?

Absolutely.

Cheers,

Michael

Quoted 4 lines

Brad Boyer
[email protected]

#20 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 19 lines · Michael Schmitz

Am 05.06.2021 um 10:49 schrieb Brad Boyer:

Quoted 3 lines

I don't see anything in drivers/pcmcia that is obviously an m68k system even though I'm pretty sure I remember discussions of supporting such hardware in the past.

There's the APNE driver (Amiga PCMCIA NE2000 clone), which is already catered for by the current code in io_mm.h. I remember seeing patches for that driver that would allow support of a variant of the APNE card that were hard to integrate in the current NE clone code framework. Didn't consider adding another isa_type for that card at the time - I'll revisit these patches if I can find them again.

Supporting PB190 PCMCIA hardware requires adding a new isa_type and the corresponding IO translation cases. Not much more, for all I can see. Existing chipset drivers from other architectures ought to work already. Maybe add a specific block_input() hook as for APNE (but I surmise that might just be code duplication from generic code in lib8390.c - didn't check).

Quoted 3 lines

Not sure what card socket code the APNE driver uses - must be one of the generic variants from drivers/pcmcia. If your PB190 needs something not already in there, we'd need to add that as well.

I had to look a bit, but I found it. The apne driver doesn't use the normal PCMCIA infrastructure at all. There is a custom Amiga PCMCIA thing found in arch/m68k/amiga/pcmcia.c. This could complicate things if we are able to use the common PCMCIA code for trex and try to build a kernel with both that and amiga/pcmcia + apne.

At least it does sound like the io macros won't be an issue.

Brad Boyer
[email protected]

#21 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Brad,

Am 05.06.2021 um 18:04 schrieb Brad Boyer:

Quoted 10 lines
Quoted 4 lines

Not sure what card socket code the APNE driver uses - must be one of the generic variants from drivers/pcmcia. If your PB190 needs something not already in there, we'd need to add that as well.

I had to look a bit, but I found it. The apne driver doesn't use the normal PCMCIA infrastructure at all. There is a custom Amiga PCMCIA thing found in arch/m68k/amiga/pcmcia.c. This could complicate things if we are able to use the common PCMCIA code for trex and try to build a kernel with both that and amiga/pcmcia + apne.

Thanks, I had missed that one.

Quoted 1 line

At least it does sound like the io macros won't be an issue.

The arch/m68k/amiga/pcmcia.c API is different from that of the drivers in drivers/pcmcia/ from what I've seen, so I think adding or reusing trex support together with Amiga PCMCIA support will be an issue.

Cheers,

Michael

Quoted 4 lines

Brad Boyer
[email protected]

#22 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

In reply to Brad Boyer

Hi Brad,

Am 05.06.2021 um 18:04 schrieb Brad Boyer:

Quoted 6 lines · Michael Schmitz
Quoted 5 lines

Am 05.06.2021 um 10:49 schrieb Brad Boyer:

Quoted 3 lines

I don't see anything in drivers/pcmcia that is obviously an m68k system even though I'm pretty sure I remember discussions of supporting such hardware in the past.

Quoted 6 lines
Quoted 6 lines

There's the APNE driver (Amiga PCMCIA NE2000 clone), which is already catered for by the current code in io_mm.h. I remember seeing patches for that driver that would allow support of a variant of the APNE card that were hard to integrate in the current NE clone code framework. Didn't consider adding another isa_type for that card at the time - I'll revisit these patches if I can find them again.

Refreshed my memory - Alex submitted a patch to netdev three years ago that essentially boiled down to changing our isa_inb() to use isa_inw().

This patch to io_mm.h (on top of my current patch), plus setting isa_type to ISA_TPYE_AG100 using a module parameter, should do the trick:

arch/m68k/include/asm/io_mm.h +20 -0
index f6b487b..6f79a5e 100644
@@ -102,6 +102,11 @@
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
 
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+#define ISA_TYPE_AG100 (4)     /* for 100 MBit APNE card */
+#define MULTI_ISA 1
+#endif
+
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
 #define ISA_SEX  0
@@ -135,6 +140,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
@@ -153,6 +161,9 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -168,6 +179,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
 {
   switch(ISA_TYPE)
     {
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -181,6 +195,9 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
@@ -199,6 +216,9 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
@@ -219,6 +239,11 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : 

out_le16(isa_itw(port),(val)))
#define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) :
out_le32(isa_itl(port),(val)))

+#if defined(CONFIG_AMIGA_PCMCIA_100)
+#undef isa_inb
+#define isa_inb(port) ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))
+#endif
+
#define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))

 #define isa_readw(p)       \
        (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \

(linebreak-mangled, sorry).

The card reset patch hunk from Alex' patch can probably go into the APNE driver regardless?

It's been quite a while - can you still try and build/test this change, Alex?

Cheers,

Michael

#23 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 9 lines · Michael Schmitz

This patch to io_mm.h (on top of my current patch), plus setting isa_type to ISA_TPYE_AG100 using a module parameter, should do the trick:

arch/m68k/include/asm/io_mm.h +0 -0
index f6b487b..6f79a5e 100644

arch/m68k/include/asm/io_mm.h line 106

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +2 -0
@@ -102,6 +102,11 @@
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
 
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+#define ISA_TYPE_AG100 (4)     /* for 100 MBit APNE card */

IMHO this would be simpler if that #define was unconditional like the others.

arch/m68k/include/asm/io_mm.h line 107

Quoted 1 line
arch/m68k/include/asm/io_mm.h +1 -0
+#define MULTI_ISA 1

Hmm...

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 12 lines
arch/m68k/include/asm/io_mm.h +5 -0
+#endif
+
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
 #define ISA_SEX  0
@@ -135,6 +140,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif

I wonder whether that 'fallthrough' is needed. One would hope not...

Quoted 45 lines
arch/m68k/include/asm/io_mm.h +12 -0
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
@@ -153,6 +161,9 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -168,6 +179,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
 {
   switch(ISA_TYPE)
     {
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -181,6 +195,9 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
@@ -199,6 +216,9 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
@@ -219,6 +239,11 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) :

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 249

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +5 -0
 out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) :
 out_le32(isa_itl(port),(val)))
 
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+#undef isa_inb
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ?
 isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))
+#endif
+

Would (port & ~1) be faster than (port - 1) here?

Also, I don't think you need '#if defined' here. When !defined(CONFIG_AMIGA_PCMCIA_100), I think ISA_TYPE should be a compile-time constant 0, and the dead code will get tossed out anyway.

Quoted 10 lines

#define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))

 #define isa_readw(p)       \
        (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \

(linebreak-mangled, sorry).

The card reset patch hunk from Alex' patch can probably go into the APNE driver regardless?

It's been quite a while - can you still try and build/test this change, Alex?

Note that isa_type is never assigned to ISA_TYPE_AG100 in arch/m68k/kernel/setup_mm.c which means (IIUC) this patch won't take effect with MULTI_ISA == 1.

#24 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Finn,

Thanks for the quick review!

Am 06.06.2021 um 16:53 schrieb Finn Thain:

Quoted 14 lines · Michael Schmitz
Quoted 13 lines

This patch to io_mm.h (on top of my current patch), plus setting isa_type to ISA_TPYE_AG100 using a module parameter, should do the trick:

arch/m68k/include/asm/io_mm.h +0 -0
index f6b487b..6f79a5e 100644
@@ -102,6 +102,11 @@
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
 
Quoted 5 lines

arch/m68k/include/asm/io_mm.h line 106

Quoted 2 lines
arch/m68k/include/asm/io_mm.h +2 -0
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+#define ISA_TYPE_AG100 (4)     /* for 100 MBit APNE card */

IMHO this would be simpler if that #define was unconditional like the others.

Yep, that one could be unconditional (and we could rearrange the defs to keep the new type between AG and ENEC).

Quoted 5 lines

arch/m68k/include/asm/io_mm.h line 107

Quoted 2 lines
arch/m68k/include/asm/io_mm.h +1 -0
+#define MULTI_ISA 1

Hmm...

That one I didn't want to make unconditional, in order to allow the optimization below.

Quoted 6 lines
Quoted 6 lines
arch/m68k/include/asm/io_mm.h +2 -0
+#endif
+
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
 #define ISA_SEX  0
@@ -135,6 +140,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
Quoted 8 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 6 lines
arch/m68k/include/asm/io_mm.h +3 -0
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif

I wonder whether that 'fallthrough' is needed. One would hope not...

It won't be, but it ought to shut up compiler warnings, no?

Quoted 50 lines
Quoted 50 lines
arch/m68k/include/asm/io_mm.h +12 -0
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
@@ -153,6 +161,9 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -168,6 +179,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
 {
   switch(ISA_TYPE)
     {
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -181,6 +195,9 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
@@ -199,6 +216,9 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
@@ -219,6 +239,11 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) :
 out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) :
 out_le32(isa_itl(port),(val)))
 
Quoted 8 lines

arch/m68k/include/asm/io_mm.h line 109

Quoted 6 lines
arch/m68k/include/asm/io_mm.h +5 -0
+#if defined(CONFIG_AMIGA_PCMCIA_100)
+#undef isa_inb
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ?
 isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))
+#endif
+

Would (port & ~1) be faster than (port - 1) here?

Perhaps it would - I'd hope the compiler will pick the most efficient solution here.

Quoted 4 lines

Also, I don't think you need '#if defined' here. When !defined(CONFIG_AMIGA_PCMCIA_100), I think ISA_TYPE should be a compile-time constant 0, and the dead code will get tossed out anyway.

Right, that's a good point.

Quoted 6 lines
Quoted 6 lines

#define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))

 #define isa_readw(p)       \
        (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \

(linebreak-mangled, sorry).

Quoted 8 lines
Quoted 4 lines

The card reset patch hunk from Alex' patch can probably go into the APNE driver regardless?

It's been quite a while - can you still try and build/test this change, Alex?

Note that isa_type is never assigned to ISA_TYPE_AG100 in arch/m68k/kernel/setup_mm.c which means (IIUC) this patch won't take effect with MULTI_ISA == 1.

In order to make this useful, a Kconfig option is needed, and a module parameter will set isa_type to ISA_TYPE_AG100 in the APNE probe routine. I'll send the complete set as RFC soon. Will include your suggestions before doing that, of course.

Cheers,

Michael

Quoted 1 line
#25 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 4 lines · Michael Schmitz
Quoted 1 line

Would (port & ~1) be faster than (port - 1) here?

Perhaps it would - I'd hope the compiler will pick the most efficient solution here.

I'm pretty sure the compiler couldn't do that optimization. Without more context, those two statements are not equivalent. I don't see how the compiler could know that.

Looking at the 68040 manual, the instruction timing of ANDI and SUBQ is mostly the same (except for immediate addressing, where ANDI is slower). The ANDI is also going to take up extra bytes in the code to put the bitmask in an extension word. BCLR can be faster than ANDI or SUBQ in some cases, but it's slower in others. It also needs an extension word when using an immediate value for the bit number. If you presume port is in a data register, then ANDI and SUBQ have the same timing and BCLR is slower. At that point, the difference between ANDI and SUBQ is the size of the instruction which would favor using SUBQ. I haven't checked if other m68k chips have similar timings.

Unless I missed something, I don't see a better way to do the equivalent of the and with a constant bitmask.

Brad Boyer
[email protected]

#26 lore raw

cover Add APNE PCMCIA 100 Mbit support

In reply to Brad Boyer

Now that we've sanitzed io_mm.h, revisit support for the 100 Mbit APNE PCMCIA card variants that didn't find favour with the netdev folks three years ago.

Add another ISA type for these cards, and switch to that type from the APNE probe code in response to a module parameter.

Entirely untested, just for comment (and hopefully someone will give this a spin).

Cheers,

Michael

#27 lore raw

RFC PATCH 1/2 m68k: io_mm.h - add APNE 100 MBit support

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG100 switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

---
 arch/m68k/include/asm/io_mm.h | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
arch/m68k/include/asm/io_mm.h +24 -1
index f6b487b..71f694a 100644
@@ -101,6 +101,11 @@
 #define ISA_TYPE_Q40  (1)
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
+#define ISA_TYPE_AG100 (4)	/* for 100 MBit APNE card */
+
+#if defined(CONFIG_APNE100MBIT)
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -135,6 +140,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
+#if defined(CONFIG_APNE100MBIT)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
@@ -153,6 +161,9 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
+#if defined(CONFIG_APNE100MBIT)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -168,6 +179,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
 {
   switch(ISA_TYPE)
     {
+#if defined(CONFIG_APNE100MBIT)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
@@ -181,6 +195,9 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
+#if defined(CONFIG_APNE100MBIT)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
@@ -199,6 +216,9 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
+#if defined(CONFIG_APNE100MBIT)
+    case ISA_TYPE_AG100: fallthrough;
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
@@ -212,13 +232,16 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+/* for APNE 100 Mbit cards - hope the APNE 100 case will be eliminated as
+ * dead code if MULTI_ISA is not set */
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))
+
 #define isa_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
 	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\
Signature · 1 line
2.7.4
#28 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Michael,

Quoted 4 lines · Michael Schmitz

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG100 switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

missing "dynamically".

Quoted 6 lines

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

Thanks for your patch!

arch/m68k/include/asm/io_mm.h line 104

Quoted 7 lines
arch/m68k/include/asm/io_mm.h +1 -0
@@ -101,6 +101,11 @@
 #define ISA_TYPE_Q40  (1)
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
+#define ISA_TYPE_AG100 (4)     /* for 100 MBit APNE card */

As this type may be needed for other cards, perhaps it should be named after what it really does, i.e. always using 16-bit accesses? ISA_TYPE_AG16?

arch/m68k/include/asm/io_mm.h line 106

Quoted 2 lines
arch/m68k/include/asm/io_mm.h +2 -0
+
+#if defined(CONFIG_APNE100MBIT)

#ifdef

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 143

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +3 -0
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -135,6 +140,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
+#if defined(CONFIG_APNE100MBIT)

#ifdef

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 144

Quoted 1 line
arch/m68k/include/asm/io_mm.h +1 -0
+    case ISA_TYPE_AG100: fallthrough;

Fallthrough to what? Oh, to ISA_TYPE_AG.
Please make this clear, and safer, by moving this inside the #ifdef below (CONFIG_APNE100MBIT depends on CONFIG_AMIGA_PCMCIA).

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 215

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +1 -1
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
@@ -212,13 +232,16 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))

Why move it below? Because its comment does not apply to the below?

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 242

Quoted 8 lines
arch/m68k/include/asm/io_mm.h +2 -0
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+/* for APNE 100 Mbit cards - hope the APNE 100 case will be eliminated as
+ * dead code if MULTI_ISA is not set */

I don't think this comment is needed.

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 247

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +2 -0
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))
+
 #define isa_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
        (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#29 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Geert,

Thanks for reviewing this one as well!

Am 07.06.2021 um 20:01 schrieb Geert Uytterhoeven:

Quoted 9 lines

Hi Michael,

Quoted 4 lines · Michael Schmitz

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG100 switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

missing "dynamically".

OK...

Quoted 10 lines
Quoted 7 lines

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

Thanks for your patch!

Quoted 11 lines

arch/m68k/include/asm/io_mm.h line 104

Quoted 7 lines
arch/m68k/include/asm/io_mm.h +1 -0
@@ -101,6 +101,11 @@
 #define ISA_TYPE_Q40  (1)
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
+#define ISA_TYPE_AG100 (4)     /* for 100 MBit APNE card */

As this type may be needed for other cards, perhaps it should be named after what it really does, i.e. always using 16-bit accesses? ISA_TYPE_AG16?

Yep, that sounds better.

Quoted 19 lines

arch/m68k/include/asm/io_mm.h line 106

Quoted 3 lines
arch/m68k/include/asm/io_mm.h +2 -0
+
+#if defined(CONFIG_APNE100MBIT)

#ifdef

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 143

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +3 -0
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -135,6 +140,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
 #ifdef CONFIG_Q40
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
+#if defined(CONFIG_APNE100MBIT)

#ifdef

Quoted 5 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 144

Quoted 1 line
arch/m68k/include/asm/io_mm.h +1 -0
+    case ISA_TYPE_AG100: fallthrough;

Fallthrough to what? Oh, to ISA_TYPE_AG.
Please make this clear, and safer, by moving this inside the #ifdef below (CONFIG_APNE100MBIT depends on CONFIG_AMIGA_PCMCIA).

OK, good point.

Quoted 5 lines
Quoted 4 lines
arch/m68k/include/asm/io_mm.h +1 -0
+#endif
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
Quoted 7 lines

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 215

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +0 -1
@@ -212,13 +232,16 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))

Why move it below? Because its comment does not apply to the below?

Because the new form depends on isa_inw()? I've seen order matter in CPP statements before ...

Quoted 10 lines

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 242

Quoted 8 lines
arch/m68k/include/asm/io_mm.h +2 -0
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+/* for APNE 100 Mbit cards - hope the APNE 100 case will be eliminated as
+ * dead code if MULTI_ISA is not set */

I don't think this comment is needed.

I'll remove it, then.

Cheers,

Michael

Quoted 11 lines

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 247

Quoted 6 lines
arch/m68k/include/asm/io_mm.h +2 -0
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))
+
 #define isa_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
        (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \

Gr{oetje,eeting}s,

Geert

#30 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

In reply to Michael Schmitz

Hi Michael,

Quoted 17 lines · Michael Schmitz

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG100 switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

arch/m68k/include/asm/io_mm.h +0 -0
@@ -212,13 +232,16 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 243

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +3 -1
-#define isa_inb(port)      in_8(isa_itb(port))
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+/* for APNE 100 Mbit cards - hope the APNE 100 case will be eliminated as
+ * dead code if MULTI_ISA is not set */
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))

This fails to compile due to a missing closing parenthesis.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#31 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Geert,

Quoted 26 lines · Geert Uytterhoeven

Hi Michael,

Quoted 23 lines · Michael Schmitz

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG100 switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

arch/m68k/include/asm/io_mm.h +0 -1
@@ -212,13 +232,16 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
  }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
  #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
  #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
  #define isa_outb(val,port) out_8(isa_itb(port),(val))
  #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
  #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
Quoted 4 lines

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 243

Quoted 3 lines
arch/m68k/include/asm/io_mm.h +3 -0
+/* for APNE 100 Mbit cards - hope the APNE 100 case will be eliminated as
+ * dead code if MULTI_ISA is not set */
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))

This fails to compile due to a missing closing parenthesis.

Sorry - looks like brown paper bag time today. (I did say 'entirely untested'? Didn't expect such a thorough review for a first RFC patch ...)

Apologies,

    Michael

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

#32 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Michael,

Quoted 25 lines · Michael Schmitz
Quoted 24 lines · Geert Uytterhoeven
Quoted 23 lines · Michael Schmitz

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG100 switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

arch/m68k/include/asm/io_mm.h +0 -1
@@ -212,13 +232,16 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
  }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
  #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
  #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
  #define isa_outb(val,port) out_8(isa_itb(port),(val))
  #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
  #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
Quoted 7 lines
Quoted 4 lines

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 243

Quoted 3 lines
arch/m68k/include/asm/io_mm.h +3 -0
+/* for APNE 100 Mbit cards - hope the APNE 100 case will be eliminated as
+ * dead code if MULTI_ISA is not set */
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))

This fails to compile due to a missing closing parenthesis.

Sorry - looks like brown paper bag time today. (I did say 'entirely untested'? Didn't expect such a thorough review for a first RFC patch ...)

Sorry, I missed that part in the cover letter ;-)

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#33 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Geert,

Quoted 5 lines · Geert Uytterhoeven

+#define isa_inb(port) ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))

Quoted 3 lines
Quoted 1 line

This fails to compile due to a missing closing parenthesis.

Sorry - looks like brown paper bag time today. (I did say 'entirely untested'? Didn't expect such a thorough review for a first RFC patch ...)

Sorry, I missed that part in the cover letter ;-)

I'll put it more prominently next time.

Ran all patches through checkpatch now, and I still get warnings and even a few errors ('trailing statements should be on the next line'). All due to my keeping to the code style used in io_mm.h, as far as I could see.

What's your preference - additions in new style, or keep the old style?

Cheers,

    Michael

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

#34 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

In reply to Geert Uytterhoeven

Hi Geert,

Quoted 5 lines · Geert Uytterhoeven

+#define isa_inb(port) ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))

Quoted 3 lines
Quoted 1 line

This fails to compile due to a missing closing parenthesis.

Sorry - looks like brown paper bag time today. (I did say 'entirely untested'? Didn't expect such a thorough review for a first RFC patch ...)

Sorry, I missed that part in the cover letter ;-)

I'll put it more prominently next time.

Ran all patches through checkpatch now, and I still get warnings and even a few errors ('trailing statements should be on the next line'). All due to my keeping to the code style used in io_mm.h, as far as I could see.

What's your preference - additions in new style, or keep the old style?

Cheers,

    Michael

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

#35 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Michael,

Quoted 7 lines · Michael Schmitz
Quoted 5 lines · Geert Uytterhoeven

+#define isa_inb(port) ((ISA_TYPE == ISA_TYPE_AG100) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port))

Quoted 3 lines
Quoted 1 line

This fails to compile due to a missing closing parenthesis.

Sorry - looks like brown paper bag time today. (I did say 'entirely untested'? Didn't expect such a thorough review for a first RFC patch ...)

Sorry, I missed that part in the cover letter ;-)

Quoted 8 lines

I'll put it more prominently next time.

Ran all patches through checkpatch now, and I still get warnings and even a few errors ('trailing statements should be on the next line'). All due to my keeping to the code style used in io_mm.h, as far as I could see.

What's your preference - additions in new style, or keep the old style?

Please use the existing style, unless you're willing to modernize the whole file in a separate patch.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#36 lore raw

RFC PATCH 2/2 net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

---
 drivers/net/ethernet/8390/Kconfig | 13 +++++++++++++
 drivers/net/ethernet/8390/apne.c  | 17 +++++++++++++++++
 2 files changed, 30 insertions(+)
drivers/net/ethernet/8390/Kconfig +13 -0
index 9f4b302..10103fb 100644
@@ -143,6 +143,19 @@ config APNE
 	  To compile this driver as a module, choose M here: the module
 	  will be called apne.
 
+if APNE
+config APNE100MBIT
+	bool "PCMCIA NE2000 100MBit support"
+	default n
+	---help---
+	  This changes the driver to support 10/100Mbit cards (e.g. Netgear
+	  FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+	  supported by the same driver.
+
+	  To activate 100 Mbit support at runtime, use the apne100 module
+	  parameter. 
+endif
+
 config PCMCIA_PCNET
 	tristate "NE2000 compatible PCMCIA support"
 	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +17 -0
index fe6c834..9648e45 100644
@@ -120,6 +120,10 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit, uint, 0);
+MODULE_PARM_DESC(apne_100_mbit, "Enable 100 Mbit support");
+
 struct net_device * __init apne_probe(int unit)
 {
 	struct net_device *dev;
@@ -139,6 +143,9 @@ struct net_device * __init apne_probe(int unit)
 	if ( !(AMIGAHW_PRESENT(PCMCIA)) )
 		return ERR_PTR(-ENODEV);
 
+        if (apne_100_mbit)
+                isa_type = ISA_TYPE_AG100;
+
 	pr_info("Looking for PCMCIA ethernet card : ");
 
 	/* check if a card is inserted */
@@ -590,6 +597,16 @@ static int init_pcmcia(void)
 #endif
 	u_long offset;
 
+#ifdef CONFIG_APNE100MBIT
+	/* reset card (idea taken from CardReset by Artur Pogoda) */
+	{
+		u_char  tmp = gayle.intreq;
+
+		gayle.intreq = 0xff;    mdelay(1);
+		gayle.intreq = tmp;     mdelay(300);
+	}
+#endif
+
 	pcmcia_reset();
 	pcmcia_program_voltage(PCMCIA_0V);
 	pcmcia_access_speed(PCMCIA_SPEED_250NS);
Signature · 1 line
2.7.4
#37 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Michael,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on m68k/for-next]
[also build test ERROR on linus/master v5.13-rc4 next-20210604] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Michael-Schmitz/m68k-io_mm-h-add-APNE-100-MBit-support/20210606-145511
base:   https://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git for-next
config: x86_64-rhel-8.3-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/ab329b079c3a9d8b1db018da46d7da344355e496
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Michael-Schmitz/m68k-io_mm-h-add-APNE-100-MBit-support/20210606-145511
        git checkout ab329b079c3a9d8b1db018da46d7da344355e496
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> Error: kernelrelease not valid - run 'make prepare' to update it
--
>> drivers/net/ethernet/8390/Kconfig:151: syntax error

drivers/net/ethernet/8390/Kconfig:150: unknown statement "---help---" drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '/' drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:151: unknown statement "This" drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character ',' drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:152: unknown statement "FA411" drivers/net/ethernet/8390/Kconfig:153:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:153: unknown statement "supported" drivers/net/ethernet/8390/Kconfig:155:warning: ignoring unsupported character ',' drivers/net/ethernet/8390/Kconfig:155: unknown statement "To" drivers/net/ethernet/8390/Kconfig:156:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:156: unknown statement "parameter"
--

>> drivers/net/ethernet/8390/Kconfig:151: syntax error
   drivers/net/ethernet/8390/Kconfig:150: unknown statement "---help---"
   drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '/'
   drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:151: unknown statement "This"
   drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character ','
   drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:152: unknown statement "FA411"
   drivers/net/ethernet/8390/Kconfig:153:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:153: unknown statement "supported"
   drivers/net/ethernet/8390/Kconfig:155:warning: ignoring unsupported character ','
   drivers/net/ethernet/8390/Kconfig:155: unknown statement "To"
   drivers/net/ethernet/8390/Kconfig:156:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:156: unknown statement "parameter"
   make[3]: *** [scripts/kconfig/Makefile:77: syncconfig] Error 1
   make[2]: *** [Makefile:614: syncconfig] Error 2
   make[1]: *** [Makefile:723: include/config/auto.conf.cmd] Error 2
   make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
   make[1]: Failed to remake makefile 'include/config/auto.conf'.
>> make[1]: *** No rule to make target 'modules_prepare'.
   make: *** [Makefile:215: __sub-make] Error 2
   make: Target 'modules_prepare' not remade because of errors.
--
>> drivers/net/ethernet/8390/Kconfig:151: syntax error

drivers/net/ethernet/8390/Kconfig:150: unknown statement "---help---" drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '/' drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:151: unknown statement "This" drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character ',' drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:152: unknown statement "FA411" drivers/net/ethernet/8390/Kconfig:153:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:153: unknown statement "supported" drivers/net/ethernet/8390/Kconfig:155:warning: ignoring unsupported character ',' drivers/net/ethernet/8390/Kconfig:155: unknown statement "To" drivers/net/ethernet/8390/Kconfig:156:warning: ignoring unsupported character '.' drivers/net/ethernet/8390/Kconfig:156: unknown statement "parameter" make[2]: *** [scripts/kconfig/Makefile:77: olddefconfig] Error 1 make[1]: *** [Makefile:614: olddefconfig] Error 2
make: *** [Makefile:215: __sub-make] Error 2
make: Target 'olddefconfig' not remade because of errors.
--

>> drivers/net/ethernet/8390/Kconfig:151: syntax error
   drivers/net/ethernet/8390/Kconfig:150: unknown statement "---help---"
   drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '/'
   drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:151:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:151: unknown statement "This"
   drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character ','
   drivers/net/ethernet/8390/Kconfig:152:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:152: unknown statement "FA411"
   drivers/net/ethernet/8390/Kconfig:153:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:153: unknown statement "supported"
   drivers/net/ethernet/8390/Kconfig:155:warning: ignoring unsupported character ','
   drivers/net/ethernet/8390/Kconfig:155: unknown statement "To"
   drivers/net/ethernet/8390/Kconfig:156:warning: ignoring unsupported character '.'
   drivers/net/ethernet/8390/Kconfig:156: unknown statement "parameter"
   make[3]: *** [scripts/kconfig/Makefile:77: syncconfig] Error 1
   make[2]: *** [Makefile:614: syncconfig] Error 2
   make[1]: *** [Makefile:723: include/config/auto.conf.cmd] Error 2
   make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
   make[1]: Failed to remake makefile 'include/config/auto.conf'.
   make[1]: *** [arch/x86/Makefile:292: checkbin] Error 1
>> Error: kernelrelease not valid - run 'make prepare' to update it

make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:215: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +151 drivers/net/ethernet/8390/Kconfig

    19	
    20	config PCMCIA_AXNET
    21		tristate "Asix AX88190 PCMCIA support"
    22		depends on PCMCIA
    23		help
    24		  Say Y here if you intend to attach an Asix AX88190-based PCMCIA
    25		  (PC-card) Fast Ethernet card to your computer.  These cards are
    26		  nearly NE2000 compatible but need a separate driver due to a few
    27		  misfeatures.
    28	
    29		  To compile this driver as a module, choose M here: the module will be
    30		  called axnet_cs.  If unsure, say N.
    31	
    32	config AX88796
    33		tristate "ASIX AX88796 NE2000 clone support" if !ZORRO
    34		depends on (ARM || MIPS || SUPERH || ZORRO || COMPILE_TEST)
    35		select CRC32
    36		select PHYLIB
    37		select MDIO_BITBANG
    38		help
    39		  AX88796 driver, using platform bus to provide
    40		  chip detection and resources
    41	
    42	config AX88796_93CX6
    43		bool "ASIX AX88796 external 93CX6 eeprom support"
    44		depends on AX88796
    45		select EEPROM_93CX6
    46		help
    47		  Select this if your platform comes with an external 93CX6 eeprom.
    48	
    49	config XSURF100
    50		tristate "Amiga XSurf 100 AX88796/NE2000 clone support"
    51		depends on ZORRO
    52		select AX88796
    53		select AX88796B_PHY
    54		help
    55		  This driver is for the Individual Computers X-Surf 100 Ethernet
    56		  card (based on the Asix AX88796 chip). If you have such a card,
    57		  say Y. Otherwise, say N.
    58	
    59		  To compile this driver as a module, choose M here: the module
    60		  will be called xsurf100.
    61	
    62	config HYDRA
    63		tristate "Hydra support"
    64		depends on ZORRO
    65		select CRC32
    66		help
    67		  If you have a Hydra Ethernet adapter, say Y. Otherwise, say N.
    68	
    69		  To compile this driver as a module, choose M here: the module
    70		  will be called hydra.
    71	
    72	config ARM_ETHERH
    73		tristate "I-cubed EtherH/ANT EtherM support"
    74		depends on ARM && ARCH_ACORN
    75		select CRC32
    76		help
    77		  If you have an Acorn system with one of these network cards, you
    78		  should say Y to this option if you wish to use it with Linux.
    79	
    80	config MAC8390
    81		tristate "Macintosh NS 8390 based ethernet cards"
    82		depends on MAC
    83		select CRC32
    84		help
    85		  If you want to include a driver to support Nubus or LC-PDS
    86		  Ethernet cards using an NS8390 chipset or its equivalent, say Y.
    87	
    88	config MCF8390
    89		tristate "ColdFire NS8390 based Ethernet support"
    90		depends on COLDFIRE
    91		select CRC32
    92		help
    93		  This driver is for Ethernet devices using an NS8390-compatible
    94		  chipset on many common ColdFire CPU based boards. Many of the older
    95		  Freescale dev boards use this, and some other common boards like
    96		  some SnapGear routers do as well.
    97	
    98		  If you have one of these boards and want to use the network interface
    99		  on them then choose Y. To compile this driver as a module, choose M
   100		  here, the module will be called mcf8390.
   101	
   102	config NE2000
   103		tristate "NE2000/NE1000 support"
   104		depends on (ISA || (Q40 && m) || MACH_TX49XX || ATARI_ETHERNEC)
   105		select CRC32
   106		help
   107		  If you have a network (Ethernet) card of this type, say Y here.
   108		  Many Ethernet cards without a specific driver are compatible with
   109		  the NE2000.
   110	
   111		  If you have a PCI NE2000 card however, say N here and Y to "PCI
   112		  NE2000 and clone support" below.
   113	
   114		  To compile this driver as a module, choose M here. The module
   115		  will be called ne.
   116	
   117	config NE2K_PCI
   118		tristate "PCI NE2000 and clones support (see help)"
   119		depends on PCI
   120		select CRC32
   121		help
   122		  This driver is for NE2000 compatible PCI cards. It will not work
   123		  with ISA NE2000 cards (they have their own driver, "NE2000/NE1000
   124		  support" below). If you have a PCI NE2000 network (Ethernet) card,
   125		  say Y here.
   126	
   127		  This driver also works for the following NE2000 clone cards:
   128		  RealTek RTL-8029  Winbond 89C940  Compex RL2000  KTI ET32P2
   129		  NetVin NV5000SC   Via 86C926      SureCom NE34   Winbond
   130		  Holtek HT80232    Holtek HT80229
   131	
   132		  To compile this driver as a module, choose M here. The module
   133		  will be called ne2k-pci.
   134	
   135	config APNE
   136		tristate "PCMCIA NE2000 support"
   137		depends on AMIGA_PCMCIA
   138		select CRC32
   139		help
   140		  If you have a PCMCIA NE2000 compatible adapter, say Y.  Otherwise,
   141		  say N.
   142	
   143		  To compile this driver as a module, choose M here: the module
   144		  will be called apne.
   145	
   146	if APNE
   147	config APNE100MBIT
   148		bool "PCMCIA NE2000 100MBit support"
   149		default n
   150		---help---
 > 151		  This changes the driver to support 10/100Mbit cards (e.g. Netgear

152 FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
153 supported by the same driver.
154
155 To activate 100 Mbit support at runtime, use the apne100 module
156 parameter.
157 endif
158

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#38 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Hi Michael,

Quoted 8 lines · Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Quoted 5 lines

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

Thanks for your patch!

drivers/net/ethernet/8390/Kconfig config APNE · line 146

Quoted 7 lines
drivers/net/ethernet/8390/Kconfig +1 -0
@@ -143,6 +143,19 @@ config APNE
          To compile this driver as a module, choose M here: the module
          will be called apne.
 
+if APNE

Please use "depends on APNE" instead of an if/endif block, as there's only a single symbol to cover.

drivers/net/ethernet/8390/Kconfig config APNE · line 156

Quoted 10 lines
drivers/net/ethernet/8390/Kconfig +10 -0
+config APNE100MBIT
+       bool "PCMCIA NE2000 100MBit support"
+       default n
+       ---help---
+         This changes the driver to support 10/100Mbit cards (e.g. Netgear
+         FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+         supported by the same driver.
+
+         To activate 100 Mbit support at runtime, use the apne100 module
+         parameter.

Trailing space.

Quoted 10 lines
drivers/net/ethernet/8390/Kconfig +2 -0
+endif
+
 config PCMCIA_PCNET
        tristate "NE2000 compatible PCMCIA support"
        depends on PCMCIA
drivers/net/ethernet/8390/apne.c +0 -0
index fe6c834..9648e45 100644

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 125

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +3 -0
@@ -120,6 +120,10 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit, uint, 0);
+MODULE_PARM_DESC(apne_100_mbit, "Enable 100 Mbit support");

Shouldn't this depend on CONFIG_APNE100MBIT, too?
Perhaps we shouldn't bother with the config symbol, and include this unconditionally?

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 147

Quoted 10 lines
drivers/net/ethernet/8390/apne.c +3 -0
+
 struct net_device * __init apne_probe(int unit)
 {
        struct net_device *dev;
@@ -139,6 +143,9 @@ struct net_device * __init apne_probe(int unit)
        if ( !(AMIGAHW_PRESENT(PCMCIA)) )
                return ERR_PTR(-ENODEV);
 
+        if (apne_100_mbit)
+                isa_type = ISA_TYPE_AG100;

Likewise.

Can we enable this automatically when needed, based on the chip detected?

+ spaces instead of TABs (scripts/checkpatch.pl is your friend).

Quoted 6 lines
drivers/net/ethernet/8390/apne.c +1 -0
+
        pr_info("Looking for PCMCIA ethernet card : ");
 
        /* check if a card is inserted */
@@ -590,6 +597,16 @@ static int init_pcmcia(void)
 #endif

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 607

Quoted 10 lines
drivers/net/ethernet/8390/apne.c +8 -0
        u_long offset;
 
+#ifdef CONFIG_APNE100MBIT
+       /* reset card (idea taken from CardReset by Artur Pogoda) */
+       {
+               u_char  tmp = gayle.intreq;
+
+               gayle.intreq = 0xff;    mdelay(1);
+               gayle.intreq = tmp;     mdelay(300);
+       }

Is this safe for all cards?

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 612

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2 -0
+#endif
+
        pcmcia_reset();
        pcmcia_program_voltage(PCMCIA_0V);
        pcmcia_access_speed(PCMCIA_SPEED_250NS);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#39 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Geert,

Am 07.06.2021 um 20:08 schrieb Geert Uytterhoeven:

Quoted 25 lines

Hi Michael,

Quoted 8 lines · Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Quoted 5 lines

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

Thanks for your patch!

Quoted 6 lines
drivers/net/ethernet/8390/Kconfig +0 -0
@@ -143,6 +143,19 @@ config APNE
          To compile this driver as a module, choose M here: the module
          will be called apne.
 
Quoted 4 lines

drivers/net/ethernet/8390/Kconfig config APNE · line 146

Quoted 1 line
drivers/net/ethernet/8390/Kconfig +1 -0
+if APNE

Please use "depends on APNE" instead of an if/endif block, as there's only a single symbol to cover.

True - I had copied that straight from Alex' patch ..

Quoted 13 lines

drivers/net/ethernet/8390/Kconfig config APNE · line 156

Quoted 11 lines
drivers/net/ethernet/8390/Kconfig +10 -0
+config APNE100MBIT
+       bool "PCMCIA NE2000 100MBit support"
+       default n
+       ---help---
+         This changes the driver to support 10/100Mbit cards (e.g. Netgear
+         FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+         supported by the same driver.
+
+         To activate 100 Mbit support at runtime, use the apne100 module
+         parameter.

Trailing space.

And ---help--- did confuse kbuild, as I found out.

Quoted 13 lines
Quoted 13 lines
drivers/net/ethernet/8390/Kconfig +2 -0
+endif
+
 config PCMCIA_PCNET
        tristate "NE2000 compatible PCMCIA support"
        depends on PCMCIA
drivers/net/ethernet/8390/apne.c +0 -0
index fe6c834..9648e45 100644
@@ -120,6 +120,10 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
Quoted 7 lines

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 125

Quoted 3 lines
drivers/net/ethernet/8390/apne.c +3 -0
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit, uint, 0);
+MODULE_PARM_DESC(apne_100_mbit, "Enable 100 Mbit support");

Shouldn't this depend on CONFIG_APNE100MBIT, too?
Perhaps we shouldn't bother with the config symbol, and include this unconditionally?

At least the parameter should not hurt - this is entirely untested so I'd hate to break APNE by including the io_mm.h changes unconditionally.

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/8390/apne.c +1 -0
+
 struct net_device * __init apne_probe(int unit)
 {
        struct net_device *dev;
@@ -139,6 +143,9 @@ struct net_device * __init apne_probe(int unit)
        if ( !(AMIGAHW_PRESENT(PCMCIA)) )
                return ERR_PTR(-ENODEV);
 
Quoted 4 lines

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 147

Quoted 2 lines
drivers/net/ethernet/8390/apne.c +2 -0
+        if (apne_100_mbit)
+                isa_type = ISA_TYPE_AG100;

Likewise.

And that one breaks if 16 bit support isn't always enabled. I'll conditionalize it.

Quoted 2 lines

Can we enable this automatically when needed, based on the chip detected?

I wondered about that - we'd have to poke the chip with 16 bit IO if 8 bit IO fails, no idea what side effects that would have.

Maybe retrying the card reset in apne_probe1 again after changing isa_type would work, but someone would have to try that and report back.

Quoted 1 line

+ spaces instead of TABs (scripts/checkpatch.pl is your friend).

Thanks, I'll fix that. Got sloppy with checkpatch, sorry.

Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/8390/apne.c +1 -0
+
        pr_info("Looking for PCMCIA ethernet card : ");
 
        /* check if a card is inserted */
@@ -590,6 +597,16 @@ static int init_pcmcia(void)
 #endif
        u_long offset;
 
Quoted 10 lines

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 607

Quoted 8 lines
drivers/net/ethernet/8390/apne.c +8 -0
+#ifdef CONFIG_APNE100MBIT
+       /* reset card (idea taken from CardReset by Artur Pogoda) */
+       {
+               u_char  tmp = gayle.intreq;
+
+               gayle.intreq = 0xff;    mdelay(1);
+               gayle.intreq = tmp;     mdelay(300);
+       }

Is this safe for all cards?

I _think_ so, but this really is a question for Alex and others involved in developing the original patch. (The original patch had that conditionalized as well so I might be wrong ...)

I'll send v2 once I've fixed these all up...

Cheers,

Michael

Quoted 10 lines

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 612

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2 -0
+#endif
+
        pcmcia_reset();
        pcmcia_program_voltage(PCMCIA_0V);
        pcmcia_access_speed(PCMCIA_SPEED_250NS);

Gr{oetje,eeting}s,

Geert

#40 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi all,

Quoted 1 line

It's been quite a while - can you still try and build/test this change, Alex?

I'm happy to test it again (assuming my Amiga still works, not used for a while).
But I'm waiting until you guys have perfected the patch.

Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/8390/apne.c +1 -0
+
        pr_info("Looking for PCMCIA ethernet card : ");
 
        /* check if a card is inserted */
@@ -590,6 +597,16 @@ static int init_pcmcia(void)
 #endif
        u_long offset;
 
Quoted 10 lines

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 607

Quoted 8 lines
drivers/net/ethernet/8390/apne.c +8 -0
+#ifdef CONFIG_APNE100MBIT
+       /* reset card (idea taken from CardReset by Artur Pogoda) */
+       {
+               u_char  tmp = gayle.intreq;
+
+               gayle.intreq = 0xff;    mdelay(1);
+               gayle.intreq = tmp;     mdelay(300);
+       }

Is this safe for all cards?

Quoted 3 lines

I _think_ so, but this really is a question for Alex and others involved in developing the original patch. (The original patch had that conditionalized as well so I might be wrong ...)

My code is based on the patches here: http://www.g-mb.de/pcmcia_e.html

I'm not deep into it, just adapted the patch. And that's why I can't tell if the other drivers will work with it always enabled, sorry.

Bye,
Alex.

#41 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Alex,

Am 07.06.2021 um 20:46 schrieb ALeX Kazik:

Quoted 7 lines

Hi all,

Quoted 1 line

It's been quite a while - can you still try and build/test this change, Alex?

I'm happy to test it again (assuming my Amiga still works, not used for a while).
But I'm waiting until you guys have perfected the patch.

Thanks, I'll keep you in the CC list.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
drivers/net/ethernet/8390/apne.c +1 -0
+
        pr_info("Looking for PCMCIA ethernet card : ");
 
        /* check if a card is inserted */
@@ -590,6 +597,16 @@ static int init_pcmcia(void)
 #endif

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 607

Quoted 10 lines
drivers/net/ethernet/8390/apne.c +8 -0
        u_long offset;
 
+#ifdef CONFIG_APNE100MBIT
+       /* reset card (idea taken from CardReset by Artur Pogoda) */
+       {
+               u_char  tmp = gayle.intreq;
+
+               gayle.intreq = 0xff;    mdelay(1);
+               gayle.intreq = tmp;     mdelay(300);
+       }

Is this safe for all cards?

Quoted 8 lines
Quoted 3 lines

I _think_ so, but this really is a question for Alex and others involved in developing the original patch. (The original patch had that conditionalized as well so I might be wrong ...)

My code is based on the patches here: http://www.g-mb.de/pcmcia_e.html

I'm not deep into it, just adapted the patch. And that's why I can't tell if the other drivers will work with it always enabled, sorry.

According to that site, the reset is needed for all 100 Mbit cards, and in your patch from 2018, you mentioned that this is because the PCMCIA reset line isn't connected on these cards. Based on that reading, this _should_ be safe for those cards that have a reset line wired as well.

Who could we ask - I guess Rolf Anders was the author of a previous patch for the 100 Mbit APNE compatible cards? Not sure I've seen an e-mail address for Artur Pogoda?

Cheers,

Michael

Quoted 4 lines

Bye,
Alex.

#42 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Hi Michael,

Quoted 17 lines · Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

drivers/net/ethernet/8390/Kconfig config APNE · line 150

Quoted 8 lines
drivers/net/ethernet/8390/Kconfig +5 -0
@@ -143,6 +143,19 @@ config APNE
          To compile this driver as a module, choose M here: the module
          will be called apne.
 
+if APNE
+config APNE100MBIT
+       bool "PCMCIA NE2000 100MBit support"
+       default n
+       ---help---

"help" (support for "---help---" was removed in v5.9).

drivers/net/ethernet/8390/Kconfig config APNE · line 161

Quoted 11 lines
drivers/net/ethernet/8390/Kconfig +8 -0
+         This changes the driver to support 10/100Mbit cards (e.g. Netgear
+         FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+         supported by the same driver.
+
+         To activate 100 Mbit support at runtime, use the apne100 module
+         parameter.
+endif
+
 config PCMCIA_PCNET
        tristate "NE2000 compatible PCMCIA support"
        depends on PCMCIA

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#43 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Hi Michael,

Quoted 17 lines · Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 124

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2 -0
@@ -120,6 +120,10 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit, uint, 0);

error: macro "module_param_named" requires 4 arguments, but only 3 given

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#44 lore raw

Re: [PATCH RFC 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Geert,

Alex has been testing the patch for me, but had to resort to hardcoding the kernel option (or isa_type).

How would this option be specified on the kernel command line?

I would have thought apne:apne_100_mbit=1 would set that variable to 1?

There's been other issues with the patch as well, this appears to need a bit more work.

Cheers,

    Michael

Quoted 30 lines · Geert Uytterhoeven

Hi Michael,

Quoted 16 lines · Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 124

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2 -0
@@ -120,6 +120,10 @@ static u32 apne_msg_enable;
  module_param_named(msg_enable, apne_msg_enable, uint, 0444);
  MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit, uint, 0);

error: macro "module_param_named" requires 4 arguments, but only 3 given

Gr{oetje,eeting}s,

Geert

#45 lore raw

cover Add APNE PCMCIA 100 Mbit support

In reply to Michael Schmitz

Now that we've sanitzed io_mm.h, revisit support for the 100 Mbit APNE PCMCIA card variants that didn't find favour with the netdev folks three years ago.

Add another ISA type for these cards, and switch to that type from the APNE probe code in response to a module parameter.

I've addressed review comments received so far, to the best of my ability.

Compile tested only - hopefully someone will be encouraged to give this a try before I submit the apne.c patch to netdev.

Cheers,

Michael

#46 lore raw

PATCH 1/2 m68k: io_mm.h - add APNE 100 MBit support

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG16 dynamically switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

--
Changes from RFC:

Geert Uytterhoeven:
- rename ISA_TYPE_AG100 to ISA_TYPE_AG16 (16 bit cards)
- move ISA_TYPE_AG16 case inside #ifdef CONFIG_AMIGA_PCMCIA
- change #if defined(CONFIG_APNE_100MBIT) to #ifdef
- fix parentheses in isa_inb() define
- omit comment about compiler optimization

- add ISA_TYPE_AG16 case to isa_delay()

---
 arch/m68k/include/asm/io_mm.h | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
arch/m68k/include/asm/io_mm.h +25 -1
index 6eae9ec..a965a0e 100644
@@ -101,6 +101,11 @@
 #define ISA_TYPE_Q40  (1)
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
+#define ISA_TYPE_AG16 (4)	/* for 100 MBit APNE card */
+
+#if defined(CONFIG_APNE100MBIT)
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -155,6 +163,9 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -171,6 +182,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
   switch(ISA_TYPE)
     {
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
     }
@@ -184,6 +198,9 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -203,6 +220,9 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -216,13 +236,14 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG16) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port)))
+
 #define isa_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
 	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\
@@ -270,6 +291,9 @@ static inline void isa_delay(void)
     case ISA_TYPE_Q40: isa_outb(0,0x80); break;
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: break;
+#endif
     case ISA_TYPE_AG: break;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
Signature · 1 line
2.7.4
#47 lore raw

Re: [PATCH v1 1/2] m68k: io_mm.h - add APNE 100 MBit support

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 8 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +3 -0
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);

Is the fallthrough annotation really needed?

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
#48 lore raw

Re: [PATCH v1 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Andreas,

Quoted 11 lines · Andreas Schwab

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 8 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +3 -0
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);

Is the fallthrough annotation really needed?

Just to shut up compiler warnings, and even that I haven't seen myself.

I have seen a number of patches adding either comments or this annotation in the core NCR5380 driver (which Finn maintains, who suggested this annotation to an earlier version of the Q40/Atari io_mm.h patch), so adding annotations appears to be encouraged now.

I personally think these annotations are over the top generally, but I've learned to program when computed goto statements were still en vogue.

In this particular case, there can be no doubt that the fallthrough is intentional, so on balance, I'll remove those annotations as well (unless Finn strongly objects?).

Cheers,

    Michael

Cheers,

    Michael

Quoted 3 lines

Andreas.

#49 lore raw

Re: [PATCH v1 1/2] m68k: io_mm.h - add APNE 100 MBit support

Quoted 20 lines · Michael Schmitz
Quoted 11 lines · Andreas Schwab

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 8 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +3 -0
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);

Is the fallthrough annotation really needed?

Just to shut up compiler warnings, and even that I haven't seen myself.

I have seen a number of patches adding either comments or this annotation in the core NCR5380 driver (which Finn maintains, who suggested this annotation to an earlier version of the Q40/Atari io_mm.h patch), so adding annotations appears to be encouraged now.

Quoted 7 lines

I personally think these annotations are over the top generally, but I've learned to program when computed goto statements were still en vogue.

In this particular case, there can be no doubt that the fallthrough is intentional, so on balance, I'll remove those annotations as well (unless Finn strongly objects?).

I don't object to removing it. On the contrary, in a previous message I also questioned adding this particular 'fallthrough' (though I did recommended adding a different one).

In general, there's no way to predict which static checkers are going to complain about any given line of code. They don't all agree about correctness and they are a moving target, just like fashion or reviewers' preferred code styles.

The 'fallthrough' that I recommended was merely the one that seemed to improve readability to my eyes (and not to some algorithm). I didn't actually run "make C=1 W=1" or any other checker.

#50 lore raw

Re: [PATCH v1 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Finn,

Quoted 29 lines · Finn Thain
Quoted 20 lines · Michael Schmitz
Quoted 11 lines · Andreas Schwab

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 8 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +3 -0
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);

Is the fallthrough annotation really needed?

Just to shut up compiler warnings, and even that I haven't seen myself.

I have seen a number of patches adding either comments or this annotation in the core NCR5380 driver (which Finn maintains, who suggested this annotation to an earlier version of the Q40/Atari io_mm.h patch), so adding annotations appears to be encouraged now.

Quoted 7 lines

I personally think these annotations are over the top generally, but I've learned to program when computed goto statements were still en vogue.

In this particular case, there can be no doubt that the fallthrough is intentional, so on balance, I'll remove those annotations as well (unless Finn strongly objects?).

Quoted 8 lines

I don't object to removing it. On the contrary, in a previous message I also questioned adding this particular 'fallthrough' (though I did recommended adding a different one).

In general, there's no way to predict which static checkers are going to complain about any given line of code. They don't all agree about correctness and they are a moving target, just like fashion or reviewers' preferred code styles.

AFAIK, they only complain when the switch() operates on an enum, and not all enum values are handled.

When operating on an int, there's not enough address space on 32-bit machines to handle all cases ;-)

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#51 lore raw

Re: [PATCH v1 1/2] m68k: io_mm.h - add APNE 100 MBit support

Hi Geert,

thanks for the explanation - and thanks Finn and Andreas for clarifying. I've removed the annotation in v2.

Cheers,

    Michael

Quoted 48 lines · Geert Uytterhoeven

Hi Finn,

Quoted 27 lines · Finn Thain
Quoted 19 lines · Michael Schmitz
Quoted 11 lines · Andreas Schwab

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 8 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +3 -0
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
       case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
   #endif
   #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
       case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);

Is the fallthrough annotation really needed?

Just to shut up compiler warnings, and even that I haven't seen myself.

I have seen a number of patches adding either comments or this annotation in the core NCR5380 driver (which Finn maintains, who suggested this annotation to an earlier version of the Q40/Atari io_mm.h patch), so adding annotations appears to be encouraged now.

Quoted 7 lines

I personally think these annotations are over the top generally, but I've learned to program when computed goto statements were still en vogue.

In this particular case, there can be no doubt that the fallthrough is intentional, so on balance, I'll remove those annotations as well (unless Finn strongly objects?).

Quoted 8 lines

I don't object to removing it. On the contrary, in a previous message I also questioned adding this particular 'fallthrough' (though I did recommended adding a different one).

In general, there's no way to predict which static checkers are going to complain about any given line of code. They don't all agree about correctness and they are a moving target, just like fashion or reviewers' preferred code styles.

AFAIK, they only complain when the switch() operates on an enum, and not all enum values are handled.

When operating on an int, there's not enough address space on 32-bit machines to handle all cases ;-)

Gr{oetje,eeting}s,

Geert

#52 lore raw

Re: [PATCH v1 1/2] m68k: io_mm.h - add APNE 100 MBit support

In reply to Michael Schmitz
Quoted 15 lines · Michael Schmitz

Hi Andreas,

Quoted 11 lines · Andreas Schwab

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 8 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +3 -0
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: fallthrough;
+#endif
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);

Is the fallthrough annotation really needed?

Quoted 1 line

Just to shut up compiler warnings, and even that I haven't seen myself.

If there is no warning, there is nothing to shut up.

Quoted 3 lines

In this particular case, there can be no doubt that the fallthrough is intentional, so on balance, I'll remove those annotations as well (unless Finn strongly objects?).

There is no fallthrough, because there is no code.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
#53 lore raw

PATCH 2/2 net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

--
Changes from RFC:

Geert Uytterhoeven:
- change APNE_100MBIT to depend on APNE
- change '---help---' to 'help' (former no longer supported)
- fix whitespace errors
- fix module_param_named() arg count
- protect all added code by #ifdef CONFIG_APNE_100MBIT

---
 drivers/net/ethernet/8390/Kconfig | 12 ++++++++++++
 drivers/net/ethernet/8390/apne.c  | 21 +++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/net/ethernet/8390/Kconfig +12 -0
index 9f4b302..8ff8da6 100644
@@ -143,6 +143,18 @@ config APNE
 	  To compile this driver as a module, choose M here: the module
 	  will be called apne.
 
+config APNE100MBIT
+	bool "PCMCIA NE2000 100MBit support"
+	depends on APNE
+	default n
+	help
+	  This changes the driver to support 10/100Mbit cards (e.g. Netgear
+	  FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+	  supported by the same driver.
+
+	  To activate 100 Mbit support at runtime, use the apne100 module
+	  parameter.
+
 config PCMCIA_PCNET
 	tristate "NE2000 compatible PCMCIA support"
 	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +21 -0
index fe6c834..cd99cc3 100644
@@ -120,6 +120,12 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+#ifdef CONFIG_APNE100MBIT
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit_msg, apne_100_mbit, uint, 0);
+MODULE_PARM_DESC(apne_100_mbit_msg, "Enable 100 Mbit support");
+#endif
+
 struct net_device * __init apne_probe(int unit)
 {
 	struct net_device *dev;
@@ -139,6 +145,11 @@ struct net_device * __init apne_probe(int unit)
 	if ( !(AMIGAHW_PRESENT(PCMCIA)) )
 		return ERR_PTR(-ENODEV);
 
+#ifdef CONFIG_APNE100MBIT
+	if (apne_100_mbit)
+		isa_type = ISA_TYPE_AG16;
+#endif
+
 	pr_info("Looking for PCMCIA ethernet card : ");
 
 	/* check if a card is inserted */
@@ -590,6 +601,16 @@ static int init_pcmcia(void)
 #endif
 	u_long offset;
 
+#ifdef CONFIG_APNE100MBIT
+	/* reset card (idea taken from CardReset by Artur Pogoda) */
+	{
+		u_char  tmp = gayle.intreq;
+
+		gayle.intreq = 0xff;    mdelay(1);
+		gayle.intreq = tmp;     mdelay(300);
+	}
+#endif
+
 	pcmcia_reset();
 	pcmcia_program_voltage(PCMCIA_0V);
 	pcmcia_access_speed(PCMCIA_SPEED_250NS);
Signature · 1 line
2.7.4
#54 lore raw

v2 cover Add APNE PCMCIA 100 Mbit support

In reply to Michael Schmitz

Now that we've sanitzed io_mm.h, revisit support for the 100 Mbit APNE PCMCIA card variants that didn't find favour with the netdev folks three years ago.

Add another ISA type for these cards, and switch to that type from the APNE probe code in response to a module parameter.

I've addressed review comments received so far, to the best of my ability. Patch 2 not changed in v2, only comments on patch 1 by Andreas Schwab were addressed.

Compile tested only - hopefully someone will be encouraged to give this a try before I submit the apne.c patch to netdev.

Cheers,

Michael

#55 lore raw

PATCH v2 1/2 m68k: io_mm.h - add APNE 100 MBit support

Add code to support 10 Mbit and 100 Mbit mode for APNE driver.

A new ISA type ISA_TYPE_AG16 dynamically switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

--
Changes from v1:

Andreas Schwab:
- remove redundant fallthrough annotations

Changes from RFC:

Geert Uytterhoeven:
- rename ISA_TYPE_AG100 to ISA_TYPE_AG16 (16 bit cards)
- move ISA_TYPE_AG16 case inside #ifdef CONFIG_AMIGA_PCMCIA
- change #if defined(CONFIG_APNE_100MBIT) to #ifdef
- fix parentheses in isa_inb() define
- omit comment about compiler optimization

- add ISA_TYPE_AG16 case to isa_delay()

fixup - review comment Andreas Schwab (fallthrough)

---
 arch/m68k/include/asm/io_mm.h | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
arch/m68k/include/asm/io_mm.h +25 -1
index 9c521b0..3ab2f1d 100644
@@ -101,6 +101,11 @@
 #define ISA_TYPE_Q40  (1)
 #define ISA_TYPE_AG   (2)
 #define ISA_TYPE_ENEC (3)
+#define ISA_TYPE_AG16 (4)	/* for 100 MBit APNE card */
+
+#if defined(CONFIG_APNE100MBIT)
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -136,6 +141,9 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -155,6 +163,9 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -171,6 +182,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
   switch(ISA_TYPE)
     {
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
     }
@@ -184,6 +198,9 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -203,6 +220,9 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -216,13 +236,14 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
 #define isa_inl(port)      (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
 #define isa_outb(val,port) out_8(isa_itb(port),(val))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+#define isa_inb(port)      ((ISA_TYPE == ISA_TYPE_AG16) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port)))
+
 #define isa_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
 	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\
@@ -270,6 +291,9 @@ static inline void isa_delay(void)
     case ISA_TYPE_Q40: isa_outb(0,0x80); break;
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: break;
+#endif
     case ISA_TYPE_AG: break;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
Signature · 1 line
2.7.4
#56 lore raw

PATCH v2 2/2 net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Add Kconfig option, module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.

10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Additional code to reset the PCMCIA hardware is also added to the driver probe.

Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.

--
Changes from RFC:

Geert Uytterhoeven:
- change APNE_100MBIT to depend on APNE
- change '---help---' to 'help' (former no longer supported)
- fix whitespace errors
- fix module_param_named() arg count
- protect all added code by #ifdef CONFIG_APNE_100MBIT

---
 drivers/net/ethernet/8390/Kconfig | 12 ++++++++++++
 drivers/net/ethernet/8390/apne.c  | 21 +++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/net/ethernet/8390/Kconfig +12 -0
index 9f4b302..8ff8da6 100644
@@ -143,6 +143,18 @@ config APNE
 	  To compile this driver as a module, choose M here: the module
 	  will be called apne.
 
+config APNE100MBIT
+	bool "PCMCIA NE2000 100MBit support"
+	depends on APNE
+	default n
+	help
+	  This changes the driver to support 10/100Mbit cards (e.g. Netgear
+	  FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+	  supported by the same driver.
+
+	  To activate 100 Mbit support at runtime, use the apne100 module
+	  parameter.
+
 config PCMCIA_PCNET
 	tristate "NE2000 compatible PCMCIA support"
 	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +21 -0
index fe6c834..cd99cc3 100644
@@ -120,6 +120,12 @@ static u32 apne_msg_enable;
 module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
 
+#ifdef CONFIG_APNE100MBIT
+static u32 apne_100_mbit;
+module_param_named(apne_100_mbit_msg, apne_100_mbit, uint, 0);
+MODULE_PARM_DESC(apne_100_mbit_msg, "Enable 100 Mbit support");
+#endif
+
 struct net_device * __init apne_probe(int unit)
 {
 	struct net_device *dev;
@@ -139,6 +145,11 @@ struct net_device * __init apne_probe(int unit)
 	if ( !(AMIGAHW_PRESENT(PCMCIA)) )
 		return ERR_PTR(-ENODEV);
 
+#ifdef CONFIG_APNE100MBIT
+	if (apne_100_mbit)
+		isa_type = ISA_TYPE_AG16;
+#endif
+
 	pr_info("Looking for PCMCIA ethernet card : ");
 
 	/* check if a card is inserted */
@@ -590,6 +601,16 @@ static int init_pcmcia(void)
 #endif
 	u_long offset;
 
+#ifdef CONFIG_APNE100MBIT
+	/* reset card (idea taken from CardReset by Artur Pogoda) */
+	{
+		u_char  tmp = gayle.intreq;
+
+		gayle.intreq = 0xff;    mdelay(1);
+		gayle.intreq = tmp;     mdelay(300);
+	}
+#endif
+
 	pcmcia_reset();
 	pcmcia_program_voltage(PCMCIA_0V);
 	pcmcia_access_speed(PCMCIA_SPEED_250NS);
Signature · 1 line
2.7.4
#57 lore raw

Re: [PATCH v2 0/2] Add APNE PCMCIA 100 Mbit support

In reply to Michael Schmitz

Hi,

I've tested the patches and they work.

At first I got it only to work with the following line removed/commented out:
if (apne_100_mbit)
And thus enabling the following line always.

I've changed, with the help of Michael, the parameters to:

  static u32 apne_100_mbit = 0;
  module_param_named(100_mbit, apne_100_mbit, uint, 0644);
  MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");

And was able to enable it with the kernel option "apne.100_mbit=1".

It's also available as /sys/module/apne/parameters/100_mbit

The 0644 is the permission (root can change it), If it shouldn't be changed at runtime 0444 or 0 would be used.

(I think there is also a bool option instead of the uint, but I'm glad it works like this.)

Alex.

#58 lore raw

Re: [PATCH v2 0/2] Add APNE PCMCIA 100 Mbit support

Hi Alex,

Thanks for testing!

Quoted 14 lines · ALeX Kazik

Hi,

I've tested the patches and they work.

At first I got it only to work with the following line removed/commented out:

   if (apne_100_mbit)

And thus enabling the following line always.

I've changed, with the help of Michael, the parameters to:

   static u32 apne_100_mbit = 0;
   module_param_named(100_mbit, apne_100_mbit, uint, 0644);
   MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");
Quoted 6 lines

And was able to enable it with the kernel option "apne.100_mbit=1".

It's also available as /sys/module/apne/parameters/100_mbit

The 0644 is the permission (root can change it), If it shouldn't be changed at runtime 0444 or 0 would be used.

Changing that parameter at runtime won't do anything (it's only tested at device probe time). But I'd better change the permission to 444.

Quoted 2 lines

(I think there is also a bool option instead of the uint, but I'm glad it works like this.)

True, that would be the better option indeed. I'll change that in the next version (which will go to netdev as well).

Cheers,

    Michael

Quoted 2 lines

Alex.

#59 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

In reply to Michael Schmitz

Hi Michael,

Quoted 21 lines · Michael Schmitz
Quoted 7 lines · Finn Thain
Quoted 6 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +0 -0
@@ -52,7 +52,11 @@
  #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
  #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
Quoted 8 lines

arch/m68k/include/asm/io_mm.h line 61

Quoted 7 lines
arch/m68k/include/asm/io_mm.h +4 -0
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1
+#else
  #define MULTI_ISA 0
+#endif /* Atari */
  #endif /* Q40 */
 

I have to wonder whether there is a nice simple definition for MULTI_ISA.

As I understand it, MULTI_ISA means that different byte orders and/or different address translations need to be used in the same kernel, so all that cannot be decided at build time.

Quoted 7 lines

As long as there is only a single platform that will use this code (ISA only used on a single platform, and neither Atari IDE nor EtherNEC used), MULTI_ISA is not needed.

If we have Kconfig symbols for 'single platform only', and 'multi-platform ISA use', that might be shorter to write and easier to understand. Geert?

It would be nice to have that automatically, like with the current MULTI_ISA define (and all the MACH_* in arch/m68k/include/asm/setup.h). Perhaps we should extend kconfig syntax to define a group of related symbols, and to automatically generate CONFIG_FOO_MULTI or CONFIG_FOO_SINGLE (and even CONFIG_BAR_ONLY?) symbols?

group ISA
item ATARI_ROM_ISA
item AMIGA_PCMCIA
item Q40

=> CONFIG_ISA_MULTI or CONFIG_ISA_SINGLE (+ e.g. ATARI_ROM_ISA_ONLY
if appropriate).

Are there other users who can benefit from this?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#60 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Geert,

Am 04.06.2021 um 19:54 schrieb Geert Uytterhoeven:

Quoted 14 lines
Quoted 6 lines
Quoted 1 line

I have to wonder whether there is a nice simple definition for MULTI_ISA.

As I understand it, MULTI_ISA means that different byte orders and/or different address translations need to be used in the same kernel, so all that cannot be decided at build time.

Quoted 7 lines

As long as there is only a single platform that will use this code (ISA only used on a single platform, and neither Atari IDE nor EtherNEC used), MULTI_ISA is not needed.

If we have Kconfig symbols for 'single platform only', and 'multi-platform ISA use', that might be shorter to write and easier to understand. Geert?

Quoted 5 lines

It would be nice to have that automatically, like with the current MULTI_ISA define (and all the MACH_* in arch/m68k/include/asm/setup.h). Perhaps we should extend kconfig syntax to define a group of related symbols, and to automatically generate CONFIG_FOO_MULTI or CONFIG_FOO_SINGLE (and even CONFIG_BAR_ONLY?) symbols?

I take it this is not supported by our current Kconfig syntax?

Quoted 10 lines

group ISA
item ATARI_ROM_ISA
item AMIGA_PCMCIA
item Q40

=> CONFIG_ISA_MULTI or CONFIG_ISA_SINGLE (+ e.g. ATARI_ROM_ISA_ONLY
if appropriate).

Are there other users who can benefit from this?

Nothing comes to mind immediately. But there will be other drivers shared between different architectures (Mac / PowerPC?) that might benefit.

Cheers,

Michael

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

#61 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 16 lines · Michael Schmitz

Am 04.06.2021 um 19:54 schrieb Geert Uytterhoeven:

Quoted 15 lines
Quoted 14 lines
Quoted 2 lines

I have to wonder whether there is a nice simple definition for MULTI_ISA.

As I understand it, MULTI_ISA means that different byte orders and/or different address translations need to be used in the same kernel, so all that cannot be decided at build time.

As long as there is only a single platform that will use this code (ISA only used on a single platform, and neither Atari IDE nor EtherNEC used), MULTI_ISA is not needed.

If we have Kconfig symbols for 'single platform only', and 'multi-platform ISA use', that might be shorter to write and easier to understand. Geert?

Quoted 9 lines
Quoted 6 lines

It would be nice to have that automatically, like with the current MULTI_ISA define (and all the MACH_* in arch/m68k/include/asm/setup.h). Perhaps we should extend kconfig syntax to define a group of related symbols, and to automatically generate CONFIG_FOO_MULTI or CONFIG_FOO_SINGLE (and even CONFIG_BAR_ONLY?) symbols?

I take it this is not supported by our current Kconfig syntax?

That may be because CPP hacking is seen as a competitive sport in some circles.

Quoted 8 lines
Quoted 8 lines

group ISA
item ATARI_ROM_ISA
item AMIGA_PCMCIA
item Q40

=> CONFIG_ISA_MULTI or CONFIG_ISA_SINGLE (+ e.g. ATARI_ROM_ISA_ONLY
if appropriate).

Since the items may be bools or tristates, it not clear what type the group has.

Anyway, I see that we can already write this:

#define IS_MULTI(a,b) __or(IS_ENABLED(a), IS_ENABLED(b))

So maybe we just need an exclusive-OR macro to go with the other operators defined in include/linux/kconfig.h? Then we could write this:

#define IS_SINGLE(a,b) __xor(IS_ENABLED(a), IS_ENABLED(b))

But these only work for a 2-way group. Extending them to N-way groups is beyond my CPP abilities. It probably requires N-way __or() and __xor()...

#62 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Quoted 5 lines · On Sat, 5 Jun 2021, I wrote:

Anyway, I see that we can already write this:

#define IS_MULTI(a,b) __or(IS_ENABLED(a), IS_ENABLED(b))

Oops. The 2-way case would be,
#define IS_MULTI(a,b) __and(IS_ENABLED(a), IS_ENABLED(b))

Quoted 8 lines

So maybe we just need an exclusive-OR macro to go with the other operators defined in include/linux/kconfig.h? Then we could write this:

#define IS_SINGLE(a,b) __xor(IS_ENABLED(a), IS_ENABLED(b))

But these only work for a 2-way group. Extending them to N-way groups is beyond my CPP abilities. It probably requires N-way __or() and __xor()...

For the 3 way case,

#define IS_SINGLE(a,b,c) (__xor(IS_ENABLED(a), IS_ENABLED(b), IS_ENABLED(c)) &&
                          !__and(IS_ENABLED(a), IS_ENABLED(b), IS_ENABLED(c)))
#define IS_MULTI(a,b,c) (!IS_SINGLE(a,b,c) &&
                         __or(IS_ENABLED(a), IS_ENABLED(b), IS_ENABLED(c)))
#63 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

In reply to Finn Thain

Hi Finn,

Am 05.06.2021 um 11:31 schrieb Finn Thain:

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

If we have Kconfig symbols for 'single platform only', and 'multi-platform ISA use', that might be shorter to write and easier to understand. Geert?

It would be nice to have that automatically, like with the current MULTI_ISA define (and all the MACH_* in arch/m68k/include/asm/setup.h). Perhaps we should extend kconfig syntax to define a group of related symbols, and to automatically generate CONFIG_FOO_MULTI or CONFIG_FOO_SINGLE (and even CONFIG_BAR_ONLY?) symbols?

Quoted 5 lines
Quoted 2 lines

I take it this is not supported by our current Kconfig syntax?

That may be because CPP hacking is seen as a competitive sport in some circles.

Good one.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

group ISA
item ATARI_ROM_ISA
item AMIGA_PCMCIA
item Q40

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

=> CONFIG_ISA_MULTI or CONFIG_ISA_SINGLE (+ e.g. ATARI_ROM_ISA_ONLY
if appropriate).

Since the items may be bools or tristates, it not clear what type the group has.

All three are of type bool.

Quoted 5 lines

Anyway, I see that we can already write this:

#define IS_MULTI(a,b) __or(IS_ENABLED(a), IS_ENABLED(b))

Quoted 7 lines

So maybe we just need an exclusive-OR macro to go with the other operators defined in include/linux/kconfig.h? Then we could write this:

#define IS_SINGLE(a,b) __xor(IS_ENABLED(a), IS_ENABLED(b))

But these only work for a 2-way group. Extending them to N-way groups is beyond my CPP abilities. It probably requires N-way __or() and __xor()...

I'll pass on this one for now ...

Cheers,

Michael

#64 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

In reply to Michael Schmitz

Hi Michael,

Quoted 35 lines · Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

arch/m68k/include/asm/io_mm.h +4 -0
@@ -52,7 +52,11 @@
 #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
 #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1
+#else
 #define MULTI_ISA 0
+#endif /* Atari */
 #endif /* Q40 */
 
 #ifdef CONFIG_AMIGA_PCMCIA

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 8 lines
arch/m68k/include/asm/io_mm.h +4 -1
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+                       else
+                               return (u8 __iomem *)(addr);

While putting a simple return on the same line as the case keyword, please start the if statement on a new line.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#65 lore raw

Re: [PATCH RFC 1/2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Geert,

Am 09.06.2021 um 18:35 schrieb Geert Uytterhoeven:

Quoted 4 lines
Quoted 4 lines
arch/m68k/include/asm/io_mm.h +0 -0
@@ -135,9 +139,12 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
Quoted 8 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 145

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +4 -1
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+                       else
+                               return (u8 __iomem *)(addr);

While putting a simple return on the same line as the case keyword, please start the if statement on a new line.

OK, changed that for v2.

Thanks,

Michael

#66 lore raw

RFC PATCH 2/2 m68k: setup_mm.c: set isa_sex for Atari if ATARI_ROM_ISA not used

In reply to Michael Schmitz

For multiplatform kernels where CONFIG_ATARI_ROM_ISA is not set, at least isa_sex must be set correctly to allow for correct I/O primitive selection in shared drivers.

---
 arch/m68k/kernel/setup_mm.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/m68k/kernel/setup_mm.c +4 -0
index 017bac3..bb43b99 100644
@@ -386,6 +386,10 @@ void __init setup_arch(char **cmdline_p)
 		isa_type = ISA_TYPE_ENEC;
 		isa_sex = 0;
 	}
+#else
+	if (MACH_IS_ATARI) {
+		isa_sex = 0;
+	}
 #endif
 #endif
 }
Signature · 1 line
2.7.4
#67 lore raw

Re: [PATCH RFC 2/2] m68k: setup_mm.c: set isa_sex for Atari if ATARI_ROM_ISA not used

Hi Michael,

Quoted 5 lines · Michael Schmitz

For multiplatform kernels where CONFIG_ATARI_ROM_ISA is not set, at least isa_sex must be set correctly to allow for correct I/O primitive selection in shared drivers.

Thanks for your patch!

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 391

Quoted 9 lines
arch/m68k/kernel/setup_mm.c +3 -0
@@ -386,6 +386,10 @@ void __init setup_arch(char **cmdline_p)
                isa_type = ISA_TYPE_ENEC;
                isa_sex = 0;
        }
+#else
+       if (MACH_IS_ATARI) {
+               isa_sex = 0;

I find it strange that you set isa_sex, but not isa_type? However, this is inside the CONFIG_ISA && MULTI_ISA block, so what kind of ISA does this correspond to?

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 394

Quoted 3 lines
arch/m68k/kernel/setup_mm.c +1 -0
+       }
 #endif
 #endif

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#68 lore raw

Re: [PATCH RFC 2/2] m68k: setup_mm.c: set isa_sex for Atari if ATARI_ROM_ISA not used

Hi Geert,

Am 02.06.2021 um 19:09 schrieb Geert Uytterhoeven:

Quoted 12 lines

Hi Michael,

Quoted 5 lines · Michael Schmitz

For multiplatform kernels where CONFIG_ATARI_ROM_ISA is not set, at least isa_sex must be set correctly to allow for correct I/O primitive selection in shared drivers.

Thanks for your patch!

Quoted 11 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 391

Quoted 9 lines
arch/m68k/kernel/setup_mm.c +3 -0
@@ -386,6 +386,10 @@ void __init setup_arch(char **cmdline_p)
                isa_type = ISA_TYPE_ENEC;
                isa_sex = 0;
        }
+#else
+       if (MACH_IS_ATARI) {
+               isa_sex = 0;

I find it strange that you set isa_sex, but not isa_type?

Yes, as I said this is only to ensure isa_sex has the correct value (0) so isa_readw() resolves to in_le16() for the Atari IDE driver after the change at the end of the first patch. Might have been better to rather say

int isa_sex=0;

at the start of setup_mm.c ... or rely on that variable being initialized as zero anyway.

Quoted 2 lines

However, this is inside the CONFIG_ISA && MULTI_ISA block, so what kind of ISA does this correspond to?

No ISA at all in that case, but since we have to route all readw() calls through isa_readw() for the sake of generality if we want to support Q40 ISA and Atari MMIO in the same kernel image, we need to make sure isa_readw() does the right thing on Atari if CONFIG_ISA is set.

I know io_mm.h says it's about various ISA bridges, but as I found out, drivers using only MMIO are also affected by these definitions.

'Maze' does not begin to describe it, 'mess' might be getting closer, but I can't see how we would avoid use of definitions in io_mm.h by non-ISA drivers.

Cheers,

Michael

Quoted 9 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 394

Quoted 4 lines
arch/m68k/kernel/setup_mm.c +1 -0
+       }
 #endif
 #endif

Gr{oetje,eeting}s,

Geert

#69 lore raw

Re: [PATCH RFC 2/2] m68k: setup_mm.c: set isa_sex for Atari if ATARI_ROM_ISA not used

Quoted 44 lines · Michael Schmitz

Hi Geert,

Am 02.06.2021 um 19:09 schrieb Geert Uytterhoeven:

Quoted 12 lines

Hi Michael,

Quoted 5 lines · Michael Schmitz

For multiplatform kernels where CONFIG_ATARI_ROM_ISA is not set, at least isa_sex must be set correctly to allow for correct I/O primitive selection in shared drivers.

Thanks for your patch!

Quoted 11 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 391

Quoted 9 lines
arch/m68k/kernel/setup_mm.c +3 -0
@@ -386,6 +386,10 @@ void __init setup_arch(char **cmdline_p)
                isa_type = ISA_TYPE_ENEC;
                isa_sex = 0;
        }
+#else
+       if (MACH_IS_ATARI) {
+               isa_sex = 0;

I find it strange that you set isa_sex, but not isa_type?

Yes, as I said this is only to ensure isa_sex has the correct value (0) so isa_readw() resolves to in_le16() for the Atari IDE driver after the change at the end of the first patch. Might have been better to rather say

int isa_sex=0;

at the start of setup_mm.c ... or rely on that variable being initialized as zero anyway.

Quoted 2 lines

However, this is inside the CONFIG_ISA && MULTI_ISA block, so what kind of ISA does this correspond to?

No ISA at all in that case, but since we have to route all readw() calls through isa_readw() for the sake of generality if we want to support Q40 ISA and Atari MMIO in the same kernel image, we need to make sure isa_readw() does the right thing on Atari if CONFIG_ISA is set.

Quoted 7 lines

I know io_mm.h says it's about various ISA bridges, but as I found out, drivers using only MMIO are also affected by these definitions.

'Maze' does not begin to describe it, 'mess' might be getting closer, but I can't see how we would avoid use of definitions in io_mm.h by non-ISA drivers.

It seems that the need for explicit zero initialization has more to do with subtelty over in asm/io_mm.h than anything else. If so, it would be better to add commentary there than to add redundant code here.

Quoted 14 lines

Cheers,

Michael

Quoted 9 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 394

Quoted 4 lines
arch/m68k/kernel/setup_mm.c +1 -0
+       }
 #endif
 #endif

Gr{oetje,eeting}s,

Geert

#70 lore raw

Re: [PATCH RFC 2/2] m68k: setup_mm.c: set isa_sex for Atari if ATARI_ROM_ISA not used

Hi Finn,

Am 03.06.2021 um 20:29 schrieb Finn Thain:

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines

However, this is inside the CONFIG_ISA && MULTI_ISA block, so what kind of ISA does this correspond to?

No ISA at all in that case, but since we have to route all readw() calls through isa_readw() for the sake of generality if we want to support Q40 ISA and Atari MMIO in the same kernel image, we need to make sure isa_readw() does the right thing on Atari if CONFIG_ISA is set.

I know io_mm.h says it's about various ISA bridges, but as I found out, drivers using only MMIO are also affected by these definitions.

Quoted 8 lines
Quoted 4 lines

'Maze' does not begin to describe it, 'mess' might be getting closer, but I can't see how we would avoid use of definitions in io_mm.h by non-ISA drivers.

It seems that the need for explicit zero initialization has more to do with subtelty over in asm/io_mm.h than anything else. If so, it would be better to add commentary there than to add redundant code here.

OK, I'll drop this one and rely on default zero initialization of globals instead.

More explicit setting of MULTI_ISA along with comments will be included in v2 of the remaining patch.

Thanks!

Michael

#71 lore raw

Re: [PATCH RFC 0/2] Fix m68k multiplatform ISA support

In reply to Michael Schmitz

Point of detail: don't forget to run 'make clean' after applying this series. Modules are not automatically rebuilt after changes to our io_mm.h (should they?)

Cheers,

Michael

Am 02.06.2021 um 17:21 schrieb Michael Schmitz:

Quoted 35 lines

Finn Thain found out that our multiplatform support is broken when attempting to build a kernel with support for both Q40 and Atari (when setting CONFIG_ISA through CONFIG_Q40, but not CONFIG_ATARI_ROM_ISA).

Inspection of the code in io_mm.h reveals that in that case, ISA I/O accessors with address translation are used for the Atari IDE driver, where MMIO accessors with no address translation would have been appropriate.

Setting CONFIG_ATARI_ROM_ISA will fix the issue for Atari, but then force the use of I/O accessors without address translation for Q40. The code in io_mm.h is fundamentally broken for kernels that have both Q40 and Atari support.

Address this by adding a check for address < 1024 to the Atari address translation case, changing the default address translation to return the untranslated address, and changing the CONFIG_ATARI_ROM_ISA section to use ISA I/O accessors for addresses > 1024 (i.e., those not intended to map to the ROM port).

Tested on ARAnyM with all combinations of CONFIG_ATARI_ROM_ISA and CONFIG_ISA. Earlier versions tested on my Falcon hardware, all using pata_falcon.

A thorough review in particular in regard to ramifications for Q40 and Amiga would be welcome. If there is a better way to implement these changes, I'd appreciate a hint. This is all academic as long as support for Q40 and Atari in the same kernel image is not needed, of course.

I suspect patch 2 may not be needed, since the isa_sex variable should always be zero?

Cheers,

Michael

#72 lore raw

Re: [PATCH RFC 0/2] Fix m68k multiplatform ISA support

Hi Michael,

Quoted 3 lines · Michael Schmitz

Point of detail: don't forget to run 'make clean' after applying this series. Modules are not automatically rebuilt after changes to our io_mm.h (should they?)

Yes they should. If not, that's a bug in the build system.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#73 lore raw

Re: [PATCH RFC 0/2] Fix m68k multiplatform ISA support

Hi Geert,

Quoted 7 lines · Geert Uytterhoeven

Hi Michael,

Quoted 3 lines · Michael Schmitz

Point of detail: don't forget to run 'make clean' after applying this series. Modules are not automatically rebuilt after changes to our io_mm.h (should they?)

Yes they should. If not, that's a bug in the build system.

Thanks - tried again and it's OK now. I appear to have lost the NE2000 config option when switching EtherNEC and ROM port support on and off repeatedly while testing config combinations, and picked up stale modules from an earlier build.

Sorry about the noise ...

Cheers,

    Michael

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

#74 lore raw

PATCH 1/1 m68k: Fix multiplatform ISA support

In reply to Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Fixes 84b16b7b0d5c818fadc731a69965dc76dce0c91e

--
Changes from RFC:

Geert Uytterhoeven;
- drop setup_mm.c patch

Finn Thain:
- Add 'Fixes' tag
- Annotate rationale for MULTI_ISA setting on Atari
- Use fallthrough macro annotation in Atari address translation

---
 arch/m68k/include/asm/io_mm.h | 62 ++++++++++++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 25 deletions(-)
arch/m68k/include/asm/io_mm.h +37 -25
index d41fa48..f6b487b 100644
@@ -52,7 +52,11 @@
 #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
 #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1	/* Need MULTI_ISA if Atari drivers (IDE) present !! */
+#else
 #define MULTI_ISA 0
+#endif /* Atari */
 #endif /* Q40 */
 
 #ifdef CONFIG_AMIGA_PCMCIA
@@ -113,7 +117,7 @@
 
 #ifdef MULTI_ISA
 extern int isa_type;
-extern int isa_sex;
+extern int isa_sex;	/* Atari relies on this to be zero-initialized */
 
 #define ISA_TYPE isa_type
 #define ISA_SEX  isa_sex
@@ -135,9 +139,11 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+			fallthrough; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u16 __iomem *isa_itw(unsigned long addr)
@@ -151,9 +157,11 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+			fallthrough; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u32 __iomem *isa_itl(unsigned long addr)
@@ -177,9 +185,11 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+			fallthrough; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 static inline u16 __iomem *isa_mtw(unsigned long addr)
@@ -193,9 +203,11 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+				return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+			fallthrough; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u16 __iomem *)(addr); /* avoid warnings, just in case */
     }
 }
 
@@ -344,31 +356,31 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)	((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)	((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl		isa_inl
 #define inl_p		isa_inl_p
 
-#define outb(val, port)	((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)	((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl		isa_outl
 #define outl_p		isa_outl_p
 
-#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 insb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
 #define insl			isa_insl
-#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 outsb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
 #define outsl			isa_outsl
 
-#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 readb   isa_readb
+#define readw   isa_readw
+#define writeb  isa_writeb
+#define writew  isa_writew
 #endif /* CONFIG_ATARI_ROM_ISA */
 
 #define readl(addr)      in_le32(addr)
Signature · 1 line
2.7.4
#75 lore raw

Re: [PATCH] m68k: Fix multiplatform ISA support

Hi Michael,

Quoted 12 lines · Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Quoted 5 lines

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Thanks for your patch!

Quoted 1 line
Fixes 84b16b7b0d5c818fadc731a69965dc76dce0c91e
Fixes 84b16b7b0d5c818f ("m68k/atari: ROM port ISA adapter support")

Hint:

    $ git help fixes
    'fixes' is aliased to 'show --format='Fixes: %h ("%s")' -s'
    $ git fixes 84b16b7b0d5c818fadc731a69965dc76dce0c91e
    Fixes: 84b16b7b0d5c818f ("m68k/atari: ROM port ISA adapter support")

arch/m68k/include/asm/io_mm.h line 120

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +1 -1
@@ -113,7 +117,7 @@
 
 #ifdef MULTI_ISA
 extern int isa_type;
-extern int isa_sex;
+extern int isa_sex;    /* Atari relies on this to be zero-initialized */

Shouldn't that comment be next to its definition in arch/m68k/kernel/setup_mm.c?

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 12 lines
arch/m68k/include/asm/io_mm.h +4 -2
@@ -135,9 +139,11 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+                       fallthrough; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }

Moving the default out of the switch() statement, as suggested by Finn, would make this more future-proof, as any case (not just the last one) can fall through to the default, using break.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#76 lore raw

Re: [PATCH] m68k: Fix multiplatform ISA support

Hi Geert,

thanks for your review!

Am 07.06.2021 um 19:49 schrieb Geert Uytterhoeven:

Quoted 25 lines

Hi Michael,

Quoted 12 lines · Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Quoted 5 lines

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Thanks for your patch!

Quoted 1 line
Fixes 84b16b7b0d5c818fadc731a69965dc76dce0c91e
Quoted 8 lines
Fixes 84b16b7b0d5c818f ("m68k/atari: ROM port ISA adapter support")

Hint:

    $ git help fixes
    'fixes' is aliased to 'show --format='Fixes: %h ("%s")' -s'
    $ git fixes 84b16b7b0d5c818fadc731a69965dc76dce0c91e
    Fixes: 84b16b7b0d5c818f ("m68k/atari: ROM port ISA adapter support")

Thanks, I'll change that.

Quoted 6 lines
Quoted 6 lines
arch/m68k/include/asm/io_mm.h +0 -0
@@ -113,7 +117,7 @@
 
Quoted 7 lines

arch/m68k/include/asm/io_mm.h line 120

Quoted 4 lines
arch/m68k/include/asm/io_mm.h +1 -1
 #ifdef MULTI_ISA
 extern int isa_type;
-extern int isa_sex;
+extern int isa_sex;    /* Atari relies on this to be zero-initialized */

Shouldn't that comment be next to its definition in arch/m68k/kernel/setup_mm.c?

I ended up dropping changes to that file, and would rather omit the comment here than touching setup_mm.c just for the sake of adding a comment.

We might omit the isa_sex = 0 stuff in setup_mm.c altogether, OTOH ...

Quoted 17 lines

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 147

Quoted 13 lines
arch/m68k/include/asm/io_mm.h +4 -2
@@ -135,9 +139,11 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC: if (addr < 1024)
+                               return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+                       fallthrough; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
+    default: return (u8 __iomem *)(addr); /* avoid warnings, just in case */
     }

Moving the default out of the switch() statement, as suggested by Finn, would make this more future-proof, as any case (not just the last one) can fall through to the default, using break.

OK, I take that to indicate the default may be changed in that way, and will move it outside the switch().

Cheers,

Michael

Quoted 12 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#77 lore raw

PATCH v2 1/1 m68k: io_mm.h: conditionalize ISA address translation on Atari

In reply to Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Fixes 84b16b7b0d5c818f ("m68k/atari: ROM port ISA adapter support")

--
Changes from v1:

Geert Uytterhoeven;
- fix Fixes tag
- remove comment about isa_sex zero initialization
- move default return outside switch statement in address translation functions to allow other code to break to default.
- fix indentation in switch statement

Changes from RFC:

Geert Uytterhoeven;
- drop setup_mm.c patch

Finn Thain:
- Add 'Fixes' tag
- Annotate rationale for MULTI_ISA setting on Atari
- Use fallthrough macro annotation in Atari address translation

---
 arch/m68k/include/asm/io_mm.h | 66 +++++++++++++++++++++++++++----------------
 1 file changed, 41 insertions(+), 25 deletions(-)
arch/m68k/include/asm/io_mm.h +41 -25
index d41fa48..6eae9ec 100644
@@ -52,7 +52,11 @@
 #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
 #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1	/* Need MULTI_ISA if Atari drivers (IDE) present !! */
+#else
 #define MULTI_ISA 0
+#endif /* Atari */
 #endif /* Q40 */
 
 #ifdef CONFIG_AMIGA_PCMCIA
@@ -135,10 +139,13 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u8 __iomem *)(addr); /* avoid warnings, just in case */
 }
 static inline u16 __iomem *isa_itw(unsigned long addr)
 {
@@ -151,10 +158,13 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u16 __iomem *)(addr); /* avoid warnings, just in case */
 }
 static inline u32 __iomem *isa_itl(unsigned long addr)
 {
@@ -163,8 +173,8 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
-    default: return 0; /* avoid warnings, just in case */
     }
+    return 0; /* avoid warnings, just in case */
 }
 static inline u8 __iomem *isa_mtb(unsigned long addr)
 {
@@ -177,10 +187,13 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u8 __iomem *)(addr); /* avoid warnings, just in case */
 }
 static inline u16 __iomem *isa_mtw(unsigned long addr)
 {
@@ -193,10 +206,13 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u16 __iomem *)(addr); /* avoid warnings, just in case */
 }
 
 
@@ -344,31 +360,31 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)	((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)	((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl		isa_inl
 #define inl_p		isa_inl_p
 
-#define outb(val, port)	((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)	((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl		isa_outl
 #define outl_p		isa_outl_p
 
-#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 insb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
 #define insl			isa_insl
-#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 outsb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
 #define outsl			isa_outsl
 
-#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 readb   isa_readb
+#define readw   isa_readw
+#define writeb  isa_writeb
+#define writew  isa_writew
 #endif /* CONFIG_ATARI_ROM_ISA */
 
 #define readl(addr)      in_le32(addr)
Signature · 1 line
2.7.4
#78 lore raw

Re: [PATCH v2] m68k: io_mm.h: conditionalize ISA address translation on Atari

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 148

Quoted 13 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +5 -2
@@ -135,10 +139,13 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u8 __iomem *)(addr); /* avoid warnings, just in case */

I don't think the comment still fits here.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
#79 lore raw

Re: [PATCH v2] m68k: io_mm.h: conditionalize ISA address translation on Atari

Hi Andreas,

Quoted 16 lines · Andreas Schwab

arch/m68k/include/asm/io_mm.h static inline u8 __iomem *isa_itb(unsigned long addr) · line 148

Quoted 13 lines · Michael Schmitz
arch/m68k/include/asm/io_mm.h +5 -2
@@ -135,10 +139,13 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
      case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+	break; /* not ROM port? fallback below! */
  #endif
-    default: return NULL; /* avoid warnings, just in case */
      }
+    return (u8 __iomem *)(addr); /* avoid warnings, just in case */

I don't think the comment still fits here.

True - I'll remove it.

Cheers,

    Michael

Quoted 3 lines

Andreas.

#80 lore raw

PATCH v3 1/1 m68k: io_mm.h: conditionalize ISA address translation on Atari

In reply to Michael Schmitz

Current io_mm.h uses address translation and ROM port IO primitives when port addresses are below 1024, and raw untranslated MMIO IO primitives else when CONFIG_ATARI_ROM_ISA is set. This is done regardless of the m68k machine type a multi-platform kernel runs on. As a consequence, the Q40 IDE driver in multiplatform kernels cannot work. Conversely, the Atari IDE driver uses wrong address translation if a multiplatform Q40 and Atari kernel does _not_ set CONFIG_ATARI_ROM_ISA.

Replace MMIO by ISA IO primitives for addresses > 1024 (if isa_type is ISA_TYPE_ENEC), and change the ISA address translation used for Atari to a no-op for those addresses.

Switch readb()/writeb() and readw()/writew() to their ISA equivalents also. Change the address translation functions to return the identity translation if CONFIG_ATARI_ROM_ISA is not defined, and set MULTI_ISA for kernels where Q40 and Atari are both configured so this can actually work (isa_type set to Q40 at compile time else).

Fixes 84b16b7b0d5c818f ("m68k/atari: ROM port ISA adapter support")

--
Changes from v2:

Andreas Schwab:
- drop misleading default return comment

Changes from v1:

Geert Uytterhoeven;
- fix Fixes tag
- remove comment about isa_sex zero initialization
- move default return outside switch statement in address translation functions to allow other code to break to default.
- fix indentation in switch statement

Changes from RFC:

Geert Uytterhoeven;
- drop setup_mm.c patch

Finn Thain:
- Add 'Fixes' tag
- Annotate rationale for MULTI_ISA setting on Atari
- Use fallthrough macro annotation in Atari address translation

---
 arch/m68k/include/asm/io_mm.h | 66 +++++++++++++++++++++++++++----------------
 1 file changed, 41 insertions(+), 25 deletions(-)
arch/m68k/include/asm/io_mm.h +41 -25
index d41fa48..9c521b0 100644
@@ -52,7 +52,11 @@
 #define Q40_ISA_MEM_B(madr)  (q40_isa_mem_base+1+4*((unsigned long)(madr)))
 #define Q40_ISA_MEM_W(madr)  (q40_isa_mem_base+  4*((unsigned long)(madr)))
 
+#ifdef CONFIG_ATARI
+#define MULTI_ISA 1	/* Need MULTI_ISA if Atari drivers (IDE) present !! */
+#else
 #define MULTI_ISA 0
+#endif /* Atari */
 #endif /* Q40 */
 
 #ifdef CONFIG_AMIGA_PCMCIA
@@ -135,10 +139,13 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u8 __iomem *)ENEC_ISA_IO_B(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u8 __iomem *)(addr);
 }
 static inline u16 __iomem *isa_itw(unsigned long addr)
 {
@@ -151,10 +158,13 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u16 __iomem *)ENEC_ISA_IO_W(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u16 __iomem *)(addr);
 }
 static inline u32 __iomem *isa_itl(unsigned long addr)
 {
@@ -163,8 +173,8 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
 #ifdef CONFIG_AMIGA_PCMCIA
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
-    default: return 0; /* avoid warnings, just in case */
     }
+    return 0; /* avoid warnings, just in case */
 }
 static inline u8 __iomem *isa_mtb(unsigned long addr)
 {
@@ -177,10 +187,13 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u8 __iomem *)(addr);
 }
 static inline u16 __iomem *isa_mtw(unsigned long addr)
 {
@@ -193,10 +206,13 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
-    case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+    case ISA_TYPE_ENEC:
+	if (addr < 1024)
+		return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
+	break; /* not ROM port? fallback below! */
 #endif
-    default: return NULL; /* avoid warnings, just in case */
     }
+    return (u16 __iomem *)(addr);
 }
 
 
@@ -344,31 +360,31 @@ static inline void isa_delay(void)
  * 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))
-#define inw(port)	((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
-#define inw_p(port)	((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
+#define inb(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb(port) : isa_inb(port))
+#define inb_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inb_p(port) : isa_inb_p(port))
+#define inw(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw(port) : isa_inw(port))
+#define inw_p(port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_inw_p(port) : isa_inw_p(port))
 #define inl		isa_inl
 #define inl_p		isa_inl_p
 
-#define outb(val, port)	((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
-#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
-#define outw(val, port)	((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
-#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
+#define outb(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb((val), (port)) : isa_outb((val), (port)))
+#define outb_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outb_p((val), (port)) : isa_outb_p((val), (port)))
+#define outw(val, port)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw((val), (port)) : isa_outw((val), (port)))
+#define outw_p(val, port) (((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outw_p((val), (port)) : isa_outw_p((val), (port)))
 #define outl		isa_outl
 #define outl_p		isa_outl_p
 
-#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 insb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
+#define insw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
 #define insl			isa_insl
-#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 outsb(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
+#define outsw(port, buf, nr)	(((port) < 1024 && ISA_TYPE == ISA_TYPE_ENEC) ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
 #define outsl			isa_outsl
 
-#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 readb   isa_readb
+#define readw   isa_readw
+#define writeb  isa_writeb
+#define writew  isa_writew
 #endif /* CONFIG_ATARI_ROM_ISA */
 
 #define readl(addr)      in_le32(addr)
Signature · 1 line
2.7.4
#81 lore raw
In reply to Michael Schmitz
Quoted 4 lines · Michael Schmitz
Quoted 3 lines

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

ISA drivers shouldn't be "updated" to the platform drivers. But I don't
see 'struct isa_driver' there either...

Quoted 3 lines

Cheers,

    Michael

MBR, Sergei

#82 lore raw
Quoted 8 lines · Sergei Shtylyov
Quoted 4 lines · Michael Schmitz
Quoted 3 lines

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

  ISA drivers shouldn't be "updated" to the platform drivers.

Why not?

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#83 lore raw
In reply to Sergei Shtylyov
Quoted 8 lines · Sergei Shtylyov
Quoted 4 lines · Michael Schmitz
Quoted 3 lines

Was macide the only IDE driver in Debian/m68k kernels without a libata alternative? If so, this patch would allow you to finally drop CONFIG_IDE.

There's still q40ide.c (ISA IDE interface, byte-swapped, so would need treatment similar to Falcon IDE). Hasn't been updated to a platform device yet.

   ISA drivers shouldn't be "updated" to the platform drivers. But I don't see 'struct isa_driver' there either...

My bad - while the Q40 has ISA slots, IDE isn't connected to the ISA bus. Got confused by the base address range matching what I remember from ISA cards...

Cheers,

    Michael

Reviewed-by on v1 1/1
#84 lore raw
In reply to Finn Thain

Hi Finn,

Am 25.04.2021 um 21:06 schrieb Finn Thain:

Quoted 8 lines

This was tested on my Quadra 630. I haven't tested it on my PowerBook 150 because I don't have a RAM adapter board for it.

Apparently, the hardware I tested doesn't need macide_clear_irq() or macide_test_irq() -- if it did, the generic driver would not have worked. It's possible that those routines are needed for the PowerBook 150 but we can cross that bridge if and when we come to it.

Quoted 5 lines

BTW, macide_clear_irq() appears to suffer from a race condition. The write to the interrupt flags register could easily have unintended side effects as it may alter other flag bits. Fortunately, all of the other bits are unused by Linux. Moreover, when tested on my Quadra 630, that assignment (*ide_ifr &= ~0x20) was observed to have no effect on bit 5.

You are worried that the bit clear might not be done atomic?

Regarding the missing effect of clearing bit 5, I suspect this has never before been tested rigorously (I don't remember ever using a Quadra 630). The logic attempted to replicate what the MacOS IDE driver did. The Linux IDE driver has its own way to test and clear a port's interrupt flag, so this extra code can quite probably go.

Thanks for cleaning this up!

Quoted 303 lines
Cc Michael Schmitz <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Joshua Thompson <[email protected]>
Cc "David S. Miller" <[email protected]>
---
 arch/m68k/configs/mac_defconfig   |   1 -
 arch/m68k/configs/multi_defconfig |   1 -
 arch/m68k/mac/config.c            |  24 +++--
 drivers/ide/Kconfig               |  14 ---
 drivers/ide/Makefile              |   1 -
 drivers/ide/macide.c              | 161 ------------------------------
 6 files changed, 14 insertions(+), 188 deletions(-)
 delete mode 100644 drivers/ide/macide.c
arch/m68k/configs/mac_defconfig +0 -1
index f6d50b3fe8c2..252596991e4f 100644
@@ -318,7 +318,6 @@ CONFIG_IDE=y
 CONFIG_IDE_GD_ATAPI=y
 CONFIG_BLK_DEV_IDECD=y
 CONFIG_BLK_DEV_PLATFORM=y
-CONFIG_BLK_DEV_MAC_IDE=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
arch/m68k/configs/multi_defconfig +0 -1
index 0e067b4320cd..697030472a83 100644
@@ -350,7 +350,6 @@ CONFIG_BLK_DEV_PLATFORM=y
 CONFIG_BLK_DEV_GAYLE=y
 CONFIG_BLK_DEV_BUDDHA=y
 CONFIG_BLK_DEV_FALCON_IDE=y
-CONFIG_BLK_DEV_MAC_IDE=y
 CONFIG_BLK_DEV_Q40IDE=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
arch/m68k/mac/config.c +14 -10
index 1cdac959bd91..5d16f9b47aa9 100644
@@ -933,13 +933,15 @@ static const struct resource mac_scsi_ccl_rsrc[] __initconst = {
 	},
 };
 
-static const struct resource mac_ide_quadra_rsrc[] __initconst = {
-	DEFINE_RES_MEM(0x50F1A000, 0x104),
+static const struct resource mac_pata_quadra_rsrc[] __initconst = {
+	DEFINE_RES_MEM(0x50F1A000, 0x38),
+	DEFINE_RES_MEM(0x50F1A038, 0x04),
 	DEFINE_RES_IRQ(IRQ_NUBUS_F),
 };
 
-static const struct resource mac_ide_pb_rsrc[] __initconst = {
-	DEFINE_RES_MEM(0x50F1A000, 0x104),
+static const struct resource mac_pata_pb_rsrc[] __initconst = {
+	DEFINE_RES_MEM(0x50F1A000, 0x38),
+	DEFINE_RES_MEM(0x50F1A038, 0x04),
 	DEFINE_RES_IRQ(IRQ_NUBUS_C),
 };
 
@@ -949,7 +951,7 @@ static const struct resource mac_pata_baboon_rsrc[] __initconst = {
 	DEFINE_RES_IRQ(IRQ_BABOON_1),
 };
 
-static const struct pata_platform_info mac_pata_baboon_data __initconst = {
+static const struct pata_platform_info mac_pata_data __initconst = {
 	.ioport_shift = 2,
 };
 
@@ -1067,17 +1069,19 @@ int __init mac_platform_init(void)
 
 	switch (macintosh_config->ide_type) {
 	case MAC_IDE_QUADRA:
-		platform_device_register_simple("mac_ide", -1,
-			mac_ide_quadra_rsrc, ARRAY_SIZE(mac_ide_quadra_rsrc));
+		platform_device_register_resndata(NULL, "pata_platform", -1,
+			mac_pata_quadra_rsrc, ARRAY_SIZE(mac_pata_quadra_rsrc),
+			&mac_pata_data, sizeof(mac_pata_data));
 		break;
 	case MAC_IDE_PB:
-		platform_device_register_simple("mac_ide", -1,
-			mac_ide_pb_rsrc, ARRAY_SIZE(mac_ide_pb_rsrc));
+		platform_device_register_resndata(NULL, "pata_platform", -1,
+			mac_pata_pb_rsrc, ARRAY_SIZE(mac_pata_pb_rsrc),
+			&mac_pata_data, sizeof(mac_pata_data));
 		break;
 	case MAC_IDE_BABOON:
 		platform_device_register_resndata(NULL, "pata_platform", -1,
 			mac_pata_baboon_rsrc, ARRAY_SIZE(mac_pata_baboon_rsrc),
-			&mac_pata_baboon_data, sizeof(mac_pata_baboon_data));
+			&mac_pata_data, sizeof(mac_pata_data));
 		break;
 	}
 
drivers/ide/Kconfig +0 -14
index 19abf11c84c8..8ce4a5878d0c 100644
@@ -739,20 +739,6 @@ config BLK_DEV_FALCON_IDE
 	  disks, CD-ROM drives, etc.) that are connected to the on-board IDE
 	  interface.
 
-config BLK_DEV_MAC_IDE
-	tristate "Macintosh Quadra/Powerbook IDE interface support"
-	depends on MAC
-	help
-	  This is the IDE driver for the on-board IDE interface on some m68k
-	  Macintosh models, namely Quadra/Centris 630, Performa 588 and
-	  Powerbook 150. The IDE interface on the Powerbook 190 is not
-	  supported by this driver and requires BLK_DEV_PLATFORM or
-	  PATA_PLATFORM.
-
-	  Say Y if you have such an Macintosh model and want to use IDE
-	  devices (hard disks, CD-ROM drives, etc.) that are connected to the
-	  on-board IDE interface.
-
 config BLK_DEV_Q40IDE
 	tristate "Q40/Q60 IDE interface support"
 	depends on Q40
drivers/ide/Makefile +0 -1
index 2605b3cdaf47..45a1c0463bed 100644
@@ -29,7 +29,6 @@ obj-$(CONFIG_BLK_DEV_4DRIVES)		+= ide-4drives.o
 
 obj-$(CONFIG_BLK_DEV_GAYLE)		+= gayle.o
 obj-$(CONFIG_BLK_DEV_FALCON_IDE)	+= falconide.o
-obj-$(CONFIG_BLK_DEV_MAC_IDE)		+= macide.o
 obj-$(CONFIG_BLK_DEV_Q40IDE)		+= q40ide.o
 obj-$(CONFIG_BLK_DEV_BUDDHA)		+= buddha.o
 
drivers/ide/macide.c deleted +0 -161
deleted file mode 100644
index 8d2bf73bc548..000000000000
@@ -1,161 +0,0 @@
-/*
- *  Macintosh IDE Driver
- *
- *     Copyright (C) 1998 by Michael Schmitz
- *
- *  This driver was written based on information obtained from the MacOS IDE
- *  driver binary by Mikael Forselius
- *
- *  This file is subject to the terms and conditions of the GNU General Public
- *  License.  See the file COPYING in the main directory of this archive for
- *  more details.
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/blkdev.h>
-#include <linux/delay.h>
-#include <linux/ide.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-
-#include <asm/macintosh.h>
-
-#define DRV_NAME "mac_ide"
-
-#define IDE_BASE 0x50F1A000	/* Base address of IDE controller */
-
-/*
- * Generic IDE registers as offsets from the base
- * These match MkLinux so they should be correct.
- */
-
-#define IDE_CONTROL	0x38	/* control/altstatus */
-
-/*
- * Mac-specific registers
- */
-
-/*
- * this register is odd; it doesn't seem to do much and it's
- * not word-aligned like virtually every other hardware register
- * on the Mac...
- */
-
-#define IDE_IFR		0x101	/* (0x101) IDE interrupt flags on Quadra:
-				 *
-				 * Bit 0+1: some interrupt flags
-				 * Bit 2+3: some interrupt enable
-				 * Bit 4:   ??
-				 * Bit 5:   IDE interrupt flag (any hwif)
-				 * Bit 6:   maybe IDE interrupt enable (any hwif) ??
-				 * Bit 7:   Any interrupt condition
-				 */
-
-volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);
-
-int macide_test_irq(ide_hwif_t *hwif)
-{
-	if (*ide_ifr & 0x20)
-		return 1;
-	return 0;
-}
-
-static void macide_clear_irq(ide_drive_t *drive)
-{
-	*ide_ifr &= ~0x20;
-}
-
-static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
-				      int irq)
-{
-	int i;
-
-	memset(hw, 0, sizeof(*hw));
-
-	for (i = 0; i < 8; i++)
-		hw->io_ports_array[i] = base + i * 4;
-
-	hw->io_ports.ctl_addr = base + IDE_CONTROL;
-
-	hw->irq = irq;
-}
-
-static const struct ide_port_ops macide_port_ops = {
-	.clear_irq		= macide_clear_irq,
-	.test_irq		= macide_test_irq,
-};
-
-static const struct ide_port_info macide_port_info = {
-	.port_ops		= &macide_port_ops,
-	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
-	.irq_flags		= IRQF_SHARED,
-	.chipset		= ide_generic,
-};
-
-static const char *mac_ide_name[] =
-	{ "Quadra", "Powerbook", "Powerbook Baboon" };
-
-/*
- * Probe for a Macintosh IDE interface
- */
-
-static int mac_ide_probe(struct platform_device *pdev)
-{
-	struct resource *mem, *irq;
-	struct ide_hw hw, *hws[] = { &hw };
-	struct ide_port_info d = macide_port_info;
-	struct ide_host *host;
-	int rc;
-
-	if (!MACH_IS_MAC)
-		return -ENODEV;
-
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem)
-		return -ENODEV;
-
-	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!irq)
-		return -ENODEV;
-
-	if (!devm_request_mem_region(&pdev->dev, mem->start,
-				     resource_size(mem), DRV_NAME)) {
-		dev_err(&pdev->dev, "resources busy\n");
-		return -EBUSY;
-	}
-
-	printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
-			 mac_ide_name[macintosh_config->ide_type - 1]);
-
-	macide_setup_ports(&hw, mem->start, irq->start);
-
-	rc = ide_host_add(&d, hws, 1, &host);
-	if (rc)
-		return rc;
-
-	platform_set_drvdata(pdev, host);
-	return 0;
-}
-
-static int mac_ide_remove(struct platform_device *pdev)
-{
-	struct ide_host *host = platform_get_drvdata(pdev);
-
-	ide_host_remove(host);
-	return 0;
-}
-
-static struct platform_driver mac_ide_driver = {
-	.driver = {
-		.name = DRV_NAME,
-	},
-	.probe  = mac_ide_probe,
-	.remove = mac_ide_remove,
-};
-
-module_platform_driver(mac_ide_driver);
-
-MODULE_ALIAS("platform:" DRV_NAME);
-MODULE_LICENSE("GPL");
#85 lore raw
Quoted 9 lines · Michael Schmitz

Am 25.04.2021 um 21:06 schrieb Finn Thain:

Quoted 8 lines

This was tested on my Quadra 630. I haven't tested it on my PowerBook 150 because I don't have a RAM adapter board for it.

Apparently, the hardware I tested doesn't need macide_clear_irq() or macide_test_irq() -- if it did, the generic driver would not have worked. It's possible that those routines are needed for the PowerBook 150 but we can cross that bridge if and when we come to it.

Quoted 8 lines
Quoted 5 lines

BTW, macide_clear_irq() appears to suffer from a race condition. The write to the interrupt flags register could easily have unintended side effects as it may alter other flag bits. Fortunately, all of the other bits are unused by Linux. Moreover, when tested on my Quadra 630, that assignment (*ide_ifr &= ~0x20) was observed to have no effect on bit 5.

You are worried that the bit clear might not be done atomic?

The edge-triggered interrupt flag bits are usually cleared by writing 1 to the flag bit. Under this scheme, writing a 0 to a flag bit has no effect.

The assignment statement here is trying to clear bit 5 by writing 0. But what about the other bits that we're writing 0 to? Some of them may also be flag bits, and they may have been asserted in between the load and store. AFAICS this scheme just can't work for edge-triggered interrupts.

So perhaps this is a level-triggered interrupt?

Quoted 5 lines

Regarding the missing effect of clearing bit 5, I suspect this has never before been tested rigorously (I don't remember ever using a Quadra 630).

The logic attempted to replicate what the MacOS IDE driver did.

Fair enough. Maybe we have found a bug in the MacOS IDE driver.

Quoted 7 lines

The Linux IDE driver has its own way to test and clear a port's interrupt flag, so this extra code can quite probably go.

Thanks for cleaning this up!

Thanks for your review.