.. | .. |
---|
36 | 36 | struct scsi_data_buffer { |
---|
37 | 37 | struct sg_table table; |
---|
38 | 38 | unsigned length; |
---|
39 | | - int resid; |
---|
40 | 39 | }; |
---|
41 | 40 | |
---|
42 | 41 | /* embedded in scsi_cmnd */ |
---|
.. | .. |
---|
59 | 58 | #define SCMD_TAGGED (1 << 0) |
---|
60 | 59 | #define SCMD_UNCHECKED_ISA_DMA (1 << 1) |
---|
61 | 60 | #define SCMD_INITIALIZED (1 << 2) |
---|
| 61 | +#define SCMD_LAST (1 << 3) |
---|
62 | 62 | /* flags preserved across unprep / reprep */ |
---|
63 | 63 | #define SCMD_PRESERVED_FLAGS (SCMD_UNCHECKED_ISA_DMA | SCMD_INITIALIZED) |
---|
| 64 | + |
---|
| 65 | +/* for scmd->state */ |
---|
| 66 | +#define SCMD_STATE_COMPLETE 0 |
---|
| 67 | +#define SCMD_STATE_INFLIGHT 1 |
---|
64 | 68 | |
---|
65 | 69 | struct scsi_cmnd { |
---|
66 | 70 | struct scsi_request req; |
---|
67 | 71 | struct scsi_device *device; |
---|
68 | | - struct list_head list; /* scsi_cmnd participates in queue lists */ |
---|
69 | 72 | struct list_head eh_entry; /* entry for the host eh_cmd_q */ |
---|
70 | 73 | struct delayed_work abort_work; |
---|
71 | 74 | |
---|
72 | 75 | struct rcu_head rcu; |
---|
73 | 76 | |
---|
74 | 77 | int eh_eflags; /* Used by error handlr */ |
---|
75 | | - |
---|
76 | | - /* |
---|
77 | | - * A SCSI Command is assigned a nonzero serial_number before passed |
---|
78 | | - * to the driver's queue command function. The serial_number is |
---|
79 | | - * cleared when scsi_done is entered indicating that the command |
---|
80 | | - * has been completed. It is a bug for LLDDs to use this number |
---|
81 | | - * for purposes other than printk (and even that is only useful |
---|
82 | | - * for debugging). |
---|
83 | | - */ |
---|
84 | | - unsigned long serial_number; |
---|
85 | 78 | |
---|
86 | 79 | /* |
---|
87 | 80 | * This is set to jiffies as it was when the command was first |
---|
.. | .. |
---|
146 | 139 | |
---|
147 | 140 | int result; /* Status code from lower level driver */ |
---|
148 | 141 | int flags; /* Command flags */ |
---|
| 142 | + unsigned long state; /* Command completion state */ |
---|
149 | 143 | |
---|
150 | 144 | unsigned char tag; /* SCSI-II queued command tag */ |
---|
| 145 | + unsigned int extra_len; /* length of alignment and padding */ |
---|
151 | 146 | |
---|
152 | 147 | ANDROID_KABI_RESERVE(1); |
---|
153 | 148 | ANDROID_KABI_RESERVE(2); |
---|
.. | .. |
---|
170 | 165 | return *(struct scsi_driver **)cmd->request->rq_disk->private_data; |
---|
171 | 166 | } |
---|
172 | 167 | |
---|
173 | | -extern void scsi_put_command(struct scsi_cmnd *); |
---|
174 | 168 | extern void scsi_finish_command(struct scsi_cmnd *cmd); |
---|
175 | 169 | |
---|
176 | 170 | extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, |
---|
177 | 171 | size_t *offset, size_t *len); |
---|
178 | 172 | extern void scsi_kunmap_atomic_sg(void *virt); |
---|
179 | 173 | |
---|
180 | | -extern int scsi_init_io(struct scsi_cmnd *cmd); |
---|
| 174 | +blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd); |
---|
| 175 | +void scsi_free_sgtables(struct scsi_cmnd *cmd); |
---|
181 | 176 | |
---|
182 | 177 | #ifdef CONFIG_SCSI_DMA |
---|
183 | 178 | extern int scsi_dma_map(struct scsi_cmnd *cmd); |
---|
.. | .. |
---|
202 | 197 | return cmd->sdb.length; |
---|
203 | 198 | } |
---|
204 | 199 | |
---|
205 | | -static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid) |
---|
| 200 | +static inline void scsi_set_resid(struct scsi_cmnd *cmd, unsigned int resid) |
---|
206 | 201 | { |
---|
207 | | - cmd->sdb.resid = resid; |
---|
| 202 | + cmd->req.resid_len = resid; |
---|
208 | 203 | } |
---|
209 | 204 | |
---|
210 | | -static inline int scsi_get_resid(struct scsi_cmnd *cmd) |
---|
| 205 | +static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd) |
---|
211 | 206 | { |
---|
212 | | - return cmd->sdb.resid; |
---|
| 207 | + return cmd->req.resid_len; |
---|
213 | 208 | } |
---|
214 | 209 | |
---|
215 | 210 | #define scsi_for_each_sg(cmd, sg, nseg, __i) \ |
---|
216 | 211 | for_each_sg(scsi_sglist(cmd), sg, nseg, __i) |
---|
217 | 212 | |
---|
218 | | -static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd) |
---|
219 | | -{ |
---|
220 | | - return blk_bidi_rq(cmd->request) && |
---|
221 | | - (cmd->request->next_rq->special != NULL); |
---|
222 | | -} |
---|
223 | | - |
---|
224 | | -static inline struct scsi_data_buffer *scsi_in(struct scsi_cmnd *cmd) |
---|
225 | | -{ |
---|
226 | | - return scsi_bidi_cmnd(cmd) ? |
---|
227 | | - cmd->request->next_rq->special : &cmd->sdb; |
---|
228 | | -} |
---|
229 | | - |
---|
230 | | -static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd) |
---|
231 | | -{ |
---|
232 | | - return &cmd->sdb; |
---|
233 | | -} |
---|
234 | | - |
---|
235 | 213 | static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd, |
---|
236 | | - void *buf, int buflen) |
---|
| 214 | + const void *buf, int buflen) |
---|
237 | 215 | { |
---|
238 | 216 | return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), |
---|
239 | 217 | buf, buflen); |
---|
.. | .. |
---|
353 | 331 | |
---|
354 | 332 | static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) |
---|
355 | 333 | { |
---|
356 | | - unsigned int xfer_len = scsi_out(scmd)->length; |
---|
| 334 | + unsigned int xfer_len = scmd->sdb.length; |
---|
357 | 335 | unsigned int prot_interval = scsi_prot_interval(scmd); |
---|
358 | 336 | |
---|
359 | 337 | if (scmd->prot_flags & SCSI_PROT_TRANSFER_PI) |
---|