All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 00/20] scsi logging update
@ 2014-09-03 10:05 Hannes Reinecke
  2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
                   ` (20 more replies)
  0 siblings, 21 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Hi all,

here's the second version of my scsi logging updates.
Main feature is the update to have all logging
statements in one line so that they won't be broken
up even under high load.
This will dramatically improve debugging.

Additionally all printk() statements are moved
to dev_printk() variants to ensure proper device
tagging and keep the systemd journal happy.

To achieve this I had to use a on-stack
buffer for formatting opcodes and sense codes;
so the stack usage will increase somewhat.

This is the second iteration; in this I've included
the reviews from Christoph Hellwig and Robert Elliot.

Reviews, comments etc are welcome.

Hannes Reinecke (20):
  Remove scsi_cmd_print_sense_hdr()
  aha152x: Debug output update and whitespace cleanup
  sd: Remove scsi_print_sense() in sd_done()
  scsi: introduce sdev_prefix_printk()
  scsi: Use sdev as argument for sense code printing
  scsi: stop decoding if scsi_normalize_sense() fails
  scsi: do not decode sense extras
  scsi: use 'bool' as return value for scsi_normalize_sense()
  scsi: remove scsi_print_status()
  Implement scsi_opcode_sa_name
  scsi: Use scsi_print_command() where possible
  scsi: merge print_opcode_name()
  scsi: consolidate opcode lookup in scsi_opcode_sa_name()
  scsi: use local buffer for printing CDB
  libata: use __scsi_print_command()
  scsi: separate out scsi_retval_string()
  scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte()
  scsi: remove scsi_show_result()
  sd: Reduce logging output
  scsi_error: format abort error message

 drivers/ata/libata-eh.c      |  12 +-
 drivers/scsi/53c700.c        |   2 +-
 drivers/scsi/aha152x.c       | 950 ++++++++++---------------------------------
 drivers/scsi/arm/acornscsi.c |   9 +-
 drivers/scsi/arm/fas216.c    |  30 +-
 drivers/scsi/ch.c            |   7 +-
 drivers/scsi/constants.c     | 620 ++++++++++++----------------
 drivers/scsi/osst.c          |   8 +-
 drivers/scsi/scsi.c          |  36 +-
 drivers/scsi/scsi_error.c    |  20 +-
 drivers/scsi/scsi_ioctl.c    |   2 +-
 drivers/scsi/scsi_lib.c      |   6 +-
 drivers/scsi/sd.c            |  85 ++--
 drivers/scsi/sg.c            |   2 +-
 drivers/scsi/sr_ioctl.c      |  15 +-
 drivers/scsi/st.c            |   6 +-
 drivers/scsi/storvsc_drv.c   |   3 +-
 include/scsi/scsi_dbg.h      |  26 +-
 include/scsi/scsi_device.h   |   9 +
 include/scsi/scsi_eh.h       |  12 +-
 20 files changed, 621 insertions(+), 1239 deletions(-)

-- 
1.8.5.2


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH 01/20] Remove scsi_cmd_print_sense_hdr()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
@ 2014-09-03 10:05 ` Hannes Reinecke
  2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Unused.

Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 14 --------------
 include/scsi/scsi_dbg.h  |  2 --
 2 files changed, 16 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index d35a5d6..2f44707 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1428,20 +1428,6 @@ scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
 }
 EXPORT_SYMBOL(scsi_print_sense_hdr);
 
-/*
- * Print normalized SCSI sense header with device information and a prefix.
- */
-void
-scsi_cmd_print_sense_hdr(struct scsi_cmnd *scmd, const char *desc,
-			  struct scsi_sense_hdr *sshdr)
-{
-	scmd_printk(KERN_INFO, scmd, "%s: ", desc);
-	scsi_show_sense_hdr(sshdr);
-	scmd_printk(KERN_INFO, scmd, "%s: ", desc);
-	scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
-}
-EXPORT_SYMBOL(scsi_cmd_print_sense_hdr);
-
 static void
 scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
 		       struct scsi_sense_hdr *sshdr)
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index e89844c..5a43a4c 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -9,8 +9,6 @@ extern void __scsi_print_command(unsigned char *);
 extern void scsi_show_extd_sense(unsigned char, unsigned char);
 extern void scsi_show_sense_hdr(struct scsi_sense_hdr *);
 extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
-extern void scsi_cmd_print_sense_hdr(struct scsi_cmnd *, const char *,
-				     struct scsi_sense_hdr *);
 extern void scsi_print_sense(char *, struct scsi_cmnd *);
 extern void __scsi_print_sense(const char *name,
 			       const unsigned char *sense_buffer,
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 02/20] aha152x: Debug output update and whitespace cleanup
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
  2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
@ 2014-09-03 10:05 ` Hannes Reinecke
  2014-09-06  0:02   ` Christoph Hellwig
  2014-09-03 10:05 ` [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
                   ` (18 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Remove all uncommented debugging code and move all
printk() statements over to dev_printk().
And while we're at it we should be doing a whitespace
cleanup, too.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/aha152x.c | 944 +++++++++++--------------------------------------
 1 file changed, 205 insertions(+), 739 deletions(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index e77b72f..447568a 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -230,7 +230,7 @@
  *
  *
  **************************************************************************
- 
+
  see Documentation/scsi/aha152x.txt for configuration details
 
  **************************************************************************/
@@ -279,45 +279,11 @@ static LIST_HEAD(aha152x_host_list);
 #error define AUTOCONF or SETUP0
 #endif
 
-#if defined(AHA152X_DEBUG)
-#define DEBUG_DEFAULT debug_eh
-
-#define DPRINTK(when,msgs...) \
-	do { if(HOSTDATA(shpnt)->debug & (when)) printk(msgs); } while(0)
-
-#define DO_LOCK(flags)	\
-	do { \
-		if(spin_is_locked(&QLOCK)) { \
-			DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
-		} \
-		DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
-		spin_lock_irqsave(&QLOCK,flags); \
-		DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
-		QLOCKER=__func__; \
-		QLOCKERL=__LINE__; \
-	} while(0)
-
-#define DO_UNLOCK(flags)	\
-	do { \
-		DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
-		spin_unlock_irqrestore(&QLOCK,flags); \
-		DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
-		QLOCKER="(not locked)"; \
-		QLOCKERL=0; \
-	} while(0)
-
-#else
-#define DPRINTK(when,msgs...)
 #define	DO_LOCK(flags)		spin_lock_irqsave(&QLOCK,flags)
 #define	DO_UNLOCK(flags)	spin_unlock_irqrestore(&QLOCK,flags)
-#endif
 
 #define LEAD		"(scsi%d:%d:%d) "
-#define WARN_LEAD	KERN_WARNING	LEAD
 #define INFO_LEAD	KERN_INFO	LEAD
-#define NOTE_LEAD	KERN_NOTICE	LEAD
-#define ERR_LEAD	KERN_ERR	LEAD
-#define DEBUG_LEAD	KERN_DEBUG	LEAD
 #define CMDINFO(cmd) \
 			(cmd) ? ((cmd)->device->host->host_no) : -1, \
                         (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
@@ -345,10 +311,10 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
 
 enum {
 	not_issued	= 0x0001,	/* command not yet issued */
-	selecting	= 0x0002, 	/* target is beeing selected */
+	selecting	= 0x0002,	/* target is beeing selected */
 	identified	= 0x0004,	/* IDENTIFY was sent */
 	disconnected	= 0x0008,	/* target disconnected */
-	completed	= 0x0010,	/* target sent COMMAND COMPLETE */ 
+	completed	= 0x0010,	/* target sent COMMAND COMPLETE */
 	aborted		= 0x0020,	/* ABORT was sent */
 	resetted	= 0x0040,	/* BUS DEVICE RESET was sent */
 	spiordy		= 0x0080,	/* waiting for SPIORDY to raise */
@@ -396,7 +362,6 @@ static int exttrans[] = {0, 0};
 module_param_array(exttrans, int, NULL, 0);
 MODULE_PARM_DESC(exttrans,"use extended translation");
 
-#if !defined(AHA152X_DEBUG)
 static int aha152x[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0};
 module_param_array(aha152x, int, NULL, 0);
 MODULE_PARM_DESC(aha152x, "parameters for first controller");
@@ -404,19 +369,6 @@ MODULE_PARM_DESC(aha152x, "parameters for first controller");
 static int aha152x1[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0};
 module_param_array(aha152x1, int, NULL, 0);
 MODULE_PARM_DESC(aha152x1, "parameters for second controller");
-#else
-static int debug[] = {DEBUG_DEFAULT, DEBUG_DEFAULT};
-module_param_array(debug, int, NULL, 0);
-MODULE_PARM_DESC(debug, "flags for driver debugging");
-
-static int aha152x[]   = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT};
-module_param_array(aha152x, int, NULL, 0);
-MODULE_PARM_DESC(aha152x, "parameters for first controller");
-
-static int aha152x1[]  = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT};
-module_param_array(aha152x1, int, NULL, 0);
-MODULE_PARM_DESC(aha152x1, "parameters for second controller");
-#endif /* !defined(AHA152X_DEBUG) */
 #endif /* MODULE */
 
 #ifdef __ISAPNP__
@@ -446,7 +398,7 @@ static struct scsi_host_template aha152x_driver_template;
 /*
  * internal states of the host
  *
- */ 
+ */
 enum aha152x_state {
 	idle=0,
 	unknown,
@@ -485,24 +437,16 @@ struct aha152x_hostdata {
 	spinlock_t lock;
 		/* host lock */
 
-#if defined(AHA152X_DEBUG)
-	const char *locker;
-		/* which function has the lock */
-	int lockerl;	/* where did it get it */
-
-	int debug;	/* current debugging setting */
-#endif
-
 #if defined(AHA152X_STAT)
-	int           total_commands;
+	int	      total_commands;
 	int	      disconnections;
 	int	      busfree_without_any_action;
 	int	      busfree_without_old_command;
 	int	      busfree_without_new_command;
 	int	      busfree_without_done_command;
 	int	      busfree_with_check_condition;
-	int           count[maxstate];
-	int           count_trans[maxstate];
+	int	      count[maxstate];
+	int	      count_trans[maxstate];
 	unsigned long time[maxstate];
 #endif
 
@@ -514,7 +458,7 @@ struct aha152x_hostdata {
 	int delay;		/* reset out delay */
 	int ext_trans;		/* extended translation enabled */
 
-	int swint; 		/* software-interrupt was fired during detect() */
+	int swint;		/* software-interrupt was fired during detect() */
 	int service;		/* bh needs to be run */
 	int in_intr;		/* bh is running */
 
@@ -543,7 +487,7 @@ struct aha152x_hostdata {
 	unsigned char msgi[256];
 		/* received message bytes */
 
-	int msgo_i, msgo_len;	
+	int msgo_i, msgo_len;
 		/* number of sent bytes and length of current messages */
 	unsigned char msgo[256];
 		/* pending messages */
@@ -689,7 +633,6 @@ static void aha152x_error(struct Scsi_Host *shpnt, char *msg);
 static void done(struct Scsi_Host *shpnt, int error);
 
 /* diagnostics */
-static void disp_ports(struct Scsi_Host *shpnt);
 static void show_command(Scsi_Cmnd * ptr);
 static void show_queues(struct Scsi_Host *shpnt);
 static void disp_enintr(struct Scsi_Host *shpnt);
@@ -812,10 +755,6 @@ struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *setup)
 	DELAY       = setup->delay;
 	EXT_TRANS   = setup->ext_trans;
 
-#if defined(AHA152X_DEBUG)
-	HOSTDATA(shpnt)->debug = setup->debug;
-#endif
-
 	SETPORT(SCSIID, setup->scsiid << 4);
 	shpnt->this_id = setup->scsiid;
 
@@ -941,31 +880,24 @@ void aha152x_release(struct Scsi_Host *shpnt)
  * setup controller to generate interrupts depending
  * on current state (lock has to be acquired)
  *
- */ 
+ */
 static int setup_expected_interrupts(struct Scsi_Host *shpnt)
 {
 	if(CURRENT_SC) {
 		CURRENT_SC->SCp.phase |= 1 << 16;
-	
+
 		if(CURRENT_SC->SCp.phase & selecting) {
-			DPRINTK(debug_intr, DEBUG_LEAD "expecting: (seldo) (seltimo) (seldi)\n", CMDINFO(CURRENT_SC));
 			SETPORT(SSTAT1, SELTO);
 			SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0));
 			SETPORT(SIMODE1, ENSELTIMO);
 		} else {
-			DPRINTK(debug_intr, DEBUG_LEAD "expecting: (phase change) (busfree) %s\n", CMDINFO(CURRENT_SC), CURRENT_SC->SCp.phase & spiordy ? "(spiordy)" : "");
 			SETPORT(SIMODE0, (CURRENT_SC->SCp.phase & spiordy) ? ENSPIORDY : 0);
-			SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); 
+			SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE);
 		}
 	} else if(STATE==seldi) {
-		DPRINTK(debug_intr, DEBUG_LEAD "expecting: (phase change) (identify)\n", CMDINFO(CURRENT_SC));
 		SETPORT(SIMODE0, 0);
-		SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); 
+		SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE);
 	} else {
-		DPRINTK(debug_intr, DEBUG_LEAD "expecting: %s %s\n",
-			CMDINFO(CURRENT_SC),
-			DISCONNECTED_SC ? "(reselection)" : "",
-			ISSUE_SC ? "(busfree)" : "");
 		SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0);
 		SETPORT(SIMODE1, ENSCSIRST | ( (ISSUE_SC||DONE_SC) ? ENBUSFREE : 0));
 	}
@@ -977,7 +909,7 @@ static int setup_expected_interrupts(struct Scsi_Host *shpnt)
 }
 
 
-/* 
+/*
  *  Queue a command and setup interrupts for a free bus.
  */
 static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
@@ -986,15 +918,6 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
 	struct Scsi_Host *shpnt = SCpnt->device->host;
 	unsigned long flags;
 
-#if defined(AHA152X_DEBUG)
-	if (HOSTDATA(shpnt)->debug & debug_queue) {
-		printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=",
-		       CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len,
-		       scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
-		__scsi_print_command(SCpnt->cmnd);
-	}
-#endif
-
 	SCpnt->scsi_done	= done;
 	SCpnt->SCp.phase	= not_issued | phase;
 	SCpnt->SCp.Status	= 0x1; /* Ilegal status by SCSI standard */
@@ -1004,13 +927,13 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
 
 	if(SCpnt->SCp.phase & (resetting|check_condition)) {
 		if (!SCpnt->host_scribble || SCSEM(SCpnt) || SCNEXT(SCpnt)) {
-			printk(ERR_LEAD "cannot reuse command\n", CMDINFO(SCpnt));
+			scmd_printk(KERN_ERR, SCpnt,"cannot reuse command\n");
 			return FAILED;
 		}
 	} else {
 		SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC);
 		if(!SCpnt->host_scribble) {
-			printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt));
+			scmd_printk(KERN_ERR, SCpnt, "allocation failed\n");
 			return FAILED;
 		}
 	}
@@ -1066,15 +989,6 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
  */
 static int aha152x_queue_lck(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
 {
-#if 0
-	if(*SCpnt->cmnd == REQUEST_SENSE) {
-		SCpnt->result = 0;
-		done(SCpnt);
-
-		return 0;
-	}
-#endif
-
 	return aha152x_internal_queue(SCpnt, NULL, 0, done);
 }
 
@@ -1082,15 +996,10 @@ static DEF_SCSI_QCMD(aha152x_queue)
 
 
 /*
- *  
  *
  */
 static void reset_done(Scsi_Cmnd *SCpnt)
 {
-#if 0
-	struct Scsi_Host *shpnt = SCpnt->host;
-	DPRINTK(debug_eh, INFO_LEAD "reset_done called\n", CMDINFO(SCpnt));
-#endif
 	if(SCSEM(SCpnt)) {
 		complete(SCSEM(SCpnt));
 	} else {
@@ -1108,20 +1017,11 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
 	Scsi_Cmnd *ptr;
 	unsigned long flags;
 
-#if defined(AHA152X_DEBUG)
-	if(HOSTDATA(shpnt)->debug & debug_eh) {
-		printk(DEBUG_LEAD "abort(%p)", CMDINFO(SCpnt), SCpnt);
-		show_queues(shpnt);
-	}
-#endif
-
 	DO_LOCK(flags);
 
 	ptr=remove_SC(&ISSUE_SC, SCpnt);
 
 	if(ptr) {
-		DPRINTK(debug_eh, DEBUG_LEAD "not yet issued - SUCCESS\n", CMDINFO(SCpnt));
-
 		HOSTDATA(shpnt)->commands--;
 		if (!HOSTDATA(shpnt)->commands)
 			SETPORT(PORTA, 0);
@@ -1131,7 +1031,7 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
 		SCpnt->host_scribble=NULL;
 
 		return SUCCESS;
-	} 
+	}
 
 	DO_UNLOCK(flags);
 
@@ -1142,7 +1042,8 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
 	 *
 	 */
 
-	printk(ERR_LEAD "cannot abort running or disconnected command\n", CMDINFO(SCpnt));
+	scmd_printk(KERN_ERR, SCpnt,
+		    "cannot abort running or disconnected command\n");
 
 	return FAILED;
 }
@@ -1160,15 +1061,8 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
 	unsigned long flags;
 	unsigned long timeleft;
 
-#if defined(AHA152X_DEBUG)
-	if(HOSTDATA(shpnt)->debug & debug_eh) {
-		printk(INFO_LEAD "aha152x_device_reset(%p)", CMDINFO(SCpnt), SCpnt);
-		show_queues(shpnt);
-	}
-#endif
-
 	if(CURRENT_SC==SCpnt) {
-		printk(ERR_LEAD "cannot reset current device\n", CMDINFO(SCpnt));
+		scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n");
 		return FAILED;
 	}
 
@@ -1208,7 +1102,7 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
 		} else if(disconnected) {
 			append_SC(&DISCONNECTED_SC, SCpnt);
 		}
-	
+
 		ret = FAILED;
 	}
 
@@ -1227,12 +1121,12 @@ static void free_hard_reset_SCs(struct Scsi_Host *shpnt, Scsi_Cmnd **SCs)
 		if(SCDATA(ptr)) {
 			next = SCNEXT(ptr);
 		} else {
-			printk(DEBUG_LEAD "queue corrupted at %p\n", CMDINFO(ptr), ptr);
+			scmd_printk(KERN_DEBUG, ptr,
+				    "queue corrupted at %p\n", ptr);
 			next = NULL;
 		}
 
 		if (!ptr->device->soft_reset) {
-			DPRINTK(debug_eh, DEBUG_LEAD "disconnected command %p removed\n", CMDINFO(ptr), ptr);
 			remove_SC(SCs, ptr);
 			HOSTDATA(shpnt)->commands--;
 			kfree(ptr->host_scribble);
@@ -1253,25 +1147,14 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt)
 
 	DO_LOCK(flags);
 
-#if defined(AHA152X_DEBUG)
-	if(HOSTDATA(shpnt)->debug & debug_eh) {
-		printk(KERN_DEBUG "scsi%d: bus reset", shpnt->host_no);
-		show_queues(shpnt);
-	}
-#endif
-
 	free_hard_reset_SCs(shpnt, &ISSUE_SC);
 	free_hard_reset_SCs(shpnt, &DISCONNECTED_SC);
 
-	DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting bus\n", shpnt->host_no);
-
 	SETPORT(SCSISEQ, SCSIRSTO);
 	mdelay(256);
 	SETPORT(SCSISEQ, 0);
 	mdelay(DELAY);
 
-	DPRINTK(debug_eh, KERN_DEBUG "scsi%d: bus resetted\n", shpnt->host_no);
-
 	setup_expected_interrupts(shpnt);
 	if(HOSTDATA(shpnt)->commands==0)
 		SETPORT(PORTA, 0);
@@ -1333,11 +1216,7 @@ static void reset_ports(struct Scsi_Host *shpnt)
  */
 int aha152x_host_reset_host(struct Scsi_Host *shpnt)
 {
-	DPRINTK(debug_eh, KERN_DEBUG "scsi%d: host reset\n", shpnt->host_no);
-
 	aha152x_bus_reset_host(shpnt);
-
-	DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting ports\n", shpnt->host_no);
 	reset_ports(shpnt);
 
 	return SUCCESS;
@@ -1345,7 +1224,7 @@ int aha152x_host_reset_host(struct Scsi_Host *shpnt)
 
 /*
  * Reset the host (bus and controller)
- * 
+ *
  */
 static int aha152x_host_reset(Scsi_Cmnd *SCpnt)
 {
@@ -1411,7 +1290,9 @@ static void done(struct Scsi_Host *shpnt, int error)
 {
 	if (CURRENT_SC) {
 		if(DONE_SC)
-			printk(ERR_LEAD "there's already a completed command %p - will cause abort\n", CMDINFO(CURRENT_SC), DONE_SC);
+			scmd_printk(KERN_ERR, CURRENT_SC,
+				    "there's already a completed command %p "
+				    "- will cause abort\n", DONE_SC);
 
 		DONE_SC = CURRENT_SC;
 		CURRENT_SC = NULL;
@@ -1466,7 +1347,7 @@ static irqreturn_t intr(int irqno, void *dev_id)
 		return IRQ_NONE;
 
 	if( TESTLO(DMASTAT, INTSTAT) )
-		return IRQ_NONE;	
+		return IRQ_NONE;
 
 	/* no more interrupts from the controller, while we're busy.
 	   INTEN is restored by the BH handler */
@@ -1501,7 +1382,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 	SETPORT(SXFRCTL0, CH1);
 
 	SETPORT(SSTAT1, CLRBUSFREE);
-	
+
 	if(CURRENT_SC) {
 #if defined(AHA152X_STAT)
 		action++;
@@ -1513,19 +1394,13 @@ static void busfree_run(struct Scsi_Host *shpnt)
 			done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16));
 
 		} else if(CURRENT_SC->SCp.phase & aborted) {
-			DPRINTK(debug_eh, DEBUG_LEAD "ABORT sent\n", CMDINFO(CURRENT_SC));
 			done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_ABORT << 16));
 
 		} else if(CURRENT_SC->SCp.phase & resetted) {
-			DPRINTK(debug_eh, DEBUG_LEAD "BUS DEVICE RESET sent\n", CMDINFO(CURRENT_SC));
 			done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_RESET << 16));
 
 		} else if(CURRENT_SC->SCp.phase & disconnected) {
 			/* target sent DISCONNECT */
-			DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n",
-				CMDINFO(CURRENT_SC),
-				scsi_get_resid(CURRENT_SC),
-				scsi_bufflen(CURRENT_SC));
 #if defined(AHA152X_STAT)
 			HOSTDATA(shpnt)->disconnections++;
 #endif
@@ -1553,13 +1428,6 @@ static void busfree_run(struct Scsi_Host *shpnt)
 			struct scsi_cmnd *cmd = HOSTDATA(shpnt)->done_SC;
 			struct aha152x_scdata *sc = SCDATA(cmd);
 
-#if 0
-			if(HOSTDATA(shpnt)->debug & debug_eh) {
-				printk(ERR_LEAD "received sense: ", CMDINFO(DONE_SC));
-				scsi_print_sense("bh", DONE_SC);
-			}
-#endif
-
 			scsi_eh_restore_cmnd(cmd, &sc->ses);
 
 			cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;
@@ -1571,17 +1439,11 @@ static void busfree_run(struct Scsi_Host *shpnt)
 #if defined(AHA152X_STAT)
 			HOSTDATA(shpnt)->busfree_with_check_condition++;
 #endif
-#if 0
-			DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC));
-#endif
 
 			if(!(DONE_SC->SCp.phase & not_issued)) {
 				struct aha152x_scdata *sc;
 				Scsi_Cmnd *ptr = DONE_SC;
 				DONE_SC=NULL;
-#if 0
-				DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));
-#endif
 
 				sc = SCDATA(ptr);
 				/* It was allocated in aha152x_internal_queue? */
@@ -1591,19 +1453,10 @@ static void busfree_run(struct Scsi_Host *shpnt)
 				DO_UNLOCK(flags);
 				aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);
 				DO_LOCK(flags);
-#if 0
-			} else {
-				DPRINTK(debug_eh, ERR_LEAD "command not issued - CHECK CONDITION ignored\n", CMDINFO(DONE_SC));
-#endif
 			}
 		}
 
 		if(DONE_SC && DONE_SC->scsi_done) {
-#if defined(AHA152X_DEBUG)
-			int hostno=DONE_SC->device->host->host_no;
-			int id=DONE_SC->device->id & 0xf;
-			int lun=((u8)DONE_SC->device->lun) & 0x7;
-#endif
 			Scsi_Cmnd *ptr = DONE_SC;
 			DONE_SC=NULL;
 
@@ -1618,9 +1471,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 			}
 
 			DO_UNLOCK(flags);
-			DPRINTK(debug_done, DEBUG_LEAD "calling scsi_done(%p)\n", hostno, id, lun, ptr);
-                	ptr->scsi_done(ptr);
-			DPRINTK(debug_done, DEBUG_LEAD "scsi_done(%p) returned\n", hostno, id, lun, ptr);
+			ptr->scsi_done(ptr);
 			DO_LOCK(flags);
 		}
 
@@ -1640,9 +1491,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 #if defined(AHA152X_STAT)
 		action++;
 #endif
-	    	CURRENT_SC->SCp.phase |= selecting;
-
-		DPRINTK(debug_selection, DEBUG_LEAD "selecting target\n", CMDINFO(CURRENT_SC));
+		CURRENT_SC->SCp.phase |= selecting;
 
 		/* clear selection timeout */
 		SETPORT(SSTAT1, SELTO);
@@ -1674,18 +1523,19 @@ static void seldo_run(struct Scsi_Host *shpnt)
 	SETPORT(SSTAT1, CLRBUSFREE);
 	SETPORT(SSTAT1, CLRPHASECHG);
 
-    	CURRENT_SC->SCp.phase &= ~(selecting|not_issued);
+	CURRENT_SC->SCp.phase &= ~(selecting|not_issued);
 
 	SETPORT(SCSISEQ, 0);
 
 	if (TESTLO(SSTAT0, SELDO)) {
-		printk(ERR_LEAD "aha152x: passing bus free condition\n", CMDINFO(CURRENT_SC));
+		scmd_printk(KERN_ERR, CURRENT_SC,
+			    "aha152x: passing bus free condition\n");
 		done(shpnt, DID_NO_CONNECT << 16);
 		return;
 	}
 
 	SETPORT(SSTAT0, CLRSELDO);
-	
+
 	ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun));
 
 	if (CURRENT_SC->SCp.phase & aborting) {
@@ -1693,7 +1543,7 @@ static void seldo_run(struct Scsi_Host *shpnt)
 	} else if (CURRENT_SC->SCp.phase & resetting) {
 		ADDMSGO(BUS_DEVICE_RESET);
 	} else if (SYNCNEG==0 && SYNCHRONOUS) {
-    		CURRENT_SC->SCp.phase |= syncneg;
+		CURRENT_SC->SCp.phase |= syncneg;
 		MSGOLEN += spi_populate_sync_msg(&MSGO(MSGOLEN), 50, 8);
 		SYNCNEG=1;		/* negotiation in progress */
 	}
@@ -1708,29 +1558,21 @@ static void seldo_run(struct Scsi_Host *shpnt)
  */
 static void selto_run(struct Scsi_Host *shpnt)
 {
-	SETPORT(SCSISEQ, 0);		
+	SETPORT(SCSISEQ, 0);
 	SETPORT(SSTAT1, CLRSELTIMO);
 
-	DPRINTK(debug_selection, DEBUG_LEAD "selection timeout\n", CMDINFO(CURRENT_SC));
-
-	if(!CURRENT_SC) {
-		DPRINTK(debug_selection, DEBUG_LEAD "!CURRENT_SC\n", CMDINFO(CURRENT_SC));
+	if(!CURRENT_SC)
 		return;
-	}
 
-    	CURRENT_SC->SCp.phase &= ~selecting;
+	CURRENT_SC->SCp.phase &= ~selecting;
 
-	if (CURRENT_SC->SCp.phase & aborted) {
-		DPRINTK(debug_selection, DEBUG_LEAD "aborted\n", CMDINFO(CURRENT_SC));
+	if (CURRENT_SC->SCp.phase & aborted)
 		done(shpnt, DID_ABORT << 16);
-	} else if (TESTLO(SSTAT0, SELINGO)) {
-		DPRINTK(debug_selection, DEBUG_LEAD "arbitration not won\n", CMDINFO(CURRENT_SC));
+	else if (TESTLO(SSTAT0, SELINGO))
 		done(shpnt, DID_BUS_BUSY << 16);
-	} else {
+	else
 		/* ARBITRATION won, but SELECTION failed */
-		DPRINTK(debug_selection, DEBUG_LEAD "selection failed\n", CMDINFO(CURRENT_SC));
 		done(shpnt, DID_NO_CONNECT << 16);
-	}
 }
 
 /*
@@ -1753,9 +1595,8 @@ static void seldi_run(struct Scsi_Host *shpnt)
 
 	if(CURRENT_SC) {
 		if(!(CURRENT_SC->SCp.phase & not_issued))
-			printk(ERR_LEAD "command should not have been issued yet\n", CMDINFO(CURRENT_SC));
-
-		DPRINTK(debug_selection, ERR_LEAD "command requeued - reselection\n", CMDINFO(CURRENT_SC));
+			scmd_printk(KERN_ERR, CURRENT_SC,
+				    "command should not have been issued yet\n");
 
 		DO_LOCK(flags);
 		append_SC(&ISSUE_SC, CURRENT_SC);
@@ -1764,17 +1605,16 @@ static void seldi_run(struct Scsi_Host *shpnt)
 		CURRENT_SC = NULL;
 	}
 
-	if(!DISCONNECTED_SC) {
-		DPRINTK(debug_selection, DEBUG_LEAD "unexpected SELDI ", CMDINFO(CURRENT_SC));
+	if(!DISCONNECTED_SC)
 		return;
-	}
 
 	RECONN_TARGET=-1;
 
 	selid = GETPORT(SELID) & ~(1 << shpnt->this_id);
 
 	if (selid==0) {
-		printk("aha152x%d: target id unknown (%02x)\n", HOSTNO, selid);
+		shost_printk(KERN_INFO, shpnt,
+			     "target id unknown (%02x)\n", selid);
 		return;
 	}
 
@@ -1782,8 +1622,8 @@ static void seldi_run(struct Scsi_Host *shpnt)
 		;
 
 	if(selid & ~(1 << target)) {
-		printk("aha152x%d: multiple targets reconnected (%02x)\n",
-		       HOSTNO, selid);
+		shost_printk(KERN_INFO, shpnt,
+			     "multiple targets reconnected (%02x)\n", selid);
 	}
 
 
@@ -1793,7 +1633,6 @@ static void seldi_run(struct Scsi_Host *shpnt)
 	SETRATE(HOSTDATA(shpnt)->syncrate[target]);
 
 	RECONN_TARGET=target;
-	DPRINTK(debug_selection, DEBUG_LEAD "target %d reselected (%02x).\n", CMDINFO(CURRENT_SC), target, selid);
 }
 
 /*
@@ -1817,31 +1656,24 @@ static void msgi_run(struct Scsi_Host *shpnt)
 		if(sstat1 & (PHASECHG|PHASEMIS|BUSFREE) || !(sstat1 & REQINIT))
 			return;
 
-		if(TESTLO(SSTAT0,SPIORDY)) {
-			DPRINTK(debug_msgi, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
+		if(TESTLO(SSTAT0,SPIORDY))
 			return;
-		}	
 
 		ADDMSGI(GETPORT(SCSIDAT));
 
-#if defined(AHA152X_DEBUG)
-		if (HOSTDATA(shpnt)->debug & debug_msgi) {
-			printk(INFO_LEAD "inbound message %02x ", CMDINFO(CURRENT_SC), MSGI(0));
-			spi_print_msg(&MSGI(0));
-			printk("\n");
-		}
-#endif
-
 		if(!CURRENT_SC) {
 			if(LASTSTATE!=seldi) {
-				printk(KERN_ERR "aha152x%d: message in w/o current command not after reselection\n", HOSTNO);
+				shost_printk(KERN_ERR, shpnt,
+					     "message in w/o current command"
+					     " not after reselection\n");
 			}
 
 			/*
-	 	 	 * Handle reselection
-	 		 */
+			 * Handle reselection
+			 */
 			if(!(MSGI(0) & IDENTIFY_BASE)) {
-				printk(KERN_ERR "aha152x%d: target didn't identify after reselection\n", HOSTNO);
+				shost_printk(KERN_ERR, shpnt,
+					     "target didn't identify after reselection\n");
 				continue;
 			}
 
@@ -1849,12 +1681,13 @@ static void msgi_run(struct Scsi_Host *shpnt)
 
 			if (!CURRENT_SC) {
 				show_queues(shpnt);
-				printk(KERN_ERR "aha152x%d: no disconnected command for target %d/%d\n", HOSTNO, RECONN_TARGET, MSGI(0) & 0x3f);
+				shost_printk(KERN_ERR, shpnt,
+					     "no disconnected command"
+					     " for target %d/%d\n",
+					     RECONN_TARGET, MSGI(0) & 0x3f);
 				continue;
 			}
 
-			DPRINTK(debug_msgi, DEBUG_LEAD "target reconnected\n", CMDINFO(CURRENT_SC));
-
 			CURRENT_SC->SCp.Message = MSGI(0);
 			CURRENT_SC->SCp.phase &= ~disconnected;
 
@@ -1862,31 +1695,32 @@ static void msgi_run(struct Scsi_Host *shpnt)
 
 			/* next message if any */
 			continue;
-		} 
+		}
 
 		CURRENT_SC->SCp.Message = MSGI(0);
 
 		switch (MSGI(0)) {
 		case DISCONNECT:
 			if (!RECONNECT)
-				printk(WARN_LEAD "target was not allowed to disconnect\n", CMDINFO(CURRENT_SC));
+				scmd_printk(KERN_WARN, CURRENT_SC,
+					    "target was not allowed to disconnect\n");
 
 			CURRENT_SC->SCp.phase |= disconnected;
 			break;
 
 		case COMMAND_COMPLETE:
-			if(CURRENT_SC->SCp.phase & completed)
-				DPRINTK(debug_msgi, DEBUG_LEAD "again COMMAND COMPLETE\n", CMDINFO(CURRENT_SC));
-
 			CURRENT_SC->SCp.phase |= completed;
 			break;
 
 		case MESSAGE_REJECT:
 			if (SYNCNEG==1) {
-				printk(INFO_LEAD "Synchronous Data Transfer Request was rejected\n", CMDINFO(CURRENT_SC));
+				scmd_printk(KERN_INFO, CURRENT_SC,
+					    "Synchronous Data Transfer Request"
+					    " was rejected\n");
 				SYNCNEG=2;	/* negotiation completed */
 			} else
-				printk(INFO_LEAD "inbound message (MESSAGE REJECT)\n", CMDINFO(CURRENT_SC));
+				scmd_printk(KERN_INFO, CURRENT_SC,
+					    "inbound message (MESSAGE REJECT)\n");
 			break;
 
 		case SAVE_POINTERS:
@@ -1907,7 +1741,8 @@ static void msgi_run(struct Scsi_Host *shpnt)
 					long ticks;
 
 					if (MSGI(1) != 3) {
-						printk(ERR_LEAD "SDTR message length!=3\n", CMDINFO(CURRENT_SC));
+						scmd_printk(KERN_ERR, CURRENT_SC,
+							    "SDTR message length!=3\n");
 						break;
 					}
 
@@ -1924,10 +1759,12 @@ static void msgi_run(struct Scsi_Host *shpnt)
 						/* negotiation in progress */
 						if (ticks > 9 || MSGI(4) < 1 || MSGI(4) > 8) {
 							ADDMSGO(MESSAGE_REJECT);
-							printk(INFO_LEAD "received Synchronous Data Transfer Request invalid - rejected\n", CMDINFO(CURRENT_SC));
+							scmd_printk(KERN_INFO,
+								    CURRENT_SC,
+								    "received Synchronous Data Transfer Request invalid - rejected\n");
 							break;
 						}
-						
+
 						SYNCRATE |= ((ticks - 2) << 4) + MSGI(4);
 					} else if (ticks <= 9 && MSGI(4) >= 1) {
 						ADDMSGO(EXTENDED_MESSAGE);
@@ -1947,7 +1784,8 @@ static void msgi_run(struct Scsi_Host *shpnt)
 						SYNCRATE |= ((ticks - 2) << 4) + MSGI(4);
 					} else {
 						/* requested SDTR is too slow, do it asynchronously */
-						printk(INFO_LEAD "Synchronous Data Transfer Request too slow - Rejecting\n", CMDINFO(CURRENT_SC));
+						scmd_printk(KERN_INFO, CURRENT_SC,
+							    "Synchronous Data Transfer Request too slow - Rejecting\n");
 						ADDMSGO(MESSAGE_REJECT);
 					}
 
@@ -1985,12 +1823,12 @@ static void msgi_run(struct Scsi_Host *shpnt)
 static void msgi_end(struct Scsi_Host *shpnt)
 {
 	if(MSGILEN>0)
-		printk(WARN_LEAD "target left before message completed (%d)\n", CMDINFO(CURRENT_SC), MSGILEN);
+		scmd_printk(KERN_WARN, CURRENT_SC,
+			    "target left before message completed (%d)\n",
+			    MSGILEN);
 
-	if (MSGOLEN > 0 && !(GETPORT(SSTAT1) & BUSFREE)) {
-		DPRINTK(debug_msgi, DEBUG_LEAD "msgo pending\n", CMDINFO(CURRENT_SC));
+	if (MSGOLEN > 0 && !(GETPORT(SSTAT1) & BUSFREE))
 		SETPORT(SCSISIG, P_MSGI | SIG_ATNO);
-	} 
 }
 
 /*
@@ -2003,21 +1841,12 @@ static void msgo_init(struct Scsi_Host *shpnt)
 		if((CURRENT_SC->SCp.phase & syncneg) && SYNCNEG==2 && SYNCRATE==0) {
 			ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun));
 		} else {
-			printk(INFO_LEAD "unexpected MESSAGE OUT phase; rejecting\n", CMDINFO(CURRENT_SC));
+			scmd_printk(KERN_INFO, CURRENT_SC,
+				    "unexpected MESSAGE OUT phase; rejecting\n");
 			ADDMSGO(MESSAGE_REJECT);
 		}
 	}
 
-#if defined(AHA152X_DEBUG)
-	if(HOSTDATA(shpnt)->debug & debug_msgo) {
-		int i;
-
-		printk(DEBUG_LEAD "messages( ", CMDINFO(CURRENT_SC));
-		for (i=0; i<MSGOLEN; i+=spi_print_msg(&MSGO(i)), printk(" "))
-			;
-		printk(")\n");
-	}
-#endif
 }
 
 /*
@@ -2026,16 +1855,9 @@ static void msgo_init(struct Scsi_Host *shpnt)
  */
 static void msgo_run(struct Scsi_Host *shpnt)
 {
-	if(MSGO_I==MSGOLEN)
-		DPRINTK(debug_msgo, DEBUG_LEAD "messages all sent (%d/%d)\n", CMDINFO(CURRENT_SC), MSGO_I, MSGOLEN);
-
 	while(MSGO_I<MSGOLEN) {
-		DPRINTK(debug_msgo, DEBUG_LEAD "message byte %02x (%d/%d)\n", CMDINFO(CURRENT_SC), MSGO(MSGO_I), MSGO_I, MSGOLEN);
-
-		if(TESTLO(SSTAT0, SPIORDY)) {
-			DPRINTK(debug_msgo, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
+		if(TESTLO(SSTAT0, SPIORDY))
 			return;
-		}
 
 		if (MSGO_I==MSGOLEN-1) {
 			/* Leave MESSAGE OUT after transfer */
@@ -2059,36 +1881,33 @@ static void msgo_run(struct Scsi_Host *shpnt)
 static void msgo_end(struct Scsi_Host *shpnt)
 {
 	if(MSGO_I<MSGOLEN) {
-		printk(ERR_LEAD "message sent incompletely (%d/%d)\n", CMDINFO(CURRENT_SC), MSGO_I, MSGOLEN);
+		scmd_printk(KERN_ERR, CURRENT_SC,
+			    "message sent incompletely (%d/%d)\n",
+			    MSGO_I, MSGOLEN);
 		if(SYNCNEG==1) {
-			printk(INFO_LEAD "Synchronous Data Transfer Request was rejected\n", CMDINFO(CURRENT_SC));
+			scmd_printk(KERN_INFO, CURRENT_SC,
+				    "Synchronous Data Transfer Request was rejected\n");
 			SYNCNEG=2;
 		}
 	}
-		
+
 	MSGO_I  = 0;
 	MSGOLEN = 0;
 }
 
-/* 
+/*
  * command phase
  *
  */
 static void cmd_init(struct Scsi_Host *shpnt)
 {
 	if (CURRENT_SC->SCp.sent_command) {
-		printk(ERR_LEAD "command already sent\n", CMDINFO(CURRENT_SC));
+		scmd_printk(KERN_ERR, CURRENT_SC,
+			    "command already sent\n");
 		done(shpnt, DID_ERROR << 16);
 		return;
 	}
 
-#if defined(AHA152X_DEBUG)
-	if (HOSTDATA(shpnt)->debug & debug_cmd) {
-		printk(DEBUG_LEAD "cmd_init: ", CMDINFO(CURRENT_SC));
-		__scsi_print_command(CURRENT_SC->cmnd);
-	}
-#endif
-
 	CMD_I=0;
 }
 
@@ -2098,18 +1917,9 @@ static void cmd_init(struct Scsi_Host *shpnt)
  */
 static void cmd_run(struct Scsi_Host *shpnt)
 {
-	if(CMD_I==CURRENT_SC->cmd_len) {
-		DPRINTK(debug_cmd, DEBUG_LEAD "command already completely sent (%d/%d)", CMDINFO(CURRENT_SC), CMD_I, CURRENT_SC->cmd_len);
-		disp_ports(shpnt);
-	}
-
 	while(CMD_I<CURRENT_SC->cmd_len) {
-		DPRINTK(debug_cmd, DEBUG_LEAD "command byte %02x (%d/%d)\n", CMDINFO(CURRENT_SC), CURRENT_SC->cmnd[CMD_I], CMD_I, CURRENT_SC->cmd_len);
-
-		if(TESTLO(SSTAT0, SPIORDY)) {
-			DPRINTK(debug_cmd, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
+		if(TESTLO(SSTAT0, SPIORDY))
 			return;
-		}
 
 		SETPORT(SCSIDAT, CURRENT_SC->cmnd[CMD_I++]);
 	}
@@ -2118,7 +1928,9 @@ static void cmd_run(struct Scsi_Host *shpnt)
 static void cmd_end(struct Scsi_Host *shpnt)
 {
 	if(CMD_I<CURRENT_SC->cmd_len)
-		printk(ERR_LEAD "command sent incompletely (%d/%d)\n", CMDINFO(CURRENT_SC), CMD_I, CURRENT_SC->cmd_len);
+		scmd_printk(KERN_ERR, CURRENT_SC,
+			    "command sent incompletely (%d/%d)\n",
+			    CMD_I, CURRENT_SC->cmd_len);
 	else
 		CURRENT_SC->SCp.sent_command++;
 }
@@ -2129,20 +1941,11 @@ static void cmd_end(struct Scsi_Host *shpnt)
  */
 static void status_run(struct Scsi_Host *shpnt)
 {
-	if(TESTLO(SSTAT0,SPIORDY)) {
-		DPRINTK(debug_status, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC));
+	if(TESTLO(SSTAT0,SPIORDY))
 		return;
-	}
 
 	CURRENT_SC->SCp.Status = GETPORT(SCSIDAT);
 
-#if defined(AHA152X_DEBUG)
-	if (HOSTDATA(shpnt)->debug & debug_status) {
-		printk(DEBUG_LEAD "inbound status %02x ", CMDINFO(CURRENT_SC), CURRENT_SC->SCp.Status);
-		scsi_print_status(CURRENT_SC->SCp.Status);
-		printk("\n");
-	}
-#endif
 }
 
 /*
@@ -2161,10 +1964,6 @@ static void datai_init(struct Scsi_Host *shpnt)
 	SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE);
 
 	DATA_LEN=0;
-	DPRINTK(debug_datai,
-		DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n",
-		CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
-		scsi_get_resid(CURRENT_SC));
 }
 
 static void datai_run(struct Scsi_Host *shpnt)
@@ -2186,8 +1985,7 @@ static void datai_run(struct Scsi_Host *shpnt)
 			barrier();
 
 		if(TESTLO(DMASTAT, DFIFOFULL|INTSTAT)) {
-			printk(ERR_LEAD "datai timeout", CMDINFO(CURRENT_SC));
-			disp_ports(shpnt);
+			scmd_printk(KERN_ERR, CURRENT_SC, "datai timeout\n");
 			break;
 		}
 
@@ -2199,8 +1997,8 @@ static void datai_run(struct Scsi_Host *shpnt)
 				barrier();
 
 			if(TESTLO(SSTAT2, SEMPTY)) {
-				printk(ERR_LEAD "datai sempty timeout", CMDINFO(CURRENT_SC));
-				disp_ports(shpnt);
+				scmd_printk(KERN_ERR, CURRENT_SC,
+					    "datai sempty timeout");
 				break;
 			}
 
@@ -2209,48 +2007,48 @@ static void datai_run(struct Scsi_Host *shpnt)
 
 		if(CURRENT_SC->SCp.this_residual>0) {
 			while(fifodata>0 && CURRENT_SC->SCp.this_residual>0) {
-                        	data_count = fifodata>CURRENT_SC->SCp.this_residual ?
+				data_count = fifodata>CURRENT_SC->SCp.this_residual ?
 						CURRENT_SC->SCp.this_residual :
 						fifodata;
 				fifodata -= data_count;
 
-                        	if(data_count & 1) {
-					DPRINTK(debug_datai, DEBUG_LEAD "8bit\n", CMDINFO(CURRENT_SC));
-                                	SETPORT(DMACNTRL0, ENDMA|_8BIT);
-                                	*CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT);
-                                	CURRENT_SC->SCp.this_residual--;
-                                	DATA_LEN++;
-                                	SETPORT(DMACNTRL0, ENDMA);
-                        	}
-	
-                        	if(data_count > 1) {
-					DPRINTK(debug_datai, DEBUG_LEAD "16bit(%d)\n", CMDINFO(CURRENT_SC), data_count);
-                                	data_count >>= 1;
-                                	insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
-                                	CURRENT_SC->SCp.ptr           += 2 * data_count;
-                                	CURRENT_SC->SCp.this_residual -= 2 * data_count;
-                                	DATA_LEN                      += 2 * data_count;
-                        	}
-	
-                        	if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
-                               		/* advance to next buffer */
-                               		CURRENT_SC->SCp.buffers_residual--;
-                               		CURRENT_SC->SCp.buffer++;
-                               		CURRENT_SC->SCp.ptr           = SG_ADDRESS(CURRENT_SC->SCp.buffer);
-                               		CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
-				} 
-                	}
-		} else if(fifodata>0) { 
-			printk(ERR_LEAD "no buffers left for %d(%d) bytes (data overrun!?)\n", CMDINFO(CURRENT_SC), fifodata, GETPORT(FIFOSTAT));
-                        SETPORT(DMACNTRL0, ENDMA|_8BIT);
+				if(data_count & 1) {
+					SETPORT(DMACNTRL0, ENDMA|_8BIT);
+					*CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT);
+					CURRENT_SC->SCp.this_residual--;
+					DATA_LEN++;
+					SETPORT(DMACNTRL0, ENDMA);
+				}
+
+				if(data_count > 1) {
+					data_count >>= 1;
+					insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
+					CURRENT_SC->SCp.ptr           += 2 * data_count;
+					CURRENT_SC->SCp.this_residual -= 2 * data_count;
+					DATA_LEN                      += 2 * data_count;
+				}
+
+				if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
+					/* advance to next buffer */
+					CURRENT_SC->SCp.buffers_residual--;
+					CURRENT_SC->SCp.buffer++;
+					CURRENT_SC->SCp.ptr           = SG_ADDRESS(CURRENT_SC->SCp.buffer);
+					CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
+				}
+			}
+		} else if(fifodata>0) {
+			scmd_printk(KERN_ERR, CURRENT_SC,
+				    "no buffers left for %d(%d) bytes"
+				    " (data overrun!?)\n",
+				    fifodata, GETPORT(FIFOSTAT));
+			SETPORT(DMACNTRL0, ENDMA|_8BIT);
 			while(fifodata>0) {
 				int data;
 				data=GETPORT(DATAPORT);
-				DPRINTK(debug_datai, DEBUG_LEAD "data=%02x\n", CMDINFO(CURRENT_SC), data);
 				fifodata--;
 				DATA_LEN++;
 			}
-                        SETPORT(DMACNTRL0, ENDMA|_8BIT);
+			SETPORT(DMACNTRL0, ENDMA|_8BIT);
 		}
 	}
 
@@ -2258,19 +2056,20 @@ static void datai_run(struct Scsi_Host *shpnt)
 	   TESTLO(DMASTAT, DFIFOEMP) ||
 	   TESTLO(SSTAT2, SEMPTY) ||
 	   GETPORT(FIFOSTAT)>0) {
-	   	/*
+		/*
 		 * something went wrong, if there's something left in the fifos
 		 * or the phase didn't change
 		 */
-		printk(ERR_LEAD "fifos should be empty and phase should have changed\n", CMDINFO(CURRENT_SC));
-		disp_ports(shpnt);
+		scmd_printk(KERN_ERR, CURRENT_SC,
+			    "fifos should be empty and phase should have changed\n");
 	}
 
 	if(DATA_LEN!=GETSTCNT()) {
-		printk(ERR_LEAD
-		       "manual transfer count differs from automatic (count=%d;stcnt=%d;diff=%d;fifostat=%d)",
-		       CMDINFO(CURRENT_SC), DATA_LEN, GETSTCNT(), GETSTCNT()-DATA_LEN, GETPORT(FIFOSTAT));
-		disp_ports(shpnt);
+		scmd_printk(KERN_ERR, CURRENT_SC,
+			    "manual transfer count differs from automatic "
+			    "(count=%d;stcnt=%d;diff=%d;fifostat=%d)",
+			    DATA_LEN, GETSTCNT(), GETSTCNT()-DATA_LEN,
+			    GETPORT(FIFOSTAT));
 		mdelay(10000);
 	}
 }
@@ -2279,11 +2078,6 @@ static void datai_end(struct Scsi_Host *shpnt)
 {
 	CMD_INC_RESID(CURRENT_SC, -GETSTCNT());
 
-	DPRINTK(debug_datai,
-		DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n",
-		CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
-		scsi_get_resid(CURRENT_SC), GETSTCNT());
-
 	SETPORT(SXFRCTL0, CH1|CLRSTCNT);
 	SETPORT(DMACNTRL0, 0);
 }
@@ -2304,11 +2098,6 @@ static void datao_init(struct Scsi_Host *shpnt)
 	SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE );
 
 	DATA_LEN = scsi_get_resid(CURRENT_SC);
-
-	DPRINTK(debug_datao,
-		DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n",
-		CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
-		scsi_get_resid(CURRENT_SC));
 }
 
 static void datao_run(struct Scsi_Host *shpnt)
@@ -2323,8 +2112,9 @@ static void datao_run(struct Scsi_Host *shpnt)
 			data_count=CURRENT_SC->SCp.this_residual;
 
 		if(TESTLO(DMASTAT, DFIFOEMP)) {
-			printk(ERR_LEAD "datao fifo not empty (%d)", CMDINFO(CURRENT_SC), GETPORT(FIFOSTAT));
-			disp_ports(shpnt);
+			scmd_printk(KERN_ERR, CURRENT_SC,
+				    "datao fifo not empty (%d)",
+				    GETPORT(FIFOSTAT));
 			break;
 		}
 
@@ -2342,7 +2132,7 @@ static void datao_run(struct Scsi_Host *shpnt)
 			CURRENT_SC->SCp.ptr           += 2 * data_count;
 			CURRENT_SC->SCp.this_residual -= 2 * data_count;
 			CMD_INC_RESID(CURRENT_SC, -2 * data_count);
-	  	}
+		}
 
 		if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
 			/* advance to next buffer */
@@ -2357,8 +2147,7 @@ static void datao_run(struct Scsi_Host *shpnt)
 			barrier();
 
 		if(TESTLO(DMASTAT, DFIFOEMP|INTSTAT)) {
-			printk(ERR_LEAD "dataout timeout", CMDINFO(CURRENT_SC));
-			disp_ports(shpnt);
+			scmd_printk(KERN_ERR, CURRENT_SC, "dataout timeout\n");
 			break;
 		}
 	}
@@ -2368,35 +2157,23 @@ static void datao_end(struct Scsi_Host *shpnt)
 {
 	if(TESTLO(DMASTAT, DFIFOEMP)) {
 		int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
-		                                                    GETSTCNT();
-
-		DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n",
-			CMDINFO(CURRENT_SC),
-			data_count,
-			DATA_LEN - scsi_get_resid(CURRENT_SC),
-			GETSTCNT());
+			GETSTCNT();
 
 		CMD_INC_RESID(CURRENT_SC, data_count);
 
 		data_count -= CURRENT_SC->SCp.ptr -
-		                             SG_ADDRESS(CURRENT_SC->SCp.buffer);
+			SG_ADDRESS(CURRENT_SC->SCp.buffer);
 		while(data_count>0) {
 			CURRENT_SC->SCp.buffer--;
 			CURRENT_SC->SCp.buffers_residual++;
 			data_count -= CURRENT_SC->SCp.buffer->length;
 		}
 		CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
-		                                                     data_count;
+			data_count;
 		CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
-		                                                     data_count;
+			data_count;
 	}
 
-	DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n",
-		CMDINFO(CURRENT_SC),
-		scsi_bufflen(CURRENT_SC),
-		scsi_get_resid(CURRENT_SC),
-		GETSTCNT());
-
 	SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
 	SETPORT(SXFRCTL0, CH1);
 
@@ -2420,7 +2197,7 @@ static int update_state(struct Scsi_Host *shpnt)
 		STATE=rsti;
 		SETPORT(SCSISEQ,0);
 		SETPORT(SSTAT1,SCSIRSTI);
-  	} else if(stat0 & SELDI && PREVSTATE==busfree) {
+	} else if(stat0 & SELDI && PREVSTATE==busfree) {
 		STATE=seldi;
 	} else if(stat0 & SELDO && CURRENT_SC && (CURRENT_SC->SCp.phase & selecting)) {
 		STATE=seldo;
@@ -2445,8 +2222,7 @@ static int update_state(struct Scsi_Host *shpnt)
 	}
 
 	if((stat0 & SELDI) && STATE!=seldi && !dataphase) {
-		printk(INFO_LEAD "reselection missed?", CMDINFO(CURRENT_SC));
-		disp_ports(shpnt);
+		scmd_printk(KERN_INFO, CURRENT_SC, "reselection missed?");
 	}
 
 	if(STATE!=PREVSTATE) {
@@ -2464,7 +2240,7 @@ static int update_state(struct Scsi_Host *shpnt)
  */
 static void parerr_run(struct Scsi_Host *shpnt)
 {
-	printk(ERR_LEAD "parity error\n", CMDINFO(CURRENT_SC));
+	scmd_printk(KERN_ERR, CURRENT_SC, "parity error\n");
 	done(shpnt, DID_PARITY << 16);
 }
 
@@ -2476,8 +2252,8 @@ static void rsti_run(struct Scsi_Host *shpnt)
 {
 	Scsi_Cmnd *ptr;
 
-	printk(KERN_NOTICE "aha152x%d: scsi reset in\n", HOSTNO);
-	
+	shost_printk(KERN_NOTICE, shpnt, "scsi reset in\n");
+
 	ptr=DISCONNECTED_SC;
 	while(ptr) {
 		Scsi_Cmnd *next = SCNEXT(ptr);
@@ -2539,8 +2315,6 @@ static void is_complete(struct Scsi_Host *shpnt)
 
 		dataphase=update_state(shpnt);
 
-		DPRINTK(debug_phases, LEAD "start %s %s(%s)\n", CMDINFO(CURRENT_SC), states[STATE].name, states[PREVSTATE].name, states[LASTSTATE].name);
-
 		/*
 		 * end previous state
 		 *
@@ -2567,9 +2341,9 @@ static void is_complete(struct Scsi_Host *shpnt)
 		if(dataphase) {
 			SETPORT(SSTAT0, REQINIT);
 			SETPORT(SCSISIG, GETPORT(SCSISIG) & P_MASK);
-			SETPORT(SSTAT1, PHASECHG);  
+			SETPORT(SSTAT1, PHASECHG);
 		}
-		
+
 		/*
 		 * enable SPIO mode if previous didn't use it
 		 * and this one does
@@ -2581,14 +2355,14 @@ static void is_complete(struct Scsi_Host *shpnt)
 			if(CURRENT_SC)
 				CURRENT_SC->SCp.phase |= spiordy;
 		}
-		
+
 		/*
 		 * initialize for new state
 		 *
 		 */
 		if(PREVSTATE!=STATE && states[STATE].init)
 			states[STATE].init(shpnt);
-		
+
 		/*
 		 * handle current state
 		 *
@@ -2596,8 +2370,9 @@ static void is_complete(struct Scsi_Host *shpnt)
 		if(states[STATE].run)
 			states[STATE].run(shpnt);
 		else
-			printk(ERR_LEAD "unexpected state (%x)\n", CMDINFO(CURRENT_SC), STATE);
-		
+			scmd_printk(KERN_ERR, CURRENT_SC,
+				    "unexpected state (%x)\n", STATE);
+
 		/*
 		 * setup controller to interrupt on
 		 * the next expected condition and
@@ -2613,7 +2388,6 @@ static void is_complete(struct Scsi_Host *shpnt)
 		HOSTDATA(shpnt)->time[STATE] += jiffies-start;
 #endif
 
-		DPRINTK(debug_phases, LEAD "end %s %s(%s)\n", CMDINFO(CURRENT_SC), states[STATE].name, states[PREVSTATE].name, states[LASTSTATE].name);
 	} while(pending);
 
 	/*
@@ -2626,289 +2400,42 @@ static void is_complete(struct Scsi_Host *shpnt)
 }
 
 
-/* 
+/*
  * Dump the current driver status and panic
  */
 static void aha152x_error(struct Scsi_Host *shpnt, char *msg)
 {
-	printk(KERN_EMERG "\naha152x%d: %s\n", HOSTNO, msg);
+	shost_printk(KERN_EMERG, shpnt, "%s\n", msg);
 	show_queues(shpnt);
 	panic("aha152x panic\n");
 }
 
 /*
- * Display registers of AIC-6260
- */
-static void disp_ports(struct Scsi_Host *shpnt)
-{
-#if defined(AHA152X_DEBUG)
-	int s;
-
-	printk("\n%s: %s(%s) ",
-		CURRENT_SC ? "busy" : "waiting",
-		states[STATE].name,
-		states[PREVSTATE].name);
-
-	s = GETPORT(SCSISEQ);
-	printk("SCSISEQ( ");
-	if (s & TEMODEO)
-		printk("TARGET MODE ");
-	if (s & ENSELO)
-		printk("SELO ");
-	if (s & ENSELI)
-		printk("SELI ");
-	if (s & ENRESELI)
-		printk("RESELI ");
-	if (s & ENAUTOATNO)
-		printk("AUTOATNO ");
-	if (s & ENAUTOATNI)
-		printk("AUTOATNI ");
-	if (s & ENAUTOATNP)
-		printk("AUTOATNP ");
-	if (s & SCSIRSTO)
-		printk("SCSIRSTO ");
-	printk(");");
-
-	printk(" SCSISIG(");
-	s = GETPORT(SCSISIG);
-	switch (s & P_MASK) {
-	case P_DATAO:
-		printk("DATA OUT");
-		break;
-	case P_DATAI:
-		printk("DATA IN");
-		break;
-	case P_CMD:
-		printk("COMMAND");
-		break;
-	case P_STATUS:
-		printk("STATUS");
-		break;
-	case P_MSGO:
-		printk("MESSAGE OUT");
-		break;
-	case P_MSGI:
-		printk("MESSAGE IN");
-		break;
-	default:
-		printk("*invalid*");
-		break;
-	}
-
-	printk("); ");
-
-	printk("INTSTAT (%s); ", TESTHI(DMASTAT, INTSTAT) ? "hi" : "lo");
-
-	printk("SSTAT( ");
-	s = GETPORT(SSTAT0);
-	if (s & TARGET)
-		printk("TARGET ");
-	if (s & SELDO)
-		printk("SELDO ");
-	if (s & SELDI)
-		printk("SELDI ");
-	if (s & SELINGO)
-		printk("SELINGO ");
-	if (s & SWRAP)
-		printk("SWRAP ");
-	if (s & SDONE)
-		printk("SDONE ");
-	if (s & SPIORDY)
-		printk("SPIORDY ");
-	if (s & DMADONE)
-		printk("DMADONE ");
-
-	s = GETPORT(SSTAT1);
-	if (s & SELTO)
-		printk("SELTO ");
-	if (s & ATNTARG)
-		printk("ATNTARG ");
-	if (s & SCSIRSTI)
-		printk("SCSIRSTI ");
-	if (s & PHASEMIS)
-		printk("PHASEMIS ");
-	if (s & BUSFREE)
-		printk("BUSFREE ");
-	if (s & SCSIPERR)
-		printk("SCSIPERR ");
-	if (s & PHASECHG)
-		printk("PHASECHG ");
-	if (s & REQINIT)
-		printk("REQINIT ");
-	printk("); ");
-
-
-	printk("SSTAT( ");
-
-	s = GETPORT(SSTAT0) & GETPORT(SIMODE0);
-
-	if (s & TARGET)
-		printk("TARGET ");
-	if (s & SELDO)
-		printk("SELDO ");
-	if (s & SELDI)
-		printk("SELDI ");
-	if (s & SELINGO)
-		printk("SELINGO ");
-	if (s & SWRAP)
-		printk("SWRAP ");
-	if (s & SDONE)
-		printk("SDONE ");
-	if (s & SPIORDY)
-		printk("SPIORDY ");
-	if (s & DMADONE)
-		printk("DMADONE ");
-
-	s = GETPORT(SSTAT1) & GETPORT(SIMODE1);
-
-	if (s & SELTO)
-		printk("SELTO ");
-	if (s & ATNTARG)
-		printk("ATNTARG ");
-	if (s & SCSIRSTI)
-		printk("SCSIRSTI ");
-	if (s & PHASEMIS)
-		printk("PHASEMIS ");
-	if (s & BUSFREE)
-		printk("BUSFREE ");
-	if (s & SCSIPERR)
-		printk("SCSIPERR ");
-	if (s & PHASECHG)
-		printk("PHASECHG ");
-	if (s & REQINIT)
-		printk("REQINIT ");
-	printk("); ");
-
-	printk("SXFRCTL0( ");
-
-	s = GETPORT(SXFRCTL0);
-	if (s & SCSIEN)
-		printk("SCSIEN ");
-	if (s & DMAEN)
-		printk("DMAEN ");
-	if (s & CH1)
-		printk("CH1 ");
-	if (s & CLRSTCNT)
-		printk("CLRSTCNT ");
-	if (s & SPIOEN)
-		printk("SPIOEN ");
-	if (s & CLRCH1)
-		printk("CLRCH1 ");
-	printk("); ");
-
-	printk("SIGNAL( ");
-
-	s = GETPORT(SCSISIG);
-	if (s & SIG_ATNI)
-		printk("ATNI ");
-	if (s & SIG_SELI)
-		printk("SELI ");
-	if (s & SIG_BSYI)
-		printk("BSYI ");
-	if (s & SIG_REQI)
-		printk("REQI ");
-	if (s & SIG_ACKI)
-		printk("ACKI ");
-	printk("); ");
-
-	printk("SELID (%02x), ", GETPORT(SELID));
-
-	printk("STCNT (%d), ", GETSTCNT());
-	
-	printk("SSTAT2( ");
-
-	s = GETPORT(SSTAT2);
-	if (s & SOFFSET)
-		printk("SOFFSET ");
-	if (s & SEMPTY)
-		printk("SEMPTY ");
-	if (s & SFULL)
-		printk("SFULL ");
-	printk("); SFCNT (%d); ", s & (SFULL | SFCNT));
-
-	s = GETPORT(SSTAT3);
-	printk("SCSICNT (%d), OFFCNT(%d), ", (s & 0xf0) >> 4, s & 0x0f);
-
-	printk("SSTAT4( ");
-	s = GETPORT(SSTAT4);
-	if (s & SYNCERR)
-		printk("SYNCERR ");
-	if (s & FWERR)
-		printk("FWERR ");
-	if (s & FRERR)
-		printk("FRERR ");
-	printk("); ");
-
-	printk("DMACNTRL0( ");
-	s = GETPORT(DMACNTRL0);
-	printk("%s ", s & _8BIT ? "8BIT" : "16BIT");
-	printk("%s ", s & DMA ? "DMA" : "PIO");
-	printk("%s ", s & WRITE_READ ? "WRITE" : "READ");
-	if (s & ENDMA)
-		printk("ENDMA ");
-	if (s & INTEN)
-		printk("INTEN ");
-	if (s & RSTFIFO)
-		printk("RSTFIFO ");
-	if (s & SWINT)
-		printk("SWINT ");
-	printk("); ");
-
-	printk("DMASTAT( ");
-	s = GETPORT(DMASTAT);
-	if (s & ATDONE)
-		printk("ATDONE ");
-	if (s & WORDRDY)
-		printk("WORDRDY ");
-	if (s & DFIFOFULL)
-		printk("DFIFOFULL ");
-	if (s & DFIFOEMP)
-		printk("DFIFOEMP ");
-	printk(")\n");
-#endif
-}
-
-/*
  * display enabled interrupts
  */
 static void disp_enintr(struct Scsi_Host *shpnt)
 {
-	int s;
-
-	printk(KERN_DEBUG "enabled interrupts ( ");
-
-	s = GETPORT(SIMODE0);
-	if (s & ENSELDO)
-		printk("ENSELDO ");
-	if (s & ENSELDI)
-		printk("ENSELDI ");
-	if (s & ENSELINGO)
-		printk("ENSELINGO ");
-	if (s & ENSWRAP)
-		printk("ENSWRAP ");
-	if (s & ENSDONE)
-		printk("ENSDONE ");
-	if (s & ENSPIORDY)
-		printk("ENSPIORDY ");
-	if (s & ENDMADONE)
-		printk("ENDMADONE ");
-
-	s = GETPORT(SIMODE1);
-	if (s & ENSELTIMO)
-		printk("ENSELTIMO ");
-	if (s & ENATNTARG)
-		printk("ENATNTARG ");
-	if (s & ENPHASEMIS)
-		printk("ENPHASEMIS ");
-	if (s & ENBUSFREE)
-		printk("ENBUSFREE ");
-	if (s & ENSCSIPERR)
-		printk("ENSCSIPERR ");
-	if (s & ENPHASECHG)
-		printk("ENPHASECHG ");
-	if (s & ENREQINIT)
-		printk("ENREQINIT ");
-	printk(")\n");
+	int s0, s1;
+
+	s0 = GETPORT(SIMODE0);
+	s1 = GETPORT(SIMODE1);
+
+	shost_printk(KERN_DEBUG, shpnt,
+		     "enabled interrupts (%s%s%s%s%s%s%s%s%s%s%s%s%s%s)\n",
+		     (s0 & ENSELDO) ? "ENSELDO " : "",
+		     (s0 & ENSELDI) ? "ENSELDI " : "",
+		     (s0 & ENSELINGO) ? "ENSELINGO " : "",
+		     (s0 & ENSWRAP) ? "ENSWRAP " : "",
+		     (s0 & ENSDONE) ? "ENSDONE " : "",
+		     (s0 & ENSPIORDY) ? "ENSPIORDY " : "",
+		     (s0 & ENDMADONE) ? "ENDMADONE " : "",
+		     (s1 & ENSELTIMO) ? "ENSELTIMO " : "",
+		     (s1 & ENATNTARG) ? "ENATNTARG " : "",
+		     (s1 & ENPHASEMIS) ? "ENPHASEMIS " : "",
+		     (s1 & ENBUSFREE) ? "ENBUSFREE " : "",
+		     (s1 & ENSCSIPERR) ? "ENSCSIPERR " : "",
+		     (s1 & ENPHASECHG) ? "ENPHASECHG " : "",
+		     (s1 & ENREQINIT) ? "ENREQINIT " : "");
 }
 
 /*
@@ -2972,7 +2499,6 @@ static void show_queues(struct Scsi_Host *shpnt)
 	for (ptr = DISCONNECTED_SC; ptr; ptr = SCDATA(ptr) ? SCNEXT(ptr) : NULL)
 		show_command(ptr);
 
-	disp_ports(shpnt);
 	disp_enintr(shpnt);
 }
 
@@ -3276,15 +2802,6 @@ static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length)
 	if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0)
 		return -EINVAL;
 
-#if defined(AHA152X_DEBUG)
-	if(length>14 && strncmp("debug ", buffer+8, 6)==0) {
-		int debug = HOSTDATA(shpnt)->debug;
-
-		HOSTDATA(shpnt)->debug = simple_strtoul(buffer+14, NULL, 0);
-
-		printk(KERN_INFO "aha152x%d: debugging options set to 0x%04x (were 0x%04x)\n", HOSTNO, HOSTDATA(shpnt)->debug, debug);
-	} else
-#endif
 #if defined(AHA152X_STAT)
 	if(length>13 && strncmp("reset", buffer+8, 5)==0) {
 		int i;
@@ -3302,7 +2819,7 @@ static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length)
 			HOSTDATA(shpnt)->time[i]=0;
 		}
 
-		printk(KERN_INFO "aha152x%d: stats reseted.\n", HOSTNO);
+		shost_printk(KERN_INFO, shpnt, "aha152x: stats reset.\n");
 
 	} else
 #endif
@@ -3343,29 +2860,6 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
 					(((HOSTDATA(shpnt)->syncrate[i] & 0x70) >> 4) + 2) * 50,
 				    HOSTDATA(shpnt)->syncrate[i] & 0x0f);
 	}
-#if defined(AHA152X_DEBUG)
-#define PDEBUG(flags,txt) \
-	if(HOSTDATA(shpnt)->debug & flags) SPRINTF("(%s) ", txt);
-
-	SPRINTF("enabled debugging options: ");
-
-	PDEBUG(debug_procinfo, "procinfo");
-	PDEBUG(debug_queue, "queue");
-	PDEBUG(debug_intr, "interrupt");
-	PDEBUG(debug_selection, "selection");
-	PDEBUG(debug_msgo, "message out");
-	PDEBUG(debug_msgi, "message in");
-	PDEBUG(debug_status, "status");
-	PDEBUG(debug_cmd, "command");
-	PDEBUG(debug_datai, "data in");
-	PDEBUG(debug_datao, "data out");
-	PDEBUG(debug_eh, "eh");
-	PDEBUG(debug_locking, "locks");
-	PDEBUG(debug_phases, "phases");
-
-	SPRINTF("\n");
-#endif
-
 	SPRINTF("\nqueue status:\n");
 	DO_LOCK(flags);
 	if (ISSUE_SC) {
@@ -3393,8 +2887,8 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
 
 #if defined(AHA152X_STAT)
 	SPRINTF("statistics:\n"
-	        "total commands:               %d\n"
-	        "disconnections:               %d\n"
+		"total commands:               %d\n"
+		"disconnections:               %d\n"
 		"busfree with check condition: %d\n"
 		"busfree without old command:  %d\n"
 		"busfree without new command:  %d\n"
@@ -3413,7 +2907,7 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt)
 		HOSTDATA(shpnt)->busfree_without_any_action);
 	for(i=0; i<maxstate; i++) {
 		SPRINTF("%-10s %-12d %-12d %-12ld\n",
-		        states[i].name,
+			states[i].name,
 			HOSTDATA(shpnt)->count_trans[i],
 			HOSTDATA(shpnt)->count[i],
 			HOSTDATA(shpnt)->time[i]);
@@ -3671,25 +3165,19 @@ static int __init aha152x_init(void)
 			setup[setup_count].synchronous = aha152x[5];
 			setup[setup_count].delay       = aha152x[6];
 			setup[setup_count].ext_trans   = aha152x[7];
-#if defined(AHA152X_DEBUG)
-			setup[setup_count].debug       = aha152x[8];
-#endif
-	  	} else if(io[0]!=0 || irq[0]!=0) {
+		} else if(io[0]!=0 || irq[0]!=0) {
 			if(io[0]!=0)  setup[setup_count].io_port = io[0];
 			if(irq[0]!=0) setup[setup_count].irq     = irq[0];
 
-	    		setup[setup_count].scsiid      = scsiid[0];
-	    		setup[setup_count].reconnect   = reconnect[0];
-	    		setup[setup_count].parity      = parity[0];
-	    		setup[setup_count].synchronous = sync[0];
-	    		setup[setup_count].delay       = delay[0];
-	    		setup[setup_count].ext_trans   = exttrans[0];
-#if defined(AHA152X_DEBUG)
-			setup[setup_count].debug       = debug[0];
-#endif
+			setup[setup_count].scsiid      = scsiid[0];
+			setup[setup_count].reconnect   = reconnect[0];
+			setup[setup_count].parity      = parity[0];
+			setup[setup_count].synchronous = sync[0];
+			setup[setup_count].delay       = delay[0];
+			setup[setup_count].ext_trans   = exttrans[0];
 		}
 
-          	if (checksetup(&setup[setup_count]))
+		if (checksetup(&setup[setup_count]))
 			setup_count++;
 		else
 			printk(KERN_ERR "aha152x: invalid module params io=0x%x, irq=%d,scsiid=%d,reconnect=%d,parity=%d,sync=%d,delay=%d,exttrans=%d\n",
@@ -3714,22 +3202,16 @@ static int __init aha152x_init(void)
 			setup[setup_count].synchronous = aha152x1[5];
 			setup[setup_count].delay       = aha152x1[6];
 			setup[setup_count].ext_trans   = aha152x1[7];
-#if defined(AHA152X_DEBUG)
-			setup[setup_count].debug       = aha152x1[8];
-#endif
-	  	} else if(io[1]!=0 || irq[1]!=0) {
+		} else if(io[1]!=0 || irq[1]!=0) {
 			if(io[1]!=0)  setup[setup_count].io_port = io[1];
 			if(irq[1]!=0) setup[setup_count].irq     = irq[1];
 
-	    		setup[setup_count].scsiid      = scsiid[1];
-	    		setup[setup_count].reconnect   = reconnect[1];
-	    		setup[setup_count].parity      = parity[1];
-	    		setup[setup_count].synchronous = sync[1];
-	    		setup[setup_count].delay       = delay[1];
-	    		setup[setup_count].ext_trans   = exttrans[1];
-#if defined(AHA152X_DEBUG)
-			setup[setup_count].debug       = debug[1];
-#endif
+			setup[setup_count].scsiid      = scsiid[1];
+			setup[setup_count].reconnect   = reconnect[1];
+			setup[setup_count].parity      = parity[1];
+			setup[setup_count].synchronous = sync[1];
+			setup[setup_count].delay       = delay[1];
+			setup[setup_count].ext_trans   = exttrans[1];
 		}
 		if (checksetup(&setup[setup_count]))
 			setup_count++;
@@ -3776,9 +3258,6 @@ static int __init aha152x_init(void)
 			setup[setup_count].synchronous = 1;
 			setup[setup_count].delay       = DELAY_DEFAULT;
 			setup[setup_count].ext_trans   = 0;
-#if defined(AHA152X_DEBUG)
-			setup[setup_count].debug       = DEBUG_DEFAULT;
-#endif
 #if defined(__ISAPNP__)
 			pnpdev[setup_count]            = dev;
 #endif
@@ -3847,9 +3326,6 @@ static int __init aha152x_init(void)
 			setup[setup_count].synchronous = conf.cf_syncneg;
 			setup[setup_count].delay = DELAY_DEFAULT;
 			setup[setup_count].ext_trans = 0;
-#if defined(AHA152X_DEBUG)
-			setup[setup_count].debug = DEBUG_DEFAULT;
-#endif
 			setup_count++;
 
 		}
@@ -3903,11 +3379,8 @@ module_exit(aha152x_exit);
 #if !defined(MODULE)
 static int __init aha152x_setup(char *str)
 {
-#if defined(AHA152X_DEBUG)
-	int ints[11];
-#else
 	int ints[10];
-#endif
+
 	get_options(str, ARRAY_SIZE(ints), ints);
 
 	if(setup_count>=ARRAY_SIZE(setup)) {
@@ -3924,16 +3397,9 @@ static int __init aha152x_setup(char *str)
 	setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1;
 	setup[setup_count].delay       = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT;
 	setup[setup_count].ext_trans   = ints[0] >= 8 ? ints[8] : 0;
-#if defined(AHA152X_DEBUG)
-	setup[setup_count].debug       = ints[0] >= 9 ? ints[9] : DEBUG_DEFAULT;
-	if (ints[0] > 9) {
-		printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
-		       "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>[,<DEBUG>]]]]]]]]\n");
-#else
 	if (ints[0] > 8) {                                                /*}*/
 		printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
 		       "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n");
-#endif
 	} else {
 		setup_count++;
 		return 0;
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
  2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
  2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
@ 2014-09-03 10:05 ` Hannes Reinecke
  2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

sd_done() was calling scsi_print_sense() for a sense code
of 'NO_SENSE'.

Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index aa43496..f5ca203 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1730,7 +1730,6 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 		 * unknown amount of data was transferred so treat it as an
 		 * error.
 		 */
-		scsi_print_sense("sd", SCpnt);
 		SCpnt->result = 0;
 		memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 		break;
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 04/20] scsi: introduce sdev_prefix_printk()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (2 preceding siblings ...)
  2014-09-03 10:05 ` [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
@ 2014-09-03 10:05 ` Hannes Reinecke
  2014-09-06  0:03   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 05/20] scsi: Use sdev as argument for sense code printing Hannes Reinecke
                   ` (16 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Like scmd_printk(), but the device name is passed in as
a string. Can be used by eg ULDs which do not have access
to the scsi_cmnd structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 include/scsi/scsi_device.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 1a0d184..4e091c8 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -243,6 +243,15 @@ struct scsi_dh_data {
 #define sdev_dbg(sdev, fmt, a...) \
 	dev_dbg(&(sdev)->sdev_gendev, fmt, ##a)
 
+/*
+ * like scmd_printk, but the device name is passed in
+ * as a string pointer
+ */
+#define sdev_prefix_printk(l, sdev, p, fmt, a...)			\
+	(p) ?								\
+	sdev_printk(l, sdev, "[%s] " fmt, p, ##a) :			\
+	sdev_printk(l, sdev, fmt, ##a)
+
 #define scmd_printk(prefix, scmd, fmt, a...)				\
         (scmd)->request->rq_disk ?					\
 	sdev_printk(prefix, (scmd)->device, "[%s] " fmt,		\
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 05/20] scsi: Use sdev as argument for sense code printing
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (3 preceding siblings ...)
  2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

We should be using the standard dev_printk() variants for
sense code printing.

Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/53c700.c      |   2 +-
 drivers/scsi/ch.c          |   2 +-
 drivers/scsi/constants.c   | 113 +++++++++++++++++++++------------------------
 drivers/scsi/osst.c        |   8 ++--
 drivers/scsi/scsi.c        |   2 +-
 drivers/scsi/scsi_error.c  |   2 +-
 drivers/scsi/scsi_ioctl.c  |   2 +-
 drivers/scsi/scsi_lib.c    |   4 +-
 drivers/scsi/sd.c          |   9 ++--
 drivers/scsi/sg.c          |   2 +-
 drivers/scsi/sr_ioctl.c    |   6 +--
 drivers/scsi/st.c          |   6 ++-
 drivers/scsi/storvsc_drv.c |   3 +-
 include/scsi/scsi_dbg.h    |  17 ++++---
 14 files changed, 91 insertions(+), 87 deletions(-)

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index fabd4be..68bf423 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -602,7 +602,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
 #ifdef NCR_700_DEBUG
 			printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n",
 			       SCp, SCp->cmnd[7], result);
-			scsi_print_sense("53c700", SCp);
+			scsi_print_sense(SCp);
 
 #endif
 			dma_unmap_single(hostdata->dev, slot->dma_handle,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index ef5ae0d..eea94a9 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -207,7 +207,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
 	DPRINTK("result: 0x%x\n",result);
 	if (driver_byte(result) & DRIVER_SENSE) {
 		if (debug)
-			scsi_print_sense_hdr(ch->name, &sshdr);
+			scsi_print_sense_hdr(ch->device, ch->name, &sshdr);
 		errno = ch_find_errno(&sshdr);
 
 		switch(sshdr.sense_key) {
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 2f44707..4ada834 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1292,18 +1292,19 @@ static const struct error_info additional[] =
 
 struct error_info2 {
 	unsigned char code1, code2_min, code2_max;
+	const char * str;
 	const char * fmt;
 };
 
 static const struct error_info2 additional2[] =
 {
-	{0x40, 0x00, 0x7f, "Ram failure (%x)"},
-	{0x40, 0x80, 0xff, "Diagnostic failure on component (%x)"},
-	{0x41, 0x00, 0xff, "Data path failure (%x)"},
-	{0x42, 0x00, 0xff, "Power-on or self-test failure (%x)"},
-	{0x4D, 0x00, 0xff, "Tagged overlapped commands (task tag %x)"},
-	{0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"},
-	{0, 0, 0, NULL}
+	{0x40, 0x00, 0x7f, "Ram failure", ""},
+	{0x40, 0x80, 0xff, "Diagnostic failure on component", ""},
+	{0x41, 0x00, 0xff, "Data path failure", ""},
+	{0x42, 0x00, 0xff, "Power-on or self-test failure", ""},
+	{0x4D, 0x00, 0xff, "Tagged overlapped commands", "task tag "},
+	{0x70, 0x00, 0xff, "Decompression exception", "short algorithm id of "},
+	{0, 0, 0, NULL, NULL}
 };
 
 /* description of the sense key values */
@@ -1349,7 +1350,8 @@ EXPORT_SYMBOL(scsi_sense_key_string);
  * This string may contain a "%x" and should be printed with ascq as arg.
  */
 const char *
-scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
+scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
+{
 #ifdef CONFIG_SCSI_CONSTANTS
 	int i;
 	unsigned short code = ((asc << 8) | ascq);
@@ -1361,7 +1363,8 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
 		if (additional2[i].code1 == asc &&
 		    ascq >= additional2[i].code2_min &&
 		    ascq <= additional2[i].code2_max)
-			return additional2[i].fmt;
+			*fmt = additional2[i].fmt;
+			return additional2[i].str;
 	}
 #endif
 	return NULL;
@@ -1369,49 +1372,47 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
 EXPORT_SYMBOL(scsi_extd_sense_format);
 
 void
-scsi_show_extd_sense(unsigned char asc, unsigned char ascq)
+scsi_show_extd_sense(struct scsi_device *sdev, const char *name,
+		     unsigned char asc, unsigned char ascq)
 {
-        const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
-
-	if (extd_sense_fmt) {
-		if (strstr(extd_sense_fmt, "%x")) {
-			printk("Add. Sense: ");
-			printk(extd_sense_fmt, ascq);
-		} else
-			printk("Add. Sense: %s", extd_sense_fmt);
+	const char *extd_sense_fmt = NULL;
+	const char *extd_sense_str = scsi_extd_sense_format(asc, ascq,
+							    &extd_sense_str);
+
+	if (extd_sense_str) {
+		sdev_prefix_printk(KERN_INFO, sdev, name,
+				   "Add. Sense: %s (%s%x)",
+				   extd_sense_str, extd_sense_fmt, ascq);
 	} else {
-		if (asc >= 0x80)
-			printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc,
-			       ascq);
-		if (ascq >= 0x80)
-			printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc,
-			       ascq);
-		else
-			printk("ASC=0x%x ASCQ=0x%x", asc, ascq);
+		sdev_prefix_printk(KERN_INFO, sdev, name,
+				   "%sASC=0x%x %sASCQ=0x%x\n",
+				   asc >= 0x80 ? "<<vendor>> " : "", asc,
+				   ascq >= 0x80 ? "<<vendor>> " : "", ascq);
 	}
-
-	printk("\n");
 }
 EXPORT_SYMBOL(scsi_show_extd_sense);
 
 void
-scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr)
+scsi_show_sense_hdr(struct scsi_device *sdev, const char *name,
+		    struct scsi_sense_hdr *sshdr)
 {
 	const char *sense_txt;
 
 	sense_txt = scsi_sense_key_string(sshdr->sense_key);
 	if (sense_txt)
-		printk("Sense Key : %s ", sense_txt);
+		sdev_prefix_printk(KERN_INFO, sdev, name,
+				   "Sense Key : %s [%s]%s\n", sense_txt,
+				   scsi_sense_is_deferred(sshdr) ?
+				   "deferred" : "current",
+				   sshdr->response_code >= 0x72 ?
+				   " [descriptor]" : "");
 	else
-		printk("Sense Key : 0x%x ", sshdr->sense_key);
-
-	printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " :
-	       "[current] ");
-
-	if (sshdr->response_code >= 0x72)
-		printk("[descriptor]");
-
-	printk("\n");
+		sdev_prefix_printk(KERN_INFO, sdev, name,
+				   "Sense Key : 0x%x [%s]%s", sshdr->sense_key,
+				   scsi_sense_is_deferred(sshdr) ?
+				   "deferred" : "current",
+				   sshdr->response_code >= 0x72 ?
+				   " [descriptor]" : "");
 }
 EXPORT_SYMBOL(scsi_show_sense_hdr);
 
@@ -1419,12 +1420,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr);
  * Print normalized SCSI sense header with a prefix.
  */
 void
-scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr)
+scsi_print_sense_hdr(struct scsi_device *sdev, const char *name,
+		     struct scsi_sense_hdr *sshdr)
 {
-	printk(KERN_INFO "%s: ", name);
-	scsi_show_sense_hdr(sshdr);
-	printk(KERN_INFO "%s: ", name);
-	scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
+	scsi_show_sense_hdr(sdev, name, sshdr);
+	scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq);
 }
 EXPORT_SYMBOL(scsi_print_sense_hdr);
 
@@ -1513,33 +1513,26 @@ scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
 }
 
 /* Normalize and print sense buffer with name prefix */
-void __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
-			int sense_len)
+void __scsi_print_sense(struct scsi_device *sdev, const char *name,
+			const unsigned char *sense_buffer, int sense_len)
 {
 	struct scsi_sense_hdr sshdr;
 
-	printk(KERN_INFO "%s: ", name);
 	scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
-	scsi_show_sense_hdr(&sshdr);
+	scsi_show_sense_hdr(sdev, name, &sshdr);
 	scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
-	printk(KERN_INFO "%s: ", name);
-	scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
+	scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
 }
 EXPORT_SYMBOL(__scsi_print_sense);
 
 /* Normalize and print sense buffer in SCSI command */
-void scsi_print_sense(char *name, struct scsi_cmnd *cmd)
+void scsi_print_sense(struct scsi_cmnd *cmd)
 {
-	struct scsi_sense_hdr sshdr;
+	struct gendisk *disk = cmd->request->rq_disk;
+	const char *disk_name = disk ? disk->disk_name : NULL;
 
-	scmd_printk(KERN_INFO, cmd, " ");
-	scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
-				 &sshdr);
-	scsi_show_sense_hdr(&sshdr);
-	scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
-				 &sshdr);
-	scmd_printk(KERN_INFO, cmd, " ");
-	scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
+	__scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer,
+			   SCSI_SENSE_BUFFERSIZE);
 }
 EXPORT_SYMBOL(scsi_print_sense);
 
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 0727ea7..4ba2a9f 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -259,9 +259,10 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
 		   SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
 		   SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
 		if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n",
-			       	name, scode, sense[12], sense[13]);
+				  name, scode, sense[12], sense[13]);
 		if (cmdstatp->have_sense)
-			__scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+			__scsi_print_sense(STp->device, name,
+					   SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
 	}
 	else
 #endif
@@ -275,7 +276,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
 		 SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */
 		if (cmdstatp->have_sense) {
 			printk(KERN_WARNING "%s:W: Command with sense data:\n", name);
-			__scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+			__scsi_print_sense(STp->device, name,
+					   SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
 		}
 		else {
 			static	int	notyetprinted = 1;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index df33060..8954036 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -598,7 +598,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
 			scsi_print_result(cmd);
 			scsi_print_command(cmd);
 			if (status_byte(cmd->result) & CHECK_CONDITION)
-				scsi_print_sense("", cmd);
+				scsi_print_sense(cmd);
 			if (level > 3)
 				scmd_printk(KERN_INFO, cmd,
 					    "scsi host busy %d failed %d\n",
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 6b20ef3..6c99624 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1180,7 +1180,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
 		SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
 			"sense requested for %p result %x\n",
 			scmd, scmd->result));
-		SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense("bh", scmd));
+		SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd));
 
 		rtn = scsi_decide_disposition(scmd);
 
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 1aaaf43..7d2de08 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -126,7 +126,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 			sdev_printk(KERN_INFO, sdev,
 				    "ioctl_internal_command return code = %x\n",
 				    result);
-			scsi_print_sense_hdr("   ", &sshdr);
+			scsi_print_sense_hdr(sdev, NULL, &sshdr);
 			break;
 		}
 	}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8b76231..de178f7 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -911,7 +911,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 		if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d))
 			;
 		else if (!(req->cmd_flags & REQ_QUIET))
-			scsi_print_sense("", cmd);
+			scsi_print_sense(cmd);
 		result = 0;
 		/* BLOCK_PC may have set error */
 		error = 0;
@@ -1040,7 +1040,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 		if (!(req->cmd_flags & REQ_QUIET)) {
 			scsi_print_result(cmd);
 			if (driver_byte(result) & DRIVER_SENSE)
-				scsi_print_sense("", cmd);
+				scsi_print_sense(cmd);
 			scsi_print_command(cmd);
 		}
 		if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0))
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f5ca203..aac267a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3319,10 +3319,11 @@ module_exit(exit_sd);
 static void sd_print_sense_hdr(struct scsi_disk *sdkp,
 			       struct scsi_sense_hdr *sshdr)
 {
-	sd_printk(KERN_INFO, sdkp, " ");
-	scsi_show_sense_hdr(sshdr);
-	sd_printk(KERN_INFO, sdkp, " ");
-	scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
+	scsi_show_sense_hdr(sdkp->device,
+			    sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr);
+	scsi_show_extd_sense(sdkp->device,
+			     sdkp->disk ? sdkp->disk->disk_name : NULL,
+			     sshdr->asc, sshdr->ascq);
 }
 
 static void sd_print_result(struct scsi_disk *sdkp, int result)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 01cf888..16f826e 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1360,7 +1360,7 @@ sg_rq_end_io(struct request *rq, int uptodate)
 		if ((sdp->sgdebug > 0) &&
 		    ((CHECK_CONDITION == srp->header.masked_status) ||
 		     (COMMAND_TERMINATED == srp->header.masked_status)))
-			__scsi_print_sense(__func__, sense,
+			__scsi_print_sense(sdp->device, __func__, sense,
 					   SCSI_SENSE_BUFFERSIZE);
 
 		/* Following if statement is a patch supplied by Eric Youngdale */
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 6389fcf..17e0c2b 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -246,7 +246,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 					  "CDROM not ready.  Make sure there "
 					  "is a disc in the drive.\n");
 #ifdef DEBUG
-			scsi_print_sense_hdr("sr", &sshdr);
+			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
 #endif
 			err = -ENOMEDIUM;
 			break;
@@ -258,14 +258,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 				err = -EDRIVE_CANT_DO_THIS;
 #ifdef DEBUG
 			__scsi_print_command(cgc->cmd);
-			scsi_print_sense_hdr("sr", &sshdr);
+			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
 #endif
 			break;
 		default:
 			sr_printk(KERN_ERR, cd,
 				  "CDROM (ioctl) error, command: ");
 			__scsi_print_command(cgc->cmd);
-			scsi_print_sense_hdr("sr", &sshdr);
+			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
 			err = -EIO;
 		}
 	}
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index aff9689..c0cc4ca 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -374,7 +374,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
 			    SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
 			    SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
 		if (cmdstatp->have_sense)
-			 __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+			__scsi_print_sense(STp->device, name,
+					   SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
 	} ) /* end DEB */
 	if (!debugging) { /* Abnormal conditions for tape */
 		if (!cmdstatp->have_sense)
@@ -390,7 +391,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
 			 SRpnt->cmd[0] != MODE_SENSE &&
 			 SRpnt->cmd[0] != TEST_UNIT_READY) {
 
-			__scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
+			__scsi_print_sense(STp->device, name,
+					   SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
 		}
 	}
 
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index fecac5d0..9168d1b 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1097,7 +1097,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
 	if (scmnd->result) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
 				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
-			scsi_print_sense_hdr("storvsc", &sense_hdr);
+			scsi_print_sense_hdr(scmnd->device, "storvsc",
+					     &sense_hdr);
 	}
 
 	if (vm_srb->srb_status != SRB_STATUS_SUCCESS)
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 5a43a4c..cd0c873 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -2,21 +2,26 @@
 #define _SCSI_SCSI_DBG_H
 
 struct scsi_cmnd;
+struct scsi_device;
 struct scsi_sense_hdr;
 
 extern void scsi_print_command(struct scsi_cmnd *);
 extern void __scsi_print_command(unsigned char *);
-extern void scsi_show_extd_sense(unsigned char, unsigned char);
-extern void scsi_show_sense_hdr(struct scsi_sense_hdr *);
-extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
-extern void scsi_print_sense(char *, struct scsi_cmnd *);
-extern void __scsi_print_sense(const char *name,
+extern void scsi_show_extd_sense(struct scsi_device *, const char *,
+				 unsigned char, unsigned char);
+extern void scsi_show_sense_hdr(struct scsi_device *, const char *,
+				struct scsi_sense_hdr *);
+extern void scsi_print_sense_hdr(struct scsi_device *, const char *,
+				 struct scsi_sense_hdr *);
+extern void scsi_print_sense(struct scsi_cmnd *);
+extern void __scsi_print_sense(struct scsi_device *, const char *name,
 			       const unsigned char *sense_buffer,
 			       int sense_len);
 extern void scsi_show_result(int);
 extern void scsi_print_result(struct scsi_cmnd *);
 extern void scsi_print_status(unsigned char);
 extern const char *scsi_sense_key_string(unsigned char);
-extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
+extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
+					  const char **);
 
 #endif /* _SCSI_SCSI_DBG_H */
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (4 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 05/20] scsi: Use sdev as argument for sense code printing Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-06  0:04   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
                   ` (14 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

If scsi_normalize_sense() fails we couldn't decode the sense
buffer, and the scsi_sense_hdr fields are invalid.
For those cases we should rather dump the sense buffer
and not try to decode invalid fields.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 4ada834..7febdb7 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1429,25 +1429,18 @@ scsi_print_sense_hdr(struct scsi_device *sdev, const char *name,
 EXPORT_SYMBOL(scsi_print_sense_hdr);
 
 static void
-scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
-		       struct scsi_sense_hdr *sshdr)
+scsi_dump_sense_buffer(struct scsi_device *sdev, const char *name,
+		       const unsigned char *sense_buffer, int sense_len)
 {
-	int k, num, res;
+	char linebuf[128];
+	int i, linelen;
 
-	res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
-	if (0 == res) {
-		/* this may be SCSI-1 sense data */
-		num = (sense_len < 32) ? sense_len : 32;
-		printk("Unrecognized sense data (in hex):");
-		for (k = 0; k < num; ++k) {
-			if (0 == (k % 16)) {
-				printk("\n");
-				printk(KERN_INFO "        ");
-			}
-			printk("%02x ", sense_buffer[k]);
-		}
-		printk("\n");
-		return;
+	for (i = 0; i < sense_len; i += 16) {
+		linelen = min(sense_len - i, 16);
+		hex_dump_to_buffer(sense_buffer + i, linelen, 16, 1,
+				   linebuf, sizeof(linebuf), false);
+		sdev_prefix_printk(KERN_INFO, sdev, name,
+				   "Sense: %s\n", linebuf);
 	}
 }
 
@@ -1518,7 +1511,10 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name,
 {
 	struct scsi_sense_hdr sshdr;
 
-	scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
+	if (!scsi_normalize_sense(sense_buffer, sense_len, &sshdr)) {
+		scsi_dump_sense_buffer(sdev, name, sense_buffer, sense_len);
+		return;
+	}
 	scsi_show_sense_hdr(sdev, name, &sshdr);
 	scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
 	scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 07/20] scsi: do not decode sense extras
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (5 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-06  0:04   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
                   ` (13 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Currently we're only decoding sense extras for tape devices.
And even there only for fixed format sense formats.
As this is of rather limited use in the general case we should
be stop trying to decode sense extras; the tape driver does
its own decoding anyway.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 62 ------------------------------------------------
 1 file changed, 62 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 7febdb7..2850062e 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1444,67 +1444,6 @@ scsi_dump_sense_buffer(struct scsi_device *sdev, const char *name,
 	}
 }
 
-static void
-scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
-			 struct scsi_sense_hdr *sshdr)
-{
-	int k, num, res;
-
-	if (sshdr->response_code < 0x72)
-	{
-		/* only decode extras for "fixed" format now */
-		char buff[80];
-		int blen, fixed_valid;
-		unsigned int info;
-
-		fixed_valid = sense_buffer[0] & 0x80;
-		info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
-			(sense_buffer[5] << 8) | sense_buffer[6]);
-		res = 0;
-		memset(buff, 0, sizeof(buff));
-		blen = sizeof(buff) - 1;
-		if (fixed_valid)
-			res += snprintf(buff + res, blen - res,
-					"Info fld=0x%x", info);
-		if (sense_buffer[2] & 0x80) {
-			/* current command has read a filemark */
-			if (res > 0)
-				res += snprintf(buff + res, blen - res, ", ");
-			res += snprintf(buff + res, blen - res, "FMK");
-		}
-		if (sense_buffer[2] & 0x40) {
-			/* end-of-medium condition exists */
-			if (res > 0)
-				res += snprintf(buff + res, blen - res, ", ");
-			res += snprintf(buff + res, blen - res, "EOM");
-		}
-		if (sense_buffer[2] & 0x20) {
-			/* incorrect block length requested */
-			if (res > 0)
-				res += snprintf(buff + res, blen - res, ", ");
-			res += snprintf(buff + res, blen - res, "ILI");
-		}
-		if (res > 0)
-			printk("%s\n", buff);
-	} else if (sshdr->additional_length > 0) {
-		/* descriptor format with sense descriptors */
-		num = 8 + sshdr->additional_length;
-		num = (sense_len < num) ? sense_len : num;
-		printk("Descriptor sense data with sense descriptors "
-		       "(in hex):");
-		for (k = 0; k < num; ++k) {
-			if (0 == (k % 16)) {
-				printk("\n");
-				printk(KERN_INFO "        ");
-			}
-			printk("%02x ", sense_buffer[k]);
-		}
-
-		printk("\n");
-	}
-
-}
-
 /* Normalize and print sense buffer with name prefix */
 void __scsi_print_sense(struct scsi_device *sdev, const char *name,
 			const unsigned char *sense_buffer, int sense_len)
@@ -1516,7 +1455,6 @@ void __scsi_print_sense(struct scsi_device *sdev, const char *name,
 		return;
 	}
 	scsi_show_sense_hdr(sdev, name, &sshdr);
-	scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
 	scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
 }
 EXPORT_SYMBOL(__scsi_print_sense);
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (6 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  0:51   ` Yoshihiro YUNOMAE
  2014-09-06  0:09   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
                   ` (12 subsequent siblings)
  20 siblings, 2 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Convert scsi_normalize_sense() and frieds to return 'bool'
instead of an integer.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_error.c | 14 +++++++-------
 drivers/scsi/scsi_lib.c   |  2 +-
 include/scsi/scsi_eh.h    | 12 ++++++------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 6c99624..8a6d382 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -2408,20 +2408,20 @@ EXPORT_SYMBOL(scsi_reset_provider);
  *	responded to a SCSI command with the CHECK_CONDITION status.
  *
  * Return value:
- *	1 if valid sense data information found, else 0;
+ *	true if valid sense data information found, else false;
  */
-int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
-                         struct scsi_sense_hdr *sshdr)
+bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
+			  struct scsi_sense_hdr *sshdr)
 {
 	if (!sense_buffer || !sb_len)
-		return 0;
+		return false;
 
 	memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
 
 	sshdr->response_code = (sense_buffer[0] & 0x7f);
 
 	if (!scsi_sense_valid(sshdr))
-		return 0;
+		return false;
 
 	if (sshdr->response_code >= 0x72) {
 		/*
@@ -2451,11 +2451,11 @@ int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
 		}
 	}
 
-	return 1;
+	return true;
 }
 EXPORT_SYMBOL(scsi_normalize_sense);
 
-int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
+bool scsi_command_normalize_sense(struct scsi_cmnd *cmd,
 				 struct scsi_sense_hdr *sshdr)
 {
 	return scsi_normalize_sense(cmd->sense_buffer,
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index de178f7..8cad004 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -830,7 +830,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	struct request *req = cmd->request;
 	int error = 0;
 	struct scsi_sense_hdr sshdr;
-	int sense_valid = 0;
+	bool sense_valid = false;
 	int sense_deferred = 0;
 	enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
 	      ACTION_DELAYED_RETRY} action;
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 06a8790..1427a66 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -27,7 +27,7 @@ struct scsi_sense_hdr {		/* See SPC-3 section 4.5 */
 	u8 additional_length;	/* always 0 for fixed sense format */
 };
 
-static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr)
+static inline bool scsi_sense_valid(struct scsi_sense_hdr *sshdr)
 {
 	if (!sshdr)
 		return 0;
@@ -42,12 +42,12 @@ extern void scsi_eh_flush_done_q(struct list_head *done_q);
 extern void scsi_report_bus_reset(struct Scsi_Host *, int);
 extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
 extern int scsi_block_when_processing_errors(struct scsi_device *);
-extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
-		struct scsi_sense_hdr *sshdr);
-extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
-		struct scsi_sense_hdr *sshdr);
+extern bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
+				 struct scsi_sense_hdr *sshdr);
+extern bool scsi_command_normalize_sense(struct scsi_cmnd *cmd,
+					 struct scsi_sense_hdr *sshdr);
 
-static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
+static inline bool scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
 {
 	return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
 }
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 09/20] scsi: remove scsi_print_status()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (7 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-06  0:10   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 10/20] Implement scsi_opcode_sa_name Hannes Reinecke
                   ` (11 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Last caller is gone, so we can remove it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 35 -----------------------------------
 include/scsi/scsi_dbg.h  |  1 -
 2 files changed, 36 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 2850062e..d3915d8 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -433,41 +433,6 @@ void scsi_print_command(struct scsi_cmnd *cmd)
 }
 EXPORT_SYMBOL(scsi_print_command);
 
-/**
- *	scsi_print_status - print scsi status description
- *	@scsi_status: scsi status value
- *
- *	If the status is recognized, the description is printed.
- *	Otherwise "Unknown status" is output. No trailing space.
- *	If CONFIG_SCSI_CONSTANTS is not set, then print status in hex
- *	(e.g. "0x2" for Check Condition).
- **/
-void
-scsi_print_status(unsigned char scsi_status) {
-#ifdef CONFIG_SCSI_CONSTANTS
-	const char * ccp;
-
-	switch (scsi_status) {
-	case 0:    ccp = "Good"; break;
-	case 0x2:  ccp = "Check Condition"; break;
-	case 0x4:  ccp = "Condition Met"; break;
-	case 0x8:  ccp = "Busy"; break;
-	case 0x10: ccp = "Intermediate"; break;
-	case 0x14: ccp = "Intermediate-Condition Met"; break;
-	case 0x18: ccp = "Reservation Conflict"; break;
-	case 0x22: ccp = "Command Terminated"; break;	/* obsolete */
-	case 0x28: ccp = "Task set Full"; break;	/* was: Queue Full */
-	case 0x30: ccp = "ACA Active"; break;
-	case 0x40: ccp = "Task Aborted"; break;
-	default:   ccp = "Unknown status";
-	}
-	printk(KERN_INFO "%s", ccp);
-#else
-	printk(KERN_INFO "0x%0x", scsi_status);
-#endif
-}
-EXPORT_SYMBOL(scsi_print_status);
-
 #ifdef CONFIG_SCSI_CONSTANTS
 
 struct error_info {
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index cd0c873..44bea15 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -19,7 +19,6 @@ extern void __scsi_print_sense(struct scsi_device *, const char *name,
 			       int sense_len);
 extern void scsi_show_result(int);
 extern void scsi_print_result(struct scsi_cmnd *);
-extern void scsi_print_status(unsigned char);
 extern const char *scsi_sense_key_string(unsigned char);
 extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
 					  const char **);
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 10/20] Implement scsi_opcode_sa_name
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (8 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Implement a lookup array for SERVICE ACTION commands instead
of hardcoding it in a large switch statement.

Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 132 +++++++++++++++++++----------------------------
 1 file changed, 54 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index d3915d8..364349c 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -244,102 +244,77 @@ static const struct value_name_pair variable_length_arr[] = {
 };
 #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
 
-static const char * get_sa_name(const struct value_name_pair * arr,
-			        int arr_sz, int service_action)
+struct sa_name_list {
+	int cmd;
+	const struct value_name_pair *arr;
+	int arr_sz;
+};
+
+static struct sa_name_list sa_names_arr[] = {
+	{VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
+	{MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
+	{MAINTENANCE_OUT, maint_out_arr, MAINT_OUT_SZ},
+	{PERSISTENT_RESERVE_IN, pr_in_arr, PR_IN_SZ},
+	{PERSISTENT_RESERVE_OUT, pr_out_arr, PR_OUT_SZ},
+	{SERVICE_ACTION_IN_12, serv_in12_arr, SERV_IN12_SZ},
+	{SERVICE_ACTION_OUT_12, serv_out12_arr, SERV_OUT12_SZ},
+	{SERVICE_ACTION_BIDIRECTIONAL, serv_bidi_arr, SERV_BIDI_SZ},
+	{SERVICE_ACTION_IN_16, serv_in16_arr, SERV_IN16_SZ},
+	{SERVICE_ACTION_OUT_16, serv_out16_arr, SERV_OUT16_SZ},
+	{THIRD_PARTY_COPY_IN, tpc_in_arr, TPC_IN_SZ},
+	{THIRD_PARTY_COPY_OUT, tpc_out_arr, TPC_OUT_SZ},
+	{0, NULL, 0},
+};
+#define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
+
+static bool scsi_opcode_sa_name(int cmd, int service_action,
+				const char **sa_name)
 {
-	int k;
+	struct sa_name_list *sa_name_ptr = sa_names_arr;
+	const struct value_name_pair * arr = NULL;
+	int arr_sz, k;
+
+	for (k = 0; k < SA_NAME_LIST_SZ; ++k, ++sa_name_ptr) {
+		if (sa_name_ptr->cmd == cmd) {
+			arr = sa_name_ptr->arr;
+			arr_sz = sa_name_ptr->arr_sz;
+			break;
+		}
+	}
+	if (!arr)
+		return false;
 
 	for (k = 0; k < arr_sz; ++k, ++arr) {
 		if (service_action == arr->value)
 			break;
 	}
-	return (k < arr_sz) ? arr->name : NULL;
+	if (k < arr_sz)
+		*sa_name = arr->name;
+
+	return true;
 }
 
 /* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
 static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 {
 	int sa, len, cdb0;
-	int fin_name = 0;
-	const char * name;
+	const char * name = NULL;
 
 	cdb0 = cdbp[0];
-	switch(cdb0) {
-	case VARIABLE_LENGTH_CMD:
+	if (cdb0 == VARIABLE_LENGTH_CMD) {
 		len = scsi_varlen_cdb_length(cdbp);
 		if (len < 10) {
 			printk("short variable length command, "
 			       "len=%d ext_len=%d", len, cdb_len);
-			break;
+			return;
 		}
 		sa = (cdbp[8] << 8) + cdbp[9];
-		name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ,
-				   sa);
-		if (name)
-			printk("%s", name);
-		else
-			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
-
-		if ((cdb_len > 0) && (len != cdb_len))
-			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
-
-		break;
-	case MAINTENANCE_IN:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
-		fin_name = 1;
-		break;
-	case MAINTENANCE_OUT:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa);
-		fin_name = 1;
-		break;
-	case PERSISTENT_RESERVE_IN:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(pr_in_arr, PR_IN_SZ, sa);
-		fin_name = 1;
-		break;
-	case PERSISTENT_RESERVE_OUT:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(pr_out_arr, PR_OUT_SZ, sa);
-		fin_name = 1;
-		break;
-	case SERVICE_ACTION_IN_12:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa);
-		fin_name = 1;
-		break;
-	case SERVICE_ACTION_OUT_12:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa);
-		fin_name = 1;
-		break;
-	case SERVICE_ACTION_BIDIRECTIONAL:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(serv_bidi_arr, SERV_BIDI_SZ, sa);
-		fin_name = 1;
-		break;
-	case SERVICE_ACTION_IN_16:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa);
-		fin_name = 1;
-		break;
-	case SERVICE_ACTION_OUT_16:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa);
-		fin_name = 1;
-		break;
-	case THIRD_PARTY_COPY_IN:
-		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(tpc_in_arr, TPC_IN_SZ, sa);
-		fin_name = 1;
-		break;
-	case THIRD_PARTY_COPY_OUT:
+	} else {
 		sa = cdbp[1] & 0x1f;
-		name = get_sa_name(tpc_out_arr, TPC_OUT_SZ, sa);
-		fin_name = 1;
-		break;
-	default:
+		len = cdb_len;
+	}
+
+	if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
 		if (cdb0 < 0xc0) {
 			name = cdb_byte0_names[cdb0];
 			if (name)
@@ -348,13 +323,14 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 				printk("cdb[0]=0x%x (reserved)", cdb0);
 		} else
 			printk("cdb[0]=0x%x (vendor)", cdb0);
-		break;
-	}
-	if (fin_name) {
+	} else {
 		if (name)
 			printk("%s", name);
 		else
 			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
+
+		if (cdb_len > 0 && len != cdb_len)
+			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
 	}
 }
 
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 11/20] scsi: Use scsi_print_command() where possible
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (9 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 10/20] Implement scsi_opcode_sa_name Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-06  0:11   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 12/20] scsi: merge print_opcode_name() Hannes Reinecke
                   ` (9 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Some drivers use __scsi_print_command() although in fact
they refer to the scsi command. So move them over to use
scsi_print_command() instead.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/aha152x.c       |  6 ++----
 drivers/scsi/arm/acornscsi.c |  9 +++++----
 drivers/scsi/arm/fas216.c    | 30 +++++++++++++-----------------
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 447568a..bc923d1 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -2443,11 +2443,9 @@ static void disp_enintr(struct Scsi_Host *shpnt)
  */
 static void show_command(Scsi_Cmnd *ptr)
 {
-	scmd_printk(KERN_DEBUG, ptr, "%p: cmnd=(", ptr);
+	scsi_print_command(ptr);
 
-	__scsi_print_command(ptr->cmnd);
-
-	printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |",
+	scmd_printk(KERN_DEBUG, ptr, "request_bufflen=%d; resid=%d; phase |",
 	       scsi_bufflen(ptr), scsi_get_resid(ptr));
 
 	if (ptr->SCp.phase & not_issued)
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index d89b9b4..78dd881 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -850,11 +850,12 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
 			break;
 
 		    default:
-			printk(KERN_ERR "scsi%d.H: incomplete data transfer detected: result=%08X command=",
-				host->host->host_no, SCpnt->result);
-			__scsi_print_command(SCpnt->cmnd);
+			scmd_printk(KERN_ERR, SCPnt,
+				    "incomplete data transfer detected:"
+				    " result=%08X\n", SCpnt->result);
+			scsi_print_command(SCpnt);
 			acornscsi_dumpdma(host, "done");
-		 	acornscsi_dumplog(host, SCpnt->device->id);
+			acornscsi_dumplog(host, SCpnt->device->id);
 			SCpnt->result &= 0xffff;
 			SCpnt->result |= DID_ERROR << 16;
 		    }
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 71cfb1e..778fd36 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -308,8 +308,7 @@ static void fas216_log_command(FAS216_Info *info, int level,
 	fas216_do_log(info, '0' + SCpnt->device->id, fmt, args);
 	va_end(args);
 
-	printk(" CDB: ");
-	__scsi_print_command(SCpnt->cmnd);
+	scsi_print_command(SCpnt);
 }
 
 static void
@@ -2079,12 +2078,12 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result)
 			break;
 
 		default:
-			printk(KERN_ERR "scsi%d.%c: incomplete data transfer "
-				"detected: res=%08X ptr=%p len=%X CDB: ",
-				info->host->host_no, '0' + SCpnt->device->id,
-				SCpnt->result, info->scsi.SCp.ptr,
-				info->scsi.SCp.this_residual);
-			__scsi_print_command(SCpnt->cmnd);
+			scmd_printk(KERN_ERR, SCpnt,
+				    "incomplete data transfer "
+				    "detected: res=%08X ptr=%p len=%X\n",
+				    SCpnt->result, info->scsi.SCp.ptr,
+				    info->scsi.SCp.this_residual);
+			scsi_print_command(SCpnt->cmnd);
 			SCpnt->result &= ~(255 << 16);
 			SCpnt->result |= DID_BAD_TARGET << 16;
 			goto request_sense;
@@ -2158,12 +2157,11 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
 	 * to transfer, we should not have a valid pointer.
 	 */
 	if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) {
-		printk("scsi%d.%c: zero bytes left to transfer, but "
-		       "buffer pointer still valid: ptr=%p len=%08x CDB: ",
-		       info->host->host_no, '0' + SCpnt->device->id,
-		       info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
+		scmd_printk(KERN_INFO, SCpnt, "zero bytes left to transfer, "
+			    "but buffer pointer still valid: ptr=%p len=%08x\n",
+			    info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
 		info->scsi.SCp.ptr = NULL;
-		__scsi_print_command(SCpnt->cmnd);
+		scsi_print_command(SCpnt);
 	}
 
 	/*
@@ -2427,14 +2425,12 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
 
 	info->stats.aborts += 1;
 
-	printk(KERN_WARNING "scsi%d: abort command ", info->host->host_no);
-	__scsi_print_command(SCpnt->cmnd);
+	scmd_printk(KERN_WARNING, SCpnt, "abort command %p\n", SCpnt);
+	scsi_print_command(SCpnt);
 
 	print_debug_list();
 	fas216_dumpstate(info);
 
-	printk(KERN_WARNING "scsi%d: abort %p ", info->host->host_no, SCpnt);
-
 	switch (fas216_find_command(info, SCpnt)) {
 	/*
 	 * We found the command, and cleared it out.  Either
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 12/20] scsi: merge print_opcode_name()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (10 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  1:24   ` Yoshihiro YUNOMAE
  2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
                   ` (8 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Instead of having two versions of print_opcode_name() we
should be consolidating them into one version.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 90 +++++++++++++++++++-----------------------------
 1 file changed, 35 insertions(+), 55 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 364349c..3aee43b 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -30,6 +30,11 @@
 #define THIRD_PARTY_COPY_IN 0x84
 
 
+struct sa_name_list {
+	int cmd;
+	const struct value_name_pair *arr;
+	int arr_sz;
+};
 
 #ifdef CONFIG_SCSI_CONSTANTS
 static const char * cdb_byte0_names[] = {
@@ -244,12 +249,6 @@ static const struct value_name_pair variable_length_arr[] = {
 };
 #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
 
-struct sa_name_list {
-	int cmd;
-	const struct value_name_pair *arr;
-	int arr_sz;
-};
-
 static struct sa_name_list sa_names_arr[] = {
 	{VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
 	{MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
@@ -267,6 +266,28 @@ static struct sa_name_list sa_names_arr[] = {
 };
 #define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
 
+#else /* ifndef CONFIG_SCSI_CONSTANTS */
+static const char * cdb_byte0_names[] = NULL;
+
+static struct sa_name_list sa_names_arr[] = {
+	{VARIABLE_LENGTH_CMD, NULL, 0},
+	{MAINTENANCE_IN, NULL, 0},
+	{MAINTENANCE_OUT, NULL, 0},
+	{PERSISTENT_RESERVE_IN, NULL, 0},
+	{PERSISTENT_RESERVE_OUT, NULL, 0},
+	{SERVICE_ACTION_IN_12, NULL, 0},
+	{SERVICE_ACTION_OUT_12, NULL, 0},
+	{SERVICE_ACTION_BIDIRECTIONAL, NULL, 0},
+	{SERVICE_ACTION_IN_16, NULL, 0},
+	{SERVICE_ACTION_OUT_16, NULL, 0},
+	{THIRD_PARTY_COPY_IN, NULL, 0},
+	{THIRD_PARTY_COPY_OUT, NULL, 0},
+	{0, NULL, 0},
+};
+#endif /* CONFIG_SCSI_CONSTANTS */
+#define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
+#define CDB_BYTE0_NAMES_SZ ARRAY_SIZE(cdb_byte0_names)
+
 static bool scsi_opcode_sa_name(int cmd, int service_action,
 				const char **sa_name)
 {
@@ -316,11 +337,14 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 
 	if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
 		if (cdb0 < 0xc0) {
-			name = cdb_byte0_names[cdb0];
-			if (name)
-				printk("%s", name);
-			else
-				printk("cdb[0]=0x%x (reserved)", cdb0);
+			if (CDB_BYTE0_NAMES_SZ) {
+				name = cdb_byte0_names[cdb0];
+				if (name)
+					printk("%s", name);
+				else
+					printk("cdb[0]=0x%x (reserved)", cdb0);
+			} else
+				printk("cdb[0]=0x%x", cdb0);
 		} else
 			printk("cdb[0]=0x%x (vendor)", cdb0);
 	} else {
@@ -334,50 +358,6 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 	}
 }
 
-#else /* ifndef CONFIG_SCSI_CONSTANTS */
-
-static void print_opcode_name(unsigned char * cdbp, int cdb_len)
-{
-	int sa, len, cdb0;
-
-	cdb0 = cdbp[0];
-	switch(cdb0) {
-	case VARIABLE_LENGTH_CMD:
-		len = scsi_varlen_cdb_length(cdbp);
-		if (len < 10) {
-			printk("short opcode=0x%x command, len=%d "
-			       "ext_len=%d", cdb0, len, cdb_len);
-			break;
-		}
-		sa = (cdbp[8] << 8) + cdbp[9];
-		printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
-		if (len != cdb_len)
-			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
-		break;
-	case MAINTENANCE_IN:
-	case MAINTENANCE_OUT:
-	case PERSISTENT_RESERVE_IN:
-	case PERSISTENT_RESERVE_OUT:
-	case SERVICE_ACTION_IN_12:
-	case SERVICE_ACTION_OUT_12:
-	case SERVICE_ACTION_BIDIRECTIONAL:
-	case SERVICE_ACTION_IN_16:
-	case SERVICE_ACTION_OUT_16:
-	case THIRD_PARTY_COPY_IN:
-	case THIRD_PARTY_COPY_OUT:
-		sa = cdbp[1] & 0x1f;
-		printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
-		break;
-	default:
-		if (cdb0 < 0xc0)
-			printk("cdb[0]=0x%x", cdb0);
-		else
-			printk("cdb[0]=0x%x (vendor)", cdb0);
-		break;
-	}
-}
-#endif
-
 void __scsi_print_command(unsigned char *cdb)
 {
 	int k, len;
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (11 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 12/20] scsi: merge print_opcode_name() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-06  0:46   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
                   ` (7 subsequent siblings)
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Consolidate the CDB opcode lookup in scsi_opcode_sa_name(),
so that we don't have to call several functions to figure
out the CDB opcode string.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 3aee43b..6076969 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -289,12 +289,19 @@ static struct sa_name_list sa_names_arr[] = {
 #define CDB_BYTE0_NAMES_SZ ARRAY_SIZE(cdb_byte0_names)
 
 static bool scsi_opcode_sa_name(int cmd, int service_action,
-				const char **sa_name)
+				const char **cdb_name, const char **sa_name)
 {
 	struct sa_name_list *sa_name_ptr = sa_names_arr;
 	const struct value_name_pair * arr = NULL;
 	int arr_sz, k;
 
+	*cdb_name = NULL;
+	if (cmd >= 0xc0)
+		return false;
+
+	if (cmd < CDB_BYTE0_NAMES_SZ)
+		*cdb_name = cdb_byte0_names[cmd];
+
 	for (k = 0; k < SA_NAME_LIST_SZ; ++k, ++sa_name_ptr) {
 		if (sa_name_ptr->cmd == cmd) {
 			arr = sa_name_ptr->arr;
@@ -319,7 +326,7 @@ static bool scsi_opcode_sa_name(int cmd, int service_action,
 static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 {
 	int sa, len, cdb0;
-	const char * name = NULL;
+	const char *cdb_name = NULL, *sa_name = NULL;
 
 	cdb0 = cdbp[0];
 	if (cdb0 == VARIABLE_LENGTH_CMD) {
@@ -335,21 +342,20 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 		len = cdb_len;
 	}
 
-	if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
-		if (cdb0 < 0xc0) {
-			if (CDB_BYTE0_NAMES_SZ) {
-				name = cdb_byte0_names[cdb0];
-				if (name)
-					printk("%s", name);
-				else
-					printk("cdb[0]=0x%x (reserved)", cdb0);
-			} else
-				printk("cdb[0]=0x%x", cdb0);
-		} else
+	if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) {
+		if (cdb_name)
+			printk("%s", cdb_name);
+		else if (cdb0 > 0xc0)
 			printk("cdb[0]=0x%x (vendor)", cdb0);
+		else if (cdb0 > 0x60 && cdb0 < 0x7e)
+			printk("cdb[0]=0x%x (reserved)", cdb0);
+		else
+			printk("cdb[0]=0x%x", cdb0);
 	} else {
-		if (name)
-			printk("%s", name);
+		if (sa_name)
+			printk("%s", sa_name);
+		else if (cdb_name)
+			printk("%s, sa=0x%x", cdb_name, sa);
 		else
 			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
 
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 14/20] scsi: use local buffer for printing CDB
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (12 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  2:02   ` Yoshihiro YUNOMAE
  2014-09-07 16:10   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 15/20] libata: use __scsi_print_command() Hannes Reinecke
                   ` (6 subsequent siblings)
  20 siblings, 2 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

The CDB needs to be printed in one line (ie with one printk
statement) to avoid the individual bytes to be broken up
under high load.
As using individual printk() statements here would lead to
unnecessary complicated code and needs the stack space to
hold the format string we should be using a local buffer
here. If the CDB is longer than the provided buffer
it will be printed in several lines.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/ch.c        |  5 +--
 drivers/scsi/constants.c | 82 ++++++++++++++++++++++++++++++++----------------
 drivers/scsi/sr_ioctl.c  |  9 ++++--
 include/scsi/scsi_dbg.h  |  2 +-
 4 files changed, 65 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index eea94a9..f0df02e 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -189,6 +189,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
 {
 	int errno, retries = 0, timeout, result;
 	struct scsi_sense_hdr sshdr;
+	char buf[80];
 
 	timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
 		? timeout_init : timeout_move;
@@ -196,8 +197,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
  retry:
 	errno = 0;
 	if (debug) {
-		DPRINTK("command: ");
-		__scsi_print_command(cmd);
+		__scsi_print_command(cmd, buf, 80);
+		DPRINTK("command: %s", buf);
 	}
 
 	result = scsi_execute_req(ch->device, cmd, direction, buffer,
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 6076969..5486816 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -322,19 +322,20 @@ static bool scsi_opcode_sa_name(int cmd, int service_action,
 	return true;
 }
 
-/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
-static void print_opcode_name(unsigned char * cdbp, int cdb_len)
+/* attempt to guess cdb length if cdb_len==0 */
+static int print_opcode_name(unsigned char * cdbp, int cdb_len,
+			     char *buf, int buf_len)
 {
-	int sa, len, cdb0;
+	int sa, len, cdb0, off = 0;
 	const char *cdb_name = NULL, *sa_name = NULL;
 
 	cdb0 = cdbp[0];
 	if (cdb0 == VARIABLE_LENGTH_CMD) {
 		len = scsi_varlen_cdb_length(cdbp);
 		if (len < 10) {
-			printk("short variable length command, "
-			       "len=%d ext_len=%d", len, cdb_len);
-			return;
+			return scnprintf(buf, buf_len,
+					 "short variable length command, "
+					 "len=%d ext_len=%d", len, cdb_len);
 		}
 		sa = (cdbp[8] << 8) + cdbp[9];
 	} else {
@@ -344,54 +345,81 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 
 	if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) {
 		if (cdb_name)
-			printk("%s", cdb_name);
+			off = scnprintf(buf, buf_len, "%s", cdb_name);
 		else if (cdb0 > 0xc0)
-			printk("cdb[0]=0x%x (vendor)", cdb0);
+			off = scnprintf(buf, buf_len,
+					 "cdb[0]=0x%x (vendor)", cdb0);
 		else if (cdb0 > 0x60 && cdb0 < 0x7e)
-			printk("cdb[0]=0x%x (reserved)", cdb0);
+			off = scnprintf(buf, buf_len,
+					 "cdb[0]=0x%x (reserved)", cdb0);
 		else
-			printk("cdb[0]=0x%x", cdb0);
+			off = scnprintf(buf, buf_len, "cdb[0]=0x%x", cdb0);
 	} else {
 		if (sa_name)
-			printk("%s", sa_name);
+			off = scnprintf(buf, buf_len, "%s", sa_name);
 		else if (cdb_name)
-			printk("%s, sa=0x%x", cdb_name, sa);
+			off = scnprintf(buf, buf_len,
+					"%s, sa=0x%x", cdb_name, sa);
 		else
-			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
+			off = scnprintf(buf, buf_len,
+					"cdb[0]=0x%x, sa=0x%x", cdb0, sa);
 
 		if (cdb_len > 0 && len != cdb_len)
-			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
+			off += scnprintf(buf + off, buf_len - off,
+					 ", in_cdb_len=%d, ext_len=%d",
+					 len, cdb_len);
 	}
+	return off;
 }
 
-void __scsi_print_command(unsigned char *cdb)
+void __scsi_print_command(unsigned char *cdb, char *buf, int buf_len)
 {
-	int k, len;
+	int len, off;
 
-	print_opcode_name(cdb, 0);
+	off = print_opcode_name(cdb, 0, buf, buf_len);
 	len = scsi_command_size(cdb);
+	/* Variable length CDBs are not supported */
+	if (len > 16)
+		return;
 	/* print out all bytes in cdb */
-	for (k = 0; k < len; ++k)
-		printk(" %02x", cdb[k]);
-	printk("\n");
+	hex_dump_to_buffer(cdb, len, 16, 1,
+			   buf, buf_len - off, false);
 }
 EXPORT_SYMBOL(__scsi_print_command);
 
 void scsi_print_command(struct scsi_cmnd *cmd)
 {
-	int k;
+	int k, off = 0;
+	/* 16 bytes + space take up 48 bytes */
+	char buf[48];
+	int buf_len = 48, linelen;
 
 	if (cmd->cmnd == NULL)
 		return;
 
-	scmd_printk(KERN_INFO, cmd, "CDB: ");
-	print_opcode_name(cmd->cmnd, cmd->cmd_len);
+	off = print_opcode_name(cmd->cmnd, cmd->cmd_len, buf, buf_len);
 
 	/* print out all bytes in cdb */
-	printk(":");
-	for (k = 0; k < cmd->cmd_len; ++k)
-		printk(" %02x", cmd->cmnd[k]);
-	printk("\n");
+	if (buf_len - off > cmd->cmd_len * 3 + 2) {
+		/* If we have enough space print CDB in one line */
+		off += scnprintf(buf + off, buf_len - off, ": ");
+		hex_dump_to_buffer(cmd->cmnd, cmd->cmd_len, 16, 1,
+				   buf, buf_len - off, false);
+		scmd_printk(KERN_INFO, cmd, "CDB: %s\n", buf);
+	} else {
+		/*
+		 * Otherwise print opcode in one line and use
+		 * separate lines for the CDB
+		 */
+		scmd_printk(KERN_INFO, cmd, "CDB: %s\n", buf);
+		for (k = 0; k < cmd->cmd_len; k += 16) {
+			linelen = min(cmd->cmd_len - k, 16);
+			hex_dump_to_buffer(cmd->cmnd, linelen, 16, 1,
+					   buf, sizeof(buf), false);
+			scmd_printk(KERN_INFO, cmd, "CDB[%0x2]: %s\n",
+				    k / 16, buf);
+		}
+	}
 }
 EXPORT_SYMBOL(scsi_print_command);
 
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 17e0c2b..8090571 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -188,6 +188,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 	struct scsi_sense_hdr sshdr;
 	int result, err = 0, retries = 0;
 	struct request_sense *sense = cgc->sense;
+	char buf[80];
 
 	SDev = cd->device;
 
@@ -257,14 +258,16 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
 				/* sense: Invalid command operation code */
 				err = -EDRIVE_CANT_DO_THIS;
 #ifdef DEBUG
-			__scsi_print_command(cgc->cmd);
+			__scsi_print_command(cgc->cmd, buf, 80);
+			sr_printk(KERN_ERR, cd,
+				  "CDROM (ioctl) invalid command %s\n", buf);
 			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
 #endif
 			break;
 		default:
+		    __scsi_print_command(cgc->cmd, buf, 80);
 			sr_printk(KERN_ERR, cd,
-				  "CDROM (ioctl) error, command: ");
-			__scsi_print_command(cgc->cmd);
+				  "CDROM (ioctl) error, command: %s\n", buf);
 			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
 			err = -EIO;
 		}
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 44bea15..5020e5e 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -6,7 +6,7 @@ struct scsi_device;
 struct scsi_sense_hdr;
 
 extern void scsi_print_command(struct scsi_cmnd *);
-extern void __scsi_print_command(unsigned char *);
+extern void __scsi_print_command(unsigned char *, char *, int);
 extern void scsi_show_extd_sense(struct scsi_device *, const char *,
 				 unsigned char, unsigned char);
 extern void scsi_show_sense_hdr(struct scsi_device *, const char *,
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 15/20] libata: use __scsi_print_command()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (13 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

libata already uses an internal buffer, so we should be using
__scsi_print_command() here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-eh.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index dad83df..acf06ba 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2509,15 +2509,11 @@ static void ata_eh_link_report(struct ata_link *link)
 
 		if (ata_is_atapi(qc->tf.protocol)) {
 			if (qc->scsicmd)
-				scsi_print_command(qc->scsicmd);
+				__scsi_print_command(qc->scsicmd->cmnd,
+						     cdb_buf, sizeof(cdb_buf));
 			else
-				snprintf(cdb_buf, sizeof(cdb_buf),
-				 "cdb %02x %02x %02x %02x %02x %02x %02x %02x  "
-				 "%02x %02x %02x %02x %02x %02x %02x %02x\n         ",
-				 cdb[0], cdb[1], cdb[2], cdb[3],
-				 cdb[4], cdb[5], cdb[6], cdb[7],
-				 cdb[8], cdb[9], cdb[10], cdb[11],
-				 cdb[12], cdb[13], cdb[14], cdb[15]);
+				__scsi_print_command((unsigned char *)cdb,
+						     cdb_buf, sizeof(cdb_buf));
 		} else {
 			const char *descr = ata_get_cmd_descript(cmd->command);
 			if (descr)
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 16/20] scsi: separate out scsi_retval_string()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (14 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 15/20] libata: use __scsi_print_command() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  2:04   ` Yoshihiro YUNOMAE
  2014-09-07 16:11   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
                   ` (4 subsequent siblings)
  20 siblings, 2 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Implement scsi_retval_string() to simplify logging.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 28 ++++++++++++++++++++++++++++
 drivers/scsi/scsi.c      | 34 ++++++----------------------------
 include/scsi/scsi_dbg.h  |  1 +
 3 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 5486816..85d2da0 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1426,6 +1426,34 @@ void scsi_print_sense(struct scsi_cmnd *cmd)
 EXPORT_SYMBOL(scsi_print_sense);
 
 #ifdef CONFIG_SCSI_CONSTANTS
+static const struct error_info internal_retval_table[] =
+{
+	{ NEEDS_RETRY, "NEEDS_RETRY " },
+	{ SUCCESS, "SUCCESS " },
+	{ FAILED, "FAILED " },
+	{ QUEUED, "QUEUED " },
+	{ SOFT_ERROR, "SOFT_ERROR " },
+	{ ADD_TO_MLQUEUE, "ADD_TO_MLQUEUE " },
+	{ TIMEOUT_ERROR, "TIMEOUT " },
+	{ SCSI_RETURN_NOT_HANDLED, "NOT_HANDLED " },
+	{ FAST_IO_FAIL, "FAST_IO_FAIL " },
+};
+#endif
+
+const char *
+scsi_retval_string(unsigned int ret)
+{
+#ifdef CONFIG_SCSI_CONSTANTS
+	int i;
+
+	for (i = 0; internal_retval_table[i].text; i++)
+		if (internal_retval_table[i].code12 == ret)
+			return internal_retval_table[i].text;
+#endif
+	return NULL;
+}
+
+#ifdef CONFIG_SCSI_CONSTANTS
 
 static const char * const hostbyte_table[]={
 "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 8954036..a1944c8 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -566,35 +566,13 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
 				       SCSI_LOG_MLCOMPLETE_BITS);
 		if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
 		    (level > 1)) {
-			scmd_printk(KERN_INFO, cmd, "Done: ");
 			if (level > 2)
-				printk("0x%p ", cmd);
-			/*
-			 * Dump truncated values, so we usually fit within
-			 * 80 chars.
-			 */
-			switch (disposition) {
-			case SUCCESS:
-				printk("SUCCESS\n");
-				break;
-			case NEEDS_RETRY:
-				printk("RETRY\n");
-				break;
-			case ADD_TO_MLQUEUE:
-				printk("MLQUEUE\n");
-				break;
-			case FAILED:
-				printk("FAILED\n");
-				break;
-			case TIMEOUT_ERROR:
-				/* 
-				 * If called via scsi_times_out.
-				 */
-				printk("TIMEOUT\n");
-				break;
-			default:
-				printk("UNKNOWN\n");
-			}
+				scmd_printk(KERN_INFO, cmd,
+					    "Done: 0x%p %s\n", cmd,
+					    scsi_retval_string(disposition));
+			else
+				scmd_printk(KERN_INFO, cmd, "Done: %s",
+					    scsi_retval_string(disposition));
 			scsi_print_result(cmd);
 			scsi_print_command(cmd);
 			if (status_byte(cmd->result) & CHECK_CONDITION)
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 5020e5e..1030cc1 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -19,6 +19,7 @@ extern void __scsi_print_sense(struct scsi_device *, const char *name,
 			       int sense_len);
 extern void scsi_show_result(int);
 extern void scsi_print_result(struct scsi_cmnd *);
+extern const char *scsi_retval_string(unsigned int);
 extern const char *scsi_sense_key_string(unsigned char);
 extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
 					  const char **);
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (15 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  4:19   ` Yoshihiro YUNOMAE
  2014-09-07 16:12   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
                   ` (3 subsequent siblings)
  20 siblings, 2 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 56 +++++++++++++++++++++++++++++++++++++-----------
 include/scsi/scsi_dbg.h  |  2 ++
 2 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 85d2da0..630e272 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1468,31 +1468,63 @@ static const char * const driverbyte_table[]={
 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
 #define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table)
 
-void scsi_show_result(int result)
+#endif
+
+const char *scsi_show_hostbyte(int result)
 {
+	const char *hb_string = NULL;
+#ifdef CONFIG_SCSI_CONSTANTS
 	int hb = host_byte(result);
-	int db = driver_byte(result);
 
-	printk("Result: hostbyte=%s driverbyte=%s\n",
-	       (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb]     : "invalid"),
-	       (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"));
+	if (hb < NUM_HOSTBYTE_STRS)
+		hb_string = hostbyte_table[hb];
+#endif
+	return hb_string;
 }
+EXPORT_SYMBOL(scsi_show_hostbyte);
 
-#else
+const char *scsi_show_driverbyte(int result)
+{
+	const char *db_string = NULL;
+#ifdef CONFIG_SCSI_CONSTANTS
+	int db = driver_byte(result);
+
+	if (db < NUM_DRIVERBYTE_STRS)
+		db_string = driverbyte_table[db];
+#endif
+	return db_string;
+}
+EXPORT_SYMBOL(scsi_show_driverbyte);
 
 void scsi_show_result(int result)
 {
-	printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
-	       host_byte(result), driver_byte(result));
-}
+	const char *hb_string = scsi_show_hostbyte(result);
+	const char *db_string = scsi_show_driverbyte(result);
 
-#endif
+	if (hb_string || db_string)
+		printk("Result: hostbyte=%s driverbyte=%s\n",
+		       hb_string ? hb_string : "invalid",
+		       db_string ? db_string : "invalid");
+	else
+		printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
+		       host_byte(result), driver_byte(result));
+}
 EXPORT_SYMBOL(scsi_show_result);
 
 
 void scsi_print_result(struct scsi_cmnd *cmd)
 {
-	scmd_printk(KERN_INFO, cmd, " ");
-	scsi_show_result(cmd->result);
+	const char *hb_string = scsi_show_hostbyte(cmd->result);
+	const char *db_string = scsi_show_driverbyte(cmd->result);
+
+	if (hb_string || db_string)
+		scmd_printk(KERN_INFO, cmd,
+			    "Result: hostbyte=%s driverbyte=%s",
+			    hb_string ? hb_string : "invalid",
+			    db_string ? db_string : "invalid");
+	else
+		scmd_printk(KERN_INFO, cmd,
+			    "Result: hostbyte=0x%02x driverbyte=0x%02x",
+			    host_byte(cmd->result), driver_byte(cmd->result));
 }
 EXPORT_SYMBOL(scsi_print_result);
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 1030cc1..a3170a5 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -19,6 +19,8 @@ extern void __scsi_print_sense(struct scsi_device *, const char *name,
 			       int sense_len);
 extern void scsi_show_result(int);
 extern void scsi_print_result(struct scsi_cmnd *);
+extern const char *scsi_show_hostbyte(int);
+extern const char *scsi_show_driverbyte(int);
 extern const char *scsi_retval_string(unsigned int);
 extern const char *scsi_sense_key_string(unsigned char);
 extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 18/20] scsi: remove scsi_show_result()
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (16 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  4:22   ` Yoshihiro YUNOMAE
  2014-09-07 16:17   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
                   ` (2 subsequent siblings)
  20 siblings, 2 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

scsi_show_result() was only ever used in one place in sd.c.
So open-code scsi_show_result() in sd.c and remove it from
constants.c.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/constants.c | 16 -------------
 drivers/scsi/sd.c        | 62 +++++++++++++++++++++++++++++-------------------
 include/scsi/scsi_dbg.h  |  1 -
 3 files changed, 37 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 630e272..d7516c3 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1496,22 +1496,6 @@ const char *scsi_show_driverbyte(int result)
 }
 EXPORT_SYMBOL(scsi_show_driverbyte);
 
-void scsi_show_result(int result)
-{
-	const char *hb_string = scsi_show_hostbyte(result);
-	const char *db_string = scsi_show_driverbyte(result);
-
-	if (hb_string || db_string)
-		printk("Result: hostbyte=%s driverbyte=%s\n",
-		       hb_string ? hb_string : "invalid",
-		       db_string ? db_string : "invalid");
-	else
-		printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
-		       host_byte(result), driver_byte(result));
-}
-EXPORT_SYMBOL(scsi_show_result);
-
-
 void scsi_print_result(struct scsi_cmnd *cmd)
 {
 	const char *hb_string = scsi_show_hostbyte(cmd->result);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index aac267a..f96e3f9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -116,7 +116,7 @@ static int sd_eh_action(struct scsi_cmnd *, int);
 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
 static void scsi_disk_release(struct device *cdev);
 static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
-static void sd_print_result(struct scsi_disk *, int);
+static void sd_print_result(struct scsi_disk *, const char *, int);
 
 static DEFINE_SPINLOCK(sd_index_lock);
 static DEFINE_IDA(sd_index_ida);
@@ -1479,7 +1479,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
 	}
 
 	if (res) {
-		sd_print_result(sdkp, res);
+		sd_print_result(sdkp, "SYNCHRONIZE CACHE failed", res);
 
 		if (driver_byte(res) & DRIVER_SENSE)
 			sd_print_sense_hdr(sdkp, &sshdr);
@@ -1820,8 +1820,8 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 			/* no sense, TUR either succeeded or failed
 			 * with a status error */
 			if(!spintime && !scsi_status_is_good(the_result)) {
-				sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
-				sd_print_result(sdkp, the_result);
+				sd_print_result(sdkp, "Unit Not Ready",
+						the_result);
 			}
 			break;
 		}
@@ -1937,11 +1937,13 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
 	return ret;
 }
 
-static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
-			struct scsi_sense_hdr *sshdr, int sense_valid,
-			int the_result)
+static void read_capacity_error(struct scsi_disk *sdkp,
+				struct scsi_sense_hdr *sshdr, int sense_valid,
+				const char *msg, int the_result)
 {
-	sd_print_result(sdkp, the_result);
+	struct scsi_device *sdp = sdkp->device;
+
+	sd_print_result(sdkp, msg, the_result);
 	if (driver_byte(the_result) & DRIVER_SENSE)
 		sd_print_sense_hdr(sdkp, sshdr);
 	else
@@ -1970,9 +1972,9 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
 
 #define READ_CAPACITY_RETRIES_ON_RESET	10
 
-static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
-						unsigned char *buffer)
+static int read_capacity_16(struct scsi_disk *sdkp, unsigned char *buffer)
 {
+	struct scsi_device *sdp = sdkp->device;
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
 	int sense_valid = 0;
@@ -2022,8 +2024,8 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 	} while (the_result && retries);
 
 	if (the_result) {
-		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
-		read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result);
+		read_capacity_error(sdkp, &sshdr, sense_valid,
+				    "READ CAPACITY(16) failed", the_result);
 		return -EINVAL;
 	}
 
@@ -2066,9 +2068,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 	return sector_size;
 }
 
-static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
-						unsigned char *buffer)
+static int read_capacity_10(struct scsi_disk *sdkp, unsigned char *buffer)
 {
+	struct scsi_device *sdp = sdkp->device;
 	unsigned char cmd[16];
 	struct scsi_sense_hdr sshdr;
 	int sense_valid = 0;
@@ -2104,8 +2106,8 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
 	} while (the_result && retries);
 
 	if (the_result) {
-		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n");
-		read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result);
+		read_capacity_error(sdkp, &sshdr, sense_valid,
+				    "READ CAPACITY failed", the_result);
 		return -EINVAL;
 	}
 
@@ -2158,17 +2160,17 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
 	sector_t old_capacity = sdkp->capacity;
 
 	if (sd_try_rc16_first(sdp)) {
-		sector_size = read_capacity_16(sdkp, sdp, buffer);
+		sector_size = read_capacity_16(sdkp, buffer);
 		if (sector_size == -EOVERFLOW)
 			goto got_data;
 		if (sector_size == -ENODEV)
 			return;
 		if (sector_size < 0)
-			sector_size = read_capacity_10(sdkp, sdp, buffer);
+			sector_size = read_capacity_10(sdkp, buffer);
 		if (sector_size < 0)
 			return;
 	} else {
-		sector_size = read_capacity_10(sdkp, sdp, buffer);
+		sector_size = read_capacity_10(sdkp, buffer);
 		if (sector_size == -EOVERFLOW)
 			goto got_data;
 		if (sector_size < 0)
@@ -2178,7 +2180,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
 			int old_sector_size = sector_size;
 			sd_printk(KERN_NOTICE, sdkp, "Very big device. "
 					"Trying to use READ CAPACITY(16).\n");
-			sector_size = read_capacity_16(sdkp, sdp, buffer);
+			sector_size = read_capacity_16(sdkp, buffer);
 			if (sector_size < 0) {
 				sd_printk(KERN_NOTICE, sdkp,
 					"Using 0xffffffff as device size\n");
@@ -3124,8 +3126,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
 	res = scsi_execute_req_flags(sdp, cmd, DMA_NONE, NULL, 0, &sshdr,
 			       SD_TIMEOUT, SD_MAX_RETRIES, NULL, REQ_PM);
 	if (res) {
-		sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n");
-		sd_print_result(sdkp, res);
+		sd_print_result(sdkp, "START_STOP failed", res);
 		if (driver_byte(res) & DRIVER_SENSE)
 			sd_print_sense_hdr(sdkp, &sshdr);
 		if (scsi_sense_valid(&sshdr) &&
@@ -3326,9 +3327,20 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp,
 			     sshdr->asc, sshdr->ascq);
 }
 
-static void sd_print_result(struct scsi_disk *sdkp, int result)
+static void sd_print_result(struct scsi_disk *sdkp, const char *msg,
+			    int result)
 {
-	sd_printk(KERN_INFO, sdkp, " ");
-	scsi_show_result(result);
+	const char *hb_string = scsi_show_hostbyte(result);
+	const char *db_string = scsi_show_driverbyte(result);
+
+	if (hb_string || db_string)
+		sd_printk(KERN_INFO, sdkp,
+			  "%s: Result: hostbyte=%s driverbyte=%s\n", msg,
+			  hb_string ? hb_string : "invalid",
+			  db_string ? db_string : "invalid");
+	else
+		sd_printk(KERN_INFO, sdkp,
+			  "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n",
+			  msg, host_byte(result), driver_byte(result));
 }
 
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index a3170a5..b4770f0 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -17,7 +17,6 @@ extern void scsi_print_sense(struct scsi_cmnd *);
 extern void __scsi_print_sense(struct scsi_device *, const char *name,
 			       const unsigned char *sense_buffer,
 			       int sense_len);
-extern void scsi_show_result(int);
 extern void scsi_print_result(struct scsi_cmnd *);
 extern const char *scsi_show_hostbyte(int);
 extern const char *scsi_show_driverbyte(int);
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 19/20] sd: Reduce logging output
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (17 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-07 16:17   ` Christoph Hellwig
  2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
  2014-09-06  0:51 ` [PATCHv2 00/20] scsi logging update Christoph Hellwig
  20 siblings, 1 reply; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

There is no need to print out the command result verbatim;
that will be done by the scsi stack if required.
Here we just should log the result in short if requested.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/sd.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f96e3f9..aa94385 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1701,14 +1701,15 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 			sense_deferred = scsi_sense_is_deferred(&sshdr);
 	}
 #ifdef CONFIG_SCSI_LOGGING
-	SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt));
+	SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
+		"sd_done: result[status,msg,host,driver]=%x,%x,%x,%x\n",
+		status_byte(result), msg_byte(result),
+		host_byte(result), driver_byte(result)));
 	if (sense_valid) {
 		SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
-						   "sd_done: sb[respc,sk,asc,"
-						   "ascq]=%x,%x,%x,%x\n",
-						   sshdr.response_code,
-						   sshdr.sense_key, sshdr.asc,
-						   sshdr.ascq));
+			"sd_done: sb[respc,sk,asc,ascq]=%x,%x,%x,%x\n",
+			sshdr.response_code, sshdr.sense_key,
+			sshdr.asc, sshdr.ascq));
 	}
 #endif
 	sdkp->medium_access_timed_out = 0;
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 20/20] scsi_error: format abort error message
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (18 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
@ 2014-09-03 10:06 ` Hannes Reinecke
  2014-09-05  4:23   ` Yoshihiro YUNOMAE
  2014-09-06  0:33   ` Christoph Hellwig
  2014-09-06  0:51 ` [PATCHv2 00/20] scsi logging update Christoph Hellwig
  20 siblings, 2 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-03 10:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi,
	Hannes Reinecke

Decode the return value if the command abort failed.

Suggested-by: Robert Elliot <elliot@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_error.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 8a6d382..eca63b2 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -157,8 +157,8 @@ scmd_eh_abort_handler(struct work_struct *work)
 		} else {
 			SCSI_LOG_ERROR_RECOVERY(3,
 				scmd_printk(KERN_INFO, scmd,
-					    "scmd %p abort failed, rtn %d\n",
-					    scmd, rtn));
+					    "scmd %p abort failed, rtn %s\n",
+					    scmd, scsi_retval_string(rtn)));
 		}
 	}
 
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense()
  2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
@ 2014-09-05  0:51   ` Yoshihiro YUNOMAE
  2014-09-05  6:07     ` Hannes Reinecke
  2014-09-06  0:09   ` Christoph Hellwig
  1 sibling, 1 reply; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  0:51 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

(2014/09/03 19:06), Hannes Reinecke wrote:
> Convert scsi_normalize_sense() and frieds to return 'bool'
> instead of an integer.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/scsi_error.c | 14 +++++++-------
>   drivers/scsi/scsi_lib.c   |  2 +-
>   include/scsi/scsi_eh.h    | 12 ++++++------
>   3 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 6c99624..8a6d382 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -2408,20 +2408,20 @@ EXPORT_SYMBOL(scsi_reset_provider);
>    *	responded to a SCSI command with the CHECK_CONDITION status.
>    *
>    * Return value:
> - *	1 if valid sense data information found, else 0;
> + *	true if valid sense data information found, else false;
>    */
> -int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
> -                         struct scsi_sense_hdr *sshdr)
> +bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
> +			  struct scsi_sense_hdr *sshdr)
>   {
>   	if (!sense_buffer || !sb_len)
> -		return 0;
> +		return false;
>   
>   	memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
>   
>   	sshdr->response_code = (sense_buffer[0] & 0x7f);
>   
>   	if (!scsi_sense_valid(sshdr))
> -		return 0;
> +		return false;
>   
>   	if (sshdr->response_code >= 0x72) {
>   		/*
> @@ -2451,11 +2451,11 @@ int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
>   		}
>   	}
>   
> -	return 1;
> +	return true;
>   }
>   EXPORT_SYMBOL(scsi_normalize_sense);
>   
> -int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
> +bool scsi_command_normalize_sense(struct scsi_cmnd *cmd,
>   				 struct scsi_sense_hdr *sshdr)
>   {
>   	return scsi_normalize_sense(cmd->sense_buffer,
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index de178f7..8cad004 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -830,7 +830,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
>   	struct request *req = cmd->request;
>   	int error = 0;
>   	struct scsi_sense_hdr sshdr;
> -	int sense_valid = 0;
> +	bool sense_valid = false;
>   	int sense_deferred = 0;
>   	enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
>   	      ACTION_DELAYED_RETRY} action;
> diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
> index 06a8790..1427a66 100644
> --- a/include/scsi/scsi_eh.h
> +++ b/include/scsi/scsi_eh.h
> @@ -27,7 +27,7 @@ struct scsi_sense_hdr {		/* See SPC-3 section 4.5 */
>   	u8 additional_length;	/* always 0 for fixed sense format */
>   };
>   
> -static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr)
> +static inline bool scsi_sense_valid(struct scsi_sense_hdr *sshdr)
>   {
>   	if (!sshdr)
>   		return 0;

Should be "return false;"

The others in this patch look good.

Thanks,
Yoshihiro YUNOMAE

> @@ -42,12 +42,12 @@ extern void scsi_eh_flush_done_q(struct list_head *done_q);
>   extern void scsi_report_bus_reset(struct Scsi_Host *, int);
>   extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
>   extern int scsi_block_when_processing_errors(struct scsi_device *);
> -extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
> -		struct scsi_sense_hdr *sshdr);
> -extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
> -		struct scsi_sense_hdr *sshdr);
> +extern bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
> +				 struct scsi_sense_hdr *sshdr);
> +extern bool scsi_command_normalize_sense(struct scsi_cmnd *cmd,
> +					 struct scsi_sense_hdr *sshdr);
>   
> -static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
> +static inline bool scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr)
>   {
>   	return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
>   }
> 

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 12/20] scsi: merge print_opcode_name()
  2014-09-03 10:06 ` [PATCH 12/20] scsi: merge print_opcode_name() Hannes Reinecke
@ 2014-09-05  1:24   ` Yoshihiro YUNOMAE
  2014-09-06  0:12     ` Christoph Hellwig
  0 siblings, 1 reply; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  1:24 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

(2014/09/03 19:06), Hannes Reinecke wrote:
> Instead of having two versions of print_opcode_name() we
> should be consolidating them into one version.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/constants.c | 90 +++++++++++++++++++-----------------------------
>   1 file changed, 35 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 364349c..3aee43b 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -30,6 +30,11 @@
>   #define THIRD_PARTY_COPY_IN 0x84
>   
>   
> +struct sa_name_list {
> +	int cmd;
> +	const struct value_name_pair *arr;
> +	int arr_sz;
> +};
>   
>   #ifdef CONFIG_SCSI_CONSTANTS
>   static const char * cdb_byte0_names[] = {
> @@ -244,12 +249,6 @@ static const struct value_name_pair variable_length_arr[] = {
>   };
>   #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
>   
> -struct sa_name_list {
> -	int cmd;
> -	const struct value_name_pair *arr;
> -	int arr_sz;
> -};
> -
>   static struct sa_name_list sa_names_arr[] = {
>   	{VARIABLE_LENGTH_CMD, variable_length_arr, VARIABLE_LENGTH_SZ},
>   	{MAINTENANCE_IN, maint_in_arr, MAINT_IN_SZ},
> @@ -267,6 +266,28 @@ static struct sa_name_list sa_names_arr[] = {
>   };
>   #define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)

We can delete SA_NAME_LIST_SZ because we define it out of
CONFIG_SCSI_CONSTANTS.

The others look good.

Thanks,
Yoshihiro YUNOMAE

> +#else /* ifndef CONFIG_SCSI_CONSTANTS */
> +static const char * cdb_byte0_names[] = NULL;
> +
> +static struct sa_name_list sa_names_arr[] = {
> +	{VARIABLE_LENGTH_CMD, NULL, 0},
> +	{MAINTENANCE_IN, NULL, 0},
> +	{MAINTENANCE_OUT, NULL, 0},
> +	{PERSISTENT_RESERVE_IN, NULL, 0},
> +	{PERSISTENT_RESERVE_OUT, NULL, 0},
> +	{SERVICE_ACTION_IN_12, NULL, 0},
> +	{SERVICE_ACTION_OUT_12, NULL, 0},
> +	{SERVICE_ACTION_BIDIRECTIONAL, NULL, 0},
> +	{SERVICE_ACTION_IN_16, NULL, 0},
> +	{SERVICE_ACTION_OUT_16, NULL, 0},
> +	{THIRD_PARTY_COPY_IN, NULL, 0},
> +	{THIRD_PARTY_COPY_OUT, NULL, 0},
> +	{0, NULL, 0},
> +};
> +#endif /* CONFIG_SCSI_CONSTANTS */
> +#define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
> +#define CDB_BYTE0_NAMES_SZ ARRAY_SIZE(cdb_byte0_names)
> +
>   static bool scsi_opcode_sa_name(int cmd, int service_action,
>   				const char **sa_name)
>   {
> @@ -316,11 +337,14 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
>   
>   	if (!scsi_opcode_sa_name(cdb0, sa, &name)) {
>   		if (cdb0 < 0xc0) {
> -			name = cdb_byte0_names[cdb0];
> -			if (name)
> -				printk("%s", name);
> -			else
> -				printk("cdb[0]=0x%x (reserved)", cdb0);
> +			if (CDB_BYTE0_NAMES_SZ) {
> +				name = cdb_byte0_names[cdb0];
> +				if (name)
> +					printk("%s", name);
> +				else
> +					printk("cdb[0]=0x%x (reserved)", cdb0);
> +			} else
> +				printk("cdb[0]=0x%x", cdb0);
>   		} else
>   			printk("cdb[0]=0x%x (vendor)", cdb0);
>   	} else {
> @@ -334,50 +358,6 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
>   	}
>   }
>   
> -#else /* ifndef CONFIG_SCSI_CONSTANTS */
> -
> -static void print_opcode_name(unsigned char * cdbp, int cdb_len)
> -{
> -	int sa, len, cdb0;
> -
> -	cdb0 = cdbp[0];
> -	switch(cdb0) {
> -	case VARIABLE_LENGTH_CMD:
> -		len = scsi_varlen_cdb_length(cdbp);
> -		if (len < 10) {
> -			printk("short opcode=0x%x command, len=%d "
> -			       "ext_len=%d", cdb0, len, cdb_len);
> -			break;
> -		}
> -		sa = (cdbp[8] << 8) + cdbp[9];
> -		printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
> -		if (len != cdb_len)
> -			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
> -		break;
> -	case MAINTENANCE_IN:
> -	case MAINTENANCE_OUT:
> -	case PERSISTENT_RESERVE_IN:
> -	case PERSISTENT_RESERVE_OUT:
> -	case SERVICE_ACTION_IN_12:
> -	case SERVICE_ACTION_OUT_12:
> -	case SERVICE_ACTION_BIDIRECTIONAL:
> -	case SERVICE_ACTION_IN_16:
> -	case SERVICE_ACTION_OUT_16:
> -	case THIRD_PARTY_COPY_IN:
> -	case THIRD_PARTY_COPY_OUT:
> -		sa = cdbp[1] & 0x1f;
> -		printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
> -		break;
> -	default:
> -		if (cdb0 < 0xc0)
> -			printk("cdb[0]=0x%x", cdb0);
> -		else
> -			printk("cdb[0]=0x%x (vendor)", cdb0);
> -		break;
> -	}
> -}
> -#endif
> -
>   void __scsi_print_command(unsigned char *cdb)
>   {
>   	int k, len;
> 

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 14/20] scsi: use local buffer for printing CDB
  2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
@ 2014-09-05  2:02   ` Yoshihiro YUNOMAE
  2014-09-07 16:10   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  2:02 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

(2014/09/03 19:06), Hannes Reinecke wrote:
> The CDB needs to be printed in one line (ie with one printk
> statement) to avoid the individual bytes to be broken up
> under high load.
> As using individual printk() statements here would lead to
> unnecessary complicated code and needs the stack space to
> hold the format string we should be using a local buffer
> here. If the CDB is longer than the provided buffer
> it will be printed in several lines.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/ch.c        |  5 +--
>   drivers/scsi/constants.c | 82 ++++++++++++++++++++++++++++++++----------------
>   drivers/scsi/sr_ioctl.c  |  9 ++++--
>   include/scsi/scsi_dbg.h  |  2 +-
>   4 files changed, 65 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
> index eea94a9..f0df02e 100644
> --- a/drivers/scsi/ch.c
> +++ b/drivers/scsi/ch.c
> @@ -189,6 +189,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
>   {
>   	int errno, retries = 0, timeout, result;
>   	struct scsi_sense_hdr sshdr;
> +	char buf[80];

This patch introduces some magic numbers like here,
but we had better define those.

Thanks,
Yoshihiro YUNOMAE

>   	timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
>   		? timeout_init : timeout_move;
> @@ -196,8 +197,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
>    retry:
>   	errno = 0;
>   	if (debug) {
> -		DPRINTK("command: ");
> -		__scsi_print_command(cmd);
> +		__scsi_print_command(cmd, buf, 80);
> +		DPRINTK("command: %s", buf);
>   	}
>   
>   	result = scsi_execute_req(ch->device, cmd, direction, buffer,
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 6076969..5486816 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -322,19 +322,20 @@ static bool scsi_opcode_sa_name(int cmd, int service_action,
>   	return true;
>   }
>   
> -/* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */
> -static void print_opcode_name(unsigned char * cdbp, int cdb_len)
> +/* attempt to guess cdb length if cdb_len==0 */
> +static int print_opcode_name(unsigned char * cdbp, int cdb_len,
> +			     char *buf, int buf_len)
>   {
> -	int sa, len, cdb0;
> +	int sa, len, cdb0, off = 0;
>   	const char *cdb_name = NULL, *sa_name = NULL;
>   
>   	cdb0 = cdbp[0];
>   	if (cdb0 == VARIABLE_LENGTH_CMD) {
>   		len = scsi_varlen_cdb_length(cdbp);
>   		if (len < 10) {
> -			printk("short variable length command, "
> -			       "len=%d ext_len=%d", len, cdb_len);
> -			return;
> +			return scnprintf(buf, buf_len,
> +					 "short variable length command, "
> +					 "len=%d ext_len=%d", len, cdb_len);
>   		}
>   		sa = (cdbp[8] << 8) + cdbp[9];
>   	} else {
> @@ -344,54 +345,81 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
>   
>   	if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) {
>   		if (cdb_name)
> -			printk("%s", cdb_name);
> +			off = scnprintf(buf, buf_len, "%s", cdb_name);
>   		else if (cdb0 > 0xc0)
> -			printk("cdb[0]=0x%x (vendor)", cdb0);
> +			off = scnprintf(buf, buf_len,
> +					 "cdb[0]=0x%x (vendor)", cdb0);
>   		else if (cdb0 > 0x60 && cdb0 < 0x7e)
> -			printk("cdb[0]=0x%x (reserved)", cdb0);
> +			off = scnprintf(buf, buf_len,
> +					 "cdb[0]=0x%x (reserved)", cdb0);
>   		else
> -			printk("cdb[0]=0x%x", cdb0);
> +			off = scnprintf(buf, buf_len, "cdb[0]=0x%x", cdb0);
>   	} else {
>   		if (sa_name)
> -			printk("%s", sa_name);
> +			off = scnprintf(buf, buf_len, "%s", sa_name);
>   		else if (cdb_name)
> -			printk("%s, sa=0x%x", cdb_name, sa);
> +			off = scnprintf(buf, buf_len,
> +					"%s, sa=0x%x", cdb_name, sa);
>   		else
> -			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
> +			off = scnprintf(buf, buf_len,
> +					"cdb[0]=0x%x, sa=0x%x", cdb0, sa);
>   
>   		if (cdb_len > 0 && len != cdb_len)
> -			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
> +			off += scnprintf(buf + off, buf_len - off,
> +					 ", in_cdb_len=%d, ext_len=%d",
> +					 len, cdb_len);
>   	}
> +	return off;
>   }
>   
> -void __scsi_print_command(unsigned char *cdb)
> +void __scsi_print_command(unsigned char *cdb, char *buf, int buf_len)
>   {
> -	int k, len;
> +	int len, off;
>   
> -	print_opcode_name(cdb, 0);
> +	off = print_opcode_name(cdb, 0, buf, buf_len);
>   	len = scsi_command_size(cdb);
> +	/* Variable length CDBs are not supported */
> +	if (len > 16)
> +		return;
>   	/* print out all bytes in cdb */
> -	for (k = 0; k < len; ++k)
> -		printk(" %02x", cdb[k]);
> -	printk("\n");
> +	hex_dump_to_buffer(cdb, len, 16, 1,
> +			   buf, buf_len - off, false);
>   }
>   EXPORT_SYMBOL(__scsi_print_command);
>   
>   void scsi_print_command(struct scsi_cmnd *cmd)
>   {
> -	int k;
> +	int k, off = 0;
> +	/* 16 bytes + space take up 48 bytes */
> +	char buf[48];
> +	int buf_len = 48, linelen;
>   
>   	if (cmd->cmnd == NULL)
>   		return;
>   
> -	scmd_printk(KERN_INFO, cmd, "CDB: ");
> -	print_opcode_name(cmd->cmnd, cmd->cmd_len);
> +	off = print_opcode_name(cmd->cmnd, cmd->cmd_len, buf, buf_len);
>   
>   	/* print out all bytes in cdb */
> -	printk(":");
> -	for (k = 0; k < cmd->cmd_len; ++k)
> -		printk(" %02x", cmd->cmnd[k]);
> -	printk("\n");
> +	if (buf_len - off > cmd->cmd_len * 3 + 2) {
> +		/* If we have enough space print CDB in one line */
> +		off += scnprintf(buf + off, buf_len - off, ": ");
> +		hex_dump_to_buffer(cmd->cmnd, cmd->cmd_len, 16, 1,
> +				   buf, buf_len - off, false);
> +		scmd_printk(KERN_INFO, cmd, "CDB: %s\n", buf);
> +	} else {
> +		/*
> +		 * Otherwise print opcode in one line and use
> +		 * separate lines for the CDB
> +		 */
> +		scmd_printk(KERN_INFO, cmd, "CDB: %s\n", buf);
> +		for (k = 0; k < cmd->cmd_len; k += 16) {
> +			linelen = min(cmd->cmd_len - k, 16);
> +			hex_dump_to_buffer(cmd->cmnd, linelen, 16, 1,
> +					   buf, sizeof(buf), false);
> +			scmd_printk(KERN_INFO, cmd, "CDB[%0x2]: %s\n",
> +				    k / 16, buf);
> +		}
> +	}
>   }
>   EXPORT_SYMBOL(scsi_print_command);
>   
> diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
> index 17e0c2b..8090571 100644
> --- a/drivers/scsi/sr_ioctl.c
> +++ b/drivers/scsi/sr_ioctl.c
> @@ -188,6 +188,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
>   	struct scsi_sense_hdr sshdr;
>   	int result, err = 0, retries = 0;
>   	struct request_sense *sense = cgc->sense;
> +	char buf[80];
>   
>   	SDev = cd->device;
>   
> @@ -257,14 +258,16 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
>   				/* sense: Invalid command operation code */
>   				err = -EDRIVE_CANT_DO_THIS;
>   #ifdef DEBUG
> -			__scsi_print_command(cgc->cmd);
> +			__scsi_print_command(cgc->cmd, buf, 80);
> +			sr_printk(KERN_ERR, cd,
> +				  "CDROM (ioctl) invalid command %s\n", buf);
>   			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
>   #endif
>   			break;
>   		default:
> +		    __scsi_print_command(cgc->cmd, buf, 80);
>   			sr_printk(KERN_ERR, cd,
> -				  "CDROM (ioctl) error, command: ");
> -			__scsi_print_command(cgc->cmd);
> +				  "CDROM (ioctl) error, command: %s\n", buf);
>   			scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
>   			err = -EIO;
>   		}
> diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
> index 44bea15..5020e5e 100644
> --- a/include/scsi/scsi_dbg.h
> +++ b/include/scsi/scsi_dbg.h
> @@ -6,7 +6,7 @@ struct scsi_device;
>   struct scsi_sense_hdr;
>   
>   extern void scsi_print_command(struct scsi_cmnd *);
> -extern void __scsi_print_command(unsigned char *);
> +extern void __scsi_print_command(unsigned char *, char *, int);
>   extern void scsi_show_extd_sense(struct scsi_device *, const char *,
>   				 unsigned char, unsigned char);
>   extern void scsi_show_sense_hdr(struct scsi_device *, const char *,
> 

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 16/20] scsi: separate out scsi_retval_string()
  2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
@ 2014-09-05  2:04   ` Yoshihiro YUNOMAE
  2014-09-05  6:14     ` Hannes Reinecke
  2014-09-07 16:11   ` Christoph Hellwig
  1 sibling, 1 reply; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  2:04 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

(2014/09/03 19:06), Hannes Reinecke wrote:
> Implement scsi_retval_string() to simplify logging.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/constants.c | 28 ++++++++++++++++++++++++++++
>   drivers/scsi/scsi.c      | 34 ++++++----------------------------
>   include/scsi/scsi_dbg.h  |  1 +
>   3 files changed, 35 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 5486816..85d2da0 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -1426,6 +1426,34 @@ void scsi_print_sense(struct scsi_cmnd *cmd)
>   EXPORT_SYMBOL(scsi_print_sense);
>   
>   #ifdef CONFIG_SCSI_CONSTANTS
> +static const struct error_info internal_retval_table[] =
> +{
> +	{ NEEDS_RETRY, "NEEDS_RETRY " },
> +	{ SUCCESS, "SUCCESS " },
> +	{ FAILED, "FAILED " },
> +	{ QUEUED, "QUEUED " },
> +	{ SOFT_ERROR, "SOFT_ERROR " },
> +	{ ADD_TO_MLQUEUE, "ADD_TO_MLQUEUE " },
> +	{ TIMEOUT_ERROR, "TIMEOUT " },
> +	{ SCSI_RETURN_NOT_HANDLED, "NOT_HANDLED " },
> +	{ FAST_IO_FAIL, "FAST_IO_FAIL " },

We don't need to add space in the last of strings, I think.
In scsi_log_completion(), the messages inserts line feeds after the
strings.

> +};
> +#endif
> +
> +const char *
> +scsi_retval_string(unsigned int ret)
> +{
> +#ifdef CONFIG_SCSI_CONSTANTS
> +	int i;
> +
> +	for (i = 0; internal_retval_table[i].text; i++)
> +		if (internal_retval_table[i].code12 == ret)
> +			return internal_retval_table[i].text;
> +#endif
> +	return NULL;
> +}
> +
> +#ifdef CONFIG_SCSI_CONSTANTS
>   
>   static const char * const hostbyte_table[]={
>   "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 8954036..a1944c8 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -566,35 +566,13 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
>   				       SCSI_LOG_MLCOMPLETE_BITS);
>   		if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
>   		    (level > 1)) {
> -			scmd_printk(KERN_INFO, cmd, "Done: ");
>   			if (level > 2)
> -				printk("0x%p ", cmd);
> -			/*
> -			 * Dump truncated values, so we usually fit within
> -			 * 80 chars.
> -			 */
> -			switch (disposition) {
> -			case SUCCESS:
> -				printk("SUCCESS\n");
> -				break;
> -			case NEEDS_RETRY:
> -				printk("RETRY\n");
> -				break;
> -			case ADD_TO_MLQUEUE:
> -				printk("MLQUEUE\n");
> -				break;
> -			case FAILED:
> -				printk("FAILED\n");
> -				break;
> -			case TIMEOUT_ERROR:
> -				/*
> -				 * If called via scsi_times_out.
> -				 */
> -				printk("TIMEOUT\n");
> -				break;
> -			default:
> -				printk("UNKNOWN\n");
> -			}
> +				scmd_printk(KERN_INFO, cmd,
> +					    "Done: 0x%p %s\n", cmd,
> +					    scsi_retval_string(disposition));
> +			else
> +				scmd_printk(KERN_INFO, cmd, "Done: %s",

We had better add "\n" in this last strings to indicate the end of line.
Structured printk automatically outputs the message in atomic,
but adding "\n" becomes more readable.

Thanks,
Yoshihiro YUNOMAE

> +					    scsi_retval_string(disposition));
>   			scsi_print_result(cmd);
>   			scsi_print_command(cmd);
>   			if (status_byte(cmd->result) & CHECK_CONDITION)
> diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
> index 5020e5e..1030cc1 100644
> --- a/include/scsi/scsi_dbg.h
> +++ b/include/scsi/scsi_dbg.h
> @@ -19,6 +19,7 @@ extern void __scsi_print_sense(struct scsi_device *, const char *name,
>   			       int sense_len);
>   extern void scsi_show_result(int);
>   extern void scsi_print_result(struct scsi_cmnd *);
> +extern const char *scsi_retval_string(unsigned int);
>   extern const char *scsi_sense_key_string(unsigned char);
>   extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
>   					  const char **);
> 

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte()
  2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
@ 2014-09-05  4:19   ` Yoshihiro YUNOMAE
  2014-09-07 16:12   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  4:19 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

This patch looks good.

Thanks,
Yoshihiro YUNOMAE

(2014/09/03 19:06), Hannes Reinecke wrote:
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/constants.c | 56 +++++++++++++++++++++++++++++++++++++-----------
>   include/scsi/scsi_dbg.h  |  2 ++
>   2 files changed, 46 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 85d2da0..630e272 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -1468,31 +1468,63 @@ static const char * const driverbyte_table[]={
>   "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
>   #define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table)
>   
> -void scsi_show_result(int result)
> +#endif
> +
> +const char *scsi_show_hostbyte(int result)
>   {
> +	const char *hb_string = NULL;
> +#ifdef CONFIG_SCSI_CONSTANTS
>   	int hb = host_byte(result);
> -	int db = driver_byte(result);
>   
> -	printk("Result: hostbyte=%s driverbyte=%s\n",
> -	       (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb]     : "invalid"),
> -	       (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"));
> +	if (hb < NUM_HOSTBYTE_STRS)
> +		hb_string = hostbyte_table[hb];
> +#endif
> +	return hb_string;
>   }
> +EXPORT_SYMBOL(scsi_show_hostbyte);
>   
> -#else
> +const char *scsi_show_driverbyte(int result)
> +{
> +	const char *db_string = NULL;
> +#ifdef CONFIG_SCSI_CONSTANTS
> +	int db = driver_byte(result);
> +
> +	if (db < NUM_DRIVERBYTE_STRS)
> +		db_string = driverbyte_table[db];
> +#endif
> +	return db_string;
> +}
> +EXPORT_SYMBOL(scsi_show_driverbyte);
>   
>   void scsi_show_result(int result)
>   {
> -	printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
> -	       host_byte(result), driver_byte(result));
> -}
> +	const char *hb_string = scsi_show_hostbyte(result);
> +	const char *db_string = scsi_show_driverbyte(result);
>   
> -#endif
> +	if (hb_string || db_string)
> +		printk("Result: hostbyte=%s driverbyte=%s\n",
> +		       hb_string ? hb_string : "invalid",
> +		       db_string ? db_string : "invalid");
> +	else
> +		printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
> +		       host_byte(result), driver_byte(result));
> +}
>   EXPORT_SYMBOL(scsi_show_result);
>   
>   
>   void scsi_print_result(struct scsi_cmnd *cmd)
>   {
> -	scmd_printk(KERN_INFO, cmd, " ");
> -	scsi_show_result(cmd->result);
> +	const char *hb_string = scsi_show_hostbyte(cmd->result);
> +	const char *db_string = scsi_show_driverbyte(cmd->result);
> +
> +	if (hb_string || db_string)
> +		scmd_printk(KERN_INFO, cmd,
> +			    "Result: hostbyte=%s driverbyte=%s",
> +			    hb_string ? hb_string : "invalid",
> +			    db_string ? db_string : "invalid");
> +	else
> +		scmd_printk(KERN_INFO, cmd,
> +			    "Result: hostbyte=0x%02x driverbyte=0x%02x",
> +			    host_byte(cmd->result), driver_byte(cmd->result));
>   }
>   EXPORT_SYMBOL(scsi_print_result);
> diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
> index 1030cc1..a3170a5 100644
> --- a/include/scsi/scsi_dbg.h
> +++ b/include/scsi/scsi_dbg.h
> @@ -19,6 +19,8 @@ extern void __scsi_print_sense(struct scsi_device *, const char *name,
>   			       int sense_len);
>   extern void scsi_show_result(int);
>   extern void scsi_print_result(struct scsi_cmnd *);
> +extern const char *scsi_show_hostbyte(int);
> +extern const char *scsi_show_driverbyte(int);
>   extern const char *scsi_retval_string(unsigned int);
>   extern const char *scsi_sense_key_string(unsigned char);
>   extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
> 

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 18/20] scsi: remove scsi_show_result()
  2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
@ 2014-09-05  4:22   ` Yoshihiro YUNOMAE
  2014-09-07 16:17   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  4:22 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

This patch looks good.

Thanks,
Yoshihiro YUNOMAE

(2014/09/03 19:06), Hannes Reinecke wrote:
> scsi_show_result() was only ever used in one place in sd.c.
> So open-code scsi_show_result() in sd.c and remove it from
> constants.c.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/constants.c | 16 -------------
>   drivers/scsi/sd.c        | 62 +++++++++++++++++++++++++++++-------------------
>   include/scsi/scsi_dbg.h  |  1 -
>   3 files changed, 37 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 630e272..d7516c3 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -1496,22 +1496,6 @@ const char *scsi_show_driverbyte(int result)
>   }
>   EXPORT_SYMBOL(scsi_show_driverbyte);
>   
> -void scsi_show_result(int result)
> -{
> -	const char *hb_string = scsi_show_hostbyte(result);
> -	const char *db_string = scsi_show_driverbyte(result);
> -
> -	if (hb_string || db_string)
> -		printk("Result: hostbyte=%s driverbyte=%s\n",
> -		       hb_string ? hb_string : "invalid",
> -		       db_string ? db_string : "invalid");
> -	else
> -		printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
> -		       host_byte(result), driver_byte(result));
> -}
> -EXPORT_SYMBOL(scsi_show_result);
> -
> -
>   void scsi_print_result(struct scsi_cmnd *cmd)
>   {
>   	const char *hb_string = scsi_show_hostbyte(cmd->result);
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index aac267a..f96e3f9 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -116,7 +116,7 @@ static int sd_eh_action(struct scsi_cmnd *, int);
>   static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
>   static void scsi_disk_release(struct device *cdev);
>   static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
> -static void sd_print_result(struct scsi_disk *, int);
> +static void sd_print_result(struct scsi_disk *, const char *, int);
>   
>   static DEFINE_SPINLOCK(sd_index_lock);
>   static DEFINE_IDA(sd_index_ida);
> @@ -1479,7 +1479,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
>   	}
>   
>   	if (res) {
> -		sd_print_result(sdkp, res);
> +		sd_print_result(sdkp, "SYNCHRONIZE CACHE failed", res);
>   
>   		if (driver_byte(res) & DRIVER_SENSE)
>   			sd_print_sense_hdr(sdkp, &sshdr);
> @@ -1820,8 +1820,8 @@ sd_spinup_disk(struct scsi_disk *sdkp)
>   			/* no sense, TUR either succeeded or failed
>   			 * with a status error */
>   			if(!spintime && !scsi_status_is_good(the_result)) {
> -				sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
> -				sd_print_result(sdkp, the_result);
> +				sd_print_result(sdkp, "Unit Not Ready",
> +						the_result);
>   			}
>   			break;
>   		}
> @@ -1937,11 +1937,13 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
>   	return ret;
>   }
>   
> -static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
> -			struct scsi_sense_hdr *sshdr, int sense_valid,
> -			int the_result)
> +static void read_capacity_error(struct scsi_disk *sdkp,
> +				struct scsi_sense_hdr *sshdr, int sense_valid,
> +				const char *msg, int the_result)
>   {
> -	sd_print_result(sdkp, the_result);
> +	struct scsi_device *sdp = sdkp->device;
> +
> +	sd_print_result(sdkp, msg, the_result);
>   	if (driver_byte(the_result) & DRIVER_SENSE)
>   		sd_print_sense_hdr(sdkp, sshdr);
>   	else
> @@ -1970,9 +1972,9 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
>   
>   #define READ_CAPACITY_RETRIES_ON_RESET	10
>   
> -static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
> -						unsigned char *buffer)
> +static int read_capacity_16(struct scsi_disk *sdkp, unsigned char *buffer)
>   {
> +	struct scsi_device *sdp = sdkp->device;
>   	unsigned char cmd[16];
>   	struct scsi_sense_hdr sshdr;
>   	int sense_valid = 0;
> @@ -2022,8 +2024,8 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
>   	} while (the_result && retries);
>   
>   	if (the_result) {
> -		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
> -		read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result);
> +		read_capacity_error(sdkp, &sshdr, sense_valid,
> +				    "READ CAPACITY(16) failed", the_result);
>   		return -EINVAL;
>   	}
>   
> @@ -2066,9 +2068,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
>   	return sector_size;
>   }
>   
> -static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
> -						unsigned char *buffer)
> +static int read_capacity_10(struct scsi_disk *sdkp, unsigned char *buffer)
>   {
> +	struct scsi_device *sdp = sdkp->device;
>   	unsigned char cmd[16];
>   	struct scsi_sense_hdr sshdr;
>   	int sense_valid = 0;
> @@ -2104,8 +2106,8 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
>   	} while (the_result && retries);
>   
>   	if (the_result) {
> -		sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n");
> -		read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result);
> +		read_capacity_error(sdkp, &sshdr, sense_valid,
> +				    "READ CAPACITY failed", the_result);
>   		return -EINVAL;
>   	}
>   
> @@ -2158,17 +2160,17 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
>   	sector_t old_capacity = sdkp->capacity;
>   
>   	if (sd_try_rc16_first(sdp)) {
> -		sector_size = read_capacity_16(sdkp, sdp, buffer);
> +		sector_size = read_capacity_16(sdkp, buffer);
>   		if (sector_size == -EOVERFLOW)
>   			goto got_data;
>   		if (sector_size == -ENODEV)
>   			return;
>   		if (sector_size < 0)
> -			sector_size = read_capacity_10(sdkp, sdp, buffer);
> +			sector_size = read_capacity_10(sdkp, buffer);
>   		if (sector_size < 0)
>   			return;
>   	} else {
> -		sector_size = read_capacity_10(sdkp, sdp, buffer);
> +		sector_size = read_capacity_10(sdkp, buffer);
>   		if (sector_size == -EOVERFLOW)
>   			goto got_data;
>   		if (sector_size < 0)
> @@ -2178,7 +2180,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
>   			int old_sector_size = sector_size;
>   			sd_printk(KERN_NOTICE, sdkp, "Very big device. "
>   					"Trying to use READ CAPACITY(16).\n");
> -			sector_size = read_capacity_16(sdkp, sdp, buffer);
> +			sector_size = read_capacity_16(sdkp, buffer);
>   			if (sector_size < 0) {
>   				sd_printk(KERN_NOTICE, sdkp,
>   					"Using 0xffffffff as device size\n");
> @@ -3124,8 +3126,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
>   	res = scsi_execute_req_flags(sdp, cmd, DMA_NONE, NULL, 0, &sshdr,
>   			       SD_TIMEOUT, SD_MAX_RETRIES, NULL, REQ_PM);
>   	if (res) {
> -		sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n");
> -		sd_print_result(sdkp, res);
> +		sd_print_result(sdkp, "START_STOP failed", res);
>   		if (driver_byte(res) & DRIVER_SENSE)
>   			sd_print_sense_hdr(sdkp, &sshdr);
>   		if (scsi_sense_valid(&sshdr) &&
> @@ -3326,9 +3327,20 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp,
>   			     sshdr->asc, sshdr->ascq);
>   }
>   
> -static void sd_print_result(struct scsi_disk *sdkp, int result)
> +static void sd_print_result(struct scsi_disk *sdkp, const char *msg,
> +			    int result)
>   {
> -	sd_printk(KERN_INFO, sdkp, " ");
> -	scsi_show_result(result);
> +	const char *hb_string = scsi_show_hostbyte(result);
> +	const char *db_string = scsi_show_driverbyte(result);
> +
> +	if (hb_string || db_string)
> +		sd_printk(KERN_INFO, sdkp,
> +			  "%s: Result: hostbyte=%s driverbyte=%s\n", msg,
> +			  hb_string ? hb_string : "invalid",
> +			  db_string ? db_string : "invalid");
> +	else
> +		sd_printk(KERN_INFO, sdkp,
> +			  "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n",
> +			  msg, host_byte(result), driver_byte(result));
>   }
>   
> diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
> index a3170a5..b4770f0 100644
> --- a/include/scsi/scsi_dbg.h
> +++ b/include/scsi/scsi_dbg.h
> @@ -17,7 +17,6 @@ extern void scsi_print_sense(struct scsi_cmnd *);
>   extern void __scsi_print_sense(struct scsi_device *, const char *name,
>   			       const unsigned char *sense_buffer,
>   			       int sense_len);
> -extern void scsi_show_result(int);
>   extern void scsi_print_result(struct scsi_cmnd *);
>   extern const char *scsi_show_hostbyte(int);
>   extern const char *scsi_show_driverbyte(int);
> 

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 20/20] scsi_error: format abort error message
  2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
@ 2014-09-05  4:23   ` Yoshihiro YUNOMAE
  2014-09-06  0:33   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Yoshihiro YUNOMAE @ 2014-09-05  4:23 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

(2014/09/03 19:06), Hannes Reinecke wrote:
> Decode the return value if the command abort failed.
> 
> Suggested-by: Robert Elliot <elliot@hp.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/scsi/scsi_error.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 8a6d382..eca63b2 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -157,8 +157,8 @@ scmd_eh_abort_handler(struct work_struct *work)
>   		} else {
>   			SCSI_LOG_ERROR_RECOVERY(3,
>   				scmd_printk(KERN_INFO, scmd,
> -					    "scmd %p abort failed, rtn %d\n",
> -					    scmd, rtn));
> +					    "scmd %p abort failed, rtn %s\n",
> +					    scmd, scsi_retval_string(rtn)));

If CONFIG_SCSI_CONSTANTS is disabled, scsi_retval_string() returns NULL.
So, if so, we had better output the raw value here.

Thanks,
Yoshihiro YUNOMAE

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae.ez@hitachi.com



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense()
  2014-09-05  0:51   ` Yoshihiro YUNOMAE
@ 2014-09-05  6:07     ` Hannes Reinecke
  0 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-05  6:07 UTC (permalink / raw)
  To: Yoshihiro YUNOMAE
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

On 09/05/2014 02:51 AM, Yoshihiro YUNOMAE wrote:
> (2014/09/03 19:06), Hannes Reinecke wrote:
>> Convert scsi_normalize_sense() and frieds to return 'bool'
>> instead of an integer.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>>   drivers/scsi/scsi_error.c | 14 +++++++-------
>>   drivers/scsi/scsi_lib.c   |  2 +-
>>   include/scsi/scsi_eh.h    | 12 ++++++------
>>   3 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
>> index 6c99624..8a6d382 100644
>> --- a/drivers/scsi/scsi_error.c
>> +++ b/drivers/scsi/scsi_error.c
>> @@ -2408,20 +2408,20 @@ EXPORT_SYMBOL(scsi_reset_provider);
>>    *	responded to a SCSI command with the CHECK_CONDITION status.
>>    *
>>    * Return value:
>> - *	1 if valid sense data information found, else 0;
>> + *	true if valid sense data information found, else false;
>>    */
>> -int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
>> -                         struct scsi_sense_hdr *sshdr)
>> +bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
>> +			  struct scsi_sense_hdr *sshdr)
>>   {
>>   	if (!sense_buffer || !sb_len)
>> -		return 0;
>> +		return false;
>>   
>>   	memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
>>   
>>   	sshdr->response_code = (sense_buffer[0] & 0x7f);
>>   
>>   	if (!scsi_sense_valid(sshdr))
>> -		return 0;
>> +		return false;
>>   
>>   	if (sshdr->response_code >= 0x72) {
>>   		/*
>> @@ -2451,11 +2451,11 @@ int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
>>   		}
>>   	}
>>   
>> -	return 1;
>> +	return true;
>>   }
>>   EXPORT_SYMBOL(scsi_normalize_sense);
>>   
>> -int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
>> +bool scsi_command_normalize_sense(struct scsi_cmnd *cmd,
>>   				 struct scsi_sense_hdr *sshdr)
>>   {
>>   	return scsi_normalize_sense(cmd->sense_buffer,
>> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
>> index de178f7..8cad004 100644
>> --- a/drivers/scsi/scsi_lib.c
>> +++ b/drivers/scsi/scsi_lib.c
>> @@ -830,7 +830,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
>>   	struct request *req = cmd->request;
>>   	int error = 0;
>>   	struct scsi_sense_hdr sshdr;
>> -	int sense_valid = 0;
>> +	bool sense_valid = false;
>>   	int sense_deferred = 0;
>>   	enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
>>   	      ACTION_DELAYED_RETRY} action;
>> diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
>> index 06a8790..1427a66 100644
>> --- a/include/scsi/scsi_eh.h
>> +++ b/include/scsi/scsi_eh.h
>> @@ -27,7 +27,7 @@ struct scsi_sense_hdr {		/* See SPC-3 section 4.5 */
>>   	u8 additional_length;	/* always 0 for fixed sense format */
>>   };
>>   
>> -static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr)
>> +static inline bool scsi_sense_valid(struct scsi_sense_hdr *sshdr)
>>   {
>>   	if (!sshdr)
>>   		return 0;
> 
> Should be "return false;"
> 
Bah. You are correct.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 16/20] scsi: separate out scsi_retval_string()
  2014-09-05  2:04   ` Yoshihiro YUNOMAE
@ 2014-09-05  6:14     ` Hannes Reinecke
  0 siblings, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-05  6:14 UTC (permalink / raw)
  To: Yoshihiro YUNOMAE
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne, linux-scsi

On 09/05/2014 04:04 AM, Yoshihiro YUNOMAE wrote:
> (2014/09/03 19:06), Hannes Reinecke wrote:
>> Implement scsi_retval_string() to simplify logging.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>>   drivers/scsi/constants.c | 28 ++++++++++++++++++++++++++++
>>   drivers/scsi/scsi.c      | 34 ++++++----------------------------
>>   include/scsi/scsi_dbg.h  |  1 +
>>   3 files changed, 35 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
>> index 5486816..85d2da0 100644
>> --- a/drivers/scsi/constants.c
>> +++ b/drivers/scsi/constants.c
>> @@ -1426,6 +1426,34 @@ void scsi_print_sense(struct scsi_cmnd *cmd)
>>   EXPORT_SYMBOL(scsi_print_sense);
>>   
>>   #ifdef CONFIG_SCSI_CONSTANTS
>> +static const struct error_info internal_retval_table[] =
>> +{
>> +	{ NEEDS_RETRY, "NEEDS_RETRY " },
>> +	{ SUCCESS, "SUCCESS " },
>> +	{ FAILED, "FAILED " },
>> +	{ QUEUED, "QUEUED " },
>> +	{ SOFT_ERROR, "SOFT_ERROR " },
>> +	{ ADD_TO_MLQUEUE, "ADD_TO_MLQUEUE " },
>> +	{ TIMEOUT_ERROR, "TIMEOUT " },
>> +	{ SCSI_RETURN_NOT_HANDLED, "NOT_HANDLED " },
>> +	{ FAST_IO_FAIL, "FAST_IO_FAIL " },
> 
> We don't need to add space in the last of strings, I think.
> In scsi_log_completion(), the messages inserts line feeds after the
> strings.
> 
>> +};
>> +#endif
>> +
>> +const char *
>> +scsi_retval_string(unsigned int ret)
>> +{
>> +#ifdef CONFIG_SCSI_CONSTANTS
>> +	int i;
>> +
>> +	for (i = 0; internal_retval_table[i].text; i++)
>> +		if (internal_retval_table[i].code12 == ret)
>> +			return internal_retval_table[i].text;
>> +#endif
>> +	return NULL;
>> +}
>> +
>> +#ifdef CONFIG_SCSI_CONSTANTS
>>   
>>   static const char * const hostbyte_table[]={
>>   "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
>> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
>> index 8954036..a1944c8 100644
>> --- a/drivers/scsi/scsi.c
>> +++ b/drivers/scsi/scsi.c
>> @@ -566,35 +566,13 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
>>   				       SCSI_LOG_MLCOMPLETE_BITS);
>>   		if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
>>   		    (level > 1)) {
>> -			scmd_printk(KERN_INFO, cmd, "Done: ");
>>   			if (level > 2)
>> -				printk("0x%p ", cmd);
>> -			/*
>> -			 * Dump truncated values, so we usually fit within
>> -			 * 80 chars.
>> -			 */
>> -			switch (disposition) {
>> -			case SUCCESS:
>> -				printk("SUCCESS\n");
>> -				break;
>> -			case NEEDS_RETRY:
>> -				printk("RETRY\n");
>> -				break;
>> -			case ADD_TO_MLQUEUE:
>> -				printk("MLQUEUE\n");
>> -				break;
>> -			case FAILED:
>> -				printk("FAILED\n");
>> -				break;
>> -			case TIMEOUT_ERROR:
>> -				/*
>> -				 * If called via scsi_times_out.
>> -				 */
>> -				printk("TIMEOUT\n");
>> -				break;
>> -			default:
>> -				printk("UNKNOWN\n");
>> -			}
>> +				scmd_printk(KERN_INFO, cmd,
>> +					    "Done: 0x%p %s\n", cmd,
>> +					    scsi_retval_string(disposition));
>> +			else
>> +				scmd_printk(KERN_INFO, cmd, "Done: %s",
> 
> We had better add "\n" in this last strings to indicate the end of line.
> Structured printk automatically outputs the message in atomic,
> but adding "\n" becomes more readable.
> 
True, we should be adding the newline.
Although the reasoning is wrong; a newline instructs printk() to
actually ship out the message. Without a newline printk assumes
it'll be line continuation.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 02/20] aha152x: Debug output update and whitespace cleanup
  2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
@ 2014-09-06  0:02   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:02 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:05:57PM +0200, Hannes Reinecke wrote:
> Remove all uncommented debugging code and move all
> printk() statements over to dev_printk().
> And while we're at it we should be doing a whitespace
> cleanup, too.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 04/20] scsi: introduce sdev_prefix_printk()
  2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
@ 2014-09-06  0:03   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:03 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:05:59PM +0200, Hannes Reinecke wrote:
> Like scmd_printk(), but the device name is passed in as
> a string. Can be used by eg ULDs which do not have access
> to the scsi_cmnd structure.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails
  2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
@ 2014-09-06  0:04   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:04 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:01PM +0200, Hannes Reinecke wrote:
> If scsi_normalize_sense() fails we couldn't decode the sense
> buffer, and the scsi_sense_hdr fields are invalid.
> For those cases we should rather dump the sense buffer
> and not try to decode invalid fields.

This description still doesn't make sense to me.  What you describe
is both old and new behavior, you just dump the raw buffer differently.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 07/20] scsi: do not decode sense extras
  2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
@ 2014-09-06  0:04   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:04 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:02PM +0200, Hannes Reinecke wrote:
> Currently we're only decoding sense extras for tape devices.
> And even there only for fixed format sense formats.
> As this is of rather limited use in the general case we should
> be stop trying to decode sense extras; the tape driver does
> its own decoding anyway.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense()
  2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
  2014-09-05  0:51   ` Yoshihiro YUNOMAE
@ 2014-09-06  0:09   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:09 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:03PM +0200, Hannes Reinecke wrote:
> Convert scsi_normalize_sense() and frieds to return 'bool'
> instead of an integer.

Looks good with the small fix spotted by Yunomae-san.

Signed-off-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 09/20] scsi: remove scsi_print_status()
  2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
@ 2014-09-06  0:10   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:10 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:04PM +0200, Hannes Reinecke wrote:
> Last caller is gone, so we can remove it.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 11/20] scsi: Use scsi_print_command() where possible
  2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
@ 2014-09-06  0:11   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:11 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 12/20] scsi: merge print_opcode_name()
  2014-09-05  1:24   ` Yoshihiro YUNOMAE
@ 2014-09-06  0:12     ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:12 UTC (permalink / raw)
  To: Yoshihiro YUNOMAE
  Cc: Hannes Reinecke, Christoph Hellwig, James Bottomley, Ewan Milne,
	linux-scsi

On Fri, Sep 05, 2014 at 10:24:40AM +0900, Yoshihiro YUNOMAE wrote:
> >   #define SA_NAME_LIST_SZ ARRAY_SIZE(sa_names_arr)
> 
> We can delete SA_NAME_LIST_SZ because we define it out of
> CONFIG_SCSI_CONSTANTS.

I'd generally prefer to just use ARRAY_SIZE() directly instead of adding
another layer of indirection.

Otherwise looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 20/20] scsi_error: format abort error message
  2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
  2014-09-05  4:23   ` Yoshihiro YUNOMAE
@ 2014-09-06  0:33   ` Christoph Hellwig
  2014-09-13  1:07     ` Elliott, Robert (Server Storage)
  1 sibling, 1 reply; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:33 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:15PM +0200, Hannes Reinecke wrote:
> Decode the return value if the command abort failed.

I've not seen an answer to my question in reply to the previous version
of this.  Why would you do pretty printing of a variable that can just
return SUCCESS or FAILURE?


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name()
  2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
@ 2014-09-06  0:46   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:46 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

> +	*cdb_name = NULL;
> +	if (cmd >= 0xc0)

Can we get a START_VENDOR_SPECIFIC_CMD or similar define for 0xc0,
please?

Otherwise looks good to me,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCHv2 00/20] scsi logging update
  2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
                   ` (19 preceding siblings ...)
  2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
@ 2014-09-06  0:51 ` Christoph Hellwig
  20 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-06  0:51 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

One more request:

if you already do major surgery to constan.c can we get rid of the
CONFIG_SCSI_CONSTANTS all over it?

E.g. only keep the code under CONFIG_SCSI_CONSTANTS in, maybe
add a no-constants.c for the stubs and move the bit of glue code
always compiled to scsi.c?

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 14/20] scsi: use local buffer for printing CDB
  2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
  2014-09-05  2:02   ` Yoshihiro YUNOMAE
@ 2014-09-07 16:10   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-07 16:10 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:09PM +0200, Hannes Reinecke wrote:
> The CDB needs to be printed in one line (ie with one printk
> statement) to avoid the individual bytes to be broken up
> under high load.
> As using individual printk() statements here would lead to
> unnecessary complicated code and needs the stack space to
> hold the format string we should be using a local buffer
> here. If the CDB is longer than the provided buffer
> it will be printed in several lines.

Some general comments:

 - as pointed out by YUNOMAE-san we need a constant for the buffer.  And
   I'd also like to see a comment why exactly you're chosing 80 for it.
 - I'd really like to see some worst case stack usage analysis of the
   old vs the new case.

> @@ -189,6 +189,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
>  {
>  	int errno, retries = 0, timeout, result;
>  	struct scsi_sense_hdr sshdr;
> +	char buf[80];
>  
>  	timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
>  		? timeout_init : timeout_move;
> @@ -196,8 +197,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
>   retry:
>  	errno = 0;
>  	if (debug) {
> -		DPRINTK("command: ");
> -		__scsi_print_command(cmd);
> +		__scsi_print_command(cmd, buf, 80);
> +		DPRINTK("command: %s", buf);

The buffer variable should be inside the "if (debug)" here.

> +/* attempt to guess cdb length if cdb_len==0 */

cdb_len == 0 is only passed in from __scsi_print_command.  But as far
as I can tell all of it's caller have it easily available, so we should
just pass it in and get rid of this special case.

> +static int print_opcode_name(unsigned char * cdbp, int cdb_len,
> +			     char *buf, int buf_len)

This doesn't print anything now, but just formats the CDB, so it
should be called format_opcode_name.   Also as a convention pass
buf and buf_len as the first two arguments similar to s*printf,
and fix up the formatting for the cdbp argument.  Can you please
just run your next series through checkpatch?

> -void __scsi_print_command(unsigned char *cdb)
> +void __scsi_print_command(unsigned char *cdb, char *buf, int buf_len)

Rename this to scsi_format_command, pass buf and buf_len as first two
argument, and as mention earlier pass in the cdb length as well.

>  {
> +	int len, off;
>  
> +	off = print_opcode_name(cdb, 0, buf, buf_len);
>  	len = scsi_command_size(cdb);
> +	/* Variable length CDBs are not supported */

Why?

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 16/20] scsi: separate out scsi_retval_string()
  2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
  2014-09-05  2:04   ` Yoshihiro YUNOMAE
@ 2014-09-07 16:11   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-07 16:11 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:11PM +0200, Hannes Reinecke wrote:
> Implement scsi_retval_string() to simplify logging.

Needs a way better patch description.  What exactly is this going to be
useful for?


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte()
  2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
  2014-09-05  4:19   ` Yoshihiro YUNOMAE
@ 2014-09-07 16:12   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-07 16:12 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

This needs a patch description that tells us why this change is useful.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 18/20] scsi: remove scsi_show_result()
  2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
  2014-09-05  4:22   ` Yoshihiro YUNOMAE
@ 2014-09-07 16:17   ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-07 16:17 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:13PM +0200, Hannes Reinecke wrote:
> scsi_show_result() was only ever used in one place in sd.c.
> So open-code scsi_show_result() in sd.c and remove it from
> constants.c.

This does a lot more refactoring in sd.c, which needs a proper
explanation and probably splitting into a separate patch.

I also think we're much better having a different prototype
for scsi_print_result and use it here, similar to your
sdev_prefix_printk:

void scsi_print_result(struct scsi_device *sdev, const char *prefix)
{
	...
}

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 19/20] sd: Reduce logging output
  2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
@ 2014-09-07 16:17   ` Christoph Hellwig
  0 siblings, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-07 16:17 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Wed, Sep 03, 2014 at 12:06:14PM +0200, Hannes Reinecke wrote:
> There is no need to print out the command result verbatim;
> that will be done by the scsi stack if required.
> Here we just should log the result in short if requested.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 20/20] scsi_error: format abort error message
  2014-09-06  0:33   ` Christoph Hellwig
@ 2014-09-13  1:07     ` Elliott, Robert (Server Storage)
  2014-09-14 10:49       ` Hannes Reinecke
  2014-09-14 16:40       ` Christoph Hellwig
  0 siblings, 2 replies; 49+ messages in thread
From: Elliott, Robert (Server Storage) @ 2014-09-13  1:07 UTC (permalink / raw)
  To: Christoph Hellwig, Hannes Reinecke
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi

> -----Original Message-----
> From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
> owner@vger.kernel.org] On Behalf Of Christoph Hellwig
> Sent: Friday, 05 September, 2014 7:33 PM
> Subject: Re: [PATCH 20/20] scsi_error: format abort error message
> 
> On Wed, Sep 03, 2014 at 12:06:15PM +0200, Hannes Reinecke wrote:
...
> > Decode the return value if the command abort failed.
> > @@ -157,8 +157,8 @@ scmd_eh_abort_handler(struct work_struct *work)
> >  		} else {
> >  			SCSI_LOG_ERROR_RECOVERY(3,
> >  				scmd_printk(KERN_INFO, scmd,
> > -					    "scmd %p abort failed, rtn %d\n",
> > -					    scmd, rtn));
> > +					    "scmd %p abort failed, rtn %s\n",
> > +					    scmd, scsi_retval_string(rtn)));
...
> I've not seen an answer to my question in reply to the previous version
> of this.  Why would you do pretty printing of a variable that can just
> return SUCCESS or FAILURE?

Is there anything prohibiting the scsi_eh_abort_handler provided by
the LLD from returning any of the other values like NEEDS_RETRY?

#define NEEDS_RETRY     0x2001
#define SUCCESS         0x2002
#define FAILED          0x2003
#define QUEUED          0x2004
#define SOFT_ERROR      0x2005
#define ADD_TO_MLQUEUE  0x2006
#define TIMEOUT_ERROR   0x2007
#define SCSI_RETURN_NOT_HANDLED   0x2008
#define FAST_IO_FAIL    0x2009

---
Rob Elliott    HP Server Storage




^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 20/20] scsi_error: format abort error message
  2014-09-13  1:07     ` Elliott, Robert (Server Storage)
@ 2014-09-14 10:49       ` Hannes Reinecke
  2014-09-14 16:40       ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Hannes Reinecke @ 2014-09-14 10:49 UTC (permalink / raw)
  To: Elliott, Robert (Server Storage), Christoph Hellwig
  Cc: James Bottomley, Ewan Milne, Yoshihiro Yunomae, linux-scsi

On 09/13/2014 03:07 AM, Elliott, Robert (Server Storage) wrote:
>> -----Original Message-----
>> From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
>> owner@vger.kernel.org] On Behalf Of Christoph Hellwig
>> Sent: Friday, 05 September, 2014 7:33 PM
>> Subject: Re: [PATCH 20/20] scsi_error: format abort error message
>>
>> On Wed, Sep 03, 2014 at 12:06:15PM +0200, Hannes Reinecke wrote:
> ...
>>> Decode the return value if the command abort failed.
>>> @@ -157,8 +157,8 @@ scmd_eh_abort_handler(struct work_struct *work)
>>>   		} else {
>>>   			SCSI_LOG_ERROR_RECOVERY(3,
>>>   				scmd_printk(KERN_INFO, scmd,
>>> -					    "scmd %p abort failed, rtn %d\n",
>>> -					    scmd, rtn));
>>> +					    "scmd %p abort failed, rtn %s\n",
>>> +					    scmd, scsi_retval_string(rtn)));
> ...
>> I've not seen an answer to my question in reply to the previous version
>> of this.  Why would you do pretty printing of a variable that can just
>> return SUCCESS or FAILURE?
>
> Is there anything prohibiting the scsi_eh_abort_handler provided by
> the LLD from returning any of the other values like NEEDS_RETRY?
>
> #define NEEDS_RETRY     0x2001
> #define SUCCESS         0x2002
> #define FAILED          0x2003
> #define QUEUED          0x2004
> #define SOFT_ERROR      0x2005
> #define ADD_TO_MLQUEUE  0x2006
> #define TIMEOUT_ERROR   0x2007
> #define SCSI_RETURN_NOT_HANDLED   0x2008
> #define FAST_IO_FAIL    0x2009
>
There is not, and hence I've added this patch.
Although the intention here would be that we should be
enforcing it, either by stating it in the description
of the function or programmatically.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 20/20] scsi_error: format abort error message
  2014-09-13  1:07     ` Elliott, Robert (Server Storage)
  2014-09-14 10:49       ` Hannes Reinecke
@ 2014-09-14 16:40       ` Christoph Hellwig
  1 sibling, 0 replies; 49+ messages in thread
From: Christoph Hellwig @ 2014-09-14 16:40 UTC (permalink / raw)
  To: Elliott, Robert (Server Storage)
  Cc: Christoph Hellwig, Hannes Reinecke, James Bottomley, Ewan Milne,
	Yoshihiro Yunomae, linux-scsi

On Sat, Sep 13, 2014 at 01:07:11AM +0000, Elliott, Robert (Server Storage) wrote:
> > I've not seen an answer to my question in reply to the previous version
> > of this.  Why would you do pretty printing of a variable that can just
> > return SUCCESS or FAILURE?
> 
> Is there anything prohibiting the scsi_eh_abort_handler provided by
> the LLD from returning any of the other values like NEEDS_RETRY?

Right now there is nothing prohibiting them from returning any possible
value, but we only handle SUCCESS specially and treat everything else
as FAILED.

If anyone is motivated enough to make this cleaner we should add a
WARN_ON for any other value as it's a driver bug.

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2014-09-14 16:40 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03 10:05 [PATCHv2 00/20] scsi logging update Hannes Reinecke
2014-09-03 10:05 ` [PATCH 01/20] Remove scsi_cmd_print_sense_hdr() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 02/20] aha152x: Debug output update and whitespace cleanup Hannes Reinecke
2014-09-06  0:02   ` Christoph Hellwig
2014-09-03 10:05 ` [PATCH 03/20] sd: Remove scsi_print_sense() in sd_done() Hannes Reinecke
2014-09-03 10:05 ` [PATCH 04/20] scsi: introduce sdev_prefix_printk() Hannes Reinecke
2014-09-06  0:03   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 05/20] scsi: Use sdev as argument for sense code printing Hannes Reinecke
2014-09-03 10:06 ` [PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails Hannes Reinecke
2014-09-06  0:04   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 07/20] scsi: do not decode sense extras Hannes Reinecke
2014-09-06  0:04   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense() Hannes Reinecke
2014-09-05  0:51   ` Yoshihiro YUNOMAE
2014-09-05  6:07     ` Hannes Reinecke
2014-09-06  0:09   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 09/20] scsi: remove scsi_print_status() Hannes Reinecke
2014-09-06  0:10   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 10/20] Implement scsi_opcode_sa_name Hannes Reinecke
2014-09-03 10:06 ` [PATCH 11/20] scsi: Use scsi_print_command() where possible Hannes Reinecke
2014-09-06  0:11   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 12/20] scsi: merge print_opcode_name() Hannes Reinecke
2014-09-05  1:24   ` Yoshihiro YUNOMAE
2014-09-06  0:12     ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name() Hannes Reinecke
2014-09-06  0:46   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 14/20] scsi: use local buffer for printing CDB Hannes Reinecke
2014-09-05  2:02   ` Yoshihiro YUNOMAE
2014-09-07 16:10   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 15/20] libata: use __scsi_print_command() Hannes Reinecke
2014-09-03 10:06 ` [PATCH 16/20] scsi: separate out scsi_retval_string() Hannes Reinecke
2014-09-05  2:04   ` Yoshihiro YUNOMAE
2014-09-05  6:14     ` Hannes Reinecke
2014-09-07 16:11   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte() Hannes Reinecke
2014-09-05  4:19   ` Yoshihiro YUNOMAE
2014-09-07 16:12   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 18/20] scsi: remove scsi_show_result() Hannes Reinecke
2014-09-05  4:22   ` Yoshihiro YUNOMAE
2014-09-07 16:17   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 19/20] sd: Reduce logging output Hannes Reinecke
2014-09-07 16:17   ` Christoph Hellwig
2014-09-03 10:06 ` [PATCH 20/20] scsi_error: format abort error message Hannes Reinecke
2014-09-05  4:23   ` Yoshihiro YUNOMAE
2014-09-06  0:33   ` Christoph Hellwig
2014-09-13  1:07     ` Elliott, Robert (Server Storage)
2014-09-14 10:49       ` Hannes Reinecke
2014-09-14 16:40       ` Christoph Hellwig
2014-09-06  0:51 ` [PATCHv2 00/20] scsi logging update Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.