aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/blk-mq.h17
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/scsi/libfc.h1
-rw-r--r--include/scsi/scsi.h12
-rw-r--r--include/scsi/scsi_cmnd.h6
-rw-r--r--include/scsi/scsi_dbg.h28
-rw-r--r--include/scsi/scsi_device.h21
-rw-r--r--include/scsi/scsi_driver.h1
-rw-r--r--include/scsi/scsi_eh.h24
-rw-r--r--include/scsi/scsi_host.h24
-rw-r--r--include/scsi/scsi_ioctl.h4
-rw-r--r--include/scsi/scsi_tcq.h87
-rw-r--r--include/scsi/scsi_transport_spi.h1
-rw-r--r--include/scsi/sg.h5
-rw-r--r--include/trace/events/scsi.h2
-rw-r--r--include/trace/events/target.h2
16 files changed, 100 insertions, 136 deletions
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,
167 gfp_t gfp, bool reserved); 167 gfp_t gfp, bool reserved);
168struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag); 168struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
169 169
170enum {
171 BLK_MQ_UNIQUE_TAG_BITS = 16,
172 BLK_MQ_UNIQUE_TAG_MASK = (1 << BLK_MQ_UNIQUE_TAG_BITS) - 1,
173};
174
175u32 blk_mq_unique_tag(struct request *rq);
176
177static inline u16 blk_mq_unique_tag_to_hwq(u32 unique_tag)
178{
179 return unique_tag >> BLK_MQ_UNIQUE_TAG_BITS;
180}
181
182static inline u16 blk_mq_unique_tag_to_tag(u32 unique_tag)
183{
184 return unique_tag & BLK_MQ_UNIQUE_TAG_MASK;
185}
186
170struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index); 187struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);
171struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int); 188struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);
172 189
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)
1136/* 1136/*
1137 * tag stuff 1137 * tag stuff
1138 */ 1138 */
1139#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
1140extern int blk_queue_start_tag(struct request_queue *, struct request *); 1139extern int blk_queue_start_tag(struct request_queue *, struct request *);
1141extern struct request *blk_queue_find_tag(struct request_queue *, int); 1140extern struct request *blk_queue_find_tag(struct request_queue *, int);
1142extern void blk_queue_end_tag(struct request_queue *, struct request *); 1141extern void blk_queue_end_tag(struct request_queue *, struct request *);
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 *);
1106int fc_eh_host_reset(struct scsi_cmnd *); 1106int fc_eh_host_reset(struct scsi_cmnd *);
1107int fc_slave_alloc(struct scsi_device *); 1107int fc_slave_alloc(struct scsi_device *);
1108int fc_change_queue_depth(struct scsi_device *, int qdepth, int reason); 1108int fc_change_queue_depth(struct scsi_device *, int qdepth, int reason);
1109int fc_change_queue_type(struct scsi_device *, int tag_type);
1110 1109
1111/* 1110/*
1112 * ELS/CT interface 1111 * ELS/CT interface
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index d17178e6fcdd..8a7f8ad58aac 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -128,8 +128,10 @@ enum scsi_timeouts {
128#define MOVE_MEDIUM 0xa5 128#define MOVE_MEDIUM 0xa5
129#define EXCHANGE_MEDIUM 0xa6 129#define EXCHANGE_MEDIUM 0xa6
130#define READ_12 0xa8 130#define READ_12 0xa8
131#define SERVICE_ACTION_OUT_12 0xa9
131#define WRITE_12 0xaa 132#define WRITE_12 0xaa
132#define READ_MEDIA_SERIAL_NUMBER 0xab 133#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
134#define SERVICE_ACTION_IN_12 0xab
133#define WRITE_VERIFY_12 0xae 135#define WRITE_VERIFY_12 0xae
134#define VERIFY_12 0xaf 136#define VERIFY_12 0xaf
135#define SEARCH_HIGH_12 0xb0 137#define SEARCH_HIGH_12 0xb0
@@ -151,7 +153,9 @@ enum scsi_timeouts {
151#define VERIFY_16 0x8f 153#define VERIFY_16 0x8f
152#define SYNCHRONIZE_CACHE_16 0x91 154#define SYNCHRONIZE_CACHE_16 0x91
153#define WRITE_SAME_16 0x93 155#define WRITE_SAME_16 0x93
154#define SERVICE_ACTION_IN 0x9e 156#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
157#define SERVICE_ACTION_IN_16 0x9e
158#define SERVICE_ACTION_OUT_16 0x9f
155/* values for service action in */ 159/* values for service action in */
156#define SAI_READ_CAPACITY_16 0x10 160#define SAI_READ_CAPACITY_16 0x10
157#define SAI_GET_LBA_STATUS 0x12 161#define SAI_GET_LBA_STATUS 0x12
@@ -165,8 +169,8 @@ enum scsi_timeouts {
165#define MI_REPORT_ALIASES 0x0b 169#define MI_REPORT_ALIASES 0x0b
166#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c 170#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
167#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d 171#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
168#define MI_REPORT_PRIORITY 0x0e 172#define MI_REPORT_PRIORITY 0x0e
169#define MI_REPORT_TIMESTAMP 0x0f 173#define MI_REPORT_TIMESTAMP 0x0f
170#define MI_MANAGEMENT_PROTOCOL_IN 0x10 174#define MI_MANAGEMENT_PROTOCOL_IN 0x10
171/* value for MI_REPORT_TARGET_PGS ext header */ 175/* value for MI_REPORT_TARGET_PGS ext header */
172#define MI_EXT_HDR_PARAM_FMT 0x20 176#define MI_EXT_HDR_PARAM_FMT 0x20
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 522a5f27f553..9fc1aecfc813 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -53,6 +53,9 @@ struct scsi_pointer {
53 volatile int phase; 53 volatile int phase;
54}; 54};
55 55
56/* for scmd->flags */
57#define SCMD_TAGGED (1 << 0)
58
56struct scsi_cmnd { 59struct scsi_cmnd {
57 struct scsi_device *device; 60 struct scsi_device *device;
58 struct list_head list; /* scsi_cmnd participates in queue lists */ 61 struct list_head list; /* scsi_cmnd participates in queue lists */
@@ -132,6 +135,7 @@ struct scsi_cmnd {
132 * to be at an address < 16Mb). */ 135 * to be at an address < 16Mb). */
133 136
134 int result; /* Status code from lower level driver */ 137 int result; /* Status code from lower level driver */
138 int flags; /* Command flags */
135 139
136 unsigned char tag; /* SCSI-II queued command tag */ 140 unsigned char tag; /* SCSI-II queued command tag */
137}; 141};
@@ -159,7 +163,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
159 size_t *offset, size_t *len); 163 size_t *offset, size_t *len);
160extern void scsi_kunmap_atomic_sg(void *virt); 164extern void scsi_kunmap_atomic_sg(void *virt);
161 165
162extern int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask); 166extern int scsi_init_io(struct scsi_cmnd *cmd);
163 167
164extern int scsi_dma_map(struct scsi_cmnd *cmd); 168extern int scsi_dma_map(struct scsi_cmnd *cmd);
165extern void scsi_dma_unmap(struct scsi_cmnd *cmd); 169extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index e89844cc2cd3..7982795df595 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -2,23 +2,27 @@
2#define _SCSI_SCSI_DBG_H 2#define _SCSI_SCSI_DBG_H
3 3
4struct scsi_cmnd; 4struct scsi_cmnd;
5struct scsi_device;
5struct scsi_sense_hdr; 6struct scsi_sense_hdr;
6 7
7extern void scsi_print_command(struct scsi_cmnd *); 8extern void scsi_print_command(struct scsi_cmnd *);
8extern void __scsi_print_command(unsigned char *); 9extern void __scsi_print_command(const unsigned char *, size_t);
9extern void scsi_show_extd_sense(unsigned char, unsigned char); 10extern void scsi_show_extd_sense(const struct scsi_device *, const char *,
10extern void scsi_show_sense_hdr(struct scsi_sense_hdr *); 11 unsigned char, unsigned char);
11extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); 12extern void scsi_show_sense_hdr(const struct scsi_device *, const char *,
12extern void scsi_cmd_print_sense_hdr(struct scsi_cmnd *, const char *, 13 const struct scsi_sense_hdr *);
13 struct scsi_sense_hdr *); 14extern void scsi_print_sense_hdr(const struct scsi_device *, const char *,
14extern void scsi_print_sense(char *, struct scsi_cmnd *); 15 const struct scsi_sense_hdr *);
15extern void __scsi_print_sense(const char *name, 16extern void scsi_print_sense(const struct scsi_cmnd *);
17extern void __scsi_print_sense(const struct scsi_device *, const char *name,
16 const unsigned char *sense_buffer, 18 const unsigned char *sense_buffer,
17 int sense_len); 19 int sense_len);
18extern void scsi_show_result(int); 20extern void scsi_print_result(struct scsi_cmnd *, const char *, int);
19extern void scsi_print_result(struct scsi_cmnd *); 21extern const char *scsi_hostbyte_string(int);
20extern void scsi_print_status(unsigned char); 22extern const char *scsi_driverbyte_string(int);
23extern const char *scsi_mlreturn_string(int);
21extern const char *scsi_sense_key_string(unsigned char); 24extern const char *scsi_sense_key_string(unsigned char);
22extern const char *scsi_extd_sense_format(unsigned char, unsigned char); 25extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
26 const char **);
23 27
24#endif /* _SCSI_SCSI_DBG_H */ 28#endif /* _SCSI_SCSI_DBG_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 27ecee73bd72..0aeaa003c3c1 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -141,7 +141,6 @@ struct scsi_device {
141 unsigned ppr:1; /* Device supports PPR messages */ 141 unsigned ppr:1; /* Device supports PPR messages */
142 unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ 142 unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */
143 unsigned simple_tags:1; /* simple queue tag messages are enabled */ 143 unsigned simple_tags:1; /* simple queue tag messages are enabled */
144 unsigned ordered_tags:1;/* ordered queue tag messages are enabled */
145 unsigned was_reset:1; /* There was a bus reset on the bus for 144 unsigned was_reset:1; /* There was a bus reset on the bus for
146 * this device */ 145 * this device */
147 unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN 146 unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
@@ -201,11 +200,6 @@ struct scsi_device {
201 unsigned long sdev_data[0]; 200 unsigned long sdev_data[0];
202} __attribute__((aligned(sizeof(unsigned long)))); 201} __attribute__((aligned(sizeof(unsigned long))));
203 202
204struct scsi_dh_devlist {
205 char *vendor;
206 char *model;
207};
208
209typedef void (*activate_complete)(void *, int); 203typedef void (*activate_complete)(void *, int);
210struct scsi_device_handler { 204struct scsi_device_handler {
211 /* Used by the infrastructure */ 205 /* Used by the infrastructure */
@@ -214,9 +208,8 @@ struct scsi_device_handler {
214 /* Filled by the hardware handler */ 208 /* Filled by the hardware handler */
215 struct module *module; 209 struct module *module;
216 const char *name; 210 const char *name;
217 const struct scsi_dh_devlist *devlist;
218 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); 211 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
219 int (*attach)(struct scsi_device *); 212 struct scsi_dh_data *(*attach)(struct scsi_device *);
220 void (*detach)(struct scsi_device *); 213 void (*detach)(struct scsi_device *);
221 int (*activate)(struct scsi_device *, activate_complete, void *); 214 int (*activate)(struct scsi_device *, activate_complete, void *);
222 int (*prep_fn)(struct scsi_device *, struct request *); 215 int (*prep_fn)(struct scsi_device *, struct request *);
@@ -228,7 +221,6 @@ struct scsi_dh_data {
228 struct scsi_device_handler *scsi_dh; 221 struct scsi_device_handler *scsi_dh;
229 struct scsi_device *sdev; 222 struct scsi_device *sdev;
230 struct kref kref; 223 struct kref kref;
231 char buf[0];
232}; 224};
233 225
234#define to_scsi_device(d) \ 226#define to_scsi_device(d) \
@@ -244,6 +236,15 @@ struct scsi_dh_data {
244#define sdev_dbg(sdev, fmt, a...) \ 236#define sdev_dbg(sdev, fmt, a...) \
245 dev_dbg(&(sdev)->sdev_gendev, fmt, ##a) 237 dev_dbg(&(sdev)->sdev_gendev, fmt, ##a)
246 238
239/*
240 * like scmd_printk, but the device name is passed in
241 * as a string pointer
242 */
243#define sdev_prefix_printk(l, sdev, p, fmt, a...) \
244 (p) ? \
245 sdev_printk(l, sdev, "[%s] " fmt, p, ##a) : \
246 sdev_printk(l, sdev, fmt, ##a)
247
247#define scmd_printk(prefix, scmd, fmt, a...) \ 248#define scmd_printk(prefix, scmd, fmt, a...) \
248 (scmd)->request->rq_disk ? \ 249 (scmd)->request->rq_disk ? \
249 sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \ 250 sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \
@@ -379,7 +380,7 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
379#define __shost_for_each_device(sdev, shost) \ 380#define __shost_for_each_device(sdev, shost) \
380 list_for_each_entry((sdev), &((shost)->__devices), siblings) 381 list_for_each_entry((sdev), &((shost)->__devices), siblings)
381 382
382extern void scsi_adjust_queue_depth(struct scsi_device *, int, int); 383extern void scsi_adjust_queue_depth(struct scsi_device *, int);
383extern int scsi_track_queue_full(struct scsi_device *, int); 384extern int scsi_track_queue_full(struct scsi_device *, int);
384 385
385extern int scsi_set_medium_removal(struct scsi_device *, char); 386extern int scsi_set_medium_removal(struct scsi_device *, char);
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;
9struct scsi_device; 9struct scsi_device;
10 10
11struct scsi_driver { 11struct scsi_driver {
12 struct module *owner;
13 struct device_driver gendrv; 12 struct device_driver gendrv;
14 13
15 void (*rescan)(struct device *); 14 void (*rescan)(struct device *);
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 06a8790893ef..1e1421b06565 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 */
27 u8 additional_length; /* always 0 for fixed sense format */ 27 u8 additional_length; /* always 0 for fixed sense format */
28}; 28};
29 29
30static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr) 30static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)
31{ 31{
32 if (!sshdr) 32 if (!sshdr)
33 return 0; 33 return false;
34 34
35 return (sshdr->response_code & 0x70) == 0x70; 35 return (sshdr->response_code & 0x70) == 0x70;
36} 36}
@@ -42,12 +42,12 @@ extern void scsi_eh_flush_done_q(struct list_head *done_q);
42extern void scsi_report_bus_reset(struct Scsi_Host *, int); 42extern void scsi_report_bus_reset(struct Scsi_Host *, int);
43extern void scsi_report_device_reset(struct Scsi_Host *, int, int); 43extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
44extern int scsi_block_when_processing_errors(struct scsi_device *); 44extern int scsi_block_when_processing_errors(struct scsi_device *);
45extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, 45extern bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
46 struct scsi_sense_hdr *sshdr); 46 struct scsi_sense_hdr *sshdr);
47extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd, 47extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
48 struct scsi_sense_hdr *sshdr); 48 struct scsi_sense_hdr *sshdr);
49 49
50static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr) 50static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
51{ 51{
52 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); 52 return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
53} 53}
@@ -60,15 +60,7 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
60 60
61extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); 61extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq);
62 62
63/* 63extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
64 * Reset request from external source
65 */
66#define SCSI_TRY_RESET_DEVICE 1
67#define SCSI_TRY_RESET_BUS 2
68#define SCSI_TRY_RESET_HOST 3
69#define SCSI_TRY_RESET_TARGET 4
70
71extern int scsi_reset_provider(struct scsi_device *, int);
72 64
73struct scsi_eh_save { 65struct scsi_eh_save {
74 /* saved state */ 66 /* saved state */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 5e362489ee88..61a81bf77e28 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -422,6 +422,11 @@ struct scsi_host_template {
422 unsigned char present; 422 unsigned char present;
423 423
424 /* 424 /*
425 * Let the block layer assigns tags to all commands.
426 */
427 unsigned use_blk_tags:1;
428
429 /*
425 * This specifies the mode that a LLD supports. 430 * This specifies the mode that a LLD supports.
426 */ 431 */
427 unsigned supported_mode:2; 432 unsigned supported_mode:2;
@@ -451,11 +456,6 @@ struct scsi_host_template {
451 */ 456 */
452 unsigned skip_settle_delay:1; 457 unsigned skip_settle_delay:1;
453 458
454 /*
455 * True if we are using ordered write support.
456 */
457 unsigned ordered_tag:1;
458
459 /* True if the controller does not support WRITE SAME */ 459 /* True if the controller does not support WRITE SAME */
460 unsigned no_write_same:1; 460 unsigned no_write_same:1;
461 461
@@ -638,6 +638,14 @@ struct Scsi_Host {
638 short unsigned int sg_prot_tablesize; 638 short unsigned int sg_prot_tablesize;
639 unsigned int max_sectors; 639 unsigned int max_sectors;
640 unsigned long dma_boundary; 640 unsigned long dma_boundary;
641 /*
642 * In scsi-mq mode, the number of hardware queues supported by the LLD.
643 *
644 * Note: it is assumed that each hardware queue has a queue depth of
645 * can_queue. In other words, the total queue depth per host
646 * is nr_hw_queues * can_queue.
647 */
648 unsigned nr_hw_queues;
641 /* 649 /*
642 * Used to assign serial numbers to the cmds. 650 * Used to assign serial numbers to the cmds.
643 * Protected by the host lock. 651 * Protected by the host lock.
@@ -647,7 +655,6 @@ struct Scsi_Host {
647 unsigned active_mode:2; 655 unsigned active_mode:2;
648 unsigned unchecked_isa_dma:1; 656 unsigned unchecked_isa_dma:1;
649 unsigned use_clustering:1; 657 unsigned use_clustering:1;
650 unsigned use_blk_tcq:1;
651 658
652 /* 659 /*
653 * Host has requested that no further requests come through for the 660 * Host has requested that no further requests come through for the
@@ -662,11 +669,6 @@ struct Scsi_Host {
662 */ 669 */
663 unsigned reverse_ordering:1; 670 unsigned reverse_ordering:1;
664 671
665 /*
666 * Ordered write support
667 */
668 unsigned ordered_tag:1;
669
670 /* Task mgmt function in progress */ 672 /* Task mgmt function in progress */
671 unsigned tmf_in_progress:1; 673 unsigned tmf_in_progress:1;
672 674
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 {
40 unsigned char host_wwn[8]; // include NULL term. 40 unsigned char host_wwn[8]; // include NULL term.
41} Scsi_FCTargAddress; 41} Scsi_FCTargAddress;
42 42
43int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev,
44 int cmd, bool ndelay);
43extern int scsi_ioctl(struct scsi_device *, int, void __user *); 45extern int scsi_ioctl(struct scsi_device *, int, void __user *);
44extern int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd,
45 void __user *arg, int ndelay);
46 46
47#endif /* __KERNEL__ */ 47#endif /* __KERNEL__ */
48#endif /* _SCSI_IOCTL_H */ 48#endif /* _SCSI_IOCTL_H */
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index 56ed843969ca..fe4a70299419 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -16,20 +16,16 @@
16 16
17#ifdef CONFIG_BLOCK 17#ifdef CONFIG_BLOCK
18 18
19int scsi_change_queue_type(struct scsi_device *sdev, int tag_type);
20
19/** 21/**
20 * scsi_get_tag_type - get the type of tag the device supports 22 * scsi_get_tag_type - get the type of tag the device supports
21 * @sdev: the scsi device 23 * @sdev: the scsi device
22 *
23 * Notes:
24 * If the drive only supports simple tags, returns MSG_SIMPLE_TAG
25 * if it supports all tag types, returns MSG_ORDERED_TAG.
26 */ 24 */
27static inline int scsi_get_tag_type(struct scsi_device *sdev) 25static inline int scsi_get_tag_type(struct scsi_device *sdev)
28{ 26{
29 if (!sdev->tagged_supported) 27 if (!sdev->tagged_supported)
30 return 0; 28 return 0;
31 if (sdev->ordered_tags)
32 return MSG_ORDERED_TAG;
33 if (sdev->simple_tags) 29 if (sdev->simple_tags)
34 return MSG_SIMPLE_TAG; 30 return MSG_SIMPLE_TAG;
35 return 0; 31 return 0;
@@ -39,90 +35,33 @@ static inline void scsi_set_tag_type(struct scsi_device *sdev, int tag)
39{ 35{
40 switch (tag) { 36 switch (tag) {
41 case MSG_ORDERED_TAG: 37 case MSG_ORDERED_TAG:
42 sdev->ordered_tags = 1;
43 /* fall through */
44 case MSG_SIMPLE_TAG: 38 case MSG_SIMPLE_TAG:
45 sdev->simple_tags = 1; 39 sdev->simple_tags = 1;
46 break; 40 break;
47 case 0: 41 case 0:
48 /* fall through */ 42 /* fall through */
49 default: 43 default:
50 sdev->ordered_tags = 0;
51 sdev->simple_tags = 0; 44 sdev->simple_tags = 0;
52 break; 45 break;
53 } 46 }
54} 47}
55/**
56 * scsi_activate_tcq - turn on tag command queueing
57 * @SDpnt: device to turn on TCQ for
58 * @depth: queue depth
59 *
60 * Notes:
61 * Eventually, I hope depth would be the maximum depth
62 * the device could cope with and the real queue depth
63 * would be adjustable from 0 to depth.
64 **/
65static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
66{
67 if (!sdev->tagged_supported)
68 return;
69
70 if (shost_use_blk_mq(sdev->host))
71 queue_flag_set_unlocked(QUEUE_FLAG_QUEUED, sdev->request_queue);
72 else if (!blk_queue_tagged(sdev->request_queue))
73 blk_queue_init_tags(sdev->request_queue, depth,
74 sdev->host->bqt);
75
76 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
77}
78
79/**
80 * scsi_deactivate_tcq - turn off tag command queueing
81 * @SDpnt: device to turn off TCQ for
82 **/
83static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
84{
85 if (blk_queue_tagged(sdev->request_queue))
86 blk_queue_free_tags(sdev->request_queue);
87 scsi_adjust_queue_depth(sdev, 0, depth);
88}
89
90/**
91 * scsi_populate_tag_msg - place a tag message in a buffer
92 * @SCpnt: pointer to the Scsi_Cmnd for the tag
93 * @msg: pointer to the area to place the tag
94 *
95 * Notes:
96 * designed to create the correct type of tag message for the
97 * particular request. Returns the size of the tag message.
98 * May return 0 if TCQ is disabled for this device.
99 **/
100static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg)
101{
102 struct request *req = cmd->request;
103
104 if (blk_rq_tagged(req)) {
105 *msg++ = MSG_SIMPLE_TAG;
106 *msg++ = req->tag;
107 return 2;
108 }
109
110 return 0;
111}
112 48
113static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost, 49static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost,
114 unsigned int hw_ctx, int tag) 50 int unique_tag)
115{ 51{
116 struct request *req; 52 u16 hwq = blk_mq_unique_tag_to_hwq(unique_tag);
53 struct request *req = NULL;
117 54
118 req = blk_mq_tag_to_rq(shost->tag_set.tags[hw_ctx], tag); 55 if (hwq < shost->tag_set.nr_hw_queues)
56 req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
57 blk_mq_unique_tag_to_tag(unique_tag));
119 return req ? (struct scsi_cmnd *)req->special : NULL; 58 return req ? (struct scsi_cmnd *)req->special : NULL;
120} 59}
121 60
122/** 61/**
123 * scsi_find_tag - find a tagged command by device 62 * scsi_find_tag - find a tagged command by device
124 * @SDpnt: pointer to the ScSI device 63 * @SDpnt: pointer to the ScSI device
125 * @tag: the tag number 64 * @tag: tag generated by blk_mq_unique_tag()
126 * 65 *
127 * Notes: 66 * Notes:
128 * Only works with tags allocated by the generic blk layer. 67 * Only works with tags allocated by the generic blk layer.
@@ -133,9 +72,9 @@ static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag)
133 72
134 if (tag != SCSI_NO_TAG) { 73 if (tag != SCSI_NO_TAG) {
135 if (shost_use_blk_mq(sdev->host)) 74 if (shost_use_blk_mq(sdev->host))
136 return scsi_mq_find_tag(sdev->host, 0, tag); 75 return scsi_mq_find_tag(sdev->host, tag);
137 76
138 req = blk_queue_find_tag(sdev->request_queue, tag); 77 req = blk_queue_find_tag(sdev->request_queue, tag);
139 return req ? (struct scsi_cmnd *)req->special : NULL; 78 return req ? (struct scsi_cmnd *)req->special : NULL;
140 } 79 }
141 80
@@ -174,7 +113,7 @@ static inline int scsi_init_shared_tag_map(struct Scsi_Host *shost, int depth)
174/** 113/**
175 * scsi_host_find_tag - find the tagged command by host 114 * scsi_host_find_tag - find the tagged command by host
176 * @shost: pointer to scsi_host 115 * @shost: pointer to scsi_host
177 * @tag: tag of the scsi_cmnd 116 * @tag: tag generated by blk_mq_unique_tag()
178 * 117 *
179 * Notes: 118 * Notes:
180 * Only works with tags allocated by the generic blk layer. 119 * Only works with tags allocated by the generic blk layer.
@@ -186,7 +125,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
186 125
187 if (tag != SCSI_NO_TAG) { 126 if (tag != SCSI_NO_TAG) {
188 if (shost_use_blk_mq(shost)) 127 if (shost_use_blk_mq(shost))
189 return scsi_mq_find_tag(shost, 0, tag); 128 return scsi_mq_find_tag(shost, tag);
190 req = blk_map_queue_find_tag(shost->bqt, tag); 129 req = blk_map_queue_find_tag(shost->bqt, tag);
191 return req ? (struct scsi_cmnd *)req->special : NULL; 130 return req ? (struct scsi_cmnd *)req->special : NULL;
192 } 131 }
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);
157int spi_populate_sync_msg(unsigned char *msg, int period, int offset); 157int spi_populate_sync_msg(unsigned char *msg, int period, int offset);
158int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width, 158int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width,
159 int options); 159 int options);
160int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd);
160 161
161#endif /* SCSI_TRANSPORT_SPI_H */ 162#endif /* SCSI_TRANSPORT_SPI_H */
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() */
164 164
165/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */ 165/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */
166#define SG_SCSI_RESET 0x2284 166#define SG_SCSI_RESET 0x2284
167/* Associated values that can be given to SG_SCSI_RESET follow */ 167/* Associated values that can be given to SG_SCSI_RESET follow.
168 * SG_SCSI_RESET_NO_ESCALATE may be OR-ed to the _DEVICE, _TARGET, _BUS
169 * or _HOST reset value so only that action is attempted. */
168#define SG_SCSI_RESET_NOTHING 0 170#define SG_SCSI_RESET_NOTHING 0
169#define SG_SCSI_RESET_DEVICE 1 171#define SG_SCSI_RESET_DEVICE 1
170#define SG_SCSI_RESET_BUS 2 172#define SG_SCSI_RESET_BUS 2
171#define SG_SCSI_RESET_HOST 3 173#define SG_SCSI_RESET_HOST 3
172#define SG_SCSI_RESET_TARGET 4 174#define SG_SCSI_RESET_TARGET 4
175#define SG_SCSI_RESET_NO_ESCALATE 0x100
173 176
174/* synchronous SCSI command ioctl, (only in version 3 interface) */ 177/* synchronous SCSI command ioctl, (only in version 3 interface) */
175#define SG_IO 0x2285 /* similar effect as write() followed by read() */ 178#define SG_IO 0x2285 /* similar effect as write() followed by read() */
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 @@
94 scsi_opcode_name(WRITE_16), \ 94 scsi_opcode_name(WRITE_16), \
95 scsi_opcode_name(VERIFY_16), \ 95 scsi_opcode_name(VERIFY_16), \
96 scsi_opcode_name(WRITE_SAME_16), \ 96 scsi_opcode_name(WRITE_SAME_16), \
97 scsi_opcode_name(SERVICE_ACTION_IN), \ 97 scsi_opcode_name(SERVICE_ACTION_IN_16), \
98 scsi_opcode_name(SAI_READ_CAPACITY_16), \ 98 scsi_opcode_name(SAI_READ_CAPACITY_16), \
99 scsi_opcode_name(SAI_GET_LBA_STATUS), \ 99 scsi_opcode_name(SAI_GET_LBA_STATUS), \
100 scsi_opcode_name(MI_REPORT_TARGET_PGS), \ 100 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 @@
96 scsi_opcode_name(WRITE_16), \ 96 scsi_opcode_name(WRITE_16), \
97 scsi_opcode_name(VERIFY_16), \ 97 scsi_opcode_name(VERIFY_16), \
98 scsi_opcode_name(WRITE_SAME_16), \ 98 scsi_opcode_name(WRITE_SAME_16), \
99 scsi_opcode_name(SERVICE_ACTION_IN), \ 99 scsi_opcode_name(SERVICE_ACTION_IN_16), \
100 scsi_opcode_name(SAI_READ_CAPACITY_16), \ 100 scsi_opcode_name(SAI_READ_CAPACITY_16), \
101 scsi_opcode_name(SAI_GET_LBA_STATUS), \ 101 scsi_opcode_name(SAI_GET_LBA_STATUS), \
102 scsi_opcode_name(MI_REPORT_TARGET_PGS), \ 102 scsi_opcode_name(MI_REPORT_TARGET_PGS), \