Skip to contentSkip to conversation

m68k related IDE cleanups

PATCH In review Bartlomiej Zolnierkiewicz 4 participants 10 messages Jan 27, 2009 – Feb 5, 2009 libata

lore
Share & tools
lore
#0 lore raw

cover m68k related IDE cleanups

Based on top of pata-2.6 tree (& hopefully tomorrow's linux-next).

This removes m68k-specific IDE_ARCH_{INTR,LOCK}, switches m68k host drivers to use core code's MMIO support and cleanups <asm-m68k/ide.h> significantly.

Geert/Michael: please take a look when possible.

diffstat:

 drivers/ide/buddha.c    |    6 ---
 drivers/ide/falconide.c |   32 +++++++++++++++++----
 drivers/ide/gayle.c     |    6 +--
 drivers/ide/ide-io.c    |   13 ++++----
 drivers/ide/ide-probe.c |    2 +
 drivers/ide/macide.c    |    2 -
 drivers/ide/q40ide.c    |    6 +--
 include/asm-m68k/ide.h  |   73 ------------------------------------------------
 include/linux/ide.h     |   21 ++++++-------
 9 files changed, 53 insertions(+), 108 deletions(-)
#1 lore raw

PATCH 1/4 ide: remove IDE_ARCH_INTR

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: remove IDE_ARCH_INTR

This micro-optimization is not worth it. Just always check for existence of ->ack_intr method in ide_intr() and ide_timer_expiry().

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>
---
 drivers/ide/ide-io.c   |    5 +++--
 include/asm-m68k/ide.h |    3 ---
 include/linux/ide.h    |    5 -----
 3 files changed, 3 insertions(+), 10 deletions(-)
drivers/ide/ide-io.c +3 -2
Index: b/drivers/ide/ide-io.c
===================================================================
@@ -736,7 +736,8 @@ void ide_timer_expiry (unsigned long dat
 		} else if (drive_is_ready(drive)) {
 			if (drive->waiting_for_dma)
 				hwif->dma_ops->dma_lost_irq(drive);
-			(void)ide_ack_intr(hwif);
+			if (hwif->ack_intr(hwif))
+				hwif->ack_intr(hwif);
 			printk(KERN_WARNING "%s: lost interrupt\n",
 				drive->name);
 			startstop = handler(drive);
@@ -851,7 +852,7 @@ irqreturn_t ide_intr (int irq, void *dev
 
 	spin_lock_irqsave(&hwif->lock, flags);
 
-	if (!ide_ack_intr(hwif))
+	if (hwif->ack_intr && hwif->ack_intr(hwif) == 0)
 		goto out;
 
 	handler = hwif->handler;
include/asm-m68k/ide.h +0 -3
Index: b/include/asm-m68k/ide.h
===================================================================
@@ -123,8 +123,5 @@ ide_get_lock(irq_handler_t handler, void
 }
 #endif /* CONFIG_BLK_DEV_FALCON_IDE */
 
-#define IDE_ARCH_ACK_INTR
-#define ide_ack_intr(hwif)	((hwif)->ack_intr ? (hwif)->ack_intr(hwif) : 1)
-
 #endif /* __KERNEL__ */
 #endif /* _M68K_IDE_H */
include/linux/ide.h +0 -5
Index: b/include/linux/ide.h
===================================================================
@@ -202,11 +202,6 @@ static inline void ide_std_init_ports(hw
 
 #define MAX_HWIFS	10
 
-/* Currently only m68k, apus and m8xx need it */
-#ifndef IDE_ARCH_ACK_INTR
-# define ide_ack_intr(hwif) (1)
-#endif
-
 /* Currently only Atari needs it */
 #ifndef IDE_ARCH_LOCK
 # define ide_release_lock()			do {} while (0)
#5 lore raw

PATCH 2/4 ide: remove IDE_ARCH_LOCK

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: remove IDE_ARCH_LOCK

* Add ->{get,release}_lock methods to struct ide_port_info and struct ide_host.

* Convert core IDE code, m68k IDE code and falconide support to use ->{get,release}_lock methods instead of ide_{get,release}_lock().

* Remove IDE_ARCH_LOCK.

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>

---
We may also consider adding struct ide_host_ops later...

 drivers/ide/falconide.c |   25 +++++++++++++++++++++++--
 drivers/ide/ide-io.c    |    8 ++++----
 drivers/ide/ide-probe.c |    2 ++
 include/asm-m68k/ide.h  |   36 ------------------------------------
 include/linux/ide.h     |   16 ++++++++++------
 5 files changed, 39 insertions(+), 48 deletions(-)
drivers/ide/falconide.c +23 -2
Index: b/drivers/ide/falconide.c
===================================================================
@@ -40,8 +40,27 @@
      *  which is shared between several drivers.
      */
 
-int falconide_intr_lock;
-EXPORT_SYMBOL(falconide_intr_lock);
+static int falconide_intr_lock;
+
+static void falconide_release_lock(void)
+{
+	if (falconide_intr_lock == 0) {
+		printk(KERN_ERR "%s: bug\n", __func__);
+		return;
+	}
+	falconide_intr_lock = 0;
+	stdma_release();
+}
+
+static void falconide_get_lock(irq_handler_t handler, void *data)
+{
+	if (falconide_intr_lock == 0) {
+		if (in_interrupt() > 0)
+			panic("Falcon IDE hasn't ST-DMA lock in interrupt");
+		stdma_lock(handler, data);
+		falconide_intr_lock = 1;
+	}
+}
 
 static void falconide_input_data(ide_drive_t *drive, struct request *rq,
 				 void *buf, unsigned int len)
@@ -81,6 +100,8 @@ static const struct ide_tp_ops falconide
 };
 
 static const struct ide_port_info falconide_port_info = {
+	.get_lock		= falconide_get_lock,
+	.release_lock		= falconide_release_lock,
 	.tp_ops			= &falconide_tp_ops,
 	.host_flags		= IDE_HFLAG_NO_DMA | IDE_HFLAG_SERIALIZE,
 };
drivers/ide/ide-io.c +4 -4
Index: b/drivers/ide/ide-io.c
===================================================================
@@ -498,8 +498,8 @@ static inline int ide_lock_host(struct i
 	if (host->host_flags & IDE_HFLAG_SERIALIZE) {
 		rc = test_and_set_bit_lock(IDE_HOST_BUSY, &host->host_busy);
 		if (rc == 0) {
-			/* for atari only */
-			ide_get_lock(ide_intr, hwif);
+			if (host->get_lock)
+				host->get_lock(ide_intr, hwif);
 		}
 	}
 	return rc;
@@ -508,8 +508,8 @@ static inline int ide_lock_host(struct i
 static inline void ide_unlock_host(struct ide_host *host)
 {
 	if (host->host_flags & IDE_HFLAG_SERIALIZE) {
-		/* for atari only */
-		ide_release_lock();
+		if (host->release_lock)
+			host->release_lock();
 		clear_bit_unlock(IDE_HOST_BUSY, &host->host_busy);
 	}
 }
drivers/ide/ide-probe.c +2 -0
Index: b/drivers/ide/ide-probe.c
===================================================================
@@ -1320,6 +1320,8 @@ struct ide_host *ide_host_alloc(const st
 
 	if (d) {
 		host->init_chipset = d->init_chipset;
+		host->get_lock     = d->get_lock;
+		host->release_lock = d->release_lock;
 		host->host_flags = d->host_flags;
 	}
 
include/asm-m68k/ide.h +0 -36
Index: b/include/asm-m68k/ide.h
===================================================================
@@ -36,11 +36,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#ifdef CONFIG_ATARI
-#include <linux/interrupt.h>
-#include <asm/atari_stdma.h>
-#endif
-
 #ifdef CONFIG_MAC
 #include <asm/macints.h>
 #endif
@@ -92,36 +87,5 @@
 #define outsw_swapw(port, addr, n)	raw_outsw_swapw((u16 *)port, addr, n)
 #endif
 
-#ifdef CONFIG_BLK_DEV_FALCON_IDE
-#define IDE_ARCH_LOCK
-
-extern int falconide_intr_lock;
-
-static __inline__ void ide_release_lock (void)
-{
-	if (MACH_IS_ATARI) {
-		if (falconide_intr_lock == 0) {
-			printk("ide_release_lock: bug\n");
-			return;
-		}
-		falconide_intr_lock = 0;
-		stdma_release();
-	}
-}
-
-static __inline__ void
-ide_get_lock(irq_handler_t handler, void *data)
-{
-	if (MACH_IS_ATARI) {
-		if (falconide_intr_lock == 0) {
-			if (in_interrupt() > 0)
-				panic( "Falcon IDE hasn't ST-DMA lock in interrupt" );
-			stdma_lock(handler, data);
-			falconide_intr_lock = 1;
-		}
-	}
-}
-#endif /* CONFIG_BLK_DEV_FALCON_IDE */
-
 #endif /* __KERNEL__ */
 #endif /* _M68K_IDE_H */
include/linux/ide.h +10 -6
Index: b/include/linux/ide.h
===================================================================
@@ -202,12 +202,6 @@ static inline void ide_std_init_ports(hw
 
 #define MAX_HWIFS	10
 
-/* Currently only Atari needs it */
-#ifndef IDE_ARCH_LOCK
-# define ide_release_lock()			do {} while (0)
-# define ide_get_lock(hdlr, data)		do {} while (0)
-#endif /* IDE_ARCH_LOCK */
-
 /*
  * Now for the data we need to maintain per-drive:  ide_drive_t
  */
@@ -844,7 +838,12 @@ struct ide_host {
 	ide_hwif_t	*ports[MAX_HOST_PORTS + 1];
 	unsigned int	n_ports;
 	struct device	*dev[2];
+
 	int		(*init_chipset)(struct pci_dev *);
+
+	void		(*get_lock)(irq_handler_t, void *);
+	void		(*release_lock)(void);
+
 	unsigned long	host_flags;
 	void		*host_priv;
 	ide_hwif_t	*cur_port;	/* for hosts requiring serialization */
@@ -1355,7 +1354,12 @@ enum {
 
 struct ide_port_info {
 	char			*name;
+
 	int			(*init_chipset)(struct pci_dev *);
+
+	void			(*get_lock)(irq_handler_t, void *);
+	void			(*release_lock)(void);
+
 	void			(*init_iops)(ide_hwif_t *);
 	void                    (*init_hwif)(ide_hwif_t *);
 	int			(*init_dma)(ide_hwif_t *,
#8 lore raw

PATCH 3/4 ide: make m68k host drivers use IDE_HFLAG_MMIO

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: make m68k host drivers use IDE_HFLAG_MMIO

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>
---
 drivers/ide/buddha.c    |    6 +-----
 drivers/ide/falconide.c |    3 ++-
 drivers/ide/gayle.c     |    6 ++----
 drivers/ide/macide.c    |    2 +-
 drivers/ide/q40ide.c    |    2 +-
 5 files changed, 7 insertions(+), 12 deletions(-)
drivers/ide/buddha.c +1 -5
Index: b/drivers/ide/buddha.c
===================================================================
@@ -144,7 +144,7 @@ static void __init buddha_setup_ports(hw
 }
 
 static const struct ide_port_info buddha_port_info = {
-	.host_flags		= IDE_HFLAG_NO_DMA,
+	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
 };
 
     /*
@@ -176,10 +176,6 @@ static int __init buddha_init(void)
 		
 		board = z->resource.start;
 
-/*
- * FIXME: we now have selectable mmio v/s iomio transports.
- */
-
 		if(type != BOARD_XSURF) {
 			if (!request_mem_region(board+BUDDHA_BASE1, 0x800, "IDE"))
 				continue;
drivers/ide/falconide.c +2 -1
Index: b/drivers/ide/falconide.c
===================================================================
@@ -103,7 +103,8 @@ static const struct ide_port_info falcon
 	.get_lock		= falconide_get_lock,
 	.release_lock		= falconide_release_lock,
 	.tp_ops			= &falconide_tp_ops,
-	.host_flags		= IDE_HFLAG_NO_DMA | IDE_HFLAG_SERIALIZE,
+	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
+				  IDE_HFLAG_NO_DMA,
 };
 
 static void __init falconide_setup_ports(hw_regs_t *hw)
drivers/ide/gayle.c +2 -4
Index: b/drivers/ide/gayle.c
===================================================================
@@ -118,7 +118,8 @@ static void __init gayle_setup_ports(hw_
 }
 
 static const struct ide_port_info gayle_port_info = {
-	.host_flags		= IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA,
+	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
+				  IDE_HFLAG_NO_DMA,
 };
 
     /*
@@ -163,9 +164,6 @@ found:
 	    irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_1200);
 	    ack_intr = gayle_ack_intr_a1200;
 	}
-/*
- * FIXME: we now have selectable modes between mmio v/s iomio
- */
 
 	res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1);
 	res_n = GAYLE_IDEREG_SIZE;
drivers/ide/macide.c +1 -1
Index: b/drivers/ide/macide.c
===================================================================
@@ -81,7 +81,7 @@ static void __init macide_setup_ports(hw
 }
 
 static const struct ide_port_info macide_port_info = {
-	.host_flags		= IDE_HFLAG_NO_DMA,
+	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
 };
 
 static const char *mac_ide_name[] =
drivers/ide/q40ide.c +1 -1
Index: b/drivers/ide/q40ide.c
===================================================================
@@ -111,7 +111,7 @@ static const struct ide_tp_ops q40ide_tp
 
 static const struct ide_port_info q40ide_port_info = {
 	.tp_ops			= &q40ide_tp_ops,
-	.host_flags		= IDE_HFLAG_NO_DMA,
+	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
 };
 
 /* 
#9 lore raw

PATCH 4/4 m68k: cleanup <asm/ide.h>

In reply to Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: cleanup <asm-m68k/ide.h>

* Remove superfluous <asm/macints.h> include.

* No need to re-define in/out*() macros as they are no longer used by m68k host drivers.

* readl() and writel() are not used by core IDE code.

* Use raw_*_swapw() directly in {falcon,q40}ide.c and remove {in,out}sw_swapw() macros.

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>
---
 drivers/ide/falconide.c |    4 ++--
 drivers/ide/q40ide.c    |    4 ++--
 include/asm-m68k/ide.h  |   34 ----------------------------------
 3 files changed, 4 insertions(+), 38 deletions(-)
drivers/ide/falconide.c +2 -2
Index: b/drivers/ide/falconide.c
===================================================================
@@ -70,7 +70,7 @@ static void falconide_input_data(ide_dri
 	if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
 		return insw(data_addr, buf, (len + 1) / 2);
 
-	insw_swapw(data_addr, buf, (len + 1) / 2);
+	raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
 }
 
 static void falconide_output_data(ide_drive_t *drive, struct request *rq,
@@ -81,7 +81,7 @@ static void falconide_output_data(ide_dr
 	if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
 		return outsw(data_addr, buf, (len + 1) / 2);
 
-	outsw_swapw(data_addr, buf, (len + 1) / 2);
+	raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
 }
 
 /* Atari has a byte-swapped IDE interface */
drivers/ide/q40ide.c +2 -2
Index: b/drivers/ide/q40ide.c
===================================================================
@@ -80,7 +80,7 @@ static void q40ide_input_data(ide_drive_
 	if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
 		return insw(data_addr, buf, (len + 1) / 2);
 
-	insw_swapw(data_addr, buf, (len + 1) / 2);
+	raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
 }
 
 static void q40ide_output_data(ide_drive_t *drive, struct request *rq,
@@ -91,7 +91,7 @@ static void q40ide_output_data(ide_drive
 	if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
 		return outsw(data_addr, buf, (len + 1) / 2);
 
-	outsw_swapw(data_addr, buf, (len + 1) / 2);
+	raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
 }
 
 /* Q40 has a byte-swapped IDE interface */
include/asm-m68k/ide.h +0 -34
Index: b/include/asm-m68k/ide.h
===================================================================
@@ -30,62 +30,28 @@
 #define _M68K_IDE_H
 
 #ifdef __KERNEL__
-
-
 #include <asm/setup.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#ifdef CONFIG_MAC
-#include <asm/macints.h>
-#endif
-
 /*
  * Get rid of defs from io.h - ide has its private and conflicting versions
  * Since so far no single m68k platform uses ISA/PCI I/O space for IDE, we
  * always use the `raw' MMIO versions
  */
-#undef inb
-#undef inw
-#undef insw
-#undef inl
-#undef insl
-#undef outb
-#undef outw
-#undef outsw
-#undef outl
-#undef outsl
 #undef readb
 #undef readw
-#undef readl
 #undef writeb
 #undef writew
-#undef writel
 
-#define inb				in_8
-#define inw				in_be16
-#define insw(port, addr, n)		raw_insw((u16 *)port, addr, n)
-#define inl				in_be32
-#define insl(port, addr, n)		raw_insl((u32 *)port, addr, n)
-#define outb(val, port)			out_8(port, val)
-#define outw(val, port)			out_be16(port, val)
-#define outsw(port, addr, n)		raw_outsw((u16 *)port, addr, n)
-#define outl(val, port)			out_be32(port, val)
-#define outsl(port, addr, n)		raw_outsl((u32 *)port, addr, n)
 #define readb				in_8
 #define readw				in_be16
 #define __ide_mm_insw(port, addr, n)	raw_insw((u16 *)port, addr, n)
-#define readl				in_be32
 #define __ide_mm_insl(port, addr, n)	raw_insl((u32 *)port, addr, n)
 #define writeb(val, port)		out_8(port, val)
 #define writew(val, port)		out_be16(port, val)
 #define __ide_mm_outsw(port, addr, n)	raw_outsw((u16 *)port, addr, n)
-#define writel(val, port)		out_be32(port, val)
 #define __ide_mm_outsl(port, addr, n)	raw_outsl((u32 *)port, addr, n)
-#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
-#define insw_swapw(port, addr, n)	raw_insw_swapw((u16 *)port, addr, n)
-#define outsw_swapw(port, addr, n)	raw_outsw_swapw((u16 *)port, addr, n)
-#endif
 
 #endif /* __KERNEL__ */
 #endif /* _M68K_IDE_H */
#2 lore raw

Re: [PATCH 1/4] ide: remove IDE_ARCH_INTR

In reply to Bartlomiej Zolnierkiewicz

[Apologies for resending. The mailing lists on vger freaked out over MIME content in the last message.]

- (void)ide_ack_intr(hwif);
+ if (hwif->ack_intr(hwif))
+ hwif->ack_intr(hwif);

Shouldn't that be:

- (void)ide_ack_intr(hwif);
+ if (hwif->ack_intr)
+ hwif->ack_intr(hwif);

Dave

#3 lore raw

Re: [PATCH 1/4] ide: remove IDE_ARCH_INTR

Hi,

drivers/ide/ide-io.c void ide_timer_expiry (unsigned long dat · line 740

Quoted 10 lines
drivers/ide/ide-io.c +2 -1
-            (void)ide_ack_intr(hwif);
+            if (hwif->ack_intr(hwif))
+                hwif->ack_intr(hwif);

Shouldn't that be:

drivers/ide/ide-io.c +2 -1
-            (void)ide_ack_intr(hwif);
+            if (hwif->ack_intr)
+                hwif->ack_intr(hwif);

Seconded. No point in ack'ing the int twice (not to mention the other side effects).

Michael

#4 lore raw

Re: [PATCH 1/4] ide: remove IDE_ARCH_INTR

Quoted 7 lines · Michael Schmitz

Hi,

Quoted 5 lines
(quoted diff) +2 -1
-            (void)ide_ack_intr(hwif);
+            if (hwif->ack_intr(hwif))
+                hwif->ack_intr(hwif);
Quoted 8 lines

Review

Quoted 5 lines

Shouldn't that be:

(quoted diff) +2 -1
-            (void)ide_ack_intr(hwif);
+            if (hwif->ack_intr)
+                hwif->ack_intr(hwif);

Seconded. No point in ack'ing the int twice (not to mention the other side effects).

Brown paper bag time and another proof that having helpful people looking over your patches really matters...

Thanks guys, I fixed it in v2.

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: remove IDE_ARCH_INTR (v2)

This micro-optimization is not worth it. Just always check for existence of ->ack_intr method in ide_intr() and ide_timer_expiry().

v2:
Fix brown-paper-bag bug spotted by David D. Kilzer.

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>
Cc "David D. Kilzer" <[email protected]>
---
 drivers/ide/ide-io.c   |    5 +++--
 include/asm-m68k/ide.h |    3 ---
 include/linux/ide.h    |    5 -----
 3 files changed, 3 insertions(+), 10 deletions(-)
drivers/ide/ide-io.c +3 -2
Index: b/drivers/ide/ide-io.c
===================================================================
@@ -736,7 +736,8 @@ void ide_timer_expiry (unsigned long dat
 		} else if (drive_is_ready(drive)) {
 			if (drive->waiting_for_dma)
 				hwif->dma_ops->dma_lost_irq(drive);
-			(void)ide_ack_intr(hwif);
+			if (hwif->ack_intr)
+				hwif->ack_intr(hwif);
 			printk(KERN_WARNING "%s: lost interrupt\n",
 				drive->name);
 			startstop = handler(drive);
@@ -851,7 +852,7 @@ irqreturn_t ide_intr (int irq, void *dev
 
 	spin_lock_irqsave(&hwif->lock, flags);
 
-	if (!ide_ack_intr(hwif))
+	if (hwif->ack_intr && hwif->ack_intr(hwif) == 0)
 		goto out;
 
 	handler = hwif->handler;
include/asm-m68k/ide.h +0 -3
Index: b/include/asm-m68k/ide.h
===================================================================
@@ -123,8 +123,5 @@ ide_get_lock(irq_handler_t handler, void
 }
 #endif /* CONFIG_BLK_DEV_FALCON_IDE */
 
-#define IDE_ARCH_ACK_INTR
-#define ide_ack_intr(hwif)	((hwif)->ack_intr ? (hwif)->ack_intr(hwif) : 1)
-
 #endif /* __KERNEL__ */
 #endif /* _M68K_IDE_H */
include/linux/ide.h +0 -5
Index: b/include/linux/ide.h
===================================================================
@@ -202,11 +202,6 @@ static inline void ide_std_init_ports(hw
 
 #define MAX_HWIFS	10
 
-/* Currently only m68k, apus and m8xx need it */
-#ifndef IDE_ARCH_ACK_INTR
-# define ide_ack_intr(hwif) (1)
-#endif
-
 /* Currently only Atari needs it */
 #ifndef IDE_ARCH_LOCK
 # define ide_release_lock()			do {} while (0)
#6 lore raw

Re: [PATCH 2/4] ide: remove IDE_ARCH_LOCK

In reply to Bartlomiej Zolnierkiewicz
Quoted 59 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: remove IDE_ARCH_LOCK

* Add ->{get,release}_lock methods to struct ide_port_info and struct ide_host.

* Convert core IDE code, m68k IDE code and falconide support to use ->{get,release}_lock methods instead of ide_{get,release}_lock().

* Remove IDE_ARCH_LOCK.

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>

---
We may also consider adding struct ide_host_ops later...

 drivers/ide/falconide.c |   25 +++++++++++++++++++++++--
 drivers/ide/ide-io.c    |    8 ++++----
 drivers/ide/ide-probe.c |    2 ++
 include/asm-m68k/ide.h  |   36 ------------------------------------
 include/linux/ide.h     |   16 ++++++++++------
 5 files changed, 39 insertions(+), 48 deletions(-)

Index: b/drivers/ide/falconide.c
===================================================================

drivers/ide/falconide.c +21 -2
@@ -40,8 +40,27 @@
      *  which is shared between several drivers.
      */
 
-int falconide_intr_lock;
-EXPORT_SYMBOL(falconide_intr_lock);
+static int falconide_intr_lock;
+
+static void falconide_release_lock(void)
+{
+	if (falconide_intr_lock == 0) {
+		printk(KERN_ERR "%s: bug\n", __func__);
+		return;
+	}
+	falconide_intr_lock = 0;
+	stdma_release();
+}
+
+static void falconide_get_lock(irq_handler_t handler, void *data)
+{
+	if (falconide_intr_lock == 0) {
+		if (in_interrupt() > 0)
+			panic("Falcon IDE hasn't ST-DMA lock in interrupt");
+		stdma_lock(handler, data);
+		falconide_intr_lock = 1;
+	}
+}
 
 static void falconide_input_data(ide_drive_t *drive, struct request *rq,
 				 void *buf, unsigned int len)

drivers/ide/falconide.c static const struct ide_tp_ops falconide · line 107

Quoted 8 lines
drivers/ide/falconide.c +2 -0
@@ -81,6 +100,8 @@ static const struct ide_tp_ops falconide
 };
 
 static const struct ide_port_info falconide_port_info = {
+	.get_lock		= falconide_get_lock,
+	.release_lock		= falconide_release_lock,
 	.tp_ops			= &falconide_tp_ops,
 	.host_flags		= IDE_HFLAG_NO_DMA | IDE_HFLAG_SERIALIZE,
 };

http://kisskb.ellerman.id.au/kisskb/buildresult/71775/

drivers/ide/falconide.c:157: error: implicit declaration of function 'ide_get_lock' drivers/ide/falconide.c:159: error: implicit declaration of function 'ide_release_lock'

Seems like you forgot to update two callers?

drivers/ide/falconide.c +2 -2
index 1203796..bb0c86e 100644
@@ -154,9 +154,9 @@ static int __init falconide_init(void)
 		goto err;
 	}
 
-	ide_get_lock(NULL, NULL);
+	falconide_get_lock(NULL, NULL);
 	rc = ide_host_register(host, &falconide_port_info, hws);
-	ide_release_lock();
+	falconide_release_lock();
 
 	if (rc)
 		goto err_free;

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

#7 lore raw

Re: [PATCH 2/4] ide: remove IDE_ARCH_LOCK

Quoted 81 lines · Geert Uytterhoeven
Quoted 59 lines · Bartlomiej Zolnierkiewicz

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: remove IDE_ARCH_LOCK

* Add ->{get,release}_lock methods to struct ide_port_info and struct ide_host.

* Convert core IDE code, m68k IDE code and falconide support to use ->{get,release}_lock methods instead of ide_{get,release}_lock().

* Remove IDE_ARCH_LOCK.

Cc Geert Uytterhoeven <[email protected]>
Cc Michael Schmitz <[email protected]>

---
We may also consider adding struct ide_host_ops later...

 drivers/ide/falconide.c |   25 +++++++++++++++++++++++--
 drivers/ide/ide-io.c    |    8 ++++----
 drivers/ide/ide-probe.c |    2 ++
 include/asm-m68k/ide.h  |   36 ------------------------------------
 include/linux/ide.h     |   16 ++++++++++------
 5 files changed, 39 insertions(+), 48 deletions(-)

Index: b/drivers/ide/falconide.c
===================================================================

drivers/ide/falconide.c +21 -2
@@ -40,8 +40,27 @@
      *  which is shared between several drivers.
      */
 
-int falconide_intr_lock;
-EXPORT_SYMBOL(falconide_intr_lock);
+static int falconide_intr_lock;
+
+static void falconide_release_lock(void)
+{
+	if (falconide_intr_lock == 0) {
+		printk(KERN_ERR "%s: bug\n", __func__);
+		return;
+	}
+	falconide_intr_lock = 0;
+	stdma_release();
+}
+
+static void falconide_get_lock(irq_handler_t handler, void *data)
+{
+	if (falconide_intr_lock == 0) {
+		if (in_interrupt() > 0)
+			panic("Falcon IDE hasn't ST-DMA lock in interrupt");
+		stdma_lock(handler, data);
+		falconide_intr_lock = 1;
+	}
+}
 
 static void falconide_input_data(ide_drive_t *drive, struct request *rq,
 				 void *buf, unsigned int len)

drivers/ide/falconide.c static const struct ide_tp_ops falconide · line 107

Quoted 8 lines
drivers/ide/falconide.c +2 -0
@@ -81,6 +100,8 @@ static const struct ide_tp_ops falconide
 };
 
 static const struct ide_port_info falconide_port_info = {
+	.get_lock		= falconide_get_lock,
+	.release_lock		= falconide_release_lock,
 	.tp_ops			= &falconide_tp_ops,
 	.host_flags		= IDE_HFLAG_NO_DMA | IDE_HFLAG_SERIALIZE,
 };

http://kisskb.ellerman.id.au/kisskb/buildresult/71775/

drivers/ide/falconide.c:157: error: implicit declaration of function 'ide_get_lock' drivers/ide/falconide.c:159: error: implicit declaration of function 'ide_release_lock'

Seems like you forgot to update two callers?

drivers/ide/falconide.c +0 -0
index 1203796..bb0c86e 100644

drivers/ide/falconide.c static int __init falconide_init(void) · line 159

Quoted 8 lines
drivers/ide/falconide.c +2 -2
@@ -154,9 +154,9 @@ static int __init falconide_init(void)
 		goto err;
 	}
 
-	ide_get_lock(NULL, NULL);
+	falconide_get_lock(NULL, NULL);
 	rc = ide_host_register(host, &falconide_port_info, hws);
-	ide_release_lock();
+	falconide_release_lock();

Thanks, I integrated above fix into the original patch.

...
v2:
* Build fix from Geert updating ide_{get,release}_lock() callers in falconide.c.
...

Bart