Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Mar 2007 18:02:55 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 116754 for review
Message-ID:  <200703281802.l2SI2tOe012718@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=116754

Change 116754 by scottl@scottl-x64 on 2007/03/28 18:01:55

	Basic locking for ahc driver, enough to get it doing normal I/O things

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic7xxx.c#6 edit
.. //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic7xxx_osm.c#10 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic7xxx.c#6 (text+ko) ====

@@ -6944,6 +6944,7 @@
 	struct ahc_softc *ahc;
 
 	ahc = scb->ahc_softc;
+	ahc_lock(ahc, NULL);
 	if ((scb->flags & SCB_ACTIVE) != 0) {
 		if ((scb->flags & SCB_TIMEDOUT) == 0) {
 			LIST_INSERT_HEAD(&ahc->timedout_scbs, scb,
@@ -6952,6 +6953,7 @@
 		}
 		ahc_wakeup_recovery_thread(ahc);
 	}
+	ahc_unlock(ahc, NULL);
 }
 
 /*

==== //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic7xxx_osm.c#10 (text+ko) ====

@@ -107,8 +107,8 @@
 
 	/* Hook up our interrupt handler */
 	error = bus_setup_intr(ahc->dev_softc, ahc->platform_data->irq,
-			       INTR_TYPE_CAM, ahc_platform_intr, ahc,
-			       &ahc->platform_data->ih);
+			       INTR_TYPE_CAM|INTR_MPSAFE, ahc_platform_intr,
+			       ahc, &ahc->platform_data->ih);
 
 	if (error != 0)
 		device_printf(ahc->dev_softc, "bus_setup_intr() failed: %d\n",
@@ -161,6 +161,11 @@
 	path = NULL;
 	path2 = NULL;
 
+
+	ahc_lockinit(ahc);
+	ahc_done_lockinit(ahc);
+	ahc_list_lockinit();
+
 	/*
 	 * Create a thread to perform all recovery.
 	 */
@@ -196,7 +201,7 @@
 	 */
 	sim = cam_sim_alloc(ahc_action, ahc_poll, "ahc", ahc,
 			    device_get_unit(ahc->dev_softc),
-			    &Giant, 1, AHC_MAX_QUEUE, devq);
+			    &ahc->platform_data->mtx, 1, AHC_MAX_QUEUE, devq);
 	if (sim == NULL) {
 		cam_simq_free(devq);
 		goto fail;
@@ -228,7 +233,8 @@
 	if (ahc->features & AHC_TWIN) {
 		sim2 = cam_sim_alloc(ahc_action, ahc_poll, "ahc",
 				    ahc, device_get_unit(ahc->dev_softc),
-				    &Giant, 1, AHC_MAX_QUEUE, devq);
+				    &ahc->platform_data->mtx, 1,
+				    AHC_MAX_QUEUE, devq);
 
 		if (sim2 == NULL) {
 			printf("ahc_attach: Unable to attach second "
@@ -278,6 +284,7 @@
 		ahc->platform_data->sim_b = sim2;
 		ahc->platform_data->path_b = path2;
 	}
+	ahc_unlock(ahc, &s);
 
 	if (count != 0) {
 		/* We have to wait until after any system dumps... */
@@ -287,7 +294,6 @@
 		ahc_intr_enable(ahc, TRUE);
 	}
 
-	ahc_unlock(ahc, &s);
 	return (count);
 }
 
@@ -300,7 +306,9 @@
 	struct	ahc_softc *ahc;
 
 	ahc = (struct ahc_softc *)arg; 
+	ahc_lock(ahc, NULL);
 	ahc_intr(ahc);
+	ahc_unlock(ahc, NULL);
 }
 
 /*
@@ -331,7 +339,7 @@
 		ahc_run_untagged_queue(ahc, untagged_q);
 	}
 
-	untimeout(ahc_platform_timeout, (caddr_t)scb, ccb->ccb_h.timeout_ch);
+	callout_stop(&ccb->ccb_h.callout);
 
 	if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
 		bus_dmasync_op_t op;
@@ -441,7 +449,6 @@
 	struct	ahc_tmode_lstate *lstate;
 	u_int	target_id;
 	u_int	our_id;
-	long	s;
 
 	CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("ahc_action\n"));
 	
@@ -474,13 +481,11 @@
 		}
 		if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) {
 
-			ahc_lock(ahc, &s);
 			SLIST_INSERT_HEAD(&lstate->accept_tios, &ccb->ccb_h,
 					  sim_links.sle);
 			ccb->ccb_h.status = CAM_REQ_INPROG;
 			if ((ahc->flags & AHC_TQINFIFO_BLOCKED) != 0)
 				ahc_run_tqinfifo(ahc, /*paused*/FALSE);
-			ahc_unlock(ahc, &s);
 			break;
 		}
 
@@ -510,17 +515,14 @@
 		/*
 		 * get an scb to use.
 		 */
-		ahc_lock(ahc, &s);
 		if ((scb = ahc_get_scb(ahc)) == NULL) {
 	
 			xpt_freeze_simq(sim, /*count*/1);
 			ahc->flags |= AHC_RESOURCE_SHORTAGE;
-			ahc_unlock(ahc, &s);
 			ccb->ccb_h.status = CAM_REQUEUE_REQ;
 			xpt_done(ccb);
 			return;
 		}
-		ahc_unlock(ahc, &s);
 		
 		hscb = scb->hscb;
 		
@@ -650,8 +652,6 @@
 			break;
 		}
 		
-		ahc_lock(ahc, &s);
-
 		if ((spi->valid & CTS_SPI_VALID_DISC) != 0) {
 			if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0)
 				*discenable |= devinfo.target_mask;
@@ -727,7 +727,6 @@
 					 spi->ppr_options, update_type,
 					 /*paused*/FALSE);
 		}
-		ahc_unlock(ahc, &s);
 		ccb->ccb_h.status = CAM_REQ_CMP;
 		xpt_done(ccb);
 		break;
@@ -736,10 +735,8 @@
 	/* Get default/user set transfer settings for the target */
 	{
 
-		ahc_lock(ahc, &s);
 		ahc_get_tran_settings(ahc, SIM_SCSI_ID(ahc, sim),
 				      SIM_CHANNEL(ahc, sim), &ccb->cts);
-		ahc_unlock(ahc, &s);
 		xpt_done(ccb);
 		break;
 	}
@@ -758,10 +755,8 @@
 	{
 		int  found;
 		
-		ahc_lock(ahc, &s);
 		found = ahc_reset_channel(ahc, SIM_CHANNEL(ahc, sim),
 					  /*initiate reset*/TRUE);
-		ahc_unlock(ahc, &s);
 		if (bootverbose) {
 			xpt_print_path(SIM_PATH(ahc, sim));
 			printf("SCSI bus reset delivered. "
@@ -909,7 +904,6 @@
 	case AC_LOST_DEVICE:
 	{
 		struct	ahc_devinfo devinfo;
-		long	s;
 
 		ahc_compile_devinfo(&devinfo, SIM_SCSI_ID(ahc, sim),
 				    xpt_path_target_id(path),
@@ -921,14 +915,12 @@
 		 * Revert to async/narrow transfers
 		 * for the next device.
 		 */
-		ahc_lock(ahc, &s);
 		ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
 			      AHC_TRANS_GOAL|AHC_TRANS_CUR, /*paused*/FALSE);
 		ahc_set_syncrate(ahc, &devinfo, /*syncrate*/NULL,
 				 /*period*/0, /*offset*/0, /*ppr_options*/0,
 				 AHC_TRANS_GOAL|AHC_TRANS_CUR,
 				 /*paused*/FALSE);
-		ahc_unlock(ahc, &s);
 		break;
 	}
 	default:
@@ -946,7 +938,6 @@
 	struct	ahc_initiator_tinfo *tinfo;
 	struct	ahc_tmode_tstate *tstate;
 	u_int	mask;
-	long	s;
 
 	scb = (struct scb *)arg;
 	ccb = scb->io_ctx;
@@ -959,9 +950,7 @@
 			aic_set_transaction_status(scb, CAM_REQ_CMP_ERR);
 		if (nsegments != 0)
 			bus_dmamap_unload(ahc->buffer_dmat, scb->dmamap);
-		ahc_lock(ahc, &s);
 		ahc_free_scb(ahc, scb);
-		ahc_unlock(ahc, &s);
 		xpt_done(ccb);
 		return;
 	}
@@ -1034,9 +1023,7 @@
 					    CAM_REQ_TOO_BIG);
 					bus_dmamap_unload(ahc->buffer_dmat,
 							  scb->dmamap);
-					ahc_lock(ahc, &s);
 					ahc_free_scb(ahc, scb);
-					ahc_unlock(ahc, &s);
 					xpt_done(ccb);
 					return;
 				}
@@ -1059,8 +1046,6 @@
 	
 	scb->sg_count = nsegments;
 
-	ahc_lock(ahc, &s);
-
 	/*
 	 * Last time we need to check if this SCB needs to
 	 * be aborted.
@@ -1069,7 +1054,6 @@
 		if (nsegments != 0)
 			bus_dmamap_unload(ahc->buffer_dmat, scb->dmamap);
 		ahc_free_scb(ahc, scb);
-		ahc_unlock(ahc, &s);
 		xpt_done(ccb);
 		return;
 	}
@@ -1120,7 +1104,6 @@
 		TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe);
 		scb->flags |= SCB_UNTAGGEDQ;
 		if (TAILQ_FIRST(untagged_q) != scb) {
-			ahc_unlock(ahc, &s);
 			return;
 		}
 	}
@@ -1142,8 +1125,6 @@
 	} else {
 		ahc_queue_scb(ahc, scb);
 	}
-
-	ahc_unlock(ahc, &s);
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703281802.l2SI2tOe012718>