Skip to contentSkip to conversation

Use libata platform drivers to replace deprecated m68k IDE drivers

PATCH In review Finn Thain 3 participants 6 messages Jun 10, 2021

Subsystems (3)
lore
Share & tools
lore

Finn Thain

author
#0 lore raw

v3 cover Use libata platform drivers to replace deprecated m68k IDE drivers

This patch series allows m68k platforms to switch from deprecated IDE drivers to libata drivers.

Changed since v1:
- Added reviewed-by and tested-by tags.
- Improved commit log.

Changed since v2:
- Added #ifdef guards to prevent build failure when CONFIG_ATARI=n.

Finn Thain (2):
m68k/mac: Replace macide driver with generic platform drivers m68k/q40: Replace q40ide driver with pata_falcon and falconide

 arch/m68k/atari/config.c          |  12 +--
 arch/m68k/configs/mac_defconfig   |   1 -
 arch/m68k/configs/multi_defconfig |   2 -
 arch/m68k/configs/q40_defconfig   |   2 +-
 arch/m68k/mac/config.c            |  24 +++--
 arch/m68k/q40/config.c            |  37 +++++--
 drivers/ata/Kconfig               |   6 +-
 drivers/ata/pata_falcon.c         |  62 ++++++++---
 drivers/ide/Kconfig               |  32 +-----
 drivers/ide/Makefile              |   2 -
 drivers/ide/falconide.c           |  79 +++++++++-----
 drivers/ide/macide.c              | 161 ----------------------------
 drivers/ide/q40ide.c              | 168 ------------------------------
 13 files changed, 155 insertions(+), 433 deletions(-)
 delete mode 100644 drivers/ide/macide.c
 delete mode 100644 drivers/ide/q40ide.c
Signature · 1 line
2.26.3
author
#1 lore raw

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

This allows m68k mac systems to switch from the deprecated IDE subsystem to libata.

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. It appears that 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 have unintended side effects as it may alter other flag bits. Fortunately, all of the other bits are unused by Linux. When tested on my Quadra 630, the assignment *ide_ifr &= ~0x20 was observed to have no effect on bit 5, so it may be redundant anyway.

---
 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 bf15e6c1c939..c72a85a084cc 100644
@@ -319,7 +319,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 5466d48fcd9d..9ee6d2b4d1f4 100644
@@ -351,7 +351,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
author
#2 lore raw

PATCH v3 2/2 m68k/q40: Replace q40ide driver with pata_falcon and falconide

In reply to Finn Thain

This allows m68k q40 systems to switch from the deprecated IDE subsystem to libata.

Enhance the byte-swapping falconide and pata_falcon platform drivers to accept an irq resource, for use on q40. Atari ST-DMA IRQ arrangements seem to co-exist with q40 IRQ arrangements without too much mess.

The new IO resources were added solely for the purpose of making request_region() reservations identical to those made by q40ide: these regions aren't used for actual IO.

---
Note that q40ide, falconide and pata_falcon all use the same accessors (raw_insw_swapw, raw_insw, raw_outsw_swapw, raw_outsw) and hence all three drivers are affected by the bug relating to CONFIG_ISA and CONFIG_ATARI_ROM_ISA which Michael has been working on recently. This patch doesn't make that issue any better or worse.

Changed since v2:
- Added #ifdef guards to prevent build failure when CONFIG_ATARI=n.

---
 arch/m68k/atari/config.c          |  12 +--
 arch/m68k/configs/multi_defconfig |   1 -
 arch/m68k/configs/q40_defconfig   |   2 +-
 arch/m68k/q40/config.c            |  37 +++++--
 drivers/ata/Kconfig               |   6 +-
 drivers/ata/pata_falcon.c         |  62 ++++++++---
 drivers/ide/Kconfig               |  18 +---
 drivers/ide/Makefile              |   1 -
 drivers/ide/falconide.c           |  79 +++++++++-----
 drivers/ide/q40ide.c              | 168 ------------------------------
 10 files changed, 141 insertions(+), 245 deletions(-)
 delete mode 100644 drivers/ide/q40ide.c
arch/m68k/atari/config.c +2 -10
index 44f9b5216ac9..261a0f57cc9a 100644
@@ -875,16 +875,8 @@ static const struct resource atari_scsi_tt_rsrc[] __initconst = {
 #define FALCON_IDE_BASE	0xfff00000
 
 static const struct resource atari_falconide_rsrc[] __initconst = {
-	{
-		.flags = IORESOURCE_MEM,
-		.start = FALCON_IDE_BASE,
-		.end   = FALCON_IDE_BASE + 0x39,
-	},
-	{
-		.flags = IORESOURCE_IRQ,
-		.start = IRQ_MFP_FSCSI,
-		.end   = IRQ_MFP_FSCSI,
-	},
+	DEFINE_RES_MEM(FALCON_IDE_BASE, 0x38),
+	DEFINE_RES_MEM(FALCON_IDE_BASE + 0x38, 2),
 };
 
 int __init atari_platform_init(void)
arch/m68k/configs/multi_defconfig +0 -1
index 9ee6d2b4d1f4..f4cafed671cb 100644
@@ -351,7 +351,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_Q40IDE=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
arch/m68k/configs/q40_defconfig +1 -1
index 3ae421cb24a4..2c25b4096397 100644
@@ -317,7 +317,7 @@ CONFIG_DUMMY_IRQ=m
 CONFIG_IDE=y
 CONFIG_IDE_GD_ATAPI=y
 CONFIG_BLK_DEV_IDECD=y
-CONFIG_BLK_DEV_Q40IDE=y
+CONFIG_BLK_DEV_FALCON_IDE=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
arch/m68k/q40/config.c +31 -6
index d6a423875231..5caf1e5be1c2 100644
@@ -286,14 +286,39 @@ static int q40_set_rtc_pll(struct rtc_pll_info *pll)
 		return -EINVAL;
 }
 
-static __init int q40_add_kbd_device(void)
-{
-	struct platform_device *pdev;
+#define PCIDE_BASE1	0x1f0
+#define PCIDE_BASE2	0x170
+#define PCIDE_CTL	0x206
+
+static const struct resource q40_pata_rsrc_0[] __initconst = {
+	DEFINE_RES_MEM(q40_isa_io_base + PCIDE_BASE1 * 4, 0x38),
+	DEFINE_RES_MEM(q40_isa_io_base + (PCIDE_BASE1 + PCIDE_CTL) * 4, 2),
+	DEFINE_RES_IO(PCIDE_BASE1, 8),
+	DEFINE_RES_IO(PCIDE_BASE1 + PCIDE_CTL, 1),
+	DEFINE_RES_IRQ(14),
+};
 
+static const struct resource q40_pata_rsrc_1[] __initconst = {
+	DEFINE_RES_MEM(q40_isa_io_base + PCIDE_BASE2 * 4, 0x38),
+	DEFINE_RES_MEM(q40_isa_io_base + (PCIDE_BASE2 + PCIDE_CTL) * 4, 2),
+	DEFINE_RES_IO(PCIDE_BASE2, 8),
+	DEFINE_RES_IO(PCIDE_BASE2 + PCIDE_CTL, 1),
+	DEFINE_RES_IRQ(15),
+};
+
+static __init int q40_platform_init(void)
+{
 	if (!MACH_IS_Q40)
 		return -ENODEV;
 
-	pdev = platform_device_register_simple("q40kbd", -1, NULL, 0);
-	return PTR_ERR_OR_ZERO(pdev);
+	platform_device_register_simple("q40kbd", -1, NULL, 0);
+
+	platform_device_register_simple("atari-falcon-ide", 0, q40_pata_rsrc_0,
+					ARRAY_SIZE(q40_pata_rsrc_0));
+
+	platform_device_register_simple("atari-falcon-ide", 1, q40_pata_rsrc_1,
+					ARRAY_SIZE(q40_pata_rsrc_1));
+
+	return 0;
 }
-arch_initcall(q40_add_kbd_device);
+arch_initcall(q40_platform_init);
drivers/ata/Kconfig +3 -3
index 030cb32da980..b7a5abee2147 100644
@@ -1015,11 +1015,11 @@ config PATA_CMD640_PCI
 	  If unsure, say N.
 
 config PATA_FALCON
-	tristate "Atari Falcon PATA support"
-	depends on M68K && ATARI
+	tristate "Atari Falcon and Q40/Q60 PATA support"
+	depends on M68K && (ATARI || Q40)
 	help
 	  This option enables support for the on-board IDE
-	  interface on the Atari Falcon.
+	  interface on the Atari Falcon and Q40/Q60.
 
 	  If unsure, say N.
 
drivers/ata/pata_falcon.c +45 -17

100 lines not on this page · raw message

drivers/ide/Kconfig +5 -13
index 8ce4a5878d0c..8af1ac69e5f8 100644
@@ -731,21 +731,13 @@ config BLK_DEV_BUDDHA
 	  to one of its IDE interfaces.
 
 config BLK_DEV_FALCON_IDE
-	tristate "Falcon IDE interface support"
-	depends on ATARI
+	tristate "Falcon and Q40/Q60 IDE interface support"
+	depends on ATARI || Q40
 	help
 	  This is the IDE driver for the on-board IDE interface on the Atari
-	  Falcon. Say Y if you have a Falcon 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
-	help
-	  Enable the on-board IDE controller in the Q40/Q60.  This should
-	  normally be on; disable it only if you are running a custom hard
-	  drive subsystem through an expansion card.
+	  Falcon and Q40/Q60. Say Y if you have such a machine and want to use
+	  IDE devices (hard disks, CD-ROM drives, etc.) that are connected to
+	  the on-board IDE interface.
 
 config BLK_DEV_PALMCHIP_BK3710
 	tristate "Palmchip bk3710 IDE controller support"
drivers/ide/Makefile +0 -1
index 45a1c0463bed..991eb72a786b 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_Q40IDE)		+= q40ide.o
 obj-$(CONFIG_BLK_DEV_BUDDHA)		+= buddha.o
 
 obj-$(CONFIG_BLK_DEV_AEC62XX)		+= aec62xx.o
drivers/ide/falconide.c +54 -25

141 lines not on this page · raw message

drivers/ide/q40ide.c deleted +0 -168

168 lines not on this page · raw message

Signature · 1 line
2.26.3
#3 lore raw
In reply to Finn Thain

Hi Finn,

Quoted 9 lines · Finn Thain

This patch series allows m68k platforms to switch from deprecated IDE drivers to libata drivers.

Changed since v1:
- Added reviewed-by and tested-by tags.
- Improved commit log.

Changed since v2:
- Added #ifdef guards to prevent build failure when CONFIG_ATARI=n.

Thanks for the update!

Note that Jens has already applied v2 to block/for-next.
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-next&id=9658506fbf8c1b629ca8a660862bc1ee57400506

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
author
#4 lore raw
Quoted 8 lines · Geert Uytterhoeven
Quoted 7 lines · Finn Thain

This patch series allows m68k platforms to switch from deprecated IDE drivers to libata drivers.

Changed since v1:
- Added reviewed-by and tested-by tags.
- Improved commit log.

Quoted 8 lines
Quoted 2 lines

Changed since v2:
- Added #ifdef guards to prevent build failure when CONFIG_ATARI=n.

Thanks for the update!

Note that Jens has already applied v2 to block/for-next.
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-next&id=9658506fbf8c1b629ca8a660862bc1ee57400506

Thanks for the tip. I gather that Jens' tree can't be rebased, so I'll have to send another patch...

#5 lore raw
Quoted 13 lines · Finn Thain
Quoted 11 lines · Geert Uytterhoeven
Quoted 9 lines · Finn Thain

This patch series allows m68k platforms to switch from deprecated IDE drivers to libata drivers.

Changed since v1:
- Added reviewed-by and tested-by tags.
- Improved commit log.

Changed since v2:
- Added #ifdef guards to prevent build failure when CONFIG_ATARI=n.

Quoted 8 lines
Quoted 5 lines

Thanks for the update!

Note that Jens has already applied v2 to block/for-next.
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-next&id=9658506fbf8c1b629ca8a660862bc1ee57400506

Thanks for the tip. I gather that Jens' tree can't be rebased, so I'll have to send another patch...

It's top of tree for that branch, so not a huge issue to rebase it. Just did...

Signature · 1 line
Jens Axboe