Skip to contentSkip to conversation

Sync up drivers/scsi/aic7xxx

PATCH In review Luben Tuikov 1 participant 1 message Sep 28, 2004 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 6/28 Sync up drivers/scsi/aic7xxx

Sync up drivers/scsi/aic7xxx/. (2285-2294)

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#175 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_osm.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_osm.c renamed from tmp/tmp.26292.0 +85 -9
@@ -1,7 +1,7 @@
 /*
  * Adaptec AIC79xx device driver for Linux.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#175 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#178 $
  *
  * --------------------------------------------------------------------------
  * Copyright (c) 1994-2000 Justin T. Gibbs.
@@ -62,6 +62,16 @@
 
 #include <linux/mm.h>		/* For fetching system memory size */
 
+/************************* Magic SysReq Support *******************************/
+static struct aic_sysrq_key_op ahd_sysrq_op =
+{
+	aic_sysrq_handler,
+	"aic79xxstatedump",
+	"Dump aic79xx controller information to Console"
+};
+
+static int ahd_sysrq_key;
+
 /*
  * Lock protecting manipulation of the ahd softc list.
  */
@@ -871,7 +881,7 @@
 	siginitsetinv(&current->blocked, 0);
 
 	daemonize();
-	sprintf(current->comm, "ahd_dv_%d", ahd->unit);
+	sprintf(current->comm, "ahd_recovery_%d", ahd->unit);
 #else
 	daemonize("ahd_recovery_%d", ahd->unit);
 #endif
@@ -927,6 +937,10 @@
 {
 	ahd->platform_data->recovery_pid =
 	    kernel_thread(ahd_linux_recovery_thread, ahd, 0);
+	
+	if (ahd->platform_data->recovery_pid < 0)
+		return (-ahd->platform_data->recovery_pid);
+
 	return (0);
 }
 
@@ -1019,12 +1033,42 @@
 		ahd = scb->ahd_softc;
 		ahd_lock(ahd, &s);
 
-		/*
-		 * Skip timeouts that fire just after
-		 * they have been cancelled.
-		 */
-		if ((scb->platform_data->flags & AHD_TIMEOUT_ACTIVE) != 0) {
+		if (scb == NULL
+		 || scb->flags == SCB_FLAG_NONE) {
+			int done_late;
+
+			/*
+			 * Handle timeout/completion races.
+			 * If the command is still sitting on
+			 * our completion queue, just re-instate
+			 * the timeout.  If we've already completed
+			 * the command, done_late will be set and
+			 * we will need to additionally complete it
+			 * again to the mid-layer.
+			 *
+			 * Since done_late is cleared by adding a
+			 * timer, we must save off its value first.
+			 */
+			done_late = cmd->done_late;
+			scsi_add_timer(cmd, 60*HZ, ahd_linux_midlayer_timeout);
+			if (done_late)
+				cmd->scsi_done(cmd);
+		} else if ((scb->platform_data->flags & AHD_TIMEOUT_ACTIVE)) {
+
+			/*
+			 * Handle the case of timeouts that expire just
+			 * as we delete timers during recovery by skipping
+			 * SCBs that don't have timers active.
+			 */
 			scb->platform_data->flags &= ~AHD_TIMEOUT_ACTIVE;
+
+			/*
+			 * We must clear out the function pointer so that
+			 * scsi_add_timer does not believe that a del_timer
+			 * is required before setting up a new timer for
+			 * this command.
+			 */
+			scb->io_ctx->eh_timeout.function = NULL;
 			ahd_timeout(scb);
 		}
 		ahd_unlock(ahd, &s);
@@ -1034,6 +1078,10 @@
 void
 ahd_linux_midlayer_timeout(struct scsi_cmnd *cmd)
 {
+	struct ahd_softc *ahd;
+
+	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+	printf("%s: ahd_midlayer_timeout\n", ahd_name(ahd));
 }
 /********************** Host Template Entry Points ****************************/
 /*
@@ -2351,13 +2399,20 @@
 	ahd_linux_setup_user_rd_strm_settings(ahd);
 	ahd_linux_initialize_scsi_bus(ahd);
 	ahd_unlock(ahd, &s);
+	ahd_sysrq_key = aic_install_sysrq(&ahd_sysrq_op);
+	ahd_spawn_recovery_thread(ahd);
+	if (ahd->platform_data->recovery_pid < 0) {
+		printf("%s: Failed to create recovery thread, error= %d\n",
+		       ahd_name(ahd), ahd->platform_data->recovery_pid);
+		return (-ahd->platform_data->recovery_pid);
+	}
 	ahd->platform_data->dv_pid = kernel_thread(ahd_linux_dv_thread, ahd, 0);
-	ahd_lock(ahd, &s);
 	if (ahd->platform_data->dv_pid < 0) {
 		printf("%s: Failed to create DV thread, error= %d\n",
 		       ahd_name(ahd), ahd->platform_data->dv_pid);
 		return (-ahd->platform_data->dv_pid);
 	}
+	ahd_lock(ahd, &s);
 	/*
 	 * Initially allocate *all* of our linux target objects
 	 * so that the DV thread will scan them all in parallel
@@ -2521,6 +2576,7 @@
 	struct ahd_linux_device *dev;
 	int i, j;
 
+	aic_remove_sysrq(ahd_sysrq_key, &ahd_sysrq_op);
 	if (ahd->platform_data != NULL) {
 		del_timer_sync(&ahd->platform_data->completeq_timer);
 		ahd_linux_kill_dv_thread(ahd);
@@ -5102,7 +5158,17 @@
 			new_status = DID_PARITY;
 			break;
 		case CAM_CMD_TIMEOUT:
-			new_status = DID_TIME_OUT;
+			/*
+			 *  Returning DID_TIME_OUT will
+			 *  wake up the error recovery
+			 *  thread instead of doing the
+			 *  command retry we desire. Since
+			 *  we have already recovered the
+			 *  command, returning DID_ERROR
+			 *  will cause a retry up to the
+			 *  retry limit for this command.
+			 */
+			new_status = DID_ERROR;
 			break;
 		case CAM_UA_ABORT:
 		case CAM_REQ_CMP_ERR:
@@ -5334,12 +5400,22 @@
 void
 ahd_platform_dump_card_state(struct ahd_softc *ahd)
 {
+	struct Scsi_Host *host;
 	struct ahd_linux_device *dev;
 	int target;
 	int maxtarget;
 	int lun;
 	int i;
 
+	host = ahd->platform_data->host;
+	printf("%s: Host Status: %s%s%s%s%s\n",
+	       ahd_name(ahd),
+	       host->eh_active ? "eh_active " : "",
+	       host->in_recovery ? "in_recovery " : "",
+	       host->host_blocked ? "host_blocked " : "",
+	       host->host_self_blocked ? "host_self_blocked " : "",
+	       host->some_device_starved ? "some_device_starved" : "");
+	
 	maxtarget = (ahd->features & AHD_WIDE) ? 15 : 7;
 	for (target = 0; target <=maxtarget; target++) {
 

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#140 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_osm.h ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_osm.h renamed from tmp/tmp.26292.1 +12 -69

122 lines not on this page · raw message

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm_pci.c#25 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_osm_pci.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_osm_pci.c renamed from tmp/tmp.26292.2 +7 -40

61 lines not on this page · raw message

==== //depot/aic7xxx/aic7xxx/aic79xx_pci.c#78 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_pci.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic79xx_pci.c renamed from tmp/tmp.26292.3 +2 -2
@@ -38,7 +38,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#78 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#79 $
  *
  * $FreeBSD$
  */
@@ -340,7 +340,7 @@
 	}
 	ahd->bus_description = pci_bus_modes[PCI_BUS_MODES_INDEX(devconfig)];
 
-	ahd_power_state_change(ahd, AHD_POWER_STATE_D0);
+	ahd_power_state_change(ahd, AIC_POWER_STATE_D0);
 
 	error = ahd_pci_map_registers(ahd);
 	if (error != 0)

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#238 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_osm.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_osm.c renamed from tmp/tmp.26292.4 +85 -9

167 lines not on this page · raw message

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#153 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_osm.h ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_osm.h renamed from tmp/tmp.26292.5 +12 -52

106 lines not on this page · raw message

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c#47 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c renamed from tmp/tmp.26292.6 +7 -40

60 lines not on this page · raw message

==== //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#70 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_pci.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aic7xxx_pci.c renamed from tmp/tmp.26292.7 +3 -3
@@ -39,7 +39,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#70 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#71 $
  *
  * $FreeBSD$
  */
@@ -798,7 +798,7 @@
 	ahc->chip |= AHC_PCI;
 	ahc->description = entry->name;
 
-	ahc_power_state_change(ahc, AHC_POWER_STATE_D0);
+	ahc_power_state_change(ahc, AIC_POWER_STATE_D0);
 
 	error = ahc_pci_map_registers(ahc);
 	if (error != 0)
@@ -2095,7 +2095,7 @@
 ahc_pci_resume(struct ahc_softc *ahc)
 {
 
-	ahc_power_state_change(ahc, AHC_POWER_STATE_D0);
+	ahc_power_state_change(ahc, AIC_POWER_STATE_D0);
 
 	/*
 	 * We assume that the OS has restored our register

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.c#9 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aiclib.c ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aiclib.c renamed from tmp/tmp.26292.8 +8 -2
@@ -1417,6 +1417,7 @@
 aic_sysrq_handler(int key, struct pt_regs *unused, struct kbd_struct *unused1,
 		  struct tty_struct *unused2)
 {
+#ifdef CONFIG_MAGIC_SYSRQ
 	struct aic_softc *aic;
 	u_long l;
 
@@ -1430,11 +1431,13 @@
 		aic_unlock(aic, &s);
 	}
 	aic_list_unlock(&l);
+#endif
 }
 
 int
-aic_install_sysrq(struct sysrq_key_op *key_op)
+aic_install_sysrq(struct aic_sysrq_key_op *key_op)
 {
+#ifdef CONFIG_MAGIC_SYSRQ
 	char *str;
 	int len;
 	int i;
@@ -1452,12 +1455,15 @@
 			return (key);
 		}
 	}
+#endif
 	return (0);
 }
 
 void
-aic_remove_sysrq(int key, struct sysrq_key_op *key_op)
+aic_remove_sysrq(int key, struct aic_sysrq_key_op *key_op)
 {
+#ifdef CONFIG_MAGIC_SYSRQ
 	unregister_sysrq_key(key, key_op);
+#endif
 }
 

==== //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aiclib.h#11 - /home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aiclib.h ====

home/luben/projects/linux/2.6/linux-2.5/drivers/scsi/aic7xxx/aiclib.h renamed from tmp/tmp.26292.9 +82 -2

114 lines not on this page · raw message