hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/include/scsi/scsi_cmnd.h
....@@ -36,7 +36,6 @@
3636 struct scsi_data_buffer {
3737 struct sg_table table;
3838 unsigned length;
39
- int resid;
4039 };
4140
4241 /* embedded in scsi_cmnd */
....@@ -59,29 +58,23 @@
5958 #define SCMD_TAGGED (1 << 0)
6059 #define SCMD_UNCHECKED_ISA_DMA (1 << 1)
6160 #define SCMD_INITIALIZED (1 << 2)
61
+#define SCMD_LAST (1 << 3)
6262 /* flags preserved across unprep / reprep */
6363 #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
6468
6569 struct scsi_cmnd {
6670 struct scsi_request req;
6771 struct scsi_device *device;
68
- struct list_head list; /* scsi_cmnd participates in queue lists */
6972 struct list_head eh_entry; /* entry for the host eh_cmd_q */
7073 struct delayed_work abort_work;
7174
7275 struct rcu_head rcu;
7376
7477 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;
8578
8679 /*
8780 * This is set to jiffies as it was when the command was first
....@@ -146,8 +139,10 @@
146139
147140 int result; /* Status code from lower level driver */
148141 int flags; /* Command flags */
142
+ unsigned long state; /* Command completion state */
149143
150144 unsigned char tag; /* SCSI-II queued command tag */
145
+ unsigned int extra_len; /* length of alignment and padding */
151146
152147 ANDROID_KABI_RESERVE(1);
153148 ANDROID_KABI_RESERVE(2);
....@@ -170,14 +165,14 @@
170165 return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
171166 }
172167
173
-extern void scsi_put_command(struct scsi_cmnd *);
174168 extern void scsi_finish_command(struct scsi_cmnd *cmd);
175169
176170 extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
177171 size_t *offset, size_t *len);
178172 extern void scsi_kunmap_atomic_sg(void *virt);
179173
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);
181176
182177 #ifdef CONFIG_SCSI_DMA
183178 extern int scsi_dma_map(struct scsi_cmnd *cmd);
....@@ -202,38 +197,21 @@
202197 return cmd->sdb.length;
203198 }
204199
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)
206201 {
207
- cmd->sdb.resid = resid;
202
+ cmd->req.resid_len = resid;
208203 }
209204
210
-static inline int scsi_get_resid(struct scsi_cmnd *cmd)
205
+static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd)
211206 {
212
- return cmd->sdb.resid;
207
+ return cmd->req.resid_len;
213208 }
214209
215210 #define scsi_for_each_sg(cmd, sg, nseg, __i) \
216211 for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
217212
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
-
235213 static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd,
236
- void *buf, int buflen)
214
+ const void *buf, int buflen)
237215 {
238216 return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd),
239217 buf, buflen);
....@@ -353,7 +331,7 @@
353331
354332 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
355333 {
356
- unsigned int xfer_len = scsi_out(scmd)->length;
334
+ unsigned int xfer_len = scmd->sdb.length;
357335 unsigned int prot_interval = scsi_prot_interval(scmd);
358336
359337 if (scmd->prot_flags & SCSI_PROT_TRANSFER_PI)