aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ahci.c55
-rw-r--r--drivers/scsi/arm/scsi.h6
-rw-r--r--drivers/scsi/ata_piix.c15
-rw-r--r--drivers/scsi/ch.c2
-rw-r--r--drivers/scsi/dec_esp.c2
-rw-r--r--drivers/scsi/hosts.c1
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c9
-rw-r--r--drivers/scsi/ibmvscsi/iseries_vscsi.c8
-rw-r--r--drivers/scsi/ide-scsi.c18
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/lasi700.c6
-rw-r--r--drivers/scsi/libata-core.c163
-rw-r--r--drivers/scsi/libata-scsi.c813
-rw-r--r--drivers/scsi/libata.h6
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c10
-rw-r--r--drivers/scsi/mesh.c2
-rw-r--r--drivers/scsi/osst.c2
-rw-r--r--drivers/scsi/pdc_adma.c46
-rw-r--r--drivers/scsi/sata_mv.c41
-rw-r--r--drivers/scsi/sata_nv.c3
-rw-r--r--drivers/scsi/sata_promise.c23
-rw-r--r--drivers/scsi/sata_qstor.c27
-rw-r--r--drivers/scsi/sata_sil.c7
-rw-r--r--drivers/scsi/sata_sil24.c76
-rw-r--r--drivers/scsi/sata_sis.c13
-rw-r--r--drivers/scsi/sata_svw.c25
-rw-r--r--drivers/scsi/sata_sx4.c13
-rw-r--r--drivers/scsi/sata_uli.c5
-rw-r--r--drivers/scsi/sata_via.c38
-rw-r--r--drivers/scsi/sata_vsc.c23
-rw-r--r--drivers/scsi/scsi_transport_fc.c1
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c3
-rw-r--r--drivers/scsi/sg.c27
-rw-r--r--drivers/scsi/st.c12
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c3
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h2
-rw-r--r--drivers/scsi/zalon.c4
37 files changed, 1013 insertions, 499 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index fe8187d6f58b..e2a5657d5fdb 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -41,6 +41,7 @@
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/device.h>
44#include "scsi.h" 45#include "scsi.h"
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
@@ -192,7 +193,6 @@ static void ahci_port_stop(struct ata_port *ap);
192static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); 193static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
193static void ahci_qc_prep(struct ata_queued_cmd *qc); 194static void ahci_qc_prep(struct ata_queued_cmd *qc);
194static u8 ahci_check_status(struct ata_port *ap); 195static u8 ahci_check_status(struct ata_port *ap);
195static u8 ahci_check_err(struct ata_port *ap);
196static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); 196static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
197static void ahci_remove_one (struct pci_dev *pdev); 197static void ahci_remove_one (struct pci_dev *pdev);
198 198
@@ -221,7 +221,6 @@ static const struct ata_port_operations ahci_ops = {
221 221
222 .check_status = ahci_check_status, 222 .check_status = ahci_check_status,
223 .check_altstatus = ahci_check_status, 223 .check_altstatus = ahci_check_status,
224 .check_err = ahci_check_err,
225 .dev_select = ata_noop_dev_select, 224 .dev_select = ata_noop_dev_select,
226 225
227 .tf_read = ahci_tf_read, 226 .tf_read = ahci_tf_read,
@@ -458,13 +457,6 @@ static u8 ahci_check_status(struct ata_port *ap)
458 return readl(mmio + PORT_TFDATA) & 0xFF; 457 return readl(mmio + PORT_TFDATA) & 0xFF;
459} 458}
460 459
461static 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
468static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) 460static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
469{ 461{
470 struct ahci_port_priv *pp = ap->private_data; 462 struct ahci_port_priv *pp = ap->private_data;
@@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap)
609 * not being called from the SCSI EH. 601 * not being called from the SCSI EH.
610 */ 602 */
611 qc->scsidone = scsi_finish_command; 603 qc->scsidone = scsi_finish_command;
612 ata_qc_complete(qc, ATA_ERR); 604 ata_qc_complete(qc, AC_ERR_OTHER);
613 } 605 }
614 606
615 spin_unlock_irqrestore(&host_set->lock, flags); 607 spin_unlock_irqrestore(&host_set->lock, flags);
@@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
638 if (status & PORT_IRQ_FATAL) { 630 if (status & PORT_IRQ_FATAL) {
639 ahci_intr_error(ap, status); 631 ahci_intr_error(ap, status);
640 if (qc) 632 if (qc)
641 ata_qc_complete(qc, ATA_ERR); 633 ata_qc_complete(qc, AC_ERR_OTHER);
642 } 634 }
643 635
644 return 1; 636 return 1;
@@ -683,10 +675,10 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
683 if (!ahci_host_intr(ap, qc)) 675 if (!ahci_host_intr(ap, qc))
684 if (ata_ratelimit()) { 676 if (ata_ratelimit()) {
685 struct pci_dev *pdev = 677 struct pci_dev *pdev =
686 to_pci_dev(ap->host_set->dev); 678 to_pci_dev(ap->host_set->dev);
687 printk(KERN_WARNING 679 dev_printk(KERN_WARNING, &pdev->dev,
688 "ahci(%s): unhandled interrupt on port %u\n", 680 "unhandled interrupt on port %u\n",
689 pci_name(pdev), i); 681 i);
690 } 682 }
691 683
692 VPRINTK("port %u\n", i); 684 VPRINTK("port %u\n", i);
@@ -694,10 +686,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
694 VPRINTK("port %u (no irq)\n", i); 686 VPRINTK("port %u (no irq)\n", i);
695 if (ata_ratelimit()) { 687 if (ata_ratelimit()) {
696 struct pci_dev *pdev = 688 struct pci_dev *pdev =
697 to_pci_dev(ap->host_set->dev); 689 to_pci_dev(ap->host_set->dev);
698 printk(KERN_WARNING 690 dev_printk(KERN_WARNING, &pdev->dev,
699 "ahci(%s): interrupt on disabled port %u\n", 691 "interrupt on disabled port %u\n", i);
700 pci_name(pdev), i);
701 } 692 }
702 } 693 }
703 694
@@ -769,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
769 760
770 tmp = readl(mmio + HOST_CTL); 761 tmp = readl(mmio + HOST_CTL);
771 if (tmp & HOST_RESET) { 762 if (tmp & HOST_RESET) {
772 printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", 763 dev_printk(KERN_ERR, &pdev->dev,
773 pci_name(pdev), tmp); 764 "controller reset failed (0x%x)\n", tmp);
774 return -EIO; 765 return -EIO;
775 } 766 }
776 767
@@ -798,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
798 if (rc) { 789 if (rc) {
799 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 790 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
800 if (rc) { 791 if (rc) {
801 printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", 792 dev_printk(KERN_ERR, &pdev->dev,
802 pci_name(pdev)); 793 "64-bit DMA enable failed\n");
803 return rc; 794 return rc;
804 } 795 }
805 } 796 }
806 } else { 797 } else {
807 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 798 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
808 if (rc) { 799 if (rc) {
809 printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", 800 dev_printk(KERN_ERR, &pdev->dev,
810 pci_name(pdev)); 801 "32-bit DMA enable failed\n");
811 return rc; 802 return rc;
812 } 803 }
813 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 804 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
814 if (rc) { 805 if (rc) {
815 printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", 806 dev_printk(KERN_ERR, &pdev->dev,
816 pci_name(pdev)); 807 "32-bit consistent DMA enable failed\n");
817 return rc; 808 return rc;
818 } 809 }
819 } 810 }
@@ -916,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
916 else 907 else
917 scc_s = "unknown"; 908 scc_s = "unknown";
918 909
919 printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x " 910 dev_printk(KERN_INFO, &pdev->dev,
911 "AHCI %02x%02x.%02x%02x "
920 "%u slots %u ports %s Gbps 0x%x impl %s mode\n" 912 "%u slots %u ports %s Gbps 0x%x impl %s mode\n"
921 , 913 ,
922 pci_name(pdev),
923 914
924 (vers >> 24) & 0xff, 915 (vers >> 24) & 0xff,
925 (vers >> 16) & 0xff, 916 (vers >> 16) & 0xff,
@@ -932,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
932 impl, 923 impl,
933 scc_s); 924 scc_s);
934 925
935 printk(KERN_INFO DRV_NAME "(%s) flags: " 926 dev_printk(KERN_INFO, &pdev->dev,
927 "flags: "
936 "%s%s%s%s%s%s" 928 "%s%s%s%s%s%s"
937 "%s%s%s%s%s%s%s\n" 929 "%s%s%s%s%s%s%s\n"
938 , 930 ,
939 pci_name(pdev),
940 931
941 cap & (1 << 31) ? "64bit " : "", 932 cap & (1 << 31) ? "64bit " : "",
942 cap & (1 << 30) ? "ncq " : "", 933 cap & (1 << 30) ? "ncq " : "",
@@ -969,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
969 VPRINTK("ENTER\n"); 960 VPRINTK("ENTER\n");
970 961
971 if (!printed_version++) 962 if (!printed_version++)
972 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 963 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
973 964
974 rc = pci_enable_device(pdev); 965 rc = pci_enable_device(pdev);
975 if (rc) 966 if (rc)
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/ata_piix.c b/drivers/scsi/ata_piix.c
index be021478f416..7f8aa1b552ce 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -45,6 +45,7 @@
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/delay.h> 47#include <linux/delay.h>
48#include <linux/device.h>
48#include "scsi.h" 49#include "scsi.h"
49#include <scsi/scsi_host.h> 50#include <scsi/scsi_host.h>
50#include <linux/libata.h> 51#include <linux/libata.h>
@@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
621{ 622{
622 static int printed_version; 623 static int printed_version;
623 struct ata_port_info *port_info[2]; 624 struct ata_port_info *port_info[2];
624 unsigned int combined = 0, n_ports = 1; 625 unsigned int combined = 0;
625 unsigned int pata_chan = 0, sata_chan = 0; 626 unsigned int pata_chan = 0, sata_chan = 0;
626 627
627 if (!printed_version++) 628 if (!printed_version++)
628 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 629 dev_printk(KERN_DEBUG, &pdev->dev,
630 "version " DRV_VERSION "\n");
629 631
630 /* no hotplugging support (FIXME) */ 632 /* no hotplugging support (FIXME) */
631 if (!in_module_init) 633 if (!in_module_init)
632 return -ENODEV; 634 return -ENODEV;
633 635
634 port_info[0] = &piix_port_info[ent->driver_data]; 636 port_info[0] = &piix_port_info[ent->driver_data];
635 port_info[1] = NULL; 637 port_info[1] = &piix_port_info[ent->driver_data];
636 638
637 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { 639 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) {
638 u8 tmp; 640 u8 tmp;
@@ -670,12 +672,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
670 port_info[sata_chan] = &piix_port_info[ent->driver_data]; 672 port_info[sata_chan] = &piix_port_info[ent->driver_data];
671 port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS; 673 port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS;
672 port_info[pata_chan] = &piix_port_info[ich5_pata]; 674 port_info[pata_chan] = &piix_port_info[ich5_pata];
673 n_ports++;
674 675
675 printk(KERN_WARNING DRV_NAME ": combined mode detected\n"); 676 dev_printk(KERN_WARNING, &pdev->dev,
677 "combined mode detected (p=%u, s=%u)\n",
678 pata_chan, sata_chan);
676 } 679 }
677 680
678 return ata_pci_init_one(pdev, port_info, n_ports); 681 return ata_pci_init_one(pdev, port_info, 2);
679} 682}
680 683
681static int __init piix_init(void) 684static int __init piix_init(void)
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 833241508070..ccbbae2bf478 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 2d7bde693d96..256d6baf8df3 100644
--- a/drivers/scsi/dec_esp.c
+++ b/drivers/scsi/dec_esp.c
@@ -230,7 +230,7 @@ static int dec_esp_detect(Scsi_Host_Template * tpnt)
230 mem_start = get_tc_base_addr(slot); 230 mem_start = get_tc_base_addr(slot);
231 231
232 /* Store base addr into esp struct */ 232 /* Store base addr into esp struct */
233 esp->slot = mem_start; 233 esp->slot = CPHYSADDR(mem_start);
234 234
235 esp->dregs = 0; 235 esp->dregs = 0;
236 esp->eregs = (void *)CKSEG1ADDR(mem_start + 236 esp->eregs = (void *)CKSEG1ADDR(mem_start +
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 0d48c9ceebd3..5b9c2c5a7f0e 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/completion.h> 31#include <linux/completion.h>
32#include <linux/transport_class.h> 32#include <linux/transport_class.h>
33#include <linux/platform_device.h>
33 34
34#include <scsi/scsi_device.h> 35#include <scsi/scsi_device.h>
35#include <scsi/scsi_host.h> 36#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index ff25210b00ba..822b9fa706f3 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1543,13 +1543,16 @@ static struct vio_device_id ibmvscsi_device_table[] __devinitdata = {
1543 {"vscsi", "IBM,v-scsi"}, 1543 {"vscsi", "IBM,v-scsi"},
1544 { "", "" } 1544 { "", "" }
1545}; 1545};
1546
1547MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table); 1546MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table);
1547
1548static struct vio_driver ibmvscsi_driver = { 1548static struct vio_driver ibmvscsi_driver = {
1549 .name = "ibmvscsi",
1550 .id_table = ibmvscsi_device_table, 1549 .id_table = ibmvscsi_device_table,
1551 .probe = ibmvscsi_probe, 1550 .probe = ibmvscsi_probe,
1552 .remove = ibmvscsi_remove 1551 .remove = ibmvscsi_remove,
1552 .driver = {
1553 .name = "ibmvscsi",
1554 .owner = THIS_MODULE,
1555 }
1553}; 1556};
1554 1557
1555int __init ibmvscsi_module_init(void) 1558int __init ibmvscsi_module_init(void)
diff --git a/drivers/scsi/ibmvscsi/iseries_vscsi.c b/drivers/scsi/ibmvscsi/iseries_vscsi.c
index e9202f2a8276..1045872b0175 100644
--- a/drivers/scsi/ibmvscsi/iseries_vscsi.c
+++ b/drivers/scsi/ibmvscsi/iseries_vscsi.c
@@ -28,10 +28,10 @@
28 * hypervisor system or a converged hypervisor system. 28 * hypervisor system or a converged hypervisor system.
29 */ 29 */
30 30
31#include <asm/iSeries/vio.h> 31#include <asm/iseries/vio.h>
32#include <asm/iSeries/HvLpEvent.h> 32#include <asm/iseries/hv_lp_event.h>
33#include <asm/iSeries/HvTypes.h> 33#include <asm/iseries/hv_types.h>
34#include <asm/iSeries/HvLpConfig.h> 34#include <asm/iseries/hv_lp_config.h>
35#include <asm/vio.h> 35#include <asm/vio.h>
36#include <linux/device.h> 36#include <linux/device.h>
37#include "ibmvscsi.h" 37#include "ibmvscsi.h"
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 01f8ebf8a42e..f04f3289938d 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -184,13 +184,16 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
184 unsigned long flags; 184 unsigned long flags;
185 185
186 local_irq_save(flags); 186 local_irq_save(flags);
187 buf = kmap_atomic(pc->sg->page, KM_IRQ0) + pc->sg->offset; 187 buf = kmap_atomic(pc->sg->page, KM_IRQ0) +
188 drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count); 188 pc->sg->offset;
189 drive->hwif->atapi_input_bytes(drive,
190 buf + pc->b_count, count);
189 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); 191 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
190 local_irq_restore(flags); 192 local_irq_restore(flags);
191 } else { 193 } else {
192 buf = page_address(pc->sg->page) + pc->sg->offset; 194 buf = page_address(pc->sg->page) + pc->sg->offset;
193 drive->hwif->atapi_input_bytes(drive, buf + pc->b_count, count); 195 drive->hwif->atapi_input_bytes(drive,
196 buf + pc->b_count, count);
194 } 197 }
195 bcount -= count; pc->b_count += count; 198 bcount -= count; pc->b_count += count;
196 if (pc->b_count == pc->sg->length) { 199 if (pc->b_count == pc->sg->length) {
@@ -216,13 +219,16 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
216 unsigned long flags; 219 unsigned long flags;
217 220
218 local_irq_save(flags); 221 local_irq_save(flags);
219 buf = kmap_atomic(pc->sg->page, KM_IRQ0) + pc->sg->offset; 222 buf = kmap_atomic(pc->sg->page, KM_IRQ0) +
220 drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count); 223 pc->sg->offset;
224 drive->hwif->atapi_output_bytes(drive,
225 buf + pc->b_count, count);
221 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); 226 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
222 local_irq_restore(flags); 227 local_irq_restore(flags);
223 } else { 228 } else {
224 buf = page_address(pc->sg->page) + pc->sg->offset; 229 buf = page_address(pc->sg->page) + pc->sg->offset;
225 drive->hwif->atapi_output_bytes(drive, buf + pc->b_count, count); 230 drive->hwif->atapi_output_bytes(drive,
231 buf + pc->b_count, count);
226 } 232 }
227 bcount -= count; pc->b_count += count; 233 bcount -= count; pc->b_count += count;
228 if (pc->b_count == pc->sg->length) { 234 if (pc->b_count == pc->sg->length) {
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);
98static int __init 98static int __init
99lasi700_probe(struct parisc_device *dev) 99lasi700_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
170static struct parisc_driver lasi700_driver = { 168static 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 f53d7b8ac33f..ff18fa7044c5 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"
@@ -294,28 +295,6 @@ void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
294} 295}
295 296
296/** 297/**
297 * ata_exec - issue ATA command to host controller
298 * @ap: port to which command is being issued
299 * @tf: ATA taskfile register set
300 *
301 * Issues PIO/MMIO write to ATA command register, with proper
302 * synchronization with interrupt handler / other threads.
303 *
304 * LOCKING:
305 * Obtains host_set lock.
306 */
307
308static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
309{
310 unsigned long flags;
311
312 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
313 spin_lock_irqsave(&ap->host_set->lock, flags);
314 ap->ops->exec_command(ap, tf);
315 spin_unlock_irqrestore(&ap->host_set->lock, flags);
316}
317
318/**
319 * ata_tf_to_host - issue ATA taskfile to host controller 298 * ata_tf_to_host - issue ATA taskfile to host controller
320 * @ap: port to which command is being issued 299 * @ap: port to which command is being issued
321 * @tf: ATA taskfile register set 300 * @tf: ATA taskfile register set
@@ -325,30 +304,11 @@ static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
325 * other threads. 304 * other threads.
326 * 305 *
327 * LOCKING: 306 * LOCKING:
328 * Obtains host_set lock.
329 */
330
331static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf)
332{
333 ap->ops->tf_load(ap, tf);
334
335 ata_exec(ap, tf);
336}
337
338/**
339 * ata_tf_to_host_nolock - issue ATA taskfile to host controller
340 * @ap: port to which command is being issued
341 * @tf: ATA taskfile register set
342 *
343 * Issues ATA taskfile register set to ATA host controller,
344 * with proper synchronization with interrupt handler and
345 * other threads.
346 *
347 * LOCKING:
348 * spin_lock_irqsave(host_set lock) 307 * spin_lock_irqsave(host_set lock)
349 */ 308 */
350 309
351void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf) 310static inline void ata_tf_to_host(struct ata_port *ap,
311 const struct ata_taskfile *tf)
352{ 312{
353 ap->ops->tf_load(ap, tf); 313 ap->ops->tf_load(ap, tf);
354 ap->ops->exec_command(ap, tf); 314 ap->ops->exec_command(ap, tf);
@@ -370,6 +330,8 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf)
370{ 330{
371 struct ata_ioports *ioaddr = &ap->ioaddr; 331 struct ata_ioports *ioaddr = &ap->ioaddr;
372 332
333 tf->command = ata_check_status(ap);
334 tf->feature = inb(ioaddr->error_addr);
373 tf->nsect = inb(ioaddr->nsect_addr); 335 tf->nsect = inb(ioaddr->nsect_addr);
374 tf->lbal = inb(ioaddr->lbal_addr); 336 tf->lbal = inb(ioaddr->lbal_addr);
375 tf->lbam = inb(ioaddr->lbam_addr); 337 tf->lbam = inb(ioaddr->lbam_addr);
@@ -402,6 +364,8 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf)
402{ 364{
403 struct ata_ioports *ioaddr = &ap->ioaddr; 365 struct ata_ioports *ioaddr = &ap->ioaddr;
404 366
367 tf->command = ata_check_status(ap);
368 tf->feature = readb((void __iomem *)ioaddr->error_addr);
405 tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); 369 tf->nsect = readb((void __iomem *)ioaddr->nsect_addr);
406 tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); 370 tf->lbal = readb((void __iomem *)ioaddr->lbal_addr);
407 tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); 371 tf->lbam = readb((void __iomem *)ioaddr->lbam_addr);
@@ -522,30 +486,6 @@ u8 ata_altstatus(struct ata_port *ap)
522 486
523 487
524/** 488/**
525 * ata_chk_err - Read device error reg
526 * @ap: port where the device is
527 *
528 * Reads ATA taskfile error register for
529 * currently-selected device and return its value.
530 *
531 * Note: may NOT be used as the check_err() entry in
532 * ata_port_operations.
533 *
534 * LOCKING:
535 * Inherited from caller.
536 */
537u8 ata_chk_err(struct ata_port *ap)
538{
539 if (ap->ops->check_err)
540 return ap->ops->check_err(ap);
541
542 if (ap->flags & ATA_FLAG_MMIO) {
543 return readb((void __iomem *) ap->ioaddr.error_addr);
544 }
545 return inb(ap->ioaddr.error_addr);
546}
547
548/**
549 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure 489 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
550 * @tf: Taskfile to convert 490 * @tf: Taskfile to convert
551 * @fis: Buffer into which data will output 491 * @fis: Buffer into which data will output
@@ -897,8 +837,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
897 837
898 memset(&tf, 0, sizeof(tf)); 838 memset(&tf, 0, sizeof(tf));
899 839
900 err = ata_chk_err(ap);
901 ap->ops->tf_read(ap, &tf); 840 ap->ops->tf_read(ap, &tf);
841 err = tf.feature;
902 842
903 dev->class = ATA_DEV_NONE; 843 dev->class = ATA_DEV_NONE;
904 844
@@ -1135,7 +1075,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1135 unsigned int major_version; 1075 unsigned int major_version;
1136 u16 tmp; 1076 u16 tmp;
1137 unsigned long xfer_modes; 1077 unsigned long xfer_modes;
1138 u8 status;
1139 unsigned int using_edd; 1078 unsigned int using_edd;
1140 DECLARE_COMPLETION(wait); 1079 DECLARE_COMPLETION(wait);
1141 struct ata_queued_cmd *qc; 1080 struct ata_queued_cmd *qc;
@@ -1189,8 +1128,11 @@ retry:
1189 else 1128 else
1190 wait_for_completion(&wait); 1129 wait_for_completion(&wait);
1191 1130
1192 status = ata_chk_status(ap); 1131 spin_lock_irqsave(&ap->host_set->lock, flags);
1193 if (status & ATA_ERR) { 1132 ap->ops->tf_read(ap, &qc->tf);
1133 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1134
1135 if (qc->tf.command & ATA_ERR) {
1194 /* 1136 /*
1195 * arg! EDD works for all test cases, but seems to return 1137 * arg! EDD works for all test cases, but seems to return
1196 * the ATA signature for some ATAPI devices. Until the 1138 * the ATA signature for some ATAPI devices. Until the
@@ -1203,7 +1145,7 @@ retry:
1203 * to have this problem. 1145 * to have this problem.
1204 */ 1146 */
1205 if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { 1147 if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) {
1206 u8 err = ata_chk_err(ap); 1148 u8 err = qc->tf.feature;
1207 if (err & ATA_ABORTED) { 1149 if (err & ATA_ABORTED) {
1208 dev->class = ATA_DEV_ATAPI; 1150 dev->class = ATA_DEV_ATAPI;
1209 qc->cursg = 0; 1151 qc->cursg = 0;
@@ -1929,12 +1871,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1929 * 1871 *
1930 * LOCKING: 1872 * LOCKING:
1931 * PCI/etc. bus probe sem. 1873 * PCI/etc. bus probe sem.
1874 * Obtains host_set lock.
1932 * 1875 *
1933 */ 1876 */
1934 1877
1935static unsigned int ata_bus_edd(struct ata_port *ap) 1878static unsigned int ata_bus_edd(struct ata_port *ap)
1936{ 1879{
1937 struct ata_taskfile tf; 1880 struct ata_taskfile tf;
1881 unsigned long flags;
1938 1882
1939 /* set up execute-device-diag (bus reset) taskfile */ 1883 /* set up execute-device-diag (bus reset) taskfile */
1940 /* also, take interrupts to a known state (disabled) */ 1884 /* also, take interrupts to a known state (disabled) */
@@ -1945,7 +1889,9 @@ static unsigned int ata_bus_edd(struct ata_port *ap)
1945 tf.protocol = ATA_PROT_NODATA; 1889 tf.protocol = ATA_PROT_NODATA;
1946 1890
1947 /* do bus reset */ 1891 /* do bus reset */
1892 spin_lock_irqsave(&ap->host_set->lock, flags);
1948 ata_tf_to_host(ap, &tf); 1893 ata_tf_to_host(ap, &tf);
1894 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1949 1895
1950 /* spec says at least 2ms. but who knows with those 1896 /* spec says at least 2ms. but who knows with those
1951 * crazy ATAPI devices... 1897 * crazy ATAPI devices...
@@ -2572,19 +2518,12 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2572 2518
2573void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 2519void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2574{ 2520{
2575 struct scatterlist *sg;
2576
2577 qc->flags |= ATA_QCFLAG_SINGLE; 2521 qc->flags |= ATA_QCFLAG_SINGLE;
2578 2522
2579 memset(&qc->sgent, 0, sizeof(qc->sgent));
2580 qc->sg = &qc->sgent; 2523 qc->sg = &qc->sgent;
2581 qc->n_elem = 1; 2524 qc->n_elem = 1;
2582 qc->buf_virt = buf; 2525 qc->buf_virt = buf;
2583 2526 sg_init_one(qc->sg, buf, buflen);
2584 sg = qc->sg;
2585 sg->page = virt_to_page(buf);
2586 sg->offset = (unsigned long) buf & ~PAGE_MASK;
2587 sg->length = buflen;
2588} 2527}
2589 2528
2590/** 2529/**
@@ -2687,7 +2626,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2687 * None. (grabs host lock) 2626 * None. (grabs host lock)
2688 */ 2627 */
2689 2628
2690void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 2629void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2691{ 2630{
2692 struct ata_port *ap = qc->ap; 2631 struct ata_port *ap = qc->ap;
2693 unsigned long flags; 2632 unsigned long flags;
@@ -2695,7 +2634,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2695 spin_lock_irqsave(&ap->host_set->lock, flags); 2634 spin_lock_irqsave(&ap->host_set->lock, flags);
2696 ap->flags &= ~ATA_FLAG_NOINTR; 2635 ap->flags &= ~ATA_FLAG_NOINTR;
2697 ata_irq_on(ap); 2636 ata_irq_on(ap);
2698 ata_qc_complete(qc, drv_stat); 2637 ata_qc_complete(qc, err_mask);
2699 spin_unlock_irqrestore(&ap->host_set->lock, flags); 2638 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2700} 2639}
2701 2640
@@ -2792,7 +2731,7 @@ static int ata_pio_complete (struct ata_port *ap)
2792 2731
2793 ap->hsm_task_state = HSM_ST_IDLE; 2732 ap->hsm_task_state = HSM_ST_IDLE;
2794 2733
2795 ata_poll_qc_complete(qc, drv_stat); 2734 ata_poll_qc_complete(qc, 0);
2796 2735
2797 /* another command may start at this point */ 2736 /* another command may start at this point */
2798 2737
@@ -3160,18 +3099,15 @@ static void ata_pio_block(struct ata_port *ap)
3160static void ata_pio_error(struct ata_port *ap) 3099static void ata_pio_error(struct ata_port *ap)
3161{ 3100{
3162 struct ata_queued_cmd *qc; 3101 struct ata_queued_cmd *qc;
3163 u8 drv_stat; 3102
3103 printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
3164 3104
3165 qc = ata_qc_from_tag(ap, ap->active_tag); 3105 qc = ata_qc_from_tag(ap, ap->active_tag);
3166 assert(qc != NULL); 3106 assert(qc != NULL);
3167 3107
3168 drv_stat = ata_chk_status(ap);
3169 printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n",
3170 ap->id, drv_stat);
3171
3172 ap->hsm_task_state = HSM_ST_IDLE; 3108 ap->hsm_task_state = HSM_ST_IDLE;
3173 3109
3174 ata_poll_qc_complete(qc, drv_stat | ATA_ERR); 3110 ata_poll_qc_complete(qc, AC_ERR_ATA_BUS);
3175} 3111}
3176 3112
3177static void ata_pio_task(void *_data) 3113static void ata_pio_task(void *_data)
@@ -3294,7 +3230,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3294 ap->id, qc->tf.command, drv_stat, host_stat); 3230 ap->id, qc->tf.command, drv_stat, host_stat);
3295 3231
3296 /* complete taskfile transaction */ 3232 /* complete taskfile transaction */
3297 ata_qc_complete(qc, drv_stat); 3233 ata_qc_complete(qc, ac_err_mask(drv_stat));
3298 break; 3234 break;
3299 } 3235 }
3300 3236
@@ -3399,7 +3335,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3399 return qc; 3335 return qc;
3400} 3336}
3401 3337
3402int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) 3338int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
3403{ 3339{
3404 return 0; 3340 return 0;
3405} 3341}
@@ -3458,7 +3394,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3458 * spin_lock_irqsave(host_set lock) 3394 * spin_lock_irqsave(host_set lock)
3459 */ 3395 */
3460 3396
3461void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3397void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
3462{ 3398{
3463 int rc; 3399 int rc;
3464 3400
@@ -3475,7 +3411,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
3475 qc->flags &= ~ATA_QCFLAG_ACTIVE; 3411 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3476 3412
3477 /* call completion callback */ 3413 /* call completion callback */
3478 rc = qc->complete_fn(qc, drv_stat); 3414 rc = qc->complete_fn(qc, err_mask);
3479 3415
3480 /* if callback indicates not to complete command (non-zero), 3416 /* if callback indicates not to complete command (non-zero),
3481 * return immediately 3417 * return immediately
@@ -3582,7 +3518,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3582 3518
3583 switch (qc->tf.protocol) { 3519 switch (qc->tf.protocol) {
3584 case ATA_PROT_NODATA: 3520 case ATA_PROT_NODATA:
3585 ata_tf_to_host_nolock(ap, &qc->tf); 3521 ata_tf_to_host(ap, &qc->tf);
3586 break; 3522 break;
3587 3523
3588 case ATA_PROT_DMA: 3524 case ATA_PROT_DMA:
@@ -3593,20 +3529,20 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3593 3529
3594 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ 3530 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */
3595 ata_qc_set_polling(qc); 3531 ata_qc_set_polling(qc);
3596 ata_tf_to_host_nolock(ap, &qc->tf); 3532 ata_tf_to_host(ap, &qc->tf);
3597 ap->hsm_task_state = HSM_ST; 3533 ap->hsm_task_state = HSM_ST;
3598 queue_work(ata_wq, &ap->pio_task); 3534 queue_work(ata_wq, &ap->pio_task);
3599 break; 3535 break;
3600 3536
3601 case ATA_PROT_ATAPI: 3537 case ATA_PROT_ATAPI:
3602 ata_qc_set_polling(qc); 3538 ata_qc_set_polling(qc);
3603 ata_tf_to_host_nolock(ap, &qc->tf); 3539 ata_tf_to_host(ap, &qc->tf);
3604 queue_work(ata_wq, &ap->packet_task); 3540 queue_work(ata_wq, &ap->packet_task);
3605 break; 3541 break;
3606 3542
3607 case ATA_PROT_ATAPI_NODATA: 3543 case ATA_PROT_ATAPI_NODATA:
3608 ap->flags |= ATA_FLAG_NOINTR; 3544 ap->flags |= ATA_FLAG_NOINTR;
3609 ata_tf_to_host_nolock(ap, &qc->tf); 3545 ata_tf_to_host(ap, &qc->tf);
3610 queue_work(ata_wq, &ap->packet_task); 3546 queue_work(ata_wq, &ap->packet_task);
3611 break; 3547 break;
3612 3548
@@ -3913,7 +3849,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
3913 ap->ops->irq_clear(ap); 3849 ap->ops->irq_clear(ap);
3914 3850
3915 /* complete taskfile transaction */ 3851 /* complete taskfile transaction */
3916 ata_qc_complete(qc, status); 3852 ata_qc_complete(qc, ac_err_mask(status));
3917 break; 3853 break;
3918 3854
3919 default: 3855 default:
@@ -4008,7 +3944,7 @@ static void atapi_packet_task(void *_data)
4008 /* sleep-wait for BSY to clear */ 3944 /* sleep-wait for BSY to clear */
4009 DPRINTK("busy wait\n"); 3945 DPRINTK("busy wait\n");
4010 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) 3946 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB))
4011 goto err_out; 3947 goto err_out_status;
4012 3948
4013 /* make sure DRQ is set */ 3949 /* make sure DRQ is set */
4014 status = ata_chk_status(ap); 3950 status = ata_chk_status(ap);
@@ -4045,8 +3981,10 @@ static void atapi_packet_task(void *_data)
4045 3981
4046 return; 3982 return;
4047 3983
3984err_out_status:
3985 status = ata_chk_status(ap);
4048err_out: 3986err_out:
4049 ata_poll_qc_complete(qc, ATA_ERR); 3987 ata_poll_qc_complete(qc, __ac_err_mask(status));
4050} 3988}
4051 3989
4052 3990
@@ -4151,8 +4089,6 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4151 host->unique_id = ata_unique_id++; 4089 host->unique_id = ata_unique_id++;
4152 host->max_cmd_len = 12; 4090 host->max_cmd_len = 12;
4153 4091
4154 scsi_assign_lock(host, &host_set->lock);
4155
4156 ap->flags = ATA_FLAG_PORT_DISABLED; 4092 ap->flags = ATA_FLAG_PORT_DISABLED;
4157 ap->id = host->unique_id; 4093 ap->id = host->unique_id;
4158 ap->host = host; 4094 ap->host = host;
@@ -4254,11 +4190,10 @@ int ata_device_add(const struct ata_probe_ent *ent)
4254 4190
4255 DPRINTK("ENTER\n"); 4191 DPRINTK("ENTER\n");
4256 /* alloc a container for our list of ATA ports (buses) */ 4192 /* alloc a container for our list of ATA ports (buses) */
4257 host_set = kmalloc(sizeof(struct ata_host_set) + 4193 host_set = kzalloc(sizeof(struct ata_host_set) +
4258 (ent->n_ports * sizeof(void *)), GFP_KERNEL); 4194 (ent->n_ports * sizeof(void *)), GFP_KERNEL);
4259 if (!host_set) 4195 if (!host_set)
4260 return 0; 4196 return 0;
4261 memset(host_set, 0, sizeof(struct ata_host_set) + (ent->n_ports * sizeof(void *)));
4262 spin_lock_init(&host_set->lock); 4197 spin_lock_init(&host_set->lock);
4263 4198
4264 host_set->dev = dev; 4199 host_set->dev = dev;
@@ -4298,10 +4233,8 @@ int ata_device_add(const struct ata_probe_ent *ent)
4298 count++; 4233 count++;
4299 } 4234 }
4300 4235
4301 if (!count) { 4236 if (!count)
4302 kfree(host_set); 4237 goto err_free_ret;
4303 return 0;
4304 }
4305 4238
4306 /* obtain irq, that is shared between channels */ 4239 /* obtain irq, that is shared between channels */
4307 if (request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags, 4240 if (request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags,
@@ -4359,6 +4292,7 @@ err_out:
4359 ata_host_remove(host_set->ports[i], 1); 4292 ata_host_remove(host_set->ports[i], 1);
4360 scsi_host_put(host_set->ports[i]->host); 4293 scsi_host_put(host_set->ports[i]->host);
4361 } 4294 }
4295err_free_ret:
4362 kfree(host_set); 4296 kfree(host_set);
4363 VPRINTK("EXIT, returning 0\n"); 4297 VPRINTK("EXIT, returning 0\n");
4364 return 0; 4298 return 0;
@@ -4468,15 +4402,13 @@ ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
4468{ 4402{
4469 struct ata_probe_ent *probe_ent; 4403 struct ata_probe_ent *probe_ent;
4470 4404
4471 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); 4405 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
4472 if (!probe_ent) { 4406 if (!probe_ent) {
4473 printk(KERN_ERR DRV_NAME "(%s): out of memory\n", 4407 printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
4474 kobject_name(&(dev->kobj))); 4408 kobject_name(&(dev->kobj)));
4475 return NULL; 4409 return NULL;
4476 } 4410 }
4477 4411
4478 memset(probe_ent, 0, sizeof(*probe_ent));
4479
4480 INIT_LIST_HEAD(&probe_ent->node); 4412 INIT_LIST_HEAD(&probe_ent->node);
4481 probe_ent->dev = dev; 4413 probe_ent->dev = dev;
4482 4414
@@ -4556,11 +4488,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
4556 return probe_ent; 4488 return probe_ent;
4557} 4489}
4558 4490
4559static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info **port, int port_num) 4491static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info *port, int port_num)
4560{ 4492{
4561 struct ata_probe_ent *probe_ent; 4493 struct ata_probe_ent *probe_ent;
4562 4494
4563 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); 4495 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
4564 if (!probe_ent) 4496 if (!probe_ent)
4565 return NULL; 4497 return NULL;
4566 4498
@@ -4707,9 +4639,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4707 4639
4708 if (legacy_mode) { 4640 if (legacy_mode) {
4709 if (legacy_mode & (1 << 0)) 4641 if (legacy_mode & (1 << 0))
4710 probe_ent = ata_pci_init_legacy_port(pdev, port, 0); 4642 probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0);
4711 if (legacy_mode & (1 << 1)) 4643 if (legacy_mode & (1 << 1))
4712 probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); 4644 probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1);
4713 } else { 4645 } else {
4714 if (n_ports == 2) 4646 if (n_ports == 2)
4715 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 4647 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
@@ -4873,7 +4805,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis);
4873EXPORT_SYMBOL_GPL(ata_tf_from_fis); 4805EXPORT_SYMBOL_GPL(ata_tf_from_fis);
4874EXPORT_SYMBOL_GPL(ata_check_status); 4806EXPORT_SYMBOL_GPL(ata_check_status);
4875EXPORT_SYMBOL_GPL(ata_altstatus); 4807EXPORT_SYMBOL_GPL(ata_altstatus);
4876EXPORT_SYMBOL_GPL(ata_chk_err);
4877EXPORT_SYMBOL_GPL(ata_exec_command); 4808EXPORT_SYMBOL_GPL(ata_exec_command);
4878EXPORT_SYMBOL_GPL(ata_port_start); 4809EXPORT_SYMBOL_GPL(ata_port_start);
4879EXPORT_SYMBOL_GPL(ata_port_stop); 4810EXPORT_SYMBOL_GPL(ata_port_stop);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 58858886d751..248baae96486 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -39,15 +39,58 @@
39#include <scsi/scsi.h> 39#include <scsi/scsi.h>
40#include "scsi.h" 40#include "scsi.h"
41#include <scsi/scsi_host.h> 41#include <scsi/scsi_host.h>
42#include <scsi/scsi_device.h>
42#include <linux/libata.h> 43#include <linux/libata.h>
44#include <linux/hdreg.h>
43#include <asm/uaccess.h> 45#include <asm/uaccess.h>
44 46
45#include "libata.h" 47#include "libata.h"
46 48
49#define SECTOR_SIZE 512
50
47typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); 51typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
48static struct ata_device * 52static struct ata_device *
49ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); 53ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);
50 54
55#define RW_RECOVERY_MPAGE 0x1
56#define RW_RECOVERY_MPAGE_LEN 12
57#define CACHE_MPAGE 0x8
58#define CACHE_MPAGE_LEN 20
59#define CONTROL_MPAGE 0xa
60#define CONTROL_MPAGE_LEN 12
61#define ALL_MPAGES 0x3f
62#define ALL_SUB_MPAGES 0xff
63
64
65static const u8 def_rw_recovery_mpage[] = {
66 RW_RECOVERY_MPAGE,
67 RW_RECOVERY_MPAGE_LEN - 2,
68 (1 << 7) | /* AWRE, sat-r06 say it shall be 0 */
69 (1 << 6), /* ARRE (auto read reallocation) */
70 0, /* read retry count */
71 0, 0, 0, 0,
72 0, /* write retry count */
73 0, 0, 0
74};
75
76static const u8 def_cache_mpage[CACHE_MPAGE_LEN] = {
77 CACHE_MPAGE,
78 CACHE_MPAGE_LEN - 2,
79 0, /* contains WCE, needs to be 0 for logic */
80 0, 0, 0, 0, 0, 0, 0, 0, 0,
81 0, /* contains DRA, needs to be 0 for logic */
82 0, 0, 0, 0, 0, 0, 0
83};
84
85static const u8 def_control_mpage[CONTROL_MPAGE_LEN] = {
86 CONTROL_MPAGE,
87 CONTROL_MPAGE_LEN - 2,
88 2, /* DSENSE=0, GLTSD=1 */
89 0, /* [QAM+QERR may be 1, see 05-359r1] */
90 0, 0, 0, 0, 0xff, 0xff,
91 0, 30 /* extended self test time, see 05-359r1 */
92};
93
51 94
52static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 95static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
53 void (*done)(struct scsi_cmnd *)) 96 void (*done)(struct scsi_cmnd *))
@@ -86,6 +129,150 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
86 return 0; 129 return 0;
87} 130}
88 131
132/**
133 * ata_cmd_ioctl - Handler for HDIO_DRIVE_CMD ioctl
134 * @dev: Device to whom we are issuing command
135 * @arg: User provided data for issuing command
136 *
137 * LOCKING:
138 * Defined by the SCSI layer. We don't really care.
139 *
140 * RETURNS:
141 * Zero on success, negative errno on error.
142 */
143
144int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
145{
146 int rc = 0;
147 u8 scsi_cmd[MAX_COMMAND_SIZE];
148 u8 args[4], *argbuf = NULL;
149 int argsize = 0;
150 struct scsi_request *sreq;
151
152 if (NULL == (void *)arg)
153 return -EINVAL;
154
155 if (copy_from_user(args, arg, sizeof(args)))
156 return -EFAULT;
157
158 sreq = scsi_allocate_request(scsidev, GFP_KERNEL);
159 if (!sreq)
160 return -EINTR;
161
162 memset(scsi_cmd, 0, sizeof(scsi_cmd));
163
164 if (args[3]) {
165 argsize = SECTOR_SIZE * args[3];
166 argbuf = kmalloc(argsize, GFP_KERNEL);
167 if (argbuf == NULL) {
168 rc = -ENOMEM;
169 goto error;
170 }
171
172 scsi_cmd[1] = (4 << 1); /* PIO Data-in */
173 scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev,
174 block count in sector count field */
175 sreq->sr_data_direction = DMA_FROM_DEVICE;
176 } else {
177 scsi_cmd[1] = (3 << 1); /* Non-data */
178 /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */
179 sreq->sr_data_direction = DMA_NONE;
180 }
181
182 scsi_cmd[0] = ATA_16;
183
184 scsi_cmd[4] = args[2];
185 if (args[0] == WIN_SMART) { /* hack -- ide driver does this too... */
186 scsi_cmd[6] = args[3];
187 scsi_cmd[8] = args[1];
188 scsi_cmd[10] = 0x4f;
189 scsi_cmd[12] = 0xc2;
190 } else {
191 scsi_cmd[6] = args[1];
192 }
193 scsi_cmd[14] = args[0];
194
195 /* Good values for timeout and retries? Values below
196 from scsi_ioctl_send_command() for default case... */
197 scsi_wait_req(sreq, scsi_cmd, argbuf, argsize, (10*HZ), 5);
198
199 if (sreq->sr_result) {
200 rc = -EIO;
201 goto error;
202 }
203
204 /* Need code to retrieve data from check condition? */
205
206 if ((argbuf)
207 && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize))
208 rc = -EFAULT;
209error:
210 scsi_release_request(sreq);
211
212 if (argbuf)
213 kfree(argbuf);
214
215 return rc;
216}
217
218/**
219 * ata_task_ioctl - Handler for HDIO_DRIVE_TASK ioctl
220 * @dev: Device to whom we are issuing command
221 * @arg: User provided data for issuing command
222 *
223 * LOCKING:
224 * Defined by the SCSI layer. We don't really care.
225 *
226 * RETURNS:
227 * Zero on success, negative errno on error.
228 */
229int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
230{
231 int rc = 0;
232 u8 scsi_cmd[MAX_COMMAND_SIZE];
233 u8 args[7];
234 struct scsi_request *sreq;
235
236 if (NULL == (void *)arg)
237 return -EINVAL;
238
239 if (copy_from_user(args, arg, sizeof(args)))
240 return -EFAULT;
241
242 memset(scsi_cmd, 0, sizeof(scsi_cmd));
243 scsi_cmd[0] = ATA_16;
244 scsi_cmd[1] = (3 << 1); /* Non-data */
245 /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */
246 scsi_cmd[4] = args[1];
247 scsi_cmd[6] = args[2];
248 scsi_cmd[8] = args[3];
249 scsi_cmd[10] = args[4];
250 scsi_cmd[12] = args[5];
251 scsi_cmd[14] = args[0];
252
253 sreq = scsi_allocate_request(scsidev, GFP_KERNEL);
254 if (!sreq) {
255 rc = -EINTR;
256 goto error;
257 }
258
259 sreq->sr_data_direction = DMA_NONE;
260 /* Good values for timeout and retries? Values below
261 from scsi_ioctl_send_command() for default case... */
262 scsi_wait_req(sreq, scsi_cmd, NULL, 0, (10*HZ), 5);
263
264 if (sreq->sr_result) {
265 rc = -EIO;
266 goto error;
267 }
268
269 /* Need code to retrieve data from check condition? */
270
271error:
272 scsi_release_request(sreq);
273 return rc;
274}
275
89int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) 276int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
90{ 277{
91 struct ata_port *ap; 278 struct ata_port *ap;
@@ -115,6 +302,16 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
115 return -EINVAL; 302 return -EINVAL;
116 return 0; 303 return 0;
117 304
305 case HDIO_DRIVE_CMD:
306 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
307 return -EACCES;
308 return ata_cmd_ioctl(scsidev, arg);
309
310 case HDIO_DRIVE_TASK:
311 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
312 return -EACCES;
313 return ata_task_ioctl(scsidev, arg);
314
118 default: 315 default:
119 rc = -ENOTTY; 316 rc = -ENOTTY;
120 break; 317 break;
@@ -173,23 +370,70 @@ struct ata_queued_cmd *ata_scsi_qc_new(struct ata_port *ap,
173} 370}
174 371
175/** 372/**
373 * ata_dump_status - user friendly display of error info
374 * @id: id of the port in question
375 * @tf: ptr to filled out taskfile
376 *
377 * Decode and dump the ATA error/status registers for the user so
378 * that they have some idea what really happened at the non
379 * make-believe layer.
380 *
381 * LOCKING:
382 * inherited from caller
383 */
384void ata_dump_status(unsigned id, struct ata_taskfile *tf)
385{
386 u8 stat = tf->command, err = tf->feature;
387
388 printk(KERN_WARNING "ata%u: status=0x%02x { ", id, stat);
389 if (stat & ATA_BUSY) {
390 printk("Busy }\n"); /* Data is not valid in this case */
391 } else {
392 if (stat & 0x40) printk("DriveReady ");
393 if (stat & 0x20) printk("DeviceFault ");
394 if (stat & 0x10) printk("SeekComplete ");
395 if (stat & 0x08) printk("DataRequest ");
396 if (stat & 0x04) printk("CorrectedError ");
397 if (stat & 0x02) printk("Index ");
398 if (stat & 0x01) printk("Error ");
399 printk("}\n");
400
401 if (err) {
402 printk(KERN_WARNING "ata%u: error=0x%02x { ", id, err);
403 if (err & 0x04) printk("DriveStatusError ");
404 if (err & 0x80) {
405 if (err & 0x04) printk("BadCRC ");
406 else printk("Sector ");
407 }
408 if (err & 0x40) printk("UncorrectableError ");
409 if (err & 0x10) printk("SectorIdNotFound ");
410 if (err & 0x02) printk("TrackZeroNotFound ");
411 if (err & 0x01) printk("AddrMarkNotFound ");
412 printk("}\n");
413 }
414 }
415}
416
417/**
176 * ata_to_sense_error - convert ATA error to SCSI error 418 * 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 419 * @drv_stat: value contained in ATA status register
420 * @drv_err: value contained in ATA error register
421 * @sk: the sense key we'll fill out
422 * @asc: the additional sense code we'll fill out
423 * @ascq: the additional sense code qualifier we'll fill out
179 * 424 *
180 * Converts an ATA error into a SCSI error. While we are at it 425 * 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 426 * SK, ASC, and ASCQ bytes for later use in fixed or descriptor
182 * have some idea what really happened at the non make-believe 427 * format sense blocks.
183 * layer.
184 * 428 *
185 * LOCKING: 429 * LOCKING:
186 * spin_lock_irqsave(host_set lock) 430 * spin_lock_irqsave(host_set lock)
187 */ 431 */
188 432void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
189void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat) 433 u8 *ascq)
190{ 434{
191 struct scsi_cmnd *cmd = qc->scsicmd; 435 int i;
192 u8 err = 0; 436
193 /* Based on the 3ware driver translation table */ 437 /* Based on the 3ware driver translation table */
194 static unsigned char sense_table[][4] = { 438 static unsigned char sense_table[][4] = {
195 /* BBD|ECC|ID|MAR */ 439 /* BBD|ECC|ID|MAR */
@@ -230,96 +474,192 @@ 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 474 {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered
231 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark 475 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark
232 }; 476 };
233 int i = 0;
234 477
235 /* 478 /*
236 * Is this an error we can process/parse 479 * Is this an error we can process/parse
237 */ 480 */
481 if (drv_stat & ATA_BUSY) {
482 drv_err = 0; /* Ignore the err bits, they're invalid */
483 }
238 484
239 if(drv_stat & ATA_ERR) 485 if (drv_err) {
240 /* Read the err bits */ 486 /* Look for drv_err */
241 err = ata_chk_err(qc->ap); 487 for (i = 0; sense_table[i][0] != 0xFF; i++) {
488 /* Look for best matches first */
489 if ((sense_table[i][0] & drv_err) ==
490 sense_table[i][0]) {
491 *sk = sense_table[i][1];
492 *asc = sense_table[i][2];
493 *ascq = sense_table[i][3];
494 goto translate_done;
495 }
496 }
497 /* No immediate match */
498 printk(KERN_WARNING "ata%u: no sense translation for "
499 "error 0x%02x\n", id, drv_err);
500 }
242 501
243 /* Display the ATA level error info */ 502 /* Fall back to interpreting status bits */
503 for (i = 0; stat_table[i][0] != 0xFF; i++) {
504 if (stat_table[i][0] & drv_stat) {
505 *sk = stat_table[i][1];
506 *asc = stat_table[i][2];
507 *ascq = stat_table[i][3];
508 goto translate_done;
509 }
510 }
511 /* No error? Undecoded? */
512 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
513 id, drv_stat);
244 514
245 printk(KERN_WARNING "ata%u: status=0x%02x { ", qc->ap->id, drv_stat); 515 /* For our last chance pick, use medium read error because
246 if(drv_stat & 0x80) 516 * it's much more common than an ATA drive telling you a write
247 { 517 * has failed.
248 printk("Busy "); 518 */
249 err = 0; /* Data is not valid in this case */ 519 *sk = MEDIUM_ERROR;
520 *asc = 0x11; /* "unrecovered read error" */
521 *ascq = 0x04; /* "auto-reallocation failed" */
522
523 translate_done:
524 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to "
525 "SCSI SK/ASC/ASCQ 0x%x/%02x/%02x\n", id, drv_stat, drv_err,
526 *sk, *asc, *ascq);
527 return;
528}
529
530/*
531 * ata_gen_ata_desc_sense - Generate check condition sense block.
532 * @qc: Command that completed.
533 *
534 * This function is specific to the ATA descriptor format sense
535 * block specified for the ATA pass through commands. Regardless
536 * of whether the command errored or not, return a sense
537 * block. Copy all controller registers into the sense
538 * block. Clear sense key, ASC & ASCQ if there is no error.
539 *
540 * LOCKING:
541 * spin_lock_irqsave(host_set lock)
542 */
543void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
544{
545 struct scsi_cmnd *cmd = qc->scsicmd;
546 struct ata_taskfile *tf = &qc->tf;
547 unsigned char *sb = cmd->sense_buffer;
548 unsigned char *desc = sb + 8;
549
550 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
551
552 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
553
554 /*
555 * Read the controller registers.
556 */
557 assert(NULL != qc->ap->ops->tf_read);
558 qc->ap->ops->tf_read(qc->ap, tf);
559
560 /*
561 * Use ata_to_sense_error() to map status register bits
562 * onto sense key, asc & ascq.
563 */
564 if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
565 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
566 &sb[1], &sb[2], &sb[3]);
567 sb[1] &= 0x0f;
250 } 568 }
251 else { 569
252 if(drv_stat & 0x40) printk("DriveReady "); 570 /*
253 if(drv_stat & 0x20) printk("DeviceFault "); 571 * Sense data is current and format is descriptor.
254 if(drv_stat & 0x10) printk("SeekComplete "); 572 */
255 if(drv_stat & 0x08) printk("DataRequest "); 573 sb[0] = 0x72;
256 if(drv_stat & 0x04) printk("CorrectedError "); 574
257 if(drv_stat & 0x02) printk("Index "); 575 desc[0] = 0x09;
258 if(drv_stat & 0x01) printk("Error "); 576
577 /*
578 * Set length of additional sense data.
579 * Since we only populate descriptor 0, the total
580 * length is the same (fixed) length as descriptor 0.
581 */
582 desc[1] = sb[7] = 14;
583
584 /*
585 * Copy registers into sense buffer.
586 */
587 desc[2] = 0x00;
588 desc[3] = tf->feature; /* == error reg */
589 desc[5] = tf->nsect;
590 desc[7] = tf->lbal;
591 desc[9] = tf->lbam;
592 desc[11] = tf->lbah;
593 desc[12] = tf->device;
594 desc[13] = tf->command; /* == status reg */
595
596 /*
597 * Fill in Extend bit, and the high order bytes
598 * if applicable.
599 */
600 if (tf->flags & ATA_TFLAG_LBA48) {
601 desc[2] |= 0x01;
602 desc[4] = tf->hob_nsect;
603 desc[6] = tf->hob_lbal;
604 desc[8] = tf->hob_lbam;
605 desc[10] = tf->hob_lbah;
259 } 606 }
260 printk("}\n"); 607}
261
262 if(err)
263 {
264 printk(KERN_WARNING "ata%u: error=0x%02x { ", qc->ap->id, err);
265 if(err & 0x04) printk("DriveStatusError ");
266 if(err & 0x80)
267 {
268 if(err & 0x04)
269 printk("BadCRC ");
270 else
271 printk("Sector ");
272 }
273 if(err & 0x40) printk("UncorrectableError ");
274 if(err & 0x10) printk("SectorIdNotFound ");
275 if(err & 0x02) printk("TrackZeroNotFound ");
276 if(err & 0x01) printk("AddrMarkNotFound ");
277 printk("}\n");
278 608
279 /* Should we dump sector info here too ?? */ 609/**
610 * ata_gen_fixed_sense - generate a SCSI fixed sense block
611 * @qc: Command that we are erroring out
612 *
613 * Leverage ata_to_sense_error() to give us the codes. Fit our
614 * LBA in here if there's room.
615 *
616 * LOCKING:
617 * inherited from caller
618 */
619void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
620{
621 struct scsi_cmnd *cmd = qc->scsicmd;
622 struct ata_taskfile *tf = &qc->tf;
623 unsigned char *sb = cmd->sense_buffer;
624
625 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
626
627 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
628
629 /*
630 * Read the controller registers.
631 */
632 assert(NULL != qc->ap->ops->tf_read);
633 qc->ap->ops->tf_read(qc->ap, tf);
634
635 /*
636 * Use ata_to_sense_error() to map status register bits
637 * onto sense key, asc & ascq.
638 */
639 if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
640 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
641 &sb[2], &sb[12], &sb[13]);
642 sb[2] &= 0x0f;
280 } 643 }
281 644
645 sb[0] = 0x70;
646 sb[7] = 0x0a;
282 647
283 /* Look for err */ 648 if (tf->flags & ATA_TFLAG_LBA48) {
284 while(sense_table[i][0] != 0xFF) 649 /* TODO: find solution for LBA48 descriptors */
285 {
286 /* Look for best matches first */
287 if((sense_table[i][0] & err) == sense_table[i][0])
288 {
289 ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */,
290 sense_table[i][2] /* asc */,
291 sense_table[i][3] /* ascq */ );
292 return;
293 }
294 i++;
295 } 650 }
296 /* No immediate match */
297 if(err)
298 printk(KERN_DEBUG "ata%u: no sense translation for 0x%02x\n", qc->ap->id, err);
299 651
300 i = 0; 652 else if (tf->flags & ATA_TFLAG_LBA) {
301 /* Fall back to interpreting status bits */ 653 /* A small (28b) LBA will fit in the 32b info field */
302 while(stat_table[i][0] != 0xFF) 654 sb[0] |= 0x80; /* set valid bit */
303 { 655 sb[3] = tf->device & 0x0f;
304 if(stat_table[i][0] & drv_stat) 656 sb[4] = tf->lbah;
305 { 657 sb[5] = tf->lbam;
306 ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */, 658 sb[6] = tf->lbal;
307 sense_table[i][2] /* asc */,
308 sense_table[i][3] /* ascq */ );
309 return;
310 }
311 i++;
312 } 659 }
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 660
317 if (cmd->sc_data_direction == DMA_FROM_DEVICE) { 661 else {
318 ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0x11, 0x4); 662 /* TODO: C/H/S */
319 /* "unrecovered read error" */
320 } else {
321 ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0xc, 0x2);
322 /* "write error - auto-reallocation failed" */
323 } 663 }
324} 664}
325 665
@@ -868,14 +1208,41 @@ nothing_to_do:
868 return 1; 1208 return 1;
869} 1209}
870 1210
871static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 1211static int ata_scsi_qc_complete(struct ata_queued_cmd *qc,
1212 unsigned int err_mask)
872{ 1213{
873 struct scsi_cmnd *cmd = qc->scsicmd; 1214 struct scsi_cmnd *cmd = qc->scsicmd;
1215 u8 *cdb = cmd->cmnd;
1216 int need_sense = (err_mask != 0);
1217
1218 /* For ATA pass thru (SAT) commands, generate a sense block if
1219 * user mandated it or if there's an error. Note that if we
1220 * generate because the user forced us to, a check condition
1221 * is generated and the ATA register values are returned
1222 * whether the command completed successfully or not. If there
1223 * was no error, SK, ASC and ASCQ will all be zero.
1224 */
1225 if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
1226 ((cdb[2] & 0x20) || need_sense)) {
1227 ata_gen_ata_desc_sense(qc);
1228 } else {
1229 if (!need_sense) {
1230 cmd->result = SAM_STAT_GOOD;
1231 } else {
1232 /* TODO: decide which descriptor format to use
1233 * for 48b LBA devices and call that here
1234 * instead of the fixed desc, which is only
1235 * good for smaller LBA (and maybe CHS?)
1236 * devices.
1237 */
1238 ata_gen_fixed_sense(qc);
1239 }
1240 }
874 1241
875 if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) 1242 if (need_sense) {
876 ata_to_sense_error(qc, drv_stat); 1243 /* The ata_gen_..._sense routines fill in tf */
877 else 1244 ata_dump_status(qc->ap->id, &qc->tf);
878 cmd->result = SAM_STAT_GOOD; 1245 }
879 1246
880 qc->scsidone(cmd); 1247 qc->scsidone(cmd);
881 1248
@@ -1266,13 +1633,9 @@ static void ata_msense_push(u8 **ptr_io, const u8 *last,
1266static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, 1633static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io,
1267 const u8 *last) 1634 const u8 *last)
1268{ 1635{
1269 u8 page[] = { 1636 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 1637
1638 memcpy(page, def_cache_mpage, sizeof(page));
1276 if (ata_id_wcache_enabled(id)) 1639 if (ata_id_wcache_enabled(id))
1277 page[2] |= (1 << 2); /* write cache enable */ 1640 page[2] |= (1 << 2); /* write cache enable */
1278 if (!ata_id_rahead_enabled(id)) 1641 if (!ata_id_rahead_enabled(id))
@@ -1296,15 +1659,9 @@ static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io,
1296 1659
1297static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) 1660static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last)
1298{ 1661{
1299 const u8 page[] = {0xa, 0xa, 6, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 30}; 1662 ata_msense_push(ptr_io, last, def_control_mpage,
1300 1663 sizeof(def_control_mpage));
1301 /* byte 2: set the descriptor format sense data bit (bit 2) 1664 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} 1665}
1309 1666
1310/** 1667/**
@@ -1321,15 +1678,10 @@ static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last)
1321 1678
1322static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) 1679static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last)
1323{ 1680{
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 1681
1331 ata_msense_push(ptr_io, last, page, sizeof(page)); 1682 ata_msense_push(ptr_io, last, def_rw_recovery_mpage,
1332 return sizeof(page); 1683 sizeof(def_rw_recovery_mpage));
1684 return sizeof(def_rw_recovery_mpage);
1333} 1685}
1334 1686
1335/** 1687/**
@@ -1338,7 +1690,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. 1690 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1339 * @buflen: Response buffer length. 1691 * @buflen: Response buffer length.
1340 * 1692 *
1341 * Simulate MODE SENSE commands. 1693 * Simulate MODE SENSE commands. Assume this is invoked for direct
1694 * access devices (e.g. disks) only. There should be no block
1695 * descriptor for other device types.
1342 * 1696 *
1343 * LOCKING: 1697 * LOCKING:
1344 * spin_lock_irqsave(host_set lock) 1698 * spin_lock_irqsave(host_set lock)
@@ -1348,15 +1702,22 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1348 unsigned int buflen) 1702 unsigned int buflen)
1349{ 1703{
1350 u8 *scsicmd = args->cmd->cmnd, *p, *last; 1704 u8 *scsicmd = args->cmd->cmnd, *p, *last;
1351 unsigned int page_control, six_byte, output_len; 1705 const u8 sat_blk_desc[] = {
1706 0, 0, 0, 0, /* number of blocks: sat unspecified */
1707 0,
1708 0, 0x2, 0x0 /* block length: 512 bytes */
1709 };
1710 u8 pg, spg;
1711 unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen;
1352 1712
1353 VPRINTK("ENTER\n"); 1713 VPRINTK("ENTER\n");
1354 1714
1355 six_byte = (scsicmd[0] == MODE_SENSE); 1715 six_byte = (scsicmd[0] == MODE_SENSE);
1356 1716 ebd = !(scsicmd[1] & 0x8); /* dbd bit inverted == edb */
1357 /* we only support saved and current values (which we treat 1717 /*
1358 * in the same manner) 1718 * LLBA bit in msense(10) ignored (compliant)
1359 */ 1719 */
1720
1360 page_control = scsicmd[2] >> 6; 1721 page_control = scsicmd[2] >> 6;
1361 switch (page_control) { 1722 switch (page_control) {
1362 case 0: /* current */ 1723 case 0: /* current */
@@ -1369,29 +1730,42 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1369 goto invalid_fld; 1730 goto invalid_fld;
1370 } 1731 }
1371 1732
1372 if (six_byte) 1733 if (six_byte) {
1373 output_len = 4; 1734 output_len = 4 + (ebd ? 8 : 0);
1374 else 1735 alloc_len = scsicmd[4];
1375 output_len = 8; 1736 } else {
1737 output_len = 8 + (ebd ? 8 : 0);
1738 alloc_len = (scsicmd[7] << 8) + scsicmd[8];
1739 }
1740 minlen = (alloc_len < buflen) ? alloc_len : buflen;
1376 1741
1377 p = rbuf + output_len; 1742 p = rbuf + output_len;
1378 last = rbuf + buflen - 1; 1743 last = rbuf + minlen - 1;
1744
1745 pg = scsicmd[2] & 0x3f;
1746 spg = scsicmd[3];
1747 /*
1748 * No mode subpages supported (yet) but asking for _all_
1749 * subpages may be valid
1750 */
1751 if (spg && (spg != ALL_SUB_MPAGES))
1752 goto invalid_fld;
1379 1753
1380 switch(scsicmd[2] & 0x3f) { 1754 switch(pg) {
1381 case 0x01: /* r/w error recovery */ 1755 case RW_RECOVERY_MPAGE:
1382 output_len += ata_msense_rw_recovery(&p, last); 1756 output_len += ata_msense_rw_recovery(&p, last);
1383 break; 1757 break;
1384 1758
1385 case 0x08: /* caching */ 1759 case CACHE_MPAGE:
1386 output_len += ata_msense_caching(args->id, &p, last); 1760 output_len += ata_msense_caching(args->id, &p, last);
1387 break; 1761 break;
1388 1762
1389 case 0x0a: { /* control mode */ 1763 case CONTROL_MPAGE: {
1390 output_len += ata_msense_ctl_mode(&p, last); 1764 output_len += ata_msense_ctl_mode(&p, last);
1391 break; 1765 break;
1392 } 1766 }
1393 1767
1394 case 0x3f: /* all pages */ 1768 case ALL_MPAGES:
1395 output_len += ata_msense_rw_recovery(&p, last); 1769 output_len += ata_msense_rw_recovery(&p, last);
1396 output_len += ata_msense_caching(args->id, &p, last); 1770 output_len += ata_msense_caching(args->id, &p, last);
1397 output_len += ata_msense_ctl_mode(&p, last); 1771 output_len += ata_msense_ctl_mode(&p, last);
@@ -1401,15 +1775,31 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1401 goto invalid_fld; 1775 goto invalid_fld;
1402 } 1776 }
1403 1777
1778 if (minlen < 1)
1779 return 0;
1404 if (six_byte) { 1780 if (six_byte) {
1405 output_len--; 1781 output_len--;
1406 rbuf[0] = output_len; 1782 rbuf[0] = output_len;
1783 if (ebd) {
1784 if (minlen > 3)
1785 rbuf[3] = sizeof(sat_blk_desc);
1786 if (minlen > 11)
1787 memcpy(rbuf + 4, sat_blk_desc,
1788 sizeof(sat_blk_desc));
1789 }
1407 } else { 1790 } else {
1408 output_len -= 2; 1791 output_len -= 2;
1409 rbuf[0] = output_len >> 8; 1792 rbuf[0] = output_len >> 8;
1410 rbuf[1] = output_len; 1793 if (minlen > 1)
1794 rbuf[1] = output_len;
1795 if (ebd) {
1796 if (minlen > 7)
1797 rbuf[7] = sizeof(sat_blk_desc);
1798 if (minlen > 15)
1799 memcpy(rbuf + 8, sat_blk_desc,
1800 sizeof(sat_blk_desc));
1801 }
1411 } 1802 }
1412
1413 return 0; 1803 return 0;
1414 1804
1415invalid_fld: 1805invalid_fld:
@@ -1616,16 +2006,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
1616 DPRINTK("EXIT\n"); 2006 DPRINTK("EXIT\n");
1617} 2007}
1618 2008
1619static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 2009static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
1620{ 2010{
1621 struct scsi_cmnd *cmd = qc->scsicmd; 2011 struct scsi_cmnd *cmd = qc->scsicmd;
1622 2012
1623 VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); 2013 VPRINTK("ENTER, err_mask 0x%X\n", err_mask);
1624 2014
1625 if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) 2015 if (unlikely(err_mask & AC_ERR_DEV)) {
1626 ata_to_sense_error(qc, drv_stat);
1627
1628 else if (unlikely(drv_stat & ATA_ERR)) {
1629 DPRINTK("request check condition\n"); 2016 DPRINTK("request check condition\n");
1630 2017
1631 /* FIXME: command completion with check condition 2018 /* FIXME: command completion with check condition
@@ -1642,6 +2029,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1642 return 1; 2029 return 1;
1643 } 2030 }
1644 2031
2032 else if (unlikely(err_mask))
2033 /* FIXME: not quite right; we don't want the
2034 * translation of taskfile registers into
2035 * a sense descriptors, since that's only
2036 * correct for ATA, not ATAPI
2037 */
2038 ata_gen_ata_desc_sense(qc);
2039
1645 else { 2040 else {
1646 u8 *scsicmd = cmd->cmnd; 2041 u8 *scsicmd = cmd->cmnd;
1647 2042
@@ -1782,6 +2177,143 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
1782 return dev; 2177 return dev;
1783} 2178}
1784 2179
2180/*
2181 * ata_scsi_map_proto - Map pass-thru protocol value to taskfile value.
2182 * @byte1: Byte 1 from pass-thru CDB.
2183 *
2184 * RETURNS:
2185 * ATA_PROT_UNKNOWN if mapping failed/unimplemented, protocol otherwise.
2186 */
2187static u8
2188ata_scsi_map_proto(u8 byte1)
2189{
2190 switch((byte1 & 0x1e) >> 1) {
2191 case 3: /* Non-data */
2192 return ATA_PROT_NODATA;
2193
2194 case 6: /* DMA */
2195 return ATA_PROT_DMA;
2196
2197 case 4: /* PIO Data-in */
2198 case 5: /* PIO Data-out */
2199 if (byte1 & 0xe0) {
2200 return ATA_PROT_PIO_MULT;
2201 }
2202 return ATA_PROT_PIO;
2203
2204 case 10: /* Device Reset */
2205 case 0: /* Hard Reset */
2206 case 1: /* SRST */
2207 case 2: /* Bus Idle */
2208 case 7: /* Packet */
2209 case 8: /* DMA Queued */
2210 case 9: /* Device Diagnostic */
2211 case 11: /* UDMA Data-in */
2212 case 12: /* UDMA Data-Out */
2213 case 13: /* FPDMA */
2214 default: /* Reserved */
2215 break;
2216 }
2217
2218 return ATA_PROT_UNKNOWN;
2219}
2220
2221/**
2222 * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile
2223 * @qc: command structure to be initialized
2224 * @cmd: SCSI command to convert
2225 *
2226 * Handles either 12 or 16-byte versions of the CDB.
2227 *
2228 * RETURNS:
2229 * Zero on success, non-zero on failure.
2230 */
2231static unsigned int
2232ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2233{
2234 struct ata_taskfile *tf = &(qc->tf);
2235 struct scsi_cmnd *cmd = qc->scsicmd;
2236
2237 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
2238 return 1;
2239
2240 /*
2241 * 12 and 16 byte CDBs use different offsets to
2242 * provide the various register values.
2243 */
2244 if (scsicmd[0] == ATA_16) {
2245 /*
2246 * 16-byte CDB - may contain extended commands.
2247 *
2248 * If that is the case, copy the upper byte register values.
2249 */
2250 if (scsicmd[1] & 0x01) {
2251 tf->hob_feature = scsicmd[3];
2252 tf->hob_nsect = scsicmd[5];
2253 tf->hob_lbal = scsicmd[7];
2254 tf->hob_lbam = scsicmd[9];
2255 tf->hob_lbah = scsicmd[11];
2256 tf->flags |= ATA_TFLAG_LBA48;
2257 } else
2258 tf->flags &= ~ATA_TFLAG_LBA48;
2259
2260 /*
2261 * Always copy low byte, device and command registers.
2262 */
2263 tf->feature = scsicmd[4];
2264 tf->nsect = scsicmd[6];
2265 tf->lbal = scsicmd[8];
2266 tf->lbam = scsicmd[10];
2267 tf->lbah = scsicmd[12];
2268 tf->device = scsicmd[13];
2269 tf->command = scsicmd[14];
2270 } else {
2271 /*
2272 * 12-byte CDB - incapable of extended commands.
2273 */
2274 tf->flags &= ~ATA_TFLAG_LBA48;
2275
2276 tf->feature = scsicmd[3];
2277 tf->nsect = scsicmd[4];
2278 tf->lbal = scsicmd[5];
2279 tf->lbam = scsicmd[6];
2280 tf->lbah = scsicmd[7];
2281 tf->device = scsicmd[8];
2282 tf->command = scsicmd[9];
2283 }
2284
2285 /*
2286 * Filter SET_FEATURES - XFER MODE command -- otherwise,
2287 * SET_FEATURES - XFER MODE must be preceded/succeeded
2288 * by an update to hardware-specific registers for each
2289 * controller (i.e. the reason for ->set_piomode(),
2290 * ->set_dmamode(), and ->post_set_mode() hooks).
2291 */
2292 if ((tf->command == ATA_CMD_SET_FEATURES)
2293 && (tf->feature == SETFEATURES_XFER))
2294 return 1;
2295
2296 /*
2297 * Set flags so that all registers will be written,
2298 * and pass on write indication (used for PIO/DMA
2299 * setup.)
2300 */
2301 tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE);
2302
2303 if (cmd->sc_data_direction == DMA_TO_DEVICE)
2304 tf->flags |= ATA_TFLAG_WRITE;
2305
2306 /*
2307 * Set transfer length.
2308 *
2309 * TODO: find out if we need to do more here to
2310 * cover scatter/gather case.
2311 */
2312 qc->nsect = cmd->bufflen / ATA_SECT_SIZE;
2313
2314 return 0;
2315}
2316
1785/** 2317/**
1786 * ata_get_xlat_func - check if SCSI to ATA translation is possible 2318 * ata_get_xlat_func - check if SCSI to ATA translation is possible
1787 * @dev: ATA device 2319 * @dev: ATA device
@@ -1814,6 +2346,11 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
1814 case VERIFY: 2346 case VERIFY:
1815 case VERIFY_16: 2347 case VERIFY_16:
1816 return ata_scsi_verify_xlat; 2348 return ata_scsi_verify_xlat;
2349
2350 case ATA_12:
2351 case ATA_16:
2352 return ata_scsi_pass_thru;
2353
1817 case START_STOP: 2354 case START_STOP:
1818 return ata_scsi_start_stop_xlat; 2355 return ata_scsi_start_stop_xlat;
1819 } 2356 }
@@ -1869,8 +2406,12 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
1869 struct ata_port *ap; 2406 struct ata_port *ap;
1870 struct ata_device *dev; 2407 struct ata_device *dev;
1871 struct scsi_device *scsidev = cmd->device; 2408 struct scsi_device *scsidev = cmd->device;
2409 struct Scsi_Host *shost = scsidev->host;
1872 2410
1873 ap = (struct ata_port *) &scsidev->host->hostdata[0]; 2411 ap = (struct ata_port *) &shost->hostdata[0];
2412
2413 spin_unlock(shost->host_lock);
2414 spin_lock(&ap->host_set->lock);
1874 2415
1875 ata_scsi_dump_cdb(ap, cmd); 2416 ata_scsi_dump_cdb(ap, cmd);
1876 2417
@@ -1893,6 +2434,8 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
1893 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); 2434 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
1894 2435
1895out_unlock: 2436out_unlock:
2437 spin_unlock(&ap->host_set->lock);
2438 spin_lock(shost->host_lock);
1896 return 0; 2439 return 0;
1897} 2440}
1898 2441
@@ -1972,7 +2515,7 @@ void ata_scsi_simulate(u16 *id,
1972 ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); 2515 ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns);
1973 break; 2516 break;
1974 2517
1975 /* mandantory commands we haven't implemented yet */ 2518 /* mandatory commands we haven't implemented yet */
1976 case REQUEST_SENSE: 2519 case REQUEST_SENSE:
1977 2520
1978 /* all other commands */ 2521 /* all other commands */
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 3d60190584ba..fad051ca4672 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -39,7 +39,7 @@ struct ata_scsi_args {
39 39
40/* libata-core.c */ 40/* libata-core.c */
41extern int atapi_enabled; 41extern int atapi_enabled;
42extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat); 42extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask);
43extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 43extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
44 struct ata_device *dev); 44 struct ata_device *dev);
45extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); 45extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc);
@@ -48,15 +48,15 @@ extern int ata_qc_issue(struct ata_queued_cmd *qc);
48extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); 48extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
49extern void ata_dev_select(struct ata_port *ap, unsigned int device, 49extern 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);
51extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf);
52extern void swap_buf_le16(u16 *buf, unsigned int buf_words); 51extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
52extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
53extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
53 54
54 55
55/* libata-scsi.c */ 56/* libata-scsi.c */
56extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, 57extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
57 struct scsi_cmnd *cmd); 58 struct scsi_cmnd *cmd);
58extern void ata_scsi_scan_host(struct ata_port *ap); 59extern void ata_scsi_scan_host(struct ata_port *ap);
59extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat);
60extern int ata_scsi_error(struct Scsi_Host *host); 60extern int ata_scsi_error(struct Scsi_Host *host);
61extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 61extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
62 unsigned int buflen); 62 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
77static int megaraid_probe_one(struct pci_dev*, const struct pci_device_id *); 77static int megaraid_probe_one(struct pci_dev*, const struct pci_device_id *);
78static void megaraid_detach_one(struct pci_dev *); 78static void megaraid_detach_one(struct pci_dev *);
79static void megaraid_mbox_shutdown(struct device *); 79static void megaraid_mbox_shutdown(struct pci_dev *);
80 80
81static int megaraid_io_attach(adapter_t *); 81static int megaraid_io_attach(adapter_t *);
82static void megaraid_io_detach(adapter_t *); 82static 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 */
675static void 673static void
676megaraid_mbox_shutdown(struct device *device) 674megaraid_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/mesh.c b/drivers/scsi/mesh.c
index b235556b7b65..bdccf73cf9fe 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -730,7 +730,7 @@ static void start_phase(struct mesh_state *ms)
730 * issue a SEQ_MSGOUT to get the mesh to drop ACK. 730 * issue a SEQ_MSGOUT to get the mesh to drop ACK.
731 */ 731 */
732 if ((in_8(&mr->bus_status0) & BS0_ATN) == 0) { 732 if ((in_8(&mr->bus_status0) & BS0_ATN) == 0) {
733 dlog(ms, "bus0 was %.2x explictly asserting ATN", mr->bus_status0); 733 dlog(ms, "bus0 was %.2x explicitly asserting ATN", mr->bus_status0);
734 out_8(&mr->bus_status0, BS0_ATN); /* explicit ATN */ 734 out_8(&mr->bus_status0, BS0_ATN); /* explicit ATN */
735 mesh_flush_io(mr); 735 mesh_flush_io(mr);
736 udelay(1); 736 udelay(1);
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index c65c418a7906..1cf11c3322fb 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 9820f272f889..665017eda8a6 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -40,13 +40,14 @@
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/device.h>
43#include "scsi.h" 44#include "scsi.h"
44#include <scsi/scsi_host.h> 45#include <scsi/scsi_host.h>
45#include <asm/io.h> 46#include <asm/io.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
47 48
48#define DRV_NAME "pdc_adma" 49#define DRV_NAME "pdc_adma"
49#define DRV_VERSION "0.01" 50#define DRV_VERSION "0.03"
50 51
51/* macro to calculate base address for ATA regs */ 52/* macro to calculate base address for ATA regs */
52#define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) 53#define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40))
@@ -79,7 +80,6 @@ enum {
79 aNIEN = (1 << 8), /* irq mask: 1==masked */ 80 aNIEN = (1 << 8), /* irq mask: 1==masked */
80 aGO = (1 << 7), /* packet trigger ("Go!") */ 81 aGO = (1 << 7), /* packet trigger ("Go!") */
81 aRSTADM = (1 << 5), /* ADMA logic reset */ 82 aRSTADM = (1 << 5), /* ADMA logic reset */
82 aRSTA = (1 << 2), /* ATA hard reset */
83 aPIOMD4 = 0x0003, /* PIO mode 4 */ 83 aPIOMD4 = 0x0003, /* PIO mode 4 */
84 84
85 /* ADMA_STATUS register bits */ 85 /* ADMA_STATUS register bits */
@@ -452,24 +452,28 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
452 struct adma_port_priv *pp; 452 struct adma_port_priv *pp;
453 struct ata_queued_cmd *qc; 453 struct ata_queued_cmd *qc;
454 void __iomem *chan = ADMA_REGS(mmio_base, port_no); 454 void __iomem *chan = ADMA_REGS(mmio_base, port_no);
455 u8 drv_stat, status = readb(chan + ADMA_STATUS); 455 u8 status = readb(chan + ADMA_STATUS);
456 456
457 if (status == 0) 457 if (status == 0)
458 continue; 458 continue;
459 handled = 1; 459 handled = 1;
460 adma_enter_reg_mode(ap); 460 adma_enter_reg_mode(ap);
461 if ((ap->flags & ATA_FLAG_PORT_DISABLED)) 461 if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))
462 continue; 462 continue;
463 pp = ap->private_data; 463 pp = ap->private_data;
464 if (!pp || pp->state != adma_state_pkt) 464 if (!pp || pp->state != adma_state_pkt)
465 continue; 465 continue;
466 qc = ata_qc_from_tag(ap, ap->active_tag); 466 qc = ata_qc_from_tag(ap, ap->active_tag);
467 drv_stat = 0; 467 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
468 if ((status & (aPERR | aPSD | aUIRQ))) 468 unsigned int err_mask = 0;
469 drv_stat = ATA_ERR; 469
470 else if (pp->pkt[0] != cDONE) 470 if ((status & (aPERR | aPSD | aUIRQ)))
471 drv_stat = ATA_ERR; 471 err_mask = AC_ERR_OTHER;
472 ata_qc_complete(qc, drv_stat); 472 else if (pp->pkt[0] != cDONE)
473 err_mask = AC_ERR_OTHER;
474
475 ata_qc_complete(qc, err_mask);
476 }
473 } 477 }
474 return handled; 478 return handled;
475} 479}
@@ -490,7 +494,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
490 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 494 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
491 495
492 /* check main status, clearing INTRQ */ 496 /* check main status, clearing INTRQ */
493 u8 status = ata_chk_status(ap); 497 u8 status = ata_check_status(ap);
494 if ((status & ATA_BUSY)) 498 if ((status & ATA_BUSY))
495 continue; 499 continue;
496 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", 500 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
@@ -498,7 +502,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
498 502
499 /* complete taskfile transaction */ 503 /* complete taskfile transaction */
500 pp->state = adma_state_idle; 504 pp->state = adma_state_idle;
501 ata_qc_complete(qc, status); 505 ata_qc_complete(qc, ac_err_mask(status));
502 handled = 1; 506 handled = 1;
503 } 507 }
504 } 508 }
@@ -561,15 +565,15 @@ static int adma_port_start(struct ata_port *ap)
561 if ((pp->pkt_dma & 7) != 0) { 565 if ((pp->pkt_dma & 7) != 0) {
562 printk("bad alignment for pp->pkt_dma: %08x\n", 566 printk("bad alignment for pp->pkt_dma: %08x\n",
563 (u32)pp->pkt_dma); 567 (u32)pp->pkt_dma);
564 goto err_out_kfree2; 568 dma_free_coherent(dev, ADMA_PKT_BYTES,
569 pp->pkt, pp->pkt_dma);
570 goto err_out_kfree;
565 } 571 }
566 memset(pp->pkt, 0, ADMA_PKT_BYTES); 572 memset(pp->pkt, 0, ADMA_PKT_BYTES);
567 ap->private_data = pp; 573 ap->private_data = pp;
568 adma_reinit_engine(ap); 574 adma_reinit_engine(ap);
569 return 0; 575 return 0;
570 576
571err_out_kfree2:
572 kfree(pp);
573err_out_kfree: 577err_out_kfree:
574 kfree(pp); 578 kfree(pp);
575err_out: 579err_out:
@@ -623,16 +627,14 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
623 627
624 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 628 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
625 if (rc) { 629 if (rc) {
626 printk(KERN_ERR DRV_NAME 630 dev_printk(KERN_ERR, &pdev->dev,
627 "(%s): 32-bit DMA enable failed\n", 631 "32-bit DMA enable failed\n");
628 pci_name(pdev));
629 return rc; 632 return rc;
630 } 633 }
631 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 634 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
632 if (rc) { 635 if (rc) {
633 printk(KERN_ERR DRV_NAME 636 dev_printk(KERN_ERR, &pdev->dev,
634 "(%s): 32-bit consistent DMA enable failed\n", 637 "32-bit consistent DMA enable failed\n");
635 pci_name(pdev));
636 return rc; 638 return rc;
637 } 639 }
638 return 0; 640 return 0;
@@ -648,7 +650,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
648 int rc, port_no; 650 int rc, port_no;
649 651
650 if (!printed_version++) 652 if (!printed_version++)
651 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 653 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
652 654
653 rc = pci_enable_device(pdev); 655 rc = pci_enable_device(pdev);
654 if (rc) 656 if (rc)
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 422e0b6f603a..46dbdee79f77 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -29,6 +29,7 @@
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/device.h>
32#include "scsi.h" 33#include "scsi.h"
33#include <scsi/scsi_host.h> 34#include <scsi/scsi_host.h>
34#include <linux/libata.h> 35#include <linux/libata.h>
@@ -258,7 +259,6 @@ struct mv_host_priv {
258static void mv_irq_clear(struct ata_port *ap); 259static void mv_irq_clear(struct ata_port *ap);
259static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); 260static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
260static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 261static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
261static u8 mv_check_err(struct ata_port *ap);
262static void mv_phy_reset(struct ata_port *ap); 262static void mv_phy_reset(struct ata_port *ap);
263static void mv_host_stop(struct ata_host_set *host_set); 263static void mv_host_stop(struct ata_host_set *host_set);
264static int mv_port_start(struct ata_port *ap); 264static int mv_port_start(struct ata_port *ap);
@@ -296,7 +296,6 @@ static const struct ata_port_operations mv_ops = {
296 .tf_load = ata_tf_load, 296 .tf_load = ata_tf_load,
297 .tf_read = ata_tf_read, 297 .tf_read = ata_tf_read,
298 .check_status = ata_check_status, 298 .check_status = ata_check_status,
299 .check_err = mv_check_err,
300 .exec_command = ata_exec_command, 299 .exec_command = ata_exec_command,
301 .dev_select = ata_std_dev_select, 300 .dev_select = ata_std_dev_select,
302 301
@@ -1067,6 +1066,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1067 struct ata_queued_cmd *qc; 1066 struct ata_queued_cmd *qc;
1068 u32 hc_irq_cause; 1067 u32 hc_irq_cause;
1069 int shift, port, port0, hard_port, handled; 1068 int shift, port, port0, hard_port, handled;
1069 unsigned int err_mask;
1070 u8 ata_status = 0; 1070 u8 ata_status = 0;
1071 1071
1072 if (hc == 0) { 1072 if (hc == 0) {
@@ -1102,15 +1102,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1102 handled++; 1102 handled++;
1103 } 1103 }
1104 1104
1105 err_mask = ac_err_mask(ata_status);
1106
1105 shift = port << 1; /* (port * 2) */ 1107 shift = port << 1; /* (port * 2) */
1106 if (port >= MV_PORTS_PER_HC) { 1108 if (port >= MV_PORTS_PER_HC) {
1107 shift++; /* skip bit 8 in the HC Main IRQ reg */ 1109 shift++; /* skip bit 8 in the HC Main IRQ reg */
1108 } 1110 }
1109 if ((PORT0_ERR << shift) & relevant) { 1111 if ((PORT0_ERR << shift) & relevant) {
1110 mv_err_intr(ap); 1112 mv_err_intr(ap);
1111 /* OR in ATA_ERR to ensure libata knows we took one */ 1113 err_mask |= AC_ERR_OTHER;
1112 ata_status = readb((void __iomem *)
1113 ap->ioaddr.status_addr) | ATA_ERR;
1114 handled++; 1114 handled++;
1115 } 1115 }
1116 1116
@@ -1120,7 +1120,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1120 VPRINTK("port %u IRQ found for qc, " 1120 VPRINTK("port %u IRQ found for qc, "
1121 "ata_status 0x%x\n", port,ata_status); 1121 "ata_status 0x%x\n", port,ata_status);
1122 /* mark qc status appropriately */ 1122 /* mark qc status appropriately */
1123 ata_qc_complete(qc, ata_status); 1123 ata_qc_complete(qc, err_mask);
1124 } 1124 }
1125 } 1125 }
1126 } 1126 }
@@ -1185,22 +1185,6 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1185} 1185}
1186 1186
1187/** 1187/**
1188 * mv_check_err - Return the error shadow register to caller.
1189 * @ap: ATA channel to manipulate
1190 *
1191 * Marvell requires DMA to be stopped before accessing shadow
1192 * registers. So we do that, then return the needed register.
1193 *
1194 * LOCKING:
1195 * Inherited from caller. FIXME: protect mv_stop_dma with lock?
1196 */
1197static u8 mv_check_err(struct ata_port *ap)
1198{
1199 mv_stop_dma(ap); /* can't read shadow regs if DMA on */
1200 return readb((void __iomem *) ap->ioaddr.error_addr);
1201}
1202
1203/**
1204 * mv_phy_reset - Perform eDMA reset followed by COMRESET 1188 * mv_phy_reset - Perform eDMA reset followed by COMRESET
1205 * @ap: ATA channel to manipulate 1189 * @ap: ATA channel to manipulate
1206 * 1190 *
@@ -1312,7 +1296,7 @@ static void mv_eng_timeout(struct ata_port *ap)
1312 */ 1296 */
1313 spin_lock_irqsave(&ap->host_set->lock, flags); 1297 spin_lock_irqsave(&ap->host_set->lock, flags);
1314 qc->scsidone = scsi_finish_command; 1298 qc->scsidone = scsi_finish_command;
1315 ata_qc_complete(qc, ATA_ERR); 1299 ata_qc_complete(qc, AC_ERR_OTHER);
1316 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1300 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1317 } 1301 }
1318} 1302}
@@ -1454,9 +1438,9 @@ static void mv_print_info(struct ata_probe_ent *probe_ent)
1454 else 1438 else
1455 scc_s = "unknown"; 1439 scc_s = "unknown";
1456 1440
1457 printk(KERN_INFO DRV_NAME 1441 dev_printk(KERN_INFO, &pdev->dev,
1458 "(%s) %u slots %u ports %s mode IRQ via %s\n", 1442 "%u slots %u ports %s mode IRQ via %s\n",
1459 pci_name(pdev), (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports, 1443 (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports,
1460 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); 1444 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
1461} 1445}
1462 1446
@@ -1477,9 +1461,8 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1477 void __iomem *mmio_base; 1461 void __iomem *mmio_base;
1478 int pci_dev_busy = 0, rc; 1462 int pci_dev_busy = 0, rc;
1479 1463
1480 if (!printed_version++) { 1464 if (!printed_version++)
1481 printk(KERN_INFO DRV_NAME " version " DRV_VERSION "\n"); 1465 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
1482 }
1483 1466
1484 rc = pci_enable_device(pdev); 1467 rc = pci_enable_device(pdev);
1485 if (rc) { 1468 if (rc) {
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 1a56d6c79ddd..d573888eda76 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -61,6 +61,7 @@
61#include <linux/blkdev.h> 61#include <linux/blkdev.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/interrupt.h> 63#include <linux/interrupt.h>
64#include <linux/device.h>
64#include "scsi.h" 65#include "scsi.h"
65#include <scsi/scsi_host.h> 66#include <scsi/scsi_host.h>
66#include <linux/libata.h> 67#include <linux/libata.h>
@@ -383,7 +384,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
383 return -ENODEV; 384 return -ENODEV;
384 385
385 if (!printed_version++) 386 if (!printed_version++)
386 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 387 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
387 388
388 rc = pci_enable_device(pdev); 389 rc = pci_enable_device(pdev);
389 if (rc) 390 if (rc)
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index eee93b0016df..b41c977d6fab 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -38,6 +38,7 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/device.h>
41#include "scsi.h" 42#include "scsi.h"
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -195,6 +196,8 @@ static struct ata_port_info pdc_port_info[] = {
195static struct pci_device_id pdc_ata_pci_tbl[] = { 196static struct pci_device_id pdc_ata_pci_tbl[] = {
196 { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 197 { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
197 board_2037x }, 198 board_2037x },
199 { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
200 board_2037x },
198 { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 201 { PCI_VENDOR_ID_PROMISE, 0x3571, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
199 board_2037x }, 202 board_2037x },
200 { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 203 { PCI_VENDOR_ID_PROMISE, 0x3373, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
@@ -207,6 +210,8 @@ static struct pci_device_id pdc_ata_pci_tbl[] = {
207 board_2037x }, 210 board_2037x },
208 { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 211 { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
209 board_2037x }, 212 board_2037x },
213 { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
214 board_2037x },
210 215
211 { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 216 { PCI_VENDOR_ID_PROMISE, 0x3318, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
212 board_20319 }, 217 board_20319 },
@@ -395,7 +400,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
395 case ATA_PROT_DMA: 400 case ATA_PROT_DMA:
396 case ATA_PROT_NODATA: 401 case ATA_PROT_NODATA:
397 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 402 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
398 ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); 403 drv_stat = ata_wait_idle(ap);
404 ata_qc_complete(qc, __ac_err_mask(drv_stat));
399 break; 405 break;
400 406
401 default: 407 default:
@@ -404,7 +410,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
404 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", 410 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
405 ap->id, qc->tf.command, drv_stat); 411 ap->id, qc->tf.command, drv_stat);
406 412
407 ata_qc_complete(qc, drv_stat); 413 ata_qc_complete(qc, ac_err_mask(drv_stat));
408 break; 414 break;
409 } 415 }
410 416
@@ -416,24 +422,21 @@ out:
416static inline unsigned int pdc_host_intr( struct ata_port *ap, 422static inline unsigned int pdc_host_intr( struct ata_port *ap,
417 struct ata_queued_cmd *qc) 423 struct ata_queued_cmd *qc)
418{ 424{
419 u8 status; 425 unsigned int handled = 0, err_mask = 0;
420 unsigned int handled = 0, have_err = 0;
421 u32 tmp; 426 u32 tmp;
422 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; 427 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
423 428
424 tmp = readl(mmio); 429 tmp = readl(mmio);
425 if (tmp & PDC_ERR_MASK) { 430 if (tmp & PDC_ERR_MASK) {
426 have_err = 1; 431 err_mask = AC_ERR_DEV;
427 pdc_reset_port(ap); 432 pdc_reset_port(ap);
428 } 433 }
429 434
430 switch (qc->tf.protocol) { 435 switch (qc->tf.protocol) {
431 case ATA_PROT_DMA: 436 case ATA_PROT_DMA:
432 case ATA_PROT_NODATA: 437 case ATA_PROT_NODATA:
433 status = ata_wait_idle(ap); 438 err_mask |= ac_err_mask(ata_wait_idle(ap));
434 if (have_err) 439 ata_qc_complete(qc, err_mask);
435 status |= ATA_ERR;
436 ata_qc_complete(qc, status);
437 handled = 1; 440 handled = 1;
438 break; 441 break;
439 442
@@ -631,7 +634,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
631 int rc; 634 int rc;
632 635
633 if (!printed_version++) 636 if (!printed_version++)
634 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 637 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
635 638
636 /* 639 /*
637 * If this driver happens to only be useful on Apple's K2, then 640 * If this driver happens to only be useful on Apple's K2, then
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index 250dafa6bc36..9938dae782b6 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/device.h>
38#include "scsi.h" 39#include "scsi.h"
39#include <scsi/scsi_host.h> 40#include <scsi/scsi_host.h>
40#include <asm/io.h> 41#include <asm/io.h>
@@ -400,11 +401,12 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
400 qc = ata_qc_from_tag(ap, ap->active_tag); 401 qc = ata_qc_from_tag(ap, ap->active_tag);
401 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 402 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
402 switch (sHST) { 403 switch (sHST) {
403 case 0: /* sucessful CPB */ 404 case 0: /* successful CPB */
404 case 3: /* device error */ 405 case 3: /* device error */
405 pp->state = qs_state_idle; 406 pp->state = qs_state_idle;
406 qs_enter_reg_mode(qc->ap); 407 qs_enter_reg_mode(qc->ap);
407 ata_qc_complete(qc, sDST); 408 ata_qc_complete(qc,
409 ac_err_mask(sDST));
408 break; 410 break;
409 default: 411 default:
410 break; 412 break;
@@ -433,7 +435,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
433 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 435 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
434 436
435 /* check main status, clearing INTRQ */ 437 /* check main status, clearing INTRQ */
436 u8 status = ata_chk_status(ap); 438 u8 status = ata_check_status(ap);
437 if ((status & ATA_BUSY)) 439 if ((status & ATA_BUSY))
438 continue; 440 continue;
439 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", 441 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
@@ -441,7 +443,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
441 443
442 /* complete taskfile transaction */ 444 /* complete taskfile transaction */
443 pp->state = qs_state_idle; 445 pp->state = qs_state_idle;
444 ata_qc_complete(qc, status); 446 ata_qc_complete(qc, ac_err_mask(status));
445 handled = 1; 447 handled = 1;
446 } 448 }
447 } 449 }
@@ -599,25 +601,22 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
599 if (rc) { 601 if (rc) {
600 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 602 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
601 if (rc) { 603 if (rc) {
602 printk(KERN_ERR DRV_NAME 604 dev_printk(KERN_ERR, &pdev->dev,
603 "(%s): 64-bit DMA enable failed\n", 605 "64-bit DMA enable failed\n");
604 pci_name(pdev));
605 return rc; 606 return rc;
606 } 607 }
607 } 608 }
608 } else { 609 } else {
609 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 610 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
610 if (rc) { 611 if (rc) {
611 printk(KERN_ERR DRV_NAME 612 dev_printk(KERN_ERR, &pdev->dev,
612 "(%s): 32-bit DMA enable failed\n", 613 "32-bit DMA enable failed\n");
613 pci_name(pdev));
614 return rc; 614 return rc;
615 } 615 }
616 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 616 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
617 if (rc) { 617 if (rc) {
618 printk(KERN_ERR DRV_NAME 618 dev_printk(KERN_ERR, &pdev->dev,
619 "(%s): 32-bit consistent DMA enable failed\n", 619 "32-bit consistent DMA enable failed\n");
620 pci_name(pdev));
621 return rc; 620 return rc;
622 } 621 }
623 } 622 }
@@ -634,7 +633,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
634 int rc, port_no; 633 int rc, port_no;
635 634
636 if (!printed_version++) 635 if (!printed_version++)
637 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 636 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
638 637
639 rc = pci_enable_device(pdev); 638 rc = pci_enable_device(pdev);
640 if (rc) 639 if (rc)
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 3a056173fb95..435f7e0085ec 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -41,6 +41,7 @@
41#include <linux/blkdev.h> 41#include <linux/blkdev.h>
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/device.h>
44#include "scsi.h" 45#include "scsi.h"
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
@@ -386,7 +387,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
386 u8 cls; 387 u8 cls;
387 388
388 if (!printed_version++) 389 if (!printed_version++)
389 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 390 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
390 391
391 /* 392 /*
392 * If this driver happens to only be useful on Apple's K2, then 393 * If this driver happens to only be useful on Apple's K2, then
@@ -463,8 +464,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
463 writeb(cls, mmio_base + SIL_FIFO_W3); 464 writeb(cls, mmio_base + SIL_FIFO_W3);
464 } 465 }
465 } else 466 } else
466 printk(KERN_WARNING DRV_NAME "(%s): cache line size not set. Driver may not function\n", 467 dev_printk(KERN_WARNING, &pdev->dev,
467 pci_name(pdev)); 468 "cache line size not set. Driver may not function\n");
468 469
469 if (ent->driver_data == sil_3114) { 470 if (ent->driver_data == sil_3114) {
470 irq_mask = SIL_MASK_4PORT; 471 irq_mask = SIL_MASK_4PORT;
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 32d730bd5bb6..c66548025657 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/device.h>
38#include <scsi/scsi_host.h> 39#include <scsi/scsi_host.h>
39#include "scsi.h" 40#include "scsi.h"
40#include <linux/libata.h> 41#include <linux/libata.h>
@@ -220,12 +221,11 @@ struct sil24_port_priv {
220 221
221/* ap->host_set->private_data */ 222/* ap->host_set->private_data */
222struct sil24_host_priv { 223struct sil24_host_priv {
223 void *host_base; /* global controller control (128 bytes @BAR0) */ 224 void __iomem *host_base; /* global controller control (128 bytes @BAR0) */
224 void *port_base; /* port registers (4 * 8192 bytes @BAR2) */ 225 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */
225}; 226};
226 227
227static u8 sil24_check_status(struct ata_port *ap); 228static u8 sil24_check_status(struct ata_port *ap);
228static u8 sil24_check_err(struct ata_port *ap);
229static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); 229static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
230static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); 230static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val);
231static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); 231static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
@@ -280,7 +280,6 @@ static const struct ata_port_operations sil24_ops = {
280 280
281 .check_status = sil24_check_status, 281 .check_status = sil24_check_status,
282 .check_altstatus = sil24_check_status, 282 .check_altstatus = sil24_check_status,
283 .check_err = sil24_check_err,
284 .dev_select = ata_noop_dev_select, 283 .dev_select = ata_noop_dev_select,
285 284
286 .tf_read = sil24_tf_read, 285 .tf_read = sil24_tf_read,
@@ -349,10 +348,12 @@ static struct ata_port_info sil24_port_info[] = {
349static inline void sil24_update_tf(struct ata_port *ap) 348static inline void sil24_update_tf(struct ata_port *ap)
350{ 349{
351 struct sil24_port_priv *pp = ap->private_data; 350 struct sil24_port_priv *pp = ap->private_data;
352 void *port = (void *)ap->ioaddr.cmd_addr; 351 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
353 struct sil24_prb *prb = port; 352 struct sil24_prb __iomem *prb = port;
353 u8 fis[6 * 4];
354 354
355 ata_tf_from_fis(prb->fis, &pp->tf); 355 memcpy_fromio(fis, prb->fis, 6 * 4);
356 ata_tf_from_fis(fis, &pp->tf);
356} 357}
357 358
358static u8 sil24_check_status(struct ata_port *ap) 359static u8 sil24_check_status(struct ata_port *ap)
@@ -361,12 +362,6 @@ static u8 sil24_check_status(struct ata_port *ap)
361 return pp->tf.command; 362 return pp->tf.command;
362} 363}
363 364
364static 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
370static int sil24_scr_map[] = { 365static int sil24_scr_map[] = {
371 [SCR_CONTROL] = 0, 366 [SCR_CONTROL] = 0,
372 [SCR_STATUS] = 1, 367 [SCR_STATUS] = 1,
@@ -376,9 +371,9 @@ static int sil24_scr_map[] = {
376 371
377static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) 372static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
378{ 373{
379 void *scr_addr = (void *)ap->ioaddr.scr_addr; 374 void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
380 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { 375 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
381 void *addr; 376 void __iomem *addr;
382 addr = scr_addr + sil24_scr_map[sc_reg] * 4; 377 addr = scr_addr + sil24_scr_map[sc_reg] * 4;
383 return readl(scr_addr + sil24_scr_map[sc_reg] * 4); 378 return readl(scr_addr + sil24_scr_map[sc_reg] * 4);
384 } 379 }
@@ -387,9 +382,9 @@ static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
387 382
388static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) 383static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
389{ 384{
390 void *scr_addr = (void *)ap->ioaddr.scr_addr; 385 void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr;
391 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { 386 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
392 void *addr; 387 void __iomem *addr;
393 addr = scr_addr + sil24_scr_map[sc_reg] * 4; 388 addr = scr_addr + sil24_scr_map[sc_reg] * 4;
394 writel(val, scr_addr + sil24_scr_map[sc_reg] * 4); 389 writel(val, scr_addr + sil24_scr_map[sc_reg] * 4);
395 } 390 }
@@ -454,7 +449,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
454static int sil24_qc_issue(struct ata_queued_cmd *qc) 449static int sil24_qc_issue(struct ata_queued_cmd *qc)
455{ 450{
456 struct ata_port *ap = qc->ap; 451 struct ata_port *ap = qc->ap;
457 void *port = (void *)ap->ioaddr.cmd_addr; 452 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
458 struct sil24_port_priv *pp = ap->private_data; 453 struct sil24_port_priv *pp = ap->private_data;
459 dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block); 454 dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block);
460 455
@@ -467,7 +462,7 @@ static void sil24_irq_clear(struct ata_port *ap)
467 /* unused */ 462 /* unused */
468} 463}
469 464
470static int __sil24_reset_controller(void *port) 465static int __sil24_reset_controller(void __iomem *port)
471{ 466{
472 int cnt; 467 int cnt;
473 u32 tmp; 468 u32 tmp;
@@ -493,7 +488,7 @@ static void sil24_reset_controller(struct ata_port *ap)
493{ 488{
494 printk(KERN_NOTICE DRV_NAME 489 printk(KERN_NOTICE DRV_NAME
495 " ata%u: resetting controller...\n", ap->id); 490 " ata%u: resetting controller...\n", ap->id);
496 if (__sil24_reset_controller((void *)ap->ioaddr.cmd_addr)) 491 if (__sil24_reset_controller((void __iomem *)ap->ioaddr.cmd_addr))
497 printk(KERN_ERR DRV_NAME 492 printk(KERN_ERR DRV_NAME
498 " ata%u: failed to reset controller\n", ap->id); 493 " ata%u: failed to reset controller\n", ap->id);
499} 494}
@@ -504,7 +499,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
504 499
505 qc = ata_qc_from_tag(ap, ap->active_tag); 500 qc = ata_qc_from_tag(ap, ap->active_tag);
506 if (!qc) { 501 if (!qc) {
507 printk(KERN_ERR "ata%u: BUG: tiemout without command\n", 502 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
508 ap->id); 503 ap->id);
509 return; 504 return;
510 } 505 }
@@ -518,7 +513,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
518 */ 513 */
519 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 514 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
520 qc->scsidone = scsi_finish_command; 515 qc->scsidone = scsi_finish_command;
521 ata_qc_complete(qc, ATA_ERR); 516 ata_qc_complete(qc, AC_ERR_OTHER);
522 517
523 sil24_reset_controller(ap); 518 sil24_reset_controller(ap);
524} 519}
@@ -527,8 +522,9 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
527{ 522{
528 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); 523 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
529 struct sil24_port_priv *pp = ap->private_data; 524 struct sil24_port_priv *pp = ap->private_data;
530 void *port = (void *)ap->ioaddr.cmd_addr; 525 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
531 u32 irq_stat, cmd_err, sstatus, serror; 526 u32 irq_stat, cmd_err, sstatus, serror;
527 unsigned int err_mask;
532 528
533 irq_stat = readl(port + PORT_IRQ_STAT); 529 irq_stat = readl(port + PORT_IRQ_STAT);
534 writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ 530 writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */
@@ -556,17 +552,18 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
556 * Device is reporting error, tf registers are valid. 552 * Device is reporting error, tf registers are valid.
557 */ 553 */
558 sil24_update_tf(ap); 554 sil24_update_tf(ap);
555 err_mask = ac_err_mask(pp->tf.command);
559 } else { 556 } else {
560 /* 557 /*
561 * Other errors. libata currently doesn't have any 558 * Other errors. libata currently doesn't have any
562 * mechanism to report these errors. Just turn on 559 * mechanism to report these errors. Just turn on
563 * ATA_ERR. 560 * ATA_ERR.
564 */ 561 */
565 pp->tf.command = ATA_ERR; 562 err_mask = AC_ERR_OTHER;
566 } 563 }
567 564
568 if (qc) 565 if (qc)
569 ata_qc_complete(qc, pp->tf.command); 566 ata_qc_complete(qc, err_mask);
570 567
571 sil24_reset_controller(ap); 568 sil24_reset_controller(ap);
572} 569}
@@ -574,7 +571,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
574static inline void sil24_host_intr(struct ata_port *ap) 571static inline void sil24_host_intr(struct ata_port *ap)
575{ 572{
576 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); 573 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
577 void *port = (void *)ap->ioaddr.cmd_addr; 574 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
578 u32 slot_stat; 575 u32 slot_stat;
579 576
580 slot_stat = readl(port + PORT_SLOT_STAT); 577 slot_stat = readl(port + PORT_SLOT_STAT);
@@ -591,7 +588,7 @@ static inline void sil24_host_intr(struct ata_port *ap)
591 sil24_update_tf(ap); 588 sil24_update_tf(ap);
592 589
593 if (qc) 590 if (qc)
594 ata_qc_complete(qc, pp->tf.command); 591 ata_qc_complete(qc, ac_err_mask(pp->tf.command));
595 } else 592 } else
596 sil24_error_intr(ap, slot_stat); 593 sil24_error_intr(ap, slot_stat);
597} 594}
@@ -689,11 +686,12 @@ 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]; 686 struct ata_port_info *pinfo = &sil24_port_info[board_id];
690 struct ata_probe_ent *probe_ent = NULL; 687 struct ata_probe_ent *probe_ent = NULL;
691 struct sil24_host_priv *hpriv = NULL; 688 struct sil24_host_priv *hpriv = NULL;
692 void *host_base = NULL, *port_base = NULL; 689 void __iomem *host_base = NULL;
690 void __iomem *port_base = NULL;
693 int i, rc; 691 int i, rc;
694 692
695 if (!printed_version++) 693 if (!printed_version++)
696 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 694 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
697 695
698 rc = pci_enable_device(pdev); 696 rc = pci_enable_device(pdev);
699 if (rc) 697 if (rc)
@@ -753,14 +751,14 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
753 */ 751 */
754 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 752 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
755 if (rc) { 753 if (rc) {
756 printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", 754 dev_printk(KERN_ERR, &pdev->dev,
757 pci_name(pdev)); 755 "32-bit DMA enable failed\n");
758 goto out_free; 756 goto out_free;
759 } 757 }
760 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 758 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
761 if (rc) { 759 if (rc) {
762 printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", 760 dev_printk(KERN_ERR, &pdev->dev,
763 pci_name(pdev)); 761 "32-bit consistent DMA enable failed\n");
764 goto out_free; 762 goto out_free;
765 } 763 }
766 764
@@ -771,7 +769,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
771 writel(0, host_base + HOST_CTRL); 769 writel(0, host_base + HOST_CTRL);
772 770
773 for (i = 0; i < probe_ent->n_ports; i++) { 771 for (i = 0; i < probe_ent->n_ports; i++) {
774 void *port = port_base + i * PORT_REGS_SIZE; 772 void __iomem *port = port_base + i * PORT_REGS_SIZE;
775 unsigned long portu = (unsigned long)port; 773 unsigned long portu = (unsigned long)port;
776 u32 tmp; 774 u32 tmp;
777 int cnt; 775 int cnt;
@@ -796,9 +794,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
796 break; 794 break;
797 } 795 }
798 if (tmp & PORT_CS_PORT_RST) 796 if (tmp & PORT_CS_PORT_RST)
799 printk(KERN_ERR DRV_NAME 797 dev_printk(KERN_ERR, &pdev->dev,
800 "(%s): failed to clear port RST\n", 798 "failed to clear port RST\n");
801 pci_name(pdev));
802 } 799 }
803 800
804 /* Zero error counters. */ 801 /* Zero error counters. */
@@ -827,9 +824,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
827 824
828 /* Reset itself */ 825 /* Reset itself */
829 if (__sil24_reset_controller(port)) 826 if (__sil24_reset_controller(port))
830 printk(KERN_ERR DRV_NAME 827 dev_printk(KERN_ERR, &pdev->dev,
831 "(%s): failed to reset controller\n", 828 "failed to reset controller\n");
832 pci_name(pdev));
833 } 829 }
834 830
835 /* Turn on interrupts */ 831 /* Turn on interrupts */
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 057f7b98b6c4..42288be0e561 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -38,6 +38,7 @@
38#include <linux/blkdev.h> 38#include <linux/blkdev.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/device.h>
41#include "scsi.h" 42#include "scsi.h"
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -237,6 +238,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
237 238
238static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 239static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
239{ 240{
241 static int printed_version;
240 struct ata_probe_ent *probe_ent = NULL; 242 struct ata_probe_ent *probe_ent = NULL;
241 int rc; 243 int rc;
242 u32 genctl; 244 u32 genctl;
@@ -245,6 +247,9 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
245 u8 pmr; 247 u8 pmr;
246 u8 port2_start; 248 u8 port2_start;
247 249
250 if (!printed_version++)
251 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
252
248 rc = pci_enable_device(pdev); 253 rc = pci_enable_device(pdev);
249 if (rc) 254 if (rc)
250 return rc; 255 return rc;
@@ -288,16 +293,18 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
288 pci_read_config_byte(pdev, SIS_PMR, &pmr); 293 pci_read_config_byte(pdev, SIS_PMR, &pmr);
289 if (ent->device != 0x182) { 294 if (ent->device != 0x182) {
290 if ((pmr & SIS_PMR_COMBINED) == 0) { 295 if ((pmr & SIS_PMR_COMBINED) == 0) {
291 printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in SATA mode\n"); 296 dev_printk(KERN_INFO, &pdev->dev,
297 "Detected SiS 180/181 chipset in SATA mode\n");
292 port2_start = 64; 298 port2_start = 64;
293 } 299 }
294 else { 300 else {
295 printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in combined mode\n"); 301 dev_printk(KERN_INFO, &pdev->dev,
302 "Detected SiS 180/181 chipset in combined mode\n");
296 port2_start=0; 303 port2_start=0;
297 } 304 }
298 } 305 }
299 else { 306 else {
300 printk(KERN_INFO "sata_sis: Detected SiS 182 chipset\n"); 307 dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182 chipset\n");
301 port2_start = 0x20; 308 port2_start = 0x20;
302 } 309 }
303 310
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index e0f9570bc6dd..db615ff794d8 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -44,6 +44,7 @@
44#include <linux/blkdev.h> 44#include <linux/blkdev.h>
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/interrupt.h> 46#include <linux/interrupt.h>
47#include <linux/device.h>
47#include "scsi.h" 48#include "scsi.h"
48#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
49#include <linux/libata.h> 50#include <linux/libata.h>
@@ -84,6 +85,8 @@
84/* Port stride */ 85/* Port stride */
85#define K2_SATA_PORT_OFFSET 0x100 86#define K2_SATA_PORT_OFFSET 0x100
86 87
88static u8 k2_stat_check_status(struct ata_port *ap);
89
87 90
88static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) 91static u32 k2_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
89{ 92{
@@ -136,16 +139,24 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
136static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) 139static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
137{ 140{
138 struct ata_ioports *ioaddr = &ap->ioaddr; 141 struct ata_ioports *ioaddr = &ap->ioaddr;
139 u16 nsect, lbal, lbam, lbah; 142 u16 nsect, lbal, lbam, lbah, feature;
140 143
141 nsect = tf->nsect = readw(ioaddr->nsect_addr); 144 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); 145 tf->device = readw(ioaddr->device_addr);
146 feature = readw(ioaddr->error_addr);
147 nsect = readw(ioaddr->nsect_addr);
148 lbal = readw(ioaddr->lbal_addr);
149 lbam = readw(ioaddr->lbam_addr);
150 lbah = readw(ioaddr->lbah_addr);
151
152 tf->feature = feature;
153 tf->nsect = nsect;
154 tf->lbal = lbal;
155 tf->lbam = lbam;
156 tf->lbah = lbah;
146 157
147 if (tf->flags & ATA_TFLAG_LBA48) { 158 if (tf->flags & ATA_TFLAG_LBA48) {
148 tf->hob_feature = readw(ioaddr->error_addr) >> 8; 159 tf->hob_feature = feature >> 8;
149 tf->hob_nsect = nsect >> 8; 160 tf->hob_nsect = nsect >> 8;
150 tf->hob_lbal = lbal >> 8; 161 tf->hob_lbal = lbal >> 8;
151 tf->hob_lbam = lbam >> 8; 162 tf->hob_lbam = lbam >> 8;
@@ -352,7 +363,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
352 int i; 363 int i;
353 364
354 if (!printed_version++) 365 if (!printed_version++)
355 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 366 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
356 367
357 /* 368 /*
358 * If this driver happens to only be useful on Apple's K2, then 369 * If this driver happens to only be useful on Apple's K2, then
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index af08f4f650c1..0ec21e09f5d8 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -38,6 +38,7 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/device.h>
41#include "scsi.h" 42#include "scsi.h"
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -718,7 +719,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
718 VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, 719 VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id,
719 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); 720 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
720 /* get drive status; clear intr; complete txn */ 721 /* get drive status; clear intr; complete txn */
721 ata_qc_complete(qc, ata_wait_idle(ap)); 722 ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
722 pdc20621_pop_hdma(qc); 723 pdc20621_pop_hdma(qc);
723 } 724 }
724 725
@@ -756,7 +757,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
756 VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, 757 VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id,
757 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); 758 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
758 /* get drive status; clear intr; complete txn */ 759 /* get drive status; clear intr; complete txn */
759 ata_qc_complete(qc, ata_wait_idle(ap)); 760 ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
760 pdc20621_pop_hdma(qc); 761 pdc20621_pop_hdma(qc);
761 } 762 }
762 handled = 1; 763 handled = 1;
@@ -766,7 +767,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
766 767
767 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 768 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
768 DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); 769 DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
769 ata_qc_complete(qc, status); 770 ata_qc_complete(qc, ac_err_mask(status));
770 handled = 1; 771 handled = 1;
771 772
772 } else { 773 } else {
@@ -881,7 +882,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
881 case ATA_PROT_DMA: 882 case ATA_PROT_DMA:
882 case ATA_PROT_NODATA: 883 case ATA_PROT_NODATA:
883 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 884 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
884 ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); 885 ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap)));
885 break; 886 break;
886 887
887 default: 888 default:
@@ -890,7 +891,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
890 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", 891 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
891 ap->id, qc->tf.command, drv_stat); 892 ap->id, qc->tf.command, drv_stat);
892 893
893 ata_qc_complete(qc, drv_stat); 894 ata_qc_complete(qc, ac_err_mask(drv_stat));
894 break; 895 break;
895 } 896 }
896 897
@@ -1385,7 +1386,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1385 int rc; 1386 int rc;
1386 1387
1387 if (!printed_version++) 1388 if (!printed_version++)
1388 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 1389 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1389 1390
1390 /* 1391 /*
1391 * If this driver happens to only be useful on Apple's K2, then 1392 * If this driver happens to only be useful on Apple's K2, then
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index d68dc7d3422c..a5e245c098e1 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -32,6 +32,7 @@
32#include <linux/blkdev.h> 32#include <linux/blkdev.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/device.h>
35#include "scsi.h" 36#include "scsi.h"
36#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
37#include <linux/libata.h> 38#include <linux/libata.h>
@@ -178,12 +179,16 @@ static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
178 179
179static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 180static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
180{ 181{
182 static int printed_version;
181 struct ata_probe_ent *probe_ent; 183 struct ata_probe_ent *probe_ent;
182 struct ata_port_info *ppi; 184 struct ata_port_info *ppi;
183 int rc; 185 int rc;
184 unsigned int board_idx = (unsigned int) ent->driver_data; 186 unsigned int board_idx = (unsigned int) ent->driver_data;
185 int pci_dev_busy = 0; 187 int pci_dev_busy = 0;
186 188
189 if (!printed_version++)
190 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
191
187 rc = pci_enable_device(pdev); 192 rc = pci_enable_device(pdev);
188 if (rc) 193 if (rc)
189 return rc; 194 return rc;
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 80e291a909a9..b3ecdbe400e9 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -41,6 +41,7 @@
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/blkdev.h> 42#include <linux/blkdev.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/device.h>
44#include "scsi.h" 45#include "scsi.h"
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
@@ -259,15 +260,15 @@ static void svia_configure(struct pci_dev *pdev)
259 u8 tmp8; 260 u8 tmp8;
260 261
261 pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); 262 pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8);
262 printk(KERN_INFO DRV_NAME "(%s): routed to hard irq line %d\n", 263 dev_printk(KERN_INFO, &pdev->dev, "routed to hard irq line %d\n",
263 pci_name(pdev),
264 (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); 264 (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f);
265 265
266 /* make sure SATA channels are enabled */ 266 /* make sure SATA channels are enabled */
267 pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); 267 pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8);
268 if ((tmp8 & ALL_PORTS) != ALL_PORTS) { 268 if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
269 printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channels (0x%x)\n", 269 dev_printk(KERN_DEBUG, &pdev->dev,
270 pci_name(pdev), (int) tmp8); 270 "enabling SATA channels (0x%x)\n",
271 (int) tmp8);
271 tmp8 |= ALL_PORTS; 272 tmp8 |= ALL_PORTS;
272 pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); 273 pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8);
273 } 274 }
@@ -275,8 +276,9 @@ static void svia_configure(struct pci_dev *pdev)
275 /* make sure interrupts for each channel sent to us */ 276 /* make sure interrupts for each channel sent to us */
276 pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); 277 pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8);
277 if ((tmp8 & ALL_PORTS) != ALL_PORTS) { 278 if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
278 printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel interrupts (0x%x)\n", 279 dev_printk(KERN_DEBUG, &pdev->dev,
279 pci_name(pdev), (int) tmp8); 280 "enabling SATA channel interrupts (0x%x)\n",
281 (int) tmp8);
280 tmp8 |= ALL_PORTS; 282 tmp8 |= ALL_PORTS;
281 pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); 283 pci_write_config_byte(pdev, SATA_INT_GATE, tmp8);
282 } 284 }
@@ -284,8 +286,9 @@ static void svia_configure(struct pci_dev *pdev)
284 /* make sure native mode is enabled */ 286 /* make sure native mode is enabled */
285 pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); 287 pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8);
286 if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { 288 if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) {
287 printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel native mode (0x%x)\n", 289 dev_printk(KERN_DEBUG, &pdev->dev,
288 pci_name(pdev), (int) tmp8); 290 "enabling SATA channel native mode (0x%x)\n",
291 (int) tmp8);
289 tmp8 |= NATIVE_MODE_ALL; 292 tmp8 |= NATIVE_MODE_ALL;
290 pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); 293 pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8);
291 } 294 }
@@ -303,7 +306,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
303 u8 tmp8; 306 u8 tmp8;
304 307
305 if (!printed_version++) 308 if (!printed_version++)
306 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 309 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
307 310
308 rc = pci_enable_device(pdev); 311 rc = pci_enable_device(pdev);
309 if (rc) 312 if (rc)
@@ -318,8 +321,9 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
318 if (board_id == vt6420) { 321 if (board_id == vt6420) {
319 pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); 322 pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8);
320 if (tmp8 & SATA_2DEV) { 323 if (tmp8 & SATA_2DEV) {
321 printk(KERN_ERR DRV_NAME "(%s): SATA master/slave not supported (0x%x)\n", 324 dev_printk(KERN_ERR, &pdev->dev,
322 pci_name(pdev), (int) tmp8); 325 "SATA master/slave not supported (0x%x)\n",
326 (int) tmp8);
323 rc = -EIO; 327 rc = -EIO;
324 goto err_out_regions; 328 goto err_out_regions;
325 } 329 }
@@ -332,10 +336,11 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
332 for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++) 336 for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++)
333 if ((pci_resource_start(pdev, i) == 0) || 337 if ((pci_resource_start(pdev, i) == 0) ||
334 (pci_resource_len(pdev, i) < bar_sizes[i])) { 338 (pci_resource_len(pdev, i) < bar_sizes[i])) {
335 printk(KERN_ERR DRV_NAME "(%s): invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", 339 dev_printk(KERN_ERR, &pdev->dev,
336 pci_name(pdev), i, 340 "invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n",
337 pci_resource_start(pdev, i), 341 i,
338 pci_resource_len(pdev, i)); 342 pci_resource_start(pdev, i),
343 pci_resource_len(pdev, i));
339 rc = -ENODEV; 344 rc = -ENODEV;
340 goto err_out_regions; 345 goto err_out_regions;
341 } 346 }
@@ -353,8 +358,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
353 probe_ent = vt6421_init_probe_ent(pdev); 358 probe_ent = vt6421_init_probe_ent(pdev);
354 359
355 if (!probe_ent) { 360 if (!probe_ent) {
356 printk(KERN_ERR DRV_NAME "(%s): out of memory\n", 361 dev_printk(KERN_ERR, &pdev->dev, "out of memory\n");
357 pci_name(pdev));
358 rc = -ENOMEM; 362 rc = -ENOMEM;
359 goto err_out_regions; 363 goto err_out_regions;
360 } 364 }
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 5af05fdf8544..bb84ba0c7e83 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -42,6 +42,7 @@
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
45#include <linux/device.h>
45#include "scsi.h" 46#include "scsi.h"
46#include <scsi/scsi_host.h> 47#include <scsi/scsi_host.h>
47#include <linux/libata.h> 48#include <linux/libata.h>
@@ -153,16 +154,24 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
153static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) 154static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
154{ 155{
155 struct ata_ioports *ioaddr = &ap->ioaddr; 156 struct ata_ioports *ioaddr = &ap->ioaddr;
156 u16 nsect, lbal, lbam, lbah; 157 u16 nsect, lbal, lbam, lbah, feature;
157 158
158 nsect = tf->nsect = readw(ioaddr->nsect_addr); 159 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); 160 tf->device = readw(ioaddr->device_addr);
161 feature = readw(ioaddr->error_addr);
162 nsect = readw(ioaddr->nsect_addr);
163 lbal = readw(ioaddr->lbal_addr);
164 lbam = readw(ioaddr->lbam_addr);
165 lbah = readw(ioaddr->lbah_addr);
166
167 tf->feature = feature;
168 tf->nsect = nsect;
169 tf->lbal = lbal;
170 tf->lbam = lbam;
171 tf->lbah = lbah;
163 172
164 if (tf->flags & ATA_TFLAG_LBA48) { 173 if (tf->flags & ATA_TFLAG_LBA48) {
165 tf->hob_feature = readb(ioaddr->error_addr); 174 tf->hob_feature = feature >> 8;
166 tf->hob_nsect = nsect >> 8; 175 tf->hob_nsect = nsect >> 8;
167 tf->hob_lbal = lbal >> 8; 176 tf->hob_lbal = lbal >> 8;
168 tf->hob_lbam = lbam >> 8; 177 tf->hob_lbam = lbam >> 8;
@@ -287,7 +296,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
287 int rc; 296 int rc;
288 297
289 if (!printed_version++) 298 if (!printed_version++)
290 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 299 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
291 300
292 rc = pci_enable_device(pdev); 301 rc = pci_enable_device(pdev);
293 if (rc) 302 if (rc)
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index ca098fc2a607..6cd5931d9a54 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/sched.h> /* workqueue stuff, HZ */
29#include <scsi/scsi_device.h> 30#include <scsi/scsi_device.h>
30#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
31#include <scsi/scsi_transport.h> 32#include <scsi/scsi_transport.h>
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index d010aeda9d62..49fd18c1a9c6 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -21,8 +21,11 @@
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/string.h>
25#include <linux/slab.h>
24#include <linux/mempool.h> 26#include <linux/mempool.h>
25#include <net/tcp.h> 27#include <net/tcp.h>
28
26#include <scsi/scsi.h> 29#include <scsi/scsi.h>
27#include <scsi/scsi_host.h> 30#include <scsi/scsi_host.h>
28#include <scsi/scsi_device.h> 31#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 49b9269d487a..4f30a37db63c 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
107static int sg_add(struct class_device *); 108static int sg_add(struct class_device *, struct class_interface *);
108static void sg_remove(struct class_device *); 109static void sg_remove(struct class_device *, struct class_interface *);
109 110
110static Scsi_Request *dummy_cmdp; /* only used for sizeof */ 111static Scsi_Request *dummy_cmdp; /* only used for sizeof */
111 112
@@ -1505,7 +1506,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1505} 1506}
1506 1507
1507static int 1508static int
1508sg_add(struct class_device *cl_dev) 1509sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1509{ 1510{
1510 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1511 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
1511 struct gendisk *disk; 1512 struct gendisk *disk;
@@ -1549,7 +1550,7 @@ sg_add(struct class_device *cl_dev)
1549 if (sg_sysfs_valid) { 1550 if (sg_sysfs_valid) {
1550 struct class_device * sg_class_member; 1551 struct class_device * sg_class_member;
1551 1552
1552 sg_class_member = class_device_create(sg_sysfs_class, 1553 sg_class_member = class_device_create(sg_sysfs_class, NULL,
1553 MKDEV(SCSI_GENERIC_MAJOR, k), 1554 MKDEV(SCSI_GENERIC_MAJOR, k),
1554 cl_dev->dev, "%s", 1555 cl_dev->dev, "%s",
1555 disk->disk_name); 1556 disk->disk_name);
@@ -1578,7 +1579,7 @@ out:
1578} 1579}
1579 1580
1580static void 1581static void
1581sg_remove(struct class_device *cl_dev) 1582sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1582{ 1583{
1583 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1584 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
1584 Sg_device *sdp = NULL; 1585 Sg_device *sdp = NULL;
@@ -1882,13 +1883,17 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
1882 int i; 1883 int i;
1883 1884
1884 for (i=0; i < nr_pages; i++) { 1885 for (i=0; i < nr_pages; i++) {
1885 if (dirtied && !PageReserved(sgl[i].page)) 1886 struct page *page = sgl[i].page;
1886 SetPageDirty(sgl[i].page); 1887
1887 /* unlock_page(sgl[i].page); */ 1888 /* XXX: just for debug. Remove when PageReserved is removed */
1889 BUG_ON(PageReserved(page));
1890 if (dirtied)
1891 SetPageDirty(page);
1892 /* unlock_page(page); */
1888 /* FIXME: cache flush missing for rw==READ 1893 /* FIXME: cache flush missing for rw==READ
1889 * FIXME: call the correct reference counting function 1894 * FIXME: call the correct reference counting function
1890 */ 1895 */
1891 page_cache_release(sgl[i].page); 1896 page_cache_release(page);
1892 } 1897 }
1893 1898
1894 return 0; 1899 return 0;
@@ -1988,9 +1993,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1988 if (!p) 1993 if (!p)
1989 break; 1994 break;
1990 } 1995 }
1991 sclp->page = virt_to_page(p); 1996 sg_set_buf(sclp, p, ret_sz);
1992 sclp->offset = offset_in_page(p);
1993 sclp->length = ret_sz;
1994 1997
1995 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", 1998 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n",
1996 k, sg_scatg2virt(sclp), ret_sz)); 1999 k, sg_scatg2virt(sclp), ret_sz));
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 2913f8792317..6b85f84c8397 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4374,7 +4374,7 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4374 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4374 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4375 STp->disk->disk_name, st_formats[i]); 4375 STp->disk->disk_name, st_formats[i]);
4376 st_class_member = 4376 st_class_member =
4377 class_device_create(st_sysfs_class, 4377 class_device_create(st_sysfs_class, NULL,
4378 MKDEV(SCSI_TAPE_MAJOR, 4378 MKDEV(SCSI_TAPE_MAJOR,
4379 TAPE_MINOR(dev_num, mode, rew)), 4379 TAPE_MINOR(dev_num, mode, rew)),
4380 &STp->device->sdev_gendev, "%s", name); 4380 &STp->device->sdev_gendev, "%s", name);
@@ -4523,12 +4523,16 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p
4523 int i; 4523 int i;
4524 4524
4525 for (i=0; i < nr_pages; i++) { 4525 for (i=0; i < nr_pages; i++) {
4526 if (dirtied && !PageReserved(sgl[i].page)) 4526 struct page *page = sgl[i].page;
4527 SetPageDirty(sgl[i].page); 4527
4528 /* XXX: just for debug. Remove when PageReserved is removed */
4529 BUG_ON(PageReserved(page));
4530 if (dirtied)
4531 SetPageDirty(page);
4528 /* FIXME: cache flush missing for rw==READ 4532 /* FIXME: cache flush missing for rw==READ
4529 * FIXME: call the correct reference counting function 4533 * FIXME: call the correct reference counting function
4530 */ 4534 */
4531 page_cache_release(sgl[i].page); 4535 page_cache_release(page);
4532 } 4536 }
4533 4537
4534 return 0; 4538 return 0;
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index e753ba27dc59..a1a58e1d5ad3 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -37,6 +37,9 @@
37 * along with this program; if not, write to the Free Software 37 * along with this program; if not, write to the Free Software
38 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 38 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 */ 39 */
40
41#include <linux/slab.h>
42
40#include "sym_glue.h" 43#include "sym_glue.h"
41#include "sym_nvram.h" 44#include "sym_nvram.h"
42 45
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index 3131a6bf7ab7..3a264a408216 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -37,6 +37,8 @@
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 */ 38 */
39 39
40#include <linux/gfp.h>
41
40#ifndef SYM_HIPD_H 42#ifndef SYM_HIPD_H
41#define SYM_HIPD_H 43#define SYM_HIPD_H
42 44
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;