Re: [PATCH 22/22] sd: Reduce logging output
On 09/01/2014 12:29 AM, Christoph Hellwig wrote: > On Thu, Aug 28, 2014 at 07:33:36PM +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. > > Is there any good reason to keep this logging in sd at all? > Mainly orthogonality. SCSI_LOG_HL(QUEUE|COMPLETE) is meant for ULDs to print out some extra logging. So as sd.c already uses SCSI_LOG_HLQUEUE to print information about I/O start it should also be using SCSI_LOG_HLCOMPLETE upon I/O finish. And should preferable record the same information at both instances so that any admin can match them together. Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage h...@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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/20] scsi: stop decoding if scsi_normalize_sense() fails
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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/20] Implement scsi_opcode_sa_name
Implement a lookup array for SERVICE ACTION commands instead of hardcoding it in a large switch statement. Reviewed-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- 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,
[PATCH 15/20] libata: use __scsi_print_command()
libata already uses an internal buffer, so we should be using __scsi_print_command() here. Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/20] scsi: remove scsi_print_status()
Last caller is gone, so we can remove it. Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 16/20] scsi: separate out scsi_retval_string()
Implement scsi_retval_string() to simplify logging. Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 12/20] scsi: merge print_opcode_name()
Instead of having two versions of print_opcode_name() we should be consolidating them into one version. Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04/20] scsi: introduce sdev_prefix_printk()
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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/20] sd: Remove scsi_print_sense() in sd_done()
sd_done() was calling scsi_print_sense() for a sense code of 'NO_SENSE'. Reviewed-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 18/20] scsi: remove scsi_show_result()
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 --- 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_ca
[PATCH 17/20] scsi: separate out scsi_host_hostbyte() and scsi_show_driverbyte()
Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 13/20] scsi: consolidate opcode lookup in scsi_opcode_sa_name()
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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/20] Remove scsi_cmd_print_sense_hdr()
Unused. Reviewed-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 19/20] sd: Reduce logging output
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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/20] aha152x: Debug output update and whitespace cleanup
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 --- 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...) #defineDO_LOCK(flags) spin_lock_irqsave(&QLOCK,flags) #defineDO_UNLOCK(flags)spin_unlock_irqrestore(&QLOCK,flags) -#endif #define LEAD "(scsi%d:%d:%d) " -#define WARN_LEAD KERN_WARNINGLEAD #define INFO_LEAD KERN_INFO LEAD -#define NOTE_LEAD KERN_NOTICE LEAD -#define ERR_LEAD KERN_ERRLEAD -#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 { sp
[PATCH 08/20] scsi: use 'bool' as return value for scsi_normalize_sense()
Convert scsi_normalize_sense() and frieds to return 'bool' instead of an integer. Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/20] scsi: Use sdev as argument for sense code printing
We should be using the standard dev_printk() variants for sense code printing. Reviewed-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- 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, +
[PATCH 07/20] scsi: do not decode sense extras
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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 14/20] scsi: use local buffer for printing CDB
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 --- 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 */ +
[PATCHv2 00/20] scsi logging update
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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 20/20] scsi_error: format abort error message
Decode the return value if the command abort failed. Suggested-by: Robert Elliot Signed-off-by: Hannes Reinecke --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/20] scsi: Use scsi_print_command() where possible
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 --- 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 &= 0x; 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_comman
RE: [PATCH/RFC V2 10/16] scsi: ufs: add UFS power management support
Hi all, Thanks for reviewing the patches, I'm sorry for the late replay. I was waiting for some comments before I address all at once and re-send the series. >> >> +static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg >> *vreg, >> + int ua) >> +{ >> +int ret = 0; >> +struct regulator *reg = vreg->reg; >> +const char *name = vreg->name; >> + >> +BUG_ON(!vreg); > > For the UFS host controller driver, which doesn't have the ufs_vreg > structure for vcc and vccq, this function can cause kernel panic due to > this BUG_ON(). Any reason to put a BUG_ON here instead of a NULL pointer > checking? > > Thanks > Chuanxiao > Sure, I'll fix this. Thanks, Dolev > -- > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH/RFC V2 10/16] scsi: ufs: add UFS power management support
Hi all, Thanks for reviewing the patches, I'm sorry for the late replay. I was waiting for some comments before I address all at once and re-send the series. >> > +/** >> > + * ufshcd_resume - helper function for resume operations >> > + * @hba: per adapter instance >> > + * @pm_op: runtime PM or system PM >> > + * >> > + * This function basically brings the UFS device, UniPro link and >> > +controller >> > + * to active state. >> > + * >> > + * Returns 0 for success and non-zero for failure */ static int >> > +ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) >> > { >> > - if (!hba) >> > - return 0; >> > + int ret; >> > + enum uic_link_state old_link_state; >> > + >> > + hba->pm_op_in_progress = 1; >> > + old_link_state = hba->uic_link_state; >> > + /* Make sure clocks are enabled before accessing controller */ >> > + ret = ufshcd_setup_clocks(hba, true); >> > + if (ret) >> > + goto out; >> > + >> > + if (hba->vops && hba->vops->setup_clocks) { >> > + ret = hba->vops->setup_clocks(hba, true); >> > + if (ret) >> > + goto disable_clks; >> > + } >> > + >> > + /* enable the host irq as host controller would be active soon */ >> > + ufshcd_enable_irq(hba); >> > + >> > + ret = ufshcd_vreg_set_hpm(hba); >> > + if (ret) >> > + goto disable_irq_and_vops_clks; >> > >> >/* >> > - * The device is idle with no requests in the queue, >> > - * allow background operations. >> > + * Call vendor specific resume callback. As these callbacks may >> access >> > + * vendor specific host controller register space call them when the >> > + * host clocks are ON. >> > */ >> > - return ufshcd_enable_auto_bkops(hba); >> > + if (hba->vops && hba->vops->resume) { >> > + ret = hba->vops->resume(hba, pm_op); >> > + if (ret) >> > + goto disable_vreg; >> > + } >> > + >> > + if (ufshcd_is_link_hibern8(hba)) { >> > + ret = ufshcd_uic_hibern8_exit(hba); >> > + if (!ret) >> > + ufshcd_set_link_active(hba); >> > + else >> > + goto vendor_suspend; >> > + } else if (ufshcd_is_link_off(hba)) { >> > + ret = ufshcd_host_reset_and_restore(hba); >> > + /* >> > + * ufshcd_host_reset_and_restore() should have already >> > + * set the link state as active >> > + */ >> > + if (ret || !ufshcd_is_link_active(hba)) >> > + goto vendor_suspend; >> > + } >> > + >> > + if (!ufshcd_is_ufs_dev_active(hba)) { >> > + ret = ufshcd_set_dev_pwr_mode(hba, UFS_ACTIVE_PWR_MODE); >> > + if (ret) >> > + goto set_old_link_state; >> > + } >> > + >> > + ufshcd_disable_auto_bkops(hba); > > Should be auto background operation enabled again in ufshcd_resume()? It > is disabled during ufshcd_suspend(). > > Thanks > Chuanxiao Chuanxiao, If the system is going for runtime suspend, the bkops are enabled if necessary, and in any case disabled before the suspend. On resume we make sure, bkops are disabled. Thanks, Dolev >> > -- >> > To unsubscribe from this list: send the line "unsubscribe linux-scsi" >> in the body >> > of a message to majord...@vger.kernel.org More majordomo info at >> > http://vger.kernel.org/majordomo-info.html >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in >> the body of a message to majord...@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Reference#
-- This is to re-notify you of the 500,000.00 USD, was deposited here in the money gram office in your name is available for pickup. Contact this email responseuw...@gmail.com for your ref # This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] drivers/target/target_core_transport.c: Fix typo issue to use 'buf' instead of 'len'
It is a typo issue, need use 'buf' instead of 'len', the related warning with allmodconfig under microblaze: drivers/target/target_core_transport.c: In function ‘transport_dump_vpd_ident_type’: drivers/target/target_core_transport.c:956:9: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast len = strlen(len); ^ In file included from include/linux/bitmap.h:8:0, from include/linux/cpumask.h:11, from include/linux/mm_types.h:12, from include/linux/kmemcheck.h:4, from include/linux/net.h:25, from drivers/target/target_core_transport.c:26: include/linux/string.h:83:24: note: expected ‘const char *’ but argument is of type ‘int’ extern __kernel_size_t strlen(const char *); ^ Signed-off-by: Chen Gang --- drivers/target/target_core_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 1dd1181..3ce85ed 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -953,7 +953,7 @@ int transport_dump_vpd_ident_type( strlcat(buf, "SCSI name string\n", sizeof(buf)); break; default: - len = strlen(len); + len = strlen(buf); snprintf(&buf[len], sizeof(buf) - len, "Unsupported: 0x%02x\n", vpd->device_identifier_type); ret = -EINVAL; -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/19] lpfc 10.4.8000.0: Update lpfc version to driver version 10.4.8000.0
Update lpfc version to driver version 10.4.8000.0 This patch set updates the lpfc driver to revision 10.4.8000.0 The patches for 10.4.8000.0 contain: - Incorporate patches posted to linux-scsi - Mark functions as static in lpfc/lpfc_sli.c - Mark functions as static in lpfc/lpfc_hbadisc.c - Mark functions as static in lpfc/lpfc_init.c - Mark functions as static in lpfc/lpfc_scsi.c - Mark function as static in lpfc/lpfc_bsg.c - Use time_after() - Use dma_zalloc_coherent - random32: do not feed jiffies as seed from lpfc driver - Use pci_enable_msix_range() instead of pci_enable_msix() - Fix discovery timeout during nameserver login - Fix quarantined XRI recovery qualifier state in link bounce - Fix IP Reset processing - wait for RDY before proceeding - Fix race between LOGO/PLOGI handling causing NULL pointer - Fix locking issues with abort data paths - Fixed crash from page fault caused by use after rport delete - Fixed High priority issues from lpfc given by fortify source code scan. - Fixed Low priority issues from lpfc given by fortify source code scan. - Fix for handling unmapped ndlp in target reset handler - Update lpfc version to driver version 10.4.8000.0 The patches were cut against Christoph's scsi-queue.git, branch "drivers-for-3.18". -- james s Signed-off-by: James Smart Signed-off-by: Dick Kennedy James Smart (19): drivers/scsi/lpfc/lpfc_attr.c | 2 +- drivers/scsi/lpfc/lpfc_bsg.c | 20 ++- drivers/scsi/lpfc/lpfc_crtn.h | 1 - drivers/scsi/lpfc/lpfc_ct.c| 14 ++- drivers/scsi/lpfc/lpfc_debugfs.c | 4 +- drivers/scsi/lpfc/lpfc_disc.h | 6 +- drivers/scsi/lpfc/lpfc_els.c | 33 +++-- drivers/scsi/lpfc/lpfc_hbadisc.c | 53 +--- drivers/scsi/lpfc/lpfc_init.c | 225 - drivers/scsi/lpfc/lpfc_mbox.c | 6 +- drivers/scsi/lpfc/lpfc_nportdisc.c | 2 + drivers/scsi/lpfc/lpfc_scsi.c | 34 +++-- drivers/scsi/lpfc/lpfc_sli.c | 247 ++--- drivers/scsi/lpfc/lpfc_sli.h | 1 + drivers/scsi/lpfc/lpfc_sli4.h | 20 +-- drivers/scsi/lpfc/lpfc_version.h | 2 +- 16 files changed, 351 insertions(+), 319 deletions(-) -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/19] lpfc 10.4.8000.0: Mark functions as static in lpfc/lpfc_sli.c
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=139611643606816&w=2 Rashika Kheria [PATCH 22/55] scsi: Mark functions as static in lpfc/lpfc_sli.c Mark functions as static in lpfc/lpfc_sli.c because they are not used outside this file. This eliminates the following warnings in lpfc/lpfc_sli.c: drivers/scsi/lpfc/lpfc_sli.c:13867:1: warning: no previous prototype for ‘lpfc_sli4_alloc_xri’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_sli.c:13897:1: warning: no previous prototype for ‘__lpfc_sli4_free_xri’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_sli.c:14317:1: warning: no previous prototype for ‘lpfc_update_rcv_time_stamp’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_sli.c:14786:1: warning: no previous prototype for ‘lpfc_sli4_handle_unsol_abort’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_sli.c:15331:1: warning: no previous prototype for ‘__lpfc_sli4_free_rpi’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_sli.c:15769:1: warning: no previous prototype for ‘lpfc_check_next_fcf_pri_level’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_sli.c:16000:1: warning: no previous prototype for ‘lpfc_mbx_cmpl_redisc_fcf_table’ [-Wmissing-prototypes] Signed-off-by: Rashika Kheria Reviewed-by: Josh Triplett Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_sli.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 32ada05..04a8b74 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -14270,7 +14270,7 @@ lpfc_sli4_post_sgl(struct lpfc_hba *phba, * A nonzero rpi defined as rpi_base <= rpi < max_rpi if successful * LPFC_RPI_ALLOC_ERROR if no rpis are available. **/ -uint16_t +static uint16_t lpfc_sli4_alloc_xri(struct lpfc_hba *phba) { unsigned long xri; @@ -14300,7 +14300,7 @@ lpfc_sli4_alloc_xri(struct lpfc_hba *phba) * This routine is invoked to release an xri to the pool of * available rpis maintained by the driver. **/ -void +static void __lpfc_sli4_free_xri(struct lpfc_hba *phba, int xri) { if (test_and_clear_bit(xri, phba->sli4_hba.xri_bmask)) { @@ -14720,7 +14720,7 @@ lpfc_fc_frame_to_vport(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr, * the driver uses this time stamp to indicate if any received sequences have * timed out. **/ -void +static void lpfc_update_rcv_time_stamp(struct lpfc_vport *vport) { struct lpfc_dmabuf *h_buf; @@ -15189,7 +15189,7 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, * unsolicited sequence has been aborted. After that, it will issue a basic * accept to accept the abort. **/ -void +static void lpfc_sli4_handle_unsol_abort(struct lpfc_vport *vport, struct hbq_dmabuf *dmabuf) { @@ -15734,7 +15734,7 @@ lpfc_sli4_alloc_rpi(struct lpfc_hba *phba) * This routine is invoked to release an rpi to the pool of * available rpis maintained by the driver. **/ -void +static void __lpfc_sli4_free_rpi(struct lpfc_hba *phba, int rpi) { if (test_and_clear_bit(rpi, phba->sli4_hba.rpi_bmask)) { @@ -16172,7 +16172,7 @@ fail_fcf_read: * returns: * 1=success 0=failure **/ -int +static int lpfc_check_next_fcf_pri_level(struct lpfc_hba *phba) { uint16_t next_fcf_pri; @@ -16403,7 +16403,7 @@ lpfc_sli4_fcf_rr_index_clear(struct lpfc_hba *phba, uint16_t fcf_index) * command. If the mailbox command returned failure, it will try to stop the * FCF rediscover wait timer. **/ -void +static void lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) { struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/19] lpfc 10.4.8000.0: Use time_after()
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=140053378307936&w=2 manuel.schoell...@gmx.de [PATCH] lpfc: Use time_after() To be future-proof and for better readability the time comparisons are modified to use time_after() instead of plain, error-prone math. Signed-off-by: Manuel Schölling Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 3c250e3..6094545 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -380,12 +380,14 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba) { unsigned long flags; uint32_t evt_posted; + unsigned long expires; spin_lock_irqsave(&phba->hbalock, flags); atomic_inc(&phba->num_rsrc_err); phba->last_rsrc_error_time = jiffies; - if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) { + expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL; + if (time_after(expires, jiffies)) { spin_unlock_irqrestore(&phba->hbalock, flags); return; } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/19] lpfc 10.4.8000.0: Mark functions as static in lpfc/lpfc_scsi.c
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=139611665406898&w=2 Rashika Kheria [PATCH 25/55] scsi: Mark functions as static in lpfc/lpfc_scsi.c Mark functions as static in lpfc/lpfc_scsi.c because they are not used outside this file. This eliminates the following warnings in lpfc/lpfc_scsi.c: drivers/scsi/lpfc/lpfc_scsi.c:299:1: warning: no previous prototype for ‘lpfc_change_queue_depth’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_scsi.c:795:1: warning: no previous prototype for ‘lpfc_sli4_post_scsi_sgl_list’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_scsi.c:3019:1: warning: no previous prototype for ‘lpfc_bg_crc’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_scsi.c:3035:1: warning: no previous prototype for ‘lpfc_bg_csum’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_scsi.c:3048:1: warning: no previous prototype for ‘lpfc_calc_bg_err’ [-Wmissing-prototypes] Signed-off-by: Rashika Kheria Reviewed-by: Josh Triplett Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 7862c55..3c250e3 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -306,7 +306,7 @@ lpfc_send_sdev_queuedepth_change_event(struct lpfc_hba *phba, * depth for a scsi device. This function sets the queue depth to the new * value and sends an event out to log the queue depth change. **/ -int +static int lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) { struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; @@ -741,7 +741,7 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, * * Returns: 0 = failure, non-zero number of successfully posted buffers. **/ -int +static int lpfc_sli4_post_scsi_sgl_list(struct lpfc_hba *phba, struct list_head *post_sblist, int sb_count) { @@ -2965,7 +2965,7 @@ err: * on the specified data using a CRC algorithmn * using crc_t10dif. */ -uint16_t +static uint16_t lpfc_bg_crc(uint8_t *data, int count) { uint16_t crc = 0; @@ -2981,7 +2981,7 @@ lpfc_bg_crc(uint8_t *data, int count) * on the specified data using a CSUM algorithmn * using ip_compute_csum. */ -uint16_t +static uint16_t lpfc_bg_csum(uint8_t *data, int count) { uint16_t ret; @@ -2994,7 +2994,7 @@ lpfc_bg_csum(uint8_t *data, int count) * This function examines the protection data to try to determine * what type of T10-DIF error occurred. */ -void +static void lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) { struct scatterlist *sgpe; /* s/g prot entry */ -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/19] lpfc 10.4.8000.0: Mark functions as static in lpfc/lpfc_init.c
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=139611657206858&w=2 Rashika Kheria [PATCH 24/55] scsi: Mark functions as static in lpfc/lpfc_init.c Mark functions as static in lpfc/lpfc_init.c because they are not used outside this file. This eliminates the following warning in lpfc/lpfc_init.c: drivers/scsi/lpfc/lpfc_init.c:652:1: warning: no previous prototype for ‘lpfc_hba_init_link’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_init.c:753:1: warning: no previous prototype for ‘lpfc_hba_down_link’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_init.c:3434:1: warning: no previous prototype for ‘lpfc_sli4_fcf_redisc_wait_tmo’ [-Wmissing-prototypes] Signed-off-by: Rashika Kheria Reviewed-by: Josh Triplett Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index a5769a9..60d9518 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -649,7 +649,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) * 0 - success * Any other value - error **/ -int +static int lpfc_hba_init_link(struct lpfc_hba *phba, uint32_t flag) { return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); @@ -750,7 +750,7 @@ lpfc_hba_init_link_fc_topology(struct lpfc_hba *phba, uint32_t fc_topology, * 0 - success * Any other value - error **/ -int +static int lpfc_hba_down_link(struct lpfc_hba *phba, uint32_t flag) { LPFC_MBOXQ_t *pmb; @@ -3550,7 +3550,7 @@ lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *phba) * list, and then worker thread shall be waked up for processing from the * worker thread context. **/ -void +static void lpfc_sli4_fcf_redisc_wait_tmo(unsigned long ptr) { struct lpfc_hba *phba = (struct lpfc_hba *)ptr; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/19] lpfc 10.4.8000.0: Mark function as static in lpfc/lpfc_bsg.c
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=139611670006912&w=2 Rashika Kheria [PATCH 26/55] scsi: Mark function as static in lpfc/lpfc_bsg.c Mark function as static in lpfc/lpfc_bsg.c because it is not used outside this file. This eliminates the following warning in lpfc/lpfc_bsg.c: drivers/scsi/lpfc/lpfc_bsg.c:3348:1: warning: no previous prototype for ‘lpfc_bsg_issue_mbox_cmpl’ [-Wmissing-prototypes] Signed-off-by: Rashika Kheria Reviewed-by: Josh Triplett Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_bsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index 5b5c825..371474b 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -3344,7 +3344,7 @@ job_error: * will wake up thread waiting on the wait queue pointed by context1 * of the mailbox. **/ -void +static void lpfc_bsg_issue_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) { struct bsg_job_data *dd_data; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/19] lpfc 10.4.8000.0: Mark functions as static in lpfc/lpfc_hbadisc.c
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=139611651106838&w=2 Rashika Kheria [PATCH 23/55] scsi: Mark functions as static in lpfc/lpfc_hbadisc.c Mark functions as static in lpfc/lpfc_hbadisc.c because they are not used outside this file. This eliminates the following warnings in lpfc/lpfc_hbadisc.c: drivers/scsi/lpfc/lpfc_hbadisc.c:2047:5: warning: no previous prototype for ‘lpfc_sli4_fcf_pri_list_add’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_hbadisc.c:2681:1: warning: no previous prototype for ‘lpfc_init_vfi_cmpl’ [-Wmissing-prototypes] drivers/scsi/lpfc/lpfc_hbadisc.c:4432:1: warning: no previous prototype for ‘lpfc_nlp_logo_unreg’ [-Wmissing-prototypes] Signed-off-by: Rashika Kheria Reviewed-by: Josh Triplett Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_hbadisc.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2a17e31..667d124 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -2042,7 +2042,8 @@ lpfc_sli4_set_fcf_flogi_fail(struct lpfc_hba *phba, uint16_t fcf_index) * returns: * 0=success 1=failure **/ -int lpfc_sli4_fcf_pri_list_add(struct lpfc_hba *phba, uint16_t fcf_index, +static int lpfc_sli4_fcf_pri_list_add(struct lpfc_hba *phba, + uint16_t fcf_index, struct fcf_record *new_fcf_record) { uint16_t current_fcf_pri; @@ -2678,7 +2679,7 @@ out: * * This function handles completion of init vfi mailbox command. */ -void +static void lpfc_init_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) { struct lpfc_vport *vport = mboxq->vport; @@ -4438,7 +4439,7 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) * This function will issue an ELS LOGO command after completing * the UNREG_RPI. **/ -void +static void lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/19] lpfc 10.4.8000.0: Fix quarantined XRI recovery qualifier state in link bounce
Fix quarantined XRI recovery qualifier state in link bounce Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_crtn.h| 1 - drivers/scsi/lpfc/lpfc_hbadisc.c | 1 - drivers/scsi/lpfc/lpfc_sli.c | 36 3 files changed, 38 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index db5604f..00665a5 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h @@ -451,7 +451,6 @@ int lpfc_send_rrq(struct lpfc_hba *, struct lpfc_node_rrq *); int lpfc_set_rrq_active(struct lpfc_hba *, struct lpfc_nodelist *, uint16_t, uint16_t, uint16_t); uint16_t lpfc_sli4_xri_inrange(struct lpfc_hba *, uint16_t); -void lpfc_cleanup_wt_rrqs(struct lpfc_hba *); void lpfc_cleanup_vports_rrqs(struct lpfc_vport *, struct lpfc_nodelist *); struct lpfc_node_rrq *lpfc_get_active_rrq(struct lpfc_vport *, uint16_t, uint32_t); diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 859fffa..d178aee 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -995,7 +995,6 @@ lpfc_linkup(struct lpfc_hba *phba) struct lpfc_vport **vports; int i; - lpfc_cleanup_wt_rrqs(phba); phba->link_state = LPFC_LINK_UP; /* Unblock fabric iocbs if they are blocked */ diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 8f3be2a..deb7f12 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -786,42 +786,6 @@ lpfc_cleanup_vports_rrqs(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) } /** - * lpfc_cleanup_wt_rrqs - Remove all rrq's from the active list. - * @phba: Pointer to HBA context object. - * - * Remove all rrqs from the phba->active_rrq_list and free them by - * calling __lpfc_clr_active_rrq - * - **/ -void -lpfc_cleanup_wt_rrqs(struct lpfc_hba *phba) -{ - struct lpfc_node_rrq *rrq; - struct lpfc_node_rrq *nextrrq; - unsigned long next_time; - unsigned long iflags; - LIST_HEAD(rrq_list); - - if (phba->sli_rev != LPFC_SLI_REV4) - return; - spin_lock_irqsave(&phba->hbalock, iflags); - phba->hba_flag &= ~HBA_RRQ_ACTIVE; - next_time = jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov * 2)); - list_splice_init(&phba->active_rrq_list, &rrq_list); - spin_unlock_irqrestore(&phba->hbalock, iflags); - - list_for_each_entry_safe(rrq, nextrrq, &rrq_list, list) { - list_del(&rrq->list); - lpfc_clr_rrq_active(phba, rrq->xritag, rrq); - } - if ((!list_empty(&phba->active_rrq_list)) && - (!(phba->pport->load_flag & FC_UNLOADING))) - - mod_timer(&phba->rrq_tmr, next_time); -} - - -/** * lpfc_test_rrq_active - Test RRQ bit in xri_bitmap. * @phba: Pointer to HBA context object. * @ndlp: Targets nodelist pointer for this exchange. -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/19] lpfc 10.4.8000.0: random32: do not feed jiffies as seed from lpfc driver
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=140688548016998&w=2 Daniel Borkmann [PATCH] random32: do not feed jiffies as seed from lpfc driver In prandom we have already reseeding mechanisms that trigger periodically from a much better entropy source than just feeding in jiffies through lpfc_mbx_cmpl_fcf_scan_read_fcf_rec() [what a function name 8-)]. Therefore, just remove this. Signed-off-by: Daniel Borkmann Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_hbadisc.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 667d124..859fffa 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -2147,7 +2147,6 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) uint16_t fcf_index, next_fcf_index; struct lpfc_fcf_rec *fcf_rec = NULL; uint16_t vlan_id; - uint32_t seed; bool select_new_fcf; int rc; @@ -2384,9 +2383,6 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) phba->fcf.fcf_flag |= FCF_AVAILABLE; /* Setup initial running random FCF selection count */ phba->fcf.eligible_fcf_cnt = 1; - /* Seeding the random number generator for random selection */ - seed = (uint32_t)(0x & jiffies); - prandom_seed(seed); } spin_unlock_irq(&phba->hbalock); goto read_next_fcf; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 9/19] lpfc 10.4.8000.0: Use pci_enable_msix_range() instead of pci_enable_msix()
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=140835226413990&w=2 Alexander Gordeev [PATCH v3 11/13] lpfc: Use pci_enable_msix_range() instead of pci_enable_msix() As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces. Signed-off-by: Alexander Gordeev Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_init.c | 39 +-- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 990c3a2..1953b3b 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -8203,9 +8203,9 @@ lpfc_sli4_pci_mem_unset(struct lpfc_hba *phba) * @phba: pointer to lpfc hba data structure. * * This routine is invoked to enable the MSI-X interrupt vectors to device - * with SLI-3 interface specs. The kernel function pci_enable_msix() is - * called to enable the MSI-X vectors. Note that pci_enable_msix(), once - * invoked, enables either all or nothing, depending on the current + * with SLI-3 interface specs. The kernel function pci_enable_msix_exact() + * is called to enable the MSI-X vectors. Note that pci_enable_msix_exact(), + * once invoked, enables either all or nothing, depending on the current * availability of PCI vector resources. The device driver is responsible * for calling the individual request_irq() to register each MSI-X vector * with a interrupt handler, which is done in this function. Note that @@ -8229,8 +8229,8 @@ lpfc_sli_enable_msix(struct lpfc_hba *phba) phba->msix_entries[i].entry = i; /* Configure MSI-X capability structure */ - rc = pci_enable_msix(phba->pcidev, phba->msix_entries, - ARRAY_SIZE(phba->msix_entries)); + rc = pci_enable_msix_exact(phba->pcidev, phba->msix_entries, + LPFC_MSIX_VECTORS); if (rc) { lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "0420 PCI enable MSI-X failed (%d)\n", rc); @@ -8767,16 +8767,14 @@ out: * @phba: pointer to lpfc hba data structure. * * This routine is invoked to enable the MSI-X interrupt vectors to device - * with SLI-4 interface spec. The kernel function pci_enable_msix() is called - * to enable the MSI-X vectors. Note that pci_enable_msix(), once invoked, - * enables either all or nothing, depending on the current availability of - * PCI vector resources. The device driver is responsible for calling the - * individual request_irq() to register each MSI-X vector with a interrupt - * handler, which is done in this function. Note that later when device is - * unloading, the driver should always call free_irq() on all MSI-X vectors - * it has done request_irq() on before calling pci_disable_msix(). Failure - * to do so results in a BUG_ON() and a device will be left with MSI-X - * enabled and leaks its vectors. + * with SLI-4 interface spec. The kernel function pci_enable_msix_range() + * is called to enable the MSI-X vectors. The device driver is responsible + * for calling the individual request_irq() to register each MSI-X vector + * with a interrupt handler, which is done in this function. Note that + * later when device is unloading, the driver should always call free_irq() + * on all MSI-X vectors it has done request_irq() on before calling + * pci_disable_msix(). Failure to do so results in a BUG_ON() and a device + * will be left with MSI-X enabled and leaks its vectors. * * Return codes * 0 - successful @@ -8797,17 +8795,14 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba) phba->sli4_hba.msix_entries[index].entry = index; vectors++; } -enable_msix_vectors: - rc = pci_enable_msix(phba->pcidev, phba->sli4_hba.msix_entries, -vectors); - if (rc > 1) { - vectors = rc; - goto enable_msix_vectors; - } else if (rc) { + rc = pci_enable_msix_range(phba->pcidev, phba->sli4_hba.msix_entries, + 2, vectors); + if (rc < 0) { lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "0484 PCI enable MSI-X failed (%d)\n", rc); goto vec_fail_out; } + vectors = rc; /* Log MSI-X vector assignment */ for (index = 0; index < vectors; index++) -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/19] lpfc 10.4.8000.0: Use dma_zalloc_coherent
Incorporating prior patch: http://marc.info/?l=linux-scsi&m=140286492825640&w=2 Joe Perches [PATCH -next 19/26] lpfc: Use dma_zalloc_coherent Use the zeroing function instead of dma_alloc_coherent & memset(,0,) Signed-off-by: Joe Perches Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_bsg.c | 5 ++--- drivers/scsi/lpfc/lpfc_init.c | 22 +++--- drivers/scsi/lpfc/lpfc_mbox.c | 6 +++--- drivers/scsi/lpfc/lpfc_sli.c | 14 +- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index 371474b..d236448 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -2693,14 +2693,13 @@ lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba) INIT_LIST_HEAD(&dmabuf->list); /* now, allocate dma buffer */ - dmabuf->virt = dma_alloc_coherent(&pcidev->dev, BSG_MBOX_SIZE, - &(dmabuf->phys), GFP_KERNEL); + dmabuf->virt = dma_zalloc_coherent(&pcidev->dev, BSG_MBOX_SIZE, + &(dmabuf->phys), GFP_KERNEL); if (!dmabuf->virt) { kfree(dmabuf); return NULL; } - memset((uint8_t *)dmabuf->virt, 0, BSG_MBOX_SIZE); return dmabuf; } diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 60d9518..990c3a2 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -5848,16 +5848,14 @@ lpfc_sli4_create_rpi_hdr(struct lpfc_hba *phba) if (!dmabuf) return NULL; - dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, - LPFC_HDR_TEMPLATE_SIZE, - &dmabuf->phys, - GFP_KERNEL); + dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, + LPFC_HDR_TEMPLATE_SIZE, + &dmabuf->phys, GFP_KERNEL); if (!dmabuf->virt) { rpi_hdr = NULL; goto err_free_dmabuf; } - memset(dmabuf->virt, 0, LPFC_HDR_TEMPLATE_SIZE); if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { rpi_hdr = NULL; goto err_free_coherent; @@ -6246,14 +6244,11 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba) } /* Allocate memory for SLI-2 structures */ - phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, - SLI2_SLIM_SIZE, - &phba->slim2p.phys, - GFP_KERNEL); + phba->slim2p.virt = dma_zalloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, + &phba->slim2p.phys, GFP_KERNEL); if (!phba->slim2p.virt) goto out_iounmap; - memset(phba->slim2p.virt, 0, SLI2_SLIM_SIZE); phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); phba->mbox_ext = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx_ext_words)); @@ -6618,15 +6613,12 @@ lpfc_create_bootstrap_mbox(struct lpfc_hba *phba) * plus an alignment restriction of 16 bytes. */ bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); - dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, - bmbx_size, - &dmabuf->phys, - GFP_KERNEL); + dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, bmbx_size, + &dmabuf->phys, GFP_KERNEL); if (!dmabuf->virt) { kfree(dmabuf); return -ENOMEM; } - memset(dmabuf->virt, 0, bmbx_size); /* * Initialize the bootstrap mailbox pointers now so that the register diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 1f292e2..06241f5 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c @@ -1811,12 +1811,12 @@ lpfc_sli4_config(struct lpfc_hba *phba, struct lpfcMboxq *mbox, * page, this is used as a priori size of SLI4_PAGE_SIZE for * the later DMA memory free. */ - viraddr = dma_alloc_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, -&phyaddr, GFP_KERNEL); + viraddr = dma_zalloc_coherent(&phba->pcidev->dev, + SLI4_PAGE_SIZE, &phyaddr, + GFP_KERNEL); /* In case of malloc fails, proceed with whatever we have */ if (!viraddr) break; - memset(viraddr, 0, SLI4_PAGE_SIZE);
[PATCH 10/19] lpfc 10.4.8000.0: Fix discovery timeout during nameserver login
Fix discovery timeout during nameserver login Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_els.c | 5 + drivers/scsi/lpfc/lpfc_init.c | 15 +++ drivers/scsi/lpfc/lpfc_sli.c | 10 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 7a5d81a..30ec80f 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -8187,9 +8187,11 @@ lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, list_del(&sglq_entry->list); ndlp = sglq_entry->ndlp; sglq_entry->ndlp = NULL; + spin_lock(&pring->ring_lock); list_add_tail(&sglq_entry->list, &phba->sli4_hba.lpfc_sgl_list); sglq_entry->state = SGL_FREED; + spin_unlock(&pring->ring_lock); spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); spin_unlock_irqrestore(&phba->hbalock, iflag); lpfc_set_rrq_active(phba, ndlp, @@ -8208,12 +8210,15 @@ lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, spin_unlock_irqrestore(&phba->hbalock, iflag); return; } + spin_lock(&pring->ring_lock); sglq_entry = __lpfc_get_active_sglq(phba, lxri); if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) { + spin_unlock(&pring->ring_lock); spin_unlock_irqrestore(&phba->hbalock, iflag); return; } sglq_entry->state = SGL_XRI_ABORTED; + spin_unlock(&pring->ring_lock); spin_unlock_irqrestore(&phba->hbalock, iflag); return; } diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 1953b3b..7f54916 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -988,9 +988,12 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) LIST_HEAD(aborts); unsigned long iflag = 0; struct lpfc_sglq *sglq_entry = NULL; + struct lpfc_sli *psli = &phba->sli; + struct lpfc_sli_ring *pring; lpfc_hba_free_post_buf(phba); lpfc_hba_clean_txcmplq(phba); + pring = &psli->ring[LPFC_ELS_RING]; /* At this point in time the HBA is either reset or DOA. Either * way, nothing should be on lpfc_abts_els_sgl_list, it needs to be @@ -1008,8 +1011,10 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) &phba->sli4_hba.lpfc_abts_els_sgl_list, list) sglq_entry->state = SGL_FREED; + spin_lock(&pring->ring_lock); list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, &phba->sli4_hba.lpfc_sgl_list); + spin_unlock(&pring->ring_lock); spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); /* abts_scsi_buf_list_lock required because worker thread uses this * list. @@ -3047,6 +3052,7 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba) LIST_HEAD(els_sgl_list); LIST_HEAD(scsi_sgl_list); int rc; + struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; /* * update on pci function's els xri-sgl list @@ -3087,7 +3093,9 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba) list_add_tail(&sglq_entry->list, &els_sgl_list); } spin_lock_irq(&phba->hbalock); + spin_lock(&pring->ring_lock); list_splice_init(&els_sgl_list, &phba->sli4_hba.lpfc_sgl_list); + spin_unlock(&pring->ring_lock); spin_unlock_irq(&phba->hbalock); } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { /* els xri-sgl shrinked */ @@ -3097,7 +3105,9 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba) "%d to %d\n", phba->sli4_hba.els_xri_cnt, els_xri_cnt); spin_lock_irq(&phba->hbalock); + spin_lock(&pring->ring_lock); list_splice_init(&phba->sli4_hba.lpfc_sgl_list, &els_sgl_list); + spin_unlock(&pring->ring_lock); spin_unlock_irq(&phba->hbalock); /* release extra els sgls from list */ for (i = 0; i < xri_cnt; i++) { @@ -3110,7 +3120,9 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba) } } spin_lock_irq(&phba->hbalock); + spin_lock(&pring->ring_lock); list_splice_init(&els_sgl_list, &phba->sli4_hba.lpfc_sgl_list); + spin_unlock(&pring->ring_lock); spin_unlock_irq(&phba->hbalock); } else lpfc_printf_log(phba, KERN_INFO, LOG_SLI, @@ -5680,10 +5692,13 @@ static void lpfc_free_els_sgl_list(struct lpfc_hba *phba) { LIST_HEAD(sglq_l
[PATCH 12/19] lpfc 10.4.8000.0: Fix IP Reset processing - wait for RDY before proceeding
Fix IP Reset processing - wait for RDY before proceeding Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_init.c | 109 ++ 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 7f54916..33a24fc0 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -7903,7 +7903,8 @@ lpfc_pci_function_reset(struct lpfc_hba *phba) LPFC_MBOXQ_t *mboxq; uint32_t rc = 0, if_type; uint32_t shdr_status, shdr_add_status; - uint32_t rdy_chk, num_resets = 0, reset_again = 0; + uint32_t rdy_chk; + uint32_t port_reset = 0; union lpfc_sli4_cfg_shdr *shdr; struct lpfc_register reg_data; uint16_t devid; @@ -7943,9 +7944,42 @@ lpfc_pci_function_reset(struct lpfc_hba *phba) } break; case LPFC_SLI_INTF_IF_TYPE_2: - for (num_resets = 0; -num_resets < MAX_IF_TYPE_2_RESETS; -num_resets++) { +wait: + /* +* Poll the Port Status Register and wait for RDY for +* up to 30 seconds. If the port doesn't respond, treat +* it as an error. +*/ + for (rdy_chk = 0; rdy_chk < 3000; rdy_chk++) { + if (lpfc_readl(phba->sli4_hba.u.if_type2. + STATUSregaddr, ®_data.word0)) { + rc = -ENODEV; + goto out; + } + if (bf_get(lpfc_sliport_status_rdy, ®_data)) + break; + msleep(20); + } + + if (!bf_get(lpfc_sliport_status_rdy, ®_data)) { + phba->work_status[0] = readl( + phba->sli4_hba.u.if_type2.ERR1regaddr); + phba->work_status[1] = readl( + phba->sli4_hba.u.if_type2.ERR2regaddr); + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, + "2890 Port not ready, port status reg " + "0x%x error 1=0x%x, error 2=0x%x\n", + reg_data.word0, + phba->work_status[0], + phba->work_status[1]); + rc = -ENODEV; + goto out; + } + + if (!port_reset) { + /* +* Reset the port now +*/ reg_data.word0 = 0; bf_set(lpfc_sliport_ctrl_end, ®_data, LPFC_SLIPORT_LITTLE_ENDIAN); @@ -7956,64 +7990,16 @@ lpfc_pci_function_reset(struct lpfc_hba *phba) /* flush */ pci_read_config_word(phba->pcidev, PCI_DEVICE_ID, &devid); - /* -* Poll the Port Status Register and wait for RDY for -* up to 10 seconds. If the port doesn't respond, treat -* it as an error. If the port responds with RN, start -* the loop again. -*/ - for (rdy_chk = 0; rdy_chk < 1000; rdy_chk++) { - msleep(10); - if (lpfc_readl(phba->sli4_hba.u.if_type2. - STATUSregaddr, ®_data.word0)) { - rc = -ENODEV; - goto out; - } - if (bf_get(lpfc_sliport_status_rn, ®_data)) - reset_again++; - if (bf_get(lpfc_sliport_status_rdy, ®_data)) - break; - } - - /* -* If the port responds to the init request with -* reset needed, delay for a bit and restart the loop. -*/ - if (reset_again && (rdy_chk < 1000)) { - msleep(10); - reset_again = 0; - continue; - } - /* Detect any port errors. */ - if ((bf_get(lpfc_sliport_status_err, ®_data)) || - (rdy_chk >= 1000)) { - phba->work_status[0] = readl( - phba->sli4_hba.u.if_type2.ERR1regaddr); - phba->work_status[1] = readl( -
[PATCH 13/19] lpfc 10.4.8000.0: Fix race between LOGO/PLOGI handling causing NULL pointer
Fix race between LOGO/PLOGI handling causing NULL pointer Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_disc.h| 6 +- drivers/scsi/lpfc/lpfc_els.c | 7 +++ drivers/scsi/lpfc/lpfc_hbadisc.c | 19 ++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index 1a6fe52..6977027 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h @@ -78,7 +78,8 @@ struct lpfc_nodelist { struct list_head nlp_listp; struct lpfc_name nlp_portname; struct lpfc_name nlp_nodename; - uint32_t nlp_flag; /* entry flags */ + uint32_t nlp_flag; /* entry flags */ + uint32_t nlp_add_flag; /* additional flags */ uint32_t nlp_DID; /* FC D_ID of entry */ uint32_t nlp_last_elscmd; /* Last ELS cmd sent */ uint16_t nlp_type; @@ -157,6 +158,9 @@ struct lpfc_node_rrq { #define NLP_FIRSTBURST 0x4000 /* Target supports FirstBurst */ #define NLP_RPI_REGISTERED 0x8000 /* nlp_rpi is valid */ +/* Defines for nlp_add_flag (uint32) */ +#define NLP_IN_DEV_LOSS 0x0001/* Dev Loss processing in progress */ + /* ndlp usage management macros */ #define NLP_CHK_NODE_ACT(ndlp) (((ndlp)->nlp_usg_map \ & NLP_USG_NODE_ACT_BIT) \ diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 30ec80f..9d03e72 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -6693,6 +6693,13 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, phba->fc_stat.elsRcvFrame++; + /* +* Do not process any unsolicited ELS commands +* if the ndlp is in DEV_LOSS +*/ + if (ndlp->nlp_add_flag & NLP_IN_DEV_LOSS) + goto dropit; + elsiocb->context1 = lpfc_nlp_get(ndlp); elsiocb->vport = vport; diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index d178aee..2d929a5 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -153,6 +153,16 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) put_device(&rport->dev); return; } + + put_node = rdata->pnode != NULL; + put_rport = ndlp->rport != NULL; + rdata->pnode = NULL; + ndlp->rport = NULL; + if (put_node) + lpfc_nlp_put(ndlp); + if (put_rport) + put_device(&rport->dev); + return; } evtp = &ndlp->dev_loss_evt; @@ -161,6 +171,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) return; evtp->evt_arg1 = lpfc_nlp_get(ndlp); + ndlp->nlp_add_flag |= NLP_IN_DEV_LOSS; spin_lock_irq(&phba->hbalock); /* We need to hold the node by incrementing the reference @@ -201,8 +212,10 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) rport = ndlp->rport; - if (!rport) + if (!rport) { + ndlp->nlp_add_flag &= ~NLP_IN_DEV_LOSS; return fcf_inuse; + } rdata = rport->dd_data; name = (uint8_t *) &ndlp->nlp_portname; @@ -235,6 +248,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) put_rport = ndlp->rport != NULL; rdata->pnode = NULL; ndlp->rport = NULL; + ndlp->nlp_add_flag &= ~NLP_IN_DEV_LOSS; if (put_node) lpfc_nlp_put(ndlp); if (put_rport) @@ -250,6 +264,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) *name, *(name+1), *(name+2), *(name+3), *(name+4), *(name+5), *(name+6), *(name+7), ndlp->nlp_DID); + ndlp->nlp_add_flag &= ~NLP_IN_DEV_LOSS; return fcf_inuse; } @@ -259,6 +274,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) put_rport = ndlp->rport != NULL; rdata->pnode = NULL; ndlp->rport = NULL; + ndlp->nlp_add_flag &= ~NLP_IN_DEV_LOSS; if (put_node) lpfc_nlp_put(ndlp); if (put_rport) @@ -297,6 +313,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) put_rport = ndlp->rport != NULL; rdata->pnode = NULL; ndlp->rport = NULL; + ndlp->nlp_add_flag &= ~NLP_IN_DEV_LOSS; if (put_node) lpfc_nlp_put(ndlp); if (put_rport) -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to ma
[PATCH 14/19] lpfc 10.4.8000.0: Fix locking issues with abort data paths
Fix locking issues with abort data paths Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_scsi.c | 12 - drivers/scsi/lpfc/lpfc_sli.c | 118 +- drivers/scsi/lpfc/lpfc_sli.h | 1 + 3 files changed, 83 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 6094545..0f6be85 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -3466,7 +3466,7 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) */ if ((phba->cfg_fof) && ((struct lpfc_device_data *) scsi_cmnd->device->hostdata)->oas_enabled) - lpfc_cmd->cur_iocbq.iocb_flag |= LPFC_IO_OAS; + lpfc_cmd->cur_iocbq.iocb_flag |= (LPFC_IO_OAS | LPFC_IO_FOF); return 0; } @@ -3606,6 +3606,14 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, */ iocb_cmd->un.fcpi.fcpi_parm = fcpdl; + /* +* If the OAS driver feature is enabled and the lun is enabled for +* OAS, set the oas iocb related flags. +*/ + if ((phba->cfg_fof) && ((struct lpfc_device_data *) + scsi_cmnd->device->hostdata)->oas_enabled) + lpfc_cmd->cur_iocbq.iocb_flag |= (LPFC_IO_OAS | LPFC_IO_FOF); + return 0; err: if (lpfc_cmd->seg_cnt) @@ -4876,6 +4884,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) /* ABTS WQE must go to the same WQ as the WQE to be aborted */ abtsiocb->fcp_wqidx = iocb->fcp_wqidx; abtsiocb->iocb_flag |= LPFC_USE_FCPWQIDX; + if (iocb->iocb_flag & LPFC_IO_FOF) + abtsiocb->iocb_flag |= LPFC_IO_FOF; if (lpfc_is_link_up(phba)) icmd->ulpCommand = CMD_ABORT_XRI_CN; diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index deb7f12..7185aac 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -8753,6 +8753,37 @@ lpfc_sli_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp) return 0; } +int +lpfc_sli_calc_ring(struct lpfc_hba *phba, uint32_t ring_number, + struct lpfc_iocbq *piocb) +{ + uint32_t idx; + + if (phba->sli_rev == LPFC_SLI_REV4) { + if (piocb->iocb_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) { + /* +* fcp_wqidx should already be setup based on what +* completion queue we want to use. +*/ + if (!(phba->cfg_fof) || + (!(piocb->iocb_flag & LPFC_IO_FOF))) { + if (unlikely(!phba->sli4_hba.fcp_wq)) + return LPFC_HBA_ERROR; + idx = lpfc_sli4_scmd_to_wqidx_distr(phba); + piocb->fcp_wqidx = idx; + ring_number = MAX_SLI3_CONFIGURED_RINGS + idx; + } else { + if (unlikely(!phba->sli4_hba.oas_wq)) + return LPFC_HBA_ERROR; + idx = 0; + piocb->fcp_wqidx = idx; + ring_number = LPFC_FCP_OAS_RING; + } + } + } + return ring_number; +} + /** * lpfc_sli_issue_iocb - Wrapper function for __lpfc_sli_issue_iocb * @phba: Pointer to HBA context object. @@ -8778,61 +8809,42 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, uint32_t ring_number, int rc, idx; if (phba->sli_rev == LPFC_SLI_REV4) { - if (piocb->iocb_flag & LPFC_IO_FCP) { - if (!phba->cfg_fof || (!(piocb->iocb_flag & - LPFC_IO_OAS))) { - if (unlikely(!phba->sli4_hba.fcp_wq)) - return IOCB_ERROR; - idx = lpfc_sli4_scmd_to_wqidx_distr(phba); - piocb->fcp_wqidx = idx; - ring_number = MAX_SLI3_CONFIGURED_RINGS + idx; - } else { - if (unlikely(!phba->sli4_hba.oas_wq)) - return IOCB_ERROR; - idx = 0; - piocb->fcp_wqidx = 0; - ring_number = LPFC_FCP_OAS_RING; - } - pring = &phba->sli.ring[ring_number]; - spin_lock_irqsave(&pring->ring_lock, iflags); - rc = __lpfc_sli_issue_iocb(phba, ring_number, piocb, - flag); - spin_unlock_irqrestore(&pring->ring_lock, iflags); + ring_number = lpfc_sli_calc_ring(phba, ring_number, piocb); +
[PATCH 16/19] lpfc 10.4.8000.0: Fixed High priority issues from lpfc given by fortify source code scan
Fixed High priority issues from lpfc given by fortify source code scan. Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_bsg.c | 8 +--- drivers/scsi/lpfc/lpfc_els.c | 5 - drivers/scsi/lpfc/lpfc_init.c | 32 +++- drivers/scsi/lpfc/lpfc_nportdisc.c | 2 ++ drivers/scsi/lpfc/lpfc_sli.c | 26 +- drivers/scsi/lpfc/lpfc_sli4.h | 20 ++-- 6 files changed, 53 insertions(+), 40 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index d236448..a58bffb 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -2827,8 +2827,10 @@ diag_cmd_data_alloc(struct lpfc_hba *phba, size -= cnt; } - mlist->flag = i; - return mlist; + if (mlist) { + mlist->flag = i; + return mlist; + } out: diag_cmd_data_free(phba, mlist); return NULL; @@ -4592,7 +4594,7 @@ sli_cfg_ext_error: * being reset) and com-plete the job, otherwise issue the mailbox command and * let our completion handler finish the command. **/ -static uint32_t +static int lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job, struct lpfc_vport *vport) { diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 9d03e72..c7e5080 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1084,7 +1084,8 @@ stop_rr_fcf_flogi: * accessing it. */ prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); - + if (!prsp) + goto out; sp = prsp->virt + sizeof(uint32_t); /* FLOGI completes successfully */ @@ -7521,6 +7522,8 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); + if (!prsp) + goto out; sp = prsp->virt + sizeof(uint32_t); fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp); memcpy(&vport->fabric_portname, &sp->portName, diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 33a24fc0..0d92304 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -306,10 +306,10 @@ lpfc_dump_wakeup_param_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) dist = dist_char[prg->dist]; if ((prg->dist == 3) && (prg->num == 0)) - sprintf(phba->OptionROMVersion, "%d.%d%d", + snprintf(phba->OptionROMVersion, 32, "%d.%d%d", prg->ver, prg->rev, prg->lev); else - sprintf(phba->OptionROMVersion, "%d.%d%d%c%d", + snprintf(phba->OptionROMVersion, 32, "%d.%d%d%c%d", prg->ver, prg->rev, prg->lev, dist, prg->num); mempool_free(pmboxq, phba->mbox_mem_pool); @@ -3177,9 +3177,11 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba) for (i = 0; i < scsi_xri_cnt; i++) { list_remove_head(&scsi_sgl_list, psb, struct lpfc_scsi_buf, list); - pci_pool_free(phba->lpfc_scsi_dma_buf_pool, psb->data, - psb->dma_handle); - kfree(psb); + if (psb) { + pci_pool_free(phba->lpfc_scsi_dma_buf_pool, + psb->data, psb->dma_handle); + kfree(psb); + } } spin_lock_irq(&phba->scsi_buf_list_get_lock); phba->sli4_hba.scsi_xri_cnt -= scsi_xri_cnt; @@ -7424,7 +7426,8 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba) if (rc) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0523 Failed setup of fast-path EQ " - "(%d), rc = 0x%x\n", fcp_eqidx, rc); + "(%d), rc = 0x%x\n", fcp_eqidx, + (uint32_t)rc); goto out_destroy_hba_eq; } lpfc_printf_log(phba, KERN_INFO, LOG_INIT, @@ -7455,7 +7458,8 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba) if (rc) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0527 Failed setup of fast-path FCP " - "CQ (%d), rc = 0x%x\n", fcp_cqidx, rc); + "CQ (%d), rc = 0x%x\n", fcp_cqidx, + (uint32_t)rc); goto out_destroy_fcp_
[PATCH 18/19] lpfc 10.4.8000.0: Fix for handling unmapped ndlp in target reset handler
Fix for handling unmapped ndlp in target reset handler Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_scsi.c | 8 +++- drivers/scsi/lpfc/lpfc_sli.c | 8 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 0f6be85..b99399f 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -5339,7 +5339,13 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) if (status == FAILED) { lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, "0722 Target Reset rport failure: rdata x%p\n", rdata); - return FAILED; + spin_lock_irq(shost->host_lock); + pnode->nlp_flag &= ~NLP_NPR_ADISC; + pnode->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; + spin_unlock_irq(shost->host_lock); + lpfc_reset_flush_io_context(vport, tgt_id, lun_id, + LPFC_CTX_TGT); + return FAST_IO_FAIL; } scsi_event.event_type = FC_REG_SCSI_EVENT; diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index cea89c6..207a43d 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -10132,7 +10132,9 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd cmd) { struct lpfc_hba *phba = vport->phba; + struct lpfc_scsi_buf *lpfc_cmd; struct lpfc_iocbq *abtsiocbq; + struct lpfc_nodelist *ndlp; struct lpfc_iocbq *iocbq; IOCB_t *icmd; int sum, i, ret_val; @@ -10187,7 +10189,11 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, if (iocbq->iocb_flag & LPFC_IO_FOF) abtsiocbq->iocb_flag |= LPFC_IO_FOF; - if (lpfc_is_link_up(phba)) + lpfc_cmd = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq); + ndlp = lpfc_cmd->rdata->pnode; + + if (lpfc_is_link_up(phba) && + (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE)) abtsiocbq->iocb.ulpCommand = CMD_ABORT_XRI_CN; else abtsiocbq->iocb.ulpCommand = CMD_CLOSE_XRI_CN; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 17/19] lpfc 10.4.8000.0: Fixed Low priority issues from lpfc given by fortify source code scan
Fixed Low priority issues from lpfc given by fortify source code scan. Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_attr.c| 2 +- drivers/scsi/lpfc/lpfc_bsg.c | 5 - drivers/scsi/lpfc/lpfc_ct.c | 14 -- drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++-- drivers/scsi/lpfc/lpfc_els.c | 16 drivers/scsi/lpfc/lpfc_hbadisc.c | 10 +- drivers/scsi/lpfc/lpfc_init.c| 2 -- drivers/scsi/lpfc/lpfc_sli.c | 21 + 8 files changed, 25 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 6eed9e7..2f9b968 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -3385,7 +3385,7 @@ lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) return -EINVAL; - strcpy(bucket_data, buf); + strncpy(bucket_data, buf, LPFC_MAX_DATA_CTRL_LEN); str_ptr = &bucket_data[0]; /* Ignore this token - this is command token */ token = strsep(&str_ptr, "\t "); diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index a58bffb..a7bf359 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -656,7 +656,6 @@ lpfc_bsg_rport_els(struct fc_bsg_job *job) struct lpfc_nodelist *ndlp = rdata->pnode; uint32_t elscmd; uint32_t cmdsize; - uint32_t rspsize; struct lpfc_iocbq *cmdiocbq; uint16_t rpi = 0; struct bsg_job_data *dd_data; @@ -687,7 +686,6 @@ lpfc_bsg_rport_els(struct fc_bsg_job *job) elscmd = job->request->rqst_data.r_els.els_code; cmdsize = job->request_payload.payload_len; - rspsize = job->reply_payload.payload_len; if (!lpfc_nlp_get(ndlp)) { rc = -ENODEV; @@ -2251,7 +2249,6 @@ lpfc_sli4_bsg_diag_mode_end(struct fc_bsg_job *job) i = 0; while (phba->link_state != LPFC_LINK_DOWN) { if (i++ > timeout) { - rc = -ETIMEDOUT; lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC, "3140 Timeout waiting for link to " "diagnostic mode_end, timeout:%d ms\n", @@ -2291,7 +2288,6 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job) LPFC_MBOXQ_t *pmboxq; struct sli4_link_diag *link_diag_test_cmd; uint32_t req_len, alloc_len; - uint32_t timeout; struct lpfc_mbx_run_link_diag_test *run_link_diag_test; union lpfc_sli4_cfg_shdr *shdr; uint32_t shdr_status, shdr_add_status; @@ -2342,7 +2338,6 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job) link_diag_test_cmd = (struct sli4_link_diag *) job->request->rqst_data.h_vendor.vendor_cmd; - timeout = link_diag_test_cmd->timeout * 100; rc = lpfc_sli4_bsg_set_link_diag_state(phba, 1); diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index da61d8d..61a32cd 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -1439,7 +1439,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) /* #2 HBA attribute entry */ ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); ae->ad.bits.AttrType = be16_to_cpu(MANUFACTURER); - strcpy(ae->un.Manufacturer, "Emulex Corporation"); + strncpy(ae->un.Manufacturer, "Emulex Corporation", 64); len = strlen(ae->un.Manufacturer); len += (len & 3) ? (4 - (len & 3)) : 4; ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); @@ -1449,7 +1449,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) /* #3 HBA attribute entry */ ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); ae->ad.bits.AttrType = be16_to_cpu(SERIAL_NUMBER); - strcpy(ae->un.SerialNumber, phba->SerialNumber); + strncpy(ae->un.SerialNumber, phba->SerialNumber, 64); len = strlen(ae->un.SerialNumber); len += (len & 3) ? (4 - (len & 3)) : 4; ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); @@ -1459,7 +1459,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) /* #4 HBA attribute entry */ ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); ae->ad.bits.AttrType = be16_to_cpu(MODEL); - strcpy(ae->un.Model, phba->ModelName); + strncpy(ae->un.
[PATCH 15/19] lpfc 10.4.8000.0: Fixed crash from page fault caused by use after rport delete
Fixed crash from page fault caused by use after rport delete Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_hbadisc.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2d929a5..310507d 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -150,6 +150,17 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) /* If the WWPN of the rport and ndlp don't match, ignore it */ if (rport->port_name != wwn_to_u64(ndlp->nlp_portname.u.wwn)) { + lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE, + "6789 rport name %lx != node port name %lx", + (unsigned long)rport->port_name, + (unsigned long)wwn_to_u64( + ndlp->nlp_portname.u.wwn)); + put_node = rdata->pnode != NULL; + put_rport = ndlp->rport != NULL; + rdata->pnode = NULL; + ndlp->rport = NULL; + if (put_node) + lpfc_nlp_put(ndlp); put_device(&rport->dev); return; } @@ -285,6 +296,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) if (ndlp->nlp_sid != NLP_NO_SID) { warn_on = 1; /* flush the target */ + ndlp->nlp_add_flag &= ~NLP_IN_DEV_LOSS; lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring], ndlp->nlp_sid, 0, LPFC_CTX_TGT); } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 19/19] lpfc 10.4.8000.0: Update lpfc version to driver version 10.4.8000.0
Update lpfc version to driver version 10.4.8000.0 Signed-off-by: James Smart Signed-off-by: Dick Kennedy --- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 41675c1..89413ad 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h @@ -18,7 +18,7 @@ * included with this package. * ***/ -#define LPFC_DRIVER_VERSION "10.2.8001.0." +#define LPFC_DRIVER_VERSION "10.4.8000.0." #define LPFC_DRIVER_NAME "lpfc" /* Used for SLI 2/3 */ -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
> From: Alan Stern > > On Fri, 29 Aug 2014, Matthew Dharm wrote: > > Is there an 'easy' way to override the detected size of a storage > > device from userspace? If we had that, someone could write a helper > > application which looked for this particular fubar and try to Do The > > Right Thing(tm), or at least offer the user some options. > > You mean, force a Media Change event and override the capacity reported > by the hardware? I'm not aware of any API for doing that, although it > probably wouldn't be too hard to add one. > > How would the user know what value to put in for the capacity? Unless > the drive had been hooked up to a different computer and the user > manually noted the correct capacity and typed it in, it would have to > be guesswork. The value would most sanely be extracted from the partition table. (After verifying that the partition table looks correct.) That seems to be what Windows does, and it seems to work consistently enough for Windows to trust that method. Or at least, it could take the disk size to be the end of the last partition, which would at least make all the partitions accessible. As somebody else hinted at, the userspace program could check the USB device against a list of device types known to have this problem. It could even verify that the SCSI-reported size matches the size reported by the partition table (modulo two-to-the-whatever) (at least for GPT tables, I don't know if MBR tables report the disk size). Do we have any way of knowing what algorithm Windows uses in this situation? Dale -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
On Wed, 3 Sep 2014, Dale R. Worley wrote: > > From: Alan Stern > > > > On Fri, 29 Aug 2014, Matthew Dharm wrote: > > > Is there an 'easy' way to override the detected size of a storage > > > device from userspace? If we had that, someone could write a helper > > > application which looked for this particular fubar and try to Do The > > > Right Thing(tm), or at least offer the user some options. > > > > You mean, force a Media Change event and override the capacity reported > > by the hardware? I'm not aware of any API for doing that, although it > > probably wouldn't be too hard to add one. > > > > How would the user know what value to put in for the capacity? Unless > > the drive had been hooked up to a different computer and the user > > manually noted the correct capacity and typed it in, it would have to > > be guesswork. > > The value would most sanely be extracted from the partition table. > (After verifying that the partition table looks correct.) That seems > to be what Windows does, and it seems to work consistently enough for > Windows to trust that method. Or at least, it could take the disk > size to be the end of the last partition, which would at least make > all the partitions accessible. If there is a partition table. It might be worthwhile to try an ATA pass-through command as well. > As somebody else hinted at, the userspace program could check the USB > device against a list of device types known to have this problem. > > It could even verify that the SCSI-reported size matches the size > reported by the partition table (modulo two-to-the-whatever) (at least > for GPT tables, I don't know if MBR tables report the disk size). They don't. Just the start and end of each partition. > Do we have any way of knowing what algorithm Windows uses in this > situation? Ask Microsoft. I suspect you're not likely to get an answer, though. Anyway, I can try writing a patch to add this capability. We'll see if it can solve your problem. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RES: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
On Sat, 30 Aug 2014, Matthew Dharm wrote > I was thinking of something that could notice a USB device which is formatted > NTFS and has a partition table and filesystem that indicates a much bigger > capacity than what the drive reports. Under this circumstances, you could do > something like pop-up a dialog box saying "this drive is confused -- is it > 2TB or > 3TB?" > > Well, maybe that would say "Drive capacity is not consistent with partition > table. This can happen with certain USB drives designed for use with > Windows. Override drive capacity (emulating Windows)?" > > You could imagine increasing complex heuristics to try to detect this > scenario. > Even without an automated helper program to do it, if there was a sysfs > interface then when we got the periodic e-mails reporting this same type of > problem, we could offer a quick-and-clean solution. Hi Matt, I did small hack to skip is_pte_valid() on efi.c and now I have sdc1 partition listed on /proc/partition, but I hit other issue: ntfs-3g mount userspace tool that comes with Fedora now fails with "Failed to read last sector (7814037100): Invalid argument". I also tried to override disk capacity, but SD driver fails with "Invalid command failure" and "Illegal Request" (I'll investigate it later) Many places rely on disk capacity value, I think emulate Windows behavior for these HDD docks will not be an easy task []'s Alfredo -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
> From: Alan Stern > Anyway, I can try writing a patch to add this capability. We'll see if > it can solve your problem. Unfortunately, I think there is genuine value in such a hack. E.g., I've got two USB-to-SATA adapters. One works correctly. One does not. But at this point, I can't attach both of my high-capacity disks to the laptop at the same time, which makes it difficult to bulk-transfer files from one to the other. If, for the deficient adapter, the kernel assumed the disk size was the end of the last partition (or the backup GPT partition table, if that follows), then I could use it for everything other than repartitioning. And that would make life easier. Thanks for trying, Dale -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
On Wed, 2014-09-03 at 15:05 -0400, Alan Stern wrote: > On Wed, 3 Sep 2014, Dale R. Worley wrote: > > > > From: Alan Stern > > > > > > On Fri, 29 Aug 2014, Matthew Dharm wrote: > > > > Is there an 'easy' way to override the detected size of a storage > > > > device from userspace? If we had that, someone could write a helper > > > > application which looked for this particular fubar and try to Do The > > > > Right Thing(tm), or at least offer the user some options. > > > > > > You mean, force a Media Change event and override the capacity reported > > > by the hardware? I'm not aware of any API for doing that, although it > > > probably wouldn't be too hard to add one. > > > > > > How would the user know what value to put in for the capacity? Unless > > > the drive had been hooked up to a different computer and the user > > > manually noted the correct capacity and typed it in, it would have to > > > be guesswork. > > > > The value would most sanely be extracted from the partition table. > > (After verifying that the partition table looks correct.) That seems > > to be what Windows does, and it seems to work consistently enough for > > Windows to trust that method. Or at least, it could take the disk > > size to be the end of the last partition, which would at least make > > all the partitions accessible. > > If there is a partition table. It might be worthwhile to try an ATA > pass-through command as well. > > > As somebody else hinted at, the userspace program could check the USB > > device against a list of device types known to have this problem. > > > > It could even verify that the SCSI-reported size matches the size > > reported by the partition table (modulo two-to-the-whatever) (at least > > for GPT tables, I don't know if MBR tables report the disk size). > > They don't. Just the start and end of each partition. > > > Do we have any way of knowing what algorithm Windows uses in this > > situation? > > Ask Microsoft. I suspect you're not likely to get an answer, though. > > Anyway, I can try writing a patch to add this capability. We'll see if > it can solve your problem. Before we embark on elaborate hacks, why don't we just make the capacity writeable (by root) in sysfs from userspace (will require block change)? We can then encode all the nasty heuristics (including gpt reading) in userspace as a udev rule. James -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
On Wed, 3 Sep 2014, James Bottomley wrote: > Before we embark on elaborate hacks, why don't we just make the capacity > writeable (by root) in sysfs from userspace (will require block change)? > We can then encode all the nasty heuristics (including gpt reading) in > userspace as a udev rule. That's what I'm working on. Except that I don't know where to do it in the block layer, so for now I'm adding the attribute to sd.c. Where in the block layer would the right place be? We want this to apply only to entire devices, not to individual partitions. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)
On Wed, 2014-09-03 at 16:30 -0400, Alan Stern wrote: > On Wed, 3 Sep 2014, James Bottomley wrote: > > > Before we embark on elaborate hacks, why don't we just make the capacity > > writeable (by root) in sysfs from userspace (will require block change)? > > We can then encode all the nasty heuristics (including gpt reading) in > > userspace as a udev rule. > > That's what I'm working on. Except that I don't know where to do it in > the block layer, so for now I'm adding the attribute to sd.c. > > Where in the block layer would the right place be? We want this to > apply only to entire devices, not to individual partitions. The bottom layer for this is part0.nr_sects which is the size attribute you see in the block sysfs. However, it looks like we keep a separate value in sdkp, but we don't ever seem to use it (except to see if the capacity has changed). So this could be done in two ways: add a writeable capacity attribute in sd.c, as you were originally thinking (it would call set_capacity() on write and that would update the block layer) or make the size parameter writeable. This is how you would do the block layer one below, but there's no way to inform the lower layer (so it better not have any information cached that it makes use of). James --- diff --git a/block/genhd.c b/block/genhd.c index 791f419..a114636 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -980,7 +980,7 @@ static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL); -static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); +static DEVICE_ATTR(size, S_IRUGO|S_IWUSR, part_size_show, part_size_store); static DEVICE_ATTR(alignment_offset, S_IRUGO, disk_alignment_offset_show, NULL); static DEVICE_ATTR(discard_alignment, S_IRUGO, disk_discard_alignment_show, NULL); diff --git a/block/partition-generic.c b/block/partition-generic.c index 789cdea..d0cc418 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -87,6 +87,20 @@ ssize_t part_size_show(struct device *dev, return sprintf(buf, "%llu\n",(unsigned long long)part_nr_sects_read(p)); } +ssize_t part_size_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hd_struct *p = dev_to_part(dev); + u64 size; + + if (count > 0 && sscanf(buf, "%llu", &size) > 0) + part_nr_sects_write(p, size); + else + return -EINVAL; + + return count; +} + static ssize_t part_ro_show(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/include/linux/genhd.h b/include/linux/genhd.h index ec274e0..c9b3473 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -628,6 +628,9 @@ extern void blk_unregister_region(dev_t devt, unsigned long range); extern ssize_t part_size_show(struct device *dev, struct device_attribute *attr, char *buf); +extern ssize_t part_size_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count); extern ssize_t part_stat_show(struct device *dev, struct device_attribute *attr, char *buf); extern ssize_t part_inflight_show(struct device *dev, -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Off topic: Test suite for LLDs
Hello folks, I would like to know whether we have any standard test suite for validating a low level driver by executing all the interfaces the low level driver registers with SML? Thanks Sathya -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html