diff options
| author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-12-29 20:27:31 +0100 | 
|---|---|---|
| committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-12-29 20:27:31 +0100 | 
| commit | 2a2ca6a96194c4744a2adeefbc09ce881f3c5abe (patch) | |
| tree | 50b43d823d4a589fbfb8f8751278d6101cd3ecf3 /drivers/ide/ide-probe.c | |
| parent | 6ea52226ca131a99bb619bd56fbeee566ea5a966 (diff) | |
| download | olio-linux-3.10-2a2ca6a96194c4744a2adeefbc09ce881f3c5abe.tar.xz olio-linux-3.10-2a2ca6a96194c4744a2adeefbc09ce881f3c5abe.zip  | |
ide: replace the global ide_lock spinlock by per-hwgroup spinlocks (v2)
Now that (almost) all host drivers have been fixed not to abuse ide_lock
and core code usage of ide_lock has been sanitized we may safely replace
ide_lock by per-hwgroup locks.
This patch is partially based on earlier patch from Ravikiran G Thirumalai.
While at it:
- don't use deprecated HWIF() and HWGROUP() macros
- update locking documentation in ide.h
v2:
Add missing spin_lock_init(&hwgroup->lock).  (Noticed by Elias Oltmanns)
Cc: Vaibhav V. Nivargi <vaibhav.nivargi@gmail.com>
Cc: Alok N. Kataria <alokk@calsoftinc.com>
Cc: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
| -rw-r--r-- | drivers/ide/ide-probe.c | 26 | 
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index c55bdbd2231..504bc9480e9 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -906,7 +906,8 @@ static int ide_init_queue(ide_drive_t *drive)  	 *	do not.  	 */ -	q = blk_init_queue_node(do_ide_request, &ide_lock, hwif_to_node(hwif)); +	q = blk_init_queue_node(do_ide_request, &hwif->hwgroup->lock, +				hwif_to_node(hwif));  	if (!q)  		return 1; @@ -947,7 +948,7 @@ static void ide_add_drive_to_hwgroup(ide_drive_t *drive)  {  	ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; -	spin_lock_irq(&ide_lock); +	spin_lock_irq(&hwgroup->lock);  	if (!hwgroup->drive) {  		/* first drive for hwgroup. */  		drive->next = drive; @@ -957,7 +958,7 @@ static void ide_add_drive_to_hwgroup(ide_drive_t *drive)  		drive->next = hwgroup->drive->next;  		hwgroup->drive->next = drive;  	} -	spin_unlock_irq(&ide_lock); +	spin_unlock_irq(&hwgroup->lock);  }  /* @@ -1002,7 +1003,7 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)  	ide_ports[hwif->index] = NULL; -	spin_lock_irq(&ide_lock); +	spin_lock_irq(&hwgroup->lock);  	/*  	 * Remove us from the hwgroup, and free  	 * the hwgroup if we were the only member @@ -1030,7 +1031,7 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)  		}  		BUG_ON(hwgroup->hwif == hwif);  	} -	spin_unlock_irq(&ide_lock); +	spin_unlock_irq(&hwgroup->lock);  }  /* @@ -1092,17 +1093,19 @@ static int init_irq (ide_hwif_t *hwif)  		 * linked list, the first entry is the hwif that owns  		 * hwgroup->handler - do not change that.  		 */ -		spin_lock_irq(&ide_lock); +		spin_lock_irq(&hwgroup->lock);  		hwif->next = hwgroup->hwif->next;  		hwgroup->hwif->next = hwif;  		BUG_ON(hwif->next == hwif); -		spin_unlock_irq(&ide_lock); +		spin_unlock_irq(&hwgroup->lock);  	} else {  		hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO,  				       hwif_to_node(hwif));  		if (hwgroup == NULL)  			goto out_up; +		spin_lock_init(&hwgroup->lock); +  		hwif->hwgroup = hwgroup;  		hwgroup->hwif = hwif->next = hwif; @@ -1263,20 +1266,21 @@ static void ide_remove_drive_from_hwgroup(ide_drive_t *drive)  static void drive_release_dev (struct device *dev)  {  	ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); +	ide_hwgroup_t *hwgroup = drive->hwif->hwgroup;  	ide_proc_unregister_device(drive); -	spin_lock_irq(&ide_lock); +	spin_lock_irq(&hwgroup->lock);  	ide_remove_drive_from_hwgroup(drive);  	kfree(drive->id);  	drive->id = NULL;  	drive->dev_flags &= ~IDE_DFLAG_PRESENT;  	/* Messed up locking ... */ -	spin_unlock_irq(&ide_lock); +	spin_unlock_irq(&hwgroup->lock);  	blk_cleanup_queue(drive->queue); -	spin_lock_irq(&ide_lock); +	spin_lock_irq(&hwgroup->lock);  	drive->queue = NULL; -	spin_unlock_irq(&ide_lock); +	spin_unlock_irq(&hwgroup->lock);  	complete(&drive->gendev_rel_comp);  }  |