diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-03-24 12:29:39 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-03-24 12:29:39 -0500 |
commit | 4bbf7bc4c7bf1c80ec3c942fa5f1b6e6fa67dd99 (patch) | |
tree | c4ff89dc09abe69d58db1e14da22ecda9fdd3ce8 /drivers/scsi | |
parent | 84ac69e8bf9f36eb0166817373336d14fa58f5cc (diff) | |
parent | aec5c3c1a929d7d79a420e943285cf3ba26a7c0d (diff) |
Merge branch 'upstream'
Conflicts:
drivers/scsi/libata-core.c
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/ata_piix.c | 6 | ||||
-rw-r--r-- | drivers/scsi/g_NCR5380.c | 28 | ||||
-rw-r--r-- | drivers/scsi/g_NCR5380.h | 23 | ||||
-rw-r--r-- | drivers/scsi/ide-scsi.c | 11 | ||||
-rw-r--r-- | drivers/scsi/in2000.c | 24 | ||||
-rw-r--r-- | drivers/scsi/libata-bmdma.c | 4 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 333 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 79 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mbox.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_sil.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_vsc.c | 4 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 37 | ||||
-rw-r--r-- | drivers/scsi/sr.h | 1 | ||||
-rw-r--r-- | drivers/scsi/sr_ioctl.c | 19 |
16 files changed, 309 insertions, 268 deletions
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index a74e23d39ba9..2d5be84d8bd4 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -742,7 +742,7 @@ static int piix_disable_ahci(struct pci_dev *pdev) | |||
742 | /** | 742 | /** |
743 | * piix_check_450nx_errata - Check for problem 450NX setup | 743 | * piix_check_450nx_errata - Check for problem 450NX setup |
744 | * @ata_dev: the PCI device to check | 744 | * @ata_dev: the PCI device to check |
745 | * | 745 | * |
746 | * Check for the present of 450NX errata #19 and errata #25. If | 746 | * Check for the present of 450NX errata #19 and errata #25. If |
747 | * they are found return an error code so we can turn off DMA | 747 | * they are found return an error code so we can turn off DMA |
748 | */ | 748 | */ |
@@ -753,7 +753,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev) | |||
753 | u16 cfg; | 753 | u16 cfg; |
754 | u8 rev; | 754 | u8 rev; |
755 | int no_piix_dma = 0; | 755 | int no_piix_dma = 0; |
756 | 756 | ||
757 | while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) | 757 | while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) |
758 | { | 758 | { |
759 | /* Look for 450NX PXB. Check for problem configurations | 759 | /* Look for 450NX PXB. Check for problem configurations |
@@ -772,7 +772,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev) | |||
772 | if(no_piix_dma == 2) | 772 | if(no_piix_dma == 2) |
773 | dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n"); | 773 | dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n"); |
774 | return no_piix_dma; | 774 | return no_piix_dma; |
775 | } | 775 | } |
776 | 776 | ||
777 | static void __devinit piix_init_sata_map(struct pci_dev *pdev, | 777 | static void __devinit piix_init_sata_map(struct pci_dev *pdev, |
778 | struct ata_port_info *pinfo) | 778 | struct ata_port_info *pinfo) |
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index 45756fa90777..e6bcfe949340 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c | |||
@@ -127,7 +127,7 @@ static int ncr_53c400a = NCR_NOT_SET; | |||
127 | static int dtc_3181e = NCR_NOT_SET; | 127 | static int dtc_3181e = NCR_NOT_SET; |
128 | 128 | ||
129 | static struct override { | 129 | static struct override { |
130 | NCR5380_implementation_fields; | 130 | NCR5380_map_type NCR5380_map_name; |
131 | int irq; | 131 | int irq; |
132 | int dma; | 132 | int dma; |
133 | int board; /* Use NCR53c400, Ricoh, etc. extensions ? */ | 133 | int board; /* Use NCR53c400, Ricoh, etc. extensions ? */ |
@@ -299,6 +299,10 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt) | |||
299 | }; | 299 | }; |
300 | int flags = 0; | 300 | int flags = 0; |
301 | struct Scsi_Host *instance; | 301 | struct Scsi_Host *instance; |
302 | #ifdef CONFIG_SCSI_G_NCR5380_MEM | ||
303 | unsigned long base; | ||
304 | void __iomem *iomem; | ||
305 | #endif | ||
302 | 306 | ||
303 | if (ncr_irq != NCR_NOT_SET) | 307 | if (ncr_irq != NCR_NOT_SET) |
304 | overrides[0].irq = ncr_irq; | 308 | overrides[0].irq = ncr_irq; |
@@ -424,15 +428,22 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt) | |||
424 | region_size = NCR5380_region_size; | 428 | region_size = NCR5380_region_size; |
425 | } | 429 | } |
426 | #else | 430 | #else |
427 | if(!request_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380")) | 431 | base = overrides[current_override].NCR5380_map_name; |
432 | if (!request_mem_region(base, NCR5380_region_size, "ncr5380")) | ||
433 | continue; | ||
434 | iomem = ioremap(base, NCR5380_region_size); | ||
435 | if (!iomem) { | ||
436 | release_mem_region(base, NCR5380_region_size); | ||
428 | continue; | 437 | continue; |
438 | } | ||
429 | #endif | 439 | #endif |
430 | instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); | 440 | instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); |
431 | if (instance == NULL) { | 441 | if (instance == NULL) { |
432 | #ifndef CONFIG_SCSI_G_NCR5380_MEM | 442 | #ifndef CONFIG_SCSI_G_NCR5380_MEM |
433 | release_region(overrides[current_override].NCR5380_map_name, region_size); | 443 | release_region(overrides[current_override].NCR5380_map_name, region_size); |
434 | #else | 444 | #else |
435 | release_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size); | 445 | iounmap(iomem); |
446 | release_mem_region(base, NCR5380_region_size); | ||
436 | #endif | 447 | #endif |
437 | continue; | 448 | continue; |
438 | } | 449 | } |
@@ -440,6 +451,8 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt) | |||
440 | instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name; | 451 | instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name; |
441 | #ifndef CONFIG_SCSI_G_NCR5380_MEM | 452 | #ifndef CONFIG_SCSI_G_NCR5380_MEM |
442 | instance->n_io_port = region_size; | 453 | instance->n_io_port = region_size; |
454 | #else | ||
455 | ((struct NCR5380_hostdata *)instance->hostdata).iomem = iomem; | ||
443 | #endif | 456 | #endif |
444 | 457 | ||
445 | NCR5380_init(instance, flags); | 458 | NCR5380_init(instance, flags); |
@@ -509,6 +522,7 @@ int generic_NCR5380_release_resources(struct Scsi_Host *instance) | |||
509 | #ifndef CONFIG_SCSI_G_NCR5380_MEM | 522 | #ifndef CONFIG_SCSI_G_NCR5380_MEM |
510 | release_region(instance->NCR5380_instance_name, instance->n_io_port); | 523 | release_region(instance->NCR5380_instance_name, instance->n_io_port); |
511 | #else | 524 | #else |
525 | iounmap(((struct NCR5380_hostdata *)instance->hostdata).iomem); | ||
512 | release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size); | 526 | release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size); |
513 | #endif | 527 | #endif |
514 | 528 | ||
@@ -586,7 +600,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, | |||
586 | } | 600 | } |
587 | #else | 601 | #else |
588 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ | 602 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ |
589 | isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128); | 603 | memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128); |
590 | #endif | 604 | #endif |
591 | start += 128; | 605 | start += 128; |
592 | blocks--; | 606 | blocks--; |
@@ -606,7 +620,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, | |||
606 | } | 620 | } |
607 | #else | 621 | #else |
608 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ | 622 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ |
609 | isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128); | 623 | memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128); |
610 | #endif | 624 | #endif |
611 | start += 128; | 625 | start += 128; |
612 | blocks--; | 626 | blocks--; |
@@ -671,7 +685,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, | |||
671 | } | 685 | } |
672 | #else | 686 | #else |
673 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ | 687 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ |
674 | isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128); | 688 | memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128); |
675 | #endif | 689 | #endif |
676 | start += 128; | 690 | start += 128; |
677 | blocks--; | 691 | blocks--; |
@@ -687,7 +701,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, | |||
687 | } | 701 | } |
688 | #else | 702 | #else |
689 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ | 703 | /* implies CONFIG_SCSI_G_NCR5380_MEM */ |
690 | isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128); | 704 | memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128); |
691 | #endif | 705 | #endif |
692 | start += 128; | 706 | start += 128; |
693 | blocks--; | 707 | blocks--; |
diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h index 656fbe2f91f6..d60a89cb8052 100644 --- a/drivers/scsi/g_NCR5380.h +++ b/drivers/scsi/g_NCR5380.h | |||
@@ -82,6 +82,15 @@ static const char* generic_NCR5380_info(struct Scsi_Host *); | |||
82 | #define NCR5380_read(reg) (inb(NCR5380_map_name + (reg))) | 82 | #define NCR5380_read(reg) (inb(NCR5380_map_name + (reg))) |
83 | #define NCR5380_write(reg, value) (outb((value), (NCR5380_map_name + (reg)))) | 83 | #define NCR5380_write(reg, value) (outb((value), (NCR5380_map_name + (reg)))) |
84 | 84 | ||
85 | #define NCR5380_implementation_fields \ | ||
86 | NCR5380_map_type NCR5380_map_name | ||
87 | |||
88 | #define NCR5380_local_declare() \ | ||
89 | register NCR5380_implementation_fields | ||
90 | |||
91 | #define NCR5380_setup(instance) \ | ||
92 | NCR5380_map_name = (NCR5380_map_type)((instance)->NCR5380_instance_name) | ||
93 | |||
85 | #else | 94 | #else |
86 | /* therefore CONFIG_SCSI_G_NCR5380_MEM */ | 95 | /* therefore CONFIG_SCSI_G_NCR5380_MEM */ |
87 | 96 | ||
@@ -95,18 +104,20 @@ static const char* generic_NCR5380_info(struct Scsi_Host *); | |||
95 | #define NCR53C400_host_buffer 0x3900 | 104 | #define NCR53C400_host_buffer 0x3900 |
96 | #define NCR5380_region_size 0x3a00 | 105 | #define NCR5380_region_size 0x3a00 |
97 | 106 | ||
98 | #define NCR5380_read(reg) isa_readb(NCR5380_map_name + NCR53C400_mem_base + (reg)) | 107 | #define NCR5380_read(reg) readb(iomem + NCR53C400_mem_base + (reg)) |
99 | #define NCR5380_write(reg, value) isa_writeb(value, NCR5380_map_name + NCR53C400_mem_base + (reg)) | 108 | #define NCR5380_write(reg, value) writeb(value, iomem + NCR53C400_mem_base + (reg)) |
100 | #endif | ||
101 | 109 | ||
102 | #define NCR5380_implementation_fields \ | 110 | #define NCR5380_implementation_fields \ |
103 | NCR5380_map_type NCR5380_map_name | 111 | NCR5380_map_type NCR5380_map_name; \ |
112 | void __iomem *iomem; | ||
104 | 113 | ||
105 | #define NCR5380_local_declare() \ | 114 | #define NCR5380_local_declare() \ |
106 | register NCR5380_implementation_fields | 115 | register void __iomem *iomem |
107 | 116 | ||
108 | #define NCR5380_setup(instance) \ | 117 | #define NCR5380_setup(instance) \ |
109 | NCR5380_map_name = (NCR5380_map_type)((instance)->NCR5380_instance_name) | 118 | iomem = (((struct NCR5380_hostdata *)(instance)->hostdata).iomem) |
119 | |||
120 | #endif | ||
110 | 121 | ||
111 | #define NCR5380_intr generic_NCR5380_intr | 122 | #define NCR5380_intr generic_NCR5380_intr |
112 | #define NCR5380_queue_command generic_NCR5380_queue_command | 123 | #define NCR5380_queue_command generic_NCR5380_queue_command |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 0cf0e4c7ac0c..39b760a24241 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/ide.h> | 47 | #include <linux/ide.h> |
48 | #include <linux/scatterlist.h> | 48 | #include <linux/scatterlist.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/mutex.h> | ||
50 | 51 | ||
51 | #include <asm/io.h> | 52 | #include <asm/io.h> |
52 | #include <asm/bitops.h> | 53 | #include <asm/bitops.h> |
@@ -109,7 +110,7 @@ typedef struct ide_scsi_obj { | |||
109 | unsigned long log; /* log flags */ | 110 | unsigned long log; /* log flags */ |
110 | } idescsi_scsi_t; | 111 | } idescsi_scsi_t; |
111 | 112 | ||
112 | static DECLARE_MUTEX(idescsi_ref_sem); | 113 | static DEFINE_MUTEX(idescsi_ref_mutex); |
113 | 114 | ||
114 | #define ide_scsi_g(disk) \ | 115 | #define ide_scsi_g(disk) \ |
115 | container_of((disk)->private_data, struct ide_scsi_obj, driver) | 116 | container_of((disk)->private_data, struct ide_scsi_obj, driver) |
@@ -118,19 +119,19 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk) | |||
118 | { | 119 | { |
119 | struct ide_scsi_obj *scsi = NULL; | 120 | struct ide_scsi_obj *scsi = NULL; |
120 | 121 | ||
121 | down(&idescsi_ref_sem); | 122 | mutex_lock(&idescsi_ref_mutex); |
122 | scsi = ide_scsi_g(disk); | 123 | scsi = ide_scsi_g(disk); |
123 | if (scsi) | 124 | if (scsi) |
124 | scsi_host_get(scsi->host); | 125 | scsi_host_get(scsi->host); |
125 | up(&idescsi_ref_sem); | 126 | mutex_unlock(&idescsi_ref_mutex); |
126 | return scsi; | 127 | return scsi; |
127 | } | 128 | } |
128 | 129 | ||
129 | static void ide_scsi_put(struct ide_scsi_obj *scsi) | 130 | static void ide_scsi_put(struct ide_scsi_obj *scsi) |
130 | { | 131 | { |
131 | down(&idescsi_ref_sem); | 132 | mutex_lock(&idescsi_ref_mutex); |
132 | scsi_host_put(scsi->host); | 133 | scsi_host_put(scsi->host); |
133 | up(&idescsi_ref_sem); | 134 | mutex_unlock(&idescsi_ref_mutex); |
134 | } | 135 | } |
135 | 136 | ||
136 | static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) | 137 | static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) |
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c index 34daa3e068de..9c519876f8a0 100644 --- a/drivers/scsi/in2000.c +++ b/drivers/scsi/in2000.c | |||
@@ -1898,6 +1898,21 @@ static int int_tab[] in2000__INITDATA = { | |||
1898 | 10 | 1898 | 10 |
1899 | }; | 1899 | }; |
1900 | 1900 | ||
1901 | static int probe_bios(u32 addr, u32 *s1, uchar *switches) | ||
1902 | { | ||
1903 | void __iomem *p = ioremap(addr, 0x34); | ||
1904 | if (!p) | ||
1905 | return 0; | ||
1906 | *s1 = readl(p + 0x10); | ||
1907 | if (*s1 == 0x41564f4e || readl(p + 0x30) == 0x61776c41) { | ||
1908 | /* Read the switch image that's mapped into EPROM space */ | ||
1909 | *switches = ~readb(p + 0x20); | ||
1910 | iounmap(p); | ||
1911 | return 1; | ||
1912 | } | ||
1913 | iounmap(p); | ||
1914 | return 0; | ||
1915 | } | ||
1901 | 1916 | ||
1902 | static int __init in2000_detect(struct scsi_host_template * tpnt) | 1917 | static int __init in2000_detect(struct scsi_host_template * tpnt) |
1903 | { | 1918 | { |
@@ -1930,6 +1945,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt) | |||
1930 | 1945 | ||
1931 | detect_count = 0; | 1946 | detect_count = 0; |
1932 | for (bios = 0; bios_tab[bios]; bios++) { | 1947 | for (bios = 0; bios_tab[bios]; bios++) { |
1948 | u32 s1 = 0; | ||
1933 | if (check_setup_args("ioport", &val, buf)) { | 1949 | if (check_setup_args("ioport", &val, buf)) { |
1934 | base = val; | 1950 | base = val; |
1935 | switches = ~inb(base + IO_SWITCHES) & 0xff; | 1951 | switches = ~inb(base + IO_SWITCHES) & 0xff; |
@@ -1941,13 +1957,9 @@ static int __init in2000_detect(struct scsi_host_template * tpnt) | |||
1941 | * for the obvious ID strings. We look for the 2 most common ones and | 1957 | * for the obvious ID strings. We look for the 2 most common ones and |
1942 | * hope that they cover all the cases... | 1958 | * hope that they cover all the cases... |
1943 | */ | 1959 | */ |
1944 | else if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e || isa_readl(bios_tab[bios] + 0x30) == 0x61776c41) { | 1960 | else if (probe_bios(bios_tab[bios], &s1, &switches)) { |
1945 | printk("Found IN2000 BIOS at 0x%x ", (unsigned int) bios_tab[bios]); | 1961 | printk("Found IN2000 BIOS at 0x%x ", (unsigned int) bios_tab[bios]); |
1946 | 1962 | ||
1947 | /* Read the switch image that's mapped into EPROM space */ | ||
1948 | |||
1949 | switches = ~((isa_readb(bios_tab[bios] + 0x20) & 0xff)); | ||
1950 | |||
1951 | /* Find out where the IO space is */ | 1963 | /* Find out where the IO space is */ |
1952 | 1964 | ||
1953 | x = switches & (SW_ADDR0 | SW_ADDR1); | 1965 | x = switches & (SW_ADDR0 | SW_ADDR1); |
@@ -2037,7 +2049,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt) | |||
2037 | 2049 | ||
2038 | /* Older BIOS's had a 'sync on/off' switch - use its setting */ | 2050 | /* Older BIOS's had a 'sync on/off' switch - use its setting */ |
2039 | 2051 | ||
2040 | if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e && (switches & SW_SYNC_DOS5)) | 2052 | if (s1 == 0x41564f4e && (switches & SW_SYNC_DOS5)) |
2041 | hostdata->sync_off = 0x00; /* sync defaults to on */ | 2053 | hostdata->sync_off = 0x00; /* sync defaults to on */ |
2042 | else | 2054 | else |
2043 | hostdata->sync_off = 0xff; /* sync defaults to off */ | 2055 | hostdata->sync_off = 0xff; /* sync defaults to off */ |
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c index a00a78b30836..95d81d86d8b7 100644 --- a/drivers/scsi/libata-bmdma.c +++ b/drivers/scsi/libata-bmdma.c | |||
@@ -941,7 +941,7 @@ err_out: | |||
941 | * @pdev: PCI device | 941 | * @pdev: PCI device |
942 | * | 942 | * |
943 | * Some PCI ATA devices report simplex mode but in fact can be told to | 943 | * Some PCI ATA devices report simplex mode but in fact can be told to |
944 | * enter non simplex mode. This implements the neccessary logic to | 944 | * enter non simplex mode. This implements the neccessary logic to |
945 | * perform the task on such devices. Calling it on other devices will | 945 | * perform the task on such devices. Calling it on other devices will |
946 | * have -undefined- behaviour. | 946 | * have -undefined- behaviour. |
947 | */ | 947 | */ |
@@ -966,7 +966,7 @@ unsigned long ata_pci_default_filter(const struct ata_port *ap, struct ata_devic | |||
966 | { | 966 | { |
967 | /* Filter out DMA modes if the device has been configured by | 967 | /* Filter out DMA modes if the device has been configured by |
968 | the BIOS as PIO only */ | 968 | the BIOS as PIO only */ |
969 | 969 | ||
970 | if (ap->ioaddr.bmdma_addr == 0) | 970 | if (ap->ioaddr.bmdma_addr == 0) |
971 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); | 971 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); |
972 | return xfer_mask; | 972 | return xfer_mask; |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index dcce0f494d4a..c3c4263fdb12 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -64,10 +64,10 @@ | |||
64 | static unsigned int ata_dev_init_params(struct ata_port *ap, | 64 | static unsigned int ata_dev_init_params(struct ata_port *ap, |
65 | struct ata_device *dev); | 65 | struct ata_device *dev); |
66 | static void ata_set_mode(struct ata_port *ap); | 66 | static void ata_set_mode(struct ata_port *ap); |
67 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); | 67 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, |
68 | struct ata_device *dev); | ||
69 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev); | ||
68 | static void ata_pio_error(struct ata_port *ap); | 70 | static void ata_pio_error(struct ata_port *ap); |
69 | static unsigned int ata_dev_xfermask(struct ata_port *ap, | ||
70 | struct ata_device *dev); | ||
71 | 71 | ||
72 | static unsigned int ata_unique_id = 1; | 72 | static unsigned int ata_unique_id = 1; |
73 | static struct workqueue_struct *ata_wq; | 73 | static struct workqueue_struct *ata_wq; |
@@ -191,7 +191,7 @@ static const u8 ata_rw_cmds[] = { | |||
191 | * ata_rwcmd_protocol - set taskfile r/w commands and protocol | 191 | * ata_rwcmd_protocol - set taskfile r/w commands and protocol |
192 | * @qc: command to examine and configure | 192 | * @qc: command to examine and configure |
193 | * | 193 | * |
194 | * Examine the device configuration and tf->flags to calculate | 194 | * Examine the device configuration and tf->flags to calculate |
195 | * the proper read/write commands and protocol to use. | 195 | * the proper read/write commands and protocol to use. |
196 | * | 196 | * |
197 | * LOCKING: | 197 | * LOCKING: |
@@ -204,7 +204,7 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc) | |||
204 | u8 cmd; | 204 | u8 cmd; |
205 | 205 | ||
206 | int index, fua, lba48, write; | 206 | int index, fua, lba48, write; |
207 | 207 | ||
208 | fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; | 208 | fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; |
209 | lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; | 209 | lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; |
210 | write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; | 210 | write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; |
@@ -253,6 +253,29 @@ static unsigned int ata_pack_xfermask(unsigned int pio_mask, | |||
253 | ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA); | 253 | ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA); |
254 | } | 254 | } |
255 | 255 | ||
256 | /** | ||
257 | * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks | ||
258 | * @xfer_mask: xfer_mask to unpack | ||
259 | * @pio_mask: resulting pio_mask | ||
260 | * @mwdma_mask: resulting mwdma_mask | ||
261 | * @udma_mask: resulting udma_mask | ||
262 | * | ||
263 | * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask. | ||
264 | * Any NULL distination masks will be ignored. | ||
265 | */ | ||
266 | static void ata_unpack_xfermask(unsigned int xfer_mask, | ||
267 | unsigned int *pio_mask, | ||
268 | unsigned int *mwdma_mask, | ||
269 | unsigned int *udma_mask) | ||
270 | { | ||
271 | if (pio_mask) | ||
272 | *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO; | ||
273 | if (mwdma_mask) | ||
274 | *mwdma_mask = (xfer_mask & ATA_MASK_MWDMA) >> ATA_SHIFT_MWDMA; | ||
275 | if (udma_mask) | ||
276 | *udma_mask = (xfer_mask & ATA_MASK_UDMA) >> ATA_SHIFT_UDMA; | ||
277 | } | ||
278 | |||
256 | static const struct ata_xfer_ent { | 279 | static const struct ata_xfer_ent { |
257 | unsigned int shift, bits; | 280 | unsigned int shift, bits; |
258 | u8 base; | 281 | u8 base; |
@@ -373,6 +396,15 @@ static const char *ata_mode_string(unsigned int xfer_mask) | |||
373 | return "<n/a>"; | 396 | return "<n/a>"; |
374 | } | 397 | } |
375 | 398 | ||
399 | static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev) | ||
400 | { | ||
401 | if (ata_dev_present(dev)) { | ||
402 | printk(KERN_WARNING "ata%u: dev %u disabled\n", | ||
403 | ap->id, dev->devno); | ||
404 | dev->class++; | ||
405 | } | ||
406 | } | ||
407 | |||
376 | /** | 408 | /** |
377 | * ata_pio_devchk - PATA device presence detection | 409 | * ata_pio_devchk - PATA device presence detection |
378 | * @ap: ATA channel to examine | 410 | * @ap: ATA channel to examine |
@@ -988,6 +1020,22 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
988 | 1020 | ||
989 | ata_qc_free(qc); | 1021 | ata_qc_free(qc); |
990 | 1022 | ||
1023 | /* XXX - Some LLDDs (sata_mv) disable port on command failure. | ||
1024 | * Until those drivers are fixed, we detect the condition | ||
1025 | * here, fail the command with AC_ERR_SYSTEM and reenable the | ||
1026 | * port. | ||
1027 | * | ||
1028 | * Note that this doesn't change any behavior as internal | ||
1029 | * command failure results in disabling the device in the | ||
1030 | * higher layer for LLDDs without new reset/EH callbacks. | ||
1031 | * | ||
1032 | * Kill the following code as soon as those drivers are fixed. | ||
1033 | */ | ||
1034 | if (ap->flags & ATA_FLAG_PORT_DISABLED) { | ||
1035 | err_mask |= AC_ERR_SYSTEM; | ||
1036 | ata_port_probe(ap); | ||
1037 | } | ||
1038 | |||
991 | return err_mask; | 1039 | return err_mask; |
992 | } | 1040 | } |
993 | 1041 | ||
@@ -1008,7 +1056,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1008 | return 0; | 1056 | return 0; |
1009 | if (speed > 2) | 1057 | if (speed > 2) |
1010 | return 1; | 1058 | return 1; |
1011 | 1059 | ||
1012 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ | 1060 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ |
1013 | 1061 | ||
1014 | if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */ | 1062 | if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */ |
@@ -1034,9 +1082,8 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1034 | * | 1082 | * |
1035 | * Read ID data from the specified device. ATA_CMD_ID_ATA is | 1083 | * Read ID data from the specified device. ATA_CMD_ID_ATA is |
1036 | * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI | 1084 | * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI |
1037 | * devices. This function also takes care of EDD signature | 1085 | * devices. This function also issues ATA_CMD_INIT_DEV_PARAMS |
1038 | * misreporting (to be removed once EDD support is gone) and | 1086 | * for pre-ATA4 drives. |
1039 | * issues ATA_CMD_INIT_DEV_PARAMS for pre-ATA4 drives. | ||
1040 | * | 1087 | * |
1041 | * LOCKING: | 1088 | * LOCKING: |
1042 | * Kernel thread context (may sleep) | 1089 | * Kernel thread context (may sleep) |
@@ -1048,7 +1095,6 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1048 | unsigned int *p_class, int post_reset, u16 **p_id) | 1095 | unsigned int *p_class, int post_reset, u16 **p_id) |
1049 | { | 1096 | { |
1050 | unsigned int class = *p_class; | 1097 | unsigned int class = *p_class; |
1051 | unsigned int using_edd; | ||
1052 | struct ata_taskfile tf; | 1098 | struct ata_taskfile tf; |
1053 | unsigned int err_mask = 0; | 1099 | unsigned int err_mask = 0; |
1054 | u16 *id; | 1100 | u16 *id; |
@@ -1057,12 +1103,6 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1057 | 1103 | ||
1058 | DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno); | 1104 | DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno); |
1059 | 1105 | ||
1060 | if (ap->ops->probe_reset || | ||
1061 | ap->flags & (ATA_FLAG_SRST | ATA_FLAG_SATA_RESET)) | ||
1062 | using_edd = 0; | ||
1063 | else | ||
1064 | using_edd = 1; | ||
1065 | |||
1066 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ | 1106 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ |
1067 | 1107 | ||
1068 | id = kmalloc(sizeof(id[0]) * ATA_ID_WORDS, GFP_KERNEL); | 1108 | id = kmalloc(sizeof(id[0]) * ATA_ID_WORDS, GFP_KERNEL); |
@@ -1092,32 +1132,9 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1092 | 1132 | ||
1093 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, | 1133 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, |
1094 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1134 | id, sizeof(id[0]) * ATA_ID_WORDS); |
1095 | |||
1096 | if (err_mask) { | 1135 | if (err_mask) { |
1097 | rc = -EIO; | 1136 | rc = -EIO; |
1098 | reason = "I/O error"; | 1137 | reason = "I/O error"; |
1099 | |||
1100 | if (err_mask & ~AC_ERR_DEV) | ||
1101 | goto err_out; | ||
1102 | |||
1103 | /* | ||
1104 | * arg! EDD works for all test cases, but seems to return | ||
1105 | * the ATA signature for some ATAPI devices. Until the | ||
1106 | * reason for this is found and fixed, we fix up the mess | ||
1107 | * here. If IDENTIFY DEVICE returns command aborted | ||
1108 | * (as ATAPI devices do), then we issue an | ||
1109 | * IDENTIFY PACKET DEVICE. | ||
1110 | * | ||
1111 | * ATA software reset (SRST, the default) does not appear | ||
1112 | * to have this problem. | ||
1113 | */ | ||
1114 | if ((using_edd) && (class == ATA_DEV_ATA)) { | ||
1115 | u8 err = tf.feature; | ||
1116 | if (err & ATA_ABORTED) { | ||
1117 | class = ATA_DEV_ATAPI; | ||
1118 | goto retry; | ||
1119 | } | ||
1120 | } | ||
1121 | goto err_out; | 1138 | goto err_out; |
1122 | } | 1139 | } |
1123 | 1140 | ||
@@ -1314,7 +1331,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1314 | if (print_info) | 1331 | if (print_info) |
1315 | printk(KERN_INFO "ata%u(%u): applying bridge limits\n", | 1332 | printk(KERN_INFO "ata%u(%u): applying bridge limits\n", |
1316 | ap->id, dev->devno); | 1333 | ap->id, dev->devno); |
1317 | ap->udma_mask &= ATA_UDMA5; | 1334 | dev->udma_mask &= ATA_UDMA5; |
1318 | dev->max_sectors = ATA_MAX_SECTORS; | 1335 | dev->max_sectors = ATA_MAX_SECTORS; |
1319 | } | 1336 | } |
1320 | 1337 | ||
@@ -1325,8 +1342,6 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1325 | return 0; | 1342 | return 0; |
1326 | 1343 | ||
1327 | err_out_nosup: | 1344 | err_out_nosup: |
1328 | printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n", | ||
1329 | ap->id, dev->devno); | ||
1330 | DPRINTK("EXIT, err\n"); | 1345 | DPRINTK("EXIT, err\n"); |
1331 | return rc; | 1346 | return rc; |
1332 | } | 1347 | } |
@@ -1393,7 +1408,7 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1393 | } | 1408 | } |
1394 | 1409 | ||
1395 | if (ata_dev_configure(ap, dev, 1)) { | 1410 | if (ata_dev_configure(ap, dev, 1)) { |
1396 | dev->class++; /* disable device */ | 1411 | ata_dev_disable(ap, dev); |
1397 | continue; | 1412 | continue; |
1398 | } | 1413 | } |
1399 | 1414 | ||
@@ -1539,6 +1554,23 @@ void sata_phy_reset(struct ata_port *ap) | |||
1539 | } | 1554 | } |
1540 | 1555 | ||
1541 | /** | 1556 | /** |
1557 | * ata_dev_pair - return other device on cable | ||
1558 | * @ap: port | ||
1559 | * @adev: device | ||
1560 | * | ||
1561 | * Obtain the other device on the same cable, or if none is | ||
1562 | * present NULL is returned | ||
1563 | */ | ||
1564 | |||
1565 | struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev) | ||
1566 | { | ||
1567 | struct ata_device *pair = &ap->device[1 - adev->devno]; | ||
1568 | if (!ata_dev_present(pair)) | ||
1569 | return NULL; | ||
1570 | return pair; | ||
1571 | } | ||
1572 | |||
1573 | /** | ||
1542 | * ata_port_disable - Disable port. | 1574 | * ata_port_disable - Disable port. |
1543 | * @ap: Port to be disabled. | 1575 | * @ap: Port to be disabled. |
1544 | * | 1576 | * |
@@ -1566,7 +1598,7 @@ void ata_port_disable(struct ata_port *ap) | |||
1566 | * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). | 1598 | * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). |
1567 | * These were taken from ATA/ATAPI-6 standard, rev 0a, except | 1599 | * These were taken from ATA/ATAPI-6 standard, rev 0a, except |
1568 | * for PIO 5, which is a nonstandard extension and UDMA6, which | 1600 | * for PIO 5, which is a nonstandard extension and UDMA6, which |
1569 | * is currently supported only by Maxtor drives. | 1601 | * is currently supported only by Maxtor drives. |
1570 | */ | 1602 | */ |
1571 | 1603 | ||
1572 | static const struct ata_timing ata_timing[] = { | 1604 | static const struct ata_timing ata_timing[] = { |
@@ -1581,11 +1613,11 @@ static const struct ata_timing ata_timing[] = { | |||
1581 | { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, | 1613 | { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, |
1582 | 1614 | ||
1583 | /* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */ | 1615 | /* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */ |
1584 | 1616 | ||
1585 | { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, | 1617 | { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, |
1586 | { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, | 1618 | { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, |
1587 | { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 }, | 1619 | { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 }, |
1588 | 1620 | ||
1589 | { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 }, | 1621 | { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 }, |
1590 | { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, | 1622 | { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, |
1591 | { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, | 1623 | { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, |
@@ -1638,7 +1670,7 @@ static const struct ata_timing* ata_timing_find_mode(unsigned short speed) | |||
1638 | for (t = ata_timing; t->mode != speed; t++) | 1670 | for (t = ata_timing; t->mode != speed; t++) |
1639 | if (t->mode == 0xFF) | 1671 | if (t->mode == 0xFF) |
1640 | return NULL; | 1672 | return NULL; |
1641 | return t; | 1673 | return t; |
1642 | } | 1674 | } |
1643 | 1675 | ||
1644 | int ata_timing_compute(struct ata_device *adev, unsigned short speed, | 1676 | int ata_timing_compute(struct ata_device *adev, unsigned short speed, |
@@ -1648,7 +1680,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1648 | struct ata_timing p; | 1680 | struct ata_timing p; |
1649 | 1681 | ||
1650 | /* | 1682 | /* |
1651 | * Find the mode. | 1683 | * Find the mode. |
1652 | */ | 1684 | */ |
1653 | 1685 | ||
1654 | if (!(s = ata_timing_find_mode(speed))) | 1686 | if (!(s = ata_timing_find_mode(speed))) |
@@ -1706,20 +1738,28 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1706 | return 0; | 1738 | return 0; |
1707 | } | 1739 | } |
1708 | 1740 | ||
1709 | static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | 1741 | static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) |
1710 | { | 1742 | { |
1711 | if (!ata_dev_present(dev) || (ap->flags & ATA_FLAG_PORT_DISABLED)) | 1743 | unsigned int err_mask; |
1712 | return; | 1744 | int rc; |
1713 | 1745 | ||
1714 | if (dev->xfer_shift == ATA_SHIFT_PIO) | 1746 | if (dev->xfer_shift == ATA_SHIFT_PIO) |
1715 | dev->flags |= ATA_DFLAG_PIO; | 1747 | dev->flags |= ATA_DFLAG_PIO; |
1716 | 1748 | ||
1717 | ata_dev_set_xfermode(ap, dev); | 1749 | err_mask = ata_dev_set_xfermode(ap, dev); |
1750 | if (err_mask) { | ||
1751 | printk(KERN_ERR | ||
1752 | "ata%u: failed to set xfermode (err_mask=0x%x)\n", | ||
1753 | ap->id, err_mask); | ||
1754 | return -EIO; | ||
1755 | } | ||
1718 | 1756 | ||
1719 | if (ata_dev_revalidate(ap, dev, 0)) { | 1757 | rc = ata_dev_revalidate(ap, dev, 0); |
1720 | printk(KERN_ERR "ata%u: failed to revalidate after set " | 1758 | if (rc) { |
1721 | "xfermode, disabled\n", ap->id); | 1759 | printk(KERN_ERR |
1722 | ata_port_disable(ap); | 1760 | "ata%u: failed to revalidate after set xfermode\n", |
1761 | ap->id); | ||
1762 | return rc; | ||
1723 | } | 1763 | } |
1724 | 1764 | ||
1725 | DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", | 1765 | DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", |
@@ -1728,6 +1768,7 @@ static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1728 | printk(KERN_INFO "ata%u: dev %u configured for %s\n", | 1768 | printk(KERN_INFO "ata%u: dev %u configured for %s\n", |
1729 | ap->id, dev->devno, | 1769 | ap->id, dev->devno, |
1730 | ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode))); | 1770 | ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode))); |
1771 | return 0; | ||
1731 | } | 1772 | } |
1732 | 1773 | ||
1733 | static int ata_host_set_pio(struct ata_port *ap) | 1774 | static int ata_host_set_pio(struct ata_port *ap) |
@@ -1787,16 +1828,19 @@ static void ata_set_mode(struct ata_port *ap) | |||
1787 | /* step 1: calculate xfer_mask */ | 1828 | /* step 1: calculate xfer_mask */ |
1788 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 1829 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1789 | struct ata_device *dev = &ap->device[i]; | 1830 | struct ata_device *dev = &ap->device[i]; |
1790 | unsigned int xfer_mask; | 1831 | unsigned int pio_mask, dma_mask; |
1791 | 1832 | ||
1792 | if (!ata_dev_present(dev)) | 1833 | if (!ata_dev_present(dev)) |
1793 | continue; | 1834 | continue; |
1794 | 1835 | ||
1795 | xfer_mask = ata_dev_xfermask(ap, dev); | 1836 | ata_dev_xfermask(ap, dev); |
1837 | |||
1838 | /* TODO: let LLDD filter dev->*_mask here */ | ||
1796 | 1839 | ||
1797 | dev->pio_mode = ata_xfer_mask2mode(xfer_mask & ATA_MASK_PIO); | 1840 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); |
1798 | dev->dma_mode = ata_xfer_mask2mode(xfer_mask & (ATA_MASK_MWDMA | | 1841 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); |
1799 | ATA_MASK_UDMA)); | 1842 | dev->pio_mode = ata_xfer_mask2mode(pio_mask); |
1843 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); | ||
1800 | } | 1844 | } |
1801 | 1845 | ||
1802 | /* step 2: always set host PIO timings */ | 1846 | /* step 2: always set host PIO timings */ |
@@ -1808,11 +1852,15 @@ static void ata_set_mode(struct ata_port *ap) | |||
1808 | ata_host_set_dma(ap); | 1852 | ata_host_set_dma(ap); |
1809 | 1853 | ||
1810 | /* step 4: update devices' xfer mode */ | 1854 | /* step 4: update devices' xfer mode */ |
1811 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 1855 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1812 | ata_dev_set_mode(ap, &ap->device[i]); | 1856 | struct ata_device *dev = &ap->device[i]; |
1813 | 1857 | ||
1814 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1858 | if (!ata_dev_present(dev)) |
1815 | return; | 1859 | continue; |
1860 | |||
1861 | if (ata_dev_set_mode(ap, dev)) | ||
1862 | goto err_out; | ||
1863 | } | ||
1816 | 1864 | ||
1817 | if (ap->ops->post_set_mode) | 1865 | if (ap->ops->post_set_mode) |
1818 | ap->ops->post_set_mode(ap); | 1866 | ap->ops->post_set_mode(ap); |
@@ -1935,45 +1983,6 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask) | |||
1935 | ap->ops->dev_select(ap, 0); | 1983 | ap->ops->dev_select(ap, 0); |
1936 | } | 1984 | } |
1937 | 1985 | ||
1938 | /** | ||
1939 | * ata_bus_edd - Issue EXECUTE DEVICE DIAGNOSTIC command. | ||
1940 | * @ap: Port to reset and probe | ||
1941 | * | ||
1942 | * Use the EXECUTE DEVICE DIAGNOSTIC command to reset and | ||
1943 | * probe the bus. Not often used these days. | ||
1944 | * | ||
1945 | * LOCKING: | ||
1946 | * PCI/etc. bus probe sem. | ||
1947 | * Obtains host_set lock. | ||
1948 | * | ||
1949 | */ | ||
1950 | |||
1951 | static unsigned int ata_bus_edd(struct ata_port *ap) | ||
1952 | { | ||
1953 | struct ata_taskfile tf; | ||
1954 | unsigned long flags; | ||
1955 | |||
1956 | /* set up execute-device-diag (bus reset) taskfile */ | ||
1957 | /* also, take interrupts to a known state (disabled) */ | ||
1958 | DPRINTK("execute-device-diag\n"); | ||
1959 | ata_tf_init(ap, &tf, 0); | ||
1960 | tf.ctl |= ATA_NIEN; | ||
1961 | tf.command = ATA_CMD_EDD; | ||
1962 | tf.protocol = ATA_PROT_NODATA; | ||
1963 | |||
1964 | /* do bus reset */ | ||
1965 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1966 | ata_tf_to_host(ap, &tf); | ||
1967 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1968 | |||
1969 | /* spec says at least 2ms. but who knows with those | ||
1970 | * crazy ATAPI devices... | ||
1971 | */ | ||
1972 | msleep(150); | ||
1973 | |||
1974 | return ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | ||
1975 | } | ||
1976 | |||
1977 | static unsigned int ata_bus_softreset(struct ata_port *ap, | 1986 | static unsigned int ata_bus_softreset(struct ata_port *ap, |
1978 | unsigned int devmask) | 1987 | unsigned int devmask) |
1979 | { | 1988 | { |
@@ -2008,11 +2017,11 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
2008 | */ | 2017 | */ |
2009 | msleep(150); | 2018 | msleep(150); |
2010 | 2019 | ||
2011 | 2020 | ||
2012 | /* Before we perform post reset processing we want to see if | 2021 | /* Before we perform post reset processing we want to see if |
2013 | the bus shows 0xFF because the odd clown forgets the D7 pulldown | 2022 | the bus shows 0xFF because the odd clown forgets the D7 pulldown |
2014 | resistor */ | 2023 | resistor */ |
2015 | 2024 | ||
2016 | if (ata_check_status(ap) == 0xFF) | 2025 | if (ata_check_status(ap) == 0xFF) |
2017 | return 1; /* Positive is failure for some reason */ | 2026 | return 1; /* Positive is failure for some reason */ |
2018 | 2027 | ||
@@ -2046,7 +2055,7 @@ void ata_bus_reset(struct ata_port *ap) | |||
2046 | struct ata_ioports *ioaddr = &ap->ioaddr; | 2055 | struct ata_ioports *ioaddr = &ap->ioaddr; |
2047 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | 2056 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; |
2048 | u8 err; | 2057 | u8 err; |
2049 | unsigned int dev0, dev1 = 0, rc = 0, devmask = 0; | 2058 | unsigned int dev0, dev1 = 0, devmask = 0; |
2050 | 2059 | ||
2051 | DPRINTK("ENTER, host %u, port %u\n", ap->id, ap->port_no); | 2060 | DPRINTK("ENTER, host %u, port %u\n", ap->id, ap->port_no); |
2052 | 2061 | ||
@@ -2069,18 +2078,8 @@ void ata_bus_reset(struct ata_port *ap) | |||
2069 | 2078 | ||
2070 | /* issue bus reset */ | 2079 | /* issue bus reset */ |
2071 | if (ap->flags & ATA_FLAG_SRST) | 2080 | if (ap->flags & ATA_FLAG_SRST) |
2072 | rc = ata_bus_softreset(ap, devmask); | 2081 | if (ata_bus_softreset(ap, devmask)) |
2073 | else if ((ap->flags & ATA_FLAG_SATA_RESET) == 0) { | 2082 | goto err_out; |
2074 | /* set up device control */ | ||
2075 | if (ap->flags & ATA_FLAG_MMIO) | ||
2076 | writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr); | ||
2077 | else | ||
2078 | outb(ap->ctl, ioaddr->ctl_addr); | ||
2079 | rc = ata_bus_edd(ap); | ||
2080 | } | ||
2081 | |||
2082 | if (rc) | ||
2083 | goto err_out; | ||
2084 | 2083 | ||
2085 | /* | 2084 | /* |
2086 | * determine by signature whether we have ATA or ATAPI devices | 2085 | * determine by signature whether we have ATA or ATAPI devices |
@@ -2581,22 +2580,22 @@ static const char * const ata_dma_blacklist [] = { | |||
2581 | "SanDisk SDP3B-64", NULL, | 2580 | "SanDisk SDP3B-64", NULL, |
2582 | "SANYO CD-ROM CRD", NULL, | 2581 | "SANYO CD-ROM CRD", NULL, |
2583 | "HITACHI CDR-8", NULL, | 2582 | "HITACHI CDR-8", NULL, |
2584 | "HITACHI CDR-8335", NULL, | 2583 | "HITACHI CDR-8335", NULL, |
2585 | "HITACHI CDR-8435", NULL, | 2584 | "HITACHI CDR-8435", NULL, |
2586 | "Toshiba CD-ROM XM-6202B", NULL, | 2585 | "Toshiba CD-ROM XM-6202B", NULL, |
2587 | "TOSHIBA CD-ROM XM-1702BC", NULL, | 2586 | "TOSHIBA CD-ROM XM-1702BC", NULL, |
2588 | "CD-532E-A", NULL, | 2587 | "CD-532E-A", NULL, |
2589 | "E-IDE CD-ROM CR-840", NULL, | 2588 | "E-IDE CD-ROM CR-840", NULL, |
2590 | "CD-ROM Drive/F5A", NULL, | 2589 | "CD-ROM Drive/F5A", NULL, |
2591 | "WPI CDD-820", NULL, | 2590 | "WPI CDD-820", NULL, |
2592 | "SAMSUNG CD-ROM SC-148C", NULL, | 2591 | "SAMSUNG CD-ROM SC-148C", NULL, |
2593 | "SAMSUNG CD-ROM SC", NULL, | 2592 | "SAMSUNG CD-ROM SC", NULL, |
2594 | "SanDisk SDP3B-64", NULL, | 2593 | "SanDisk SDP3B-64", NULL, |
2595 | "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL, | 2594 | "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL, |
2596 | "_NEC DV5800A", NULL, | 2595 | "_NEC DV5800A", NULL, |
2597 | "SAMSUNG CD-ROM SN-124", "N001" | 2596 | "SAMSUNG CD-ROM SN-124", "N001" |
2598 | }; | 2597 | }; |
2599 | 2598 | ||
2600 | static int ata_strim(char *s, size_t len) | 2599 | static int ata_strim(char *s, size_t len) |
2601 | { | 2600 | { |
2602 | len = strnlen(s, len); | 2601 | len = strnlen(s, len); |
@@ -2639,18 +2638,15 @@ static int ata_dma_blacklisted(const struct ata_device *dev) | |||
2639 | * @ap: Port on which the device to compute xfermask for resides | 2638 | * @ap: Port on which the device to compute xfermask for resides |
2640 | * @dev: Device to compute xfermask for | 2639 | * @dev: Device to compute xfermask for |
2641 | * | 2640 | * |
2642 | * Compute supported xfermask of @dev. This function is | 2641 | * Compute supported xfermask of @dev and store it in |
2643 | * responsible for applying all known limits including host | 2642 | * dev->*_mask. This function is responsible for applying all |
2644 | * controller limits, device blacklist, etc... | 2643 | * known limits including host controller limits, device |
2644 | * blacklist, etc... | ||
2645 | * | 2645 | * |
2646 | * LOCKING: | 2646 | * LOCKING: |
2647 | * None. | 2647 | * None. |
2648 | * | ||
2649 | * RETURNS: | ||
2650 | * Computed xfermask. | ||
2651 | */ | 2648 | */ |
2652 | static unsigned int ata_dev_xfermask(struct ata_port *ap, | 2649 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) |
2653 | struct ata_device *dev) | ||
2654 | { | 2650 | { |
2655 | unsigned long xfer_mask; | 2651 | unsigned long xfer_mask; |
2656 | int i; | 2652 | int i; |
@@ -2663,6 +2659,8 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap, | |||
2663 | struct ata_device *d = &ap->device[i]; | 2659 | struct ata_device *d = &ap->device[i]; |
2664 | if (!ata_dev_present(d)) | 2660 | if (!ata_dev_present(d)) |
2665 | continue; | 2661 | continue; |
2662 | xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask, | ||
2663 | d->udma_mask); | ||
2666 | xfer_mask &= ata_id_xfermask(d->id); | 2664 | xfer_mask &= ata_id_xfermask(d->id); |
2667 | if (ata_dma_blacklisted(d)) | 2665 | if (ata_dma_blacklisted(d)) |
2668 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); | 2666 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); |
@@ -2672,7 +2670,8 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap, | |||
2672 | printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, " | 2670 | printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, " |
2673 | "disabling DMA\n", ap->id, dev->devno); | 2671 | "disabling DMA\n", ap->id, dev->devno); |
2674 | 2672 | ||
2675 | return xfer_mask; | 2673 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, |
2674 | &dev->udma_mask); | ||
2676 | } | 2675 | } |
2677 | 2676 | ||
2678 | /** | 2677 | /** |
@@ -2685,11 +2684,16 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap, | |||
2685 | * | 2684 | * |
2686 | * LOCKING: | 2685 | * LOCKING: |
2687 | * PCI/etc. bus probe sem. | 2686 | * PCI/etc. bus probe sem. |
2687 | * | ||
2688 | * RETURNS: | ||
2689 | * 0 on success, AC_ERR_* mask otherwise. | ||
2688 | */ | 2690 | */ |
2689 | 2691 | ||
2690 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | 2692 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, |
2693 | struct ata_device *dev) | ||
2691 | { | 2694 | { |
2692 | struct ata_taskfile tf; | 2695 | struct ata_taskfile tf; |
2696 | unsigned int err_mask; | ||
2693 | 2697 | ||
2694 | /* set up set-features taskfile */ | 2698 | /* set up set-features taskfile */ |
2695 | DPRINTK("set features - xfer mode\n"); | 2699 | DPRINTK("set features - xfer mode\n"); |
@@ -2701,13 +2705,10 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | |||
2701 | tf.protocol = ATA_PROT_NODATA; | 2705 | tf.protocol = ATA_PROT_NODATA; |
2702 | tf.nsect = dev->xfer_mode; | 2706 | tf.nsect = dev->xfer_mode; |
2703 | 2707 | ||
2704 | if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { | 2708 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); |
2705 | printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n", | ||
2706 | ap->id); | ||
2707 | ata_port_disable(ap); | ||
2708 | } | ||
2709 | 2709 | ||
2710 | DPRINTK("EXIT\n"); | 2710 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
2711 | return err_mask; | ||
2711 | } | 2712 | } |
2712 | 2713 | ||
2713 | /** | 2714 | /** |
@@ -2784,7 +2785,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2784 | 2785 | ||
2785 | if (qc->flags & ATA_QCFLAG_SG) { | 2786 | if (qc->flags & ATA_QCFLAG_SG) { |
2786 | if (qc->n_elem) | 2787 | if (qc->n_elem) |
2787 | dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir); | 2788 | dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); |
2788 | /* restore last sg */ | 2789 | /* restore last sg */ |
2789 | sg[qc->orig_n_elem - 1].length += qc->pad_len; | 2790 | sg[qc->orig_n_elem - 1].length += qc->pad_len; |
2790 | if (pad_buf) { | 2791 | if (pad_buf) { |
@@ -2795,7 +2796,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2795 | } | 2796 | } |
2796 | } else { | 2797 | } else { |
2797 | if (qc->n_elem) | 2798 | if (qc->n_elem) |
2798 | dma_unmap_single(ap->host_set->dev, | 2799 | dma_unmap_single(ap->dev, |
2799 | sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), | 2800 | sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), |
2800 | dir); | 2801 | dir); |
2801 | /* restore sg */ | 2802 | /* restore sg */ |
@@ -3006,7 +3007,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
3006 | goto skip_map; | 3007 | goto skip_map; |
3007 | } | 3008 | } |
3008 | 3009 | ||
3009 | dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, | 3010 | dma_address = dma_map_single(ap->dev, qc->buf_virt, |
3010 | sg->length, dir); | 3011 | sg->length, dir); |
3011 | if (dma_mapping_error(dma_address)) { | 3012 | if (dma_mapping_error(dma_address)) { |
3012 | /* restore sg */ | 3013 | /* restore sg */ |
@@ -3094,7 +3095,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
3094 | } | 3095 | } |
3095 | 3096 | ||
3096 | dir = qc->dma_dir; | 3097 | dir = qc->dma_dir; |
3097 | n_elem = dma_map_sg(ap->host_set->dev, sg, pre_n_elem, dir); | 3098 | n_elem = dma_map_sg(ap->dev, sg, pre_n_elem, dir); |
3098 | if (n_elem < 1) { | 3099 | if (n_elem < 1) { |
3099 | /* restore last sg */ | 3100 | /* restore last sg */ |
3100 | lsg->length += qc->pad_len; | 3101 | lsg->length += qc->pad_len; |
@@ -3793,7 +3794,7 @@ static void ata_pio_error(struct ata_port *ap) | |||
3793 | if (qc->tf.command != ATA_CMD_PACKET) | 3794 | if (qc->tf.command != ATA_CMD_PACKET) |
3794 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); | 3795 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); |
3795 | 3796 | ||
3796 | /* make sure qc->err_mask is available to | 3797 | /* make sure qc->err_mask is available to |
3797 | * know what's wrong and recover | 3798 | * know what's wrong and recover |
3798 | */ | 3799 | */ |
3799 | WARN_ON(qc->err_mask == 0); | 3800 | WARN_ON(qc->err_mask == 0); |
@@ -4630,14 +4631,15 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | |||
4630 | * Flush the cache on the drive, if appropriate, then issue a | 4631 | * Flush the cache on the drive, if appropriate, then issue a |
4631 | * standbynow command. | 4632 | * standbynow command. |
4632 | */ | 4633 | */ |
4633 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) | 4634 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state) |
4634 | { | 4635 | { |
4635 | if (!ata_dev_present(dev)) | 4636 | if (!ata_dev_present(dev)) |
4636 | return 0; | 4637 | return 0; |
4637 | if (dev->class == ATA_DEV_ATA) | 4638 | if (dev->class == ATA_DEV_ATA) |
4638 | ata_flush_cache(ap, dev); | 4639 | ata_flush_cache(ap, dev); |
4639 | 4640 | ||
4640 | ata_standby_drive(ap, dev); | 4641 | if (state.event != PM_EVENT_FREEZE) |
4642 | ata_standby_drive(ap, dev); | ||
4641 | ap->flags |= ATA_FLAG_SUSPENDED; | 4643 | ap->flags |= ATA_FLAG_SUSPENDED; |
4642 | return 0; | 4644 | return 0; |
4643 | } | 4645 | } |
@@ -4657,7 +4659,7 @@ int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) | |||
4657 | 4659 | ||
4658 | int ata_port_start (struct ata_port *ap) | 4660 | int ata_port_start (struct ata_port *ap) |
4659 | { | 4661 | { |
4660 | struct device *dev = ap->host_set->dev; | 4662 | struct device *dev = ap->dev; |
4661 | int rc; | 4663 | int rc; |
4662 | 4664 | ||
4663 | ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL); | 4665 | ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL); |
@@ -4690,7 +4692,7 @@ int ata_port_start (struct ata_port *ap) | |||
4690 | 4692 | ||
4691 | void ata_port_stop (struct ata_port *ap) | 4693 | void ata_port_stop (struct ata_port *ap) |
4692 | { | 4694 | { |
4693 | struct device *dev = ap->host_set->dev; | 4695 | struct device *dev = ap->dev; |
4694 | 4696 | ||
4695 | dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); | 4697 | dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); |
4696 | ata_pad_free(ap, dev); | 4698 | ata_pad_free(ap, dev); |
@@ -4756,6 +4758,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4756 | ap->host = host; | 4758 | ap->host = host; |
4757 | ap->ctl = ATA_DEVCTL_OBS; | 4759 | ap->ctl = ATA_DEVCTL_OBS; |
4758 | ap->host_set = host_set; | 4760 | ap->host_set = host_set; |
4761 | ap->dev = ent->dev; | ||
4759 | ap->port_no = port_no; | 4762 | ap->port_no = port_no; |
4760 | ap->hard_port_no = | 4763 | ap->hard_port_no = |
4761 | ent->legacy_mode ? ent->hard_port_no : port_no; | 4764 | ent->legacy_mode ? ent->hard_port_no : port_no; |
@@ -4771,8 +4774,13 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4771 | INIT_WORK(&ap->port_task, NULL, NULL); | 4774 | INIT_WORK(&ap->port_task, NULL, NULL); |
4772 | INIT_LIST_HEAD(&ap->eh_done_q); | 4775 | INIT_LIST_HEAD(&ap->eh_done_q); |
4773 | 4776 | ||
4774 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 4777 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
4775 | ap->device[i].devno = i; | 4778 | struct ata_device *dev = &ap->device[i]; |
4779 | dev->devno = i; | ||
4780 | dev->pio_mask = UINT_MAX; | ||
4781 | dev->mwdma_mask = UINT_MAX; | ||
4782 | dev->udma_mask = UINT_MAX; | ||
4783 | } | ||
4776 | 4784 | ||
4777 | #ifdef ATA_IRQ_TRAP | 4785 | #ifdef ATA_IRQ_TRAP |
4778 | ap->stats.unhandled_irq = 1; | 4786 | ap->stats.unhandled_irq = 1; |
@@ -4806,6 +4814,14 @@ static struct ata_port * ata_host_add(const struct ata_probe_ent *ent, | |||
4806 | int rc; | 4814 | int rc; |
4807 | 4815 | ||
4808 | DPRINTK("ENTER\n"); | 4816 | DPRINTK("ENTER\n"); |
4817 | |||
4818 | if (!ent->port_ops->probe_reset && | ||
4819 | !(ent->host_flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST))) { | ||
4820 | printk(KERN_ERR "ata%u: no reset mechanism available\n", | ||
4821 | port_no); | ||
4822 | return NULL; | ||
4823 | } | ||
4824 | |||
4809 | host = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); | 4825 | host = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); |
4810 | if (!host) | 4826 | if (!host) |
4811 | return NULL; | 4827 | return NULL; |
@@ -4966,7 +4982,7 @@ err_free_ret: | |||
4966 | * ata_host_set_remove - PCI layer callback for device removal | 4982 | * ata_host_set_remove - PCI layer callback for device removal |
4967 | * @host_set: ATA host set that was removed | 4983 | * @host_set: ATA host set that was removed |
4968 | * | 4984 | * |
4969 | * Unregister all objects associated with this host set. Free those | 4985 | * Unregister all objects associated with this host set. Free those |
4970 | * objects. | 4986 | * objects. |
4971 | * | 4987 | * |
4972 | * LOCKING: | 4988 | * LOCKING: |
@@ -5238,6 +5254,8 @@ EXPORT_SYMBOL_GPL(ata_std_postreset); | |||
5238 | EXPORT_SYMBOL_GPL(ata_std_probe_reset); | 5254 | EXPORT_SYMBOL_GPL(ata_std_probe_reset); |
5239 | EXPORT_SYMBOL_GPL(ata_drive_probe_reset); | 5255 | EXPORT_SYMBOL_GPL(ata_drive_probe_reset); |
5240 | EXPORT_SYMBOL_GPL(ata_dev_revalidate); | 5256 | EXPORT_SYMBOL_GPL(ata_dev_revalidate); |
5257 | EXPORT_SYMBOL_GPL(ata_dev_classify); | ||
5258 | EXPORT_SYMBOL_GPL(ata_dev_pair); | ||
5241 | EXPORT_SYMBOL_GPL(ata_port_disable); | 5259 | EXPORT_SYMBOL_GPL(ata_port_disable); |
5242 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 5260 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
5243 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | 5261 | EXPORT_SYMBOL_GPL(ata_busy_sleep); |
@@ -5248,7 +5266,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_error); | |||
5248 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); | 5266 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); |
5249 | EXPORT_SYMBOL_GPL(ata_scsi_release); | 5267 | EXPORT_SYMBOL_GPL(ata_scsi_release); |
5250 | EXPORT_SYMBOL_GPL(ata_host_intr); | 5268 | EXPORT_SYMBOL_GPL(ata_host_intr); |
5251 | EXPORT_SYMBOL_GPL(ata_dev_classify); | ||
5252 | EXPORT_SYMBOL_GPL(ata_id_string); | 5269 | EXPORT_SYMBOL_GPL(ata_id_string); |
5253 | EXPORT_SYMBOL_GPL(ata_id_c_string); | 5270 | EXPORT_SYMBOL_GPL(ata_id_c_string); |
5254 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); | 5271 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index a1259b242b8e..628191bfd990 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -256,7 +256,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
256 | scsi_cmd[14] = args[0]; | 256 | scsi_cmd[14] = args[0]; |
257 | 257 | ||
258 | /* Good values for timeout and retries? Values below | 258 | /* Good values for timeout and retries? Values below |
259 | from scsi_ioctl_send_command() for default case... */ | 259 | from scsi_ioctl_send_command() for default case... */ |
260 | if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr, | 260 | if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr, |
261 | (10*HZ), 5)) | 261 | (10*HZ), 5)) |
262 | rc = -EIO; | 262 | rc = -EIO; |
@@ -267,20 +267,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
267 | 267 | ||
268 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | 268 | int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) |
269 | { | 269 | { |
270 | struct ata_port *ap; | ||
271 | struct ata_device *dev; | ||
272 | int val = -EINVAL, rc = -EINVAL; | 270 | int val = -EINVAL, rc = -EINVAL; |
273 | 271 | ||
274 | ap = (struct ata_port *) &scsidev->host->hostdata[0]; | ||
275 | if (!ap) | ||
276 | goto out; | ||
277 | |||
278 | dev = ata_scsi_find_dev(ap, scsidev); | ||
279 | if (!dev) { | ||
280 | rc = -ENODEV; | ||
281 | goto out; | ||
282 | } | ||
283 | |||
284 | switch (cmd) { | 272 | switch (cmd) { |
285 | case ATA_IOC_GET_IO32: | 273 | case ATA_IOC_GET_IO32: |
286 | val = 0; | 274 | val = 0; |
@@ -309,7 +297,6 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) | |||
309 | break; | 297 | break; |
310 | } | 298 | } |
311 | 299 | ||
312 | out: | ||
313 | return rc; | 300 | return rc; |
314 | } | 301 | } |
315 | 302 | ||
@@ -414,12 +401,12 @@ int ata_scsi_device_resume(struct scsi_device *sdev) | |||
414 | return ata_device_resume(ap, dev); | 401 | return ata_device_resume(ap, dev); |
415 | } | 402 | } |
416 | 403 | ||
417 | int ata_scsi_device_suspend(struct scsi_device *sdev) | 404 | int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state) |
418 | { | 405 | { |
419 | struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; | 406 | struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; |
420 | struct ata_device *dev = &ap->device[sdev->id]; | 407 | struct ata_device *dev = &ap->device[sdev->id]; |
421 | 408 | ||
422 | return ata_device_suspend(ap, dev); | 409 | return ata_device_suspend(ap, dev, state); |
423 | } | 410 | } |
424 | 411 | ||
425 | /** | 412 | /** |
@@ -438,7 +425,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev) | |||
438 | * LOCKING: | 425 | * LOCKING: |
439 | * spin_lock_irqsave(host_set lock) | 426 | * spin_lock_irqsave(host_set lock) |
440 | */ | 427 | */ |
441 | void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | 428 | void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, |
442 | u8 *ascq) | 429 | u8 *ascq) |
443 | { | 430 | { |
444 | int i; | 431 | int i; |
@@ -495,7 +482,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | |||
495 | /* Look for drv_err */ | 482 | /* Look for drv_err */ |
496 | for (i = 0; sense_table[i][0] != 0xFF; i++) { | 483 | for (i = 0; sense_table[i][0] != 0xFF; i++) { |
497 | /* Look for best matches first */ | 484 | /* Look for best matches first */ |
498 | if ((sense_table[i][0] & drv_err) == | 485 | if ((sense_table[i][0] & drv_err) == |
499 | sense_table[i][0]) { | 486 | sense_table[i][0]) { |
500 | *sk = sense_table[i][1]; | 487 | *sk = sense_table[i][1]; |
501 | *asc = sense_table[i][2]; | 488 | *asc = sense_table[i][2]; |
@@ -518,7 +505,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | |||
518 | } | 505 | } |
519 | } | 506 | } |
520 | /* No error? Undecoded? */ | 507 | /* No error? Undecoded? */ |
521 | printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", | 508 | printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", |
522 | id, drv_stat); | 509 | id, drv_stat); |
523 | 510 | ||
524 | /* We need a sensible error return here, which is tricky, and one | 511 | /* We need a sensible error return here, which is tricky, and one |
@@ -1150,14 +1137,14 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc | |||
1150 | 1137 | ||
1151 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", | 1138 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", |
1152 | (u32)block, track, cyl, head, sect); | 1139 | (u32)block, track, cyl, head, sect); |
1153 | 1140 | ||
1154 | /* Check whether the converted CHS can fit. | 1141 | /* Check whether the converted CHS can fit. |
1155 | Cylinder: 0-65535 | 1142 | Cylinder: 0-65535 |
1156 | Head: 0-15 | 1143 | Head: 0-15 |
1157 | Sector: 1-255*/ | 1144 | Sector: 1-255*/ |
1158 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) | 1145 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) |
1159 | goto out_of_range; | 1146 | goto out_of_range; |
1160 | 1147 | ||
1161 | tf->command = ATA_CMD_VERIFY; | 1148 | tf->command = ATA_CMD_VERIFY; |
1162 | tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ | 1149 | tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ |
1163 | tf->lbal = sect; | 1150 | tf->lbal = sect; |
@@ -1289,7 +1276,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1289 | tf->lbal = block & 0xff; | 1276 | tf->lbal = block & 0xff; |
1290 | 1277 | ||
1291 | tf->device |= ATA_LBA; | 1278 | tf->device |= ATA_LBA; |
1292 | } else { | 1279 | } else { |
1293 | /* CHS */ | 1280 | /* CHS */ |
1294 | u32 sect, head, cyl, track; | 1281 | u32 sect, head, cyl, track; |
1295 | 1282 | ||
@@ -1309,8 +1296,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1309 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", | 1296 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", |
1310 | (u32)block, track, cyl, head, sect); | 1297 | (u32)block, track, cyl, head, sect); |
1311 | 1298 | ||
1312 | /* Check whether the converted CHS can fit. | 1299 | /* Check whether the converted CHS can fit. |
1313 | Cylinder: 0-65535 | 1300 | Cylinder: 0-65535 |
1314 | Head: 0-15 | 1301 | Head: 0-15 |
1315 | Sector: 1-255*/ | 1302 | Sector: 1-255*/ |
1316 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) | 1303 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) |
@@ -1697,7 +1684,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, | |||
1697 | 1684 | ||
1698 | if (buflen > (ATA_SERNO_LEN + num + 3)) { | 1685 | if (buflen > (ATA_SERNO_LEN + num + 3)) { |
1699 | /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */ | 1686 | /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */ |
1700 | rbuf[num + 0] = 2; | 1687 | rbuf[num + 0] = 2; |
1701 | rbuf[num + 3] = ATA_SERNO_LEN; | 1688 | rbuf[num + 3] = ATA_SERNO_LEN; |
1702 | num += 4; | 1689 | num += 4; |
1703 | ata_id_string(args->id, (unsigned char *) rbuf + num, | 1690 | ata_id_string(args->id, (unsigned char *) rbuf + num, |
@@ -1707,8 +1694,8 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, | |||
1707 | if (buflen > (sat_model_serial_desc_len + num + 3)) { | 1694 | if (buflen > (sat_model_serial_desc_len + num + 3)) { |
1708 | /* SAT defined lu model and serial numbers descriptor */ | 1695 | /* SAT defined lu model and serial numbers descriptor */ |
1709 | /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */ | 1696 | /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */ |
1710 | rbuf[num + 0] = 2; | 1697 | rbuf[num + 0] = 2; |
1711 | rbuf[num + 1] = 1; | 1698 | rbuf[num + 1] = 1; |
1712 | rbuf[num + 3] = sat_model_serial_desc_len; | 1699 | rbuf[num + 3] = sat_model_serial_desc_len; |
1713 | num += 4; | 1700 | num += 4; |
1714 | memcpy(rbuf + num, "ATA ", 8); | 1701 | memcpy(rbuf + num, "ATA ", 8); |
@@ -2597,6 +2584,21 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, | |||
2597 | #endif | 2584 | #endif |
2598 | } | 2585 | } |
2599 | 2586 | ||
2587 | static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), | ||
2588 | struct ata_port *ap, struct ata_device *dev) | ||
2589 | { | ||
2590 | if (dev->class == ATA_DEV_ATA) { | ||
2591 | ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, | ||
2592 | cmd->cmnd[0]); | ||
2593 | |||
2594 | if (xlat_func) | ||
2595 | ata_scsi_translate(ap, dev, cmd, done, xlat_func); | ||
2596 | else | ||
2597 | ata_scsi_simulate(ap, dev, cmd, done); | ||
2598 | } else | ||
2599 | ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); | ||
2600 | } | ||
2601 | |||
2600 | /** | 2602 | /** |
2601 | * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device | 2603 | * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device |
2602 | * @cmd: SCSI command to be sent | 2604 | * @cmd: SCSI command to be sent |
@@ -2631,24 +2633,13 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
2631 | ata_scsi_dump_cdb(ap, cmd); | 2633 | ata_scsi_dump_cdb(ap, cmd); |
2632 | 2634 | ||
2633 | dev = ata_scsi_find_dev(ap, scsidev); | 2635 | dev = ata_scsi_find_dev(ap, scsidev); |
2634 | if (unlikely(!dev)) { | 2636 | if (likely(dev)) |
2637 | __ata_scsi_queuecmd(cmd, done, ap, dev); | ||
2638 | else { | ||
2635 | cmd->result = (DID_BAD_TARGET << 16); | 2639 | cmd->result = (DID_BAD_TARGET << 16); |
2636 | done(cmd); | 2640 | done(cmd); |
2637 | goto out_unlock; | ||
2638 | } | 2641 | } |
2639 | 2642 | ||
2640 | if (dev->class == ATA_DEV_ATA) { | ||
2641 | ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, | ||
2642 | cmd->cmnd[0]); | ||
2643 | |||
2644 | if (xlat_func) | ||
2645 | ata_scsi_translate(ap, dev, cmd, done, xlat_func); | ||
2646 | else | ||
2647 | ata_scsi_simulate(ap, dev, cmd, done); | ||
2648 | } else | ||
2649 | ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); | ||
2650 | |||
2651 | out_unlock: | ||
2652 | spin_unlock(&ap->host_set->lock); | 2643 | spin_unlock(&ap->host_set->lock); |
2653 | spin_lock(shost->host_lock); | 2644 | spin_lock(shost->host_lock); |
2654 | return 0; | 2645 | return 0; |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index bf9f7f7ba354..c11e5ce6865e 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -2797,7 +2797,7 @@ mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[]) | |||
2797 | // available within 1 second, assume FW is initializing and wait | 2797 | // available within 1 second, assume FW is initializing and wait |
2798 | // for an extended amount of time | 2798 | // for an extended amount of time |
2799 | if (mbox->numstatus == 0xFF) { // status not yet available | 2799 | if (mbox->numstatus == 0xFF) { // status not yet available |
2800 | udelay(25);; | 2800 | udelay(25); |
2801 | 2801 | ||
2802 | for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) { | 2802 | for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) { |
2803 | rmb(); | 2803 | rmb(); |
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 3e75d6733239..18c296c56899 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -371,7 +371,7 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev) | |||
371 | if (quirks & SIL_QUIRK_UDMA5MAX) { | 371 | if (quirks & SIL_QUIRK_UDMA5MAX) { |
372 | printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n", | 372 | printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n", |
373 | ap->id, dev->devno, model_num); | 373 | ap->id, dev->devno, model_num); |
374 | ap->udma_mask &= ATA_UDMA5; | 374 | dev->udma_mask &= ATA_UDMA5; |
375 | return; | 375 | return; |
376 | } | 376 | } |
377 | } | 377 | } |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index 3efebea211f2..068c98a4111b 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -342,7 +342,7 @@ static struct ata_port_info sil24_port_info[] = { | |||
342 | .udma_mask = 0x3f, /* udma0-5 */ | 342 | .udma_mask = 0x3f, /* udma0-5 */ |
343 | .port_ops = &sil24_ops, | 343 | .port_ops = &sil24_ops, |
344 | }, | 344 | }, |
345 | /* sil_3132 */ | 345 | /* sil_3132 */ |
346 | { | 346 | { |
347 | .sht = &sil24_sht, | 347 | .sht = &sil24_sht, |
348 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 348 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index 9f621a97c977..5af6d5f9f4bd 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -237,11 +237,11 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance, | |||
237 | handled += ata_host_intr(ap, qc); | 237 | handled += ata_host_intr(ap, qc); |
238 | else if (is_vsc_sata_int_err(i, int_status)) { | 238 | else if (is_vsc_sata_int_err(i, int_status)) { |
239 | /* | 239 | /* |
240 | * On some chips (i.e. Intel 31244), an error | 240 | * On some chips (i.e. Intel 31244), an error |
241 | * interrupt will sneak in at initialization | 241 | * interrupt will sneak in at initialization |
242 | * time (phy state changes). Clearing the SCR | 242 | * time (phy state changes). Clearing the SCR |
243 | * error register is not required, but it prevents | 243 | * error register is not required, but it prevents |
244 | * the phy state change interrupts from recurring | 244 | * the phy state change interrupts from recurring |
245 | * later. | 245 | * later. |
246 | */ | 246 | */ |
247 | u32 err_status; | 247 | u32 err_status; |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 89055494dfee..a6fde52946d6 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -286,7 +286,7 @@ static int scsi_bus_suspend(struct device * dev, pm_message_t state) | |||
286 | return err; | 286 | return err; |
287 | 287 | ||
288 | if (sht->suspend) | 288 | if (sht->suspend) |
289 | err = sht->suspend(sdev); | 289 | err = sht->suspend(sdev, state); |
290 | 290 | ||
291 | return err; | 291 | return err; |
292 | } | 292 | } |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index f9c1192dc15e..7c80711e18ed 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -71,7 +71,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR); | |||
71 | #define SR_CAPABILITIES \ | 71 | #define SR_CAPABILITIES \ |
72 | (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ | 72 | (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ |
73 | CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ | 73 | CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ |
74 | CDC_PLAY_AUDIO|CDC_RESET|CDC_IOCTLS|CDC_DRIVE_STATUS| \ | 74 | CDC_PLAY_AUDIO|CDC_RESET|CDC_DRIVE_STATUS| \ |
75 | CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ | 75 | CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ |
76 | CDC_MRW|CDC_MRW_W|CDC_RAM) | 76 | CDC_MRW|CDC_MRW_W|CDC_RAM) |
77 | 77 | ||
@@ -118,7 +118,6 @@ static struct cdrom_device_ops sr_dops = { | |||
118 | .get_mcn = sr_get_mcn, | 118 | .get_mcn = sr_get_mcn, |
119 | .reset = sr_reset, | 119 | .reset = sr_reset, |
120 | .audio_ioctl = sr_audio_ioctl, | 120 | .audio_ioctl = sr_audio_ioctl, |
121 | .dev_ioctl = sr_dev_ioctl, | ||
122 | .capability = SR_CAPABILITIES, | 121 | .capability = SR_CAPABILITIES, |
123 | .generic_packet = sr_packet, | 122 | .generic_packet = sr_packet, |
124 | }; | 123 | }; |
@@ -456,17 +455,33 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | |||
456 | { | 455 | { |
457 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); | 456 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); |
458 | struct scsi_device *sdev = cd->device; | 457 | struct scsi_device *sdev = cd->device; |
458 | void __user *argp = (void __user *)arg; | ||
459 | int ret; | ||
459 | 460 | ||
460 | /* | 461 | /* |
461 | * Send SCSI addressing ioctls directly to mid level, send other | 462 | * Send SCSI addressing ioctls directly to mid level, send other |
462 | * ioctls to cdrom/block level. | 463 | * ioctls to cdrom/block level. |
463 | */ | 464 | */ |
464 | switch (cmd) { | 465 | switch (cmd) { |
465 | case SCSI_IOCTL_GET_IDLUN: | 466 | case SCSI_IOCTL_GET_IDLUN: |
466 | case SCSI_IOCTL_GET_BUS_NUMBER: | 467 | case SCSI_IOCTL_GET_BUS_NUMBER: |
467 | return scsi_ioctl(sdev, cmd, (void __user *)arg); | 468 | return scsi_ioctl(sdev, cmd, argp); |
468 | } | 469 | } |
469 | return cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | 470 | |
471 | ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | ||
472 | if (ret != ENOSYS) | ||
473 | return ret; | ||
474 | |||
475 | /* | ||
476 | * ENODEV means that we didn't recognise the ioctl, or that we | ||
477 | * cannot execute it in the current device state. In either | ||
478 | * case fall through to scsi_ioctl, which will return ENDOEV again | ||
479 | * if it doesn't recognise the ioctl | ||
480 | */ | ||
481 | ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL); | ||
482 | if (ret != -ENODEV) | ||
483 | return ret; | ||
484 | return scsi_ioctl(sdev, cmd, argp); | ||
470 | } | 485 | } |
471 | 486 | ||
472 | static int sr_block_media_changed(struct gendisk *disk) | 487 | static int sr_block_media_changed(struct gendisk *disk) |
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index d2bcd99c272f..d65de9621b27 100644 --- a/drivers/scsi/sr.h +++ b/drivers/scsi/sr.h | |||
@@ -55,7 +55,6 @@ int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); | |||
55 | int sr_reset(struct cdrom_device_info *); | 55 | int sr_reset(struct cdrom_device_info *); |
56 | int sr_select_speed(struct cdrom_device_info *cdi, int speed); | 56 | int sr_select_speed(struct cdrom_device_info *cdi, int speed); |
57 | int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); | 57 | int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); |
58 | int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long); | ||
59 | 58 | ||
60 | int sr_is_xa(Scsi_CD *); | 59 | int sr_is_xa(Scsi_CD *); |
61 | 60 | ||
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index b65462f76484..d1268cb46837 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -562,22 +562,3 @@ int sr_is_xa(Scsi_CD *cd) | |||
562 | #endif | 562 | #endif |
563 | return is_xa; | 563 | return is_xa; |
564 | } | 564 | } |
565 | |||
566 | int sr_dev_ioctl(struct cdrom_device_info *cdi, | ||
567 | unsigned int cmd, unsigned long arg) | ||
568 | { | ||
569 | Scsi_CD *cd = cdi->handle; | ||
570 | int ret; | ||
571 | |||
572 | ret = scsi_nonblockable_ioctl(cd->device, cmd, | ||
573 | (void __user *)arg, NULL); | ||
574 | /* | ||
575 | * ENODEV means that we didn't recognise the ioctl, or that we | ||
576 | * cannot execute it in the current device state. In either | ||
577 | * case fall through to scsi_ioctl, which will return ENDOEV again | ||
578 | * if it doesn't recognise the ioctl | ||
579 | */ | ||
580 | if (ret != -ENODEV) | ||
581 | return ret; | ||
582 | return scsi_ioctl(cd->device, cmd, (void __user *)arg); | ||
583 | } | ||