diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/ahci.c | 9 | ||||
-rw-r--r-- | drivers/scsi/arm/scsi.h | 6 | ||||
-rw-r--r-- | drivers/scsi/ch.c | 2 | ||||
-rw-r--r-- | drivers/scsi/dec_esp.c | 2 | ||||
-rw-r--r-- | drivers/scsi/ipr.c | 2 | ||||
-rw-r--r-- | drivers/scsi/lasi700.c | 6 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 65 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 786 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 3 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mbox.c | 10 | ||||
-rw-r--r-- | drivers/scsi/osst.c | 2 | ||||
-rw-r--r-- | drivers/scsi/pdc_adma.c | 28 | ||||
-rw-r--r-- | drivers/scsi/sata_mv.c | 18 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_qstor.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 43 | ||||
-rw-r--r-- | drivers/scsi/sata_svw.c | 22 | ||||
-rw-r--r-- | drivers/scsi/sata_vsc.c | 20 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 27 | ||||
-rw-r--r-- | drivers/scsi/st.c | 12 | ||||
-rw-r--r-- | drivers/scsi/zalon.c | 4 |
21 files changed, 783 insertions, 290 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index fe8187d6f58b..03829aedfd39 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -192,7 +192,6 @@ static void ahci_port_stop(struct ata_port *ap); | |||
192 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 192 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
193 | static void ahci_qc_prep(struct ata_queued_cmd *qc); | 193 | static void ahci_qc_prep(struct ata_queued_cmd *qc); |
194 | static u8 ahci_check_status(struct ata_port *ap); | 194 | static u8 ahci_check_status(struct ata_port *ap); |
195 | static u8 ahci_check_err(struct ata_port *ap); | ||
196 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 195 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
197 | static void ahci_remove_one (struct pci_dev *pdev); | 196 | static void ahci_remove_one (struct pci_dev *pdev); |
198 | 197 | ||
@@ -221,7 +220,6 @@ static const struct ata_port_operations ahci_ops = { | |||
221 | 220 | ||
222 | .check_status = ahci_check_status, | 221 | .check_status = ahci_check_status, |
223 | .check_altstatus = ahci_check_status, | 222 | .check_altstatus = ahci_check_status, |
224 | .check_err = ahci_check_err, | ||
225 | .dev_select = ata_noop_dev_select, | 223 | .dev_select = ata_noop_dev_select, |
226 | 224 | ||
227 | .tf_read = ahci_tf_read, | 225 | .tf_read = ahci_tf_read, |
@@ -458,13 +456,6 @@ static u8 ahci_check_status(struct ata_port *ap) | |||
458 | return readl(mmio + PORT_TFDATA) & 0xFF; | 456 | return readl(mmio + PORT_TFDATA) & 0xFF; |
459 | } | 457 | } |
460 | 458 | ||
461 | static u8 ahci_check_err(struct ata_port *ap) | ||
462 | { | ||
463 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr; | ||
464 | |||
465 | return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF; | ||
466 | } | ||
467 | |||
468 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 459 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
469 | { | 460 | { |
470 | struct ahci_port_priv *pp = ap->private_data; | 461 | struct ahci_port_priv *pp = ap->private_data; |
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h index 48e1c4d9738b..19937640e2e7 100644 --- a/drivers/scsi/arm/scsi.h +++ b/drivers/scsi/arm/scsi.h | |||
@@ -10,6 +10,8 @@ | |||
10 | * Commonly used scsi driver functions. | 10 | * Commonly used scsi driver functions. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/scatterlist.h> | ||
14 | |||
13 | #define BELT_AND_BRACES | 15 | #define BELT_AND_BRACES |
14 | 16 | ||
15 | /* | 17 | /* |
@@ -22,9 +24,7 @@ static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int | |||
22 | 24 | ||
23 | BUG_ON(bufs + 1 > max); | 25 | BUG_ON(bufs + 1 > max); |
24 | 26 | ||
25 | sg->page = virt_to_page(SCp->ptr); | 27 | sg_set_buf(sg, SCp->ptr, SCp->this_residual); |
26 | sg->offset = offset_in_page(SCp->ptr); | ||
27 | sg->length = SCp->this_residual; | ||
28 | 28 | ||
29 | if (bufs) | 29 | if (bufs) |
30 | memcpy(sg + 1, SCp->buffer + 1, | 30 | memcpy(sg + 1, SCp->buffer + 1, |
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index da6e51c7fe69..540147cb51ce 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -936,7 +936,7 @@ static int ch_probe(struct device *dev) | |||
936 | if (init) | 936 | if (init) |
937 | ch_init_elem(ch); | 937 | ch_init_elem(ch); |
938 | 938 | ||
939 | class_device_create(ch_sysfs_class, | 939 | class_device_create(ch_sysfs_class, NULL, |
940 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), | 940 | MKDEV(SCSI_CHANGER_MAJOR,ch->minor), |
941 | dev, "s%s", ch->name); | 941 | dev, "s%s", ch->name); |
942 | 942 | ||
diff --git a/drivers/scsi/dec_esp.c b/drivers/scsi/dec_esp.c index 315f95a0d6c0..4f39890b44ac 100644 --- a/drivers/scsi/dec_esp.c +++ b/drivers/scsi/dec_esp.c | |||
@@ -228,7 +228,7 @@ static int dec_esp_detect(Scsi_Host_Template * tpnt) | |||
228 | mem_start = get_tc_base_addr(slot); | 228 | mem_start = get_tc_base_addr(slot); |
229 | 229 | ||
230 | /* Store base addr into esp struct */ | 230 | /* Store base addr into esp struct */ |
231 | esp->slot = PHYSADDR(mem_start); | 231 | esp->slot = CPHYSADDR(mem_start); |
232 | 232 | ||
233 | esp->dregs = 0; | 233 | esp->dregs = 0; |
234 | esp->eregs = (struct ESP_regs *) (mem_start + DEC_SCSI_SREG); | 234 | esp->eregs = (struct ESP_regs *) (mem_start + DEC_SCSI_SREG); |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index babd48363402..e0039dfae8e5 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -4944,6 +4944,7 @@ static int ipr_reset_restore_cfg_space(struct ipr_cmnd *ipr_cmd) | |||
4944 | int rc; | 4944 | int rc; |
4945 | 4945 | ||
4946 | ENTER; | 4946 | ENTER; |
4947 | pci_unblock_user_cfg_access(ioa_cfg->pdev); | ||
4947 | rc = pci_restore_state(ioa_cfg->pdev); | 4948 | rc = pci_restore_state(ioa_cfg->pdev); |
4948 | 4949 | ||
4949 | if (rc != PCIBIOS_SUCCESSFUL) { | 4950 | if (rc != PCIBIOS_SUCCESSFUL) { |
@@ -4998,6 +4999,7 @@ static int ipr_reset_start_bist(struct ipr_cmnd *ipr_cmd) | |||
4998 | int rc; | 4999 | int rc; |
4999 | 5000 | ||
5000 | ENTER; | 5001 | ENTER; |
5002 | pci_block_user_cfg_access(ioa_cfg->pdev); | ||
5001 | rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START); | 5003 | rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START); |
5002 | 5004 | ||
5003 | if (rc != PCIBIOS_SUCCESSFUL) { | 5005 | if (rc != PCIBIOS_SUCCESSFUL) { |
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c index 4cbb6187cc44..459a4daebece 100644 --- a/drivers/scsi/lasi700.c +++ b/drivers/scsi/lasi700.c | |||
@@ -98,7 +98,7 @@ MODULE_DEVICE_TABLE(parisc, lasi700_ids); | |||
98 | static int __init | 98 | static int __init |
99 | lasi700_probe(struct parisc_device *dev) | 99 | lasi700_probe(struct parisc_device *dev) |
100 | { | 100 | { |
101 | unsigned long base = dev->hpa + LASI_SCSI_CORE_OFFSET; | 101 | unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET; |
102 | struct NCR_700_Host_Parameters *hostdata; | 102 | struct NCR_700_Host_Parameters *hostdata; |
103 | struct Scsi_Host *host; | 103 | struct Scsi_Host *host; |
104 | 104 | ||
@@ -125,8 +125,6 @@ lasi700_probe(struct parisc_device *dev) | |||
125 | hostdata->dmode_extra = DMODE_FC2; | 125 | hostdata->dmode_extra = DMODE_FC2; |
126 | } | 126 | } |
127 | 127 | ||
128 | NCR_700_set_mem_mapped(hostdata); | ||
129 | |||
130 | host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev); | 128 | host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev); |
131 | if (!host) | 129 | if (!host) |
132 | goto out_kfree; | 130 | goto out_kfree; |
@@ -168,7 +166,7 @@ lasi700_driver_remove(struct parisc_device *dev) | |||
168 | } | 166 | } |
169 | 167 | ||
170 | static struct parisc_driver lasi700_driver = { | 168 | static struct parisc_driver lasi700_driver = { |
171 | .name = "Lasi SCSI", | 169 | .name = "lasi_scsi", |
172 | .id_table = lasi700_ids, | 170 | .id_table = lasi700_ids, |
173 | .probe = lasi700_probe, | 171 | .probe = lasi700_probe, |
174 | .remove = __devexit_p(lasi700_driver_remove), | 172 | .remove = __devexit_p(lasi700_driver_remove), |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index ab8b7354452c..d8f248dd0d01 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/suspend.h> | 49 | #include <linux/suspend.h> |
50 | #include <linux/workqueue.h> | 50 | #include <linux/workqueue.h> |
51 | #include <linux/jiffies.h> | 51 | #include <linux/jiffies.h> |
52 | #include <linux/scatterlist.h> | ||
52 | #include <scsi/scsi.h> | 53 | #include <scsi/scsi.h> |
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include "scsi_priv.h" | 55 | #include "scsi_priv.h" |
@@ -371,6 +372,8 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) | |||
371 | { | 372 | { |
372 | struct ata_ioports *ioaddr = &ap->ioaddr; | 373 | struct ata_ioports *ioaddr = &ap->ioaddr; |
373 | 374 | ||
375 | tf->command = ata_check_status(ap); | ||
376 | tf->feature = inb(ioaddr->error_addr); | ||
374 | tf->nsect = inb(ioaddr->nsect_addr); | 377 | tf->nsect = inb(ioaddr->nsect_addr); |
375 | tf->lbal = inb(ioaddr->lbal_addr); | 378 | tf->lbal = inb(ioaddr->lbal_addr); |
376 | tf->lbam = inb(ioaddr->lbam_addr); | 379 | tf->lbam = inb(ioaddr->lbam_addr); |
@@ -403,6 +406,8 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
403 | { | 406 | { |
404 | struct ata_ioports *ioaddr = &ap->ioaddr; | 407 | struct ata_ioports *ioaddr = &ap->ioaddr; |
405 | 408 | ||
409 | tf->command = ata_check_status(ap); | ||
410 | tf->feature = readb((void __iomem *)ioaddr->error_addr); | ||
406 | tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); | 411 | tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); |
407 | tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); | 412 | tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); |
408 | tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); | 413 | tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); |
@@ -523,30 +528,6 @@ u8 ata_altstatus(struct ata_port *ap) | |||
523 | 528 | ||
524 | 529 | ||
525 | /** | 530 | /** |
526 | * ata_chk_err - Read device error reg | ||
527 | * @ap: port where the device is | ||
528 | * | ||
529 | * Reads ATA taskfile error register for | ||
530 | * currently-selected device and return its value. | ||
531 | * | ||
532 | * Note: may NOT be used as the check_err() entry in | ||
533 | * ata_port_operations. | ||
534 | * | ||
535 | * LOCKING: | ||
536 | * Inherited from caller. | ||
537 | */ | ||
538 | u8 ata_chk_err(struct ata_port *ap) | ||
539 | { | ||
540 | if (ap->ops->check_err) | ||
541 | return ap->ops->check_err(ap); | ||
542 | |||
543 | if (ap->flags & ATA_FLAG_MMIO) { | ||
544 | return readb((void __iomem *) ap->ioaddr.error_addr); | ||
545 | } | ||
546 | return inb(ap->ioaddr.error_addr); | ||
547 | } | ||
548 | |||
549 | /** | ||
550 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure | 531 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure |
551 | * @tf: Taskfile to convert | 532 | * @tf: Taskfile to convert |
552 | * @fis: Buffer into which data will output | 533 | * @fis: Buffer into which data will output |
@@ -898,8 +879,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) | |||
898 | 879 | ||
899 | memset(&tf, 0, sizeof(tf)); | 880 | memset(&tf, 0, sizeof(tf)); |
900 | 881 | ||
901 | err = ata_chk_err(ap); | ||
902 | ap->ops->tf_read(ap, &tf); | 882 | ap->ops->tf_read(ap, &tf); |
883 | err = tf.feature; | ||
903 | 884 | ||
904 | dev->class = ATA_DEV_NONE; | 885 | dev->class = ATA_DEV_NONE; |
905 | 886 | ||
@@ -1136,7 +1117,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1136 | unsigned int major_version; | 1117 | unsigned int major_version; |
1137 | u16 tmp; | 1118 | u16 tmp; |
1138 | unsigned long xfer_modes; | 1119 | unsigned long xfer_modes; |
1139 | u8 status; | ||
1140 | unsigned int using_edd; | 1120 | unsigned int using_edd; |
1141 | DECLARE_COMPLETION(wait); | 1121 | DECLARE_COMPLETION(wait); |
1142 | struct ata_queued_cmd *qc; | 1122 | struct ata_queued_cmd *qc; |
@@ -1190,8 +1170,11 @@ retry: | |||
1190 | else | 1170 | else |
1191 | wait_for_completion(&wait); | 1171 | wait_for_completion(&wait); |
1192 | 1172 | ||
1193 | status = ata_chk_status(ap); | 1173 | spin_lock_irqsave(&ap->host_set->lock, flags); |
1194 | if (status & ATA_ERR) { | 1174 | ap->ops->tf_read(ap, &qc->tf); |
1175 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1176 | |||
1177 | if (qc->tf.command & ATA_ERR) { | ||
1195 | /* | 1178 | /* |
1196 | * arg! EDD works for all test cases, but seems to return | 1179 | * arg! EDD works for all test cases, but seems to return |
1197 | * the ATA signature for some ATAPI devices. Until the | 1180 | * the ATA signature for some ATAPI devices. Until the |
@@ -1204,7 +1187,7 @@ retry: | |||
1204 | * to have this problem. | 1187 | * to have this problem. |
1205 | */ | 1188 | */ |
1206 | if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { | 1189 | if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { |
1207 | u8 err = ata_chk_err(ap); | 1190 | u8 err = qc->tf.feature; |
1208 | if (err & ATA_ABORTED) { | 1191 | if (err & ATA_ABORTED) { |
1209 | dev->class = ATA_DEV_ATAPI; | 1192 | dev->class = ATA_DEV_ATAPI; |
1210 | qc->cursg = 0; | 1193 | qc->cursg = 0; |
@@ -2576,19 +2559,12 @@ void ata_qc_prep(struct ata_queued_cmd *qc) | |||
2576 | 2559 | ||
2577 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | 2560 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) |
2578 | { | 2561 | { |
2579 | struct scatterlist *sg; | ||
2580 | |||
2581 | qc->flags |= ATA_QCFLAG_SINGLE; | 2562 | qc->flags |= ATA_QCFLAG_SINGLE; |
2582 | 2563 | ||
2583 | memset(&qc->sgent, 0, sizeof(qc->sgent)); | ||
2584 | qc->sg = &qc->sgent; | 2564 | qc->sg = &qc->sgent; |
2585 | qc->n_elem = 1; | 2565 | qc->n_elem = 1; |
2586 | qc->buf_virt = buf; | 2566 | qc->buf_virt = buf; |
2587 | 2567 | sg_init_one(qc->sg, buf, buflen); | |
2588 | sg = qc->sg; | ||
2589 | sg->page = virt_to_page(buf); | ||
2590 | sg->offset = (unsigned long) buf & ~PAGE_MASK; | ||
2591 | sg->length = buflen; | ||
2592 | } | 2568 | } |
2593 | 2569 | ||
2594 | /** | 2570 | /** |
@@ -4472,11 +4448,10 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
4472 | 4448 | ||
4473 | DPRINTK("ENTER\n"); | 4449 | DPRINTK("ENTER\n"); |
4474 | /* alloc a container for our list of ATA ports (buses) */ | 4450 | /* alloc a container for our list of ATA ports (buses) */ |
4475 | host_set = kmalloc(sizeof(struct ata_host_set) + | 4451 | host_set = kzalloc(sizeof(struct ata_host_set) + |
4476 | (ent->n_ports * sizeof(void *)), GFP_KERNEL); | 4452 | (ent->n_ports * sizeof(void *)), GFP_KERNEL); |
4477 | if (!host_set) | 4453 | if (!host_set) |
4478 | return 0; | 4454 | return 0; |
4479 | memset(host_set, 0, sizeof(struct ata_host_set) + (ent->n_ports * sizeof(void *))); | ||
4480 | spin_lock_init(&host_set->lock); | 4455 | spin_lock_init(&host_set->lock); |
4481 | 4456 | ||
4482 | host_set->dev = dev; | 4457 | host_set->dev = dev; |
@@ -4516,10 +4491,8 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
4516 | count++; | 4491 | count++; |
4517 | } | 4492 | } |
4518 | 4493 | ||
4519 | if (!count) { | 4494 | if (!count) |
4520 | kfree(host_set); | 4495 | goto err_free_ret; |
4521 | return 0; | ||
4522 | } | ||
4523 | 4496 | ||
4524 | /* obtain irq, that is shared between channels */ | 4497 | /* obtain irq, that is shared between channels */ |
4525 | if (request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags, | 4498 | if (request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags, |
@@ -4577,6 +4550,7 @@ err_out: | |||
4577 | ata_host_remove(host_set->ports[i], 1); | 4550 | ata_host_remove(host_set->ports[i], 1); |
4578 | scsi_host_put(host_set->ports[i]->host); | 4551 | scsi_host_put(host_set->ports[i]->host); |
4579 | } | 4552 | } |
4553 | err_free_ret: | ||
4580 | kfree(host_set); | 4554 | kfree(host_set); |
4581 | VPRINTK("EXIT, returning 0\n"); | 4555 | VPRINTK("EXIT, returning 0\n"); |
4582 | return 0; | 4556 | return 0; |
@@ -4686,15 +4660,13 @@ ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port) | |||
4686 | { | 4660 | { |
4687 | struct ata_probe_ent *probe_ent; | 4661 | struct ata_probe_ent *probe_ent; |
4688 | 4662 | ||
4689 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 4663 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); |
4690 | if (!probe_ent) { | 4664 | if (!probe_ent) { |
4691 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", | 4665 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", |
4692 | kobject_name(&(dev->kobj))); | 4666 | kobject_name(&(dev->kobj))); |
4693 | return NULL; | 4667 | return NULL; |
4694 | } | 4668 | } |
4695 | 4669 | ||
4696 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
4697 | |||
4698 | INIT_LIST_HEAD(&probe_ent->node); | 4670 | INIT_LIST_HEAD(&probe_ent->node); |
4699 | probe_ent->dev = dev; | 4671 | probe_ent->dev = dev; |
4700 | 4672 | ||
@@ -5091,7 +5063,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis); | |||
5091 | EXPORT_SYMBOL_GPL(ata_tf_from_fis); | 5063 | EXPORT_SYMBOL_GPL(ata_tf_from_fis); |
5092 | EXPORT_SYMBOL_GPL(ata_check_status); | 5064 | EXPORT_SYMBOL_GPL(ata_check_status); |
5093 | EXPORT_SYMBOL_GPL(ata_altstatus); | 5065 | EXPORT_SYMBOL_GPL(ata_altstatus); |
5094 | EXPORT_SYMBOL_GPL(ata_chk_err); | ||
5095 | EXPORT_SYMBOL_GPL(ata_exec_command); | 5066 | EXPORT_SYMBOL_GPL(ata_exec_command); |
5096 | EXPORT_SYMBOL_GPL(ata_port_start); | 5067 | EXPORT_SYMBOL_GPL(ata_port_start); |
5097 | EXPORT_SYMBOL_GPL(ata_port_stop); | 5068 | EXPORT_SYMBOL_GPL(ata_port_stop); |
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/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index d47be8e0ea3a..c9e743ba09ec 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -76,7 +76,7 @@ static void megaraid_exit(void); | |||
76 | 76 | ||
77 | static int megaraid_probe_one(struct pci_dev*, const struct pci_device_id *); | 77 | static int megaraid_probe_one(struct pci_dev*, const struct pci_device_id *); |
78 | static void megaraid_detach_one(struct pci_dev *); | 78 | static void megaraid_detach_one(struct pci_dev *); |
79 | static void megaraid_mbox_shutdown(struct device *); | 79 | static void megaraid_mbox_shutdown(struct pci_dev *); |
80 | 80 | ||
81 | static int megaraid_io_attach(adapter_t *); | 81 | static int megaraid_io_attach(adapter_t *); |
82 | static void megaraid_io_detach(adapter_t *); | 82 | static void megaraid_io_detach(adapter_t *); |
@@ -369,9 +369,7 @@ static struct pci_driver megaraid_pci_driver_g = { | |||
369 | .id_table = pci_id_table_g, | 369 | .id_table = pci_id_table_g, |
370 | .probe = megaraid_probe_one, | 370 | .probe = megaraid_probe_one, |
371 | .remove = __devexit_p(megaraid_detach_one), | 371 | .remove = __devexit_p(megaraid_detach_one), |
372 | .driver = { | 372 | .shutdown = megaraid_mbox_shutdown, |
373 | .shutdown = megaraid_mbox_shutdown, | ||
374 | } | ||
375 | }; | 373 | }; |
376 | 374 | ||
377 | 375 | ||
@@ -673,9 +671,9 @@ megaraid_detach_one(struct pci_dev *pdev) | |||
673 | * Shutdown notification, perform flush cache | 671 | * Shutdown notification, perform flush cache |
674 | */ | 672 | */ |
675 | static void | 673 | static void |
676 | megaraid_mbox_shutdown(struct device *device) | 674 | megaraid_mbox_shutdown(struct pci_dev *pdev) |
677 | { | 675 | { |
678 | adapter_t *adapter = pci_get_drvdata(to_pci_dev(device)); | 676 | adapter_t *adapter = pci_get_drvdata(pdev); |
679 | static int counter; | 677 | static int counter; |
680 | 678 | ||
681 | if (!adapter) { | 679 | if (!adapter) { |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index af1133104b3f..172839fce0eb 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5629,7 +5629,7 @@ static void osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * | |||
5629 | 5629 | ||
5630 | if (!osst_sysfs_valid) return; | 5630 | if (!osst_sysfs_valid) return; |
5631 | 5631 | ||
5632 | osst_class_member = class_device_create(osst_sysfs_class, dev, device, "%s", name); | 5632 | osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, device, "%s", name); |
5633 | if (IS_ERR(osst_class_member)) { | 5633 | if (IS_ERR(osst_class_member)) { |
5634 | printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); | 5634 | printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); |
5635 | return; | 5635 | return; |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index 1701e318a9f0..309b205820a4 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 | } |
@@ -490,7 +490,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) | |||
490 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { | 490 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { |
491 | 491 | ||
492 | /* check main status, clearing INTRQ */ | 492 | /* check main status, clearing INTRQ */ |
493 | u8 status = ata_chk_status(ap); | 493 | u8 status = ata_check_status(ap); |
494 | if ((status & ATA_BUSY)) | 494 | if ((status & ATA_BUSY)) |
495 | continue; | 495 | continue; |
496 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", | 496 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", |
@@ -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_mv.c b/drivers/scsi/sata_mv.c index c40e9843b454..f22726d8a8ac 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -259,7 +259,6 @@ struct mv_host_priv { | |||
259 | static void mv_irq_clear(struct ata_port *ap); | 259 | static void mv_irq_clear(struct ata_port *ap); |
260 | static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); | 260 | static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); |
261 | static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); | 261 | static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); |
262 | static u8 mv_check_err(struct ata_port *ap); | ||
263 | static void mv_phy_reset(struct ata_port *ap); | 262 | static void mv_phy_reset(struct ata_port *ap); |
264 | static void mv_host_stop(struct ata_host_set *host_set); | 263 | static void mv_host_stop(struct ata_host_set *host_set); |
265 | static int mv_port_start(struct ata_port *ap); | 264 | static int mv_port_start(struct ata_port *ap); |
@@ -297,7 +296,6 @@ static const struct ata_port_operations mv_ops = { | |||
297 | .tf_load = ata_tf_load, | 296 | .tf_load = ata_tf_load, |
298 | .tf_read = ata_tf_read, | 297 | .tf_read = ata_tf_read, |
299 | .check_status = ata_check_status, | 298 | .check_status = ata_check_status, |
300 | .check_err = mv_check_err, | ||
301 | .exec_command = ata_exec_command, | 299 | .exec_command = ata_exec_command, |
302 | .dev_select = ata_std_dev_select, | 300 | .dev_select = ata_std_dev_select, |
303 | 301 | ||
@@ -1186,22 +1184,6 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance, | |||
1186 | } | 1184 | } |
1187 | 1185 | ||
1188 | /** | 1186 | /** |
1189 | * mv_check_err - Return the error shadow register to caller. | ||
1190 | * @ap: ATA channel to manipulate | ||
1191 | * | ||
1192 | * Marvell requires DMA to be stopped before accessing shadow | ||
1193 | * registers. So we do that, then return the needed register. | ||
1194 | * | ||
1195 | * LOCKING: | ||
1196 | * Inherited from caller. FIXME: protect mv_stop_dma with lock? | ||
1197 | */ | ||
1198 | static u8 mv_check_err(struct ata_port *ap) | ||
1199 | { | ||
1200 | mv_stop_dma(ap); /* can't read shadow regs if DMA on */ | ||
1201 | return readb((void __iomem *) ap->ioaddr.error_addr); | ||
1202 | } | ||
1203 | |||
1204 | /** | ||
1205 | * mv_phy_reset - Perform eDMA reset followed by COMRESET | 1187 | * mv_phy_reset - Perform eDMA reset followed by COMRESET |
1206 | * @ap: ATA channel to manipulate | 1188 | * @ap: ATA channel to manipulate |
1207 | * | 1189 | * |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 9ca07becc49a..3c3ab866351f 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -198,6 +198,8 @@ static struct ata_port_info pdc_port_info[] = { | |||
198 | static struct pci_device_id pdc_ata_pci_tbl[] = { | 198 | static struct pci_device_id pdc_ata_pci_tbl[] = { |
199 | { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 199 | { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
200 | board_2037x }, | 200 | board_2037x }, |
201 | { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
202 | board_2037x }, | ||
201 | { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 203 | { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
202 | board_2037x }, | 204 | board_2037x }, |
203 | { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 205 | { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
@@ -210,6 +212,8 @@ static struct pci_device_id pdc_ata_pci_tbl[] = { | |||
210 | board_2037x }, | 212 | board_2037x }, |
211 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 213 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
212 | board_2037x }, | 214 | board_2037x }, |
215 | { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
216 | board_2037x }, | ||
213 | 217 | ||
214 | { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 218 | { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
215 | board_20319 }, | 219 | board_20319 }, |
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index 6e0c749b6cb4..6317a9a96e69 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -432,7 +432,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) | |||
432 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { | 432 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { |
433 | 433 | ||
434 | /* check main status, clearing INTRQ */ | 434 | /* check main status, clearing INTRQ */ |
435 | u8 status = ata_chk_status(ap); | 435 | u8 status = ata_check_status(ap); |
436 | if ((status & ATA_BUSY)) | 436 | if ((status & ATA_BUSY)) |
437 | continue; | 437 | continue; |
438 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", | 438 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index 32d730bd5bb6..e18a1e2bb65e 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -220,12 +220,11 @@ struct sil24_port_priv { | |||
220 | 220 | ||
221 | /* ap->host_set->private_data */ | 221 | /* ap->host_set->private_data */ |
222 | struct sil24_host_priv { | 222 | struct sil24_host_priv { |
223 | void *host_base; /* global controller control (128 bytes @BAR0) */ | 223 | void __iomem *host_base; /* global controller control (128 bytes @BAR0) */ |
224 | void *port_base; /* port registers (4 * 8192 bytes @BAR2) */ | 224 | void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */ |
225 | }; | 225 | }; |
226 | 226 | ||
227 | static u8 sil24_check_status(struct ata_port *ap); | 227 | static u8 sil24_check_status(struct ata_port *ap); |
228 | static u8 sil24_check_err(struct ata_port *ap); | ||
229 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); | 228 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); |
230 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); | 229 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); |
231 | static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 230 | static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
@@ -280,7 +279,6 @@ static const struct ata_port_operations sil24_ops = { | |||
280 | 279 | ||
281 | .check_status = sil24_check_status, | 280 | .check_status = sil24_check_status, |
282 | .check_altstatus = sil24_check_status, | 281 | .check_altstatus = sil24_check_status, |
283 | .check_err = sil24_check_err, | ||
284 | .dev_select = ata_noop_dev_select, | 282 | .dev_select = ata_noop_dev_select, |
285 | 283 | ||
286 | .tf_read = sil24_tf_read, | 284 | .tf_read = sil24_tf_read, |
@@ -349,10 +347,12 @@ static struct ata_port_info sil24_port_info[] = { | |||
349 | static inline void sil24_update_tf(struct ata_port *ap) | 347 | static inline void sil24_update_tf(struct ata_port *ap) |
350 | { | 348 | { |
351 | struct sil24_port_priv *pp = ap->private_data; | 349 | struct sil24_port_priv *pp = ap->private_data; |
352 | void *port = (void *)ap->ioaddr.cmd_addr; | 350 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
353 | struct sil24_prb *prb = port; | 351 | struct sil24_prb __iomem *prb = port; |
352 | u8 fis[6 * 4]; | ||
354 | 353 | ||
355 | ata_tf_from_fis(prb->fis, &pp->tf); | 354 | memcpy_fromio(fis, prb->fis, 6 * 4); |
355 | ata_tf_from_fis(fis, &pp->tf); | ||
356 | } | 356 | } |
357 | 357 | ||
358 | static u8 sil24_check_status(struct ata_port *ap) | 358 | static u8 sil24_check_status(struct ata_port *ap) |
@@ -361,12 +361,6 @@ static u8 sil24_check_status(struct ata_port *ap) | |||
361 | return pp->tf.command; | 361 | return pp->tf.command; |
362 | } | 362 | } |
363 | 363 | ||
364 | static u8 sil24_check_err(struct ata_port *ap) | ||
365 | { | ||
366 | struct sil24_port_priv *pp = ap->private_data; | ||
367 | return pp->tf.feature; | ||
368 | } | ||
369 | |||
370 | static int sil24_scr_map[] = { | 364 | static int sil24_scr_map[] = { |
371 | [SCR_CONTROL] = 0, | 365 | [SCR_CONTROL] = 0, |
372 | [SCR_STATUS] = 1, | 366 | [SCR_STATUS] = 1, |
@@ -376,9 +370,9 @@ static int sil24_scr_map[] = { | |||
376 | 370 | ||
377 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) | 371 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) |
378 | { | 372 | { |
379 | void *scr_addr = (void *)ap->ioaddr.scr_addr; | 373 | void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr; |
380 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { | 374 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { |
381 | void *addr; | 375 | void __iomem *addr; |
382 | addr = scr_addr + sil24_scr_map[sc_reg] * 4; | 376 | addr = scr_addr + sil24_scr_map[sc_reg] * 4; |
383 | return readl(scr_addr + sil24_scr_map[sc_reg] * 4); | 377 | return readl(scr_addr + sil24_scr_map[sc_reg] * 4); |
384 | } | 378 | } |
@@ -387,9 +381,9 @@ static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) | |||
387 | 381 | ||
388 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) | 382 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) |
389 | { | 383 | { |
390 | void *scr_addr = (void *)ap->ioaddr.scr_addr; | 384 | void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr; |
391 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { | 385 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { |
392 | void *addr; | 386 | void __iomem *addr; |
393 | addr = scr_addr + sil24_scr_map[sc_reg] * 4; | 387 | addr = scr_addr + sil24_scr_map[sc_reg] * 4; |
394 | writel(val, scr_addr + sil24_scr_map[sc_reg] * 4); | 388 | writel(val, scr_addr + sil24_scr_map[sc_reg] * 4); |
395 | } | 389 | } |
@@ -454,7 +448,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
454 | static int sil24_qc_issue(struct ata_queued_cmd *qc) | 448 | static int sil24_qc_issue(struct ata_queued_cmd *qc) |
455 | { | 449 | { |
456 | struct ata_port *ap = qc->ap; | 450 | struct ata_port *ap = qc->ap; |
457 | void *port = (void *)ap->ioaddr.cmd_addr; | 451 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
458 | struct sil24_port_priv *pp = ap->private_data; | 452 | struct sil24_port_priv *pp = ap->private_data; |
459 | dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block); | 453 | dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block); |
460 | 454 | ||
@@ -467,7 +461,7 @@ static void sil24_irq_clear(struct ata_port *ap) | |||
467 | /* unused */ | 461 | /* unused */ |
468 | } | 462 | } |
469 | 463 | ||
470 | static int __sil24_reset_controller(void *port) | 464 | static int __sil24_reset_controller(void __iomem *port) |
471 | { | 465 | { |
472 | int cnt; | 466 | int cnt; |
473 | u32 tmp; | 467 | u32 tmp; |
@@ -493,7 +487,7 @@ static void sil24_reset_controller(struct ata_port *ap) | |||
493 | { | 487 | { |
494 | printk(KERN_NOTICE DRV_NAME | 488 | printk(KERN_NOTICE DRV_NAME |
495 | " ata%u: resetting controller...\n", ap->id); | 489 | " ata%u: resetting controller...\n", ap->id); |
496 | if (__sil24_reset_controller((void *)ap->ioaddr.cmd_addr)) | 490 | if (__sil24_reset_controller((void __iomem *)ap->ioaddr.cmd_addr)) |
497 | printk(KERN_ERR DRV_NAME | 491 | printk(KERN_ERR DRV_NAME |
498 | " ata%u: failed to reset controller\n", ap->id); | 492 | " ata%u: failed to reset controller\n", ap->id); |
499 | } | 493 | } |
@@ -527,7 +521,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) | |||
527 | { | 521 | { |
528 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); | 522 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); |
529 | struct sil24_port_priv *pp = ap->private_data; | 523 | struct sil24_port_priv *pp = ap->private_data; |
530 | void *port = (void *)ap->ioaddr.cmd_addr; | 524 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
531 | u32 irq_stat, cmd_err, sstatus, serror; | 525 | u32 irq_stat, cmd_err, sstatus, serror; |
532 | 526 | ||
533 | irq_stat = readl(port + PORT_IRQ_STAT); | 527 | irq_stat = readl(port + PORT_IRQ_STAT); |
@@ -574,7 +568,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) | |||
574 | static inline void sil24_host_intr(struct ata_port *ap) | 568 | static inline void sil24_host_intr(struct ata_port *ap) |
575 | { | 569 | { |
576 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); | 570 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); |
577 | void *port = (void *)ap->ioaddr.cmd_addr; | 571 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
578 | u32 slot_stat; | 572 | u32 slot_stat; |
579 | 573 | ||
580 | slot_stat = readl(port + PORT_SLOT_STAT); | 574 | slot_stat = readl(port + PORT_SLOT_STAT); |
@@ -689,7 +683,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
689 | struct ata_port_info *pinfo = &sil24_port_info[board_id]; | 683 | struct ata_port_info *pinfo = &sil24_port_info[board_id]; |
690 | struct ata_probe_ent *probe_ent = NULL; | 684 | struct ata_probe_ent *probe_ent = NULL; |
691 | struct sil24_host_priv *hpriv = NULL; | 685 | struct sil24_host_priv *hpriv = NULL; |
692 | void *host_base = NULL, *port_base = NULL; | 686 | void __iomem *host_base = NULL; |
687 | void __iomem *port_base = NULL; | ||
693 | int i, rc; | 688 | int i, rc; |
694 | 689 | ||
695 | if (!printed_version++) | 690 | if (!printed_version++) |
@@ -771,7 +766,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
771 | writel(0, host_base + HOST_CTRL); | 766 | writel(0, host_base + HOST_CTRL); |
772 | 767 | ||
773 | for (i = 0; i < probe_ent->n_ports; i++) { | 768 | for (i = 0; i < probe_ent->n_ports; i++) { |
774 | void *port = port_base + i * PORT_REGS_SIZE; | 769 | void __iomem *port = port_base + i * PORT_REGS_SIZE; |
775 | unsigned long portu = (unsigned long)port; | 770 | unsigned long portu = (unsigned long)port; |
776 | u32 tmp; | 771 | u32 tmp; |
777 | int cnt; | 772 | int cnt; |
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index e0f9570bc6dd..46208f52d0e1 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c | |||
@@ -84,6 +84,8 @@ | |||
84 | /* Port stride */ | 84 | /* Port stride */ |
85 | #define K2_SATA_PORT_OFFSET 0x100 | 85 | #define K2_SATA_PORT_OFFSET 0x100 |
86 | 86 | ||
87 | static u8 k2_stat_check_status(struct ata_port *ap); | ||
88 | |||
87 | 89 | ||
88 | static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) | 90 | static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) |
89 | { | 91 | { |
@@ -136,16 +138,24 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
136 | static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 138 | static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
137 | { | 139 | { |
138 | struct ata_ioports *ioaddr = &ap->ioaddr; | 140 | struct ata_ioports *ioaddr = &ap->ioaddr; |
139 | u16 nsect, lbal, lbam, lbah; | 141 | u16 nsect, lbal, lbam, lbah, feature; |
140 | 142 | ||
141 | nsect = tf->nsect = readw(ioaddr->nsect_addr); | 143 | tf->command = k2_stat_check_status(ap); |
142 | lbal = tf->lbal = readw(ioaddr->lbal_addr); | ||
143 | lbam = tf->lbam = readw(ioaddr->lbam_addr); | ||
144 | lbah = tf->lbah = readw(ioaddr->lbah_addr); | ||
145 | tf->device = readw(ioaddr->device_addr); | 144 | tf->device = readw(ioaddr->device_addr); |
145 | feature = readw(ioaddr->error_addr); | ||
146 | nsect = readw(ioaddr->nsect_addr); | ||
147 | lbal = readw(ioaddr->lbal_addr); | ||
148 | lbam = readw(ioaddr->lbam_addr); | ||
149 | lbah = readw(ioaddr->lbah_addr); | ||
150 | |||
151 | tf->feature = feature; | ||
152 | tf->nsect = nsect; | ||
153 | tf->lbal = lbal; | ||
154 | tf->lbam = lbam; | ||
155 | tf->lbah = lbah; | ||
146 | 156 | ||
147 | if (tf->flags & ATA_TFLAG_LBA48) { | 157 | if (tf->flags & ATA_TFLAG_LBA48) { |
148 | tf->hob_feature = readw(ioaddr->error_addr) >> 8; | 158 | tf->hob_feature = feature >> 8; |
149 | tf->hob_nsect = nsect >> 8; | 159 | tf->hob_nsect = nsect >> 8; |
150 | tf->hob_lbal = lbal >> 8; | 160 | tf->hob_lbal = lbal >> 8; |
151 | tf->hob_lbam = lbam >> 8; | 161 | tf->hob_lbam = lbam >> 8; |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index 028d4ab15c01..3766afe4b288 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -153,16 +153,24 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
153 | static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 153 | static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
154 | { | 154 | { |
155 | struct ata_ioports *ioaddr = &ap->ioaddr; | 155 | struct ata_ioports *ioaddr = &ap->ioaddr; |
156 | u16 nsect, lbal, lbam, lbah; | 156 | u16 nsect, lbal, lbam, lbah, feature; |
157 | 157 | ||
158 | nsect = tf->nsect = readw(ioaddr->nsect_addr); | 158 | tf->command = ata_check_status(ap); |
159 | lbal = tf->lbal = readw(ioaddr->lbal_addr); | ||
160 | lbam = tf->lbam = readw(ioaddr->lbam_addr); | ||
161 | lbah = tf->lbah = readw(ioaddr->lbah_addr); | ||
162 | tf->device = readw(ioaddr->device_addr); | 159 | tf->device = readw(ioaddr->device_addr); |
160 | feature = readw(ioaddr->error_addr); | ||
161 | nsect = readw(ioaddr->nsect_addr); | ||
162 | lbal = readw(ioaddr->lbal_addr); | ||
163 | lbam = readw(ioaddr->lbam_addr); | ||
164 | lbah = readw(ioaddr->lbah_addr); | ||
165 | |||
166 | tf->feature = feature; | ||
167 | tf->nsect = nsect; | ||
168 | tf->lbal = lbal; | ||
169 | tf->lbam = lbam; | ||
170 | tf->lbah = lbah; | ||
163 | 171 | ||
164 | if (tf->flags & ATA_TFLAG_LBA48) { | 172 | if (tf->flags & ATA_TFLAG_LBA48) { |
165 | tf->hob_feature = readb(ioaddr->error_addr); | 173 | tf->hob_feature = feature >> 8; |
166 | tf->hob_nsect = nsect >> 8; | 174 | tf->hob_nsect = nsect >> 8; |
167 | tf->hob_lbal = lbal >> 8; | 175 | tf->hob_lbal = lbal >> 8; |
168 | tf->hob_lbam = lbam >> 8; | 176 | tf->hob_lbam = lbam >> 8; |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index fd56b7ec88b6..d86d5c26061d 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -49,6 +49,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */ | |||
49 | #include <linux/seq_file.h> | 49 | #include <linux/seq_file.h> |
50 | #include <linux/blkdev.h> | 50 | #include <linux/blkdev.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/scatterlist.h> | ||
52 | 53 | ||
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include <scsi/scsi_dbg.h> | 55 | #include <scsi/scsi_dbg.h> |
@@ -104,8 +105,8 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF; | |||
104 | 105 | ||
105 | #define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ | 106 | #define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ |
106 | 107 | ||
107 | static int sg_add(struct class_device *); | 108 | static int sg_add(struct class_device *, struct class_interface *); |
108 | static void sg_remove(struct class_device *); | 109 | static void sg_remove(struct class_device *, struct class_interface *); |
109 | 110 | ||
110 | static Scsi_Request *dummy_cmdp; /* only used for sizeof */ | 111 | static Scsi_Request *dummy_cmdp; /* only used for sizeof */ |
111 | 112 | ||
@@ -1506,7 +1507,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1506 | } | 1507 | } |
1507 | 1508 | ||
1508 | static int | 1509 | static int |
1509 | sg_add(struct class_device *cl_dev) | 1510 | sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) |
1510 | { | 1511 | { |
1511 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1512 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); |
1512 | struct gendisk *disk; | 1513 | struct gendisk *disk; |
@@ -1550,7 +1551,7 @@ sg_add(struct class_device *cl_dev) | |||
1550 | if (sg_sysfs_valid) { | 1551 | if (sg_sysfs_valid) { |
1551 | struct class_device * sg_class_member; | 1552 | struct class_device * sg_class_member; |
1552 | 1553 | ||
1553 | sg_class_member = class_device_create(sg_sysfs_class, | 1554 | sg_class_member = class_device_create(sg_sysfs_class, NULL, |
1554 | MKDEV(SCSI_GENERIC_MAJOR, k), | 1555 | MKDEV(SCSI_GENERIC_MAJOR, k), |
1555 | cl_dev->dev, "%s", | 1556 | cl_dev->dev, "%s", |
1556 | disk->disk_name); | 1557 | disk->disk_name); |
@@ -1582,7 +1583,7 @@ out: | |||
1582 | } | 1583 | } |
1583 | 1584 | ||
1584 | static void | 1585 | static void |
1585 | sg_remove(struct class_device *cl_dev) | 1586 | sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) |
1586 | { | 1587 | { |
1587 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1588 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); |
1588 | Sg_device *sdp = NULL; | 1589 | Sg_device *sdp = NULL; |
@@ -1886,13 +1887,17 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages, | |||
1886 | int i; | 1887 | int i; |
1887 | 1888 | ||
1888 | for (i=0; i < nr_pages; i++) { | 1889 | for (i=0; i < nr_pages; i++) { |
1889 | if (dirtied && !PageReserved(sgl[i].page)) | 1890 | struct page *page = sgl[i].page; |
1890 | SetPageDirty(sgl[i].page); | 1891 | |
1891 | /* unlock_page(sgl[i].page); */ | 1892 | /* XXX: just for debug. Remove when PageReserved is removed */ |
1893 | BUG_ON(PageReserved(page)); | ||
1894 | if (dirtied) | ||
1895 | SetPageDirty(page); | ||
1896 | /* unlock_page(page); */ | ||
1892 | /* FIXME: cache flush missing for rw==READ | 1897 | /* FIXME: cache flush missing for rw==READ |
1893 | * FIXME: call the correct reference counting function | 1898 | * FIXME: call the correct reference counting function |
1894 | */ | 1899 | */ |
1895 | page_cache_release(sgl[i].page); | 1900 | page_cache_release(page); |
1896 | } | 1901 | } |
1897 | 1902 | ||
1898 | return 0; | 1903 | return 0; |
@@ -1992,9 +1997,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1992 | if (!p) | 1997 | if (!p) |
1993 | break; | 1998 | break; |
1994 | } | 1999 | } |
1995 | sclp->page = virt_to_page(p); | 2000 | sg_set_buf(sclp, p, ret_sz); |
1996 | sclp->offset = offset_in_page(p); | ||
1997 | sclp->length = ret_sz; | ||
1998 | 2001 | ||
1999 | SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", | 2002 | SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", |
2000 | k, sg_scatg2virt(sclp), ret_sz)); | 2003 | k, sg_scatg2virt(sclp), ret_sz)); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 927d700f0073..da9766283bd7 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -4377,7 +4377,7 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) | |||
4377 | snprintf(name, 10, "%s%s%s", rew ? "n" : "", | 4377 | snprintf(name, 10, "%s%s%s", rew ? "n" : "", |
4378 | STp->disk->disk_name, st_formats[i]); | 4378 | STp->disk->disk_name, st_formats[i]); |
4379 | st_class_member = | 4379 | st_class_member = |
4380 | class_device_create(st_sysfs_class, | 4380 | class_device_create(st_sysfs_class, NULL, |
4381 | MKDEV(SCSI_TAPE_MAJOR, | 4381 | MKDEV(SCSI_TAPE_MAJOR, |
4382 | TAPE_MINOR(dev_num, mode, rew)), | 4382 | TAPE_MINOR(dev_num, mode, rew)), |
4383 | &STp->device->sdev_gendev, "%s", name); | 4383 | &STp->device->sdev_gendev, "%s", name); |
@@ -4526,12 +4526,16 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p | |||
4526 | int i; | 4526 | int i; |
4527 | 4527 | ||
4528 | for (i=0; i < nr_pages; i++) { | 4528 | for (i=0; i < nr_pages; i++) { |
4529 | if (dirtied && !PageReserved(sgl[i].page)) | 4529 | struct page *page = sgl[i].page; |
4530 | SetPageDirty(sgl[i].page); | 4530 | |
4531 | /* XXX: just for debug. Remove when PageReserved is removed */ | ||
4532 | BUG_ON(PageReserved(page)); | ||
4533 | if (dirtied) | ||
4534 | SetPageDirty(page); | ||
4531 | /* FIXME: cache flush missing for rw==READ | 4535 | /* FIXME: cache flush missing for rw==READ |
4532 | * FIXME: call the correct reference counting function | 4536 | * FIXME: call the correct reference counting function |
4533 | */ | 4537 | */ |
4534 | page_cache_release(sgl[i].page); | 4538 | page_cache_release(page); |
4535 | } | 4539 | } |
4536 | 4540 | ||
4537 | return 0; | 4541 | return 0; |
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c index 5a51051e31f0..b131432c677d 100644 --- a/drivers/scsi/zalon.c +++ b/drivers/scsi/zalon.c | |||
@@ -88,7 +88,7 @@ zalon_probe(struct parisc_device *dev) | |||
88 | struct gsc_irq gsc_irq; | 88 | struct gsc_irq gsc_irq; |
89 | u32 zalon_vers; | 89 | u32 zalon_vers; |
90 | int error = -ENODEV; | 90 | int error = -ENODEV; |
91 | void __iomem *zalon = ioremap(dev->hpa, 4096); | 91 | void __iomem *zalon = ioremap(dev->hpa.start, 4096); |
92 | void __iomem *io_port = zalon + GSC_SCSI_ZALON_OFFSET; | 92 | void __iomem *io_port = zalon + GSC_SCSI_ZALON_OFFSET; |
93 | static int unit = 0; | 93 | static int unit = 0; |
94 | struct Scsi_Host *host; | 94 | struct Scsi_Host *host; |
@@ -127,7 +127,7 @@ zalon_probe(struct parisc_device *dev) | |||
127 | device.chip = zalon720_chip; | 127 | device.chip = zalon720_chip; |
128 | device.host_id = 7; | 128 | device.host_id = 7; |
129 | device.dev = &dev->dev; | 129 | device.dev = &dev->dev; |
130 | device.slot.base = dev->hpa + GSC_SCSI_ZALON_OFFSET; | 130 | device.slot.base = dev->hpa.start + GSC_SCSI_ZALON_OFFSET; |
131 | device.slot.base_v = io_port; | 131 | device.slot.base_v = io_port; |
132 | device.slot.irq = dev->irq; | 132 | device.slot.irq = dev->irq; |
133 | device.differential = 2; | 133 | device.differential = 2; |