diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libata-scsi.c | 786 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 3 | ||||
-rw-r--r-- | drivers/scsi/pdc_adma.c | 26 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 4 |
4 files changed, 675 insertions, 144 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 58858886d751..89a04b1a5a0e 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -40,14 +40,56 @@ | |||
40 | #include "scsi.h" | 40 | #include "scsi.h" |
41 | #include <scsi/scsi_host.h> | 41 | #include <scsi/scsi_host.h> |
42 | #include <linux/libata.h> | 42 | #include <linux/libata.h> |
43 | #include <linux/hdreg.h> | ||
43 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
44 | 45 | ||
45 | #include "libata.h" | 46 | #include "libata.h" |
46 | 47 | ||
48 | #define SECTOR_SIZE 512 | ||
49 | |||
47 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); | 50 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); |
48 | static struct ata_device * | 51 | static struct ata_device * |
49 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); | 52 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); |
50 | 53 | ||
54 | #define RW_RECOVERY_MPAGE 0x1 | ||
55 | #define RW_RECOVERY_MPAGE_LEN 12 | ||
56 | #define CACHE_MPAGE 0x8 | ||
57 | #define CACHE_MPAGE_LEN 20 | ||
58 | #define CONTROL_MPAGE 0xa | ||
59 | #define CONTROL_MPAGE_LEN 12 | ||
60 | #define ALL_MPAGES 0x3f | ||
61 | #define ALL_SUB_MPAGES 0xff | ||
62 | |||
63 | |||
64 | static const u8 def_rw_recovery_mpage[] = { | ||
65 | RW_RECOVERY_MPAGE, | ||
66 | RW_RECOVERY_MPAGE_LEN - 2, | ||
67 | (1 << 7) | /* AWRE, sat-r06 say it shall be 0 */ | ||
68 | (1 << 6), /* ARRE (auto read reallocation) */ | ||
69 | 0, /* read retry count */ | ||
70 | 0, 0, 0, 0, | ||
71 | 0, /* write retry count */ | ||
72 | 0, 0, 0 | ||
73 | }; | ||
74 | |||
75 | static const u8 def_cache_mpage[CACHE_MPAGE_LEN] = { | ||
76 | CACHE_MPAGE, | ||
77 | CACHE_MPAGE_LEN - 2, | ||
78 | 0, /* contains WCE, needs to be 0 for logic */ | ||
79 | 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
80 | 0, /* contains DRA, needs to be 0 for logic */ | ||
81 | 0, 0, 0, 0, 0, 0, 0 | ||
82 | }; | ||
83 | |||
84 | static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = { | ||
85 | CONTROL_MPAGE, | ||
86 | CONTROL_MPAGE_LEN - 2, | ||
87 | 2, /* DSENSE=0, GLTSD=1 */ | ||
88 | 0, /* [QAM+QERR may be 1, see 05-359r1] */ | ||
89 | 0, 0, 0, 0, 0xff, 0xff, | ||
90 | 0, 30 /* extended self test time, see 05-359r1 */ | ||
91 | }; | ||
92 | |||
51 | 93 | ||
52 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, | 94 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, |
53 | void (*done)(struct scsi_cmnd *)) | 95 | void (*done)(struct scsi_cmnd *)) |
@@ -86,6 +128,150 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev, | |||
86 | return 0; | 128 | return 0; |
87 | } | 129 | } |
88 | 130 | ||
131 | /** | ||
132 | * ata_cmd_ioctl - Handler for HDIO_DRIVE_CMD ioctl | ||
133 | * @dev: Device to whom we are issuing command | ||
134 | * @arg: User provided data for issuing command | ||
135 | * | ||
136 | * LOCKING: | ||
137 | * Defined by the SCSI layer. We don't really care. | ||
138 | * | ||
139 | * RETURNS: | ||
140 | * Zero on success, negative errno on error. | ||
141 | */ | ||
142 | |||
143 | int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | ||
144 | { | ||
145 | int rc = 0; | ||
146 | u8 scsi_cmd[MAX_COMMAND_SIZE]; | ||
147 | u8 args[4], *argbuf = NULL; | ||
148 | int argsize = 0; | ||
149 | struct scsi_request *sreq; | ||
150 | |||
151 | if (NULL == (void *)arg) | ||
152 | return -EINVAL; | ||
153 | |||
154 | if (copy_from_user(args, arg, sizeof(args))) | ||
155 | return -EFAULT; | ||
156 | |||
157 | sreq = scsi_allocate_request(scsidev, GFP_KERNEL); | ||
158 | if (!sreq) | ||
159 | return -EINTR; | ||
160 | |||
161 | memset(scsi_cmd, 0, sizeof(scsi_cmd)); | ||
162 | |||
163 | if (args[3]) { | ||
164 | argsize = SECTOR_SIZE * args[3]; | ||
165 | argbuf = kmalloc(argsize, GFP_KERNEL); | ||
166 | if (argbuf == NULL) { | ||
167 | rc = -ENOMEM; | ||
168 | goto error; | ||
169 | } | ||
170 | |||
171 | scsi_cmd[1] = (4 << 1); /* PIO Data-in */ | ||
172 | scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, | ||
173 | block count in sector count field */ | ||
174 | sreq->sr_data_direction = DMA_FROM_DEVICE; | ||
175 | } else { | ||
176 | scsi_cmd[1] = (3 << 1); /* Non-data */ | ||
177 | /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ | ||
178 | sreq->sr_data_direction = DMA_NONE; | ||
179 | } | ||
180 | |||
181 | scsi_cmd[0] = ATA_16; | ||
182 | |||
183 | scsi_cmd[4] = args[2]; | ||
184 | if (args[0] == WIN_SMART) { /* hack -- ide driver does this too... */ | ||
185 | scsi_cmd[6] = args[3]; | ||
186 | scsi_cmd[8] = args[1]; | ||
187 | scsi_cmd[10] = 0x4f; | ||
188 | scsi_cmd[12] = 0xc2; | ||
189 | } else { | ||
190 | scsi_cmd[6] = args[1]; | ||
191 | } | ||
192 | scsi_cmd[14] = args[0]; | ||
193 | |||
194 | /* Good values for timeout and retries? Values below | ||
195 | from scsi_ioctl_send_command() for default case... */ | ||
196 | scsi_wait_req(sreq, scsi_cmd, argbuf, argsize, (10*HZ), 5); | ||
197 | |||
198 | if (sreq->sr_result) { | ||
199 | rc = -EIO; | ||
200 | goto error; | ||
201 | } | ||
202 | |||
203 | /* Need code to retrieve data from check condition? */ | ||
204 | |||
205 | if ((argbuf) | ||
206 | && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) | ||
207 | rc = -EFAULT; | ||
208 | error: | ||
209 | scsi_release_request(sreq); | ||
210 | |||
211 | if (argbuf) | ||
212 | kfree(argbuf); | ||
213 | |||
214 | return rc; | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * ata_task_ioctl - Handler for HDIO_DRIVE_TASK ioctl | ||
219 | * @dev: Device to whom we are issuing command | ||
220 | * @arg: User provided data for issuing command | ||
221 | * | ||
222 | * LOCKING: | ||
223 | * Defined by the SCSI layer. We don't really care. | ||
224 | * | ||
225 | * RETURNS: | ||
226 | * Zero on success, negative errno on error. | ||
227 | */ | ||
228 | int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | ||
229 | { | ||
230 | int rc = 0; | ||
231 | u8 scsi_cmd[MAX_COMMAND_SIZE]; | ||
232 | u8 args[7]; | ||
233 | struct scsi_request *sreq; | ||
234 | |||
235 | if (NULL == (void *)arg) | ||
236 | return -EINVAL; | ||
237 | |||
238 | if (copy_from_user(args, arg, sizeof(args))) | ||
239 | return -EFAULT; | ||
240 | |||
241 | memset(scsi_cmd, 0, sizeof(scsi_cmd)); | ||
242 | scsi_cmd[0] = ATA_16; | ||
243 | scsi_cmd[1] = (3 << 1); /* Non-data */ | ||
244 | /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ | ||
245 | scsi_cmd[4] = args[1]; | ||
246 | scsi_cmd[6] = args[2]; | ||
247 | scsi_cmd[8] = args[3]; | ||
248 | scsi_cmd[10] = args[4]; | ||
249 | scsi_cmd[12] = args[5]; | ||
250 | scsi_cmd[14] = args[0]; | ||
251 | |||
252 | sreq = scsi_allocate_request(scsidev, GFP_KERNEL); | ||
253 | if (!sreq) { | ||
254 | rc = -EINTR; | ||
255 | goto error; | ||
256 | } | ||
257 | |||
258 | sreq->sr_data_direction = DMA_NONE; | ||
259 | /* Good values for timeout and retries? Values below | ||
260 | from scsi_ioctl_send_command() for default case... */ | ||
261 | scsi_wait_req(sreq, scsi_cmd, NULL, 0, (10*HZ), 5); | ||
262 | |||
263 | if (sreq->sr_result) { | ||
264 | rc = -EIO; | ||
265 | goto error; | ||
266 | } | ||
267 | |||
268 | /* Need code to retrieve data from check condition? */ | ||
269 | |||
270 | error: | ||
271 | scsi_release_request(sreq); | ||
272 | return rc; | ||
273 | } | ||
274 | |||
89 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | 275 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) |
90 | { | 276 | { |
91 | struct ata_port *ap; | 277 | struct ata_port *ap; |
@@ -115,6 +301,16 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | |||
115 | return -EINVAL; | 301 | return -EINVAL; |
116 | return 0; | 302 | return 0; |
117 | 303 | ||
304 | case HDIO_DRIVE_CMD: | ||
305 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
306 | return -EACCES; | ||
307 | return ata_cmd_ioctl(scsidev, arg); | ||
308 | |||
309 | case HDIO_DRIVE_TASK: | ||
310 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
311 | return -EACCES; | ||
312 | return ata_task_ioctl(scsidev, arg); | ||
313 | |||
118 | default: | 314 | default: |
119 | rc = -ENOTTY; | 315 | rc = -ENOTTY; |
120 | break; | 316 | break; |
@@ -173,23 +369,70 @@ struct ata_queued_cmd *ata_scsi_qc_new(struct ata_port *ap, | |||
173 | } | 369 | } |
174 | 370 | ||
175 | /** | 371 | /** |
372 | * ata_dump_status - user friendly display of error info | ||
373 | * @id: id of the port in question | ||
374 | * @tf: ptr to filled out taskfile | ||
375 | * | ||
376 | * Decode and dump the ATA error/status registers for the user so | ||
377 | * that they have some idea what really happened at the non | ||
378 | * make-believe layer. | ||
379 | * | ||
380 | * LOCKING: | ||
381 | * inherited from caller | ||
382 | */ | ||
383 | void ata_dump_status(unsigned id, struct ata_taskfile *tf) | ||
384 | { | ||
385 | u8 stat = tf->command, err = tf->feature; | ||
386 | |||
387 | printk(KERN_WARNING "ata%u: status=0x%02x { ", id, stat); | ||
388 | if (stat & ATA_BUSY) { | ||
389 | printk("Busy }\n"); /* Data is not valid in this case */ | ||
390 | } else { | ||
391 | if (stat & 0x40) printk("DriveReady "); | ||
392 | if (stat & 0x20) printk("DeviceFault "); | ||
393 | if (stat & 0x10) printk("SeekComplete "); | ||
394 | if (stat & 0x08) printk("DataRequest "); | ||
395 | if (stat & 0x04) printk("CorrectedError "); | ||
396 | if (stat & 0x02) printk("Index "); | ||
397 | if (stat & 0x01) printk("Error "); | ||
398 | printk("}\n"); | ||
399 | |||
400 | if (err) { | ||
401 | printk(KERN_WARNING "ata%u: error=0x%02x { ", id, err); | ||
402 | if (err & 0x04) printk("DriveStatusError "); | ||
403 | if (err & 0x80) { | ||
404 | if (err & 0x04) printk("BadCRC "); | ||
405 | else printk("Sector "); | ||
406 | } | ||
407 | if (err & 0x40) printk("UncorrectableError "); | ||
408 | if (err & 0x10) printk("SectorIdNotFound "); | ||
409 | if (err & 0x02) printk("TrackZeroNotFound "); | ||
410 | if (err & 0x01) printk("AddrMarkNotFound "); | ||
411 | printk("}\n"); | ||
412 | } | ||
413 | } | ||
414 | } | ||
415 | |||
416 | /** | ||
176 | * ata_to_sense_error - convert ATA error to SCSI error | 417 | * ata_to_sense_error - convert ATA error to SCSI error |
177 | * @qc: Command that we are erroring out | ||
178 | * @drv_stat: value contained in ATA status register | 418 | * @drv_stat: value contained in ATA status register |
419 | * @drv_err: value contained in ATA error register | ||
420 | * @sk: the sense key we'll fill out | ||
421 | * @asc: the additional sense code we'll fill out | ||
422 | * @ascq: the additional sense code qualifier we'll fill out | ||
179 | * | 423 | * |
180 | * Converts an ATA error into a SCSI error. While we are at it | 424 | * Converts an ATA error into a SCSI error. Fill out pointers to |
181 | * we decode and dump the ATA error for the user so that they | 425 | * SK, ASC, and ASCQ bytes for later use in fixed or descriptor |
182 | * have some idea what really happened at the non make-believe | 426 | * format sense blocks. |
183 | * layer. | ||
184 | * | 427 | * |
185 | * LOCKING: | 428 | * LOCKING: |
186 | * spin_lock_irqsave(host_set lock) | 429 | * spin_lock_irqsave(host_set lock) |
187 | */ | 430 | */ |
188 | 431 | void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | |
189 | void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat) | 432 | u8 *ascq) |
190 | { | 433 | { |
191 | struct scsi_cmnd *cmd = qc->scsicmd; | 434 | int i; |
192 | u8 err = 0; | 435 | |
193 | /* Based on the 3ware driver translation table */ | 436 | /* Based on the 3ware driver translation table */ |
194 | static unsigned char sense_table[][4] = { | 437 | static unsigned char sense_table[][4] = { |
195 | /* BBD|ECC|ID|MAR */ | 438 | /* BBD|ECC|ID|MAR */ |
@@ -230,96 +473,184 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat) | |||
230 | {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered | 473 | {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered |
231 | {0xFF, 0xFF, 0xFF, 0xFF}, // END mark | 474 | {0xFF, 0xFF, 0xFF, 0xFF}, // END mark |
232 | }; | 475 | }; |
233 | int i = 0; | ||
234 | 476 | ||
235 | /* | 477 | /* |
236 | * Is this an error we can process/parse | 478 | * Is this an error we can process/parse |
237 | */ | 479 | */ |
238 | 480 | if (drv_stat & ATA_BUSY) { | |
239 | if(drv_stat & ATA_ERR) | 481 | drv_err = 0; /* Ignore the err bits, they're invalid */ |
240 | /* Read the err bits */ | ||
241 | err = ata_chk_err(qc->ap); | ||
242 | |||
243 | /* Display the ATA level error info */ | ||
244 | |||
245 | printk(KERN_WARNING "ata%u: status=0x%02x { ", qc->ap->id, drv_stat); | ||
246 | if(drv_stat & 0x80) | ||
247 | { | ||
248 | printk("Busy "); | ||
249 | err = 0; /* Data is not valid in this case */ | ||
250 | } | 482 | } |
251 | else { | 483 | |
252 | if(drv_stat & 0x40) printk("DriveReady "); | 484 | if (drv_err) { |
253 | if(drv_stat & 0x20) printk("DeviceFault "); | 485 | /* Look for drv_err */ |
254 | if(drv_stat & 0x10) printk("SeekComplete "); | 486 | for (i = 0; sense_table[i][0] != 0xFF; i++) { |
255 | if(drv_stat & 0x08) printk("DataRequest "); | 487 | /* Look for best matches first */ |
256 | if(drv_stat & 0x04) printk("CorrectedError "); | 488 | if ((sense_table[i][0] & drv_err) == |
257 | if(drv_stat & 0x02) printk("Index "); | 489 | sense_table[i][0]) { |
258 | if(drv_stat & 0x01) printk("Error "); | 490 | *sk = sense_table[i][1]; |
491 | *asc = sense_table[i][2]; | ||
492 | *ascq = sense_table[i][3]; | ||
493 | goto translate_done; | ||
494 | } | ||
495 | } | ||
496 | /* No immediate match */ | ||
497 | printk(KERN_WARNING "ata%u: no sense translation for " | ||
498 | "error 0x%02x\n", id, drv_err); | ||
259 | } | 499 | } |
260 | printk("}\n"); | 500 | |
261 | 501 | /* Fall back to interpreting status bits */ | |
262 | if(err) | 502 | for (i = 0; stat_table[i][0] != 0xFF; i++) { |
263 | { | 503 | if (stat_table[i][0] & drv_stat) { |
264 | printk(KERN_WARNING "ata%u: error=0x%02x { ", qc->ap->id, err); | 504 | *sk = stat_table[i][1]; |
265 | if(err & 0x04) printk("DriveStatusError "); | 505 | *asc = stat_table[i][2]; |
266 | if(err & 0x80) | 506 | *ascq = stat_table[i][3]; |
267 | { | 507 | goto translate_done; |
268 | if(err & 0x04) | ||
269 | printk("BadCRC "); | ||
270 | else | ||
271 | printk("Sector "); | ||
272 | } | 508 | } |
273 | if(err & 0x40) printk("UncorrectableError "); | 509 | } |
274 | if(err & 0x10) printk("SectorIdNotFound "); | 510 | /* No error? Undecoded? */ |
275 | if(err & 0x02) printk("TrackZeroNotFound "); | 511 | printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", |
276 | if(err & 0x01) printk("AddrMarkNotFound "); | 512 | id, drv_stat); |
277 | printk("}\n"); | 513 | |
514 | /* For our last chance pick, use medium read error because | ||
515 | * it's much more common than an ATA drive telling you a write | ||
516 | * has failed. | ||
517 | */ | ||
518 | *sk = MEDIUM_ERROR; | ||
519 | *asc = 0x11; /* "unrecovered read error" */ | ||
520 | *ascq = 0x04; /* "auto-reallocation failed" */ | ||
521 | |||
522 | translate_done: | ||
523 | printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " | ||
524 | "SCSI SK/ASC/ASCQ 0x%x/%02x/%02x\n", id, drv_stat, drv_err, | ||
525 | *sk, *asc, *ascq); | ||
526 | return; | ||
527 | } | ||
528 | |||
529 | /* | ||
530 | * ata_gen_ata_desc_sense - Generate check condition sense block. | ||
531 | * @qc: Command that completed. | ||
532 | * | ||
533 | * This function is specific to the ATA descriptor format sense | ||
534 | * block specified for the ATA pass through commands. Regardless | ||
535 | * of whether the command errored or not, return a sense | ||
536 | * block. Copy all controller registers into the sense | ||
537 | * block. Clear sense key, ASC & ASCQ if there is no error. | ||
538 | * | ||
539 | * LOCKING: | ||
540 | * spin_lock_irqsave(host_set lock) | ||
541 | */ | ||
542 | void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) | ||
543 | { | ||
544 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
545 | struct ata_taskfile *tf = &qc->tf; | ||
546 | unsigned char *sb = cmd->sense_buffer; | ||
547 | unsigned char *desc = sb + 8; | ||
548 | |||
549 | memset(sb, 0, SCSI_SENSE_BUFFERSIZE); | ||
550 | |||
551 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | ||
552 | |||
553 | /* | ||
554 | * Read the controller registers. | ||
555 | */ | ||
556 | assert(NULL != qc->ap->ops->tf_read); | ||
557 | qc->ap->ops->tf_read(qc->ap, tf); | ||
278 | 558 | ||
279 | /* Should we dump sector info here too ?? */ | 559 | /* |
560 | * Use ata_to_sense_error() to map status register bits | ||
561 | * onto sense key, asc & ascq. | ||
562 | */ | ||
563 | if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { | ||
564 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | ||
565 | &sb[1], &sb[2], &sb[3]); | ||
566 | sb[1] &= 0x0f; | ||
280 | } | 567 | } |
281 | 568 | ||
569 | /* | ||
570 | * Sense data is current and format is descriptor. | ||
571 | */ | ||
572 | sb[0] = 0x72; | ||
282 | 573 | ||
283 | /* Look for err */ | 574 | desc[0] = 0x09; |
284 | while(sense_table[i][0] != 0xFF) | 575 | |
285 | { | 576 | /* |
286 | /* Look for best matches first */ | 577 | * Set length of additional sense data. |
287 | if((sense_table[i][0] & err) == sense_table[i][0]) | 578 | * Since we only populate descriptor 0, the total |
288 | { | 579 | * length is the same (fixed) length as descriptor 0. |
289 | ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, | 580 | */ |
290 | sense_table[i][2] /* asc */, | 581 | desc[1] = sb[7] = 14; |
291 | sense_table[i][3] /* ascq */ ); | 582 | |
292 | return; | 583 | /* |
293 | } | 584 | * Copy registers into sense buffer. |
294 | i++; | 585 | */ |
586 | desc[2] = 0x00; | ||
587 | desc[3] = tf->feature; /* == error reg */ | ||
588 | desc[5] = tf->nsect; | ||
589 | desc[7] = tf->lbal; | ||
590 | desc[9] = tf->lbam; | ||
591 | desc[11] = tf->lbah; | ||
592 | desc[12] = tf->device; | ||
593 | desc[13] = tf->command; /* == status reg */ | ||
594 | |||
595 | /* | ||
596 | * Fill in Extend bit, and the high order bytes | ||
597 | * if applicable. | ||
598 | */ | ||
599 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
600 | desc[2] |= 0x01; | ||
601 | desc[4] = tf->hob_nsect; | ||
602 | desc[6] = tf->hob_lbal; | ||
603 | desc[8] = tf->hob_lbam; | ||
604 | desc[10] = tf->hob_lbah; | ||
295 | } | 605 | } |
296 | /* No immediate match */ | 606 | } |
297 | if(err) | ||
298 | printk(KERN_DEBUG "ata%u: no sense translation for 0x%02x\n", qc->ap->id, err); | ||
299 | 607 | ||
300 | i = 0; | 608 | /** |
301 | /* Fall back to interpreting status bits */ | 609 | * ata_gen_fixed_sense - generate a SCSI fixed sense block |
302 | while(stat_table[i][0] != 0xFF) | 610 | * @qc: Command that we are erroring out |
303 | { | 611 | * |
304 | if(stat_table[i][0] & drv_stat) | 612 | * Leverage ata_to_sense_error() to give us the codes. Fit our |
305 | { | 613 | * LBA in here if there's room. |
306 | ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, | 614 | * |
307 | sense_table[i][2] /* asc */, | 615 | * LOCKING: |
308 | sense_table[i][3] /* ascq */ ); | 616 | * inherited from caller |
309 | return; | 617 | */ |
310 | } | 618 | void ata_gen_fixed_sense(struct ata_queued_cmd *qc) |
311 | i++; | 619 | { |
620 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
621 | struct ata_taskfile *tf = &qc->tf; | ||
622 | unsigned char *sb = cmd->sense_buffer; | ||
623 | |||
624 | memset(sb, 0, SCSI_SENSE_BUFFERSIZE); | ||
625 | |||
626 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | ||
627 | |||
628 | /* | ||
629 | * Read the controller registers. | ||
630 | */ | ||
631 | assert(NULL != qc->ap->ops->tf_read); | ||
632 | qc->ap->ops->tf_read(qc->ap, tf); | ||
633 | |||
634 | /* | ||
635 | * Use ata_to_sense_error() to map status register bits | ||
636 | * onto sense key, asc & ascq. | ||
637 | */ | ||
638 | if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { | ||
639 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | ||
640 | &sb[2], &sb[12], &sb[13]); | ||
641 | sb[2] &= 0x0f; | ||
312 | } | 642 | } |
313 | /* No error ?? */ | ||
314 | printk(KERN_ERR "ata%u: called with no error (%02X)!\n", qc->ap->id, drv_stat); | ||
315 | /* additional-sense-code[-qualifier] */ | ||
316 | 643 | ||
317 | if (cmd->sc_data_direction == DMA_FROM_DEVICE) { | 644 | sb[0] = 0x70; |
318 | ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0x11, 0x4); | 645 | sb[7] = 0x0a; |
319 | /* "unrecovered read error" */ | 646 | |
320 | } else { | 647 | if (tf->flags & ATA_TFLAG_LBA && !(tf->flags & ATA_TFLAG_LBA48)) { |
321 | ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0xc, 0x2); | 648 | /* A small (28b) LBA will fit in the 32b info field */ |
322 | /* "write error - auto-reallocation failed" */ | 649 | sb[0] |= 0x80; /* set valid bit */ |
650 | sb[3] = tf->device & 0x0f; | ||
651 | sb[4] = tf->lbah; | ||
652 | sb[5] = tf->lbam; | ||
653 | sb[6] = tf->lbal; | ||
323 | } | 654 | } |
324 | } | 655 | } |
325 | 656 | ||
@@ -871,11 +1202,36 @@ nothing_to_do: | |||
871 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | 1202 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) |
872 | { | 1203 | { |
873 | struct scsi_cmnd *cmd = qc->scsicmd; | 1204 | struct scsi_cmnd *cmd = qc->scsicmd; |
1205 | int need_sense = drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ); | ||
1206 | |||
1207 | /* For ATA pass thru (SAT) commands, generate a sense block if | ||
1208 | * user mandated it or if there's an error. Note that if we | ||
1209 | * generate because the user forced us to, a check condition | ||
1210 | * is generated and the ATA register values are returned | ||
1211 | * whether the command completed successfully or not. If there | ||
1212 | * was no error, SK, ASC and ASCQ will all be zero. | ||
1213 | */ | ||
1214 | if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && | ||
1215 | ((cmd->cmnd[2] & 0x20) || need_sense)) { | ||
1216 | ata_gen_ata_desc_sense(qc); | ||
1217 | } else { | ||
1218 | if (!need_sense) { | ||
1219 | cmd->result = SAM_STAT_GOOD; | ||
1220 | } else { | ||
1221 | /* TODO: decide which descriptor format to use | ||
1222 | * for 48b LBA devices and call that here | ||
1223 | * instead of the fixed desc, which is only | ||
1224 | * good for smaller LBA (and maybe CHS?) | ||
1225 | * devices. | ||
1226 | */ | ||
1227 | ata_gen_fixed_sense(qc); | ||
1228 | } | ||
1229 | } | ||
874 | 1230 | ||
875 | if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) | 1231 | if (need_sense) { |
876 | ata_to_sense_error(qc, drv_stat); | 1232 | /* The ata_gen_..._sense routines fill in tf */ |
877 | else | 1233 | ata_dump_status(qc->ap->id, &qc->tf); |
878 | cmd->result = SAM_STAT_GOOD; | 1234 | } |
879 | 1235 | ||
880 | qc->scsidone(cmd); | 1236 | qc->scsidone(cmd); |
881 | 1237 | ||
@@ -1266,13 +1622,9 @@ static void ata_msense_push(u8 **ptr_io, const u8 *last, | |||
1266 | static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, | 1622 | static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, |
1267 | const u8 *last) | 1623 | const u8 *last) |
1268 | { | 1624 | { |
1269 | u8 page[] = { | 1625 | u8 page[CACHE_MPAGE_LEN]; |
1270 | 0x8, /* page code */ | ||
1271 | 0x12, /* page length */ | ||
1272 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 zeroes */ | ||
1273 | 0, 0, 0, 0, 0, 0, 0, 0 /* 8 zeroes */ | ||
1274 | }; | ||
1275 | 1626 | ||
1627 | memcpy(page, def_cache_mpage, sizeof(page)); | ||
1276 | if (ata_id_wcache_enabled(id)) | 1628 | if (ata_id_wcache_enabled(id)) |
1277 | page[2] |= (1 << 2); /* write cache enable */ | 1629 | page[2] |= (1 << 2); /* write cache enable */ |
1278 | if (!ata_id_rahead_enabled(id)) | 1630 | if (!ata_id_rahead_enabled(id)) |
@@ -1296,15 +1648,9 @@ static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, | |||
1296 | 1648 | ||
1297 | static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) | 1649 | static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) |
1298 | { | 1650 | { |
1299 | const u8 page[] = {0xa, 0xa, 6, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 30}; | 1651 | ata_msense_push(ptr_io, last, def_control_mpage, |
1300 | 1652 | sizeof(def_control_mpage)); | |
1301 | /* byte 2: set the descriptor format sense data bit (bit 2) | 1653 | return sizeof(def_control_mpage); |
1302 | * since we need to support returning this format for SAT | ||
1303 | * commands and any SCSI commands against a 48b LBA device. | ||
1304 | */ | ||
1305 | |||
1306 | ata_msense_push(ptr_io, last, page, sizeof(page)); | ||
1307 | return sizeof(page); | ||
1308 | } | 1654 | } |
1309 | 1655 | ||
1310 | /** | 1656 | /** |
@@ -1321,15 +1667,10 @@ static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) | |||
1321 | 1667 | ||
1322 | static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) | 1668 | static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) |
1323 | { | 1669 | { |
1324 | const u8 page[] = { | ||
1325 | 0x1, /* page code */ | ||
1326 | 0xa, /* page length */ | ||
1327 | (1 << 7) | (1 << 6), /* note auto r/w reallocation */ | ||
1328 | 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 9 zeroes */ | ||
1329 | }; | ||
1330 | 1670 | ||
1331 | ata_msense_push(ptr_io, last, page, sizeof(page)); | 1671 | ata_msense_push(ptr_io, last, def_rw_recovery_mpage, |
1332 | return sizeof(page); | 1672 | sizeof(def_rw_recovery_mpage)); |
1673 | return sizeof(def_rw_recovery_mpage); | ||
1333 | } | 1674 | } |
1334 | 1675 | ||
1335 | /** | 1676 | /** |
@@ -1338,7 +1679,9 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) | |||
1338 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. | 1679 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. |
1339 | * @buflen: Response buffer length. | 1680 | * @buflen: Response buffer length. |
1340 | * | 1681 | * |
1341 | * Simulate MODE SENSE commands. | 1682 | * Simulate MODE SENSE commands. Assume this is invoked for direct |
1683 | * access devices (e.g. disks) only. There should be no block | ||
1684 | * descriptor for other device types. | ||
1342 | * | 1685 | * |
1343 | * LOCKING: | 1686 | * LOCKING: |
1344 | * spin_lock_irqsave(host_set lock) | 1687 | * spin_lock_irqsave(host_set lock) |
@@ -1348,15 +1691,22 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1348 | unsigned int buflen) | 1691 | unsigned int buflen) |
1349 | { | 1692 | { |
1350 | u8 *scsicmd = args->cmd->cmnd, *p, *last; | 1693 | u8 *scsicmd = args->cmd->cmnd, *p, *last; |
1351 | unsigned int page_control, six_byte, output_len; | 1694 | const u8 sat_blk_desc[] = { |
1695 | 0, 0, 0, 0, /* number of blocks: sat unspecified */ | ||
1696 | 0, | ||
1697 | 0, 0x2, 0x0 /* block length: 512 bytes */ | ||
1698 | }; | ||
1699 | u8 pg, spg; | ||
1700 | unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; | ||
1352 | 1701 | ||
1353 | VPRINTK("ENTER\n"); | 1702 | VPRINTK("ENTER\n"); |
1354 | 1703 | ||
1355 | six_byte = (scsicmd[0] == MODE_SENSE); | 1704 | six_byte = (scsicmd[0] == MODE_SENSE); |
1356 | 1705 | ebd = !(scsicmd[1] & 0x8); /* dbd bit inverted == edb */ | |
1357 | /* we only support saved and current values (which we treat | 1706 | /* |
1358 | * in the same manner) | 1707 | * LLBA bit in msense(10) ignored (compliant) |
1359 | */ | 1708 | */ |
1709 | |||
1360 | page_control = scsicmd[2] >> 6; | 1710 | page_control = scsicmd[2] >> 6; |
1361 | switch (page_control) { | 1711 | switch (page_control) { |
1362 | case 0: /* current */ | 1712 | case 0: /* current */ |
@@ -1369,29 +1719,42 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1369 | goto invalid_fld; | 1719 | goto invalid_fld; |
1370 | } | 1720 | } |
1371 | 1721 | ||
1372 | if (six_byte) | 1722 | if (six_byte) { |
1373 | output_len = 4; | 1723 | output_len = 4 + (ebd ? 8 : 0); |
1374 | else | 1724 | alloc_len = scsicmd[4]; |
1375 | output_len = 8; | 1725 | } else { |
1726 | output_len = 8 + (ebd ? 8 : 0); | ||
1727 | alloc_len = (scsicmd[7] << 8) + scsicmd[8]; | ||
1728 | } | ||
1729 | minlen = (alloc_len < buflen) ? alloc_len : buflen; | ||
1376 | 1730 | ||
1377 | p = rbuf + output_len; | 1731 | p = rbuf + output_len; |
1378 | last = rbuf + buflen - 1; | 1732 | last = rbuf + minlen - 1; |
1379 | 1733 | ||
1380 | switch(scsicmd[2] & 0x3f) { | 1734 | pg = scsicmd[2] & 0x3f; |
1381 | case 0x01: /* r/w error recovery */ | 1735 | spg = scsicmd[3]; |
1736 | /* | ||
1737 | * No mode subpages supported (yet) but asking for _all_ | ||
1738 | * subpages may be valid | ||
1739 | */ | ||
1740 | if (spg && (spg != ALL_SUB_MPAGES)) | ||
1741 | goto invalid_fld; | ||
1742 | |||
1743 | switch(pg) { | ||
1744 | case RW_RECOVERY_MPAGE: | ||
1382 | output_len += ata_msense_rw_recovery(&p, last); | 1745 | output_len += ata_msense_rw_recovery(&p, last); |
1383 | break; | 1746 | break; |
1384 | 1747 | ||
1385 | case 0x08: /* caching */ | 1748 | case CACHE_MPAGE: |
1386 | output_len += ata_msense_caching(args->id, &p, last); | 1749 | output_len += ata_msense_caching(args->id, &p, last); |
1387 | break; | 1750 | break; |
1388 | 1751 | ||
1389 | case 0x0a: { /* control mode */ | 1752 | case CONTROL_MPAGE: { |
1390 | output_len += ata_msense_ctl_mode(&p, last); | 1753 | output_len += ata_msense_ctl_mode(&p, last); |
1391 | break; | 1754 | break; |
1392 | } | 1755 | } |
1393 | 1756 | ||
1394 | case 0x3f: /* all pages */ | 1757 | case ALL_MPAGES: |
1395 | output_len += ata_msense_rw_recovery(&p, last); | 1758 | output_len += ata_msense_rw_recovery(&p, last); |
1396 | output_len += ata_msense_caching(args->id, &p, last); | 1759 | output_len += ata_msense_caching(args->id, &p, last); |
1397 | output_len += ata_msense_ctl_mode(&p, last); | 1760 | output_len += ata_msense_ctl_mode(&p, last); |
@@ -1401,15 +1764,31 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1401 | goto invalid_fld; | 1764 | goto invalid_fld; |
1402 | } | 1765 | } |
1403 | 1766 | ||
1767 | if (minlen < 1) | ||
1768 | return 0; | ||
1404 | if (six_byte) { | 1769 | if (six_byte) { |
1405 | output_len--; | 1770 | output_len--; |
1406 | rbuf[0] = output_len; | 1771 | rbuf[0] = output_len; |
1772 | if (ebd) { | ||
1773 | if (minlen > 3) | ||
1774 | rbuf[3] = sizeof(sat_blk_desc); | ||
1775 | if (minlen > 11) | ||
1776 | memcpy(rbuf + 4, sat_blk_desc, | ||
1777 | sizeof(sat_blk_desc)); | ||
1778 | } | ||
1407 | } else { | 1779 | } else { |
1408 | output_len -= 2; | 1780 | output_len -= 2; |
1409 | rbuf[0] = output_len >> 8; | 1781 | rbuf[0] = output_len >> 8; |
1410 | rbuf[1] = output_len; | 1782 | if (minlen > 1) |
1783 | rbuf[1] = output_len; | ||
1784 | if (ebd) { | ||
1785 | if (minlen > 7) | ||
1786 | rbuf[7] = sizeof(sat_blk_desc); | ||
1787 | if (minlen > 15) | ||
1788 | memcpy(rbuf + 8, sat_blk_desc, | ||
1789 | sizeof(sat_blk_desc)); | ||
1790 | } | ||
1411 | } | 1791 | } |
1412 | |||
1413 | return 0; | 1792 | return 0; |
1414 | 1793 | ||
1415 | invalid_fld: | 1794 | invalid_fld: |
@@ -1623,7 +2002,12 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | |||
1623 | VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); | 2002 | VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); |
1624 | 2003 | ||
1625 | if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) | 2004 | if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) |
1626 | ata_to_sense_error(qc, drv_stat); | 2005 | /* FIXME: not quite right; we don't want the |
2006 | * translation of taskfile registers into | ||
2007 | * a sense descriptors, since that's only | ||
2008 | * correct for ATA, not ATAPI | ||
2009 | */ | ||
2010 | ata_gen_ata_desc_sense(qc); | ||
1627 | 2011 | ||
1628 | else if (unlikely(drv_stat & ATA_ERR)) { | 2012 | else if (unlikely(drv_stat & ATA_ERR)) { |
1629 | DPRINTK("request check condition\n"); | 2013 | DPRINTK("request check condition\n"); |
@@ -1782,6 +2166,143 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev) | |||
1782 | return dev; | 2166 | return dev; |
1783 | } | 2167 | } |
1784 | 2168 | ||
2169 | /* | ||
2170 | * ata_scsi_map_proto - Map pass-thru protocol value to taskfile value. | ||
2171 | * @byte1: Byte 1 from pass-thru CDB. | ||
2172 | * | ||
2173 | * RETURNS: | ||
2174 | * ATA_PROT_UNKNOWN if mapping failed/unimplemented, protocol otherwise. | ||
2175 | */ | ||
2176 | static u8 | ||
2177 | ata_scsi_map_proto(u8 byte1) | ||
2178 | { | ||
2179 | switch((byte1 & 0x1e) >> 1) { | ||
2180 | case 3: /* Non-data */ | ||
2181 | return ATA_PROT_NODATA; | ||
2182 | |||
2183 | case 6: /* DMA */ | ||
2184 | return ATA_PROT_DMA; | ||
2185 | |||
2186 | case 4: /* PIO Data-in */ | ||
2187 | case 5: /* PIO Data-out */ | ||
2188 | if (byte1 & 0xe0) { | ||
2189 | return ATA_PROT_PIO_MULT; | ||
2190 | } | ||
2191 | return ATA_PROT_PIO; | ||
2192 | |||
2193 | case 10: /* Device Reset */ | ||
2194 | case 0: /* Hard Reset */ | ||
2195 | case 1: /* SRST */ | ||
2196 | case 2: /* Bus Idle */ | ||
2197 | case 7: /* Packet */ | ||
2198 | case 8: /* DMA Queued */ | ||
2199 | case 9: /* Device Diagnostic */ | ||
2200 | case 11: /* UDMA Data-in */ | ||
2201 | case 12: /* UDMA Data-Out */ | ||
2202 | case 13: /* FPDMA */ | ||
2203 | default: /* Reserved */ | ||
2204 | break; | ||
2205 | } | ||
2206 | |||
2207 | return ATA_PROT_UNKNOWN; | ||
2208 | } | ||
2209 | |||
2210 | /** | ||
2211 | * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile | ||
2212 | * @qc: command structure to be initialized | ||
2213 | * @cmd: SCSI command to convert | ||
2214 | * | ||
2215 | * Handles either 12 or 16-byte versions of the CDB. | ||
2216 | * | ||
2217 | * RETURNS: | ||
2218 | * Zero on success, non-zero on failure. | ||
2219 | */ | ||
2220 | static unsigned int | ||
2221 | ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd) | ||
2222 | { | ||
2223 | struct ata_taskfile *tf = &(qc->tf); | ||
2224 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
2225 | |||
2226 | if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) | ||
2227 | return 1; | ||
2228 | |||
2229 | /* | ||
2230 | * 12 and 16 byte CDBs use different offsets to | ||
2231 | * provide the various register values. | ||
2232 | */ | ||
2233 | if (scsicmd[0] == ATA_16) { | ||
2234 | /* | ||
2235 | * 16-byte CDB - may contain extended commands. | ||
2236 | * | ||
2237 | * If that is the case, copy the upper byte register values. | ||
2238 | */ | ||
2239 | if (scsicmd[1] & 0x01) { | ||
2240 | tf->hob_feature = scsicmd[3]; | ||
2241 | tf->hob_nsect = scsicmd[5]; | ||
2242 | tf->hob_lbal = scsicmd[7]; | ||
2243 | tf->hob_lbam = scsicmd[9]; | ||
2244 | tf->hob_lbah = scsicmd[11]; | ||
2245 | tf->flags |= ATA_TFLAG_LBA48; | ||
2246 | } else | ||
2247 | tf->flags &= ~ATA_TFLAG_LBA48; | ||
2248 | |||
2249 | /* | ||
2250 | * Always copy low byte, device and command registers. | ||
2251 | */ | ||
2252 | tf->feature = scsicmd[4]; | ||
2253 | tf->nsect = scsicmd[6]; | ||
2254 | tf->lbal = scsicmd[8]; | ||
2255 | tf->lbam = scsicmd[10]; | ||
2256 | tf->lbah = scsicmd[12]; | ||
2257 | tf->device = scsicmd[13]; | ||
2258 | tf->command = scsicmd[14]; | ||
2259 | } else { | ||
2260 | /* | ||
2261 | * 12-byte CDB - incapable of extended commands. | ||
2262 | */ | ||
2263 | tf->flags &= ~ATA_TFLAG_LBA48; | ||
2264 | |||
2265 | tf->feature = scsicmd[3]; | ||
2266 | tf->nsect = scsicmd[4]; | ||
2267 | tf->lbal = scsicmd[5]; | ||
2268 | tf->lbam = scsicmd[6]; | ||
2269 | tf->lbah = scsicmd[7]; | ||
2270 | tf->device = scsicmd[8]; | ||
2271 | tf->command = scsicmd[9]; | ||
2272 | } | ||
2273 | |||
2274 | /* | ||
2275 | * Filter SET_FEATURES - XFER MODE command -- otherwise, | ||
2276 | * SET_FEATURES - XFER MODE must be preceded/succeeded | ||
2277 | * by an update to hardware-specific registers for each | ||
2278 | * controller (i.e. the reason for ->set_piomode(), | ||
2279 | * ->set_dmamode(), and ->post_set_mode() hooks). | ||
2280 | */ | ||
2281 | if ((tf->command == ATA_CMD_SET_FEATURES) | ||
2282 | && (tf->feature == SETFEATURES_XFER)) | ||
2283 | return 1; | ||
2284 | |||
2285 | /* | ||
2286 | * Set flags so that all registers will be written, | ||
2287 | * and pass on write indication (used for PIO/DMA | ||
2288 | * setup.) | ||
2289 | */ | ||
2290 | tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); | ||
2291 | |||
2292 | if (cmd->sc_data_direction == DMA_TO_DEVICE) | ||
2293 | tf->flags |= ATA_TFLAG_WRITE; | ||
2294 | |||
2295 | /* | ||
2296 | * Set transfer length. | ||
2297 | * | ||
2298 | * TODO: find out if we need to do more here to | ||
2299 | * cover scatter/gather case. | ||
2300 | */ | ||
2301 | qc->nsect = cmd->bufflen / ATA_SECT_SIZE; | ||
2302 | |||
2303 | return 0; | ||
2304 | } | ||
2305 | |||
1785 | /** | 2306 | /** |
1786 | * ata_get_xlat_func - check if SCSI to ATA translation is possible | 2307 | * ata_get_xlat_func - check if SCSI to ATA translation is possible |
1787 | * @dev: ATA device | 2308 | * @dev: ATA device |
@@ -1814,6 +2335,11 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) | |||
1814 | case VERIFY: | 2335 | case VERIFY: |
1815 | case VERIFY_16: | 2336 | case VERIFY_16: |
1816 | return ata_scsi_verify_xlat; | 2337 | return ata_scsi_verify_xlat; |
2338 | |||
2339 | case ATA_12: | ||
2340 | case ATA_16: | ||
2341 | return ata_scsi_pass_thru; | ||
2342 | |||
1817 | case START_STOP: | 2343 | case START_STOP: |
1818 | return ata_scsi_start_stop_xlat; | 2344 | return ata_scsi_start_stop_xlat; |
1819 | } | 2345 | } |
@@ -1972,7 +2498,7 @@ void ata_scsi_simulate(u16 *id, | |||
1972 | ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); | 2498 | ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); |
1973 | break; | 2499 | break; |
1974 | 2500 | ||
1975 | /* mandantory commands we haven't implemented yet */ | 2501 | /* mandatory commands we haven't implemented yet */ |
1976 | case REQUEST_SENSE: | 2502 | case REQUEST_SENSE: |
1977 | 2503 | ||
1978 | /* all other commands */ | 2504 | /* all other commands */ |
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 3d60190584ba..65c264b91136 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -50,13 +50,14 @@ extern void ata_dev_select(struct ata_port *ap, unsigned int device, | |||
50 | unsigned int wait, unsigned int can_sleep); | 50 | unsigned int wait, unsigned int can_sleep); |
51 | extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); | 51 | extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); |
52 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); | 52 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); |
53 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); | ||
54 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | ||
53 | 55 | ||
54 | 56 | ||
55 | /* libata-scsi.c */ | 57 | /* libata-scsi.c */ |
56 | extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | 58 | extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, |
57 | struct scsi_cmnd *cmd); | 59 | struct scsi_cmnd *cmd); |
58 | extern void ata_scsi_scan_host(struct ata_port *ap); | 60 | extern void ata_scsi_scan_host(struct ata_port *ap); |
59 | extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat); | ||
60 | extern int ata_scsi_error(struct Scsi_Host *host); | 61 | extern int ata_scsi_error(struct Scsi_Host *host); |
61 | extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, | 62 | extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, |
62 | unsigned int buflen); | 63 | unsigned int buflen); |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index 9820f272f889..7999817915c3 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "pdc_adma" | 48 | #define DRV_NAME "pdc_adma" |
49 | #define DRV_VERSION "0.01" | 49 | #define DRV_VERSION "0.03" |
50 | 50 | ||
51 | /* macro to calculate base address for ATA regs */ | 51 | /* macro to calculate base address for ATA regs */ |
52 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) | 52 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) |
@@ -79,7 +79,6 @@ enum { | |||
79 | aNIEN = (1 << 8), /* irq mask: 1==masked */ | 79 | aNIEN = (1 << 8), /* irq mask: 1==masked */ |
80 | aGO = (1 << 7), /* packet trigger ("Go!") */ | 80 | aGO = (1 << 7), /* packet trigger ("Go!") */ |
81 | aRSTADM = (1 << 5), /* ADMA logic reset */ | 81 | aRSTADM = (1 << 5), /* ADMA logic reset */ |
82 | aRSTA = (1 << 2), /* ATA hard reset */ | ||
83 | aPIOMD4 = 0x0003, /* PIO mode 4 */ | 82 | aPIOMD4 = 0x0003, /* PIO mode 4 */ |
84 | 83 | ||
85 | /* ADMA_STATUS register bits */ | 84 | /* ADMA_STATUS register bits */ |
@@ -452,24 +451,25 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
452 | struct adma_port_priv *pp; | 451 | struct adma_port_priv *pp; |
453 | struct ata_queued_cmd *qc; | 452 | struct ata_queued_cmd *qc; |
454 | void __iomem *chan = ADMA_REGS(mmio_base, port_no); | 453 | void __iomem *chan = ADMA_REGS(mmio_base, port_no); |
455 | u8 drv_stat, status = readb(chan + ADMA_STATUS); | 454 | u8 drv_stat = 0, status = readb(chan + ADMA_STATUS); |
456 | 455 | ||
457 | if (status == 0) | 456 | if (status == 0) |
458 | continue; | 457 | continue; |
459 | handled = 1; | 458 | handled = 1; |
460 | adma_enter_reg_mode(ap); | 459 | adma_enter_reg_mode(ap); |
461 | if ((ap->flags & ATA_FLAG_PORT_DISABLED)) | 460 | if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)) |
462 | continue; | 461 | continue; |
463 | pp = ap->private_data; | 462 | pp = ap->private_data; |
464 | if (!pp || pp->state != adma_state_pkt) | 463 | if (!pp || pp->state != adma_state_pkt) |
465 | continue; | 464 | continue; |
466 | qc = ata_qc_from_tag(ap, ap->active_tag); | 465 | qc = ata_qc_from_tag(ap, ap->active_tag); |
467 | drv_stat = 0; | 466 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { |
468 | if ((status & (aPERR | aPSD | aUIRQ))) | 467 | if ((status & (aPERR | aPSD | aUIRQ))) |
469 | drv_stat = ATA_ERR; | 468 | drv_stat = ATA_ERR; |
470 | else if (pp->pkt[0] != cDONE) | 469 | else if (pp->pkt[0] != cDONE) |
471 | drv_stat = ATA_ERR; | 470 | drv_stat = ATA_ERR; |
472 | ata_qc_complete(qc, drv_stat); | 471 | ata_qc_complete(qc, drv_stat); |
472 | } | ||
473 | } | 473 | } |
474 | return handled; | 474 | return handled; |
475 | } | 475 | } |
@@ -561,15 +561,15 @@ static int adma_port_start(struct ata_port *ap) | |||
561 | if ((pp->pkt_dma & 7) != 0) { | 561 | if ((pp->pkt_dma & 7) != 0) { |
562 | printk("bad alignment for pp->pkt_dma: %08x\n", | 562 | printk("bad alignment for pp->pkt_dma: %08x\n", |
563 | (u32)pp->pkt_dma); | 563 | (u32)pp->pkt_dma); |
564 | goto err_out_kfree2; | 564 | dma_free_coherent(dev, ADMA_PKT_BYTES, |
565 | pp->pkt, pp->pkt_dma); | ||
566 | goto err_out_kfree; | ||
565 | } | 567 | } |
566 | memset(pp->pkt, 0, ADMA_PKT_BYTES); | 568 | memset(pp->pkt, 0, ADMA_PKT_BYTES); |
567 | ap->private_data = pp; | 569 | ap->private_data = pp; |
568 | adma_reinit_engine(ap); | 570 | adma_reinit_engine(ap); |
569 | return 0; | 571 | return 0; |
570 | 572 | ||
571 | err_out_kfree2: | ||
572 | kfree(pp); | ||
573 | err_out_kfree: | 573 | err_out_kfree: |
574 | kfree(pp); | 574 | kfree(pp); |
575 | err_out: | 575 | err_out: |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index eee93b0016df..63911f16b6ec 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -195,6 +195,8 @@ static struct ata_port_info pdc_port_info[] = { | |||
195 | static struct pci_device_id pdc_ata_pci_tbl[] = { | 195 | static struct pci_device_id pdc_ata_pci_tbl[] = { |
196 | { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 196 | { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
197 | board_2037x }, | 197 | board_2037x }, |
198 | { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
199 | board_2037x }, | ||
198 | { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 200 | { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
199 | board_2037x }, | 201 | board_2037x }, |
200 | { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 202 | { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
@@ -207,6 +209,8 @@ static struct pci_device_id pdc_ata_pci_tbl[] = { | |||
207 | board_2037x }, | 209 | board_2037x }, |
208 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 210 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
209 | board_2037x }, | 211 | board_2037x }, |
212 | { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
213 | board_2037x }, | ||
210 | 214 | ||
211 | { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 215 | { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
212 | board_20319 }, | 216 | board_20319 }, |