diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-26 14:13:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-26 14:13:06 -0400 |
commit | bc2fd381d8f9dbeb181f82286cdca1567e3d0def (patch) | |
tree | e03b088a8bc1052d8f851764d201a13366cb97ce /drivers | |
parent | 928a726b0e12184729900c076e13dbf1c511c96c (diff) | |
parent | 2ebe1d9efed5f232afc8d00901d0959c9814bce3 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (53 commits)
ide: use try_to_identify() in ide_driveid_update()
ide: clear drive IRQ after re-enabling local IRQs in ide_driveid_update()
ide: sanitize SELECT_MASK() usage in ide_driveid_update()
ide: classify device type in do_probe()
ide: remove broken EXABYTENEST support
ide: shorten timeout value in ide_driveid_update()
ide: propagate AltStatus workarounds to ide_driveid_update()
ide: fix kmalloc() failure handling in ide_driveid_update()
mn10300: remove <asm/ide.h>
frv: remove <asm/ide.h>
ide: remove pciirq argument from ide_pci_setup_ports()
ide: fix ->init_chipset method to return 'int' value
ide: remove try_to_identify() wrapper
ide: remove no longer needed IRQ auto-probing from try_to_identify() (v2)
ide: remove no longer needed IRQ fallback code from hwif_init()
amd74xx: remove no longer needed ->init_hwif method
ide: remove no longer needed IDE_HFLAG[_FORCE]_LEGACY_IRQS
ide: use ide_pci_is_in_compatibility_mode() in ide_pci_init_{one,two}()
ide: use pci_get_legacy_ide_irq() in ide_pci_init_{one,two}()
ide: handle IDE_HFLAG[_FORCE]_LEGACY_IRQS in ide_pci_init_{one,two}()
...
Diffstat (limited to 'drivers')
40 files changed, 1533 insertions, 1850 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 5ea3bfad172a..640c99207242 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -56,8 +56,12 @@ if IDE | |||
56 | 56 | ||
57 | comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" | 57 | comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" |
58 | 58 | ||
59 | config IDE_XFER_MODE | ||
60 | bool | ||
61 | |||
59 | config IDE_TIMINGS | 62 | config IDE_TIMINGS |
60 | bool | 63 | bool |
64 | select IDE_XFER_MODE | ||
61 | 65 | ||
62 | config IDE_ATAPI | 66 | config IDE_ATAPI |
63 | bool | 67 | bool |
@@ -698,6 +702,7 @@ config BLK_DEV_IDE_PMAC_ATA100FIRST | |||
698 | config BLK_DEV_IDE_AU1XXX | 702 | config BLK_DEV_IDE_AU1XXX |
699 | bool "IDE for AMD Alchemy Au1200" | 703 | bool "IDE for AMD Alchemy Au1200" |
700 | depends on SOC_AU1200 | 704 | depends on SOC_AU1200 |
705 | select IDE_XFER_MODE | ||
701 | choice | 706 | choice |
702 | prompt "IDE Mode for AMD Alchemy Au1200" | 707 | prompt "IDE Mode for AMD Alchemy Au1200" |
703 | default CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA | 708 | default CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA |
@@ -871,6 +876,7 @@ config BLK_DEV_ALI14XX | |||
871 | 876 | ||
872 | config BLK_DEV_DTC2278 | 877 | config BLK_DEV_DTC2278 |
873 | tristate "DTC-2278 support" | 878 | tristate "DTC-2278 support" |
879 | select IDE_XFER_MODE | ||
874 | select IDE_LEGACY | 880 | select IDE_LEGACY |
875 | help | 881 | help |
876 | This driver is enabled at runtime using the "dtc2278.probe" kernel | 882 | This driver is enabled at runtime using the "dtc2278.probe" kernel |
@@ -902,6 +908,7 @@ config BLK_DEV_QD65XX | |||
902 | 908 | ||
903 | config BLK_DEV_UMC8672 | 909 | config BLK_DEV_UMC8672 |
904 | tristate "UMC-8672 support" | 910 | tristate "UMC-8672 support" |
911 | select IDE_XFER_MODE | ||
905 | select IDE_LEGACY | 912 | select IDE_LEGACY |
906 | help | 913 | help |
907 | This driver is enabled at runtime using the "umc8672.probe" kernel | 914 | This driver is enabled at runtime using the "umc8672.probe" kernel |
@@ -915,5 +922,6 @@ endif | |||
915 | config BLK_DEV_IDEDMA | 922 | config BLK_DEV_IDEDMA |
916 | def_bool BLK_DEV_IDEDMA_SFF || \ | 923 | def_bool BLK_DEV_IDEDMA_SFF || \ |
917 | BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 924 | BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
925 | select IDE_XFER_MODE | ||
918 | 926 | ||
919 | endif # IDE | 927 | endif # IDE |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 1c326d94aa6d..9b4bbe1cdc1a 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -5,9 +5,11 @@ | |||
5 | EXTRA_CFLAGS += -Idrivers/ide | 5 | EXTRA_CFLAGS += -Idrivers/ide |
6 | 6 | ||
7 | ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ | 7 | ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ |
8 | ide-taskfile.o ide-pm.o ide-park.o ide-pio-blacklist.o ide-sysfs.o | 8 | ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \ |
9 | ide-io-std.o ide-eh.o | ||
9 | 10 | ||
10 | # core IDE code | 11 | # core IDE code |
12 | ide-core-$(CONFIG_IDE_XFER_MODE) += ide-pio-blacklist.o ide-xfer-mode.o | ||
11 | ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o | 13 | ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o |
12 | ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o | 14 | ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o |
13 | ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o | 15 | ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o |
diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c index 4485b9c6f0e6..878f8ec6dbe1 100644 --- a/drivers/ide/aec62xx.c +++ b/drivers/ide/aec62xx.c | |||
@@ -139,7 +139,7 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
139 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); | 139 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); |
140 | } | 140 | } |
141 | 141 | ||
142 | static unsigned int init_chipset_aec62xx(struct pci_dev *dev) | 142 | static int init_chipset_aec62xx(struct pci_dev *dev) |
143 | { | 143 | { |
144 | /* These are necessary to get AEC6280 Macintosh cards to work */ | 144 | /* These are necessary to get AEC6280 Macintosh cards to work */ |
145 | if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || | 145 | if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || |
@@ -156,7 +156,7 @@ static unsigned int init_chipset_aec62xx(struct pci_dev *dev) | |||
156 | pci_write_config_byte(dev, 0x4a, reg4ah | 0x80); | 156 | pci_write_config_byte(dev, 0x4a, reg4ah | 0x80); |
157 | } | 157 | } |
158 | 158 | ||
159 | return dev->irq; | 159 | return 0; |
160 | } | 160 | } |
161 | 161 | ||
162 | static u8 atp86x_cable_detect(ide_hwif_t *hwif) | 162 | static u8 atp86x_cable_detect(ide_hwif_t *hwif) |
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index 66f43083408b..d3513b6b8530 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c | |||
@@ -212,7 +212,7 @@ static int ali15x3_dma_setup(ide_drive_t *drive) | |||
212 | * appropriate also sets up the 1533 southbridge. | 212 | * appropriate also sets up the 1533 southbridge. |
213 | */ | 213 | */ |
214 | 214 | ||
215 | static unsigned int init_chipset_ali15x3(struct pci_dev *dev) | 215 | static int init_chipset_ali15x3(struct pci_dev *dev) |
216 | { | 216 | { |
217 | unsigned long flags; | 217 | unsigned long flags; |
218 | u8 tmpbyte; | 218 | u8 tmpbyte; |
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c index 77267c859965..628cd2e5fed8 100644 --- a/drivers/ide/amd74xx.c +++ b/drivers/ide/amd74xx.c | |||
@@ -140,7 +140,7 @@ static void amd7411_cable_detect(struct pci_dev *dev) | |||
140 | * The initialization callback. Initialize drive independent registers. | 140 | * The initialization callback. Initialize drive independent registers. |
141 | */ | 141 | */ |
142 | 142 | ||
143 | static unsigned int init_chipset_amd74xx(struct pci_dev *dev) | 143 | static int init_chipset_amd74xx(struct pci_dev *dev) |
144 | { | 144 | { |
145 | u8 t = 0, offset = amd_offset(dev); | 145 | u8 t = 0, offset = amd_offset(dev); |
146 | 146 | ||
@@ -172,7 +172,7 @@ static unsigned int init_chipset_amd74xx(struct pci_dev *dev) | |||
172 | t |= 0xf0; | 172 | t |= 0xf0; |
173 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); | 173 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); |
174 | 174 | ||
175 | return dev->irq; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | static u8 amd_cable_detect(ide_hwif_t *hwif) | 178 | static u8 amd_cable_detect(ide_hwif_t *hwif) |
@@ -183,14 +183,6 @@ static u8 amd_cable_detect(ide_hwif_t *hwif) | |||
183 | return ATA_CBL_PATA40; | 183 | return ATA_CBL_PATA40; |
184 | } | 184 | } |
185 | 185 | ||
186 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | ||
187 | { | ||
188 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
189 | |||
190 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ | ||
191 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); | ||
192 | } | ||
193 | |||
194 | static const struct ide_port_ops amd_port_ops = { | 186 | static const struct ide_port_ops amd_port_ops = { |
195 | .set_pio_mode = amd_set_pio_mode, | 187 | .set_pio_mode = amd_set_pio_mode, |
196 | .set_dma_mode = amd_set_drive, | 188 | .set_dma_mode = amd_set_drive, |
@@ -207,7 +199,6 @@ static const struct ide_port_ops amd_port_ops = { | |||
207 | { \ | 199 | { \ |
208 | .name = DRV_NAME, \ | 200 | .name = DRV_NAME, \ |
209 | .init_chipset = init_chipset_amd74xx, \ | 201 | .init_chipset = init_chipset_amd74xx, \ |
210 | .init_hwif = init_hwif_amd74xx, \ | ||
211 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 202 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
212 | .port_ops = &amd_port_ops, \ | 203 | .port_ops = &amd_port_ops, \ |
213 | .host_flags = IDE_HFLAGS_AMD, \ | 204 | .host_flags = IDE_HFLAGS_AMD, \ |
@@ -221,7 +212,6 @@ static const struct ide_port_ops amd_port_ops = { | |||
221 | { \ | 212 | { \ |
222 | .name = DRV_NAME, \ | 213 | .name = DRV_NAME, \ |
223 | .init_chipset = init_chipset_amd74xx, \ | 214 | .init_chipset = init_chipset_amd74xx, \ |
224 | .init_hwif = init_hwif_amd74xx, \ | ||
225 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ | 215 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ |
226 | .port_ops = &amd_port_ops, \ | 216 | .port_ops = &amd_port_ops, \ |
227 | .host_flags = IDE_HFLAGS_AMD, \ | 217 | .host_flags = IDE_HFLAGS_AMD, \ |
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c index ecd1e62ca91a..923cbfe259d3 100644 --- a/drivers/ide/atiixp.c +++ b/drivers/ide/atiixp.c | |||
@@ -142,7 +142,6 @@ static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | |||
142 | .name = DRV_NAME, | 142 | .name = DRV_NAME, |
143 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, | 143 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, |
144 | .port_ops = &atiixp_port_ops, | 144 | .port_ops = &atiixp_port_ops, |
145 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | ||
146 | .pio_mask = ATA_PIO4, | 145 | .pio_mask = ATA_PIO4, |
147 | .mwdma_mask = ATA_MWDMA2, | 146 | .mwdma_mask = ATA_MWDMA2, |
148 | .udma_mask = ATA_UDMA5, | 147 | .udma_mask = ATA_UDMA5, |
@@ -151,7 +150,7 @@ static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | |||
151 | .name = DRV_NAME, | 150 | .name = DRV_NAME, |
152 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, | 151 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, |
153 | .port_ops = &atiixp_port_ops, | 152 | .port_ops = &atiixp_port_ops, |
154 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, | 153 | .host_flags = IDE_HFLAG_SINGLE, |
155 | .pio_mask = ATA_PIO4, | 154 | .pio_mask = ATA_PIO4, |
156 | .mwdma_mask = ATA_MWDMA2, | 155 | .mwdma_mask = ATA_MWDMA2, |
157 | .udma_mask = ATA_UDMA5, | 156 | .udma_mask = ATA_UDMA5, |
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index 2f9688d87ecd..aeee036b1503 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c | |||
@@ -333,7 +333,7 @@ static int cmd646_1_dma_end(ide_drive_t *drive) | |||
333 | return (dma_stat & 7) != 4; | 333 | return (dma_stat & 7) != 4; |
334 | } | 334 | } |
335 | 335 | ||
336 | static unsigned int init_chipset_cmd64x(struct pci_dev *dev) | 336 | static int init_chipset_cmd64x(struct pci_dev *dev) |
337 | { | 337 | { |
338 | u8 mrdmode = 0; | 338 | u8 mrdmode = 0; |
339 | 339 | ||
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c index d003bec56ff9..58fb90e5b763 100644 --- a/drivers/ide/cs5520.c +++ b/drivers/ide/cs5520.c | |||
@@ -133,7 +133,8 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic | |||
133 | * do all the device setup for us | 133 | * do all the device setup for us |
134 | */ | 134 | */ |
135 | 135 | ||
136 | ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]); | 136 | ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); |
137 | hw[0].irq = 14; | ||
137 | 138 | ||
138 | return ide_host_add(d, hws, NULL); | 139 | return ide_host_add(d, hws, NULL); |
139 | } | 140 | } |
diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c index d8ede85fe17f..8e8b35a89901 100644 --- a/drivers/ide/cs5530.c +++ b/drivers/ide/cs5530.c | |||
@@ -135,7 +135,7 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
135 | * Initialize the cs5530 bridge for reliable IDE DMA operation. | 135 | * Initialize the cs5530 bridge for reliable IDE DMA operation. |
136 | */ | 136 | */ |
137 | 137 | ||
138 | static unsigned int init_chipset_cs5530(struct pci_dev *dev) | 138 | static int init_chipset_cs5530(struct pci_dev *dev) |
139 | { | 139 | { |
140 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; | 140 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; |
141 | 141 | ||
diff --git a/drivers/ide/delkin_cb.c b/drivers/ide/delkin_cb.c index 8f1b2d9f0513..bacb1194c9c9 100644 --- a/drivers/ide/delkin_cb.c +++ b/drivers/ide/delkin_cb.c | |||
@@ -46,7 +46,7 @@ static const struct ide_port_ops delkin_cb_port_ops = { | |||
46 | .quirkproc = ide_undecoded_slave, | 46 | .quirkproc = ide_undecoded_slave, |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static unsigned int delkin_cb_init_chipset(struct pci_dev *dev) | 49 | static int delkin_cb_init_chipset(struct pci_dev *dev) |
50 | { | 50 | { |
51 | unsigned long base = pci_resource_start(dev, 0); | 51 | unsigned long base = pci_resource_start(dev, 0); |
52 | int i; | 52 | int i; |
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index 3eb9b5c63a0f..d3b3e824f445 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c | |||
@@ -995,7 +995,7 @@ static void hpt3xx_disable_fast_irq(struct pci_dev *dev, u8 mcr_addr) | |||
995 | pci_write_config_byte(dev, mcr_addr + 1, new_mcr); | 995 | pci_write_config_byte(dev, mcr_addr + 1, new_mcr); |
996 | } | 996 | } |
997 | 997 | ||
998 | static unsigned int init_chipset_hpt366(struct pci_dev *dev) | 998 | static int init_chipset_hpt366(struct pci_dev *dev) |
999 | { | 999 | { |
1000 | unsigned long io_base = pci_resource_start(dev, 4); | 1000 | unsigned long io_base = pci_resource_start(dev, 4); |
1001 | struct hpt_info *info = hpt3xx_get_info(&dev->dev); | 1001 | struct hpt_info *info = hpt3xx_get_info(&dev->dev); |
@@ -1237,7 +1237,7 @@ static unsigned int init_chipset_hpt366(struct pci_dev *dev) | |||
1237 | hpt3xx_disable_fast_irq(dev, 0x50); | 1237 | hpt3xx_disable_fast_irq(dev, 0x50); |
1238 | hpt3xx_disable_fast_irq(dev, 0x54); | 1238 | hpt3xx_disable_fast_irq(dev, 0x54); |
1239 | 1239 | ||
1240 | return dev->irq; | 1240 | return 0; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | static u8 hpt3xx_cable_detect(ide_hwif_t *hwif) | 1243 | static u8 hpt3xx_cable_detect(ide_hwif_t *hwif) |
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index ec7d07fa570a..5b704f1ea90c 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -20,9 +20,6 @@ | |||
20 | #include <acpi/acpi_bus.h> | 20 | #include <acpi/acpi_bus.h> |
21 | 21 | ||
22 | #define REGS_PER_GTF 7 | 22 | #define REGS_PER_GTF 7 |
23 | struct taskfile_array { | ||
24 | u8 tfa[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */ | ||
25 | }; | ||
26 | 23 | ||
27 | struct GTM_buffer { | 24 | struct GTM_buffer { |
28 | u32 PIO_speed0; | 25 | u32 PIO_speed0; |
@@ -89,12 +86,8 @@ static const struct dmi_system_id ide_acpi_dmi_table[] = { | |||
89 | { } /* terminate list */ | 86 | { } /* terminate list */ |
90 | }; | 87 | }; |
91 | 88 | ||
92 | static int ide_acpi_blacklist(void) | 89 | int ide_acpi_init(void) |
93 | { | 90 | { |
94 | static int done; | ||
95 | if (done) | ||
96 | return 0; | ||
97 | done = 1; | ||
98 | dmi_check_system(ide_acpi_dmi_table); | 91 | dmi_check_system(ide_acpi_dmi_table); |
99 | return 0; | 92 | return 0; |
100 | } | 93 | } |
@@ -202,40 +195,6 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif) | |||
202 | } | 195 | } |
203 | 196 | ||
204 | /** | 197 | /** |
205 | * ide_acpi_drive_get_handle - Get ACPI object handle for a given drive | ||
206 | * @drive: device to locate | ||
207 | * | ||
208 | * Retrieves the object handle of a given drive. According to the ACPI | ||
209 | * spec the drive is a child of the hwif. | ||
210 | * | ||
211 | * Returns handle on success, 0 on error. | ||
212 | */ | ||
213 | static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive) | ||
214 | { | ||
215 | ide_hwif_t *hwif = drive->hwif; | ||
216 | int port; | ||
217 | acpi_handle drive_handle; | ||
218 | |||
219 | if (!hwif->acpidata) | ||
220 | return NULL; | ||
221 | |||
222 | if (!hwif->acpidata->obj_handle) | ||
223 | return NULL; | ||
224 | |||
225 | port = hwif->channel ? drive->dn - 2: drive->dn; | ||
226 | |||
227 | DEBPRINT("ENTER: %s at channel#: %d port#: %d\n", | ||
228 | drive->name, hwif->channel, port); | ||
229 | |||
230 | |||
231 | /* TBD: could also check ACPI object VALID bits */ | ||
232 | drive_handle = acpi_get_child(hwif->acpidata->obj_handle, port); | ||
233 | DEBPRINT("drive %s handle 0x%p\n", drive->name, drive_handle); | ||
234 | |||
235 | return drive_handle; | ||
236 | } | ||
237 | |||
238 | /** | ||
239 | * do_drive_get_GTF - get the drive bootup default taskfile settings | 198 | * do_drive_get_GTF - get the drive bootup default taskfile settings |
240 | * @drive: the drive for which the taskfile settings should be retrieved | 199 | * @drive: the drive for which the taskfile settings should be retrieved |
241 | * @gtf_length: number of bytes of _GTF data returned at @gtf_address | 200 | * @gtf_length: number of bytes of _GTF data returned at @gtf_address |
@@ -257,47 +216,15 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
257 | acpi_status status; | 216 | acpi_status status; |
258 | struct acpi_buffer output; | 217 | struct acpi_buffer output; |
259 | union acpi_object *out_obj; | 218 | union acpi_object *out_obj; |
260 | ide_hwif_t *hwif = drive->hwif; | ||
261 | struct device *dev = hwif->gendev.parent; | ||
262 | int err = -ENODEV; | 219 | int err = -ENODEV; |
263 | int port; | ||
264 | 220 | ||
265 | *gtf_length = 0; | 221 | *gtf_length = 0; |
266 | *gtf_address = 0UL; | 222 | *gtf_address = 0UL; |
267 | *obj_loc = 0UL; | 223 | *obj_loc = 0UL; |
268 | 224 | ||
269 | if (ide_noacpi) | ||
270 | return 0; | ||
271 | |||
272 | if (!dev) { | ||
273 | DEBPRINT("no PCI device for %s\n", hwif->name); | ||
274 | goto out; | ||
275 | } | ||
276 | |||
277 | if (!hwif->acpidata) { | ||
278 | DEBPRINT("no ACPI data for %s\n", hwif->name); | ||
279 | goto out; | ||
280 | } | ||
281 | |||
282 | port = hwif->channel ? drive->dn - 2: drive->dn; | ||
283 | |||
284 | DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n", | ||
285 | hwif->name, dev_name(dev), port, hwif->channel); | ||
286 | |||
287 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) { | ||
288 | DEBPRINT("%s drive %d:%d not present\n", | ||
289 | hwif->name, hwif->channel, port); | ||
290 | goto out; | ||
291 | } | ||
292 | |||
293 | /* Get this drive's _ADR info. if not already known. */ | ||
294 | if (!drive->acpidata->obj_handle) { | 225 | if (!drive->acpidata->obj_handle) { |
295 | drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); | 226 | DEBPRINT("No ACPI object found for %s\n", drive->name); |
296 | if (!drive->acpidata->obj_handle) { | 227 | goto out; |
297 | DEBPRINT("No ACPI object found for %s\n", | ||
298 | drive->name); | ||
299 | goto out; | ||
300 | } | ||
301 | } | 228 | } |
302 | 229 | ||
303 | /* Setting up output buffer */ | 230 | /* Setting up output buffer */ |
@@ -355,43 +282,6 @@ out: | |||
355 | } | 282 | } |
356 | 283 | ||
357 | /** | 284 | /** |
358 | * taskfile_load_raw - send taskfile registers to drive | ||
359 | * @drive: drive to which output is sent | ||
360 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) | ||
361 | * | ||
362 | * Outputs IDE taskfile to the drive. | ||
363 | */ | ||
364 | static int taskfile_load_raw(ide_drive_t *drive, | ||
365 | const struct taskfile_array *gtf) | ||
366 | { | ||
367 | ide_task_t args; | ||
368 | int err = 0; | ||
369 | |||
370 | DEBPRINT("(0x1f1-1f7): hex: " | ||
371 | "%02x %02x %02x %02x %02x %02x %02x\n", | ||
372 | gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], | ||
373 | gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]); | ||
374 | |||
375 | memset(&args, 0, sizeof(ide_task_t)); | ||
376 | |||
377 | /* convert gtf to IDE Taskfile */ | ||
378 | memcpy(&args.tf_array[7], >f->tfa, 7); | ||
379 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
380 | |||
381 | if (!ide_acpigtf) { | ||
382 | DEBPRINT("_GTF execution disabled\n"); | ||
383 | return err; | ||
384 | } | ||
385 | |||
386 | err = ide_no_data_taskfile(drive, &args); | ||
387 | if (err) | ||
388 | printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", | ||
389 | __func__, err); | ||
390 | |||
391 | return err; | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * do_drive_set_taskfiles - write the drive taskfile settings from _GTF | 285 | * do_drive_set_taskfiles - write the drive taskfile settings from _GTF |
396 | * @drive: the drive to which the taskfile command should be sent | 286 | * @drive: the drive to which the taskfile command should be sent |
397 | * @gtf_length: total number of bytes of _GTF taskfiles | 287 | * @gtf_length: total number of bytes of _GTF taskfiles |
@@ -404,43 +294,41 @@ static int do_drive_set_taskfiles(ide_drive_t *drive, | |||
404 | unsigned int gtf_length, | 294 | unsigned int gtf_length, |
405 | unsigned long gtf_address) | 295 | unsigned long gtf_address) |
406 | { | 296 | { |
407 | int rc = -ENODEV, err; | 297 | int rc = 0, err; |
408 | int gtf_count = gtf_length / REGS_PER_GTF; | 298 | int gtf_count = gtf_length / REGS_PER_GTF; |
409 | int ix; | 299 | int ix; |
410 | struct taskfile_array *gtf; | ||
411 | |||
412 | if (ide_noacpi) | ||
413 | return 0; | ||
414 | |||
415 | DEBPRINT("ENTER: %s, hard_port#: %d\n", drive->name, drive->dn); | ||
416 | |||
417 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | ||
418 | goto out; | ||
419 | |||
420 | if (!gtf_count) /* shouldn't be here */ | ||
421 | goto out; | ||
422 | 300 | ||
423 | DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n", | 301 | DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n", |
424 | gtf_length, gtf_length, gtf_count, gtf_address); | 302 | gtf_length, gtf_length, gtf_count, gtf_address); |
425 | 303 | ||
426 | if (gtf_length % REGS_PER_GTF) { | 304 | /* send all taskfile registers (0x1f1-0x1f7) *in*that*order* */ |
427 | printk(KERN_ERR "%s: unexpected GTF length (%d)\n", | ||
428 | __func__, gtf_length); | ||
429 | goto out; | ||
430 | } | ||
431 | |||
432 | rc = 0; | ||
433 | for (ix = 0; ix < gtf_count; ix++) { | 305 | for (ix = 0; ix < gtf_count; ix++) { |
434 | gtf = (struct taskfile_array *) | 306 | u8 *gtf = (u8 *)(gtf_address + ix * REGS_PER_GTF); |
435 | (gtf_address + ix * REGS_PER_GTF); | 307 | ide_task_t task; |
436 | 308 | ||
437 | /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ | 309 | DEBPRINT("(0x1f1-1f7): " |
438 | err = taskfile_load_raw(drive, gtf); | 310 | "hex: %02x %02x %02x %02x %02x %02x %02x\n", |
439 | if (err) | 311 | gtf[0], gtf[1], gtf[2], |
312 | gtf[3], gtf[4], gtf[5], gtf[6]); | ||
313 | |||
314 | if (!ide_acpigtf) { | ||
315 | DEBPRINT("_GTF execution disabled\n"); | ||
316 | continue; | ||
317 | } | ||
318 | |||
319 | /* convert GTF to taskfile */ | ||
320 | memset(&task, 0, sizeof(ide_task_t)); | ||
321 | memcpy(&task.tf_array[7], gtf, REGS_PER_GTF); | ||
322 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
323 | |||
324 | err = ide_no_data_taskfile(drive, &task); | ||
325 | if (err) { | ||
326 | printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", | ||
327 | __func__, err); | ||
440 | rc = err; | 328 | rc = err; |
329 | } | ||
441 | } | 330 | } |
442 | 331 | ||
443 | out: | ||
444 | return rc; | 332 | return rc; |
445 | } | 333 | } |
446 | 334 | ||
@@ -647,26 +535,23 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) | |||
647 | DEBPRINT("no ACPI data for %s\n", hwif->name); | 535 | DEBPRINT("no ACPI data for %s\n", hwif->name); |
648 | return; | 536 | return; |
649 | } | 537 | } |
538 | |||
650 | /* channel first and then drives for power on and verse versa for power off */ | 539 | /* channel first and then drives for power on and verse versa for power off */ |
651 | if (on) | 540 | if (on) |
652 | acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); | 541 | acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); |
653 | 542 | ||
654 | ide_port_for_each_dev(i, drive, hwif) { | 543 | ide_port_for_each_present_dev(i, drive, hwif) { |
655 | if (!drive->acpidata->obj_handle) | 544 | if (drive->acpidata->obj_handle) |
656 | drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); | ||
657 | |||
658 | if (drive->acpidata->obj_handle && | ||
659 | (drive->dev_flags & IDE_DFLAG_PRESENT)) { | ||
660 | acpi_bus_set_power(drive->acpidata->obj_handle, | 545 | acpi_bus_set_power(drive->acpidata->obj_handle, |
661 | on? ACPI_STATE_D0: ACPI_STATE_D3); | 546 | on ? ACPI_STATE_D0 : ACPI_STATE_D3); |
662 | } | ||
663 | } | 547 | } |
548 | |||
664 | if (!on) | 549 | if (!on) |
665 | acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3); | 550 | acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3); |
666 | } | 551 | } |
667 | 552 | ||
668 | /** | 553 | /** |
669 | * ide_acpi_init - initialize the ACPI link for an IDE interface | 554 | * ide_acpi_init_port - initialize the ACPI link for an IDE interface |
670 | * @hwif: target IDE interface (channel) | 555 | * @hwif: target IDE interface (channel) |
671 | * | 556 | * |
672 | * The ACPI spec is not quite clear when the drive identify buffer | 557 | * The ACPI spec is not quite clear when the drive identify buffer |
@@ -676,10 +561,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) | |||
676 | * So we get the information during startup; but this means that | 561 | * So we get the information during startup; but this means that |
677 | * any changes during run-time will be lost after resume. | 562 | * any changes during run-time will be lost after resume. |
678 | */ | 563 | */ |
679 | void ide_acpi_init(ide_hwif_t *hwif) | 564 | void ide_acpi_init_port(ide_hwif_t *hwif) |
680 | { | 565 | { |
681 | ide_acpi_blacklist(); | ||
682 | |||
683 | hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); | 566 | hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); |
684 | if (!hwif->acpidata) | 567 | if (!hwif->acpidata) |
685 | return; | 568 | return; |
@@ -708,15 +591,24 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) | |||
708 | hwif->devices[0]->acpidata = &hwif->acpidata->master; | 591 | hwif->devices[0]->acpidata = &hwif->acpidata->master; |
709 | hwif->devices[1]->acpidata = &hwif->acpidata->slave; | 592 | hwif->devices[1]->acpidata = &hwif->acpidata->slave; |
710 | 593 | ||
711 | /* | 594 | /* get _ADR info for each device */ |
712 | * Send IDENTIFY for each drive | 595 | ide_port_for_each_present_dev(i, drive, hwif) { |
713 | */ | 596 | acpi_handle dev_handle; |
714 | ide_port_for_each_dev(i, drive, hwif) { | ||
715 | memset(drive->acpidata, 0, sizeof(*drive->acpidata)); | ||
716 | 597 | ||
717 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 598 | DEBPRINT("ENTER: %s at channel#: %d port#: %d\n", |
718 | continue; | 599 | drive->name, hwif->channel, drive->dn & 1); |
600 | |||
601 | /* TBD: could also check ACPI object VALID bits */ | ||
602 | dev_handle = acpi_get_child(hwif->acpidata->obj_handle, | ||
603 | drive->dn & 1); | ||
604 | |||
605 | DEBPRINT("drive %s handle 0x%p\n", drive->name, dev_handle); | ||
606 | |||
607 | drive->acpidata->obj_handle = dev_handle; | ||
608 | } | ||
719 | 609 | ||
610 | /* send IDENTIFY for each device */ | ||
611 | ide_port_for_each_present_dev(i, drive, hwif) { | ||
720 | err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff); | 612 | err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff); |
721 | if (err) | 613 | if (err) |
722 | DEBPRINT("identify device %s failed (%d)\n", | 614 | DEBPRINT("identify device %s failed (%d)\n", |
@@ -736,9 +628,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) | |||
736 | ide_acpi_get_timing(hwif); | 628 | ide_acpi_get_timing(hwif); |
737 | ide_acpi_push_timing(hwif); | 629 | ide_acpi_push_timing(hwif); |
738 | 630 | ||
739 | ide_port_for_each_dev(i, drive, hwif) { | 631 | ide_port_for_each_present_dev(i, drive, hwif) { |
740 | if (drive->dev_flags & IDE_DFLAG_PRESENT) | 632 | ide_acpi_exec_tfs(drive); |
741 | /* Execute ACPI startup code */ | ||
742 | ide_acpi_exec_tfs(drive); | ||
743 | } | 633 | } |
744 | } | 634 | } |
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index e9d042dba0e0..6adc5b4a4406 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -149,7 +149,10 @@ static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, | |||
149 | memcpy(rq->cmd, pc->c, 12); | 149 | memcpy(rq->cmd, pc->c, 12); |
150 | if (drive->media == ide_tape) | 150 | if (drive->media == ide_tape) |
151 | rq->cmd[13] = REQ_IDETAPE_PC1; | 151 | rq->cmd[13] = REQ_IDETAPE_PC1; |
152 | ide_do_drive_cmd(drive, rq); | 152 | |
153 | drive->hwif->rq = NULL; | ||
154 | |||
155 | elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0); | ||
153 | } | 156 | } |
154 | 157 | ||
155 | /* | 158 | /* |
@@ -297,6 +300,21 @@ int ide_cd_get_xferlen(struct request *rq) | |||
297 | } | 300 | } |
298 | EXPORT_SYMBOL_GPL(ide_cd_get_xferlen); | 301 | EXPORT_SYMBOL_GPL(ide_cd_get_xferlen); |
299 | 302 | ||
303 | void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason) | ||
304 | { | ||
305 | ide_task_t task; | ||
306 | |||
307 | memset(&task, 0, sizeof(task)); | ||
308 | task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM | | ||
309 | IDE_TFLAG_IN_NSECT; | ||
310 | |||
311 | drive->hwif->tp_ops->tf_read(drive, &task); | ||
312 | |||
313 | *bcount = (task.tf.lbah << 8) | task.tf.lbam; | ||
314 | *ireason = task.tf.nsect & 3; | ||
315 | } | ||
316 | EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); | ||
317 | |||
300 | /* | 318 | /* |
301 | * This is the usual interrupt handler which will be called during a packet | 319 | * This is the usual interrupt handler which will be called during a packet |
302 | * command. We will transfer some of the data (as requested by the drive) | 320 | * command. We will transfer some of the data (as requested by the drive) |
@@ -456,6 +474,25 @@ next_irq: | |||
456 | return ide_started; | 474 | return ide_started; |
457 | } | 475 | } |
458 | 476 | ||
477 | static void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount) | ||
478 | { | ||
479 | ide_hwif_t *hwif = drive->hwif; | ||
480 | ide_task_t task; | ||
481 | u8 dma = drive->dma; | ||
482 | |||
483 | memset(&task, 0, sizeof(task)); | ||
484 | task.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM | | ||
485 | IDE_TFLAG_OUT_FEATURE | tf_flags; | ||
486 | task.tf.feature = dma; /* Use PIO/DMA */ | ||
487 | task.tf.lbam = bcount & 0xff; | ||
488 | task.tf.lbah = (bcount >> 8) & 0xff; | ||
489 | |||
490 | ide_tf_dump(drive->name, &task.tf); | ||
491 | hwif->tp_ops->set_irq(hwif, 1); | ||
492 | SELECT_MASK(drive, 0); | ||
493 | hwif->tp_ops->tf_load(drive, &task); | ||
494 | } | ||
495 | |||
459 | static u8 ide_read_ireason(ide_drive_t *drive) | 496 | static u8 ide_read_ireason(ide_drive_t *drive) |
460 | { | 497 | { |
461 | ide_task_t task; | 498 | ide_task_t task; |
@@ -629,7 +666,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive) | |||
629 | : WAIT_TAPE_CMD; | 666 | : WAIT_TAPE_CMD; |
630 | } | 667 | } |
631 | 668 | ||
632 | ide_pktcmd_tf_load(drive, tf_flags, bcount, drive->dma); | 669 | ide_pktcmd_tf_load(drive, tf_flags, bcount); |
633 | 670 | ||
634 | /* Issue the packet command */ | 671 | /* Issue the packet command */ |
635 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { | 672 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index ddfbea41d296..2177cd11664c 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -242,7 +242,9 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
242 | ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x\n", | 242 | ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x\n", |
243 | failed_command->cmd[0]); | 243 | failed_command->cmd[0]); |
244 | 244 | ||
245 | ide_do_drive_cmd(drive, rq); | 245 | drive->hwif->rq = NULL; |
246 | |||
247 | elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0); | ||
246 | } | 248 | } |
247 | 249 | ||
248 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) | 250 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) |
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c new file mode 100644 index 000000000000..7c3953414d47 --- /dev/null +++ b/drivers/ide/ide-devsets.c | |||
@@ -0,0 +1,190 @@ | |||
1 | |||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/ide.h> | ||
4 | |||
5 | DEFINE_MUTEX(ide_setting_mtx); | ||
6 | |||
7 | ide_devset_get(io_32bit, io_32bit); | ||
8 | |||
9 | static int set_io_32bit(ide_drive_t *drive, int arg) | ||
10 | { | ||
11 | if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) | ||
12 | return -EPERM; | ||
13 | |||
14 | if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) | ||
15 | return -EINVAL; | ||
16 | |||
17 | drive->io_32bit = arg; | ||
18 | |||
19 | return 0; | ||
20 | } | ||
21 | |||
22 | ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS); | ||
23 | |||
24 | static int set_ksettings(ide_drive_t *drive, int arg) | ||
25 | { | ||
26 | if (arg < 0 || arg > 1) | ||
27 | return -EINVAL; | ||
28 | |||
29 | if (arg) | ||
30 | drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS; | ||
31 | else | ||
32 | drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS; | ||
33 | |||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA); | ||
38 | |||
39 | static int set_using_dma(ide_drive_t *drive, int arg) | ||
40 | { | ||
41 | #ifdef CONFIG_BLK_DEV_IDEDMA | ||
42 | int err = -EPERM; | ||
43 | |||
44 | if (arg < 0 || arg > 1) | ||
45 | return -EINVAL; | ||
46 | |||
47 | if (ata_id_has_dma(drive->id) == 0) | ||
48 | goto out; | ||
49 | |||
50 | if (drive->hwif->dma_ops == NULL) | ||
51 | goto out; | ||
52 | |||
53 | err = 0; | ||
54 | |||
55 | if (arg) { | ||
56 | if (ide_set_dma(drive)) | ||
57 | err = -EIO; | ||
58 | } else | ||
59 | ide_dma_off(drive); | ||
60 | |||
61 | out: | ||
62 | return err; | ||
63 | #else | ||
64 | if (arg < 0 || arg > 1) | ||
65 | return -EINVAL; | ||
66 | |||
67 | return -EPERM; | ||
68 | #endif | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away | ||
73 | */ | ||
74 | static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) | ||
75 | { | ||
76 | switch (req_pio) { | ||
77 | case 202: | ||
78 | case 201: | ||
79 | case 200: | ||
80 | case 102: | ||
81 | case 101: | ||
82 | case 100: | ||
83 | return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0; | ||
84 | case 9: | ||
85 | case 8: | ||
86 | return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0; | ||
87 | case 7: | ||
88 | case 6: | ||
89 | return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0; | ||
90 | default: | ||
91 | return 0; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | static int set_pio_mode(ide_drive_t *drive, int arg) | ||
96 | { | ||
97 | ide_hwif_t *hwif = drive->hwif; | ||
98 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
99 | |||
100 | if (arg < 0 || arg > 255) | ||
101 | return -EINVAL; | ||
102 | |||
103 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || | ||
104 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
105 | return -ENOSYS; | ||
106 | |||
107 | if (set_pio_mode_abuse(drive->hwif, arg)) { | ||
108 | if (arg == 8 || arg == 9) { | ||
109 | unsigned long flags; | ||
110 | |||
111 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ | ||
112 | spin_lock_irqsave(&hwif->lock, flags); | ||
113 | port_ops->set_pio_mode(drive, arg); | ||
114 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
115 | } else | ||
116 | port_ops->set_pio_mode(drive, arg); | ||
117 | } else { | ||
118 | int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | ||
119 | |||
120 | ide_set_pio(drive, arg); | ||
121 | |||
122 | if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) { | ||
123 | if (keep_dma) | ||
124 | ide_dma_on(drive); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK); | ||
132 | |||
133 | static int set_unmaskirq(ide_drive_t *drive, int arg) | ||
134 | { | ||
135 | if (drive->dev_flags & IDE_DFLAG_NO_UNMASK) | ||
136 | return -EPERM; | ||
137 | |||
138 | if (arg < 0 || arg > 1) | ||
139 | return -EINVAL; | ||
140 | |||
141 | if (arg) | ||
142 | drive->dev_flags |= IDE_DFLAG_UNMASK; | ||
143 | else | ||
144 | drive->dev_flags &= ~IDE_DFLAG_UNMASK; | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | ide_ext_devset_rw_sync(io_32bit, io_32bit); | ||
150 | ide_ext_devset_rw_sync(keepsettings, ksettings); | ||
151 | ide_ext_devset_rw_sync(unmaskirq, unmaskirq); | ||
152 | ide_ext_devset_rw_sync(using_dma, using_dma); | ||
153 | __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); | ||
154 | |||
155 | int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, | ||
156 | int arg) | ||
157 | { | ||
158 | struct request_queue *q = drive->queue; | ||
159 | struct request *rq; | ||
160 | int ret = 0; | ||
161 | |||
162 | if (!(setting->flags & DS_SYNC)) | ||
163 | return setting->set(drive, arg); | ||
164 | |||
165 | rq = blk_get_request(q, READ, __GFP_WAIT); | ||
166 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
167 | rq->cmd_len = 5; | ||
168 | rq->cmd[0] = REQ_DEVSET_EXEC; | ||
169 | *(int *)&rq->cmd[1] = arg; | ||
170 | rq->special = setting->set; | ||
171 | |||
172 | if (blk_execute_rq(q, NULL, rq, 0)) | ||
173 | ret = rq->errors; | ||
174 | blk_put_request(rq); | ||
175 | |||
176 | return ret; | ||
177 | } | ||
178 | |||
179 | ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq) | ||
180 | { | ||
181 | int err, (*setfunc)(ide_drive_t *, int) = rq->special; | ||
182 | |||
183 | err = setfunc(drive, *(int *)&rq->cmd[1]); | ||
184 | if (err) | ||
185 | rq->errors = err; | ||
186 | else | ||
187 | err = 1; | ||
188 | ide_end_request(drive, err, 0); | ||
189 | return ide_stopped; | ||
190 | } | ||
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 059c90bb5ad2..a878f4734f81 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -470,6 +470,63 @@ void ide_dma_timeout(ide_drive_t *drive) | |||
470 | } | 470 | } |
471 | EXPORT_SYMBOL_GPL(ide_dma_timeout); | 471 | EXPORT_SYMBOL_GPL(ide_dma_timeout); |
472 | 472 | ||
473 | /* | ||
474 | * un-busy the port etc, and clear any pending DMA status. we want to | ||
475 | * retry the current request in pio mode instead of risking tossing it | ||
476 | * all away | ||
477 | */ | ||
478 | ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | ||
479 | { | ||
480 | ide_hwif_t *hwif = drive->hwif; | ||
481 | struct request *rq; | ||
482 | ide_startstop_t ret = ide_stopped; | ||
483 | |||
484 | /* | ||
485 | * end current dma transaction | ||
486 | */ | ||
487 | |||
488 | if (error < 0) { | ||
489 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); | ||
490 | (void)hwif->dma_ops->dma_end(drive); | ||
491 | ret = ide_error(drive, "dma timeout error", | ||
492 | hwif->tp_ops->read_status(hwif)); | ||
493 | } else { | ||
494 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); | ||
495 | hwif->dma_ops->dma_timeout(drive); | ||
496 | } | ||
497 | |||
498 | /* | ||
499 | * disable dma for now, but remember that we did so because of | ||
500 | * a timeout -- we'll reenable after we finish this next request | ||
501 | * (or rather the first chunk of it) in pio. | ||
502 | */ | ||
503 | drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY; | ||
504 | drive->retry_pio++; | ||
505 | ide_dma_off_quietly(drive); | ||
506 | |||
507 | /* | ||
508 | * un-busy drive etc and make sure request is sane | ||
509 | */ | ||
510 | |||
511 | rq = hwif->rq; | ||
512 | if (!rq) | ||
513 | goto out; | ||
514 | |||
515 | hwif->rq = NULL; | ||
516 | |||
517 | rq->errors = 0; | ||
518 | |||
519 | if (!rq->bio) | ||
520 | goto out; | ||
521 | |||
522 | rq->sector = rq->bio->bi_sector; | ||
523 | rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9; | ||
524 | rq->hard_cur_sectors = rq->current_nr_sectors; | ||
525 | rq->buffer = bio_data(rq->bio); | ||
526 | out: | ||
527 | return ret; | ||
528 | } | ||
529 | |||
473 | void ide_release_dma_engine(ide_hwif_t *hwif) | 530 | void ide_release_dma_engine(ide_hwif_t *hwif) |
474 | { | 531 | { |
475 | if (hwif->dmatable_cpu) { | 532 | if (hwif->dmatable_cpu) { |
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c new file mode 100644 index 000000000000..1231b5e486f2 --- /dev/null +++ b/drivers/ide/ide-eh.c | |||
@@ -0,0 +1,428 @@ | |||
1 | |||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/ide.h> | ||
4 | #include <linux/delay.h> | ||
5 | |||
6 | static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, | ||
7 | u8 stat, u8 err) | ||
8 | { | ||
9 | ide_hwif_t *hwif = drive->hwif; | ||
10 | |||
11 | if ((stat & ATA_BUSY) || | ||
12 | ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) { | ||
13 | /* other bits are useless when BUSY */ | ||
14 | rq->errors |= ERROR_RESET; | ||
15 | } else if (stat & ATA_ERR) { | ||
16 | /* err has different meaning on cdrom and tape */ | ||
17 | if (err == ATA_ABORTED) { | ||
18 | if ((drive->dev_flags & IDE_DFLAG_LBA) && | ||
19 | /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ | ||
20 | hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS) | ||
21 | return ide_stopped; | ||
22 | } else if ((err & BAD_CRC) == BAD_CRC) { | ||
23 | /* UDMA crc error, just retry the operation */ | ||
24 | drive->crc_count++; | ||
25 | } else if (err & (ATA_BBK | ATA_UNC)) { | ||
26 | /* retries won't help these */ | ||
27 | rq->errors = ERROR_MAX; | ||
28 | } else if (err & ATA_TRK0NF) { | ||
29 | /* help it find track zero */ | ||
30 | rq->errors |= ERROR_RECAL; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ && | ||
35 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) { | ||
36 | int nsect = drive->mult_count ? drive->mult_count : 1; | ||
37 | |||
38 | ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE); | ||
39 | } | ||
40 | |||
41 | if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { | ||
42 | ide_kill_rq(drive, rq); | ||
43 | return ide_stopped; | ||
44 | } | ||
45 | |||
46 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) | ||
47 | rq->errors |= ERROR_RESET; | ||
48 | |||
49 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { | ||
50 | ++rq->errors; | ||
51 | return ide_do_reset(drive); | ||
52 | } | ||
53 | |||
54 | if ((rq->errors & ERROR_RECAL) == ERROR_RECAL) | ||
55 | drive->special.b.recalibrate = 1; | ||
56 | |||
57 | ++rq->errors; | ||
58 | |||
59 | return ide_stopped; | ||
60 | } | ||
61 | |||
62 | static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, | ||
63 | u8 stat, u8 err) | ||
64 | { | ||
65 | ide_hwif_t *hwif = drive->hwif; | ||
66 | |||
67 | if ((stat & ATA_BUSY) || | ||
68 | ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) { | ||
69 | /* other bits are useless when BUSY */ | ||
70 | rq->errors |= ERROR_RESET; | ||
71 | } else { | ||
72 | /* add decoding error stuff */ | ||
73 | } | ||
74 | |||
75 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) | ||
76 | /* force an abort */ | ||
77 | hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE); | ||
78 | |||
79 | if (rq->errors >= ERROR_MAX) { | ||
80 | ide_kill_rq(drive, rq); | ||
81 | } else { | ||
82 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { | ||
83 | ++rq->errors; | ||
84 | return ide_do_reset(drive); | ||
85 | } | ||
86 | ++rq->errors; | ||
87 | } | ||
88 | |||
89 | return ide_stopped; | ||
90 | } | ||
91 | |||
92 | static ide_startstop_t __ide_error(ide_drive_t *drive, struct request *rq, | ||
93 | u8 stat, u8 err) | ||
94 | { | ||
95 | if (drive->media == ide_disk) | ||
96 | return ide_ata_error(drive, rq, stat, err); | ||
97 | return ide_atapi_error(drive, rq, stat, err); | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * ide_error - handle an error on the IDE | ||
102 | * @drive: drive the error occurred on | ||
103 | * @msg: message to report | ||
104 | * @stat: status bits | ||
105 | * | ||
106 | * ide_error() takes action based on the error returned by the drive. | ||
107 | * For normal I/O that may well include retries. We deal with | ||
108 | * both new-style (taskfile) and old style command handling here. | ||
109 | * In the case of taskfile command handling there is work left to | ||
110 | * do | ||
111 | */ | ||
112 | |||
113 | ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat) | ||
114 | { | ||
115 | struct request *rq; | ||
116 | u8 err; | ||
117 | |||
118 | err = ide_dump_status(drive, msg, stat); | ||
119 | |||
120 | rq = drive->hwif->rq; | ||
121 | if (rq == NULL) | ||
122 | return ide_stopped; | ||
123 | |||
124 | /* retry only "normal" I/O: */ | ||
125 | if (!blk_fs_request(rq)) { | ||
126 | rq->errors = 1; | ||
127 | ide_end_drive_cmd(drive, stat, err); | ||
128 | return ide_stopped; | ||
129 | } | ||
130 | |||
131 | return __ide_error(drive, rq, stat, err); | ||
132 | } | ||
133 | EXPORT_SYMBOL_GPL(ide_error); | ||
134 | |||
135 | static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) | ||
136 | { | ||
137 | struct request *rq = drive->hwif->rq; | ||
138 | |||
139 | if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) | ||
140 | ide_end_request(drive, err ? err : 1, 0); | ||
141 | } | ||
142 | |||
143 | /* needed below */ | ||
144 | static ide_startstop_t do_reset1(ide_drive_t *, int); | ||
145 | |||
146 | /* | ||
147 | * atapi_reset_pollfunc() gets invoked to poll the interface for completion | ||
148 | * every 50ms during an atapi drive reset operation. If the drive has not yet | ||
149 | * responded, and we have not yet hit our maximum waiting time, then the timer | ||
150 | * is restarted for another 50ms. | ||
151 | */ | ||
152 | static ide_startstop_t atapi_reset_pollfunc(ide_drive_t *drive) | ||
153 | { | ||
154 | ide_hwif_t *hwif = drive->hwif; | ||
155 | u8 stat; | ||
156 | |||
157 | SELECT_DRIVE(drive); | ||
158 | udelay(10); | ||
159 | stat = hwif->tp_ops->read_status(hwif); | ||
160 | |||
161 | if (OK_STAT(stat, 0, ATA_BUSY)) | ||
162 | printk(KERN_INFO "%s: ATAPI reset complete\n", drive->name); | ||
163 | else { | ||
164 | if (time_before(jiffies, hwif->poll_timeout)) { | ||
165 | ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, | ||
166 | NULL); | ||
167 | /* continue polling */ | ||
168 | return ide_started; | ||
169 | } | ||
170 | /* end of polling */ | ||
171 | hwif->polling = 0; | ||
172 | printk(KERN_ERR "%s: ATAPI reset timed-out, status=0x%02x\n", | ||
173 | drive->name, stat); | ||
174 | /* do it the old fashioned way */ | ||
175 | return do_reset1(drive, 1); | ||
176 | } | ||
177 | /* done polling */ | ||
178 | hwif->polling = 0; | ||
179 | ide_complete_drive_reset(drive, 0); | ||
180 | return ide_stopped; | ||
181 | } | ||
182 | |||
183 | static void ide_reset_report_error(ide_hwif_t *hwif, u8 err) | ||
184 | { | ||
185 | static const char *err_master_vals[] = | ||
186 | { NULL, "passed", "formatter device error", | ||
187 | "sector buffer error", "ECC circuitry error", | ||
188 | "controlling MPU error" }; | ||
189 | |||
190 | u8 err_master = err & 0x7f; | ||
191 | |||
192 | printk(KERN_ERR "%s: reset: master: ", hwif->name); | ||
193 | if (err_master && err_master < 6) | ||
194 | printk(KERN_CONT "%s", err_master_vals[err_master]); | ||
195 | else | ||
196 | printk(KERN_CONT "error (0x%02x?)", err); | ||
197 | if (err & 0x80) | ||
198 | printk(KERN_CONT "; slave: failed"); | ||
199 | printk(KERN_CONT "\n"); | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * reset_pollfunc() gets invoked to poll the interface for completion every 50ms | ||
204 | * during an ide reset operation. If the drives have not yet responded, | ||
205 | * and we have not yet hit our maximum waiting time, then the timer is restarted | ||
206 | * for another 50ms. | ||
207 | */ | ||
208 | static ide_startstop_t reset_pollfunc(ide_drive_t *drive) | ||
209 | { | ||
210 | ide_hwif_t *hwif = drive->hwif; | ||
211 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
212 | u8 tmp; | ||
213 | int err = 0; | ||
214 | |||
215 | if (port_ops && port_ops->reset_poll) { | ||
216 | err = port_ops->reset_poll(drive); | ||
217 | if (err) { | ||
218 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", | ||
219 | hwif->name, drive->name); | ||
220 | goto out; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | tmp = hwif->tp_ops->read_status(hwif); | ||
225 | |||
226 | if (!OK_STAT(tmp, 0, ATA_BUSY)) { | ||
227 | if (time_before(jiffies, hwif->poll_timeout)) { | ||
228 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | ||
229 | /* continue polling */ | ||
230 | return ide_started; | ||
231 | } | ||
232 | printk(KERN_ERR "%s: reset timed-out, status=0x%02x\n", | ||
233 | hwif->name, tmp); | ||
234 | drive->failures++; | ||
235 | err = -EIO; | ||
236 | } else { | ||
237 | tmp = ide_read_error(drive); | ||
238 | |||
239 | if (tmp == 1) { | ||
240 | printk(KERN_INFO "%s: reset: success\n", hwif->name); | ||
241 | drive->failures = 0; | ||
242 | } else { | ||
243 | ide_reset_report_error(hwif, tmp); | ||
244 | drive->failures++; | ||
245 | err = -EIO; | ||
246 | } | ||
247 | } | ||
248 | out: | ||
249 | hwif->polling = 0; /* done polling */ | ||
250 | ide_complete_drive_reset(drive, err); | ||
251 | return ide_stopped; | ||
252 | } | ||
253 | |||
254 | static void ide_disk_pre_reset(ide_drive_t *drive) | ||
255 | { | ||
256 | int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; | ||
257 | |||
258 | drive->special.all = 0; | ||
259 | drive->special.b.set_geometry = legacy; | ||
260 | drive->special.b.recalibrate = legacy; | ||
261 | |||
262 | drive->mult_count = 0; | ||
263 | drive->dev_flags &= ~IDE_DFLAG_PARKED; | ||
264 | |||
265 | if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 && | ||
266 | (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) | ||
267 | drive->mult_req = 0; | ||
268 | |||
269 | if (drive->mult_req != drive->mult_count) | ||
270 | drive->special.b.set_multmode = 1; | ||
271 | } | ||
272 | |||
273 | static void pre_reset(ide_drive_t *drive) | ||
274 | { | ||
275 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; | ||
276 | |||
277 | if (drive->media == ide_disk) | ||
278 | ide_disk_pre_reset(drive); | ||
279 | else | ||
280 | drive->dev_flags |= IDE_DFLAG_POST_RESET; | ||
281 | |||
282 | if (drive->dev_flags & IDE_DFLAG_USING_DMA) { | ||
283 | if (drive->crc_count) | ||
284 | ide_check_dma_crc(drive); | ||
285 | else | ||
286 | ide_dma_off(drive); | ||
287 | } | ||
288 | |||
289 | if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) { | ||
290 | if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) { | ||
291 | drive->dev_flags &= ~IDE_DFLAG_UNMASK; | ||
292 | drive->io_32bit = 0; | ||
293 | } | ||
294 | return; | ||
295 | } | ||
296 | |||
297 | if (port_ops && port_ops->pre_reset) | ||
298 | port_ops->pre_reset(drive); | ||
299 | |||
300 | if (drive->current_speed != 0xff) | ||
301 | drive->desired_speed = drive->current_speed; | ||
302 | drive->current_speed = 0xff; | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * do_reset1() attempts to recover a confused drive by resetting it. | ||
307 | * Unfortunately, resetting a disk drive actually resets all devices on | ||
308 | * the same interface, so it can really be thought of as resetting the | ||
309 | * interface rather than resetting the drive. | ||
310 | * | ||
311 | * ATAPI devices have their own reset mechanism which allows them to be | ||
312 | * individually reset without clobbering other devices on the same interface. | ||
313 | * | ||
314 | * Unfortunately, the IDE interface does not generate an interrupt to let | ||
315 | * us know when the reset operation has finished, so we must poll for this. | ||
316 | * Equally poor, though, is the fact that this may a very long time to complete, | ||
317 | * (up to 30 seconds worstcase). So, instead of busy-waiting here for it, | ||
318 | * we set a timer to poll at 50ms intervals. | ||
319 | */ | ||
320 | static ide_startstop_t do_reset1(ide_drive_t *drive, int do_not_try_atapi) | ||
321 | { | ||
322 | ide_hwif_t *hwif = drive->hwif; | ||
323 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
324 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
325 | const struct ide_port_ops *port_ops; | ||
326 | ide_drive_t *tdrive; | ||
327 | unsigned long flags, timeout; | ||
328 | int i; | ||
329 | DEFINE_WAIT(wait); | ||
330 | |||
331 | spin_lock_irqsave(&hwif->lock, flags); | ||
332 | |||
333 | /* We must not reset with running handlers */ | ||
334 | BUG_ON(hwif->handler != NULL); | ||
335 | |||
336 | /* For an ATAPI device, first try an ATAPI SRST. */ | ||
337 | if (drive->media != ide_disk && !do_not_try_atapi) { | ||
338 | pre_reset(drive); | ||
339 | SELECT_DRIVE(drive); | ||
340 | udelay(20); | ||
341 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | ||
342 | ndelay(400); | ||
343 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; | ||
344 | hwif->polling = 1; | ||
345 | __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); | ||
346 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
347 | return ide_started; | ||
348 | } | ||
349 | |||
350 | /* We must not disturb devices in the IDE_DFLAG_PARKED state. */ | ||
351 | do { | ||
352 | unsigned long now; | ||
353 | |||
354 | prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); | ||
355 | timeout = jiffies; | ||
356 | ide_port_for_each_present_dev(i, tdrive, hwif) { | ||
357 | if ((tdrive->dev_flags & IDE_DFLAG_PARKED) && | ||
358 | time_after(tdrive->sleep, timeout)) | ||
359 | timeout = tdrive->sleep; | ||
360 | } | ||
361 | |||
362 | now = jiffies; | ||
363 | if (time_before_eq(timeout, now)) | ||
364 | break; | ||
365 | |||
366 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
367 | timeout = schedule_timeout_uninterruptible(timeout - now); | ||
368 | spin_lock_irqsave(&hwif->lock, flags); | ||
369 | } while (timeout); | ||
370 | finish_wait(&ide_park_wq, &wait); | ||
371 | |||
372 | /* | ||
373 | * First, reset any device state data we were maintaining | ||
374 | * for any of the drives on this interface. | ||
375 | */ | ||
376 | ide_port_for_each_dev(i, tdrive, hwif) | ||
377 | pre_reset(tdrive); | ||
378 | |||
379 | if (io_ports->ctl_addr == 0) { | ||
380 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
381 | ide_complete_drive_reset(drive, -ENXIO); | ||
382 | return ide_stopped; | ||
383 | } | ||
384 | |||
385 | /* | ||
386 | * Note that we also set nIEN while resetting the device, | ||
387 | * to mask unwanted interrupts from the interface during the reset. | ||
388 | * However, due to the design of PC hardware, this will cause an | ||
389 | * immediate interrupt due to the edge transition it produces. | ||
390 | * This single interrupt gives us a "fast poll" for drives that | ||
391 | * recover from reset very quickly, saving us the first 50ms wait time. | ||
392 | * | ||
393 | * TODO: add ->softreset method and stop abusing ->set_irq | ||
394 | */ | ||
395 | /* set SRST and nIEN */ | ||
396 | tp_ops->set_irq(hwif, 4); | ||
397 | /* more than enough time */ | ||
398 | udelay(10); | ||
399 | /* clear SRST, leave nIEN (unless device is on the quirk list) */ | ||
400 | tp_ops->set_irq(hwif, drive->quirk_list == 2); | ||
401 | /* more than enough time */ | ||
402 | udelay(10); | ||
403 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; | ||
404 | hwif->polling = 1; | ||
405 | __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | ||
406 | |||
407 | /* | ||
408 | * Some weird controller like resetting themselves to a strange | ||
409 | * state when the disks are reset this way. At least, the Winbond | ||
410 | * 553 documentation says that | ||
411 | */ | ||
412 | port_ops = hwif->port_ops; | ||
413 | if (port_ops && port_ops->resetproc) | ||
414 | port_ops->resetproc(drive); | ||
415 | |||
416 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
417 | return ide_started; | ||
418 | } | ||
419 | |||
420 | /* | ||
421 | * ide_do_reset() is the entry point to the drive/interface reset code. | ||
422 | */ | ||
423 | |||
424 | ide_startstop_t ide_do_reset(ide_drive_t *drive) | ||
425 | { | ||
426 | return do_reset1(drive, 0); | ||
427 | } | ||
428 | EXPORT_SYMBOL(ide_do_reset); | ||
diff --git a/drivers/ide/ide-io-std.c b/drivers/ide/ide-io-std.c new file mode 100644 index 000000000000..45b43dd49cda --- /dev/null +++ b/drivers/ide/ide-io-std.c | |||
@@ -0,0 +1,316 @@ | |||
1 | |||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/ide.h> | ||
4 | |||
5 | /* | ||
6 | * Conventional PIO operations for ATA devices | ||
7 | */ | ||
8 | |||
9 | static u8 ide_inb(unsigned long port) | ||
10 | { | ||
11 | return (u8) inb(port); | ||
12 | } | ||
13 | |||
14 | static void ide_outb(u8 val, unsigned long port) | ||
15 | { | ||
16 | outb(val, port); | ||
17 | } | ||
18 | |||
19 | /* | ||
20 | * MMIO operations, typically used for SATA controllers | ||
21 | */ | ||
22 | |||
23 | static u8 ide_mm_inb(unsigned long port) | ||
24 | { | ||
25 | return (u8) readb((void __iomem *) port); | ||
26 | } | ||
27 | |||
28 | static void ide_mm_outb(u8 value, unsigned long port) | ||
29 | { | ||
30 | writeb(value, (void __iomem *) port); | ||
31 | } | ||
32 | |||
33 | void ide_exec_command(ide_hwif_t *hwif, u8 cmd) | ||
34 | { | ||
35 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
36 | writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); | ||
37 | else | ||
38 | outb(cmd, hwif->io_ports.command_addr); | ||
39 | } | ||
40 | EXPORT_SYMBOL_GPL(ide_exec_command); | ||
41 | |||
42 | u8 ide_read_status(ide_hwif_t *hwif) | ||
43 | { | ||
44 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
45 | return readb((void __iomem *)hwif->io_ports.status_addr); | ||
46 | else | ||
47 | return inb(hwif->io_ports.status_addr); | ||
48 | } | ||
49 | EXPORT_SYMBOL_GPL(ide_read_status); | ||
50 | |||
51 | u8 ide_read_altstatus(ide_hwif_t *hwif) | ||
52 | { | ||
53 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
54 | return readb((void __iomem *)hwif->io_ports.ctl_addr); | ||
55 | else | ||
56 | return inb(hwif->io_ports.ctl_addr); | ||
57 | } | ||
58 | EXPORT_SYMBOL_GPL(ide_read_altstatus); | ||
59 | |||
60 | void ide_set_irq(ide_hwif_t *hwif, int on) | ||
61 | { | ||
62 | u8 ctl = ATA_DEVCTL_OBS; | ||
63 | |||
64 | if (on == 4) { /* hack for SRST */ | ||
65 | ctl |= 4; | ||
66 | on &= ~4; | ||
67 | } | ||
68 | |||
69 | ctl |= on ? 0 : 2; | ||
70 | |||
71 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
72 | writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr); | ||
73 | else | ||
74 | outb(ctl, hwif->io_ports.ctl_addr); | ||
75 | } | ||
76 | EXPORT_SYMBOL_GPL(ide_set_irq); | ||
77 | |||
78 | void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | ||
79 | { | ||
80 | ide_hwif_t *hwif = drive->hwif; | ||
81 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
82 | struct ide_taskfile *tf = &task->tf; | ||
83 | void (*tf_outb)(u8 addr, unsigned long port); | ||
84 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
85 | u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; | ||
86 | |||
87 | if (mmio) | ||
88 | tf_outb = ide_mm_outb; | ||
89 | else | ||
90 | tf_outb = ide_outb; | ||
91 | |||
92 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | ||
93 | HIHI = 0xFF; | ||
94 | |||
95 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { | ||
96 | u16 data = (tf->hob_data << 8) | tf->data; | ||
97 | |||
98 | if (mmio) | ||
99 | writew(data, (void __iomem *)io_ports->data_addr); | ||
100 | else | ||
101 | outw(data, io_ports->data_addr); | ||
102 | } | ||
103 | |||
104 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) | ||
105 | tf_outb(tf->hob_feature, io_ports->feature_addr); | ||
106 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) | ||
107 | tf_outb(tf->hob_nsect, io_ports->nsect_addr); | ||
108 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) | ||
109 | tf_outb(tf->hob_lbal, io_ports->lbal_addr); | ||
110 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) | ||
111 | tf_outb(tf->hob_lbam, io_ports->lbam_addr); | ||
112 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) | ||
113 | tf_outb(tf->hob_lbah, io_ports->lbah_addr); | ||
114 | |||
115 | if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) | ||
116 | tf_outb(tf->feature, io_ports->feature_addr); | ||
117 | if (task->tf_flags & IDE_TFLAG_OUT_NSECT) | ||
118 | tf_outb(tf->nsect, io_ports->nsect_addr); | ||
119 | if (task->tf_flags & IDE_TFLAG_OUT_LBAL) | ||
120 | tf_outb(tf->lbal, io_ports->lbal_addr); | ||
121 | if (task->tf_flags & IDE_TFLAG_OUT_LBAM) | ||
122 | tf_outb(tf->lbam, io_ports->lbam_addr); | ||
123 | if (task->tf_flags & IDE_TFLAG_OUT_LBAH) | ||
124 | tf_outb(tf->lbah, io_ports->lbah_addr); | ||
125 | |||
126 | if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) | ||
127 | tf_outb((tf->device & HIHI) | drive->select, | ||
128 | io_ports->device_addr); | ||
129 | } | ||
130 | EXPORT_SYMBOL_GPL(ide_tf_load); | ||
131 | |||
132 | void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | ||
133 | { | ||
134 | ide_hwif_t *hwif = drive->hwif; | ||
135 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
136 | struct ide_taskfile *tf = &task->tf; | ||
137 | void (*tf_outb)(u8 addr, unsigned long port); | ||
138 | u8 (*tf_inb)(unsigned long port); | ||
139 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
140 | |||
141 | if (mmio) { | ||
142 | tf_outb = ide_mm_outb; | ||
143 | tf_inb = ide_mm_inb; | ||
144 | } else { | ||
145 | tf_outb = ide_outb; | ||
146 | tf_inb = ide_inb; | ||
147 | } | ||
148 | |||
149 | if (task->tf_flags & IDE_TFLAG_IN_DATA) { | ||
150 | u16 data; | ||
151 | |||
152 | if (mmio) | ||
153 | data = readw((void __iomem *)io_ports->data_addr); | ||
154 | else | ||
155 | data = inw(io_ports->data_addr); | ||
156 | |||
157 | tf->data = data & 0xff; | ||
158 | tf->hob_data = (data >> 8) & 0xff; | ||
159 | } | ||
160 | |||
161 | /* be sure we're looking at the low order bits */ | ||
162 | tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | ||
163 | |||
164 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
165 | tf->feature = tf_inb(io_ports->feature_addr); | ||
166 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | ||
167 | tf->nsect = tf_inb(io_ports->nsect_addr); | ||
168 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | ||
169 | tf->lbal = tf_inb(io_ports->lbal_addr); | ||
170 | if (task->tf_flags & IDE_TFLAG_IN_LBAM) | ||
171 | tf->lbam = tf_inb(io_ports->lbam_addr); | ||
172 | if (task->tf_flags & IDE_TFLAG_IN_LBAH) | ||
173 | tf->lbah = tf_inb(io_ports->lbah_addr); | ||
174 | if (task->tf_flags & IDE_TFLAG_IN_DEVICE) | ||
175 | tf->device = tf_inb(io_ports->device_addr); | ||
176 | |||
177 | if (task->tf_flags & IDE_TFLAG_LBA48) { | ||
178 | tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); | ||
179 | |||
180 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | ||
181 | tf->hob_feature = tf_inb(io_ports->feature_addr); | ||
182 | if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) | ||
183 | tf->hob_nsect = tf_inb(io_ports->nsect_addr); | ||
184 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) | ||
185 | tf->hob_lbal = tf_inb(io_ports->lbal_addr); | ||
186 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) | ||
187 | tf->hob_lbam = tf_inb(io_ports->lbam_addr); | ||
188 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) | ||
189 | tf->hob_lbah = tf_inb(io_ports->lbah_addr); | ||
190 | } | ||
191 | } | ||
192 | EXPORT_SYMBOL_GPL(ide_tf_read); | ||
193 | |||
194 | /* | ||
195 | * Some localbus EIDE interfaces require a special access sequence | ||
196 | * when using 32-bit I/O instructions to transfer data. We call this | ||
197 | * the "vlb_sync" sequence, which consists of three successive reads | ||
198 | * of the sector count register location, with interrupts disabled | ||
199 | * to ensure that the reads all happen together. | ||
200 | */ | ||
201 | static void ata_vlb_sync(unsigned long port) | ||
202 | { | ||
203 | (void)inb(port); | ||
204 | (void)inb(port); | ||
205 | (void)inb(port); | ||
206 | } | ||
207 | |||
208 | /* | ||
209 | * This is used for most PIO data transfers *from* the IDE interface | ||
210 | * | ||
211 | * These routines will round up any request for an odd number of bytes, | ||
212 | * so if an odd len is specified, be sure that there's at least one | ||
213 | * extra byte allocated for the buffer. | ||
214 | */ | ||
215 | void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf, | ||
216 | unsigned int len) | ||
217 | { | ||
218 | ide_hwif_t *hwif = drive->hwif; | ||
219 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
220 | unsigned long data_addr = io_ports->data_addr; | ||
221 | u8 io_32bit = drive->io_32bit; | ||
222 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
223 | |||
224 | len++; | ||
225 | |||
226 | if (io_32bit) { | ||
227 | unsigned long uninitialized_var(flags); | ||
228 | |||
229 | if ((io_32bit & 2) && !mmio) { | ||
230 | local_irq_save(flags); | ||
231 | ata_vlb_sync(io_ports->nsect_addr); | ||
232 | } | ||
233 | |||
234 | if (mmio) | ||
235 | __ide_mm_insl((void __iomem *)data_addr, buf, len / 4); | ||
236 | else | ||
237 | insl(data_addr, buf, len / 4); | ||
238 | |||
239 | if ((io_32bit & 2) && !mmio) | ||
240 | local_irq_restore(flags); | ||
241 | |||
242 | if ((len & 3) >= 2) { | ||
243 | if (mmio) | ||
244 | __ide_mm_insw((void __iomem *)data_addr, | ||
245 | (u8 *)buf + (len & ~3), 1); | ||
246 | else | ||
247 | insw(data_addr, (u8 *)buf + (len & ~3), 1); | ||
248 | } | ||
249 | } else { | ||
250 | if (mmio) | ||
251 | __ide_mm_insw((void __iomem *)data_addr, buf, len / 2); | ||
252 | else | ||
253 | insw(data_addr, buf, len / 2); | ||
254 | } | ||
255 | } | ||
256 | EXPORT_SYMBOL_GPL(ide_input_data); | ||
257 | |||
258 | /* | ||
259 | * This is used for most PIO data transfers *to* the IDE interface | ||
260 | */ | ||
261 | void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf, | ||
262 | unsigned int len) | ||
263 | { | ||
264 | ide_hwif_t *hwif = drive->hwif; | ||
265 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
266 | unsigned long data_addr = io_ports->data_addr; | ||
267 | u8 io_32bit = drive->io_32bit; | ||
268 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
269 | |||
270 | len++; | ||
271 | |||
272 | if (io_32bit) { | ||
273 | unsigned long uninitialized_var(flags); | ||
274 | |||
275 | if ((io_32bit & 2) && !mmio) { | ||
276 | local_irq_save(flags); | ||
277 | ata_vlb_sync(io_ports->nsect_addr); | ||
278 | } | ||
279 | |||
280 | if (mmio) | ||
281 | __ide_mm_outsl((void __iomem *)data_addr, buf, len / 4); | ||
282 | else | ||
283 | outsl(data_addr, buf, len / 4); | ||
284 | |||
285 | if ((io_32bit & 2) && !mmio) | ||
286 | local_irq_restore(flags); | ||
287 | |||
288 | if ((len & 3) >= 2) { | ||
289 | if (mmio) | ||
290 | __ide_mm_outsw((void __iomem *)data_addr, | ||
291 | (u8 *)buf + (len & ~3), 1); | ||
292 | else | ||
293 | outsw(data_addr, (u8 *)buf + (len & ~3), 1); | ||
294 | } | ||
295 | } else { | ||
296 | if (mmio) | ||
297 | __ide_mm_outsw((void __iomem *)data_addr, buf, len / 2); | ||
298 | else | ||
299 | outsw(data_addr, buf, len / 2); | ||
300 | } | ||
301 | } | ||
302 | EXPORT_SYMBOL_GPL(ide_output_data); | ||
303 | |||
304 | const struct ide_tp_ops default_tp_ops = { | ||
305 | .exec_command = ide_exec_command, | ||
306 | .read_status = ide_read_status, | ||
307 | .read_altstatus = ide_read_altstatus, | ||
308 | |||
309 | .set_irq = ide_set_irq, | ||
310 | |||
311 | .tf_load = ide_tf_load, | ||
312 | .tf_read = ide_tf_read, | ||
313 | |||
314 | .input_data = ide_input_data, | ||
315 | .output_data = ide_output_data, | ||
316 | }; | ||
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index a9a6c208288a..2e92497b58aa 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -196,7 +196,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | |||
196 | } | 196 | } |
197 | EXPORT_SYMBOL(ide_end_drive_cmd); | 197 | EXPORT_SYMBOL(ide_end_drive_cmd); |
198 | 198 | ||
199 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) | 199 | void ide_kill_rq(ide_drive_t *drive, struct request *rq) |
200 | { | 200 | { |
201 | if (rq->rq_disk) { | 201 | if (rq->rq_disk) { |
202 | struct ide_driver *drv; | 202 | struct ide_driver *drv; |
@@ -207,133 +207,6 @@ static void ide_kill_rq(ide_drive_t *drive, struct request *rq) | |||
207 | ide_end_request(drive, 0, 0); | 207 | ide_end_request(drive, 0, 0); |
208 | } | 208 | } |
209 | 209 | ||
210 | static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | ||
211 | { | ||
212 | ide_hwif_t *hwif = drive->hwif; | ||
213 | |||
214 | if ((stat & ATA_BUSY) || | ||
215 | ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) { | ||
216 | /* other bits are useless when BUSY */ | ||
217 | rq->errors |= ERROR_RESET; | ||
218 | } else if (stat & ATA_ERR) { | ||
219 | /* err has different meaning on cdrom and tape */ | ||
220 | if (err == ATA_ABORTED) { | ||
221 | if ((drive->dev_flags & IDE_DFLAG_LBA) && | ||
222 | /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ | ||
223 | hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS) | ||
224 | return ide_stopped; | ||
225 | } else if ((err & BAD_CRC) == BAD_CRC) { | ||
226 | /* UDMA crc error, just retry the operation */ | ||
227 | drive->crc_count++; | ||
228 | } else if (err & (ATA_BBK | ATA_UNC)) { | ||
229 | /* retries won't help these */ | ||
230 | rq->errors = ERROR_MAX; | ||
231 | } else if (err & ATA_TRK0NF) { | ||
232 | /* help it find track zero */ | ||
233 | rq->errors |= ERROR_RECAL; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ && | ||
238 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) { | ||
239 | int nsect = drive->mult_count ? drive->mult_count : 1; | ||
240 | |||
241 | ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE); | ||
242 | } | ||
243 | |||
244 | if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { | ||
245 | ide_kill_rq(drive, rq); | ||
246 | return ide_stopped; | ||
247 | } | ||
248 | |||
249 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) | ||
250 | rq->errors |= ERROR_RESET; | ||
251 | |||
252 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { | ||
253 | ++rq->errors; | ||
254 | return ide_do_reset(drive); | ||
255 | } | ||
256 | |||
257 | if ((rq->errors & ERROR_RECAL) == ERROR_RECAL) | ||
258 | drive->special.b.recalibrate = 1; | ||
259 | |||
260 | ++rq->errors; | ||
261 | |||
262 | return ide_stopped; | ||
263 | } | ||
264 | |||
265 | static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | ||
266 | { | ||
267 | ide_hwif_t *hwif = drive->hwif; | ||
268 | |||
269 | if ((stat & ATA_BUSY) || | ||
270 | ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) { | ||
271 | /* other bits are useless when BUSY */ | ||
272 | rq->errors |= ERROR_RESET; | ||
273 | } else { | ||
274 | /* add decoding error stuff */ | ||
275 | } | ||
276 | |||
277 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) | ||
278 | /* force an abort */ | ||
279 | hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE); | ||
280 | |||
281 | if (rq->errors >= ERROR_MAX) { | ||
282 | ide_kill_rq(drive, rq); | ||
283 | } else { | ||
284 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { | ||
285 | ++rq->errors; | ||
286 | return ide_do_reset(drive); | ||
287 | } | ||
288 | ++rq->errors; | ||
289 | } | ||
290 | |||
291 | return ide_stopped; | ||
292 | } | ||
293 | |||
294 | static ide_startstop_t | ||
295 | __ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | ||
296 | { | ||
297 | if (drive->media == ide_disk) | ||
298 | return ide_ata_error(drive, rq, stat, err); | ||
299 | return ide_atapi_error(drive, rq, stat, err); | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * ide_error - handle an error on the IDE | ||
304 | * @drive: drive the error occurred on | ||
305 | * @msg: message to report | ||
306 | * @stat: status bits | ||
307 | * | ||
308 | * ide_error() takes action based on the error returned by the drive. | ||
309 | * For normal I/O that may well include retries. We deal with | ||
310 | * both new-style (taskfile) and old style command handling here. | ||
311 | * In the case of taskfile command handling there is work left to | ||
312 | * do | ||
313 | */ | ||
314 | |||
315 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat) | ||
316 | { | ||
317 | struct request *rq; | ||
318 | u8 err; | ||
319 | |||
320 | err = ide_dump_status(drive, msg, stat); | ||
321 | |||
322 | rq = drive->hwif->rq; | ||
323 | if (rq == NULL) | ||
324 | return ide_stopped; | ||
325 | |||
326 | /* retry only "normal" I/O: */ | ||
327 | if (!blk_fs_request(rq)) { | ||
328 | rq->errors = 1; | ||
329 | ide_end_drive_cmd(drive, stat, err); | ||
330 | return ide_stopped; | ||
331 | } | ||
332 | |||
333 | return __ide_error(drive, rq, stat, err); | ||
334 | } | ||
335 | EXPORT_SYMBOL_GPL(ide_error); | ||
336 | |||
337 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | 210 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) |
338 | { | 211 | { |
339 | tf->nsect = drive->sect; | 212 | tf->nsect = drive->sect; |
@@ -490,71 +363,16 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, | |||
490 | return ide_stopped; | 363 | return ide_stopped; |
491 | } | 364 | } |
492 | 365 | ||
493 | int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, | ||
494 | int arg) | ||
495 | { | ||
496 | struct request_queue *q = drive->queue; | ||
497 | struct request *rq; | ||
498 | int ret = 0; | ||
499 | |||
500 | if (!(setting->flags & DS_SYNC)) | ||
501 | return setting->set(drive, arg); | ||
502 | |||
503 | rq = blk_get_request(q, READ, __GFP_WAIT); | ||
504 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
505 | rq->cmd_len = 5; | ||
506 | rq->cmd[0] = REQ_DEVSET_EXEC; | ||
507 | *(int *)&rq->cmd[1] = arg; | ||
508 | rq->special = setting->set; | ||
509 | |||
510 | if (blk_execute_rq(q, NULL, rq, 0)) | ||
511 | ret = rq->errors; | ||
512 | blk_put_request(rq); | ||
513 | |||
514 | return ret; | ||
515 | } | ||
516 | EXPORT_SYMBOL_GPL(ide_devset_execute); | ||
517 | |||
518 | static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) | 366 | static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) |
519 | { | 367 | { |
520 | u8 cmd = rq->cmd[0]; | 368 | u8 cmd = rq->cmd[0]; |
521 | 369 | ||
522 | if (cmd == REQ_PARK_HEADS || cmd == REQ_UNPARK_HEADS) { | ||
523 | ide_task_t task; | ||
524 | struct ide_taskfile *tf = &task.tf; | ||
525 | |||
526 | memset(&task, 0, sizeof(task)); | ||
527 | if (cmd == REQ_PARK_HEADS) { | ||
528 | drive->sleep = *(unsigned long *)rq->special; | ||
529 | drive->dev_flags |= IDE_DFLAG_SLEEPING; | ||
530 | tf->command = ATA_CMD_IDLEIMMEDIATE; | ||
531 | tf->feature = 0x44; | ||
532 | tf->lbal = 0x4c; | ||
533 | tf->lbam = 0x4e; | ||
534 | tf->lbah = 0x55; | ||
535 | task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER; | ||
536 | } else /* cmd == REQ_UNPARK_HEADS */ | ||
537 | tf->command = ATA_CMD_CHK_POWER; | ||
538 | |||
539 | task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
540 | task.rq = rq; | ||
541 | drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA; | ||
542 | return do_rw_taskfile(drive, &task); | ||
543 | } | ||
544 | |||
545 | switch (cmd) { | 370 | switch (cmd) { |
371 | case REQ_PARK_HEADS: | ||
372 | case REQ_UNPARK_HEADS: | ||
373 | return ide_do_park_unpark(drive, rq); | ||
546 | case REQ_DEVSET_EXEC: | 374 | case REQ_DEVSET_EXEC: |
547 | { | 375 | return ide_do_devset(drive, rq); |
548 | int err, (*setfunc)(ide_drive_t *, int) = rq->special; | ||
549 | |||
550 | err = setfunc(drive, *(int *)&rq->cmd[1]); | ||
551 | if (err) | ||
552 | rq->errors = err; | ||
553 | else | ||
554 | err = 1; | ||
555 | ide_end_request(drive, err, 0); | ||
556 | return ide_stopped; | ||
557 | } | ||
558 | case REQ_DRIVE_RESET: | 376 | case REQ_DRIVE_RESET: |
559 | return ide_do_reset(drive); | 377 | return ide_do_reset(drive); |
560 | default: | 378 | default: |
@@ -820,63 +638,6 @@ plug_device_2: | |||
820 | blk_plug_device(q); | 638 | blk_plug_device(q); |
821 | } | 639 | } |
822 | 640 | ||
823 | /* | ||
824 | * un-busy the port etc, and clear any pending DMA status. we want to | ||
825 | * retry the current request in pio mode instead of risking tossing it | ||
826 | * all away | ||
827 | */ | ||
828 | static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | ||
829 | { | ||
830 | ide_hwif_t *hwif = drive->hwif; | ||
831 | struct request *rq; | ||
832 | ide_startstop_t ret = ide_stopped; | ||
833 | |||
834 | /* | ||
835 | * end current dma transaction | ||
836 | */ | ||
837 | |||
838 | if (error < 0) { | ||
839 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); | ||
840 | (void)hwif->dma_ops->dma_end(drive); | ||
841 | ret = ide_error(drive, "dma timeout error", | ||
842 | hwif->tp_ops->read_status(hwif)); | ||
843 | } else { | ||
844 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); | ||
845 | hwif->dma_ops->dma_timeout(drive); | ||
846 | } | ||
847 | |||
848 | /* | ||
849 | * disable dma for now, but remember that we did so because of | ||
850 | * a timeout -- we'll reenable after we finish this next request | ||
851 | * (or rather the first chunk of it) in pio. | ||
852 | */ | ||
853 | drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY; | ||
854 | drive->retry_pio++; | ||
855 | ide_dma_off_quietly(drive); | ||
856 | |||
857 | /* | ||
858 | * un-busy drive etc and make sure request is sane | ||
859 | */ | ||
860 | |||
861 | rq = hwif->rq; | ||
862 | if (!rq) | ||
863 | goto out; | ||
864 | |||
865 | hwif->rq = NULL; | ||
866 | |||
867 | rq->errors = 0; | ||
868 | |||
869 | if (!rq->bio) | ||
870 | goto out; | ||
871 | |||
872 | rq->sector = rq->bio->bi_sector; | ||
873 | rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9; | ||
874 | rq->hard_cur_sectors = rq->current_nr_sectors; | ||
875 | rq->buffer = bio_data(rq->bio); | ||
876 | out: | ||
877 | return ret; | ||
878 | } | ||
879 | |||
880 | static void ide_plug_device(ide_drive_t *drive) | 641 | static void ide_plug_device(ide_drive_t *drive) |
881 | { | 642 | { |
882 | struct request_queue *q = drive->queue; | 643 | struct request_queue *q = drive->queue; |
@@ -888,6 +649,29 @@ static void ide_plug_device(ide_drive_t *drive) | |||
888 | spin_unlock_irqrestore(q->queue_lock, flags); | 649 | spin_unlock_irqrestore(q->queue_lock, flags); |
889 | } | 650 | } |
890 | 651 | ||
652 | static int drive_is_ready(ide_drive_t *drive) | ||
653 | { | ||
654 | ide_hwif_t *hwif = drive->hwif; | ||
655 | u8 stat = 0; | ||
656 | |||
657 | if (drive->waiting_for_dma) | ||
658 | return hwif->dma_ops->dma_test_irq(drive); | ||
659 | |||
660 | if (hwif->io_ports.ctl_addr && | ||
661 | (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) | ||
662 | stat = hwif->tp_ops->read_altstatus(hwif); | ||
663 | else | ||
664 | /* Note: this may clear a pending IRQ!! */ | ||
665 | stat = hwif->tp_ops->read_status(hwif); | ||
666 | |||
667 | if (stat & ATA_BUSY) | ||
668 | /* drive busy: definitely not interrupting */ | ||
669 | return 0; | ||
670 | |||
671 | /* drive ready: *might* be interrupting */ | ||
672 | return 1; | ||
673 | } | ||
674 | |||
891 | /** | 675 | /** |
892 | * ide_timer_expiry - handle lack of an IDE interrupt | 676 | * ide_timer_expiry - handle lack of an IDE interrupt |
893 | * @data: timer callback magic (hwif) | 677 | * @data: timer callback magic (hwif) |
@@ -1164,54 +948,6 @@ out_early: | |||
1164 | } | 948 | } |
1165 | EXPORT_SYMBOL_GPL(ide_intr); | 949 | EXPORT_SYMBOL_GPL(ide_intr); |
1166 | 950 | ||
1167 | /** | ||
1168 | * ide_do_drive_cmd - issue IDE special command | ||
1169 | * @drive: device to issue command | ||
1170 | * @rq: request to issue | ||
1171 | * | ||
1172 | * This function issues a special IDE device request | ||
1173 | * onto the request queue. | ||
1174 | * | ||
1175 | * the rq is queued at the head of the request queue, displacing | ||
1176 | * the currently-being-processed request and this function | ||
1177 | * returns immediately without waiting for the new rq to be | ||
1178 | * completed. This is VERY DANGEROUS, and is intended for | ||
1179 | * careful use by the ATAPI tape/cdrom driver code. | ||
1180 | */ | ||
1181 | |||
1182 | void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq) | ||
1183 | { | ||
1184 | struct request_queue *q = drive->queue; | ||
1185 | unsigned long flags; | ||
1186 | |||
1187 | drive->hwif->rq = NULL; | ||
1188 | |||
1189 | spin_lock_irqsave(q->queue_lock, flags); | ||
1190 | __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); | ||
1191 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
1192 | } | ||
1193 | EXPORT_SYMBOL(ide_do_drive_cmd); | ||
1194 | |||
1195 | void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) | ||
1196 | { | ||
1197 | ide_hwif_t *hwif = drive->hwif; | ||
1198 | ide_task_t task; | ||
1199 | |||
1200 | memset(&task, 0, sizeof(task)); | ||
1201 | task.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM | | ||
1202 | IDE_TFLAG_OUT_FEATURE | tf_flags; | ||
1203 | task.tf.feature = dma; /* Use PIO/DMA */ | ||
1204 | task.tf.lbam = bcount & 0xff; | ||
1205 | task.tf.lbah = (bcount >> 8) & 0xff; | ||
1206 | |||
1207 | ide_tf_dump(drive->name, &task.tf); | ||
1208 | hwif->tp_ops->set_irq(hwif, 1); | ||
1209 | SELECT_MASK(drive, 0); | ||
1210 | hwif->tp_ops->tf_load(drive, &task); | ||
1211 | } | ||
1212 | |||
1213 | EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load); | ||
1214 | |||
1215 | void ide_pad_transfer(ide_drive_t *drive, int write, int len) | 951 | void ide_pad_transfer(ide_drive_t *drive, int write, int len) |
1216 | { | 952 | { |
1217 | ide_hwif_t *hwif = drive->hwif; | 953 | ide_hwif_t *hwif = drive->hwif; |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index b1892bd95c6f..317c5dadd7c0 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -27,35 +27,7 @@ | |||
27 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | 29 | ||
30 | /* | 30 | void SELECT_DRIVE(ide_drive_t *drive) |
31 | * Conventional PIO operations for ATA devices | ||
32 | */ | ||
33 | |||
34 | static u8 ide_inb (unsigned long port) | ||
35 | { | ||
36 | return (u8) inb(port); | ||
37 | } | ||
38 | |||
39 | static void ide_outb (u8 val, unsigned long port) | ||
40 | { | ||
41 | outb(val, port); | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * MMIO operations, typically used for SATA controllers | ||
46 | */ | ||
47 | |||
48 | static u8 ide_mm_inb (unsigned long port) | ||
49 | { | ||
50 | return (u8) readb((void __iomem *) port); | ||
51 | } | ||
52 | |||
53 | static void ide_mm_outb (u8 value, unsigned long port) | ||
54 | { | ||
55 | writeb(value, (void __iomem *) port); | ||
56 | } | ||
57 | |||
58 | void SELECT_DRIVE (ide_drive_t *drive) | ||
59 | { | 31 | { |
60 | ide_hwif_t *hwif = drive->hwif; | 32 | ide_hwif_t *hwif = drive->hwif; |
61 | const struct ide_port_ops *port_ops = hwif->port_ops; | 33 | const struct ide_port_ops *port_ops = hwif->port_ops; |
@@ -78,277 +50,6 @@ void SELECT_MASK(ide_drive_t *drive, int mask) | |||
78 | port_ops->maskproc(drive, mask); | 50 | port_ops->maskproc(drive, mask); |
79 | } | 51 | } |
80 | 52 | ||
81 | void ide_exec_command(ide_hwif_t *hwif, u8 cmd) | ||
82 | { | ||
83 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
84 | writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); | ||
85 | else | ||
86 | outb(cmd, hwif->io_ports.command_addr); | ||
87 | } | ||
88 | EXPORT_SYMBOL_GPL(ide_exec_command); | ||
89 | |||
90 | u8 ide_read_status(ide_hwif_t *hwif) | ||
91 | { | ||
92 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
93 | return readb((void __iomem *)hwif->io_ports.status_addr); | ||
94 | else | ||
95 | return inb(hwif->io_ports.status_addr); | ||
96 | } | ||
97 | EXPORT_SYMBOL_GPL(ide_read_status); | ||
98 | |||
99 | u8 ide_read_altstatus(ide_hwif_t *hwif) | ||
100 | { | ||
101 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
102 | return readb((void __iomem *)hwif->io_ports.ctl_addr); | ||
103 | else | ||
104 | return inb(hwif->io_ports.ctl_addr); | ||
105 | } | ||
106 | EXPORT_SYMBOL_GPL(ide_read_altstatus); | ||
107 | |||
108 | void ide_set_irq(ide_hwif_t *hwif, int on) | ||
109 | { | ||
110 | u8 ctl = ATA_DEVCTL_OBS; | ||
111 | |||
112 | if (on == 4) { /* hack for SRST */ | ||
113 | ctl |= 4; | ||
114 | on &= ~4; | ||
115 | } | ||
116 | |||
117 | ctl |= on ? 0 : 2; | ||
118 | |||
119 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
120 | writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr); | ||
121 | else | ||
122 | outb(ctl, hwif->io_ports.ctl_addr); | ||
123 | } | ||
124 | EXPORT_SYMBOL_GPL(ide_set_irq); | ||
125 | |||
126 | void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | ||
127 | { | ||
128 | ide_hwif_t *hwif = drive->hwif; | ||
129 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
130 | struct ide_taskfile *tf = &task->tf; | ||
131 | void (*tf_outb)(u8 addr, unsigned long port); | ||
132 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
133 | u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; | ||
134 | |||
135 | if (mmio) | ||
136 | tf_outb = ide_mm_outb; | ||
137 | else | ||
138 | tf_outb = ide_outb; | ||
139 | |||
140 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | ||
141 | HIHI = 0xFF; | ||
142 | |||
143 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { | ||
144 | u16 data = (tf->hob_data << 8) | tf->data; | ||
145 | |||
146 | if (mmio) | ||
147 | writew(data, (void __iomem *)io_ports->data_addr); | ||
148 | else | ||
149 | outw(data, io_ports->data_addr); | ||
150 | } | ||
151 | |||
152 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) | ||
153 | tf_outb(tf->hob_feature, io_ports->feature_addr); | ||
154 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) | ||
155 | tf_outb(tf->hob_nsect, io_ports->nsect_addr); | ||
156 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) | ||
157 | tf_outb(tf->hob_lbal, io_ports->lbal_addr); | ||
158 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) | ||
159 | tf_outb(tf->hob_lbam, io_ports->lbam_addr); | ||
160 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) | ||
161 | tf_outb(tf->hob_lbah, io_ports->lbah_addr); | ||
162 | |||
163 | if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) | ||
164 | tf_outb(tf->feature, io_ports->feature_addr); | ||
165 | if (task->tf_flags & IDE_TFLAG_OUT_NSECT) | ||
166 | tf_outb(tf->nsect, io_ports->nsect_addr); | ||
167 | if (task->tf_flags & IDE_TFLAG_OUT_LBAL) | ||
168 | tf_outb(tf->lbal, io_ports->lbal_addr); | ||
169 | if (task->tf_flags & IDE_TFLAG_OUT_LBAM) | ||
170 | tf_outb(tf->lbam, io_ports->lbam_addr); | ||
171 | if (task->tf_flags & IDE_TFLAG_OUT_LBAH) | ||
172 | tf_outb(tf->lbah, io_ports->lbah_addr); | ||
173 | |||
174 | if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) | ||
175 | tf_outb((tf->device & HIHI) | drive->select, | ||
176 | io_ports->device_addr); | ||
177 | } | ||
178 | EXPORT_SYMBOL_GPL(ide_tf_load); | ||
179 | |||
180 | void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | ||
181 | { | ||
182 | ide_hwif_t *hwif = drive->hwif; | ||
183 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
184 | struct ide_taskfile *tf = &task->tf; | ||
185 | void (*tf_outb)(u8 addr, unsigned long port); | ||
186 | u8 (*tf_inb)(unsigned long port); | ||
187 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
188 | |||
189 | if (mmio) { | ||
190 | tf_outb = ide_mm_outb; | ||
191 | tf_inb = ide_mm_inb; | ||
192 | } else { | ||
193 | tf_outb = ide_outb; | ||
194 | tf_inb = ide_inb; | ||
195 | } | ||
196 | |||
197 | if (task->tf_flags & IDE_TFLAG_IN_DATA) { | ||
198 | u16 data; | ||
199 | |||
200 | if (mmio) | ||
201 | data = readw((void __iomem *)io_ports->data_addr); | ||
202 | else | ||
203 | data = inw(io_ports->data_addr); | ||
204 | |||
205 | tf->data = data & 0xff; | ||
206 | tf->hob_data = (data >> 8) & 0xff; | ||
207 | } | ||
208 | |||
209 | /* be sure we're looking at the low order bits */ | ||
210 | tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | ||
211 | |||
212 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
213 | tf->feature = tf_inb(io_ports->feature_addr); | ||
214 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | ||
215 | tf->nsect = tf_inb(io_ports->nsect_addr); | ||
216 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | ||
217 | tf->lbal = tf_inb(io_ports->lbal_addr); | ||
218 | if (task->tf_flags & IDE_TFLAG_IN_LBAM) | ||
219 | tf->lbam = tf_inb(io_ports->lbam_addr); | ||
220 | if (task->tf_flags & IDE_TFLAG_IN_LBAH) | ||
221 | tf->lbah = tf_inb(io_ports->lbah_addr); | ||
222 | if (task->tf_flags & IDE_TFLAG_IN_DEVICE) | ||
223 | tf->device = tf_inb(io_ports->device_addr); | ||
224 | |||
225 | if (task->tf_flags & IDE_TFLAG_LBA48) { | ||
226 | tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); | ||
227 | |||
228 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | ||
229 | tf->hob_feature = tf_inb(io_ports->feature_addr); | ||
230 | if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) | ||
231 | tf->hob_nsect = tf_inb(io_ports->nsect_addr); | ||
232 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) | ||
233 | tf->hob_lbal = tf_inb(io_ports->lbal_addr); | ||
234 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) | ||
235 | tf->hob_lbam = tf_inb(io_ports->lbam_addr); | ||
236 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) | ||
237 | tf->hob_lbah = tf_inb(io_ports->lbah_addr); | ||
238 | } | ||
239 | } | ||
240 | EXPORT_SYMBOL_GPL(ide_tf_read); | ||
241 | |||
242 | /* | ||
243 | * Some localbus EIDE interfaces require a special access sequence | ||
244 | * when using 32-bit I/O instructions to transfer data. We call this | ||
245 | * the "vlb_sync" sequence, which consists of three successive reads | ||
246 | * of the sector count register location, with interrupts disabled | ||
247 | * to ensure that the reads all happen together. | ||
248 | */ | ||
249 | static void ata_vlb_sync(unsigned long port) | ||
250 | { | ||
251 | (void)inb(port); | ||
252 | (void)inb(port); | ||
253 | (void)inb(port); | ||
254 | } | ||
255 | |||
256 | /* | ||
257 | * This is used for most PIO data transfers *from* the IDE interface | ||
258 | * | ||
259 | * These routines will round up any request for an odd number of bytes, | ||
260 | * so if an odd len is specified, be sure that there's at least one | ||
261 | * extra byte allocated for the buffer. | ||
262 | */ | ||
263 | void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf, | ||
264 | unsigned int len) | ||
265 | { | ||
266 | ide_hwif_t *hwif = drive->hwif; | ||
267 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
268 | unsigned long data_addr = io_ports->data_addr; | ||
269 | u8 io_32bit = drive->io_32bit; | ||
270 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
271 | |||
272 | len++; | ||
273 | |||
274 | if (io_32bit) { | ||
275 | unsigned long uninitialized_var(flags); | ||
276 | |||
277 | if ((io_32bit & 2) && !mmio) { | ||
278 | local_irq_save(flags); | ||
279 | ata_vlb_sync(io_ports->nsect_addr); | ||
280 | } | ||
281 | |||
282 | if (mmio) | ||
283 | __ide_mm_insl((void __iomem *)data_addr, buf, len / 4); | ||
284 | else | ||
285 | insl(data_addr, buf, len / 4); | ||
286 | |||
287 | if ((io_32bit & 2) && !mmio) | ||
288 | local_irq_restore(flags); | ||
289 | |||
290 | if ((len & 3) >= 2) { | ||
291 | if (mmio) | ||
292 | __ide_mm_insw((void __iomem *)data_addr, | ||
293 | (u8 *)buf + (len & ~3), 1); | ||
294 | else | ||
295 | insw(data_addr, (u8 *)buf + (len & ~3), 1); | ||
296 | } | ||
297 | } else { | ||
298 | if (mmio) | ||
299 | __ide_mm_insw((void __iomem *)data_addr, buf, len / 2); | ||
300 | else | ||
301 | insw(data_addr, buf, len / 2); | ||
302 | } | ||
303 | } | ||
304 | EXPORT_SYMBOL_GPL(ide_input_data); | ||
305 | |||
306 | /* | ||
307 | * This is used for most PIO data transfers *to* the IDE interface | ||
308 | */ | ||
309 | void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf, | ||
310 | unsigned int len) | ||
311 | { | ||
312 | ide_hwif_t *hwif = drive->hwif; | ||
313 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
314 | unsigned long data_addr = io_ports->data_addr; | ||
315 | u8 io_32bit = drive->io_32bit; | ||
316 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
317 | |||
318 | len++; | ||
319 | |||
320 | if (io_32bit) { | ||
321 | unsigned long uninitialized_var(flags); | ||
322 | |||
323 | if ((io_32bit & 2) && !mmio) { | ||
324 | local_irq_save(flags); | ||
325 | ata_vlb_sync(io_ports->nsect_addr); | ||
326 | } | ||
327 | |||
328 | if (mmio) | ||
329 | __ide_mm_outsl((void __iomem *)data_addr, buf, len / 4); | ||
330 | else | ||
331 | outsl(data_addr, buf, len / 4); | ||
332 | |||
333 | if ((io_32bit & 2) && !mmio) | ||
334 | local_irq_restore(flags); | ||
335 | |||
336 | if ((len & 3) >= 2) { | ||
337 | if (mmio) | ||
338 | __ide_mm_outsw((void __iomem *)data_addr, | ||
339 | (u8 *)buf + (len & ~3), 1); | ||
340 | else | ||
341 | outsw(data_addr, (u8 *)buf + (len & ~3), 1); | ||
342 | } | ||
343 | } else { | ||
344 | if (mmio) | ||
345 | __ide_mm_outsw((void __iomem *)data_addr, buf, len / 2); | ||
346 | else | ||
347 | outsw(data_addr, buf, len / 2); | ||
348 | } | ||
349 | } | ||
350 | EXPORT_SYMBOL_GPL(ide_output_data); | ||
351 | |||
352 | u8 ide_read_error(ide_drive_t *drive) | 53 | u8 ide_read_error(ide_drive_t *drive) |
353 | { | 54 | { |
354 | ide_task_t task; | 55 | ide_task_t task; |
@@ -362,35 +63,6 @@ u8 ide_read_error(ide_drive_t *drive) | |||
362 | } | 63 | } |
363 | EXPORT_SYMBOL_GPL(ide_read_error); | 64 | EXPORT_SYMBOL_GPL(ide_read_error); |
364 | 65 | ||
365 | void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason) | ||
366 | { | ||
367 | ide_task_t task; | ||
368 | |||
369 | memset(&task, 0, sizeof(task)); | ||
370 | task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM | | ||
371 | IDE_TFLAG_IN_NSECT; | ||
372 | |||
373 | drive->hwif->tp_ops->tf_read(drive, &task); | ||
374 | |||
375 | *bcount = (task.tf.lbah << 8) | task.tf.lbam; | ||
376 | *ireason = task.tf.nsect & 3; | ||
377 | } | ||
378 | EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); | ||
379 | |||
380 | const struct ide_tp_ops default_tp_ops = { | ||
381 | .exec_command = ide_exec_command, | ||
382 | .read_status = ide_read_status, | ||
383 | .read_altstatus = ide_read_altstatus, | ||
384 | |||
385 | .set_irq = ide_set_irq, | ||
386 | |||
387 | .tf_load = ide_tf_load, | ||
388 | .tf_read = ide_tf_read, | ||
389 | |||
390 | .input_data = ide_input_data, | ||
391 | .output_data = ide_output_data, | ||
392 | }; | ||
393 | |||
394 | void ide_fix_driveid(u16 *id) | 66 | void ide_fix_driveid(u16 *id) |
395 | { | 67 | { |
396 | #ifndef __LITTLE_ENDIAN | 68 | #ifndef __LITTLE_ENDIAN |
@@ -412,7 +84,7 @@ void ide_fix_driveid(u16 *id) | |||
412 | * returned by the ATA_CMD_ID_ATA[PI] commands. | 84 | * returned by the ATA_CMD_ID_ATA[PI] commands. |
413 | */ | 85 | */ |
414 | 86 | ||
415 | void ide_fixstring (u8 *s, const int bytecount, const int byteswap) | 87 | void ide_fixstring(u8 *s, const int bytecount, const int byteswap) |
416 | { | 88 | { |
417 | u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */ | 89 | u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */ |
418 | 90 | ||
@@ -435,44 +107,9 @@ void ide_fixstring (u8 *s, const int bytecount, const int byteswap) | |||
435 | while (p != end) | 107 | while (p != end) |
436 | *p++ = '\0'; | 108 | *p++ = '\0'; |
437 | } | 109 | } |
438 | |||
439 | EXPORT_SYMBOL(ide_fixstring); | 110 | EXPORT_SYMBOL(ide_fixstring); |
440 | 111 | ||
441 | /* | 112 | /* |
442 | * Needed for PCI irq sharing | ||
443 | */ | ||
444 | int drive_is_ready (ide_drive_t *drive) | ||
445 | { | ||
446 | ide_hwif_t *hwif = drive->hwif; | ||
447 | u8 stat = 0; | ||
448 | |||
449 | if (drive->waiting_for_dma) | ||
450 | return hwif->dma_ops->dma_test_irq(drive); | ||
451 | |||
452 | /* | ||
453 | * We do a passive status test under shared PCI interrupts on | ||
454 | * cards that truly share the ATA side interrupt, but may also share | ||
455 | * an interrupt with another pci card/device. We make no assumptions | ||
456 | * about possible isa-pnp and pci-pnp issues yet. | ||
457 | */ | ||
458 | if (hwif->io_ports.ctl_addr && | ||
459 | (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) | ||
460 | stat = hwif->tp_ops->read_altstatus(hwif); | ||
461 | else | ||
462 | /* Note: this may clear a pending IRQ!! */ | ||
463 | stat = hwif->tp_ops->read_status(hwif); | ||
464 | |||
465 | if (stat & ATA_BUSY) | ||
466 | /* drive busy: definitely not interrupting */ | ||
467 | return 0; | ||
468 | |||
469 | /* drive ready: *might* be interrupting */ | ||
470 | return 1; | ||
471 | } | ||
472 | |||
473 | EXPORT_SYMBOL(drive_is_ready); | ||
474 | |||
475 | /* | ||
476 | * This routine busy-waits for the drive status to be not "busy". | 113 | * This routine busy-waits for the drive status to be not "busy". |
477 | * It then checks the status for all of the "good" bits and none | 114 | * It then checks the status for all of the "good" bits and none |
478 | * of the "bad" bits, and if all is okay it returns 0. All other | 115 | * of the "bad" bits, and if all is okay it returns 0. All other |
@@ -483,7 +120,8 @@ EXPORT_SYMBOL(drive_is_ready); | |||
483 | * setting a timer to wake up at half second intervals thereafter, | 120 | * setting a timer to wake up at half second intervals thereafter, |
484 | * until timeout is achieved, before timing out. | 121 | * until timeout is achieved, before timing out. |
485 | */ | 122 | */ |
486 | static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) | 123 | static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, |
124 | unsigned long timeout, u8 *rstat) | ||
487 | { | 125 | { |
488 | ide_hwif_t *hwif = drive->hwif; | 126 | ide_hwif_t *hwif = drive->hwif; |
489 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 127 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
@@ -541,7 +179,8 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti | |||
541 | * The caller should return the updated value of "startstop" in this case, | 179 | * The caller should return the updated value of "startstop" in this case, |
542 | * "startstop" is unchanged when the function returns 0. | 180 | * "startstop" is unchanged when the function returns 0. |
543 | */ | 181 | */ |
544 | int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout) | 182 | int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, |
183 | u8 bad, unsigned long timeout) | ||
545 | { | 184 | { |
546 | int err; | 185 | int err; |
547 | u8 stat; | 186 | u8 stat; |
@@ -561,7 +200,6 @@ int ide_wait_stat(ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 ba | |||
561 | 200 | ||
562 | return err; | 201 | return err; |
563 | } | 202 | } |
564 | |||
565 | EXPORT_SYMBOL(ide_wait_stat); | 203 | EXPORT_SYMBOL(ide_wait_stat); |
566 | 204 | ||
567 | /** | 205 | /** |
@@ -582,7 +220,6 @@ int ide_in_drive_list(u16 *id, const struct drive_list_entry *table) | |||
582 | return 1; | 220 | return 1; |
583 | return 0; | 221 | return 0; |
584 | } | 222 | } |
585 | |||
586 | EXPORT_SYMBOL_GPL(ide_in_drive_list); | 223 | EXPORT_SYMBOL_GPL(ide_in_drive_list); |
587 | 224 | ||
588 | /* | 225 | /* |
@@ -607,7 +244,7 @@ static const struct drive_list_entry ivb_list[] = { | |||
607 | * All hosts that use the 80c ribbon must use! | 244 | * All hosts that use the 80c ribbon must use! |
608 | * The name is derived from upper byte of word 93 and the 80c ribbon. | 245 | * The name is derived from upper byte of word 93 and the 80c ribbon. |
609 | */ | 246 | */ |
610 | u8 eighty_ninty_three (ide_drive_t *drive) | 247 | u8 eighty_ninty_three(ide_drive_t *drive) |
611 | { | 248 | { |
612 | ide_hwif_t *hwif = drive->hwif; | 249 | ide_hwif_t *hwif = drive->hwif; |
613 | u16 *id = drive->id; | 250 | u16 *id = drive->id; |
@@ -652,47 +289,19 @@ no_80w: | |||
652 | 289 | ||
653 | int ide_driveid_update(ide_drive_t *drive) | 290 | int ide_driveid_update(ide_drive_t *drive) |
654 | { | 291 | { |
655 | ide_hwif_t *hwif = drive->hwif; | ||
656 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
657 | u16 *id; | 292 | u16 *id; |
658 | unsigned long flags; | 293 | int rc; |
659 | u8 stat; | ||
660 | |||
661 | /* | ||
662 | * Re-read drive->id for possible DMA mode | ||
663 | * change (copied from ide-probe.c) | ||
664 | */ | ||
665 | |||
666 | SELECT_MASK(drive, 1); | ||
667 | tp_ops->set_irq(hwif, 0); | ||
668 | msleep(50); | ||
669 | tp_ops->exec_command(hwif, ATA_CMD_ID_ATA); | ||
670 | 294 | ||
671 | if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) { | 295 | id = kmalloc(SECTOR_SIZE, GFP_ATOMIC); |
672 | SELECT_MASK(drive, 0); | 296 | if (id == NULL) |
673 | return 0; | 297 | return 0; |
674 | } | ||
675 | |||
676 | msleep(50); /* wait for IRQ and ATA_DRQ */ | ||
677 | stat = tp_ops->read_status(hwif); | ||
678 | 298 | ||
679 | if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) { | 299 | SELECT_MASK(drive, 1); |
680 | SELECT_MASK(drive, 0); | 300 | rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id); |
681 | printk("%s: CHECK for good STATUS\n", drive->name); | ||
682 | return 0; | ||
683 | } | ||
684 | local_irq_save(flags); | ||
685 | SELECT_MASK(drive, 0); | 301 | SELECT_MASK(drive, 0); |
686 | id = kmalloc(SECTOR_SIZE, GFP_ATOMIC); | 302 | |
687 | if (!id) { | 303 | if (rc) |
688 | local_irq_restore(flags); | 304 | goto out_err; |
689 | return 0; | ||
690 | } | ||
691 | tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); | ||
692 | (void)tp_ops->read_status(hwif); /* clear drive IRQ */ | ||
693 | local_irq_enable(); | ||
694 | local_irq_restore(flags); | ||
695 | ide_fix_driveid(id); | ||
696 | 305 | ||
697 | drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; | 306 | drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; |
698 | drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; | 307 | drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; |
@@ -705,6 +314,12 @@ int ide_driveid_update(ide_drive_t *drive) | |||
705 | ide_dma_off(drive); | 314 | ide_dma_off(drive); |
706 | 315 | ||
707 | return 1; | 316 | return 1; |
317 | out_err: | ||
318 | SELECT_MASK(drive, 0); | ||
319 | if (rc == 2) | ||
320 | printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__); | ||
321 | kfree(id); | ||
322 | return 0; | ||
708 | } | 323 | } |
709 | 324 | ||
710 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | 325 | int ide_config_drive_speed(ide_drive_t *drive, u8 speed) |
@@ -731,18 +346,15 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
731 | * but for some reason these don't work at | 346 | * but for some reason these don't work at |
732 | * this point (lost interrupt). | 347 | * this point (lost interrupt). |
733 | */ | 348 | */ |
734 | /* | 349 | |
735 | * Select the drive, and issue the SETFEATURES command | ||
736 | */ | ||
737 | disable_irq_nosync(hwif->irq); | ||
738 | |||
739 | /* | 350 | /* |
740 | * FIXME: we race against the running IRQ here if | 351 | * FIXME: we race against the running IRQ here if |
741 | * this is called from non IRQ context. If we use | 352 | * this is called from non IRQ context. If we use |
742 | * disable_irq() we hang on the error path. Work | 353 | * disable_irq() we hang on the error path. Work |
743 | * is needed. | 354 | * is needed. |
744 | */ | 355 | */ |
745 | 356 | disable_irq_nosync(hwif->irq); | |
357 | |||
746 | udelay(1); | 358 | udelay(1); |
747 | SELECT_DRIVE(drive); | 359 | SELECT_DRIVE(drive); |
748 | SELECT_MASK(drive, 1); | 360 | SELECT_MASK(drive, 1); |
@@ -812,8 +424,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
812 | * | 424 | * |
813 | * See also ide_execute_command | 425 | * See also ide_execute_command |
814 | */ | 426 | */ |
815 | static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, | 427 | void __ide_set_handler(ide_drive_t *drive, ide_handler_t *handler, |
816 | unsigned int timeout, ide_expiry_t *expiry) | 428 | unsigned int timeout, ide_expiry_t *expiry) |
817 | { | 429 | { |
818 | ide_hwif_t *hwif = drive->hwif; | 430 | ide_hwif_t *hwif = drive->hwif; |
819 | 431 | ||
@@ -835,9 +447,8 @@ void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, | |||
835 | __ide_set_handler(drive, handler, timeout, expiry); | 447 | __ide_set_handler(drive, handler, timeout, expiry); |
836 | spin_unlock_irqrestore(&hwif->lock, flags); | 448 | spin_unlock_irqrestore(&hwif->lock, flags); |
837 | } | 449 | } |
838 | |||
839 | EXPORT_SYMBOL(ide_set_handler); | 450 | EXPORT_SYMBOL(ide_set_handler); |
840 | 451 | ||
841 | /** | 452 | /** |
842 | * ide_execute_command - execute an IDE command | 453 | * ide_execute_command - execute an IDE command |
843 | * @drive: IDE drive to issue the command against | 454 | * @drive: IDE drive to issue the command against |
@@ -847,7 +458,7 @@ EXPORT_SYMBOL(ide_set_handler); | |||
847 | * @expiry: handler to run on timeout | 458 | * @expiry: handler to run on timeout |
848 | * | 459 | * |
849 | * Helper function to issue an IDE command. This handles the | 460 | * Helper function to issue an IDE command. This handles the |
850 | * atomicity requirements, command timing and ensures that the | 461 | * atomicity requirements, command timing and ensures that the |
851 | * handler and IRQ setup do not race. All IDE command kick off | 462 | * handler and IRQ setup do not race. All IDE command kick off |
852 | * should go via this function or do equivalent locking. | 463 | * should go via this function or do equivalent locking. |
853 | */ | 464 | */ |
@@ -884,301 +495,6 @@ void ide_execute_pkt_cmd(ide_drive_t *drive) | |||
884 | } | 495 | } |
885 | EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); | 496 | EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); |
886 | 497 | ||
887 | static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) | ||
888 | { | ||
889 | struct request *rq = drive->hwif->rq; | ||
890 | |||
891 | if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) | ||
892 | ide_end_request(drive, err ? err : 1, 0); | ||
893 | } | ||
894 | |||
895 | /* needed below */ | ||
896 | static ide_startstop_t do_reset1 (ide_drive_t *, int); | ||
897 | |||
898 | /* | ||
899 | * atapi_reset_pollfunc() gets invoked to poll the interface for completion every 50ms | ||
900 | * during an atapi drive reset operation. If the drive has not yet responded, | ||
901 | * and we have not yet hit our maximum waiting time, then the timer is restarted | ||
902 | * for another 50ms. | ||
903 | */ | ||
904 | static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | ||
905 | { | ||
906 | ide_hwif_t *hwif = drive->hwif; | ||
907 | u8 stat; | ||
908 | |||
909 | SELECT_DRIVE(drive); | ||
910 | udelay (10); | ||
911 | stat = hwif->tp_ops->read_status(hwif); | ||
912 | |||
913 | if (OK_STAT(stat, 0, ATA_BUSY)) | ||
914 | printk("%s: ATAPI reset complete\n", drive->name); | ||
915 | else { | ||
916 | if (time_before(jiffies, hwif->poll_timeout)) { | ||
917 | ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); | ||
918 | /* continue polling */ | ||
919 | return ide_started; | ||
920 | } | ||
921 | /* end of polling */ | ||
922 | hwif->polling = 0; | ||
923 | printk("%s: ATAPI reset timed-out, status=0x%02x\n", | ||
924 | drive->name, stat); | ||
925 | /* do it the old fashioned way */ | ||
926 | return do_reset1(drive, 1); | ||
927 | } | ||
928 | /* done polling */ | ||
929 | hwif->polling = 0; | ||
930 | ide_complete_drive_reset(drive, 0); | ||
931 | return ide_stopped; | ||
932 | } | ||
933 | |||
934 | static void ide_reset_report_error(ide_hwif_t *hwif, u8 err) | ||
935 | { | ||
936 | static const char *err_master_vals[] = | ||
937 | { NULL, "passed", "formatter device error", | ||
938 | "sector buffer error", "ECC circuitry error", | ||
939 | "controlling MPU error" }; | ||
940 | |||
941 | u8 err_master = err & 0x7f; | ||
942 | |||
943 | printk(KERN_ERR "%s: reset: master: ", hwif->name); | ||
944 | if (err_master && err_master < 6) | ||
945 | printk(KERN_CONT "%s", err_master_vals[err_master]); | ||
946 | else | ||
947 | printk(KERN_CONT "error (0x%02x?)", err); | ||
948 | if (err & 0x80) | ||
949 | printk(KERN_CONT "; slave: failed"); | ||
950 | printk(KERN_CONT "\n"); | ||
951 | } | ||
952 | |||
953 | /* | ||
954 | * reset_pollfunc() gets invoked to poll the interface for completion every 50ms | ||
955 | * during an ide reset operation. If the drives have not yet responded, | ||
956 | * and we have not yet hit our maximum waiting time, then the timer is restarted | ||
957 | * for another 50ms. | ||
958 | */ | ||
959 | static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | ||
960 | { | ||
961 | ide_hwif_t *hwif = drive->hwif; | ||
962 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
963 | u8 tmp; | ||
964 | int err = 0; | ||
965 | |||
966 | if (port_ops && port_ops->reset_poll) { | ||
967 | err = port_ops->reset_poll(drive); | ||
968 | if (err) { | ||
969 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", | ||
970 | hwif->name, drive->name); | ||
971 | goto out; | ||
972 | } | ||
973 | } | ||
974 | |||
975 | tmp = hwif->tp_ops->read_status(hwif); | ||
976 | |||
977 | if (!OK_STAT(tmp, 0, ATA_BUSY)) { | ||
978 | if (time_before(jiffies, hwif->poll_timeout)) { | ||
979 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | ||
980 | /* continue polling */ | ||
981 | return ide_started; | ||
982 | } | ||
983 | printk("%s: reset timed-out, status=0x%02x\n", hwif->name, tmp); | ||
984 | drive->failures++; | ||
985 | err = -EIO; | ||
986 | } else { | ||
987 | tmp = ide_read_error(drive); | ||
988 | |||
989 | if (tmp == 1) { | ||
990 | printk(KERN_INFO "%s: reset: success\n", hwif->name); | ||
991 | drive->failures = 0; | ||
992 | } else { | ||
993 | ide_reset_report_error(hwif, tmp); | ||
994 | drive->failures++; | ||
995 | err = -EIO; | ||
996 | } | ||
997 | } | ||
998 | out: | ||
999 | hwif->polling = 0; /* done polling */ | ||
1000 | ide_complete_drive_reset(drive, err); | ||
1001 | return ide_stopped; | ||
1002 | } | ||
1003 | |||
1004 | static void ide_disk_pre_reset(ide_drive_t *drive) | ||
1005 | { | ||
1006 | int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; | ||
1007 | |||
1008 | drive->special.all = 0; | ||
1009 | drive->special.b.set_geometry = legacy; | ||
1010 | drive->special.b.recalibrate = legacy; | ||
1011 | |||
1012 | drive->mult_count = 0; | ||
1013 | drive->dev_flags &= ~IDE_DFLAG_PARKED; | ||
1014 | |||
1015 | if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 && | ||
1016 | (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) | ||
1017 | drive->mult_req = 0; | ||
1018 | |||
1019 | if (drive->mult_req != drive->mult_count) | ||
1020 | drive->special.b.set_multmode = 1; | ||
1021 | } | ||
1022 | |||
1023 | static void pre_reset(ide_drive_t *drive) | ||
1024 | { | ||
1025 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; | ||
1026 | |||
1027 | if (drive->media == ide_disk) | ||
1028 | ide_disk_pre_reset(drive); | ||
1029 | else | ||
1030 | drive->dev_flags |= IDE_DFLAG_POST_RESET; | ||
1031 | |||
1032 | if (drive->dev_flags & IDE_DFLAG_USING_DMA) { | ||
1033 | if (drive->crc_count) | ||
1034 | ide_check_dma_crc(drive); | ||
1035 | else | ||
1036 | ide_dma_off(drive); | ||
1037 | } | ||
1038 | |||
1039 | if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) { | ||
1040 | if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) { | ||
1041 | drive->dev_flags &= ~IDE_DFLAG_UNMASK; | ||
1042 | drive->io_32bit = 0; | ||
1043 | } | ||
1044 | return; | ||
1045 | } | ||
1046 | |||
1047 | if (port_ops && port_ops->pre_reset) | ||
1048 | port_ops->pre_reset(drive); | ||
1049 | |||
1050 | if (drive->current_speed != 0xff) | ||
1051 | drive->desired_speed = drive->current_speed; | ||
1052 | drive->current_speed = 0xff; | ||
1053 | } | ||
1054 | |||
1055 | /* | ||
1056 | * do_reset1() attempts to recover a confused drive by resetting it. | ||
1057 | * Unfortunately, resetting a disk drive actually resets all devices on | ||
1058 | * the same interface, so it can really be thought of as resetting the | ||
1059 | * interface rather than resetting the drive. | ||
1060 | * | ||
1061 | * ATAPI devices have their own reset mechanism which allows them to be | ||
1062 | * individually reset without clobbering other devices on the same interface. | ||
1063 | * | ||
1064 | * Unfortunately, the IDE interface does not generate an interrupt to let | ||
1065 | * us know when the reset operation has finished, so we must poll for this. | ||
1066 | * Equally poor, though, is the fact that this may a very long time to complete, | ||
1067 | * (up to 30 seconds worstcase). So, instead of busy-waiting here for it, | ||
1068 | * we set a timer to poll at 50ms intervals. | ||
1069 | */ | ||
1070 | static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | ||
1071 | { | ||
1072 | ide_hwif_t *hwif = drive->hwif; | ||
1073 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
1074 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
1075 | const struct ide_port_ops *port_ops; | ||
1076 | ide_drive_t *tdrive; | ||
1077 | unsigned long flags, timeout; | ||
1078 | int i; | ||
1079 | DEFINE_WAIT(wait); | ||
1080 | |||
1081 | spin_lock_irqsave(&hwif->lock, flags); | ||
1082 | |||
1083 | /* We must not reset with running handlers */ | ||
1084 | BUG_ON(hwif->handler != NULL); | ||
1085 | |||
1086 | /* For an ATAPI device, first try an ATAPI SRST. */ | ||
1087 | if (drive->media != ide_disk && !do_not_try_atapi) { | ||
1088 | pre_reset(drive); | ||
1089 | SELECT_DRIVE(drive); | ||
1090 | udelay (20); | ||
1091 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | ||
1092 | ndelay(400); | ||
1093 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; | ||
1094 | hwif->polling = 1; | ||
1095 | __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); | ||
1096 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
1097 | return ide_started; | ||
1098 | } | ||
1099 | |||
1100 | /* We must not disturb devices in the IDE_DFLAG_PARKED state. */ | ||
1101 | do { | ||
1102 | unsigned long now; | ||
1103 | |||
1104 | prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); | ||
1105 | timeout = jiffies; | ||
1106 | ide_port_for_each_dev(i, tdrive, hwif) { | ||
1107 | if (tdrive->dev_flags & IDE_DFLAG_PRESENT && | ||
1108 | tdrive->dev_flags & IDE_DFLAG_PARKED && | ||
1109 | time_after(tdrive->sleep, timeout)) | ||
1110 | timeout = tdrive->sleep; | ||
1111 | } | ||
1112 | |||
1113 | now = jiffies; | ||
1114 | if (time_before_eq(timeout, now)) | ||
1115 | break; | ||
1116 | |||
1117 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
1118 | timeout = schedule_timeout_uninterruptible(timeout - now); | ||
1119 | spin_lock_irqsave(&hwif->lock, flags); | ||
1120 | } while (timeout); | ||
1121 | finish_wait(&ide_park_wq, &wait); | ||
1122 | |||
1123 | /* | ||
1124 | * First, reset any device state data we were maintaining | ||
1125 | * for any of the drives on this interface. | ||
1126 | */ | ||
1127 | ide_port_for_each_dev(i, tdrive, hwif) | ||
1128 | pre_reset(tdrive); | ||
1129 | |||
1130 | if (io_ports->ctl_addr == 0) { | ||
1131 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
1132 | ide_complete_drive_reset(drive, -ENXIO); | ||
1133 | return ide_stopped; | ||
1134 | } | ||
1135 | |||
1136 | /* | ||
1137 | * Note that we also set nIEN while resetting the device, | ||
1138 | * to mask unwanted interrupts from the interface during the reset. | ||
1139 | * However, due to the design of PC hardware, this will cause an | ||
1140 | * immediate interrupt due to the edge transition it produces. | ||
1141 | * This single interrupt gives us a "fast poll" for drives that | ||
1142 | * recover from reset very quickly, saving us the first 50ms wait time. | ||
1143 | * | ||
1144 | * TODO: add ->softreset method and stop abusing ->set_irq | ||
1145 | */ | ||
1146 | /* set SRST and nIEN */ | ||
1147 | tp_ops->set_irq(hwif, 4); | ||
1148 | /* more than enough time */ | ||
1149 | udelay(10); | ||
1150 | /* clear SRST, leave nIEN (unless device is on the quirk list) */ | ||
1151 | tp_ops->set_irq(hwif, drive->quirk_list == 2); | ||
1152 | /* more than enough time */ | ||
1153 | udelay(10); | ||
1154 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; | ||
1155 | hwif->polling = 1; | ||
1156 | __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | ||
1157 | |||
1158 | /* | ||
1159 | * Some weird controller like resetting themselves to a strange | ||
1160 | * state when the disks are reset this way. At least, the Winbond | ||
1161 | * 553 documentation says that | ||
1162 | */ | ||
1163 | port_ops = hwif->port_ops; | ||
1164 | if (port_ops && port_ops->resetproc) | ||
1165 | port_ops->resetproc(drive); | ||
1166 | |||
1167 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
1168 | return ide_started; | ||
1169 | } | ||
1170 | |||
1171 | /* | ||
1172 | * ide_do_reset() is the entry point to the drive/interface reset code. | ||
1173 | */ | ||
1174 | |||
1175 | ide_startstop_t ide_do_reset (ide_drive_t *drive) | ||
1176 | { | ||
1177 | return do_reset1(drive, 0); | ||
1178 | } | ||
1179 | |||
1180 | EXPORT_SYMBOL(ide_do_reset); | ||
1181 | |||
1182 | /* | 498 | /* |
1183 | * ide_wait_not_busy() waits for the currently selected device on the hwif | 499 | * ide_wait_not_busy() waits for the currently selected device on the hwif |
1184 | * to report a non-busy status, see comments in ide_probe_port(). | 500 | * to report a non-busy status, see comments in ide_probe_port(). |
@@ -1187,7 +503,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) | |||
1187 | { | 503 | { |
1188 | u8 stat = 0; | 504 | u8 stat = 0; |
1189 | 505 | ||
1190 | while(timeout--) { | 506 | while (timeout--) { |
1191 | /* | 507 | /* |
1192 | * Turn this into a schedule() sleep once I'm sure | 508 | * Turn this into a schedule() sleep once I'm sure |
1193 | * about locking issues (2.5 work ?). | 509 | * about locking issues (2.5 work ?). |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 09526a0de734..f6c683dd2987 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -5,163 +5,6 @@ | |||
5 | #include <linux/ide.h> | 5 | #include <linux/ide.h> |
6 | #include <linux/bitops.h> | 6 | #include <linux/bitops.h> |
7 | 7 | ||
8 | static const char *udma_str[] = | ||
9 | { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44", | ||
10 | "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" }; | ||
11 | static const char *mwdma_str[] = | ||
12 | { "MWDMA0", "MWDMA1", "MWDMA2" }; | ||
13 | static const char *swdma_str[] = | ||
14 | { "SWDMA0", "SWDMA1", "SWDMA2" }; | ||
15 | static const char *pio_str[] = | ||
16 | { "PIO0", "PIO1", "PIO2", "PIO3", "PIO4", "PIO5" }; | ||
17 | |||
18 | /** | ||
19 | * ide_xfer_verbose - return IDE mode names | ||
20 | * @mode: transfer mode | ||
21 | * | ||
22 | * Returns a constant string giving the name of the mode | ||
23 | * requested. | ||
24 | */ | ||
25 | |||
26 | const char *ide_xfer_verbose(u8 mode) | ||
27 | { | ||
28 | const char *s; | ||
29 | u8 i = mode & 0xf; | ||
30 | |||
31 | if (mode >= XFER_UDMA_0 && mode <= XFER_UDMA_7) | ||
32 | s = udma_str[i]; | ||
33 | else if (mode >= XFER_MW_DMA_0 && mode <= XFER_MW_DMA_2) | ||
34 | s = mwdma_str[i]; | ||
35 | else if (mode >= XFER_SW_DMA_0 && mode <= XFER_SW_DMA_2) | ||
36 | s = swdma_str[i]; | ||
37 | else if (mode >= XFER_PIO_0 && mode <= XFER_PIO_5) | ||
38 | s = pio_str[i & 0x7]; | ||
39 | else if (mode == XFER_PIO_SLOW) | ||
40 | s = "PIO SLOW"; | ||
41 | else | ||
42 | s = "XFER ERROR"; | ||
43 | |||
44 | return s; | ||
45 | } | ||
46 | EXPORT_SYMBOL(ide_xfer_verbose); | ||
47 | |||
48 | /** | ||
49 | * ide_rate_filter - filter transfer mode | ||
50 | * @drive: IDE device | ||
51 | * @speed: desired speed | ||
52 | * | ||
53 | * Given the available transfer modes this function returns | ||
54 | * the best available speed at or below the speed requested. | ||
55 | * | ||
56 | * TODO: check device PIO capabilities | ||
57 | */ | ||
58 | |||
59 | static u8 ide_rate_filter(ide_drive_t *drive, u8 speed) | ||
60 | { | ||
61 | ide_hwif_t *hwif = drive->hwif; | ||
62 | u8 mode = ide_find_dma_mode(drive, speed); | ||
63 | |||
64 | if (mode == 0) { | ||
65 | if (hwif->pio_mask) | ||
66 | mode = fls(hwif->pio_mask) - 1 + XFER_PIO_0; | ||
67 | else | ||
68 | mode = XFER_PIO_4; | ||
69 | } | ||
70 | |||
71 | /* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */ | ||
72 | |||
73 | return min(speed, mode); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * ide_get_best_pio_mode - get PIO mode from drive | ||
78 | * @drive: drive to consider | ||
79 | * @mode_wanted: preferred mode | ||
80 | * @max_mode: highest allowed mode | ||
81 | * | ||
82 | * This routine returns the recommended PIO settings for a given drive, | ||
83 | * based on the drive->id information and the ide_pio_blacklist[]. | ||
84 | * | ||
85 | * Drive PIO mode is auto-selected if 255 is passed as mode_wanted. | ||
86 | * This is used by most chipset support modules when "auto-tuning". | ||
87 | */ | ||
88 | |||
89 | u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode) | ||
90 | { | ||
91 | u16 *id = drive->id; | ||
92 | int pio_mode = -1, overridden = 0; | ||
93 | |||
94 | if (mode_wanted != 255) | ||
95 | return min_t(u8, mode_wanted, max_mode); | ||
96 | |||
97 | if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0) | ||
98 | pio_mode = ide_scan_pio_blacklist((char *)&id[ATA_ID_PROD]); | ||
99 | |||
100 | if (pio_mode != -1) { | ||
101 | printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name); | ||
102 | } else { | ||
103 | pio_mode = id[ATA_ID_OLD_PIO_MODES] >> 8; | ||
104 | if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */ | ||
105 | pio_mode = 2; | ||
106 | overridden = 1; | ||
107 | } | ||
108 | |||
109 | if (id[ATA_ID_FIELD_VALID] & 2) { /* ATA2? */ | ||
110 | if (ata_id_has_iordy(id)) { | ||
111 | if (id[ATA_ID_PIO_MODES] & 7) { | ||
112 | overridden = 0; | ||
113 | if (id[ATA_ID_PIO_MODES] & 4) | ||
114 | pio_mode = 5; | ||
115 | else if (id[ATA_ID_PIO_MODES] & 2) | ||
116 | pio_mode = 4; | ||
117 | else | ||
118 | pio_mode = 3; | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | |||
123 | if (overridden) | ||
124 | printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n", | ||
125 | drive->name); | ||
126 | } | ||
127 | |||
128 | if (pio_mode > max_mode) | ||
129 | pio_mode = max_mode; | ||
130 | |||
131 | return pio_mode; | ||
132 | } | ||
133 | EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); | ||
134 | |||
135 | /* req_pio == "255" for auto-tune */ | ||
136 | void ide_set_pio(ide_drive_t *drive, u8 req_pio) | ||
137 | { | ||
138 | ide_hwif_t *hwif = drive->hwif; | ||
139 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
140 | u8 host_pio, pio; | ||
141 | |||
142 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || | ||
143 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
144 | return; | ||
145 | |||
146 | BUG_ON(hwif->pio_mask == 0x00); | ||
147 | |||
148 | host_pio = fls(hwif->pio_mask) - 1; | ||
149 | |||
150 | pio = ide_get_best_pio_mode(drive, req_pio, host_pio); | ||
151 | |||
152 | /* | ||
153 | * TODO: | ||
154 | * - report device max PIO mode | ||
155 | * - check req_pio != 255 against device max PIO mode | ||
156 | */ | ||
157 | printk(KERN_DEBUG "%s: host max PIO%d wanted PIO%d%s selected PIO%d\n", | ||
158 | drive->name, host_pio, req_pio, | ||
159 | req_pio == 255 ? "(auto-tune)" : "", pio); | ||
160 | |||
161 | (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio); | ||
162 | } | ||
163 | EXPORT_SYMBOL_GPL(ide_set_pio); | ||
164 | |||
165 | /** | 8 | /** |
166 | * ide_toggle_bounce - handle bounce buffering | 9 | * ide_toggle_bounce - handle bounce buffering |
167 | * @drive: drive to update | 10 | * @drive: drive to update |
@@ -188,89 +31,6 @@ void ide_toggle_bounce(ide_drive_t *drive, int on) | |||
188 | blk_queue_bounce_limit(drive->queue, addr); | 31 | blk_queue_bounce_limit(drive->queue, addr); |
189 | } | 32 | } |
190 | 33 | ||
191 | int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | ||
192 | { | ||
193 | ide_hwif_t *hwif = drive->hwif; | ||
194 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
195 | |||
196 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
197 | return 0; | ||
198 | |||
199 | if (port_ops == NULL || port_ops->set_pio_mode == NULL) | ||
200 | return -1; | ||
201 | |||
202 | /* | ||
203 | * TODO: temporary hack for some legacy host drivers that didn't | ||
204 | * set transfer mode on the device in ->set_pio_mode method... | ||
205 | */ | ||
206 | if (port_ops->set_dma_mode == NULL) { | ||
207 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | ||
212 | if (ide_config_drive_speed(drive, mode)) | ||
213 | return -1; | ||
214 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | ||
215 | return 0; | ||
216 | } else { | ||
217 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | ||
218 | return ide_config_drive_speed(drive, mode); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) | ||
223 | { | ||
224 | ide_hwif_t *hwif = drive->hwif; | ||
225 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
226 | |||
227 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
228 | return 0; | ||
229 | |||
230 | if (port_ops == NULL || port_ops->set_dma_mode == NULL) | ||
231 | return -1; | ||
232 | |||
233 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | ||
234 | if (ide_config_drive_speed(drive, mode)) | ||
235 | return -1; | ||
236 | port_ops->set_dma_mode(drive, mode); | ||
237 | return 0; | ||
238 | } else { | ||
239 | port_ops->set_dma_mode(drive, mode); | ||
240 | return ide_config_drive_speed(drive, mode); | ||
241 | } | ||
242 | } | ||
243 | EXPORT_SYMBOL_GPL(ide_set_dma_mode); | ||
244 | |||
245 | /** | ||
246 | * ide_set_xfer_rate - set transfer rate | ||
247 | * @drive: drive to set | ||
248 | * @rate: speed to attempt to set | ||
249 | * | ||
250 | * General helper for setting the speed of an IDE device. This | ||
251 | * function knows about user enforced limits from the configuration | ||
252 | * which ->set_pio_mode/->set_dma_mode does not. | ||
253 | */ | ||
254 | |||
255 | int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) | ||
256 | { | ||
257 | ide_hwif_t *hwif = drive->hwif; | ||
258 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
259 | |||
260 | if (port_ops == NULL || port_ops->set_dma_mode == NULL || | ||
261 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
262 | return -1; | ||
263 | |||
264 | rate = ide_rate_filter(drive, rate); | ||
265 | |||
266 | BUG_ON(rate < XFER_PIO_0); | ||
267 | |||
268 | if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5) | ||
269 | return ide_set_pio_mode(drive, rate); | ||
270 | |||
271 | return ide_set_dma_mode(drive, rate); | ||
272 | } | ||
273 | |||
274 | static void ide_dump_opcode(ide_drive_t *drive) | 34 | static void ide_dump_opcode(ide_drive_t *drive) |
275 | { | 35 | { |
276 | struct request *rq = drive->hwif->rq; | 36 | struct request *rq = drive->hwif->rq; |
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c index c875a957596c..f30e52152fcb 100644 --- a/drivers/ide/ide-park.c +++ b/drivers/ide/ide-park.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/ide.h> | 2 | #include <linux/ide.h> |
3 | #include <linux/hdreg.h> | ||
3 | #include <linux/jiffies.h> | 4 | #include <linux/jiffies.h> |
4 | #include <linux/blkdev.h> | 5 | #include <linux/blkdev.h> |
5 | 6 | ||
@@ -60,6 +61,30 @@ out: | |||
60 | return; | 61 | return; |
61 | } | 62 | } |
62 | 63 | ||
64 | ide_startstop_t ide_do_park_unpark(ide_drive_t *drive, struct request *rq) | ||
65 | { | ||
66 | ide_task_t task; | ||
67 | struct ide_taskfile *tf = &task.tf; | ||
68 | |||
69 | memset(&task, 0, sizeof(task)); | ||
70 | if (rq->cmd[0] == REQ_PARK_HEADS) { | ||
71 | drive->sleep = *(unsigned long *)rq->special; | ||
72 | drive->dev_flags |= IDE_DFLAG_SLEEPING; | ||
73 | tf->command = ATA_CMD_IDLEIMMEDIATE; | ||
74 | tf->feature = 0x44; | ||
75 | tf->lbal = 0x4c; | ||
76 | tf->lbam = 0x4e; | ||
77 | tf->lbah = 0x55; | ||
78 | task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER; | ||
79 | } else /* cmd == REQ_UNPARK_HEADS */ | ||
80 | tf->command = ATA_CMD_CHK_POWER; | ||
81 | |||
82 | task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
83 | task.rq = rq; | ||
84 | drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA; | ||
85 | return do_rw_taskfile(drive, &task); | ||
86 | } | ||
87 | |||
63 | ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, | 88 | ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, |
64 | char *buf) | 89 | char *buf) |
65 | { | 90 | { |
diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c index bddae2b329a0..61111fd27130 100644 --- a/drivers/ide/ide-pci-generic.c +++ b/drivers/ide/ide-pci-generic.c | |||
@@ -33,8 +33,6 @@ static int ide_generic_all; /* Set to claim all devices */ | |||
33 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); | 33 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); |
34 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); | 34 | MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); |
35 | 35 | ||
36 | #define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS) | ||
37 | |||
38 | #define DECLARE_GENERIC_PCI_DEV(extra_flags) \ | 36 | #define DECLARE_GENERIC_PCI_DEV(extra_flags) \ |
39 | { \ | 37 | { \ |
40 | .name = DRV_NAME, \ | 38 | .name = DRV_NAME, \ |
@@ -61,7 +59,7 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
61 | /* 2: SAMURAI / HT6565 / HINT_IDE */ | 59 | /* 2: SAMURAI / HT6565 / HINT_IDE */ |
62 | DECLARE_GENERIC_PCI_DEV(0), | 60 | DECLARE_GENERIC_PCI_DEV(0), |
63 | /* 3: UM8673F / UM8886A / UM8886BF */ | 61 | /* 3: UM8673F / UM8886A / UM8886BF */ |
64 | DECLARE_GENERIC_PCI_DEV(IDE_HFLAGS_UMC), | 62 | DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_DMA), |
65 | /* 4: VIA_IDE / OPTI621V / Piccolo010{2,3,5} */ | 63 | /* 4: VIA_IDE / OPTI621V / Piccolo010{2,3,5} */ |
66 | DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_AUTODMA), | 64 | DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_AUTODMA), |
67 | 65 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index ee8e3e7cad51..974067043fba 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -181,16 +181,16 @@ static void ide_classify_atapi_dev(ide_drive_t *drive) | |||
181 | * do_identify - identify a drive | 181 | * do_identify - identify a drive |
182 | * @drive: drive to identify | 182 | * @drive: drive to identify |
183 | * @cmd: command used | 183 | * @cmd: command used |
184 | * @id: buffer for IDENTIFY data | ||
184 | * | 185 | * |
185 | * Called when we have issued a drive identify command to | 186 | * Called when we have issued a drive identify command to |
186 | * read and parse the results. This function is run with | 187 | * read and parse the results. This function is run with |
187 | * interrupts disabled. | 188 | * interrupts disabled. |
188 | */ | 189 | */ |
189 | 190 | ||
190 | static void do_identify(ide_drive_t *drive, u8 cmd) | 191 | static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id) |
191 | { | 192 | { |
192 | ide_hwif_t *hwif = drive->hwif; | 193 | ide_hwif_t *hwif = drive->hwif; |
193 | u16 *id = drive->id; | ||
194 | char *m = (char *)&id[ATA_ID_PROD]; | 194 | char *m = (char *)&id[ATA_ID_PROD]; |
195 | unsigned long flags; | 195 | unsigned long flags; |
196 | int bswap = 1; | 196 | int bswap = 1; |
@@ -233,16 +233,6 @@ static void do_identify(ide_drive_t *drive, u8 cmd) | |||
233 | drive->dev_flags |= IDE_DFLAG_PRESENT; | 233 | drive->dev_flags |= IDE_DFLAG_PRESENT; |
234 | drive->dev_flags &= ~IDE_DFLAG_DEAD; | 234 | drive->dev_flags &= ~IDE_DFLAG_DEAD; |
235 | 235 | ||
236 | /* | ||
237 | * Check for an ATAPI device | ||
238 | */ | ||
239 | if (cmd == ATA_CMD_ID_ATAPI) | ||
240 | ide_classify_atapi_dev(drive); | ||
241 | else | ||
242 | /* | ||
243 | * Not an ATAPI device: looks like a "regular" hard disk | ||
244 | */ | ||
245 | ide_classify_ata_dev(drive); | ||
246 | return; | 236 | return; |
247 | err_misc: | 237 | err_misc: |
248 | kfree(id); | 238 | kfree(id); |
@@ -250,21 +240,19 @@ err_misc: | |||
250 | } | 240 | } |
251 | 241 | ||
252 | /** | 242 | /** |
253 | * actual_try_to_identify - send ata/atapi identify | 243 | * ide_dev_read_id - send ATA/ATAPI IDENTIFY command |
254 | * @drive: drive to identify | 244 | * @drive: drive to identify |
255 | * @cmd: command to use | 245 | * @cmd: command to use |
246 | * @id: buffer for IDENTIFY data | ||
256 | * | 247 | * |
257 | * try_to_identify() sends an ATA(PI) IDENTIFY request to a drive | 248 | * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response. |
258 | * and waits for a response. It also monitors irqs while this is | ||
259 | * happening, in hope of automatically determining which one is | ||
260 | * being used by the interface. | ||
261 | * | 249 | * |
262 | * Returns: 0 device was identified | 250 | * Returns: 0 device was identified |
263 | * 1 device timed-out (no response to identify request) | 251 | * 1 device timed-out (no response to identify request) |
264 | * 2 device aborted the command (refused to identify itself) | 252 | * 2 device aborted the command (refused to identify itself) |
265 | */ | 253 | */ |
266 | 254 | ||
267 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | 255 | int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) |
268 | { | 256 | { |
269 | ide_hwif_t *hwif = drive->hwif; | 257 | ide_hwif_t *hwif = drive->hwif; |
270 | struct ide_io_ports *io_ports = &hwif->io_ports; | 258 | struct ide_io_ports *io_ports = &hwif->io_ports; |
@@ -273,6 +261,13 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
273 | unsigned long timeout; | 261 | unsigned long timeout; |
274 | u8 s = 0, a = 0; | 262 | u8 s = 0, a = 0; |
275 | 263 | ||
264 | /* | ||
265 | * Disable device IRQ. Otherwise we'll get spurious interrupts | ||
266 | * during the identify phase that the IRQ handler isn't expecting. | ||
267 | */ | ||
268 | if (io_ports->ctl_addr) | ||
269 | tp_ops->set_irq(hwif, 0); | ||
270 | |||
276 | /* take a deep breath */ | 271 | /* take a deep breath */ |
277 | msleep(50); | 272 | msleep(50); |
278 | 273 | ||
@@ -317,7 +312,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
317 | 312 | ||
318 | if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { | 313 | if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { |
319 | /* drive returned ID */ | 314 | /* drive returned ID */ |
320 | do_identify(drive, cmd); | 315 | do_identify(drive, cmd, id); |
321 | /* drive responded with ID */ | 316 | /* drive responded with ID */ |
322 | rc = 0; | 317 | rc = 0; |
323 | /* clear drive IRQ */ | 318 | /* clear drive IRQ */ |
@@ -329,63 +324,6 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
329 | return rc; | 324 | return rc; |
330 | } | 325 | } |
331 | 326 | ||
332 | /** | ||
333 | * try_to_identify - try to identify a drive | ||
334 | * @drive: drive to probe | ||
335 | * @cmd: command to use | ||
336 | * | ||
337 | * Issue the identify command and then do IRQ probing to | ||
338 | * complete the identification when needed by finding the | ||
339 | * IRQ the drive is attached to | ||
340 | */ | ||
341 | |||
342 | static int try_to_identify (ide_drive_t *drive, u8 cmd) | ||
343 | { | ||
344 | ide_hwif_t *hwif = drive->hwif; | ||
345 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
346 | int retval; | ||
347 | int autoprobe = 0; | ||
348 | unsigned long cookie = 0; | ||
349 | |||
350 | /* | ||
351 | * Disable device irq unless we need to | ||
352 | * probe for it. Otherwise we'll get spurious | ||
353 | * interrupts during the identify-phase that | ||
354 | * the irq handler isn't expecting. | ||
355 | */ | ||
356 | if (hwif->io_ports.ctl_addr) { | ||
357 | if (!hwif->irq) { | ||
358 | autoprobe = 1; | ||
359 | cookie = probe_irq_on(); | ||
360 | } | ||
361 | tp_ops->set_irq(hwif, autoprobe); | ||
362 | } | ||
363 | |||
364 | retval = actual_try_to_identify(drive, cmd); | ||
365 | |||
366 | if (autoprobe) { | ||
367 | int irq; | ||
368 | |||
369 | tp_ops->set_irq(hwif, 0); | ||
370 | /* clear drive IRQ */ | ||
371 | (void)tp_ops->read_status(hwif); | ||
372 | udelay(5); | ||
373 | irq = probe_irq_off(cookie); | ||
374 | if (!hwif->irq) { | ||
375 | if (irq > 0) { | ||
376 | hwif->irq = irq; | ||
377 | } else { | ||
378 | /* Mmmm.. multiple IRQs.. | ||
379 | * don't know which was ours | ||
380 | */ | ||
381 | printk(KERN_ERR "%s: IRQ probe failed (0x%lx)\n", | ||
382 | drive->name, cookie); | ||
383 | } | ||
384 | } | ||
385 | } | ||
386 | return retval; | ||
387 | } | ||
388 | |||
389 | int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) | 327 | int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) |
390 | { | 328 | { |
391 | u8 stat; | 329 | u8 stat; |
@@ -440,6 +378,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
440 | { | 378 | { |
441 | ide_hwif_t *hwif = drive->hwif; | 379 | ide_hwif_t *hwif = drive->hwif; |
442 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 380 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
381 | u16 *id = drive->id; | ||
443 | int rc; | 382 | int rc; |
444 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; | 383 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; |
445 | 384 | ||
@@ -475,11 +414,10 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
475 | 414 | ||
476 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || | 415 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || |
477 | present || cmd == ATA_CMD_ID_ATAPI) { | 416 | present || cmd == ATA_CMD_ID_ATAPI) { |
478 | /* send cmd and wait */ | 417 | rc = ide_dev_read_id(drive, cmd, id); |
479 | if ((rc = try_to_identify(drive, cmd))) { | 418 | if (rc) |
480 | /* failed: try again */ | 419 | /* failed: try again */ |
481 | rc = try_to_identify(drive,cmd); | 420 | rc = ide_dev_read_id(drive, cmd, id); |
482 | } | ||
483 | 421 | ||
484 | stat = tp_ops->read_status(hwif); | 422 | stat = tp_ops->read_status(hwif); |
485 | 423 | ||
@@ -494,7 +432,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
494 | msleep(50); | 432 | msleep(50); |
495 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | 433 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
496 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); | 434 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); |
497 | rc = try_to_identify(drive, cmd); | 435 | rc = ide_dev_read_id(drive, cmd, id); |
498 | } | 436 | } |
499 | 437 | ||
500 | /* ensure drive IRQ is clear */ | 438 | /* ensure drive IRQ is clear */ |
@@ -517,37 +455,6 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
517 | return rc; | 455 | return rc; |
518 | } | 456 | } |
519 | 457 | ||
520 | /* | ||
521 | * | ||
522 | */ | ||
523 | static void enable_nest (ide_drive_t *drive) | ||
524 | { | ||
525 | ide_hwif_t *hwif = drive->hwif; | ||
526 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
527 | u8 stat; | ||
528 | |||
529 | printk(KERN_INFO "%s: enabling %s -- ", | ||
530 | hwif->name, (char *)&drive->id[ATA_ID_PROD]); | ||
531 | |||
532 | SELECT_DRIVE(drive); | ||
533 | msleep(50); | ||
534 | tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST); | ||
535 | |||
536 | if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) { | ||
537 | printk(KERN_CONT "failed (timeout)\n"); | ||
538 | return; | ||
539 | } | ||
540 | |||
541 | msleep(50); | ||
542 | |||
543 | stat = tp_ops->read_status(hwif); | ||
544 | |||
545 | if (!OK_STAT(stat, 0, BAD_STAT)) | ||
546 | printk(KERN_CONT "failed (status = 0x%02x)\n", stat); | ||
547 | else | ||
548 | printk(KERN_CONT "success\n"); | ||
549 | } | ||
550 | |||
551 | /** | 458 | /** |
552 | * probe_for_drives - upper level drive probe | 459 | * probe_for_drives - upper level drive probe |
553 | * @drive: drive to probe for | 460 | * @drive: drive to probe for |
@@ -563,6 +470,8 @@ static void enable_nest (ide_drive_t *drive) | |||
563 | static u8 probe_for_drive(ide_drive_t *drive) | 470 | static u8 probe_for_drive(ide_drive_t *drive) |
564 | { | 471 | { |
565 | char *m; | 472 | char *m; |
473 | int rc; | ||
474 | u8 cmd; | ||
566 | 475 | ||
567 | /* | 476 | /* |
568 | * In order to keep things simple we have an id | 477 | * In order to keep things simple we have an id |
@@ -586,21 +495,19 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
586 | 495 | ||
587 | /* skip probing? */ | 496 | /* skip probing? */ |
588 | if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { | 497 | if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { |
589 | retry: | ||
590 | /* if !(success||timed-out) */ | 498 | /* if !(success||timed-out) */ |
591 | if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) | 499 | cmd = ATA_CMD_ID_ATA; |
500 | rc = do_probe(drive, cmd); | ||
501 | if (rc >= 2) { | ||
592 | /* look for ATAPI device */ | 502 | /* look for ATAPI device */ |
593 | (void)do_probe(drive, ATA_CMD_ID_ATAPI); | 503 | cmd = ATA_CMD_ID_ATAPI; |
504 | rc = do_probe(drive, cmd); | ||
505 | } | ||
594 | 506 | ||
595 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 507 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
596 | /* drive not found */ | 508 | /* drive not found */ |
597 | return 0; | 509 | return 0; |
598 | 510 | ||
599 | if (strstr(m, "E X A B Y T E N E S T")) { | ||
600 | enable_nest(drive); | ||
601 | goto retry; | ||
602 | } | ||
603 | |||
604 | /* identification failed? */ | 511 | /* identification failed? */ |
605 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { | 512 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
606 | if (drive->media == ide_disk) { | 513 | if (drive->media == ide_disk) { |
@@ -614,8 +521,12 @@ retry: | |||
614 | printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); | 521 | printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); |
615 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | 522 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
616 | } | 523 | } |
524 | } else { | ||
525 | if (cmd == ATA_CMD_ID_ATAPI) | ||
526 | ide_classify_atapi_dev(drive); | ||
527 | else | ||
528 | ide_classify_ata_dev(drive); | ||
617 | } | 529 | } |
618 | /* drive was found */ | ||
619 | } | 530 | } |
620 | 531 | ||
621 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 532 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
@@ -779,7 +690,6 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave); | |||
779 | static int ide_probe_port(ide_hwif_t *hwif) | 690 | static int ide_probe_port(ide_hwif_t *hwif) |
780 | { | 691 | { |
781 | ide_drive_t *drive; | 692 | ide_drive_t *drive; |
782 | unsigned long flags; | ||
783 | unsigned int irqd; | 693 | unsigned int irqd; |
784 | int i, rc = -ENODEV; | 694 | int i, rc = -ENODEV; |
785 | 695 | ||
@@ -797,9 +707,6 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
797 | if (irqd) | 707 | if (irqd) |
798 | disable_irq(hwif->irq); | 708 | disable_irq(hwif->irq); |
799 | 709 | ||
800 | local_save_flags(flags); | ||
801 | local_irq_enable_in_hardirq(); | ||
802 | |||
803 | if (ide_port_wait_ready(hwif) == -EBUSY) | 710 | if (ide_port_wait_ready(hwif) == -EBUSY) |
804 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); | 711 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); |
805 | 712 | ||
@@ -813,8 +720,6 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
813 | rc = 0; | 720 | rc = 0; |
814 | } | 721 | } |
815 | 722 | ||
816 | local_irq_restore(flags); | ||
817 | |||
818 | /* | 723 | /* |
819 | * Use cached IRQ number. It might be (and is...) changed by probe | 724 | * Use cached IRQ number. It might be (and is...) changed by probe |
820 | * code above | 725 | * code above |
@@ -831,29 +736,18 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
831 | ide_drive_t *drive; | 736 | ide_drive_t *drive; |
832 | int i; | 737 | int i; |
833 | 738 | ||
834 | ide_port_for_each_dev(i, drive, hwif) { | 739 | ide_port_for_each_present_dev(i, drive, hwif) { |
835 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | 740 | if (port_ops && port_ops->quirkproc) |
836 | if (port_ops && port_ops->quirkproc) | 741 | port_ops->quirkproc(drive); |
837 | port_ops->quirkproc(drive); | ||
838 | } | ||
839 | } | 742 | } |
840 | 743 | ||
841 | ide_port_for_each_dev(i, drive, hwif) { | 744 | ide_port_for_each_present_dev(i, drive, hwif) { |
842 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | 745 | ide_set_max_pio(drive); |
843 | ide_set_max_pio(drive); | ||
844 | 746 | ||
845 | drive->dev_flags |= IDE_DFLAG_NICE1; | 747 | drive->dev_flags |= IDE_DFLAG_NICE1; |
846 | |||
847 | if (hwif->dma_ops) | ||
848 | ide_set_dma(drive); | ||
849 | } | ||
850 | } | ||
851 | 748 | ||
852 | ide_port_for_each_dev(i, drive, hwif) { | 749 | if (hwif->dma_ops) |
853 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) | 750 | ide_set_dma(drive); |
854 | drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; | ||
855 | else | ||
856 | drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT; | ||
857 | } | 751 | } |
858 | } | 752 | } |
859 | 753 | ||
@@ -924,10 +818,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif) | |||
924 | int i, j = 0; | 818 | int i, j = 0; |
925 | 819 | ||
926 | mutex_lock(&ide_cfg_mtx); | 820 | mutex_lock(&ide_cfg_mtx); |
927 | ide_port_for_each_dev(i, drive, hwif) { | 821 | ide_port_for_each_present_dev(i, drive, hwif) { |
928 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | ||
929 | continue; | ||
930 | |||
931 | if (ide_init_queue(drive)) { | 822 | if (ide_init_queue(drive)) { |
932 | printk(KERN_ERR "ide: failed to init %s\n", | 823 | printk(KERN_ERR "ide: failed to init %s\n", |
933 | drive->name); | 824 | drive->name); |
@@ -953,13 +844,6 @@ static int init_irq (ide_hwif_t *hwif) | |||
953 | irq_handler_t irq_handler; | 844 | irq_handler_t irq_handler; |
954 | int sa = 0; | 845 | int sa = 0; |
955 | 846 | ||
956 | mutex_lock(&ide_cfg_mtx); | ||
957 | spin_lock_init(&hwif->lock); | ||
958 | |||
959 | init_timer(&hwif->timer); | ||
960 | hwif->timer.function = &ide_timer_expiry; | ||
961 | hwif->timer.data = (unsigned long)hwif; | ||
962 | |||
963 | irq_handler = hwif->host->irq_handler; | 847 | irq_handler = hwif->host->irq_handler; |
964 | if (irq_handler == NULL) | 848 | if (irq_handler == NULL) |
965 | irq_handler = ide_intr; | 849 | irq_handler = ide_intr; |
@@ -997,10 +881,8 @@ static int init_irq (ide_hwif_t *hwif) | |||
997 | printk(KERN_CONT " (serialized)"); | 881 | printk(KERN_CONT " (serialized)"); |
998 | printk(KERN_CONT "\n"); | 882 | printk(KERN_CONT "\n"); |
999 | 883 | ||
1000 | mutex_unlock(&ide_cfg_mtx); | ||
1001 | return 0; | 884 | return 0; |
1002 | out_up: | 885 | out_up: |
1003 | mutex_unlock(&ide_cfg_mtx); | ||
1004 | return 1; | 886 | return 1; |
1005 | } | 887 | } |
1006 | 888 | ||
@@ -1099,14 +981,9 @@ static void drive_release_dev (struct device *dev) | |||
1099 | 981 | ||
1100 | static int hwif_init(ide_hwif_t *hwif) | 982 | static int hwif_init(ide_hwif_t *hwif) |
1101 | { | 983 | { |
1102 | int old_irq; | ||
1103 | |||
1104 | if (!hwif->irq) { | 984 | if (!hwif->irq) { |
1105 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); | 985 | printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); |
1106 | if (!hwif->irq) { | 986 | return 0; |
1107 | printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); | ||
1108 | return 0; | ||
1109 | } | ||
1110 | } | 987 | } |
1111 | 988 | ||
1112 | if (register_blkdev(hwif->major, hwif->name)) | 989 | if (register_blkdev(hwif->major, hwif->name)) |
@@ -1124,29 +1001,12 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1124 | 1001 | ||
1125 | sg_init_table(hwif->sg_table, hwif->sg_max_nents); | 1002 | sg_init_table(hwif->sg_table, hwif->sg_max_nents); |
1126 | 1003 | ||
1127 | if (init_irq(hwif) == 0) | ||
1128 | goto done; | ||
1129 | |||
1130 | old_irq = hwif->irq; | ||
1131 | /* | ||
1132 | * It failed to initialise. Find the default IRQ for | ||
1133 | * this port and try that. | ||
1134 | */ | ||
1135 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); | ||
1136 | if (!hwif->irq) { | ||
1137 | printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n", | ||
1138 | hwif->name, old_irq); | ||
1139 | goto out; | ||
1140 | } | ||
1141 | if (init_irq(hwif)) { | 1004 | if (init_irq(hwif)) { |
1142 | printk(KERN_ERR "%s: probed IRQ %d and default IRQ %d failed\n", | 1005 | printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n", |
1143 | hwif->name, old_irq, hwif->irq); | 1006 | hwif->name, hwif->irq); |
1144 | goto out; | 1007 | goto out; |
1145 | } | 1008 | } |
1146 | printk(KERN_WARNING "%s: probed IRQ %d failed, using default\n", | ||
1147 | hwif->name, hwif->irq); | ||
1148 | 1009 | ||
1149 | done: | ||
1150 | blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, | 1010 | blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, |
1151 | THIS_MODULE, ata_probe, ata_lock, hwif); | 1011 | THIS_MODULE, ata_probe, ata_lock, hwif); |
1152 | return 1; | 1012 | return 1; |
@@ -1161,13 +1021,10 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
1161 | ide_drive_t *drive; | 1021 | ide_drive_t *drive; |
1162 | unsigned int i; | 1022 | unsigned int i; |
1163 | 1023 | ||
1164 | ide_port_for_each_dev(i, drive, hwif) { | 1024 | ide_port_for_each_present_dev(i, drive, hwif) { |
1165 | struct device *dev = &drive->gendev; | 1025 | struct device *dev = &drive->gendev; |
1166 | int ret; | 1026 | int ret; |
1167 | 1027 | ||
1168 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | ||
1169 | continue; | ||
1170 | |||
1171 | dev_set_name(dev, "%u.%u", hwif->index, i); | 1028 | dev_set_name(dev, "%u.%u", hwif->index, i); |
1172 | dev->parent = &hwif->gendev; | 1029 | dev->parent = &hwif->gendev; |
1173 | dev->bus = &ide_bus_type; | 1030 | dev->bus = &ide_bus_type; |
@@ -1192,6 +1049,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1192 | 1049 | ||
1193 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) | 1050 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) |
1194 | drive->io_32bit = 1; | 1051 | drive->io_32bit = 1; |
1052 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) | ||
1053 | drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; | ||
1195 | if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) | 1054 | if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) |
1196 | drive->dev_flags |= IDE_DFLAG_UNMASK; | 1055 | drive->dev_flags |= IDE_DFLAG_UNMASK; |
1197 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | 1056 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) |
@@ -1213,10 +1072,6 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1213 | if (d->init_iops) | 1072 | if (d->init_iops) |
1214 | d->init_iops(hwif); | 1073 | d->init_iops(hwif); |
1215 | 1074 | ||
1216 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || | ||
1217 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | ||
1218 | hwif->irq = port ? 15 : 14; | ||
1219 | |||
1220 | /* ->host_flags may be set by ->init_iops (or even earlier...) */ | 1075 | /* ->host_flags may be set by ->init_iops (or even earlier...) */ |
1221 | hwif->host_flags |= d->host_flags; | 1076 | hwif->host_flags |= d->host_flags; |
1222 | hwif->pio_mask = d->pio_mask; | 1077 | hwif->pio_mask = d->pio_mask; |
@@ -1317,6 +1172,12 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
1317 | hwif->name[2] = 'e'; | 1172 | hwif->name[2] = 'e'; |
1318 | hwif->name[3] = '0' + index; | 1173 | hwif->name[3] = '0' + index; |
1319 | 1174 | ||
1175 | spin_lock_init(&hwif->lock); | ||
1176 | |||
1177 | init_timer(&hwif->timer); | ||
1178 | hwif->timer.function = &ide_timer_expiry; | ||
1179 | hwif->timer.data = (unsigned long)hwif; | ||
1180 | |||
1320 | init_completion(&hwif->gendev_rel_comp); | 1181 | init_completion(&hwif->gendev_rel_comp); |
1321 | 1182 | ||
1322 | hwif->tp_ops = &default_tp_ops; | 1183 | hwif->tp_ops = &default_tp_ops; |
@@ -1567,7 +1428,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1567 | 1428 | ||
1568 | j++; | 1429 | j++; |
1569 | 1430 | ||
1570 | ide_acpi_init(hwif); | 1431 | ide_acpi_init_port(hwif); |
1571 | 1432 | ||
1572 | if (hwif->present) | 1433 | if (hwif->present) |
1573 | ide_acpi_port_init_devices(hwif); | 1434 | ide_acpi_port_init_devices(hwif); |
@@ -1624,11 +1485,9 @@ static void __ide_port_unregister_devices(ide_hwif_t *hwif) | |||
1624 | ide_drive_t *drive; | 1485 | ide_drive_t *drive; |
1625 | int i; | 1486 | int i; |
1626 | 1487 | ||
1627 | ide_port_for_each_dev(i, drive, hwif) { | 1488 | ide_port_for_each_present_dev(i, drive, hwif) { |
1628 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | 1489 | device_unregister(&drive->gendev); |
1629 | device_unregister(&drive->gendev); | 1490 | wait_for_completion(&drive->gendev_rel_comp); |
1630 | wait_for_completion(&drive->gendev_rel_comp); | ||
1631 | } | ||
1632 | } | 1491 | } |
1633 | } | 1492 | } |
1634 | 1493 | ||
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index a7b9287ee0d4..417cde56eafd 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -600,7 +600,7 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif) | |||
600 | int i; | 600 | int i; |
601 | 601 | ||
602 | ide_port_for_each_dev(i, drive, hwif) { | 602 | ide_port_for_each_dev(i, drive, hwif) { |
603 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) | 603 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
604 | continue; | 604 | continue; |
605 | 605 | ||
606 | drive->proc = proc_mkdir(drive->name, parent); | 606 | drive->proc = proc_mkdir(drive->name, parent); |
diff --git a/drivers/ide/ide-xfer-mode.c b/drivers/ide/ide-xfer-mode.c new file mode 100644 index 000000000000..6910f6a257e8 --- /dev/null +++ b/drivers/ide/ide-xfer-mode.c | |||
@@ -0,0 +1,246 @@ | |||
1 | #include <linux/types.h> | ||
2 | #include <linux/string.h> | ||
3 | #include <linux/kernel.h> | ||
4 | #include <linux/interrupt.h> | ||
5 | #include <linux/ide.h> | ||
6 | #include <linux/bitops.h> | ||
7 | |||
8 | static const char *udma_str[] = | ||
9 | { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44", | ||
10 | "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" }; | ||
11 | static const char *mwdma_str[] = | ||
12 | { "MWDMA0", "MWDMA1", "MWDMA2" }; | ||
13 | static const char *swdma_str[] = | ||
14 | { "SWDMA0", "SWDMA1", "SWDMA2" }; | ||
15 | static const char *pio_str[] = | ||
16 | { "PIO0", "PIO1", "PIO2", "PIO3", "PIO4", "PIO5" }; | ||
17 | |||
18 | /** | ||
19 | * ide_xfer_verbose - return IDE mode names | ||
20 | * @mode: transfer mode | ||
21 | * | ||
22 | * Returns a constant string giving the name of the mode | ||
23 | * requested. | ||
24 | */ | ||
25 | |||
26 | const char *ide_xfer_verbose(u8 mode) | ||
27 | { | ||
28 | const char *s; | ||
29 | u8 i = mode & 0xf; | ||
30 | |||
31 | if (mode >= XFER_UDMA_0 && mode <= XFER_UDMA_7) | ||
32 | s = udma_str[i]; | ||
33 | else if (mode >= XFER_MW_DMA_0 && mode <= XFER_MW_DMA_2) | ||
34 | s = mwdma_str[i]; | ||
35 | else if (mode >= XFER_SW_DMA_0 && mode <= XFER_SW_DMA_2) | ||
36 | s = swdma_str[i]; | ||
37 | else if (mode >= XFER_PIO_0 && mode <= XFER_PIO_5) | ||
38 | s = pio_str[i & 0x7]; | ||
39 | else if (mode == XFER_PIO_SLOW) | ||
40 | s = "PIO SLOW"; | ||
41 | else | ||
42 | s = "XFER ERROR"; | ||
43 | |||
44 | return s; | ||
45 | } | ||
46 | EXPORT_SYMBOL(ide_xfer_verbose); | ||
47 | |||
48 | /** | ||
49 | * ide_get_best_pio_mode - get PIO mode from drive | ||
50 | * @drive: drive to consider | ||
51 | * @mode_wanted: preferred mode | ||
52 | * @max_mode: highest allowed mode | ||
53 | * | ||
54 | * This routine returns the recommended PIO settings for a given drive, | ||
55 | * based on the drive->id information and the ide_pio_blacklist[]. | ||
56 | * | ||
57 | * Drive PIO mode is auto-selected if 255 is passed as mode_wanted. | ||
58 | * This is used by most chipset support modules when "auto-tuning". | ||
59 | */ | ||
60 | |||
61 | u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode) | ||
62 | { | ||
63 | u16 *id = drive->id; | ||
64 | int pio_mode = -1, overridden = 0; | ||
65 | |||
66 | if (mode_wanted != 255) | ||
67 | return min_t(u8, mode_wanted, max_mode); | ||
68 | |||
69 | if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0) | ||
70 | pio_mode = ide_scan_pio_blacklist((char *)&id[ATA_ID_PROD]); | ||
71 | |||
72 | if (pio_mode != -1) { | ||
73 | printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name); | ||
74 | } else { | ||
75 | pio_mode = id[ATA_ID_OLD_PIO_MODES] >> 8; | ||
76 | if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */ | ||
77 | pio_mode = 2; | ||
78 | overridden = 1; | ||
79 | } | ||
80 | |||
81 | if (id[ATA_ID_FIELD_VALID] & 2) { /* ATA2? */ | ||
82 | if (ata_id_has_iordy(id)) { | ||
83 | if (id[ATA_ID_PIO_MODES] & 7) { | ||
84 | overridden = 0; | ||
85 | if (id[ATA_ID_PIO_MODES] & 4) | ||
86 | pio_mode = 5; | ||
87 | else if (id[ATA_ID_PIO_MODES] & 2) | ||
88 | pio_mode = 4; | ||
89 | else | ||
90 | pio_mode = 3; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | if (overridden) | ||
96 | printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n", | ||
97 | drive->name); | ||
98 | } | ||
99 | |||
100 | if (pio_mode > max_mode) | ||
101 | pio_mode = max_mode; | ||
102 | |||
103 | return pio_mode; | ||
104 | } | ||
105 | EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); | ||
106 | |||
107 | int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | ||
108 | { | ||
109 | ide_hwif_t *hwif = drive->hwif; | ||
110 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
111 | |||
112 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
113 | return 0; | ||
114 | |||
115 | if (port_ops == NULL || port_ops->set_pio_mode == NULL) | ||
116 | return -1; | ||
117 | |||
118 | /* | ||
119 | * TODO: temporary hack for some legacy host drivers that didn't | ||
120 | * set transfer mode on the device in ->set_pio_mode method... | ||
121 | */ | ||
122 | if (port_ops->set_dma_mode == NULL) { | ||
123 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | ||
128 | if (ide_config_drive_speed(drive, mode)) | ||
129 | return -1; | ||
130 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | ||
131 | return 0; | ||
132 | } else { | ||
133 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | ||
134 | return ide_config_drive_speed(drive, mode); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) | ||
139 | { | ||
140 | ide_hwif_t *hwif = drive->hwif; | ||
141 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
142 | |||
143 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | ||
144 | return 0; | ||
145 | |||
146 | if (port_ops == NULL || port_ops->set_dma_mode == NULL) | ||
147 | return -1; | ||
148 | |||
149 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | ||
150 | if (ide_config_drive_speed(drive, mode)) | ||
151 | return -1; | ||
152 | port_ops->set_dma_mode(drive, mode); | ||
153 | return 0; | ||
154 | } else { | ||
155 | port_ops->set_dma_mode(drive, mode); | ||
156 | return ide_config_drive_speed(drive, mode); | ||
157 | } | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(ide_set_dma_mode); | ||
160 | |||
161 | /* req_pio == "255" for auto-tune */ | ||
162 | void ide_set_pio(ide_drive_t *drive, u8 req_pio) | ||
163 | { | ||
164 | ide_hwif_t *hwif = drive->hwif; | ||
165 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
166 | u8 host_pio, pio; | ||
167 | |||
168 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || | ||
169 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
170 | return; | ||
171 | |||
172 | BUG_ON(hwif->pio_mask == 0x00); | ||
173 | |||
174 | host_pio = fls(hwif->pio_mask) - 1; | ||
175 | |||
176 | pio = ide_get_best_pio_mode(drive, req_pio, host_pio); | ||
177 | |||
178 | /* | ||
179 | * TODO: | ||
180 | * - report device max PIO mode | ||
181 | * - check req_pio != 255 against device max PIO mode | ||
182 | */ | ||
183 | printk(KERN_DEBUG "%s: host max PIO%d wanted PIO%d%s selected PIO%d\n", | ||
184 | drive->name, host_pio, req_pio, | ||
185 | req_pio == 255 ? "(auto-tune)" : "", pio); | ||
186 | |||
187 | (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio); | ||
188 | } | ||
189 | EXPORT_SYMBOL_GPL(ide_set_pio); | ||
190 | |||
191 | /** | ||
192 | * ide_rate_filter - filter transfer mode | ||
193 | * @drive: IDE device | ||
194 | * @speed: desired speed | ||
195 | * | ||
196 | * Given the available transfer modes this function returns | ||
197 | * the best available speed at or below the speed requested. | ||
198 | * | ||
199 | * TODO: check device PIO capabilities | ||
200 | */ | ||
201 | |||
202 | static u8 ide_rate_filter(ide_drive_t *drive, u8 speed) | ||
203 | { | ||
204 | ide_hwif_t *hwif = drive->hwif; | ||
205 | u8 mode = ide_find_dma_mode(drive, speed); | ||
206 | |||
207 | if (mode == 0) { | ||
208 | if (hwif->pio_mask) | ||
209 | mode = fls(hwif->pio_mask) - 1 + XFER_PIO_0; | ||
210 | else | ||
211 | mode = XFER_PIO_4; | ||
212 | } | ||
213 | |||
214 | /* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */ | ||
215 | |||
216 | return min(speed, mode); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * ide_set_xfer_rate - set transfer rate | ||
221 | * @drive: drive to set | ||
222 | * @rate: speed to attempt to set | ||
223 | * | ||
224 | * General helper for setting the speed of an IDE device. This | ||
225 | * function knows about user enforced limits from the configuration | ||
226 | * which ->set_pio_mode/->set_dma_mode does not. | ||
227 | */ | ||
228 | |||
229 | int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) | ||
230 | { | ||
231 | ide_hwif_t *hwif = drive->hwif; | ||
232 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
233 | |||
234 | if (port_ops == NULL || port_ops->set_dma_mode == NULL || | ||
235 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
236 | return -1; | ||
237 | |||
238 | rate = ide_rate_filter(drive, rate); | ||
239 | |||
240 | BUG_ON(rate < XFER_PIO_0); | ||
241 | |||
242 | if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5) | ||
243 | return ide_set_pio_mode(drive, rate); | ||
244 | |||
245 | return ide_set_dma_mode(drive, rate); | ||
246 | } | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 0920e3b0c962..92c9b90931e7 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -62,160 +62,6 @@ | |||
62 | 62 | ||
63 | struct class *ide_port_class; | 63 | struct class *ide_port_class; |
64 | 64 | ||
65 | /* | ||
66 | * Locks for IDE setting functionality | ||
67 | */ | ||
68 | |||
69 | DEFINE_MUTEX(ide_setting_mtx); | ||
70 | |||
71 | ide_devset_get(io_32bit, io_32bit); | ||
72 | |||
73 | static int set_io_32bit(ide_drive_t *drive, int arg) | ||
74 | { | ||
75 | if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) | ||
76 | return -EPERM; | ||
77 | |||
78 | if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) | ||
79 | return -EINVAL; | ||
80 | |||
81 | drive->io_32bit = arg; | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS); | ||
87 | |||
88 | static int set_ksettings(ide_drive_t *drive, int arg) | ||
89 | { | ||
90 | if (arg < 0 || arg > 1) | ||
91 | return -EINVAL; | ||
92 | |||
93 | if (arg) | ||
94 | drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS; | ||
95 | else | ||
96 | drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS; | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA); | ||
102 | |||
103 | static int set_using_dma(ide_drive_t *drive, int arg) | ||
104 | { | ||
105 | #ifdef CONFIG_BLK_DEV_IDEDMA | ||
106 | int err = -EPERM; | ||
107 | |||
108 | if (arg < 0 || arg > 1) | ||
109 | return -EINVAL; | ||
110 | |||
111 | if (ata_id_has_dma(drive->id) == 0) | ||
112 | goto out; | ||
113 | |||
114 | if (drive->hwif->dma_ops == NULL) | ||
115 | goto out; | ||
116 | |||
117 | err = 0; | ||
118 | |||
119 | if (arg) { | ||
120 | if (ide_set_dma(drive)) | ||
121 | err = -EIO; | ||
122 | } else | ||
123 | ide_dma_off(drive); | ||
124 | |||
125 | out: | ||
126 | return err; | ||
127 | #else | ||
128 | if (arg < 0 || arg > 1) | ||
129 | return -EINVAL; | ||
130 | |||
131 | return -EPERM; | ||
132 | #endif | ||
133 | } | ||
134 | |||
135 | /* | ||
136 | * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away | ||
137 | */ | ||
138 | static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) | ||
139 | { | ||
140 | switch (req_pio) { | ||
141 | case 202: | ||
142 | case 201: | ||
143 | case 200: | ||
144 | case 102: | ||
145 | case 101: | ||
146 | case 100: | ||
147 | return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0; | ||
148 | case 9: | ||
149 | case 8: | ||
150 | return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0; | ||
151 | case 7: | ||
152 | case 6: | ||
153 | return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0; | ||
154 | default: | ||
155 | return 0; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | static int set_pio_mode(ide_drive_t *drive, int arg) | ||
160 | { | ||
161 | ide_hwif_t *hwif = drive->hwif; | ||
162 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
163 | |||
164 | if (arg < 0 || arg > 255) | ||
165 | return -EINVAL; | ||
166 | |||
167 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || | ||
168 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | ||
169 | return -ENOSYS; | ||
170 | |||
171 | if (set_pio_mode_abuse(drive->hwif, arg)) { | ||
172 | if (arg == 8 || arg == 9) { | ||
173 | unsigned long flags; | ||
174 | |||
175 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ | ||
176 | spin_lock_irqsave(&hwif->lock, flags); | ||
177 | port_ops->set_pio_mode(drive, arg); | ||
178 | spin_unlock_irqrestore(&hwif->lock, flags); | ||
179 | } else | ||
180 | port_ops->set_pio_mode(drive, arg); | ||
181 | } else { | ||
182 | int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | ||
183 | |||
184 | ide_set_pio(drive, arg); | ||
185 | |||
186 | if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) { | ||
187 | if (keep_dma) | ||
188 | ide_dma_on(drive); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK); | ||
196 | |||
197 | static int set_unmaskirq(ide_drive_t *drive, int arg) | ||
198 | { | ||
199 | if (drive->dev_flags & IDE_DFLAG_NO_UNMASK) | ||
200 | return -EPERM; | ||
201 | |||
202 | if (arg < 0 || arg > 1) | ||
203 | return -EINVAL; | ||
204 | |||
205 | if (arg) | ||
206 | drive->dev_flags |= IDE_DFLAG_UNMASK; | ||
207 | else | ||
208 | drive->dev_flags &= ~IDE_DFLAG_UNMASK; | ||
209 | |||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | ide_ext_devset_rw_sync(io_32bit, io_32bit); | ||
214 | ide_ext_devset_rw_sync(keepsettings, ksettings); | ||
215 | ide_ext_devset_rw_sync(unmaskirq, unmaskirq); | ||
216 | ide_ext_devset_rw_sync(using_dma, using_dma); | ||
217 | __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); | ||
218 | |||
219 | /** | 65 | /** |
220 | * ide_device_get - get an additional reference to a ide_drive_t | 66 | * ide_device_get - get an additional reference to a ide_drive_t |
221 | * @drive: device to get a reference to | 67 | * @drive: device to get a reference to |
@@ -527,6 +373,8 @@ static int __init ide_init(void) | |||
527 | goto out_port_class; | 373 | goto out_port_class; |
528 | } | 374 | } |
529 | 375 | ||
376 | ide_acpi_init(); | ||
377 | |||
530 | proc_ide_create(); | 378 | proc_ide_create(); |
531 | 379 | ||
532 | return 0; | 380 | return 0; |
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c index 13b8153112ed..6b9fc950b4af 100644 --- a/drivers/ide/it821x.c +++ b/drivers/ide/it821x.c | |||
@@ -603,7 +603,7 @@ static void it8212_disable_raid(struct pci_dev *dev) | |||
603 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); | 603 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); |
604 | } | 604 | } |
605 | 605 | ||
606 | static unsigned int init_chipset_it821x(struct pci_dev *dev) | 606 | static int init_chipset_it821x(struct pci_dev *dev) |
607 | { | 607 | { |
608 | u8 conf; | 608 | u8 conf; |
609 | static char *mode[2] = { "pass through", "smart" }; | 609 | static char *mode[2] = { "pass through", "smart" }; |
diff --git a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c index 83643ed9a426..ea48a3ee8063 100644 --- a/drivers/ide/ns87415.c +++ b/drivers/ide/ns87415.c | |||
@@ -286,9 +286,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
286 | } | 286 | } |
287 | 287 | ||
288 | if (!using_inta) | 288 | if (!using_inta) |
289 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); | 289 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); |
290 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | ||
291 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ | ||
292 | 290 | ||
293 | if (!hwif->dma_base) | 291 | if (!hwif->dma_base) |
294 | return; | 292 | return; |
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c index f21290c4b447..b68906c3c17e 100644 --- a/drivers/ide/pdc202xx_new.c +++ b/drivers/ide/pdc202xx_new.c | |||
@@ -325,7 +325,7 @@ static void apple_kiwi_init(struct pci_dev *pdev) | |||
325 | } | 325 | } |
326 | #endif /* CONFIG_PPC_PMAC */ | 326 | #endif /* CONFIG_PPC_PMAC */ |
327 | 327 | ||
328 | static unsigned int init_chipset_pdcnew(struct pci_dev *dev) | 328 | static int init_chipset_pdcnew(struct pci_dev *dev) |
329 | { | 329 | { |
330 | const char *name = DRV_NAME; | 330 | const char *name = DRV_NAME; |
331 | unsigned long dma_base = pci_resource_start(dev, 4); | 331 | unsigned long dma_base = pci_resource_start(dev, 4); |
@@ -444,7 +444,7 @@ static unsigned int init_chipset_pdcnew(struct pci_dev *dev) | |||
444 | #endif | 444 | #endif |
445 | 445 | ||
446 | out: | 446 | out: |
447 | return dev->irq; | 447 | return 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | 450 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) |
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c index 97193323aebf..cba66ebce4e3 100644 --- a/drivers/ide/pdc202xx_old.c +++ b/drivers/ide/pdc202xx_old.c | |||
@@ -264,7 +264,7 @@ static void pdc202xx_dma_timeout(ide_drive_t *drive) | |||
264 | ide_dma_timeout(drive); | 264 | ide_dma_timeout(drive); |
265 | } | 265 | } |
266 | 266 | ||
267 | static unsigned int init_chipset_pdc202xx(struct pci_dev *dev) | 267 | static int init_chipset_pdc202xx(struct pci_dev *dev) |
268 | { | 268 | { |
269 | unsigned long dmabase = pci_resource_start(dev, 4); | 269 | unsigned long dmabase = pci_resource_start(dev, 4); |
270 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; | 270 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; |
@@ -290,7 +290,7 @@ static unsigned int init_chipset_pdc202xx(struct pci_dev *dev) | |||
290 | printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); | 290 | printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); |
291 | } | 291 | } |
292 | out: | 292 | out: |
293 | return dev->irq; | 293 | return 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | 296 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, |
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c index f1e2e4ef0d71..2aa699933064 100644 --- a/drivers/ide/piix.c +++ b/drivers/ide/piix.c | |||
@@ -204,7 +204,7 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
204 | * out to be nice and simple. | 204 | * out to be nice and simple. |
205 | */ | 205 | */ |
206 | 206 | ||
207 | static unsigned int init_chipset_ich(struct pci_dev *dev) | 207 | static int init_chipset_ich(struct pci_dev *dev) |
208 | { | 208 | { |
209 | u32 extra = 0; | 209 | u32 extra = 0; |
210 | 210 | ||
@@ -318,19 +318,12 @@ static const struct ide_port_ops ich_port_ops = { | |||
318 | .cable_detect = piix_cable_detect, | 318 | .cable_detect = piix_cable_detect, |
319 | }; | 319 | }; |
320 | 320 | ||
321 | #ifndef CONFIG_IA64 | ||
322 | #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS | ||
323 | #else | ||
324 | #define IDE_HFLAGS_PIIX 0 | ||
325 | #endif | ||
326 | |||
327 | #define DECLARE_PIIX_DEV(udma) \ | 321 | #define DECLARE_PIIX_DEV(udma) \ |
328 | { \ | 322 | { \ |
329 | .name = DRV_NAME, \ | 323 | .name = DRV_NAME, \ |
330 | .init_hwif = init_hwif_piix, \ | 324 | .init_hwif = init_hwif_piix, \ |
331 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 325 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
332 | .port_ops = &piix_port_ops, \ | 326 | .port_ops = &piix_port_ops, \ |
333 | .host_flags = IDE_HFLAGS_PIIX, \ | ||
334 | .pio_mask = ATA_PIO4, \ | 327 | .pio_mask = ATA_PIO4, \ |
335 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 328 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
336 | .mwdma_mask = ATA_MWDMA12_ONLY, \ | 329 | .mwdma_mask = ATA_MWDMA12_ONLY, \ |
@@ -344,7 +337,6 @@ static const struct ide_port_ops ich_port_ops = { | |||
344 | .init_hwif = init_hwif_piix, \ | 337 | .init_hwif = init_hwif_piix, \ |
345 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 338 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
346 | .port_ops = &ich_port_ops, \ | 339 | .port_ops = &ich_port_ops, \ |
347 | .host_flags = IDE_HFLAGS_PIIX, \ | ||
348 | .pio_mask = ATA_PIO4, \ | 340 | .pio_mask = ATA_PIO4, \ |
349 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 341 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
350 | .mwdma_mask = ATA_MWDMA12_ONLY, \ | 342 | .mwdma_mask = ATA_MWDMA12_ONLY, \ |
@@ -360,8 +352,7 @@ static const struct ide_port_info piix_pci_info[] __devinitdata = { | |||
360 | */ | 352 | */ |
361 | .name = DRV_NAME, | 353 | .name = DRV_NAME, |
362 | .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}}, | 354 | .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}}, |
363 | .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA | | 355 | .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA, |
364 | IDE_HFLAGS_PIIX, | ||
365 | .pio_mask = ATA_PIO4, | 356 | .pio_mask = ATA_PIO4, |
366 | /* This is a painful system best to let it self tune for now */ | 357 | /* This is a painful system best to let it self tune for now */ |
367 | }, | 358 | }, |
diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c index 382102ba467b..b6554ef92716 100644 --- a/drivers/ide/serverworks.c +++ b/drivers/ide/serverworks.c | |||
@@ -175,7 +175,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
175 | pci_write_config_byte(dev, 0x54, ultra_enable); | 175 | pci_write_config_byte(dev, 0x54, ultra_enable); |
176 | } | 176 | } |
177 | 177 | ||
178 | static unsigned int init_chipset_svwks(struct pci_dev *dev) | 178 | static int init_chipset_svwks(struct pci_dev *dev) |
179 | { | 179 | { |
180 | unsigned int reg; | 180 | unsigned int reg; |
181 | u8 btr; | 181 | u8 btr; |
@@ -270,7 +270,7 @@ static unsigned int init_chipset_svwks(struct pci_dev *dev) | |||
270 | pci_write_config_byte(dev, 0x5A, btr); | 270 | pci_write_config_byte(dev, 0x5A, btr); |
271 | } | 271 | } |
272 | 272 | ||
273 | return dev->irq; | 273 | return 0; |
274 | } | 274 | } |
275 | 275 | ||
276 | static u8 ata66_svwks_svwks(ide_hwif_t *hwif) | 276 | static u8 ata66_svwks_svwks(ide_hwif_t *hwif) |
@@ -353,14 +353,11 @@ static const struct ide_port_ops svwks_port_ops = { | |||
353 | .cable_detect = svwks_cable_detect, | 353 | .cable_detect = svwks_cable_detect, |
354 | }; | 354 | }; |
355 | 355 | ||
356 | #define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS | ||
357 | |||
358 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | 356 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { |
359 | { /* 0: OSB4 */ | 357 | { /* 0: OSB4 */ |
360 | .name = DRV_NAME, | 358 | .name = DRV_NAME, |
361 | .init_chipset = init_chipset_svwks, | 359 | .init_chipset = init_chipset_svwks, |
362 | .port_ops = &osb4_port_ops, | 360 | .port_ops = &osb4_port_ops, |
363 | .host_flags = IDE_HFLAGS_SVWKS, | ||
364 | .pio_mask = ATA_PIO4, | 361 | .pio_mask = ATA_PIO4, |
365 | .mwdma_mask = ATA_MWDMA2, | 362 | .mwdma_mask = ATA_MWDMA2, |
366 | .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ | 363 | .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ |
@@ -369,7 +366,6 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
369 | .name = DRV_NAME, | 366 | .name = DRV_NAME, |
370 | .init_chipset = init_chipset_svwks, | 367 | .init_chipset = init_chipset_svwks, |
371 | .port_ops = &svwks_port_ops, | 368 | .port_ops = &svwks_port_ops, |
372 | .host_flags = IDE_HFLAGS_SVWKS, | ||
373 | .pio_mask = ATA_PIO4, | 369 | .pio_mask = ATA_PIO4, |
374 | .mwdma_mask = ATA_MWDMA2, | 370 | .mwdma_mask = ATA_MWDMA2, |
375 | .udma_mask = ATA_UDMA5, | 371 | .udma_mask = ATA_UDMA5, |
@@ -378,7 +374,6 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
378 | .name = DRV_NAME, | 374 | .name = DRV_NAME, |
379 | .init_chipset = init_chipset_svwks, | 375 | .init_chipset = init_chipset_svwks, |
380 | .port_ops = &svwks_port_ops, | 376 | .port_ops = &svwks_port_ops, |
381 | .host_flags = IDE_HFLAGS_SVWKS, | ||
382 | .pio_mask = ATA_PIO4, | 377 | .pio_mask = ATA_PIO4, |
383 | .mwdma_mask = ATA_MWDMA2, | 378 | .mwdma_mask = ATA_MWDMA2, |
384 | .udma_mask = ATA_UDMA5, | 379 | .udma_mask = ATA_UDMA5, |
@@ -387,7 +382,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
387 | .name = DRV_NAME, | 382 | .name = DRV_NAME, |
388 | .init_chipset = init_chipset_svwks, | 383 | .init_chipset = init_chipset_svwks, |
389 | .port_ops = &svwks_port_ops, | 384 | .port_ops = &svwks_port_ops, |
390 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 385 | .host_flags = IDE_HFLAG_SINGLE, |
391 | .pio_mask = ATA_PIO4, | 386 | .pio_mask = ATA_PIO4, |
392 | .mwdma_mask = ATA_MWDMA2, | 387 | .mwdma_mask = ATA_MWDMA2, |
393 | .udma_mask = ATA_UDMA5, | 388 | .udma_mask = ATA_UDMA5, |
@@ -396,7 +391,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
396 | .name = DRV_NAME, | 391 | .name = DRV_NAME, |
397 | .init_chipset = init_chipset_svwks, | 392 | .init_chipset = init_chipset_svwks, |
398 | .port_ops = &svwks_port_ops, | 393 | .port_ops = &svwks_port_ops, |
399 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 394 | .host_flags = IDE_HFLAG_SINGLE, |
400 | .pio_mask = ATA_PIO4, | 395 | .pio_mask = ATA_PIO4, |
401 | .mwdma_mask = ATA_MWDMA2, | 396 | .mwdma_mask = ATA_MWDMA2, |
402 | .udma_mask = ATA_UDMA5, | 397 | .udma_mask = ATA_UDMA5, |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index e85d1ed29c2a..24bc884826fc 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -305,7 +305,6 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
305 | * @dev: PCI device holding interface | 305 | * @dev: PCI device holding interface |
306 | * @d: IDE port info | 306 | * @d: IDE port info |
307 | * @port: port number | 307 | * @port: port number |
308 | * @irq: PCI IRQ | ||
309 | * @hw: hw_regs_t instance corresponding to this port | 308 | * @hw: hw_regs_t instance corresponding to this port |
310 | * | 309 | * |
311 | * Perform the initial set up for the hardware interface structure. This | 310 | * Perform the initial set up for the hardware interface structure. This |
@@ -316,7 +315,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
316 | */ | 315 | */ |
317 | 316 | ||
318 | static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, | 317 | static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, |
319 | unsigned int port, int irq, hw_regs_t *hw) | 318 | unsigned int port, hw_regs_t *hw) |
320 | { | 319 | { |
321 | unsigned long ctl = 0, base = 0; | 320 | unsigned long ctl = 0, base = 0; |
322 | 321 | ||
@@ -344,7 +343,6 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, | |||
344 | } | 343 | } |
345 | 344 | ||
346 | memset(hw, 0, sizeof(*hw)); | 345 | memset(hw, 0, sizeof(*hw)); |
347 | hw->irq = irq; | ||
348 | hw->dev = &dev->dev; | 346 | hw->dev = &dev->dev; |
349 | hw->chipset = d->chipset ? d->chipset : ide_pci; | 347 | hw->chipset = d->chipset ? d->chipset : ide_pci; |
350 | ide_std_init_ports(hw, base, ctl | 2); | 348 | ide_std_init_ports(hw, base, ctl | 2); |
@@ -448,7 +446,6 @@ out: | |||
448 | * ide_pci_setup_ports - configure ports/devices on PCI IDE | 446 | * ide_pci_setup_ports - configure ports/devices on PCI IDE |
449 | * @dev: PCI device | 447 | * @dev: PCI device |
450 | * @d: IDE port info | 448 | * @d: IDE port info |
451 | * @pciirq: IRQ line | ||
452 | * @hw: hw_regs_t instances corresponding to this PCI IDE device | 449 | * @hw: hw_regs_t instances corresponding to this PCI IDE device |
453 | * @hws: hw_regs_t pointers table to update | 450 | * @hws: hw_regs_t pointers table to update |
454 | * | 451 | * |
@@ -462,7 +459,7 @@ out: | |||
462 | */ | 459 | */ |
463 | 460 | ||
464 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | 461 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, |
465 | int pciirq, hw_regs_t *hw, hw_regs_t **hws) | 462 | hw_regs_t *hw, hw_regs_t **hws) |
466 | { | 463 | { |
467 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 464 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
468 | u8 tmp; | 465 | u8 tmp; |
@@ -481,7 +478,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | |||
481 | continue; /* port not enabled */ | 478 | continue; /* port not enabled */ |
482 | } | 479 | } |
483 | 480 | ||
484 | if (ide_hw_configure(dev, d, port, pciirq, hw + port)) | 481 | if (ide_hw_configure(dev, d, port, hw + port)) |
485 | continue; | 482 | continue; |
486 | 483 | ||
487 | *(hws + port) = hw + port; | 484 | *(hws + port) = hw + port; |
@@ -524,7 +521,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, | |||
524 | if (noisy) | 521 | if (noisy) |
525 | printk(KERN_INFO "%s %s: not 100%% native mode: will " | 522 | printk(KERN_INFO "%s %s: not 100%% native mode: will " |
526 | "probe irqs later\n", d->name, pci_name(dev)); | 523 | "probe irqs later\n", d->name, pci_name(dev)); |
527 | pciirq = ret; | 524 | pciirq = 0; |
528 | } else if (!pciirq && noisy) { | 525 | } else if (!pciirq && noisy) { |
529 | printk(KERN_WARNING "%s %s: bad irq (%d): will probe later\n", | 526 | printk(KERN_WARNING "%s %s: bad irq (%d): will probe later\n", |
530 | d->name, pci_name(dev), pciirq); | 527 | d->name, pci_name(dev), pciirq); |
@@ -549,7 +546,7 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | |||
549 | if (ret < 0) | 546 | if (ret < 0) |
550 | goto out; | 547 | goto out; |
551 | 548 | ||
552 | ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]); | 549 | ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); |
553 | 550 | ||
554 | host = ide_host_alloc(d, hws); | 551 | host = ide_host_alloc(d, hws); |
555 | if (host == NULL) { | 552 | if (host == NULL) { |
@@ -568,7 +565,11 @@ int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | |||
568 | goto out; | 565 | goto out; |
569 | 566 | ||
570 | /* fixup IRQ */ | 567 | /* fixup IRQ */ |
571 | hw[1].irq = hw[0].irq = ret; | 568 | if (ide_pci_is_in_compatibility_mode(dev)) { |
569 | hw[0].irq = pci_get_legacy_ide_irq(dev, 0); | ||
570 | hw[1].irq = pci_get_legacy_ide_irq(dev, 1); | ||
571 | } else | ||
572 | hw[1].irq = hw[0].irq = ret; | ||
572 | 573 | ||
573 | ret = ide_host_register(host, d, hws); | 574 | ret = ide_host_register(host, d, hws); |
574 | if (ret) | 575 | if (ret) |
@@ -591,7 +592,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | |||
591 | if (ret < 0) | 592 | if (ret < 0) |
592 | goto out; | 593 | goto out; |
593 | 594 | ||
594 | ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]); | 595 | ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]); |
595 | } | 596 | } |
596 | 597 | ||
597 | host = ide_host_alloc(d, hws); | 598 | host = ide_host_alloc(d, hws); |
@@ -619,7 +620,11 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | |||
619 | goto out; | 620 | goto out; |
620 | 621 | ||
621 | /* fixup IRQ */ | 622 | /* fixup IRQ */ |
622 | hw[i*2 + 1].irq = hw[i*2].irq = ret; | 623 | if (ide_pci_is_in_compatibility_mode(pdev[i])) { |
624 | hw[i*2].irq = pci_get_legacy_ide_irq(pdev[i], 0); | ||
625 | hw[i*2 + 1].irq = pci_get_legacy_ide_irq(pdev[i], 1); | ||
626 | } else | ||
627 | hw[i*2 + 1].irq = hw[i*2].irq = ret; | ||
623 | } | 628 | } |
624 | 629 | ||
625 | ret = ide_host_register(host, d, hws); | 630 | ret = ide_host_register(host, d, hws); |
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c index cb2b352b876b..1811ae9cd843 100644 --- a/drivers/ide/siimage.c +++ b/drivers/ide/siimage.c | |||
@@ -464,7 +464,7 @@ static void sil_sata_pre_reset(ide_drive_t *drive) | |||
464 | * to 133 MHz clocking if the system isn't already set up to do it. | 464 | * to 133 MHz clocking if the system isn't already set up to do it. |
465 | */ | 465 | */ |
466 | 466 | ||
467 | static unsigned int init_chipset_siimage(struct pci_dev *dev) | 467 | static int init_chipset_siimage(struct pci_dev *dev) |
468 | { | 468 | { |
469 | struct ide_host *host = pci_get_drvdata(dev); | 469 | struct ide_host *host = pci_get_drvdata(dev); |
470 | void __iomem *ioaddr = host->host_priv; | 470 | void __iomem *ioaddr = host->host_priv; |
diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c index 9ec1a4a4432c..afca22beaadf 100644 --- a/drivers/ide/sis5513.c +++ b/drivers/ide/sis5513.c | |||
@@ -447,7 +447,7 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
447 | return chipset_family; | 447 | return chipset_family; |
448 | } | 448 | } |
449 | 449 | ||
450 | static unsigned int init_chipset_sis5513(struct pci_dev *dev) | 450 | static int init_chipset_sis5513(struct pci_dev *dev) |
451 | { | 451 | { |
452 | /* Make general config ops here | 452 | /* Make general config ops here |
453 | 1/ tell IDE channels to operate in Compatibility mode only | 453 | 1/ tell IDE channels to operate in Compatibility mode only |
@@ -563,7 +563,7 @@ static const struct ide_port_info sis5513_chipset __devinitdata = { | |||
563 | .name = DRV_NAME, | 563 | .name = DRV_NAME, |
564 | .init_chipset = init_chipset_sis5513, | 564 | .init_chipset = init_chipset_sis5513, |
565 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, | 565 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, |
566 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, | 566 | .host_flags = IDE_HFLAG_NO_AUTODMA, |
567 | .pio_mask = ATA_PIO4, | 567 | .pio_mask = ATA_PIO4, |
568 | .mwdma_mask = ATA_MWDMA2, | 568 | .mwdma_mask = ATA_MWDMA2, |
569 | }; | 569 | }; |
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c index 6297956507c0..dba213c51baa 100644 --- a/drivers/ide/sl82c105.c +++ b/drivers/ide/sl82c105.c | |||
@@ -271,7 +271,7 @@ static u8 sl82c105_bridge_revision(struct pci_dev *dev) | |||
271 | * channel 0 here at least, but channel 1 has to be enabled by | 271 | * channel 0 here at least, but channel 1 has to be enabled by |
272 | * firmware or arch code. We still set both to 16 bits mode. | 272 | * firmware or arch code. We still set both to 16 bits mode. |
273 | */ | 273 | */ |
274 | static unsigned int init_chipset_sl82c105(struct pci_dev *dev) | 274 | static int init_chipset_sl82c105(struct pci_dev *dev) |
275 | { | 275 | { |
276 | u32 val; | 276 | u32 val; |
277 | 277 | ||
@@ -281,7 +281,7 @@ static unsigned int init_chipset_sl82c105(struct pci_dev *dev) | |||
281 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; | 281 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; |
282 | pci_write_config_dword(dev, 0x40, val); | 282 | pci_write_config_dword(dev, 0x40, val); |
283 | 283 | ||
284 | return dev->irq; | 284 | return 0; |
285 | } | 285 | } |
286 | 286 | ||
287 | static const struct ide_port_ops sl82c105_port_ops = { | 287 | static const struct ide_port_ops sl82c105_port_ops = { |
diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c index 40b4b94a4288..f55d7d6313e8 100644 --- a/drivers/ide/slc90e66.c +++ b/drivers/ide/slc90e66.c | |||
@@ -136,7 +136,6 @@ static const struct ide_port_info slc90e66_chipset __devinitdata = { | |||
136 | .name = DRV_NAME, | 136 | .name = DRV_NAME, |
137 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, | 137 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, |
138 | .port_ops = &slc90e66_port_ops, | 138 | .port_ops = &slc90e66_port_ops, |
139 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | ||
140 | .pio_mask = ATA_PIO4, | 139 | .pio_mask = ATA_PIO4, |
141 | .swdma_mask = ATA_SWDMA2_ONLY, | 140 | .swdma_mask = ATA_SWDMA2_ONLY, |
142 | .mwdma_mask = ATA_MWDMA12_ONLY, | 141 | .mwdma_mask = ATA_MWDMA12_ONLY, |
diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c index b6a1285a4021..1c09e549c423 100644 --- a/drivers/ide/trm290.c +++ b/drivers/ide/trm290.c | |||
@@ -277,9 +277,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
277 | if (reg & 0x10) | 277 | if (reg & 0x10) |
278 | /* legacy mode */ | 278 | /* legacy mode */ |
279 | hwif->irq = hwif->channel ? 15 : 14; | 279 | hwif->irq = hwif->channel ? 15 : 14; |
280 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | ||
281 | /* sharing IRQ with mate */ | ||
282 | hwif->irq = hwif->mate->irq; | ||
283 | 280 | ||
284 | #if 1 | 281 | #if 1 |
285 | { | 282 | { |
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c index 6092fe3f409d..3ff7231e4858 100644 --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c | |||
@@ -267,7 +267,7 @@ static void via_cable_detect(struct via82cxxx_dev *vdev, u32 u) | |||
267 | * and initialize its drive independent registers. | 267 | * and initialize its drive independent registers. |
268 | */ | 268 | */ |
269 | 269 | ||
270 | static unsigned int init_chipset_via82cxxx(struct pci_dev *dev) | 270 | static int init_chipset_via82cxxx(struct pci_dev *dev) |
271 | { | 271 | { |
272 | struct ide_host *host = pci_get_drvdata(dev); | 272 | struct ide_host *host = pci_get_drvdata(dev); |
273 | struct via82cxxx_dev *vdev = host->host_priv; | 273 | struct via82cxxx_dev *vdev = host->host_priv; |
@@ -443,16 +443,6 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
443 | if ((via_config->flags & VIA_NO_UNMASK) == 0) | 443 | if ((via_config->flags & VIA_NO_UNMASK) == 0) |
444 | d.host_flags |= IDE_HFLAG_UNMASK_IRQS; | 444 | d.host_flags |= IDE_HFLAG_UNMASK_IRQS; |
445 | 445 | ||
446 | #ifdef CONFIG_PPC_CHRP | ||
447 | if (machine_is(chrp) && _chrp_type == _CHRP_Pegasos) | ||
448 | d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS; | ||
449 | #endif | ||
450 | |||
451 | #ifdef CONFIG_AMIGAONE | ||
452 | if (machine_is(amigaone)) | ||
453 | d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS; | ||
454 | #endif | ||
455 | |||
456 | d.udma_mask = via_config->udma_mask; | 446 | d.udma_mask = via_config->udma_mask; |
457 | 447 | ||
458 | vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); | 448 | vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); |