diff options
Diffstat (limited to 'drivers/ide')
54 files changed, 857 insertions, 1415 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index cf06494bb744..9a5d0aaac9d0 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -46,7 +46,7 @@ menuconfig IDE | |||
46 | SMART parameters from disk drives. | 46 | SMART parameters from disk drives. |
47 | 47 | ||
48 | To compile this driver as a module, choose M here: the | 48 | To compile this driver as a module, choose M here: the |
49 | module will be called ide-core.ko. | 49 | module will be called ide-core. |
50 | 50 | ||
51 | For further information, please read <file:Documentation/ide/ide.txt>. | 51 | For further information, please read <file:Documentation/ide/ide.txt>. |
52 | 52 | ||
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index 537da1cde16d..e59b6dee9ae2 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c | |||
@@ -402,27 +402,23 @@ static u8 ali_cable_detect(ide_hwif_t *hwif) | |||
402 | return cbl; | 402 | return cbl; |
403 | } | 403 | } |
404 | 404 | ||
405 | #if !defined(CONFIG_SPARC64) && !defined(CONFIG_PPC) | 405 | #ifndef CONFIG_SPARC64 |
406 | /** | 406 | /** |
407 | * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff | 407 | * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff |
408 | * @hwif: interface to configure | 408 | * @hwif: interface to configure |
409 | * | 409 | * |
410 | * Obtain the IRQ tables for an ALi based IDE solution on the PC | 410 | * Obtain the IRQ tables for an ALi based IDE solution on the PC |
411 | * class platforms. This part of the code isn't applicable to the | 411 | * class platforms. This part of the code isn't applicable to the |
412 | * Sparc and PowerPC systems. | 412 | * Sparc systems. |
413 | */ | 413 | */ |
414 | 414 | ||
415 | static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) | 415 | static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) |
416 | { | 416 | { |
417 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
418 | u8 ideic, inmir; | 417 | u8 ideic, inmir; |
419 | s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, | 418 | s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, |
420 | 1, 11, 0, 12, 0, 14, 0, 15 }; | 419 | 1, 11, 0, 12, 0, 14, 0, 15 }; |
421 | int irq = -1; | 420 | int irq = -1; |
422 | 421 | ||
423 | if (dev->device == PCI_DEVICE_ID_AL_M5229) | ||
424 | hwif->irq = hwif->channel ? 15 : 14; | ||
425 | |||
426 | if (isa_dev) { | 422 | if (isa_dev) { |
427 | /* | 423 | /* |
428 | * read IDE interface control | 424 | * read IDE interface control |
@@ -455,7 +451,7 @@ static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) | |||
455 | } | 451 | } |
456 | #else | 452 | #else |
457 | #define init_hwif_ali15x3 NULL | 453 | #define init_hwif_ali15x3 NULL |
458 | #endif /* !defined(CONFIG_SPARC64) && !defined(CONFIG_PPC) */ | 454 | #endif /* CONFIG_SPARC64 */ |
459 | 455 | ||
460 | /** | 456 | /** |
461 | * init_dma_ali15x3 - set up DMA on ALi15x3 | 457 | * init_dma_ali15x3 - set up DMA on ALi15x3 |
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c index 403d0e4265db..fc0949a8cfde 100644 --- a/drivers/ide/at91_ide.c +++ b/drivers/ide/at91_ide.c | |||
@@ -216,6 +216,7 @@ static const struct ide_port_info at91_ide_port_info __initdata = { | |||
216 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE | | 216 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE | |
217 | IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS, | 217 | IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS, |
218 | .pio_mask = ATA_PIO6, | 218 | .pio_mask = ATA_PIO6, |
219 | .chipset = ide_generic, | ||
219 | }; | 220 | }; |
220 | 221 | ||
221 | /* | 222 | /* |
@@ -246,8 +247,7 @@ irqreturn_t at91_irq_handler(int irq, void *dev_id) | |||
246 | static int __init at91_ide_probe(struct platform_device *pdev) | 247 | static int __init at91_ide_probe(struct platform_device *pdev) |
247 | { | 248 | { |
248 | int ret; | 249 | int ret; |
249 | hw_regs_t hw; | 250 | struct ide_hw hw, *hws[] = { &hw }; |
250 | hw_regs_t *hws[] = { &hw, NULL, NULL, NULL }; | ||
251 | struct ide_host *host; | 251 | struct ide_host *host; |
252 | struct resource *res; | 252 | struct resource *res; |
253 | unsigned long tf_base = 0, ctl_base = 0; | 253 | unsigned long tf_base = 0, ctl_base = 0; |
@@ -304,10 +304,9 @@ static int __init at91_ide_probe(struct platform_device *pdev) | |||
304 | ide_std_init_ports(&hw, tf_base, ctl_base + 6); | 304 | ide_std_init_ports(&hw, tf_base, ctl_base + 6); |
305 | 305 | ||
306 | hw.irq = board->irq_pin; | 306 | hw.irq = board->irq_pin; |
307 | hw.chipset = ide_generic; | ||
308 | hw.dev = &pdev->dev; | 307 | hw.dev = &pdev->dev; |
309 | 308 | ||
310 | host = ide_host_alloc(&at91_ide_port_info, hws); | 309 | host = ide_host_alloc(&at91_ide_port_info, hws, 1); |
311 | if (!host) { | 310 | if (!host) { |
312 | perr("failed to allocate ide host\n"); | 311 | perr("failed to allocate ide host\n"); |
313 | return -ENOMEM; | 312 | return -ENOMEM; |
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c index 46013644c965..58121bd6c115 100644 --- a/drivers/ide/au1xxx-ide.c +++ b/drivers/ide/au1xxx-ide.c | |||
@@ -449,7 +449,7 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
449 | } | 449 | } |
450 | #endif | 450 | #endif |
451 | 451 | ||
452 | static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) | 452 | static void auide_setup_ports(struct ide_hw *hw, _auide_hwif *ahwif) |
453 | { | 453 | { |
454 | int i; | 454 | int i; |
455 | unsigned long *ata_regs = hw->io_ports_array; | 455 | unsigned long *ata_regs = hw->io_ports_array; |
@@ -499,6 +499,7 @@ static const struct ide_port_info au1xxx_port_info = { | |||
499 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 499 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
500 | .mwdma_mask = ATA_MWDMA2, | 500 | .mwdma_mask = ATA_MWDMA2, |
501 | #endif | 501 | #endif |
502 | .chipset = ide_au1xxx, | ||
502 | }; | 503 | }; |
503 | 504 | ||
504 | static int au_ide_probe(struct platform_device *dev) | 505 | static int au_ide_probe(struct platform_device *dev) |
@@ -507,7 +508,7 @@ static int au_ide_probe(struct platform_device *dev) | |||
507 | struct resource *res; | 508 | struct resource *res; |
508 | struct ide_host *host; | 509 | struct ide_host *host; |
509 | int ret = 0; | 510 | int ret = 0; |
510 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 511 | struct ide_hw hw, *hws[] = { &hw }; |
511 | 512 | ||
512 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) | 513 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) |
513 | char *mode = "MWDMA2"; | 514 | char *mode = "MWDMA2"; |
@@ -548,9 +549,8 @@ static int au_ide_probe(struct platform_device *dev) | |||
548 | auide_setup_ports(&hw, ahwif); | 549 | auide_setup_ports(&hw, ahwif); |
549 | hw.irq = ahwif->irq; | 550 | hw.irq = ahwif->irq; |
550 | hw.dev = &dev->dev; | 551 | hw.dev = &dev->dev; |
551 | hw.chipset = ide_au1xxx; | ||
552 | 552 | ||
553 | ret = ide_host_add(&au1xxx_port_info, hws, &host); | 553 | ret = ide_host_add(&au1xxx_port_info, hws, 1, &host); |
554 | if (ret) | 554 | if (ret) |
555 | goto out; | 555 | goto out; |
556 | 556 | ||
diff --git a/drivers/ide/buddha.c b/drivers/ide/buddha.c index d028f8864bc1..e3c6a5913305 100644 --- a/drivers/ide/buddha.c +++ b/drivers/ide/buddha.c | |||
@@ -121,7 +121,7 @@ static int xsurf_ack_intr(ide_hwif_t *hwif) | |||
121 | return 1; | 121 | return 1; |
122 | } | 122 | } |
123 | 123 | ||
124 | static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, | 124 | static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base, |
125 | unsigned long ctl, unsigned long irq_port, | 125 | unsigned long ctl, unsigned long irq_port, |
126 | ide_ack_intr_t *ack_intr) | 126 | ide_ack_intr_t *ack_intr) |
127 | { | 127 | { |
@@ -139,13 +139,12 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, | |||
139 | 139 | ||
140 | hw->irq = IRQ_AMIGA_PORTS; | 140 | hw->irq = IRQ_AMIGA_PORTS; |
141 | hw->ack_intr = ack_intr; | 141 | hw->ack_intr = ack_intr; |
142 | |||
143 | hw->chipset = ide_generic; | ||
144 | } | 142 | } |
145 | 143 | ||
146 | static const struct ide_port_info buddha_port_info = { | 144 | static const struct ide_port_info buddha_port_info = { |
147 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, | 145 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, |
148 | .irq_flags = IRQF_SHARED, | 146 | .irq_flags = IRQF_SHARED, |
147 | .chipset = ide_generic, | ||
149 | }; | 148 | }; |
150 | 149 | ||
151 | /* | 150 | /* |
@@ -161,7 +160,7 @@ static int __init buddha_init(void) | |||
161 | 160 | ||
162 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { | 161 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { |
163 | unsigned long board; | 162 | unsigned long board; |
164 | hw_regs_t hw[MAX_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; | 163 | struct ide_hw hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS]; |
165 | 164 | ||
166 | if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { | 165 | if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { |
167 | buddha_num_hwifs = BUDDHA_NUM_HWIFS; | 166 | buddha_num_hwifs = BUDDHA_NUM_HWIFS; |
@@ -225,7 +224,7 @@ fail_base2: | |||
225 | hws[i] = &hw[i]; | 224 | hws[i] = &hw[i]; |
226 | } | 225 | } |
227 | 226 | ||
228 | ide_host_add(&buddha_port_info, hws, NULL); | 227 | ide_host_add(&buddha_port_info, hws, i, NULL); |
229 | } | 228 | } |
230 | 229 | ||
231 | return 0; | 230 | return 0; |
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c index 8890276fef7f..1683ed5c7329 100644 --- a/drivers/ide/cmd640.c +++ b/drivers/ide/cmd640.c | |||
@@ -708,7 +708,7 @@ static int __init cmd640x_init(void) | |||
708 | int second_port_cmd640 = 0, rc; | 708 | int second_port_cmd640 = 0, rc; |
709 | const char *bus_type, *port2; | 709 | const char *bus_type, *port2; |
710 | u8 b, cfr; | 710 | u8 b, cfr; |
711 | hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; | 711 | struct ide_hw hw[2], *hws[2]; |
712 | 712 | ||
713 | if (cmd640_vlb && probe_for_cmd640_vlb()) { | 713 | if (cmd640_vlb && probe_for_cmd640_vlb()) { |
714 | bus_type = "VLB"; | 714 | bus_type = "VLB"; |
@@ -762,11 +762,9 @@ static int __init cmd640x_init(void) | |||
762 | 762 | ||
763 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | 763 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); |
764 | hw[0].irq = 14; | 764 | hw[0].irq = 14; |
765 | hw[0].chipset = ide_cmd640; | ||
766 | 765 | ||
767 | ide_std_init_ports(&hw[1], 0x170, 0x376); | 766 | ide_std_init_ports(&hw[1], 0x170, 0x376); |
768 | hw[1].irq = 15; | 767 | hw[1].irq = 15; |
769 | hw[1].chipset = ide_cmd640; | ||
770 | 768 | ||
771 | printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" | 769 | printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x" |
772 | "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); | 770 | "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr); |
@@ -824,7 +822,8 @@ static int __init cmd640x_init(void) | |||
824 | cmd640_dump_regs(); | 822 | cmd640_dump_regs(); |
825 | #endif | 823 | #endif |
826 | 824 | ||
827 | return ide_host_add(&cmd640_port_info, hws, NULL); | 825 | return ide_host_add(&cmd640_port_info, hws, second_port_cmd640 ? 2 : 1, |
826 | NULL); | ||
828 | } | 827 | } |
829 | 828 | ||
830 | module_param_named(probe_vlb, cmd640_vlb, bool, 0); | 829 | module_param_named(probe_vlb, cmd640_vlb, bool, 0); |
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c index 87987a7d36c9..bd066bb9d611 100644 --- a/drivers/ide/cs5520.c +++ b/drivers/ide/cs5520.c | |||
@@ -110,7 +110,7 @@ static const struct ide_port_info cyrix_chipset __devinitdata = { | |||
110 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 110 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
111 | { | 111 | { |
112 | const struct ide_port_info *d = &cyrix_chipset; | 112 | const struct ide_port_info *d = &cyrix_chipset; |
113 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 113 | struct ide_hw hw[2], *hws[] = { NULL, NULL }; |
114 | 114 | ||
115 | ide_setup_pci_noise(dev, d); | 115 | ide_setup_pci_noise(dev, d); |
116 | 116 | ||
@@ -136,7 +136,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic | |||
136 | ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); | 136 | ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); |
137 | hw[0].irq = 14; | 137 | hw[0].irq = 14; |
138 | 138 | ||
139 | return ide_host_add(d, hws, NULL); | 139 | return ide_host_add(d, hws, 2, NULL); |
140 | } | 140 | } |
141 | 141 | ||
142 | static const struct pci_device_id cs5520_pci_tbl[] = { | 142 | static const struct pci_device_id cs5520_pci_tbl[] = { |
diff --git a/drivers/ide/delkin_cb.c b/drivers/ide/delkin_cb.c index f153b95619bb..1e10eba62ceb 100644 --- a/drivers/ide/delkin_cb.c +++ b/drivers/ide/delkin_cb.c | |||
@@ -68,6 +68,7 @@ static const struct ide_port_info delkin_cb_port_info = { | |||
68 | IDE_HFLAG_NO_DMA, | 68 | IDE_HFLAG_NO_DMA, |
69 | .irq_flags = IRQF_SHARED, | 69 | .irq_flags = IRQF_SHARED, |
70 | .init_chipset = delkin_cb_init_chipset, | 70 | .init_chipset = delkin_cb_init_chipset, |
71 | .chipset = ide_pci, | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | static int __devinit | 74 | static int __devinit |
@@ -76,7 +77,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
76 | struct ide_host *host; | 77 | struct ide_host *host; |
77 | unsigned long base; | 78 | unsigned long base; |
78 | int rc; | 79 | int rc; |
79 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 80 | struct ide_hw hw, *hws[] = { &hw }; |
80 | 81 | ||
81 | rc = pci_enable_device(dev); | 82 | rc = pci_enable_device(dev); |
82 | if (rc) { | 83 | if (rc) { |
@@ -97,9 +98,8 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
97 | ide_std_init_ports(&hw, base + 0x10, base + 0x1e); | 98 | ide_std_init_ports(&hw, base + 0x10, base + 0x1e); |
98 | hw.irq = dev->irq; | 99 | hw.irq = dev->irq; |
99 | hw.dev = &dev->dev; | 100 | hw.dev = &dev->dev; |
100 | hw.chipset = ide_pci; /* this enables IRQ sharing */ | ||
101 | 101 | ||
102 | rc = ide_host_add(&delkin_cb_port_info, hws, &host); | 102 | rc = ide_host_add(&delkin_cb_port_info, hws, 1, &host); |
103 | if (rc) | 103 | if (rc) |
104 | goto out_disable; | 104 | goto out_disable; |
105 | 105 | ||
diff --git a/drivers/ide/falconide.c b/drivers/ide/falconide.c index 0e2df6755ec9..22fa27389c3b 100644 --- a/drivers/ide/falconide.c +++ b/drivers/ide/falconide.c | |||
@@ -111,9 +111,10 @@ static const struct ide_port_info falconide_port_info = { | |||
111 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | | 111 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | |
112 | IDE_HFLAG_NO_DMA, | 112 | IDE_HFLAG_NO_DMA, |
113 | .irq_flags = IRQF_SHARED, | 113 | .irq_flags = IRQF_SHARED, |
114 | .chipset = ide_generic, | ||
114 | }; | 115 | }; |
115 | 116 | ||
116 | static void __init falconide_setup_ports(hw_regs_t *hw) | 117 | static void __init falconide_setup_ports(struct ide_hw *hw) |
117 | { | 118 | { |
118 | int i; | 119 | int i; |
119 | 120 | ||
@@ -128,8 +129,6 @@ static void __init falconide_setup_ports(hw_regs_t *hw) | |||
128 | 129 | ||
129 | hw->irq = IRQ_MFP_IDE; | 130 | hw->irq = IRQ_MFP_IDE; |
130 | hw->ack_intr = NULL; | 131 | hw->ack_intr = NULL; |
131 | |||
132 | hw->chipset = ide_generic; | ||
133 | } | 132 | } |
134 | 133 | ||
135 | /* | 134 | /* |
@@ -139,7 +138,7 @@ static void __init falconide_setup_ports(hw_regs_t *hw) | |||
139 | static int __init falconide_init(void) | 138 | static int __init falconide_init(void) |
140 | { | 139 | { |
141 | struct ide_host *host; | 140 | struct ide_host *host; |
142 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 141 | struct ide_hw hw, *hws[] = { &hw }; |
143 | int rc; | 142 | int rc; |
144 | 143 | ||
145 | if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) | 144 | if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) |
@@ -154,7 +153,7 @@ static int __init falconide_init(void) | |||
154 | 153 | ||
155 | falconide_setup_ports(&hw); | 154 | falconide_setup_ports(&hw); |
156 | 155 | ||
157 | host = ide_host_alloc(&falconide_port_info, hws); | 156 | host = ide_host_alloc(&falconide_port_info, hws, 1); |
158 | if (host == NULL) { | 157 | if (host == NULL) { |
159 | rc = -ENOMEM; | 158 | rc = -ENOMEM; |
160 | goto err; | 159 | goto err; |
diff --git a/drivers/ide/gayle.c b/drivers/ide/gayle.c index c7119516c5a7..4451a6a5dfe0 100644 --- a/drivers/ide/gayle.c +++ b/drivers/ide/gayle.c | |||
@@ -88,7 +88,7 @@ static int gayle_ack_intr_a1200(ide_hwif_t *hwif) | |||
88 | return 1; | 88 | return 1; |
89 | } | 89 | } |
90 | 90 | ||
91 | static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, | 91 | static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base, |
92 | unsigned long ctl, unsigned long irq_port, | 92 | unsigned long ctl, unsigned long irq_port, |
93 | ide_ack_intr_t *ack_intr) | 93 | ide_ack_intr_t *ack_intr) |
94 | { | 94 | { |
@@ -106,14 +106,13 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, | |||
106 | 106 | ||
107 | hw->irq = IRQ_AMIGA_PORTS; | 107 | hw->irq = IRQ_AMIGA_PORTS; |
108 | hw->ack_intr = ack_intr; | 108 | hw->ack_intr = ack_intr; |
109 | |||
110 | hw->chipset = ide_generic; | ||
111 | } | 109 | } |
112 | 110 | ||
113 | static const struct ide_port_info gayle_port_info = { | 111 | static const struct ide_port_info gayle_port_info = { |
114 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | | 112 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | |
115 | IDE_HFLAG_NO_DMA, | 113 | IDE_HFLAG_NO_DMA, |
116 | .irq_flags = IRQF_SHARED, | 114 | .irq_flags = IRQF_SHARED, |
115 | .chipset = ide_generic, | ||
117 | }; | 116 | }; |
118 | 117 | ||
119 | /* | 118 | /* |
@@ -126,7 +125,7 @@ static int __init gayle_init(void) | |||
126 | unsigned long base, ctrlport, irqport; | 125 | unsigned long base, ctrlport, irqport; |
127 | ide_ack_intr_t *ack_intr; | 126 | ide_ack_intr_t *ack_intr; |
128 | int a4000, i, rc; | 127 | int a4000, i, rc; |
129 | hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; | 128 | struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS]; |
130 | 129 | ||
131 | if (!MACH_IS_AMIGA) | 130 | if (!MACH_IS_AMIGA) |
132 | return -ENODEV; | 131 | return -ENODEV; |
@@ -171,7 +170,7 @@ found: | |||
171 | hws[i] = &hw[i]; | 170 | hws[i] = &hw[i]; |
172 | } | 171 | } |
173 | 172 | ||
174 | rc = ide_host_add(&gayle_port_info, hws, NULL); | 173 | rc = ide_host_add(&gayle_port_info, hws, i, NULL); |
175 | if (rc) | 174 | if (rc) |
176 | release_mem_region(res_start, res_n); | 175 | release_mem_region(res_start, res_n); |
177 | 176 | ||
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index 0feb66c720e1..7ce68ef6b904 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c | |||
@@ -138,14 +138,6 @@ | |||
138 | #undef HPT_RESET_STATE_ENGINE | 138 | #undef HPT_RESET_STATE_ENGINE |
139 | #undef HPT_DELAY_INTERRUPT | 139 | #undef HPT_DELAY_INTERRUPT |
140 | 140 | ||
141 | static const char *quirk_drives[] = { | ||
142 | "QUANTUM FIREBALLlct08 08", | ||
143 | "QUANTUM FIREBALLP KA6.4", | ||
144 | "QUANTUM FIREBALLP LM20.4", | ||
145 | "QUANTUM FIREBALLP LM20.5", | ||
146 | NULL | ||
147 | }; | ||
148 | |||
149 | static const char *bad_ata100_5[] = { | 141 | static const char *bad_ata100_5[] = { |
150 | "IBM-DTLA-307075", | 142 | "IBM-DTLA-307075", |
151 | "IBM-DTLA-307060", | 143 | "IBM-DTLA-307060", |
@@ -729,27 +721,13 @@ static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
729 | hpt3xx_set_mode(drive, XFER_PIO_0 + pio); | 721 | hpt3xx_set_mode(drive, XFER_PIO_0 + pio); |
730 | } | 722 | } |
731 | 723 | ||
732 | static void hpt3xx_quirkproc(ide_drive_t *drive) | ||
733 | { | ||
734 | char *m = (char *)&drive->id[ATA_ID_PROD]; | ||
735 | const char **list = quirk_drives; | ||
736 | |||
737 | while (*list) | ||
738 | if (strstr(m, *list++)) { | ||
739 | drive->quirk_list = 1; | ||
740 | return; | ||
741 | } | ||
742 | |||
743 | drive->quirk_list = 0; | ||
744 | } | ||
745 | |||
746 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | 724 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) |
747 | { | 725 | { |
748 | ide_hwif_t *hwif = drive->hwif; | 726 | ide_hwif_t *hwif = drive->hwif; |
749 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 727 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
750 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); | 728 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); |
751 | 729 | ||
752 | if (drive->quirk_list == 0) | 730 | if ((drive->dev_flags & IDE_DFLAG_NIEN_QUIRK) == 0) |
753 | return; | 731 | return; |
754 | 732 | ||
755 | if (info->chip_type >= HPT370) { | 733 | if (info->chip_type >= HPT370) { |
@@ -1404,7 +1382,6 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1404 | static const struct ide_port_ops hpt3xx_port_ops = { | 1382 | static const struct ide_port_ops hpt3xx_port_ops = { |
1405 | .set_pio_mode = hpt3xx_set_pio_mode, | 1383 | .set_pio_mode = hpt3xx_set_pio_mode, |
1406 | .set_dma_mode = hpt3xx_set_mode, | 1384 | .set_dma_mode = hpt3xx_set_mode, |
1407 | .quirkproc = hpt3xx_quirkproc, | ||
1408 | .maskproc = hpt3xx_maskproc, | 1385 | .maskproc = hpt3xx_maskproc, |
1409 | .mdma_filter = hpt3xx_mdma_filter, | 1386 | .mdma_filter = hpt3xx_mdma_filter, |
1410 | .udma_filter = hpt3xx_udma_filter, | 1387 | .udma_filter = hpt3xx_udma_filter, |
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c index 36da913cc553..5af3d0ffaf0a 100644 --- a/drivers/ide/icside.c +++ b/drivers/ide/icside.c | |||
@@ -65,8 +65,6 @@ static struct cardinfo icside_cardinfo_v6_2 = { | |||
65 | }; | 65 | }; |
66 | 66 | ||
67 | struct icside_state { | 67 | struct icside_state { |
68 | unsigned int channel; | ||
69 | unsigned int enabled; | ||
70 | void __iomem *irq_port; | 68 | void __iomem *irq_port; |
71 | void __iomem *ioc_base; | 69 | void __iomem *ioc_base; |
72 | unsigned int sel; | 70 | unsigned int sel; |
@@ -116,18 +114,11 @@ static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr) | |||
116 | struct icside_state *state = ec->irq_data; | 114 | struct icside_state *state = ec->irq_data; |
117 | void __iomem *base = state->irq_port; | 115 | void __iomem *base = state->irq_port; |
118 | 116 | ||
119 | state->enabled = 1; | 117 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1); |
118 | readb(base + ICS_ARCIN_V6_INTROFFSET_2); | ||
120 | 119 | ||
121 | switch (state->channel) { | 120 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2); |
122 | case 0: | 121 | readb(base + ICS_ARCIN_V6_INTROFFSET_1); |
123 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1); | ||
124 | readb(base + ICS_ARCIN_V6_INTROFFSET_2); | ||
125 | break; | ||
126 | case 1: | ||
127 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2); | ||
128 | readb(base + ICS_ARCIN_V6_INTROFFSET_1); | ||
129 | break; | ||
130 | } | ||
131 | } | 122 | } |
132 | 123 | ||
133 | /* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) | 124 | /* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) |
@@ -137,8 +128,6 @@ static void icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) | |||
137 | { | 128 | { |
138 | struct icside_state *state = ec->irq_data; | 129 | struct icside_state *state = ec->irq_data; |
139 | 130 | ||
140 | state->enabled = 0; | ||
141 | |||
142 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | 131 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); |
143 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | 132 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); |
144 | } | 133 | } |
@@ -160,44 +149,6 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = { | |||
160 | .irqpending = icside_irqpending_arcin_v6, | 149 | .irqpending = icside_irqpending_arcin_v6, |
161 | }; | 150 | }; |
162 | 151 | ||
163 | /* | ||
164 | * Handle routing of interrupts. This is called before | ||
165 | * we write the command to the drive. | ||
166 | */ | ||
167 | static void icside_maskproc(ide_drive_t *drive, int mask) | ||
168 | { | ||
169 | ide_hwif_t *hwif = drive->hwif; | ||
170 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | ||
171 | struct icside_state *state = ecard_get_drvdata(ec); | ||
172 | unsigned long flags; | ||
173 | |||
174 | local_irq_save(flags); | ||
175 | |||
176 | state->channel = hwif->channel; | ||
177 | |||
178 | if (state->enabled && !mask) { | ||
179 | switch (hwif->channel) { | ||
180 | case 0: | ||
181 | writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | ||
182 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | ||
183 | break; | ||
184 | case 1: | ||
185 | writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | ||
186 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | ||
187 | break; | ||
188 | } | ||
189 | } else { | ||
190 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | ||
191 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | ||
192 | } | ||
193 | |||
194 | local_irq_restore(flags); | ||
195 | } | ||
196 | |||
197 | static const struct ide_port_ops icside_v6_no_dma_port_ops = { | ||
198 | .maskproc = icside_maskproc, | ||
199 | }; | ||
200 | |||
201 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS | 152 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS |
202 | /* | 153 | /* |
203 | * SG-DMA support. | 154 | * SG-DMA support. |
@@ -275,7 +226,6 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) | |||
275 | 226 | ||
276 | static const struct ide_port_ops icside_v6_port_ops = { | 227 | static const struct ide_port_ops icside_v6_port_ops = { |
277 | .set_dma_mode = icside_set_dma_mode, | 228 | .set_dma_mode = icside_set_dma_mode, |
278 | .maskproc = icside_maskproc, | ||
279 | }; | 229 | }; |
280 | 230 | ||
281 | static void icside_dma_host_set(ide_drive_t *drive, int on) | 231 | static void icside_dma_host_set(ide_drive_t *drive, int on) |
@@ -320,11 +270,6 @@ static int icside_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) | |||
320 | BUG_ON(dma_channel_active(ec->dma)); | 270 | BUG_ON(dma_channel_active(ec->dma)); |
321 | 271 | ||
322 | /* | 272 | /* |
323 | * Ensure that we have the right interrupt routed. | ||
324 | */ | ||
325 | icside_maskproc(drive, 0); | ||
326 | |||
327 | /* | ||
328 | * Route the DMA signals to the correct interface. | 273 | * Route the DMA signals to the correct interface. |
329 | */ | 274 | */ |
330 | writeb(state->sel | hwif->channel, state->ioc_base); | 275 | writeb(state->sel | hwif->channel, state->ioc_base); |
@@ -381,7 +326,7 @@ static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
381 | return -EOPNOTSUPP; | 326 | return -EOPNOTSUPP; |
382 | } | 327 | } |
383 | 328 | ||
384 | static void icside_setup_ports(hw_regs_t *hw, void __iomem *base, | 329 | static void icside_setup_ports(struct ide_hw *hw, void __iomem *base, |
385 | struct cardinfo *info, struct expansion_card *ec) | 330 | struct cardinfo *info, struct expansion_card *ec) |
386 | { | 331 | { |
387 | unsigned long port = (unsigned long)base + info->dataoffset; | 332 | unsigned long port = (unsigned long)base + info->dataoffset; |
@@ -398,11 +343,11 @@ static void icside_setup_ports(hw_regs_t *hw, void __iomem *base, | |||
398 | 343 | ||
399 | hw->irq = ec->irq; | 344 | hw->irq = ec->irq; |
400 | hw->dev = &ec->dev; | 345 | hw->dev = &ec->dev; |
401 | hw->chipset = ide_acorn; | ||
402 | } | 346 | } |
403 | 347 | ||
404 | static const struct ide_port_info icside_v5_port_info = { | 348 | static const struct ide_port_info icside_v5_port_info = { |
405 | .host_flags = IDE_HFLAG_NO_DMA, | 349 | .host_flags = IDE_HFLAG_NO_DMA, |
350 | .chipset = ide_acorn, | ||
406 | }; | 351 | }; |
407 | 352 | ||
408 | static int __devinit | 353 | static int __devinit |
@@ -410,7 +355,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
410 | { | 355 | { |
411 | void __iomem *base; | 356 | void __iomem *base; |
412 | struct ide_host *host; | 357 | struct ide_host *host; |
413 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 358 | struct ide_hw hw, *hws[] = { &hw }; |
414 | int ret; | 359 | int ret; |
415 | 360 | ||
416 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); | 361 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
@@ -431,7 +376,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
431 | 376 | ||
432 | icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); | 377 | icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec); |
433 | 378 | ||
434 | host = ide_host_alloc(&icside_v5_port_info, hws); | 379 | host = ide_host_alloc(&icside_v5_port_info, hws, 1); |
435 | if (host == NULL) | 380 | if (host == NULL) |
436 | return -ENODEV; | 381 | return -ENODEV; |
437 | 382 | ||
@@ -452,11 +397,11 @@ err_free: | |||
452 | 397 | ||
453 | static const struct ide_port_info icside_v6_port_info __initdata = { | 398 | static const struct ide_port_info icside_v6_port_info __initdata = { |
454 | .init_dma = icside_dma_off_init, | 399 | .init_dma = icside_dma_off_init, |
455 | .port_ops = &icside_v6_no_dma_port_ops, | ||
456 | .dma_ops = &icside_v6_dma_ops, | 400 | .dma_ops = &icside_v6_dma_ops, |
457 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO, | 401 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO, |
458 | .mwdma_mask = ATA_MWDMA2, | 402 | .mwdma_mask = ATA_MWDMA2, |
459 | .swdma_mask = ATA_SWDMA2, | 403 | .swdma_mask = ATA_SWDMA2, |
404 | .chipset = ide_acorn, | ||
460 | }; | 405 | }; |
461 | 406 | ||
462 | static int __devinit | 407 | static int __devinit |
@@ -466,7 +411,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
466 | struct ide_host *host; | 411 | struct ide_host *host; |
467 | unsigned int sel = 0; | 412 | unsigned int sel = 0; |
468 | int ret; | 413 | int ret; |
469 | hw_regs_t hw[2], *hws[] = { &hw[0], &hw[1], NULL, NULL }; | 414 | struct ide_hw hw[2], *hws[] = { &hw[0], &hw[1] }; |
470 | struct ide_port_info d = icside_v6_port_info; | 415 | struct ide_port_info d = icside_v6_port_info; |
471 | 416 | ||
472 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 417 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
@@ -506,7 +451,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
506 | icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); | 451 | icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec); |
507 | icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); | 452 | icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec); |
508 | 453 | ||
509 | host = ide_host_alloc(&d, hws); | 454 | host = ide_host_alloc(&d, hws, 2); |
510 | if (host == NULL) | 455 | if (host == NULL) |
511 | return -ENODEV; | 456 | return -ENODEV; |
512 | 457 | ||
diff --git a/drivers/ide/ide-4drives.c b/drivers/ide/ide-4drives.c index 78aca75a2c48..979d342c338a 100644 --- a/drivers/ide/ide-4drives.c +++ b/drivers/ide/ide-4drives.c | |||
@@ -25,12 +25,13 @@ static const struct ide_port_info ide_4drives_port_info = { | |||
25 | .port_ops = &ide_4drives_port_ops, | 25 | .port_ops = &ide_4drives_port_ops, |
26 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA | | 26 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA | |
27 | IDE_HFLAG_4DRIVES, | 27 | IDE_HFLAG_4DRIVES, |
28 | .chipset = ide_4drives, | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | static int __init ide_4drives_init(void) | 31 | static int __init ide_4drives_init(void) |
31 | { | 32 | { |
32 | unsigned long base = 0x1f0, ctl = 0x3f6; | 33 | unsigned long base = 0x1f0, ctl = 0x3f6; |
33 | hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL }; | 34 | struct ide_hw hw, *hws[] = { &hw, &hw }; |
34 | 35 | ||
35 | if (probe_4drives == 0) | 36 | if (probe_4drives == 0) |
36 | return -ENODEV; | 37 | return -ENODEV; |
@@ -52,9 +53,8 @@ static int __init ide_4drives_init(void) | |||
52 | 53 | ||
53 | ide_std_init_ports(&hw, base, ctl); | 54 | ide_std_init_ports(&hw, base, ctl); |
54 | hw.irq = 14; | 55 | hw.irq = 14; |
55 | hw.chipset = ide_4drives; | ||
56 | 56 | ||
57 | return ide_host_add(&ide_4drives_port_info, hws, NULL); | 57 | return ide_host_add(&ide_4drives_port_info, hws, 2, NULL); |
58 | } | 58 | } |
59 | 59 | ||
60 | module_init(ide_4drives_init); | 60 | module_init(ide_4drives_init); |
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 7201b176d75b..702ef64a0f12 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -80,34 +80,6 @@ void ide_init_pc(struct ide_atapi_pc *pc) | |||
80 | EXPORT_SYMBOL_GPL(ide_init_pc); | 80 | EXPORT_SYMBOL_GPL(ide_init_pc); |
81 | 81 | ||
82 | /* | 82 | /* |
83 | * Generate a new packet command request in front of the request queue, before | ||
84 | * the current request, so that it will be processed immediately, on the next | ||
85 | * pass through the driver. | ||
86 | */ | ||
87 | static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, | ||
88 | struct ide_atapi_pc *pc, struct request *rq) | ||
89 | { | ||
90 | blk_rq_init(NULL, rq); | ||
91 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
92 | rq->cmd_flags |= REQ_PREEMPT; | ||
93 | rq->buffer = (char *)pc; | ||
94 | rq->rq_disk = disk; | ||
95 | |||
96 | if (pc->req_xfer) { | ||
97 | rq->data = pc->buf; | ||
98 | rq->data_len = pc->req_xfer; | ||
99 | } | ||
100 | |||
101 | memcpy(rq->cmd, pc->c, 12); | ||
102 | if (drive->media == ide_tape) | ||
103 | rq->cmd[13] = REQ_IDETAPE_PC1; | ||
104 | |||
105 | drive->hwif->rq = NULL; | ||
106 | |||
107 | elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * Add a special packet command request to the tail of the request queue, | 83 | * Add a special packet command request to the tail of the request queue, |
112 | * and wait for it to be serviced. | 84 | * and wait for it to be serviced. |
113 | */ | 85 | */ |
@@ -119,19 +91,21 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, | |||
119 | 91 | ||
120 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 92 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
121 | rq->cmd_type = REQ_TYPE_SPECIAL; | 93 | rq->cmd_type = REQ_TYPE_SPECIAL; |
122 | rq->buffer = (char *)pc; | 94 | rq->special = (char *)pc; |
123 | 95 | ||
124 | if (pc->req_xfer) { | 96 | if (pc->req_xfer) { |
125 | rq->data = pc->buf; | 97 | error = blk_rq_map_kern(drive->queue, rq, pc->buf, pc->req_xfer, |
126 | rq->data_len = pc->req_xfer; | 98 | GFP_NOIO); |
99 | if (error) | ||
100 | goto put_req; | ||
127 | } | 101 | } |
128 | 102 | ||
129 | memcpy(rq->cmd, pc->c, 12); | 103 | memcpy(rq->cmd, pc->c, 12); |
130 | if (drive->media == ide_tape) | 104 | if (drive->media == ide_tape) |
131 | rq->cmd[13] = REQ_IDETAPE_PC1; | 105 | rq->cmd[13] = REQ_IDETAPE_PC1; |
132 | error = blk_execute_rq(drive->queue, disk, rq, 0); | 106 | error = blk_execute_rq(drive->queue, disk, rq, 0); |
107 | put_req: | ||
133 | blk_put_request(rq); | 108 | blk_put_request(rq); |
134 | |||
135 | return error; | 109 | return error; |
136 | } | 110 | } |
137 | EXPORT_SYMBOL_GPL(ide_queue_pc_tail); | 111 | EXPORT_SYMBOL_GPL(ide_queue_pc_tail); |
@@ -191,20 +165,113 @@ void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc) | |||
191 | } | 165 | } |
192 | EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd); | 166 | EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd); |
193 | 167 | ||
168 | void ide_prep_sense(ide_drive_t *drive, struct request *rq) | ||
169 | { | ||
170 | struct request_sense *sense = &drive->sense_data; | ||
171 | struct request *sense_rq = &drive->sense_rq; | ||
172 | unsigned int cmd_len, sense_len; | ||
173 | int err; | ||
174 | |||
175 | debug_log("%s: enter\n", __func__); | ||
176 | |||
177 | switch (drive->media) { | ||
178 | case ide_floppy: | ||
179 | cmd_len = 255; | ||
180 | sense_len = 18; | ||
181 | break; | ||
182 | case ide_tape: | ||
183 | cmd_len = 20; | ||
184 | sense_len = 20; | ||
185 | break; | ||
186 | default: | ||
187 | cmd_len = 18; | ||
188 | sense_len = 18; | ||
189 | } | ||
190 | |||
191 | BUG_ON(sense_len > sizeof(*sense)); | ||
192 | |||
193 | if (blk_sense_request(rq) || drive->sense_rq_armed) | ||
194 | return; | ||
195 | |||
196 | memset(sense, 0, sizeof(*sense)); | ||
197 | |||
198 | blk_rq_init(rq->q, sense_rq); | ||
199 | |||
200 | err = blk_rq_map_kern(drive->queue, sense_rq, sense, sense_len, | ||
201 | GFP_NOIO); | ||
202 | if (unlikely(err)) { | ||
203 | if (printk_ratelimit()) | ||
204 | printk(KERN_WARNING "%s: failed to map sense buffer\n", | ||
205 | drive->name); | ||
206 | return; | ||
207 | } | ||
208 | |||
209 | sense_rq->rq_disk = rq->rq_disk; | ||
210 | sense_rq->cmd[0] = GPCMD_REQUEST_SENSE; | ||
211 | sense_rq->cmd[4] = cmd_len; | ||
212 | sense_rq->cmd_type = REQ_TYPE_SENSE; | ||
213 | sense_rq->cmd_flags |= REQ_PREEMPT; | ||
214 | |||
215 | if (drive->media == ide_tape) | ||
216 | sense_rq->cmd[13] = REQ_IDETAPE_PC1; | ||
217 | |||
218 | drive->sense_rq_armed = true; | ||
219 | } | ||
220 | EXPORT_SYMBOL_GPL(ide_prep_sense); | ||
221 | |||
222 | int ide_queue_sense_rq(ide_drive_t *drive, void *special) | ||
223 | { | ||
224 | /* deferred failure from ide_prep_sense() */ | ||
225 | if (!drive->sense_rq_armed) { | ||
226 | printk(KERN_WARNING "%s: failed queue sense request\n", | ||
227 | drive->name); | ||
228 | return -ENOMEM; | ||
229 | } | ||
230 | |||
231 | drive->sense_rq.special = special; | ||
232 | drive->sense_rq_armed = false; | ||
233 | |||
234 | drive->hwif->rq = NULL; | ||
235 | |||
236 | elv_add_request(drive->queue, &drive->sense_rq, | ||
237 | ELEVATOR_INSERT_FRONT, 0); | ||
238 | return 0; | ||
239 | } | ||
240 | EXPORT_SYMBOL_GPL(ide_queue_sense_rq); | ||
241 | |||
194 | /* | 242 | /* |
195 | * Called when an error was detected during the last packet command. | 243 | * Called when an error was detected during the last packet command. |
196 | * We queue a request sense packet command in the head of the request list. | 244 | * We queue a request sense packet command at the head of the request |
245 | * queue. | ||
197 | */ | 246 | */ |
198 | void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk) | 247 | void ide_retry_pc(ide_drive_t *drive) |
199 | { | 248 | { |
200 | struct request *rq = &drive->request_sense_rq; | 249 | struct request *failed_rq = drive->hwif->rq; |
250 | struct request *sense_rq = &drive->sense_rq; | ||
201 | struct ide_atapi_pc *pc = &drive->request_sense_pc; | 251 | struct ide_atapi_pc *pc = &drive->request_sense_pc; |
202 | 252 | ||
203 | (void)ide_read_error(drive); | 253 | (void)ide_read_error(drive); |
204 | ide_create_request_sense_cmd(drive, pc); | 254 | |
255 | /* init pc from sense_rq */ | ||
256 | ide_init_pc(pc); | ||
257 | memcpy(pc->c, sense_rq->cmd, 12); | ||
258 | pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */ | ||
259 | pc->req_xfer = blk_rq_bytes(sense_rq); | ||
260 | |||
205 | if (drive->media == ide_tape) | 261 | if (drive->media == ide_tape) |
206 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); | 262 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; |
207 | ide_queue_pc_head(drive, disk, pc, rq); | 263 | |
264 | /* | ||
265 | * Push back the failed request and put request sense on top | ||
266 | * of it. The failed command will be retried after sense data | ||
267 | * is acquired. | ||
268 | */ | ||
269 | blk_requeue_request(failed_rq->q, failed_rq); | ||
270 | drive->hwif->rq = NULL; | ||
271 | if (ide_queue_sense_rq(drive, pc)) { | ||
272 | blk_start_request(failed_rq); | ||
273 | ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq)); | ||
274 | } | ||
208 | } | 275 | } |
209 | EXPORT_SYMBOL_GPL(ide_retry_pc); | 276 | EXPORT_SYMBOL_GPL(ide_retry_pc); |
210 | 277 | ||
@@ -246,7 +313,7 @@ int ide_cd_get_xferlen(struct request *rq) | |||
246 | return 32768; | 313 | return 32768; |
247 | else if (blk_sense_request(rq) || blk_pc_request(rq) || | 314 | else if (blk_sense_request(rq) || blk_pc_request(rq) || |
248 | rq->cmd_type == REQ_TYPE_ATA_PC) | 315 | rq->cmd_type == REQ_TYPE_ATA_PC) |
249 | return rq->data_len; | 316 | return blk_rq_bytes(rq); |
250 | else | 317 | else |
251 | return 0; | 318 | return 0; |
252 | } | 319 | } |
@@ -276,7 +343,6 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
276 | struct ide_cmd *cmd = &hwif->cmd; | 343 | struct ide_cmd *cmd = &hwif->cmd; |
277 | struct request *rq = hwif->rq; | 344 | struct request *rq = hwif->rq; |
278 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 345 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
279 | xfer_func_t *xferfunc; | ||
280 | unsigned int timeout, done; | 346 | unsigned int timeout, done; |
281 | u16 bcount; | 347 | u16 bcount; |
282 | u8 stat, ireason, dsc = 0; | 348 | u8 stat, ireason, dsc = 0; |
@@ -303,18 +369,14 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
303 | drive->name, rq_data_dir(pc->rq) | 369 | drive->name, rq_data_dir(pc->rq) |
304 | ? "write" : "read"); | 370 | ? "write" : "read"); |
305 | pc->flags |= PC_FLAG_DMA_ERROR; | 371 | pc->flags |= PC_FLAG_DMA_ERROR; |
306 | } else { | 372 | } else |
307 | pc->xferred = pc->req_xfer; | 373 | pc->xferred = pc->req_xfer; |
308 | if (drive->pc_update_buffers) | ||
309 | drive->pc_update_buffers(drive, pc); | ||
310 | } | ||
311 | debug_log("%s: DMA finished\n", drive->name); | 374 | debug_log("%s: DMA finished\n", drive->name); |
312 | } | 375 | } |
313 | 376 | ||
314 | /* No more interrupts */ | 377 | /* No more interrupts */ |
315 | if ((stat & ATA_DRQ) == 0) { | 378 | if ((stat & ATA_DRQ) == 0) { |
316 | int uptodate, error; | 379 | int uptodate, error; |
317 | unsigned int done; | ||
318 | 380 | ||
319 | debug_log("Packet command completed, %d bytes transferred\n", | 381 | debug_log("Packet command completed, %d bytes transferred\n", |
320 | pc->xferred); | 382 | pc->xferred); |
@@ -343,7 +405,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
343 | debug_log("[cmd %x]: check condition\n", rq->cmd[0]); | 405 | debug_log("[cmd %x]: check condition\n", rq->cmd[0]); |
344 | 406 | ||
345 | /* Retry operation */ | 407 | /* Retry operation */ |
346 | ide_retry_pc(drive, rq->rq_disk); | 408 | ide_retry_pc(drive); |
347 | 409 | ||
348 | /* queued, but not started */ | 410 | /* queued, but not started */ |
349 | return ide_stopped; | 411 | return ide_stopped; |
@@ -353,6 +415,12 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
353 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && (stat & ATA_DSC) == 0) | 415 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && (stat & ATA_DSC) == 0) |
354 | dsc = 1; | 416 | dsc = 1; |
355 | 417 | ||
418 | /* | ||
419 | * ->pc_callback() might change rq->data_len for | ||
420 | * residual count, cache total length. | ||
421 | */ | ||
422 | done = blk_rq_bytes(rq); | ||
423 | |||
356 | /* Command finished - Call the callback function */ | 424 | /* Command finished - Call the callback function */ |
357 | uptodate = drive->pc_callback(drive, dsc); | 425 | uptodate = drive->pc_callback(drive, dsc); |
358 | 426 | ||
@@ -361,7 +429,6 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
361 | 429 | ||
362 | if (blk_special_request(rq)) { | 430 | if (blk_special_request(rq)) { |
363 | rq->errors = 0; | 431 | rq->errors = 0; |
364 | done = blk_rq_bytes(rq); | ||
365 | error = 0; | 432 | error = 0; |
366 | } else { | 433 | } else { |
367 | 434 | ||
@@ -370,15 +437,10 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
370 | rq->errors = -EIO; | 437 | rq->errors = -EIO; |
371 | } | 438 | } |
372 | 439 | ||
373 | if (drive->media == ide_tape) | ||
374 | done = ide_rq_bytes(rq); /* FIXME */ | ||
375 | else | ||
376 | done = blk_rq_bytes(rq); | ||
377 | |||
378 | error = uptodate ? 0 : -EIO; | 440 | error = uptodate ? 0 : -EIO; |
379 | } | 441 | } |
380 | 442 | ||
381 | ide_complete_rq(drive, error, done); | 443 | ide_complete_rq(drive, error, blk_rq_bytes(rq)); |
382 | return ide_stopped; | 444 | return ide_stopped; |
383 | } | 445 | } |
384 | 446 | ||
@@ -407,21 +469,11 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
407 | return ide_do_reset(drive); | 469 | return ide_do_reset(drive); |
408 | } | 470 | } |
409 | 471 | ||
410 | xferfunc = write ? tp_ops->output_data : tp_ops->input_data; | 472 | done = min_t(unsigned int, bcount, cmd->nleft); |
411 | 473 | ide_pio_bytes(drive, cmd, write, done); | |
412 | if (drive->media == ide_floppy && pc->buf == NULL) { | ||
413 | done = min_t(unsigned int, bcount, cmd->nleft); | ||
414 | ide_pio_bytes(drive, cmd, write, done); | ||
415 | } else if (drive->media == ide_tape && pc->bh) { | ||
416 | done = drive->pc_io_buffers(drive, pc, bcount, write); | ||
417 | } else { | ||
418 | done = min_t(unsigned int, bcount, pc->req_xfer - pc->xferred); | ||
419 | xferfunc(drive, NULL, pc->cur_pos, done); | ||
420 | } | ||
421 | 474 | ||
422 | /* Update the current position */ | 475 | /* Update transferred byte count */ |
423 | pc->xferred += done; | 476 | pc->xferred += done; |
424 | pc->cur_pos += done; | ||
425 | 477 | ||
426 | bcount -= done; | 478 | bcount -= done; |
427 | 479 | ||
@@ -525,7 +577,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) | |||
525 | 577 | ||
526 | /* | 578 | /* |
527 | * If necessary schedule the packet transfer to occur 'timeout' | 579 | * If necessary schedule the packet transfer to occur 'timeout' |
528 | * miliseconds later in ide_delayed_transfer_pc() after the | 580 | * milliseconds later in ide_delayed_transfer_pc() after the |
529 | * device says it's ready for a packet. | 581 | * device says it's ready for a packet. |
530 | */ | 582 | */ |
531 | if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { | 583 | if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { |
@@ -599,7 +651,6 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) | |||
599 | 651 | ||
600 | /* We haven't transferred any data yet */ | 652 | /* We haven't transferred any data yet */ |
601 | pc->xferred = 0; | 653 | pc->xferred = 0; |
602 | pc->cur_pos = pc->buf; | ||
603 | 654 | ||
604 | valid_tf = IDE_VALID_DEVICE; | 655 | valid_tf = IDE_VALID_DEVICE; |
605 | bcount = ((drive->media == ide_tape) ? | 656 | bcount = ((drive->media == ide_tape) ? |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 925eb9e245d1..424140c6c400 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -182,7 +182,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
182 | (sense->information[2] << 8) | | 182 | (sense->information[2] << 8) | |
183 | (sense->information[3]); | 183 | (sense->information[3]); |
184 | 184 | ||
185 | if (drive->queue->hardsect_size == 2048) | 185 | if (queue_logical_block_size(drive->queue) == 2048) |
186 | /* device sector size is 2K */ | 186 | /* device sector size is 2K */ |
187 | sector <<= 2; | 187 | sector <<= 2; |
188 | 188 | ||
@@ -206,54 +206,25 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
206 | ide_cd_log_error(drive->name, failed_command, sense); | 206 | ide_cd_log_error(drive->name, failed_command, sense); |
207 | } | 207 | } |
208 | 208 | ||
209 | static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | ||
210 | struct request *failed_command) | ||
211 | { | ||
212 | struct cdrom_info *info = drive->driver_data; | ||
213 | struct request *rq = &drive->request_sense_rq; | ||
214 | |||
215 | ide_debug_log(IDE_DBG_SENSE, "enter"); | ||
216 | |||
217 | if (sense == NULL) | ||
218 | sense = &info->sense_data; | ||
219 | |||
220 | /* stuff the sense request in front of our current request */ | ||
221 | blk_rq_init(NULL, rq); | ||
222 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
223 | rq->rq_disk = info->disk; | ||
224 | |||
225 | rq->data = sense; | ||
226 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | ||
227 | rq->cmd[4] = 18; | ||
228 | rq->data_len = 18; | ||
229 | |||
230 | rq->cmd_type = REQ_TYPE_SENSE; | ||
231 | rq->cmd_flags |= REQ_PREEMPT; | ||
232 | |||
233 | /* NOTE! Save the failed command in "rq->buffer" */ | ||
234 | rq->buffer = (void *) failed_command; | ||
235 | |||
236 | if (failed_command) | ||
237 | ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x", | ||
238 | failed_command->cmd[0]); | ||
239 | |||
240 | drive->hwif->rq = NULL; | ||
241 | |||
242 | elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0); | ||
243 | } | ||
244 | |||
245 | static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) | 209 | static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) |
246 | { | 210 | { |
247 | /* | 211 | /* |
248 | * For REQ_TYPE_SENSE, "rq->buffer" points to the original | 212 | * For REQ_TYPE_SENSE, "rq->special" points to the original |
249 | * failed request | 213 | * failed request. Also, the sense data should be read |
214 | * directly from rq which might be different from the original | ||
215 | * sense buffer if it got copied during mapping. | ||
250 | */ | 216 | */ |
251 | struct request *failed = (struct request *)rq->buffer; | 217 | struct request *failed = (struct request *)rq->special; |
252 | struct cdrom_info *info = drive->driver_data; | 218 | void *sense = bio_data(rq->bio); |
253 | void *sense = &info->sense_data; | ||
254 | 219 | ||
255 | if (failed) { | 220 | if (failed) { |
256 | if (failed->sense) { | 221 | if (failed->sense) { |
222 | /* | ||
223 | * Sense is always read into drive->sense_data. | ||
224 | * Copy back if the failed request has its | ||
225 | * sense pointer set. | ||
226 | */ | ||
227 | memcpy(failed->sense, sense, 18); | ||
257 | sense = failed->sense; | 228 | sense = failed->sense; |
258 | failed->sense_len = rq->sense_len; | 229 | failed->sense_len = rq->sense_len; |
259 | } | 230 | } |
@@ -428,22 +399,13 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat) | |||
428 | 399 | ||
429 | /* if we got a CHECK_CONDITION status, queue a request sense command */ | 400 | /* if we got a CHECK_CONDITION status, queue a request sense command */ |
430 | if (stat & ATA_ERR) | 401 | if (stat & ATA_ERR) |
431 | cdrom_queue_request_sense(drive, NULL, NULL); | 402 | return ide_queue_sense_rq(drive, NULL) ? 2 : 1; |
432 | return 1; | 403 | return 1; |
433 | 404 | ||
434 | end_request: | 405 | end_request: |
435 | if (stat & ATA_ERR) { | 406 | if (stat & ATA_ERR) { |
436 | struct request_queue *q = drive->queue; | ||
437 | unsigned long flags; | ||
438 | |||
439 | spin_lock_irqsave(q->queue_lock, flags); | ||
440 | blkdev_dequeue_request(rq); | ||
441 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
442 | |||
443 | hwif->rq = NULL; | 407 | hwif->rq = NULL; |
444 | 408 | return ide_queue_sense_rq(drive, rq) ? 2 : 1; | |
445 | cdrom_queue_request_sense(drive, rq->sense, rq); | ||
446 | return 1; | ||
447 | } else | 409 | } else |
448 | return 2; | 410 | return 2; |
449 | } | 411 | } |
@@ -503,14 +465,8 @@ static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd) | |||
503 | * and some drives don't send them. Sigh. | 465 | * and some drives don't send them. Sigh. |
504 | */ | 466 | */ |
505 | if (rq->cmd[0] == GPCMD_REQUEST_SENSE && | 467 | if (rq->cmd[0] == GPCMD_REQUEST_SENSE && |
506 | cmd->nleft > 0 && cmd->nleft <= 5) { | 468 | cmd->nleft > 0 && cmd->nleft <= 5) |
507 | unsigned int ofs = cmd->nbytes - cmd->nleft; | 469 | cmd->nleft = 0; |
508 | |||
509 | while (cmd->nleft > 0) { | ||
510 | *((u8 *)rq->data + ofs++) = 0; | ||
511 | cmd->nleft--; | ||
512 | } | ||
513 | } | ||
514 | } | 470 | } |
515 | 471 | ||
516 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, | 472 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, |
@@ -543,14 +499,18 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, | |||
543 | rq->cmd_flags |= cmd_flags; | 499 | rq->cmd_flags |= cmd_flags; |
544 | rq->timeout = timeout; | 500 | rq->timeout = timeout; |
545 | if (buffer) { | 501 | if (buffer) { |
546 | rq->data = buffer; | 502 | error = blk_rq_map_kern(drive->queue, rq, buffer, |
547 | rq->data_len = *bufflen; | 503 | *bufflen, GFP_NOIO); |
504 | if (error) { | ||
505 | blk_put_request(rq); | ||
506 | return error; | ||
507 | } | ||
548 | } | 508 | } |
549 | 509 | ||
550 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); | 510 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); |
551 | 511 | ||
552 | if (buffer) | 512 | if (buffer) |
553 | *bufflen = rq->data_len; | 513 | *bufflen = rq->resid_len; |
554 | 514 | ||
555 | flags = rq->cmd_flags; | 515 | flags = rq->cmd_flags; |
556 | blk_put_request(rq); | 516 | blk_put_request(rq); |
@@ -608,7 +568,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
608 | struct request *rq = hwif->rq; | 568 | struct request *rq = hwif->rq; |
609 | ide_expiry_t *expiry = NULL; | 569 | ide_expiry_t *expiry = NULL; |
610 | int dma_error = 0, dma, thislen, uptodate = 0; | 570 | int dma_error = 0, dma, thislen, uptodate = 0; |
611 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors; | 571 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0; |
612 | int sense = blk_sense_request(rq); | 572 | int sense = blk_sense_request(rq); |
613 | unsigned int timeout; | 573 | unsigned int timeout; |
614 | u16 len; | 574 | u16 len; |
@@ -738,13 +698,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
738 | 698 | ||
739 | out_end: | 699 | out_end: |
740 | if (blk_pc_request(rq) && rc == 0) { | 700 | if (blk_pc_request(rq) && rc == 0) { |
741 | unsigned int dlen = rq->data_len; | 701 | rq->resid_len = 0; |
742 | 702 | blk_end_request_all(rq, 0); | |
743 | rq->data_len = 0; | ||
744 | |||
745 | if (blk_end_request(rq, 0, dlen)) | ||
746 | BUG(); | ||
747 | |||
748 | hwif->rq = NULL; | 703 | hwif->rq = NULL; |
749 | } else { | 704 | } else { |
750 | if (sense && uptodate) | 705 | if (sense && uptodate) |
@@ -762,21 +717,13 @@ out_end: | |||
762 | ide_cd_error_cmd(drive, cmd); | 717 | ide_cd_error_cmd(drive, cmd); |
763 | 718 | ||
764 | /* make sure it's fully ended */ | 719 | /* make sure it's fully ended */ |
765 | if (blk_pc_request(rq)) | ||
766 | nsectors = (rq->data_len + 511) >> 9; | ||
767 | else | ||
768 | nsectors = rq->hard_nr_sectors; | ||
769 | |||
770 | if (nsectors == 0) | ||
771 | nsectors = 1; | ||
772 | |||
773 | if (blk_fs_request(rq) == 0) { | 720 | if (blk_fs_request(rq) == 0) { |
774 | rq->data_len -= (cmd->nbytes - cmd->nleft); | 721 | rq->resid_len -= cmd->nbytes - cmd->nleft; |
775 | if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) | 722 | if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) |
776 | rq->data_len += cmd->last_xfer_len; | 723 | rq->resid_len += cmd->last_xfer_len; |
777 | } | 724 | } |
778 | 725 | ||
779 | ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9); | 726 | ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq)); |
780 | 727 | ||
781 | if (sense && rc == 2) | 728 | if (sense && rc == 2) |
782 | ide_error(drive, "request sense failure", stat); | 729 | ide_error(drive, "request sense failure", stat); |
@@ -790,7 +737,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
790 | struct request_queue *q = drive->queue; | 737 | struct request_queue *q = drive->queue; |
791 | int write = rq_data_dir(rq) == WRITE; | 738 | int write = rq_data_dir(rq) == WRITE; |
792 | unsigned short sectors_per_frame = | 739 | unsigned short sectors_per_frame = |
793 | queue_hardsect_size(q) >> SECTOR_BITS; | 740 | queue_logical_block_size(q) >> SECTOR_BITS; |
794 | 741 | ||
795 | ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, " | 742 | ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, " |
796 | "secs_per_frame: %u", | 743 | "secs_per_frame: %u", |
@@ -809,8 +756,8 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
809 | } | 756 | } |
810 | 757 | ||
811 | /* fs requests *must* be hardware frame aligned */ | 758 | /* fs requests *must* be hardware frame aligned */ |
812 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || | 759 | if ((blk_rq_sectors(rq) & (sectors_per_frame - 1)) || |
813 | (rq->sector & (sectors_per_frame - 1))) | 760 | (blk_rq_pos(rq) & (sectors_per_frame - 1))) |
814 | return ide_stopped; | 761 | return ide_stopped; |
815 | 762 | ||
816 | /* use DMA, if possible */ | 763 | /* use DMA, if possible */ |
@@ -838,15 +785,10 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
838 | drive->dma = 0; | 785 | drive->dma = 0; |
839 | 786 | ||
840 | /* sg request */ | 787 | /* sg request */ |
841 | if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) { | 788 | if (rq->bio) { |
842 | struct request_queue *q = drive->queue; | 789 | struct request_queue *q = drive->queue; |
790 | char *buf = bio_data(rq->bio); | ||
843 | unsigned int alignment; | 791 | unsigned int alignment; |
844 | char *buf; | ||
845 | |||
846 | if (rq->bio) | ||
847 | buf = bio_data(rq->bio); | ||
848 | else | ||
849 | buf = rq->data; | ||
850 | 792 | ||
851 | drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | 793 | drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); |
852 | 794 | ||
@@ -858,7 +800,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
858 | */ | 800 | */ |
859 | alignment = queue_dma_alignment(q) | q->dma_pad_mask; | 801 | alignment = queue_dma_alignment(q) | q->dma_pad_mask; |
860 | if ((unsigned long)buf & alignment | 802 | if ((unsigned long)buf & alignment |
861 | || rq->data_len & q->dma_pad_mask | 803 | || blk_rq_bytes(rq) & q->dma_pad_mask |
862 | || object_is_on_stack(buf)) | 804 | || object_is_on_stack(buf)) |
863 | drive->dma = 0; | 805 | drive->dma = 0; |
864 | } | 806 | } |
@@ -896,6 +838,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
896 | goto out_end; | 838 | goto out_end; |
897 | } | 839 | } |
898 | 840 | ||
841 | /* prepare sense request for this command */ | ||
842 | ide_prep_sense(drive, rq); | ||
843 | |||
899 | memset(&cmd, 0, sizeof(cmd)); | 844 | memset(&cmd, 0, sizeof(cmd)); |
900 | 845 | ||
901 | if (rq_data_dir(rq)) | 846 | if (rq_data_dir(rq)) |
@@ -903,15 +848,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
903 | 848 | ||
904 | cmd.rq = rq; | 849 | cmd.rq = rq; |
905 | 850 | ||
906 | if (blk_fs_request(rq) || rq->data_len) { | 851 | if (blk_fs_request(rq) || blk_rq_bytes(rq)) { |
907 | ide_init_sg_cmd(&cmd, blk_fs_request(rq) ? (rq->nr_sectors << 9) | 852 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
908 | : rq->data_len); | ||
909 | ide_map_sg(drive, &cmd); | 853 | ide_map_sg(drive, &cmd); |
910 | } | 854 | } |
911 | 855 | ||
912 | return ide_issue_pc(drive, &cmd); | 856 | return ide_issue_pc(drive, &cmd); |
913 | out_end: | 857 | out_end: |
914 | nsectors = rq->hard_nr_sectors; | 858 | nsectors = blk_rq_sectors(rq); |
915 | 859 | ||
916 | if (nsectors == 0) | 860 | if (nsectors == 0) |
917 | nsectors = 1; | 861 | nsectors = 1; |
@@ -1077,8 +1021,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1077 | /* save a private copy of the TOC capacity for error handling */ | 1021 | /* save a private copy of the TOC capacity for error handling */ |
1078 | drive->probed_capacity = toc->capacity * sectors_per_frame; | 1022 | drive->probed_capacity = toc->capacity * sectors_per_frame; |
1079 | 1023 | ||
1080 | blk_queue_hardsect_size(drive->queue, | 1024 | blk_queue_logical_block_size(drive->queue, |
1081 | sectors_per_frame << SECTOR_BITS); | 1025 | sectors_per_frame << SECTOR_BITS); |
1082 | 1026 | ||
1083 | /* first read just the header, so we know how long the TOC is */ | 1027 | /* first read just the header, so we know how long the TOC is */ |
1084 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, | 1028 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, |
@@ -1394,9 +1338,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1394 | /* standard prep_rq_fn that builds 10 byte cmds */ | 1338 | /* standard prep_rq_fn that builds 10 byte cmds */ |
1395 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) | 1339 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) |
1396 | { | 1340 | { |
1397 | int hard_sect = queue_hardsect_size(q); | 1341 | int hard_sect = queue_logical_block_size(q); |
1398 | long block = (long)rq->hard_sector / (hard_sect >> 9); | 1342 | long block = (long)blk_rq_pos(rq) / (hard_sect >> 9); |
1399 | unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9); | 1343 | unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9); |
1400 | 1344 | ||
1401 | memset(rq->cmd, 0, BLK_MAX_CDB); | 1345 | memset(rq->cmd, 0, BLK_MAX_CDB); |
1402 | 1346 | ||
@@ -1599,7 +1543,7 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
1599 | 1543 | ||
1600 | nslots = ide_cdrom_probe_capabilities(drive); | 1544 | nslots = ide_cdrom_probe_capabilities(drive); |
1601 | 1545 | ||
1602 | blk_queue_hardsect_size(q, CD_FRAMESIZE); | 1546 | blk_queue_logical_block_size(q, CD_FRAMESIZE); |
1603 | 1547 | ||
1604 | if (ide_cdrom_register(drive, nslots)) { | 1548 | if (ide_cdrom_register(drive, nslots)) { |
1605 | printk(KERN_ERR PFX "%s: %s failed to register device with the" | 1549 | printk(KERN_ERR PFX "%s: %s failed to register device with the" |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index 1d97101099ce..93a3cf1b0f3f 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -87,10 +87,6 @@ struct cdrom_info { | |||
87 | 87 | ||
88 | struct atapi_toc *toc; | 88 | struct atapi_toc *toc; |
89 | 89 | ||
90 | /* The result of the last successful request sense command | ||
91 | on this device. */ | ||
92 | struct request_sense sense_data; | ||
93 | |||
94 | u8 max_speed; /* Max speed of the drive. */ | 90 | u8 max_speed; /* Max speed of the drive. */ |
95 | u8 current_speed; /* Current speed of the drive. */ | 91 | u8 current_speed; /* Current speed of the drive. */ |
96 | 92 | ||
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c index 9e47f3529d55..527908ff298c 100644 --- a/drivers/ide/ide-cs.c +++ b/drivers/ide/ide-cs.c | |||
@@ -155,6 +155,7 @@ static const struct ide_port_info idecs_port_info = { | |||
155 | .port_ops = &idecs_port_ops, | 155 | .port_ops = &idecs_port_ops, |
156 | .host_flags = IDE_HFLAG_NO_DMA, | 156 | .host_flags = IDE_HFLAG_NO_DMA, |
157 | .irq_flags = IRQF_SHARED, | 157 | .irq_flags = IRQF_SHARED, |
158 | .chipset = ide_pci, | ||
158 | }; | 159 | }; |
159 | 160 | ||
160 | static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, | 161 | static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, |
@@ -163,7 +164,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, | |||
163 | struct ide_host *host; | 164 | struct ide_host *host; |
164 | ide_hwif_t *hwif; | 165 | ide_hwif_t *hwif; |
165 | int i, rc; | 166 | int i, rc; |
166 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 167 | struct ide_hw hw, *hws[] = { &hw }; |
167 | 168 | ||
168 | if (!request_region(io, 8, DRV_NAME)) { | 169 | if (!request_region(io, 8, DRV_NAME)) { |
169 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | 170 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", |
@@ -181,10 +182,9 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, | |||
181 | memset(&hw, 0, sizeof(hw)); | 182 | memset(&hw, 0, sizeof(hw)); |
182 | ide_std_init_ports(&hw, io, ctl); | 183 | ide_std_init_ports(&hw, io, ctl); |
183 | hw.irq = irq; | 184 | hw.irq = irq; |
184 | hw.chipset = ide_pci; | ||
185 | hw.dev = &handle->dev; | 185 | hw.dev = &handle->dev; |
186 | 186 | ||
187 | rc = ide_host_add(&idecs_port_info, hws, &host); | 187 | rc = ide_host_add(&idecs_port_info, hws, 1, &host); |
188 | if (rc) | 188 | if (rc) |
189 | goto out_release; | 189 | goto out_release; |
190 | 190 | ||
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index a9fbe2c31210..6a1de2169709 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -82,7 +82,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
82 | sector_t block) | 82 | sector_t block) |
83 | { | 83 | { |
84 | ide_hwif_t *hwif = drive->hwif; | 84 | ide_hwif_t *hwif = drive->hwif; |
85 | u16 nsectors = (u16)rq->nr_sectors; | 85 | u16 nsectors = (u16)blk_rq_sectors(rq); |
86 | u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); | 86 | u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); |
87 | u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | 87 | u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); |
88 | struct ide_cmd cmd; | 88 | struct ide_cmd cmd; |
@@ -90,7 +90,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
90 | ide_startstop_t rc; | 90 | ide_startstop_t rc; |
91 | 91 | ||
92 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) { | 92 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) { |
93 | if (block + rq->nr_sectors > 1ULL << 28) | 93 | if (block + blk_rq_sectors(rq) > 1ULL << 28) |
94 | dma = 0; | 94 | dma = 0; |
95 | else | 95 | else |
96 | lba48 = 0; | 96 | lba48 = 0; |
@@ -195,9 +195,9 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
195 | 195 | ||
196 | ledtrig_ide_activity(); | 196 | ledtrig_ide_activity(); |
197 | 197 | ||
198 | pr_debug("%s: %sing: block=%llu, sectors=%lu, buffer=0x%08lx\n", | 198 | pr_debug("%s: %sing: block=%llu, sectors=%u, buffer=0x%08lx\n", |
199 | drive->name, rq_data_dir(rq) == READ ? "read" : "writ", | 199 | drive->name, rq_data_dir(rq) == READ ? "read" : "writ", |
200 | (unsigned long long)block, rq->nr_sectors, | 200 | (unsigned long long)block, blk_rq_sectors(rq), |
201 | (unsigned long)rq->buffer); | 201 | (unsigned long)rq->buffer); |
202 | 202 | ||
203 | if (hwif->rw_disk) | 203 | if (hwif->rw_disk) |
@@ -302,14 +302,12 @@ static const struct drive_list_entry hpa_list[] = { | |||
302 | { NULL, NULL } | 302 | { NULL, NULL } |
303 | }; | 303 | }; |
304 | 304 | ||
305 | static void idedisk_check_hpa(ide_drive_t *drive) | 305 | static u64 ide_disk_hpa_get_native_capacity(ide_drive_t *drive, int lba48) |
306 | { | 306 | { |
307 | unsigned long long capacity, set_max; | 307 | u64 capacity, set_max; |
308 | int lba48 = ata_id_lba48_enabled(drive->id); | ||
309 | 308 | ||
310 | capacity = drive->capacity64; | 309 | capacity = drive->capacity64; |
311 | 310 | set_max = idedisk_read_native_max_address(drive, lba48); | |
312 | set_max = idedisk_read_native_max_address(drive, lba48); | ||
313 | 311 | ||
314 | if (ide_in_drive_list(drive->id, hpa_list)) { | 312 | if (ide_in_drive_list(drive->id, hpa_list)) { |
315 | /* | 313 | /* |
@@ -320,9 +318,31 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
320 | set_max--; | 318 | set_max--; |
321 | } | 319 | } |
322 | 320 | ||
321 | return set_max; | ||
322 | } | ||
323 | |||
324 | static u64 ide_disk_hpa_set_capacity(ide_drive_t *drive, u64 set_max, int lba48) | ||
325 | { | ||
326 | set_max = idedisk_set_max_address(drive, set_max, lba48); | ||
327 | if (set_max) | ||
328 | drive->capacity64 = set_max; | ||
329 | |||
330 | return set_max; | ||
331 | } | ||
332 | |||
333 | static void idedisk_check_hpa(ide_drive_t *drive) | ||
334 | { | ||
335 | u64 capacity, set_max; | ||
336 | int lba48 = ata_id_lba48_enabled(drive->id); | ||
337 | |||
338 | capacity = drive->capacity64; | ||
339 | set_max = ide_disk_hpa_get_native_capacity(drive, lba48); | ||
340 | |||
323 | if (set_max <= capacity) | 341 | if (set_max <= capacity) |
324 | return; | 342 | return; |
325 | 343 | ||
344 | drive->probed_capacity = set_max; | ||
345 | |||
326 | printk(KERN_INFO "%s: Host Protected Area detected.\n" | 346 | printk(KERN_INFO "%s: Host Protected Area detected.\n" |
327 | "\tcurrent capacity is %llu sectors (%llu MB)\n" | 347 | "\tcurrent capacity is %llu sectors (%llu MB)\n" |
328 | "\tnative capacity is %llu sectors (%llu MB)\n", | 348 | "\tnative capacity is %llu sectors (%llu MB)\n", |
@@ -330,13 +350,13 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
330 | capacity, sectors_to_MB(capacity), | 350 | capacity, sectors_to_MB(capacity), |
331 | set_max, sectors_to_MB(set_max)); | 351 | set_max, sectors_to_MB(set_max)); |
332 | 352 | ||
333 | set_max = idedisk_set_max_address(drive, set_max, lba48); | 353 | if ((drive->dev_flags & IDE_DFLAG_NOHPA) == 0) |
354 | return; | ||
334 | 355 | ||
335 | if (set_max) { | 356 | set_max = ide_disk_hpa_set_capacity(drive, set_max, lba48); |
336 | drive->capacity64 = set_max; | 357 | if (set_max) |
337 | printk(KERN_INFO "%s: Host Protected Area disabled.\n", | 358 | printk(KERN_INFO "%s: Host Protected Area disabled.\n", |
338 | drive->name); | 359 | drive->name); |
339 | } | ||
340 | } | 360 | } |
341 | 361 | ||
342 | static int ide_disk_get_capacity(ide_drive_t *drive) | 362 | static int ide_disk_get_capacity(ide_drive_t *drive) |
@@ -358,6 +378,8 @@ static int ide_disk_get_capacity(ide_drive_t *drive) | |||
358 | drive->capacity64 = drive->cyl * drive->head * drive->sect; | 378 | drive->capacity64 = drive->cyl * drive->head * drive->sect; |
359 | } | 379 | } |
360 | 380 | ||
381 | drive->probed_capacity = drive->capacity64; | ||
382 | |||
361 | if (lba) { | 383 | if (lba) { |
362 | drive->dev_flags |= IDE_DFLAG_LBA; | 384 | drive->dev_flags |= IDE_DFLAG_LBA; |
363 | 385 | ||
@@ -376,7 +398,7 @@ static int ide_disk_get_capacity(ide_drive_t *drive) | |||
376 | "%llu sectors (%llu MB)\n", | 398 | "%llu sectors (%llu MB)\n", |
377 | drive->name, (unsigned long long)drive->capacity64, | 399 | drive->name, (unsigned long long)drive->capacity64, |
378 | sectors_to_MB(drive->capacity64)); | 400 | sectors_to_MB(drive->capacity64)); |
379 | drive->capacity64 = 1ULL << 28; | 401 | drive->probed_capacity = drive->capacity64 = 1ULL << 28; |
380 | } | 402 | } |
381 | 403 | ||
382 | if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && | 404 | if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && |
@@ -392,6 +414,34 @@ static int ide_disk_get_capacity(ide_drive_t *drive) | |||
392 | return 0; | 414 | return 0; |
393 | } | 415 | } |
394 | 416 | ||
417 | static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity) | ||
418 | { | ||
419 | u64 set = min(capacity, drive->probed_capacity); | ||
420 | u16 *id = drive->id; | ||
421 | int lba48 = ata_id_lba48_enabled(id); | ||
422 | |||
423 | if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 || | ||
424 | ata_id_hpa_enabled(id) == 0) | ||
425 | goto out; | ||
426 | |||
427 | /* | ||
428 | * according to the spec the SET MAX ADDRESS command shall be | ||
429 | * immediately preceded by a READ NATIVE MAX ADDRESS command | ||
430 | */ | ||
431 | capacity = ide_disk_hpa_get_native_capacity(drive, lba48); | ||
432 | if (capacity == 0) | ||
433 | goto out; | ||
434 | |||
435 | set = ide_disk_hpa_set_capacity(drive, set, lba48); | ||
436 | if (set) { | ||
437 | /* needed for ->resume to disable HPA */ | ||
438 | drive->dev_flags |= IDE_DFLAG_NOHPA; | ||
439 | return set; | ||
440 | } | ||
441 | out: | ||
442 | return drive->capacity64; | ||
443 | } | ||
444 | |||
395 | static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | 445 | static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) |
396 | { | 446 | { |
397 | ide_drive_t *drive = q->queuedata; | 447 | ide_drive_t *drive = q->queuedata; |
@@ -411,7 +461,6 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | |||
411 | cmd->protocol = ATA_PROT_NODATA; | 461 | cmd->protocol = ATA_PROT_NODATA; |
412 | 462 | ||
413 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; | 463 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
414 | rq->cmd_flags |= REQ_SOFTBARRIER; | ||
415 | rq->special = cmd; | 464 | rq->special = cmd; |
416 | } | 465 | } |
417 | 466 | ||
@@ -429,14 +478,14 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
429 | if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff)) | 478 | if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff)) |
430 | return -EINVAL; | 479 | return -EINVAL; |
431 | 480 | ||
432 | if (drive->special.b.set_multmode) | 481 | if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) |
433 | return -EBUSY; | 482 | return -EBUSY; |
434 | 483 | ||
435 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 484 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
436 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; | 485 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
437 | 486 | ||
438 | drive->mult_req = arg; | 487 | drive->mult_req = arg; |
439 | drive->special.b.set_multmode = 1; | 488 | drive->special_flags |= IDE_SFLAG_SET_MULTMODE; |
440 | error = blk_execute_rq(drive->queue, NULL, rq, 0); | 489 | error = blk_execute_rq(drive->queue, NULL, rq, 0); |
441 | blk_put_request(rq); | 490 | blk_put_request(rq); |
442 | 491 | ||
@@ -640,7 +689,7 @@ static void ide_disk_setup(ide_drive_t *drive) | |||
640 | } | 689 | } |
641 | 690 | ||
642 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, | 691 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, |
643 | q->max_sectors / 2); | 692 | queue_max_sectors(q) / 2); |
644 | 693 | ||
645 | if (ata_id_is_ssd(id)) | 694 | if (ata_id_is_ssd(id)) |
646 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); | 695 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); |
@@ -741,6 +790,7 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk, | |||
741 | 790 | ||
742 | const struct ide_disk_ops ide_ata_disk_ops = { | 791 | const struct ide_disk_ops ide_ata_disk_ops = { |
743 | .check = ide_disk_check, | 792 | .check = ide_disk_check, |
793 | .set_capacity = ide_disk_set_capacity, | ||
744 | .get_capacity = ide_disk_get_capacity, | 794 | .get_capacity = ide_disk_get_capacity, |
745 | .setup = ide_disk_setup, | 795 | .setup = ide_disk_setup, |
746 | .flush = ide_disk_flush, | 796 | .flush = ide_disk_flush, |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index a0b8cab1d9a6..219e6fb78dc6 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -103,7 +103,7 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive) | |||
103 | ide_finish_cmd(drive, cmd, stat); | 103 | ide_finish_cmd(drive, cmd, stat); |
104 | else | 104 | else |
105 | ide_complete_rq(drive, 0, | 105 | ide_complete_rq(drive, 0, |
106 | cmd->rq->nr_sectors << 9); | 106 | blk_rq_sectors(cmd->rq) << 9); |
107 | return ide_stopped; | 107 | return ide_stopped; |
108 | } | 108 | } |
109 | printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n", | 109 | printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n", |
@@ -347,7 +347,6 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode) | |||
347 | 347 | ||
348 | return mode; | 348 | return mode; |
349 | } | 349 | } |
350 | EXPORT_SYMBOL_GPL(ide_find_dma_mode); | ||
351 | 350 | ||
352 | static int ide_tune_dma(ide_drive_t *drive) | 351 | static int ide_tune_dma(ide_drive_t *drive) |
353 | { | 352 | { |
@@ -510,23 +509,11 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | |||
510 | /* | 509 | /* |
511 | * un-busy drive etc and make sure request is sane | 510 | * un-busy drive etc and make sure request is sane |
512 | */ | 511 | */ |
513 | |||
514 | rq = hwif->rq; | 512 | rq = hwif->rq; |
515 | if (!rq) | 513 | if (rq) { |
516 | goto out; | 514 | hwif->rq = NULL; |
517 | 515 | rq->errors = 0; | |
518 | hwif->rq = NULL; | 516 | } |
519 | |||
520 | rq->errors = 0; | ||
521 | |||
522 | if (!rq->bio) | ||
523 | goto out; | ||
524 | |||
525 | rq->sector = rq->bio->bi_sector; | ||
526 | rq->current_nr_sectors = bio_iovec(rq->bio)->bv_len >> 9; | ||
527 | rq->hard_cur_sectors = rq->current_nr_sectors; | ||
528 | rq->buffer = bio_data(rq->bio); | ||
529 | out: | ||
530 | return ret; | 517 | return ret; |
531 | } | 518 | } |
532 | 519 | ||
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c index 5d5fb961b5ce..2b9141979613 100644 --- a/drivers/ide/ide-eh.c +++ b/drivers/ide/ide-eh.c | |||
@@ -52,7 +52,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, | |||
52 | } | 52 | } |
53 | 53 | ||
54 | if ((rq->errors & ERROR_RECAL) == ERROR_RECAL) | 54 | if ((rq->errors & ERROR_RECAL) == ERROR_RECAL) |
55 | drive->special.b.recalibrate = 1; | 55 | drive->special_flags |= IDE_SFLAG_RECALIBRATE; |
56 | 56 | ||
57 | ++rq->errors; | 57 | ++rq->errors; |
58 | 58 | ||
@@ -268,9 +268,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive) | |||
268 | { | 268 | { |
269 | int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; | 269 | int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; |
270 | 270 | ||
271 | drive->special.all = 0; | 271 | drive->special_flags = |
272 | drive->special.b.set_geometry = legacy; | 272 | legacy ? (IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE) : 0; |
273 | drive->special.b.recalibrate = legacy; | ||
274 | 273 | ||
275 | drive->mult_count = 0; | 274 | drive->mult_count = 0; |
276 | drive->dev_flags &= ~IDE_DFLAG_PARKED; | 275 | drive->dev_flags &= ~IDE_DFLAG_PARKED; |
@@ -280,7 +279,7 @@ static void ide_disk_pre_reset(ide_drive_t *drive) | |||
280 | drive->mult_req = 0; | 279 | drive->mult_req = 0; |
281 | 280 | ||
282 | if (drive->mult_req != drive->mult_count) | 281 | if (drive->mult_req != drive->mult_count) |
283 | drive->special.b.set_multmode = 1; | 282 | drive->special_flags |= IDE_SFLAG_SET_MULTMODE; |
284 | } | 283 | } |
285 | 284 | ||
286 | static void pre_reset(ide_drive_t *drive) | 285 | static void pre_reset(ide_drive_t *drive) |
@@ -408,8 +407,9 @@ static ide_startstop_t do_reset1(ide_drive_t *drive, int do_not_try_atapi) | |||
408 | /* more than enough time */ | 407 | /* more than enough time */ |
409 | udelay(10); | 408 | udelay(10); |
410 | /* clear SRST, leave nIEN (unless device is on the quirk list) */ | 409 | /* clear SRST, leave nIEN (unless device is on the quirk list) */ |
411 | tp_ops->write_devctl(hwif, (drive->quirk_list == 2 ? 0 : ATA_NIEN) | | 410 | tp_ops->write_devctl(hwif, |
412 | ATA_DEVCTL_OBS); | 411 | ((drive->dev_flags & IDE_DFLAG_NIEN_QUIRK) ? 0 : ATA_NIEN) | |
412 | ATA_DEVCTL_OBS); | ||
413 | /* more than enough time */ | 413 | /* more than enough time */ |
414 | udelay(10); | 414 | udelay(10); |
415 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; | 415 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 2b4868d95f8b..650981758f15 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -134,13 +134,17 @@ static ide_startstop_t ide_floppy_issue_pc(ide_drive_t *drive, | |||
134 | drive->pc = pc; | 134 | drive->pc = pc; |
135 | 135 | ||
136 | if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { | 136 | if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { |
137 | unsigned int done = blk_rq_bytes(drive->hwif->rq); | ||
138 | |||
137 | if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) | 139 | if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) |
138 | ide_floppy_report_error(floppy, pc); | 140 | ide_floppy_report_error(floppy, pc); |
141 | |||
139 | /* Giving up */ | 142 | /* Giving up */ |
140 | pc->error = IDE_DRV_ERROR_GENERAL; | 143 | pc->error = IDE_DRV_ERROR_GENERAL; |
141 | 144 | ||
142 | drive->failed_pc = NULL; | 145 | drive->failed_pc = NULL; |
143 | drive->pc_callback(drive, 0); | 146 | drive->pc_callback(drive, 0); |
147 | ide_complete_rq(drive, -EIO, done); | ||
144 | return ide_stopped; | 148 | return ide_stopped; |
145 | } | 149 | } |
146 | 150 | ||
@@ -190,7 +194,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive, | |||
190 | { | 194 | { |
191 | struct ide_disk_obj *floppy = drive->driver_data; | 195 | struct ide_disk_obj *floppy = drive->driver_data; |
192 | int block = sector / floppy->bs_factor; | 196 | int block = sector / floppy->bs_factor; |
193 | int blocks = rq->nr_sectors / floppy->bs_factor; | 197 | int blocks = blk_rq_sectors(rq) / floppy->bs_factor; |
194 | int cmd = rq_data_dir(rq); | 198 | int cmd = rq_data_dir(rq); |
195 | 199 | ||
196 | ide_debug_log(IDE_DBG_FUNC, "block: %d, blocks: %d", block, blocks); | 200 | ide_debug_log(IDE_DBG_FUNC, "block: %d, blocks: %d", block, blocks); |
@@ -216,16 +220,14 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy, | |||
216 | ide_init_pc(pc); | 220 | ide_init_pc(pc); |
217 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); | 221 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); |
218 | pc->rq = rq; | 222 | pc->rq = rq; |
219 | if (rq->data_len && rq_data_dir(rq) == WRITE) | 223 | if (blk_rq_bytes(rq)) { |
220 | pc->flags |= PC_FLAG_WRITING; | ||
221 | pc->buf = rq->data; | ||
222 | if (rq->bio) | ||
223 | pc->flags |= PC_FLAG_DMA_OK; | 224 | pc->flags |= PC_FLAG_DMA_OK; |
224 | /* | 225 | if (rq_data_dir(rq) == WRITE) |
225 | * possibly problematic, doesn't look like ide-floppy correctly | 226 | pc->flags |= PC_FLAG_WRITING; |
226 | * handled scattered requests if dma fails... | 227 | } |
227 | */ | 228 | /* pio will be performed by ide_pio_bytes() which handles sg fine */ |
228 | pc->req_xfer = pc->buf_size = rq->data_len; | 229 | pc->buf = NULL; |
230 | pc->req_xfer = pc->buf_size = blk_rq_bytes(rq); | ||
229 | } | 231 | } |
230 | 232 | ||
231 | static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | 233 | static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, |
@@ -257,16 +259,16 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
257 | goto out_end; | 259 | goto out_end; |
258 | } | 260 | } |
259 | if (blk_fs_request(rq)) { | 261 | if (blk_fs_request(rq)) { |
260 | if (((long)rq->sector % floppy->bs_factor) || | 262 | if (((long)blk_rq_pos(rq) % floppy->bs_factor) || |
261 | (rq->nr_sectors % floppy->bs_factor)) { | 263 | (blk_rq_sectors(rq) % floppy->bs_factor)) { |
262 | printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", | 264 | printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", |
263 | drive->name); | 265 | drive->name); |
264 | goto out_end; | 266 | goto out_end; |
265 | } | 267 | } |
266 | pc = &floppy->queued_pc; | 268 | pc = &floppy->queued_pc; |
267 | idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); | 269 | idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); |
268 | } else if (blk_special_request(rq)) { | 270 | } else if (blk_special_request(rq) || blk_sense_request(rq)) { |
269 | pc = (struct ide_atapi_pc *) rq->buffer; | 271 | pc = (struct ide_atapi_pc *)rq->special; |
270 | } else if (blk_pc_request(rq)) { | 272 | } else if (blk_pc_request(rq)) { |
271 | pc = &floppy->queued_pc; | 273 | pc = &floppy->queued_pc; |
272 | idefloppy_blockpc_cmd(floppy, pc, rq); | 274 | idefloppy_blockpc_cmd(floppy, pc, rq); |
@@ -275,6 +277,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
275 | goto out_end; | 277 | goto out_end; |
276 | } | 278 | } |
277 | 279 | ||
280 | ide_prep_sense(drive, rq); | ||
281 | |||
278 | memset(&cmd, 0, sizeof(cmd)); | 282 | memset(&cmd, 0, sizeof(cmd)); |
279 | 283 | ||
280 | if (rq_data_dir(rq)) | 284 | if (rq_data_dir(rq)) |
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 4b6b71e2cdf5..214119026b3f 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c | |||
@@ -287,6 +287,19 @@ static int ide_gd_media_changed(struct gendisk *disk) | |||
287 | return ret; | 287 | return ret; |
288 | } | 288 | } |
289 | 289 | ||
290 | static unsigned long long ide_gd_set_capacity(struct gendisk *disk, | ||
291 | unsigned long long capacity) | ||
292 | { | ||
293 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); | ||
294 | ide_drive_t *drive = idkp->drive; | ||
295 | const struct ide_disk_ops *disk_ops = drive->disk_ops; | ||
296 | |||
297 | if (disk_ops->set_capacity) | ||
298 | return disk_ops->set_capacity(drive, capacity); | ||
299 | |||
300 | return drive->capacity64; | ||
301 | } | ||
302 | |||
290 | static int ide_gd_revalidate_disk(struct gendisk *disk) | 303 | static int ide_gd_revalidate_disk(struct gendisk *disk) |
291 | { | 304 | { |
292 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); | 305 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); |
@@ -315,6 +328,7 @@ static struct block_device_operations ide_gd_ops = { | |||
315 | .locked_ioctl = ide_gd_ioctl, | 328 | .locked_ioctl = ide_gd_ioctl, |
316 | .getgeo = ide_gd_getgeo, | 329 | .getgeo = ide_gd_getgeo, |
317 | .media_changed = ide_gd_media_changed, | 330 | .media_changed = ide_gd_media_changed, |
331 | .set_capacity = ide_gd_set_capacity, | ||
318 | .revalidate_disk = ide_gd_revalidate_disk | 332 | .revalidate_disk = ide_gd_revalidate_disk |
319 | }; | 333 | }; |
320 | 334 | ||
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 7812ca0be13b..54d7c4685d23 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -29,6 +29,7 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports"); | |||
29 | 29 | ||
30 | static const struct ide_port_info ide_generic_port_info = { | 30 | static const struct ide_port_info ide_generic_port_info = { |
31 | .host_flags = IDE_HFLAG_NO_DMA, | 31 | .host_flags = IDE_HFLAG_NO_DMA, |
32 | .chipset = ide_generic, | ||
32 | }; | 33 | }; |
33 | 34 | ||
34 | #ifdef CONFIG_ARM | 35 | #ifdef CONFIG_ARM |
@@ -85,7 +86,7 @@ static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) | |||
85 | 86 | ||
86 | static int __init ide_generic_init(void) | 87 | static int __init ide_generic_init(void) |
87 | { | 88 | { |
88 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 89 | struct ide_hw hw, *hws[] = { &hw }; |
89 | unsigned long io_addr; | 90 | unsigned long io_addr; |
90 | int i, rc = 0, primary = 0, secondary = 0; | 91 | int i, rc = 0, primary = 0, secondary = 0; |
91 | 92 | ||
@@ -132,9 +133,7 @@ static int __init ide_generic_init(void) | |||
132 | #else | 133 | #else |
133 | hw.irq = legacy_irqs[i]; | 134 | hw.irq = legacy_irqs[i]; |
134 | #endif | 135 | #endif |
135 | hw.chipset = ide_generic; | 136 | rc = ide_host_add(&ide_generic_port_info, hws, 1, NULL); |
136 | |||
137 | rc = ide_host_add(&ide_generic_port_info, hws, NULL); | ||
138 | if (rc) { | 137 | if (rc) { |
139 | release_region(io_addr + 0x206, 1); | 138 | release_region(io_addr + 0x206, 1); |
140 | release_region(io_addr, 8); | 139 | release_region(io_addr, 8); |
diff --git a/drivers/ide/ide-h8300.c b/drivers/ide/ide-h8300.c index c06ebdc4a130..520f42c5445a 100644 --- a/drivers/ide/ide-h8300.c +++ b/drivers/ide/ide-h8300.c | |||
@@ -64,26 +64,26 @@ static const struct ide_tp_ops h8300_tp_ops = { | |||
64 | 64 | ||
65 | #define H8300_IDE_GAP (2) | 65 | #define H8300_IDE_GAP (2) |
66 | 66 | ||
67 | static inline void hw_setup(hw_regs_t *hw) | 67 | static inline void hw_setup(struct ide_hw *hw) |
68 | { | 68 | { |
69 | int i; | 69 | int i; |
70 | 70 | ||
71 | memset(hw, 0, sizeof(hw_regs_t)); | 71 | memset(hw, 0, sizeof(*hw)); |
72 | for (i = 0; i <= 7; i++) | 72 | for (i = 0; i <= 7; i++) |
73 | hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; | 73 | hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i; |
74 | hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT; | 74 | hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT; |
75 | hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; | 75 | hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ; |
76 | hw->chipset = ide_generic; | ||
77 | } | 76 | } |
78 | 77 | ||
79 | static const struct ide_port_info h8300_port_info = { | 78 | static const struct ide_port_info h8300_port_info = { |
80 | .tp_ops = &h8300_tp_ops, | 79 | .tp_ops = &h8300_tp_ops, |
81 | .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, | 80 | .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, |
81 | .chipset = ide_generic, | ||
82 | }; | 82 | }; |
83 | 83 | ||
84 | static int __init h8300_ide_init(void) | 84 | static int __init h8300_ide_init(void) |
85 | { | 85 | { |
86 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 86 | struct ide_hw hw, *hws[] = { &hw }; |
87 | 87 | ||
88 | printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); | 88 | printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); |
89 | 89 | ||
@@ -96,7 +96,7 @@ static int __init h8300_ide_init(void) | |||
96 | 96 | ||
97 | hw_setup(&hw); | 97 | hw_setup(&hw); |
98 | 98 | ||
99 | return ide_host_add(&h8300_port_info, hws, NULL); | 99 | return ide_host_add(&h8300_port_info, hws, 1, NULL); |
100 | 100 | ||
101 | out_busy: | 101 | out_busy: |
102 | printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n"); | 102 | printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n"); |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 35dc38d3b2c5..272cc38f6dbe 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -116,9 +116,9 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err) | |||
116 | unsigned int ide_rq_bytes(struct request *rq) | 116 | unsigned int ide_rq_bytes(struct request *rq) |
117 | { | 117 | { |
118 | if (blk_pc_request(rq)) | 118 | if (blk_pc_request(rq)) |
119 | return rq->data_len; | 119 | return blk_rq_bytes(rq); |
120 | else | 120 | else |
121 | return rq->hard_cur_sectors << 9; | 121 | return blk_rq_cur_sectors(rq) << 9; |
122 | } | 122 | } |
123 | EXPORT_SYMBOL_GPL(ide_rq_bytes); | 123 | EXPORT_SYMBOL_GPL(ide_rq_bytes); |
124 | 124 | ||
@@ -133,7 +133,7 @@ int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes) | |||
133 | * and complete the whole request right now | 133 | * and complete the whole request right now |
134 | */ | 134 | */ |
135 | if (blk_noretry_request(rq) && error <= 0) | 135 | if (blk_noretry_request(rq) && error <= 0) |
136 | nr_bytes = rq->hard_nr_sectors << 9; | 136 | nr_bytes = blk_rq_sectors(rq) << 9; |
137 | 137 | ||
138 | rc = ide_end_rq(drive, rq, error, nr_bytes); | 138 | rc = ide_end_rq(drive, rq, error, nr_bytes); |
139 | if (rc == 0) | 139 | if (rc == 0) |
@@ -184,29 +184,42 @@ static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | |||
184 | tf->command = ATA_CMD_SET_MULTI; | 184 | tf->command = ATA_CMD_SET_MULTI; |
185 | } | 185 | } |
186 | 186 | ||
187 | static ide_startstop_t ide_disk_special(ide_drive_t *drive) | 187 | /** |
188 | * do_special - issue some special commands | ||
189 | * @drive: drive the command is for | ||
190 | * | ||
191 | * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS, | ||
192 | * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive. | ||
193 | */ | ||
194 | |||
195 | static ide_startstop_t do_special(ide_drive_t *drive) | ||
188 | { | 196 | { |
189 | special_t *s = &drive->special; | ||
190 | struct ide_cmd cmd; | 197 | struct ide_cmd cmd; |
191 | 198 | ||
199 | #ifdef DEBUG | ||
200 | printk(KERN_DEBUG "%s: %s: 0x%02x\n", drive->name, __func__, | ||
201 | drive->special_flags); | ||
202 | #endif | ||
203 | if (drive->media != ide_disk) { | ||
204 | drive->special_flags = 0; | ||
205 | drive->mult_req = 0; | ||
206 | return ide_stopped; | ||
207 | } | ||
208 | |||
192 | memset(&cmd, 0, sizeof(cmd)); | 209 | memset(&cmd, 0, sizeof(cmd)); |
193 | cmd.protocol = ATA_PROT_NODATA; | 210 | cmd.protocol = ATA_PROT_NODATA; |
194 | 211 | ||
195 | if (s->b.set_geometry) { | 212 | if (drive->special_flags & IDE_SFLAG_SET_GEOMETRY) { |
196 | s->b.set_geometry = 0; | 213 | drive->special_flags &= ~IDE_SFLAG_SET_GEOMETRY; |
197 | ide_tf_set_specify_cmd(drive, &cmd.tf); | 214 | ide_tf_set_specify_cmd(drive, &cmd.tf); |
198 | } else if (s->b.recalibrate) { | 215 | } else if (drive->special_flags & IDE_SFLAG_RECALIBRATE) { |
199 | s->b.recalibrate = 0; | 216 | drive->special_flags &= ~IDE_SFLAG_RECALIBRATE; |
200 | ide_tf_set_restore_cmd(drive, &cmd.tf); | 217 | ide_tf_set_restore_cmd(drive, &cmd.tf); |
201 | } else if (s->b.set_multmode) { | 218 | } else if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) { |
202 | s->b.set_multmode = 0; | 219 | drive->special_flags &= ~IDE_SFLAG_SET_MULTMODE; |
203 | ide_tf_set_setmult_cmd(drive, &cmd.tf); | 220 | ide_tf_set_setmult_cmd(drive, &cmd.tf); |
204 | } else if (s->all) { | 221 | } else |
205 | int special = s->all; | 222 | BUG(); |
206 | s->all = 0; | ||
207 | printk(KERN_ERR "%s: bad special flag: 0x%02x\n", drive->name, special); | ||
208 | return ide_stopped; | ||
209 | } | ||
210 | 223 | ||
211 | cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; | 224 | cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; |
212 | cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; | 225 | cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; |
@@ -217,45 +230,13 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) | |||
217 | return ide_started; | 230 | return ide_started; |
218 | } | 231 | } |
219 | 232 | ||
220 | /** | ||
221 | * do_special - issue some special commands | ||
222 | * @drive: drive the command is for | ||
223 | * | ||
224 | * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS, | ||
225 | * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive. | ||
226 | * | ||
227 | * It used to do much more, but has been scaled back. | ||
228 | */ | ||
229 | |||
230 | static ide_startstop_t do_special (ide_drive_t *drive) | ||
231 | { | ||
232 | special_t *s = &drive->special; | ||
233 | |||
234 | #ifdef DEBUG | ||
235 | printk("%s: do_special: 0x%02x\n", drive->name, s->all); | ||
236 | #endif | ||
237 | if (drive->media == ide_disk) | ||
238 | return ide_disk_special(drive); | ||
239 | |||
240 | s->all = 0; | ||
241 | drive->mult_req = 0; | ||
242 | return ide_stopped; | ||
243 | } | ||
244 | |||
245 | void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd) | 233 | void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd) |
246 | { | 234 | { |
247 | ide_hwif_t *hwif = drive->hwif; | 235 | ide_hwif_t *hwif = drive->hwif; |
248 | struct scatterlist *sg = hwif->sg_table; | 236 | struct scatterlist *sg = hwif->sg_table; |
249 | struct request *rq = cmd->rq; | 237 | struct request *rq = cmd->rq; |
250 | 238 | ||
251 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { | 239 | cmd->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); |
252 | sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE); | ||
253 | cmd->sg_nents = 1; | ||
254 | } else if (!rq->bio) { | ||
255 | sg_init_one(sg, rq->data, rq->data_len); | ||
256 | cmd->sg_nents = 1; | ||
257 | } else | ||
258 | cmd->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); | ||
259 | } | 240 | } |
260 | EXPORT_SYMBOL_GPL(ide_map_sg); | 241 | EXPORT_SYMBOL_GPL(ide_map_sg); |
261 | 242 | ||
@@ -286,7 +267,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, | |||
286 | 267 | ||
287 | if (cmd) { | 268 | if (cmd) { |
288 | if (cmd->protocol == ATA_PROT_PIO) { | 269 | if (cmd->protocol == ATA_PROT_PIO) { |
289 | ide_init_sg_cmd(cmd, rq->nr_sectors << 9); | 270 | ide_init_sg_cmd(cmd, blk_rq_sectors(rq) << 9); |
290 | ide_map_sg(drive, cmd); | 271 | ide_map_sg(drive, cmd); |
291 | } | 272 | } |
292 | 273 | ||
@@ -358,7 +339,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
358 | printk(KERN_ERR "%s: drive not ready for command\n", drive->name); | 339 | printk(KERN_ERR "%s: drive not ready for command\n", drive->name); |
359 | return startstop; | 340 | return startstop; |
360 | } | 341 | } |
361 | if (!drive->special.all) { | 342 | |
343 | if (drive->special_flags == 0) { | ||
362 | struct ide_driver *drv; | 344 | struct ide_driver *drv; |
363 | 345 | ||
364 | /* | 346 | /* |
@@ -371,7 +353,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
371 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) | 353 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) |
372 | return execute_drive_cmd(drive, rq); | 354 | return execute_drive_cmd(drive, rq); |
373 | else if (blk_pm_request(rq)) { | 355 | else if (blk_pm_request(rq)) { |
374 | struct request_pm_state *pm = rq->data; | 356 | struct request_pm_state *pm = rq->special; |
375 | #ifdef DEBUG_PM | 357 | #ifdef DEBUG_PM |
376 | printk("%s: start_power_step(step: %d)\n", | 358 | printk("%s: start_power_step(step: %d)\n", |
377 | drive->name, pm->pm_step); | 359 | drive->name, pm->pm_step); |
@@ -394,7 +376,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
394 | 376 | ||
395 | drv = *(struct ide_driver **)rq->rq_disk->private_data; | 377 | drv = *(struct ide_driver **)rq->rq_disk->private_data; |
396 | 378 | ||
397 | return drv->do_request(drive, rq, rq->sector); | 379 | return drv->do_request(drive, rq, blk_rq_pos(rq)); |
398 | } | 380 | } |
399 | return do_special(drive); | 381 | return do_special(drive); |
400 | kill_rq: | 382 | kill_rq: |
@@ -484,6 +466,9 @@ void do_ide_request(struct request_queue *q) | |||
484 | 466 | ||
485 | spin_unlock_irq(q->queue_lock); | 467 | spin_unlock_irq(q->queue_lock); |
486 | 468 | ||
469 | /* HLD do_request() callback might sleep, make sure it's okay */ | ||
470 | might_sleep(); | ||
471 | |||
487 | if (ide_lock_host(host, hwif)) | 472 | if (ide_lock_host(host, hwif)) |
488 | goto plug_device_2; | 473 | goto plug_device_2; |
489 | 474 | ||
@@ -491,10 +476,10 @@ void do_ide_request(struct request_queue *q) | |||
491 | 476 | ||
492 | if (!ide_lock_port(hwif)) { | 477 | if (!ide_lock_port(hwif)) { |
493 | ide_hwif_t *prev_port; | 478 | ide_hwif_t *prev_port; |
479 | |||
480 | WARN_ON_ONCE(hwif->rq); | ||
494 | repeat: | 481 | repeat: |
495 | prev_port = hwif->host->cur_port; | 482 | prev_port = hwif->host->cur_port; |
496 | hwif->rq = NULL; | ||
497 | |||
498 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && | 483 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && |
499 | time_after(drive->sleep, jiffies)) { | 484 | time_after(drive->sleep, jiffies)) { |
500 | ide_unlock_port(hwif); | 485 | ide_unlock_port(hwif); |
@@ -503,11 +488,15 @@ repeat: | |||
503 | 488 | ||
504 | if ((hwif->host->host_flags & IDE_HFLAG_SERIALIZE) && | 489 | if ((hwif->host->host_flags & IDE_HFLAG_SERIALIZE) && |
505 | hwif != prev_port) { | 490 | hwif != prev_port) { |
491 | ide_drive_t *cur_dev = | ||
492 | prev_port ? prev_port->cur_dev : NULL; | ||
493 | |||
506 | /* | 494 | /* |
507 | * set nIEN for previous port, drives in the | 495 | * set nIEN for previous port, drives in the |
508 | * quirk_list may not like intr setups/cleanups | 496 | * quirk list may not like intr setups/cleanups |
509 | */ | 497 | */ |
510 | if (prev_port && prev_port->cur_dev->quirk_list == 0) | 498 | if (cur_dev && |
499 | (cur_dev->dev_flags & IDE_DFLAG_NIEN_QUIRK) == 0) | ||
511 | prev_port->tp_ops->write_devctl(prev_port, | 500 | prev_port->tp_ops->write_devctl(prev_port, |
512 | ATA_NIEN | | 501 | ATA_NIEN | |
513 | ATA_DEVCTL_OBS); | 502 | ATA_DEVCTL_OBS); |
@@ -523,7 +512,9 @@ repeat: | |||
523 | * we know that the queue isn't empty, but this can happen | 512 | * we know that the queue isn't empty, but this can happen |
524 | * if the q->prep_rq_fn() decides to kill a request | 513 | * if the q->prep_rq_fn() decides to kill a request |
525 | */ | 514 | */ |
526 | rq = elv_next_request(drive->queue); | 515 | if (!rq) |
516 | rq = blk_fetch_request(drive->queue); | ||
517 | |||
527 | spin_unlock_irq(q->queue_lock); | 518 | spin_unlock_irq(q->queue_lock); |
528 | spin_lock_irq(&hwif->lock); | 519 | spin_lock_irq(&hwif->lock); |
529 | 520 | ||
@@ -535,7 +526,7 @@ repeat: | |||
535 | /* | 526 | /* |
536 | * Sanity: don't accept a request that isn't a PM request | 527 | * Sanity: don't accept a request that isn't a PM request |
537 | * if we are currently power managed. This is very important as | 528 | * if we are currently power managed. This is very important as |
538 | * blk_stop_queue() doesn't prevent the elv_next_request() | 529 | * blk_stop_queue() doesn't prevent the blk_fetch_request() |
539 | * above to return us whatever is in the queue. Since we call | 530 | * above to return us whatever is in the queue. Since we call |
540 | * ide_do_request() ourselves, we end up taking requests while | 531 | * ide_do_request() ourselves, we end up taking requests while |
541 | * the queue is blocked... | 532 | * the queue is blocked... |
@@ -559,8 +550,11 @@ repeat: | |||
559 | startstop = start_request(drive, rq); | 550 | startstop = start_request(drive, rq); |
560 | spin_lock_irq(&hwif->lock); | 551 | spin_lock_irq(&hwif->lock); |
561 | 552 | ||
562 | if (startstop == ide_stopped) | 553 | if (startstop == ide_stopped) { |
554 | rq = hwif->rq; | ||
555 | hwif->rq = NULL; | ||
563 | goto repeat; | 556 | goto repeat; |
557 | } | ||
564 | } else | 558 | } else |
565 | goto plug_device; | 559 | goto plug_device; |
566 | out: | 560 | out: |
@@ -576,18 +570,24 @@ plug_device: | |||
576 | plug_device_2: | 570 | plug_device_2: |
577 | spin_lock_irq(q->queue_lock); | 571 | spin_lock_irq(q->queue_lock); |
578 | 572 | ||
573 | if (rq) | ||
574 | blk_requeue_request(q, rq); | ||
579 | if (!elv_queue_empty(q)) | 575 | if (!elv_queue_empty(q)) |
580 | blk_plug_device(q); | 576 | blk_plug_device(q); |
581 | } | 577 | } |
582 | 578 | ||
583 | static void ide_plug_device(ide_drive_t *drive) | 579 | static void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) |
584 | { | 580 | { |
585 | struct request_queue *q = drive->queue; | 581 | struct request_queue *q = drive->queue; |
586 | unsigned long flags; | 582 | unsigned long flags; |
587 | 583 | ||
588 | spin_lock_irqsave(q->queue_lock, flags); | 584 | spin_lock_irqsave(q->queue_lock, flags); |
585 | |||
586 | if (rq) | ||
587 | blk_requeue_request(q, rq); | ||
589 | if (!elv_queue_empty(q)) | 588 | if (!elv_queue_empty(q)) |
590 | blk_plug_device(q); | 589 | blk_plug_device(q); |
590 | |||
591 | spin_unlock_irqrestore(q->queue_lock, flags); | 591 | spin_unlock_irqrestore(q->queue_lock, flags); |
592 | } | 592 | } |
593 | 593 | ||
@@ -636,6 +636,7 @@ void ide_timer_expiry (unsigned long data) | |||
636 | unsigned long flags; | 636 | unsigned long flags; |
637 | int wait = -1; | 637 | int wait = -1; |
638 | int plug_device = 0; | 638 | int plug_device = 0; |
639 | struct request *uninitialized_var(rq_in_flight); | ||
639 | 640 | ||
640 | spin_lock_irqsave(&hwif->lock, flags); | 641 | spin_lock_irqsave(&hwif->lock, flags); |
641 | 642 | ||
@@ -696,7 +697,9 @@ void ide_timer_expiry (unsigned long data) | |||
696 | } | 697 | } |
697 | spin_lock_irq(&hwif->lock); | 698 | spin_lock_irq(&hwif->lock); |
698 | enable_irq(hwif->irq); | 699 | enable_irq(hwif->irq); |
699 | if (startstop == ide_stopped) { | 700 | if (startstop == ide_stopped && hwif->polling == 0) { |
701 | rq_in_flight = hwif->rq; | ||
702 | hwif->rq = NULL; | ||
700 | ide_unlock_port(hwif); | 703 | ide_unlock_port(hwif); |
701 | plug_device = 1; | 704 | plug_device = 1; |
702 | } | 705 | } |
@@ -705,7 +708,7 @@ void ide_timer_expiry (unsigned long data) | |||
705 | 708 | ||
706 | if (plug_device) { | 709 | if (plug_device) { |
707 | ide_unlock_host(hwif->host); | 710 | ide_unlock_host(hwif->host); |
708 | ide_plug_device(drive); | 711 | ide_requeue_and_plug(drive, rq_in_flight); |
709 | } | 712 | } |
710 | } | 713 | } |
711 | 714 | ||
@@ -791,6 +794,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
791 | ide_startstop_t startstop; | 794 | ide_startstop_t startstop; |
792 | irqreturn_t irq_ret = IRQ_NONE; | 795 | irqreturn_t irq_ret = IRQ_NONE; |
793 | int plug_device = 0; | 796 | int plug_device = 0; |
797 | struct request *uninitialized_var(rq_in_flight); | ||
794 | 798 | ||
795 | if (host->host_flags & IDE_HFLAG_SERIALIZE) { | 799 | if (host->host_flags & IDE_HFLAG_SERIALIZE) { |
796 | if (hwif != host->cur_port) | 800 | if (hwif != host->cur_port) |
@@ -868,8 +872,10 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
868 | * same irq as is currently being serviced here, and Linux | 872 | * same irq as is currently being serviced here, and Linux |
869 | * won't allow another of the same (on any CPU) until we return. | 873 | * won't allow another of the same (on any CPU) until we return. |
870 | */ | 874 | */ |
871 | if (startstop == ide_stopped) { | 875 | if (startstop == ide_stopped && hwif->polling == 0) { |
872 | BUG_ON(hwif->handler); | 876 | BUG_ON(hwif->handler); |
877 | rq_in_flight = hwif->rq; | ||
878 | hwif->rq = NULL; | ||
873 | ide_unlock_port(hwif); | 879 | ide_unlock_port(hwif); |
874 | plug_device = 1; | 880 | plug_device = 1; |
875 | } | 881 | } |
@@ -879,7 +885,7 @@ out: | |||
879 | out_early: | 885 | out_early: |
880 | if (plug_device) { | 886 | if (plug_device) { |
881 | ide_unlock_host(hwif->host); | 887 | ide_unlock_host(hwif->host); |
882 | ide_plug_device(drive); | 888 | ide_requeue_and_plug(drive, rq_in_flight); |
883 | } | 889 | } |
884 | 890 | ||
885 | return irq_ret; | 891 | return irq_ret; |
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c index c1c25ebbaa1f..5991b23793f2 100644 --- a/drivers/ide/ide-ioctls.c +++ b/drivers/ide/ide-ioctls.c | |||
@@ -231,7 +231,6 @@ static int generic_drive_reset(ide_drive_t *drive) | |||
231 | rq->cmd_type = REQ_TYPE_SPECIAL; | 231 | rq->cmd_type = REQ_TYPE_SPECIAL; |
232 | rq->cmd_len = 1; | 232 | rq->cmd_len = 1; |
233 | rq->cmd[0] = REQ_DRIVE_RESET; | 233 | rq->cmd[0] = REQ_DRIVE_RESET; |
234 | rq->cmd_flags |= REQ_SOFTBARRIER; | ||
235 | if (blk_execute_rq(drive->queue, NULL, rq, 1)) | 234 | if (blk_execute_rq(drive->queue, NULL, rq, 1)) |
236 | ret = rq->errors; | 235 | ret = rq->errors; |
237 | blk_put_request(rq); | 236 | blk_put_request(rq); |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index c19a221b1e18..fa047150a1c6 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -206,8 +206,6 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list); | |||
206 | 206 | ||
207 | /* | 207 | /* |
208 | * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. | 208 | * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. |
209 | * We list them here and depend on the device side cable detection for them. | ||
210 | * | ||
211 | * Some optical devices with the buggy firmwares have the same problem. | 209 | * Some optical devices with the buggy firmwares have the same problem. |
212 | */ | 210 | */ |
213 | static const struct drive_list_entry ivb_list[] = { | 211 | static const struct drive_list_entry ivb_list[] = { |
@@ -251,10 +249,25 @@ u8 eighty_ninty_three(ide_drive_t *drive) | |||
251 | * - force bit13 (80c cable present) check also for !ivb devices | 249 | * - force bit13 (80c cable present) check also for !ivb devices |
252 | * (unless the slave device is pre-ATA3) | 250 | * (unless the slave device is pre-ATA3) |
253 | */ | 251 | */ |
254 | if ((id[ATA_ID_HW_CONFIG] & 0x4000) || | 252 | if (id[ATA_ID_HW_CONFIG] & 0x4000) |
255 | (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000))) | ||
256 | return 1; | 253 | return 1; |
257 | 254 | ||
255 | if (ivb) { | ||
256 | const char *model = (char *)&id[ATA_ID_PROD]; | ||
257 | |||
258 | if (strstr(model, "TSSTcorp CDDVDW SH-S202")) { | ||
259 | /* | ||
260 | * These ATAPI devices always report 80c cable | ||
261 | * so we have to depend on the host in this case. | ||
262 | */ | ||
263 | if (hwif->cbl == ATA_CBL_PATA80) | ||
264 | return 1; | ||
265 | } else { | ||
266 | /* Depend on the device side cable detection. */ | ||
267 | if (id[ATA_ID_HW_CONFIG] & 0x2000) | ||
268 | return 1; | ||
269 | } | ||
270 | } | ||
258 | no_80w: | 271 | no_80w: |
259 | if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED) | 272 | if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED) |
260 | return 0; | 273 | return 0; |
@@ -269,6 +282,29 @@ no_80w: | |||
269 | return 0; | 282 | return 0; |
270 | } | 283 | } |
271 | 284 | ||
285 | static const char *nien_quirk_list[] = { | ||
286 | "QUANTUM FIREBALLlct08 08", | ||
287 | "QUANTUM FIREBALLP KA6.4", | ||
288 | "QUANTUM FIREBALLP KA9.1", | ||
289 | "QUANTUM FIREBALLP KX13.6", | ||
290 | "QUANTUM FIREBALLP KX20.5", | ||
291 | "QUANTUM FIREBALLP KX27.3", | ||
292 | "QUANTUM FIREBALLP LM20.4", | ||
293 | "QUANTUM FIREBALLP LM20.5", | ||
294 | NULL | ||
295 | }; | ||
296 | |||
297 | void ide_check_nien_quirk_list(ide_drive_t *drive) | ||
298 | { | ||
299 | const char **list, *m = (char *)&drive->id[ATA_ID_PROD]; | ||
300 | |||
301 | for (list = nien_quirk_list; *list != NULL; list++) | ||
302 | if (strstr(m, *list) != NULL) { | ||
303 | drive->dev_flags |= IDE_DFLAG_NIEN_QUIRK; | ||
304 | return; | ||
305 | } | ||
306 | } | ||
307 | |||
272 | int ide_driveid_update(ide_drive_t *drive) | 308 | int ide_driveid_update(ide_drive_t *drive) |
273 | { | 309 | { |
274 | u16 *id; | 310 | u16 *id; |
@@ -298,7 +334,6 @@ int ide_driveid_update(ide_drive_t *drive) | |||
298 | 334 | ||
299 | return 1; | 335 | return 1; |
300 | out_err: | 336 | out_err: |
301 | SELECT_MASK(drive, 0); | ||
302 | if (rc == 2) | 337 | if (rc == 2) |
303 | printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__); | 338 | printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__); |
304 | kfree(id); | 339 | kfree(id); |
@@ -352,7 +387,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
352 | 387 | ||
353 | tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); | 388 | tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); |
354 | 389 | ||
355 | if (drive->quirk_list == 2) | 390 | if (drive->dev_flags & IDE_DFLAG_NIEN_QUIRK) |
356 | tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); | 391 | tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); |
357 | 392 | ||
358 | error = __ide_wait_stat(drive, drive->ready_stat, | 393 | error = __ide_wait_stat(drive, drive->ready_stat, |
diff --git a/drivers/ide/ide-legacy.c b/drivers/ide/ide-legacy.c index 8c5dcbf22547..b9654a7bb7be 100644 --- a/drivers/ide/ide-legacy.c +++ b/drivers/ide/ide-legacy.c | |||
@@ -1,7 +1,7 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/ide.h> | 2 | #include <linux/ide.h> |
3 | 3 | ||
4 | static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw, | 4 | static void ide_legacy_init_one(struct ide_hw **hws, struct ide_hw *hw, |
5 | u8 port_no, const struct ide_port_info *d, | 5 | u8 port_no, const struct ide_port_info *d, |
6 | unsigned long config) | 6 | unsigned long config) |
7 | { | 7 | { |
@@ -33,7 +33,6 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw, | |||
33 | 33 | ||
34 | ide_std_init_ports(hw, base, ctl); | 34 | ide_std_init_ports(hw, base, ctl); |
35 | hw->irq = irq; | 35 | hw->irq = irq; |
36 | hw->chipset = d->chipset; | ||
37 | hw->config = config; | 36 | hw->config = config; |
38 | 37 | ||
39 | hws[port_no] = hw; | 38 | hws[port_no] = hw; |
@@ -41,7 +40,7 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw, | |||
41 | 40 | ||
42 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) | 41 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) |
43 | { | 42 | { |
44 | hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; | 43 | struct ide_hw hw[2], *hws[] = { NULL, NULL }; |
45 | 44 | ||
46 | memset(&hw, 0, sizeof(hw)); | 45 | memset(&hw, 0, sizeof(hw)); |
47 | 46 | ||
@@ -53,6 +52,6 @@ int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) | |||
53 | (d->host_flags & IDE_HFLAG_SINGLE)) | 52 | (d->host_flags & IDE_HFLAG_SINGLE)) |
54 | return -ENOENT; | 53 | return -ENOENT; |
55 | 54 | ||
56 | return ide_host_add(d, hws, NULL); | 55 | return ide_host_add(d, hws, 2, NULL); |
57 | } | 56 | } |
58 | EXPORT_SYMBOL_GPL(ide_legacy_device_add); | 57 | EXPORT_SYMBOL_GPL(ide_legacy_device_add); |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 56ff8c46c7d1..e386a32dc9ba 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -31,24 +31,6 @@ void ide_toggle_bounce(ide_drive_t *drive, int on) | |||
31 | blk_queue_bounce_limit(drive->queue, addr); | 31 | blk_queue_bounce_limit(drive->queue, addr); |
32 | } | 32 | } |
33 | 33 | ||
34 | static void ide_dump_opcode(ide_drive_t *drive) | ||
35 | { | ||
36 | struct request *rq = drive->hwif->rq; | ||
37 | struct ide_cmd *cmd = NULL; | ||
38 | |||
39 | if (!rq) | ||
40 | return; | ||
41 | |||
42 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) | ||
43 | cmd = rq->special; | ||
44 | |||
45 | printk(KERN_ERR "ide: failed opcode was: "); | ||
46 | if (cmd == NULL) | ||
47 | printk(KERN_CONT "unknown\n"); | ||
48 | else | ||
49 | printk(KERN_CONT "0x%02x\n", cmd->tf.command); | ||
50 | } | ||
51 | |||
52 | u64 ide_get_lba_addr(struct ide_cmd *cmd, int lba48) | 34 | u64 ide_get_lba_addr(struct ide_cmd *cmd, int lba48) |
53 | { | 35 | { |
54 | struct ide_taskfile *tf = &cmd->tf; | 36 | struct ide_taskfile *tf = &cmd->tf; |
@@ -91,7 +73,7 @@ static void ide_dump_sector(ide_drive_t *drive) | |||
91 | 73 | ||
92 | static void ide_dump_ata_error(ide_drive_t *drive, u8 err) | 74 | static void ide_dump_ata_error(ide_drive_t *drive, u8 err) |
93 | { | 75 | { |
94 | printk(KERN_ERR "{ "); | 76 | printk(KERN_CONT "{ "); |
95 | if (err & ATA_ABORTED) | 77 | if (err & ATA_ABORTED) |
96 | printk(KERN_CONT "DriveStatusError "); | 78 | printk(KERN_CONT "DriveStatusError "); |
97 | if (err & ATA_ICRC) | 79 | if (err & ATA_ICRC) |
@@ -114,14 +96,14 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err) | |||
114 | 96 | ||
115 | if (rq) | 97 | if (rq) |
116 | printk(KERN_CONT ", sector=%llu", | 98 | printk(KERN_CONT ", sector=%llu", |
117 | (unsigned long long)rq->sector); | 99 | (unsigned long long)blk_rq_pos(rq)); |
118 | } | 100 | } |
119 | printk(KERN_CONT "\n"); | 101 | printk(KERN_CONT "\n"); |
120 | } | 102 | } |
121 | 103 | ||
122 | static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) | 104 | static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) |
123 | { | 105 | { |
124 | printk(KERN_ERR "{ "); | 106 | printk(KERN_CONT "{ "); |
125 | if (err & ATAPI_ILI) | 107 | if (err & ATAPI_ILI) |
126 | printk(KERN_CONT "IllegalLengthIndication "); | 108 | printk(KERN_CONT "IllegalLengthIndication "); |
127 | if (err & ATAPI_EOM) | 109 | if (err & ATAPI_EOM) |
@@ -179,7 +161,10 @@ u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) | |||
179 | else | 161 | else |
180 | ide_dump_atapi_error(drive, err); | 162 | ide_dump_atapi_error(drive, err); |
181 | } | 163 | } |
182 | ide_dump_opcode(drive); | 164 | |
165 | printk(KERN_ERR "%s: possibly failed opcode: 0x%02x\n", | ||
166 | drive->name, drive->hwif->cmd.tf.command); | ||
167 | |||
183 | return err; | 168 | return err; |
184 | } | 169 | } |
185 | EXPORT_SYMBOL(ide_dump_status); | 170 | EXPORT_SYMBOL(ide_dump_status); |
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c index 310d03f2b5b7..a914023d6d03 100644 --- a/drivers/ide/ide-park.c +++ b/drivers/ide/ide-park.c | |||
@@ -24,11 +24,8 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) | |||
24 | start_queue = 1; | 24 | start_queue = 1; |
25 | spin_unlock_irq(&hwif->lock); | 25 | spin_unlock_irq(&hwif->lock); |
26 | 26 | ||
27 | if (start_queue) { | 27 | if (start_queue) |
28 | spin_lock_irq(q->queue_lock); | 28 | blk_run_queue(q); |
29 | blk_start_queueing(q); | ||
30 | spin_unlock_irq(q->queue_lock); | ||
31 | } | ||
32 | return; | 29 | return; |
33 | } | 30 | } |
34 | spin_unlock_irq(&hwif->lock); | 31 | spin_unlock_irq(&hwif->lock); |
diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c index 61111fd27130..39d4e01f5c9c 100644 --- a/drivers/ide/ide-pci-generic.c +++ b/drivers/ide/ide-pci-generic.c | |||
@@ -33,6 +33,16 @@ 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 | static void netcell_quirkproc(ide_drive_t *drive) | ||
37 | { | ||
38 | /* mark words 85-87 as valid */ | ||
39 | drive->id[ATA_ID_CSF_DEFAULT] |= 0x4000; | ||
40 | } | ||
41 | |||
42 | static const struct ide_port_ops netcell_port_ops = { | ||
43 | .quirkproc = netcell_quirkproc, | ||
44 | }; | ||
45 | |||
36 | #define DECLARE_GENERIC_PCI_DEV(extra_flags) \ | 46 | #define DECLARE_GENERIC_PCI_DEV(extra_flags) \ |
37 | { \ | 47 | { \ |
38 | .name = DRV_NAME, \ | 48 | .name = DRV_NAME, \ |
@@ -74,6 +84,7 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
74 | 84 | ||
75 | { /* 6: Revolution */ | 85 | { /* 6: Revolution */ |
76 | .name = DRV_NAME, | 86 | .name = DRV_NAME, |
87 | .port_ops = &netcell_port_ops, | ||
77 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | | 88 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | |
78 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 89 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
79 | IDE_HFLAG_OFF_BOARD, | 90 | IDE_HFLAG_OFF_BOARD, |
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c index 0d8a151c0a01..ba1488bd8430 100644 --- a/drivers/ide/ide-pm.c +++ b/drivers/ide/ide-pm.c | |||
@@ -7,7 +7,6 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) | |||
7 | ide_hwif_t *hwif = drive->hwif; | 7 | ide_hwif_t *hwif = drive->hwif; |
8 | struct request *rq; | 8 | struct request *rq; |
9 | struct request_pm_state rqpm; | 9 | struct request_pm_state rqpm; |
10 | struct ide_cmd cmd; | ||
11 | int ret; | 10 | int ret; |
12 | 11 | ||
13 | /* call ACPI _GTM only once */ | 12 | /* call ACPI _GTM only once */ |
@@ -15,11 +14,9 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) | |||
15 | ide_acpi_get_timing(hwif); | 14 | ide_acpi_get_timing(hwif); |
16 | 15 | ||
17 | memset(&rqpm, 0, sizeof(rqpm)); | 16 | memset(&rqpm, 0, sizeof(rqpm)); |
18 | memset(&cmd, 0, sizeof(cmd)); | ||
19 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 17 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
20 | rq->cmd_type = REQ_TYPE_PM_SUSPEND; | 18 | rq->cmd_type = REQ_TYPE_PM_SUSPEND; |
21 | rq->special = &cmd; | 19 | rq->special = &rqpm; |
22 | rq->data = &rqpm; | ||
23 | rqpm.pm_step = IDE_PM_START_SUSPEND; | 20 | rqpm.pm_step = IDE_PM_START_SUSPEND; |
24 | if (mesg.event == PM_EVENT_PRETHAW) | 21 | if (mesg.event == PM_EVENT_PRETHAW) |
25 | mesg.event = PM_EVENT_FREEZE; | 22 | mesg.event = PM_EVENT_FREEZE; |
@@ -41,7 +38,6 @@ int generic_ide_resume(struct device *dev) | |||
41 | ide_hwif_t *hwif = drive->hwif; | 38 | ide_hwif_t *hwif = drive->hwif; |
42 | struct request *rq; | 39 | struct request *rq; |
43 | struct request_pm_state rqpm; | 40 | struct request_pm_state rqpm; |
44 | struct ide_cmd cmd; | ||
45 | int err; | 41 | int err; |
46 | 42 | ||
47 | /* call ACPI _PS0 / _STM only once */ | 43 | /* call ACPI _PS0 / _STM only once */ |
@@ -53,12 +49,10 @@ int generic_ide_resume(struct device *dev) | |||
53 | ide_acpi_exec_tfs(drive); | 49 | ide_acpi_exec_tfs(drive); |
54 | 50 | ||
55 | memset(&rqpm, 0, sizeof(rqpm)); | 51 | memset(&rqpm, 0, sizeof(rqpm)); |
56 | memset(&cmd, 0, sizeof(cmd)); | ||
57 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 52 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
58 | rq->cmd_type = REQ_TYPE_PM_RESUME; | 53 | rq->cmd_type = REQ_TYPE_PM_RESUME; |
59 | rq->cmd_flags |= REQ_PREEMPT; | 54 | rq->cmd_flags |= REQ_PREEMPT; |
60 | rq->special = &cmd; | 55 | rq->special = &rqpm; |
61 | rq->data = &rqpm; | ||
62 | rqpm.pm_step = IDE_PM_START_RESUME; | 56 | rqpm.pm_step = IDE_PM_START_RESUME; |
63 | rqpm.pm_state = PM_EVENT_ON; | 57 | rqpm.pm_state = PM_EVENT_ON; |
64 | 58 | ||
@@ -77,7 +71,7 @@ int generic_ide_resume(struct device *dev) | |||
77 | 71 | ||
78 | void ide_complete_power_step(ide_drive_t *drive, struct request *rq) | 72 | void ide_complete_power_step(ide_drive_t *drive, struct request *rq) |
79 | { | 73 | { |
80 | struct request_pm_state *pm = rq->data; | 74 | struct request_pm_state *pm = rq->special; |
81 | 75 | ||
82 | #ifdef DEBUG_PM | 76 | #ifdef DEBUG_PM |
83 | printk(KERN_INFO "%s: complete_power_step(step: %d)\n", | 77 | printk(KERN_INFO "%s: complete_power_step(step: %d)\n", |
@@ -107,10 +101,8 @@ void ide_complete_power_step(ide_drive_t *drive, struct request *rq) | |||
107 | 101 | ||
108 | ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) | 102 | ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) |
109 | { | 103 | { |
110 | struct request_pm_state *pm = rq->data; | 104 | struct request_pm_state *pm = rq->special; |
111 | struct ide_cmd *cmd = rq->special; | 105 | struct ide_cmd cmd = { }; |
112 | |||
113 | memset(cmd, 0, sizeof(*cmd)); | ||
114 | 106 | ||
115 | switch (pm->pm_step) { | 107 | switch (pm->pm_step) { |
116 | case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ | 108 | case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ |
@@ -123,12 +115,12 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) | |||
123 | return ide_stopped; | 115 | return ide_stopped; |
124 | } | 116 | } |
125 | if (ata_id_flush_ext_enabled(drive->id)) | 117 | if (ata_id_flush_ext_enabled(drive->id)) |
126 | cmd->tf.command = ATA_CMD_FLUSH_EXT; | 118 | cmd.tf.command = ATA_CMD_FLUSH_EXT; |
127 | else | 119 | else |
128 | cmd->tf.command = ATA_CMD_FLUSH; | 120 | cmd.tf.command = ATA_CMD_FLUSH; |
129 | goto out_do_tf; | 121 | goto out_do_tf; |
130 | case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ | 122 | case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ |
131 | cmd->tf.command = ATA_CMD_STANDBYNOW1; | 123 | cmd.tf.command = ATA_CMD_STANDBYNOW1; |
132 | goto out_do_tf; | 124 | goto out_do_tf; |
133 | case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ | 125 | case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ |
134 | ide_set_max_pio(drive); | 126 | ide_set_max_pio(drive); |
@@ -141,7 +133,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) | |||
141 | ide_complete_power_step(drive, rq); | 133 | ide_complete_power_step(drive, rq); |
142 | return ide_stopped; | 134 | return ide_stopped; |
143 | case IDE_PM_IDLE: /* Resume step 2 (idle) */ | 135 | case IDE_PM_IDLE: /* Resume step 2 (idle) */ |
144 | cmd->tf.command = ATA_CMD_IDLEIMMEDIATE; | 136 | cmd.tf.command = ATA_CMD_IDLEIMMEDIATE; |
145 | goto out_do_tf; | 137 | goto out_do_tf; |
146 | case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */ | 138 | case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */ |
147 | /* | 139 | /* |
@@ -163,11 +155,11 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) | |||
163 | return ide_stopped; | 155 | return ide_stopped; |
164 | 156 | ||
165 | out_do_tf: | 157 | out_do_tf: |
166 | cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; | 158 | cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; |
167 | cmd->valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; | 159 | cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; |
168 | cmd->protocol = ATA_PROT_NODATA; | 160 | cmd.protocol = ATA_PROT_NODATA; |
169 | 161 | ||
170 | return do_rw_taskfile(drive, cmd); | 162 | return do_rw_taskfile(drive, &cmd); |
171 | } | 163 | } |
172 | 164 | ||
173 | /** | 165 | /** |
@@ -181,7 +173,7 @@ out_do_tf: | |||
181 | void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) | 173 | void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) |
182 | { | 174 | { |
183 | struct request_queue *q = drive->queue; | 175 | struct request_queue *q = drive->queue; |
184 | struct request_pm_state *pm = rq->data; | 176 | struct request_pm_state *pm = rq->special; |
185 | unsigned long flags; | 177 | unsigned long flags; |
186 | 178 | ||
187 | ide_complete_power_step(drive, rq); | 179 | ide_complete_power_step(drive, rq); |
@@ -207,7 +199,7 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) | |||
207 | 199 | ||
208 | void ide_check_pm_state(ide_drive_t *drive, struct request *rq) | 200 | void ide_check_pm_state(ide_drive_t *drive, struct request *rq) |
209 | { | 201 | { |
210 | struct request_pm_state *pm = rq->data; | 202 | struct request_pm_state *pm = rq->special; |
211 | 203 | ||
212 | if (blk_pm_suspend_request(rq) && | 204 | if (blk_pm_suspend_request(rq) && |
213 | pm->pm_step == IDE_PM_START_SUSPEND) | 205 | pm->pm_step == IDE_PM_START_SUSPEND) |
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index 6e80b774e88a..017b1df3b805 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
@@ -29,6 +29,7 @@ static struct pnp_device_id idepnp_devices[] = { | |||
29 | 29 | ||
30 | static const struct ide_port_info ide_pnp_port_info = { | 30 | static const struct ide_port_info ide_pnp_port_info = { |
31 | .host_flags = IDE_HFLAG_NO_DMA, | 31 | .host_flags = IDE_HFLAG_NO_DMA, |
32 | .chipset = ide_generic, | ||
32 | }; | 33 | }; |
33 | 34 | ||
34 | static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | 35 | static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) |
@@ -36,7 +37,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
36 | struct ide_host *host; | 37 | struct ide_host *host; |
37 | unsigned long base, ctl; | 38 | unsigned long base, ctl; |
38 | int rc; | 39 | int rc; |
39 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 40 | struct ide_hw hw, *hws[] = { &hw }; |
40 | 41 | ||
41 | printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); | 42 | printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); |
42 | 43 | ||
@@ -62,9 +63,8 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
62 | memset(&hw, 0, sizeof(hw)); | 63 | memset(&hw, 0, sizeof(hw)); |
63 | ide_std_init_ports(&hw, base, ctl); | 64 | ide_std_init_ports(&hw, base, ctl); |
64 | hw.irq = pnp_irq(dev, 0); | 65 | hw.irq = pnp_irq(dev, 0); |
65 | hw.chipset = ide_generic; | ||
66 | 66 | ||
67 | rc = ide_host_add(&ide_pnp_port_info, hws, &host); | 67 | rc = ide_host_add(&ide_pnp_port_info, hws, 1, &host); |
68 | if (rc) | 68 | if (rc) |
69 | goto out; | 69 | goto out; |
70 | 70 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 7f264ed1141b..f371b0de314f 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -97,7 +97,7 @@ static void ide_disk_init_mult_count(ide_drive_t *drive) | |||
97 | drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; | 97 | drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; |
98 | 98 | ||
99 | if (drive->mult_req) | 99 | if (drive->mult_req) |
100 | drive->special.b.set_multmode = 1; | 100 | drive->special_flags |= IDE_SFLAG_SET_MULTMODE; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
@@ -295,7 +295,7 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) | |||
295 | 295 | ||
296 | timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 296 | timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
297 | 297 | ||
298 | if (ide_busy_sleep(hwif, timeout, use_altstatus)) | 298 | if (ide_busy_sleep(drive, timeout, use_altstatus)) |
299 | return 1; | 299 | return 1; |
300 | 300 | ||
301 | /* wait for IRQ and ATA_DRQ */ | 301 | /* wait for IRQ and ATA_DRQ */ |
@@ -316,8 +316,9 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) | |||
316 | return rc; | 316 | return rc; |
317 | } | 317 | } |
318 | 318 | ||
319 | int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) | 319 | int ide_busy_sleep(ide_drive_t *drive, unsigned long timeout, int altstatus) |
320 | { | 320 | { |
321 | ide_hwif_t *hwif = drive->hwif; | ||
321 | u8 stat; | 322 | u8 stat; |
322 | 323 | ||
323 | timeout += jiffies; | 324 | timeout += jiffies; |
@@ -330,6 +331,8 @@ int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) | |||
330 | return 0; | 331 | return 0; |
331 | } while (time_before(jiffies, timeout)); | 332 | } while (time_before(jiffies, timeout)); |
332 | 333 | ||
334 | printk(KERN_ERR "%s: timeout in %s\n", drive->name, __func__); | ||
335 | |||
333 | return 1; /* drive timed-out */ | 336 | return 1; /* drive timed-out */ |
334 | } | 337 | } |
335 | 338 | ||
@@ -420,7 +423,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
420 | tp_ops->dev_select(drive); | 423 | tp_ops->dev_select(drive); |
421 | msleep(50); | 424 | msleep(50); |
422 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | 425 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
423 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); | 426 | (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0); |
424 | rc = ide_dev_read_id(drive, cmd, id); | 427 | rc = ide_dev_read_id(drive, cmd, id); |
425 | } | 428 | } |
426 | 429 | ||
@@ -462,23 +465,8 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
462 | int rc; | 465 | int rc; |
463 | u8 cmd; | 466 | u8 cmd; |
464 | 467 | ||
465 | /* | ||
466 | * In order to keep things simple we have an id | ||
467 | * block for all drives at all times. If the device | ||
468 | * is pre ATA or refuses ATA/ATAPI identify we | ||
469 | * will add faked data to this. | ||
470 | * | ||
471 | * Also note that 0 everywhere means "can't do X" | ||
472 | */ | ||
473 | |||
474 | drive->dev_flags &= ~IDE_DFLAG_ID_READ; | 468 | drive->dev_flags &= ~IDE_DFLAG_ID_READ; |
475 | 469 | ||
476 | drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); | ||
477 | if (drive->id == NULL) { | ||
478 | printk(KERN_ERR "ide: out of memory for id data.\n"); | ||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | m = (char *)&drive->id[ATA_ID_PROD]; | 470 | m = (char *)&drive->id[ATA_ID_PROD]; |
483 | strcpy(m, "UNKNOWN"); | 471 | strcpy(m, "UNKNOWN"); |
484 | 472 | ||
@@ -494,7 +482,7 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
494 | } | 482 | } |
495 | 483 | ||
496 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 484 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
497 | goto out_free; | 485 | return 0; |
498 | 486 | ||
499 | /* identification failed? */ | 487 | /* identification failed? */ |
500 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { | 488 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
@@ -518,7 +506,7 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
518 | } | 506 | } |
519 | 507 | ||
520 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 508 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
521 | goto out_free; | 509 | return 0; |
522 | 510 | ||
523 | /* The drive wasn't being helpful. Add generic info only */ | 511 | /* The drive wasn't being helpful. Add generic info only */ |
524 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { | 512 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
@@ -532,9 +520,6 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
532 | } | 520 | } |
533 | 521 | ||
534 | return 1; | 522 | return 1; |
535 | out_free: | ||
536 | kfree(drive->id); | ||
537 | return 0; | ||
538 | } | 523 | } |
539 | 524 | ||
540 | static void hwif_release_dev(struct device *dev) | 525 | static void hwif_release_dev(struct device *dev) |
@@ -699,8 +684,14 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
699 | if (irqd) | 684 | if (irqd) |
700 | disable_irq(hwif->irq); | 685 | disable_irq(hwif->irq); |
701 | 686 | ||
702 | if (ide_port_wait_ready(hwif) == -EBUSY) | 687 | rc = ide_port_wait_ready(hwif); |
703 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); | 688 | if (rc == -ENODEV) { |
689 | printk(KERN_INFO "%s: no devices on the port\n", hwif->name); | ||
690 | goto out; | ||
691 | } else if (rc == -EBUSY) | ||
692 | printk(KERN_ERR "%s: not ready before the probe\n", hwif->name); | ||
693 | else | ||
694 | rc = -ENODEV; | ||
704 | 695 | ||
705 | /* | 696 | /* |
706 | * Second drive should only exist if first drive was found, | 697 | * Second drive should only exist if first drive was found, |
@@ -711,7 +702,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
711 | if (drive->dev_flags & IDE_DFLAG_PRESENT) | 702 | if (drive->dev_flags & IDE_DFLAG_PRESENT) |
712 | rc = 0; | 703 | rc = 0; |
713 | } | 704 | } |
714 | 705 | out: | |
715 | /* | 706 | /* |
716 | * Use cached IRQ number. It might be (and is...) changed by probe | 707 | * Use cached IRQ number. It might be (and is...) changed by probe |
717 | * code above | 708 | * code above |
@@ -729,6 +720,8 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
729 | int i; | 720 | int i; |
730 | 721 | ||
731 | ide_port_for_each_present_dev(i, drive, hwif) { | 722 | ide_port_for_each_present_dev(i, drive, hwif) { |
723 | ide_check_nien_quirk_list(drive); | ||
724 | |||
732 | if (port_ops && port_ops->quirkproc) | 725 | if (port_ops && port_ops->quirkproc) |
733 | port_ops->quirkproc(drive); | 726 | port_ops->quirkproc(drive); |
734 | } | 727 | } |
@@ -814,8 +807,6 @@ static int ide_port_setup_devices(ide_hwif_t *hwif) | |||
814 | if (ide_init_queue(drive)) { | 807 | if (ide_init_queue(drive)) { |
815 | printk(KERN_ERR "ide: failed to init %s\n", | 808 | printk(KERN_ERR "ide: failed to init %s\n", |
816 | drive->name); | 809 | drive->name); |
817 | kfree(drive->id); | ||
818 | drive->id = NULL; | ||
819 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | 810 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
820 | continue; | 811 | continue; |
821 | } | 812 | } |
@@ -944,9 +935,6 @@ static void drive_release_dev (struct device *dev) | |||
944 | blk_cleanup_queue(drive->queue); | 935 | blk_cleanup_queue(drive->queue); |
945 | drive->queue = NULL; | 936 | drive->queue = NULL; |
946 | 937 | ||
947 | kfree(drive->id); | ||
948 | drive->id = NULL; | ||
949 | |||
950 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | 938 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
951 | 939 | ||
952 | complete(&drive->gendev_rel_comp); | 940 | complete(&drive->gendev_rel_comp); |
@@ -1032,6 +1020,15 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1032 | if (port_ops && port_ops->init_dev) | 1020 | if (port_ops && port_ops->init_dev) |
1033 | port_ops->init_dev(drive); | 1021 | port_ops->init_dev(drive); |
1034 | } | 1022 | } |
1023 | |||
1024 | ide_port_for_each_dev(i, drive, hwif) { | ||
1025 | /* | ||
1026 | * default to PIO Mode 0 before we figure out | ||
1027 | * the most suited mode for the attached device | ||
1028 | */ | ||
1029 | if (port_ops && port_ops->set_pio_mode) | ||
1030 | port_ops->set_pio_mode(drive, 0); | ||
1031 | } | ||
1035 | } | 1032 | } |
1036 | 1033 | ||
1037 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | 1034 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, |
@@ -1039,8 +1036,7 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1039 | { | 1036 | { |
1040 | hwif->channel = port; | 1037 | hwif->channel = port; |
1041 | 1038 | ||
1042 | if (d->chipset) | 1039 | hwif->chipset = d->chipset ? d->chipset : ide_pci; |
1043 | hwif->chipset = d->chipset; | ||
1044 | 1040 | ||
1045 | if (d->init_iops) | 1041 | if (d->init_iops) |
1046 | d->init_iops(hwif); | 1042 | d->init_iops(hwif); |
@@ -1121,16 +1117,19 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
1121 | 1117 | ||
1122 | ide_port_for_each_dev(i, drive, hwif) { | 1118 | ide_port_for_each_dev(i, drive, hwif) { |
1123 | u8 j = (hwif->index * MAX_DRIVES) + i; | 1119 | u8 j = (hwif->index * MAX_DRIVES) + i; |
1120 | u16 *saved_id = drive->id; | ||
1124 | 1121 | ||
1125 | memset(drive, 0, sizeof(*drive)); | 1122 | memset(drive, 0, sizeof(*drive)); |
1123 | memset(saved_id, 0, SECTOR_SIZE); | ||
1124 | drive->id = saved_id; | ||
1126 | 1125 | ||
1127 | drive->media = ide_disk; | 1126 | drive->media = ide_disk; |
1128 | drive->select = (i << 4) | ATA_DEVICE_OBS; | 1127 | drive->select = (i << 4) | ATA_DEVICE_OBS; |
1129 | drive->hwif = hwif; | 1128 | drive->hwif = hwif; |
1130 | drive->ready_stat = ATA_DRDY; | 1129 | drive->ready_stat = ATA_DRDY; |
1131 | drive->bad_wstat = BAD_W_STAT; | 1130 | drive->bad_wstat = BAD_W_STAT; |
1132 | drive->special.b.recalibrate = 1; | 1131 | drive->special_flags = IDE_SFLAG_RECALIBRATE | |
1133 | drive->special.b.set_geometry = 1; | 1132 | IDE_SFLAG_SET_GEOMETRY; |
1134 | drive->name[0] = 'h'; | 1133 | drive->name[0] = 'h'; |
1135 | drive->name[1] = 'd'; | 1134 | drive->name[1] = 'd'; |
1136 | drive->name[2] = 'a' + j; | 1135 | drive->name[2] = 'a' + j; |
@@ -1165,11 +1164,10 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
1165 | ide_port_init_devices_data(hwif); | 1164 | ide_port_init_devices_data(hwif); |
1166 | } | 1165 | } |
1167 | 1166 | ||
1168 | static void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | 1167 | static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw) |
1169 | { | 1168 | { |
1170 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | 1169 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); |
1171 | hwif->irq = hw->irq; | 1170 | hwif->irq = hw->irq; |
1172 | hwif->chipset = hw->chipset; | ||
1173 | hwif->dev = hw->dev; | 1171 | hwif->dev = hw->dev; |
1174 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | 1172 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; |
1175 | hwif->ack_intr = hw->ack_intr; | 1173 | hwif->ack_intr = hw->ack_intr; |
@@ -1230,8 +1228,10 @@ static void ide_port_free_devices(ide_hwif_t *hwif) | |||
1230 | ide_drive_t *drive; | 1228 | ide_drive_t *drive; |
1231 | int i; | 1229 | int i; |
1232 | 1230 | ||
1233 | ide_port_for_each_dev(i, drive, hwif) | 1231 | ide_port_for_each_dev(i, drive, hwif) { |
1232 | kfree(drive->id); | ||
1234 | kfree(drive); | 1233 | kfree(drive); |
1234 | } | ||
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) | 1237 | static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) |
@@ -1245,6 +1245,18 @@ static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) | |||
1245 | if (drive == NULL) | 1245 | if (drive == NULL) |
1246 | goto out_nomem; | 1246 | goto out_nomem; |
1247 | 1247 | ||
1248 | /* | ||
1249 | * In order to keep things simple we have an id | ||
1250 | * block for all drives at all times. If the device | ||
1251 | * is pre ATA or refuses ATA/ATAPI identify we | ||
1252 | * will add faked data to this. | ||
1253 | * | ||
1254 | * Also note that 0 everywhere means "can't do X" | ||
1255 | */ | ||
1256 | drive->id = kzalloc_node(SECTOR_SIZE, GFP_KERNEL, node); | ||
1257 | if (drive->id == NULL) | ||
1258 | goto out_nomem; | ||
1259 | |||
1248 | hwif->devices[i] = drive; | 1260 | hwif->devices[i] = drive; |
1249 | } | 1261 | } |
1250 | return 0; | 1262 | return 0; |
@@ -1254,7 +1266,8 @@ out_nomem: | |||
1254 | return -ENOMEM; | 1266 | return -ENOMEM; |
1255 | } | 1267 | } |
1256 | 1268 | ||
1257 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | 1269 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, |
1270 | struct ide_hw **hws, unsigned int n_ports) | ||
1258 | { | 1271 | { |
1259 | struct ide_host *host; | 1272 | struct ide_host *host; |
1260 | struct device *dev = hws[0] ? hws[0]->dev : NULL; | 1273 | struct device *dev = hws[0] ? hws[0]->dev : NULL; |
@@ -1265,7 +1278,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1265 | if (host == NULL) | 1278 | if (host == NULL) |
1266 | return NULL; | 1279 | return NULL; |
1267 | 1280 | ||
1268 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1281 | for (i = 0; i < n_ports; i++) { |
1269 | ide_hwif_t *hwif; | 1282 | ide_hwif_t *hwif; |
1270 | int idx; | 1283 | int idx; |
1271 | 1284 | ||
@@ -1285,6 +1298,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1285 | if (idx < 0) { | 1298 | if (idx < 0) { |
1286 | printk(KERN_ERR "%s: no free slot for interface\n", | 1299 | printk(KERN_ERR "%s: no free slot for interface\n", |
1287 | d ? d->name : "ide"); | 1300 | d ? d->name : "ide"); |
1301 | ide_port_free_devices(hwif); | ||
1288 | kfree(hwif); | 1302 | kfree(hwif); |
1289 | continue; | 1303 | continue; |
1290 | } | 1304 | } |
@@ -1341,7 +1355,7 @@ static void ide_disable_port(ide_hwif_t *hwif) | |||
1341 | } | 1355 | } |
1342 | 1356 | ||
1343 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | 1357 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, |
1344 | hw_regs_t **hws) | 1358 | struct ide_hw **hws) |
1345 | { | 1359 | { |
1346 | ide_hwif_t *hwif, *mate = NULL; | 1360 | ide_hwif_t *hwif, *mate = NULL; |
1347 | int i, j = 0; | 1361 | int i, j = 0; |
@@ -1435,13 +1449,13 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1435 | } | 1449 | } |
1436 | EXPORT_SYMBOL_GPL(ide_host_register); | 1450 | EXPORT_SYMBOL_GPL(ide_host_register); |
1437 | 1451 | ||
1438 | int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws, | 1452 | int ide_host_add(const struct ide_port_info *d, struct ide_hw **hws, |
1439 | struct ide_host **hostp) | 1453 | unsigned int n_ports, struct ide_host **hostp) |
1440 | { | 1454 | { |
1441 | struct ide_host *host; | 1455 | struct ide_host *host; |
1442 | int rc; | 1456 | int rc; |
1443 | 1457 | ||
1444 | host = ide_host_alloc(d, hws); | 1458 | host = ide_host_alloc(d, hws, n_ports); |
1445 | if (host == NULL) | 1459 | if (host == NULL) |
1446 | return -ENOMEM; | 1460 | return -ENOMEM; |
1447 | 1461 | ||
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 3a53e0834cf7..4b447a8a49d4 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -131,13 +131,6 @@ enum { | |||
131 | IDETAPE_DIR_WRITE = (1 << 2), | 131 | IDETAPE_DIR_WRITE = (1 << 2), |
132 | }; | 132 | }; |
133 | 133 | ||
134 | struct idetape_bh { | ||
135 | u32 b_size; | ||
136 | atomic_t b_count; | ||
137 | struct idetape_bh *b_reqnext; | ||
138 | char *b_data; | ||
139 | }; | ||
140 | |||
141 | /* Tape door status */ | 134 | /* Tape door status */ |
142 | #define DOOR_UNLOCKED 0 | 135 | #define DOOR_UNLOCKED 0 |
143 | #define DOOR_LOCKED 1 | 136 | #define DOOR_LOCKED 1 |
@@ -219,18 +212,12 @@ typedef struct ide_tape_obj { | |||
219 | 212 | ||
220 | /* Data buffer size chosen based on the tape's recommendation */ | 213 | /* Data buffer size chosen based on the tape's recommendation */ |
221 | int buffer_size; | 214 | int buffer_size; |
222 | /* merge buffer */ | 215 | /* Staging buffer of buffer_size bytes */ |
223 | struct idetape_bh *merge_bh; | 216 | void *buf; |
224 | /* size of the merge buffer */ | 217 | /* The read/write cursor */ |
225 | int merge_bh_size; | 218 | void *cur; |
226 | /* pointer to current buffer head within the merge buffer */ | 219 | /* The number of valid bytes in buf */ |
227 | struct idetape_bh *bh; | 220 | size_t valid; |
228 | char *b_data; | ||
229 | int b_count; | ||
230 | |||
231 | int pages_per_buffer; | ||
232 | /* Wasted space in each stage */ | ||
233 | int excess_bh_size; | ||
234 | 221 | ||
235 | /* Measures average tape speed */ | 222 | /* Measures average tape speed */ |
236 | unsigned long avg_time; | 223 | unsigned long avg_time; |
@@ -253,18 +240,27 @@ static struct class *idetape_sysfs_class; | |||
253 | 240 | ||
254 | static void ide_tape_release(struct device *); | 241 | static void ide_tape_release(struct device *); |
255 | 242 | ||
256 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | 243 | static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; |
244 | |||
245 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk, bool cdev, | ||
246 | unsigned int i) | ||
257 | { | 247 | { |
258 | struct ide_tape_obj *tape = NULL; | 248 | struct ide_tape_obj *tape = NULL; |
259 | 249 | ||
260 | mutex_lock(&idetape_ref_mutex); | 250 | mutex_lock(&idetape_ref_mutex); |
261 | tape = ide_drv_g(disk, ide_tape_obj); | 251 | |
252 | if (cdev) | ||
253 | tape = idetape_devs[i]; | ||
254 | else | ||
255 | tape = ide_drv_g(disk, ide_tape_obj); | ||
256 | |||
262 | if (tape) { | 257 | if (tape) { |
263 | if (ide_device_get(tape->drive)) | 258 | if (ide_device_get(tape->drive)) |
264 | tape = NULL; | 259 | tape = NULL; |
265 | else | 260 | else |
266 | get_device(&tape->dev); | 261 | get_device(&tape->dev); |
267 | } | 262 | } |
263 | |||
268 | mutex_unlock(&idetape_ref_mutex); | 264 | mutex_unlock(&idetape_ref_mutex); |
269 | return tape; | 265 | return tape; |
270 | } | 266 | } |
@@ -280,102 +276,6 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
280 | } | 276 | } |
281 | 277 | ||
282 | /* | 278 | /* |
283 | * The variables below are used for the character device interface. Additional | ||
284 | * state variables are defined in our ide_drive_t structure. | ||
285 | */ | ||
286 | static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; | ||
287 | |||
288 | static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | ||
289 | { | ||
290 | struct ide_tape_obj *tape = NULL; | ||
291 | |||
292 | mutex_lock(&idetape_ref_mutex); | ||
293 | tape = idetape_devs[i]; | ||
294 | if (tape) | ||
295 | get_device(&tape->dev); | ||
296 | mutex_unlock(&idetape_ref_mutex); | ||
297 | return tape; | ||
298 | } | ||
299 | |||
300 | static int idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
301 | unsigned int bcount) | ||
302 | { | ||
303 | struct idetape_bh *bh = pc->bh; | ||
304 | int count; | ||
305 | |||
306 | while (bcount) { | ||
307 | if (bh == NULL) | ||
308 | break; | ||
309 | count = min( | ||
310 | (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), | ||
311 | bcount); | ||
312 | drive->hwif->tp_ops->input_data(drive, NULL, bh->b_data + | ||
313 | atomic_read(&bh->b_count), count); | ||
314 | bcount -= count; | ||
315 | atomic_add(count, &bh->b_count); | ||
316 | if (atomic_read(&bh->b_count) == bh->b_size) { | ||
317 | bh = bh->b_reqnext; | ||
318 | if (bh) | ||
319 | atomic_set(&bh->b_count, 0); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | pc->bh = bh; | ||
324 | |||
325 | return bcount; | ||
326 | } | ||
327 | |||
328 | static int idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
329 | unsigned int bcount) | ||
330 | { | ||
331 | struct idetape_bh *bh = pc->bh; | ||
332 | int count; | ||
333 | |||
334 | while (bcount) { | ||
335 | if (bh == NULL) | ||
336 | break; | ||
337 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); | ||
338 | drive->hwif->tp_ops->output_data(drive, NULL, pc->b_data, count); | ||
339 | bcount -= count; | ||
340 | pc->b_data += count; | ||
341 | pc->b_count -= count; | ||
342 | if (!pc->b_count) { | ||
343 | bh = bh->b_reqnext; | ||
344 | pc->bh = bh; | ||
345 | if (bh) { | ||
346 | pc->b_data = bh->b_data; | ||
347 | pc->b_count = atomic_read(&bh->b_count); | ||
348 | } | ||
349 | } | ||
350 | } | ||
351 | |||
352 | return bcount; | ||
353 | } | ||
354 | |||
355 | static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) | ||
356 | { | ||
357 | struct idetape_bh *bh = pc->bh; | ||
358 | int count; | ||
359 | unsigned int bcount = pc->xferred; | ||
360 | |||
361 | if (pc->flags & PC_FLAG_WRITING) | ||
362 | return; | ||
363 | while (bcount) { | ||
364 | if (bh == NULL) { | ||
365 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", | ||
366 | __func__); | ||
367 | return; | ||
368 | } | ||
369 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); | ||
370 | atomic_set(&bh->b_count, count); | ||
371 | if (atomic_read(&bh->b_count) == bh->b_size) | ||
372 | bh = bh->b_reqnext; | ||
373 | bcount -= count; | ||
374 | } | ||
375 | pc->bh = bh; | ||
376 | } | ||
377 | |||
378 | /* | ||
379 | * called on each failed packet command retry to analyze the request sense. We | 279 | * called on each failed packet command retry to analyze the request sense. We |
380 | * currently do not utilize this information. | 280 | * currently do not utilize this information. |
381 | */ | 281 | */ |
@@ -392,12 +292,10 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
392 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); | 292 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); |
393 | 293 | ||
394 | /* Correct pc->xferred by asking the tape. */ | 294 | /* Correct pc->xferred by asking the tape. */ |
395 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 295 | if (pc->flags & PC_FLAG_DMA_ERROR) |
396 | pc->xferred = pc->req_xfer - | 296 | pc->xferred = pc->req_xfer - |
397 | tape->blk_size * | 297 | tape->blk_size * |
398 | get_unaligned_be32(&sense[3]); | 298 | get_unaligned_be32(&sense[3]); |
399 | idetape_update_buffers(drive, pc); | ||
400 | } | ||
401 | 299 | ||
402 | /* | 300 | /* |
403 | * If error was the result of a zero-length read or write command, | 301 | * If error was the result of a zero-length read or write command, |
@@ -436,29 +334,6 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
436 | } | 334 | } |
437 | } | 335 | } |
438 | 336 | ||
439 | /* Free data buffers completely. */ | ||
440 | static void ide_tape_kfree_buffer(idetape_tape_t *tape) | ||
441 | { | ||
442 | struct idetape_bh *prev_bh, *bh = tape->merge_bh; | ||
443 | |||
444 | while (bh) { | ||
445 | u32 size = bh->b_size; | ||
446 | |||
447 | while (size) { | ||
448 | unsigned int order = fls(size >> PAGE_SHIFT)-1; | ||
449 | |||
450 | if (bh->b_data) | ||
451 | free_pages((unsigned long)bh->b_data, order); | ||
452 | |||
453 | size &= (order-1); | ||
454 | bh->b_data += (1 << order) * PAGE_SIZE; | ||
455 | } | ||
456 | prev_bh = bh; | ||
457 | bh = bh->b_reqnext; | ||
458 | kfree(prev_bh); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | static void ide_tape_handle_dsc(ide_drive_t *); | 337 | static void ide_tape_handle_dsc(ide_drive_t *); |
463 | 338 | ||
464 | static int ide_tape_callback(ide_drive_t *drive, int dsc) | 339 | static int ide_tape_callback(ide_drive_t *drive, int dsc) |
@@ -496,7 +371,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
496 | } | 371 | } |
497 | 372 | ||
498 | tape->first_frame += blocks; | 373 | tape->first_frame += blocks; |
499 | rq->current_nr_sectors -= blocks; | 374 | rq->resid_len -= blocks * tape->blk_size; |
500 | 375 | ||
501 | if (pc->error) { | 376 | if (pc->error) { |
502 | uptodate = 0; | 377 | uptodate = 0; |
@@ -513,7 +388,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
513 | if (readpos[0] & 0x4) { | 388 | if (readpos[0] & 0x4) { |
514 | printk(KERN_INFO "ide-tape: Block location is unknown" | 389 | printk(KERN_INFO "ide-tape: Block location is unknown" |
515 | "to the tape\n"); | 390 | "to the tape\n"); |
516 | clear_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 391 | clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), |
392 | &drive->atapi_flags); | ||
517 | uptodate = 0; | 393 | uptodate = 0; |
518 | err = IDE_DRV_ERROR_GENERAL; | 394 | err = IDE_DRV_ERROR_GENERAL; |
519 | } else { | 395 | } else { |
@@ -522,7 +398,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
522 | 398 | ||
523 | tape->partition = readpos[1]; | 399 | tape->partition = readpos[1]; |
524 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); | 400 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); |
525 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 401 | set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), |
402 | &drive->atapi_flags); | ||
526 | } | 403 | } |
527 | } | 404 | } |
528 | 405 | ||
@@ -558,19 +435,6 @@ static void ide_tape_handle_dsc(ide_drive_t *drive) | |||
558 | idetape_postpone_request(drive); | 435 | idetape_postpone_request(drive); |
559 | } | 436 | } |
560 | 437 | ||
561 | static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
562 | unsigned int bcount, int write) | ||
563 | { | ||
564 | unsigned int bleft; | ||
565 | |||
566 | if (write) | ||
567 | bleft = idetape_output_buffers(drive, pc, bcount); | ||
568 | else | ||
569 | bleft = idetape_input_buffers(drive, pc, bcount); | ||
570 | |||
571 | return bcount - bleft; | ||
572 | } | ||
573 | |||
574 | /* | 438 | /* |
575 | * Packet Command Interface | 439 | * Packet Command Interface |
576 | * | 440 | * |
@@ -622,6 +486,8 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
622 | 486 | ||
623 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || | 487 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || |
624 | (pc->flags & PC_FLAG_ABORT)) { | 488 | (pc->flags & PC_FLAG_ABORT)) { |
489 | unsigned int done = blk_rq_bytes(drive->hwif->rq); | ||
490 | |||
625 | /* | 491 | /* |
626 | * We will "abort" retrying a packet command in case legitimate | 492 | * We will "abort" retrying a packet command in case legitimate |
627 | * error code was received (crossing a filemark, or end of the | 493 | * error code was received (crossing a filemark, or end of the |
@@ -641,8 +507,10 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
641 | /* Giving up */ | 507 | /* Giving up */ |
642 | pc->error = IDE_DRV_ERROR_GENERAL; | 508 | pc->error = IDE_DRV_ERROR_GENERAL; |
643 | } | 509 | } |
510 | |||
644 | drive->failed_pc = NULL; | 511 | drive->failed_pc = NULL; |
645 | drive->pc_callback(drive, 0); | 512 | drive->pc_callback(drive, 0); |
513 | ide_complete_rq(drive, -EIO, done); | ||
646 | return ide_stopped; | 514 | return ide_stopped; |
647 | } | 515 | } |
648 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 516 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
@@ -695,7 +563,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | |||
695 | printk(KERN_ERR "ide-tape: %s: I/O error, ", | 563 | printk(KERN_ERR "ide-tape: %s: I/O error, ", |
696 | tape->name); | 564 | tape->name); |
697 | /* Retry operation */ | 565 | /* Retry operation */ |
698 | ide_retry_pc(drive, tape->disk); | 566 | ide_retry_pc(drive); |
699 | return ide_stopped; | 567 | return ide_stopped; |
700 | } | 568 | } |
701 | pc->error = 0; | 569 | pc->error = 0; |
@@ -711,27 +579,22 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
711 | struct ide_atapi_pc *pc, struct request *rq, | 579 | struct ide_atapi_pc *pc, struct request *rq, |
712 | u8 opcode) | 580 | u8 opcode) |
713 | { | 581 | { |
714 | struct idetape_bh *bh = (struct idetape_bh *)rq->special; | 582 | unsigned int length = blk_rq_sectors(rq); |
715 | unsigned int length = rq->current_nr_sectors; | ||
716 | 583 | ||
717 | ide_init_pc(pc); | 584 | ide_init_pc(pc); |
718 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 585 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
719 | pc->c[1] = 1; | 586 | pc->c[1] = 1; |
720 | pc->bh = bh; | ||
721 | pc->buf = NULL; | 587 | pc->buf = NULL; |
722 | pc->buf_size = length * tape->blk_size; | 588 | pc->buf_size = length * tape->blk_size; |
723 | pc->req_xfer = pc->buf_size; | 589 | pc->req_xfer = pc->buf_size; |
724 | if (pc->req_xfer == tape->buffer_size) | 590 | if (pc->req_xfer == tape->buffer_size) |
725 | pc->flags |= PC_FLAG_DMA_OK; | 591 | pc->flags |= PC_FLAG_DMA_OK; |
726 | 592 | ||
727 | if (opcode == READ_6) { | 593 | if (opcode == READ_6) |
728 | pc->c[0] = READ_6; | 594 | pc->c[0] = READ_6; |
729 | atomic_set(&bh->b_count, 0); | 595 | else if (opcode == WRITE_6) { |
730 | } else if (opcode == WRITE_6) { | ||
731 | pc->c[0] = WRITE_6; | 596 | pc->c[0] = WRITE_6; |
732 | pc->flags |= PC_FLAG_WRITING; | 597 | pc->flags |= PC_FLAG_WRITING; |
733 | pc->b_data = bh->b_data; | ||
734 | pc->b_count = atomic_read(&bh->b_count); | ||
735 | } | 598 | } |
736 | 599 | ||
737 | memcpy(rq->cmd, pc->c, 12); | 600 | memcpy(rq->cmd, pc->c, 12); |
@@ -747,12 +610,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
747 | struct ide_cmd cmd; | 610 | struct ide_cmd cmd; |
748 | u8 stat; | 611 | u8 stat; |
749 | 612 | ||
750 | debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu," | 613 | debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n" |
751 | " current_nr_sectors: %u\n", | 614 | (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); |
752 | (unsigned long long)rq->sector, rq->nr_sectors, | ||
753 | rq->current_nr_sectors); | ||
754 | 615 | ||
755 | if (!blk_special_request(rq)) { | 616 | if (!(blk_special_request(rq) || blk_sense_request(rq))) { |
756 | /* We do not support buffer cache originated requests. */ | 617 | /* We do not support buffer cache originated requests. */ |
757 | printk(KERN_NOTICE "ide-tape: %s: Unsupported request in " | 618 | printk(KERN_NOTICE "ide-tape: %s: Unsupported request in " |
758 | "request queue (%d)\n", drive->name, rq->cmd_type); | 619 | "request queue (%d)\n", drive->name, rq->cmd_type); |
@@ -788,15 +649,15 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
788 | 649 | ||
789 | if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && | 650 | if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && |
790 | (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) | 651 | (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) |
791 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); | 652 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; |
792 | 653 | ||
793 | if (drive->dev_flags & IDE_DFLAG_POST_RESET) { | 654 | if (drive->dev_flags & IDE_DFLAG_POST_RESET) { |
794 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); | 655 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; |
795 | drive->dev_flags &= ~IDE_DFLAG_POST_RESET; | 656 | drive->dev_flags &= ~IDE_DFLAG_POST_RESET; |
796 | } | 657 | } |
797 | 658 | ||
798 | if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && | 659 | if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && |
799 | (stat & ATA_DSC) == 0) { | 660 | !(stat & ATA_DSC)) { |
800 | if (postponed_rq == NULL) { | 661 | if (postponed_rq == NULL) { |
801 | tape->dsc_polling_start = jiffies; | 662 | tape->dsc_polling_start = jiffies; |
802 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; | 663 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; |
@@ -816,7 +677,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
816 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; | 677 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; |
817 | idetape_postpone_request(drive); | 678 | idetape_postpone_request(drive); |
818 | return ide_stopped; | 679 | return ide_stopped; |
819 | } | 680 | } else |
681 | drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; | ||
682 | |||
820 | if (rq->cmd[13] & REQ_IDETAPE_READ) { | 683 | if (rq->cmd[13] & REQ_IDETAPE_READ) { |
821 | pc = &tape->queued_pc; | 684 | pc = &tape->queued_pc; |
822 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); | 685 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); |
@@ -828,7 +691,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
828 | goto out; | 691 | goto out; |
829 | } | 692 | } |
830 | if (rq->cmd[13] & REQ_IDETAPE_PC1) { | 693 | if (rq->cmd[13] & REQ_IDETAPE_PC1) { |
831 | pc = (struct ide_atapi_pc *) rq->buffer; | 694 | pc = (struct ide_atapi_pc *)rq->special; |
832 | rq->cmd[13] &= ~(REQ_IDETAPE_PC1); | 695 | rq->cmd[13] &= ~(REQ_IDETAPE_PC1); |
833 | rq->cmd[13] |= REQ_IDETAPE_PC2; | 696 | rq->cmd[13] |= REQ_IDETAPE_PC2; |
834 | goto out; | 697 | goto out; |
@@ -840,6 +703,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
840 | BUG(); | 703 | BUG(); |
841 | 704 | ||
842 | out: | 705 | out: |
706 | /* prepare sense request for this command */ | ||
707 | ide_prep_sense(drive, rq); | ||
708 | |||
843 | memset(&cmd, 0, sizeof(cmd)); | 709 | memset(&cmd, 0, sizeof(cmd)); |
844 | 710 | ||
845 | if (rq_data_dir(rq)) | 711 | if (rq_data_dir(rq)) |
@@ -847,167 +713,10 @@ out: | |||
847 | 713 | ||
848 | cmd.rq = rq; | 714 | cmd.rq = rq; |
849 | 715 | ||
850 | return ide_tape_issue_pc(drive, &cmd, pc); | 716 | ide_init_sg_cmd(&cmd, pc->req_xfer); |
851 | } | 717 | ide_map_sg(drive, &cmd); |
852 | |||
853 | /* | ||
854 | * The function below uses __get_free_pages to allocate a data buffer of size | ||
855 | * tape->buffer_size (or a bit more). We attempt to combine sequential pages as | ||
856 | * much as possible. | ||
857 | * | ||
858 | * It returns a pointer to the newly allocated buffer, or NULL in case of | ||
859 | * failure. | ||
860 | */ | ||
861 | static struct idetape_bh *ide_tape_kmalloc_buffer(idetape_tape_t *tape, | ||
862 | int full, int clear) | ||
863 | { | ||
864 | struct idetape_bh *prev_bh, *bh, *merge_bh; | ||
865 | int pages = tape->pages_per_buffer; | ||
866 | unsigned int order, b_allocd; | ||
867 | char *b_data = NULL; | ||
868 | |||
869 | merge_bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); | ||
870 | bh = merge_bh; | ||
871 | if (bh == NULL) | ||
872 | goto abort; | ||
873 | |||
874 | order = fls(pages) - 1; | ||
875 | bh->b_data = (char *) __get_free_pages(GFP_KERNEL, order); | ||
876 | if (!bh->b_data) | ||
877 | goto abort; | ||
878 | b_allocd = (1 << order) * PAGE_SIZE; | ||
879 | pages &= (order-1); | ||
880 | |||
881 | if (clear) | ||
882 | memset(bh->b_data, 0, b_allocd); | ||
883 | bh->b_reqnext = NULL; | ||
884 | bh->b_size = b_allocd; | ||
885 | atomic_set(&bh->b_count, full ? bh->b_size : 0); | ||
886 | |||
887 | while (pages) { | ||
888 | order = fls(pages) - 1; | ||
889 | b_data = (char *) __get_free_pages(GFP_KERNEL, order); | ||
890 | if (!b_data) | ||
891 | goto abort; | ||
892 | b_allocd = (1 << order) * PAGE_SIZE; | ||
893 | |||
894 | if (clear) | ||
895 | memset(b_data, 0, b_allocd); | ||
896 | |||
897 | /* newly allocated page frames below buffer header or ...*/ | ||
898 | if (bh->b_data == b_data + b_allocd) { | ||
899 | bh->b_size += b_allocd; | ||
900 | bh->b_data -= b_allocd; | ||
901 | if (full) | ||
902 | atomic_add(b_allocd, &bh->b_count); | ||
903 | continue; | ||
904 | } | ||
905 | /* they are above the header */ | ||
906 | if (b_data == bh->b_data + bh->b_size) { | ||
907 | bh->b_size += b_allocd; | ||
908 | if (full) | ||
909 | atomic_add(b_allocd, &bh->b_count); | ||
910 | continue; | ||
911 | } | ||
912 | prev_bh = bh; | ||
913 | bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); | ||
914 | if (!bh) { | ||
915 | free_pages((unsigned long) b_data, order); | ||
916 | goto abort; | ||
917 | } | ||
918 | bh->b_reqnext = NULL; | ||
919 | bh->b_data = b_data; | ||
920 | bh->b_size = b_allocd; | ||
921 | atomic_set(&bh->b_count, full ? bh->b_size : 0); | ||
922 | prev_bh->b_reqnext = bh; | ||
923 | |||
924 | pages &= (order-1); | ||
925 | } | ||
926 | |||
927 | bh->b_size -= tape->excess_bh_size; | ||
928 | if (full) | ||
929 | atomic_sub(tape->excess_bh_size, &bh->b_count); | ||
930 | return merge_bh; | ||
931 | abort: | ||
932 | ide_tape_kfree_buffer(tape); | ||
933 | return NULL; | ||
934 | } | ||
935 | |||
936 | static int idetape_copy_stage_from_user(idetape_tape_t *tape, | ||
937 | const char __user *buf, int n) | ||
938 | { | ||
939 | struct idetape_bh *bh = tape->bh; | ||
940 | int count; | ||
941 | int ret = 0; | ||
942 | |||
943 | while (n) { | ||
944 | if (bh == NULL) { | ||
945 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", | ||
946 | __func__); | ||
947 | return 1; | ||
948 | } | ||
949 | count = min((unsigned int) | ||
950 | (bh->b_size - atomic_read(&bh->b_count)), | ||
951 | (unsigned int)n); | ||
952 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, | ||
953 | count)) | ||
954 | ret = 1; | ||
955 | n -= count; | ||
956 | atomic_add(count, &bh->b_count); | ||
957 | buf += count; | ||
958 | if (atomic_read(&bh->b_count) == bh->b_size) { | ||
959 | bh = bh->b_reqnext; | ||
960 | if (bh) | ||
961 | atomic_set(&bh->b_count, 0); | ||
962 | } | ||
963 | } | ||
964 | tape->bh = bh; | ||
965 | return ret; | ||
966 | } | ||
967 | 718 | ||
968 | static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf, | 719 | return ide_tape_issue_pc(drive, &cmd, pc); |
969 | int n) | ||
970 | { | ||
971 | struct idetape_bh *bh = tape->bh; | ||
972 | int count; | ||
973 | int ret = 0; | ||
974 | |||
975 | while (n) { | ||
976 | if (bh == NULL) { | ||
977 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", | ||
978 | __func__); | ||
979 | return 1; | ||
980 | } | ||
981 | count = min(tape->b_count, n); | ||
982 | if (copy_to_user(buf, tape->b_data, count)) | ||
983 | ret = 1; | ||
984 | n -= count; | ||
985 | tape->b_data += count; | ||
986 | tape->b_count -= count; | ||
987 | buf += count; | ||
988 | if (!tape->b_count) { | ||
989 | bh = bh->b_reqnext; | ||
990 | tape->bh = bh; | ||
991 | if (bh) { | ||
992 | tape->b_data = bh->b_data; | ||
993 | tape->b_count = atomic_read(&bh->b_count); | ||
994 | } | ||
995 | } | ||
996 | } | ||
997 | return ret; | ||
998 | } | ||
999 | |||
1000 | static void idetape_init_merge_buffer(idetape_tape_t *tape) | ||
1001 | { | ||
1002 | struct idetape_bh *bh = tape->merge_bh; | ||
1003 | tape->bh = tape->merge_bh; | ||
1004 | |||
1005 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) | ||
1006 | atomic_set(&bh->b_count, 0); | ||
1007 | else { | ||
1008 | tape->b_data = bh->b_data; | ||
1009 | tape->b_count = atomic_read(&bh->b_count); | ||
1010 | } | ||
1011 | } | 720 | } |
1012 | 721 | ||
1013 | /* | 722 | /* |
@@ -1030,7 +739,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1030 | int load_attempted = 0; | 739 | int load_attempted = 0; |
1031 | 740 | ||
1032 | /* Wait for the tape to become ready */ | 741 | /* Wait for the tape to become ready */ |
1033 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 742 | set_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), &drive->atapi_flags); |
1034 | timeout += jiffies; | 743 | timeout += jiffies; |
1035 | while (time_before(jiffies, timeout)) { | 744 | while (time_before(jiffies, timeout)) { |
1036 | if (ide_do_test_unit_ready(drive, disk) == 0) | 745 | if (ide_do_test_unit_ready(drive, disk) == 0) |
@@ -1106,11 +815,11 @@ static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) | |||
1106 | if (tape->chrdev_dir != IDETAPE_DIR_READ) | 815 | if (tape->chrdev_dir != IDETAPE_DIR_READ) |
1107 | return; | 816 | return; |
1108 | 817 | ||
1109 | clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags); | 818 | clear_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags); |
1110 | tape->merge_bh_size = 0; | 819 | tape->valid = 0; |
1111 | if (tape->merge_bh != NULL) { | 820 | if (tape->buf != NULL) { |
1112 | ide_tape_kfree_buffer(tape); | 821 | kfree(tape->buf); |
1113 | tape->merge_bh = NULL; | 822 | tape->buf = NULL; |
1114 | } | 823 | } |
1115 | 824 | ||
1116 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 825 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
@@ -1164,36 +873,44 @@ static void ide_tape_discard_merge_buffer(ide_drive_t *drive, | |||
1164 | * Generate a read/write request for the block device interface and wait for it | 873 | * Generate a read/write request for the block device interface and wait for it |
1165 | * to be serviced. | 874 | * to be serviced. |
1166 | */ | 875 | */ |
1167 | static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | 876 | static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) |
1168 | struct idetape_bh *bh) | ||
1169 | { | 877 | { |
1170 | idetape_tape_t *tape = drive->driver_data; | 878 | idetape_tape_t *tape = drive->driver_data; |
1171 | struct request *rq; | 879 | struct request *rq; |
1172 | int ret, errors; | 880 | int ret; |
1173 | 881 | ||
1174 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); | 882 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); |
883 | BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); | ||
884 | BUG_ON(size < 0 || size % tape->blk_size); | ||
1175 | 885 | ||
1176 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 886 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1177 | rq->cmd_type = REQ_TYPE_SPECIAL; | 887 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1178 | rq->cmd[13] = cmd; | 888 | rq->cmd[13] = cmd; |
1179 | rq->rq_disk = tape->disk; | 889 | rq->rq_disk = tape->disk; |
1180 | rq->special = (void *)bh; | 890 | rq->__sector = tape->first_frame; |
1181 | rq->sector = tape->first_frame; | ||
1182 | rq->nr_sectors = blocks; | ||
1183 | rq->current_nr_sectors = blocks; | ||
1184 | blk_execute_rq(drive->queue, tape->disk, rq, 0); | ||
1185 | 891 | ||
1186 | errors = rq->errors; | 892 | if (size) { |
1187 | ret = tape->blk_size * (blocks - rq->current_nr_sectors); | 893 | ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size, |
1188 | blk_put_request(rq); | 894 | __GFP_WAIT); |
895 | if (ret) | ||
896 | goto out_put; | ||
897 | } | ||
1189 | 898 | ||
1190 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) | 899 | blk_execute_rq(drive->queue, tape->disk, rq, 0); |
1191 | return 0; | ||
1192 | 900 | ||
1193 | if (tape->merge_bh) | 901 | /* calculate the number of transferred bytes and update buffer state */ |
1194 | idetape_init_merge_buffer(tape); | 902 | size -= rq->resid_len; |
1195 | if (errors == IDE_DRV_ERROR_GENERAL) | 903 | tape->cur = tape->buf; |
1196 | return -EIO; | 904 | if (cmd == REQ_IDETAPE_READ) |
905 | tape->valid = size; | ||
906 | else | ||
907 | tape->valid = 0; | ||
908 | |||
909 | ret = size; | ||
910 | if (rq->errors == IDE_DRV_ERROR_GENERAL) | ||
911 | ret = -EIO; | ||
912 | out_put: | ||
913 | blk_put_request(rq); | ||
1197 | return ret; | 914 | return ret; |
1198 | } | 915 | } |
1199 | 916 | ||
@@ -1230,153 +947,87 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | |||
1230 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 947 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1231 | } | 948 | } |
1232 | 949 | ||
1233 | /* Queue up a character device originated write request. */ | ||
1234 | static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) | ||
1235 | { | ||
1236 | idetape_tape_t *tape = drive->driver_data; | ||
1237 | |||
1238 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); | ||
1239 | |||
1240 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, | ||
1241 | blocks, tape->merge_bh); | ||
1242 | } | ||
1243 | |||
1244 | static void ide_tape_flush_merge_buffer(ide_drive_t *drive) | 950 | static void ide_tape_flush_merge_buffer(ide_drive_t *drive) |
1245 | { | 951 | { |
1246 | idetape_tape_t *tape = drive->driver_data; | 952 | idetape_tape_t *tape = drive->driver_data; |
1247 | int blocks, min; | ||
1248 | struct idetape_bh *bh; | ||
1249 | 953 | ||
1250 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { | 954 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { |
1251 | printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer" | 955 | printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer" |
1252 | " but we are not writing.\n"); | 956 | " but we are not writing.\n"); |
1253 | return; | 957 | return; |
1254 | } | 958 | } |
1255 | if (tape->merge_bh_size > tape->buffer_size) { | 959 | if (tape->buf) { |
1256 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); | 960 | size_t aligned = roundup(tape->valid, tape->blk_size); |
1257 | tape->merge_bh_size = tape->buffer_size; | 961 | |
1258 | } | 962 | memset(tape->cur, 0, aligned - tape->valid); |
1259 | if (tape->merge_bh_size) { | 963 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, aligned); |
1260 | blocks = tape->merge_bh_size / tape->blk_size; | 964 | kfree(tape->buf); |
1261 | if (tape->merge_bh_size % tape->blk_size) { | 965 | tape->buf = NULL; |
1262 | unsigned int i; | ||
1263 | |||
1264 | blocks++; | ||
1265 | i = tape->blk_size - tape->merge_bh_size % | ||
1266 | tape->blk_size; | ||
1267 | bh = tape->bh->b_reqnext; | ||
1268 | while (bh) { | ||
1269 | atomic_set(&bh->b_count, 0); | ||
1270 | bh = bh->b_reqnext; | ||
1271 | } | ||
1272 | bh = tape->bh; | ||
1273 | while (i) { | ||
1274 | if (bh == NULL) { | ||
1275 | printk(KERN_INFO "ide-tape: bug," | ||
1276 | " bh NULL\n"); | ||
1277 | break; | ||
1278 | } | ||
1279 | min = min(i, (unsigned int)(bh->b_size - | ||
1280 | atomic_read(&bh->b_count))); | ||
1281 | memset(bh->b_data + atomic_read(&bh->b_count), | ||
1282 | 0, min); | ||
1283 | atomic_add(min, &bh->b_count); | ||
1284 | i -= min; | ||
1285 | bh = bh->b_reqnext; | ||
1286 | } | ||
1287 | } | ||
1288 | (void) idetape_add_chrdev_write_request(drive, blocks); | ||
1289 | tape->merge_bh_size = 0; | ||
1290 | } | ||
1291 | if (tape->merge_bh != NULL) { | ||
1292 | ide_tape_kfree_buffer(tape); | ||
1293 | tape->merge_bh = NULL; | ||
1294 | } | 966 | } |
1295 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 967 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
1296 | } | 968 | } |
1297 | 969 | ||
1298 | static int idetape_init_read(ide_drive_t *drive) | 970 | static int idetape_init_rw(ide_drive_t *drive, int dir) |
1299 | { | 971 | { |
1300 | idetape_tape_t *tape = drive->driver_data; | 972 | idetape_tape_t *tape = drive->driver_data; |
1301 | int bytes_read; | 973 | int rc; |
1302 | |||
1303 | /* Initialize read operation */ | ||
1304 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | ||
1305 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { | ||
1306 | ide_tape_flush_merge_buffer(drive); | ||
1307 | idetape_flush_tape_buffers(drive); | ||
1308 | } | ||
1309 | if (tape->merge_bh || tape->merge_bh_size) { | ||
1310 | printk(KERN_ERR "ide-tape: merge_bh_size should be" | ||
1311 | " 0 now\n"); | ||
1312 | tape->merge_bh_size = 0; | ||
1313 | } | ||
1314 | tape->merge_bh = ide_tape_kmalloc_buffer(tape, 0, 0); | ||
1315 | if (!tape->merge_bh) | ||
1316 | return -ENOMEM; | ||
1317 | tape->chrdev_dir = IDETAPE_DIR_READ; | ||
1318 | 974 | ||
1319 | /* | 975 | BUG_ON(dir != IDETAPE_DIR_READ && dir != IDETAPE_DIR_WRITE); |
1320 | * Issue a read 0 command to ensure that DSC handshake is | ||
1321 | * switched from completion mode to buffer available mode. | ||
1322 | * No point in issuing this if DSC overlap isn't supported, some | ||
1323 | * drives (Seagate STT3401A) will return an error. | ||
1324 | */ | ||
1325 | if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { | ||
1326 | bytes_read = idetape_queue_rw_tail(drive, | ||
1327 | REQ_IDETAPE_READ, 0, | ||
1328 | tape->merge_bh); | ||
1329 | if (bytes_read < 0) { | ||
1330 | ide_tape_kfree_buffer(tape); | ||
1331 | tape->merge_bh = NULL; | ||
1332 | tape->chrdev_dir = IDETAPE_DIR_NONE; | ||
1333 | return bytes_read; | ||
1334 | } | ||
1335 | } | ||
1336 | } | ||
1337 | 976 | ||
1338 | return 0; | 977 | if (tape->chrdev_dir == dir) |
1339 | } | 978 | return 0; |
1340 | 979 | ||
1341 | /* called from idetape_chrdev_read() to service a chrdev read request. */ | 980 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
1342 | static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | 981 | ide_tape_discard_merge_buffer(drive, 1); |
1343 | { | 982 | else if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { |
1344 | idetape_tape_t *tape = drive->driver_data; | 983 | ide_tape_flush_merge_buffer(drive); |
984 | idetape_flush_tape_buffers(drive); | ||
985 | } | ||
1345 | 986 | ||
1346 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); | 987 | if (tape->buf || tape->valid) { |
988 | printk(KERN_ERR "ide-tape: valid should be 0 now\n"); | ||
989 | tape->valid = 0; | ||
990 | } | ||
1347 | 991 | ||
1348 | /* If we are at a filemark, return a read length of 0 */ | 992 | tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); |
1349 | if (test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) | 993 | if (!tape->buf) |
1350 | return 0; | 994 | return -ENOMEM; |
995 | tape->chrdev_dir = dir; | ||
996 | tape->cur = tape->buf; | ||
1351 | 997 | ||
1352 | idetape_init_read(drive); | 998 | /* |
999 | * Issue a 0 rw command to ensure that DSC handshake is | ||
1000 | * switched from completion mode to buffer available mode. No | ||
1001 | * point in issuing this if DSC overlap isn't supported, some | ||
1002 | * drives (Seagate STT3401A) will return an error. | ||
1003 | */ | ||
1004 | if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { | ||
1005 | int cmd = dir == IDETAPE_DIR_READ ? REQ_IDETAPE_READ | ||
1006 | : REQ_IDETAPE_WRITE; | ||
1007 | |||
1008 | rc = idetape_queue_rw_tail(drive, cmd, 0); | ||
1009 | if (rc < 0) { | ||
1010 | kfree(tape->buf); | ||
1011 | tape->buf = NULL; | ||
1012 | tape->chrdev_dir = IDETAPE_DIR_NONE; | ||
1013 | return rc; | ||
1014 | } | ||
1015 | } | ||
1353 | 1016 | ||
1354 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, | 1017 | return 0; |
1355 | tape->merge_bh); | ||
1356 | } | 1018 | } |
1357 | 1019 | ||
1358 | static void idetape_pad_zeros(ide_drive_t *drive, int bcount) | 1020 | static void idetape_pad_zeros(ide_drive_t *drive, int bcount) |
1359 | { | 1021 | { |
1360 | idetape_tape_t *tape = drive->driver_data; | 1022 | idetape_tape_t *tape = drive->driver_data; |
1361 | struct idetape_bh *bh; | 1023 | |
1362 | int blocks; | 1024 | memset(tape->buf, 0, tape->buffer_size); |
1363 | 1025 | ||
1364 | while (bcount) { | 1026 | while (bcount) { |
1365 | unsigned int count; | 1027 | unsigned int count = min(tape->buffer_size, bcount); |
1366 | 1028 | ||
1367 | bh = tape->merge_bh; | 1029 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, count); |
1368 | count = min(tape->buffer_size, bcount); | ||
1369 | bcount -= count; | 1030 | bcount -= count; |
1370 | blocks = count / tape->blk_size; | ||
1371 | while (count) { | ||
1372 | atomic_set(&bh->b_count, | ||
1373 | min(count, (unsigned int)bh->b_size)); | ||
1374 | memset(bh->b_data, 0, atomic_read(&bh->b_count)); | ||
1375 | count -= atomic_read(&bh->b_count); | ||
1376 | bh = bh->b_reqnext; | ||
1377 | } | ||
1378 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, | ||
1379 | tape->merge_bh); | ||
1380 | } | 1031 | } |
1381 | } | 1032 | } |
1382 | 1033 | ||
@@ -1456,8 +1107,9 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
1456 | } | 1107 | } |
1457 | 1108 | ||
1458 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 1109 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
1459 | tape->merge_bh_size = 0; | 1110 | tape->valid = 0; |
1460 | if (test_and_clear_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) | 1111 | if (test_and_clear_bit(ilog2(IDE_AFLAG_FILEMARK), |
1112 | &drive->atapi_flags)) | ||
1461 | ++count; | 1113 | ++count; |
1462 | ide_tape_discard_merge_buffer(drive, 0); | 1114 | ide_tape_discard_merge_buffer(drive, 0); |
1463 | } | 1115 | } |
@@ -1505,61 +1157,56 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
1505 | { | 1157 | { |
1506 | struct ide_tape_obj *tape = file->private_data; | 1158 | struct ide_tape_obj *tape = file->private_data; |
1507 | ide_drive_t *drive = tape->drive; | 1159 | ide_drive_t *drive = tape->drive; |
1508 | ssize_t bytes_read, temp, actually_read = 0, rc; | 1160 | size_t done = 0; |
1509 | ssize_t ret = 0; | 1161 | ssize_t ret = 0; |
1510 | u16 ctl = *(u16 *)&tape->caps[12]; | 1162 | int rc; |
1511 | 1163 | ||
1512 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 1164 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); |
1513 | 1165 | ||
1514 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 1166 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
1515 | if (test_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags)) | 1167 | if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) |
1516 | if (count > tape->blk_size && | 1168 | if (count > tape->blk_size && |
1517 | (count % tape->blk_size) == 0) | 1169 | (count % tape->blk_size) == 0) |
1518 | tape->user_bs_factor = count / tape->blk_size; | 1170 | tape->user_bs_factor = count / tape->blk_size; |
1519 | } | 1171 | } |
1520 | rc = idetape_init_read(drive); | 1172 | |
1173 | rc = idetape_init_rw(drive, IDETAPE_DIR_READ); | ||
1521 | if (rc < 0) | 1174 | if (rc < 0) |
1522 | return rc; | 1175 | return rc; |
1523 | if (count == 0) | 1176 | |
1524 | return (0); | 1177 | while (done < count) { |
1525 | if (tape->merge_bh_size) { | 1178 | size_t todo; |
1526 | actually_read = min((unsigned int)(tape->merge_bh_size), | 1179 | |
1527 | (unsigned int)count); | 1180 | /* refill if staging buffer is empty */ |
1528 | if (idetape_copy_stage_to_user(tape, buf, actually_read)) | 1181 | if (!tape->valid) { |
1529 | ret = -EFAULT; | 1182 | /* If we are at a filemark, nothing more to read */ |
1530 | buf += actually_read; | 1183 | if (test_bit(ilog2(IDE_AFLAG_FILEMARK), |
1531 | tape->merge_bh_size -= actually_read; | 1184 | &drive->atapi_flags)) |
1532 | count -= actually_read; | 1185 | break; |
1533 | } | 1186 | /* read */ |
1534 | while (count >= tape->buffer_size) { | 1187 | if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, |
1535 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); | 1188 | tape->buffer_size) <= 0) |
1536 | if (bytes_read <= 0) | 1189 | break; |
1537 | goto finish; | 1190 | } |
1538 | if (idetape_copy_stage_to_user(tape, buf, bytes_read)) | 1191 | |
1539 | ret = -EFAULT; | 1192 | /* copy out */ |
1540 | buf += bytes_read; | 1193 | todo = min_t(size_t, count - done, tape->valid); |
1541 | count -= bytes_read; | 1194 | if (copy_to_user(buf + done, tape->cur, todo)) |
1542 | actually_read += bytes_read; | ||
1543 | } | ||
1544 | if (count) { | ||
1545 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); | ||
1546 | if (bytes_read <= 0) | ||
1547 | goto finish; | ||
1548 | temp = min((unsigned long)count, (unsigned long)bytes_read); | ||
1549 | if (idetape_copy_stage_to_user(tape, buf, temp)) | ||
1550 | ret = -EFAULT; | 1195 | ret = -EFAULT; |
1551 | actually_read += temp; | 1196 | |
1552 | tape->merge_bh_size = bytes_read-temp; | 1197 | tape->cur += todo; |
1198 | tape->valid -= todo; | ||
1199 | done += todo; | ||
1553 | } | 1200 | } |
1554 | finish: | 1201 | |
1555 | if (!actually_read && test_bit(IDE_AFLAG_FILEMARK, &drive->atapi_flags)) { | 1202 | if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { |
1556 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); | 1203 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); |
1557 | 1204 | ||
1558 | idetape_space_over_filemarks(drive, MTFSF, 1); | 1205 | idetape_space_over_filemarks(drive, MTFSF, 1); |
1559 | return 0; | 1206 | return 0; |
1560 | } | 1207 | } |
1561 | 1208 | ||
1562 | return ret ? ret : actually_read; | 1209 | return ret ? ret : done; |
1563 | } | 1210 | } |
1564 | 1211 | ||
1565 | static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | 1212 | static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, |
@@ -1567,9 +1214,9 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
1567 | { | 1214 | { |
1568 | struct ide_tape_obj *tape = file->private_data; | 1215 | struct ide_tape_obj *tape = file->private_data; |
1569 | ide_drive_t *drive = tape->drive; | 1216 | ide_drive_t *drive = tape->drive; |
1570 | ssize_t actually_written = 0; | 1217 | size_t done = 0; |
1571 | ssize_t ret = 0; | 1218 | ssize_t ret = 0; |
1572 | u16 ctl = *(u16 *)&tape->caps[12]; | 1219 | int rc; |
1573 | 1220 | ||
1574 | /* The drive is write protected. */ | 1221 | /* The drive is write protected. */ |
1575 | if (tape->write_prot) | 1222 | if (tape->write_prot) |
@@ -1578,80 +1225,31 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
1578 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 1225 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); |
1579 | 1226 | ||
1580 | /* Initialize write operation */ | 1227 | /* Initialize write operation */ |
1581 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { | 1228 | rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); |
1582 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 1229 | if (rc < 0) |
1583 | ide_tape_discard_merge_buffer(drive, 1); | 1230 | return rc; |
1584 | if (tape->merge_bh || tape->merge_bh_size) { | ||
1585 | printk(KERN_ERR "ide-tape: merge_bh_size " | ||
1586 | "should be 0 now\n"); | ||
1587 | tape->merge_bh_size = 0; | ||
1588 | } | ||
1589 | tape->merge_bh = ide_tape_kmalloc_buffer(tape, 0, 0); | ||
1590 | if (!tape->merge_bh) | ||
1591 | return -ENOMEM; | ||
1592 | tape->chrdev_dir = IDETAPE_DIR_WRITE; | ||
1593 | idetape_init_merge_buffer(tape); | ||
1594 | 1231 | ||
1595 | /* | 1232 | while (done < count) { |
1596 | * Issue a write 0 command to ensure that DSC handshake is | 1233 | size_t todo; |
1597 | * switched from completion mode to buffer available mode. No | 1234 | |
1598 | * point in issuing this if DSC overlap isn't supported, some | 1235 | /* flush if staging buffer is full */ |
1599 | * drives (Seagate STT3401A) will return an error. | 1236 | if (tape->valid == tape->buffer_size && |
1600 | */ | 1237 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, |
1601 | if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { | 1238 | tape->buffer_size) <= 0) |
1602 | ssize_t retval = idetape_queue_rw_tail(drive, | 1239 | return rc; |
1603 | REQ_IDETAPE_WRITE, 0, | 1240 | |
1604 | tape->merge_bh); | 1241 | /* copy in */ |
1605 | if (retval < 0) { | 1242 | todo = min_t(size_t, count - done, |
1606 | ide_tape_kfree_buffer(tape); | 1243 | tape->buffer_size - tape->valid); |
1607 | tape->merge_bh = NULL; | 1244 | if (copy_from_user(tape->cur, buf + done, todo)) |
1608 | tape->chrdev_dir = IDETAPE_DIR_NONE; | ||
1609 | return retval; | ||
1610 | } | ||
1611 | } | ||
1612 | } | ||
1613 | if (count == 0) | ||
1614 | return (0); | ||
1615 | if (tape->merge_bh_size) { | ||
1616 | if (tape->merge_bh_size >= tape->buffer_size) { | ||
1617 | printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); | ||
1618 | tape->merge_bh_size = 0; | ||
1619 | } | ||
1620 | actually_written = min((unsigned int) | ||
1621 | (tape->buffer_size - tape->merge_bh_size), | ||
1622 | (unsigned int)count); | ||
1623 | if (idetape_copy_stage_from_user(tape, buf, actually_written)) | ||
1624 | ret = -EFAULT; | ||
1625 | buf += actually_written; | ||
1626 | tape->merge_bh_size += actually_written; | ||
1627 | count -= actually_written; | ||
1628 | |||
1629 | if (tape->merge_bh_size == tape->buffer_size) { | ||
1630 | ssize_t retval; | ||
1631 | tape->merge_bh_size = 0; | ||
1632 | retval = idetape_add_chrdev_write_request(drive, ctl); | ||
1633 | if (retval <= 0) | ||
1634 | return (retval); | ||
1635 | } | ||
1636 | } | ||
1637 | while (count >= tape->buffer_size) { | ||
1638 | ssize_t retval; | ||
1639 | if (idetape_copy_stage_from_user(tape, buf, tape->buffer_size)) | ||
1640 | ret = -EFAULT; | ||
1641 | buf += tape->buffer_size; | ||
1642 | count -= tape->buffer_size; | ||
1643 | retval = idetape_add_chrdev_write_request(drive, ctl); | ||
1644 | actually_written += tape->buffer_size; | ||
1645 | if (retval <= 0) | ||
1646 | return (retval); | ||
1647 | } | ||
1648 | if (count) { | ||
1649 | actually_written += count; | ||
1650 | if (idetape_copy_stage_from_user(tape, buf, count)) | ||
1651 | ret = -EFAULT; | 1245 | ret = -EFAULT; |
1652 | tape->merge_bh_size += count; | 1246 | |
1247 | tape->cur += todo; | ||
1248 | tape->valid += todo; | ||
1249 | done += todo; | ||
1653 | } | 1250 | } |
1654 | return ret ? ret : actually_written; | 1251 | |
1252 | return ret ? ret : done; | ||
1655 | } | 1253 | } |
1656 | 1254 | ||
1657 | static int idetape_write_filemark(ide_drive_t *drive) | 1255 | static int idetape_write_filemark(ide_drive_t *drive) |
@@ -1735,7 +1333,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1735 | ide_tape_discard_merge_buffer(drive, 0); | 1333 | ide_tape_discard_merge_buffer(drive, 0); |
1736 | retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); | 1334 | retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); |
1737 | if (!retval) | 1335 | if (!retval) |
1738 | clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 1336 | clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), |
1337 | &drive->atapi_flags); | ||
1739 | return retval; | 1338 | return retval; |
1740 | case MTNOP: | 1339 | case MTNOP: |
1741 | ide_tape_discard_merge_buffer(drive, 0); | 1340 | ide_tape_discard_merge_buffer(drive, 0); |
@@ -1757,9 +1356,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1757 | mt_count % tape->blk_size) | 1356 | mt_count % tape->blk_size) |
1758 | return -EIO; | 1357 | return -EIO; |
1759 | tape->user_bs_factor = mt_count / tape->blk_size; | 1358 | tape->user_bs_factor = mt_count / tape->blk_size; |
1760 | clear_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); | 1359 | clear_bit(ilog2(IDE_AFLAG_DETECT_BS), |
1360 | &drive->atapi_flags); | ||
1761 | } else | 1361 | } else |
1762 | set_bit(IDE_AFLAG_DETECT_BS, &drive->atapi_flags); | 1362 | set_bit(ilog2(IDE_AFLAG_DETECT_BS), |
1363 | &drive->atapi_flags); | ||
1763 | return 0; | 1364 | return 0; |
1764 | case MTSEEK: | 1365 | case MTSEEK: |
1765 | ide_tape_discard_merge_buffer(drive, 0); | 1366 | ide_tape_discard_merge_buffer(drive, 0); |
@@ -1812,7 +1413,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
1812 | idetape_flush_tape_buffers(drive); | 1413 | idetape_flush_tape_buffers(drive); |
1813 | } | 1414 | } |
1814 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { | 1415 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { |
1815 | block_offset = tape->merge_bh_size / | 1416 | block_offset = tape->valid / |
1816 | (tape->blk_size * tape->user_bs_factor); | 1417 | (tape->blk_size * tape->user_bs_factor); |
1817 | position = idetape_read_position(drive); | 1418 | position = idetape_read_position(drive); |
1818 | if (position < 0) | 1419 | if (position < 0) |
@@ -1885,7 +1486,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1885 | return -ENXIO; | 1486 | return -ENXIO; |
1886 | 1487 | ||
1887 | lock_kernel(); | 1488 | lock_kernel(); |
1888 | tape = ide_tape_chrdev_get(i); | 1489 | tape = ide_tape_get(NULL, true, i); |
1889 | if (!tape) { | 1490 | if (!tape) { |
1890 | unlock_kernel(); | 1491 | unlock_kernel(); |
1891 | return -ENXIO; | 1492 | return -ENXIO; |
@@ -1904,20 +1505,20 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1904 | 1505 | ||
1905 | filp->private_data = tape; | 1506 | filp->private_data = tape; |
1906 | 1507 | ||
1907 | if (test_and_set_bit(IDE_AFLAG_BUSY, &drive->atapi_flags)) { | 1508 | if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { |
1908 | retval = -EBUSY; | 1509 | retval = -EBUSY; |
1909 | goto out_put_tape; | 1510 | goto out_put_tape; |
1910 | } | 1511 | } |
1911 | 1512 | ||
1912 | retval = idetape_wait_ready(drive, 60 * HZ); | 1513 | retval = idetape_wait_ready(drive, 60 * HZ); |
1913 | if (retval) { | 1514 | if (retval) { |
1914 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 1515 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1915 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); | 1516 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); |
1916 | goto out_put_tape; | 1517 | goto out_put_tape; |
1917 | } | 1518 | } |
1918 | 1519 | ||
1919 | idetape_read_position(drive); | 1520 | idetape_read_position(drive); |
1920 | if (!test_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags)) | 1521 | if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags)) |
1921 | (void)idetape_rewind_tape(drive); | 1522 | (void)idetape_rewind_tape(drive); |
1922 | 1523 | ||
1923 | /* Read block size and write protect status from drive. */ | 1524 | /* Read block size and write protect status from drive. */ |
@@ -1933,7 +1534,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1933 | if (tape->write_prot) { | 1534 | if (tape->write_prot) { |
1934 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || | 1535 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || |
1935 | (filp->f_flags & O_ACCMODE) == O_RDWR) { | 1536 | (filp->f_flags & O_ACCMODE) == O_RDWR) { |
1936 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 1537 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1937 | retval = -EROFS; | 1538 | retval = -EROFS; |
1938 | goto out_put_tape; | 1539 | goto out_put_tape; |
1939 | } | 1540 | } |
@@ -1960,12 +1561,12 @@ static void idetape_write_release(ide_drive_t *drive, unsigned int minor) | |||
1960 | idetape_tape_t *tape = drive->driver_data; | 1561 | idetape_tape_t *tape = drive->driver_data; |
1961 | 1562 | ||
1962 | ide_tape_flush_merge_buffer(drive); | 1563 | ide_tape_flush_merge_buffer(drive); |
1963 | tape->merge_bh = ide_tape_kmalloc_buffer(tape, 1, 0); | 1564 | tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); |
1964 | if (tape->merge_bh != NULL) { | 1565 | if (tape->buf != NULL) { |
1965 | idetape_pad_zeros(drive, tape->blk_size * | 1566 | idetape_pad_zeros(drive, tape->blk_size * |
1966 | (tape->user_bs_factor - 1)); | 1567 | (tape->user_bs_factor - 1)); |
1967 | ide_tape_kfree_buffer(tape); | 1568 | kfree(tape->buf); |
1968 | tape->merge_bh = NULL; | 1569 | tape->buf = NULL; |
1969 | } | 1570 | } |
1970 | idetape_write_filemark(drive); | 1571 | idetape_write_filemark(drive); |
1971 | idetape_flush_tape_buffers(drive); | 1572 | idetape_flush_tape_buffers(drive); |
@@ -1990,15 +1591,17 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1990 | ide_tape_discard_merge_buffer(drive, 1); | 1591 | ide_tape_discard_merge_buffer(drive, 1); |
1991 | } | 1592 | } |
1992 | 1593 | ||
1993 | if (minor < 128 && test_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags)) | 1594 | if (minor < 128 && test_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), |
1595 | &drive->atapi_flags)) | ||
1994 | (void) idetape_rewind_tape(drive); | 1596 | (void) idetape_rewind_tape(drive); |
1597 | |||
1995 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 1598 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
1996 | if (tape->door_locked == DOOR_LOCKED) { | 1599 | if (tape->door_locked == DOOR_LOCKED) { |
1997 | if (!ide_set_media_lock(drive, tape->disk, 0)) | 1600 | if (!ide_set_media_lock(drive, tape->disk, 0)) |
1998 | tape->door_locked = DOOR_UNLOCKED; | 1601 | tape->door_locked = DOOR_UNLOCKED; |
1999 | } | 1602 | } |
2000 | } | 1603 | } |
2001 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 1604 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
2002 | ide_tape_put(tape); | 1605 | ide_tape_put(tape); |
2003 | unlock_kernel(); | 1606 | unlock_kernel(); |
2004 | return 0; | 1607 | return 0; |
@@ -2159,8 +1762,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
2159 | u16 *ctl = (u16 *)&tape->caps[12]; | 1762 | u16 *ctl = (u16 *)&tape->caps[12]; |
2160 | 1763 | ||
2161 | drive->pc_callback = ide_tape_callback; | 1764 | drive->pc_callback = ide_tape_callback; |
2162 | drive->pc_update_buffers = idetape_update_buffers; | ||
2163 | drive->pc_io_buffers = ide_tape_io_buffers; | ||
2164 | 1765 | ||
2165 | drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; | 1766 | drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; |
2166 | 1767 | ||
@@ -2191,11 +1792,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
2191 | tape->buffer_size = *ctl * tape->blk_size; | 1792 | tape->buffer_size = *ctl * tape->blk_size; |
2192 | } | 1793 | } |
2193 | buffer_size = tape->buffer_size; | 1794 | buffer_size = tape->buffer_size; |
2194 | tape->pages_per_buffer = buffer_size / PAGE_SIZE; | ||
2195 | if (buffer_size % PAGE_SIZE) { | ||
2196 | tape->pages_per_buffer++; | ||
2197 | tape->excess_bh_size = PAGE_SIZE - buffer_size % PAGE_SIZE; | ||
2198 | } | ||
2199 | 1795 | ||
2200 | /* select the "best" DSC read/write polling freq */ | 1796 | /* select the "best" DSC read/write polling freq */ |
2201 | speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); | 1797 | speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); |
@@ -2238,7 +1834,7 @@ static void ide_tape_release(struct device *dev) | |||
2238 | ide_drive_t *drive = tape->drive; | 1834 | ide_drive_t *drive = tape->drive; |
2239 | struct gendisk *g = tape->disk; | 1835 | struct gendisk *g = tape->disk; |
2240 | 1836 | ||
2241 | BUG_ON(tape->merge_bh_size); | 1837 | BUG_ON(tape->valid); |
2242 | 1838 | ||
2243 | drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; | 1839 | drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; |
2244 | drive->driver_data = NULL; | 1840 | drive->driver_data = NULL; |
@@ -2311,7 +1907,7 @@ static const struct file_operations idetape_fops = { | |||
2311 | 1907 | ||
2312 | static int idetape_open(struct block_device *bdev, fmode_t mode) | 1908 | static int idetape_open(struct block_device *bdev, fmode_t mode) |
2313 | { | 1909 | { |
2314 | struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk); | 1910 | struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk, false, 0); |
2315 | 1911 | ||
2316 | if (!tape) | 1912 | if (!tape) |
2317 | return -ENXIO; | 1913 | return -ENXIO; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 4aa6223c11be..75b85a8cd2d4 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -98,7 +98,6 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd) | |||
98 | if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { | 98 | if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { |
99 | ide_tf_dump(drive->name, cmd); | 99 | ide_tf_dump(drive->name, cmd); |
100 | tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); | 100 | tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); |
101 | SELECT_MASK(drive, 0); | ||
102 | 101 | ||
103 | if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) { | 102 | if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) { |
104 | u8 data[2] = { cmd->tf.data, cmd->hob.data }; | 103 | u8 data[2] = { cmd->tf.data, cmd->hob.data }; |
@@ -166,7 +165,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive) | |||
166 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { | 165 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { |
167 | if (custom && tf->command == ATA_CMD_SET_MULTI) { | 166 | if (custom && tf->command == ATA_CMD_SET_MULTI) { |
168 | drive->mult_req = drive->mult_count = 0; | 167 | drive->mult_req = drive->mult_count = 0; |
169 | drive->special.b.recalibrate = 1; | 168 | drive->special_flags |= IDE_SFLAG_RECALIBRATE; |
170 | (void)ide_dump_status(drive, __func__, stat); | 169 | (void)ide_dump_status(drive, __func__, stat); |
171 | return ide_stopped; | 170 | return ide_stopped; |
172 | } else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) { | 171 | } else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) { |
@@ -385,7 +384,7 @@ out_end: | |||
385 | if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) | 384 | if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) |
386 | ide_finish_cmd(drive, cmd, stat); | 385 | ide_finish_cmd(drive, cmd, stat); |
387 | else | 386 | else |
388 | ide_complete_rq(drive, 0, cmd->rq->nr_sectors << 9); | 387 | ide_complete_rq(drive, 0, blk_rq_sectors(cmd->rq) << 9); |
389 | return ide_stopped; | 388 | return ide_stopped; |
390 | out_err: | 389 | out_err: |
391 | ide_error_cmd(drive, cmd); | 390 | ide_error_cmd(drive, cmd); |
@@ -424,7 +423,9 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, | |||
424 | 423 | ||
425 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 424 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
426 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; | 425 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
427 | rq->buffer = buf; | 426 | |
427 | if (cmd->tf_flags & IDE_TFLAG_WRITE) | ||
428 | rq->cmd_flags |= REQ_RW; | ||
428 | 429 | ||
429 | /* | 430 | /* |
430 | * (ks) We transfer currently only whole sectors. | 431 | * (ks) We transfer currently only whole sectors. |
@@ -432,18 +433,20 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, | |||
432 | * if we would find a solution to transfer any size. | 433 | * if we would find a solution to transfer any size. |
433 | * To support special commands like READ LONG. | 434 | * To support special commands like READ LONG. |
434 | */ | 435 | */ |
435 | rq->hard_nr_sectors = rq->nr_sectors = nsect; | 436 | if (nsect) { |
436 | rq->hard_cur_sectors = rq->current_nr_sectors = nsect; | 437 | error = blk_rq_map_kern(drive->queue, rq, buf, |
437 | 438 | nsect * SECTOR_SIZE, __GFP_WAIT); | |
438 | if (cmd->tf_flags & IDE_TFLAG_WRITE) | 439 | if (error) |
439 | rq->cmd_flags |= REQ_RW; | 440 | goto put_req; |
441 | } | ||
440 | 442 | ||
441 | rq->special = cmd; | 443 | rq->special = cmd; |
442 | cmd->rq = rq; | 444 | cmd->rq = rq; |
443 | 445 | ||
444 | error = blk_execute_rq(drive->queue, NULL, rq, 0); | 446 | error = blk_execute_rq(drive->queue, NULL, rq, 0); |
445 | blk_put_request(rq); | ||
446 | 447 | ||
448 | put_req: | ||
449 | blk_put_request(rq); | ||
447 | return error; | 450 | return error; |
448 | } | 451 | } |
449 | 452 | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 92c9b90931e7..16d056939f9f 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -211,6 +211,11 @@ static unsigned int ide_noflush; | |||
211 | module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); | 211 | module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); |
212 | MODULE_PARM_DESC(noflush, "disable flush requests for a device"); | 212 | MODULE_PARM_DESC(noflush, "disable flush requests for a device"); |
213 | 213 | ||
214 | static unsigned int ide_nohpa; | ||
215 | |||
216 | module_param_call(nohpa, ide_set_dev_param_mask, NULL, &ide_nohpa, 0); | ||
217 | MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device"); | ||
218 | |||
214 | static unsigned int ide_noprobe; | 219 | static unsigned int ide_noprobe; |
215 | 220 | ||
216 | module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); | 221 | module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); |
@@ -281,6 +286,11 @@ static void ide_dev_apply_params(ide_drive_t *drive, u8 unit) | |||
281 | drive->name); | 286 | drive->name); |
282 | drive->dev_flags |= IDE_DFLAG_NOFLUSH; | 287 | drive->dev_flags |= IDE_DFLAG_NOFLUSH; |
283 | } | 288 | } |
289 | if (ide_nohpa & (1 << i)) { | ||
290 | printk(KERN_INFO "ide: disabling Host Protected Area for %s\n", | ||
291 | drive->name); | ||
292 | drive->dev_flags |= IDE_DFLAG_NOHPA; | ||
293 | } | ||
284 | if (ide_noprobe & (1 << i)) { | 294 | if (ide_noprobe & (1 << i)) { |
285 | printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); | 295 | printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); |
286 | drive->dev_flags |= IDE_DFLAG_NOPROBE; | 296 | drive->dev_flags |= IDE_DFLAG_NOPROBE; |
diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c index 051b4ab0f359..ee9b55ecc62b 100644 --- a/drivers/ide/ide_platform.c +++ b/drivers/ide/ide_platform.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | 23 | ||
24 | static void __devinit plat_ide_setup_ports(hw_regs_t *hw, | 24 | static void __devinit plat_ide_setup_ports(struct ide_hw *hw, |
25 | void __iomem *base, | 25 | void __iomem *base, |
26 | void __iomem *ctrl, | 26 | void __iomem *ctrl, |
27 | struct pata_platform_info *pdata, | 27 | struct pata_platform_info *pdata, |
@@ -40,12 +40,11 @@ static void __devinit plat_ide_setup_ports(hw_regs_t *hw, | |||
40 | hw->io_ports.ctl_addr = (unsigned long)ctrl; | 40 | hw->io_ports.ctl_addr = (unsigned long)ctrl; |
41 | 41 | ||
42 | hw->irq = irq; | 42 | hw->irq = irq; |
43 | |||
44 | hw->chipset = ide_generic; | ||
45 | } | 43 | } |
46 | 44 | ||
47 | static const struct ide_port_info platform_ide_port_info = { | 45 | static const struct ide_port_info platform_ide_port_info = { |
48 | .host_flags = IDE_HFLAG_NO_DMA, | 46 | .host_flags = IDE_HFLAG_NO_DMA, |
47 | .chipset = ide_generic, | ||
49 | }; | 48 | }; |
50 | 49 | ||
51 | static int __devinit plat_ide_probe(struct platform_device *pdev) | 50 | static int __devinit plat_ide_probe(struct platform_device *pdev) |
@@ -55,7 +54,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
55 | struct pata_platform_info *pdata; | 54 | struct pata_platform_info *pdata; |
56 | struct ide_host *host; | 55 | struct ide_host *host; |
57 | int ret = 0, mmio = 0; | 56 | int ret = 0, mmio = 0; |
58 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 57 | struct ide_hw hw, *hws[] = { &hw }; |
59 | struct ide_port_info d = platform_ide_port_info; | 58 | struct ide_port_info d = platform_ide_port_info; |
60 | 59 | ||
61 | pdata = pdev->dev.platform_data; | 60 | pdata = pdev->dev.platform_data; |
@@ -99,7 +98,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
99 | if (mmio) | 98 | if (mmio) |
100 | d.host_flags |= IDE_HFLAG_MMIO; | 99 | d.host_flags |= IDE_HFLAG_MMIO; |
101 | 100 | ||
102 | ret = ide_host_add(&d, hws, &host); | 101 | ret = ide_host_add(&d, hws, 1, &host); |
103 | if (ret) | 102 | if (ret) |
104 | goto out; | 103 | goto out; |
105 | 104 | ||
diff --git a/drivers/ide/macide.c b/drivers/ide/macide.c index 4b1718e83283..1447c8c90565 100644 --- a/drivers/ide/macide.c +++ b/drivers/ide/macide.c | |||
@@ -62,7 +62,7 @@ int macide_ack_intr(ide_hwif_t* hwif) | |||
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base, | 65 | static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base, |
66 | int irq, ide_ack_intr_t *ack_intr) | 66 | int irq, ide_ack_intr_t *ack_intr) |
67 | { | 67 | { |
68 | int i; | 68 | int i; |
@@ -76,13 +76,12 @@ static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base, | |||
76 | 76 | ||
77 | hw->irq = irq; | 77 | hw->irq = irq; |
78 | hw->ack_intr = ack_intr; | 78 | hw->ack_intr = ack_intr; |
79 | |||
80 | hw->chipset = ide_generic; | ||
81 | } | 79 | } |
82 | 80 | ||
83 | static const struct ide_port_info macide_port_info = { | 81 | static const struct ide_port_info macide_port_info = { |
84 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, | 82 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, |
85 | .irq_flags = IRQF_SHARED, | 83 | .irq_flags = IRQF_SHARED, |
84 | .chipset = ide_generic, | ||
86 | }; | 85 | }; |
87 | 86 | ||
88 | static const char *mac_ide_name[] = | 87 | static const char *mac_ide_name[] = |
@@ -97,7 +96,7 @@ static int __init macide_init(void) | |||
97 | ide_ack_intr_t *ack_intr; | 96 | ide_ack_intr_t *ack_intr; |
98 | unsigned long base; | 97 | unsigned long base; |
99 | int irq; | 98 | int irq; |
100 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 99 | struct ide_hw hw, *hws[] = { &hw }; |
101 | 100 | ||
102 | if (!MACH_IS_MAC) | 101 | if (!MACH_IS_MAC) |
103 | return -ENODEV; | 102 | return -ENODEV; |
@@ -127,7 +126,7 @@ static int __init macide_init(void) | |||
127 | 126 | ||
128 | macide_setup_ports(&hw, base, irq, ack_intr); | 127 | macide_setup_ports(&hw, base, irq, ack_intr); |
129 | 128 | ||
130 | return ide_host_add(&macide_port_info, hws, NULL); | 129 | return ide_host_add(&macide_port_info, hws, 1, NULL); |
131 | } | 130 | } |
132 | 131 | ||
133 | module_init(macide_init); | 132 | module_init(macide_init); |
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c index 09d813d313f4..3c1dc0152153 100644 --- a/drivers/ide/palm_bk3710.c +++ b/drivers/ide/palm_bk3710.c | |||
@@ -306,6 +306,7 @@ static struct ide_port_info __devinitdata palm_bk3710_port_info = { | |||
306 | .host_flags = IDE_HFLAG_MMIO, | 306 | .host_flags = IDE_HFLAG_MMIO, |
307 | .pio_mask = ATA_PIO4, | 307 | .pio_mask = ATA_PIO4, |
308 | .mwdma_mask = ATA_MWDMA2, | 308 | .mwdma_mask = ATA_MWDMA2, |
309 | .chipset = ide_palm3710, | ||
309 | }; | 310 | }; |
310 | 311 | ||
311 | static int __init palm_bk3710_probe(struct platform_device *pdev) | 312 | static int __init palm_bk3710_probe(struct platform_device *pdev) |
@@ -315,7 +316,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) | |||
315 | void __iomem *base; | 316 | void __iomem *base; |
316 | unsigned long rate, mem_size; | 317 | unsigned long rate, mem_size; |
317 | int i, rc; | 318 | int i, rc; |
318 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 319 | struct ide_hw hw, *hws[] = { &hw }; |
319 | 320 | ||
320 | clk = clk_get(&pdev->dev, "IDECLK"); | 321 | clk = clk_get(&pdev->dev, "IDECLK"); |
321 | if (IS_ERR(clk)) | 322 | if (IS_ERR(clk)) |
@@ -363,13 +364,12 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) | |||
363 | (base + IDE_PALM_ATA_PRI_CTL_OFFSET); | 364 | (base + IDE_PALM_ATA_PRI_CTL_OFFSET); |
364 | hw.irq = irq->start; | 365 | hw.irq = irq->start; |
365 | hw.dev = &pdev->dev; | 366 | hw.dev = &pdev->dev; |
366 | hw.chipset = ide_palm3710; | ||
367 | 367 | ||
368 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : | 368 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : |
369 | ATA_UDMA5; | 369 | ATA_UDMA5; |
370 | 370 | ||
371 | /* Register the IDE interface with Linux */ | 371 | /* Register the IDE interface with Linux */ |
372 | rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); | 372 | rc = ide_host_add(&palm_bk3710_port_info, hws, 1, NULL); |
373 | if (rc) | 373 | if (rc) |
374 | goto out; | 374 | goto out; |
375 | 375 | ||
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c index b68906c3c17e..65ba8239e7b5 100644 --- a/drivers/ide/pdc202xx_new.c +++ b/drivers/ide/pdc202xx_new.c | |||
@@ -40,18 +40,6 @@ | |||
40 | #define DBG(fmt, args...) | 40 | #define DBG(fmt, args...) |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | static const char *pdc_quirk_drives[] = { | ||
44 | "QUANTUM FIREBALLlct08 08", | ||
45 | "QUANTUM FIREBALLP KA6.4", | ||
46 | "QUANTUM FIREBALLP KA9.1", | ||
47 | "QUANTUM FIREBALLP LM20.4", | ||
48 | "QUANTUM FIREBALLP KX13.6", | ||
49 | "QUANTUM FIREBALLP KX20.5", | ||
50 | "QUANTUM FIREBALLP KX27.3", | ||
51 | "QUANTUM FIREBALLP LM20.5", | ||
52 | NULL | ||
53 | }; | ||
54 | |||
55 | static u8 max_dma_rate(struct pci_dev *pdev) | 43 | static u8 max_dma_rate(struct pci_dev *pdev) |
56 | { | 44 | { |
57 | u8 mode; | 45 | u8 mode; |
@@ -200,19 +188,6 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif) | |||
200 | return ATA_CBL_PATA80; | 188 | return ATA_CBL_PATA80; |
201 | } | 189 | } |
202 | 190 | ||
203 | static void pdcnew_quirkproc(ide_drive_t *drive) | ||
204 | { | ||
205 | const char **list, *m = (char *)&drive->id[ATA_ID_PROD]; | ||
206 | |||
207 | for (list = pdc_quirk_drives; *list != NULL; list++) | ||
208 | if (strstr(m, *list) != NULL) { | ||
209 | drive->quirk_list = 2; | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | drive->quirk_list = 0; | ||
214 | } | ||
215 | |||
216 | static void pdcnew_reset(ide_drive_t *drive) | 191 | static void pdcnew_reset(ide_drive_t *drive) |
217 | { | 192 | { |
218 | /* | 193 | /* |
@@ -473,7 +448,6 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | |||
473 | static const struct ide_port_ops pdcnew_port_ops = { | 448 | static const struct ide_port_ops pdcnew_port_ops = { |
474 | .set_pio_mode = pdcnew_set_pio_mode, | 449 | .set_pio_mode = pdcnew_set_pio_mode, |
475 | .set_dma_mode = pdcnew_set_dma_mode, | 450 | .set_dma_mode = pdcnew_set_dma_mode, |
476 | .quirkproc = pdcnew_quirkproc, | ||
477 | .resetproc = pdcnew_reset, | 451 | .resetproc = pdcnew_reset, |
478 | .cable_detect = pdcnew_cable_detect, | 452 | .cable_detect = pdcnew_cable_detect, |
479 | }; | 453 | }; |
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c index 248a54bd2386..b6abf7e52cac 100644 --- a/drivers/ide/pdc202xx_old.c +++ b/drivers/ide/pdc202xx_old.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> |
3 | * Copyright (C) 2006-2007 MontaVista Software, Inc. | 3 | * Copyright (C) 2006-2007, 2009 MontaVista Software, Inc. |
4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
5 | * | 5 | * |
6 | * Portions Copyright (C) 1999 Promise Technology, Inc. | 6 | * Portions Copyright (C) 1999 Promise Technology, Inc. |
@@ -23,18 +23,6 @@ | |||
23 | 23 | ||
24 | #define PDC202XX_DEBUG_DRIVE_INFO 0 | 24 | #define PDC202XX_DEBUG_DRIVE_INFO 0 |
25 | 25 | ||
26 | static const char *pdc_quirk_drives[] = { | ||
27 | "QUANTUM FIREBALLlct08 08", | ||
28 | "QUANTUM FIREBALLP KA6.4", | ||
29 | "QUANTUM FIREBALLP KA9.1", | ||
30 | "QUANTUM FIREBALLP LM20.4", | ||
31 | "QUANTUM FIREBALLP KX13.6", | ||
32 | "QUANTUM FIREBALLP KX20.5", | ||
33 | "QUANTUM FIREBALLP KX27.3", | ||
34 | "QUANTUM FIREBALLP LM20.5", | ||
35 | NULL | ||
36 | }; | ||
37 | |||
38 | static void pdc_old_disable_66MHz_clock(ide_hwif_t *); | 26 | static void pdc_old_disable_66MHz_clock(ide_hwif_t *); |
39 | 27 | ||
40 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) | 28 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) |
@@ -151,19 +139,6 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif) | |||
151 | outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); | 139 | outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); |
152 | } | 140 | } |
153 | 141 | ||
154 | static void pdc202xx_quirkproc(ide_drive_t *drive) | ||
155 | { | ||
156 | const char **list, *m = (char *)&drive->id[ATA_ID_PROD]; | ||
157 | |||
158 | for (list = pdc_quirk_drives; *list != NULL; list++) | ||
159 | if (strstr(m, *list) != NULL) { | ||
160 | drive->quirk_list = 2; | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | drive->quirk_list = 0; | ||
165 | } | ||
166 | |||
167 | static void pdc202xx_dma_start(ide_drive_t *drive) | 142 | static void pdc202xx_dma_start(ide_drive_t *drive) |
168 | { | 143 | { |
169 | if (drive->current_speed > XFER_UDMA_2) | 144 | if (drive->current_speed > XFER_UDMA_2) |
@@ -177,7 +152,7 @@ static void pdc202xx_dma_start(ide_drive_t *drive) | |||
177 | u8 clock = inb(high_16 + 0x11); | 152 | u8 clock = inb(high_16 + 0x11); |
178 | 153 | ||
179 | outb(clock | (hwif->channel ? 0x08 : 0x02), high_16 + 0x11); | 154 | outb(clock | (hwif->channel ? 0x08 : 0x02), high_16 + 0x11); |
180 | word_count = (rq->nr_sectors << 8); | 155 | word_count = (blk_rq_sectors(rq) << 8); |
181 | word_count = (rq_data_dir(rq) == READ) ? | 156 | word_count = (rq_data_dir(rq) == READ) ? |
182 | word_count | 0x05000000 : | 157 | word_count | 0x05000000 : |
183 | word_count | 0x06000000; | 158 | word_count | 0x06000000; |
@@ -203,61 +178,6 @@ static int pdc202xx_dma_end(ide_drive_t *drive) | |||
203 | return ide_dma_end(drive); | 178 | return ide_dma_end(drive); |
204 | } | 179 | } |
205 | 180 | ||
206 | static int pdc202xx_dma_test_irq(ide_drive_t *drive) | ||
207 | { | ||
208 | ide_hwif_t *hwif = drive->hwif; | ||
209 | unsigned long high_16 = hwif->extra_base - 16; | ||
210 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); | ||
211 | u8 sc1d = inb(high_16 + 0x001d); | ||
212 | |||
213 | if (hwif->channel) { | ||
214 | /* bit7: Error, bit6: Interrupting, bit5: FIFO Full, bit4: FIFO Empty */ | ||
215 | if ((sc1d & 0x50) == 0x50) | ||
216 | goto somebody_else; | ||
217 | else if ((sc1d & 0x40) == 0x40) | ||
218 | return (dma_stat & 4) == 4; | ||
219 | } else { | ||
220 | /* bit3: Error, bit2: Interrupting, bit1: FIFO Full, bit0: FIFO Empty */ | ||
221 | if ((sc1d & 0x05) == 0x05) | ||
222 | goto somebody_else; | ||
223 | else if ((sc1d & 0x04) == 0x04) | ||
224 | return (dma_stat & 4) == 4; | ||
225 | } | ||
226 | somebody_else: | ||
227 | return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ | ||
228 | } | ||
229 | |||
230 | static void pdc202xx_reset_host (ide_hwif_t *hwif) | ||
231 | { | ||
232 | unsigned long high_16 = hwif->extra_base - 16; | ||
233 | u8 udma_speed_flag = inb(high_16 | 0x001f); | ||
234 | |||
235 | outb(udma_speed_flag | 0x10, high_16 | 0x001f); | ||
236 | mdelay(100); | ||
237 | outb(udma_speed_flag & ~0x10, high_16 | 0x001f); | ||
238 | mdelay(2000); /* 2 seconds ?! */ | ||
239 | |||
240 | printk(KERN_WARNING "PDC202XX: %s channel reset.\n", | ||
241 | hwif->channel ? "Secondary" : "Primary"); | ||
242 | } | ||
243 | |||
244 | static void pdc202xx_reset (ide_drive_t *drive) | ||
245 | { | ||
246 | ide_hwif_t *hwif = drive->hwif; | ||
247 | ide_hwif_t *mate = hwif->mate; | ||
248 | |||
249 | pdc202xx_reset_host(hwif); | ||
250 | pdc202xx_reset_host(mate); | ||
251 | |||
252 | ide_set_max_pio(drive); | ||
253 | } | ||
254 | |||
255 | static void pdc202xx_dma_lost_irq(ide_drive_t *drive) | ||
256 | { | ||
257 | pdc202xx_reset(drive); | ||
258 | ide_dma_lost_irq(drive); | ||
259 | } | ||
260 | |||
261 | static int init_chipset_pdc202xx(struct pci_dev *dev) | 181 | static int init_chipset_pdc202xx(struct pci_dev *dev) |
262 | { | 182 | { |
263 | unsigned long dmabase = pci_resource_start(dev, 4); | 183 | unsigned long dmabase = pci_resource_start(dev, 4); |
@@ -311,38 +231,22 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
311 | static const struct ide_port_ops pdc20246_port_ops = { | 231 | static const struct ide_port_ops pdc20246_port_ops = { |
312 | .set_pio_mode = pdc202xx_set_pio_mode, | 232 | .set_pio_mode = pdc202xx_set_pio_mode, |
313 | .set_dma_mode = pdc202xx_set_mode, | 233 | .set_dma_mode = pdc202xx_set_mode, |
314 | .quirkproc = pdc202xx_quirkproc, | ||
315 | }; | 234 | }; |
316 | 235 | ||
317 | static const struct ide_port_ops pdc2026x_port_ops = { | 236 | static const struct ide_port_ops pdc2026x_port_ops = { |
318 | .set_pio_mode = pdc202xx_set_pio_mode, | 237 | .set_pio_mode = pdc202xx_set_pio_mode, |
319 | .set_dma_mode = pdc202xx_set_mode, | 238 | .set_dma_mode = pdc202xx_set_mode, |
320 | .quirkproc = pdc202xx_quirkproc, | ||
321 | .resetproc = pdc202xx_reset, | ||
322 | .cable_detect = pdc2026x_cable_detect, | 239 | .cable_detect = pdc2026x_cable_detect, |
323 | }; | 240 | }; |
324 | 241 | ||
325 | static const struct ide_dma_ops pdc20246_dma_ops = { | ||
326 | .dma_host_set = ide_dma_host_set, | ||
327 | .dma_setup = ide_dma_setup, | ||
328 | .dma_start = ide_dma_start, | ||
329 | .dma_end = ide_dma_end, | ||
330 | .dma_test_irq = pdc202xx_dma_test_irq, | ||
331 | .dma_lost_irq = pdc202xx_dma_lost_irq, | ||
332 | .dma_timer_expiry = ide_dma_sff_timer_expiry, | ||
333 | .dma_clear = pdc202xx_reset, | ||
334 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
335 | }; | ||
336 | |||
337 | static const struct ide_dma_ops pdc2026x_dma_ops = { | 242 | static const struct ide_dma_ops pdc2026x_dma_ops = { |
338 | .dma_host_set = ide_dma_host_set, | 243 | .dma_host_set = ide_dma_host_set, |
339 | .dma_setup = ide_dma_setup, | 244 | .dma_setup = ide_dma_setup, |
340 | .dma_start = pdc202xx_dma_start, | 245 | .dma_start = pdc202xx_dma_start, |
341 | .dma_end = pdc202xx_dma_end, | 246 | .dma_end = pdc202xx_dma_end, |
342 | .dma_test_irq = pdc202xx_dma_test_irq, | 247 | .dma_test_irq = ide_dma_test_irq, |
343 | .dma_lost_irq = pdc202xx_dma_lost_irq, | 248 | .dma_lost_irq = ide_dma_lost_irq, |
344 | .dma_timer_expiry = ide_dma_sff_timer_expiry, | 249 | .dma_timer_expiry = ide_dma_sff_timer_expiry, |
345 | .dma_clear = pdc202xx_reset, | ||
346 | .dma_sff_read_status = ide_dma_sff_read_status, | 250 | .dma_sff_read_status = ide_dma_sff_read_status, |
347 | }; | 251 | }; |
348 | 252 | ||
@@ -364,7 +268,7 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { | |||
364 | .name = DRV_NAME, | 268 | .name = DRV_NAME, |
365 | .init_chipset = init_chipset_pdc202xx, | 269 | .init_chipset = init_chipset_pdc202xx, |
366 | .port_ops = &pdc20246_port_ops, | 270 | .port_ops = &pdc20246_port_ops, |
367 | .dma_ops = &pdc20246_dma_ops, | 271 | .dma_ops = &sff_dma_ops, |
368 | .host_flags = IDE_HFLAGS_PDC202XX, | 272 | .host_flags = IDE_HFLAGS_PDC202XX, |
369 | .pio_mask = ATA_PIO4, | 273 | .pio_mask = ATA_PIO4, |
370 | .mwdma_mask = ATA_MWDMA2, | 274 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c index f76e4e6b408f..97642a7a79c4 100644 --- a/drivers/ide/pmac.c +++ b/drivers/ide/pmac.c | |||
@@ -1023,13 +1023,14 @@ static const struct ide_port_info pmac_port_info = { | |||
1023 | * Setup, register & probe an IDE channel driven by this driver, this is | 1023 | * Setup, register & probe an IDE channel driven by this driver, this is |
1024 | * called by one of the 2 probe functions (macio or PCI). | 1024 | * called by one of the 2 probe functions (macio or PCI). |
1025 | */ | 1025 | */ |
1026 | static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) | 1026 | static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, |
1027 | struct ide_hw *hw) | ||
1027 | { | 1028 | { |
1028 | struct device_node *np = pmif->node; | 1029 | struct device_node *np = pmif->node; |
1029 | const int *bidp; | 1030 | const int *bidp; |
1030 | struct ide_host *host; | 1031 | struct ide_host *host; |
1031 | ide_hwif_t *hwif; | 1032 | ide_hwif_t *hwif; |
1032 | hw_regs_t *hws[] = { hw, NULL, NULL, NULL }; | 1033 | struct ide_hw *hws[] = { hw }; |
1033 | struct ide_port_info d = pmac_port_info; | 1034 | struct ide_port_info d = pmac_port_info; |
1034 | int rc; | 1035 | int rc; |
1035 | 1036 | ||
@@ -1077,7 +1078,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) | |||
1077 | /* Make sure we have sane timings */ | 1078 | /* Make sure we have sane timings */ |
1078 | sanitize_timings(pmif); | 1079 | sanitize_timings(pmif); |
1079 | 1080 | ||
1080 | host = ide_host_alloc(&d, hws); | 1081 | host = ide_host_alloc(&d, hws, 1); |
1081 | if (host == NULL) | 1082 | if (host == NULL) |
1082 | return -ENOMEM; | 1083 | return -ENOMEM; |
1083 | hwif = host->ports[0]; | 1084 | hwif = host->ports[0]; |
@@ -1124,7 +1125,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) | |||
1124 | return 0; | 1125 | return 0; |
1125 | } | 1126 | } |
1126 | 1127 | ||
1127 | static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base) | 1128 | static void __devinit pmac_ide_init_ports(struct ide_hw *hw, unsigned long base) |
1128 | { | 1129 | { |
1129 | int i; | 1130 | int i; |
1130 | 1131 | ||
@@ -1144,7 +1145,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1144 | unsigned long regbase; | 1145 | unsigned long regbase; |
1145 | pmac_ide_hwif_t *pmif; | 1146 | pmac_ide_hwif_t *pmif; |
1146 | int irq, rc; | 1147 | int irq, rc; |
1147 | hw_regs_t hw; | 1148 | struct ide_hw hw; |
1148 | 1149 | ||
1149 | pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); | 1150 | pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); |
1150 | if (pmif == NULL) | 1151 | if (pmif == NULL) |
@@ -1268,7 +1269,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1268 | void __iomem *base; | 1269 | void __iomem *base; |
1269 | unsigned long rbase, rlen; | 1270 | unsigned long rbase, rlen; |
1270 | int rc; | 1271 | int rc; |
1271 | hw_regs_t hw; | 1272 | struct ide_hw hw; |
1272 | 1273 | ||
1273 | np = pci_device_to_OF_node(pdev); | 1274 | np = pci_device_to_OF_node(pdev); |
1274 | if (np == NULL) { | 1275 | if (np == NULL) { |
diff --git a/drivers/ide/q40ide.c b/drivers/ide/q40ide.c index c79346679244..ab49a97023d9 100644 --- a/drivers/ide/q40ide.c +++ b/drivers/ide/q40ide.c | |||
@@ -51,11 +51,11 @@ static int q40ide_default_irq(unsigned long base) | |||
51 | /* | 51 | /* |
52 | * Addresses are pretranslated for Q40 ISA access. | 52 | * Addresses are pretranslated for Q40 ISA access. |
53 | */ | 53 | */ |
54 | static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base, | 54 | static void q40_ide_setup_ports(struct ide_hw *hw, unsigned long base, |
55 | ide_ack_intr_t *ack_intr, | 55 | ide_ack_intr_t *ack_intr, |
56 | int irq) | 56 | int irq) |
57 | { | 57 | { |
58 | memset(hw, 0, sizeof(hw_regs_t)); | 58 | memset(hw, 0, sizeof(*hw)); |
59 | /* BIG FAT WARNING: | 59 | /* BIG FAT WARNING: |
60 | assumption: only DATA port is ever used in 16 bit mode */ | 60 | assumption: only DATA port is ever used in 16 bit mode */ |
61 | hw->io_ports.data_addr = Q40_ISA_IO_W(base); | 61 | hw->io_ports.data_addr = Q40_ISA_IO_W(base); |
@@ -70,8 +70,6 @@ static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base, | |||
70 | 70 | ||
71 | hw->irq = irq; | 71 | hw->irq = irq; |
72 | hw->ack_intr = ack_intr; | 72 | hw->ack_intr = ack_intr; |
73 | |||
74 | hw->chipset = ide_generic; | ||
75 | } | 73 | } |
76 | 74 | ||
77 | static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, | 75 | static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, |
@@ -119,6 +117,7 @@ static const struct ide_port_info q40ide_port_info = { | |||
119 | .tp_ops = &q40ide_tp_ops, | 117 | .tp_ops = &q40ide_tp_ops, |
120 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, | 118 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, |
121 | .irq_flags = IRQF_SHARED, | 119 | .irq_flags = IRQF_SHARED, |
120 | .chipset = ide_generic, | ||
122 | }; | 121 | }; |
123 | 122 | ||
124 | /* | 123 | /* |
@@ -136,7 +135,7 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={ | |||
136 | static int __init q40ide_init(void) | 135 | static int __init q40ide_init(void) |
137 | { | 136 | { |
138 | int i; | 137 | int i; |
139 | hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; | 138 | struct ide_hw hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL }; |
140 | 139 | ||
141 | if (!MACH_IS_Q40) | 140 | if (!MACH_IS_Q40) |
142 | return -ENODEV; | 141 | return -ENODEV; |
@@ -163,7 +162,7 @@ static int __init q40ide_init(void) | |||
163 | hws[i] = &hw[i]; | 162 | hws[i] = &hw[i]; |
164 | } | 163 | } |
165 | 164 | ||
166 | return ide_host_add(&q40ide_port_info, hws, NULL); | 165 | return ide_host_add(&q40ide_port_info, hws, Q40IDE_NUM_HWIFS, NULL); |
167 | } | 166 | } |
168 | 167 | ||
169 | module_init(q40ide_init); | 168 | module_init(q40ide_init); |
diff --git a/drivers/ide/rapide.c b/drivers/ide/rapide.c index d5003ca69801..00f54248f41f 100644 --- a/drivers/ide/rapide.c +++ b/drivers/ide/rapide.c | |||
@@ -13,9 +13,10 @@ | |||
13 | 13 | ||
14 | static const struct ide_port_info rapide_port_info = { | 14 | static const struct ide_port_info rapide_port_info = { |
15 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, | 15 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, |
16 | .chipset = ide_generic, | ||
16 | }; | 17 | }; |
17 | 18 | ||
18 | static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, | 19 | static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base, |
19 | void __iomem *ctrl, unsigned int sz, int irq) | 20 | void __iomem *ctrl, unsigned int sz, int irq) |
20 | { | 21 | { |
21 | unsigned long port = (unsigned long)base; | 22 | unsigned long port = (unsigned long)base; |
@@ -35,7 +36,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
35 | void __iomem *base; | 36 | void __iomem *base; |
36 | struct ide_host *host; | 37 | struct ide_host *host; |
37 | int ret; | 38 | int ret; |
38 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 39 | struct ide_hw hw, *hws[] = { &hw }; |
39 | 40 | ||
40 | ret = ecard_request_resources(ec); | 41 | ret = ecard_request_resources(ec); |
41 | if (ret) | 42 | if (ret) |
@@ -49,10 +50,9 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
49 | 50 | ||
50 | memset(&hw, 0, sizeof(hw)); | 51 | memset(&hw, 0, sizeof(hw)); |
51 | rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); | 52 | rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); |
52 | hw.chipset = ide_generic; | ||
53 | hw.dev = &ec->dev; | 53 | hw.dev = &ec->dev; |
54 | 54 | ||
55 | ret = ide_host_add(&rapide_port_info, hws, &host); | 55 | ret = ide_host_add(&rapide_port_info, hws, 1, &host); |
56 | if (ret) | 56 | if (ret) |
57 | goto release; | 57 | goto release; |
58 | 58 | ||
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 5be41f25204f..1104bb301eb9 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c | |||
@@ -559,7 +559,7 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
559 | { | 559 | { |
560 | struct scc_ports *ports = pci_get_drvdata(dev); | 560 | struct scc_ports *ports = pci_get_drvdata(dev); |
561 | struct ide_host *host; | 561 | struct ide_host *host; |
562 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 562 | struct ide_hw hw, *hws[] = { &hw }; |
563 | int i, rc; | 563 | int i, rc; |
564 | 564 | ||
565 | memset(&hw, 0, sizeof(hw)); | 565 | memset(&hw, 0, sizeof(hw)); |
@@ -567,9 +567,8 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
567 | hw.io_ports_array[i] = ports->dma + 0x20 + i * 4; | 567 | hw.io_ports_array[i] = ports->dma + 0x20 + i * 4; |
568 | hw.irq = dev->irq; | 568 | hw.irq = dev->irq; |
569 | hw.dev = &dev->dev; | 569 | hw.dev = &dev->dev; |
570 | hw.chipset = ide_pci; | ||
571 | 570 | ||
572 | rc = ide_host_add(d, hws, &host); | 571 | rc = ide_host_add(d, hws, 1, &host); |
573 | if (rc) | 572 | if (rc) |
574 | return rc; | 573 | return rc; |
575 | 574 | ||
@@ -823,6 +822,7 @@ static const struct ide_port_info scc_chipset __devinitdata = { | |||
823 | .host_flags = IDE_HFLAG_SINGLE, | 822 | .host_flags = IDE_HFLAG_SINGLE, |
824 | .irq_flags = IRQF_SHARED, | 823 | .irq_flags = IRQF_SHARED, |
825 | .pio_mask = ATA_PIO4, | 824 | .pio_mask = ATA_PIO4, |
825 | .chipset = ide_pci, | ||
826 | }; | 826 | }; |
827 | 827 | ||
828 | /** | 828 | /** |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 7a3a12d6e638..ab3db61d2ba0 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
3 | * Copyright (C) 1995-1998 Mark Lord | 3 | * Copyright (C) 1995-1998 Mark Lord |
4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2007-2009 Bartlomiej Zolnierkiewicz |
5 | * | 5 | * |
6 | * May be copied or modified under the terms of the GNU General Public License | 6 | * May be copied or modified under the terms of the GNU General Public License |
7 | */ | 7 | */ |
@@ -301,11 +301,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
301 | } | 301 | } |
302 | 302 | ||
303 | /** | 303 | /** |
304 | * ide_hw_configure - configure a hw_regs_t instance | 304 | * ide_hw_configure - configure a struct ide_hw instance |
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 | * @hw: hw_regs_t instance corresponding to this port | 308 | * @hw: struct ide_hw instance corresponding to this port |
309 | * | 309 | * |
310 | * Perform the initial set up for the hardware interface structure. This | 310 | * Perform the initial set up for the hardware interface structure. This |
311 | * is done per interface port rather than per PCI device. There may be | 311 | * is done per interface port rather than per PCI device. There may be |
@@ -315,7 +315,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
315 | */ | 315 | */ |
316 | 316 | ||
317 | 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, |
318 | unsigned int port, hw_regs_t *hw) | 318 | unsigned int port, struct ide_hw *hw) |
319 | { | 319 | { |
320 | unsigned long ctl = 0, base = 0; | 320 | unsigned long ctl = 0, base = 0; |
321 | 321 | ||
@@ -344,7 +344,6 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, | |||
344 | 344 | ||
345 | memset(hw, 0, sizeof(*hw)); | 345 | memset(hw, 0, sizeof(*hw)); |
346 | hw->dev = &dev->dev; | 346 | hw->dev = &dev->dev; |
347 | hw->chipset = d->chipset ? d->chipset : ide_pci; | ||
348 | ide_std_init_ports(hw, base, ctl | 2); | 347 | ide_std_init_ports(hw, base, ctl | 2); |
349 | 348 | ||
350 | return 0; | 349 | return 0; |
@@ -446,8 +445,8 @@ out: | |||
446 | * ide_pci_setup_ports - configure ports/devices on PCI IDE | 445 | * ide_pci_setup_ports - configure ports/devices on PCI IDE |
447 | * @dev: PCI device | 446 | * @dev: PCI device |
448 | * @d: IDE port info | 447 | * @d: IDE port info |
449 | * @hw: hw_regs_t instances corresponding to this PCI IDE device | 448 | * @hw: struct ide_hw instances corresponding to this PCI IDE device |
450 | * @hws: hw_regs_t pointers table to update | 449 | * @hws: struct ide_hw pointers table to update |
451 | * | 450 | * |
452 | * Scan the interfaces attached to this device and do any | 451 | * Scan the interfaces attached to this device and do any |
453 | * necessary per port setup. Attach the devices and ask the | 452 | * necessary per port setup. Attach the devices and ask the |
@@ -459,7 +458,7 @@ out: | |||
459 | */ | 458 | */ |
460 | 459 | ||
461 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | 460 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, |
462 | hw_regs_t *hw, hw_regs_t **hws) | 461 | struct ide_hw *hw, struct ide_hw **hws) |
463 | { | 462 | { |
464 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 463 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
465 | u8 tmp; | 464 | u8 tmp; |
@@ -535,61 +534,15 @@ out: | |||
535 | return ret; | 534 | return ret; |
536 | } | 535 | } |
537 | 536 | ||
538 | int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | ||
539 | void *priv) | ||
540 | { | ||
541 | struct ide_host *host; | ||
542 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | ||
543 | int ret; | ||
544 | |||
545 | ret = ide_setup_pci_controller(dev, d, 1); | ||
546 | if (ret < 0) | ||
547 | goto out; | ||
548 | |||
549 | ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); | ||
550 | |||
551 | host = ide_host_alloc(d, hws); | ||
552 | if (host == NULL) { | ||
553 | ret = -ENOMEM; | ||
554 | goto out; | ||
555 | } | ||
556 | |||
557 | host->dev[0] = &dev->dev; | ||
558 | |||
559 | host->host_priv = priv; | ||
560 | |||
561 | host->irq_flags = IRQF_SHARED; | ||
562 | |||
563 | pci_set_drvdata(dev, host); | ||
564 | |||
565 | ret = do_ide_setup_pci_device(dev, d, 1); | ||
566 | if (ret < 0) | ||
567 | goto out; | ||
568 | |||
569 | /* fixup IRQ */ | ||
570 | if (ide_pci_is_in_compatibility_mode(dev)) { | ||
571 | hw[0].irq = pci_get_legacy_ide_irq(dev, 0); | ||
572 | hw[1].irq = pci_get_legacy_ide_irq(dev, 1); | ||
573 | } else | ||
574 | hw[1].irq = hw[0].irq = ret; | ||
575 | |||
576 | ret = ide_host_register(host, d, hws); | ||
577 | if (ret) | ||
578 | ide_host_free(host); | ||
579 | out: | ||
580 | return ret; | ||
581 | } | ||
582 | EXPORT_SYMBOL_GPL(ide_pci_init_one); | ||
583 | |||
584 | int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | 537 | int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, |
585 | const struct ide_port_info *d, void *priv) | 538 | const struct ide_port_info *d, void *priv) |
586 | { | 539 | { |
587 | struct pci_dev *pdev[] = { dev1, dev2 }; | 540 | struct pci_dev *pdev[] = { dev1, dev2 }; |
588 | struct ide_host *host; | 541 | struct ide_host *host; |
589 | int ret, i; | 542 | int ret, i, n_ports = dev2 ? 4 : 2; |
590 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 543 | struct ide_hw hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
591 | 544 | ||
592 | for (i = 0; i < 2; i++) { | 545 | for (i = 0; i < n_ports / 2; i++) { |
593 | ret = ide_setup_pci_controller(pdev[i], d, !i); | 546 | ret = ide_setup_pci_controller(pdev[i], d, !i); |
594 | if (ret < 0) | 547 | if (ret < 0) |
595 | goto out; | 548 | goto out; |
@@ -597,23 +550,24 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | |||
597 | ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]); | 550 | ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]); |
598 | } | 551 | } |
599 | 552 | ||
600 | host = ide_host_alloc(d, hws); | 553 | host = ide_host_alloc(d, hws, n_ports); |
601 | if (host == NULL) { | 554 | if (host == NULL) { |
602 | ret = -ENOMEM; | 555 | ret = -ENOMEM; |
603 | goto out; | 556 | goto out; |
604 | } | 557 | } |
605 | 558 | ||
606 | host->dev[0] = &dev1->dev; | 559 | host->dev[0] = &dev1->dev; |
607 | host->dev[1] = &dev2->dev; | 560 | if (dev2) |
561 | host->dev[1] = &dev2->dev; | ||
608 | 562 | ||
609 | host->host_priv = priv; | 563 | host->host_priv = priv; |
610 | |||
611 | host->irq_flags = IRQF_SHARED; | 564 | host->irq_flags = IRQF_SHARED; |
612 | 565 | ||
613 | pci_set_drvdata(pdev[0], host); | 566 | pci_set_drvdata(pdev[0], host); |
614 | pci_set_drvdata(pdev[1], host); | 567 | if (dev2) |
568 | pci_set_drvdata(pdev[1], host); | ||
615 | 569 | ||
616 | for (i = 0; i < 2; i++) { | 570 | for (i = 0; i < n_ports / 2; i++) { |
617 | ret = do_ide_setup_pci_device(pdev[i], d, !i); | 571 | ret = do_ide_setup_pci_device(pdev[i], d, !i); |
618 | 572 | ||
619 | /* | 573 | /* |
@@ -639,6 +593,13 @@ out: | |||
639 | } | 593 | } |
640 | EXPORT_SYMBOL_GPL(ide_pci_init_two); | 594 | EXPORT_SYMBOL_GPL(ide_pci_init_two); |
641 | 595 | ||
596 | int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | ||
597 | void *priv) | ||
598 | { | ||
599 | return ide_pci_init_two(dev, NULL, d, priv); | ||
600 | } | ||
601 | EXPORT_SYMBOL_GPL(ide_pci_init_one); | ||
602 | |||
642 | void ide_pci_remove(struct pci_dev *dev) | 603 | void ide_pci_remove(struct pci_dev *dev) |
643 | { | 604 | { |
644 | struct ide_host *host = pci_get_drvdata(dev); | 605 | struct ide_host *host = pci_get_drvdata(dev); |
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c index e5d2a48a84de..5f37f168f944 100644 --- a/drivers/ide/sgiioc4.c +++ b/drivers/ide/sgiioc4.c | |||
@@ -91,7 +91,7 @@ typedef struct { | |||
91 | 91 | ||
92 | 92 | ||
93 | static void | 93 | static void |
94 | sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port, | 94 | sgiioc4_init_hwif_ports(struct ide_hw *hw, unsigned long data_port, |
95 | unsigned long ctrl_port, unsigned long irq_port) | 95 | unsigned long ctrl_port, unsigned long irq_port) |
96 | { | 96 | { |
97 | unsigned long reg = data_port; | 97 | unsigned long reg = data_port; |
@@ -546,7 +546,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
546 | unsigned long cmd_base, irqport; | 546 | unsigned long cmd_base, irqport; |
547 | unsigned long bar0, cmd_phys_base, ctl; | 547 | unsigned long bar0, cmd_phys_base, ctl; |
548 | void __iomem *virt_base; | 548 | void __iomem *virt_base; |
549 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 549 | struct ide_hw hw, *hws[] = { &hw }; |
550 | int rc; | 550 | int rc; |
551 | 551 | ||
552 | /* Get the CmdBlk and CtrlBlk Base Registers */ | 552 | /* Get the CmdBlk and CtrlBlk Base Registers */ |
@@ -575,13 +575,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
575 | memset(&hw, 0, sizeof(hw)); | 575 | memset(&hw, 0, sizeof(hw)); |
576 | sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport); | 576 | sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport); |
577 | hw.irq = dev->irq; | 577 | hw.irq = dev->irq; |
578 | hw.chipset = ide_pci; | ||
579 | hw.dev = &dev->dev; | 578 | hw.dev = &dev->dev; |
580 | 579 | ||
581 | /* Initializing chipset IRQ Registers */ | 580 | /* Initializing chipset IRQ Registers */ |
582 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); | 581 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); |
583 | 582 | ||
584 | rc = ide_host_add(&sgiioc4_port_info, hws, NULL); | 583 | rc = ide_host_add(&sgiioc4_port_info, hws, 1, NULL); |
585 | if (!rc) | 584 | if (!rc) |
586 | return 0; | 585 | return 0; |
587 | 586 | ||
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c index e4973cd1fba9..bd82d228608c 100644 --- a/drivers/ide/siimage.c +++ b/drivers/ide/siimage.c | |||
@@ -451,8 +451,8 @@ static int sil_sata_reset_poll(ide_drive_t *drive) | |||
451 | static void sil_sata_pre_reset(ide_drive_t *drive) | 451 | static void sil_sata_pre_reset(ide_drive_t *drive) |
452 | { | 452 | { |
453 | if (drive->media == ide_disk) { | 453 | if (drive->media == ide_disk) { |
454 | drive->special.b.set_geometry = 0; | 454 | drive->special_flags &= |
455 | drive->special.b.recalibrate = 0; | 455 | ~(IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c index b0a460625335..0924abff52ff 100644 --- a/drivers/ide/sl82c105.c +++ b/drivers/ide/sl82c105.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * with the timing registers setup. | 10 | * with the timing registers setup. |
11 | * -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org | 11 | * -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org |
12 | * | 12 | * |
13 | * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> | 13 | * Copyright (C) 2006-2007,2009 MontaVista Software, Inc. <source@mvista.com> |
14 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 14 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz |
15 | */ | 15 | */ |
16 | 16 | ||
@@ -146,14 +146,15 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive) | |||
146 | u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; | 146 | u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; |
147 | u8 dma_cmd; | 147 | u8 dma_cmd; |
148 | 148 | ||
149 | printk("sl82c105: lost IRQ, resetting host\n"); | 149 | printk(KERN_WARNING "sl82c105: lost IRQ, resetting host\n"); |
150 | 150 | ||
151 | /* | 151 | /* |
152 | * Check the raw interrupt from the drive. | 152 | * Check the raw interrupt from the drive. |
153 | */ | 153 | */ |
154 | pci_read_config_dword(dev, 0x40, &val); | 154 | pci_read_config_dword(dev, 0x40, &val); |
155 | if (val & mask) | 155 | if (val & mask) |
156 | printk("sl82c105: drive was requesting IRQ, but host lost it\n"); | 156 | printk(KERN_INFO "sl82c105: drive was requesting IRQ, " |
157 | "but host lost it\n"); | ||
157 | 158 | ||
158 | /* | 159 | /* |
159 | * Was DMA enabled? If so, disable it - we're resetting the | 160 | * Was DMA enabled? If so, disable it - we're resetting the |
@@ -162,7 +163,7 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive) | |||
162 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); | 163 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
163 | if (dma_cmd & 1) { | 164 | if (dma_cmd & 1) { |
164 | outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); | 165 | outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); |
165 | printk("sl82c105: DMA was enabled\n"); | 166 | printk(KERN_INFO "sl82c105: DMA was enabled\n"); |
166 | } | 167 | } |
167 | 168 | ||
168 | sl82c105_reset_host(dev); | 169 | sl82c105_reset_host(dev); |
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c index b4cf42dc8a6f..05a93d6baecc 100644 --- a/drivers/ide/tc86c001.c +++ b/drivers/ide/tc86c001.c | |||
@@ -112,7 +112,7 @@ static void tc86c001_dma_start(ide_drive_t *drive) | |||
112 | ide_hwif_t *hwif = drive->hwif; | 112 | ide_hwif_t *hwif = drive->hwif; |
113 | unsigned long sc_base = hwif->config_data; | 113 | unsigned long sc_base = hwif->config_data; |
114 | unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); | 114 | unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); |
115 | unsigned long nsectors = hwif->rq->nr_sectors; | 115 | unsigned long nsectors = blk_rq_sectors(hwif->rq); |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * We have to manually load the sector count and size into | 118 | * We have to manually load the sector count and size into |
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c index e33d764e2945..ea89fddeed91 100644 --- a/drivers/ide/tx4938ide.c +++ b/drivers/ide/tx4938ide.c | |||
@@ -130,8 +130,7 @@ static const struct ide_port_info tx4938ide_port_info __initdata = { | |||
130 | 130 | ||
131 | static int __init tx4938ide_probe(struct platform_device *pdev) | 131 | static int __init tx4938ide_probe(struct platform_device *pdev) |
132 | { | 132 | { |
133 | hw_regs_t hw; | 133 | struct ide_hw hw, *hws[] = { &hw }; |
134 | hw_regs_t *hws[] = { &hw, NULL, NULL, NULL }; | ||
135 | struct ide_host *host; | 134 | struct ide_host *host; |
136 | struct resource *res; | 135 | struct resource *res; |
137 | struct tx4938ide_platform_info *pdata = pdev->dev.platform_data; | 136 | struct tx4938ide_platform_info *pdata = pdev->dev.platform_data; |
@@ -183,7 +182,7 @@ static int __init tx4938ide_probe(struct platform_device *pdev) | |||
183 | tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0); | 182 | tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0); |
184 | else | 183 | else |
185 | d.port_ops = NULL; | 184 | d.port_ops = NULL; |
186 | ret = ide_host_add(&d, hws, &host); | 185 | ret = ide_host_add(&d, hws, 1, &host); |
187 | if (!ret) | 186 | if (!ret) |
188 | platform_set_drvdata(pdev, host); | 187 | platform_set_drvdata(pdev, host); |
189 | return ret; | 188 | return ret; |
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c index 564422d23976..64b58ecc3f0e 100644 --- a/drivers/ide/tx4939ide.c +++ b/drivers/ide/tx4939ide.c | |||
@@ -307,7 +307,7 @@ static int tx4939ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) | |||
307 | tx4939ide_writew(SECTOR_SIZE / 2, base, drive->dn ? | 307 | tx4939ide_writew(SECTOR_SIZE / 2, base, drive->dn ? |
308 | TX4939IDE_Xfer_Cnt_2 : TX4939IDE_Xfer_Cnt_1); | 308 | TX4939IDE_Xfer_Cnt_2 : TX4939IDE_Xfer_Cnt_1); |
309 | 309 | ||
310 | tx4939ide_writew(cmd->rq->nr_sectors, base, TX4939IDE_Sec_Cnt); | 310 | tx4939ide_writew(blk_rq_sectors(cmd->rq), base, TX4939IDE_Sec_Cnt); |
311 | 311 | ||
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
@@ -537,8 +537,7 @@ static const struct ide_port_info tx4939ide_port_info __initdata = { | |||
537 | 537 | ||
538 | static int __init tx4939ide_probe(struct platform_device *pdev) | 538 | static int __init tx4939ide_probe(struct platform_device *pdev) |
539 | { | 539 | { |
540 | hw_regs_t hw; | 540 | struct ide_hw hw, *hws[] = { &hw }; |
541 | hw_regs_t *hws[] = { &hw, NULL, NULL, NULL }; | ||
542 | struct ide_host *host; | 541 | struct ide_host *host; |
543 | struct resource *res; | 542 | struct resource *res; |
544 | int irq, ret; | 543 | int irq, ret; |
@@ -581,7 +580,7 @@ static int __init tx4939ide_probe(struct platform_device *pdev) | |||
581 | hw.dev = &pdev->dev; | 580 | hw.dev = &pdev->dev; |
582 | 581 | ||
583 | pr_info("TX4939 IDE interface (base %#lx, irq %d)\n", mapbase, irq); | 582 | pr_info("TX4939 IDE interface (base %#lx, irq %d)\n", mapbase, irq); |
584 | host = ide_host_alloc(&tx4939ide_port_info, hws); | 583 | host = ide_host_alloc(&tx4939ide_port_info, hws, 1); |
585 | if (!host) | 584 | if (!host) |
586 | return -ENOMEM; | 585 | return -ENOMEM; |
587 | /* use extra_base for base address of the all registers */ | 586 | /* use extra_base for base address of the all registers */ |
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c index 3ff7231e4858..028de26a25fe 100644 --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c | |||
@@ -67,6 +67,7 @@ static struct via_isa_bridge { | |||
67 | u8 udma_mask; | 67 | u8 udma_mask; |
68 | u8 flags; | 68 | u8 flags; |
69 | } via_isa_bridges[] = { | 69 | } via_isa_bridges[] = { |
70 | { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | ||
70 | { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 71 | { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
71 | { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 72 | { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
72 | { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 73 | { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
@@ -474,6 +475,7 @@ static const struct pci_device_id via_pci_tbl[] = { | |||
474 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 }, | 475 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 }, |
475 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 }, | 476 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 }, |
476 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 }, | 477 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 }, |
478 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_VX855_IDE), 0 }, | ||
477 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 }, | 479 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 }, |
478 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 }, | 480 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 }, |
479 | { 0, }, | 481 | { 0, }, |