Thread: [Linux1394-cvslog] rev 772 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <ben...@li...> - 2003-02-06 17:04:04
|
Author: bencollins Date: 2003-02-06 12:03:31 -0500 (Thu, 06 Feb 2003) New Revision: 772 Modified: trunk/sbp2.c Log: Patch from Sancho Dauskard removing sbp2 spinlock wrappers Modified: trunk/sbp2.c ============================================================================== --- trunk/sbp2.c (original) +++ trunk/sbp2.c 2003-02-06 12:03:32.000000000 -0500 @@ -298,6 +298,7 @@ * 06/09/02 - Don't force 36-bute SCSI inquiry, but leave in a define for badly behaved devices. (JSG) * 02/04/03 - Fixed a SMP deadlock (don't hold sbp2_command_lock while calling sbp2scsi_complete_command). * Also save/restore irq flags in sbp2scsi_complete_command - Sancho Dauskardt <sd...@bd...> + * 02/06/03 - Removed spinlock debugging; use kernel stuff instead (sda) * */ @@ -491,19 +492,6 @@ #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) -/* - * Spinlock debugging stuff. - */ -#define SBP2_USE_REAL_SPINLOCKS - -#ifdef SBP2_USE_REAL_SPINLOCKS -#define sbp2_spin_lock(lock, flags) spin_lock_irqsave(lock, flags) -#define sbp2_spin_unlock(lock, flags) spin_unlock_irqrestore(lock, flags); -static spinlock_t sbp2_host_info_lock = SPIN_LOCK_UNLOCKED; -#else -#define sbp2_spin_lock(lock, flags) do {save_flags(flags); cli();} while (0) -#define sbp2_spin_unlock(lock, flags) do {restore_flags(flags);} while (0) -#endif /* * Globals @@ -515,6 +503,8 @@ static LIST_HEAD(sbp2_host_info_list); +static spinlock_t sbp2_host_info_lock = SPIN_LOCK_UNLOCKED; + static struct hpsb_highlevel *sbp2_hl_handle = NULL; static struct hpsb_highlevel_ops sbp2_hl_ops = { @@ -689,12 +679,12 @@ orbs = sbp2_serialize_io ? 2 : SBP2_MAX_COMMAND_ORBS; - sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); for (i = 0; i < orbs; i++) { command = (struct sbp2_command_info *) kmalloc(sizeof(struct sbp2_command_info), GFP_KERNEL); if (!command) { - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return(-ENOMEM); } memset(command, '\0', sizeof(struct sbp2_command_info)); @@ -711,7 +701,7 @@ INIT_LIST_HEAD(&command->list); list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); } - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return 0; } @@ -725,7 +715,7 @@ struct sbp2_command_info *command; unsigned long flags; - sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); if (!list_empty(&scsi_id->sbp2_command_orb_completed)) { list_for_each_safe(lh, next, &scsi_id->sbp2_command_orb_completed) { command = list_entry(lh, struct sbp2_command_info, list); @@ -743,7 +733,7 @@ kfree(command); } } - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return; } @@ -758,17 +748,17 @@ struct sbp2_command_info *command; unsigned long flags; - sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); if (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { list_for_each(lh, &scsi_id->sbp2_command_orb_inuse) { command = list_entry(lh, struct sbp2_command_info, list); if (command->command_orb_dma == orb) { - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return (command); } } } - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); @@ -785,17 +775,17 @@ struct sbp2_command_info *command; unsigned long flags; - sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); if (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { list_for_each(lh, &scsi_id->sbp2_command_orb_inuse) { command = list_entry(lh, struct sbp2_command_info, list); if (command->Current_SCpnt == SCpnt) { - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return (command); } } } - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return(NULL); } @@ -812,7 +802,7 @@ struct sbp2_command_info *command = NULL; unsigned long flags; - sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); if (!list_empty(&scsi_id->sbp2_command_orb_completed)) { lh = scsi_id->sbp2_command_orb_completed.next; list_del(lh); @@ -823,7 +813,7 @@ } else { SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); } - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return (command); } @@ -868,11 +858,11 @@ { unsigned long flags; - sbp2_spin_lock(&scsi_id->sbp2_command_orb_lock, flags); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); list_del(&command->list); sbp2util_free_command_dma(command); list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); - sbp2_spin_unlock(&scsi_id->sbp2_command_orb_lock, flags); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); } @@ -995,9 +985,9 @@ /* Complete any pending commands with busy (so they get * retried) and remove them from our queue */ - sbp2_spin_lock(&hi->sbp2_command_lock, flags); + spin_lock_irqsave(&hi->sbp2_command_lock, flags); sbp2scsi_complete_all_commands(hi, scsi_id, DID_BUS_BUSY); - sbp2_spin_unlock(&hi->sbp2_command_lock, flags); + spin_unlock_irqrestore(&hi->sbp2_command_lock, flags); } /* @@ -1027,9 +1017,9 @@ hi->host = host; hi->sbp2_command_lock = SPIN_LOCK_UNLOCKED; - sbp2_spin_lock(&sbp2_host_info_lock, flags); + spin_lock_irqsave(&sbp2_host_info_lock, flags); list_add_tail(&hi->list, &sbp2_host_info_list); - sbp2_spin_unlock(&sbp2_host_info_lock, flags); + spin_unlock_irqrestore(&sbp2_host_info_lock, flags); /* Register our host with the SCSI stack. */ hi->scsi_host = scsi_register (&scsi_driver_template, sizeof(void *)); @@ -1088,7 +1078,7 @@ SBP2_DEBUG("sbp2_remove_host"); - sbp2_spin_lock(&sbp2_host_info_lock, flags); + spin_lock_irqsave(&sbp2_host_info_lock, flags); hi = sbp2_find_host_info(host); if (hi != NULL) { @@ -1098,7 +1088,7 @@ else SBP2_ERR("attempt to remove unknown host %p", host); - sbp2_spin_unlock(&sbp2_host_info_lock, flags); + spin_unlock_irqrestore(&sbp2_host_info_lock, flags); } /* @@ -2524,16 +2514,16 @@ return(RCODE_ADDRESS_ERROR); } - sbp2_spin_lock(&sbp2_host_info_lock, flags); + spin_lock_irqsave(&sbp2_host_info_lock, flags); hi = sbp2_find_host_info(host); - sbp2_spin_unlock(&sbp2_host_info_lock, flags); + spin_unlock_irqrestore(&sbp2_host_info_lock, flags); if (!hi) { SBP2_ERR("host info is NULL - this is bad!"); return(RCODE_ADDRESS_ERROR); } - sbp2_spin_lock(&hi->sbp2_command_lock, flags); + spin_lock_irqsave(&hi->sbp2_command_lock, flags); /* * Find our scsi_id structure by looking at the status fifo address written to by @@ -2544,7 +2534,7 @@ if (!scsi_id) { SBP2_ERR("scsi_id is NULL - device is gone?"); - sbp2_spin_unlock(&hi->sbp2_command_lock, flags); + spin_unlock_irqrestore(&hi->sbp2_command_lock, flags); return(RCODE_ADDRESS_ERROR); } @@ -2631,7 +2621,7 @@ } } - sbp2_spin_unlock(&hi->sbp2_command_lock, flags); + spin_unlock_irqrestore(&hi->sbp2_command_lock, flags); if (SCpnt) { @@ -2727,12 +2717,12 @@ /* * Try and send our SCSI command */ - sbp2_spin_lock(&hi->sbp2_command_lock, flags); + spin_lock_irqsave(&hi->sbp2_command_lock, flags); if (sbp2_send_command(hi, scsi_id, SCpnt, done)) { SBP2_ERR("Error sending SCSI command"); sbp2scsi_complete_command(hi, scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT, SCpnt, done); } - sbp2_spin_unlock(&hi->sbp2_command_lock, flags); + spin_unlock_irqrestore(&hi->sbp2_command_lock, flags); return(0); } @@ -2912,7 +2902,7 @@ * Right now, just return any matching command structures * to the free pool. */ - sbp2_spin_lock(&hi->sbp2_command_lock, flags); + spin_lock_irqsave(&hi->sbp2_command_lock, flags); command = sbp2util_find_command_for_SCpnt(scsi_id, SCpnt); if (command) { SBP2_DEBUG("Found command to abort"); @@ -2937,7 +2927,7 @@ */ sbp2_agent_reset(hi, scsi_id, 0); sbp2scsi_complete_all_commands(hi, scsi_id, DID_BUS_BUSY); - sbp2_spin_unlock(&hi->sbp2_command_lock, flags); + spin_unlock_irqrestore(&hi->sbp2_command_lock, flags); } return(SUCCESS); |