From eb221849540b7f4165c58b6c79d98b97ac902fdb Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 30 Jan 2006 16:10:31 +0100 Subject: [SCSI] aic79xx: Fix timer handling Fix the timer handling in aic79xx to use the SCSI-ML provided handling instead of implementing our own. It also fixes a deadlock in the command recovery code. Signed-off-by: Hannes Reinecke Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'drivers/scsi/aic7xxx/aic79xx_osm.c') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 815c06312c8..7254ea535a1 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1089,7 +1089,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa return (ENOMEM); *((struct ahd_softc **)host->hostdata) = ahd; - ahd_lock(ahd, &s); ahd->platform_data->host = host; host->can_queue = AHD_MAX_QUEUE; host->cmd_per_lun = 2; @@ -1100,7 +1099,9 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa host->max_lun = AHD_NUM_LUNS; host->max_channel = 0; host->sg_tablesize = AHD_NSEG; + ahd_lock(ahd, &s); ahd_set_unit(ahd, ahd_linux_unit++); + ahd_unlock(ahd, &s); sprintf(buf, "scsi%d", host->host_no); new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); if (new_name != NULL) { @@ -1110,7 +1111,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa host->unique_id = ahd->unit; ahd_linux_initialize_scsi_bus(ahd); ahd_intr_enable(ahd, TRUE); - ahd_unlock(ahd, &s); host->transportt = ahd_linux_transport_template; @@ -1144,6 +1144,7 @@ ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd) { u_int target_id; u_int numtarg; + unsigned long s; target_id = 0; numtarg = 0; @@ -1156,6 +1157,8 @@ ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd) else numtarg = (ahd->features & AHD_WIDE) ? 16 : 8; + ahd_lock(ahd, &s); + /* * Force negotiation to async for all targets that * will not see an initial bus reset. @@ -1172,16 +1175,12 @@ ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd) ahd_update_neg_request(ahd, &devinfo, tstate, tinfo, AHD_NEG_ALWAYS); } + ahd_unlock(ahd, &s); /* Give the bus some time to recover */ if ((ahd->flags & AHD_RESET_BUS_A) != 0) { ahd_freeze_simq(ahd); - init_timer(&ahd->platform_data->reset_timer); - ahd->platform_data->reset_timer.data = (u_long)ahd; - ahd->platform_data->reset_timer.expires = - jiffies + (AIC79XX_RESET_DELAY * HZ)/1000; - ahd->platform_data->reset_timer.function = - (ahd_linux_callback_t *)ahd_release_simq; - add_timer(&ahd->platform_data->reset_timer); + msleep(AIC79XX_RESET_DELAY); + ahd_release_simq(ahd); } } @@ -2050,6 +2049,9 @@ ahd_linux_sem_timeout(u_long arg) void ahd_freeze_simq(struct ahd_softc *ahd) { + unsigned long s; + + ahd_lock(ahd, &s); ahd->platform_data->qfrozen++; if (ahd->platform_data->qfrozen == 1) { scsi_block_requests(ahd->platform_data->host); @@ -2057,6 +2059,7 @@ ahd_freeze_simq(struct ahd_softc *ahd) CAM_LUN_WILDCARD, SCB_LIST_NULL, ROLE_INITIATOR, CAM_REQUEUE_REQ); } + ahd_unlock(ahd, &s); } void @@ -2361,8 +2364,9 @@ done: ahd_name(ahd), dev->active); retval = FAILED; } - } - ahd_unlock(ahd, &flags); + } else + ahd_unlock(ahd, &flags); + return (retval); } -- cgit v1.2.3