Skip to contentSkip to conversation

m68k Atari SCSI fixes

PATCH Applied Michael Schmitz 6 participants 14 messages Mar 1, 2014 – May 2, 2014

Subsystems (2)
lore
Share & tools
lore

Michael Schmitz

author maintainer
#0 lore raw

cover m68k Atari SCSI fixes

All,

please review the following patches to the m68k Atari NCR5380 SCSI code.

The first patch is my corrected version of Arnd Bergmann's sleep_on removal RFC series (2/16), tested on my Atari Falcon. Geert, please take this one through the linux-m68k tree so Arnd's sleep_on remove can go ahead.

The second and third one are updates to the Atari NCR5380 drivers' error handling (return codes updated) and queue_command() function (return SCSI_MLQEUE_HOST_BUSY if the lock for the SCSI/DMA hardware cannot be safely taken). Again, tested on my Falcon. These will need Ack from the SCSI maintainers but could be taken through Geert's tree as well.

This patch series supersedes a previous one of mine, due to a botch-up mingling parts of patch 1 and 3. Apologies for spamming everyone again.

Please CC: me in on any replies, I am not subscribed to linux-scsi.

Thanks,

Michael Schmitz

[PATCH 1/3] m68k/atari - convert atari_scsi falcon_get_lock() to use wait_event() [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes [PATCH 3/3] m68k/atari - atari_scsi: punt if deadlocked

author maintainer
#1 lore raw

PATCH 1/3 m68k/atari - convert atari_scsi falcon_get_lock() to use wait_event()

sleep_on is known broken and going away. The atari_scsi driver is one of two remaining users in the falcon_get_lock() function, which is a rather crazy piece of code. This does not attempt to fix the driver's locking scheme in general, but at least prevents falcon_get_lock from going to sleep when no other thread holds the same lock or tries to get it, and we no longer schedule with irqs disabled.

MSch: fixed completion conditions missed in Arnds' original RFC patch.

---
 drivers/scsi/atari_scsi.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
drivers/scsi/atari_scsi.c +9 -3
index a3e6c8a..296c936 100644
@@ -90,6 +90,7 @@
 #include <linux/init.h>
 #include <linux/nvram.h>
 #include <linux/bitops.h>
+#include <linux/wait.h>
 
 #include <asm/setup.h>
 #include <asm/atarihw.h>
@@ -549,8 +550,10 @@ static void falcon_get_lock(void)
 
 	local_irq_save(flags);
 
-	while (!in_irq() && falcon_got_lock && stdma_others_waiting())
-		sleep_on(&falcon_fairness_wait);
+	wait_event_cmd(falcon_fairness_wait,
+		in_interrupt() || !falcon_got_lock || !stdma_others_waiting(),
+		local_irq_restore(flags),
+		local_irq_save(flags));
 
 	while (!falcon_got_lock) {
 		if (in_irq())
@@ -562,7 +565,10 @@ static void falcon_get_lock(void)
 			falcon_trying_lock = 0;
 			wake_up(&falcon_try_wait);
 		} else {
-			sleep_on(&falcon_try_wait);
+			wait_event_cmd(falcon_try_wait,
+				falcon_got_lock && !falcon_trying_lock,
+				local_irq_restore(flags),
+				local_irq_save(flags));
 		}
 	}
 
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH 1/3] m68k/atari - convert atari_scsi falcon_get_lock() to use wait_event()

Quoted 8 lines · Michael Schmitz

sleep_on is known broken and going away. The atari_scsi driver is one of two remaining users in the falcon_get_lock() function, which is a rather crazy piece of code. This does not attempt to fix the driver's locking scheme in general, but at least prevents falcon_get_lock from going to sleep when no other thread holds the same lock or tries to get it, and we no longer schedule with irqs disabled.

Quoted 7 lines

MSch: fixed completion conditions missed in Arnds' original RFC patch.

Thanks a lot for taking care of this so quickly!

A minor note about patch processing: The normal way to forward a patch from another person is to add your 'Signed-off-by:' line below the one from the original submitter, i.e. in the place where you have the 'Acked-by:'. Not sure if you just forgot to update your patch or you weren't aware of that. Geert will be able to fix that when he adds his own Signed-off-by line.

Also if you want to preserve authorship of the patch, you can add as the first line before the description a line 'From: Arnd Bergmann <[email protected]>'. Since you modified most the lines I originally changed and the patch is very small, I don't care about having me listed as the author, it's absolutely ok to have you listed here, just explaining it here in case you intended differently.

Arnd

#3 lore raw

Re: [PATCH 1/3] m68k/atari - convert atari_scsi falcon_get_lock() to use wait_event()

Arnd ,

Quoted 11 lines · Michael Schmitz
Quoted 10 lines

sleep_on is known broken and going away. The atari_scsi driver is one of two remaining users in the falcon_get_lock() function, which is a rather crazy piece of code. This does not attempt to fix the driver's locking scheme in general, but at least prevents falcon_get_lock from going to sleep when no other thread holds the same lock or tries to get it, and we no longer schedule with irqs disabled.

MSch: fixed completion conditions missed in Arnds' original RFC patch.

Quoted 9 lines
Quoted 6 lines

Thanks a lot for taking care of this so quickly!

No matter - if I don't do it right away, chances are it won't get done for weeks. Happens far too often.

Quoted 7 lines

A minor note about patch processing: The normal way to forward a patch from another person is to add your 'Signed-off-by:' line below the one from the original submitter, i.e. in the place where you have the 'Acked-by:'. Not sure if you just forgot to update your patch or you weren't aware of that. Geert will be able to fix that when he adds his own Signed-off-by line.

I wasn't aware really - thanks.

Quoted 7 lines

Also if you want to preserve authorship of the patch, you can add as the first line before the description a line 'From: Arnd Bergmann <[email protected]>'. Since you modified most the lines I originally changed and the patch is very small, I don't care about having me listed as the author, it's absolutely ok to have you listed here, just explaining it here in case you intended differently.

I think I'd prefer for you to retain ownership of the patch - by rights it belongs into your patch series and I just did the testing. I'm blissfully unaware of all the problems with locking and sleep_on vs. wait_event - as the general state of the Atari NCR5380 driver probably attests.

Can you fix that up in passing as well please, Geert?

Cheers,

Michael

#4 lore raw

Re: [PATCH 1/3] m68k/atari - convert atari_scsi falcon_get_lock() to use wait_event()

In reply to Michael Schmitz
Quoted 7 lines · Michael Schmitz

sleep_on is known broken and going away. The atari_scsi driver is one of two remaining users in the falcon_get_lock() function, which is a rather crazy piece of code. This does not attempt to fix the driver's locking scheme in general, but at least prevents falcon_get_lock from going to sleep when no other thread holds the same lock or tries to get it, and we no longer schedule with irqs disabled.

Quoted 7 lines

MSch: fixed completion conditions missed in Arnds' original RFC patch.

Thanks, applied with original authorship attribution, original subject matching SCSI oneline summary style, and proper SoB.

Will queue for 3.15.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#5 lore raw

PATCH 2/3 m68k/atari - atari_scsi: change abort/reset return codes

In reply to Michael Schmitz

The abort/reset lowlevel return codes had changed with the new error SCSI handling - update Atari NCR5380 driver to reflect this.

Change reset handling to clear queues only, do not attempt to call done() on each command aborted by the reset. The EH code should do that for us.
Queues _must_ be cleared, otherwise atari_scsi_bus_reset will not release the ST-DMA lock, deadlocking further error recovery.

Cc Geert Uytterhoeven <[email protected]>
Cc James E.J. Bottomley <[email protected]>
---
 drivers/scsi/atari_NCR5380.c |   29 ++++++++++++++++++-----------
 drivers/scsi/atari_scsi.c    |    2 +-
 2 files changed, 19 insertions(+), 12 deletions(-)
drivers/scsi/atari_NCR5380.c +18 -11
index 0f3cdbc..465e63d 100644
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		} else {
 /*			local_irq_restore(flags); */
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-			return SCSI_ABORT_ERROR;
+			return FAILED;
 		}
 	}
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			 * yet... */
 			tmp->scsi_done(tmp);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		}
 	}
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	if (hostdata->connected) {
 		local_irq_restore(flags);
 		ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-		return SCSI_ABORT_SNOOZE;
+		return FAILED;
 	}
 
 	/*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
 			if (NCR5380_select(instance, cmd, (int)cmd->tag))
-				return SCSI_ABORT_BUSY;
+				return FAILED;
 
 			ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
 					falcon_release_lock_if_possible(hostdata);
-					return SCSI_ABORT_SUCCESS;
+					return SUCCESS;
 				}
 			}
 		}
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 */
 	falcon_release_lock_if_possible(hostdata);
 
-	return SCSI_ABORT_NOT_RUNNING;
+	return FAILED;
 }
 
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
 	Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * through anymore ... */
 	(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be reset by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
 	/* XXX see below                                            XXX */
 
 	/* MSch: old-style reset: actually abort all command processing here */
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * the midlevel code that the reset was SUCCESSFUL, and there is no
 	 * need to 'wake up' the commands by a request_sense
 	 */
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #else /* 1 */
 
 	/* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required */
-	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/atari_scsi.c +1 -1
index 296c936..4ae0c1a 100644
@@ -827,7 +827,7 @@ static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
 	} else {
 		atari_turnon_irq(IRQ_MFP_FSCSI);
 	}
-	if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+	if (rv == SUCCESS)
 		falcon_release_lock_if_possible(hostdata);
 
 	return rv;
Signature · 1 line
1.7.0.4
#6 lore raw

Re: [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes

This is a larger version of Michael's patch. It takes care of the header files and comments and it addresses sun3_NCR5380 as well as atari_NCR5380. This means that the initio.h include (!) can be dropped from sun3_scsi.h.

---

Michael, I'm assuming that your patch hasn't been merged already (I didn't find it in any of the likely repos). Please go ahead and add your sign-off on this version if it is satisfactory. I didn't test this patch: I presume that sun3_NCR5380 would need the same abort/reset fixes that atari_NCR5380 needed...

drivers/scsi/atari_NCR5380.c +19 -12
index 0f3cdbc..e4aaf9a 100644
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		} else {
 /*			local_irq_restore(flags); */
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-			return SCSI_ABORT_ERROR;
+			return FAILED;
 		}
 	}
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			 * yet... */
 			tmp->scsi_done(tmp);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		}
 	}
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	if (hostdata->connected) {
 		local_irq_restore(flags);
 		ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-		return SCSI_ABORT_SNOOZE;
+		return FAILED;
 	}
 
 	/*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
 			if (NCR5380_select(instance, cmd, (int)cmd->tag))
-				return SCSI_ABORT_BUSY;
+				return FAILED;
 
 			ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
 					falcon_release_lock_if_possible(hostdata);
-					return SCSI_ABORT_SUCCESS;
+					return SUCCESS;
 				}
 			}
 		}
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 */
 	falcon_release_lock_if_possible(hostdata);
 
-	return SCSI_ABORT_NOT_RUNNING;
+	return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
 	Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * through anymore ... */
 	(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be reset by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
 	/* XXX see below                                            XXX */
 
 	/* MSch: old-style reset: actually abort all command processing here */
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * the midlevel code that the reset was SUCCESSFUL, and there is no
 	 * need to 'wake up' the commands by a request_sense
 	 */
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #else /* 1 */
 
 	/* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required */
-	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/atari_scsi.c +1 -1
index a3e6c8a..3ed39e5 100644
@@ -821,7 +821,7 @@ static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
 	} else {
 		atari_turnon_irq(IRQ_MFP_FSCSI);
 	}
-	if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+	if (rv == SUCCESS)
 		falcon_release_lock_if_possible(hostdata);
 
 	return rv;
drivers/scsi/atari_scsi.h +0 -26
index 11c624b..ae559f4 100644
@@ -54,32 +54,6 @@
 #define	NCR5380_dma_xfer_len(i,cmd,phase) \
 	atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS		0x01
-#define SCSI_RESET_ASYNCHRONOUS		0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 /* Debugging printk definitions:
  *
  *  ARB  -> arbitration
drivers/scsi/sun3_NCR5380.c +20 -13
index 636bbe0..455b1f0 100644
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
 	  local_irq_restore(flags);
 	  cmd->scsi_done(cmd);
-	  return SCSI_ABORT_SUCCESS;
+	  return SUCCESS;
 	} else {
 /*	  local_irq_restore(flags); */
 	  printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-	  return SCSI_ABORT_ERROR;
+	  return FAILED;
 	} 
    }
 #endif
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 	    /* Tagged queuing note: no tag to free here, hasn't been assigned
 	     * yet... */
 	    tmp->scsi_done(tmp);
-	    return SCSI_ABORT_SUCCESS;
+	    return SUCCESS;
 	}
 
 /* 
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     if (hostdata->connected) {
 	local_irq_restore(flags);
 	ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 
 /*
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 	    ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
   
             if (NCR5380_select (instance, cmd, (int) cmd->tag)) 
-		return SCSI_ABORT_BUSY;
+		return FAILED;
 
 	    ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
 		    local_irq_restore(flags);
 		    tmp->scsi_done(tmp);
-		    return SCSI_ABORT_SUCCESS;
+		    return SUCCESS;
 		}
 	}
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO); 
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
  * 
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */ 
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */
-      /* XXX see below                                            XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be reset by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* XXX see below                                            XXX */
 
     /* MSch: old-style reset: actually abort all command processing here */
 
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
      * the midlevel code that the reset was SUCCESSFUL, and there is no 
      * need to 'wake up' the commands by a request_sense
      */
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is required */
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
 
drivers/scsi/sun3_scsi.c +0 -1
index e2c009b..0cfa542 100644
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
#7 lore raw

Re: [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes

CC Sammy

Quoted 309 lines · Finn Thain

This is a larger version of Michael's patch. It takes care of the header files and comments and it addresses sun3_NCR5380 as well as atari_NCR5380. This means that the initio.h include (!) can be dropped from sun3_scsi.h.

---

Michael, I'm assuming that your patch hasn't been merged already (I didn't find it in any of the likely repos). Please go ahead and add your sign-off on this version if it is satisfactory. I didn't test this patch: I presume that sun3_NCR5380 would need the same abort/reset fixes that atari_NCR5380 needed...

drivers/scsi/atari_NCR5380.c +19 -12
index 0f3cdbc..e4aaf9a 100644
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                        local_irq_restore(flags);
                        cmd->scsi_done(cmd);
                        falcon_release_lock_if_possible(hostdata);
-                       return SCSI_ABORT_SUCCESS;
+                       return SUCCESS;
                } else {
 /*                     local_irq_restore(flags); */
                        printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-                       return SCSI_ABORT_ERROR;
+                       return FAILED;
                }
        }
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                         * yet... */
                        tmp->scsi_done(tmp);
                        falcon_release_lock_if_possible(hostdata);
-                       return SCSI_ABORT_SUCCESS;
+                       return SUCCESS;
                }
        }
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
        if (hostdata->connected) {
                local_irq_restore(flags);
                ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-               return SCSI_ABORT_SNOOZE;
+               return FAILED;
        }
 
        /*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                        ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
                        if (NCR5380_select(instance, cmd, (int)cmd->tag))
-                               return SCSI_ABORT_BUSY;
+                               return FAILED;
 
                        ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                                        local_irq_restore(flags);
                                        tmp->scsi_done(tmp);
                                        falcon_release_lock_if_possible(hostdata);
-                                       return SCSI_ABORT_SUCCESS;
+                                       return SUCCESS;
                                }
                        }
                }
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
         */
        falcon_release_lock_if_possible(hostdata);
 
-       return SCSI_ABORT_NOT_RUNNING;
+       return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
        SETUP_HOSTDATA(cmd->device->host);
        int i;
        unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
        Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
         * through anymore ... */
        (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1  /* XXX Should now be done by midlevel code, but it's broken XXX */
+       /* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+        * should go.
+        * Catch-22: if we don't clear all queues, the SCSI driver lock will
+        * not be reset by atari_scsi_reset()!
+        */
+
+#if defined(RESET_RUN_DONE)
+       /* XXX Should now be done by midlevel code, but it's broken XXX */
        /* XXX see below                                            XXX */
 
        /* MSch: old-style reset: actually abort all command processing here */
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
         * the midlevel code that the reset was SUCCESSFUL, and there is no
         * need to 'wake up' the commands by a request_sense
         */
-       return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+       return SUCCESS;
 #else /* 1 */
 
        /* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
        local_irq_restore(flags);
 
        /* we did no complete reset of all commands, so a wakeup is required */
-       return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+       return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/atari_scsi.c +1 -1
index a3e6c8a..3ed39e5 100644
@@ -821,7 +821,7 @@ static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
        } else {
                atari_turnon_irq(IRQ_MFP_FSCSI);
        }
-       if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+       if (rv == SUCCESS)
                falcon_release_lock_if_possible(hostdata);
 
        return rv;
drivers/scsi/atari_scsi.h +0 -26
index 11c624b..ae559f4 100644
@@ -54,32 +54,6 @@
 #define        NCR5380_dma_xfer_len(i,cmd,phase) \
        atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS         0x01
-#define SCSI_RESET_ASYNCHRONOUS                0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET   0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET  0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 /* Debugging printk definitions:
  *
  *  ARB  -> arbitration
drivers/scsi/sun3_NCR5380.c +20 -13
index 636bbe0..455b1f0 100644
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
          local_irq_restore(flags);
          cmd->scsi_done(cmd);
-         return SCSI_ABORT_SUCCESS;
+         return SUCCESS;
        } else {
 /*       local_irq_restore(flags); */
          printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-         return SCSI_ABORT_ERROR;
+         return FAILED;
        }
    }
 #endif
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
            /* Tagged queuing note: no tag to free here, hasn't been assigned
             * yet... */
            tmp->scsi_done(tmp);
-           return SCSI_ABORT_SUCCESS;
+           return SUCCESS;
        }
 
 /*
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     if (hostdata->connected) {
        local_irq_restore(flags);
        ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 
 /*
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
            ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
             if (NCR5380_select (instance, cmd, (int) cmd->tag))
-               return SCSI_ABORT_BUSY;
+               return FAILED;
 
            ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
                    local_irq_restore(flags);
                    tmp->scsi_done(tmp);
-                   return SCSI_ABORT_SUCCESS;
+                   return SUCCESS;
                }
        }
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO);
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */
-      /* XXX see below                                            XXX */
+       /* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+        * should go.
+        * Catch-22: if we don't clear all queues, the SCSI driver lock will
+        * not be reset by atari_scsi_reset()!
+        */
+
+#if defined(RESET_RUN_DONE)
+       /* XXX Should now be done by midlevel code, but it's broken XXX */
+       /* XXX see below                                            XXX */
 
     /* MSch: old-style reset: actually abort all command processing here */
 
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
      * the midlevel code that the reset was SUCCESSFUL, and there is no
      * need to 'wake up' the commands by a request_sense
      */
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is required */
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
 
drivers/scsi/sun3_scsi.c +0 -1
index e2c009b..0cfa542 100644
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
Signature · 10 lines
Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#8 lore raw

Re: [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes

Bugger - forgot to CC Sammy as well.

My only comment of substance is that the reset handling doesn't need to be done the same way as on Atari, as there's no special locking to account for.

Cheers,

Michael

Am 11.03.2014 um 21:28 schrieb Geert Uytterhoeven:

Quoted 366 lines

CC Sammy

Quoted 345 lines · Finn Thain

This is a larger version of Michael's patch. It takes care of the header files and comments and it addresses sun3_NCR5380 as well as atari_NCR5380. This means that the initio.h include (!) can be dropped from sun3_scsi.h.

---

Michael, I'm assuming that your patch hasn't been merged already (I didn't find it in any of the likely repos). Please go ahead and add your sign-off on this version if it is satisfactory. I didn't test this patch: I presume that sun3_NCR5380 would need the same abort/reset fixes that atari_NCR5380 needed...

drivers/scsi/atari_NCR5380.c +2 -2
index 0f3cdbc..e4aaf9a 100644
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                        local_irq_restore(flags);
                        cmd->scsi_done(cmd);
                        falcon_release_lock_if_possible(hostdata);
-                       return SCSI_ABORT_SUCCESS;
+                       return SUCCESS;
                } else {
 /*                     local_irq_restore(flags); */
                        printk("scsi%d: abort of connected command 
 failed!\n", HOSTNO);
-                       return SCSI_ABORT_ERROR;
+                       return FAILED;
                }
        }

#endif

drivers/scsi/atari_NCR5380.c +2 -2
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                         * yet... */
                        tmp->scsi_done(tmp);
                        falcon_release_lock_if_possible(hostdata);
-                       return SCSI_ABORT_SUCCESS;
+                       return SUCCESS;
                }
        }
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
        if (hostdata->connected) {
                local_irq_restore(flags);
                ABRT_PRINTK("scsi%d: abort failed, command 
 connected.\n", HOSTNO);
-               return SCSI_ABORT_SNOOZE;
+               return FAILED;
        }
 
        /*
drivers/scsi/atari_NCR5380.c +1 -1
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                        ABRT_PRINTK("scsi%d: aborting disconnected 
 command.\n", HOSTNO);
 
                        if (NCR5380_select(instance, cmd, 
 (int)cmd->tag))
-                               return SCSI_ABORT_BUSY;
+                               return FAILED;
 

ABRT_PRINTK("scsi%d: nexus reestablished.\n",
HOSTNO);

drivers/scsi/atari_NCR5380.c +1 -1
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
                                        local_irq_restore(flags);
                                        tmp->scsi_done(tmp);
 
 falcon_release_lock_if_possible(hostdata);
-                                       return SCSI_ABORT_SUCCESS;
+                                       return SUCCESS;
                                }
                        }
                }
drivers/scsi/atari_NCR5380.c +3 -4
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
         */
        falcon_release_lock_if_possible(hostdata);
 
-       return SCSI_ABORT_NOT_RUNNING;
+       return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
        SETUP_HOSTDATA(cmd->device->host);
        int i;
        unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
        Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
         * through anymore ... */
        (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1  /* XXX Should now be done by midlevel code, but it's broken 

XXX */
+ /* MSch 20140115 - looking at the generic NCR5380 driver, all
of this

drivers/scsi/atari_NCR5380.c +2 -0
+        * should go.
+        * Catch-22: if we don't clear all queues, the SCSI driver 

lock will

drivers/scsi/atari_NCR5380.c +5 -0
+        * not be reset by atari_scsi_reset()!
+        */
+
+#if defined(RESET_RUN_DONE)
+       /* XXX Should now be done by midlevel code, but it's broken 

XXX */

        /* XXX see below                                            

XXX */

        /* MSch: old-style reset: actually abort all command 

processing here */

drivers/scsi/atari_NCR5380.c +0 -0
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
         * the midlevel code that the reset was SUCCESSFUL, and there 

is no
* need to 'wake up' the commands by a request_sense */

drivers/scsi/atari_NCR5380.c +1 -1
-       return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+       return SUCCESS;
 #else /* 1 */
 
        /* MSch: new-style reset handling: let the mid-level do what 

it can */

drivers/scsi/atari_NCR5380.c +0 -0
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
        local_irq_restore(flags);
 
        /* we did no complete reset of all commands, so a wakeup is 

required */

drivers/scsi/atari_NCR5380.c +1 -1
-       return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+       return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/atari_scsi.c +1 -1
index a3e6c8a..3ed39e5 100644
@@ -821,7 +821,7 @@ static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
        } else {
                atari_turnon_irq(IRQ_MFP_FSCSI);
        }
-       if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+       if (rv == SUCCESS)
                falcon_release_lock_if_possible(hostdata);
 
        return rv;
drivers/scsi/atari_scsi.h +0 -26
index 11c624b..ae559f4 100644
@@ -54,32 +54,6 @@
 #define        NCR5380_dma_xfer_len(i,cmd,phase) \
        atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & 
 SR_IO) ? 0 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS         0x01
-#define SCSI_RESET_ASYNCHRONOUS                0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET   0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET  0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 /* Debugging printk definitions:
  *

* ARB -> arbitration

drivers/scsi/sun3_NCR5380.c +2 -2
index 636bbe0..455b1f0 100644
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmnd 
 *cmd)
 #endif
          local_irq_restore(flags);
          cmd->scsi_done(cmd);
-         return SCSI_ABORT_SUCCESS;
+         return SUCCESS;
        } else {
 /*       local_irq_restore(flags); */
          printk("scsi%d: abort of connected command failed!\n", 
 HOSTNO);
-         return SCSI_ABORT_ERROR;
+         return FAILED;
        }
    }

#endif

drivers/scsi/sun3_NCR5380.c +0 -0
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
            /* Tagged queuing note: no tag to free here, hasn't been 

assigned
* yet... */
tmp->scsi_done(tmp);

drivers/scsi/sun3_NCR5380.c +2 -2
-           return SCSI_ABORT_SUCCESS;
+           return SUCCESS;
        }
 
 /*
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     if (hostdata->connected) {
        local_irq_restore(flags);
        ABRT_PRINTK("scsi%d: abort failed, command connected.\n", 
 HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 

/*

drivers/scsi/sun3_NCR5380.c +5 -6
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
            ABRT_PRINTK("scsi%d: aborting disconnected command.\n", 
 HOSTNO);
 
             if (NCR5380_select (instance, cmd, (int) cmd->tag))
-               return SCSI_ABORT_BUSY;
+               return FAILED;
 
            ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
                    local_irq_restore(flags);
                    tmp->scsi_done(tmp);
-                   return SCSI_ABORT_SUCCESS;
+                   return SUCCESS;
                }
        }
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably 
 completed successfully before abortion\n", HOSTNO);
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken 

XXX */
- /* XXX see below
XXX */
+ /* MSch 20140115 - looking at the generic NCR5380 driver, all
of this

drivers/scsi/sun3_NCR5380.c +2 -0
+        * should go.
+        * Catch-22: if we don't clear all queues, the SCSI driver 

lock will

drivers/scsi/sun3_NCR5380.c +5 -0
+        * not be reset by atari_scsi_reset()!
+        */
+
+#if defined(RESET_RUN_DONE)
+       /* XXX Should now be done by midlevel code, but it's broken 

XXX */
+ /* XXX see below
XXX */

     /* MSch: old-style reset: actually abort all command processing 

here */

drivers/scsi/sun3_NCR5380.c +0 -0
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
      * the midlevel code that the reset was SUCCESSFUL, and there is 

no
* need to 'wake up' the commands by a request_sense */

drivers/scsi/sun3_NCR5380.c +1 -1
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it 

can */

drivers/scsi/sun3_NCR5380.c +0 -0
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is 

required */

drivers/scsi/sun3_NCR5380.c +1 -1
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/sun3_scsi.c +0 -1
index e2c009b..0cfa542 100644
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
Signature · 14 lines
Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

Re: [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes

This is a larger version of Michael's patch. It takes care of the header files and comments and it addresses sun3_NCR5380 as well as atari_NCR5380. This means that the initio.h include (!) can be dropped from sun3_scsi.h.

---

This version defines RESET_RUN_DONE in sun3_scsi.c, to avoid changing driver behaviour whilst trying to keep sun3_NCR5380.c in sync with atari_NCR5380.c (from which it was originally copied).

drivers/scsi/atari_NCR5380.c +19 -12
Index: linux-m68k/drivers/scsi/atari_NCR5380.c
===================================================================
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		} else {
 /*			local_irq_restore(flags); */
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-			return SCSI_ABORT_ERROR;
+			return FAILED;
 		}
 	}
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			 * yet... */
 			tmp->scsi_done(tmp);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		}
 	}
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	if (hostdata->connected) {
 		local_irq_restore(flags);
 		ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-		return SCSI_ABORT_SNOOZE;
+		return FAILED;
 	}
 
 	/*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
 			if (NCR5380_select(instance, cmd, (int)cmd->tag))
-				return SCSI_ABORT_BUSY;
+				return FAILED;
 
 			ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
 					falcon_release_lock_if_possible(hostdata);
-					return SCSI_ABORT_SUCCESS;
+					return SUCCESS;
 				}
 			}
 		}
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 */
 	falcon_release_lock_if_possible(hostdata);
 
-	return SCSI_ABORT_NOT_RUNNING;
+	return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
 	Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	 * through anymore ... */
 	(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be released by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
 	/* XXX see below                                            XXX */
 
 	/* MSch: old-style reset: actually abort all command processing here */
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	 * the midlevel code that the reset was SUCCESSFUL, and there is no
 	 * need to 'wake up' the commands by a request_sense
 	 */
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #else /* 1 */
 
 	/* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required */
-	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/atari_scsi.c +1 -1
Index: linux-m68k/drivers/scsi/atari_scsi.c
===================================================================
@@ -821,7 +821,7 @@ static int atari_scsi_bus_reset(Scsi_Cmn
 	} else {
 		atari_turnon_irq(IRQ_MFP_FSCSI);
 	}
-	if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+	if (rv == SUCCESS)
 		falcon_release_lock_if_possible(hostdata);
 
 	return rv;
drivers/scsi/atari_scsi.h +0 -26
Index: linux-m68k/drivers/scsi/atari_scsi.h
===================================================================
@@ -54,32 +54,6 @@
 #define	NCR5380_dma_xfer_len(i,cmd,phase) \
 	atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS		0x01
-#define SCSI_RESET_ASYNCHRONOUS		0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 /* Debugging printk definitions:
  *
  *  ARB  -> arbitration
drivers/scsi/sun3_NCR5380.c +20 -13
Index: linux-m68k/drivers/scsi/sun3_NCR5380.c
===================================================================
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmn
 #endif
 	  local_irq_restore(flags);
 	  cmd->scsi_done(cmd);
-	  return SCSI_ABORT_SUCCESS;
+	  return SUCCESS;
 	} else {
 /*	  local_irq_restore(flags); */
 	  printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-	  return SCSI_ABORT_ERROR;
+	  return FAILED;
 	} 
    }
 #endif
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmn
 	    /* Tagged queuing note: no tag to free here, hasn't been assigned
 	     * yet... */
 	    tmp->scsi_done(tmp);
-	    return SCSI_ABORT_SUCCESS;
+	    return SUCCESS;
 	}
 
 /* 
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmn
     if (hostdata->connected) {
 	local_irq_restore(flags);
 	ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 
 /*
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmn
 	    ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
   
             if (NCR5380_select (instance, cmd, (int) cmd->tag)) 
-		return SCSI_ABORT_BUSY;
+		return FAILED;
 
 	    ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmn
 #endif
 		    local_irq_restore(flags);
 		    tmp->scsi_done(tmp);
-		    return SCSI_ABORT_SUCCESS;
+		    return SUCCESS;
 		}
 	}
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmn
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO); 
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmn
  * 
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */ 
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */
-      /* XXX see below                                            XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be released by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* XXX see below                                            XXX */
 
     /* MSch: old-style reset: actually abort all command processing here */
 
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi
      * the midlevel code that the reset was SUCCESSFUL, and there is no 
      * need to 'wake up' the commands by a request_sense
      */
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is required */
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
 
drivers/scsi/sun3_scsi.c +2 -1
Index: linux-m68k/drivers/scsi/sun3_scsi.c
===================================================================
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
@@ -123,6 +122,8 @@ module_param(setup_hostid, int, 0);
 
 static struct scsi_cmnd *sun3_dma_setup_done = NULL;
 
+#define	RESET_RUN_DONE
+
 #define	AFTER_RESET_DELAY	(HZ/2)
 
 /* ms to wait after hitting dma regs */
Acked-by
#10 lore raw

Re: [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes

Quoted 316 lines · Finn Thain

This is a larger version of Michael's patch. It takes care of the header files and comments and it addresses sun3_NCR5380 as well as atari_NCR5380. This means that the initio.h include (!) can be dropped from sun3_scsi.h.

---

This version defines RESET_RUN_DONE in sun3_scsi.c, to avoid changing driver behaviour whilst trying to keep sun3_NCR5380.c in sync with atari_NCR5380.c (from which it was originally copied).

Index: linux-m68k/drivers/scsi/atari_NCR5380.c
===================================================================

drivers/scsi/atari_NCR5380.c +19 -12
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		} else {
 /*			local_irq_restore(flags); */
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-			return SCSI_ABORT_ERROR;
+			return FAILED;
 		}
 	}
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			 * yet... */
 			tmp->scsi_done(tmp);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		}
 	}
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	if (hostdata->connected) {
 		local_irq_restore(flags);
 		ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-		return SCSI_ABORT_SNOOZE;
+		return FAILED;
 	}
 
 	/*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
 			if (NCR5380_select(instance, cmd, (int)cmd->tag))
-				return SCSI_ABORT_BUSY;
+				return FAILED;
 
 			ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
 					falcon_release_lock_if_possible(hostdata);
-					return SCSI_ABORT_SUCCESS;
+					return SUCCESS;
 				}
 			}
 		}
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 */
 	falcon_release_lock_if_possible(hostdata);
 
-	return SCSI_ABORT_NOT_RUNNING;
+	return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
 	Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	 * through anymore ... */
 	(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be released by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
 	/* XXX see below                                            XXX */
 
 	/* MSch: old-style reset: actually abort all command processing here */
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	 * the midlevel code that the reset was SUCCESSFUL, and there is no
 	 * need to 'wake up' the commands by a request_sense
 	 */
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #else /* 1 */
 
 	/* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required */
-	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #endif /* 1 */
 }

Index: linux-m68k/drivers/scsi/atari_scsi.c
===================================================================

drivers/scsi/atari_scsi.c +1 -1
@@ -821,7 +821,7 @@ static int atari_scsi_bus_reset(Scsi_Cmn
 	} else {
 		atari_turnon_irq(IRQ_MFP_FSCSI);
 	}
-	if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+	if (rv == SUCCESS)
 		falcon_release_lock_if_possible(hostdata);
 
 	return rv;

Index: linux-m68k/drivers/scsi/atari_scsi.h
===================================================================

drivers/scsi/atari_scsi.h +0 -26
@@ -54,32 +54,6 @@
 #define	NCR5380_dma_xfer_len(i,cmd,phase) \
 	atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS		0x01
-#define SCSI_RESET_ASYNCHRONOUS		0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 /* Debugging printk definitions:
  *
  *  ARB  -> arbitration

Index: linux-m68k/drivers/scsi/sun3_NCR5380.c
===================================================================

drivers/scsi/sun3_NCR5380.c +20 -13
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmn
 #endif
 	  local_irq_restore(flags);
 	  cmd->scsi_done(cmd);
-	  return SCSI_ABORT_SUCCESS;
+	  return SUCCESS;
 	} else {
 /*	  local_irq_restore(flags); */
 	  printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-	  return SCSI_ABORT_ERROR;
+	  return FAILED;
 	} 
    }
 #endif
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmn
 	    /* Tagged queuing note: no tag to free here, hasn't been assigned
 	     * yet... */
 	    tmp->scsi_done(tmp);
-	    return SCSI_ABORT_SUCCESS;
+	    return SUCCESS;
 	}
 
 /* 
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmn
     if (hostdata->connected) {
 	local_irq_restore(flags);
 	ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 
 /*
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmn
 	    ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
             if (NCR5380_select (instance, cmd, (int) cmd->tag)) 
-		return SCSI_ABORT_BUSY;
+		return FAILED;
 
 	    ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmn
 #endif
 		    local_irq_restore(flags);
 		    tmp->scsi_done(tmp);
-		    return SCSI_ABORT_SUCCESS;
+		    return SUCCESS;
 		}
 	}
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmn
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO); 
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmn
  * 
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */ 
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */
-      /* XXX see below                                            XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be released by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* XXX see below                                            XXX */
 
     /* MSch: old-style reset: actually abort all command processing here */
 
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi
      * the midlevel code that the reset was SUCCESSFUL, and there is no 
      * need to 'wake up' the commands by a request_sense
      */
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is required */
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
 

Index: linux-m68k/drivers/scsi/sun3_scsi.c
===================================================================

drivers/scsi/sun3_scsi.c +2 -1
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
@@ -123,6 +122,8 @@ module_param(setup_hostid, int, 0);
 
 static struct scsi_cmnd *sun3_dma_setup_done = NULL;
 
+#define	RESET_RUN_DONE
+
 #define	AFTER_RESET_DELAY	(HZ/2)
 
 /* ms to wait after hitting dma regs */
author maintainer
#11 lore raw

Re: [PATCH 2/3] m68k/atari - atari_scsi: change abort/reset return codes

In reply to Finn Thain

Finn,

nothings' been merged yet, still pending review from the SCSI team. Comments below.

Quoted 98 lines

This is a larger version of Michael's patch. It takes care of the header files and comments and it addresses sun3_NCR5380 as well as atari_NCR5380. This means that the initio.h include (!) can be dropped from sun3_scsi.h.

---

Michael, I'm assuming that your patch hasn't been merged already (I didn't find it in any of the likely repos). Please go ahead and add your sign-off on this version if it is satisfactory. I didn't test this patch: I presume that sun3_NCR5380 would need the same abort/reset fixes that atari_NCR5380 needed...

drivers/scsi/atari_NCR5380.c +9 -9
index 0f3cdbc..e4aaf9a 100644
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		} else {
 /*			local_irq_restore(flags); */
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-			return SCSI_ABORT_ERROR;
+			return FAILED;
 		}
 	}
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			 * yet... */
 			tmp->scsi_done(tmp);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		}
 	}
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	if (hostdata->connected) {
 		local_irq_restore(flags);
 		ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-		return SCSI_ABORT_SNOOZE;
+		return FAILED;
 	}
 
 	/*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
 			if (NCR5380_select(instance, cmd, (int)cmd->tag))
-				return SCSI_ABORT_BUSY;
+				return FAILED;
 
 			ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
 					falcon_release_lock_if_possible(hostdata);
-					return SCSI_ABORT_SUCCESS;
+					return SUCCESS;
 				}
 			}
 		}
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 */
 	falcon_release_lock_if_possible(hostdata);
 
-	return SCSI_ABORT_NOT_RUNNING;
+	return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
 	Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 

drivers/scsi/atari_NCR5380.c static int NCR5380_bus_reset(Scsi_Cmnd *cmd) · line 2866

Quoted 9 lines
drivers/scsi/atari_NCR5380.c +4 -1
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * through anymore ... */
 	(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1	/* XXX Should now be done by midlevel code, but it's broken XXX 
 */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be reset by atari_scsi_reset()!

Bugger - typo of mine, meant to say 'released' not 'reset'.

Quoted 66 lines
drivers/scsi/atari_NCR5380.c +4 -0
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
 	/* XXX see below                                            XXX */
 

/* MSch: old-style reset: actually abort all command processing here
*/

drivers/scsi/atari_NCR5380.c +1 -1
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * the midlevel code that the reset was SUCCESSFUL, and there is no
 	 * need to 'wake up' the commands by a request_sense
 	 */
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #else /* 1 */
 
 	/* MSch: new-style reset handling: let the mid-level do what it can 

*/

drivers/scsi/atari_NCR5380.c +1 -1
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required 
 */
-	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #endif /* 1 */

}

drivers/scsi/atari_scsi.c +1 -1
index a3e6c8a..3ed39e5 100644
@@ -821,7 +821,7 @@ static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
 	} else {
 		atari_turnon_irq(IRQ_MFP_FSCSI);
 	}
-	if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+	if (rv == SUCCESS)
 		falcon_release_lock_if_possible(hostdata);
 
 	return rv;
drivers/scsi/atari_scsi.h +0 -17
index 11c624b..ae559f4 100644
@@ -54,32 +54,6 @@
 #define	NCR5380_dma_xfer_len(i,cmd,phase) \
 	atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 
 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-

drivers/scsi/atari_scsi.h line 58

Quoted 10 lines
drivers/scsi/atari_scsi.h +0 -9
-#define SCSI_RESET_SYNCHRONOUS		0x01
-#define SCSI_RESET_ASYNCHRONOUS		0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 

Thanks, I'd missed those.

Quoted 91 lines
drivers/scsi/atari_scsi.h +0 -0
 /* Debugging printk definitions:

*
* ARB -> arbitration

drivers/scsi/sun3_NCR5380.c +9 -9
index 636bbe0..455b1f0 100644
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
 	  local_irq_restore(flags);
 	  cmd->scsi_done(cmd);
-	  return SCSI_ABORT_SUCCESS;
+	  return SUCCESS;
 	} else {
 /*	  local_irq_restore(flags); */
 	  printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-	  return SCSI_ABORT_ERROR;
+	  return FAILED;
 	}
    }
 #endif
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 	    /* Tagged queuing note: no tag to free here, hasn't been assigned
 	     * yet... */
 	    tmp->scsi_done(tmp);
-	    return SCSI_ABORT_SUCCESS;
+	    return SUCCESS;
 	}
 
 /*
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     if (hostdata->connected) {
 	local_irq_restore(flags);
 	ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 
 /*
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 	    ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
             if (NCR5380_select (instance, cmd, (int) cmd->tag))
-		return SCSI_ABORT_BUSY;
+		return FAILED;
 
 	    ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
 		    local_irq_restore(flags);
 		    tmp->scsi_done(tmp);
-		    return SCSI_ABORT_SUCCESS;
+		    return SUCCESS;
 		}
 	}
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably 
 completed successfully before abortion\n", HOSTNO);
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );

drivers/scsi/sun3_NCR5380.c static int NCR5380_bus_reset(struct scsi_cmnd · line 2836

Quoted 10 lines
drivers/scsi/sun3_NCR5380.c +5 -2
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX 
 */
-      /* XXX see below                                            XXX 
 */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be reset by atari_scsi_reset()!
+	 */

That's not appropriate here - sun3 doesn't have dodgy locking across IDE, SCSI and floppy. The abort and reset should work much like in the Mac5380 driver. I.e. don't bother about clearing the queues, IIRC.

Cheers,

Michael

Quoted 47 lines
drivers/scsi/sun3_NCR5380.c +4 -0
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* XXX see below                                            XXX */
     /* MSch: old-style reset: actually abort all command processing 

here */

drivers/scsi/sun3_NCR5380.c +0 -0
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
      * the midlevel code that the reset was SUCCESSFUL, and there is 

no
* need to 'wake up' the commands by a request_sense */

drivers/scsi/sun3_NCR5380.c +1 -1
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it 

can */

drivers/scsi/sun3_NCR5380.c +0 -0
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd 
 *cmd)
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is 

required */

drivers/scsi/sun3_NCR5380.c +1 -1
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/sun3_scsi.c +0 -2
index e2c009b..0cfa542 100644
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
--

To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#12 lore raw

PATCH v2 1/1 m68k/atari - atari_scsi: change abort/reset return codes

In reply to Michael Schmitz

[Resend of earlier patch - added equivalent changes to sun3 NCR5380 code]

The abort/reset lowlevel return codes had changed with the new error SCSI handling - update Atari and Sun3 NCR5380 drivers to reflect this.

Change reset handling for Atari to clear queues only, do not attempt to call done() on each command aborted by the reset. The EH code should do that for us. Queues _must_ be cleared, otherwise atari_scsi_bus_reset will not release the ST-DMA lock, deadlocking further error recovery.

Update the Sun3 NCR5380 driver as well - the Sun3 driver was derived from the Atari one. Kudos to Finn Thain for the Sun3 part and cleaning up the header files. After the header cleanup, the initio.h include (!) can be dropped from sun3_scsi.h now.

---
 drivers/scsi/atari_NCR5380.c |   31 +++++++++++++++++++------------
 drivers/scsi/atari_scsi.c    |    2 +-
 drivers/scsi/atari_scsi.h    |   26 --------------------------
 drivers/scsi/sun3_NCR5380.c  |   33 ++++++++++++++++++++-------------
 drivers/scsi/sun3_scsi.c     |    3 ++-
 5 files changed, 42 insertions(+), 53 deletions(-)
drivers/scsi/atari_NCR5380.c +19 -12
index 0f3cdbc..e4aaf9a 100644
@@ -2683,11 +2683,11 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		} else {
 /*			local_irq_restore(flags); */
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-			return SCSI_ABORT_ERROR;
+			return FAILED;
 		}
 	}
 #endif
@@ -2711,7 +2711,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			 * yet... */
 			tmp->scsi_done(tmp);
 			falcon_release_lock_if_possible(hostdata);
-			return SCSI_ABORT_SUCCESS;
+			return SUCCESS;
 		}
 	}
 
@@ -2729,7 +2729,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	if (hostdata->connected) {
 		local_irq_restore(flags);
 		ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-		return SCSI_ABORT_SNOOZE;
+		return FAILED;
 	}
 
 	/*
@@ -2764,7 +2764,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
 
 			if (NCR5380_select(instance, cmd, (int)cmd->tag))
-				return SCSI_ABORT_BUSY;
+				return FAILED;
 
 			ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2791,7 +2791,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
 					falcon_release_lock_if_possible(hostdata);
-					return SCSI_ABORT_SUCCESS;
+					return SUCCESS;
 				}
 			}
 		}
@@ -2816,7 +2816,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 */
 	falcon_release_lock_if_possible(hostdata);
 
-	return SCSI_ABORT_NOT_RUNNING;
+	return FAILED;
 }
 
 
@@ -2825,7 +2825,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */
 
@@ -2834,7 +2834,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
 	Scsi_Cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2859,7 +2859,14 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * through anymore ... */
 	(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-#if 1	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be reset by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
 	/* XXX see below                                            XXX */
 
 	/* MSch: old-style reset: actually abort all command processing here */
@@ -2915,7 +2922,7 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	 * the midlevel code that the reset was SUCCESSFUL, and there is no
 	 * need to 'wake up' the commands by a request_sense
 	 */
-	return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #else /* 1 */
 
 	/* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2963,6 +2970,6 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required */
-	return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+	return SUCCESS;
 #endif /* 1 */
 }
drivers/scsi/atari_scsi.c +1 -1
index 296c936..4ae0c1a 100644
@@ -827,7 +827,7 @@ static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
 	} else {
 		atari_turnon_irq(IRQ_MFP_FSCSI);
 	}
-	if ((rv & SCSI_RESET_ACTION) == SCSI_RESET_SUCCESS)
+	if (rv == SUCCESS)
 		falcon_release_lock_if_possible(hostdata);
 
 	return rv;
drivers/scsi/atari_scsi.h +0 -26
index 11c624b..ae559f4 100644
@@ -54,32 +54,6 @@
 #define	NCR5380_dma_xfer_len(i,cmd,phase) \
 	atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
 
-/* former generic SCSI error handling stuff */
-
-#define SCSI_ABORT_SNOOZE 0
-#define SCSI_ABORT_SUCCESS 1
-#define SCSI_ABORT_PENDING 2
-#define SCSI_ABORT_BUSY 3
-#define SCSI_ABORT_NOT_RUNNING 4
-#define SCSI_ABORT_ERROR 5
-
-#define SCSI_RESET_SNOOZE 0
-#define SCSI_RESET_PUNT 1
-#define SCSI_RESET_SUCCESS 2
-#define SCSI_RESET_PENDING 3
-#define SCSI_RESET_WAKEUP 4
-#define SCSI_RESET_NOT_RUNNING 5
-#define SCSI_RESET_ERROR 6
-
-#define SCSI_RESET_SYNCHRONOUS		0x01
-#define SCSI_RESET_ASYNCHRONOUS		0x02
-#define SCSI_RESET_SUGGEST_BUS_RESET	0x04
-#define SCSI_RESET_SUGGEST_HOST_RESET	0x08
-
-#define SCSI_RESET_BUS_RESET 0x100
-#define SCSI_RESET_HOST_RESET 0x200
-#define SCSI_RESET_ACTION   0xff
-
 /* Debugging printk definitions:
  *
  *  ARB  -> arbitration
drivers/scsi/sun3_NCR5380.c +20 -13
index 636bbe0..72550bd 100644
@@ -2664,11 +2664,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
 	  local_irq_restore(flags);
 	  cmd->scsi_done(cmd);
-	  return SCSI_ABORT_SUCCESS;
+	  return SUCCESS;
 	} else {
 /*	  local_irq_restore(flags); */
 	  printk("scsi%d: abort of connected command failed!\n", HOSTNO);
-	  return SCSI_ABORT_ERROR;
+	  return FAILED;
 	} 
    }
 #endif
@@ -2691,7 +2691,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 	    /* Tagged queuing note: no tag to free here, hasn't been assigned
 	     * yet... */
 	    tmp->scsi_done(tmp);
-	    return SCSI_ABORT_SUCCESS;
+	    return SUCCESS;
 	}
 
 /* 
@@ -2708,7 +2708,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     if (hostdata->connected) {
 	local_irq_restore(flags);
 	ABRT_PRINTK("scsi%d: abort failed, command connected.\n", HOSTNO);
-        return SCSI_ABORT_SNOOZE;
+        return FAILED;
     }
 
 /*
@@ -2743,7 +2743,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 	    ABRT_PRINTK("scsi%d: aborting disconnected command.\n", HOSTNO);
   
             if (NCR5380_select (instance, cmd, (int) cmd->tag)) 
-		return SCSI_ABORT_BUSY;
+		return FAILED;
 
 	    ABRT_PRINTK("scsi%d: nexus reestablished.\n", HOSTNO);
 
@@ -2769,7 +2769,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
 #endif
 		    local_irq_restore(flags);
 		    tmp->scsi_done(tmp);
-		    return SCSI_ABORT_SUCCESS;
+		    return SUCCESS;
 		}
 	}
 
@@ -2786,7 +2786,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
     printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO); 
 
-    return SCSI_ABORT_NOT_RUNNING;
+    return FAILED;
 }
 
 
@@ -2795,7 +2795,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
  * 
  * Purpose : reset the SCSI bus.
  *
- * Returns : SCSI_RESET_WAKEUP
+ * Returns : SUCCESS or FAILURE
  *
  */ 
 
@@ -2804,7 +2804,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
     SETUP_HOSTDATA(cmd->device->host);
     int           i;
     unsigned long flags;
-#if 1
+#if defined(RESET_RUN_DONE)
     struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
@@ -2826,8 +2826,15 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
      * through anymore ... */
     (void)NCR5380_read( RESET_PARITY_INTERRUPT_REG );
 
-#if 1 /* XXX Should now be done by midlevel code, but it's broken XXX */
-      /* XXX see below                                            XXX */
+	/* MSch 20140115 - looking at the generic NCR5380 driver, all of this
+	 * should go.
+	 * Catch-22: if we don't clear all queues, the SCSI driver lock will
+	 * not be released by atari_scsi_reset()!
+	 */
+
+#if defined(RESET_RUN_DONE)
+	/* XXX Should now be done by midlevel code, but it's broken XXX */
+	/* XXX see below                                            XXX */
 
     /* MSch: old-style reset: actually abort all command processing here */
 
@@ -2876,7 +2883,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
      * the midlevel code that the reset was SUCCESSFUL, and there is no 
      * need to 'wake up' the commands by a request_sense
      */
-    return SCSI_RESET_SUCCESS | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #else /* 1 */
 
     /* MSch: new-style reset handling: let the mid-level do what it can */
@@ -2924,7 +2931,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
     local_irq_restore(flags);
 
     /* we did no complete reset of all commands, so a wakeup is required */
-    return SCSI_RESET_WAKEUP | SCSI_RESET_BUS_RESET;
+    return SUCCESS;
 #endif /* 1 */
 }
 
drivers/scsi/sun3_scsi.c +2 -1
index e2c009b..243c228 100644
@@ -79,7 +79,6 @@
 #define REAL_DMA
 
 #include "scsi.h"
-#include "initio.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 
@@ -123,6 +122,8 @@ module_param(setup_hostid, int, 0);
 
 static struct scsi_cmnd *sun3_dma_setup_done = NULL;
 
+#define	RESET_RUN_DONE
+
 #define	AFTER_RESET_DELAY	(HZ/2)
 
 /* ms to wait after hitting dma regs */
Signature · 1 line
1.7.0.4
author maintainer
#13 lore raw

PATCH 3/3 m68k/atari - atari_scsi: punt if deadlocked

In reply to Michael Schmitz

In case a SCSI command is queued from softirq context, and another driver currently holds the ST-DMA lock, tell the SCSI midlevel to hold off queueing commands for now. Midlevel will resume play later.

Cc Geert Uytterhoeven <[email protected]>
Cc James E.J. Bottomley <[email protected]>
---
 drivers/scsi/atari_NCR5380.c |   12 +++++++++---
 drivers/scsi/atari_scsi.c    |   24 ++++++++++++++++++++----
 2 files changed, 29 insertions(+), 7 deletions(-)
drivers/scsi/atari_NCR5380.c +9 -3
index 465e63d..90a90e8 100644
@@ -967,9 +967,15 @@ static int NCR5380_queue_command_lck(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
 	 * alter queues and touch the lock.
 	 */
 	if (!IS_A_TT()) {
-		/* perhaps stop command timer here */
-		falcon_get_lock();
-		/* perhaps restart command timer here */
+		/* MSch 20140119: check whether obtaining the ST-DMA lock did
+		 * succeed.
+		 * If the lock could not be acquired without risking to
+		 * deadlock, i.e. from softirq context with ST-DMA currently
+		 * otherwise locked, defer queueing further commands.
+		 */
+		if (falcon_get_lock()) {
+			return SCSI_MLQUEUE_HOST_BUSY;
+		}
 	}
 	if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
 		LIST(cmd, hostdata->issue_queue);
drivers/scsi/atari_scsi.c +20 -4
index 4ae0c1a..30c7385 100644
@@ -197,7 +197,7 @@ static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
 static irqreturn_t scsi_tt_intr(int irq, void *dummy);
 static irqreturn_t scsi_falcon_intr(int irq, void *dummy);
 static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata);
-static void falcon_get_lock(void);
+static int falcon_get_lock(void);
 #ifdef CONFIG_ATARI_SCSI_RESET_BOOT
 static void atari_scsi_reset_boot(void);
 #endif
@@ -541,12 +541,12 @@ static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata)
  * Complicated, complicated.... Sigh...
  */
 
-static void falcon_get_lock(void)
+static int falcon_get_lock(void)
 {
 	unsigned long flags;
 
 	if (IS_A_TT())
-		return;
+		return 0;
 
 	local_irq_save(flags);
 
@@ -557,8 +557,23 @@ static void falcon_get_lock(void)
 
 	while (!falcon_got_lock) {
 		if (in_irq())
-			panic("Falcon SCSI hasn't ST-DMA lock in interrupt");
+			panic("Falcon SCSI hasn't got ST-DMA lock in irq");
 		if (!falcon_trying_lock) {
+			if (in_interrupt()) {
+				if (stdma_islocked()) {
+					/* MSch 20140119: problem -
+					 * cannot schedule in interrupt!
+					 * Unless stdma_lock can be modified
+					 * to interruptible wait, this will
+					 * be needed to avoid deadlocking here!
+					 * Return error to indicate command
+					 * queueing would deadlock, and allow
+					 * queue_command() to stall queueing.
+					 */
+					local_irq_restore(flags);
+					return 1;
+				}
+			}
 			falcon_trying_lock = 1;
 			stdma_lock(scsi_falcon_intr, NULL);
 			falcon_got_lock = 1;
@@ -575,6 +590,7 @@ static void falcon_get_lock(void)
 	local_irq_restore(flags);
 	if (!falcon_got_lock)
 		panic("Falcon SCSI: someone stole the lock :-(\n");
+	return 0;
 }
 
 
Signature · 1 line
1.7.0.4