public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Andrew Morton <akpm@osdl.org>
Cc: David Howells <dhowells@redhat.com>,
	torvalds@osdl.org, hch@infradead.org, arjan@infradead.org,
	matthew@wil.cx, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation
Date: Tue, 13 Dec 2005 10:55:44 +0100	[thread overview]
Message-ID: <20051213095544.GA31612@elte.hu> (raw)
In-Reply-To: <20051213075441.GB6765@elte.hu>

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]


* Ingo Molnar <mingo@elte.hu> wrote:

> all this simplified the 'compatibility conversion' to the patch below.  
> No other non-generic changes are needed.

there were 3 more patches needed, which convert some semaphores to 
completions:

 sx8-sem2completions.patch
 cpu5wdt-sem2completions.patch
 ide-gendev-sem-to-completion.patch

all attached.

	Ingo

[-- Attachment #2: sx8-sem2completions.patch --]
[-- Type: text/plain, Size: 1526 bytes --]

 drivers/block/sx8.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

Index: linux/drivers/block/sx8.c
===================================================================
--- linux.orig/drivers/block/sx8.c
+++ linux/drivers/block/sx8.c
@@ -27,6 +27,7 @@
 #include <linux/time.h>
 #include <linux/hdreg.h>
 #include <linux/dma-mapping.h>
+#include <linux/completion.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
 #include <asm/uaccess.h>
@@ -303,7 +304,7 @@ struct carm_host {
 
 	struct work_struct		fsm_task;
 
-	struct semaphore		probe_sem;
+	struct completion		probe_comp;
 };
 
 struct carm_response {
@@ -1365,7 +1366,7 @@ static void carm_fsm_task (void *_data)
 	}
 
 	case HST_PROBE_FINISHED:
-		up(&host->probe_sem);
+		complete(&host->probe_comp);
 		break;
 
 	case HST_ERROR:
@@ -1641,7 +1642,7 @@ static int carm_init_one (struct pci_dev
 	host->flags = pci_dac ? FL_DAC : 0;
 	spin_lock_init(&host->lock);
 	INIT_WORK(&host->fsm_task, carm_fsm_task, host);
-	init_MUTEX_LOCKED(&host->probe_sem);
+	init_completion(&host->probe_comp);
 
 	for (i = 0; i < ARRAY_SIZE(host->req); i++)
 		host->req[i].tag = i;
@@ -1710,8 +1711,8 @@ static int carm_init_one (struct pci_dev
 	if (rc)
 		goto err_out_free_irq;
 
-	DPRINTK("waiting for probe_sem\n");
-	down(&host->probe_sem);
+	DPRINTK("waiting for probe_comp\n");
+	wait_for_completion(&host->probe_comp);
 
 	printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n",
 	       host->name, pci_name(pdev), (int) CARM_MAX_PORTS,

[-- Attachment #3: cpu5wdt-sem2completions.patch --]
[-- Type: text/plain, Size: 1419 bytes --]

 drivers/char/watchdog/cpu5wdt.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

Index: linux/drivers/char/watchdog/cpu5wdt.c
===================================================================
--- linux.orig/drivers/char/watchdog/cpu5wdt.c
+++ linux/drivers/char/watchdog/cpu5wdt.c
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/timer.h>
+#include <linux/completion.h>
 #include <linux/jiffies.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -57,7 +58,7 @@ static int ticks = 10000;
 /* some device data */
 
 static struct {
-	struct semaphore stop;
+	struct completion stop;
 	volatile int running;
 	struct timer_list timer;
 	volatile int queue;
@@ -85,7 +86,7 @@ static void cpu5wdt_trigger(unsigned lon
 	}
 	else {
 		/* ticks doesn't matter anyway */
-		up(&cpu5wdt_device.stop);
+		complete(&cpu5wdt_device.stop);
 	}
 
 }
@@ -239,7 +240,7 @@ static int __devinit cpu5wdt_init(void)
 	if ( !val )
 		printk(KERN_INFO PFX "sorry, was my fault\n");
 
-	init_MUTEX_LOCKED(&cpu5wdt_device.stop);
+	init_completion(&cpu5wdt_device.stop);
 	cpu5wdt_device.queue = 0;
 
 	clear_bit(0, &cpu5wdt_device.inuse);
@@ -269,7 +270,7 @@ static void __devexit cpu5wdt_exit(void)
 {
 	if ( cpu5wdt_device.queue ) {
 		cpu5wdt_device.queue = 0;
-		down(&cpu5wdt_device.stop);
+		wait_for_completion(&cpu5wdt_device.stop);
 	}
 
 	misc_deregister(&cpu5wdt_misc);

[-- Attachment #4: ide-gendev-sem-to-completion.patch --]
[-- Type: text/plain, Size: 3535 bytes --]

The following patch is from Montavista.  I modified it slightly.
Semaphores are currently being used where it makes more sense for
completions.  This patch corrects that.

-- Steve

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Source: MontaVista Software, Inc.
Signed-off-by: Aleksey Makarov <amakarov@ru.mvista.com>
Description:
	The patch changes semaphores that are initialized as 
	locked to complete().

 drivers/ide/ide-probe.c |    4 ++--
 drivers/ide/ide.c       |    8 ++++----
 include/linux/ide.h     |    5 +++--
 3 files changed, 9 insertions(+), 8 deletions(-)

Index: linux/drivers/ide/ide-probe.c
===================================================================
--- linux.orig/drivers/ide/ide-probe.c
+++ linux/drivers/ide/ide-probe.c
@@ -655,7 +655,7 @@ static void hwif_release_dev (struct dev
 {
 	ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev);
 
-	up(&hwif->gendev_rel_sem);
+	complete(&hwif->gendev_rel_comp);
 }
 
 static void hwif_register (ide_hwif_t *hwif)
@@ -1325,7 +1325,7 @@ static void drive_release_dev (struct de
 	drive->queue = NULL;
 	spin_unlock_irq(&ide_lock);
 
-	up(&drive->gendev_rel_sem);
+	complete(&drive->gendev_rel_comp);
 }
 
 /*
Index: linux/drivers/ide/ide.c
===================================================================
--- linux.orig/drivers/ide/ide.c
+++ linux/drivers/ide/ide.c
@@ -222,7 +222,7 @@ static void init_hwif_data(ide_hwif_t *h
 	hwif->mwdma_mask = 0x80;	/* disable all mwdma */
 	hwif->swdma_mask = 0x80;	/* disable all swdma */
 
-	sema_init(&hwif->gendev_rel_sem, 0);
+	init_completion(&hwif->gendev_rel_comp);
 
 	default_hwif_iops(hwif);
 	default_hwif_transport(hwif);
@@ -245,7 +245,7 @@ static void init_hwif_data(ide_hwif_t *h
 		drive->is_flash			= 0;
 		drive->vdma			= 0;
 		INIT_LIST_HEAD(&drive->list);
-		sema_init(&drive->gendev_rel_sem, 0);
+		init_completion(&drive->gendev_rel_comp);
 	}
 }
 
@@ -602,7 +602,7 @@ void ide_unregister(unsigned int index)
 		}
 		spin_unlock_irq(&ide_lock);
 		device_unregister(&drive->gendev);
-		down(&drive->gendev_rel_sem);
+		wait_for_completion(&drive->gendev_rel_comp);
 		spin_lock_irq(&ide_lock);
 	}
 	hwif->present = 0;
@@ -662,7 +662,7 @@ void ide_unregister(unsigned int index)
 	/* More messed up locking ... */
 	spin_unlock_irq(&ide_lock);
 	device_unregister(&hwif->gendev);
-	down(&hwif->gendev_rel_sem);
+	wait_for_completion(&hwif->gendev_rel_comp);
 
 	/*
 	 * Remove us from the kernel's knowledge
Index: linux/include/linux/ide.h
===================================================================
--- linux.orig/include/linux/ide.h
+++ linux/include/linux/ide.h
@@ -18,6 +18,7 @@
 #include <linux/bio.h>
 #include <linux/device.h>
 #include <linux/pci.h>
+#include <linux/completion.h>
 #include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/io.h>
@@ -759,7 +760,7 @@ typedef struct ide_drive_s {
 	int		crc_count;	/* crc counter to reduce drive speed */
 	struct list_head list;
 	struct device	gendev;
-	struct semaphore gendev_rel_sem;	/* to deal with device release() */
+	struct completion gendev_rel_comp;	/* to deal with device release() */
 } ide_drive_t;
 
 #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
@@ -915,7 +916,7 @@ typedef struct hwif_s {
 	unsigned	sg_mapped  : 1;	/* sg_table and sg_nents are ready */
 
 	struct device	gendev;
-	struct semaphore gendev_rel_sem; /* To deal with device release() */
+	struct completion gendev_rel_comp; /* To deal with device release() */
 
 	void		*hwif_data;	/* extra hwif data */
 

  parent reply	other threads:[~2005-12-13  9:55 UTC|newest]

Thread overview: 228+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-12 23:45 [PATCH 1/19] MUTEX: Introduce simple mutex implementation David Howells
2005-12-12 23:45 ` [PATCH 2/19] MUTEX: i386 arch mutex David Howells
2005-12-12 23:45 ` [PATCH 5/19] MUTEX: Core kernel changes David Howells
2005-12-12 23:45 ` [PATCH 3/19] MUTEX: x86_64 arch mutex David Howells
2005-12-12 23:45 ` [PATCH 4/19] MUTEX: FRV " David Howells
2005-12-12 23:45 ` [PATCH 8/19] MUTEX: Drivers I-K changes David Howells
2005-12-12 23:45 ` [PATCH 6/19] MUTEX: Drivers A-E changes David Howells
2005-12-12 23:45 ` [PATCH 7/19] MUTEX: Drivers F-H changes David Howells
2005-12-12 23:45 ` [PATCH 11/19] MUTEX: Drivers Q-S changes David Howells
2005-12-12 23:45 ` [PATCH 14/19] MUTEX: First set of include changes David Howells
2005-12-12 23:45 ` [PATCH 13/19] MUTEX: Filesystem changes David Howells
2005-12-12 23:45 ` [PATCH 15/19] MUTEX: Second set of include changes David Howells
2005-12-12 23:45 ` [PATCH 9/19] MUTEX: Drivers L-M changes David Howells
2005-12-12 23:45 ` [PATCH 12/19] MUTEX: Drivers T-Z changes David Howells
2005-12-12 23:45 ` [PATCH 10/19] MUTEX: Drivers N-P changes David Howells
2005-12-12 23:45 ` [PATCH 19/19] MUTEX: Sound changes David Howells
2005-12-12 23:45 ` [PATCH 17/19] MUTEX: Networking changes David Howells
2005-12-12 23:45 ` [PATCH 18/19] MUTEX: Security changes David Howells
2005-12-12 23:45 ` [PATCH 16/19] MUTEX: IPC changes David Howells
2005-12-13  0:13 ` [PATCH 1/19] MUTEX: Introduce simple mutex implementation Nick Piggin
2005-12-13  9:54   ` David Howells
2005-12-13 10:13     ` Ingo Molnar
2005-12-13 10:34       ` Ingo Molnar
2005-12-13 10:37         ` Ingo Molnar
2005-12-13 12:47         ` Oliver Neukum
2005-12-13 13:09           ` Alan Cox
2005-12-13 13:13             ` Matthew Wilcox
2005-12-13 14:04               ` Alan Cox
2005-12-13 13:24             ` Oliver Neukum
2005-12-14  1:00     ` Nick Piggin
2005-12-14 10:54       ` David Howells
2005-12-14 11:17         ` Nick Piggin
2005-12-14 11:46           ` David Howells
2005-12-14 21:23             ` Nick Piggin
2005-12-16 12:00               ` David Howells
2005-12-16 13:16                 ` Nick Piggin
2005-12-16 15:53                   ` David Howells
2005-12-16 23:41                     ` Nick Piggin
2005-12-16 16:02                   ` David Howells
2005-12-13  0:19 ` Nick Piggin
2005-12-13 11:23   ` David Howells
2005-12-13 11:34     ` David Howells
2005-12-13  0:19 ` Andrew Morton
2005-12-13  7:54   ` Ingo Molnar
2005-12-13  7:58     ` Andi Kleen
2005-12-13  8:42       ` Andrew Morton
2005-12-13  8:49         ` Andi Kleen
2005-12-13  9:01           ` Andrew Morton
2005-12-13  9:02             ` Andrew Morton
2005-12-13 10:07               ` Jakub Jelinek
2005-12-13 10:11                 ` Andi Kleen
2005-12-13 10:15                   ` Jakub Jelinek
2005-12-13 10:25                   ` Andrew Morton
2005-12-14 10:46               ` Russell King
2005-12-13  9:05             ` Andi Kleen
2005-12-13  9:15               ` Andrew Morton
2005-12-13  9:24                 ` Andi Kleen
2005-12-13  9:44                   ` Andrew Morton
2005-12-13  9:49                     ` Andi Kleen
2005-12-13 10:28                   ` Andreas Schwab
2005-12-13 10:30                     ` Andi Kleen
2005-12-13 12:33                   ` Matthew Wilcox
2005-12-13 22:18               ` Adrian Bunk
2005-12-13 22:25                 ` Andi Kleen
2005-12-13 22:32                   ` Adrian Bunk
2005-12-13  9:11             ` Ingo Molnar
2005-12-13  9:04           ` Christoph Hellwig
2005-12-13  9:13             ` Ingo Molnar
2005-12-13 10:11             ` Jakub Jelinek
2005-12-13 10:19               ` Christoph Hellwig
2005-12-13 10:27                 ` Ingo Molnar
2005-12-15  4:53                 ` Miles Bader
2005-12-15  5:05                   ` Nick Piggin
2005-12-13  9:09           ` Ingo Molnar
2005-12-13  9:21             ` Andi Kleen
2005-12-13 16:16           ` Linus Torvalds
2005-12-13  9:03         ` Christoph Hellwig
2005-12-13  9:14           ` Andrew Morton
2005-12-13  9:21             ` Christoph Hellwig
2005-12-13 10:31             ` drivers/scsi/sd.c gcc-2.95.3 Alexey Dobriyan
2005-12-13  8:00     ` [PATCH 1/19] MUTEX: Introduce simple mutex implementation Arjan van de Ven
2005-12-13  9:03       ` Ingo Molnar
2005-12-13  9:09         ` Andi Kleen
2005-12-13  9:34           ` Ingo Molnar
2005-12-13 14:33             ` Mark Lord
2005-12-13 14:45               ` Arjan van de Ven
2005-12-13  9:37           ` Ingo Molnar
2005-12-13  9:19         ` Arjan van de Ven
2005-12-13  9:02     ` Christoph Hellwig
2005-12-13  9:39       ` Ingo Molnar
2005-12-13 10:00         ` Ingo Molnar
2005-12-13 17:40           ` Paul Jackson
2005-12-13 18:34             ` David Howells
2005-12-13 22:31               ` Paul Jackson
2005-12-14 11:02                 ` David Howells
2005-12-14 11:12                   ` David Howells
2005-12-14 11:18                     ` Alan Cox
2005-12-14 12:35                       ` David Howells
2005-12-14 13:58                         ` Thomas Gleixner
2005-12-14 23:40                           ` Mark Lord
2005-12-14 23:54                             ` Andrew Morton
2005-12-15 13:41                               ` Nikita Danilov
2005-12-15 14:56                                 ` Alan Cox
2005-12-15 15:52                                   ` Nikita Danilov
2005-12-15 15:55                                     ` David Howells
2005-12-15 16:22                                       ` linux-os (Dick Johnson)
2005-12-15 16:28                                       ` Linus Torvalds
2005-12-15 16:51                                         ` David Howells
2005-12-15 17:04                                         ` Thomas Gleixner
2005-12-15 17:09                                         ` Paul Jackson
2005-12-15 17:17                                           ` David Howells
2005-12-15 16:56                                       ` Paul Jackson
2005-12-15 17:28                                         ` David Howells
2005-12-15 17:48                                           ` Linus Torvalds
2005-12-15 18:20                                             ` Nikita Danilov
2005-12-15 20:58                                               ` Steven Rostedt
2005-12-15 19:21                                             ` Andrew Morton
2005-12-15 19:38                                               ` Linus Torvalds
2005-12-15 20:28                                               ` Steven Rostedt
2005-12-15 20:32                                                 ` Geert Uytterhoeven
2005-12-16 21:41                                                   ` Thomas Gleixner
2005-12-16 21:41                                                     ` Linus Torvalds
2005-12-16 22:06                                                       ` Thomas Gleixner
2005-12-16 22:19                                                         ` Linus Torvalds
2005-12-16 22:32                                                           ` Steven Rostedt
2005-12-16 22:42                                                           ` Thomas Gleixner
2005-12-16 22:41                                                             ` Linus Torvalds
2005-12-16 22:49                                                               ` Steven Rostedt
2005-12-16 23:29                                                               ` Thomas Gleixner
2005-12-17  0:29                                                               ` Joe Korty
2005-12-17  1:00                                                                 ` Linus Torvalds
2005-12-17  3:13                                                                   ` Steven Rostedt
2005-12-17  7:34                                                                     ` Linus Torvalds
2005-12-17 23:43                                                                       ` Matthew Wilcox
2005-12-18  0:05                                                                         ` Lee Revell
2005-12-18  0:21                                                                           ` Matthew Wilcox
2005-12-18  1:25                                                                             ` Lee Revell
2005-12-22 12:27                                                                         ` Bill Huey
2005-12-19 16:08                                                                       ` Ingo Molnar
2005-12-22 12:40                                                                       ` Bill Huey
2005-12-22 12:45                                                                         ` Bill Huey
2005-12-19 23:46                                                                   ` Keith Owens
2005-12-15 16:50                                     ` Christopher Friesen
2005-12-15 20:53                                       ` Steven Rostedt
2005-12-15 14:41                               ` Steven Rostedt
2005-12-15 15:37                               ` David Howells
2005-12-15 19:28                                 ` Andrew Morton
2005-12-15 20:18                                   ` Andrew Morton
2005-12-15 21:28                                     ` Steven Rostedt
2005-12-16 10:45                                     ` David Howells
2005-12-16 22:02                                     ` Thomas Gleixner
2005-12-14 23:57                             ` Thomas Gleixner
2005-12-14 23:57                               ` Mark Lord
2005-12-15  0:10                                 ` Thomas Gleixner
2005-12-15  2:46                                   ` Linus Torvalds
2005-12-15 15:53                                     ` David Howells
2005-12-13  9:55     ` Ingo Molnar [this message]
2005-12-13 10:48   ` David Howells
2005-12-13 12:39     ` Matthew Wilcox
2005-12-13  0:30 ` Arnd Bergmann
2005-12-13 21:03   ` David Howells
2005-12-13  0:57 ` Daniel Walker
2005-12-13  3:23   ` Steven Rostedt
2005-12-13  2:57 ` Mark Lord
2005-12-13  3:17   ` Steven Rostedt
2005-12-13  9:06   ` Christoph Hellwig
2005-12-13 10:54 ` Ingo Molnar
2005-12-13 11:24   ` David Howells
2005-12-13 13:45     ` Ingo Molnar
2005-12-13 13:05 ` Alan Cox
2005-12-13 13:15   ` Alan Cox
2005-12-13 23:21     ` Nikita Danilov
2005-12-13 13:32   ` David Howells
2005-12-13 14:00     ` Alan Cox
2005-12-13 15:23       ` David Howells
2005-12-15  5:24         ` Miles Bader
2005-12-13 14:35     ` Christopher Friesen
2005-12-13 14:44       ` Arjan van de Ven
2005-12-13 14:59         ` Christopher Friesen
2005-12-13 15:39       ` David Howells
2005-12-13 16:10         ` Alan Cox
2005-12-14 10:29           ` Arjan van de Ven
2005-12-14 11:03             ` Arjan van de Ven
2005-12-14 11:03             ` Alan Cox
2005-12-14 11:08               ` Arjan van de Ven
2005-12-14 11:24                 ` Alan Cox
2005-12-14 11:35                   ` Andrew Morton
2005-12-14 11:44                     ` Arjan van de Ven
2005-12-14 11:52                       ` Andi Kleen
2005-12-14 11:55                         ` Arjan van de Ven
2005-12-14 11:57                       ` David Howells
2005-12-14 12:19                         ` Jakub Jelinek
2005-12-16  1:54                         ` Nick Piggin
2005-12-16 11:02                           ` David Howells
2005-12-16 11:30                             ` David Howells
2005-12-16 16:33                               ` Linus Torvalds
2005-12-16 22:23                                 ` David S. Miller
2005-12-16 22:38                                   ` Linus Torvalds
2005-12-16 22:53                                     ` David S. Miller
2005-12-17  0:41                                       ` Jesse Barnes
2005-12-17  7:10                                         ` David S. Miller
2005-12-17  7:40                                           ` Linus Torvalds
2005-12-17 17:22                                             ` Jesse Barnes
2005-12-17 17:19                                           ` Jesse Barnes
2005-12-17 22:38                                       ` Richard Henderson
2005-12-17 23:05                                         ` David S. Miller
2005-12-16 13:01                             ` Nick Piggin
2005-12-16 13:21                               ` Russell King
2005-12-16 13:41                                 ` Nick Piggin
2005-12-16 13:46                                 ` Linh Dang
2005-12-16 14:31                                   ` Russell King
2005-12-16 15:24                                     ` Linh Dang
2005-12-16 15:35                                       ` Nick Piggin
2005-12-16 15:40                                       ` Kyle Moffett
2005-12-16 15:46                                     ` David Howells
2005-12-16 15:58                                       ` Russell King
2005-12-16 15:49                                     ` Linh Dang
2005-12-17 15:57                               ` Nikita Danilov
2005-12-16 16:28                             ` Linus Torvalds
2005-12-14 12:17                     ` Christoph Hellwig
2005-12-14 11:42                   ` Arjan van de Ven
2005-12-14  8:31         ` Ingo Molnar
2005-12-13 20:04     ` Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2005-12-15 17:45 Luck, Tony
2005-12-15 18:00 ` David Howells
2005-12-15 18:48 ` James Bottomley
2005-12-15 20:38 ` Jeff Dike
2005-12-15 23:45   ` Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051213095544.GA31612@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox