From fb0d82f49167a2519f8c52e91b9b278cec57bff4 Mon Sep 17 00:00:00 2001 From: Mark Knibbs Date: Thu, 9 Oct 2014 12:39:40 +0100 Subject: scsi: fix trivial typos in scsi_scan.c comment Signed-off-by: Mark Knibbs Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index ba3f1e8d0d57..619e68d015aa 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1214,9 +1214,9 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget, sparse_lun = 0; /* - * If less than SCSI_1_CSS, and no special lun scaning, stop + * If less than SCSI_1_CCS, and no special lun scanning, stop * scanning; this matches 2.4 behaviour, but could just be a bug - * (to continue scanning a SCSI_1_CSS device). + * (to continue scanning a SCSI_1_CCS device). * * This test is broken. We might not have any device on lun0 for * a sparselun device, and if that's the case then how would we -- cgit v1.2.3 From 605c6dbef7556604b20b9831ea790dfe988416d8 Mon Sep 17 00:00:00 2001 From: Mark Knibbs Date: Thu, 9 Oct 2014 12:39:48 +0100 Subject: scsi: fix off-by-one LUN check in scsi_scan_host_selected() The Scsi_Host structure max_lun field is the maximum allowed LUN plus 1. So a LUN value is invalid if >= max_lun. Signed-off-by: Mark Knibbs Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 619e68d015aa..b1aa1646012a 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1727,7 +1727,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) || ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) || - ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) + ((lun != SCAN_WILD_CARD) && (lun >= shost->max_lun))) return -EINVAL; mutex_lock(&shost->scan_mutex); -- cgit v1.2.3 From 037e6d8654469051e6a75d64e6c2d6727130fe4c Mon Sep 17 00:00:00 2001 From: Mark Rustad Date: Tue, 14 Oct 2014 06:38:53 -0700 Subject: scsi: resolve some missing-field-initializers warnings Resolve some missing-field-initializers warnings by using designated initialization. [hch: W=2 with modern gcc warns about this. Pretty pointless to me, but I'd prefer to keep us warning free] Signed-off-by: Mark Rustad Signed-off-by: Jeff Kirsher Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 50a6e1ac8d9c..389bc6fd19ae 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -47,7 +47,7 @@ struct scsi_host_sg_pool { mempool_t *pool; }; -#define SP(x) { x, "sgpool-" __stringify(x) } +#define SP(x) { .size = x, "sgpool-" __stringify(x) } #if (SCSI_MAX_SG_SEGMENTS < 32) #error SCSI_MAX_SG_SEGMENTS is too small (must be 32 or greater) #endif -- cgit v1.2.3 From 678e27573237a0b065defdf99e5070c9b0c403c3 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 1 Oct 2014 20:31:01 +0200 Subject: scsi: PC partition tables are little endian As sparse correctly pointed out, scsi_partsize should use get_unaligned_le32 to read PC partition tables from disk, as they are little endian. The result of this bug is that we returned incorrect geometries on big endian systems when using the scsicam variant. Which probably doesn't matter as only old x86 systems every cared about the geometry. Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/scsicam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c index 92d24d6dcb39..910f4a7a3924 100644 --- a/drivers/scsi/scsicam.c +++ b/drivers/scsi/scsicam.c @@ -163,8 +163,8 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity, end_head * end_sector + end_sector; /* This is the actual _sector_ number at the end */ - logical_end = get_unaligned(&largest->start_sect) - + get_unaligned(&largest->nr_sects); + logical_end = get_unaligned_le32(&largest->start_sect) + + get_unaligned_le32(&largest->nr_sects); /* This is for >1023 cylinders */ ext_cyl = (logical_end - (end_head * end_sector + end_sector)) -- cgit v1.2.3 From 26cf591e6dfc0d07495b7bcf20a557b316811f00 Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Sat, 18 Oct 2014 22:11:21 +0200 Subject: scsi: add SG_SCSI_RESET_NO_ESCALATE flag to SG_SCSI_RESET ioctl Further to a January 2013 thread titled: "[PATCH] SG_SCSI_RESET ioctl should only perform requested operation" by Jeremy Linton a patch (v3) is presented that expands the existing ioctl to include "no_escalate" versions to the existing resets. This requires no changes to SCSI low level drivers (LLDs); it adds several more finely tuned reset options to the user space. For example: /* This call remains the same, with the same escalating semantics * if the device (LU) reset fail. That is: on failure to try a * target reset and if that fails, try a bus reset, and if that fails * try a host (i.e. LLD) reset. */ val = SG_SCSI_RESET_DEVICE; res = ioctl(, SG_SCSI_RESET, &val); /* What follows is a new option introduced by this patch series. Only * a device reset is attempted. If that fails then an appropriate * error code is provided. N.B. There is no reset escalation. */ val = SG_SCSI_RESET_DEVICE | SG_SCSI_RESET_NO_ESCALATE; res = ioctl(, SG_SCSI_RESET, &val); Signed-off-by: Douglas Gilbert Reviewed-by: Jeremy Linton Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_error.c | 10 ++++++++++ drivers/scsi/scsi_ioctl.c | 20 +++++++++++++------- drivers/scsi/sg.c | 17 +++++++++++------ include/scsi/scsi_eh.h | 5 +++++ include/scsi/sg.h | 5 ++++- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index bc5ff6ff9c79..0ed666112b4f 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2366,8 +2366,18 @@ scsi_reset_provider(struct scsi_device *dev, int flag) break; /* FALLTHROUGH */ case SCSI_TRY_RESET_HOST: + case SCSI_TRY_RESET_HOST | SCSI_TRY_RESET_NO_ESCALATE: rtn = scsi_try_host_reset(scmd); break; + case SCSI_TRY_RESET_DEVICE | SCSI_TRY_RESET_NO_ESCALATE: + rtn = scsi_try_bus_device_reset(scmd); + break; + case SCSI_TRY_RESET_TARGET | SCSI_TRY_RESET_NO_ESCALATE: + rtn = scsi_try_target_reset(scmd); + break; + case SCSI_TRY_RESET_BUS | SCSI_TRY_RESET_NO_ESCALATE: + rtn = scsi_try_bus_reset(scmd); + break; default: rtn = FAILED; } diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 1aaaf43c6803..12fe676d1343 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -285,13 +285,14 @@ EXPORT_SYMBOL(scsi_ioctl); * scsi_nonblockable_ioctl() - Handle SG_SCSI_RESET * @sdev: scsi device receiving ioctl * @cmd: Must be SC_SCSI_RESET - * @arg: pointer to int containing SG_SCSI_RESET_{DEVICE,BUS,HOST} + * @arg: pointer to int containing SG_SCSI_RESET_{DEVICE,TARGET,BUS,HOST} + * possibly OR-ed with SG_SCSI_RESET_NO_ESCALATE * @ndelay: file mode O_NDELAY flag */ int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, void __user *arg, int ndelay) { - int val, result; + int val, val2, result; /* The first set of iocts may be executed even if we're doing * error processing, as long as the device was opened @@ -307,27 +308,32 @@ int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, result = get_user(val, (int __user *)arg); if (result) return result; + if (val & SG_SCSI_RESET_NO_ESCALATE) { + val &= ~SG_SCSI_RESET_NO_ESCALATE; + val2 = SCSI_TRY_RESET_NO_ESCALATE; + } else + val2 = 0; if (val == SG_SCSI_RESET_NOTHING) return 0; switch (val) { case SG_SCSI_RESET_DEVICE: - val = SCSI_TRY_RESET_DEVICE; + val2 |= SCSI_TRY_RESET_DEVICE; break; case SG_SCSI_RESET_TARGET: - val = SCSI_TRY_RESET_TARGET; + val2 |= SCSI_TRY_RESET_TARGET; break; case SG_SCSI_RESET_BUS: - val = SCSI_TRY_RESET_BUS; + val2 |= SCSI_TRY_RESET_BUS; break; case SG_SCSI_RESET_HOST: - val = SCSI_TRY_RESET_HOST; + val2 |= SCSI_TRY_RESET_HOST; break; default: return -EINVAL; } if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) return -EACCES; - return (scsi_reset_provider(sdev, val) == + return (scsi_reset_provider(sdev, val2) == SUCCESS) ? 0 : -EIO; } return -ENODEV; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 60354449d9ed..fe44c14f551e 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -847,7 +847,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) { void __user *p = (void __user *)arg; int __user *ip = p; - int result, val, read_only; + int result, val, val2, read_only; Sg_device *sdp; Sg_fd *sfp; Sg_request *srp; @@ -1082,27 +1082,32 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) result = get_user(val, ip); if (result) return result; + if (val & SG_SCSI_RESET_NO_ESCALATE) { + val &= ~SG_SCSI_RESET_NO_ESCALATE; + val2 = SCSI_TRY_RESET_NO_ESCALATE; + } else + val2 = 0; if (SG_SCSI_RESET_NOTHING == val) return 0; switch (val) { case SG_SCSI_RESET_DEVICE: - val = SCSI_TRY_RESET_DEVICE; + val2 |= SCSI_TRY_RESET_DEVICE; break; case SG_SCSI_RESET_TARGET: - val = SCSI_TRY_RESET_TARGET; + val2 |= SCSI_TRY_RESET_TARGET; break; case SG_SCSI_RESET_BUS: - val = SCSI_TRY_RESET_BUS; + val2 |= SCSI_TRY_RESET_BUS; break; case SG_SCSI_RESET_HOST: - val = SCSI_TRY_RESET_HOST; + val2 |= SCSI_TRY_RESET_HOST; break; default: return -EINVAL; } if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) return -EACCES; - return (scsi_reset_provider(sdp->device, val) == + return (scsi_reset_provider(sdp->device, val2) == SUCCESS) ? 0 : -EIO; case SCSI_IOCTL_SEND_COMMAND: if (atomic_read(&sdp->detaching)) diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 06a8790893ef..49af14ad5288 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -62,11 +62,16 @@ extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); /* * Reset request from external source + * Note: if SCSI_TRY_RESET_DEVICE fails then it will escalate to + * SCSI_TRY_RESET_TARGET which if it fails will escalate to + * SCSI_TRY_RESET_BUS which if it fails will escalate to SCSI_TRY_RESET_HOST. + * To prevent escalation OR with SCSI_TRY_RESET_NO_ESCALATE. */ #define SCSI_TRY_RESET_DEVICE 1 #define SCSI_TRY_RESET_BUS 2 #define SCSI_TRY_RESET_HOST 3 #define SCSI_TRY_RESET_TARGET 4 +#define SCSI_TRY_RESET_NO_ESCALATE 0x100 /* OR-ed to prior defines */ extern int scsi_reset_provider(struct scsi_device *, int); diff --git a/include/scsi/sg.h b/include/scsi/sg.h index 750e5db7c6bf..3afec7032448 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h @@ -164,12 +164,15 @@ typedef struct sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ /* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */ #define SG_SCSI_RESET 0x2284 -/* Associated values that can be given to SG_SCSI_RESET follow */ +/* Associated values that can be given to SG_SCSI_RESET follow. + * SG_SCSI_RESET_NO_ESCALATE may be OR-ed to the _DEVICE, _TARGET, _BUS + * or _HOST reset value so only that action is attempted. */ #define SG_SCSI_RESET_NOTHING 0 #define SG_SCSI_RESET_DEVICE 1 #define SG_SCSI_RESET_BUS 2 #define SG_SCSI_RESET_HOST 3 #define SG_SCSI_RESET_TARGET 4 +#define SG_SCSI_RESET_NO_ESCALATE 0x100 /* synchronous SCSI command ioctl, (only in version 3 interface) */ #define SG_IO 0x2285 /* similar effect as write() followed by read() */ -- cgit v1.2.3 From 2bec708a88ce053ffcb0dd8e373d1e46c6dc38a4 Mon Sep 17 00:00:00 2001 From: Laurence Oberman Date: Sun, 19 Oct 2014 09:44:25 -0400 Subject: st: add a debug_flag module parameter request This patch adds a debug_flag parameter that can be set on module load, and allows the DEBUG facility without a module recompile. Note that now DEBUG 1 is the default with this patch. Usage: modprobe st debug_flag=1 Signed-off-by: Laurence Oberman Acked-by: Kai M??kisara Signed-off-by: Christoph Hellwig --- Documentation/scsi/st.txt | 8 +++++--- drivers/scsi/st.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Documentation/scsi/st.txt b/Documentation/scsi/st.txt index f346abbdd6ff..0d5bdb153d3b 100644 --- a/Documentation/scsi/st.txt +++ b/Documentation/scsi/st.txt @@ -506,9 +506,11 @@ user does not request data that far.) DEBUGGING HINTS -To enable debugging messages, edit st.c and #define DEBUG 1. As seen -above, debugging can be switched off with an ioctl if debugging is -compiled into the driver. The debugging output is not voluminous. +Debugging code is now compiled in by default but debugging is turned off +with the kernel module parameter debug_flag defaulting to 0. Debugging +can still be switched on and off with an ioctl. To enable debug at +module load time add debug_flag=1 to the module load options, the +debugging output is not voluminous. If the tape seems to hang, I would be very interested to hear where the driver is waiting. With the command 'ps -l' you can see the state diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 4daa372ed381..8d5f8b4f9a22 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -56,7 +56,8 @@ static const char *verstr = "20101219"; /* The driver prints some debugging information on the console if DEBUG is defined and non-zero. */ -#define DEBUG 0 +#define DEBUG 1 +#define NO_DEBUG 0 #define ST_DEB_MSG KERN_NOTICE #if DEBUG @@ -80,6 +81,7 @@ static int max_sg_segs; static int try_direct_io = TRY_DIRECT_IO; static int try_rdio = 1; static int try_wdio = 1; +static int debug_flag; static struct class st_sysfs_class; static const struct attribute_group *st_dev_groups[]; @@ -100,6 +102,9 @@ module_param_named(max_sg_segs, max_sg_segs, int, 0); MODULE_PARM_DESC(max_sg_segs, "Maximum number of scatter/gather segments to use (256)"); module_param_named(try_direct_io, try_direct_io, int, 0); MODULE_PARM_DESC(try_direct_io, "Try direct I/O between user buffer and tape drive (1)"); +module_param_named(debug_flag, debug_flag, int, 0); +MODULE_PARM_DESC(debug_flag, "Enable DEBUG, same as setting debugging=1"); + /* Extra parameters for testing */ module_param_named(try_rdio, try_rdio, int, 0); @@ -124,6 +129,9 @@ static struct st_dev_parm { }, { "try_direct_io", &try_direct_io + }, + { + "debug_flag", &debug_flag } }; #endif @@ -4309,6 +4317,12 @@ static int __init init_st(void) printk(KERN_INFO "st: Version %s, fixed bufsize %d, s/g segs %d\n", verstr, st_fixed_buffer_size, st_max_sg_segs); + debugging = (debug_flag > 0) ? debug_flag : NO_DEBUG; + if (debugging) { + printk(KERN_INFO "st: Debugging enabled debug_flag = %d\n", + debugging); + } + err = class_register(&st_sysfs_class); if (err) { pr_err("Unable register sysfs class for SCSI tapes\n"); -- cgit v1.2.3 From d2fd76e6f60ce438e98512236138a3527ad6a736 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Sat, 4 Oct 2014 13:35:15 +0000 Subject: enclosure: handle non-unique element descriptors Some SES devices give non-unique Element Descriptors as part of the Element Descriptor diag page. Since we use these for creating sysfs entries, they need to be unique. The specification doesn't require these to be unique. Eg: $ sg_ses -p 7 /dev/sg0 FTS CORP TXS6_SAS20BPX12 0500 enclosure services device Element descriptor In diagnostic page: generation code: 0x0 element descriptor by type list Element type: Array device, subenclosure id: 0 Overall descriptor: ArrayDevicesInSubEnclsr0 Element 1 descriptor: ArrayDevice00 Element 2 descriptor: ArrayDevice01 Element 3 descriptor: ArrayDevice02 Element 4 descriptor: ArrayDevice03 Element 5 descriptor: ArrayDevice03 Element 6 descriptor: ArrayDevice03 Element 7 descriptor: ArrayDevice03 Element 8 descriptor: ArrayDevice03 Element 9 descriptor: ArrayDevice03 Element 10 descriptor: ArrayDevice03 Element 11 descriptor: ArrayDevice03 Element 12 descriptor: ArrayDevice03 Based on http://thread.gmane.org/gmane.linux.scsi/69289. This version implements James' ideas about the naming convention Signed-off-by: Markus Stockhausen Acked-by: James Bottomley Signed-off-by: Christoph Hellwig --- drivers/misc/enclosure.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 2cf2bbc0b927..180a5442fd4b 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -187,6 +187,7 @@ void enclosure_unregister(struct enclosure_device *edev) EXPORT_SYMBOL_GPL(enclosure_unregister); #define ENCLOSURE_NAME_SIZE 64 +#define COMPONENT_NAME_SIZE 64 static void enclosure_link_name(struct enclosure_component *cdev, char *name) { @@ -246,6 +247,29 @@ static void enclosure_component_release(struct device *dev) put_device(dev->parent); } +static struct enclosure_component * +enclosure_component_find_by_name(struct enclosure_device *edev, + const char *name) +{ + int i; + const char *cname; + struct enclosure_component *ecomp; + + if (!edev || !name || !name[0]) + return NULL; + + for (i = 0; i < edev->components; i++) { + ecomp = &edev->component[i]; + cname = dev_name(&ecomp->cdev); + if (ecomp->number != -1 && + cname && cname[0] && + !strcmp(cname, name)) + return ecomp; + } + + return NULL; +} + static const struct attribute_group *enclosure_component_groups[]; /** @@ -269,7 +293,8 @@ enclosure_component_register(struct enclosure_device *edev, { struct enclosure_component *ecomp; struct device *cdev; - int err; + int err, i; + char newname[COMPONENT_NAME_SIZE]; if (number >= edev->components) return ERR_PTR(-EINVAL); @@ -283,9 +308,20 @@ enclosure_component_register(struct enclosure_device *edev, ecomp->number = number; cdev = &ecomp->cdev; cdev->parent = get_device(&edev->edev); - if (name && name[0]) - dev_set_name(cdev, "%s", name); - else + + if (name && name[0]) { + /* Some hardware (e.g. enclosure in RX300 S6) has components + * with non unique names. Registering duplicates in sysfs + * will lead to warnings during bootup. So make the names + * unique by appending consecutive numbers -1, -2, ... */ + i = 1; + snprintf(newname, COMPONENT_NAME_SIZE, + "%s", name); + while (enclosure_component_find_by_name(edev, newname)) + snprintf(newname, COMPONENT_NAME_SIZE, + "%s-%i", name, i++); + dev_set_name(cdev, "%s", newname); + } else dev_set_name(cdev, "%u", number); cdev->release = enclosure_component_release; -- cgit v1.2.3 From 639ae4d0337ce5bc6f5f6921ecb144841b617c26 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:41 +0200 Subject: scsi: remove scsi_cmd_print_sense_hdr() Unused. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- 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 d35a5d6c8d7c..2f447075adbb 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 e89844cc2cd3..5a43a4cd96c6 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, -- cgit v1.2.3 From ad3819c09b55f9edb145f1d367678403666d857a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:42 +0200 Subject: sd: remove scsi_print_sense() in sd_done() sd_done() was calling scsi_print_sense() for a sense code of 'NO_SENSE'. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index cfba74cd8e8b..52b40b1e8c45 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1743,7 +1743,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; -- cgit v1.2.3 From f75ae8ed0853e62dff70f4d0229f8d57228c84bd Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:43 +0200 Subject: 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 Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/aha152x.c | 994 +++++++++++-------------------------------------- 1 file changed, 224 insertions(+), 770 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index e77b72f78006..2b960b326daf 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -230,7 +230,7 @@ * * ************************************************************************** - + see Documentation/scsi/aha152x.txt for configuration details **************************************************************************/ @@ -279,45 +279,11 @@ static LIST_HEAD(aha152x_host_list); #error define AUTOCONF or SETUP0 #endif -#if defined(AHA152X_DEBUG) -#define DEBUG_DEFAULT debug_eh - -#define DPRINTK(when,msgs...) \ - do { if(HOSTDATA(shpnt)->debug & (when)) printk(msgs); } while(0) - -#define DO_LOCK(flags) \ - do { \ - if(spin_is_locked(&QLOCK)) { \ - DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \ - } \ - DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \ - spin_lock_irqsave(&QLOCK,flags); \ - DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \ - QLOCKER=__func__; \ - QLOCKERL=__LINE__; \ - } while(0) - -#define DO_UNLOCK(flags) \ - do { \ - DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \ - spin_unlock_irqrestore(&QLOCK,flags); \ - DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \ - QLOCKER="(not locked)"; \ - QLOCKERL=0; \ - } while(0) - -#else -#define DPRINTK(when,msgs...) #define DO_LOCK(flags) spin_lock_irqsave(&QLOCK,flags) #define DO_UNLOCK(flags) spin_unlock_irqrestore(&QLOCK,flags) -#endif #define LEAD "(scsi%d:%d:%d) " -#define WARN_LEAD KERN_WARNING LEAD #define INFO_LEAD KERN_INFO LEAD -#define NOTE_LEAD KERN_NOTICE LEAD -#define ERR_LEAD KERN_ERR LEAD -#define DEBUG_LEAD KERN_DEBUG LEAD #define CMDINFO(cmd) \ (cmd) ? ((cmd)->device->host->host_no) : -1, \ (cmd) ? ((cmd)->device->id & 0x0f) : -1, \ @@ -345,10 +311,10 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc) enum { not_issued = 0x0001, /* command not yet issued */ - selecting = 0x0002, /* target is beeing selected */ + selecting = 0x0002, /* target is being selected */ identified = 0x0004, /* IDENTIFY was sent */ disconnected = 0x0008, /* target disconnected */ - completed = 0x0010, /* target sent COMMAND COMPLETE */ + completed = 0x0010, /* target sent COMMAND COMPLETE */ aborted = 0x0020, /* ABORT was sent */ resetted = 0x0040, /* BUS DEVICE RESET was sent */ spiordy = 0x0080, /* waiting for SPIORDY to raise */ @@ -396,7 +362,6 @@ static int exttrans[] = {0, 0}; module_param_array(exttrans, int, NULL, 0); MODULE_PARM_DESC(exttrans,"use extended translation"); -#if !defined(AHA152X_DEBUG) static int aha152x[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0}; module_param_array(aha152x, int, NULL, 0); MODULE_PARM_DESC(aha152x, "parameters for first controller"); @@ -404,19 +369,6 @@ MODULE_PARM_DESC(aha152x, "parameters for first controller"); static int aha152x1[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0}; module_param_array(aha152x1, int, NULL, 0); MODULE_PARM_DESC(aha152x1, "parameters for second controller"); -#else -static int debug[] = {DEBUG_DEFAULT, DEBUG_DEFAULT}; -module_param_array(debug, int, NULL, 0); -MODULE_PARM_DESC(debug, "flags for driver debugging"); - -static int aha152x[] = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT}; -module_param_array(aha152x, int, NULL, 0); -MODULE_PARM_DESC(aha152x, "parameters for first controller"); - -static int aha152x1[] = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT}; -module_param_array(aha152x1, int, NULL, 0); -MODULE_PARM_DESC(aha152x1, "parameters for second controller"); -#endif /* !defined(AHA152X_DEBUG) */ #endif /* MODULE */ #ifdef __ISAPNP__ @@ -446,7 +398,7 @@ static struct scsi_host_template aha152x_driver_template; /* * internal states of the host * - */ + */ enum aha152x_state { idle=0, unknown, @@ -485,24 +437,16 @@ struct aha152x_hostdata { spinlock_t lock; /* host lock */ -#if defined(AHA152X_DEBUG) - const char *locker; - /* which function has the lock */ - int lockerl; /* where did it get it */ - - int debug; /* current debugging setting */ -#endif - #if defined(AHA152X_STAT) - int total_commands; + int total_commands; int disconnections; int busfree_without_any_action; int busfree_without_old_command; int busfree_without_new_command; int busfree_without_done_command; int busfree_with_check_condition; - int count[maxstate]; - int count_trans[maxstate]; + int count[maxstate]; + int count_trans[maxstate]; unsigned long time[maxstate]; #endif @@ -514,7 +458,7 @@ struct aha152x_hostdata { int delay; /* reset out delay */ int ext_trans; /* extended translation enabled */ - int swint; /* software-interrupt was fired during detect() */ + int swint; /* software-interrupt was fired during detect() */ int service; /* bh needs to be run */ int in_intr; /* bh is running */ @@ -543,7 +487,7 @@ struct aha152x_hostdata { unsigned char msgi[256]; /* received message bytes */ - int msgo_i, msgo_len; + int msgo_i, msgo_len; /* number of sent bytes and length of current messages */ unsigned char msgo[256]; /* pending messages */ @@ -689,7 +633,6 @@ static void aha152x_error(struct Scsi_Host *shpnt, char *msg); static void done(struct Scsi_Host *shpnt, int error); /* diagnostics */ -static void disp_ports(struct Scsi_Host *shpnt); static void show_command(Scsi_Cmnd * ptr); static void show_queues(struct Scsi_Host *shpnt); static void disp_enintr(struct Scsi_Host *shpnt); @@ -812,10 +755,6 @@ struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *setup) DELAY = setup->delay; EXT_TRANS = setup->ext_trans; -#if defined(AHA152X_DEBUG) - HOSTDATA(shpnt)->debug = setup->debug; -#endif - SETPORT(SCSIID, setup->scsiid << 4); shpnt->this_id = setup->scsiid; @@ -941,31 +880,24 @@ void aha152x_release(struct Scsi_Host *shpnt) * setup controller to generate interrupts depending * on current state (lock has to be acquired) * - */ + */ static int setup_expected_interrupts(struct Scsi_Host *shpnt) { if(CURRENT_SC) { CURRENT_SC->SCp.phase |= 1 << 16; - + if(CURRENT_SC->SCp.phase & selecting) { - DPRINTK(debug_intr, DEBUG_LEAD "expecting: (seldo) (seltimo) (seldi)\n", CMDINFO(CURRENT_SC)); SETPORT(SSTAT1, SELTO); SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0)); SETPORT(SIMODE1, ENSELTIMO); } else { - DPRINTK(debug_intr, DEBUG_LEAD "expecting: (phase change) (busfree) %s\n", CMDINFO(CURRENT_SC), CURRENT_SC->SCp.phase & spiordy ? "(spiordy)" : ""); SETPORT(SIMODE0, (CURRENT_SC->SCp.phase & spiordy) ? ENSPIORDY : 0); - SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); + SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); } } else if(STATE==seldi) { - DPRINTK(debug_intr, DEBUG_LEAD "expecting: (phase change) (identify)\n", CMDINFO(CURRENT_SC)); SETPORT(SIMODE0, 0); - SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); + SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); } else { - DPRINTK(debug_intr, DEBUG_LEAD "expecting: %s %s\n", - CMDINFO(CURRENT_SC), - DISCONNECTED_SC ? "(reselection)" : "", - ISSUE_SC ? "(busfree)" : ""); SETPORT(SIMODE0, DISCONNECTED_SC ? ENSELDI : 0); SETPORT(SIMODE1, ENSCSIRST | ( (ISSUE_SC||DONE_SC) ? ENBUSFREE : 0)); } @@ -977,7 +909,7 @@ static int setup_expected_interrupts(struct Scsi_Host *shpnt) } -/* +/* * Queue a command and setup interrupts for a free bus. */ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, @@ -986,15 +918,6 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, struct Scsi_Host *shpnt = SCpnt->device->host; unsigned long flags; -#if defined(AHA152X_DEBUG) - if (HOSTDATA(shpnt)->debug & debug_queue) { - printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=", - CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len, - scsi_sg_count(SCpnt), scsi_bufflen(SCpnt)); - __scsi_print_command(SCpnt->cmnd); - } -#endif - SCpnt->scsi_done = done; SCpnt->SCp.phase = not_issued | phase; SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ @@ -1004,13 +927,13 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, if(SCpnt->SCp.phase & (resetting|check_condition)) { if (!SCpnt->host_scribble || SCSEM(SCpnt) || SCNEXT(SCpnt)) { - printk(ERR_LEAD "cannot reuse command\n", CMDINFO(SCpnt)); + scmd_printk(KERN_ERR, SCpnt, "cannot reuse command\n"); return FAILED; } } else { SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC); if(!SCpnt->host_scribble) { - printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt)); + scmd_printk(KERN_ERR, SCpnt, "allocation failed\n"); return FAILED; } } @@ -1066,15 +989,6 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, */ static int aha152x_queue_lck(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { -#if 0 - if(*SCpnt->cmnd == REQUEST_SENSE) { - SCpnt->result = 0; - done(SCpnt); - - return 0; - } -#endif - return aha152x_internal_queue(SCpnt, NULL, 0, done); } @@ -1082,15 +996,10 @@ static DEF_SCSI_QCMD(aha152x_queue) /* - * * */ static void reset_done(Scsi_Cmnd *SCpnt) { -#if 0 - struct Scsi_Host *shpnt = SCpnt->host; - DPRINTK(debug_eh, INFO_LEAD "reset_done called\n", CMDINFO(SCpnt)); -#endif if(SCSEM(SCpnt)) { complete(SCSEM(SCpnt)); } else { @@ -1108,20 +1017,11 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt) Scsi_Cmnd *ptr; unsigned long flags; -#if defined(AHA152X_DEBUG) - if(HOSTDATA(shpnt)->debug & debug_eh) { - printk(DEBUG_LEAD "abort(%p)", CMDINFO(SCpnt), SCpnt); - show_queues(shpnt); - } -#endif - DO_LOCK(flags); ptr=remove_SC(&ISSUE_SC, SCpnt); if(ptr) { - DPRINTK(debug_eh, DEBUG_LEAD "not yet issued - SUCCESS\n", CMDINFO(SCpnt)); - HOSTDATA(shpnt)->commands--; if (!HOSTDATA(shpnt)->commands) SETPORT(PORTA, 0); @@ -1131,7 +1031,7 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt) SCpnt->host_scribble=NULL; return SUCCESS; - } + } DO_UNLOCK(flags); @@ -1142,7 +1042,8 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt) * */ - printk(ERR_LEAD "cannot abort running or disconnected command\n", CMDINFO(SCpnt)); + scmd_printk(KERN_ERR, SCpnt, + "cannot abort running or disconnected command\n"); return FAILED; } @@ -1160,15 +1061,8 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt) unsigned long flags; unsigned long timeleft; -#if defined(AHA152X_DEBUG) - if(HOSTDATA(shpnt)->debug & debug_eh) { - printk(INFO_LEAD "aha152x_device_reset(%p)", CMDINFO(SCpnt), SCpnt); - show_queues(shpnt); - } -#endif - if(CURRENT_SC==SCpnt) { - printk(ERR_LEAD "cannot reset current device\n", CMDINFO(SCpnt)); + scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n"); return FAILED; } @@ -1208,7 +1102,7 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt) } else if(disconnected) { append_SC(&DISCONNECTED_SC, SCpnt); } - + ret = FAILED; } @@ -1227,12 +1121,12 @@ static void free_hard_reset_SCs(struct Scsi_Host *shpnt, Scsi_Cmnd **SCs) if(SCDATA(ptr)) { next = SCNEXT(ptr); } else { - printk(DEBUG_LEAD "queue corrupted at %p\n", CMDINFO(ptr), ptr); + scmd_printk(KERN_DEBUG, ptr, + "queue corrupted at %p\n", ptr); next = NULL; } if (!ptr->device->soft_reset) { - DPRINTK(debug_eh, DEBUG_LEAD "disconnected command %p removed\n", CMDINFO(ptr), ptr); remove_SC(SCs, ptr); HOSTDATA(shpnt)->commands--; kfree(ptr->host_scribble); @@ -1253,25 +1147,14 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt) DO_LOCK(flags); -#if defined(AHA152X_DEBUG) - if(HOSTDATA(shpnt)->debug & debug_eh) { - printk(KERN_DEBUG "scsi%d: bus reset", shpnt->host_no); - show_queues(shpnt); - } -#endif - free_hard_reset_SCs(shpnt, &ISSUE_SC); free_hard_reset_SCs(shpnt, &DISCONNECTED_SC); - DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting bus\n", shpnt->host_no); - SETPORT(SCSISEQ, SCSIRSTO); mdelay(256); SETPORT(SCSISEQ, 0); mdelay(DELAY); - DPRINTK(debug_eh, KERN_DEBUG "scsi%d: bus resetted\n", shpnt->host_no); - setup_expected_interrupts(shpnt); if(HOSTDATA(shpnt)->commands==0) SETPORT(PORTA, 0); @@ -1333,11 +1216,7 @@ static void reset_ports(struct Scsi_Host *shpnt) */ int aha152x_host_reset_host(struct Scsi_Host *shpnt) { - DPRINTK(debug_eh, KERN_DEBUG "scsi%d: host reset\n", shpnt->host_no); - aha152x_bus_reset_host(shpnt); - - DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting ports\n", shpnt->host_no); reset_ports(shpnt); return SUCCESS; @@ -1345,7 +1224,7 @@ int aha152x_host_reset_host(struct Scsi_Host *shpnt) /* * Reset the host (bus and controller) - * + * */ static int aha152x_host_reset(Scsi_Cmnd *SCpnt) { @@ -1411,7 +1290,9 @@ static void done(struct Scsi_Host *shpnt, int error) { if (CURRENT_SC) { if(DONE_SC) - printk(ERR_LEAD "there's already a completed command %p - will cause abort\n", CMDINFO(CURRENT_SC), DONE_SC); + scmd_printk(KERN_ERR, CURRENT_SC, + "there's already a completed command %p " + "- will cause abort\n", DONE_SC); DONE_SC = CURRENT_SC; CURRENT_SC = NULL; @@ -1466,7 +1347,7 @@ static irqreturn_t intr(int irqno, void *dev_id) return IRQ_NONE; if( TESTLO(DMASTAT, INTSTAT) ) - return IRQ_NONE; + return IRQ_NONE; /* no more interrupts from the controller, while we're busy. INTEN is restored by the BH handler */ @@ -1501,7 +1382,7 @@ static void busfree_run(struct Scsi_Host *shpnt) SETPORT(SXFRCTL0, CH1); SETPORT(SSTAT1, CLRBUSFREE); - + if(CURRENT_SC) { #if defined(AHA152X_STAT) action++; @@ -1513,19 +1394,13 @@ static void busfree_run(struct Scsi_Host *shpnt) done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16)); } else if(CURRENT_SC->SCp.phase & aborted) { - DPRINTK(debug_eh, DEBUG_LEAD "ABORT sent\n", CMDINFO(CURRENT_SC)); done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_ABORT << 16)); } else if(CURRENT_SC->SCp.phase & resetted) { - DPRINTK(debug_eh, DEBUG_LEAD "BUS DEVICE RESET sent\n", CMDINFO(CURRENT_SC)); done(shpnt, (CURRENT_SC->SCp.Status & 0xff) | ((CURRENT_SC->SCp.Message & 0xff) << 8) | (DID_RESET << 16)); } else if(CURRENT_SC->SCp.phase & disconnected) { /* target sent DISCONNECT */ - DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", - CMDINFO(CURRENT_SC), - scsi_get_resid(CURRENT_SC), - scsi_bufflen(CURRENT_SC)); #if defined(AHA152X_STAT) HOSTDATA(shpnt)->disconnections++; #endif @@ -1553,13 +1428,6 @@ static void busfree_run(struct Scsi_Host *shpnt) struct scsi_cmnd *cmd = HOSTDATA(shpnt)->done_SC; struct aha152x_scdata *sc = SCDATA(cmd); -#if 0 - if(HOSTDATA(shpnt)->debug & debug_eh) { - printk(ERR_LEAD "received sense: ", CMDINFO(DONE_SC)); - scsi_print_sense("bh", DONE_SC); - } -#endif - scsi_eh_restore_cmnd(cmd, &sc->ses); cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; @@ -1571,17 +1439,11 @@ static void busfree_run(struct Scsi_Host *shpnt) #if defined(AHA152X_STAT) HOSTDATA(shpnt)->busfree_with_check_condition++; #endif -#if 0 - DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC)); -#endif if(!(DONE_SC->SCp.phase & not_issued)) { struct aha152x_scdata *sc; Scsi_Cmnd *ptr = DONE_SC; DONE_SC=NULL; -#if 0 - DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr)); -#endif sc = SCDATA(ptr); /* It was allocated in aha152x_internal_queue? */ @@ -1591,19 +1453,10 @@ static void busfree_run(struct Scsi_Host *shpnt) DO_UNLOCK(flags); aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done); DO_LOCK(flags); -#if 0 - } else { - DPRINTK(debug_eh, ERR_LEAD "command not issued - CHECK CONDITION ignored\n", CMDINFO(DONE_SC)); -#endif } } if(DONE_SC && DONE_SC->scsi_done) { -#if defined(AHA152X_DEBUG) - int hostno=DONE_SC->device->host->host_no; - int id=DONE_SC->device->id & 0xf; - int lun=((u8)DONE_SC->device->lun) & 0x7; -#endif Scsi_Cmnd *ptr = DONE_SC; DONE_SC=NULL; @@ -1618,9 +1471,7 @@ static void busfree_run(struct Scsi_Host *shpnt) } DO_UNLOCK(flags); - DPRINTK(debug_done, DEBUG_LEAD "calling scsi_done(%p)\n", hostno, id, lun, ptr); - ptr->scsi_done(ptr); - DPRINTK(debug_done, DEBUG_LEAD "scsi_done(%p) returned\n", hostno, id, lun, ptr); + ptr->scsi_done(ptr); DO_LOCK(flags); } @@ -1640,9 +1491,7 @@ static void busfree_run(struct Scsi_Host *shpnt) #if defined(AHA152X_STAT) action++; #endif - CURRENT_SC->SCp.phase |= selecting; - - DPRINTK(debug_selection, DEBUG_LEAD "selecting target\n", CMDINFO(CURRENT_SC)); + CURRENT_SC->SCp.phase |= selecting; /* clear selection timeout */ SETPORT(SSTAT1, SELTO); @@ -1674,18 +1523,19 @@ static void seldo_run(struct Scsi_Host *shpnt) SETPORT(SSTAT1, CLRBUSFREE); SETPORT(SSTAT1, CLRPHASECHG); - CURRENT_SC->SCp.phase &= ~(selecting|not_issued); + CURRENT_SC->SCp.phase &= ~(selecting|not_issued); SETPORT(SCSISEQ, 0); if (TESTLO(SSTAT0, SELDO)) { - printk(ERR_LEAD "aha152x: passing bus free condition\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_ERR, CURRENT_SC, + "aha152x: passing bus free condition\n"); done(shpnt, DID_NO_CONNECT << 16); return; } SETPORT(SSTAT0, CLRSELDO); - + ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun)); if (CURRENT_SC->SCp.phase & aborting) { @@ -1693,7 +1543,7 @@ static void seldo_run(struct Scsi_Host *shpnt) } else if (CURRENT_SC->SCp.phase & resetting) { ADDMSGO(BUS_DEVICE_RESET); } else if (SYNCNEG==0 && SYNCHRONOUS) { - CURRENT_SC->SCp.phase |= syncneg; + CURRENT_SC->SCp.phase |= syncneg; MSGOLEN += spi_populate_sync_msg(&MSGO(MSGOLEN), 50, 8); SYNCNEG=1; /* negotiation in progress */ } @@ -1708,29 +1558,21 @@ static void seldo_run(struct Scsi_Host *shpnt) */ static void selto_run(struct Scsi_Host *shpnt) { - SETPORT(SCSISEQ, 0); + SETPORT(SCSISEQ, 0); SETPORT(SSTAT1, CLRSELTIMO); - DPRINTK(debug_selection, DEBUG_LEAD "selection timeout\n", CMDINFO(CURRENT_SC)); - - if(!CURRENT_SC) { - DPRINTK(debug_selection, DEBUG_LEAD "!CURRENT_SC\n", CMDINFO(CURRENT_SC)); + if (!CURRENT_SC) return; - } - CURRENT_SC->SCp.phase &= ~selecting; + CURRENT_SC->SCp.phase &= ~selecting; - if (CURRENT_SC->SCp.phase & aborted) { - DPRINTK(debug_selection, DEBUG_LEAD "aborted\n", CMDINFO(CURRENT_SC)); + if (CURRENT_SC->SCp.phase & aborted) done(shpnt, DID_ABORT << 16); - } else if (TESTLO(SSTAT0, SELINGO)) { - DPRINTK(debug_selection, DEBUG_LEAD "arbitration not won\n", CMDINFO(CURRENT_SC)); + else if (TESTLO(SSTAT0, SELINGO)) done(shpnt, DID_BUS_BUSY << 16); - } else { + else /* ARBITRATION won, but SELECTION failed */ - DPRINTK(debug_selection, DEBUG_LEAD "selection failed\n", CMDINFO(CURRENT_SC)); done(shpnt, DID_NO_CONNECT << 16); - } } /* @@ -1753,9 +1595,8 @@ static void seldi_run(struct Scsi_Host *shpnt) if(CURRENT_SC) { if(!(CURRENT_SC->SCp.phase & not_issued)) - printk(ERR_LEAD "command should not have been issued yet\n", CMDINFO(CURRENT_SC)); - - DPRINTK(debug_selection, ERR_LEAD "command requeued - reselection\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_ERR, CURRENT_SC, + "command should not have been issued yet\n"); DO_LOCK(flags); append_SC(&ISSUE_SC, CURRENT_SC); @@ -1764,17 +1605,16 @@ static void seldi_run(struct Scsi_Host *shpnt) CURRENT_SC = NULL; } - if(!DISCONNECTED_SC) { - DPRINTK(debug_selection, DEBUG_LEAD "unexpected SELDI ", CMDINFO(CURRENT_SC)); + if (!DISCONNECTED_SC) return; - } RECONN_TARGET=-1; selid = GETPORT(SELID) & ~(1 << shpnt->this_id); if (selid==0) { - printk("aha152x%d: target id unknown (%02x)\n", HOSTNO, selid); + shost_printk(KERN_INFO, shpnt, + "target id unknown (%02x)\n", selid); return; } @@ -1782,8 +1622,8 @@ static void seldi_run(struct Scsi_Host *shpnt) ; if(selid & ~(1 << target)) { - printk("aha152x%d: multiple targets reconnected (%02x)\n", - HOSTNO, selid); + shost_printk(KERN_INFO, shpnt, + "multiple targets reconnected (%02x)\n", selid); } @@ -1793,7 +1633,6 @@ static void seldi_run(struct Scsi_Host *shpnt) SETRATE(HOSTDATA(shpnt)->syncrate[target]); RECONN_TARGET=target; - DPRINTK(debug_selection, DEBUG_LEAD "target %d reselected (%02x).\n", CMDINFO(CURRENT_SC), target, selid); } /* @@ -1817,31 +1656,24 @@ static void msgi_run(struct Scsi_Host *shpnt) if(sstat1 & (PHASECHG|PHASEMIS|BUSFREE) || !(sstat1 & REQINIT)) return; - if(TESTLO(SSTAT0,SPIORDY)) { - DPRINTK(debug_msgi, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC)); + if (TESTLO(SSTAT0, SPIORDY)) return; - } ADDMSGI(GETPORT(SCSIDAT)); -#if defined(AHA152X_DEBUG) - if (HOSTDATA(shpnt)->debug & debug_msgi) { - printk(INFO_LEAD "inbound message %02x ", CMDINFO(CURRENT_SC), MSGI(0)); - spi_print_msg(&MSGI(0)); - printk("\n"); - } -#endif - if(!CURRENT_SC) { if(LASTSTATE!=seldi) { - printk(KERN_ERR "aha152x%d: message in w/o current command not after reselection\n", HOSTNO); + shost_printk(KERN_ERR, shpnt, + "message in w/o current command" + " not after reselection\n"); } /* - * Handle reselection - */ + * Handle reselection + */ if(!(MSGI(0) & IDENTIFY_BASE)) { - printk(KERN_ERR "aha152x%d: target didn't identify after reselection\n", HOSTNO); + shost_printk(KERN_ERR, shpnt, + "target didn't identify after reselection\n"); continue; } @@ -1849,12 +1681,13 @@ static void msgi_run(struct Scsi_Host *shpnt) if (!CURRENT_SC) { show_queues(shpnt); - printk(KERN_ERR "aha152x%d: no disconnected command for target %d/%d\n", HOSTNO, RECONN_TARGET, MSGI(0) & 0x3f); + shost_printk(KERN_ERR, shpnt, + "no disconnected command" + " for target %d/%d\n", + RECONN_TARGET, MSGI(0) & 0x3f); continue; } - DPRINTK(debug_msgi, DEBUG_LEAD "target reconnected\n", CMDINFO(CURRENT_SC)); - CURRENT_SC->SCp.Message = MSGI(0); CURRENT_SC->SCp.phase &= ~disconnected; @@ -1862,31 +1695,32 @@ static void msgi_run(struct Scsi_Host *shpnt) /* next message if any */ continue; - } + } CURRENT_SC->SCp.Message = MSGI(0); switch (MSGI(0)) { case DISCONNECT: if (!RECONNECT) - printk(WARN_LEAD "target was not allowed to disconnect\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_WARNING, CURRENT_SC, + "target was not allowed to disconnect\n"); CURRENT_SC->SCp.phase |= disconnected; break; case COMMAND_COMPLETE: - if(CURRENT_SC->SCp.phase & completed) - DPRINTK(debug_msgi, DEBUG_LEAD "again COMMAND COMPLETE\n", CMDINFO(CURRENT_SC)); - CURRENT_SC->SCp.phase |= completed; break; case MESSAGE_REJECT: if (SYNCNEG==1) { - printk(INFO_LEAD "Synchronous Data Transfer Request was rejected\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_INFO, CURRENT_SC, + "Synchronous Data Transfer Request" + " was rejected\n"); SYNCNEG=2; /* negotiation completed */ } else - printk(INFO_LEAD "inbound message (MESSAGE REJECT)\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_INFO, CURRENT_SC, + "inbound message (MESSAGE REJECT)\n"); break; case SAVE_POINTERS: @@ -1907,7 +1741,8 @@ static void msgi_run(struct Scsi_Host *shpnt) long ticks; if (MSGI(1) != 3) { - printk(ERR_LEAD "SDTR message length!=3\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_ERR, CURRENT_SC, + "SDTR message length!=3\n"); break; } @@ -1924,10 +1759,12 @@ static void msgi_run(struct Scsi_Host *shpnt) /* negotiation in progress */ if (ticks > 9 || MSGI(4) < 1 || MSGI(4) > 8) { ADDMSGO(MESSAGE_REJECT); - printk(INFO_LEAD "received Synchronous Data Transfer Request invalid - rejected\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_INFO, + CURRENT_SC, + "received Synchronous Data Transfer Request invalid - rejected\n"); break; } - + SYNCRATE |= ((ticks - 2) << 4) + MSGI(4); } else if (ticks <= 9 && MSGI(4) >= 1) { ADDMSGO(EXTENDED_MESSAGE); @@ -1947,11 +1784,14 @@ static void msgi_run(struct Scsi_Host *shpnt) SYNCRATE |= ((ticks - 2) << 4) + MSGI(4); } else { /* requested SDTR is too slow, do it asynchronously */ - printk(INFO_LEAD "Synchronous Data Transfer Request too slow - Rejecting\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_INFO, + CURRENT_SC, + "Synchronous Data Transfer Request too slow - Rejecting\n"); ADDMSGO(MESSAGE_REJECT); } - SYNCNEG=2; /* negotiation completed */ + /* negotiation completed */ + SYNCNEG=2; SETRATE(SYNCRATE); } break; @@ -1985,12 +1825,12 @@ static void msgi_run(struct Scsi_Host *shpnt) static void msgi_end(struct Scsi_Host *shpnt) { if(MSGILEN>0) - printk(WARN_LEAD "target left before message completed (%d)\n", CMDINFO(CURRENT_SC), MSGILEN); + scmd_printk(KERN_WARNING, CURRENT_SC, + "target left before message completed (%d)\n", + MSGILEN); - if (MSGOLEN > 0 && !(GETPORT(SSTAT1) & BUSFREE)) { - DPRINTK(debug_msgi, DEBUG_LEAD "msgo pending\n", CMDINFO(CURRENT_SC)); + if (MSGOLEN > 0 && !(GETPORT(SSTAT1) & BUSFREE)) SETPORT(SCSISIG, P_MSGI | SIG_ATNO); - } } /* @@ -2003,21 +1843,12 @@ static void msgo_init(struct Scsi_Host *shpnt) if((CURRENT_SC->SCp.phase & syncneg) && SYNCNEG==2 && SYNCRATE==0) { ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun)); } else { - printk(INFO_LEAD "unexpected MESSAGE OUT phase; rejecting\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_INFO, CURRENT_SC, + "unexpected MESSAGE OUT phase; rejecting\n"); ADDMSGO(MESSAGE_REJECT); } } -#if defined(AHA152X_DEBUG) - if(HOSTDATA(shpnt)->debug & debug_msgo) { - int i; - - printk(DEBUG_LEAD "messages( ", CMDINFO(CURRENT_SC)); - for (i=0; iSCp.sent_command) { - printk(ERR_LEAD "command already sent\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_ERR, CURRENT_SC, + "command already sent\n"); done(shpnt, DID_ERROR << 16); return; } -#if defined(AHA152X_DEBUG) - if (HOSTDATA(shpnt)->debug & debug_cmd) { - printk(DEBUG_LEAD "cmd_init: ", CMDINFO(CURRENT_SC)); - __scsi_print_command(CURRENT_SC->cmnd); - } -#endif - CMD_I=0; } @@ -2098,18 +1919,9 @@ static void cmd_init(struct Scsi_Host *shpnt) */ static void cmd_run(struct Scsi_Host *shpnt) { - if(CMD_I==CURRENT_SC->cmd_len) { - DPRINTK(debug_cmd, DEBUG_LEAD "command already completely sent (%d/%d)", CMDINFO(CURRENT_SC), CMD_I, CURRENT_SC->cmd_len); - disp_ports(shpnt); - } - while(CMD_Icmd_len) { - DPRINTK(debug_cmd, DEBUG_LEAD "command byte %02x (%d/%d)\n", CMDINFO(CURRENT_SC), CURRENT_SC->cmnd[CMD_I], CMD_I, CURRENT_SC->cmd_len); - - if(TESTLO(SSTAT0, SPIORDY)) { - DPRINTK(debug_cmd, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC)); + if (TESTLO(SSTAT0, SPIORDY)) return; - } SETPORT(SCSIDAT, CURRENT_SC->cmnd[CMD_I++]); } @@ -2118,7 +1930,9 @@ static void cmd_run(struct Scsi_Host *shpnt) static void cmd_end(struct Scsi_Host *shpnt) { if(CMD_Icmd_len) - printk(ERR_LEAD "command sent incompletely (%d/%d)\n", CMDINFO(CURRENT_SC), CMD_I, CURRENT_SC->cmd_len); + scmd_printk(KERN_ERR, CURRENT_SC, + "command sent incompletely (%d/%d)\n", + CMD_I, CURRENT_SC->cmd_len); else CURRENT_SC->SCp.sent_command++; } @@ -2129,20 +1943,11 @@ static void cmd_end(struct Scsi_Host *shpnt) */ static void status_run(struct Scsi_Host *shpnt) { - if(TESTLO(SSTAT0,SPIORDY)) { - DPRINTK(debug_status, DEBUG_LEAD "!SPIORDY\n", CMDINFO(CURRENT_SC)); + if (TESTLO(SSTAT0, SPIORDY)) return; - } CURRENT_SC->SCp.Status = GETPORT(SCSIDAT); -#if defined(AHA152X_DEBUG) - if (HOSTDATA(shpnt)->debug & debug_status) { - printk(DEBUG_LEAD "inbound status %02x ", CMDINFO(CURRENT_SC), CURRENT_SC->SCp.Status); - scsi_print_status(CURRENT_SC->SCp.Status); - printk("\n"); - } -#endif } /* @@ -2161,10 +1966,6 @@ static void datai_init(struct Scsi_Host *shpnt) SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE); DATA_LEN=0; - DPRINTK(debug_datai, - DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", - CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), - scsi_get_resid(CURRENT_SC)); } static void datai_run(struct Scsi_Host *shpnt) @@ -2186,8 +1987,7 @@ static void datai_run(struct Scsi_Host *shpnt) barrier(); if(TESTLO(DMASTAT, DFIFOFULL|INTSTAT)) { - printk(ERR_LEAD "datai timeout", CMDINFO(CURRENT_SC)); - disp_ports(shpnt); + scmd_printk(KERN_ERR, CURRENT_SC, "datai timeout\n"); break; } @@ -2199,8 +1999,8 @@ static void datai_run(struct Scsi_Host *shpnt) barrier(); if(TESTLO(SSTAT2, SEMPTY)) { - printk(ERR_LEAD "datai sempty timeout", CMDINFO(CURRENT_SC)); - disp_ports(shpnt); + scmd_printk(KERN_ERR, CURRENT_SC, + "datai sempty timeout"); break; } @@ -2209,48 +2009,49 @@ static void datai_run(struct Scsi_Host *shpnt) if(CURRENT_SC->SCp.this_residual>0) { while(fifodata>0 && CURRENT_SC->SCp.this_residual>0) { - data_count = fifodata>CURRENT_SC->SCp.this_residual ? + data_count = fifodata > CURRENT_SC->SCp.this_residual ? CURRENT_SC->SCp.this_residual : fifodata; fifodata -= data_count; - if(data_count & 1) { - DPRINTK(debug_datai, DEBUG_LEAD "8bit\n", CMDINFO(CURRENT_SC)); - SETPORT(DMACNTRL0, ENDMA|_8BIT); - *CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT); - CURRENT_SC->SCp.this_residual--; - DATA_LEN++; - SETPORT(DMACNTRL0, ENDMA); - } - - if(data_count > 1) { - DPRINTK(debug_datai, DEBUG_LEAD "16bit(%d)\n", CMDINFO(CURRENT_SC), data_count); - data_count >>= 1; - insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); - CURRENT_SC->SCp.ptr += 2 * data_count; - CURRENT_SC->SCp.this_residual -= 2 * data_count; - DATA_LEN += 2 * data_count; - } - - if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { - /* advance to next buffer */ - CURRENT_SC->SCp.buffers_residual--; - CURRENT_SC->SCp.buffer++; - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; - } - } - } else if(fifodata>0) { - printk(ERR_LEAD "no buffers left for %d(%d) bytes (data overrun!?)\n", CMDINFO(CURRENT_SC), fifodata, GETPORT(FIFOSTAT)); - SETPORT(DMACNTRL0, ENDMA|_8BIT); + if (data_count & 1) { + SETPORT(DMACNTRL0, ENDMA|_8BIT); + *CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT); + CURRENT_SC->SCp.this_residual--; + DATA_LEN++; + SETPORT(DMACNTRL0, ENDMA); + } + + if (data_count > 1) { + data_count >>= 1; + insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); + CURRENT_SC->SCp.ptr += 2 * data_count; + CURRENT_SC->SCp.this_residual -= 2 * data_count; + DATA_LEN += 2 * data_count; + } + + if (CURRENT_SC->SCp.this_residual == 0 && + CURRENT_SC->SCp.buffers_residual > 0) { + /* advance to next buffer */ + CURRENT_SC->SCp.buffers_residual--; + CURRENT_SC->SCp.buffer++; + CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); + CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; + } + } + } else if (fifodata > 0) { + scmd_printk(KERN_ERR, CURRENT_SC, + "no buffers left for %d(%d) bytes" + " (data overrun!?)\n", + fifodata, GETPORT(FIFOSTAT)); + SETPORT(DMACNTRL0, ENDMA|_8BIT); while(fifodata>0) { int data; data=GETPORT(DATAPORT); - DPRINTK(debug_datai, DEBUG_LEAD "data=%02x\n", CMDINFO(CURRENT_SC), data); fifodata--; DATA_LEN++; } - SETPORT(DMACNTRL0, ENDMA|_8BIT); + SETPORT(DMACNTRL0, ENDMA|_8BIT); } } @@ -2258,19 +2059,20 @@ static void datai_run(struct Scsi_Host *shpnt) TESTLO(DMASTAT, DFIFOEMP) || TESTLO(SSTAT2, SEMPTY) || GETPORT(FIFOSTAT)>0) { - /* + /* * something went wrong, if there's something left in the fifos * or the phase didn't change */ - printk(ERR_LEAD "fifos should be empty and phase should have changed\n", CMDINFO(CURRENT_SC)); - disp_ports(shpnt); + scmd_printk(KERN_ERR, CURRENT_SC, + "fifos should be empty and phase should have changed\n"); } if(DATA_LEN!=GETSTCNT()) { - printk(ERR_LEAD - "manual transfer count differs from automatic (count=%d;stcnt=%d;diff=%d;fifostat=%d)", - CMDINFO(CURRENT_SC), DATA_LEN, GETSTCNT(), GETSTCNT()-DATA_LEN, GETPORT(FIFOSTAT)); - disp_ports(shpnt); + scmd_printk(KERN_ERR, CURRENT_SC, + "manual transfer count differs from automatic " + "(count=%d;stcnt=%d;diff=%d;fifostat=%d)", + DATA_LEN, GETSTCNT(), GETSTCNT()-DATA_LEN, + GETPORT(FIFOSTAT)); mdelay(10000); } } @@ -2279,11 +2081,6 @@ static void datai_end(struct Scsi_Host *shpnt) { CMD_INC_RESID(CURRENT_SC, -GETSTCNT()); - DPRINTK(debug_datai, - DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n", - CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), - scsi_get_resid(CURRENT_SC), GETSTCNT()); - SETPORT(SXFRCTL0, CH1|CLRSTCNT); SETPORT(DMACNTRL0, 0); } @@ -2304,11 +2101,6 @@ static void datao_init(struct Scsi_Host *shpnt) SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); DATA_LEN = scsi_get_resid(CURRENT_SC); - - DPRINTK(debug_datao, - DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", - CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC), - scsi_get_resid(CURRENT_SC)); } static void datao_run(struct Scsi_Host *shpnt) @@ -2323,8 +2115,9 @@ static void datao_run(struct Scsi_Host *shpnt) data_count=CURRENT_SC->SCp.this_residual; if(TESTLO(DMASTAT, DFIFOEMP)) { - printk(ERR_LEAD "datao fifo not empty (%d)", CMDINFO(CURRENT_SC), GETPORT(FIFOSTAT)); - disp_ports(shpnt); + scmd_printk(KERN_ERR, CURRENT_SC, + "datao fifo not empty (%d)", + GETPORT(FIFOSTAT)); break; } @@ -2342,7 +2135,7 @@ static void datao_run(struct Scsi_Host *shpnt) CURRENT_SC->SCp.ptr += 2 * data_count; CURRENT_SC->SCp.this_residual -= 2 * data_count; CMD_INC_RESID(CURRENT_SC, -2 * data_count); - } + } if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { /* advance to next buffer */ @@ -2357,8 +2150,7 @@ static void datao_run(struct Scsi_Host *shpnt) barrier(); if(TESTLO(DMASTAT, DFIFOEMP|INTSTAT)) { - printk(ERR_LEAD "dataout timeout", CMDINFO(CURRENT_SC)); - disp_ports(shpnt); + scmd_printk(KERN_ERR, CURRENT_SC, "dataout timeout\n"); break; } } @@ -2368,35 +2160,23 @@ static void datao_end(struct Scsi_Host *shpnt) { if(TESTLO(DMASTAT, DFIFOEMP)) { int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - - GETSTCNT(); - - DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n", - CMDINFO(CURRENT_SC), - data_count, - DATA_LEN - scsi_get_resid(CURRENT_SC), - GETSTCNT()); + GETSTCNT(); CMD_INC_RESID(CURRENT_SC, data_count); data_count -= CURRENT_SC->SCp.ptr - - SG_ADDRESS(CURRENT_SC->SCp.buffer); + SG_ADDRESS(CURRENT_SC->SCp.buffer); while(data_count>0) { CURRENT_SC->SCp.buffer--; CURRENT_SC->SCp.buffers_residual++; data_count -= CURRENT_SC->SCp.buffer->length; } CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - - data_count; + data_count; CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + - data_count; + data_count; } - DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n", - CMDINFO(CURRENT_SC), - scsi_bufflen(CURRENT_SC), - scsi_get_resid(CURRENT_SC), - GETSTCNT()); - SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); SETPORT(SXFRCTL0, CH1); @@ -2420,7 +2200,7 @@ static int update_state(struct Scsi_Host *shpnt) STATE=rsti; SETPORT(SCSISEQ,0); SETPORT(SSTAT1,SCSIRSTI); - } else if(stat0 & SELDI && PREVSTATE==busfree) { + } else if (stat0 & SELDI && PREVSTATE == busfree) { STATE=seldi; } else if(stat0 & SELDO && CURRENT_SC && (CURRENT_SC->SCp.phase & selecting)) { STATE=seldo; @@ -2445,8 +2225,7 @@ static int update_state(struct Scsi_Host *shpnt) } if((stat0 & SELDI) && STATE!=seldi && !dataphase) { - printk(INFO_LEAD "reselection missed?", CMDINFO(CURRENT_SC)); - disp_ports(shpnt); + scmd_printk(KERN_INFO, CURRENT_SC, "reselection missed?"); } if(STATE!=PREVSTATE) { @@ -2464,7 +2243,7 @@ static int update_state(struct Scsi_Host *shpnt) */ static void parerr_run(struct Scsi_Host *shpnt) { - printk(ERR_LEAD "parity error\n", CMDINFO(CURRENT_SC)); + scmd_printk(KERN_ERR, CURRENT_SC, "parity error\n"); done(shpnt, DID_PARITY << 16); } @@ -2476,8 +2255,8 @@ static void rsti_run(struct Scsi_Host *shpnt) { Scsi_Cmnd *ptr; - printk(KERN_NOTICE "aha152x%d: scsi reset in\n", HOSTNO); - + shost_printk(KERN_NOTICE, shpnt, "scsi reset in\n"); + ptr=DISCONNECTED_SC; while(ptr) { Scsi_Cmnd *next = SCNEXT(ptr); @@ -2539,8 +2318,6 @@ static void is_complete(struct Scsi_Host *shpnt) dataphase=update_state(shpnt); - DPRINTK(debug_phases, LEAD "start %s %s(%s)\n", CMDINFO(CURRENT_SC), states[STATE].name, states[PREVSTATE].name, states[LASTSTATE].name); - /* * end previous state * @@ -2567,9 +2344,9 @@ static void is_complete(struct Scsi_Host *shpnt) if(dataphase) { SETPORT(SSTAT0, REQINIT); SETPORT(SCSISIG, GETPORT(SCSISIG) & P_MASK); - SETPORT(SSTAT1, PHASECHG); + SETPORT(SSTAT1, PHASECHG); } - + /* * enable SPIO mode if previous didn't use it * and this one does @@ -2581,14 +2358,14 @@ static void is_complete(struct Scsi_Host *shpnt) if(CURRENT_SC) CURRENT_SC->SCp.phase |= spiordy; } - + /* * initialize for new state * */ if(PREVSTATE!=STATE && states[STATE].init) states[STATE].init(shpnt); - + /* * handle current state * @@ -2596,8 +2373,9 @@ static void is_complete(struct Scsi_Host *shpnt) if(states[STATE].run) states[STATE].run(shpnt); else - printk(ERR_LEAD "unexpected state (%x)\n", CMDINFO(CURRENT_SC), STATE); - + scmd_printk(KERN_ERR, CURRENT_SC, + "unexpected state (%x)\n", STATE); + /* * setup controller to interrupt on * the next expected condition and @@ -2613,7 +2391,6 @@ static void is_complete(struct Scsi_Host *shpnt) HOSTDATA(shpnt)->time[STATE] += jiffies-start; #endif - DPRINTK(debug_phases, LEAD "end %s %s(%s)\n", CMDINFO(CURRENT_SC), states[STATE].name, states[PREVSTATE].name, states[LASTSTATE].name); } while(pending); /* @@ -2626,289 +2403,42 @@ static void is_complete(struct Scsi_Host *shpnt) } -/* +/* * Dump the current driver status and panic */ static void aha152x_error(struct Scsi_Host *shpnt, char *msg) { - printk(KERN_EMERG "\naha152x%d: %s\n", HOSTNO, msg); + shost_printk(KERN_EMERG, shpnt, "%s\n", msg); show_queues(shpnt); panic("aha152x panic\n"); } -/* - * Display registers of AIC-6260 - */ -static void disp_ports(struct Scsi_Host *shpnt) -{ -#if defined(AHA152X_DEBUG) - int s; - - printk("\n%s: %s(%s) ", - CURRENT_SC ? "busy" : "waiting", - states[STATE].name, - states[PREVSTATE].name); - - s = GETPORT(SCSISEQ); - printk("SCSISEQ( "); - if (s & TEMODEO) - printk("TARGET MODE "); - if (s & ENSELO) - printk("SELO "); - if (s & ENSELI) - printk("SELI "); - if (s & ENRESELI) - printk("RESELI "); - if (s & ENAUTOATNO) - printk("AUTOATNO "); - if (s & ENAUTOATNI) - printk("AUTOATNI "); - if (s & ENAUTOATNP) - printk("AUTOATNP "); - if (s & SCSIRSTO) - printk("SCSIRSTO "); - printk(");"); - - printk(" SCSISIG("); - s = GETPORT(SCSISIG); - switch (s & P_MASK) { - case P_DATAO: - printk("DATA OUT"); - break; - case P_DATAI: - printk("DATA IN"); - break; - case P_CMD: - printk("COMMAND"); - break; - case P_STATUS: - printk("STATUS"); - break; - case P_MSGO: - printk("MESSAGE OUT"); - break; - case P_MSGI: - printk("MESSAGE IN"); - break; - default: - printk("*invalid*"); - break; - } - - printk("); "); - - printk("INTSTAT (%s); ", TESTHI(DMASTAT, INTSTAT) ? "hi" : "lo"); - - printk("SSTAT( "); - s = GETPORT(SSTAT0); - if (s & TARGET) - printk("TARGET "); - if (s & SELDO) - printk("SELDO "); - if (s & SELDI) - printk("SELDI "); - if (s & SELINGO) - printk("SELINGO "); - if (s & SWRAP) - printk("SWRAP "); - if (s & SDONE) - printk("SDONE "); - if (s & SPIORDY) - printk("SPIORDY "); - if (s & DMADONE) - printk("DMADONE "); - - s = GETPORT(SSTAT1); - if (s & SELTO) - printk("SELTO "); - if (s & ATNTARG) - printk("ATNTARG "); - if (s & SCSIRSTI) - printk("SCSIRSTI "); - if (s & PHASEMIS) - printk("PHASEMIS "); - if (s & BUSFREE) - printk("BUSFREE "); - if (s & SCSIPERR) - printk("SCSIPERR "); - if (s & PHASECHG) - printk("PHASECHG "); - if (s & REQINIT) - printk("REQINIT "); - printk("); "); - - - printk("SSTAT( "); - - s = GETPORT(SSTAT0) & GETPORT(SIMODE0); - - if (s & TARGET) - printk("TARGET "); - if (s & SELDO) - printk("SELDO "); - if (s & SELDI) - printk("SELDI "); - if (s & SELINGO) - printk("SELINGO "); - if (s & SWRAP) - printk("SWRAP "); - if (s & SDONE) - printk("SDONE "); - if (s & SPIORDY) - printk("SPIORDY "); - if (s & DMADONE) - printk("DMADONE "); - - s = GETPORT(SSTAT1) & GETPORT(SIMODE1); - - if (s & SELTO) - printk("SELTO "); - if (s & ATNTARG) - printk("ATNTARG "); - if (s & SCSIRSTI) - printk("SCSIRSTI "); - if (s & PHASEMIS) - printk("PHASEMIS "); - if (s & BUSFREE) - printk("BUSFREE "); - if (s & SCSIPERR) - printk("SCSIPERR "); - if (s & PHASECHG) - printk("PHASECHG "); - if (s & REQINIT) - printk("REQINIT "); - printk("); "); - - printk("SXFRCTL0( "); - - s = GETPORT(SXFRCTL0); - if (s & SCSIEN) - printk("SCSIEN "); - if (s & DMAEN) - printk("DMAEN "); - if (s & CH1) - printk("CH1 "); - if (s & CLRSTCNT) - printk("CLRSTCNT "); - if (s & SPIOEN) - printk("SPIOEN "); - if (s & CLRCH1) - printk("CLRCH1 "); - printk("); "); - - printk("SIGNAL( "); - - s = GETPORT(SCSISIG); - if (s & SIG_ATNI) - printk("ATNI "); - if (s & SIG_SELI) - printk("SELI "); - if (s & SIG_BSYI) - printk("BSYI "); - if (s & SIG_REQI) - printk("REQI "); - if (s & SIG_ACKI) - printk("ACKI "); - printk("); "); - - printk("SELID (%02x), ", GETPORT(SELID)); - - printk("STCNT (%d), ", GETSTCNT()); - - printk("SSTAT2( "); - - s = GETPORT(SSTAT2); - if (s & SOFFSET) - printk("SOFFSET "); - if (s & SEMPTY) - printk("SEMPTY "); - if (s & SFULL) - printk("SFULL "); - printk("); SFCNT (%d); ", s & (SFULL | SFCNT)); - - s = GETPORT(SSTAT3); - printk("SCSICNT (%d), OFFCNT(%d), ", (s & 0xf0) >> 4, s & 0x0f); - - printk("SSTAT4( "); - s = GETPORT(SSTAT4); - if (s & SYNCERR) - printk("SYNCERR "); - if (s & FWERR) - printk("FWERR "); - if (s & FRERR) - printk("FRERR "); - printk("); "); - - printk("DMACNTRL0( "); - s = GETPORT(DMACNTRL0); - printk("%s ", s & _8BIT ? "8BIT" : "16BIT"); - printk("%s ", s & DMA ? "DMA" : "PIO"); - printk("%s ", s & WRITE_READ ? "WRITE" : "READ"); - if (s & ENDMA) - printk("ENDMA "); - if (s & INTEN) - printk("INTEN "); - if (s & RSTFIFO) - printk("RSTFIFO "); - if (s & SWINT) - printk("SWINT "); - printk("); "); - - printk("DMASTAT( "); - s = GETPORT(DMASTAT); - if (s & ATDONE) - printk("ATDONE "); - if (s & WORDRDY) - printk("WORDRDY "); - if (s & DFIFOFULL) - printk("DFIFOFULL "); - if (s & DFIFOEMP) - printk("DFIFOEMP "); - printk(")\n"); -#endif -} - /* * display enabled interrupts */ static void disp_enintr(struct Scsi_Host *shpnt) { - int s; - - printk(KERN_DEBUG "enabled interrupts ( "); - - s = GETPORT(SIMODE0); - if (s & ENSELDO) - printk("ENSELDO "); - if (s & ENSELDI) - printk("ENSELDI "); - if (s & ENSELINGO) - printk("ENSELINGO "); - if (s & ENSWRAP) - printk("ENSWRAP "); - if (s & ENSDONE) - printk("ENSDONE "); - if (s & ENSPIORDY) - printk("ENSPIORDY "); - if (s & ENDMADONE) - printk("ENDMADONE "); - - s = GETPORT(SIMODE1); - if (s & ENSELTIMO) - printk("ENSELTIMO "); - if (s & ENATNTARG) - printk("ENATNTARG "); - if (s & ENPHASEMIS) - printk("ENPHASEMIS "); - if (s & ENBUSFREE) - printk("ENBUSFREE "); - if (s & ENSCSIPERR) - printk("ENSCSIPERR "); - if (s & ENPHASECHG) - printk("ENPHASECHG "); - if (s & ENREQINIT) - printk("ENREQINIT "); - printk(")\n"); + int s0, s1; + + s0 = GETPORT(SIMODE0); + s1 = GETPORT(SIMODE1); + + shost_printk(KERN_DEBUG, shpnt, + "enabled interrupts (%s%s%s%s%s%s%s%s%s%s%s%s%s%s)\n", + (s0 & ENSELDO) ? "ENSELDO " : "", + (s0 & ENSELDI) ? "ENSELDI " : "", + (s0 & ENSELINGO) ? "ENSELINGO " : "", + (s0 & ENSWRAP) ? "ENSWRAP " : "", + (s0 & ENSDONE) ? "ENSDONE " : "", + (s0 & ENSPIORDY) ? "ENSPIORDY " : "", + (s0 & ENDMADONE) ? "ENDMADONE " : "", + (s1 & ENSELTIMO) ? "ENSELTIMO " : "", + (s1 & ENATNTARG) ? "ENATNTARG " : "", + (s1 & ENPHASEMIS) ? "ENPHASEMIS " : "", + (s1 & ENBUSFREE) ? "ENBUSFREE " : "", + (s1 & ENSCSIPERR) ? "ENSCSIPERR " : "", + (s1 & ENPHASECHG) ? "ENPHASECHG " : "", + (s1 & ENREQINIT) ? "ENREQINIT " : ""); } /* @@ -2916,36 +2446,21 @@ 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->cmnd); - - printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", - scsi_bufflen(ptr), scsi_get_resid(ptr)); - - if (ptr->SCp.phase & not_issued) - printk("not issued|"); - if (ptr->SCp.phase & selecting) - printk("selecting|"); - if (ptr->SCp.phase & identified) - printk("identified|"); - if (ptr->SCp.phase & disconnected) - printk("disconnected|"); - if (ptr->SCp.phase & completed) - printk("completed|"); - if (ptr->SCp.phase & spiordy) - printk("spiordy|"); - if (ptr->SCp.phase & syncneg) - printk("syncneg|"); - if (ptr->SCp.phase & aborted) - printk("aborted|"); - if (ptr->SCp.phase & resetted) - printk("resetted|"); - if( SCDATA(ptr) ) { - printk("; next=0x%p\n", SCNEXT(ptr)); - } else { - printk("; next=(host scribble NULL)\n"); - } + scsi_print_command(ptr); + scmd_printk(KERN_DEBUG, ptr, + "request_bufflen=%d; resid=%d; " + "phase |%s%s%s%s%s%s%s%s%s; next=0x%p", + scsi_bufflen(ptr), scsi_get_resid(ptr), + (ptr->SCp.phase & not_issued) ? "not issued|" : "", + (ptr->SCp.phase & selecting) ? "selecting|" : "", + (ptr->SCp.phase & identified) ? "identified|" : "", + (ptr->SCp.phase & disconnected) ? "disconnected|" : "", + (ptr->SCp.phase & completed) ? "completed|" : "", + (ptr->SCp.phase & spiordy) ? "spiordy|" : "", + (ptr->SCp.phase & syncneg) ? "syncneg|" : "", + (ptr->SCp.phase & aborted) ? "aborted|" : "", + (ptr->SCp.phase & resetted) ? "resetted|" : "", + (SCDATA(ptr)) ? SCNEXT(ptr) : NULL); } /* @@ -2972,7 +2487,6 @@ static void show_queues(struct Scsi_Host *shpnt) for (ptr = DISCONNECTED_SC; ptr; ptr = SCDATA(ptr) ? SCNEXT(ptr) : NULL) show_command(ptr); - disp_ports(shpnt); disp_enintr(shpnt); } @@ -3276,15 +2790,6 @@ static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length) if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0) return -EINVAL; -#if defined(AHA152X_DEBUG) - if(length>14 && strncmp("debug ", buffer+8, 6)==0) { - int debug = HOSTDATA(shpnt)->debug; - - HOSTDATA(shpnt)->debug = simple_strtoul(buffer+14, NULL, 0); - - printk(KERN_INFO "aha152x%d: debugging options set to 0x%04x (were 0x%04x)\n", HOSTNO, HOSTDATA(shpnt)->debug, debug); - } else -#endif #if defined(AHA152X_STAT) if(length>13 && strncmp("reset", buffer+8, 5)==0) { int i; @@ -3302,7 +2807,7 @@ static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length) HOSTDATA(shpnt)->time[i]=0; } - printk(KERN_INFO "aha152x%d: stats reseted.\n", HOSTNO); + shost_printk(KERN_INFO, shpnt, "aha152x: stats reset.\n"); } else #endif @@ -3343,29 +2848,6 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt) (((HOSTDATA(shpnt)->syncrate[i] & 0x70) >> 4) + 2) * 50, HOSTDATA(shpnt)->syncrate[i] & 0x0f); } -#if defined(AHA152X_DEBUG) -#define PDEBUG(flags,txt) \ - if(HOSTDATA(shpnt)->debug & flags) SPRINTF("(%s) ", txt); - - SPRINTF("enabled debugging options: "); - - PDEBUG(debug_procinfo, "procinfo"); - PDEBUG(debug_queue, "queue"); - PDEBUG(debug_intr, "interrupt"); - PDEBUG(debug_selection, "selection"); - PDEBUG(debug_msgo, "message out"); - PDEBUG(debug_msgi, "message in"); - PDEBUG(debug_status, "status"); - PDEBUG(debug_cmd, "command"); - PDEBUG(debug_datai, "data in"); - PDEBUG(debug_datao, "data out"); - PDEBUG(debug_eh, "eh"); - PDEBUG(debug_locking, "locks"); - PDEBUG(debug_phases, "phases"); - - SPRINTF("\n"); -#endif - SPRINTF("\nqueue status:\n"); DO_LOCK(flags); if (ISSUE_SC) { @@ -3393,8 +2875,8 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt) #if defined(AHA152X_STAT) SPRINTF("statistics:\n" - "total commands: %d\n" - "disconnections: %d\n" + "total commands: %d\n" + "disconnections: %d\n" "busfree with check condition: %d\n" "busfree without old command: %d\n" "busfree without new command: %d\n" @@ -3413,7 +2895,7 @@ static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt) HOSTDATA(shpnt)->busfree_without_any_action); for(i=0; icount_trans[i], HOSTDATA(shpnt)->count[i], HOSTDATA(shpnt)->time[i]); @@ -3671,25 +3153,19 @@ static int __init aha152x_init(void) setup[setup_count].synchronous = aha152x[5]; setup[setup_count].delay = aha152x[6]; setup[setup_count].ext_trans = aha152x[7]; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = aha152x[8]; -#endif - } else if(io[0]!=0 || irq[0]!=0) { + } else if (io[0] != 0 || irq[0] != 0) { if(io[0]!=0) setup[setup_count].io_port = io[0]; if(irq[0]!=0) setup[setup_count].irq = irq[0]; - setup[setup_count].scsiid = scsiid[0]; - setup[setup_count].reconnect = reconnect[0]; - setup[setup_count].parity = parity[0]; - setup[setup_count].synchronous = sync[0]; - setup[setup_count].delay = delay[0]; - setup[setup_count].ext_trans = exttrans[0]; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = debug[0]; -#endif + setup[setup_count].scsiid = scsiid[0]; + setup[setup_count].reconnect = reconnect[0]; + setup[setup_count].parity = parity[0]; + setup[setup_count].synchronous = sync[0]; + setup[setup_count].delay = delay[0]; + setup[setup_count].ext_trans = exttrans[0]; } - if (checksetup(&setup[setup_count])) + if (checksetup(&setup[setup_count])) setup_count++; else printk(KERN_ERR "aha152x: invalid module params io=0x%x, irq=%d,scsiid=%d,reconnect=%d,parity=%d,sync=%d,delay=%d,exttrans=%d\n", @@ -3714,22 +3190,16 @@ static int __init aha152x_init(void) setup[setup_count].synchronous = aha152x1[5]; setup[setup_count].delay = aha152x1[6]; setup[setup_count].ext_trans = aha152x1[7]; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = aha152x1[8]; -#endif - } else if(io[1]!=0 || irq[1]!=0) { + } else if (io[1] != 0 || irq[1] != 0) { if(io[1]!=0) setup[setup_count].io_port = io[1]; if(irq[1]!=0) setup[setup_count].irq = irq[1]; - setup[setup_count].scsiid = scsiid[1]; - setup[setup_count].reconnect = reconnect[1]; - setup[setup_count].parity = parity[1]; - setup[setup_count].synchronous = sync[1]; - setup[setup_count].delay = delay[1]; - setup[setup_count].ext_trans = exttrans[1]; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = debug[1]; -#endif + setup[setup_count].scsiid = scsiid[1]; + setup[setup_count].reconnect = reconnect[1]; + setup[setup_count].parity = parity[1]; + setup[setup_count].synchronous = sync[1]; + setup[setup_count].delay = delay[1]; + setup[setup_count].ext_trans = exttrans[1]; } if (checksetup(&setup[setup_count])) setup_count++; @@ -3776,9 +3246,6 @@ static int __init aha152x_init(void) setup[setup_count].synchronous = 1; setup[setup_count].delay = DELAY_DEFAULT; setup[setup_count].ext_trans = 0; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = DEBUG_DEFAULT; -#endif #if defined(__ISAPNP__) pnpdev[setup_count] = dev; #endif @@ -3847,9 +3314,6 @@ static int __init aha152x_init(void) setup[setup_count].synchronous = conf.cf_syncneg; setup[setup_count].delay = DELAY_DEFAULT; setup[setup_count].ext_trans = 0; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = DEBUG_DEFAULT; -#endif setup_count++; } @@ -3903,11 +3367,8 @@ module_exit(aha152x_exit); #if !defined(MODULE) static int __init aha152x_setup(char *str) { -#if defined(AHA152X_DEBUG) - int ints[11]; -#else int ints[10]; -#endif + get_options(str, ARRAY_SIZE(ints), ints); if(setup_count>=ARRAY_SIZE(setup)) { @@ -3924,16 +3385,9 @@ static int __init aha152x_setup(char *str) setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1; setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT; setup[setup_count].ext_trans = ints[0] >= 8 ? ints[8] : 0; -#if defined(AHA152X_DEBUG) - setup[setup_count].debug = ints[0] >= 9 ? ints[9] : DEBUG_DEFAULT; - if (ints[0] > 9) { - printk(KERN_NOTICE "aha152x: usage: aha152x=[,[," - "[,[,[,[,[,[,]]]]]]]]\n"); -#else if (ints[0] > 8) { /*}*/ printk(KERN_NOTICE "aha152x: usage: aha152x=[,[," "[,[,[,[,[,]]]]]]]\n"); -#endif } else { setup_count++; return 0; -- cgit v1.2.3 From 22e0d994151c3eac183625f8c1400c0c83ac414f Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:44 +0200 Subject: 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 Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/ch.c | 3 +-- drivers/scsi/sd.h | 6 +++--- drivers/scsi/sg.c | 4 ++-- drivers/scsi/sr.h | 3 +-- drivers/scsi/st.c | 3 +-- include/scsi/scsi_device.h | 9 +++++++++ 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index ef5ae0d03616..52060e72b75d 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -85,8 +85,7 @@ static const char * vendor_labels[CH_TYPES-4] = { // module_param_string_array(vendor_labels, NULL, 0444); #define ch_printk(prefix, ch, fmt, a...) \ - sdev_printk(prefix, (ch)->device, "[%s] " fmt, \ - (ch)->name, ##a) + sdev_prefix_printk(prefix, (ch)->device, (ch)->name, fmt, ##a) #define DPRINTK(fmt, arg...) \ do { \ diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 467377884b63..63ba5ca7f9a1 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -103,9 +103,9 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk) #define sd_printk(prefix, sdsk, fmt, a...) \ (sdsk)->disk ? \ - sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \ - (sdsk)->disk->disk_name, ##a) : \ - sdev_printk(prefix, (sdsk)->device, fmt, ##a) + sdev_prefix_printk(prefix, (sdsk)->device, \ + (sdsk)->disk->disk_name, fmt, ##a) : \ + sdev_printk(prefix, (sdsk)->device, fmt, ##a) #define sd_first_printk(prefix, sdsk, fmt, a...) \ do { \ diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index fe44c14f551e..55cbc6689d27 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -219,8 +219,8 @@ static void sg_device_destroy(struct kref *kref); #define SZ_SG_REQ_INFO sizeof(sg_req_info_t) #define sg_printk(prefix, sdp, fmt, a...) \ - sdev_printk(prefix, (sdp)->device, "[%s] " fmt, \ - (sdp)->disk->disk_name, ##a) + sdev_prefix_printk(prefix, (sdp)->device, \ + (sdp)->disk->disk_name, fmt, ##a) static int sg_allow_access(struct file *filp, unsigned char *cmd) { diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index 1d1f6f416c59..1de33719ad8e 100644 --- a/drivers/scsi/sr.h +++ b/drivers/scsi/sr.h @@ -57,8 +57,7 @@ typedef struct scsi_cd { } Scsi_CD; #define sr_printk(prefix, cd, fmt, a...) \ - sdev_printk(prefix, (cd)->device, "[%s] " fmt, \ - (cd)->cdi.name, ##a) + sdev_prefix_printk(prefix, (cd)->device, (cd)->cdi.name, fmt, ##a) int sr_do_ioctl(Scsi_CD *, struct packet_command *); diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 8d5f8b4f9a22..36ab023793ca 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -314,8 +314,7 @@ static inline char *tape_name(struct scsi_tape *tape) } #define st_printk(prefix, t, fmt, a...) \ - sdev_printk(prefix, (t)->device, "%s: " fmt, \ - tape_name(t), ##a) + sdev_prefix_printk(prefix, (t)->device, tape_name(t), fmt, ##a) #ifdef DEBUG #define DEBC_printk(t, fmt, a...) \ if (debugging) { st_printk(ST_DEB_MSG, t, fmt, ##a ); } diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 27ecee73bd72..0b18a097c1ba 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -244,6 +244,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, \ -- cgit v1.2.3 From d811b848ebb78a1135658aa20a80e31994df47f7 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:45 +0200 Subject: scsi: use sdev as argument for sense code printing We should be using the standard dev_printk() variants for sense code printing. [hch: remove __scsi_print_sense call in xen-scsiback, Acked by Juergen] [hch: folded bracing fix from Dan Carpenter] Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/53c700.c | 2 +- drivers/scsi/ch.c | 2 +- drivers/scsi/constants.c | 120 ++++++++++++++++++++++---------------------- 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 +- drivers/scsi/ufs/ufshcd.c | 4 +- drivers/usb/storage/debug.c | 10 ++-- drivers/xen/xen-scsiback.c | 4 -- include/scsi/scsi_dbg.h | 17 ++++--- include/scsi/scsi_eh.h | 2 +- 18 files changed, 107 insertions(+), 98 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index fabd4be2c985..68bf423008a4 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 52060e72b75d..53621a34c5f9 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -206,7 +206,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 2f447075adbb..9065b6f8f51b 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); @@ -1360,8 +1362,10 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { for (i = 0; additional2[i].fmt; i++) { if (additional2[i].code1 == asc && ascq >= additional2[i].code2_min && - ascq <= additional2[i].code2_max) - return additional2[i].fmt; + ascq <= additional2[i].code2_max) { + *fmt = additional2[i].fmt; + return additional2[i].str; + } } #endif return NULL; @@ -1369,49 +1373,53 @@ 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(const struct scsi_device *sdev, const char *name, + unsigned char asc, unsigned char ascq) { - const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); + const char *extd_sense_fmt = NULL; + const char *extd_sense_str = scsi_extd_sense_format(asc, ascq, + &extd_sense_fmt); + + if (extd_sense_str) { + if (extd_sense_fmt) + sdev_prefix_printk(KERN_INFO, sdev, name, + "Add. Sense: %s (%s%x)", + extd_sense_str, extd_sense_fmt, + ascq); + else + sdev_prefix_printk(KERN_INFO, sdev, name, + "Add. Sense: %s", extd_sense_str); - 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); } else { - if (asc >= 0x80) - printk("<> ASC=0x%x ASCQ=0x%x", asc, - ascq); - if (ascq >= 0x80) - printk("ASC=0x%x <> ASCQ=0x%x", asc, - ascq); - else - printk("ASC=0x%x ASCQ=0x%x", asc, ascq); + sdev_prefix_printk(KERN_INFO, sdev, name, + "%sASC=0x%x %sASCQ=0x%x\n", + asc >= 0x80 ? "<> " : "", asc, + ascq >= 0x80 ? "<> " : "", ascq); } - - printk("\n"); } EXPORT_SYMBOL(scsi_show_extd_sense); void -scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr) +scsi_show_sense_hdr(const struct scsi_device *sdev, const char *name, + const struct scsi_sense_hdr *sshdr) { const char *sense_txt; sense_txt = scsi_sense_key_string(sshdr->sense_key); if (sense_txt) - printk("Sense Key : %s ", sense_txt); + sdev_prefix_printk(KERN_INFO, sdev, name, + "Sense Key : %s [%s]%s\n", sense_txt, + scsi_sense_is_deferred(sshdr) ? + "deferred" : "current", + sshdr->response_code >= 0x72 ? + " [descriptor]" : ""); else - printk("Sense Key : 0x%x ", sshdr->sense_key); - - printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " : - "[current] "); - - if (sshdr->response_code >= 0x72) - printk("[descriptor]"); - - printk("\n"); + sdev_prefix_printk(KERN_INFO, sdev, name, + "Sense Key : 0x%x [%s]%s", sshdr->sense_key, + scsi_sense_is_deferred(sshdr) ? + "deferred" : "current", + sshdr->response_code >= 0x72 ? + " [descriptor]" : ""); } EXPORT_SYMBOL(scsi_show_sense_hdr); @@ -1419,12 +1427,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr); * Print normalized SCSI sense header with a prefix. */ void -scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) +scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name, + const struct scsi_sense_hdr *sshdr) { - printk(KERN_INFO "%s: ", name); - scsi_show_sense_hdr(sshdr); - printk(KERN_INFO "%s: ", name); - scsi_show_extd_sense(sshdr->asc, sshdr->ascq); + scsi_show_sense_hdr(sdev, name, sshdr); + scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq); } EXPORT_SYMBOL(scsi_print_sense_hdr); @@ -1513,33 +1520,26 @@ scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len, } /* Normalize and print sense buffer with name prefix */ -void __scsi_print_sense(const char *name, const unsigned char *sense_buffer, - int sense_len) +void __scsi_print_sense(const struct scsi_device *sdev, const char *name, + const unsigned char *sense_buffer, int sense_len) { struct scsi_sense_hdr sshdr; - printk(KERN_INFO "%s: ", name); scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); - scsi_show_sense_hdr(&sshdr); + scsi_show_sense_hdr(sdev, name, &sshdr); scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); - printk(KERN_INFO "%s: ", name); - scsi_show_extd_sense(sshdr.asc, sshdr.ascq); + scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq); } EXPORT_SYMBOL(__scsi_print_sense); /* Normalize and print sense buffer in SCSI command */ -void scsi_print_sense(char *name, struct scsi_cmnd *cmd) +void scsi_print_sense(const struct scsi_cmnd *cmd) { - struct scsi_sense_hdr sshdr; + struct gendisk *disk = cmd->request->rq_disk; + const char *disk_name = disk ? disk->disk_name : NULL; - scmd_printk(KERN_INFO, cmd, " "); - scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, - &sshdr); - scsi_show_sense_hdr(&sshdr); - scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, - &sshdr); - scmd_printk(KERN_INFO, cmd, " "); - scsi_show_extd_sense(sshdr.asc, sshdr.ascq); + __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer, + SCSI_SENSE_BUFFERSIZE); } EXPORT_SYMBOL(scsi_print_sense); diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index dff37a250d79..3d0d13c4da15 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -259,9 +259,10 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt) SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n", - name, scode, sense[12], sense[13]); + name, scode, sense[12], sense[13]); if (cmdstatp->have_sense) - __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); + __scsi_print_sense(STp->device, name, + SRpnt->sense, SCSI_SENSE_BUFFERSIZE); } else #endif @@ -275,7 +276,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt) SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ if (cmdstatp->have_sense) { printk(KERN_WARNING "%s:W: Command with sense data:\n", name); - __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); + __scsi_print_sense(STp->device, name, + SRpnt->sense, SCSI_SENSE_BUFFERSIZE); } else { static int notyetprinted = 1; diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 79c77b485a67..32eaac03cf4e 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -606,7 +606,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) scsi_print_result(cmd); scsi_print_command(cmd); if (status_byte(cmd->result) & CHECK_CONDITION) - scsi_print_sense("", cmd); + scsi_print_sense(cmd); if (level > 3) scmd_printk(KERN_INFO, cmd, "scsi host busy %d failed %d\n", diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 0ed666112b4f..0084f0b21a91 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1180,7 +1180,7 @@ int scsi_eh_get_sense(struct list_head *work_q, SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, "sense requested for %p result %x\n", scmd, scmd->result)); - SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense("bh", scmd)); + SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd)); rtn = scsi_decide_disposition(scmd); diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 12fe676d1343..5207274574f5 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -126,7 +126,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, sdev_printk(KERN_INFO, sdev, "ioctl_internal_command return code = %x\n", result); - scsi_print_sense_hdr(" ", &sshdr); + scsi_print_sense_hdr(sdev, NULL, &sshdr); break; } } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 389bc6fd19ae..3c96e3923520 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -912,7 +912,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d)) ; else if (!(req->cmd_flags & REQ_QUIET)) - scsi_print_sense("", cmd); + scsi_print_sense(cmd); result = 0; /* BLOCK_PC may have set error */ error = 0; @@ -1041,7 +1041,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) if (!(req->cmd_flags & REQ_QUIET)) { scsi_print_result(cmd); if (driver_byte(result) & DRIVER_SENSE) - scsi_print_sense("", cmd); + scsi_print_sense(cmd); scsi_print_command(cmd); } if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0)) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 52b40b1e8c45..3ae75402809a 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3336,10 +3336,11 @@ module_exit(exit_sd); static void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) { - sd_printk(KERN_INFO, sdkp, " "); - scsi_show_sense_hdr(sshdr); - sd_printk(KERN_INFO, sdkp, " "); - scsi_show_extd_sense(sshdr->asc, sshdr->ascq); + scsi_show_sense_hdr(sdkp->device, + sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr); + scsi_show_extd_sense(sdkp->device, + sdkp->disk ? sdkp->disk->disk_name : NULL, + sshdr->asc, sshdr->ascq); } static void sd_print_result(struct scsi_disk *sdkp, int result) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 55cbc6689d27..2fe2701d86db 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1365,7 +1365,7 @@ sg_rq_end_io(struct request *rq, int uptodate) if ((sdp->sgdebug > 0) && ((CHECK_CONDITION == srp->header.masked_status) || (COMMAND_TERMINATED == srp->header.masked_status))) - __scsi_print_sense(__func__, sense, + __scsi_print_sense(sdp->device, __func__, sense, SCSI_SENSE_BUFFERSIZE); /* Following if statement is a patch supplied by Eric Youngdale */ diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 6389fcff12ec..17e0c2b28a99 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -246,7 +246,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) "CDROM not ready. Make sure there " "is a disc in the drive.\n"); #ifdef DEBUG - scsi_print_sense_hdr("sr", &sshdr); + scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr); #endif err = -ENOMEDIUM; break; @@ -258,14 +258,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) err = -EDRIVE_CANT_DO_THIS; #ifdef DEBUG __scsi_print_command(cgc->cmd); - scsi_print_sense_hdr("sr", &sshdr); + scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr); #endif break; default: sr_printk(KERN_ERR, cd, "CDROM (ioctl) error, command: "); __scsi_print_command(cgc->cmd); - scsi_print_sense_hdr("sr", &sshdr); + scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr); err = -EIO; } } diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 36ab023793ca..63c35ed3c88d 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -381,7 +381,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); if (cmdstatp->have_sense) - __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); + __scsi_print_sense(STp->device, name, + SRpnt->sense, SCSI_SENSE_BUFFERSIZE); } ) /* end DEB */ if (!debugging) { /* Abnormal conditions for tape */ if (!cmdstatp->have_sense) @@ -397,7 +398,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) SRpnt->cmd[0] != MODE_SENSE && SRpnt->cmd[0] != TEST_UNIT_READY) { - __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); + __scsi_print_sense(STp->device, name, + SRpnt->sense, SCSI_SENSE_BUFFERSIZE); } } diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 733e5f759518..37f5fd8ed765 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1097,7 +1097,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request) if (scmnd->result) { if (scsi_normalize_sense(scmnd->sense_buffer, SCSI_SENSE_BUFFERSIZE, &sense_hdr)) - scsi_print_sense_hdr("storvsc", &sense_hdr); + scsi_print_sense_hdr(scmnd->device, "storvsc", + &sense_hdr); } if (vm_srb->srb_status != SRB_STATUS_SUCCESS) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 497c38a4a866..eb3997ed8e73 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4710,8 +4710,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, "START_STOP failed for power mode: %d\n", pwr_mode); scsi_show_result(ret); if (driver_byte(ret) & DRIVER_SENSE) { - scsi_show_sense_hdr(&sshdr); - scsi_show_extd_sense(sshdr.asc, sshdr.ascq); + scsi_show_sense_hdr(sdp, NULL, &sshdr); + scsi_show_extd_sense(sdp, NULL, sshdr.asc, sshdr.ascq); } } diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c index e08f64780e30..66a684a29938 100644 --- a/drivers/usb/storage/debug.c +++ b/drivers/usb/storage/debug.c @@ -164,10 +164,10 @@ void usb_stor_show_sense(const struct us_data *us, unsigned char asc, unsigned char ascq) { - const char *what, *keystr; + const char *what, *keystr, *fmt; keystr = scsi_sense_key_string(key); - what = scsi_extd_sense_format(asc, ascq); + what = scsi_extd_sense_format(asc, ascq, &fmt); if (keystr == NULL) keystr = "(Unknown Key)"; @@ -175,8 +175,10 @@ void usb_stor_show_sense(const struct us_data *us, what = "(unknown ASC/ASCQ)"; usb_stor_dbg(us, "%s: ", keystr); - US_DEBUGPX(what, ascq); - US_DEBUGPX("\n"); + if (fmt) + US_DEBUGPX("%s (%s%x)\n", what, fmt, ascq); + else + US_DEBUGPX("%s\n", what); } int usb_stor_dbg(const struct us_data *us, const char *fmt, ...) diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 3e32146472a5..50610a6acf3d 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -274,10 +274,6 @@ static void scsiback_print_status(char *sense_buffer, int errors, tpg->tport->tport_name, pending_req->v2p->lun, pending_req->cmnd[0], status_byte(errors), msg_byte(errors), host_byte(errors), driver_byte(errors)); - - if (CHECK_CONDITION & status_byte(errors)) - __scsi_print_sense("xen-pvscsi", sense_buffer, - SCSI_SENSE_BUFFERSIZE); } static void scsiback_fast_flush_area(struct vscsibk_pend *req) diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index 5a43a4cd96c6..6cbd179a17cc 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -2,21 +2,26 @@ #define _SCSI_SCSI_DBG_H struct scsi_cmnd; +struct scsi_device; struct scsi_sense_hdr; extern void scsi_print_command(struct scsi_cmnd *); extern void __scsi_print_command(unsigned char *); -extern void scsi_show_extd_sense(unsigned char, unsigned char); -extern void scsi_show_sense_hdr(struct scsi_sense_hdr *); -extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); -extern void scsi_print_sense(char *, struct scsi_cmnd *); -extern void __scsi_print_sense(const char *name, +extern void scsi_show_extd_sense(const struct scsi_device *, const char *, + unsigned char, unsigned char); +extern void scsi_show_sense_hdr(const struct scsi_device *, const char *, + const struct scsi_sense_hdr *); +extern void scsi_print_sense_hdr(const struct scsi_device *, const char *, + const struct scsi_sense_hdr *); +extern void scsi_print_sense(const struct scsi_cmnd *); +extern void __scsi_print_sense(const struct scsi_device *, const char *name, const unsigned char *sense_buffer, int sense_len); extern void scsi_show_result(int); extern void scsi_print_result(struct scsi_cmnd *); extern void scsi_print_status(unsigned char); extern const char *scsi_sense_key_string(unsigned char); -extern const char *scsi_extd_sense_format(unsigned char, unsigned char); +extern const char *scsi_extd_sense_format(unsigned char, unsigned char, + const char **); #endif /* _SCSI_SCSI_DBG_H */ diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 49af14ad5288..5e598f01143c 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -47,7 +47,7 @@ extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, extern int 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 int scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr) { return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); } -- cgit v1.2.3 From 2e120a5762a0f9c8dad25f04bdfdf374ff890d2e Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:46 +0200 Subject: acornscsi: use scsi_print_command() Update acornscsi to use scsi_print_command() instead of the underscore version and use scmd_printk() in acornscsi_done(). This will add correct device annotations in the resulting message. And we should be using set_host_byte() for setting the final result. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/arm/acornscsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index d89b9b4deb3c..deaaf84989cd 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -850,13 +850,13 @@ 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", SCpnt->result); + scsi_print_command(SCpnt); acornscsi_dumpdma(host, "done"); - acornscsi_dumplog(host, SCpnt->device->id); - SCpnt->result &= 0xffff; - SCpnt->result |= DID_ERROR << 16; + acornscsi_dumplog(host, SCpnt->device->id); + set_host_byte(SCpnt, DID_ERROR); } } } -- cgit v1.2.3 From 279c43b30b82c8d509e4222ffdfa8b552a5f2a73 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:47 +0200 Subject: fas216: return DID_ERROR for incomplete data transfer fas216 returns DID_BAD_TARGET for an incomplete data transfer. The midlayer uses DID_BAD_TARGET to signal a non-existing or not reachable target. So we should rather be using DID_ERROR here. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/arm/fas216.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 71cfb1e504c4..7fc6fd30593d 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2085,8 +2085,7 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) 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; + set_host_byte(SCpnt, DID_ERROR); goto request_sense; } } -- cgit v1.2.3 From e04ca9078ef5d32951a68b1e97aef4b059d68fdc Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:48 +0200 Subject: fas216: update logging messages Update logging messages to use dev_printk() variants for correct device annotations. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/arm/fas216.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 7fc6fd30593d..cea34633b90a 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,11 @@ 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); set_host_byte(SCpnt, DID_ERROR); goto request_sense; } @@ -2157,12 +2155,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); } /* @@ -2663,8 +2660,7 @@ int fas216_eh_host_reset(struct scsi_cmnd *SCpnt) fas216_checkmagic(info); - printk("scsi%d.%c: %s: resetting host\n", - info->host->host_no, '0' + SCpnt->device->id, __func__); + fas216_log(info, LOG_ERROR, "resetting host"); /* * Reset the SCSI chip. -- cgit v1.2.3 From 7d170907191ff42d1624fc4a55c2f2400ffec07a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:49 +0200 Subject: 53c700: remove scsi_print_sense() usage The 53c700 driver would be using scsi_print_sense() in a debug statement, which was never compiled in. Plus the same information can get retrieved with logging. So remove it. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/53c700.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 68bf423008a4..179a24ec7561 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -592,19 +592,14 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata, hostdata->cmd = NULL; if(SCp != NULL) { - struct NCR_700_command_slot *slot = + struct NCR_700_command_slot *slot = (struct NCR_700_command_slot *)SCp->host_scribble; - + dma_unmap_single(hostdata->dev, slot->pCmd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); if (slot->flags == NCR_700_FLAG_AUTOSENSE) { char *cmnd = NCR_700_get_sense_cmnd(SCp->device); -#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(SCp); -#endif dma_unmap_single(hostdata->dev, slot->dma_handle, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); /* restore the old result if the request sense was -- cgit v1.2.3 From 149d18cc2143079ac5fc4e61bc53bb532b8eed26 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:50 +0200 Subject: 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 Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 9065b6f8f51b..d7b6e4bfa55c 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1436,26 +1436,21 @@ scsi_print_sense_hdr(const 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(const unsigned char *sense_buffer, int sense_len) { - int k, num, res; - - 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]); + int k, num; + + 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("\n"); - return; + printk("%02x ", sense_buffer[k]); } + printk("\n"); + return; } static void @@ -1525,7 +1520,10 @@ void __scsi_print_sense(const 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(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); -- cgit v1.2.3 From 15c75f8a6d570e1d22594fe7f1cdb45360651a60 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:51 +0200 Subject: 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 Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 62 ------------------------------------------------ 1 file changed, 62 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index d7b6e4bfa55c..94c0642e2874 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1453,67 +1453,6 @@ scsi_dump_sense_buffer(const unsigned char *sense_buffer, int sense_len) return; } -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(const struct scsi_device *sdev, const char *name, const unsigned char *sense_buffer, int sense_len) @@ -1525,7 +1464,6 @@ void __scsi_print_sense(const 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); -- cgit v1.2.3 From 4753cbc0a1286a60d2f859a7056f8e4873f494c8 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:52 +0200 Subject: scsi: use 'bool' as return value for scsi_normalize_sense() Convert scsi_normalize_sense() and friends to return 'bool' instead of an integer. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Reviewed-by: Yoshihiro Yunomae Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_error.c | 16 ++++++++-------- drivers/scsi/scsi_lib.c | 2 +- include/scsi/scsi_eh.h | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 0084f0b21a91..ab570f5cb6bb 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2422,20 +2422,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) { /* @@ -2465,12 +2465,12 @@ 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, - struct scsi_sense_hdr *sshdr) +bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd, + struct scsi_sense_hdr *sshdr) { return scsi_normalize_sense(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, sshdr); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3c96e3923520..30f51c11a279 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -831,7 +831,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 5e598f01143c..256248141322 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -27,10 +27,10 @@ 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(const struct scsi_sense_hdr *sshdr) { if (!sshdr) - return 0; + return false; return (sshdr->response_code & 0x70) == 0x70; } @@ -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(const struct scsi_cmnd *cmd, + struct scsi_sense_hdr *sshdr); -static inline int scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr) +static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr) { return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); } -- cgit v1.2.3 From 7ac7076344d90b27e0b6dcbe1380b0841f70859b Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:53 +0200 Subject: scsi: remove scsi_print_status() Last caller is gone, so we can remove it. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- 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 94c0642e2874..885c559164d0 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 6cbd179a17cc..386474ee53a1 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -19,7 +19,6 @@ extern void __scsi_print_sense(const 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 **); -- cgit v1.2.3 From 6033f97919383b51ba6be74fbc1071ba934f9716 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:54 +0200 Subject: scsi: implement scsi_opcode_sa_name Implement a lookup array for SERVICE ACTION commands instead of hardcoding it in a large switch statement. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 131 +++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 78 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 885c559164d0..6d2f316d0255 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -244,102 +244,76 @@ 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 opcode; + 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}, +}; + +static bool scsi_opcode_sa_name(int opcode, int service_action, + const char **sa_name) { - int k; + struct sa_name_list *sa_name_ptr; + const struct value_name_pair *arr = NULL; + int arr_sz, k; + + for (sa_name_ptr = sa_names_arr; sa_name_ptr->arr; ++sa_name_ptr) { + if (sa_name_ptr->opcode == opcode) { + arr = sa_name_ptr->arr; + arr_sz = sa_name_ptr->arr_sz; + break; + } + } + if (!arr) + return false; for (k = 0; k < arr_sz; ++k, ++arr) { if (service_action == arr->value) break; } - return (k < arr_sz) ? arr->name : NULL; + if (k < arr_sz) + *sa_name = arr->name; + + return true; } /* attempt to guess cdb length if cdb_len==0 . No trailing linefeed. */ static void print_opcode_name(unsigned char * cdbp, int cdb_len) { int sa, len, cdb0; - int fin_name = 0; - const char * name; + const char *name = NULL; cdb0 = cdbp[0]; - switch(cdb0) { - case VARIABLE_LENGTH_CMD: + if (cdb0 == VARIABLE_LENGTH_CMD) { len = scsi_varlen_cdb_length(cdbp); if (len < 10) { printk("short variable length command, " "len=%d ext_len=%d", len, cdb_len); - break; + return; } sa = (cdbp[8] << 8) + cdbp[9]; - name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ, - sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); - - if ((cdb_len > 0) && (len != cdb_len)) - printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len); - - break; - case MAINTENANCE_IN: - sa = cdbp[1] & 0x1f; - name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); - fin_name = 1; - break; - case MAINTENANCE_OUT: - sa = cdbp[1] & 0x1f; - name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa); - fin_name = 1; - break; - case PERSISTENT_RESERVE_IN: - sa = cdbp[1] & 0x1f; - name = get_sa_name(pr_in_arr, PR_IN_SZ, sa); - fin_name = 1; - break; - case PERSISTENT_RESERVE_OUT: - sa = cdbp[1] & 0x1f; - name = get_sa_name(pr_out_arr, PR_OUT_SZ, sa); - fin_name = 1; - break; - case SERVICE_ACTION_IN_12: - sa = cdbp[1] & 0x1f; - name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa); - fin_name = 1; - break; - case SERVICE_ACTION_OUT_12: - sa = cdbp[1] & 0x1f; - name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa); - fin_name = 1; - break; - case SERVICE_ACTION_BIDIRECTIONAL: - sa = cdbp[1] & 0x1f; - name = get_sa_name(serv_bidi_arr, SERV_BIDI_SZ, sa); - fin_name = 1; - break; - case SERVICE_ACTION_IN_16: - sa = cdbp[1] & 0x1f; - name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa); - fin_name = 1; - break; - case SERVICE_ACTION_OUT_16: - sa = cdbp[1] & 0x1f; - name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa); - fin_name = 1; - break; - case THIRD_PARTY_COPY_IN: - sa = cdbp[1] & 0x1f; - name = get_sa_name(tpc_in_arr, TPC_IN_SZ, sa); - fin_name = 1; - break; - case THIRD_PARTY_COPY_OUT: + } else { sa = cdbp[1] & 0x1f; - name = get_sa_name(tpc_out_arr, TPC_OUT_SZ, sa); - fin_name = 1; - break; - default: + len = cdb_len; + } + + if (!scsi_opcode_sa_name(cdb0, sa, &name)) { if (cdb0 < 0xc0) { name = cdb_byte0_names[cdb0]; if (name) @@ -348,13 +322,14 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) printk("cdb[0]=0x%x (reserved)", cdb0); } else printk("cdb[0]=0x%x (vendor)", cdb0); - break; - } - if (fin_name) { + } else { if (name) printk("%s", name); else printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + + if (cdb_len > 0 && len != cdb_len) + printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len); } } -- cgit v1.2.3 From 234d67781956e5c6891906e4c3b1eb89edddb6be Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:55 +0200 Subject: 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 Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 98 +++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 60 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 6d2f316d0255..3707d8a6377a 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -30,6 +30,16 @@ #define THIRD_PARTY_COPY_IN 0x84 +struct sa_name_list { + int opcode; + const struct value_name_pair *arr; + int arr_sz; +}; + +struct value_name_pair { + int value; + const char * name; +}; #ifdef CONFIG_SCSI_CONSTANTS static const char * cdb_byte0_names[] = { @@ -102,11 +112,6 @@ static const char * cdb_byte0_names[] = { "Volume set (out), Send DVD structure", }; -struct value_name_pair { - int value; - const char * name; -}; - static const struct value_name_pair maint_in_arr[] = { {0x5, "Report identifying information"}, {0xa, "Report target port groups"}, @@ -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 opcode; - 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}, @@ -266,6 +265,26 @@ static struct sa_name_list sa_names_arr[] = { {0, NULL, 0}, }; +#else /* ifndef CONFIG_SCSI_CONSTANTS */ +static const char *cdb_byte0_names[]; + +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 */ + static bool scsi_opcode_sa_name(int opcode, int service_action, const char **sa_name) { @@ -315,11 +334,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 (ARRAY_SIZE(cdb_byte0_names) > 1) { + 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 { @@ -333,50 +355,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; -- cgit v1.2.3 From 2478a736a7d01e3ef8d273e8fc5b11b6ed9af3ea Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:56 +0200 Subject: 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 Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 3707d8a6377a..dc1b18c821ed 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -29,6 +29,7 @@ #define THIRD_PARTY_COPY_OUT 0x83 #define THIRD_PARTY_COPY_IN 0x84 +#define VENDOR_SPECIFIC_CDB 0xc0 struct sa_name_list { int opcode; @@ -266,7 +267,7 @@ static struct sa_name_list sa_names_arr[] = { }; #else /* ifndef CONFIG_SCSI_CONSTANTS */ -static const char *cdb_byte0_names[]; +static const char *cdb_byte0_names[0]; static struct sa_name_list sa_names_arr[] = { {VARIABLE_LENGTH_CMD, NULL, 0}, @@ -286,12 +287,19 @@ static struct sa_name_list sa_names_arr[] = { #endif /* CONFIG_SCSI_CONSTANTS */ static bool scsi_opcode_sa_name(int opcode, int service_action, - const char **sa_name) + const char **cdb_name, const char **sa_name) { struct sa_name_list *sa_name_ptr; const struct value_name_pair *arr = NULL; int arr_sz, k; + *cdb_name = NULL; + if (opcode >= VENDOR_SPECIFIC_CDB) + return false; + + if (opcode < ARRAY_SIZE(cdb_byte0_names)) + *cdb_name = cdb_byte0_names[opcode]; + for (sa_name_ptr = sa_names_arr; sa_name_ptr->arr; ++sa_name_ptr) { if (sa_name_ptr->opcode == opcode) { arr = sa_name_ptr->arr; @@ -316,7 +324,7 @@ static bool scsi_opcode_sa_name(int opcode, 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) { @@ -332,21 +340,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 (ARRAY_SIZE(cdb_byte0_names) > 1) { - 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 >= VENDOR_SPECIFIC_CDB) 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); -- cgit v1.2.3 From a9a47bf58ac1d5525ae99922e055d8de87eeae78 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:57 +0200 Subject: scsi: repurpose the last argument from print_opcode_name() print_opcode_name() was only ever called with a '0' argument from LLDDs and ULDs which were _not_ supporting variable length CDBs, so the 'if' clause was never triggered. Instead we should be using the last argument to specify the cdb length to avoid accidental overflow when reading the cdb buffer. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/arm/fas216.c | 2 +- drivers/scsi/ch.c | 24 +++++++++++++----------- drivers/scsi/constants.c | 25 ++++++++++--------------- drivers/scsi/sr_ioctl.c | 4 ++-- include/scsi/scsi_dbg.h | 2 +- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index cea34633b90a..d2581cb41ec8 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2424,7 +2424,7 @@ 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); + __scsi_print_command(SCpnt->cmnd, SCpnt->cmd_len); print_debug_list(); fas216_dumpstate(info); diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 53621a34c5f9..226ef771efff 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -182,7 +182,7 @@ static int ch_find_errno(struct scsi_sense_hdr *sshdr) } static int -ch_do_scsi(scsi_changer *ch, unsigned char *cmd, +ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, void *buffer, unsigned buflength, enum dma_data_direction direction) { @@ -196,7 +196,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, errno = 0; if (debug) { DPRINTK("command: "); - __scsi_print_command(cmd); + __scsi_print_command(cmd, cmd_len); } result = scsi_execute_req(ch->device, cmd, direction, buffer, @@ -257,7 +257,8 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data) cmd[3] = elem & 0xff; cmd[5] = 1; cmd[9] = 255; - if (0 == (result = ch_do_scsi(ch, cmd, buffer, 256, DMA_FROM_DEVICE))) { + if (0 == (result = ch_do_scsi(ch, cmd, 12, + buffer, 256, DMA_FROM_DEVICE))) { if (((buffer[16] << 8) | buffer[17]) != elem) { DPRINTK("asked for element 0x%02x, got 0x%02x\n", elem,(buffer[16] << 8) | buffer[17]); @@ -287,7 +288,7 @@ ch_init_elem(scsi_changer *ch) memset(cmd,0,sizeof(cmd)); cmd[0] = INITIALIZE_ELEMENT_STATUS; cmd[1] = (ch->device->lun & 0x7) << 5; - err = ch_do_scsi(ch, cmd, NULL, 0, DMA_NONE); + err = ch_do_scsi(ch, cmd, 6, NULL, 0, DMA_NONE); VPRINTK(KERN_INFO, "... finished\n"); return err; } @@ -309,10 +310,10 @@ ch_readconfig(scsi_changer *ch) cmd[1] = (ch->device->lun & 0x7) << 5; cmd[2] = 0x1d; cmd[4] = 255; - result = ch_do_scsi(ch, cmd, buffer, 255, DMA_FROM_DEVICE); + result = ch_do_scsi(ch, cmd, 10, buffer, 255, DMA_FROM_DEVICE); if (0 != result) { cmd[1] |= (1<<3); - result = ch_do_scsi(ch, cmd, buffer, 255, DMA_FROM_DEVICE); + result = ch_do_scsi(ch, cmd, 10, buffer, 255, DMA_FROM_DEVICE); } if (0 == result) { ch->firsts[CHET_MT] = @@ -437,7 +438,7 @@ ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate) cmd[4] = (elem >> 8) & 0xff; cmd[5] = elem & 0xff; cmd[8] = rotate ? 1 : 0; - return ch_do_scsi(ch, cmd, NULL, 0, DMA_NONE); + return ch_do_scsi(ch, cmd, 10, NULL, 0, DMA_NONE); } static int @@ -458,7 +459,7 @@ ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate) cmd[6] = (dest >> 8) & 0xff; cmd[7] = dest & 0xff; cmd[10] = rotate ? 1 : 0; - return ch_do_scsi(ch, cmd, NULL,0, DMA_NONE); + return ch_do_scsi(ch, cmd, 12, NULL,0, DMA_NONE); } static int @@ -484,7 +485,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src, cmd[9] = dest2 & 0xff; cmd[10] = (rotate1 ? 1 : 0) | (rotate2 ? 2 : 0); - return ch_do_scsi(ch, cmd, NULL,0, DMA_NONE); + return ch_do_scsi(ch, cmd, 12, NULL, 0, DMA_NONE); } static void @@ -534,7 +535,7 @@ ch_set_voltag(scsi_changer *ch, u_int elem, memcpy(buffer,tag,32); ch_check_voltag(buffer); - result = ch_do_scsi(ch, cmd, buffer, 256, DMA_TO_DEVICE); + result = ch_do_scsi(ch, cmd, 12, buffer, 256, DMA_TO_DEVICE); kfree(buffer); return result; } @@ -765,7 +766,8 @@ static long ch_ioctl(struct file *file, ch_cmd[5] = 1; ch_cmd[9] = 255; - result = ch_do_scsi(ch, ch_cmd, buffer, 256, DMA_FROM_DEVICE); + result = ch_do_scsi(ch, ch_cmd, 12, + buffer, 256, DMA_FROM_DEVICE); if (!result) { cge.cge_status = buffer[18]; cge.cge_flags = 0; diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index dc1b18c821ed..a84ced0de02b 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -320,25 +320,21 @@ static bool scsi_opcode_sa_name(int opcode, 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) +static void print_opcode_name(const unsigned char *cdbp, size_t cdb_len) { - int sa, len, cdb0; + int sa, cdb0; 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); + if (cdb_len < 10) { + printk("short variable length command, len=%zu", + cdb_len); return; } sa = (cdbp[8] << 8) + cdbp[9]; - } else { + } else sa = cdbp[1] & 0x1f; - len = cdb_len; - } if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) { if (cdb_name) @@ -356,18 +352,17 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) printk("%s, sa=0x%x", cdb_name, sa); 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); } } -void __scsi_print_command(unsigned char *cdb) +void __scsi_print_command(const unsigned char *cdb, size_t cdb_len) { int k, len; - print_opcode_name(cdb, 0); + print_opcode_name(cdb, cdb_len); len = scsi_command_size(cdb); + if (cdb_len < len) + len = cdb_len; /* print out all bytes in cdb */ for (k = 0; k < len; ++k) printk(" %02x", cdb[k]); diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 17e0c2b28a99..fb929fac22ba 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -257,14 +257,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) /* sense: Invalid command operation code */ err = -EDRIVE_CANT_DO_THIS; #ifdef DEBUG - __scsi_print_command(cgc->cmd); + __scsi_print_command(cgc->cmd, CDROM_PACKET_SIZE); scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr); #endif break; default: sr_printk(KERN_ERR, cd, "CDROM (ioctl) error, command: "); - __scsi_print_command(cgc->cmd); + __scsi_print_command(cgc->cmd, CDROM_PACKET_SIZE); scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr); err = -EIO; } diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index 386474ee53a1..81d041822229 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -6,7 +6,7 @@ struct scsi_device; struct scsi_sense_hdr; extern void scsi_print_command(struct scsi_cmnd *); -extern void __scsi_print_command(unsigned char *); +extern void __scsi_print_command(const unsigned char *, size_t); extern void scsi_show_extd_sense(const struct scsi_device *, const char *, unsigned char, unsigned char); extern void scsi_show_sense_hdr(const struct scsi_device *, const char *, -- cgit v1.2.3 From 1fa6b5fbba8c7d4d0cbc428efc4838b813046420 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:58 +0200 Subject: scsi: Remove scsi_print_command when calling abort Calling scsi_print_command should not be necessary during abort; if the information is required one should enable scsi logging. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/53c700.c | 4 +--- drivers/scsi/NCR5380.c | 5 ++--- drivers/scsi/arm/fas216.c | 10 +++------- drivers/scsi/atari_NCR5380.c | 3 +-- drivers/scsi/ps3rom.c | 4 ---- drivers/scsi/stex.c | 9 +++------ drivers/scsi/sun3_NCR5380.c | 3 +-- 7 files changed, 11 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 179a24ec7561..474cc6dc98e2 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -1906,9 +1906,7 @@ NCR_700_abort(struct scsi_cmnd * SCp) { struct NCR_700_command_slot *slot; - scmd_printk(KERN_INFO, SCp, - "New error handler wants to abort command\n\t"); - scsi_print_command(SCp); + scmd_printk(KERN_INFO, SCp, "abort command\n"); slot = (struct NCR_700_command_slot *)SCp->host_scribble; diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 45da3c823322..50873bb6b7ee 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -2666,9 +2666,8 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { struct Scsi_Host *instance = cmd->device->host; struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; Scsi_Cmnd *tmp, **prev; - - printk(KERN_WARNING "scsi%d : aborting command\n", instance->host_no); - scsi_print_command(cmd); + + scmd_printk(KERN_WARNING, cmd, "aborting command\n"); NCR5380_print_status(instance); diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index d2581cb41ec8..e64c3af7c1a0 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2423,14 +2423,11 @@ 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, SCpnt->cmd_len); + scmd_printk(KERN_WARNING, SCpnt, "abort command\n"); print_debug_list(); fas216_dumpstate(info); - printk(KERN_WARNING "scsi%d: abort %p ", info->host->host_no, SCpnt); - switch (fas216_find_command(info, SCpnt)) { /* * We found the command, and cleared it out. Either @@ -2438,7 +2435,7 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt) * target, or the busylun bit is not set. */ case res_success: - printk("success\n"); + scmd_printk(KERN_WARNING, SCpnt, "abort %p success\n", SCpnt); result = SUCCESS; break; @@ -2448,14 +2445,13 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt) * if the bus is free. */ case res_hw_abort: - /* * We are unable to abort the command for some reason. */ default: case res_failed: - printk("failed\n"); + scmd_printk(KERN_WARNING, SCpnt, "abort %p failed\n", SCpnt); break; } diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 79e6f045c2a9..229c61bfbc6b 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -2623,8 +2623,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd) Scsi_Cmnd *tmp, **prev; unsigned long flags; - printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO); - scsi_print_command(cmd); + scmd_printk(KERN_NOTICE, cmd, "aborting command\n"); NCR5380_print_status(instance); diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c index ef23fabe3924..b3b48b5a984c 100644 --- a/drivers/scsi/ps3rom.c +++ b/drivers/scsi/ps3rom.c @@ -220,10 +220,6 @@ static int ps3rom_queuecommand_lck(struct scsi_cmnd *cmd, unsigned char opcode; int res; -#ifdef DEBUG - scsi_print_command(cmd); -#endif - priv->curr_cmd = cmd; cmd->scsi_done = done; diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 1aa4befcfbd0..713af13b858e 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -1162,9 +1162,7 @@ static int stex_abort(struct scsi_cmnd *cmd) int result = SUCCESS; unsigned long flags; - printk(KERN_INFO DRV_NAME - "(%s): aborting command\n", pci_name(hba->pdev)); - scsi_print_command(cmd); + scmd_printk(KERN_INFO, cmd, "aborting command\n"); base = hba->mmio_base; spin_lock_irqsave(host->host_lock, flags); @@ -1352,9 +1350,8 @@ static int stex_reset(struct scsi_cmnd *cmd) hba = (struct st_hba *) &cmd->device->host->hostdata[0]; - printk(KERN_INFO DRV_NAME - "(%s): resetting host\n", pci_name(hba->pdev)); - scsi_print_command(cmd); + shost_printk(KERN_INFO, cmd->device->host, + "resetting host\n"); return stex_do_reset(hba) ? FAILED : SUCCESS; } diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 1a2367a1b1f2..3abd796b9893 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -2608,8 +2608,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd) struct scsi_cmnd *tmp, **prev; unsigned long flags; - printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO); - scsi_print_command(cmd); + scmd_printk(KERN_NOTICE, cmd, "aborting command\n"); NCR5380_print_status (instance); -- cgit v1.2.3 From 3cc958cc19278de5fa090f3f7f1ed48b0170980a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:26:59 +0200 Subject: scsi: separate out scsi_(host|driver)byte_string() Export functions for later use. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 58 ++++++++++++++++++++++++++++++++++++------------ include/scsi/scsi_dbg.h | 2 ++ 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index a84ced0de02b..541a8620929c 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1407,38 +1407,68 @@ static const char * const hostbyte_table[]={ "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE", "DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", "DID_NEXUS_FAILURE" }; -#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) static const char * const driverbyte_table[]={ "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", "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_hostbyte_string(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 < ARRAY_SIZE(hostbyte_table)) + hb_string = hostbyte_table[hb]; +#endif + return hb_string; } +EXPORT_SYMBOL(scsi_hostbyte_string); -#else +const char *scsi_driverbyte_string(int result) +{ + const char *db_string = NULL; +#ifdef CONFIG_SCSI_CONSTANTS + int db = driver_byte(result); + + if (db < ARRAY_SIZE(driverbyte_table)) + db_string = driverbyte_table[db]; +#endif + return db_string; +} +EXPORT_SYMBOL(scsi_driverbyte_string); 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_hostbyte_string(result); + const char *db_string = scsi_driverbyte_string(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_hostbyte_string(cmd->result); + const char *db_string = scsi_driverbyte_string(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 81d041822229..50f4d8542ece 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -19,6 +19,8 @@ extern void __scsi_print_sense(const 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_hostbyte_string(int); +extern const char *scsi_driverbyte_string(int); extern const char *scsi_sense_key_string(unsigned char); extern const char *scsi_extd_sense_format(unsigned char, unsigned char, const char **); -- cgit v1.2.3 From ef61329db7b8b4326b1c4e603806b2754fd2a692 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:27:00 +0200 Subject: scsi: remove scsi_show_result() Open-code scsi_print_result in sd.c, and cleanup logging to not print duplicate informations. Also remove the call to scsi_show_result() in ufshcd.c to be consistent with other callers of scsi_execute(). With that we can remove scsi_show_result in constants.c Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 16 --------------- drivers/scsi/sd.c | 50 ++++++++++++++++++++++++----------------------- drivers/scsi/ufs/ufshcd.c | 4 ++-- include/scsi/scsi_dbg.h | 1 - 4 files changed, 28 insertions(+), 43 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 541a8620929c..2893464129b5 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1440,22 +1440,6 @@ const char *scsi_driverbyte_string(int result) } EXPORT_SYMBOL(scsi_driverbyte_string); -void scsi_show_result(int result) -{ - const char *hb_string = scsi_hostbyte_string(result); - const char *db_string = scsi_driverbyte_string(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_hostbyte_string(cmd->result); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3ae75402809a..242f9b177285 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(const struct scsi_disk *, const char *, int); static DEFINE_SPINLOCK(sd_index_lock); static DEFINE_IDA(sd_index_ida); @@ -1492,7 +1492,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) } if (res) { - sd_print_result(sdkp, res); + sd_print_result(sdkp, "Synchronize Cache(10) failed", res); if (driver_byte(res) & DRIVER_SENSE) sd_print_sense_hdr(sdkp, &sshdr); @@ -1713,17 +1713,6 @@ static int sd_done(struct scsi_cmnd *SCpnt) if (sense_valid) sense_deferred = scsi_sense_is_deferred(&sshdr); } -#ifdef CONFIG_SCSI_LOGGING - SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt)); - 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)); - } -#endif sdkp->medium_access_timed_out = 0; if (driver_byte(result) != DRIVER_SENSE && @@ -1778,6 +1767,10 @@ static int sd_done(struct scsi_cmnd *SCpnt) break; } out: + SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt, + "sd_done: completed %d of %d bytes\n", + good_bytes, scsi_bufflen(SCpnt))); + if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt)) sd_dif_complete(SCpnt, good_bytes); @@ -1833,12 +1826,12 @@ 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, "Test Unit Ready failed", + the_result); } break; } - + /* * The device does not want the automatic start to be issued. */ @@ -1954,7 +1947,6 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, struct scsi_sense_hdr *sshdr, int sense_valid, int the_result) { - sd_print_result(sdkp, the_result); if (driver_byte(the_result) & DRIVER_SENSE) sd_print_sense_hdr(sdkp, sshdr); else @@ -2035,7 +2027,7 @@ 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"); + sd_print_result(sdkp, "Read Capacity(16) failed", the_result); read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); return -EINVAL; } @@ -2117,7 +2109,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, } while (the_result && retries); if (the_result) { - sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n"); + sd_print_result(sdkp, "Read Capacity(10) failed", the_result); read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); return -EINVAL; } @@ -3141,8 +3133,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) res = scsi_execute_req_flags(sdp, cmd, DMA_NONE, NULL, 0, &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL, REQ_PM); if (res) { - sd_printk(KERN_WARNING, sdkp, "START_STOP FAILED\n"); - sd_print_result(sdkp, res); + sd_print_result(sdkp, "Start/Stop Unit failed", res); if (driver_byte(res) & DRIVER_SENSE) sd_print_sense_hdr(sdkp, &sshdr); if (scsi_sense_valid(&sshdr) && @@ -3343,9 +3334,20 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp, sshdr->asc, sshdr->ascq); } -static void sd_print_result(struct scsi_disk *sdkp, int result) +static void sd_print_result(const struct scsi_disk *sdkp, const char *msg, + int result) { - sd_printk(KERN_INFO, sdkp, " "); - scsi_show_result(result); + const char *hb_string = scsi_hostbyte_string(result); + const char *db_string = scsi_driverbyte_string(result); + + if (hb_string || db_string) + sd_printk(KERN_INFO, sdkp, + "%s: Result: hostbyte=%s driverbyte=%s\n", msg, + hb_string ? hb_string : "invalid", + db_string ? db_string : "invalid"); + else + sd_printk(KERN_INFO, sdkp, + "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n", + msg, host_byte(result), driver_byte(result)); } diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index eb3997ed8e73..9da319130da5 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4707,8 +4707,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, START_STOP_TIMEOUT, 0, NULL, REQ_PM); if (ret) { sdev_printk(KERN_WARNING, sdp, - "START_STOP failed for power mode: %d\n", pwr_mode); - scsi_show_result(ret); + "START_STOP failed for power mode: %d, result %x\n", + pwr_mode, ret); if (driver_byte(ret) & DRIVER_SENSE) { scsi_show_sense_hdr(sdp, NULL, &sshdr); scsi_show_extd_sense(sdp, NULL, sshdr.asc, sshdr.ascq); diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index 50f4d8542ece..f41a86bc1a8f 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -17,7 +17,6 @@ extern void scsi_print_sense(const struct scsi_cmnd *); extern void __scsi_print_sense(const struct scsi_device *, const char *name, const unsigned char *sense_buffer, int sense_len); -extern void scsi_show_result(int); extern void scsi_print_result(struct scsi_cmnd *); extern const char *scsi_hostbyte_string(int); extern const char *scsi_driverbyte_string(int); -- cgit v1.2.3 From c11c004b1c052fae77d3d0d14462d1f3a4e88d06 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:27:01 +0200 Subject: scsi: simplify scsi_log_(send|completion) Simplify scsi_log_(send|completion) by externalizing scsi_mlreturn_string() and always print the command address. Signed-off-by: Hannes Reinecke Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 41 ++++++++++++++++++++++++++++++++++++++--- drivers/scsi/scsi.c | 43 ++++++------------------------------------- drivers/scsi/scsi_lib.c | 13 ++++++++++--- drivers/scsi/scsi_logging.h | 1 + include/scsi/scsi_dbg.h | 3 ++- 5 files changed, 57 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 2893464129b5..0cf43f6e464b 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1440,19 +1440,54 @@ const char *scsi_driverbyte_string(int result) } EXPORT_SYMBOL(scsi_driverbyte_string); -void scsi_print_result(struct scsi_cmnd *cmd) +#ifdef CONFIG_SCSI_CONSTANTS +#define scsi_mlreturn_name(result) { result, #result } +static const struct value_name_pair scsi_mlreturn_arr[] = { + scsi_mlreturn_name(NEEDS_RETRY), + scsi_mlreturn_name(SUCCESS), + scsi_mlreturn_name(FAILED), + scsi_mlreturn_name(QUEUED), + scsi_mlreturn_name(SOFT_ERROR), + scsi_mlreturn_name(ADD_TO_MLQUEUE), + scsi_mlreturn_name(TIMEOUT_ERROR), + scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED), + scsi_mlreturn_name(FAST_IO_FAIL) +}; +#endif + +const char *scsi_mlreturn_string(int result) +{ +#ifdef CONFIG_SCSI_CONSTANTS + const struct value_name_pair *arr = scsi_mlreturn_arr; + int k; + + for (k = 0; k < ARRAY_SIZE(scsi_mlreturn_arr); ++k, ++arr) { + if (result == arr->value) + return arr->name; + } +#endif + return NULL; +} +EXPORT_SYMBOL(scsi_mlreturn_string); + +void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition) { + const char *mlret_string = scsi_mlreturn_string(disposition); const char *hb_string = scsi_hostbyte_string(cmd->result); const char *db_string = scsi_driverbyte_string(cmd->result); if (hb_string || db_string) scmd_printk(KERN_INFO, cmd, - "Result: hostbyte=%s driverbyte=%s", + "%s%s Result: hostbyte=%s driverbyte=%s", + msg ? msg : "", + mlret_string ? mlret_string : "UNKNOWN", hb_string ? hb_string : "invalid", db_string ? db_string : "invalid"); else scmd_printk(KERN_INFO, cmd, - "Result: hostbyte=0x%02x driverbyte=0x%02x", + "%s%s Result: hostbyte=0x%02x driverbyte=0x%02x", + msg ? msg : "", + mlret_string ? mlret_string : "UNKNOWN", host_byte(cmd->result), driver_byte(cmd->result)); } EXPORT_SYMBOL(scsi_print_result); diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 32eaac03cf4e..bc52bbd97381 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -527,9 +527,9 @@ void scsi_log_send(struct scsi_cmnd *cmd) * * 1: nothing (match completion) * - * 2: log opcode + command of all commands + * 2: log opcode + command of all commands + cmd address * - * 3: same as 2 plus dump cmd address + * 3: same as 2 * * 4: same as 3 plus dump extra junk */ @@ -537,10 +537,8 @@ void scsi_log_send(struct scsi_cmnd *cmd) level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS); if (level > 1) { - scmd_printk(KERN_INFO, cmd, "Send: "); - if (level > 2) - printk("0x%p ", cmd); - printk("\n"); + scmd_printk(KERN_INFO, cmd, + "Send: scmd 0x%p\n", cmd); scsi_print_command(cmd); if (level > 3) { printk(KERN_INFO "buffer = 0x%p, bufflen = %d," @@ -565,7 +563,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) * * 2: same as 1 but for all command completions. * - * 3: same as 2 plus dump cmd address + * 3: same as 2 * * 4: same as 3 plus dump extra junk */ @@ -574,36 +572,7 @@ 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"); - } - scsi_print_result(cmd); + scsi_print_result(cmd, "Done: ", disposition); scsi_print_command(cmd); if (status_byte(cmd->result) & CHECK_CONDITION) scsi_print_sense(cmd); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 30f51c11a279..26a57faf885b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -832,7 +832,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) int error = 0; struct scsi_sense_hdr sshdr; bool sense_valid = false; - int sense_deferred = 0; + int sense_deferred = 0, level = 0; enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY, ACTION_DELAYED_RETRY} action; unsigned long wait_for = (cmd->allowed + 1) * req->timeout; @@ -1038,8 +1038,15 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) switch (action) { case ACTION_FAIL: /* Give up and fail the remainder of the request */ - if (!(req->cmd_flags & REQ_QUIET)) { - scsi_print_result(cmd); + if (unlikely(scsi_logging_level)) + level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, + SCSI_LOG_MLQUEUE_BITS); + /* + * if logging is enabled the failure will be printed + * in scsi_log_completion(), so avoid duplicate messages + */ + if (!level && !(req->cmd_flags & REQ_QUIET)) { + scsi_print_result(cmd, NULL, FAILED); if (driver_byte(result) & DRIVER_SENSE) scsi_print_sense(cmd); scsi_print_command(cmd); diff --git a/drivers/scsi/scsi_logging.h b/drivers/scsi/scsi_logging.h index 1f65139e14f8..7fe64a847143 100644 --- a/drivers/scsi/scsi_logging.h +++ b/drivers/scsi/scsi_logging.h @@ -51,6 +51,7 @@ do { \ } while (0); \ } while (0) #else +#define SCSI_LOG_LEVEL(SHIFT, BITS) 0 #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) #endif /* CONFIG_SCSI_LOGGING */ diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index f41a86bc1a8f..7982795df595 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -17,9 +17,10 @@ extern void scsi_print_sense(const struct scsi_cmnd *); extern void __scsi_print_sense(const struct scsi_device *, const char *name, const unsigned char *sense_buffer, int sense_len); -extern void scsi_print_result(struct scsi_cmnd *); +extern void scsi_print_result(struct scsi_cmnd *, const char *, int); extern const char *scsi_hostbyte_string(int); extern const char *scsi_driverbyte_string(int); +extern const char *scsi_mlreturn_string(int); extern const char *scsi_sense_key_string(unsigned char); extern const char *scsi_extd_sense_format(unsigned char, unsigned char, const char **); -- cgit v1.2.3 From a222b1e2fe4299a01c86ea8ccafbf0a05aeaa5a1 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:27:02 +0200 Subject: scsi: fixup logging messages in scsi_error.c Use the matching scope for logging messages to allow for better command tracing. Signed-off-by: Hannes Reinecke Suggested-by: Robert Elliott Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/hosts.c | 4 +-- drivers/scsi/scsi_error.c | 77 +++++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 6de80e352871..06030e1ad696 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -485,8 +485,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) WQ_UNBOUND | WQ_MEM_RECLAIM, 1, shost->host_no); if (!shost->tmf_work_q) { - printk(KERN_WARNING "scsi%d: failed to create tmf workq\n", - shost->host_no); + shost_printk(KERN_WARNING, shost, + "failed to create tmf workq\n"); goto fail_kthread; } scsi_proc_hostdir_add(shost->hostt); diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ab570f5cb6bb..c2bef46e90e0 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1156,9 +1156,9 @@ int scsi_eh_get_sense(struct list_head *work_q, shost = scmd->device->host; if (scsi_host_eh_past_deadline(shost)) { SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "skip %s, past eh deadline\n", - __func__)); + scmd_printk(KERN_INFO, scmd, + "%s: skip request sense, past eh deadline\n", + current->comm)); break; } if (status_byte(scmd->result) != CHECK_CONDITION) @@ -1265,9 +1265,9 @@ static int scsi_eh_test_devices(struct list_head *cmd_list, /* Push items back onto work_q */ list_splice_init(cmd_list, work_q); SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, sdev->host, - "skip %s, past eh deadline", - __func__)); + sdev_printk(KERN_INFO, sdev, + "%s: skip test device, past eh deadline", + current->comm)); break; } } @@ -1318,21 +1318,20 @@ static int scsi_eh_abort_cmds(struct list_head *work_q, if (scsi_host_eh_past_deadline(shost)) { list_splice_init(&check_list, work_q); SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "skip %s, past eh deadline\n", - __func__)); + scmd_printk(KERN_INFO, scmd, + "%s: skip aborting cmd, past eh deadline\n", + current->comm)); return list_empty(work_q); } SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "%s: aborting cmd: 0x%p\n", - current->comm, scmd)); + scmd_printk(KERN_INFO, scmd, + "%s: aborting cmd\n", current->comm)); rtn = scsi_try_to_abort_cmd(shost->hostt, scmd); if (rtn == FAILED) { SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "%s: aborting cmd failed: 0x%p\n", - current->comm, scmd)); + scmd_printk(KERN_INFO, scmd, + "%s: aborting cmd failed\n", + current->comm)); list_splice_init(&check_list, work_q); return list_empty(work_q); } @@ -1390,9 +1389,9 @@ static int scsi_eh_stu(struct Scsi_Host *shost, shost_for_each_device(sdev, shost) { if (scsi_host_eh_past_deadline(shost)) { SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "skip %s, past eh deadline\n", - __func__)); + sdev_printk(KERN_INFO, sdev, + "%s: skip START_UNIT, past eh deadline\n", + current->comm)); break; } stu_scmd = NULL; @@ -1407,9 +1406,9 @@ static int scsi_eh_stu(struct Scsi_Host *shost, continue; SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "%s: Sending START_UNIT to sdev: 0x%p\n", - current->comm, sdev)); + sdev_printk(KERN_INFO, sdev, + "%s: Sending START_UNIT\n", + current->comm)); if (!scsi_eh_try_stu(stu_scmd)) { if (!scsi_device_online(sdev) || @@ -1423,9 +1422,9 @@ static int scsi_eh_stu(struct Scsi_Host *shost, } } else { SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "%s: START_UNIT failed to sdev:" - " 0x%p\n", current->comm, sdev)); + sdev_printk(KERN_INFO, sdev, + "%s: START_UNIT failed\n", + current->comm)); } } @@ -1456,9 +1455,9 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, shost_for_each_device(sdev, shost) { if (scsi_host_eh_past_deadline(shost)) { SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "skip %s, past eh deadline\n", - __func__)); + sdev_printk(KERN_INFO, sdev, + "%s: skip BDR, past eh deadline\n", + current->comm)); break; } bdr_scmd = NULL; @@ -1472,9 +1471,8 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, continue; SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "%s: Sending BDR sdev: 0x%p\n", - current->comm, sdev)); + sdev_printk(KERN_INFO, sdev, + "%s: Sending BDR\n", current->comm)); rtn = scsi_try_bus_device_reset(bdr_scmd); if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { if (!scsi_device_online(sdev) || @@ -1490,9 +1488,8 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, } } else { SCSI_LOG_ERROR_RECOVERY(3, - shost_printk(KERN_INFO, shost, - "%s: BDR failed sdev: 0x%p\n", - current->comm, sdev)); + sdev_printk(KERN_INFO, sdev, + "%s: BDR failed\n", current->comm)); } } @@ -1528,8 +1525,8 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost, list_splice_init(&tmp_list, work_q); SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, shost, - "skip %s, past eh deadline\n", - __func__)); + "%s: Skip target reset, past eh deadline\n", + current->comm)); return list_empty(work_q); } @@ -1591,8 +1588,8 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost, list_splice_init(&check_list, work_q); SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, shost, - "skip %s, past eh deadline\n", - __func__)); + "%s: skip BRST, past eh deadline\n", + current->comm)); return list_empty(work_q); } @@ -2193,9 +2190,9 @@ int scsi_error_handler(void *data) */ if (!shost->eh_noresume && scsi_autopm_get_host(shost) != 0) { SCSI_LOG_ERROR_RECOVERY(1, - printk(KERN_ERR "Error handler scsi_eh_%d " - "unable to autoresume\n", - shost->host_no)); + shost_printk(KERN_ERR, shost, + "scsi_eh_%d: unable to autoresume\n", + shost->host_no)); continue; } -- cgit v1.2.3 From a3a790dcb2f4dc1d8ebcaa4bf87773b9c6a13174 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:27:03 +0200 Subject: scsi: use shost argument in scsi_eh_prt_fail_stats The EH statistics are per host, so we should be using shost_printk() here. Signed-off-by: Hannes Reinecke Suggested-by: Robert Elliott Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index c2bef46e90e0..44e2576878a3 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -355,7 +355,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost, if (cmd_cancel || cmd_failed) { SCSI_LOG_ERROR_RECOVERY(3, - sdev_printk(KERN_INFO, sdev, + shost_printk(KERN_INFO, shost, "%s: cmds failed: %d, cancel: %d\n", __func__, cmd_failed, cmd_cancel)); -- cgit v1.2.3 From 883a030f989a17b81167f3a181cf93d741fa98b4 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:27:04 +0200 Subject: scsi: document scsi_try_to_abort_cmd scsi_try_to_abort_cmd() should only return SUCCESS, FAILED, or FAST_IO_FAIL. So document that in the function description and simplify the logging message. Signed-off-by: Hannes Reinecke Suggested-by: Christoph Hellwig Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_error.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 44e2576878a3..95c9abb64183 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -157,8 +157,9 @@ 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 %s\n", scmd, + (rtn == FAST_IO_FAIL) ? + "not send" : "failed")); } } @@ -869,7 +870,24 @@ static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd) return rtn; } -static int scsi_try_to_abort_cmd(struct scsi_host_template *hostt, struct scsi_cmnd *scmd) +/** + * scsi_try_to_abort_cmd - Ask host to abort a SCSI command + * @scmd: SCSI cmd used to send a target reset + * + * Return value: + * SUCCESS, FAILED, or FAST_IO_FAIL + * + * Notes: + * SUCCESS does not necessarily indicate that the command + * has been aborted; it only indicates that the LLDDs + * has cleared all references to that command. + * LLDDs should return FAILED only if an abort was required + * but could not be executed. LLDDs should return FAST_IO_FAIL + * if the device is temporarily unavailable (eg due to a + * link down on FibreChannel) + */ +static int scsi_try_to_abort_cmd(struct scsi_host_template *hostt, + struct scsi_cmnd *scmd) { if (!hostt->eh_abort_handler) return FAILED; -- cgit v1.2.3 From b6c92b7e0af575e2b8b05bdf33633cf9e1661cbf Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 30 Oct 2014 09:44:36 +0100 Subject: scsi: correct return values for .eh_abort_handler implementations The .eh_abort_handler needs to return SUCCESS, FAILED, or FAST_IO_FAIL. So fixup all callers to adhere to this requirement. Reviewed-by: Robert Elliott Cc: Signed-off-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.c | 12 ++++++------ drivers/scsi/aha1740.c | 2 +- drivers/scsi/atari_NCR5380.c | 2 +- drivers/scsi/esas2r/esas2r_main.c | 2 +- drivers/scsi/megaraid.c | 8 ++++---- drivers/scsi/sun3_NCR5380.c | 10 +++++----- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 50873bb6b7ee..296c6f53605a 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -2647,14 +2647,14 @@ static void NCR5380_dma_complete(NCR5380_instance * instance) { * * Purpose : abort a command * - * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the - * host byte of the result field to, if zero DID_ABORTED is + * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the + * host byte of the result field to, if zero DID_ABORTED is * used. * - * Returns : 0 - success, -1 on failure. + * Returns : SUCCESS - success, FAILED on failure. * - * XXX - there is no way to abort the command that is currently - * connected, you have to wait for it to complete. If this is + * XXX - there is no way to abort the command that is currently + * connected, you have to wait for it to complete. If this is * a problem, we could implement longjmp() / setjmp(), setjmp() * called where the loop started in NCR5380_main(). * @@ -2703,7 +2703,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { * aborted flag and get back into our main loop. */ - return 0; + return SUCCESS; } #endif diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c index 5f3101797c93..31ace4bef8fe 100644 --- a/drivers/scsi/aha1740.c +++ b/drivers/scsi/aha1740.c @@ -531,7 +531,7 @@ static int aha1740_eh_abort_handler (Scsi_Cmnd *dummy) * quiet as possible... */ - return 0; + return SUCCESS; } static struct scsi_host_template aha1740_template = { diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 229c61bfbc6b..11e93025b87a 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -2607,7 +2607,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) * host byte of the result field to, if zero DID_ABORTED is * used. * - * Returns : 0 - success, -1 on failure. + * Returns : SUCCESS - success, FAILED on failure. * * XXX - there is no way to abort the command that is currently * connected, you have to wait for it to complete. If this is diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 6504a195c874..45aa684f8b74 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1057,7 +1057,7 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd) cmd->scsi_done(cmd); - return 0; + return SUCCESS; } spin_lock_irqsave(&a->queue_lock, flags); diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index ac5d94cfd52f..2485255f3414 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1945,7 +1945,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor) cmd->device->id, (u32)cmd->device->lun); if(list_empty(&adapter->pending_list)) - return FALSE; + return FAILED; list_for_each_safe(pos, next, &adapter->pending_list) { @@ -1968,7 +1968,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor) (aor==SCB_ABORT) ? "ABORTING":"RESET", scb->idx); - return FALSE; + return FAILED; } else { @@ -1993,12 +1993,12 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor) list_add_tail(SCSI_LIST(cmd), &adapter->completed_list); - return TRUE; + return SUCCESS; } } } - return FALSE; + return FAILED; } static inline int diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 3abd796b9893..835bd8dafe0a 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -2590,15 +2590,15 @@ static void NCR5380_reselect (struct Scsi_Host *instance) * Purpose : abort a command * * Inputs : cmd - the struct scsi_cmnd to abort, code - code to set the - * host byte of the result field to, if zero DID_ABORTED is + * host byte of the result field to, if zero DID_ABORTED is * used. * - * Returns : 0 - success, -1 on failure. + * Returns : SUCCESS - success, FAILED on failure. * - * XXX - there is no way to abort the command that is currently - * connected, you have to wait for it to complete. If this is + * XXX - there is no way to abort the command that is currently + * connected, you have to wait for it to complete. If this is * a problem, we could implement longjmp() / setjmp(), setjmp() - * called where the loop started in NCR5380_main(). + * called where the loop started in NCR5380_main(). */ static int NCR5380_abort(struct scsi_cmnd *cmd) -- cgit v1.2.3 From f1569ff1d5ae0ca8598956be632947a88f540e2a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 24 Oct 2014 14:27:07 +0200 Subject: scsi: ratelimit I/O error messages There can be quite a lot of I/O error messages, even on smaller machines. So we need to ratelimit them to not overwhelm logging. Signed-off-by: Hannes Reinecke Tested-by: Robert Elliott Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_lib.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 26a57faf885b..fc0a8a0c0a34 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -1038,18 +1039,25 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) switch (action) { case ACTION_FAIL: /* Give up and fail the remainder of the request */ - if (unlikely(scsi_logging_level)) - level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, - SCSI_LOG_MLQUEUE_BITS); - /* - * if logging is enabled the failure will be printed - * in scsi_log_completion(), so avoid duplicate messages - */ - if (!level && !(req->cmd_flags & REQ_QUIET)) { - scsi_print_result(cmd, NULL, FAILED); - if (driver_byte(result) & DRIVER_SENSE) - scsi_print_sense(cmd); - scsi_print_command(cmd); + if (!(req->cmd_flags & REQ_QUIET)) { + static DEFINE_RATELIMIT_STATE(_rs, + DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + + if (unlikely(scsi_logging_level)) + level = SCSI_LOG_LEVEL(SCSI_LOG_MLCOMPLETE_SHIFT, + SCSI_LOG_MLCOMPLETE_BITS); + + /* + * if logging is enabled the failure will be printed + * in scsi_log_completion(), so avoid duplicate messages + */ + if (!level && __ratelimit(&_rs)) { + scsi_print_result(cmd, NULL, FAILED); + if (driver_byte(result) & DRIVER_SENSE) + scsi_print_sense(cmd); + scsi_print_command(cmd); + } } if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0)) return; -- cgit v1.2.3 From 205fb5f5ba1d8edcf18009998ed05b80b7d186af Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 30 Oct 2014 14:45:11 +0100 Subject: blk-mq: add blk_mq_unique_tag() The queuecommand() callback functions in SCSI low-level drivers need to know which hardware context has been selected by the block layer. Since this information is not available in the request structure, and since passing the hctx pointer directly to the queuecommand callback function would require modification of all SCSI LLDs, add a function to the block layer that allows to query the hardware context index. Signed-off-by: Bart Van Assche Acked-by: Jens Axboe Reviewed-by: Sagi Grimberg Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- block/blk-mq-tag.c | 28 ++++++++++++++++++++++++++++ block/blk-mq.c | 2 ++ include/linux/blk-mq.h | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 8317175a3009..728b9a4d5f56 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -584,6 +584,34 @@ int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int tdepth) return 0; } +/** + * blk_mq_unique_tag() - return a tag that is unique queue-wide + * @rq: request for which to compute a unique tag + * + * The tag field in struct request is unique per hardware queue but not over + * all hardware queues. Hence this function that returns a tag with the + * hardware context index in the upper bits and the per hardware queue tag in + * the lower bits. + * + * Note: When called for a request that is queued on a non-multiqueue request + * queue, the hardware context index is set to zero. + */ +u32 blk_mq_unique_tag(struct request *rq) +{ + struct request_queue *q = rq->q; + struct blk_mq_hw_ctx *hctx; + int hwq = 0; + + if (q->mq_ops) { + hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu); + hwq = hctx->queue_num; + } + + return (hwq << BLK_MQ_UNIQUE_TAG_BITS) | + (rq->tag & BLK_MQ_UNIQUE_TAG_MASK); +} +EXPORT_SYMBOL(blk_mq_unique_tag); + ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page) { char *orig_page = page; diff --git a/block/blk-mq.c b/block/blk-mq.c index 68929bad9a6a..b5896d436fc9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2024,6 +2024,8 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) */ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) { + BUILD_BUG_ON(BLK_MQ_MAX_DEPTH > 1 << BLK_MQ_UNIQUE_TAG_BITS); + if (!set->nr_hw_queues) return -EINVAL; if (!set->queue_depth) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index c9be1589415a..15f7034aa377 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -167,6 +167,23 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, bool reserved); struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag); +enum { + BLK_MQ_UNIQUE_TAG_BITS = 16, + BLK_MQ_UNIQUE_TAG_MASK = (1 << BLK_MQ_UNIQUE_TAG_BITS) - 1, +}; + +u32 blk_mq_unique_tag(struct request *rq); + +static inline u16 blk_mq_unique_tag_to_hwq(u32 unique_tag) +{ + return unique_tag >> BLK_MQ_UNIQUE_TAG_BITS; +} + +static inline u16 blk_mq_unique_tag_to_tag(u32 unique_tag) +{ + return unique_tag & BLK_MQ_UNIQUE_TAG_MASK; +} + struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index); struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int); -- cgit v1.2.3 From efec4b90f1a9b4c80827e4b8c0863334e13b0bf1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 30 Oct 2014 14:45:36 +0100 Subject: scsi: add support for multiple hardware queues Allow a SCSI LLD to declare how many hardware queues it supports by setting Scsi_Host.nr_hw_queues before calling scsi_add_host(). Signed-off-by: Bart Van Assche Reviewed-by: Sagi Grimberg Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- drivers/scsi/scsi_lib.c | 2 +- include/scsi/scsi_host.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fc0a8a0c0a34..38f8c85957b6 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2106,7 +2106,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) memset(&shost->tag_set, 0, sizeof(shost->tag_set)); shost->tag_set.ops = &scsi_mq_ops; - shost->tag_set.nr_hw_queues = 1; + shost->tag_set.nr_hw_queues = shost->nr_hw_queues ? : 1; shost->tag_set.queue_depth = shost->can_queue; shost->tag_set.cmd_size = cmd_size; shost->tag_set.numa_node = NUMA_NO_NODE; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 5e362489ee88..bb9e27815be5 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -638,6 +638,14 @@ struct Scsi_Host { short unsigned int sg_prot_tablesize; unsigned int max_sectors; unsigned long dma_boundary; + /* + * In scsi-mq mode, the number of hardware queues supported by the LLD. + * + * Note: it is assumed that each hardware queue has a queue depth of + * can_queue. In other words, the total queue depth per host + * is nr_hw_queues * can_queue. + */ + unsigned nr_hw_queues; /* * Used to assign serial numbers to the cmds. * Protected by the host lock. -- cgit v1.2.3 From 1ee8e889d946b3b1c2cc8b99e29eac47d1581dfd Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 30 Oct 2014 14:46:00 +0100 Subject: scsi: add support for multiple hardware queues in scsi_(host_)find_tag Modify scsi_find_tag() and scsi_host_find_tag() such that these functions can translate a tag generated by blk_mq_unique_tag(). Signed-off-by: Bart Van Assche Reviewed-by: Martin K. Petersen Signed-off-by: Christoph Hellwig --- include/scsi/scsi_tcq.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 56ed843969ca..7529c6acc231 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -111,18 +111,21 @@ static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg) } static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost, - unsigned int hw_ctx, int tag) + int unique_tag) { - struct request *req; + u16 hwq = blk_mq_unique_tag_to_hwq(unique_tag); + struct request *req = NULL; - req = blk_mq_tag_to_rq(shost->tag_set.tags[hw_ctx], tag); + if (hwq < shost->tag_set.nr_hw_queues) + req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq], + blk_mq_unique_tag_to_tag(unique_tag)); return req ? (struct scsi_cmnd *)req->special : NULL; } /** * scsi_find_tag - find a tagged command by device * @SDpnt: pointer to the ScSI device - * @tag: the tag number + * @tag: tag generated by blk_mq_unique_tag() * * Notes: * Only works with tags allocated by the generic blk layer. @@ -133,9 +136,9 @@ static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag) if (tag != SCSI_NO_TAG) { if (shost_use_blk_mq(sdev->host)) - return scsi_mq_find_tag(sdev->host, 0, tag); + return scsi_mq_find_tag(sdev->host, tag); - req = blk_queue_find_tag(sdev->request_queue, tag); + req = blk_queue_find_tag(sdev->request_queue, tag); return req ? (struct scsi_cmnd *)req->special : NULL; } @@ -174,7 +177,7 @@ static inline int scsi_init_shared_tag_map(struct Scsi_Host *shost, int depth) /** * scsi_host_find_tag - find the tagged command by host * @shost: pointer to scsi_host - * @tag: tag of the scsi_cmnd + * @tag: tag generated by blk_mq_unique_tag() * * Notes: * Only works with tags allocated by the generic blk layer. @@ -186,7 +189,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost, if (tag != SCSI_NO_TAG) { if (shost_use_blk_mq(shost)) - return scsi_mq_find_tag(shost, 0, tag); + return scsi_mq_find_tag(shost, tag); req = blk_map_queue_find_tag(shost->bqt, tag); return req ? (struct scsi_cmnd *)req->special : NULL; } -- cgit v1.2.3 From 176aa9d6ee2db582e7e856dbe1983004a82869b4 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 11 Oct 2014 12:06:47 +0200 Subject: scsi: refactor scsi_reset_provider handling Pull the common code from the two callers into the function, and rename it to scsi_ioctl_reset. Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 76 ++++++++++++++++++++++------------------------- drivers/scsi/scsi_ioctl.c | 33 +------------------- drivers/scsi/sg.c | 34 ++------------------- include/scsi/scsi_eh.h | 15 +--------- 4 files changed, 41 insertions(+), 117 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 95c9abb64183..a6f6b9222b51 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "scsi_priv.h" #include "scsi_logging.h" @@ -2311,39 +2312,36 @@ scsi_reset_provider_done_command(struct scsi_cmnd *scmd) { } -/* - * Function: scsi_reset_provider - * - * Purpose: Send requested reset to a bus or device at any phase. - * - * Arguments: device - device to send reset to - * flag - reset type (see scsi.h) - * - * Returns: SUCCESS/FAILURE. - * - * Notes: This is used by the SCSI Generic driver to provide - * Bus/Device reset capability. +/** + * scsi_ioctl_reset: explicitly reset a host/bus/target/device + * @dev: scsi_device to operate on + * @arg: reset type (see sg.h) */ int -scsi_reset_provider(struct scsi_device *dev, int flag) +scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) { struct scsi_cmnd *scmd; struct Scsi_Host *shost = dev->host; struct request req; unsigned long flags; - int rtn; + int error = 0, rtn, val; + + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) + return -EACCES; + + error = get_user(val, arg); + if (error) + return error; if (scsi_autopm_get_host(shost) < 0) - return FAILED; + return -EIO; - if (!get_device(&dev->sdev_gendev)) { - rtn = FAILED; + error = -EIO; + if (!get_device(&dev->sdev_gendev)) goto out_put_autopm_host; - } scmd = scsi_get_command(dev, GFP_KERNEL); if (!scmd) { - rtn = FAILED; put_device(&dev->sdev_gendev); goto out_put_autopm_host; } @@ -2364,39 +2362,37 @@ scsi_reset_provider(struct scsi_device *dev, int flag) shost->tmf_in_progress = 1; spin_unlock_irqrestore(shost->host_lock, flags); - switch (flag) { - case SCSI_TRY_RESET_DEVICE: + switch (val & ~SG_SCSI_RESET_NO_ESCALATE) { + case SG_SCSI_RESET_NOTHING: + rtn = SUCCESS; + break; + case SG_SCSI_RESET_DEVICE: rtn = scsi_try_bus_device_reset(scmd); - if (rtn == SUCCESS) + if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE)) break; /* FALLTHROUGH */ - case SCSI_TRY_RESET_TARGET: + case SG_SCSI_RESET_TARGET: rtn = scsi_try_target_reset(scmd); - if (rtn == SUCCESS) + if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE)) break; /* FALLTHROUGH */ - case SCSI_TRY_RESET_BUS: + case SG_SCSI_RESET_BUS: rtn = scsi_try_bus_reset(scmd); - if (rtn == SUCCESS) + if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE)) break; /* FALLTHROUGH */ - case SCSI_TRY_RESET_HOST: - case SCSI_TRY_RESET_HOST | SCSI_TRY_RESET_NO_ESCALATE: + case SG_SCSI_RESET_HOST: rtn = scsi_try_host_reset(scmd); - break; - case SCSI_TRY_RESET_DEVICE | SCSI_TRY_RESET_NO_ESCALATE: - rtn = scsi_try_bus_device_reset(scmd); - break; - case SCSI_TRY_RESET_TARGET | SCSI_TRY_RESET_NO_ESCALATE: - rtn = scsi_try_target_reset(scmd); - break; - case SCSI_TRY_RESET_BUS | SCSI_TRY_RESET_NO_ESCALATE: - rtn = scsi_try_bus_reset(scmd); - break; + if (rtn == SUCCESS) + break; default: + /* FALLTHROUGH */ rtn = FAILED; + break; } + error = (rtn == SUCCESS) ? 0 : -EIO; + spin_lock_irqsave(shost->host_lock, flags); shost->tmf_in_progress = 0; spin_unlock_irqrestore(shost->host_lock, flags); @@ -2416,9 +2412,9 @@ scsi_reset_provider(struct scsi_device *dev, int flag) scsi_next_command(scmd); out_put_autopm_host: scsi_autopm_put_host(shost); - return rtn; + return error; } -EXPORT_SYMBOL(scsi_reset_provider); +EXPORT_SYMBOL(scsi_ioctl_reset); /** * scsi_normalize_sense - normalize main elements from either fixed or diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 5207274574f5..5ddc08f39987 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -292,8 +292,6 @@ EXPORT_SYMBOL(scsi_ioctl); int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, void __user *arg, int ndelay) { - int val, val2, result; - /* The first set of iocts may be executed even if we're doing * error processing, as long as the device was opened * non-blocking */ @@ -305,36 +303,7 @@ int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, switch (cmd) { case SG_SCSI_RESET: - result = get_user(val, (int __user *)arg); - if (result) - return result; - if (val & SG_SCSI_RESET_NO_ESCALATE) { - val &= ~SG_SCSI_RESET_NO_ESCALATE; - val2 = SCSI_TRY_RESET_NO_ESCALATE; - } else - val2 = 0; - if (val == SG_SCSI_RESET_NOTHING) - return 0; - switch (val) { - case SG_SCSI_RESET_DEVICE: - val2 |= SCSI_TRY_RESET_DEVICE; - break; - case SG_SCSI_RESET_TARGET: - val2 |= SCSI_TRY_RESET_TARGET; - break; - case SG_SCSI_RESET_BUS: - val2 |= SCSI_TRY_RESET_BUS; - break; - case SG_SCSI_RESET_HOST: - val2 |= SCSI_TRY_RESET_HOST; - break; - default: - return -EINVAL; - } - if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EACCES; - return (scsi_reset_provider(sdev, val2) == - SUCCESS) ? 0 : -EIO; + return scsi_ioctl_reset(sdev, arg); } return -ENODEV; } diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 2fe2701d86db..7c55cacceb7c 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -847,7 +847,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) { void __user *p = (void __user *)arg; int __user *ip = p; - int result, val, val2, read_only; + int result, val, read_only; Sg_device *sdp; Sg_fd *sfp; Sg_request *srp; @@ -1079,36 +1079,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) return -EBUSY; } else if (!scsi_block_when_processing_errors(sdp->device)) return -EBUSY; - result = get_user(val, ip); - if (result) - return result; - if (val & SG_SCSI_RESET_NO_ESCALATE) { - val &= ~SG_SCSI_RESET_NO_ESCALATE; - val2 = SCSI_TRY_RESET_NO_ESCALATE; - } else - val2 = 0; - if (SG_SCSI_RESET_NOTHING == val) - return 0; - switch (val) { - case SG_SCSI_RESET_DEVICE: - val2 |= SCSI_TRY_RESET_DEVICE; - break; - case SG_SCSI_RESET_TARGET: - val2 |= SCSI_TRY_RESET_TARGET; - break; - case SG_SCSI_RESET_BUS: - val2 |= SCSI_TRY_RESET_BUS; - break; - case SG_SCSI_RESET_HOST: - val2 |= SCSI_TRY_RESET_HOST; - break; - default: - return -EINVAL; - } - if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EACCES; - return (scsi_reset_provider(sdp->device, val2) == - SUCCESS) ? 0 : -EIO; + + return scsi_ioctl_reset(sdp->device, ip); case SCSI_IOCTL_SEND_COMMAND: if (atomic_read(&sdp->detaching)) return -ENODEV; diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 256248141322..1e1421b06565 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -60,20 +60,7 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); -/* - * Reset request from external source - * Note: if SCSI_TRY_RESET_DEVICE fails then it will escalate to - * SCSI_TRY_RESET_TARGET which if it fails will escalate to - * SCSI_TRY_RESET_BUS which if it fails will escalate to SCSI_TRY_RESET_HOST. - * To prevent escalation OR with SCSI_TRY_RESET_NO_ESCALATE. - */ -#define SCSI_TRY_RESET_DEVICE 1 -#define SCSI_TRY_RESET_BUS 2 -#define SCSI_TRY_RESET_HOST 3 -#define SCSI_TRY_RESET_TARGET 4 -#define SCSI_TRY_RESET_NO_ESCALATE 0x100 /* OR-ed to prior defines */ - -extern int scsi_reset_provider(struct scsi_device *, int); +extern int scsi_ioctl_reset(struct scsi_device *, int __user *); struct scsi_eh_save { /* saved state */ -- cgit v1.2.3 From 906d15fbd23c1267addab361063c1c8119992215 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 11 Oct 2014 16:25:31 +0200 Subject: scsi: split scsi_nonblockable_ioctl The calling conventions for this function are bad as it could return -ENODEV both for a device not currently online and a not recognized ioctl. Add a new scsi_ioctl_block_when_processing_errors function that wraps scsi_block_when_processing_errors with the a special case for the SG_SCSI_RESET ioctl command, and handle the SG_SCSI_RESET case itself in scsi_ioctl. All callers of scsi_ioctl now must call the above helper to check for the EH state, so that the ioctl handler itself doesn't have to. Reported-by: Robert Elliott Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/ch.c | 5 +++++ drivers/scsi/osst.c | 6 +++--- drivers/scsi/scsi_ioctl.c | 47 +++++++++++++---------------------------------- drivers/scsi/sd.c | 6 +++--- drivers/scsi/sg.c | 33 +++++++++++++++------------------ drivers/scsi/sr.c | 15 +++++---------- drivers/scsi/st.c | 7 +++---- include/scsi/scsi_ioctl.h | 4 ++-- 8 files changed, 49 insertions(+), 74 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 226ef771efff..4f502f95f3b8 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -616,6 +616,11 @@ static long ch_ioctl(struct file *file, int retval; void __user *argp = (void __user *)arg; + retval = scsi_ioctl_block_when_processing_errors(ch->device, cmd, + file->f_flags & O_NDELAY); + if (retval) + return retval; + switch (cmd) { case CHIOGPARAMS: { diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 3d0d13c4da15..b6d63d636692 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -4969,10 +4969,10 @@ static long osst_ioctl(struct file * file, * may try and take the device offline, in which case all further * access to the device is prohibited. */ - if( !scsi_block_when_processing_errors(STp->device) ) { - retval = (-ENXIO); + retval = scsi_ioctl_block_when_processing_errors(STp->device, cmd_in, + file->f_flags & O_NDELAY); + if (retval) goto out; - } cmd_type = _IOC_TYPE(cmd_in); cmd_nr = _IOC_NR(cmd_in); diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 5ddc08f39987..712f159ebb69 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -200,19 +200,6 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) { char scsi_cmd[MAX_COMMAND_SIZE]; - /* No idea how this happens.... */ - if (!sdev) - return -ENXIO; - - /* - * If we are in the middle of error recovery, don't let anyone - * else try and use this device. Also, if error recovery fails, it - * may try and take the device offline, in which case all further - * access to the device is prohibited. - */ - if (!scsi_block_when_processing_errors(sdev)) - return -ENODEV; - /* Check for deprecated ioctls ... all the ioctls which don't * follow the new unique numbering scheme are deprecated */ switch (cmd) { @@ -273,6 +260,8 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) START_STOP_TIMEOUT, NORMAL_RETRIES); case SCSI_IOCTL_GET_PCI: return scsi_ioctl_get_pci(sdev, arg); + case SG_SCSI_RESET: + return scsi_ioctl_reset(sdev, arg); default: if (sdev->host->hostt->ioctl) return sdev->host->hostt->ioctl(sdev, cmd, arg); @@ -281,30 +270,20 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) } EXPORT_SYMBOL(scsi_ioctl); -/** - * scsi_nonblockable_ioctl() - Handle SG_SCSI_RESET - * @sdev: scsi device receiving ioctl - * @cmd: Must be SC_SCSI_RESET - * @arg: pointer to int containing SG_SCSI_RESET_{DEVICE,TARGET,BUS,HOST} - * possibly OR-ed with SG_SCSI_RESET_NO_ESCALATE - * @ndelay: file mode O_NDELAY flag +/* + * We can process a reset even when a device isn't fully operable. */ -int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, - void __user *arg, int ndelay) +int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int cmd, + bool ndelay) { - /* The first set of iocts may be executed even if we're doing - * error processing, as long as the device was opened - * non-blocking */ - if (ndelay) { + if (cmd == SG_SCSI_RESET && ndelay) { if (scsi_host_in_recovery(sdev->host)) return -ENODEV; - } else if (!scsi_block_when_processing_errors(sdev)) - return -ENODEV; - - switch (cmd) { - case SG_SCSI_RESET: - return scsi_ioctl_reset(sdev, arg); + } else { + if (!scsi_block_when_processing_errors(sdev)) + return -ENODEV; } - return -ENODEV; + + return 0; } -EXPORT_SYMBOL(scsi_nonblockable_ioctl); +EXPORT_SYMBOL_GPL(scsi_ioctl_block_when_processing_errors); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 242f9b177285..ddf763ad3b83 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1334,9 +1334,9 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode, * may try and take the device offline, in which case all further * access to the device is prohibited. */ - error = scsi_nonblockable_ioctl(sdp, cmd, p, - (mode & FMODE_NDELAY) != 0); - if (!scsi_block_when_processing_errors(sdp) || !error) + error = scsi_ioctl_block_when_processing_errors(sdp, cmd, + (mode & FMODE_NDELAY) != 0); + if (error) goto out; /* diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 7c55cacceb7c..b14f64cb9724 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1071,16 +1071,6 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) if (atomic_read(&sdp->detaching)) return -ENODEV; return put_user(sdp->device->host->hostt->emulated, ip); - case SG_SCSI_RESET: - if (atomic_read(&sdp->detaching)) - return -ENODEV; - if (filp->f_flags & O_NONBLOCK) { - if (scsi_host_in_recovery(sdp->device->host)) - return -EBUSY; - } else if (!scsi_block_when_processing_errors(sdp->device)) - return -EBUSY; - - return scsi_ioctl_reset(sdp->device, ip); case SCSI_IOCTL_SEND_COMMAND: if (atomic_read(&sdp->detaching)) return -ENODEV; @@ -1100,13 +1090,6 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) return result; sdp->sgdebug = (char) val; return 0; - case SCSI_IOCTL_GET_IDLUN: - case SCSI_IOCTL_GET_BUS_NUMBER: - case SCSI_IOCTL_PROBE_HOST: - case SG_GET_TRANSFORM: - if (atomic_read(&sdp->detaching)) - return -ENODEV; - return scsi_ioctl(sdp->device, cmd_in, p); case BLKSECTGET: return put_user(max_sectors_bytes(sdp->device->request_queue), ip); @@ -1122,11 +1105,25 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) return blk_trace_startstop(sdp->device->request_queue, 0); case BLKTRACETEARDOWN: return blk_trace_remove(sdp->device->request_queue); + case SCSI_IOCTL_GET_IDLUN: + case SCSI_IOCTL_GET_BUS_NUMBER: + case SCSI_IOCTL_PROBE_HOST: + case SG_GET_TRANSFORM: + case SG_SCSI_RESET: + if (atomic_read(&sdp->detaching)) + return -ENODEV; + break; default: if (read_only) return -EPERM; /* don't know so take safe approach */ - return scsi_ioctl(sdp->device, cmd_in, p); + break; } + + result = scsi_ioctl_block_when_processing_errors(sdp->device, + cmd_in, filp->f_flags & O_NDELAY); + if (result) + return result; + return scsi_ioctl(sdp->device, cmd_in, p); } #ifdef CONFIG_COMPAT diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 2de44cc58b1a..3d5399e341af 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -549,6 +549,11 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, mutex_lock(&sr_mutex); + ret = scsi_ioctl_block_when_processing_errors(sdev, cmd, + (mode & FMODE_NDELAY) != 0); + if (ret) + goto out; + /* * Send SCSI addressing ioctls directly to mid level, send other * ioctls to cdrom/block level. @@ -564,16 +569,6 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, if (ret != -ENOSYS) goto out; - /* - * ENODEV means that we didn't recognise the ioctl, or that we - * cannot execute it in the current device state. In either - * case fall through to scsi_ioctl, which will return ENDOEV again - * if it doesn't recognise the ioctl - */ - ret = scsi_nonblockable_ioctl(sdev, cmd, argp, - (mode & FMODE_NDELAY) != 0); - if (ret != -ENODEV) - goto out; ret = scsi_ioctl(sdev, cmd, argp); out: diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 63c35ed3c88d..7d2e036c75c1 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -3376,11 +3376,10 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) * may try and take the device offline, in which case all further * access to the device is prohibited. */ - retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, - file->f_flags & O_NDELAY); - if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV) + retval = scsi_ioctl_block_when_processing_errors(STp->device, cmd_in, + file->f_flags & O_NDELAY); + if (retval) goto out; - retval = 0; cmd_type = _IOC_TYPE(cmd_in); cmd_nr = _IOC_NR(cmd_in); diff --git a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h index b9006848b813..8d19d1d233c3 100644 --- a/include/scsi/scsi_ioctl.h +++ b/include/scsi/scsi_ioctl.h @@ -40,9 +40,9 @@ typedef struct scsi_fctargaddress { unsigned char host_wwn[8]; // include NULL term. } Scsi_FCTargAddress; +int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, + int cmd, bool ndelay); extern int scsi_ioctl(struct scsi_device *, int, void __user *); -extern int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, - void __user *arg, int ndelay); #endif /* __KERNEL__ */ #endif /* _SCSI_IOCTL_H */ -- cgit v1.2.3 From 21a9d4c9d6c6bb22dffad67cb82f0037859262b7 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 24 Oct 2014 18:39:37 +0200 Subject: sd: fix up ->compat_ioctl No need to verify the passthrough ioctls, the real handler will take care of that. Also make sure not to block for resets on O_NONBLOCK fds. Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/sd.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ddf763ad3b83..b041eca8955d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1541,31 +1541,19 @@ static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device; - int ret; - - ret = scsi_verify_blk_ioctl(bdev, cmd); - if (ret < 0) - return ret; + int error; - /* - * If we are in the middle of error recovery, don't let anyone - * else try and use this device. Also, if error recovery fails, it - * may try and take the device offline, in which case all further - * access to the device is prohibited. - */ - if (!scsi_block_when_processing_errors(sdev)) - return -ENODEV; + error = scsi_ioctl_block_when_processing_errors(sdev, cmd, + (mode & FMODE_NDELAY) != 0); + if (error) + return error; - if (sdev->host->hostt->compat_ioctl) { - ret = sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg); - - return ret; - } - /* * Let the static ioctl translation table take care of it. */ - return -ENOIOCTLCMD; + if (!sdev->host->hostt->compat_ioctl) + return -ENOIOCTLCMD; + return sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg); } #endif -- cgit v1.2.3 From dccfa688ca7ffba0996bd5d9cd0e01b01002748e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 11 Oct 2014 15:59:39 +0200 Subject: st: call scsi_set_medium_removal directly Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/st.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 7d2e036c75c1..e46e02b24ba4 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -861,17 +861,16 @@ static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm) /* Lock or unlock the drive door. Don't use when st_request allocated. */ static int do_door_lock(struct scsi_tape * STp, int do_lock) { - int retval, cmd; + int retval; - cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK; DEBC_printk(STp, "%socking drive door.\n", do_lock ? "L" : "Unl"); - retval = scsi_ioctl(STp->device, cmd, NULL); - if (!retval) { + + retval = scsi_set_medium_removal(STp->device, + do_lock ? SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW); + if (!retval) STp->door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED; - } - else { + else STp->door_locked = ST_LOCK_FAILS; - } return retval; } -- cgit v1.2.3 From 2b3b3d61e8517b34432d1c73242b6345c9a15ebe Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 11 Oct 2014 16:00:33 +0200 Subject: osst: call scsi_set_medium_removal directly Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/osst.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index b6d63d636692..8c384648eef9 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -3327,19 +3327,18 @@ static int osst_write_frame(struct osst_tape * STp, struct osst_request ** aSRpn /* Lock or unlock the drive door. Don't use when struct osst_request allocated. */ static int do_door_lock(struct osst_tape * STp, int do_lock) { - int retval, cmd; + int retval; - cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK; #if DEBUG printk(OSST_DEB_MSG "%s:D: %socking drive door.\n", tape_name(STp), do_lock ? "L" : "Unl"); #endif - retval = scsi_ioctl(STp->device, cmd, NULL); - if (!retval) { + + retval = scsi_set_medium_removal(STp->device, + do_lock ? SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW); + if (!retval) STp->door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED; - } - else { + else STp->door_locked = ST_LOCK_FAILS; - } return retval; } -- cgit v1.2.3 From e9afccc5245a35468f52bc3f53ed162caabf275d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 27 Oct 2014 16:28:13 +0100 Subject: scsi: return EAGAIN when resetting a device under EH Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 712f159ebb69..c4f7b56fa6f6 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -278,7 +278,7 @@ int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int cmd, { if (cmd == SG_SCSI_RESET && ndelay) { if (scsi_host_in_recovery(sdev->host)) - return -ENODEV; + return -EAGAIN; } else { if (!scsi_block_when_processing_errors(sdev)) return -ENODEV; -- cgit v1.2.3 From 7985090aa0201fa7760583f9f8e6ba41a8d4c392 Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Fri, 7 Nov 2014 00:08:13 -0500 Subject: sd: disable discard_zeroes_data for UNMAP The T10 SBC UNMAP command does not provide any hard guarantees that blocks will return zeroes on a subsequent READ. This is due to the fact that the device server is free to silently ignore all or parts of the request. The only way to ensure that a block consistently returns zeroes after being unmapped is to use WRITE SAME with the UNMAP bit set. Should the device be unable to unmap one or more blocks described by the command it is required to manually write zeroes to them. Until now we have preferred UNMAP over the WRITE SAME variants to accommodate thinly provisioned devices that predated the final SBC-3 spec. This patch changes the heuristic so that we favor WRITE SAME(16) or (10) over UNMAP if these commands are marked as supported in the Logical Block Provisioning VPD page. The patch also disables discard_zeroes_data for devices operating in UNMAP mode. Signed-off-by: Martin K. Petersen Reviewed-by: Paolo Bonzini Signed-off-by: Christoph Hellwig --- drivers/scsi/sd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index b041eca8955d..95bfb7bfbb9d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -656,7 +656,7 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) unsigned int logical_block_size = sdkp->device->sector_size; unsigned int max_blocks = 0; - q->limits.discard_zeroes_data = sdkp->lbprz; + q->limits.discard_zeroes_data = 0; q->limits.discard_alignment = sdkp->unmap_alignment * logical_block_size; q->limits.discard_granularity = @@ -680,11 +680,13 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) case SD_LBP_WS16: max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS16_BLOCKS); + q->limits.discard_zeroes_data = sdkp->lbprz; break; case SD_LBP_WS10: max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS10_BLOCKS); + q->limits.discard_zeroes_data = sdkp->lbprz; break; case SD_LBP_ZERO: @@ -2622,12 +2624,12 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) } else { /* LBP VPD page tells us what to use */ - if (sdkp->lbpu && sdkp->max_unmap_blocks) - sd_config_discard(sdkp, SD_LBP_UNMAP); - else if (sdkp->lbpws) + if (sdkp->lbpws) sd_config_discard(sdkp, SD_LBP_WS16); else if (sdkp->lbpws10) sd_config_discard(sdkp, SD_LBP_WS10); + else if (sdkp->lbpu && sdkp->max_unmap_blocks) + sd_config_discard(sdkp, SD_LBP_UNMAP); else sd_config_discard(sdkp, SD_LBP_DISABLE); } -- cgit v1.2.3 From 0b9c08442c5d0991dd1632fed63221f5b6a35e83 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 14 Sep 2014 11:01:34 -0700 Subject: scsi_dh_hp_sw: fix return value on failed allocation Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 4ee2759f5299..4824bfbe3051 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -364,7 +364,7 @@ static int hp_sw_bus_attach(struct scsi_device *sdev) if (!scsi_dh_data) { sdev_printk(KERN_ERR, sdev, "%s: Attach Failed\n", HP_SW_NAME); - return 0; + return -ENOMEM; } scsi_dh_data->scsi_dh = &hp_sw_dh; -- cgit v1.2.3 From 27c888f0bb889693c6a3b6d39eba3265c16c072f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 13 Sep 2014 19:41:16 -0700 Subject: scsi_dh: get module reference outside of device handler We need to grab a reference to the module before calling the attach routines to avoid a small race vs module removal. It also cleans up the code significantly as a side effect. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh.c | 31 ++++++++++++++++++++--------- drivers/scsi/device_handler/scsi_dh_alua.c | 4 ---- drivers/scsi/device_handler/scsi_dh_emc.c | 4 ---- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ---- drivers/scsi/device_handler/scsi_dh_rdac.c | 4 ---- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c index 33e422e75835..1a8dbf33f2ac 100644 --- a/drivers/scsi/device_handler/scsi_dh.c +++ b/drivers/scsi/device_handler/scsi_dh.c @@ -102,23 +102,36 @@ static int scsi_dh_handler_attach(struct scsi_device *sdev, if (sdev->scsi_dh_data) { if (sdev->scsi_dh_data->scsi_dh != scsi_dh) - err = -EBUSY; - else - kref_get(&sdev->scsi_dh_data->kref); - } else if (scsi_dh->attach) { + return -EBUSY; + + kref_get(&sdev->scsi_dh_data->kref); + return 0; + } + + if (scsi_dh->attach) { + if (!try_module_get(scsi_dh->module)) + return -EINVAL; + err = scsi_dh->attach(sdev); - if (!err) { - kref_init(&sdev->scsi_dh_data->kref); - sdev->scsi_dh_data->sdev = sdev; + if (err) { + module_put(scsi_dh->module); + return err; } + + kref_init(&sdev->scsi_dh_data->kref); + sdev->scsi_dh_data->sdev = sdev; } return err; } static void __detach_handler (struct kref *kref) { - struct scsi_dh_data *scsi_dh_data = container_of(kref, struct scsi_dh_data, kref); - scsi_dh_data->scsi_dh->detach(scsi_dh_data->sdev); + struct scsi_dh_data *scsi_dh_data = + container_of(kref, struct scsi_dh_data, kref); + struct scsi_device_handler *scsi_dh = scsi_dh_data->scsi_dh; + + scsi_dh->detach(scsi_dh_data->sdev); + module_put(scsi_dh->module); } /* diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index fd78bdc53528..9115c31f26e9 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -873,9 +873,6 @@ static int alua_bus_attach(struct scsi_device *sdev) if ((err != SCSI_DH_OK) && (err != SCSI_DH_DEV_OFFLINED)) goto failed; - if (!try_module_get(THIS_MODULE)) - goto failed; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); sdev->scsi_dh_data = scsi_dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); @@ -908,7 +905,6 @@ static void alua_bus_detach(struct scsi_device *sdev) if (h->buff && h->inq != h->buff) kfree(h->buff); kfree(scsi_dh_data); - module_put(THIS_MODULE); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", ALUA_DH_NAME); } diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 84765384c47c..153b4c3547a2 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -692,9 +692,6 @@ static int clariion_bus_attach(struct scsi_device *sdev) if (err != SCSI_DH_OK) goto failed; - if (!try_module_get(THIS_MODULE)) - goto failed; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); sdev->scsi_dh_data = scsi_dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); @@ -728,7 +725,6 @@ static void clariion_bus_detach(struct scsi_device *sdev) CLARIION_NAME); kfree(scsi_dh_data); - module_put(THIS_MODULE); } static int __init clariion_init(void) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 4824bfbe3051..cf36557a1d4d 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -377,9 +377,6 @@ static int hp_sw_bus_attach(struct scsi_device *sdev) if (ret != SCSI_DH_OK || h->path_state == HP_SW_PATH_UNINITIALIZED) goto failed; - if (!try_module_get(THIS_MODULE)) - goto failed; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); sdev->scsi_dh_data = scsi_dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); @@ -406,7 +403,6 @@ static void hp_sw_bus_detach( struct scsi_device *sdev ) scsi_dh_data = sdev->scsi_dh_data; sdev->scsi_dh_data = NULL; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - module_put(THIS_MODULE); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", HP_SW_NAME); diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 1b5bc9293e37..b850954c4e22 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -878,9 +878,6 @@ static int rdac_bus_attach(struct scsi_device *sdev) if (err != SCSI_DH_OK) goto clean_ctlr; - if (!try_module_get(THIS_MODULE)) - goto clean_ctlr; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); sdev->scsi_dh_data = scsi_dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); @@ -924,7 +921,6 @@ static void rdac_bus_detach( struct scsi_device *sdev ) kref_put(&h->ctlr->kref, release_controller); spin_unlock(&list_lock); kfree(scsi_dh_data); - module_put(THIS_MODULE); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME); } -- cgit v1.2.3 From cd37743fc978a14fee75a4e662582e15d16038a3 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 13 Sep 2014 19:59:51 -0700 Subject: scsi: use container_of to get at device handler private data Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh_alua.c | 25 +++++++++---------------- drivers/scsi/device_handler/scsi_dh_emc.c | 24 ++++++++++-------------- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 23 +++++++++-------------- drivers/scsi/device_handler/scsi_dh_rdac.c | 25 +++++++++---------------- include/scsi/scsi_device.h | 1 - 5 files changed, 37 insertions(+), 61 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 9115c31f26e9..d9781045c4ee 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -62,6 +62,7 @@ #define ALUA_OPTIMIZE_STPG 1 struct alua_dh_data { + struct scsi_dh_data dh_data; int group_id; int rel_port; int tpgs; @@ -87,9 +88,7 @@ static int alua_check_sense(struct scsi_device *, struct scsi_sense_hdr *); static inline struct alua_dh_data *get_alua_data(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data; - BUG_ON(scsi_dh_data == NULL); - return ((struct alua_dh_data *) scsi_dh_data->buf); + return container_of(sdev->scsi_dh_data, struct alua_dh_data, dh_data); } static int realloc_buffer(struct alua_dh_data *h, unsigned len) @@ -846,21 +845,18 @@ static struct scsi_device_handler alua_dh = { */ static int alua_bus_attach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; struct alua_dh_data *h; unsigned long flags; int err = SCSI_DH_OK; - scsi_dh_data = kzalloc(sizeof(*scsi_dh_data) - + sizeof(*h) , GFP_KERNEL); - if (!scsi_dh_data) { + h = kzalloc(sizeof(*h) , GFP_KERNEL); + if (!h) { sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n", ALUA_DH_NAME); return -ENOMEM; } - scsi_dh_data->scsi_dh = &alua_dh; - h = (struct alua_dh_data *) scsi_dh_data->buf; + h->dh_data.scsi_dh = &alua_dh; h->tpgs = TPGS_MODE_UNINITIALIZED; h->state = TPGS_STATE_OPTIMIZED; h->group_id = -1; @@ -874,14 +870,14 @@ static int alua_bus_attach(struct scsi_device *sdev) goto failed; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = scsi_dh_data; + sdev->scsi_dh_data = &h->dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_NOTICE, sdev, "%s: Attached\n", ALUA_DH_NAME); return 0; failed: - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_ERR, sdev, "%s: not attached\n", ALUA_DH_NAME); return -EINVAL; } @@ -892,19 +888,16 @@ failed: */ static void alua_bus_detach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; - struct alua_dh_data *h; + struct alua_dh_data *h = get_alua_data(sdev); unsigned long flags; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - scsi_dh_data = sdev->scsi_dh_data; sdev->scsi_dh_data = NULL; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - h = (struct alua_dh_data *) scsi_dh_data->buf; if (h->buff && h->inq != h->buff) kfree(h->buff); - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", ALUA_DH_NAME); } diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 153b4c3547a2..c2e26cdef21a 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -72,6 +72,7 @@ static const char * lun_state[] = }; struct clariion_dh_data { + struct scsi_dh_data dh_data; /* * Flags: * CLARIION_SHORT_TRESPASS @@ -116,9 +117,8 @@ struct clariion_dh_data { static inline struct clariion_dh_data *get_clariion_data(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data; - BUG_ON(scsi_dh_data == NULL); - return ((struct clariion_dh_data *) scsi_dh_data->buf); + return container_of(sdev->scsi_dh_data, struct clariion_dh_data, + dh_data); } /* @@ -665,21 +665,18 @@ static struct scsi_device_handler clariion_dh = { static int clariion_bus_attach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; struct clariion_dh_data *h; unsigned long flags; int err; - scsi_dh_data = kzalloc(sizeof(*scsi_dh_data) - + sizeof(*h) , GFP_KERNEL); - if (!scsi_dh_data) { + h = kzalloc(sizeof(*h) , GFP_KERNEL); + if (!h) { sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n", CLARIION_NAME); return -ENOMEM; } - scsi_dh_data->scsi_dh = &clariion_dh; - h = (struct clariion_dh_data *) scsi_dh_data->buf; + h->dh_data.scsi_dh = &clariion_dh; h->lun_state = CLARIION_LUN_UNINITIALIZED; h->default_sp = CLARIION_UNBOUND_LU; h->current_sp = CLARIION_UNBOUND_LU; @@ -693,7 +690,7 @@ static int clariion_bus_attach(struct scsi_device *sdev) goto failed; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = scsi_dh_data; + sdev->scsi_dh_data = &h->dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_INFO, sdev, @@ -705,7 +702,7 @@ static int clariion_bus_attach(struct scsi_device *sdev) return 0; failed: - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_ERR, sdev, "%s: not attached\n", CLARIION_NAME); return -EINVAL; @@ -713,18 +710,17 @@ failed: static void clariion_bus_detach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; + struct clariion_dh_data *h = get_clariion_data(sdev); unsigned long flags; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - scsi_dh_data = sdev->scsi_dh_data; sdev->scsi_dh_data = NULL; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", CLARIION_NAME); - kfree(scsi_dh_data); + kfree(h); } static int __init clariion_init(void) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index cf36557a1d4d..37dedcae0aa4 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -38,6 +38,7 @@ #define HP_SW_PATH_PASSIVE 1 struct hp_sw_dh_data { + struct scsi_dh_data dh_data; unsigned char sense[SCSI_SENSE_BUFFERSIZE]; int path_state; int retries; @@ -51,9 +52,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *); static inline struct hp_sw_dh_data *get_hp_sw_data(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data; - BUG_ON(scsi_dh_data == NULL); - return ((struct hp_sw_dh_data *) scsi_dh_data->buf); + return container_of(sdev->scsi_dh_data, struct hp_sw_dh_data, dh_data); } /* @@ -354,21 +353,18 @@ static struct scsi_device_handler hp_sw_dh = { static int hp_sw_bus_attach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; struct hp_sw_dh_data *h; unsigned long flags; int ret; - scsi_dh_data = kzalloc(sizeof(*scsi_dh_data) - + sizeof(*h) , GFP_KERNEL); - if (!scsi_dh_data) { + h = kzalloc(sizeof(*h), GFP_KERNEL); + if (!h) { sdev_printk(KERN_ERR, sdev, "%s: Attach Failed\n", HP_SW_NAME); return -ENOMEM; } - scsi_dh_data->scsi_dh = &hp_sw_dh; - h = (struct hp_sw_dh_data *) scsi_dh_data->buf; + h->dh_data.scsi_dh = &hp_sw_dh; h->path_state = HP_SW_PATH_UNINITIALIZED; h->retries = HP_SW_RETRIES; h->sdev = sdev; @@ -378,7 +374,7 @@ static int hp_sw_bus_attach(struct scsi_device *sdev) goto failed; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = scsi_dh_data; + sdev->scsi_dh_data = &h->dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_INFO, sdev, "%s: attached to %s path\n", @@ -388,7 +384,7 @@ static int hp_sw_bus_attach(struct scsi_device *sdev) return 0; failed: - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_ERR, sdev, "%s: not attached\n", HP_SW_NAME); return -EINVAL; @@ -396,17 +392,16 @@ failed: static void hp_sw_bus_detach( struct scsi_device *sdev ) { - struct scsi_dh_data *scsi_dh_data; + struct hp_sw_dh_data *h = get_hp_sw_data(sdev); unsigned long flags; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - scsi_dh_data = sdev->scsi_dh_data; sdev->scsi_dh_data = NULL; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", HP_SW_NAME); - kfree(scsi_dh_data); + kfree(h); } static int __init hp_sw_init(void) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index b850954c4e22..ef8caaaad76f 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -181,6 +181,7 @@ struct c2_inquiry { }; struct rdac_dh_data { + struct scsi_dh_data dh_data; struct rdac_controller *ctlr; #define UNINITIALIZED_LUN (1 << 8) unsigned lun; @@ -261,9 +262,7 @@ do { \ static inline struct rdac_dh_data *get_rdac_data(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data; - BUG_ON(scsi_dh_data == NULL); - return ((struct rdac_dh_data *) scsi_dh_data->buf); + return container_of(sdev->scsi_dh_data, struct rdac_dh_data, dh_data); } static struct request *get_rdac_req(struct scsi_device *sdev, @@ -842,23 +841,20 @@ static struct scsi_device_handler rdac_dh = { static int rdac_bus_attach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; struct rdac_dh_data *h; unsigned long flags; int err; char array_name[ARRAY_LABEL_LEN]; char array_id[UNIQUE_ID_LEN]; - scsi_dh_data = kzalloc(sizeof(*scsi_dh_data) - + sizeof(*h) , GFP_KERNEL); - if (!scsi_dh_data) { + h = kzalloc(sizeof(*h) , GFP_KERNEL); + if (!h) { sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n", RDAC_NAME); return -ENOMEM; } - scsi_dh_data->scsi_dh = &rdac_dh; - h = (struct rdac_dh_data *) scsi_dh_data->buf; + h->dh_data.scsi_dh = &rdac_dh; h->lun = UNINITIALIZED_LUN; h->state = RDAC_STATE_ACTIVE; @@ -879,7 +875,7 @@ static int rdac_bus_attach(struct scsi_device *sdev) goto clean_ctlr; spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = scsi_dh_data; + sdev->scsi_dh_data = &h->dh_data; spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_NOTICE, sdev, @@ -895,7 +891,7 @@ clean_ctlr: spin_unlock(&list_lock); failed: - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_ERR, sdev, "%s: not attached\n", RDAC_NAME); return -EINVAL; @@ -903,12 +899,9 @@ failed: static void rdac_bus_detach( struct scsi_device *sdev ) { - struct scsi_dh_data *scsi_dh_data; - struct rdac_dh_data *h; + struct rdac_dh_data *h = get_rdac_data(sdev); unsigned long flags; - scsi_dh_data = sdev->scsi_dh_data; - h = (struct rdac_dh_data *) scsi_dh_data->buf; if (h->ctlr && h->ctlr->ms_queued) flush_workqueue(kmpath_rdacd); @@ -920,7 +913,7 @@ static void rdac_bus_detach( struct scsi_device *sdev ) if (h->ctlr) kref_put(&h->ctlr->kref, release_controller); spin_unlock(&list_lock); - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME); } diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 0b18a097c1ba..04cd5ad8289e 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -228,7 +228,6 @@ struct scsi_dh_data { struct scsi_device_handler *scsi_dh; struct scsi_device *sdev; struct kref kref; - char buf[0]; }; #define to_scsi_device(d) \ -- cgit v1.2.3 From a64d01dcf8440846f3077a436344f99313c1396c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 13 Sep 2014 20:05:04 -0700 Subject: scsi: remove struct scsi_dh_devlist All drivers now do their own matching, so there is no more need to expose a device list as part of the interface. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh_emc.c | 6 ++++-- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 6 ++++-- drivers/scsi/device_handler/scsi_dh_rdac.c | 6 ++++-- include/scsi/scsi_device.h | 6 ------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index c2e26cdef21a..800deb75a111 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -622,7 +622,10 @@ done: return result; } -static const struct scsi_dh_devlist clariion_dev_list[] = { +static const struct { + char *vendor; + char *model; +} clariion_dev_list[] = { {"DGC", "RAID"}, {"DGC", "DISK"}, {"DGC", "VRAID"}, @@ -653,7 +656,6 @@ static void clariion_bus_detach(struct scsi_device *sdev); static struct scsi_device_handler clariion_dh = { .name = CLARIION_NAME, .module = THIS_MODULE, - .devlist = clariion_dev_list, .attach = clariion_bus_attach, .detach = clariion_bus_detach, .check_sense = clariion_check_sense, diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 37dedcae0aa4..471ffd19f2c5 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -311,7 +311,10 @@ static int hp_sw_activate(struct scsi_device *sdev, return 0; } -static const struct scsi_dh_devlist hp_sw_dh_data_list[] = { +static const struct { + char *vendor; + char *model; +} hp_sw_dh_data_list[] = { {"COMPAQ", "MSA1000 VOLUME"}, {"COMPAQ", "HSV110"}, {"HP", "HSV100"}, @@ -343,7 +346,6 @@ static void hp_sw_bus_detach(struct scsi_device *sdev); static struct scsi_device_handler hp_sw_dh = { .name = HP_SW_NAME, .module = THIS_MODULE, - .devlist = hp_sw_dh_data_list, .attach = hp_sw_bus_attach, .detach = hp_sw_bus_detach, .activate = hp_sw_activate, diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index ef8caaaad76f..8b09528613d2 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -778,7 +778,10 @@ static int rdac_check_sense(struct scsi_device *sdev, return SCSI_RETURN_NOT_HANDLED; } -static const struct scsi_dh_devlist rdac_dev_list[] = { +static const struct { + char *vendor; + char *model; +} rdac_dev_list[] = { {"IBM", "1722"}, {"IBM", "1724"}, {"IBM", "1726"}, @@ -830,7 +833,6 @@ static void rdac_bus_detach(struct scsi_device *sdev); static struct scsi_device_handler rdac_dh = { .name = RDAC_NAME, .module = THIS_MODULE, - .devlist = rdac_dev_list, .prep_fn = rdac_prep_fn, .check_sense = rdac_check_sense, .attach = rdac_bus_attach, diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 04cd5ad8289e..2601c97fd8b9 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -201,11 +201,6 @@ struct scsi_device { unsigned long sdev_data[0]; } __attribute__((aligned(sizeof(unsigned long)))); -struct scsi_dh_devlist { - char *vendor; - char *model; -}; - typedef void (*activate_complete)(void *, int); struct scsi_device_handler { /* Used by the infrastructure */ @@ -214,7 +209,6 @@ struct scsi_device_handler { /* Filled by the hardware handler */ struct module *module; const char *name; - const struct scsi_dh_devlist *devlist; int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); int (*attach)(struct scsi_device *); void (*detach)(struct scsi_device *); -- cgit v1.2.3 From 1f12ffa51479741db7c4ac1b7abc21662e4ce119 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 13 Sep 2014 20:08:44 -0700 Subject: scsi: device handlers must have attach and detach methods Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c index 1a8dbf33f2ac..d8a8aac2c3db 100644 --- a/drivers/scsi/device_handler/scsi_dh.c +++ b/drivers/scsi/device_handler/scsi_dh.c @@ -108,19 +108,17 @@ static int scsi_dh_handler_attach(struct scsi_device *sdev, return 0; } - if (scsi_dh->attach) { - if (!try_module_get(scsi_dh->module)) - return -EINVAL; - - err = scsi_dh->attach(sdev); - if (err) { - module_put(scsi_dh->module); - return err; - } + if (!try_module_get(scsi_dh->module)) + return -EINVAL; - kref_init(&sdev->scsi_dh_data->kref); - sdev->scsi_dh_data->sdev = sdev; + err = scsi_dh->attach(sdev); + if (err) { + module_put(scsi_dh->module); + return err; } + + kref_init(&sdev->scsi_dh_data->kref); + sdev->scsi_dh_data->sdev = sdev; return err; } @@ -154,7 +152,7 @@ static void scsi_dh_handler_detach(struct scsi_device *sdev, if (!scsi_dh) scsi_dh = sdev->scsi_dh_data->scsi_dh; - if (scsi_dh && scsi_dh->detach) + if (scsi_dh) kref_put(&sdev->scsi_dh_data->kref, __detach_handler); } @@ -343,6 +341,9 @@ int scsi_register_device_handler(struct scsi_device_handler *scsi_dh) if (get_device_handler(scsi_dh->name)) return -EBUSY; + if (!scsi_dh->attach || !scsi_dh->detach) + return -EINVAL; + spin_lock(&list_lock); list_add(&scsi_dh->list, &scsi_dh_list); spin_unlock(&list_lock); -- cgit v1.2.3 From 1d5203284d8acbdfdf9b478d434450b34f338f28 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 14 Sep 2014 11:08:21 -0700 Subject: scsi: handle more device handler setup/teardown in common code Move all code to set up and tear down sdev->scsi_dh_data to common code. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh.c | 29 ++++++++++---- drivers/scsi/device_handler/scsi_dh_alua.c | 59 ++++++++++------------------- drivers/scsi/device_handler/scsi_dh_emc.c | 58 +++++++++------------------- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 54 ++++++++------------------ drivers/scsi/device_handler/scsi_dh_rdac.c | 53 ++++++++------------------ include/scsi/scsi_device.h | 2 +- 6 files changed, 88 insertions(+), 167 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c index d8a8aac2c3db..1dba62c5cf6a 100644 --- a/drivers/scsi/device_handler/scsi_dh.c +++ b/drivers/scsi/device_handler/scsi_dh.c @@ -98,7 +98,7 @@ device_handler_match(struct scsi_device_handler *scsi_dh, static int scsi_dh_handler_attach(struct scsi_device *sdev, struct scsi_device_handler *scsi_dh) { - int err = 0; + struct scsi_dh_data *d; if (sdev->scsi_dh_data) { if (sdev->scsi_dh_data->scsi_dh != scsi_dh) @@ -111,15 +111,22 @@ static int scsi_dh_handler_attach(struct scsi_device *sdev, if (!try_module_get(scsi_dh->module)) return -EINVAL; - err = scsi_dh->attach(sdev); - if (err) { + d = scsi_dh->attach(sdev); + if (IS_ERR(d)) { + sdev_printk(KERN_ERR, sdev, "%s: Attach failed (%ld)\n", + scsi_dh->name, PTR_ERR(d)); module_put(scsi_dh->module); - return err; + return PTR_ERR(d); } - kref_init(&sdev->scsi_dh_data->kref); - sdev->scsi_dh_data->sdev = sdev; - return err; + d->scsi_dh = scsi_dh; + kref_init(&d->kref); + d->sdev = sdev; + + spin_lock_irq(sdev->request_queue->queue_lock); + sdev->scsi_dh_data = d; + spin_unlock_irq(sdev->request_queue->queue_lock); + return 0; } static void __detach_handler (struct kref *kref) @@ -127,8 +134,14 @@ static void __detach_handler (struct kref *kref) struct scsi_dh_data *scsi_dh_data = container_of(kref, struct scsi_dh_data, kref); struct scsi_device_handler *scsi_dh = scsi_dh_data->scsi_dh; + struct scsi_device *sdev = scsi_dh_data->sdev; + + spin_lock_irq(sdev->request_queue->queue_lock); + sdev->scsi_dh_data = NULL; + spin_unlock_irq(sdev->request_queue->queue_lock); - scsi_dh->detach(scsi_dh_data->sdev); + scsi_dh->detach(sdev); + sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", scsi_dh->name); module_put(scsi_dh->module); } diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index d9781045c4ee..854b568b9931 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -824,39 +824,18 @@ static bool alua_match(struct scsi_device *sdev) return (scsi_device_tpgs(sdev) != 0); } -static int alua_bus_attach(struct scsi_device *sdev); -static void alua_bus_detach(struct scsi_device *sdev); - -static struct scsi_device_handler alua_dh = { - .name = ALUA_DH_NAME, - .module = THIS_MODULE, - .attach = alua_bus_attach, - .detach = alua_bus_detach, - .prep_fn = alua_prep_fn, - .check_sense = alua_check_sense, - .activate = alua_activate, - .set_params = alua_set_params, - .match = alua_match, -}; - /* * alua_bus_attach - Attach device handler * @sdev: device to be attached to */ -static int alua_bus_attach(struct scsi_device *sdev) +static struct scsi_dh_data *alua_bus_attach(struct scsi_device *sdev) { struct alua_dh_data *h; - unsigned long flags; - int err = SCSI_DH_OK; + int err; h = kzalloc(sizeof(*h) , GFP_KERNEL); - if (!h) { - sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n", - ALUA_DH_NAME); - return -ENOMEM; - } - - h->dh_data.scsi_dh = &alua_dh; + if (!h) + return ERR_PTR(-ENOMEM); h->tpgs = TPGS_MODE_UNINITIALIZED; h->state = TPGS_STATE_OPTIMIZED; h->group_id = -1; @@ -866,20 +845,14 @@ static int alua_bus_attach(struct scsi_device *sdev) h->sdev = sdev; err = alua_initialize(sdev, h); - if ((err != SCSI_DH_OK) && (err != SCSI_DH_DEV_OFFLINED)) + if (err != SCSI_DH_OK && err != SCSI_DH_DEV_OFFLINED) goto failed; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = &h->dh_data; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); sdev_printk(KERN_NOTICE, sdev, "%s: Attached\n", ALUA_DH_NAME); - - return 0; - + return &h->dh_data; failed: kfree(h); - sdev_printk(KERN_ERR, sdev, "%s: not attached\n", ALUA_DH_NAME); - return -EINVAL; + return ERR_PTR(-EINVAL); } /* @@ -889,18 +862,24 @@ failed: static void alua_bus_detach(struct scsi_device *sdev) { struct alua_dh_data *h = get_alua_data(sdev); - unsigned long flags; - - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = NULL; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); if (h->buff && h->inq != h->buff) kfree(h->buff); kfree(h); - sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", ALUA_DH_NAME); } +static struct scsi_device_handler alua_dh = { + .name = ALUA_DH_NAME, + .module = THIS_MODULE, + .attach = alua_bus_attach, + .detach = alua_bus_detach, + .prep_fn = alua_prep_fn, + .check_sense = alua_check_sense, + .activate = alua_activate, + .set_params = alua_set_params, + .match = alua_match, +}; + static int __init alua_init(void) { int r; diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 800deb75a111..6ed1caadbc6a 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -650,35 +650,14 @@ static bool clariion_match(struct scsi_device *sdev) return false; } -static int clariion_bus_attach(struct scsi_device *sdev); -static void clariion_bus_detach(struct scsi_device *sdev); - -static struct scsi_device_handler clariion_dh = { - .name = CLARIION_NAME, - .module = THIS_MODULE, - .attach = clariion_bus_attach, - .detach = clariion_bus_detach, - .check_sense = clariion_check_sense, - .activate = clariion_activate, - .prep_fn = clariion_prep_fn, - .set_params = clariion_set_params, - .match = clariion_match, -}; - -static int clariion_bus_attach(struct scsi_device *sdev) +static struct scsi_dh_data *clariion_bus_attach(struct scsi_device *sdev) { struct clariion_dh_data *h; - unsigned long flags; int err; h = kzalloc(sizeof(*h) , GFP_KERNEL); - if (!h) { - sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n", - CLARIION_NAME); - return -ENOMEM; - } - - h->dh_data.scsi_dh = &clariion_dh; + if (!h) + return ERR_PTR(-ENOMEM); h->lun_state = CLARIION_LUN_UNINITIALIZED; h->default_sp = CLARIION_UNBOUND_LU; h->current_sp = CLARIION_UNBOUND_LU; @@ -691,40 +670,37 @@ static int clariion_bus_attach(struct scsi_device *sdev) if (err != SCSI_DH_OK) goto failed; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = &h->dh_data; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - sdev_printk(KERN_INFO, sdev, "%s: connected to SP %c Port %d (%s, default SP %c)\n", CLARIION_NAME, h->current_sp + 'A', h->port, lun_state[h->lun_state], h->default_sp + 'A'); - - return 0; + return &h->dh_data; failed: kfree(h); - sdev_printk(KERN_ERR, sdev, "%s: not attached\n", - CLARIION_NAME); - return -EINVAL; + return ERR_PTR(-EINVAL); } static void clariion_bus_detach(struct scsi_device *sdev) { struct clariion_dh_data *h = get_clariion_data(sdev); - unsigned long flags; - - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = NULL; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - - sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", - CLARIION_NAME); kfree(h); } +static struct scsi_device_handler clariion_dh = { + .name = CLARIION_NAME, + .module = THIS_MODULE, + .attach = clariion_bus_attach, + .detach = clariion_bus_detach, + .check_sense = clariion_check_sense, + .activate = clariion_activate, + .prep_fn = clariion_prep_fn, + .set_params = clariion_set_params, + .match = clariion_match, +}; + static int __init clariion_init(void) { int r; diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 471ffd19f2c5..485d99544a15 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -340,33 +340,14 @@ static bool hp_sw_match(struct scsi_device *sdev) return false; } -static int hp_sw_bus_attach(struct scsi_device *sdev); -static void hp_sw_bus_detach(struct scsi_device *sdev); - -static struct scsi_device_handler hp_sw_dh = { - .name = HP_SW_NAME, - .module = THIS_MODULE, - .attach = hp_sw_bus_attach, - .detach = hp_sw_bus_detach, - .activate = hp_sw_activate, - .prep_fn = hp_sw_prep_fn, - .match = hp_sw_match, -}; - -static int hp_sw_bus_attach(struct scsi_device *sdev) +static struct scsi_dh_data *hp_sw_bus_attach(struct scsi_device *sdev) { struct hp_sw_dh_data *h; - unsigned long flags; int ret; h = kzalloc(sizeof(*h), GFP_KERNEL); - if (!h) { - sdev_printk(KERN_ERR, sdev, "%s: Attach Failed\n", - HP_SW_NAME); - return -ENOMEM; - } - - h->dh_data.scsi_dh = &hp_sw_dh; + if (!h) + return ERR_PTR(-ENOMEM); h->path_state = HP_SW_PATH_UNINITIALIZED; h->retries = HP_SW_RETRIES; h->sdev = sdev; @@ -375,37 +356,32 @@ static int hp_sw_bus_attach(struct scsi_device *sdev) if (ret != SCSI_DH_OK || h->path_state == HP_SW_PATH_UNINITIALIZED) goto failed; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = &h->dh_data; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - sdev_printk(KERN_INFO, sdev, "%s: attached to %s path\n", HP_SW_NAME, h->path_state == HP_SW_PATH_ACTIVE? "active":"passive"); - - return 0; - + return &h->dh_data; failed: kfree(h); - sdev_printk(KERN_ERR, sdev, "%s: not attached\n", - HP_SW_NAME); - return -EINVAL; + return ERR_PTR(-EINVAL); } static void hp_sw_bus_detach( struct scsi_device *sdev ) { struct hp_sw_dh_data *h = get_hp_sw_data(sdev); - unsigned long flags; - - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = NULL; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - - sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", HP_SW_NAME); kfree(h); } +static struct scsi_device_handler hp_sw_dh = { + .name = HP_SW_NAME, + .module = THIS_MODULE, + .attach = hp_sw_bus_attach, + .detach = hp_sw_bus_detach, + .activate = hp_sw_activate, + .prep_fn = hp_sw_prep_fn, + .match = hp_sw_match, +}; + static int __init hp_sw_init(void) { return scsi_register_device_handler(&hp_sw_dh); diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 8b09528613d2..b46ace3d4bf0 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -827,36 +827,16 @@ static bool rdac_match(struct scsi_device *sdev) return false; } -static int rdac_bus_attach(struct scsi_device *sdev); -static void rdac_bus_detach(struct scsi_device *sdev); - -static struct scsi_device_handler rdac_dh = { - .name = RDAC_NAME, - .module = THIS_MODULE, - .prep_fn = rdac_prep_fn, - .check_sense = rdac_check_sense, - .attach = rdac_bus_attach, - .detach = rdac_bus_detach, - .activate = rdac_activate, - .match = rdac_match, -}; - -static int rdac_bus_attach(struct scsi_device *sdev) +static struct scsi_dh_data *rdac_bus_attach(struct scsi_device *sdev) { struct rdac_dh_data *h; - unsigned long flags; int err; char array_name[ARRAY_LABEL_LEN]; char array_id[UNIQUE_ID_LEN]; h = kzalloc(sizeof(*h) , GFP_KERNEL); - if (!h) { - sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n", - RDAC_NAME); - return -ENOMEM; - } - - h->dh_data.scsi_dh = &rdac_dh; + if (!h) + return ERR_PTR(-ENOMEM); h->lun = UNINITIALIZED_LUN; h->state = RDAC_STATE_ACTIVE; @@ -876,16 +856,12 @@ static int rdac_bus_attach(struct scsi_device *sdev) if (err != SCSI_DH_OK) goto clean_ctlr; - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = &h->dh_data; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - sdev_printk(KERN_NOTICE, sdev, "%s: LUN %d (%s) (%s)\n", RDAC_NAME, h->lun, mode[(int)h->mode], lun_state[(int)h->lun_state]); - return 0; + return &h->dh_data; clean_ctlr: spin_lock(&list_lock); @@ -894,32 +870,33 @@ clean_ctlr: failed: kfree(h); - sdev_printk(KERN_ERR, sdev, "%s: not attached\n", - RDAC_NAME); - return -EINVAL; + return ERR_PTR(-EINVAL); } static void rdac_bus_detach( struct scsi_device *sdev ) { struct rdac_dh_data *h = get_rdac_data(sdev); - unsigned long flags; if (h->ctlr && h->ctlr->ms_queued) flush_workqueue(kmpath_rdacd); - spin_lock_irqsave(sdev->request_queue->queue_lock, flags); - sdev->scsi_dh_data = NULL; - spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); - spin_lock(&list_lock); if (h->ctlr) kref_put(&h->ctlr->kref, release_controller); spin_unlock(&list_lock); kfree(h); - sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME); } - +static struct scsi_device_handler rdac_dh = { + .name = RDAC_NAME, + .module = THIS_MODULE, + .prep_fn = rdac_prep_fn, + .check_sense = rdac_check_sense, + .attach = rdac_bus_attach, + .detach = rdac_bus_detach, + .activate = rdac_activate, + .match = rdac_match, +}; static int __init rdac_init(void) { diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 2601c97fd8b9..50d47e6e89d1 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -210,7 +210,7 @@ struct scsi_device_handler { struct module *module; const char *name; int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); - int (*attach)(struct scsi_device *); + struct scsi_dh_data *(*attach)(struct scsi_device *); void (*detach)(struct scsi_device *); int (*activate)(struct scsi_device *, activate_complete, void *); int (*prep_fn)(struct scsi_device *, struct request *); -- cgit v1.2.3 From a62182f338b39a22035531c6afc0a8d2928b1df2 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 2 Oct 2014 14:39:55 +0200 Subject: scsi: provide a generic change_queue_type method Most drivers use exactly the same implementation, so provide it as a library function. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Mike Christie Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/infiniband/ulp/srp/ib_srp.c | 24 +----------------------- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 +- drivers/scsi/esas2r/esas2r.h | 1 - drivers/scsi/esas2r/esas2r_main.c | 20 +------------------- drivers/scsi/fcoe/fcoe.c | 2 +- drivers/scsi/fnic/fnic_main.c | 2 +- drivers/scsi/ibmvscsi/ibmvfc.c | 25 +------------------------ drivers/scsi/ipr.c | 20 +++----------------- drivers/scsi/libfc/fc_fcp.c | 20 -------------------- drivers/scsi/lpfc/lpfc_scsi.c | 24 ++---------------------- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 24 +----------------------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 25 +------------------------ drivers/scsi/pmcraid.c | 14 ++++---------- drivers/scsi/qla2xxx/qla_os.c | 18 +----------------- drivers/scsi/scsi.c | 20 ++++++++++++++++++++ drivers/scsi/scsi_debug.c | 9 +-------- drivers/target/loopback/tcm_loop.c | 17 +---------------- include/scsi/libfc.h | 1 - include/scsi/scsi_tcq.h | 2 ++ 19 files changed, 42 insertions(+), 228 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 62d2a18e1b41..51670d75ab78 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2258,28 +2258,6 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) return 0; } -/** - * srp_change_queue_type - changing device queue tag type - * @sdev: scsi device struct - * @tag_type: requested tag type - * - * Returns queue tag type. - */ -static int -srp_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} - /** * srp_change_queue_depth - setting device queue depth * @sdev: scsi device struct @@ -2600,7 +2578,7 @@ static struct scsi_host_template srp_template = { .info = srp_target_info, .queuecommand = srp_queuecommand, .change_queue_depth = srp_change_queue_depth, - .change_queue_type = srp_change_queue_type, + .change_queue_type = scsi_change_queue_type, .eh_abort_handler = srp_abort, .eh_device_reset_handler = srp_reset_device, .eh_host_reset_handler = srp_reset_host, diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 79e5c94107a9..3c6dc8abc776 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2784,7 +2784,7 @@ static struct scsi_host_template bnx2fc_shost_template = { .eh_host_reset_handler = fc_eh_host_reset, .slave_alloc = fc_slave_alloc, .change_queue_depth = fc_change_queue_depth, - .change_queue_type = fc_change_queue_type, + .change_queue_type = scsi_change_queue_type, .this_id = -1, .cmd_per_lun = 3, .use_clustering = ENABLE_CLUSTERING, diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index 3fd305d6b67d..20ab211983f2 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -976,7 +976,6 @@ int esas2r_slave_alloc(struct scsi_device *dev); int esas2r_slave_configure(struct scsi_device *dev); void esas2r_slave_destroy(struct scsi_device *dev); int esas2r_change_queue_depth(struct scsi_device *dev, int depth, int reason); -int esas2r_change_queue_type(struct scsi_device *dev, int type); long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); /* SCSI error handler (eh) functions */ diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 45aa684f8b74..be09c628d034 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -258,7 +258,7 @@ static struct scsi_host_template driver_template = { .slave_alloc = esas2r_slave_alloc, .slave_destroy = esas2r_slave_destroy, .change_queue_depth = esas2r_change_queue_depth, - .change_queue_type = esas2r_change_queue_type, + .change_queue_type = scsi_change_queue_type, .max_sectors = 0xFFFF, }; @@ -1268,24 +1268,6 @@ int esas2r_change_queue_depth(struct scsi_device *dev, int depth, int reason) return dev->queue_depth; } -int esas2r_change_queue_type(struct scsi_device *dev, int type) -{ - esas2r_log(ESAS2R_LOG_INFO, "change_queue_type %p, %d", dev, type); - - if (dev->tagged_supported) { - scsi_set_tag_type(dev, type); - - if (type) - scsi_activate_tcq(dev, dev->queue_depth); - else - scsi_deactivate_tcq(dev, dev->queue_depth); - } else { - type = 0; - } - - return type; -} - int esas2r_slave_alloc(struct scsi_device *dev) { return 0; diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 4a8ac7d8c76b..86956cc3448e 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -281,7 +281,7 @@ static struct scsi_host_template fcoe_shost_template = { .eh_host_reset_handler = fc_eh_host_reset, .slave_alloc = fc_slave_alloc, .change_queue_depth = fc_change_queue_depth, - .change_queue_type = fc_change_queue_type, + .change_queue_type = scsi_change_queue_type, .this_id = -1, .cmd_per_lun = 3, .can_queue = FCOE_MAX_OUTSTANDING_COMMANDS, diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 8c56fdc3a456..8581ce662cf0 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -113,7 +113,7 @@ static struct scsi_host_template fnic_host_template = { .eh_host_reset_handler = fnic_host_reset, .slave_alloc = fnic_slave_alloc, .change_queue_depth = fc_change_queue_depth, - .change_queue_type = fc_change_queue_type, + .change_queue_type = scsi_change_queue_type, .this_id = -1, .cmd_per_lun = 3, .can_queue = FNIC_DFLT_IO_REQ, diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 598c42cba5a8..48d19a3256ce 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2929,29 +2929,6 @@ static int ibmvfc_change_queue_depth(struct scsi_device *sdev, int qdepth, return sdev->queue_depth; } -/** - * ibmvfc_change_queue_type - Change the device's queue type - * @sdev: scsi device struct - * @tag_type: type of tags to use - * - * Return value: - * actual queue type set - **/ -static int ibmvfc_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} - static ssize_t ibmvfc_show_host_partition_name(struct device *dev, struct device_attribute *attr, char *buf) { @@ -3133,7 +3110,7 @@ static struct scsi_host_template driver_template = { .target_alloc = ibmvfc_target_alloc, .scan_finished = ibmvfc_scan_finished, .change_queue_depth = ibmvfc_change_queue_depth, - .change_queue_type = ibmvfc_change_queue_type, + .change_queue_type = scsi_change_queue_type, .cmd_per_lun = 16, .can_queue = IBMVFC_MAX_REQUESTS_DEFAULT, .this_id = -1, diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 2a9578c116b7..3d689f6023e9 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -4364,24 +4364,10 @@ static int ipr_change_queue_type(struct scsi_device *sdev, int tag_type) spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); res = (struct ipr_resource_entry *)sdev->hostdata; - - if (res) { - if (ipr_is_gscsi(res) && sdev->tagged_supported) { - /* - * We don't bother quiescing the device here since the - * adapter firmware does it for us. - */ - scsi_set_tag_type(sdev, tag_type); - - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - } else + if (res && ipr_is_gscsi(res)) + tag_type = scsi_change_queue_type(sdev, tag_type); + else tag_type = 0; - spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); return tag_type; } diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index 1d7e76e8b447..f3043ad1f35d 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -2195,26 +2195,6 @@ int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) } EXPORT_SYMBOL(fc_change_queue_depth); -/** - * fc_change_queue_type() - Change a device's queue type - * @sdev: The SCSI device whose queue depth is to change - * @tag_type: Identifier for queue type - */ -int fc_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} -EXPORT_SYMBOL(fc_change_queue_type); - /** * fc_fcp_destory() - Tear down the FCP layer for a given local port * @lport: The local port that no longer needs the FCP layer diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index b99399fe2548..2896e52ac6cd 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -344,26 +344,6 @@ lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) return sdev->queue_depth; } -/** - * lpfc_change_queue_type() - Change a device's scsi tag queuing type - * @sdev: Pointer the scsi device whose queue depth is to change - * @tag_type: Identifier for queue tag type - */ -static int -lpfc_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} - /** * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread * @phba: The Hba for which this call is being executed. @@ -6019,7 +5999,7 @@ struct scsi_host_template lpfc_template = { .max_sectors = 0xFFFF, .vendor_id = LPFC_NL_VENDOR_ID, .change_queue_depth = lpfc_change_queue_depth, - .change_queue_type = lpfc_change_queue_type, + .change_queue_type = scsi_change_queue_type, }; struct scsi_host_template lpfc_vport_template = { @@ -6042,5 +6022,5 @@ struct scsi_host_template lpfc_vport_template = { .shost_attrs = lpfc_vport_attrs, .max_sectors = 0xFFFF, .change_queue_depth = lpfc_change_queue_depth, - .change_queue_type = lpfc_change_queue_type, + .change_queue_type = scsi_change_queue_type, }; diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index c80ed0482649..ec36b91c880f 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -1254,28 +1254,6 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) return sdev->queue_depth; } -/** - * _scsih_change_queue_type - changing device queue tag type - * @sdev: scsi device struct - * @tag_type: requested tag type - * - * Returns queue tag type. - */ -static int -_scsih_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} - /** * _scsih_target_alloc - target add routine * @starget: scsi target struct @@ -7653,7 +7631,7 @@ static struct scsi_host_template scsih_driver_template = { .scan_finished = _scsih_scan_finished, .scan_start = _scsih_scan_start, .change_queue_depth = _scsih_change_queue_depth, - .change_queue_type = _scsih_change_queue_type, + .change_queue_type = scsi_change_queue_type, .eh_abort_handler = _scsih_abort, .eh_device_reset_handler = _scsih_dev_reset, .eh_target_reset_handler = _scsih_target_reset, diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 857276b8880f..52464ace282b 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1122,29 +1122,6 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) return sdev->queue_depth; } -/** - * _scsih_change_queue_type - changing device queue tag type - * @sdev: scsi device struct - * @tag_type: requested tag type - * - * Returns queue tag type. - */ -static int -_scsih_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} - - /** * _scsih_target_alloc - target add routine * @starget: scsi target struct @@ -7284,7 +7261,7 @@ static struct scsi_host_template scsih_driver_template = { .scan_finished = _scsih_scan_finished, .scan_start = _scsih_scan_start, .change_queue_depth = _scsih_change_queue_depth, - .change_queue_type = _scsih_change_queue_type, + .change_queue_type = scsi_change_queue_type, .eh_abort_handler = _scsih_abort, .eh_device_reset_handler = _scsih_dev_reset, .eh_target_reset_handler = _scsih_target_reset, diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index bcb64eb1387f..2233ed6b89e3 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -321,16 +321,10 @@ static int pmcraid_change_queue_type(struct scsi_device *scsi_dev, int tag) struct pmcraid_resource_entry *res; res = (struct pmcraid_resource_entry *)scsi_dev->hostdata; - - if ((res) && scsi_dev->tagged_supported && - (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) { - scsi_set_tag_type(scsi_dev, tag); - - if (tag) - scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth); - else - scsi_deactivate_tcq(scsi_dev, scsi_dev->queue_depth); - } else + if (res && scsi_dev->tagged_supported && + (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) + tag = scsi_change_queue_type(scsi_dev, tag); + else tag = 0; return tag; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index db3dbd999cb6..5e755747e073 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -237,7 +237,6 @@ static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); static int qla2xxx_eh_host_reset(struct scsi_cmnd *); static int qla2x00_change_queue_depth(struct scsi_device *, int, int); -static int qla2x00_change_queue_type(struct scsi_device *, int); static void qla2x00_clear_drv_active(struct qla_hw_data *); static void qla2x00_free_device(scsi_qla_host_t *); static void qla83xx_disable_laser(scsi_qla_host_t *vha); @@ -260,7 +259,7 @@ struct scsi_host_template qla2xxx_driver_template = { .scan_finished = qla2xxx_scan_finished, .scan_start = qla2xxx_scan_start, .change_queue_depth = qla2x00_change_queue_depth, - .change_queue_type = qla2x00_change_queue_type, + .change_queue_type = scsi_change_queue_type, .this_id = -1, .cmd_per_lun = 3, .use_clustering = ENABLE_CLUSTERING, @@ -1473,21 +1472,6 @@ qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) return sdev->queue_depth; } -static int -qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; - - return tag_type; -} - /** * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. * @ha: HA context diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index bc52bbd97381..9baeff03dd9b 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -866,6 +866,26 @@ int scsi_track_queue_full(struct scsi_device *sdev, int depth) } EXPORT_SYMBOL(scsi_track_queue_full); +/** + * scsi_change_queue_type() - Change a device's queue type + * @sdev: The SCSI device whose queue depth is to change + * @tag_type: Identifier for queue type + */ +int scsi_change_queue_type(struct scsi_device *sdev, int tag_type) +{ + if (sdev->tagged_supported) { + scsi_set_tag_type(sdev, tag_type); + if (tag_type) + scsi_activate_tcq(sdev, sdev->queue_depth); + else + scsi_deactivate_tcq(sdev, sdev->queue_depth); + } else + tag_type = 0; + + return tag_type; +} +EXPORT_SYMBOL(scsi_change_queue_type); + /** * scsi_vpd_inquiry - Request a device provide us with a VPD page * @sdev: The device to ask diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 238e06f13b8a..7bcace2cdd53 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4532,14 +4532,7 @@ sdebug_change_qdepth(struct scsi_device *sdev, int qdepth, int reason) static int sdebug_change_qtype(struct scsi_device *sdev, int qtype) { - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, qtype); - if (qtype) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - qtype = 0; + qtype = scsi_change_queue_type(sdev, qtype); if (SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) { const char *cp; diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index ab3ab27d49b7..3b9c76835b45 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -135,21 +135,6 @@ static int tcm_loop_change_queue_depth( return sdev->queue_depth; } -static int tcm_loop_change_queue_type(struct scsi_device *sdev, int tag) -{ - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag); - - if (tag) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag = 0; - - return tag; -} - /* * Locate the SAM Task Attr from struct scsi_cmnd * */ @@ -451,7 +436,7 @@ static struct scsi_host_template tcm_loop_driver_template = { .name = "TCM_Loopback", .queuecommand = tcm_loop_queuecommand, .change_queue_depth = tcm_loop_change_queue_depth, - .change_queue_type = tcm_loop_change_queue_type, + .change_queue_type = scsi_change_queue_type, .eh_abort_handler = tcm_loop_abort_task, .eh_device_reset_handler = tcm_loop_device_reset, .eh_target_reset_handler = tcm_loop_target_reset, diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 52beadf9a29b..2e0cf568a9c1 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -1106,7 +1106,6 @@ int fc_eh_device_reset(struct scsi_cmnd *); int fc_eh_host_reset(struct scsi_cmnd *); int fc_slave_alloc(struct scsi_device *); int fc_change_queue_depth(struct scsi_device *, int qdepth, int reason); -int fc_change_queue_type(struct scsi_device *, int tag_type); /* * ELS/CT interface diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 7529c6acc231..1712dab6e00e 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -16,6 +16,8 @@ #ifdef CONFIG_BLOCK +int scsi_change_queue_type(struct scsi_device *sdev, int tag_type); + /** * scsi_get_tag_type - get the type of tag the device supports * @sdev: the scsi device -- cgit v1.2.3 From 125c99bc8b6b108d251169a86324a7ed3c6f3cce Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 12:47:47 +0100 Subject: scsi: add new scsi-command flag for tagged commands Currently scsi piggy backs on the block layer to define the concept of a tagged command. But we want to be able to have block-level host-wide tags assigned even for untagged commands like the initial INQUIRY, so add a new SCSI-level flag for commands that are tagged at the scsi level, so that even commands without that set can have tags assigned to them. Note that this alredy is the case for the blk-mq code path, and this just lets the old path catch up with it. We also set this flag based upon sdev->simple_tags instead of the block queue flag, so that it is entirely independent of the block layer tagging, and thus always correct even if a driver doesn't use block level tagging yet. Also remove the old blk_rq_tagged; it was only used by SCSI drivers, and removing it forces them to look for the proper replacement. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- Documentation/block/biodoc.txt | 4 ---- block/blk-core.c | 4 ++-- drivers/scsi/53c700.c | 6 +++--- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 +- drivers/scsi/scsi_lib.c | 13 +++++++++---- drivers/usb/storage/uas.c | 2 +- include/linux/blkdev.h | 1 - include/scsi/scsi_cmnd.h | 4 ++++ include/scsi/scsi_tcq.h | 6 ++---- 9 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt index 2101e718670d..6b972b287795 100644 --- a/Documentation/block/biodoc.txt +++ b/Documentation/block/biodoc.txt @@ -827,10 +827,6 @@ but in the event of any barrier requests in the tag queue we need to ensure that requests are restarted in the order they were queue. This may happen if the driver needs to use blk_queue_invalidate_tags(). -Tagging also defines a new request flag, REQ_QUEUED. This is set whenever -a request is currently tagged. You should not use this flag directly, -blk_rq_tagged(rq) is the portable way to do so. - 3.3 I/O Submission The routine submit_bio() is used to submit a single io. Higher level i/o diff --git a/block/blk-core.c b/block/blk-core.c index 0421b53e6431..2e7424b42947 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1266,7 +1266,7 @@ void blk_requeue_request(struct request_queue *q, struct request *rq) blk_clear_rq_complete(rq); trace_block_rq_requeue(q, rq); - if (blk_rq_tagged(rq)) + if (rq->cmd_flags & REQ_QUEUED) blk_queue_end_tag(q, rq); BUG_ON(blk_queued_rq(rq)); @@ -2554,7 +2554,7 @@ EXPORT_SYMBOL_GPL(blk_unprep_request); */ void blk_finish_request(struct request *req, int error) { - if (blk_rq_tagged(req)) + if (req->cmd_flags & REQ_QUEUED) blk_queue_end_tag(req->q, req); BUG_ON(blk_queued_rq(req)); diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 474cc6dc98e2..5143d3213e86 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -1767,7 +1767,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *) */ if(NCR_700_get_depth(SCp->device) != 0 && (!(hostdata->tag_negotiated & (1<request))) { + || !(SCp->flags & SCMD_TAGGED))) { CDEBUG(KERN_ERR, SCp, "has non zero depth %d\n", NCR_700_get_depth(SCp->device)); return SCSI_MLQUEUE_DEVICE_BUSY; @@ -1795,7 +1795,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *) printk("53c700: scsi%d, command ", SCp->device->host->host_no); scsi_print_command(SCp); #endif - if(blk_rq_tagged(SCp->request) + if ((SCp->flags & SCMD_TAGGED) && (hostdata->tag_negotiated &(1<device) == NCR_700_START_TAG_NEGOTIATION) { scmd_printk(KERN_ERR, SCp, "Enabling Tag Command Queuing\n"); @@ -1809,7 +1809,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *) * * FIXME: This will royally screw up on multiple LUN devices * */ - if(!blk_rq_tagged(SCp->request) + if (!(SCp->flags & SCMD_TAGGED) && (hostdata->tag_negotiated &(1<tag_negotiated &= ~(1<request) + if (!(cmd->flags & SCMD_TAGGED) && (ahc->features & AHC_SCB_BTT) == 0) { int target_offset; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 38f8c85957b6..994eb083fff9 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1740,7 +1740,7 @@ static void scsi_request_fn(struct request_queue *q) * we add the dev to the starved list so it eventually gets * a run when a tag is freed. */ - if (blk_queue_tagged(q) && !blk_rq_tagged(req)) { + if (blk_queue_tagged(q) && !(req->cmd_flags & REQ_QUEUED)) { spin_lock_irq(shost->host_lock); if (list_empty(&sdev->starved_entry)) list_add_tail(&sdev->starved_entry, @@ -1754,6 +1754,11 @@ static void scsi_request_fn(struct request_queue *q) if (!scsi_host_queue_ready(q, shost, sdev)) goto host_not_ready; + + if (sdev->simple_tags) + cmd->flags |= SCMD_TAGGED; + else + cmd->flags &= ~SCMD_TAGGED; /* * Finally, initialize any error handling parameters, and set up @@ -1908,10 +1913,10 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req, blk_mq_start_request(req); } - if (blk_queue_tagged(q)) - req->cmd_flags |= REQ_QUEUED; + if (sdev->simple_tags) + cmd->flags |= SCMD_TAGGED; else - req->cmd_flags &= ~REQ_QUEUED; + cmd->flags &= ~SCMD_TAGGED; scsi_init_cmd_errh(cmd); cmd->scsi_done = scsi_mq_done; diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 89b24349269e..b38bc1318a60 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -181,7 +181,7 @@ static int uas_get_tag(struct scsi_cmnd *cmnd) { int tag; - if (blk_rq_tagged(cmnd->request)) + if (cmnd->flags & SCMD_TAGGED) tag = cmnd->request->tag + 2; else tag = 1; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index aac0f9ea952a..6d76b8b4aa2b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1136,7 +1136,6 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk) /* * tag stuff */ -#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED) extern int blk_queue_start_tag(struct request_queue *, struct request *); extern struct request *blk_queue_find_tag(struct request_queue *, int); extern void blk_queue_end_tag(struct request_queue *, struct request *); diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 522a5f27f553..e119142e565e 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -53,6 +53,9 @@ struct scsi_pointer { volatile int phase; }; +/* for scmd->flags */ +#define SCMD_TAGGED (1 << 0) + struct scsi_cmnd { struct scsi_device *device; struct list_head list; /* scsi_cmnd participates in queue lists */ @@ -132,6 +135,7 @@ struct scsi_cmnd { * to be at an address < 16Mb). */ int result; /* Status code from lower level driver */ + int flags; /* Command flags */ unsigned char tag; /* SCSI-II queued command tag */ }; diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 1712dab6e00e..032df74b66d7 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -101,11 +101,9 @@ static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) **/ static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg) { - struct request *req = cmd->request; - - if (blk_rq_tagged(req)) { + if (cmd->flags & SCMD_TAGGED) { *msg++ = MSG_SIMPLE_TAG; - *msg++ = req->tag; + *msg++ = cmd->request->tag; return 2; } -- cgit v1.2.3 From 609aa22f3be76d470a334f39cc2197112dc91bd7 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 30 Oct 2014 11:54:58 +0100 Subject: scsi: remove ordered_tags scsi_device field Remove the ordered_tags field, we haven't been issuing ordered tags based on it since the big barrier rework in 2010. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Bart Van Assche Reviewed-by: Martin K. Petersen --- drivers/message/fusion/mptscsih.c | 5 ++--- drivers/scsi/bfa/bfad_im.c | 11 +++-------- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 16 ++++------------ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 15 +++------------ drivers/scsi/qla2xxx/qla_os.c | 5 +---- drivers/scsi/scsi.c | 13 ++----------- drivers/scsi/scsi_sysfs.c | 13 +++++++------ drivers/scsi/vmw_pvscsi.c | 4 ++-- drivers/target/loopback/tcm_loop.c | 14 +------------- include/scsi/scsi_device.h | 1 - include/scsi/scsi_tcq.h | 9 --------- 11 files changed, 25 insertions(+), 81 deletions(-) diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index e7dcb2583369..00bd13dc3dc4 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -2400,9 +2400,8 @@ mptscsih_slave_configure(struct scsi_device *sdev) mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH, SCSI_QDEPTH_DEFAULT); dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT - "tagged %d, simple %d, ordered %d\n", - ioc->name,sdev->tagged_supported, sdev->simple_tags, - sdev->ordered_tags)); + "tagged %d, simple %d\n", + ioc->name,sdev->tagged_supported, sdev->simple_tags)); blk_queue_dma_alignment (sdev->request_queue, 512 - 1); diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index f067332bf763..99280e89c289 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -868,14 +868,9 @@ bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim, struct scsi_device *sdev) if (bfa_lun_queue_depth > tmp_sdev->queue_depth) { if (tmp_sdev->id != sdev->id) continue; - if (tmp_sdev->ordered_tags) - scsi_adjust_queue_depth(tmp_sdev, - MSG_ORDERED_TAG, - tmp_sdev->queue_depth + 1); - else - scsi_adjust_queue_depth(tmp_sdev, - MSG_SIMPLE_TAG, - tmp_sdev->queue_depth + 1); + scsi_adjust_queue_depth(tmp_sdev, + MSG_SIMPLE_TAG, + tmp_sdev->queue_depth + 1); itnim->last_ramp_up_time = jiffies; } diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index ec36b91c880f..69dc166b52bc 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -1246,9 +1246,9 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) if (sdev->inquiry_len > 7) sdev_printk(KERN_INFO, sdev, "qdepth(%d), tagged(%d), " - "simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n", + "simple(%d), scsi_level(%d), cmd_que(%d)\n", sdev->queue_depth, sdev->tagged_supported, sdev->simple_tags, - sdev->ordered_tags, sdev->scsi_level, + sdev->scsi_level, (sdev->inquiry[7] & 2) >> 1); return sdev->queue_depth; @@ -3944,16 +3944,8 @@ _scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) mpi_control = MPI2_SCSIIO_CONTROL_NODATATRANSFER; /* set tags */ - if (!(sas_device_priv_data->flags & MPT_DEVICE_FLAGS_INIT)) { - if (scmd->device->tagged_supported) { - if (scmd->device->ordered_tags) - mpi_control |= MPI2_SCSIIO_CONTROL_ORDEREDQ; - else - mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; - } else - mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; - } else - mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; + mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; + /* Make sure Device is not raid volume. * We do not expose raid functionality to upper layer for warpdrive. */ diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 52464ace282b..d3abf254341d 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1114,9 +1114,9 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) if (sdev->inquiry_len > 7) sdev_printk(KERN_INFO, sdev, "qdepth(%d), tagged(%d), " \ - "simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n", + "simple(%d), scsi_level(%d), cmd_que(%d)\n", sdev->queue_depth, sdev->tagged_supported, sdev->simple_tags, - sdev->ordered_tags, sdev->scsi_level, + sdev->scsi_level, (sdev->inquiry[7] & 2) >> 1); return sdev->queue_depth; @@ -3563,16 +3563,7 @@ _scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) mpi_control = MPI2_SCSIIO_CONTROL_NODATATRANSFER; /* set tags */ - if (!(sas_device_priv_data->flags & MPT_DEVICE_FLAGS_INIT)) { - if (scmd->device->tagged_supported) { - if (scmd->device->ordered_tags) - mpi_control |= MPI2_SCSIIO_CONTROL_ORDEREDQ; - else - mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; - } else - mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; - } else - mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; + mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON) && scmd->cmd_len != 32) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 5e755747e073..1e34fcf68e77 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1442,10 +1442,7 @@ static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) return; - if (sdev->ordered_tags) - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth); - else - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); + scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); ql_dbg(ql_dbg_io, vha, 0x302a, "Queue depth adjusted-up to %d for nexus=%ld:%d:%llu.\n", diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 9baeff03dd9b..22c449e926fa 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -789,19 +789,13 @@ void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags) sdev->queue_depth = tags; switch (tagged) { case 0: - sdev->ordered_tags = 0; sdev->simple_tags = 0; break; case MSG_ORDERED_TAG: - sdev->ordered_tags = 1; - sdev->simple_tags = 1; - break; case MSG_SIMPLE_TAG: - sdev->ordered_tags = 0; sdev->simple_tags = 1; break; default: - sdev->ordered_tags = 0; sdev->simple_tags = 0; sdev_printk(KERN_WARNING, sdev, "scsi_adjust_queue_depth, bad queue type, " @@ -857,11 +851,8 @@ int scsi_track_queue_full(struct scsi_device *sdev, int depth) scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); return -1; } - - if (sdev->ordered_tags) - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth); - else - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); + + scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); return depth; } EXPORT_SYMBOL(scsi_track_queue_full); diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index f4cb7b3e9e23..35d93b0af82b 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -727,9 +727,7 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr, struct scsi_device *sdev = to_scsi_device(dev); const char *name = "none"; - if (sdev->ordered_tags) - name = "ordered"; - else if (sdev->simple_tags) + if (sdev->simple_tags) name = "simple"; return snprintf(buf, 20, "%s\n", name); @@ -747,9 +745,12 @@ store_queue_type_field(struct device *dev, struct device_attribute *attr, if (!sdev->tagged_supported || !sht->change_queue_type) return -EINVAL; - if (strncmp(buf, "ordered", 7) == 0) - tag_type = MSG_ORDERED_TAG; - else if (strncmp(buf, "simple", 6) == 0) + /* + * We're never issueing order tags these days, but allow the value + * for backwards compatibility. + */ + if (strncmp(buf, "ordered", 7) == 0 || + strncmp(buf, "simple", 6) == 0) tag_type = MSG_SIMPLE_TAG; else if (strncmp(buf, "none", 4) != 0) return -EINVAL; diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 598f65efaaec..53a3eb6c0634 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -526,9 +526,9 @@ static int pvscsi_change_queue_depth(struct scsi_device *sdev, if (sdev->inquiry_len > 7) sdev_printk(KERN_INFO, sdev, - "qdepth(%d), tagged(%d), simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n", + "qdepth(%d), tagged(%d), simple(%d), scsi_level(%d), cmd_que(%d)\n", sdev->queue_depth, sdev->tagged_supported, - sdev->simple_tags, sdev->ordered_tags, + sdev->simple_tags, sdev->scsi_level, (sdev->inquiry[7] & 2) >> 1); return sdev->queue_depth; } diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 3b9c76835b45..e30932f989a1 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -135,18 +135,6 @@ static int tcm_loop_change_queue_depth( return sdev->queue_depth; } -/* - * Locate the SAM Task Attr from struct scsi_cmnd * - */ -static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag) -{ - if (sc->device->tagged_supported && - sc->device->ordered_tags && tag >= 0) - return MSG_ORDERED_TAG; - - return MSG_SIMPLE_TAG; -} - static void tcm_loop_submission_work(struct work_struct *work) { struct tcm_loop_cmd *tl_cmd = @@ -205,7 +193,7 @@ static void tcm_loop_submission_work(struct work_struct *work) rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun, - transfer_length, tcm_loop_sam_attr(sc, tl_cmd->sc_cmd_tag), + transfer_length, MSG_SIMPLE_TAG, sc->sc_data_direction, 0, scsi_sglist(sc), scsi_sg_count(sc), sgl_bidi, sgl_bidi_count, diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 50d47e6e89d1..e8fecb5ea79a 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -141,7 +141,6 @@ struct scsi_device { unsigned ppr:1; /* Device supports PPR messages */ unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ unsigned simple_tags:1; /* simple queue tag messages are enabled */ - unsigned ordered_tags:1;/* ordered queue tag messages are enabled */ unsigned was_reset:1; /* There was a bus reset on the bus for * this device */ unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 032df74b66d7..342f38c5b065 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -21,17 +21,11 @@ int scsi_change_queue_type(struct scsi_device *sdev, int tag_type); /** * scsi_get_tag_type - get the type of tag the device supports * @sdev: the scsi device - * - * Notes: - * If the drive only supports simple tags, returns MSG_SIMPLE_TAG - * if it supports all tag types, returns MSG_ORDERED_TAG. */ static inline int scsi_get_tag_type(struct scsi_device *sdev) { if (!sdev->tagged_supported) return 0; - if (sdev->ordered_tags) - return MSG_ORDERED_TAG; if (sdev->simple_tags) return MSG_SIMPLE_TAG; return 0; @@ -41,15 +35,12 @@ static inline void scsi_set_tag_type(struct scsi_device *sdev, int tag) { switch (tag) { case MSG_ORDERED_TAG: - sdev->ordered_tags = 1; - /* fall through */ case MSG_SIMPLE_TAG: sdev->simple_tags = 1; break; case 0: /* fall through */ default: - sdev->ordered_tags = 0; sdev->simple_tags = 0; break; } -- cgit v1.2.3 From abd0c533e37789ef56a73562d6d06d39897bd801 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 14:47:07 +0100 Subject: scsi: remove ordered_tag host template field Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Mike Christie Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/scsi/hosts.c | 1 - drivers/usb/storage/uas.c | 1 - include/scsi/scsi_host.h | 10 ---------- 3 files changed, 12 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 06030e1ad696..8bb173e01084 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -418,7 +418,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->cmd_per_lun = sht->cmd_per_lun; shost->unchecked_isa_dma = sht->unchecked_isa_dma; shost->use_clustering = sht->use_clustering; - shost->ordered_tag = sht->ordered_tag; shost->no_write_same = sht->no_write_same; if (shost_eh_deadline == -1 || !sht->eh_host_reset_handler) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index b38bc1318a60..1bc5df4200a7 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -817,7 +817,6 @@ static struct scsi_host_template uas_host_template = { .sg_tablesize = SG_NONE, .cmd_per_lun = 1, /* until we override it */ .skip_settle_delay = 1, - .ordered_tag = 1, /* * The uas drivers expects tags not to be bigger than the maximum diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index bb9e27815be5..5b03ba9d7390 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -451,11 +451,6 @@ struct scsi_host_template { */ unsigned skip_settle_delay:1; - /* - * True if we are using ordered write support. - */ - unsigned ordered_tag:1; - /* True if the controller does not support WRITE SAME */ unsigned no_write_same:1; @@ -670,11 +665,6 @@ struct Scsi_Host { */ unsigned reverse_ordering:1; - /* - * Ordered write support - */ - unsigned ordered_tag:1; - /* Task mgmt function in progress */ unsigned tmf_in_progress:1; -- cgit v1.2.3 From 5066863337afdb0ad7323f424f7959d9f9f066da Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 30 Oct 2014 14:30:06 +0100 Subject: scsi: remove abuses of scsi_populate_tag Unless we want to build a SPI tag message we should just check SCMD_TAGGED instead of reverse engineering a tag type through the use of scsi_populate_tag_msg. Also rename the function to spi_populate_tag_msg, make it behave like the other spi message helpers, and move it to the spi transport class. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/s390/scsi/zfcp_fc.h | 14 +----- drivers/scsi/53c700.c | 2 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 9 ---- drivers/scsi/aic7xxx/aic7xxx_osm.c | 10 +---- drivers/scsi/bnx2fc/bnx2fc_io.c | 18 ++------ drivers/scsi/csiostor/csio_scsi.c | 29 ++---------- drivers/scsi/esp_scsi.c | 2 +- drivers/scsi/fnic/fnic_scsi.c | 11 +---- drivers/scsi/ibmvscsi/ibmvfc.c | 16 ++----- drivers/scsi/ipr.c | 34 ++------------ drivers/scsi/lpfc/lpfc_scsi.c | 16 +------ drivers/scsi/pmcraid.c | 34 ++------------ drivers/scsi/qla2xxx/qla_iocb.c | 92 ++------------------------------------ drivers/scsi/qla2xxx/qla_mr.c | 13 ------ drivers/scsi/qla4xxx/ql4_iocb.c | 10 ----- drivers/scsi/scsi_transport_spi.c | 23 ++++++++++ drivers/scsi/tmscsim.c | 12 +++-- include/scsi/scsi_tcq.h | 21 --------- include/scsi/scsi_transport_spi.h | 1 + 19 files changed, 56 insertions(+), 311 deletions(-) diff --git a/drivers/s390/scsi/zfcp_fc.h b/drivers/s390/scsi/zfcp_fc.h index b1d2024ed513..df2b541c8287 100644 --- a/drivers/s390/scsi/zfcp_fc.h +++ b/drivers/s390/scsi/zfcp_fc.h @@ -212,8 +212,6 @@ static inline void zfcp_fc_scsi_to_fcp(struct fcp_cmnd *fcp, struct scsi_cmnd *scsi, u8 tm_flags) { - char tag[2]; - int_to_scsilun(scsi->device->lun, (struct scsi_lun *) &fcp->fc_lun); if (unlikely(tm_flags)) { @@ -221,17 +219,7 @@ void zfcp_fc_scsi_to_fcp(struct fcp_cmnd *fcp, struct scsi_cmnd *scsi, return; } - if (scsi_populate_tag_msg(scsi, tag)) { - switch (tag[0]) { - case MSG_ORDERED_TAG: - fcp->fc_pri_ta |= FCP_PTA_ORDERED; - break; - case MSG_SIMPLE_TAG: - fcp->fc_pri_ta |= FCP_PTA_SIMPLE; - break; - }; - } else - fcp->fc_pri_ta = FCP_PTA_SIMPLE; + fcp->fc_pri_ta = FCP_PTA_SIMPLE; if (scsi->sc_data_direction == DMA_FROM_DEVICE) fcp->fc_flags |= FCP_CFL_RDDATA; diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 5143d3213e86..1b36fd3a6e62 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -1427,7 +1427,7 @@ NCR_700_start_command(struct scsi_cmnd *SCp) if((hostdata->tag_negotiated & (1<tag != SCSI_NO_TAG && SCp->cmnd[0] != REQUEST_SENSE && slot->flags != NCR_700_FLAG_AUTOSENSE)) { - count += scsi_populate_tag_msg(SCp, &hostdata->msgout[count]); + count += spi_populate_tag_msg(&hostdata->msgout[count], SCp); } if(hostdata->fast && diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index ed333669a7dc..d3b6d68107ea 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1619,15 +1619,6 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev, } if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) { - int msg_bytes; - uint8_t tag_msgs[2]; - - msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); - if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { - hscb->control |= tag_msgs[0]; - if (tag_msgs[0] == MSG_ORDERED_TASK) - dev->commands_since_idle_or_otag = 0; - } else if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH && (dev->flags & AHD_DEV_Q_TAGGED) != 0) { hscb->control |= MSG_ORDERED_TASK; diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 63bae7c65c9f..33a5f959e86a 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -1501,15 +1501,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, } if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) { - int msg_bytes; - uint8_t tag_msgs[2]; - - msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); - if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { - hscb->control |= tag_msgs[0]; - if (tag_msgs[0] == MSG_ORDERED_TASK) - dev->commands_since_idle_or_otag = 0; - } else if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH + if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH && (dev->flags & AHC_DEV_Q_TAGGED) != 0) { hscb->control |= MSG_ORDERED_TASK; dev->commands_since_idle_or_otag = 0; diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 5b99844ef6bf..4b56858c1df2 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -1725,7 +1725,6 @@ void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, struct fcp_cmnd *fcp_cmnd) { struct scsi_cmnd *sc_cmd = io_req->sc_cmd; - char tag[2]; memset(fcp_cmnd, 0, sizeof(struct fcp_cmnd)); @@ -1739,21 +1738,10 @@ void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; fcp_cmnd->fc_flags = io_req->io_req_flags; - if (scsi_populate_tag_msg(sc_cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - fcp_cmnd->fc_pri_ta = FCP_PTA_HEADQ; - break; - case ORDERED_QUEUE_TAG: - fcp_cmnd->fc_pri_ta = FCP_PTA_ORDERED; - break; - default: - fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE; - break; - } - } else { + if (sc_cmd->flags & SCMD_TAGGED) + fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE; + else fcp_cmnd->fc_pri_ta = 0; - } } static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index 86103c8475d8..8231505cce0a 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -152,28 +152,6 @@ csio_scsi_itnexus_loss_error(uint16_t error) return 0; } -static inline void -csio_scsi_tag(struct scsi_cmnd *scmnd, uint8_t *tag, uint8_t hq, - uint8_t oq, uint8_t sq) -{ - char stag[2]; - - if (scsi_populate_tag_msg(scmnd, stag)) { - switch (stag[0]) { - case HEAD_OF_QUEUE_TAG: - *tag = hq; - break; - case ORDERED_QUEUE_TAG: - *tag = oq; - break; - default: - *tag = sq; - break; - } - } else - *tag = 0; -} - /* * csio_scsi_fcp_cmnd - Frame the SCSI FCP command paylod. * @req: IO req structure. @@ -192,11 +170,12 @@ csio_scsi_fcp_cmnd(struct csio_ioreq *req, void *addr) int_to_scsilun(scmnd->device->lun, &fcp_cmnd->fc_lun); fcp_cmnd->fc_tm_flags = 0; fcp_cmnd->fc_cmdref = 0; - fcp_cmnd->fc_pri_ta = 0; memcpy(fcp_cmnd->fc_cdb, scmnd->cmnd, 16); - csio_scsi_tag(scmnd, &fcp_cmnd->fc_pri_ta, - FCP_PTA_HEADQ, FCP_PTA_ORDERED, FCP_PTA_SIMPLE); + if (scmnd->flags & SCMD_TAGGED) + fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE; + else + fcp_cmnd->fc_pri_ta = 0; fcp_cmnd->fc_dl = cpu_to_be32(scsi_bufflen(scmnd)); if (req->nsge) diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 55548dc5cec3..b23101b28bfa 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -663,7 +663,7 @@ static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp) return ent; } - if (!scsi_populate_tag_msg(cmd, &ent->tag[0])) { + if (!spi_populate_tag_msg(&ent->tag[0], cmd)) { ent->tag[0] = 0; ent->tag[1] = 0; } diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 961bdf5d31cd..10d5c6bbc9e7 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -325,13 +325,11 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, struct fc_rport_libfc_priv *rp = rport->dd_data; struct host_sg_desc *desc; struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; - u8 pri_tag = 0; unsigned int i; unsigned long intr_flags; int flags; u8 exch_flags; struct scsi_lun fc_lun; - char msg[2]; if (sg_count) { /* For each SGE, create a device desc entry */ @@ -357,12 +355,6 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, int_to_scsilun(sc->device->lun, &fc_lun); - pri_tag = FCPIO_ICMND_PTA_SIMPLE; - msg[0] = MSG_SIMPLE_TAG; - scsi_populate_tag_msg(sc, msg); - if (msg[0] == MSG_ORDERED_TAG) - pri_tag = FCPIO_ICMND_PTA_ORDERED; - /* Enqueue the descriptor in the Copy WQ */ spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); @@ -394,7 +386,8 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, io_req->sgl_list_pa, io_req->sense_buf_pa, 0, /* scsi cmd ref, always 0 */ - pri_tag, /* scsi pri and tag */ + FCPIO_ICMND_PTA_SIMPLE, + /* scsi pri and tag */ flags, /* command flags */ sc->cmnd, sc->cmd_len, scsi_bufflen(sc), diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 48d19a3256ce..a964f8c85833 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -1643,19 +1643,9 @@ static int ibmvfc_queuecommand_lck(struct scsi_cmnd *cmnd, int_to_scsilun(cmnd->device->lun, &vfc_cmd->iu.lun); memcpy(vfc_cmd->iu.cdb, cmnd->cmnd, cmnd->cmd_len); - if (scsi_populate_tag_msg(cmnd, tag)) { - vfc_cmd->task_tag = cpu_to_be64(tag[1]); - switch (tag[0]) { - case MSG_SIMPLE_TAG: - vfc_cmd->iu.pri_task_attr = IBMVFC_SIMPLE_TASK; - break; - case MSG_HEAD_TAG: - vfc_cmd->iu.pri_task_attr = IBMVFC_HEAD_OF_QUEUE; - break; - case MSG_ORDERED_TAG: - vfc_cmd->iu.pri_task_attr = IBMVFC_ORDERED_TASK; - break; - }; + if (cmnd->flags & SCMD_TAGGED) { + vfc_cmd->task_tag = cpu_to_be64(cmnd->tag); + vfc_cmd->iu.pri_task_attr = IBMVFC_SIMPLE_TASK; } if (likely(!(rc = ibmvfc_map_sg_data(cmnd, evt, vfc_cmd, vhost->dev)))) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 3d689f6023e9..6b52feafa929 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -5658,35 +5658,6 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg, return 0; } -/** - * ipr_get_task_attributes - Translate SPI Q-Tag to task attributes - * @scsi_cmd: scsi command struct - * - * Return value: - * task attributes - **/ -static u8 ipr_get_task_attributes(struct scsi_cmnd *scsi_cmd) -{ - u8 tag[2]; - u8 rc = IPR_FLAGS_LO_UNTAGGED_TASK; - - if (scsi_populate_tag_msg(scsi_cmd, tag)) { - switch (tag[0]) { - case MSG_SIMPLE_TAG: - rc = IPR_FLAGS_LO_SIMPLE_TASK; - break; - case MSG_HEAD_TAG: - rc = IPR_FLAGS_LO_HEAD_OF_Q_TASK; - break; - case MSG_ORDERED_TAG: - rc = IPR_FLAGS_LO_ORDERED_TASK; - break; - }; - } - - return rc; -} - /** * ipr_erp_done - Process completion of ERP for a device * @ipr_cmd: ipr command struct @@ -6222,7 +6193,10 @@ static int ipr_queuecommand(struct Scsi_Host *shost, ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_DELAY_AFTER_RST; } ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_ALIGNED_BFR; - ioarcb->cmd_pkt.flags_lo |= ipr_get_task_attributes(scsi_cmd); + if (scsi_cmd->flags & SCMD_TAGGED) + ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_SIMPLE_TASK; + else + ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_UNTAGGED_TASK; } if (scsi_cmd->cmnd[0] >= 0xC0 && diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 2896e52ac6cd..4a150063fb4d 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -4266,7 +4266,6 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq); int datadir = scsi_cmnd->sc_data_direction; - char tag[2]; uint8_t *ptr; bool sli4; uint32_t fcpdl; @@ -4288,20 +4287,7 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, memset(ptr, 0, (LPFC_FCP_CDB_LEN - scsi_cmnd->cmd_len)); } - if (scsi_populate_tag_msg(scsi_cmnd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - fcp_cmnd->fcpCntl1 = HEAD_OF_Q; - break; - case ORDERED_QUEUE_TAG: - fcp_cmnd->fcpCntl1 = ORDERED_Q; - break; - default: - fcp_cmnd->fcpCntl1 = SIMPLE_Q; - break; - } - } else - fcp_cmnd->fcpCntl1 = SIMPLE_Q; + fcp_cmnd->fcpCntl1 = SIMPLE_Q; sli4 = (phba->sli_rev == LPFC_SLI_REV4); piocbq->iocb.un.fcpi.fcpi_XRdy = 0; diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 2233ed6b89e3..d5fb31fa388b 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3168,36 +3168,6 @@ static int pmcraid_eh_host_reset_handler(struct scsi_cmnd *scmd) return pmcraid_reset_bringup(pinstance) == 0 ? SUCCESS : FAILED; } -/** - * pmcraid_task_attributes - Translate SPI Q-Tags to task attributes - * @scsi_cmd: scsi command struct - * - * Return value - * number of tags or 0 if the task is not tagged - */ -static u8 pmcraid_task_attributes(struct scsi_cmnd *scsi_cmd) -{ - char tag[2]; - u8 rc = 0; - - if (scsi_populate_tag_msg(scsi_cmd, tag)) { - switch (tag[0]) { - case MSG_SIMPLE_TAG: - rc = TASK_TAG_SIMPLE; - break; - case MSG_HEAD_TAG: - rc = TASK_TAG_QUEUE_HEAD; - break; - case MSG_ORDERED_TAG: - rc = TASK_TAG_ORDERED; - break; - }; - } - - return rc; -} - - /** * pmcraid_init_ioadls - initializes IOADL related fields in IOARCB * @cmd: pmcraid command struct @@ -3553,7 +3523,9 @@ static int pmcraid_queuecommand_lck( } ioarcb->request_flags0 |= NO_LINK_DESCS; - ioarcb->request_flags1 |= pmcraid_task_attributes(scsi_cmd); + + if (scsi_cmd->flags & SCMD_TAGGED) + ioarcb->request_flags1 |= TASK_TAG_SIMPLE; if (RES_IS_GSCSI(res->cfg_entry)) ioarcb->request_flags1 |= DELAY_AFTER_RESET; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index f0edb07f3198..a1ab25fca874 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -325,7 +325,6 @@ qla2x00_start_scsi(srb_t *sp) struct qla_hw_data *ha; struct req_que *req; struct rsp_que *rsp; - char tag[2]; /* Setup device pointers. */ ret = 0; @@ -404,26 +403,7 @@ qla2x00_start_scsi(srb_t *sp) /* Set target ID and LUN number*/ SET_TARGET_ID(ha, cmd_pkt->target, sp->fcport->loop_id); cmd_pkt->lun = cpu_to_le16(cmd->device->lun); - - /* Update tagged queuing modifier */ - if (scsi_populate_tag_msg(cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - cmd_pkt->control_flags = - __constant_cpu_to_le16(CF_HEAD_TAG); - break; - case ORDERED_QUEUE_TAG: - cmd_pkt->control_flags = - __constant_cpu_to_le16(CF_ORDERED_TAG); - break; - default: - cmd_pkt->control_flags = - __constant_cpu_to_le16(CF_SIMPLE_TAG); - break; - } - } else { - cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG); - } + cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG); /* Load SCSI command packet. */ memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len); @@ -1264,7 +1244,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, uint16_t fcp_cmnd_len; struct fcp_cmnd *fcp_cmnd; dma_addr_t crc_ctx_dma; - char tag[2]; cmd = GET_CMD_SP(sp); @@ -1356,25 +1335,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, cmd_pkt->fcp_cmnd_dseg_address[1] = cpu_to_le32( MSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); fcp_cmnd->task_management = 0; - - /* - * Update tagged queuing modifier if using command tag queuing - */ - if (scsi_populate_tag_msg(cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - fcp_cmnd->task_attribute = TSK_HEAD_OF_QUEUE; - break; - case ORDERED_QUEUE_TAG: - fcp_cmnd->task_attribute = TSK_ORDERED; - break; - default: - fcp_cmnd->task_attribute = TSK_SIMPLE; - break; - } - } else { - fcp_cmnd->task_attribute = TSK_SIMPLE; - } + fcp_cmnd->task_attribute = TSK_SIMPLE; cmd_pkt->fcp_rsp_dseg_len = 0; /* Let response come in status iocb */ @@ -1495,7 +1456,6 @@ qla24xx_start_scsi(srb_t *sp) struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct scsi_qla_host *vha = sp->fcport->vha; struct qla_hw_data *ha = vha->hw; - char tag[2]; /* Setup device pointers. */ ret = 0; @@ -1578,22 +1538,7 @@ qla24xx_start_scsi(srb_t *sp) int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); - /* Update tagged queuing modifier -- default is TSK_SIMPLE (0). */ - if (scsi_populate_tag_msg(cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - cmd_pkt->task = TSK_HEAD_OF_QUEUE; - break; - case ORDERED_QUEUE_TAG: - cmd_pkt->task = TSK_ORDERED; - break; - default: - cmd_pkt->task = TSK_SIMPLE; - break; - } - } else { - cmd_pkt->task = TSK_SIMPLE; - } + cmd_pkt->task = TSK_SIMPLE; /* Load SCSI command packet. */ memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len); @@ -2310,7 +2255,6 @@ qla82xx_start_scsi(srb_t *sp) struct qla_hw_data *ha = vha->hw; struct req_que *req = NULL; struct rsp_que *rsp = NULL; - char tag[2]; /* Setup device pointers. */ ret = 0; @@ -2489,22 +2433,6 @@ sufficient_dsds: else if (cmd->sc_data_direction == DMA_FROM_DEVICE) ctx->fcp_cmnd->additional_cdb_len |= 2; - /* - * Update tagged queuing modifier -- default is TSK_SIMPLE (0). - */ - if (scsi_populate_tag_msg(cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - ctx->fcp_cmnd->task_attribute = - TSK_HEAD_OF_QUEUE; - break; - case ORDERED_QUEUE_TAG: - ctx->fcp_cmnd->task_attribute = - TSK_ORDERED; - break; - } - } - /* Populate the FCP_PRIO. */ if (ha->flags.fcp_prio_enabled) ctx->fcp_cmnd->task_attribute |= @@ -2565,20 +2493,6 @@ sufficient_dsds: host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); - /* - * Update tagged queuing modifier -- default is TSK_SIMPLE (0). - */ - if (scsi_populate_tag_msg(cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - cmd_pkt->task = TSK_HEAD_OF_QUEUE; - break; - case ORDERED_QUEUE_TAG: - cmd_pkt->task = TSK_ORDERED; - break; - } - } - /* Populate the FCP_PRIO. */ if (ha->flags.fcp_prio_enabled) cmd_pkt->task |= sp->fcport->fcp_prio << 3; diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index 80867599527d..6d190b4b82a0 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -3086,7 +3086,6 @@ qlafx00_start_scsi(srb_t *sp) struct cmd_type_7_fx00 *cmd_pkt; struct cmd_type_7_fx00 lcmd_pkt; struct scsi_lun llun; - char tag[2]; /* Setup device pointers. */ ret = 0; @@ -3157,18 +3156,6 @@ qlafx00_start_scsi(srb_t *sp) host_to_adap((uint8_t *)&llun, (uint8_t *)&lcmd_pkt.lun, sizeof(lcmd_pkt.lun)); - /* Update tagged queuing modifier -- default is TSK_SIMPLE (0). */ - if (scsi_populate_tag_msg(cmd, tag)) { - switch (tag[0]) { - case HEAD_OF_QUEUE_TAG: - lcmd_pkt.task = TSK_HEAD_OF_QUEUE; - break; - case ORDERED_QUEUE_TAG: - lcmd_pkt.task = TSK_ORDERED; - break; - } - } - /* Load SCSI command packet. */ host_to_adap(cmd->cmnd, lcmd_pkt.fcp_cdb, sizeof(lcmd_pkt.fcp_cdb)); lcmd_pkt.byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); diff --git a/drivers/scsi/qla4xxx/ql4_iocb.c b/drivers/scsi/qla4xxx/ql4_iocb.c index 08ab6dac226d..17222eb49762 100644 --- a/drivers/scsi/qla4xxx/ql4_iocb.c +++ b/drivers/scsi/qla4xxx/ql4_iocb.c @@ -280,7 +280,6 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb) uint16_t req_cnt; unsigned long flags; uint32_t index; - char tag[2]; /* Get real lun and adapter */ ddb_entry = srb->ddb; @@ -352,15 +351,6 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb) /* Set tagged queueing control flags */ cmd_entry->control_flags |= CF_SIMPLE_TAG; - if (scsi_populate_tag_msg(cmd, tag)) - switch (tag[0]) { - case MSG_HEAD_TAG: - cmd_entry->control_flags |= CF_HEAD_TAG; - break; - case MSG_ORDERED_TAG: - cmd_entry->control_flags |= CF_ORDERED_TAG; - break; - } qla4xxx_advance_req_ring_ptr(ha); qla4xxx_build_scsi_iocbs(srb, cmd_entry, tot_dsds); diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index cf08071a9b6e..fa2aece76cc2 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -1207,6 +1208,28 @@ int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, } EXPORT_SYMBOL_GPL(spi_populate_ppr_msg); +/** + * spi_populate_tag_msg - place a tag message in a buffer + * @msg: pointer to the area to place the tag + * @cmd: pointer to the scsi command for the tag + * + * Notes: + * designed to create the correct type of tag message for the + * particular request. Returns the size of the tag message. + * May return 0 if TCQ is disabled for this device. + **/ +int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd) +{ + if (cmd->flags & SCMD_TAGGED) { + *msg++ = MSG_SIMPLE_TAG; + *msg++ = cmd->request->tag; + return 2; + } + + return 0; +} +EXPORT_SYMBOL_GPL(spi_populate_tag_msg); + #ifdef CONFIG_SCSI_CONSTANTS static const char * const one_byte_msgs[] = { /* 0x00 */ "Task Complete", NULL /* Extended Message */, "Save Pointers", diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c index 764575726c85..547812437a7c 100644 --- a/drivers/scsi/tmscsim.c +++ b/drivers/scsi/tmscsim.c @@ -243,7 +243,6 @@ #include #include - #define DC390_BANNER "Tekram DC390/AM53C974" #define DC390_VERSION "2.1d 2004-05-27" @@ -508,7 +507,6 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_sr struct scsi_cmnd *scmd = pSRB->pcmd; struct scsi_device *sdev = scmd->device; u8 cmd, disc_allowed, try_sync_nego; - char tag[2]; pSRB->ScsiPhase = SCSI_NOP0; @@ -560,11 +558,11 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_sr cmd = SEL_W_ATN; DC390_write8 (ScsiFifo, IDENTIFY(disc_allowed, pDCB->TargetLUN)); /* Change 99/05/31: Don't use tags when not disconnecting (BUSY) */ - if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed && scsi_populate_tag_msg(scmd, tag)) { - DC390_write8(ScsiFifo, tag[0]); - pDCB->TagMask |= 1 << tag[1]; - pSRB->TagNumber = tag[1]; - DC390_write8(ScsiFifo, tag[1]); + if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed && (scmd->flags & SCMD_TAGGED)) { + DC390_write8(ScsiFifo, MSG_SIMPLE_TAG); + pDCB->TagMask |= 1 << scmd->request->tag; + pSRB->TagNumber = scmd->request->tag; + DC390_write8(ScsiFifo, scmd->request->tag); DEBUG1(printk(KERN_INFO "DC390: Select w/DisCn for SRB %p, block tag %02x\n", pSRB, tag[1])); cmd = SEL_W_ATN3; } else { diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 342f38c5b065..005f68da5adb 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -80,27 +80,6 @@ static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) scsi_adjust_queue_depth(sdev, 0, depth); } -/** - * scsi_populate_tag_msg - place a tag message in a buffer - * @SCpnt: pointer to the Scsi_Cmnd for the tag - * @msg: pointer to the area to place the tag - * - * Notes: - * designed to create the correct type of tag message for the - * particular request. Returns the size of the tag message. - * May return 0 if TCQ is disabled for this device. - **/ -static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg) -{ - if (cmd->flags & SCMD_TAGGED) { - *msg++ = MSG_SIMPLE_TAG; - *msg++ = cmd->request->tag; - return 2; - } - - return 0; -} - static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost, int unique_tag) { diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h index 7497a383b1a4..a4fa52b4d5c5 100644 --- a/include/scsi/scsi_transport_spi.h +++ b/include/scsi/scsi_transport_spi.h @@ -157,5 +157,6 @@ int spi_populate_width_msg(unsigned char *msg, int width); int spi_populate_sync_msg(unsigned char *msg, int period, int offset); int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width, int options); +int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd); #endif /* SCSI_TRANSPORT_SPI_H */ -- cgit v1.2.3 From 8f88dc41927f6a9bbb03d5d0496d04ba3775dc8d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 14:49:39 +0100 Subject: mptfusion: don't change queue type in ->change_queue_depth This function shouldn't change the queue type, just the depth. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- drivers/message/fusion/mptscsih.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 00bd13dc3dc4..c0d84a09db9a 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -2322,7 +2322,6 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) VirtTarget *vtarget; struct scsi_target *starget; int max_depth; - int tagged; MPT_ADAPTER *ioc = hd->ioc; starget = scsi_target(sdev); @@ -2347,12 +2346,8 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) if (qdepth > max_depth) qdepth = max_depth; - if (qdepth == 1) - tagged = 0; - else - tagged = MSG_SIMPLE_TAG; - scsi_adjust_queue_depth(sdev, tagged, qdepth); + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); return sdev->queue_depth; } -- cgit v1.2.3 From e2eddf4d530df745019fded0fedfb78f6d3e33ca Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 4 Nov 2014 07:58:28 +0100 Subject: scsi: remove use_blk_tcq Scsi_Host field Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke Reviewed-by: Martin K. Petersen --- include/scsi/scsi_host.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 5b03ba9d7390..d6bd65294009 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -650,7 +650,6 @@ struct Scsi_Host { unsigned active_mode:2; unsigned unchecked_isa_dma:1; unsigned use_clustering:1; - unsigned use_blk_tcq:1; /* * Host has requested that no further requests come through for the -- cgit v1.2.3 From 2ecb204d07ac8debe3893c362415919bc78bebd6 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 14:09:02 +0100 Subject: scsi: always assign block layer tags if enabled Allow a driver to ask for block layer tags by setting .use_blk_tags in the host template, in which case it will always see a valid value in request->tag, similar to the behavior when using blk-mq. This means even SCSI "untagged" commands will now have a tag, which is especially useful when using a host-wide tag map. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- Documentation/scsi/scsi_mid_low_api.txt | 38 +-------------------------------- drivers/message/fusion/mptsas.c | 1 + drivers/scsi/53c700.c | 12 +++++------ drivers/scsi/aic7xxx/aic79xx_osm.c | 11 +++++----- drivers/scsi/aic7xxx/aic7xxx_osm.c | 11 +++++----- drivers/scsi/aic94xx/aic94xx_init.c | 1 + drivers/scsi/bfa/bfad_im.c | 8 +++---- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 1 + drivers/scsi/csiostor/csio_scsi.c | 8 +++---- drivers/scsi/esas2r/esas2r_main.c | 12 +++++------ drivers/scsi/esp_scsi.c | 6 +++--- drivers/scsi/fcoe/fcoe.c | 1 + drivers/scsi/fnic/fnic_main.c | 3 ++- drivers/scsi/ibmvscsi/ibmvfc.c | 11 +++++----- drivers/scsi/ipr.c | 1 + drivers/scsi/isci/init.c | 1 + drivers/scsi/libfc/fc_fcp.c | 7 +----- drivers/scsi/libsas/sas_scsi_host.c | 11 +++------- drivers/scsi/lpfc/lpfc_scsi.c | 7 +++--- drivers/scsi/mvsas/mv_init.c | 1 + drivers/scsi/pm8001/pm8001_init.c | 1 + drivers/scsi/pmcraid.c | 4 ++-- drivers/scsi/qla2xxx/qla_os.c | 6 ++---- drivers/scsi/qla4xxx/ql4_os.c | 10 ++------- drivers/scsi/scsi.c | 12 ++++------- drivers/scsi/scsi_scan.c | 6 ++++++ drivers/scsi/stex.c | 10 ++------- drivers/scsi/tmscsim.c | 3 ++- drivers/scsi/ufs/ufshcd.c | 5 +++-- drivers/target/loopback/tcm_loop.c | 2 +- drivers/usb/storage/uas.c | 4 ++-- include/scsi/scsi_host.h | 5 +++++ include/scsi/scsi_tcq.h | 34 ----------------------------- 33 files changed, 86 insertions(+), 168 deletions(-) diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt index d6a9bdeee7f2..a67194209581 100644 --- a/Documentation/scsi/scsi_mid_low_api.txt +++ b/Documentation/scsi/scsi_mid_low_api.txt @@ -366,13 +366,11 @@ is initialized. The functions below are listed alphabetically and their names all start with "scsi_". Summary: - scsi_activate_tcq - turn on tag command queueing scsi_add_device - creates new scsi device (lu) instance scsi_add_host - perform sysfs registration and set up transport class scsi_adjust_queue_depth - change the queue depth on a SCSI device scsi_bios_ptable - return copy of block device's partition table scsi_block_requests - prevent further commands being queued to given host - scsi_deactivate_tcq - turn off tag command queueing scsi_host_alloc - return a new scsi_host instance whose refcount==1 scsi_host_get - increments Scsi_Host instance's refcount scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) @@ -389,24 +387,6 @@ Summary: Details: -/** - * scsi_activate_tcq - turn on tag command queueing ("ordered" task attribute) - * @sdev: device to turn on TCQ for - * @depth: queue depth - * - * Returns nothing - * - * Might block: no - * - * Notes: Eventually, it is hoped depth would be the maximum depth - * the device could cope with and the real queue depth - * would be adjustable from 0 to depth. - * - * Defined (inline) in: include/scsi/scsi_tcq.h - **/ -void scsi_activate_tcq(struct scsi_device *sdev, int depth) - - /** * scsi_add_device - creates new scsi device (lu) instance * @shost: pointer to scsi host instance @@ -471,9 +451,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device * dev) * * Notes: Can be invoked any time on a SCSI device controlled by this * LLD. [Specifically during and after slave_configure() and prior to - * slave_destroy().] Can safely be invoked from interrupt code. Actual - * queue depth change may be delayed until the next command is being - * processed. See also scsi_activate_tcq() and scsi_deactivate_tcq(). + * slave_destroy().] Can safely be invoked from interrupt code. * * Defined in: drivers/scsi/scsi.c [see source code for more notes] * @@ -514,20 +492,6 @@ unsigned char *scsi_bios_ptable(struct block_device *dev) void scsi_block_requests(struct Scsi_Host * shost) -/** - * scsi_deactivate_tcq - turn off tag command queueing - * @sdev: device to turn off TCQ for - * @depth: queue depth (stored in sdev) - * - * Returns nothing - * - * Might block: no - * - * Defined (inline) in: include/scsi/scsi_tcq.h - **/ -void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) - - /** * scsi_host_alloc - create a scsi host adapter instance and perform basic * initialization. diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 0707fa2c701b..5bdaae15a742 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1994,6 +1994,7 @@ static struct scsi_host_template mptsas_driver_template = { .cmd_per_lun = 7, .use_clustering = ENABLE_CLUSTERING, .shost_attrs = mptscsih_host_attrs, + .use_blk_tags = 1, }; static int mptsas_get_linkerrors(struct sas_phy *phy) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 1b36fd3a6e62..497cbb1efd4b 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -327,6 +327,7 @@ NCR_700_detect(struct scsi_host_template *tpnt, tpnt->slave_alloc = NCR_700_slave_alloc; tpnt->change_queue_depth = NCR_700_change_queue_depth; tpnt->change_queue_type = NCR_700_change_queue_type; + tpnt->use_blk_tags = 1; if(tpnt->name == NULL) tpnt->name = "53c700"; @@ -902,7 +903,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata NCR_700_set_tag_neg_state(SCp->device, NCR_700_FINISHED_TAG_NEGOTIATION); hostdata->tag_negotiated &= ~(1<device->tagged_supported = 0; - scsi_deactivate_tcq(SCp->device, host->cmd_per_lun); + scsi_adjust_queue_depth(SCp->device, 0, host->cmd_per_lun); } else { shost_printk(KERN_WARNING, host, "(%d:%d) Unexpected REJECT Message %s\n", @@ -2049,8 +2050,7 @@ NCR_700_slave_configure(struct scsi_device *SDp) /* to do here: allocate memory; build a queue_full list */ if(SDp->tagged_supported) { - scsi_set_tag_type(SDp, MSG_ORDERED_TAG); - scsi_activate_tcq(SDp, NCR_700_DEFAULT_TAGS); + scsi_adjust_queue_depth(SDp, MSG_ORDERED_TAG, NCR_700_DEFAULT_TAGS); NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION); } else { /* initialise to default depth */ @@ -2094,8 +2094,6 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type) struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0]; - scsi_set_tag_type(SDp, tag_type); - /* We have a global (per target) flag to track whether TCQ is * enabled, so we'll be turning it off for the entire target here. * our tag algorithm will fail if we mix tagged and untagged commands, @@ -2106,12 +2104,12 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type) if (!tag_type) { /* shift back to the default unqueued number of commands * (the user can still raise this) */ - scsi_deactivate_tcq(SDp, SDp->host->cmd_per_lun); + scsi_adjust_queue_depth(SDp, 0, SDp->host->cmd_per_lun); hostdata->tag_negotiated &= ~(1 << sdev_id(SDp)); } else { /* Here, we cleared the negotiation flag above, so this * will force the driver to renegotiate */ - scsi_activate_tcq(SDp, SDp->queue_depth); + scsi_adjust_queue_depth(SDp, tag_type, SDp->queue_depth); if (change_tag) NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION); } diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index d3b6d68107ea..9fd6b5618b25 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -925,6 +925,7 @@ struct scsi_host_template aic79xx_driver_template = { .slave_configure = ahd_linux_slave_configure, .target_alloc = ahd_linux_target_alloc, .target_destroy = ahd_linux_target_destroy, + .use_blk_tags = 1, }; /******************************** Bus DMA *************************************/ @@ -1468,12 +1469,12 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev, switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) { case AHD_DEV_Q_BASIC: - scsi_set_tag_type(sdev, MSG_SIMPLE_TASK); - scsi_activate_tcq(sdev, dev->openings + dev->active); + scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK, + dev->openings + dev->active); break; case AHD_DEV_Q_TAGGED: - scsi_set_tag_type(sdev, MSG_ORDERED_TASK); - scsi_activate_tcq(sdev, dev->openings + dev->active); + scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK, + dev->openings + dev->active); break; default: /* @@ -1482,7 +1483,7 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev, * serially on the controller/device. This should * remove some latency. */ - scsi_deactivate_tcq(sdev, 1); + scsi_adjust_queue_depth(sdev, 0, 1); break; } } diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 33a5f959e86a..f18b6d69d3fb 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -812,6 +812,7 @@ struct scsi_host_template aic7xxx_driver_template = { .slave_configure = ahc_linux_slave_configure, .target_alloc = ahc_linux_target_alloc, .target_destroy = ahc_linux_target_destroy, + .use_blk_tags = 1, }; /**************************** Tasklet Handler *********************************/ @@ -1334,12 +1335,12 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev, } switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { case AHC_DEV_Q_BASIC: - scsi_set_tag_type(sdev, MSG_SIMPLE_TAG); - scsi_activate_tcq(sdev, dev->openings + dev->active); + scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK, + dev->openings + dev->active); break; case AHC_DEV_Q_TAGGED: - scsi_set_tag_type(sdev, MSG_ORDERED_TAG); - scsi_activate_tcq(sdev, dev->openings + dev->active); + scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK, + dev->openings + dev->active); break; default: /* @@ -1348,7 +1349,7 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev, * serially on the controller/device. This should * remove some latency. */ - scsi_deactivate_tcq(sdev, 2); + scsi_adjust_queue_depth(sdev, 0, 2); break; } } diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index c56741fc4b99..579dc2f460c4 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -83,6 +83,7 @@ static struct scsi_host_template aic94xx_sht = { .eh_bus_reset_handler = sas_eh_bus_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, + .use_blk_tags = 1, }; static int asd_map_memio(struct asd_ha_struct *asd_ha) diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 99280e89c289..d8e43c81d19b 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -776,11 +776,7 @@ bfad_thread_workq(struct bfad_s *bfad) static int bfad_im_slave_configure(struct scsi_device *sdev) { - if (sdev->tagged_supported) - scsi_activate_tcq(sdev, bfa_lun_queue_depth); - else - scsi_deactivate_tcq(sdev, bfa_lun_queue_depth); - + scsi_adjust_queue_depth(sdev, 0, bfa_lun_queue_depth); return 0; } @@ -804,6 +800,7 @@ struct scsi_host_template bfad_im_scsi_host_template = { .shost_attrs = bfad_im_host_attrs, .max_sectors = BFAD_MAX_SECTORS, .vendor_id = BFA_PCI_VENDOR_ID_BROCADE, + .use_blk_tags = 1, }; struct scsi_host_template bfad_im_vport_template = { @@ -825,6 +822,7 @@ struct scsi_host_template bfad_im_vport_template = { .use_clustering = ENABLE_CLUSTERING, .shost_attrs = bfad_im_vport_attrs, .max_sectors = BFAD_MAX_SECTORS, + .use_blk_tags = 1, }; bfa_status_t diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 3c6dc8abc776..cd2e61025926 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2790,6 +2790,7 @@ static struct scsi_host_template bnx2fc_shost_template = { .use_clustering = ENABLE_CLUSTERING, .sg_tablesize = BNX2FC_MAX_BDS_PER_CMD, .max_sectors = 1024, + .use_blk_tags = 1, }; static struct libfc_function_template bnx2fc_libfc_fcn_templ = { diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index 8231505cce0a..f73155db80a3 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -2241,11 +2241,7 @@ csio_slave_alloc(struct scsi_device *sdev) static int csio_slave_configure(struct scsi_device *sdev) { - if (sdev->tagged_supported) - scsi_activate_tcq(sdev, csio_lun_qdepth); - else - scsi_deactivate_tcq(sdev, csio_lun_qdepth); - + scsi_adjust_queue_depth(sdev, 0, csio_lun_qdepth); return 0; } @@ -2290,6 +2286,7 @@ struct scsi_host_template csio_fcoe_shost_template = { .use_clustering = ENABLE_CLUSTERING, .shost_attrs = csio_fcoe_lport_attrs, .max_sectors = CSIO_MAX_SECTOR_SIZE, + .use_blk_tags = 1, }; struct scsi_host_template csio_fcoe_shost_vport_template = { @@ -2309,6 +2306,7 @@ struct scsi_host_template csio_fcoe_shost_vport_template = { .use_clustering = ENABLE_CLUSTERING, .shost_attrs = csio_fcoe_vport_attrs, .max_sectors = CSIO_MAX_SECTOR_SIZE, + .use_blk_tags = 1, }; /* diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index be09c628d034..a020b09ba347 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -260,6 +260,7 @@ static struct scsi_host_template driver_template = { .change_queue_depth = esas2r_change_queue_depth, .change_queue_type = scsi_change_queue_type, .max_sectors = 0xFFFF, + .use_blk_tags = 1, }; int sgl_page_size = 512; @@ -1278,13 +1279,10 @@ int esas2r_slave_configure(struct scsi_device *dev) esas2r_log_dev(ESAS2R_LOG_INFO, &(dev->sdev_gendev), "esas2r_slave_configure()"); - if (dev->tagged_supported) { - scsi_set_tag_type(dev, MSG_SIMPLE_TAG); - scsi_activate_tcq(dev, cmd_per_lun); - } else { - scsi_set_tag_type(dev, 0); - scsi_deactivate_tcq(dev, cmd_per_lun); - } + if (dev->tagged_supported) + scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, cmd_per_lun); + else + scsi_adjust_queue_depth(dev, 0, cmd_per_lun); return 0; } diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index b23101b28bfa..66b6ce10b259 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2419,10 +2419,9 @@ static int esp_slave_configure(struct scsi_device *dev) queue_depth = dev->host->cmd_per_lun; if (goal_tags) { - scsi_set_tag_type(dev, MSG_ORDERED_TAG); - scsi_activate_tcq(dev, queue_depth); + scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, queue_depth); } else { - scsi_deactivate_tcq(dev, queue_depth); + scsi_adjust_queue_depth(dev, 0, queue_depth); } tp->flags |= ESP_TGT_DISCONNECT; @@ -2631,6 +2630,7 @@ struct scsi_host_template scsi_esp_template = { .use_clustering = ENABLE_CLUSTERING, .max_sectors = 0xffff, .skip_settle_delay = 1, + .use_blk_tags = 1, }; EXPORT_SYMBOL(scsi_esp_template); diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 86956cc3448e..a3eeb6842499 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -288,6 +288,7 @@ static struct scsi_host_template fcoe_shost_template = { .use_clustering = ENABLE_CLUSTERING, .sg_tablesize = SG_ALL, .max_sectors = 0xffff, + .use_blk_tags = 1, }; /** diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 8581ce662cf0..2a6c98b7d4db 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -100,7 +100,7 @@ static int fnic_slave_alloc(struct scsi_device *sdev) if (!rport || fc_remote_port_chkready(rport)) return -ENXIO; - scsi_activate_tcq(sdev, fnic_max_qdepth); + scsi_adjust_queue_depth(sdev, 0, fnic_max_qdepth); return 0; } @@ -121,6 +121,7 @@ static struct scsi_host_template fnic_host_template = { .sg_tablesize = FNIC_MAX_SG_DESC_CNT, .max_sectors = 0xffff, .shost_attrs = fnic_attrs, + .use_blk_tags = 1, }; static void diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index a964f8c85833..4723d89df5ac 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2888,11 +2888,11 @@ static int ibmvfc_slave_configure(struct scsi_device *sdev) if (sdev->type == TYPE_DISK) sdev->allow_restart = 1; - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, MSG_SIMPLE_TAG); - scsi_activate_tcq(sdev, sdev->queue_depth); - } else - scsi_deactivate_tcq(sdev, sdev->queue_depth); + if (sdev->tagged_supported) + scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, + sdev->queue_depth); + else + scsi_adjust_queue_depth(sdev, 0, sdev->queue_depth); spin_unlock_irqrestore(shost->host_lock, flags); return 0; } @@ -3108,6 +3108,7 @@ static struct scsi_host_template driver_template = { .max_sectors = IBMVFC_MAX_SECTORS, .use_clustering = ENABLE_CLUSTERING, .shost_attrs = ibmvfc_attrs, + .use_blk_tags = 1, }; /** diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 6b52feafa929..f84fcb9a6ed7 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -6317,6 +6317,7 @@ static struct scsi_host_template driver_template = { .sdev_attrs = ipr_dev_attrs, .proc_name = IPR_NAME, .no_write_same = 1, + .use_blk_tags = 1, }; /** diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 2e890b1e2526..897562056018 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -172,6 +172,7 @@ static struct scsi_host_template isci_sht = { .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = isci_host_attrs, + .use_blk_tags = 1, }; static struct sas_domain_function_template isci_transport_ops = { diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index f3043ad1f35d..d4bb642f2681 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -2160,12 +2160,7 @@ int fc_slave_alloc(struct scsi_device *sdev) if (!rport || fc_remote_port_chkready(rport)) return -ENXIO; - if (sdev->tagged_supported) - scsi_activate_tcq(sdev, FC_FCP_DFLT_QUEUE_DEPTH); - else - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), - FC_FCP_DFLT_QUEUE_DEPTH); - + scsi_adjust_queue_depth(sdev, 0, FC_FCP_DFLT_QUEUE_DEPTH); return 0; } EXPORT_SYMBOL(fc_slave_alloc); diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 24e477d2ea70..eee21a060d93 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -940,15 +940,13 @@ int sas_slave_configure(struct scsi_device *scsi_dev) sas_read_port_mode_page(scsi_dev); if (scsi_dev->tagged_supported) { - scsi_set_tag_type(scsi_dev, MSG_SIMPLE_TAG); - scsi_activate_tcq(scsi_dev, SAS_DEF_QD); + scsi_adjust_queue_depth(scsi_dev, MSG_SIMPLE_TAG, SAS_DEF_QD); } else { SAS_DPRINTK("device %llx, LUN %llx doesn't support " "TCQ\n", SAS_ADDR(dev->sas_addr), scsi_dev->lun); scsi_dev->tagged_supported = 0; - scsi_set_tag_type(scsi_dev, 0); - scsi_deactivate_tcq(scsi_dev, 1); + scsi_adjust_queue_depth(scsi_dev, 0, 1); } scsi_dev->allow_restart = 1; @@ -991,10 +989,7 @@ int sas_change_queue_type(struct scsi_device *scsi_dev, int qt) if (!scsi_dev->tagged_supported) return 0; - scsi_deactivate_tcq(scsi_dev, 1); - - scsi_set_tag_type(scsi_dev, qt); - scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth); + scsi_adjust_queue_depth(scsi_dev, qt, scsi_dev->queue_depth); return qt; } diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 4a150063fb4d..a24106a70968 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -5598,10 +5598,7 @@ lpfc_slave_configure(struct scsi_device *sdev) struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; struct lpfc_hba *phba = vport->phba; - if (sdev->tagged_supported) - scsi_activate_tcq(sdev, vport->cfg_lun_queue_depth); - else - scsi_deactivate_tcq(sdev, vport->cfg_lun_queue_depth); + scsi_adjust_queue_depth(sdev, 0, vport->cfg_lun_queue_depth); if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { lpfc_sli_handle_fast_ring_event(phba, @@ -5986,6 +5983,7 @@ struct scsi_host_template lpfc_template = { .vendor_id = LPFC_NL_VENDOR_ID, .change_queue_depth = lpfc_change_queue_depth, .change_queue_type = scsi_change_queue_type, + .use_blk_tags = 1, }; struct scsi_host_template lpfc_vport_template = { @@ -6009,4 +6007,5 @@ struct scsi_host_template lpfc_vport_template = { .max_sectors = 0xFFFF, .change_queue_depth = lpfc_change_queue_depth, .change_queue_type = scsi_change_queue_type, + .use_blk_tags = 1, }; diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index eacee48a955c..d3c1fa5e76fb 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -76,6 +76,7 @@ static struct scsi_host_template mvs_sht = { .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = mvst_host_attrs, + .use_blk_tags = 1, }; static struct sas_domain_function_template mvs_transport_ops = { diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 666bf5af06e2..3ff759a3b74d 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -89,6 +89,7 @@ static struct scsi_host_template pm8001_sht = { .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = pm8001_host_attrs, + .use_blk_tags = 1, }; /** diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index d5fb31fa388b..71f9f59b13c6 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -251,7 +251,6 @@ static int pmcraid_slave_configure(struct scsi_device *scsi_dev) if (scsi_dev->tagged_supported && (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) { - scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth); scsi_adjust_queue_depth(scsi_dev, MSG_SIMPLE_TAG, scsi_dev->host->cmd_per_lun); } else { @@ -4295,7 +4294,8 @@ static struct scsi_host_template pmcraid_host_template = { .cmd_per_lun = PMCRAID_MAX_CMD_PER_LUN, .use_clustering = ENABLE_CLUSTERING, .shost_attrs = pmcraid_host_attrs, - .proc_name = PMCRAID_DRIVER_NAME + .proc_name = PMCRAID_DRIVER_NAME, + .use_blk_tags = 1, }; /* diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 1e34fcf68e77..eb0465305f8d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -269,6 +269,7 @@ struct scsi_host_template qla2xxx_driver_template = { .shost_attrs = qla2x00_host_attrs, .supported_mode = MODE_INITIATOR, + .use_blk_tags = 1, }; static struct scsi_transport_template *qla2xxx_transport_template = NULL; @@ -1404,10 +1405,7 @@ qla2xxx_slave_configure(struct scsi_device *sdev) if (IS_T10_PI_CAPABLE(vha->hw)) blk_queue_update_dma_alignment(sdev->request_queue, 0x7); - if (sdev->tagged_supported) - scsi_activate_tcq(sdev, req->max_q_depth); - else - scsi_deactivate_tcq(sdev, req->max_q_depth); + scsi_adjust_queue_depth(sdev, 0, req->max_q_depth); return 0; } diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 199fcf79a051..f3119c144e29 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -163,7 +163,6 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd); static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd); static int qla4xxx_slave_alloc(struct scsi_device *device); static int qla4xxx_slave_configure(struct scsi_device *device); -static void qla4xxx_slave_destroy(struct scsi_device *sdev); static umode_t qla4_attr_is_visible(int param_type, int param); static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type); static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth, @@ -206,7 +205,6 @@ static struct scsi_host_template qla4xxx_driver_template = { .slave_configure = qla4xxx_slave_configure, .slave_alloc = qla4xxx_slave_alloc, - .slave_destroy = qla4xxx_slave_destroy, .change_queue_depth = qla4xxx_change_queue_depth, .this_id = -1, @@ -218,6 +216,7 @@ static struct scsi_host_template qla4xxx_driver_template = { .shost_attrs = qla4xxx_host_attrs, .host_reset = qla4xxx_host_reset, .vendor_id = SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC, + .use_blk_tags = 1, }; static struct iscsi_transport qla4xxx_iscsi_transport = { @@ -9065,7 +9064,7 @@ static int qla4xxx_slave_alloc(struct scsi_device *sdev) if (ql4xmaxqdepth != 0 && ql4xmaxqdepth <= 0xffffU) queue_depth = ql4xmaxqdepth; - scsi_activate_tcq(sdev, queue_depth); + scsi_adjust_queue_depth(sdev, 0, queue_depth); return 0; } @@ -9075,11 +9074,6 @@ static int qla4xxx_slave_configure(struct scsi_device *sdev) return 0; } -static void qla4xxx_slave_destroy(struct scsi_device *sdev) -{ - scsi_deactivate_tcq(sdev, 1); -} - static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) { diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 22c449e926fa..a3426f1bf0dd 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -864,16 +864,12 @@ EXPORT_SYMBOL(scsi_track_queue_full); */ int scsi_change_queue_type(struct scsi_device *sdev, int tag_type) { - if (sdev->tagged_supported) { - scsi_set_tag_type(sdev, tag_type); - if (tag_type) - scsi_activate_tcq(sdev, sdev->queue_depth); - else - scsi_deactivate_tcq(sdev, sdev->queue_depth); - } else - tag_type = 0; + if (!sdev->tagged_supported) + return 0; + scsi_adjust_queue_depth(sdev, tag_type, sdev->queue_depth); return tag_type; + } EXPORT_SYMBOL(scsi_change_queue_type); diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index b1aa1646012a..408891cb14ff 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -286,6 +286,12 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, } WARN_ON_ONCE(!blk_get_queue(sdev->request_queue)); sdev->request_queue->queuedata = sdev; + + if (!shost_use_blk_mq(sdev->host) && + (shost->bqt || shost->hostt->use_blk_tags)) { + blk_queue_init_tags(sdev->request_queue, + sdev->host->cmd_per_lun, shost->bqt); + } scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); scsi_sysfs_device_initialize(sdev); diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 713af13b858e..b5eae4f6ba46 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -549,7 +549,7 @@ stex_slave_alloc(struct scsi_device *sdev) /* Cheat: usually extracted from Inquiry data */ sdev->tagged_supported = 1; - scsi_activate_tcq(sdev, sdev->host->can_queue); + scsi_adjust_queue_depth(sdev, 0, sdev->host->can_queue); return 0; } @@ -565,12 +565,6 @@ stex_slave_config(struct scsi_device *sdev) return 0; } -static void -stex_slave_destroy(struct scsi_device *sdev) -{ - scsi_deactivate_tcq(sdev, 1); -} - static int stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { @@ -1390,10 +1384,10 @@ static struct scsi_host_template driver_template = { .queuecommand = stex_queuecommand, .slave_alloc = stex_slave_alloc, .slave_configure = stex_slave_config, - .slave_destroy = stex_slave_destroy, .eh_abort_handler = stex_abort, .eh_host_reset_handler = stex_reset, .this_id = -1, + .use_blk_tags = 1, }; static struct pci_device_id stex_pci_tbl[] = { diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c index 547812437a7c..6369f9a282f1 100644 --- a/drivers/scsi/tmscsim.c +++ b/drivers/scsi/tmscsim.c @@ -2187,7 +2187,7 @@ static int dc390_slave_configure(struct scsi_device *sdev) acb->scan_devices = 0; if (sdev->tagged_supported && (dcb->DevMode & TAG_QUEUEING_)) { dcb->SyncMode |= EN_TAG_QUEUEING; - scsi_activate_tcq(sdev, acb->TagMaxNum); + scsi_adjust_queue_depth(sdev, 0, acb->TagMaxNum); } return 0; @@ -2209,6 +2209,7 @@ static struct scsi_host_template driver_template = { .cmd_per_lun = 1, .use_clustering = ENABLE_CLUSTERING, .max_sectors = 0x4000, /* 8MiB = 16 * 1024 * 512 */ + .use_blk_tags = 1, }; /*********************************************************************** diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9da319130da5..48c7f9e8f256 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2695,7 +2695,8 @@ static void ufshcd_set_queue_depth(struct scsi_device *sdev) dev_dbg(hba->dev, "%s: activate tcq with queue depth %d\n", __func__, lun_qdepth); - scsi_activate_tcq(sdev, lun_qdepth); + if (sdev->tagged_supported) + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), lun_qdepth); } /* @@ -2842,7 +2843,6 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev) struct ufs_hba *hba; hba = shost_priv(sdev->host); - scsi_deactivate_tcq(sdev, hba->nutrs); /* Drop the reference as it won't be needed anymore */ if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) hba->sdev_ufs_device = NULL; @@ -4235,6 +4235,7 @@ static struct scsi_host_template ufshcd_driver_template = { .cmd_per_lun = UFSHCD_CMD_PER_LUN, .can_queue = UFSHCD_CAN_QUEUE, .max_host_blocked = 1, + .use_blk_tags = 1, }; static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index e30932f989a1..120a851df0d7 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -407,7 +407,6 @@ static int tcm_loop_slave_alloc(struct scsi_device *sd) static int tcm_loop_slave_configure(struct scsi_device *sd) { if (sd->tagged_supported) { - scsi_activate_tcq(sd, sd->queue_depth); scsi_adjust_queue_depth(sd, MSG_SIMPLE_TAG, sd->host->cmd_per_lun); } else { @@ -437,6 +436,7 @@ static struct scsi_host_template tcm_loop_driver_template = { .slave_alloc = tcm_loop_slave_alloc, .slave_configure = tcm_loop_slave_configure, .module = THIS_MODULE, + .use_blk_tags = 1, }; static int tcm_loop_driver_probe(struct device *dev) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 1bc5df4200a7..ee69b82fc7d1 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -799,8 +799,7 @@ static int uas_slave_configure(struct scsi_device *sdev) if (devinfo->flags & US_FL_NO_REPORT_OPCODES) sdev->no_report_opcodes = 1; - scsi_set_tag_type(sdev, MSG_ORDERED_TAG); - scsi_activate_tcq(sdev, devinfo->qdepth - 2); + scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, devinfo->qdepth - 2); return 0; } @@ -824,6 +823,7 @@ static struct scsi_host_template uas_host_template = { * allocator. */ .disable_blk_mq = true, + .use_blk_tags = 1, }; #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index d6bd65294009..61a81bf77e28 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -421,6 +421,11 @@ struct scsi_host_template { */ unsigned char present; + /* + * Let the block layer assigns tags to all commands. + */ + unsigned use_blk_tags:1; + /* * This specifies the mode that a LLD supports. */ diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 005f68da5adb..fe4a70299419 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -45,40 +45,6 @@ static inline void scsi_set_tag_type(struct scsi_device *sdev, int tag) break; } } -/** - * scsi_activate_tcq - turn on tag command queueing - * @SDpnt: device to turn on TCQ for - * @depth: queue depth - * - * Notes: - * Eventually, I hope depth would be the maximum depth - * the device could cope with and the real queue depth - * would be adjustable from 0 to depth. - **/ -static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth) -{ - if (!sdev->tagged_supported) - return; - - if (shost_use_blk_mq(sdev->host)) - queue_flag_set_unlocked(QUEUE_FLAG_QUEUED, sdev->request_queue); - else if (!blk_queue_tagged(sdev->request_queue)) - blk_queue_init_tags(sdev->request_queue, depth, - sdev->host->bqt); - - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); -} - -/** - * scsi_deactivate_tcq - turn off tag command queueing - * @SDpnt: device to turn off TCQ for - **/ -static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) -{ - if (blk_queue_tagged(sdev->request_queue)) - blk_queue_free_tags(sdev->request_queue); - scsi_adjust_queue_depth(sdev, 0, depth); -} static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost, int unique_tag) -- cgit v1.2.3 From c8b09f6fb67df7fc1b51ced1037fa9b677428149 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 20:15:14 +0100 Subject: scsi: don't set tagging state from scsi_adjust_queue_depth Remove the tagged argument from scsi_adjust_queue_depth, and just let it handle the queue depth. For most drivers those two are fairly separate, given that most modern drivers don't care about the SCSI "tagged" status of a command at all, and many old drivers allow queuing of multiple untagged commands in the driver. Instead we start out with the ->simple_tags flag set before calling ->slave_configure, which is how all drivers actually looking at ->simple_tags except for one worke anyway. The one other case looks broken, but I've kept the behavior as-is for now. Except for that we only change ->simple_tags from the ->change_queue_type, and when rejecting a tag message in a single driver, so keeping this churn out of scsi_adjust_queue_depth is a clear win. Now that the usage of scsi_adjust_queue_depth is more obvious we can also remove all the trivial instances in ->slave_alloc or ->slave_configure that just set it to the cmd_per_lun default. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke Reviewed-by: Martin K. Petersen --- Documentation/scsi/scsi_mid_low_api.txt | 12 ++++------ drivers/ata/libata-scsi.c | 4 ++-- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- drivers/message/fusion/mptscsih.c | 2 +- drivers/s390/scsi/zfcp_scsi.c | 8 +++---- drivers/scsi/3w-9xxx.c | 2 +- drivers/scsi/3w-sas.c | 2 +- drivers/scsi/3w-xxxx.c | 2 +- drivers/scsi/53c700.c | 17 ++++++------- drivers/scsi/BusLogic.c | 4 ++-- drivers/scsi/aacraid/linit.c | 8 +++---- drivers/scsi/advansys.c | 7 ++---- drivers/scsi/aic7xxx/aic79xx_osm.c | 7 ++---- drivers/scsi/aic7xxx/aic7xxx_osm.c | 8 ++----- drivers/scsi/arcmsr/arcmsr_hba.c | 2 +- drivers/scsi/bfa/bfad_im.c | 3 +-- drivers/scsi/csiostor/csio_scsi.c | 2 +- drivers/scsi/dpt_i2o.c | 4 +--- drivers/scsi/eata.c | 8 +++---- drivers/scsi/esas2r/esas2r.h | 3 --- drivers/scsi/esas2r/esas2r_main.c | 29 +--------------------- drivers/scsi/esp_scsi.c | 17 ++----------- drivers/scsi/fnic/fnic_main.c | 2 +- drivers/scsi/gdth.c | 1 - drivers/scsi/hpsa.c | 2 +- drivers/scsi/hptiop.c | 2 +- drivers/scsi/ibmvscsi/ibmvfc.c | 8 +------ drivers/scsi/ibmvscsi/ibmvscsi.c | 3 +-- drivers/scsi/ipr.c | 8 +++---- drivers/scsi/ips.c | 2 +- drivers/scsi/libfc/fc_fcp.c | 6 ++--- drivers/scsi/libiscsi.c | 4 ++-- drivers/scsi/libsas/sas_scsi_host.c | 20 +++++----------- drivers/scsi/lpfc/lpfc_scsi.c | 4 ++-- drivers/scsi/megaraid/megaraid_mbox.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +-- drivers/scsi/mpt2sas/mpt2sas_scsih.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- drivers/scsi/ncr53c8xx.c | 5 +--- drivers/scsi/pmcraid.c | 40 ++++++------------------------- drivers/scsi/qla1280.c | 5 ++-- drivers/scsi/qla2xxx/qla_os.c | 6 ++--- drivers/scsi/qla4xxx/ql4_os.c | 2 +- drivers/scsi/scsi.c | 25 ++++--------------- drivers/scsi/scsi_debug.c | 7 ++---- drivers/scsi/scsi_scan.c | 6 +++-- drivers/scsi/stex.c | 2 -- drivers/scsi/storvsc_drv.c | 3 +-- drivers/scsi/sym53c8xx_2/sym_glue.c | 4 +--- drivers/scsi/tmscsim.c | 9 ++++++- drivers/scsi/u14-34f.c | 10 ++++---- drivers/scsi/ufs/ufshcd.c | 4 ++-- drivers/scsi/virtio_scsi.c | 4 +--- drivers/scsi/vmw_pvscsi.c | 2 +- drivers/target/loopback/tcm_loop.c | 18 ++------------ drivers/usb/storage/uas.c | 2 +- include/scsi/scsi_device.h | 2 +- 57 files changed, 120 insertions(+), 260 deletions(-) diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt index a67194209581..bee7d86b9dcc 100644 --- a/Documentation/scsi/scsi_mid_low_api.txt +++ b/Documentation/scsi/scsi_mid_low_api.txt @@ -271,9 +271,9 @@ init_this_scsi_driver() ----+ slave_destroy() *** ------------------------------------------------------------ -The mid level invokes scsi_adjust_queue_depth() with tagged queuing off and -"cmd_per_lun" for that host as the queue length. These settings can be -overridden by a slave_configure() supplied by the LLD. +The mid level invokes scsi_adjust_queue_depth() with "cmd_per_lun" for that +host as the queue length. These settings can be overridden by a +slave_configure() supplied by the LLD. *** For scsi devices that the mid level tries to scan but do not respond, a slave_alloc(), slave_destroy() pair is called. @@ -438,9 +438,6 @@ int scsi_add_host(struct Scsi_Host *shost, struct device * dev) /** * scsi_adjust_queue_depth - allow LLD to change queue depth on a SCSI device * @sdev: pointer to SCSI device to change queue depth on - * @tagged: 0 - no tagged queuing - * MSG_SIMPLE_TAG - simple tagged queuing - * MSG_ORDERED_TAG - ordered tagged queuing * @tags Number of tags allowed if tagged queuing enabled, * or number of commands the LLD can queue up * in non-tagged mode (as per cmd_per_lun). @@ -456,8 +453,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device * dev) * Defined in: drivers/scsi/scsi.c [see source code for more notes] * **/ -void scsi_adjust_queue_depth(struct scsi_device * sdev, int tagged, - int tags) +void scsi_adjust_queue_depth(struct scsi_device *sdev, int tags) /** diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 0586f66d70fa..c8bb6abbf12c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1164,7 +1164,7 @@ static int ata_scsi_dev_config(struct scsi_device *sdev, depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id)); depth = min(ATA_MAX_QUEUE - 1, depth); - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); + scsi_adjust_queue_depth(sdev, depth); } blk_queue_flush_queueable(q, false); @@ -1282,7 +1282,7 @@ int __ata_change_queue_depth(struct ata_port *ap, struct scsi_device *sdev, if (sdev->queue_depth == queue_depth) return -EINVAL; - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 51670d75ab78..023a66f5ca14 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2278,7 +2278,7 @@ srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) max_depth = 1; if (qdepth > max_depth) qdepth = max_depth; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); } else if (reason == SCSI_QDEPTH_QFULL) scsi_track_queue_full(sdev, qdepth); else diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index c0d84a09db9a..dee06d6f0b68 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -2347,7 +2347,7 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) if (qdepth > max_depth) qdepth = max_depth; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); return sdev->queue_depth; } diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 7b353647cb90..b5dfa51f396f 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -37,13 +37,13 @@ static int zfcp_scsi_change_queue_depth(struct scsi_device *sdev, int depth, { switch (reason) { case SCSI_QDEPTH_DEFAULT: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; case SCSI_QDEPTH_QFULL: scsi_track_queue_full(sdev, depth); break; case SCSI_QDEPTH_RAMP_UP: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; default: return -EOPNOTSUPP; @@ -66,9 +66,7 @@ static void zfcp_scsi_slave_destroy(struct scsi_device *sdev) static int zfcp_scsi_slave_configure(struct scsi_device *sdp) { if (sdp->tagged_supported) - scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, default_depth); - else - scsi_adjust_queue_depth(sdp, 0, 1); + scsi_adjust_queue_depth(sdp, default_depth); return 0; } diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 0a7325361d29..02021f5ca866 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -198,7 +198,7 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth, if (queue_depth > TW_Q_LENGTH-2) queue_depth = TW_Q_LENGTH-2; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } /* End twa_change_queue_depth() */ diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index 6da6cec9a651..ac0c2544a470 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -200,7 +200,7 @@ static int twl_change_queue_depth(struct scsi_device *sdev, int queue_depth, if (queue_depth > TW_Q_LENGTH-2) queue_depth = TW_Q_LENGTH-2; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } /* End twl_change_queue_depth() */ diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 752624e6bc00..1ec9ad92b6c3 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -532,7 +532,7 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth, if (queue_depth > TW_Q_LENGTH-2) queue_depth = TW_Q_LENGTH-2; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } /* End tw_change_queue_depth() */ diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 497cbb1efd4b..d7557b932113 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -902,8 +902,10 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata /* we're done negotiating */ NCR_700_set_tag_neg_state(SCp->device, NCR_700_FINISHED_TAG_NEGOTIATION); hostdata->tag_negotiated &= ~(1<device->tagged_supported = 0; - scsi_adjust_queue_depth(SCp->device, 0, host->cmd_per_lun); + scsi_adjust_queue_depth(SCp->device, host->cmd_per_lun); + scsi_set_tag_type(SCp->device, 0); } else { shost_printk(KERN_WARNING, host, "(%d:%d) Unexpected REJECT Message %s\n", @@ -2050,12 +2052,10 @@ NCR_700_slave_configure(struct scsi_device *SDp) /* to do here: allocate memory; build a queue_full list */ if(SDp->tagged_supported) { - scsi_adjust_queue_depth(SDp, MSG_ORDERED_TAG, NCR_700_DEFAULT_TAGS); + scsi_adjust_queue_depth(SDp, NCR_700_DEFAULT_TAGS); NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION); - } else { - /* initialise to default depth */ - scsi_adjust_queue_depth(SDp, 0, SDp->host->cmd_per_lun); } + if(hostdata->fast) { /* Find the correct offset and period via domain validation */ if (!spi_initial_dv(SDp->sdev_target)) @@ -2083,7 +2083,7 @@ NCR_700_change_queue_depth(struct scsi_device *SDp, int depth, int reason) if (depth > NCR_700_MAX_TAGS) depth = NCR_700_MAX_TAGS; - scsi_adjust_queue_depth(SDp, scsi_get_tag_type(SDp), depth); + scsi_adjust_queue_depth(SDp, depth); return depth; } @@ -2101,15 +2101,16 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type) if (change_tag) scsi_target_quiesce(SDp->sdev_target); + scsi_set_tag_type(SDp, tag_type); if (!tag_type) { /* shift back to the default unqueued number of commands * (the user can still raise this) */ - scsi_adjust_queue_depth(SDp, 0, SDp->host->cmd_per_lun); + scsi_adjust_queue_depth(SDp, SDp->host->cmd_per_lun); hostdata->tag_negotiated &= ~(1 << sdev_id(SDp)); } else { /* Here, we cleared the negotiation flag above, so this * will force the driver to renegotiate */ - scsi_adjust_queue_depth(SDp, tag_type, SDp->queue_depth); + scsi_adjust_queue_depth(SDp, SDp->queue_depth); if (change_tag) NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION); } diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 64c75143c89a..5aa476b6b8a8 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -2327,12 +2327,12 @@ static int blogic_slaveconfig(struct scsi_device *dev) if (qdepth == 0) qdepth = BLOGIC_MAX_AUTO_TAG_DEPTH; adapter->qdepth[tgt_id] = qdepth; - scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, qdepth); + scsi_adjust_queue_depth(dev, qdepth); } else { adapter->tagq_ok &= ~(1 << tgt_id); qdepth = adapter->untag_qdepth; adapter->qdepth[tgt_id] = qdepth; - scsi_adjust_queue_depth(dev, 0, qdepth); + scsi_adjust_queue_depth(dev, qdepth); } qdepth = 0; for (tgt_id = 0; tgt_id < adapter->maxdev; tgt_id++) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index a759cb2d4b15..41b9c68bca67 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -462,9 +462,9 @@ static int aac_slave_configure(struct scsi_device *sdev) depth = 256; else if (depth < 2) depth = 2; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth); + scsi_adjust_queue_depth(sdev, depth); } else - scsi_adjust_queue_depth(sdev, 0, 1); + scsi_adjust_queue_depth(sdev, 1); return 0; } @@ -504,9 +504,9 @@ static int aac_change_queue_depth(struct scsi_device *sdev, int depth, depth = 256; else if (depth < 2) depth = 2; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth); + scsi_adjust_queue_depth(sdev, depth); } else - scsi_adjust_queue_depth(sdev, 0, 1); + scsi_adjust_queue_depth(sdev, 1); return sdev->queue_depth; } diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 43761c1c46f0..ae4840e4c1c5 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -7706,7 +7706,7 @@ advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc) asc_dvc->cfg->can_tagged_qng |= tid_bit; asc_dvc->use_tagged_qng |= tid_bit; } - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, + scsi_adjust_queue_depth(sdev, asc_dvc->max_dvc_qng[sdev->id]); } } else { @@ -7714,7 +7714,6 @@ advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc) asc_dvc->cfg->can_tagged_qng &= ~tid_bit; asc_dvc->use_tagged_qng &= ~tid_bit; } - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); } if ((sdev->lun == 0) && @@ -7849,10 +7848,8 @@ advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc) } if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) { - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, + scsi_adjust_queue_depth(sdev, adv_dvc->max_dvc_qng); - } else { - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); } } diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 9fd6b5618b25..80cb4fd7caaa 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1469,11 +1469,8 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev, switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) { case AHD_DEV_Q_BASIC: - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK, - dev->openings + dev->active); - break; case AHD_DEV_Q_TAGGED: - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK, + scsi_adjust_queue_depth(sdev, dev->openings + dev->active); break; default: @@ -1483,7 +1480,7 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev, * serially on the controller/device. This should * remove some latency. */ - scsi_adjust_queue_depth(sdev, 0, 1); + scsi_adjust_queue_depth(sdev, 1); break; } } diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index f18b6d69d3fb..a6a27d5398dd 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -1335,13 +1335,9 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev, } switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { case AHC_DEV_Q_BASIC: - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK, - dev->openings + dev->active); - break; case AHC_DEV_Q_TAGGED: - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK, + scsi_adjust_queue_depth(sdev, dev->openings + dev->active); - break; default: /* * We allow the OS to queue 2 untagged transactions to @@ -1349,7 +1345,7 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev, * serially on the controller/device. This should * remove some latency. */ - scsi_adjust_queue_depth(sdev, 0, 2); + scsi_adjust_queue_depth(sdev, 2); break; } } diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 0b44fb5ee485..209f77162d06 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -122,7 +122,7 @@ static int arcmsr_adjust_disk_queue_depth(struct scsi_device *sdev, if (queue_depth > ARCMSR_MAX_CMD_PERLUN) queue_depth = ARCMSR_MAX_CMD_PERLUN; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index d8e43c81d19b..87b09cd232cc 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -776,7 +776,7 @@ bfad_thread_workq(struct bfad_s *bfad) static int bfad_im_slave_configure(struct scsi_device *sdev) { - scsi_adjust_queue_depth(sdev, 0, bfa_lun_queue_depth); + scsi_adjust_queue_depth(sdev, bfa_lun_queue_depth); return 0; } @@ -867,7 +867,6 @@ bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim, struct scsi_device *sdev) if (tmp_sdev->id != sdev->id) continue; scsi_adjust_queue_depth(tmp_sdev, - MSG_SIMPLE_TAG, tmp_sdev->queue_depth + 1); itnim->last_ramp_up_time = jiffies; diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index f73155db80a3..44a8cc51428f 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -2241,7 +2241,7 @@ csio_slave_alloc(struct scsi_device *sdev) static int csio_slave_configure(struct scsi_device *sdev) { - scsi_adjust_queue_depth(sdev, 0, csio_lun_qdepth); + scsi_adjust_queue_depth(sdev, csio_lun_qdepth); return 0; } diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 072f0ec2851e..1af8d54bcded 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -415,10 +415,8 @@ static int adpt_slave_configure(struct scsi_device * device) pHba = (adpt_hba *) host->hostdata[0]; if (host->can_queue && device->tagged_supported) { - scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG, + scsi_adjust_queue_depth(device, host->can_queue - 1); - } else { - scsi_adjust_queue_depth(device, 0, 1); } return 0; } diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c index 943ad3a19661..bc0f918f1729 100644 --- a/drivers/scsi/eata.c +++ b/drivers/scsi/eata.c @@ -946,20 +946,18 @@ static int eata2x_slave_configure(struct scsi_device *dev) if (TLDEV(dev->type) && dev->tagged_supported) { if (tag_mode == TAG_SIMPLE) { - scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, tqd); tag_suffix = ", simple tags"; } else if (tag_mode == TAG_ORDERED) { - scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, tqd); tag_suffix = ", ordered tags"; } else { - scsi_adjust_queue_depth(dev, 0, tqd); tag_suffix = ", no tags"; } + scsi_adjust_queue_depth(dev, tqd); } else if (TLDEV(dev->type) && linked_comm) { - scsi_adjust_queue_depth(dev, 0, tqd); + scsi_adjust_queue_depth(dev, tqd); tag_suffix = ", untagged"; } else { - scsi_adjust_queue_depth(dev, 0, utqd); + scsi_adjust_queue_depth(dev, utqd); tag_suffix = ""; } diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index 20ab211983f2..1941d837f6f2 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -972,9 +972,6 @@ u8 handle_hba_ioctl(struct esas2r_adapter *a, struct atto_ioctl *ioctl_hba); int esas2r_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd); int esas2r_show_info(struct seq_file *m, struct Scsi_Host *sh); -int esas2r_slave_alloc(struct scsi_device *dev); -int esas2r_slave_configure(struct scsi_device *dev); -void esas2r_slave_destroy(struct scsi_device *dev); int esas2r_change_queue_depth(struct scsi_device *dev, int depth, int reason); long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index a020b09ba347..30fce64faf75 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -254,9 +254,6 @@ static struct scsi_host_template driver_template = { .use_clustering = ENABLE_CLUSTERING, .emulated = 0, .proc_name = ESAS2R_DRVR_NAME, - .slave_configure = esas2r_slave_configure, - .slave_alloc = esas2r_slave_alloc, - .slave_destroy = esas2r_slave_destroy, .change_queue_depth = esas2r_change_queue_depth, .change_queue_type = scsi_change_queue_type, .max_sectors = 0xFFFF, @@ -1264,35 +1261,11 @@ int esas2r_change_queue_depth(struct scsi_device *dev, int depth, int reason) { esas2r_log(ESAS2R_LOG_INFO, "change_queue_depth %p, %d", dev, depth); - scsi_adjust_queue_depth(dev, scsi_get_tag_type(dev), depth); + scsi_adjust_queue_depth(dev, depth); return dev->queue_depth; } -int esas2r_slave_alloc(struct scsi_device *dev) -{ - return 0; -} - -int esas2r_slave_configure(struct scsi_device *dev) -{ - esas2r_log_dev(ESAS2R_LOG_INFO, &(dev->sdev_gendev), - "esas2r_slave_configure()"); - - if (dev->tagged_supported) - scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, cmd_per_lun); - else - scsi_adjust_queue_depth(dev, 0, cmd_per_lun); - - return 0; -} - -void esas2r_slave_destroy(struct scsi_device *dev) -{ - esas2r_log_dev(ESAS2R_LOG_INFO, &(dev->sdev_gendev), - "esas2r_slave_destroy()"); -} - void esas2r_log_request_failure(struct esas2r_adapter *a, struct esas2r_request *rq) { diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 66b6ce10b259..38c23e0b73af 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2402,27 +2402,14 @@ static int esp_slave_configure(struct scsi_device *dev) { struct esp *esp = shost_priv(dev->host); struct esp_target_data *tp = &esp->target[dev->id]; - int goal_tags, queue_depth; - - goal_tags = 0; if (dev->tagged_supported) { /* XXX make this configurable somehow XXX */ - goal_tags = ESP_DEFAULT_TAGS; + int goal_tags = min(ESP_DEFAULT_TAGS, ESP_MAX_TAG); - if (goal_tags > ESP_MAX_TAG) - goal_tags = ESP_MAX_TAG; + scsi_adjust_queue_depth(dev, goal_tags); } - queue_depth = goal_tags; - if (queue_depth < dev->host->cmd_per_lun) - queue_depth = dev->host->cmd_per_lun; - - if (goal_tags) { - scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, queue_depth); - } else { - scsi_adjust_queue_depth(dev, 0, queue_depth); - } tp->flags |= ESP_TGT_DISCONNECT; if (!spi_initial_dv(dev->sdev_target)) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 2a6c98b7d4db..0f29e3f89b26 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -100,7 +100,7 @@ static int fnic_slave_alloc(struct scsi_device *sdev) if (!rport || fc_remote_port_chkready(rport)) return -ENXIO; - scsi_adjust_queue_depth(sdev, 0, fnic_max_qdepth); + scsi_adjust_queue_depth(sdev, fnic_max_qdepth); return 0; } diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 0f1ae13ce7c7..4ebbeae161e2 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -4661,7 +4661,6 @@ static void gdth_flush(gdth_ha_str *ha) /* configure lun */ static int gdth_slave_configure(struct scsi_device *sdev) { - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); sdev->skip_ms_page_3f = 1; sdev->skip_ms_page_8 = 1; return 0; diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index cef5d49b59cd..18ea2e16e34f 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -4165,7 +4165,7 @@ static int hpsa_change_queue_depth(struct scsi_device *sdev, else if (qdepth > h->nr_cmds) qdepth = h->nr_cmds; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); return sdev->queue_depth; } diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index dedb62c21b29..151893148abd 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -1127,7 +1127,7 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev, if (queue_depth > hba->max_requests) queue_depth = hba->max_requests; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 4723d89df5ac..147b80e07b00 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2887,12 +2887,6 @@ static int ibmvfc_slave_configure(struct scsi_device *sdev) spin_lock_irqsave(shost->host_lock, flags); if (sdev->type == TYPE_DISK) sdev->allow_restart = 1; - - if (sdev->tagged_supported) - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, - sdev->queue_depth); - else - scsi_adjust_queue_depth(sdev, 0, sdev->queue_depth); spin_unlock_irqrestore(shost->host_lock, flags); return 0; } @@ -2915,7 +2909,7 @@ static int ibmvfc_change_queue_depth(struct scsi_device *sdev, int qdepth, if (qdepth > IBMVFC_MAX_CMDS_PER_LUN) qdepth = IBMVFC_MAX_CMDS_PER_LUN; - scsi_adjust_queue_depth(sdev, 0, qdepth); + scsi_adjust_queue_depth(sdev, qdepth); return sdev->queue_depth; } diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 7b23f21f22f1..e8c3cdf0d03b 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -1929,7 +1929,6 @@ static int ibmvscsi_slave_configure(struct scsi_device *sdev) blk_queue_rq_timeout(sdev->request_queue, 120 * HZ); } spin_unlock_irqrestore(shost->host_lock, lock_flags); - scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun); return 0; } @@ -1951,7 +1950,7 @@ static int ibmvscsi_change_queue_depth(struct scsi_device *sdev, int qdepth, if (qdepth > IBMVSCSI_MAX_CMDS_PER_LUN) qdepth = IBMVSCSI_MAX_CMDS_PER_LUN; - scsi_adjust_queue_depth(sdev, 0, qdepth); + scsi_adjust_queue_depth(sdev, qdepth); return sdev->queue_depth; } diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index f84fcb9a6ed7..256ef98f5c29 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -4344,7 +4344,7 @@ static int ipr_change_queue_depth(struct scsi_device *sdev, int qdepth, qdepth = IPR_MAX_CMD_PER_ATA_LUN; spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); return sdev->queue_depth; } @@ -4751,10 +4751,10 @@ static int ipr_slave_configure(struct scsi_device *sdev) spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); if (ap) { - scsi_adjust_queue_depth(sdev, 0, IPR_MAX_CMD_PER_ATA_LUN); + scsi_adjust_queue_depth(sdev, IPR_MAX_CMD_PER_ATA_LUN); ata_sas_slave_configure(sdev, ap); - } else - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); + } + if (ioa_cfg->sis64) sdev_printk(KERN_INFO, sdev, "Resource path: %s\n", ipr_format_res_path(ioa_cfg, diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index e5afc3884d74..454741a8da45 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -1210,7 +1210,7 @@ ips_slave_configure(struct scsi_device * SDptr) min = ha->max_cmds / 2; if (ha->enq->ucLogDriveCount <= 2) min = ha->max_cmds - 1; - scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, min); + scsi_adjust_queue_depth(SDptr, min); } SDptr->skip_ms_page_8 = 1; diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index d4bb642f2681..bf954ee050f8 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -2160,7 +2160,7 @@ int fc_slave_alloc(struct scsi_device *sdev) if (!rport || fc_remote_port_chkready(rport)) return -ENXIO; - scsi_adjust_queue_depth(sdev, 0, FC_FCP_DFLT_QUEUE_DEPTH); + scsi_adjust_queue_depth(sdev, FC_FCP_DFLT_QUEUE_DEPTH); return 0; } EXPORT_SYMBOL(fc_slave_alloc); @@ -2175,13 +2175,13 @@ int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) { switch (reason) { case SCSI_QDEPTH_DEFAULT: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); break; case SCSI_QDEPTH_QFULL: scsi_track_queue_full(sdev, qdepth); break; case SCSI_QDEPTH_RAMP_UP: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); break; default: return -EOPNOTSUPP; diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 0d8bc6c66650..d521624dedfb 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1775,13 +1775,13 @@ int iscsi_change_queue_depth(struct scsi_device *sdev, int depth, int reason) { switch (reason) { case SCSI_QDEPTH_DEFAULT: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; case SCSI_QDEPTH_QFULL: scsi_track_queue_full(sdev, depth); break; case SCSI_QDEPTH_RAMP_UP: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; default: return -EOPNOTSUPP; diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index eee21a060d93..56d698af073d 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -940,13 +940,13 @@ int sas_slave_configure(struct scsi_device *scsi_dev) sas_read_port_mode_page(scsi_dev); if (scsi_dev->tagged_supported) { - scsi_adjust_queue_depth(scsi_dev, MSG_SIMPLE_TAG, SAS_DEF_QD); + scsi_adjust_queue_depth(scsi_dev, SAS_DEF_QD); } else { SAS_DPRINTK("device %llx, LUN %llx doesn't support " "TCQ\n", SAS_ADDR(dev->sas_addr), scsi_dev->lun); scsi_dev->tagged_supported = 0; - scsi_adjust_queue_depth(scsi_dev, 0, 1); + scsi_adjust_queue_depth(scsi_dev, 1); } scsi_dev->allow_restart = 1; @@ -967,7 +967,7 @@ int sas_change_queue_depth(struct scsi_device *sdev, int depth, int reason) case SCSI_QDEPTH_RAMP_UP: if (!sdev->tagged_supported) depth = 1; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; case SCSI_QDEPTH_QFULL: scsi_track_queue_full(sdev, depth); @@ -979,19 +979,11 @@ int sas_change_queue_depth(struct scsi_device *sdev, int depth, int reason) return depth; } -int sas_change_queue_type(struct scsi_device *scsi_dev, int qt) +int sas_change_queue_type(struct scsi_device *scsi_dev, int type) { - struct domain_device *dev = sdev_to_domain_dev(scsi_dev); - - if (dev_is_sata(dev)) + if (dev_is_sata(sdev_to_domain_dev(scsi_dev))) return -EINVAL; - - if (!scsi_dev->tagged_supported) - return 0; - - scsi_adjust_queue_depth(scsi_dev, qt, scsi_dev->queue_depth); - - return qt; + return scsi_change_queue_type(scsi_dev, type); } int sas_bios_param(struct scsi_device *scsi_dev, diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index a24106a70968..8533ee9b818d 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -320,7 +320,7 @@ lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) case SCSI_QDEPTH_DEFAULT: /* change request from sysfs, fall through */ case SCSI_QDEPTH_RAMP_UP: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); break; case SCSI_QDEPTH_QFULL: if (scsi_track_queue_full(sdev, qdepth) == 0) @@ -5598,7 +5598,7 @@ lpfc_slave_configure(struct scsi_device *sdev) struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; struct lpfc_hba *phba = vport->phba; - scsi_adjust_queue_depth(sdev, 0, vport->cfg_lun_queue_depth); + scsi_adjust_queue_depth(sdev, vport->cfg_lun_queue_depth); if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { lpfc_sli_handle_fast_ring_event(phba, diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 531dce419c18..6b077d839f2b 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -349,7 +349,7 @@ static int megaraid_change_queue_depth(struct scsi_device *sdev, int qdepth, if (qdepth > MBOX_MAX_SCSI_CMDS) qdepth = MBOX_MAX_SCSI_CMDS; - scsi_adjust_queue_depth(sdev, 0, qdepth); + scsi_adjust_queue_depth(sdev, qdepth); return sdev->queue_depth; } diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 5640ad1c8214..107244cebd22 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -2594,8 +2594,7 @@ static int megasas_change_queue_depth(struct scsi_device *sdev, if (queue_depth > sdev->host->can_queue) queue_depth = sdev->host->can_queue; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), - queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return queue_depth; } diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 69dc166b52bc..42fef914d441 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c @@ -1222,7 +1222,7 @@ _scsih_adjust_queue_depth(struct scsi_device *sdev, int qdepth) max_depth = 1; if (qdepth > max_depth) qdepth = max_depth; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); } /** diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index d3abf254341d..b23c2e7588e5 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1090,7 +1090,7 @@ _scsih_adjust_queue_depth(struct scsi_device *sdev, int qdepth) max_depth = 1; if (qdepth > max_depth) qdepth = max_depth; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); } /** diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index a7305ffc359d..9c331b7bfdcd 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -7997,10 +7997,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device) if (depth_to_use > MAX_TAGS) depth_to_use = MAX_TAGS; - scsi_adjust_queue_depth(device, - (device->tagged_supported ? - MSG_SIMPLE_TAG : 0), - depth_to_use); + scsi_adjust_queue_depth(device, depth_to_use); /* ** Since the queue depth is not tunable under Linux, diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 71f9f59b13c6..d8b9ba251fbd 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -249,14 +249,11 @@ static int pmcraid_slave_configure(struct scsi_device *scsi_dev) PMCRAID_VSET_MAX_SECTORS); } - if (scsi_dev->tagged_supported && - (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) { - scsi_adjust_queue_depth(scsi_dev, MSG_SIMPLE_TAG, - scsi_dev->host->cmd_per_lun); - } else { - scsi_adjust_queue_depth(scsi_dev, 0, - scsi_dev->host->cmd_per_lun); - } + /* + * We never want to report TCQ support for these types of devices. + */ + if (!RES_IS_GSCSI(res->cfg_entry) && !RES_IS_VSET(res->cfg_entry)) + scsi_dev->tagged_supported = 0; return 0; } @@ -302,34 +299,11 @@ static int pmcraid_change_queue_depth(struct scsi_device *scsi_dev, int depth, if (depth > PMCRAID_MAX_CMD_PER_LUN) depth = PMCRAID_MAX_CMD_PER_LUN; - scsi_adjust_queue_depth(scsi_dev, scsi_get_tag_type(scsi_dev), depth); + scsi_adjust_queue_depth(scsi_dev, depth); return scsi_dev->queue_depth; } -/** - * pmcraid_change_queue_type - Change the device's queue type - * @scsi_dev: scsi device struct - * @tag: type of tags to use - * - * Return value: - * actual queue type set - */ -static int pmcraid_change_queue_type(struct scsi_device *scsi_dev, int tag) -{ - struct pmcraid_resource_entry *res; - - res = (struct pmcraid_resource_entry *)scsi_dev->hostdata; - if (res && scsi_dev->tagged_supported && - (RES_IS_GSCSI(res->cfg_entry) || RES_IS_VSET(res->cfg_entry))) - tag = scsi_change_queue_type(scsi_dev, tag); - else - tag = 0; - - return tag; -} - - /** * pmcraid_init_cmdblk - initializes a command block * @@ -4285,7 +4259,7 @@ static struct scsi_host_template pmcraid_host_template = { .slave_configure = pmcraid_slave_configure, .slave_destroy = pmcraid_slave_destroy, .change_queue_depth = pmcraid_change_queue_depth, - .change_queue_type = pmcraid_change_queue_type, + .change_queue_type = scsi_change_queue_type, .can_queue = PMCRAID_MAX_IO_CMD, .this_id = -1, .sg_tablesize = PMCRAID_MAX_IOADLS, diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 158020522dfb..adedb6ef8eec 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1224,10 +1224,9 @@ qla1280_slave_configure(struct scsi_device *device) if (device->tagged_supported && (ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) { - scsi_adjust_queue_depth(device, MSG_ORDERED_TAG, - ha->bus_settings[bus].hiwat); + scsi_adjust_queue_depth(device, ha->bus_settings[bus].hiwat); } else { - scsi_adjust_queue_depth(device, 0, default_depth); + scsi_adjust_queue_depth(device, default_depth); } nv->bus[bus].target[target].parameter.enable_sync = device->sdtr; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index eb0465305f8d..33166ebec7d8 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1405,7 +1405,7 @@ qla2xxx_slave_configure(struct scsi_device *sdev) if (IS_T10_PI_CAPABLE(vha->hw)) blk_queue_update_dma_alignment(sdev->request_queue, 0x7); - scsi_adjust_queue_depth(sdev, 0, req->max_q_depth); + scsi_adjust_queue_depth(sdev, req->max_q_depth); return 0; } @@ -1440,7 +1440,7 @@ static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) return; - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); + scsi_adjust_queue_depth(sdev, qdepth); ql_dbg(ql_dbg_io, vha, 0x302a, "Queue depth adjusted-up to %d for nexus=%ld:%d:%llu.\n", @@ -1452,7 +1452,7 @@ qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) { switch (reason) { case SCSI_QDEPTH_DEFAULT: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); break; case SCSI_QDEPTH_QFULL: qla2x00_handle_queue_full(sdev, qdepth); diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index f3119c144e29..784f59e55510 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -9064,7 +9064,7 @@ static int qla4xxx_slave_alloc(struct scsi_device *sdev) if (ql4xmaxqdepth != 0 && ql4xmaxqdepth <= 0xffffU) queue_depth = ql4xmaxqdepth; - scsi_adjust_queue_depth(sdev, 0, queue_depth); + scsi_adjust_queue_depth(sdev, queue_depth); return 0; } diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index a3426f1bf0dd..106fa2f886d2 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -744,8 +744,6 @@ void scsi_finish_command(struct scsi_cmnd *cmd) /** * scsi_adjust_queue_depth - Let low level drivers change a device's queue depth * @sdev: SCSI Device in question - * @tagged: Do we use tagged queueing (non-0) or do we treat - * this device as an untagged device (0) * @tags: Number of tags allowed if tagged queueing enabled, * or number of commands the low level driver can * queue up in non-tagged mode (as per cmd_per_lun). @@ -759,7 +757,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd) * currently active and whether or not it even has the * command blocks built yet. */ -void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags) +void scsi_adjust_queue_depth(struct scsi_device *sdev, int tags) { unsigned long flags; @@ -787,20 +785,6 @@ void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags) } sdev->queue_depth = tags; - switch (tagged) { - case 0: - sdev->simple_tags = 0; - break; - case MSG_ORDERED_TAG: - case MSG_SIMPLE_TAG: - sdev->simple_tags = 1; - break; - default: - sdev->simple_tags = 0; - sdev_printk(KERN_WARNING, sdev, - "scsi_adjust_queue_depth, bad queue type, " - "disabled\n"); - } out: spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); } @@ -848,11 +832,12 @@ int scsi_track_queue_full(struct scsi_device *sdev, int depth) return 0; if (sdev->last_queue_full_depth < 8) { /* Drop back to untagged */ - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); + scsi_set_tag_type(sdev, 0); + scsi_adjust_queue_depth(sdev, sdev->host->cmd_per_lun); return -1; } - scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); + scsi_adjust_queue_depth(sdev, depth); return depth; } EXPORT_SYMBOL(scsi_track_queue_full); @@ -867,7 +852,7 @@ int scsi_change_queue_type(struct scsi_device *sdev, int tag_type) if (!sdev->tagged_supported) return 0; - scsi_adjust_queue_depth(sdev, tag_type, sdev->queue_depth); + scsi_set_tag_type(sdev, tag_type); return tag_type; } diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 7bcace2cdd53..fce4e47becc7 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2700,11 +2700,8 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp) devip = devInfoReg(sdp); if (NULL == devip) return 1; /* no resources, will be marked offline */ - sdp->hostdata = devip; sdp->tagged_supported = 1; - if (sdp->host->cmd_per_lun) - scsi_adjust_queue_depth(sdp, DEF_TAGGED_QUEUING, - DEF_CMD_PER_LUN); + sdp->hostdata = devip; blk_queue_max_segment_size(sdp->request_queue, -1U); if (scsi_debug_no_uld) sdp->no_uld_attach = 1; @@ -4494,7 +4491,7 @@ sdebug_change_qdepth(struct scsi_device *sdev, int qdepth, int reason) /* allow to exceed max host queued_arr elements for testing */ if (qdepth > SCSI_DEBUG_CANQUEUE + 10) qdepth = SCSI_DEBUG_CANQUEUE + 10; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); } else if (reason == SCSI_QDEPTH_QFULL) scsi_track_queue_full(sdev, qdepth); else diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 408891cb14ff..d97597e6337e 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -292,7 +292,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, blk_queue_init_tags(sdev->request_queue, sdev->host->cmd_per_lun, shost->bqt); } - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); + scsi_adjust_queue_depth(sdev, sdev->host->cmd_per_lun); scsi_sysfs_device_initialize(sdev); @@ -880,8 +880,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, (inq_result[3] & 0x0f) == 1 ? " CCS" : ""); if ((sdev->scsi_level >= SCSI_2) && (inq_result[7] & 2) && - !(*bflags & BLIST_NOTQ)) + !(*bflags & BLIST_NOTQ)) { sdev->tagged_supported = 1; + sdev->simple_tags = 1; + } /* * Some devices (Texel CD ROM drives) have handshaking problems diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index b5eae4f6ba46..2bb8a9e74dac 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -549,8 +549,6 @@ stex_slave_alloc(struct scsi_device *sdev) /* Cheat: usually extracted from Inquiry data */ sdev->tagged_supported = 1; - scsi_adjust_queue_depth(sdev, 0, sdev->host->can_queue); - return 0; } diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 37f5fd8ed765..ff8befbdf17c 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1429,8 +1429,7 @@ static void storvsc_device_destroy(struct scsi_device *sdevice) static int storvsc_device_configure(struct scsi_device *sdevice) { - scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG, - STORVSC_MAX_IO_REQUESTS); + scsi_adjust_queue_depth(sdevice, STORVSC_MAX_IO_REQUESTS); blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE); diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index e59e6f96b725..3557b385251a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -820,9 +820,7 @@ static int sym53c8xx_slave_configure(struct scsi_device *sdev) if (reqtags > SYM_CONF_MAX_TAG) reqtags = SYM_CONF_MAX_TAG; depth_to_use = reqtags ? reqtags : 1; - scsi_adjust_queue_depth(sdev, - sdev->tagged_supported ? MSG_SIMPLE_TAG : 0, - depth_to_use); + scsi_adjust_queue_depth(sdev, depth_to_use); lp->s.scdev_depth = depth_to_use; sym_tune_dev_queuing(tp, sdev->lun, reqtags); diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c index 6369f9a282f1..844c9a048c00 100644 --- a/drivers/scsi/tmscsim.c +++ b/drivers/scsi/tmscsim.c @@ -2185,9 +2185,16 @@ static int dc390_slave_configure(struct scsi_device *sdev) struct dc390_dcb *dcb = (struct dc390_dcb *)sdev->hostdata; acb->scan_devices = 0; + + /* + * XXX: Note that while this driver used to called scsi_activate_tcq, + * it never actually set a tag type, so emulate the old behavior. + */ + scsi_set_tag_type(sdev, 0); + if (sdev->tagged_supported && (dcb->DevMode & TAG_QUEUEING_)) { dcb->SyncMode |= EN_TAG_QUEUEING; - scsi_adjust_queue_depth(sdev, 0, acb->TagMaxNum); + scsi_adjust_queue_depth(sdev, acb->TagMaxNum); } return 0; diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c index d8dcf36aed11..aa0f4035afaf 100644 --- a/drivers/scsi/u14-34f.c +++ b/drivers/scsi/u14-34f.c @@ -696,25 +696,25 @@ static int u14_34f_slave_configure(struct scsi_device *dev) { if (TLDEV(dev->type) && dev->tagged_supported) if (tag_mode == TAG_SIMPLE) { - scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, tqd); + scsi_adjust_queue_depth(dev, tqd); tag_suffix = ", simple tags"; } else if (tag_mode == TAG_ORDERED) { - scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, tqd); + scsi_adjust_queue_depth(dev, tqd); tag_suffix = ", ordered tags"; } else { - scsi_adjust_queue_depth(dev, 0, tqd); + scsi_adjust_queue_depth(dev, tqd); tag_suffix = ", no tags"; } else if (TLDEV(dev->type) && linked_comm) { - scsi_adjust_queue_depth(dev, 0, tqd); + scsi_adjust_queue_depth(dev, tqd); tag_suffix = ", untagged"; } else { - scsi_adjust_queue_depth(dev, 0, utqd); + scsi_adjust_queue_depth(dev, utqd); tag_suffix = ""; } diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 48c7f9e8f256..5eb4931e2adc 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2696,7 +2696,7 @@ static void ufshcd_set_queue_depth(struct scsi_device *sdev) dev_dbg(hba->dev, "%s: activate tcq with queue depth %d\n", __func__, lun_qdepth); if (sdev->tagged_supported) - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), lun_qdepth); + scsi_adjust_queue_depth(sdev, lun_qdepth); } /* @@ -2808,7 +2808,7 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, case SCSI_QDEPTH_RAMP_UP: if (!sdev->tagged_supported) depth = 1; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; case SCSI_QDEPTH_QFULL: scsi_track_queue_full(sdev, depth); diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index b83846fc7859..355afbc7fde1 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -683,9 +683,7 @@ static int virtscsi_change_queue_depth(struct scsi_device *sdev, break; case SCSI_QDEPTH_RAMP_UP: /* Raise qdepth after BUSY state resolved */ case SCSI_QDEPTH_DEFAULT: /* Manual change via sysfs */ - scsi_adjust_queue_depth(sdev, - scsi_get_tag_type(sdev), - min(max_depth, qdepth)); + scsi_adjust_queue_depth(sdev, min(max_depth, qdepth)); break; default: return -EOPNOTSUPP; diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 53a3eb6c0634..c3b4f8b3a3a5 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -522,7 +522,7 @@ static int pvscsi_change_queue_depth(struct scsi_device *sdev, max_depth = 1; if (qdepth > max_depth) qdepth = max_depth; - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + scsi_adjust_queue_depth(sdev, qdepth); if (sdev->inquiry_len > 7) sdev_printk(KERN_INFO, sdev, diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 120a851df0d7..0ed96644ec94 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -121,13 +121,13 @@ static int tcm_loop_change_queue_depth( { switch (reason) { case SCSI_QDEPTH_DEFAULT: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; case SCSI_QDEPTH_QFULL: scsi_track_queue_full(sdev, depth); break; case SCSI_QDEPTH_RAMP_UP: - scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + scsi_adjust_queue_depth(sdev, depth); break; default: return -EOPNOTSUPP; @@ -404,19 +404,6 @@ static int tcm_loop_slave_alloc(struct scsi_device *sd) return 0; } -static int tcm_loop_slave_configure(struct scsi_device *sd) -{ - if (sd->tagged_supported) { - scsi_adjust_queue_depth(sd, MSG_SIMPLE_TAG, - sd->host->cmd_per_lun); - } else { - scsi_adjust_queue_depth(sd, 0, - sd->host->cmd_per_lun); - } - - return 0; -} - static struct scsi_host_template tcm_loop_driver_template = { .show_info = tcm_loop_show_info, .proc_name = "tcm_loopback", @@ -434,7 +421,6 @@ static struct scsi_host_template tcm_loop_driver_template = { .max_sectors = 0xFFFF, .use_clustering = DISABLE_CLUSTERING, .slave_alloc = tcm_loop_slave_alloc, - .slave_configure = tcm_loop_slave_configure, .module = THIS_MODULE, .use_blk_tags = 1, }; diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index ee69b82fc7d1..33f211b56a42 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -799,7 +799,7 @@ static int uas_slave_configure(struct scsi_device *sdev) if (devinfo->flags & US_FL_NO_REPORT_OPCODES) sdev->no_report_opcodes = 1; - scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, devinfo->qdepth - 2); + scsi_adjust_queue_depth(sdev, devinfo->qdepth - 2); return 0; } diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index e8fecb5ea79a..0aeaa003c3c1 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -380,7 +380,7 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *, #define __shost_for_each_device(sdev, shost) \ list_for_each_entry((sdev), &((shost)->__devices), siblings) -extern void scsi_adjust_queue_depth(struct scsi_device *, int, int); +extern void scsi_adjust_queue_depth(struct scsi_device *, int); extern int scsi_track_queue_full(struct scsi_device *, int); extern int scsi_set_medium_removal(struct scsi_device *, char); -- cgit v1.2.3 From ee11560f3ad150a1108d261cbff4fd617cc3fa09 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 20:40:56 +0100 Subject: scsi: don't force tagged_supported in drivers Now that we also get proper values in cmd->request->tag for untagged commands, there is no need to force tagged_supported to on in drivers that need host-wide tags. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/fnic/fnic_main.c | 2 -- drivers/scsi/libsas/sas_scsi_host.c | 1 - drivers/scsi/qla4xxx/ql4_os.c | 9 --------- drivers/scsi/scsi_debug.c | 1 - drivers/scsi/stex.c | 11 ----------- drivers/scsi/ufs/ufshcd.c | 6 +----- 6 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 0f29e3f89b26..cf1560c30b7f 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -95,8 +95,6 @@ static int fnic_slave_alloc(struct scsi_device *sdev) { struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); - sdev->tagged_supported = 1; - if (!rport || fc_remote_port_chkready(rport)) return -ENXIO; diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 56d698af073d..89e8b687a679 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -945,7 +945,6 @@ int sas_slave_configure(struct scsi_device *scsi_dev) SAS_DPRINTK("device %llx, LUN %llx doesn't support " "TCQ\n", SAS_ADDR(dev->sas_addr), scsi_dev->lun); - scsi_dev->tagged_supported = 0; scsi_adjust_queue_depth(scsi_dev, 1); } diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 784f59e55510..f8724f2e0158 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -162,7 +162,6 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd); static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd); static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd); static int qla4xxx_slave_alloc(struct scsi_device *device); -static int qla4xxx_slave_configure(struct scsi_device *device); static umode_t qla4_attr_is_visible(int param_type, int param); static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type); static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth, @@ -203,7 +202,6 @@ static struct scsi_host_template qla4xxx_driver_template = { .eh_host_reset_handler = qla4xxx_eh_host_reset, .eh_timed_out = qla4xxx_eh_cmd_timed_out, - .slave_configure = qla4xxx_slave_configure, .slave_alloc = qla4xxx_slave_alloc, .change_queue_depth = qla4xxx_change_queue_depth, @@ -9059,7 +9057,6 @@ static int qla4xxx_slave_alloc(struct scsi_device *sdev) ddb = sess->dd_data; sdev->hostdata = ddb; - sdev->tagged_supported = 1; if (ql4xmaxqdepth != 0 && ql4xmaxqdepth <= 0xffffU) queue_depth = ql4xmaxqdepth; @@ -9068,12 +9065,6 @@ static int qla4xxx_slave_alloc(struct scsi_device *sdev) return 0; } -static int qla4xxx_slave_configure(struct scsi_device *sdev) -{ - sdev->tagged_supported = 1; - return 0; -} - static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) { diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index fce4e47becc7..b02571390d01 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2700,7 +2700,6 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp) devip = devInfoReg(sdp); if (NULL == devip) return 1; /* no resources, will be marked offline */ - sdp->tagged_supported = 1; sdp->hostdata = devip; blk_queue_max_segment_size(sdp->request_queue, -1U); if (scsi_debug_no_uld) diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 2bb8a9e74dac..98a62bc15069 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -543,22 +543,12 @@ stex_ss_send_cmd(struct st_hba *hba, struct req_msg *req, u16 tag) readl(hba->mmio_base + YH2I_REQ); /* flush */ } -static int -stex_slave_alloc(struct scsi_device *sdev) -{ - /* Cheat: usually extracted from Inquiry data */ - sdev->tagged_supported = 1; - - return 0; -} - static int stex_slave_config(struct scsi_device *sdev) { sdev->use_10_for_rw = 1; sdev->use_10_for_ms = 1; blk_queue_rq_timeout(sdev->request_queue, 60 * HZ); - sdev->tagged_supported = 1; return 0; } @@ -1380,7 +1370,6 @@ static struct scsi_host_template driver_template = { .proc_name = DRV_NAME, .bios_param = stex_biosparam, .queuecommand = stex_queuecommand, - .slave_alloc = stex_slave_alloc, .slave_configure = stex_slave_config, .eh_abort_handler = stex_abort, .eh_host_reset_handler = stex_reset, diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5eb4931e2adc..67e2280e2be3 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2695,8 +2695,7 @@ static void ufshcd_set_queue_depth(struct scsi_device *sdev) dev_dbg(hba->dev, "%s: activate tcq with queue depth %d\n", __func__, lun_qdepth); - if (sdev->tagged_supported) - scsi_adjust_queue_depth(sdev, lun_qdepth); + scsi_adjust_queue_depth(sdev, lun_qdepth); } /* @@ -2766,7 +2765,6 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) struct ufs_hba *hba; hba = shost_priv(sdev->host); - sdev->tagged_supported = 1; /* Mode sense(6) is not supported by UFS, so use Mode sense(10) */ sdev->use_10_for_ms = 1; @@ -2806,8 +2804,6 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, switch (reason) { case SCSI_QDEPTH_DEFAULT: case SCSI_QDEPTH_RAMP_UP: - if (!sdev->tagged_supported) - depth = 1; scsi_adjust_queue_depth(sdev, depth); break; case SCSI_QDEPTH_QFULL: -- cgit v1.2.3 From d7cb71ec3a28e525c4f523ca52d5389407b7aea0 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 3 Nov 2014 20:43:28 +0100 Subject: ufs: remove spurious scsi_set_tag_type call ufs never looks at the tag type, so there is no need to set it either. Signed-off-by: Christoph Hellwig Reviewed-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/scsi/ufs/ufshcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 67e2280e2be3..362b818ad827 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2768,7 +2768,6 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) /* Mode sense(6) is not supported by UFS, so use Mode sense(10) */ sdev->use_10_for_ms = 1; - scsi_set_tag_type(sdev, MSG_SIMPLE_TAG); /* allow SCSI layer to restart the device in case of errors */ sdev->allow_restart = 1; -- cgit v1.2.3 From 0f121dd85dc2128fe989da9f57dee764284689f6 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 5 Sep 2014 18:00:05 -0700 Subject: scsi: don't use scsi_next_command in scsi_reset_provider scsi_reset_provider already manually runs all queues for the given host, so it doesn't need the scsi_run_queues call from it, and it doesn't need a reference on the device because it's synchronous. So let's just call scsi_put_command directly and avoid the device reference dance to simplify the code. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index a6f6b9222b51..96627bae753c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2337,14 +2337,9 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) return -EIO; error = -EIO; - if (!get_device(&dev->sdev_gendev)) - goto out_put_autopm_host; - scmd = scsi_get_command(dev, GFP_KERNEL); - if (!scmd) { - put_device(&dev->sdev_gendev); + if (!scmd) goto out_put_autopm_host; - } blk_rq_init(NULL, &req); scmd->request = &req; @@ -2406,10 +2401,10 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) "waking up host to restart after TMF\n")); wake_up(&shost->host_wait); - scsi_run_host_queues(shost); - scsi_next_command(scmd); + scsi_put_command(scmd); + out_put_autopm_host: scsi_autopm_put_host(shost); return error; -- cgit v1.2.3 From bb3ec62a179922b501535d5bd210cb8ba2ad069b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 5 Sep 2014 18:02:09 -0700 Subject: scsi: remove scsi_next_command There's only one caller left, so inline it and reduce the blk-mq vs !blk-mq diff a litte bit. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_lib.c | 18 ++++-------------- drivers/scsi/scsi_priv.h | 1 - 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 994eb083fff9..2179851cdaf3 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -543,17 +543,6 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd) put_device(&sdev->sdev_gendev); } -void scsi_next_command(struct scsi_cmnd *cmd) -{ - struct scsi_device *sdev = cmd->device; - struct request_queue *q = sdev->request_queue; - - scsi_put_command(cmd); - scsi_run_queue(q); - - put_device(&sdev->sdev_gendev); -} - void scsi_run_host_queues(struct Scsi_Host *shost) { struct scsi_device *sdev; @@ -731,8 +720,6 @@ static bool scsi_end_request(struct request *req, int error, kblockd_schedule_work(&sdev->requeue_work); else blk_mq_start_stopped_hw_queues(q, true); - - put_device(&sdev->sdev_gendev); } else { unsigned long flags; @@ -744,9 +731,12 @@ static bool scsi_end_request(struct request *req, int error, spin_unlock_irqrestore(q->queue_lock, flags); scsi_release_buffers(cmd); - scsi_next_command(cmd); + + scsi_put_command(cmd); + scsi_run_queue(q); } + put_device(&sdev->sdev_gendev); return false; } diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index 12b8e1bee7f0..2a382c100760 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -84,7 +84,6 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd); extern int scsi_maybe_unblock_host(struct scsi_device *sdev); extern void scsi_device_unbusy(struct scsi_device *sdev); extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason); -extern void scsi_next_command(struct scsi_cmnd *cmd); extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); extern void scsi_run_host_queues(struct Scsi_Host *shost); extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev); -- cgit v1.2.3 From 3c356bde19e9a728b26a231a23099c8057dbe881 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 5 Sep 2014 18:20:23 -0700 Subject: scsi: stop passing a gfp_mask argument down the command setup path There is no reason for ULDs to pass in a flag on how to allocate the S/G lists. While we don't need GFP_ATOMIC for the blk-mq case because we don't hold locks, that decision can be made way down the chain without having to pass a pointless gfp_mask argument. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_lib.c | 20 +++++++++----------- drivers/scsi/sd.c | 6 +++--- drivers/scsi/sr.c | 2 +- include/scsi/scsi_cmnd.h | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 2179851cdaf3..fcdc585278bf 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -588,10 +588,10 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq) __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, mq, scsi_sg_free); } -static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, - gfp_t gfp_mask, bool mq) +static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq) { struct scatterlist *first_chunk = NULL; + gfp_t gfp_mask = mq ? GFP_NOIO : GFP_ATOMIC; int ret; BUG_ON(!nents); @@ -1077,8 +1077,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) } } -static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, - gfp_t gfp_mask) +static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb) { int count; @@ -1086,7 +1085,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, * If sg table allocation fails, requeue request later. */ if (unlikely(scsi_alloc_sgtable(sdb, req->nr_phys_segments, - gfp_mask, req->mq_ctx != NULL))) + req->mq_ctx != NULL))) return BLKPREP_DEFER; /* @@ -1111,7 +1110,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, * BLKPREP_DEFER if the failure is retryable * BLKPREP_KILL if the failure is fatal */ -int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) +int scsi_init_io(struct scsi_cmnd *cmd) { struct scsi_device *sdev = cmd->device; struct request *rq = cmd->request; @@ -1120,7 +1119,7 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) BUG_ON(!rq->nr_phys_segments); - error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask); + error = scsi_init_sgtable(rq, &cmd->sdb); if (error) goto err_exit; @@ -1136,8 +1135,7 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) rq->next_rq->special = bidi_sdb; } - error = scsi_init_sgtable(rq->next_rq, rq->next_rq->special, - GFP_ATOMIC); + error = scsi_init_sgtable(rq->next_rq, rq->next_rq->special); if (error) goto err_exit; } @@ -1149,7 +1147,7 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) BUG_ON(prot_sdb == NULL); ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); - if (scsi_alloc_sgtable(prot_sdb, ivecs, gfp_mask, is_mq)) { + if (scsi_alloc_sgtable(prot_sdb, ivecs, is_mq)) { error = BLKPREP_DEFER; goto err_exit; } @@ -1218,7 +1216,7 @@ static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) * submit a request without an attached bio. */ if (req->bio) { - int ret = scsi_init_io(cmd, GFP_ATOMIC); + int ret = scsi_init_io(cmd); if (unlikely(ret)) return ret; } else { diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 95bfb7bfbb9d..f2e9b1dad574 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -786,7 +786,7 @@ static int sd_setup_discard_cmnd(struct scsi_cmnd *cmd) * amount of blocks described by the request. */ blk_add_request_payload(rq, page, len); - ret = scsi_init_io(cmd, GFP_ATOMIC); + ret = scsi_init_io(cmd); rq->__data_len = nr_bytes; out: @@ -880,7 +880,7 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) * knows how much to actually write. */ rq->__data_len = sdp->sector_size; - ret = scsi_init_io(cmd, GFP_ATOMIC); + ret = scsi_init_io(cmd); rq->__data_len = nr_bytes; return ret; } @@ -914,7 +914,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) int ret; unsigned char protect; - ret = scsi_init_io(SCpnt, GFP_ATOMIC); + ret = scsi_init_io(SCpnt); if (ret != BLKPREP_OK) goto out; SCpnt = rq->special; diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 3d5399e341af..5ebadc2ace9b 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -387,7 +387,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) struct request *rq = SCpnt->request; int ret; - ret = scsi_init_io(SCpnt, GFP_ATOMIC); + ret = scsi_init_io(SCpnt); if (ret != BLKPREP_OK) goto out; SCpnt = rq->special; diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index e119142e565e..9fc1aecfc813 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -163,7 +163,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, size_t *offset, size_t *len); extern void scsi_kunmap_atomic_sg(void *virt); -extern int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask); +extern int scsi_init_io(struct scsi_cmnd *cmd); extern int scsi_dma_map(struct scsi_cmnd *cmd); extern void scsi_dma_unmap(struct scsi_cmnd *cmd); -- cgit v1.2.3 From 82042a2cdb55cd8402207f14a6e2c24d7a5febe8 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 5 Sep 2014 18:23:07 -0700 Subject: scsi: move scsi_dispatch_cmd to scsi_lib.c scsi_lib.c is where the rest of the I/O submission path lives, so move scsi_dispatch_cmd there and mark it static. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi.c | 81 ------------------------------------------------ drivers/scsi/scsi_lib.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_priv.h | 1 - 3 files changed, 81 insertions(+), 82 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 106fa2f886d2..2d9730432233 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -602,87 +602,6 @@ void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) } EXPORT_SYMBOL(scsi_cmd_get_serial); -/** - * scsi_dispatch_command - Dispatch a command to the low-level driver. - * @cmd: command block we are dispatching. - * - * Return: nonzero return request was rejected and device's queue needs to be - * plugged. - */ -int scsi_dispatch_cmd(struct scsi_cmnd *cmd) -{ - struct Scsi_Host *host = cmd->device->host; - int rtn = 0; - - atomic_inc(&cmd->device->iorequest_cnt); - - /* check if the device is still usable */ - if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { - /* in SDEV_DEL we error all commands. DID_NO_CONNECT - * returns an immediate error upwards, and signals - * that the device is no longer present */ - cmd->result = DID_NO_CONNECT << 16; - goto done; - } - - /* Check to see if the scsi lld made this device blocked. */ - if (unlikely(scsi_device_blocked(cmd->device))) { - /* - * in blocked state, the command is just put back on - * the device queue. The suspend state has already - * blocked the queue so future requests should not - * occur until the device transitions out of the - * suspend state. - */ - SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, - "queuecommand : device blocked\n")); - return SCSI_MLQUEUE_DEVICE_BUSY; - } - - /* Store the LUN value in cmnd, if needed. */ - if (cmd->device->lun_in_cdb) - cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) | - (cmd->device->lun << 5 & 0xe0); - - scsi_log_send(cmd); - - /* - * Before we queue this command, check if the command - * length exceeds what the host adapter can handle. - */ - if (cmd->cmd_len > cmd->device->host->max_cmd_len) { - SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, - "queuecommand : command too long. " - "cdb_size=%d host->max_cmd_len=%d\n", - cmd->cmd_len, cmd->device->host->max_cmd_len)); - cmd->result = (DID_ABORT << 16); - goto done; - } - - if (unlikely(host->shost_state == SHOST_DEL)) { - cmd->result = (DID_NO_CONNECT << 16); - goto done; - - } - - trace_scsi_dispatch_cmd_start(cmd); - rtn = host->hostt->queuecommand(host, cmd); - if (rtn) { - trace_scsi_dispatch_cmd_error(cmd, rtn); - if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && - rtn != SCSI_MLQUEUE_TARGET_BUSY) - rtn = SCSI_MLQUEUE_HOST_BUSY; - - SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, - "queuecommand : request rejected\n")); - } - - return rtn; - done: - cmd->scsi_done(cmd); - return 0; -} - /** * scsi_finish_command - cleanup and pass command back to upper layer * @cmd: the command diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fcdc585278bf..7e3d954c9cac 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1640,6 +1640,87 @@ static void scsi_softirq_done(struct request *rq) } } +/** + * scsi_dispatch_command - Dispatch a command to the low-level driver. + * @cmd: command block we are dispatching. + * + * Return: nonzero return request was rejected and device's queue needs to be + * plugged. + */ +static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) +{ + struct Scsi_Host *host = cmd->device->host; + int rtn = 0; + + atomic_inc(&cmd->device->iorequest_cnt); + + /* check if the device is still usable */ + if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { + /* in SDEV_DEL we error all commands. DID_NO_CONNECT + * returns an immediate error upwards, and signals + * that the device is no longer present */ + cmd->result = DID_NO_CONNECT << 16; + goto done; + } + + /* Check to see if the scsi lld made this device blocked. */ + if (unlikely(scsi_device_blocked(cmd->device))) { + /* + * in blocked state, the command is just put back on + * the device queue. The suspend state has already + * blocked the queue so future requests should not + * occur until the device transitions out of the + * suspend state. + */ + SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, + "queuecommand : device blocked\n")); + return SCSI_MLQUEUE_DEVICE_BUSY; + } + + /* Store the LUN value in cmnd, if needed. */ + if (cmd->device->lun_in_cdb) + cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) | + (cmd->device->lun << 5 & 0xe0); + + scsi_log_send(cmd); + + /* + * Before we queue this command, check if the command + * length exceeds what the host adapter can handle. + */ + if (cmd->cmd_len > cmd->device->host->max_cmd_len) { + SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, + "queuecommand : command too long. " + "cdb_size=%d host->max_cmd_len=%d\n", + cmd->cmd_len, cmd->device->host->max_cmd_len)); + cmd->result = (DID_ABORT << 16); + goto done; + } + + if (unlikely(host->shost_state == SHOST_DEL)) { + cmd->result = (DID_NO_CONNECT << 16); + goto done; + + } + + trace_scsi_dispatch_cmd_start(cmd); + rtn = host->hostt->queuecommand(host, cmd); + if (rtn) { + trace_scsi_dispatch_cmd_error(cmd, rtn); + if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && + rtn != SCSI_MLQUEUE_TARGET_BUSY) + rtn = SCSI_MLQUEUE_HOST_BUSY; + + SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, + "queuecommand : request rejected\n")); + } + + return rtn; + done: + cmd->scsi_done(cmd); + return 0; +} + /** * scsi_done - Invoke completion on finished SCSI command. * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index 2a382c100760..2dc4a83fb84c 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -29,7 +29,6 @@ extern int scsi_init_hosts(void); extern void scsi_exit_hosts(void); /* scsi.c */ -extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd); extern int scsi_setup_command_freelist(struct Scsi_Host *shost); extern void scsi_destroy_command_freelist(struct Scsi_Host *shost); #ifdef CONFIG_SCSI_LOGGING -- cgit v1.2.3 From 3af6b35261182ff185db1f0fd271254147e2663e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 12 Nov 2014 18:34:51 +0100 Subject: scsi: remove scsi_driver owner field The driver core driver structure has grown an owner field and now requires it to be set for all modular drivers. Set it up for all scsi_driver instances and get rid of the now superflous scsi_driver owner field. Signed-off-by: Christoph Hellwig Reported-by: Shane M Seymour Reviewed-by: Ewan D. Milne --- drivers/scsi/ch.c | 2 +- drivers/scsi/osd/osd_uld.c | 2 +- drivers/scsi/osst.c | 2 +- drivers/scsi/scsi_scan.c | 9 ++++----- drivers/scsi/sd.c | 2 +- drivers/scsi/ses.c | 2 +- drivers/scsi/sr.c | 2 +- drivers/scsi/st.c | 2 +- include/scsi/scsi_driver.h | 1 - 9 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 4f502f95f3b8..6bac8a746ee2 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -972,9 +972,9 @@ static int ch_remove(struct device *dev) } static struct scsi_driver ch_template = { - .owner = THIS_MODULE, .gendrv = { .name = "ch", + .owner = THIS_MODULE, .probe = ch_probe, .remove = ch_remove, }, diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index 92cdd4b06526..243eab3d10d0 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c @@ -540,9 +540,9 @@ static int osd_remove(struct device *dev) */ static struct scsi_driver osd_driver = { - .owner = THIS_MODULE, .gendrv = { .name = osd_name, + .owner = THIS_MODULE, .probe = osd_probe, .remove = osd_remove, } diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 8c384648eef9..5033223f6287 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -172,9 +172,9 @@ static int osst_probe(struct device *); static int osst_remove(struct device *); static struct scsi_driver osst_template = { - .owner = THIS_MODULE, .gendrv = { .name = "osst", + .owner = THIS_MODULE, .probe = osst_probe, .remove = osst_remove, } diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index d97597e6337e..0cda53adfd35 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1593,16 +1593,15 @@ EXPORT_SYMBOL(scsi_add_device); void scsi_rescan_device(struct device *dev) { - struct scsi_driver *drv; - if (!dev->driver) return; - drv = to_scsi_driver(dev->driver); - if (try_module_get(drv->owner)) { + if (try_module_get(dev->driver->owner)) { + struct scsi_driver *drv = to_scsi_driver(dev->driver); + if (drv->rescan) drv->rescan(dev); - module_put(drv->owner); + module_put(dev->driver->owner); } } EXPORT_SYMBOL(scsi_rescan_device); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f2e9b1dad574..54abcb220ab4 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -510,9 +510,9 @@ static const struct dev_pm_ops sd_pm_ops = { }; static struct scsi_driver sd_template = { - .owner = THIS_MODULE, .gendrv = { .name = "sd", + .owner = THIS_MODULE, .probe = sd_probe, .remove = sd_remove, .shutdown = sd_shutdown, diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 80bfece1a2de..b7e79e7646ad 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -693,9 +693,9 @@ static struct class_interface ses_interface = { }; static struct scsi_driver ses_template = { - .owner = THIS_MODULE, .gendrv = { .name = "ses", + .owner = THIS_MODULE, .probe = ses_probe, .remove = ses_remove, }, diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 5ebadc2ace9b..8bd54a64efd6 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -88,9 +88,9 @@ static struct dev_pm_ops sr_pm_ops = { }; static struct scsi_driver sr_template = { - .owner = THIS_MODULE, .gendrv = { .name = "sr", + .owner = THIS_MODULE, .probe = sr_probe, .remove = sr_remove, .pm = &sr_pm_ops, diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index e46e02b24ba4..128d3b55bdd9 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -202,9 +202,9 @@ static int do_create_sysfs_files(void); static void do_remove_sysfs_files(void); static struct scsi_driver st_template = { - .owner = THIS_MODULE, .gendrv = { .name = "st", + .owner = THIS_MODULE, .probe = st_probe, .remove = st_remove, }, diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h index c2b759809d8a..891a658aa867 100644 --- a/include/scsi/scsi_driver.h +++ b/include/scsi/scsi_driver.h @@ -9,7 +9,6 @@ struct scsi_cmnd; struct scsi_device; struct scsi_driver { - struct module *owner; struct device_driver gendrv; void (*rescan)(struct device *); -- cgit v1.2.3 From eb846d9f147455e4e5e1863bfb5e31974bb69b7c Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 17 Nov 2014 14:25:19 +0100 Subject: scsi: rename SERVICE_ACTION_IN to SERVICE_ACTION_IN_16 SPC-3 defines SERVICE ACTION IN(12) and SERVICE ACTION IN(16). So rename SERVICE_ACTION_IN to SERVICE_ACTION_IN_16 to be consistent with SPC and to allow for better distinction. Signed-off-by: Hannes Reinecke Tested-by: Robert Elliott Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- block/scsi_ioctl.c | 2 +- drivers/ata/libata-scsi.c | 2 +- drivers/block/nvme-scsi.c | 4 ++-- drivers/scsi/aacraid/aachba.c | 4 ++-- drivers/scsi/aacraid/linit.c | 2 +- drivers/scsi/constants.c | 1 - drivers/scsi/gdth.c | 4 ++-- drivers/scsi/scsi_debug.c | 2 +- drivers/scsi/scsi_trace.c | 2 +- drivers/scsi/sd.c | 2 +- drivers/target/target_core_alua.c | 2 +- drivers/target/target_core_sbc.c | 2 +- drivers/usb/gadget/legacy/tcm_usb_gadget.c | 2 +- include/scsi/scsi.h | 2 +- include/trace/events/scsi.h | 2 +- include/trace/events/target.h | 2 +- tools/lib/traceevent/plugin_scsi.c | 4 ++-- 17 files changed, 20 insertions(+), 21 deletions(-) diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 1e053d911240..c7bbc190f16f 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -142,7 +142,7 @@ static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter) __set_bit(GPCMD_VERIFY_10, filter->read_ok); __set_bit(VERIFY_16, filter->read_ok); __set_bit(REPORT_LUNS, filter->read_ok); - __set_bit(SERVICE_ACTION_IN, filter->read_ok); + __set_bit(SERVICE_ACTION_IN_16, filter->read_ok); __set_bit(RECEIVE_DIAGNOSTIC, filter->read_ok); __set_bit(MAINTENANCE_IN, filter->read_ok); __set_bit(GPCMD_READ_BUFFER_CAPACITY, filter->read_ok); diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index c8bb6abbf12c..fc6a60abe518 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3570,7 +3570,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd) ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); break; - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); else diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c index a4cd6d691c63..0b4b2775600e 100644 --- a/drivers/block/nvme-scsi.c +++ b/drivers/block/nvme-scsi.c @@ -329,7 +329,7 @@ INQUIRY_EVPD_BIT_MASK) ? 1 : 0) (GET_U32_FROM_CDB(cdb, READ_CAP_16_CDB_ALLOC_LENGTH_OFFSET)) #define IS_READ_CAP_16(cdb) \ -((cdb[0] == SERVICE_ACTION_IN && cdb[1] == SAI_READ_CAPACITY_16) ? 1 : 0) +((cdb[0] == SERVICE_ACTION_IN_16 && cdb[1] == SAI_READ_CAPACITY_16) ? 1 : 0) /* Request Sense Helper Macros */ #define GET_REQUEST_SENSE_ALLOC_LENGTH(cdb) \ @@ -2947,7 +2947,7 @@ static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr) case READ_CAPACITY: retcode = nvme_trans_read_capacity(ns, hdr, cmd); break; - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if (IS_READ_CAP_16(cmd)) retcode = nvme_trans_read_capacity(ns, hdr, cmd); else diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 681434e2dfe9..b32e77db0c48 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -2181,7 +2181,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) (fsa_dev_ptr[cid].sense_data.sense_key == NOT_READY)) { switch (scsicmd->cmnd[0]) { - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if (!(dev->raw_io_interface) || !(dev->raw_io_64) || ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) @@ -2309,7 +2309,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) scsi_sg_copy_from_buffer(scsicmd, &inq_data, sizeof(inq_data)); return aac_get_container_name(scsicmd); } - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if (!(dev->raw_io_interface) || !(dev->raw_io_64) || ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 41b9c68bca67..4c340d88c33d 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -555,7 +555,7 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) AAC_DRIVERNAME, host->host_no, sdev_channel(dev), sdev_id(dev), dev->lun); switch (cmd->cmnd[0]) { - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if (!(aac->raw_io_interface) || !(aac->raw_io_64) || ((cmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 0cf43f6e464b..52afabd23d9f 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -24,7 +24,6 @@ #define SERVICE_ACTION_IN_12 0xab #define SERVICE_ACTION_OUT_12 0xa9 #define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_IN_16 0x9e #define SERVICE_ACTION_OUT_16 0x9f #define THIRD_PARTY_COPY_OUT 0x83 #define THIRD_PARTY_COPY_IN 0x84 diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 4ebbeae161e2..71e138044379 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -2159,7 +2159,7 @@ static void gdth_next(gdth_ha_str *ha) case VERIFY: case START_STOP: case MODE_SENSE: - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0], nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], nscp->cmnd[4],nscp->cmnd[5])); @@ -2391,7 +2391,7 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp) gdth_copy_internal_data(ha, scp, (char*)&rdc, sizeof(gdth_rdcap_data)); break; - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if ((scp->cmnd[1] & 0x1f) == SAI_READ_CAPACITY_16 && (ha->cache_feat & GDT_64BIT)) { gdth_rdcap16_data rdc16; diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index b02571390d01..378e0aae29ca 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4210,7 +4210,7 @@ scsi_debug_queuecommand(struct scsi_cmnd *SCpnt) case READ_CAPACITY: errsts = resp_readcap(SCpnt, devip); break; - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: if (cmd[1] == SAI_READ_CAPACITY_16) errsts = resp_readcap16(SCpnt, devip); else if (cmd[1] == SAI_GET_LBA_STATUS) { diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c index 503594e5f76d..82af28b90294 100644 --- a/drivers/scsi/scsi_trace.c +++ b/drivers/scsi/scsi_trace.c @@ -278,7 +278,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len) return scsi_trace_rw16(p, cdb, len); case UNMAP: return scsi_trace_unmap(p, cdb, len); - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: return scsi_trace_service_action_in(p, cdb, len); case VARIABLE_LENGTH_CMD: return scsi_trace_varlen(p, cdb, len); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 54abcb220ab4..fedab3c21ddf 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1982,7 +1982,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, do { memset(cmd, 0, 16); - cmd[0] = SERVICE_ACTION_IN; + cmd[0] = SERVICE_ACTION_IN_16; cmd[1] = SAI_READ_CAPACITY_16; cmd[13] = RC16_LEN; memset(buffer, 0, RC16_LEN); diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index fb87780929d2..75cbde1f7c5b 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -576,7 +576,7 @@ static inline int core_alua_state_standby( case SEND_DIAGNOSTIC: case READ_CAPACITY: return 0; - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: switch (cdb[1] & 0x1f) { case SAI_READ_CAPACITY_16: return 0; diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index ebe62afb957d..8d171ff77e75 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -852,7 +852,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) size = READ_CAP_LEN; cmd->execute_cmd = sbc_emulate_readcapacity; break; - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: switch (cmd->t_task_cdb[1] & 0x1f) { case SAI_READ_CAPACITY_16: cmd->execute_cmd = sbc_emulate_readcapacity_16; diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c index 6cdb7a534f23..024f58475a94 100644 --- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c +++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c @@ -912,7 +912,7 @@ static int get_cmd_dir(const unsigned char *cdb) case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: case MAINTENANCE_IN: case PERSISTENT_RESERVE_IN: case SECURITY_PROTOCOL_IN: diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index d17178e6fcdd..b354c0de324e 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -151,7 +151,7 @@ enum scsi_timeouts { #define VERIFY_16 0x8f #define SYNCHRONIZE_CACHE_16 0x91 #define WRITE_SAME_16 0x93 -#define SERVICE_ACTION_IN 0x9e +#define SERVICE_ACTION_IN_16 0x9e /* values for service action in */ #define SAI_READ_CAPACITY_16 0x10 #define SAI_GET_LBA_STATUS 0x12 diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index db6c93510f74..079bd10a01b4 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -94,7 +94,7 @@ scsi_opcode_name(WRITE_16), \ scsi_opcode_name(VERIFY_16), \ scsi_opcode_name(WRITE_SAME_16), \ - scsi_opcode_name(SERVICE_ACTION_IN), \ + scsi_opcode_name(SERVICE_ACTION_IN_16), \ scsi_opcode_name(SAI_READ_CAPACITY_16), \ scsi_opcode_name(SAI_GET_LBA_STATUS), \ scsi_opcode_name(MI_REPORT_TARGET_PGS), \ diff --git a/include/trace/events/target.h b/include/trace/events/target.h index da9cc0f05c93..45403443dd82 100644 --- a/include/trace/events/target.h +++ b/include/trace/events/target.h @@ -96,7 +96,7 @@ scsi_opcode_name(WRITE_16), \ scsi_opcode_name(VERIFY_16), \ scsi_opcode_name(WRITE_SAME_16), \ - scsi_opcode_name(SERVICE_ACTION_IN), \ + scsi_opcode_name(SERVICE_ACTION_IN_16), \ scsi_opcode_name(SAI_READ_CAPACITY_16), \ scsi_opcode_name(SAI_GET_LBA_STATUS), \ scsi_opcode_name(MI_REPORT_TARGET_PGS), \ diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index eda326fc8620..c699f477a101 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c @@ -107,7 +107,7 @@ typedef unsigned int u32; #define VERIFY_16 0x8f #define SYNCHRONIZE_CACHE_16 0x91 #define WRITE_SAME_16 0x93 -#define SERVICE_ACTION_IN 0x9e +#define SERVICE_ACTION_IN_16 0x9e /* values for service action in */ #define SAI_READ_CAPACITY_16 0x10 #define SAI_GET_LBA_STATUS 0x12 @@ -393,7 +393,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len) return scsi_trace_rw16(p, cdb, len); case UNMAP: return scsi_trace_unmap(p, cdb, len); - case SERVICE_ACTION_IN: + case SERVICE_ACTION_IN_16: return scsi_trace_service_action_in(p, cdb, len); case VARIABLE_LENGTH_CMD: return scsi_trace_varlen(p, cdb, len); -- cgit v1.2.3 From 85686f696d81a4bcfa5e51ee9ee2b6aae5531c6f Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 17 Nov 2014 14:25:20 +0100 Subject: scsi: add SPC-3 command definitions SPC-3 defines SERVICE ACTION IN(12), SERVICE_ACTION OUT(12), SERVICE ACTION OUT(16), and SERVICE ACTION BIDIRECTIONAL. And READ MEDIA SERIAL NUMBER has long since been deprecated. So update callers to refer to the new cdb name. Signed-off-by: Hannes Reinecke Tested-by: Robert Elliott Reviewed-by: Robert Elliott Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 4 ---- drivers/target/target_core_pr.c | 2 +- include/scsi/scsi.h | 10 +++++++--- tools/lib/traceevent/plugin_scsi.c | 5 ++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 52afabd23d9f..aee62f60b43d 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -21,10 +21,6 @@ /* Commands with service actions that change the command name */ -#define SERVICE_ACTION_IN_12 0xab -#define SERVICE_ACTION_OUT_12 0xa9 -#define SERVICE_ACTION_BIDIRECTIONAL 0x9d -#define SERVICE_ACTION_OUT_16 0x9f #define THIRD_PARTY_COPY_OUT 0x83 #define THIRD_PARTY_COPY_IN 0x84 diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 8c60a1a1ae8d..806bfba894ca 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -459,7 +459,7 @@ static int core_scsi3_pr_seq_non_holder( case ACCESS_CONTROL_OUT: case INQUIRY: case LOG_SENSE: - case READ_MEDIA_SERIAL_NUMBER: + case SERVICE_ACTION_IN_12: case REPORT_LUNS: case REQUEST_SENSE: case PERSISTENT_RESERVE_IN: diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index b354c0de324e..8a7f8ad58aac 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -128,8 +128,10 @@ enum scsi_timeouts { #define MOVE_MEDIUM 0xa5 #define EXCHANGE_MEDIUM 0xa6 #define READ_12 0xa8 +#define SERVICE_ACTION_OUT_12 0xa9 #define WRITE_12 0xaa -#define READ_MEDIA_SERIAL_NUMBER 0xab +#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */ +#define SERVICE_ACTION_IN_12 0xab #define WRITE_VERIFY_12 0xae #define VERIFY_12 0xaf #define SEARCH_HIGH_12 0xb0 @@ -151,7 +153,9 @@ enum scsi_timeouts { #define VERIFY_16 0x8f #define SYNCHRONIZE_CACHE_16 0x91 #define WRITE_SAME_16 0x93 +#define SERVICE_ACTION_BIDIRECTIONAL 0x9d #define SERVICE_ACTION_IN_16 0x9e +#define SERVICE_ACTION_OUT_16 0x9f /* values for service action in */ #define SAI_READ_CAPACITY_16 0x10 #define SAI_GET_LBA_STATUS 0x12 @@ -165,8 +169,8 @@ enum scsi_timeouts { #define MI_REPORT_ALIASES 0x0b #define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c #define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d -#define MI_REPORT_PRIORITY 0x0e -#define MI_REPORT_TIMESTAMP 0x0f +#define MI_REPORT_PRIORITY 0x0e +#define MI_REPORT_TIMESTAMP 0x0f #define MI_MANAGEMENT_PROTOCOL_IN 0x10 /* value for MI_REPORT_TARGET_PGS ext header */ #define MI_EXT_HDR_PARAM_FMT 0x20 diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index c699f477a101..3727de48c8d5 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c @@ -85,8 +85,9 @@ typedef unsigned int u32; #define MOVE_MEDIUM 0xa5 #define EXCHANGE_MEDIUM 0xa6 #define READ_12 0xa8 +#define SERVICE_ACTION_OUT_12 0xa9 #define WRITE_12 0xaa -#define READ_MEDIA_SERIAL_NUMBER 0xab +#define SERVICE_ACTION_IN_12 0xab #define WRITE_VERIFY_12 0xae #define VERIFY_12 0xaf #define SEARCH_HIGH_12 0xb0 @@ -107,7 +108,9 @@ typedef unsigned int u32; #define VERIFY_16 0x8f #define SYNCHRONIZE_CACHE_16 0x91 #define WRITE_SAME_16 0x93 +#define SERVICE_ACTION_BIDIRECTIONAL 0x9d #define SERVICE_ACTION_IN_16 0x9e +#define SERVICE_ACTION_OUT_16 0x9f /* values for service action in */ #define SAI_READ_CAPACITY_16 0x10 #define SAI_GET_LBA_STATUS 0x12 -- cgit v1.2.3 From 249b15ba6380830881b7863ca5dd3f33320adfdb Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 2 Dec 2014 14:07:30 +0300 Subject: scsi: set fmt to NULL scsi_extd_sense_format() by default One of the two callers passes an unintialized pointer as "fmt" and expects it to be set to NULL if there is no format string. Let's make this function work as expected. Fixes: d811b848ebb7 ('scsi: use sdev as argument for sense code printing') Signed-off-by: Dan Carpenter Reviewed-by: James Bottomley Signed-off-by: Christoph Hellwig --- drivers/scsi/constants.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index aee62f60b43d..e2068a2621c4 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1271,6 +1271,7 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) int i; unsigned short code = ((asc << 8) | ascq); + *fmt = NULL; for (i = 0; additional[i].text; i++) if (additional[i].code12 == code) return additional[i].text; @@ -1282,6 +1283,8 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) return additional2[i].str; } } +#else + *fmt = NULL; #endif return NULL; } -- cgit v1.2.3