diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-15 14:15:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-15 14:15:36 -0400 |
commit | 98339cbd360b77c3167db287fd611468c2c44559 (patch) | |
tree | 06779e040c18aa40fc5a6e15b132fa1f70ec45f6 /drivers/ide | |
parent | e4e0fadcd929138aa82130a1c5f22206d86d7bb2 (diff) | |
parent | cbbc4e818de4451cdef75a112b7fc8a523d5d2a0 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (80 commits)
ide-floppy: fix unfortunate function naming
ide-tape: unify idetape_create_read/write_cmd
ide: add ide_pc_intr() helper
ide-{floppy,scsi}: read Status Register before stopping DMA engine
ide-scsi: add more debugging to idescsi_pc_intr()
ide-scsi: use pc->callback
ide-floppy: add more debugging to idefloppy_pc_intr()
ide-tape: always log debug info in idetape_pc_intr() if debugging is enabled
ide-tape: add ide_tape_io_buffers() helper
ide-tape: factor out DSC handling from idetape_pc_intr()
ide-{floppy,tape}: move checking of ->failed_pc to ->callback
ide: add ide_issue_pc() helper
ide: add PC_FLAG_DRQ_INTERRUPT pc flag
ide-scsi: move idescsi_map_sg() call out from idescsi_issue_pc()
ide: add ide_transfer_pc() helper
ide-scsi: set drive->scsi flag for devices handled by the driver
ide-{cd,floppy,tape}: remove checking for drive->scsi
ide: add PC_FLAG_ZIP_DRIVE pc flag
ide-tape: factor out waiting for good ireason from idetape_transfer_pc()
ide-tape: set PC_FLAG_DMA_IN_PROGRESS flag in idetape_transfer_pc()
...
Diffstat (limited to 'drivers/ide')
37 files changed, 807 insertions, 1369 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 1607536ff5fb..cf707c8f08d4 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -98,6 +98,9 @@ if BLK_DEV_IDE | |||
98 | 98 | ||
99 | comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" | 99 | comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" |
100 | 100 | ||
101 | config IDE_ATAPI | ||
102 | bool | ||
103 | |||
101 | config BLK_DEV_IDE_SATA | 104 | config BLK_DEV_IDE_SATA |
102 | bool "Support for SATA (deprecated; conflicts with libata SATA driver)" | 105 | bool "Support for SATA (deprecated; conflicts with libata SATA driver)" |
103 | default n | 106 | default n |
@@ -201,6 +204,7 @@ config BLK_DEV_IDECD_VERBOSE_ERRORS | |||
201 | 204 | ||
202 | config BLK_DEV_IDETAPE | 205 | config BLK_DEV_IDETAPE |
203 | tristate "Include IDE/ATAPI TAPE support" | 206 | tristate "Include IDE/ATAPI TAPE support" |
207 | select IDE_ATAPI | ||
204 | help | 208 | help |
205 | If you have an IDE tape drive using the ATAPI protocol, say Y. | 209 | If you have an IDE tape drive using the ATAPI protocol, say Y. |
206 | ATAPI is a newer protocol used by IDE tape and CD-ROM drives, | 210 | ATAPI is a newer protocol used by IDE tape and CD-ROM drives, |
@@ -223,6 +227,7 @@ config BLK_DEV_IDETAPE | |||
223 | 227 | ||
224 | config BLK_DEV_IDEFLOPPY | 228 | config BLK_DEV_IDEFLOPPY |
225 | tristate "Include IDE/ATAPI FLOPPY support" | 229 | tristate "Include IDE/ATAPI FLOPPY support" |
230 | select IDE_ATAPI | ||
226 | ---help--- | 231 | ---help--- |
227 | If you have an IDE floppy drive which uses the ATAPI protocol, | 232 | If you have an IDE floppy drive which uses the ATAPI protocol, |
228 | answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy | 233 | answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy |
@@ -246,6 +251,7 @@ config BLK_DEV_IDEFLOPPY | |||
246 | config BLK_DEV_IDESCSI | 251 | config BLK_DEV_IDESCSI |
247 | tristate "SCSI emulation support" | 252 | tristate "SCSI emulation support" |
248 | depends on SCSI | 253 | depends on SCSI |
254 | select IDE_ATAPI | ||
249 | ---help--- | 255 | ---help--- |
250 | WARNING: ide-scsi is no longer needed for cd writing applications! | 256 | WARNING: ide-scsi is no longer needed for cd writing applications! |
251 | The 2.6 kernel supports direct writing to ide-cd, which eliminates | 257 | The 2.6 kernel supports direct writing to ide-cd, which eliminates |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index f94b679b611e..a2b3f84d710d 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -14,6 +14,7 @@ EXTRA_CFLAGS += -Idrivers/ide | |||
14 | ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o | 14 | ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o |
15 | 15 | ||
16 | # core IDE code | 16 | # core IDE code |
17 | ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o | ||
17 | ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o | 18 | ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o |
18 | ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o | 19 | ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o |
19 | ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o | 20 | ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o |
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 2f2b4f4cf229..3839f5722985 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -83,7 +83,7 @@ static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { | |||
83 | {125, 160}, /* UDMA Mode 1 */ | 83 | {125, 160}, /* UDMA Mode 1 */ |
84 | {100, 120}, /* UDMA Mode 2 */ | 84 | {100, 120}, /* UDMA Mode 2 */ |
85 | {100, 90}, /* UDMA Mode 3 */ | 85 | {100, 90}, /* UDMA Mode 3 */ |
86 | {85, 60}, /* UDMA Mode 4 */ | 86 | {100, 60}, /* UDMA Mode 4 */ |
87 | }; | 87 | }; |
88 | 88 | ||
89 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | 89 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, |
@@ -405,7 +405,6 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
405 | ide_init_port_data(hwif, i); | 405 | ide_init_port_data(hwif, i); |
406 | ide_init_port_hw(hwif, &hw); | 406 | ide_init_port_hw(hwif, &hw); |
407 | 407 | ||
408 | hwif->mmio = 1; | ||
409 | default_hwif_mmiops(hwif); | 408 | default_hwif_mmiops(hwif); |
410 | 409 | ||
411 | idx[0] = i; | 410 | idx[0] = i; |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index ecf53bb0d2aa..ae37ee58bae2 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
@@ -52,8 +52,6 @@ static void h8300_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
52 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | 52 | if (task->tf_flags & IDE_TFLAG_FLAGGED) |
53 | HIHI = 0xFF; | 53 | HIHI = 0xFF; |
54 | 54 | ||
55 | ide_set_irq(drive, 1); | ||
56 | |||
57 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) | 55 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) |
58 | mm_outw((tf->hob_data << 8) | tf->data, io_ports->data_addr); | 56 | mm_outw((tf->hob_data << 8) | tf->data, io_ports->data_addr); |
59 | 57 | ||
@@ -98,7 +96,7 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
98 | } | 96 | } |
99 | 97 | ||
100 | /* be sure we're looking at the low order bits */ | 98 | /* be sure we're looking at the low order bits */ |
101 | outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 99 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
102 | 100 | ||
103 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 101 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
104 | tf->nsect = inb(io_ports->nsect_addr); | 102 | tf->nsect = inb(io_ports->nsect_addr); |
@@ -112,7 +110,7 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
112 | tf->device = inb(io_ports->device_addr); | 110 | tf->device = inb(io_ports->device_addr); |
113 | 111 | ||
114 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 112 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
115 | outb(drive->ctl | 0x80, io_ports->ctl_addr); | 113 | outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
116 | 114 | ||
117 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 115 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
118 | tf->hob_feature = inb(io_ports->feature_addr); | 116 | tf->hob_feature = inb(io_ports->feature_addr); |
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 9d3601fa5680..6f704628c27d 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -60,15 +60,15 @@ struct ide_acpi_hwif_link { | |||
60 | #define DEBPRINT(fmt, args...) do {} while (0) | 60 | #define DEBPRINT(fmt, args...) do {} while (0) |
61 | #endif /* DEBUGGING */ | 61 | #endif /* DEBUGGING */ |
62 | 62 | ||
63 | int ide_noacpi; | 63 | static int ide_noacpi; |
64 | module_param_named(noacpi, ide_noacpi, bool, 0); | 64 | module_param_named(noacpi, ide_noacpi, bool, 0); |
65 | MODULE_PARM_DESC(noacpi, "disable IDE ACPI support"); | 65 | MODULE_PARM_DESC(noacpi, "disable IDE ACPI support"); |
66 | 66 | ||
67 | int ide_acpigtf; | 67 | static int ide_acpigtf; |
68 | module_param_named(acpigtf, ide_acpigtf, bool, 0); | 68 | module_param_named(acpigtf, ide_acpigtf, bool, 0); |
69 | MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support"); | 69 | MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support"); |
70 | 70 | ||
71 | int ide_acpionboot; | 71 | static int ide_acpionboot; |
72 | module_param_named(acpionboot, ide_acpionboot, bool, 0); | 72 | module_param_named(acpionboot, ide_acpionboot, bool, 0); |
73 | MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot"); | 73 | MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot"); |
74 | 74 | ||
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c new file mode 100644 index 000000000000..2802031de670 --- /dev/null +++ b/drivers/ide/ide-atapi.c | |||
@@ -0,0 +1,296 @@ | |||
1 | /* | ||
2 | * ATAPI support. | ||
3 | */ | ||
4 | |||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/delay.h> | ||
7 | #include <linux/ide.h> | ||
8 | #include <scsi/scsi.h> | ||
9 | |||
10 | #ifdef DEBUG | ||
11 | #define debug_log(fmt, args...) \ | ||
12 | printk(KERN_INFO "ide: " fmt, ## args) | ||
13 | #else | ||
14 | #define debug_log(fmt, args...) do {} while (0) | ||
15 | #endif | ||
16 | |||
17 | /* TODO: unify the code thus making some arguments go away */ | ||
18 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
19 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | ||
20 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | ||
21 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | ||
22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) | ||
23 | { | ||
24 | ide_hwif_t *hwif = drive->hwif; | ||
25 | xfer_func_t *xferfunc; | ||
26 | unsigned int temp; | ||
27 | u16 bcount; | ||
28 | u8 stat, ireason, scsi = drive->scsi; | ||
29 | |||
30 | debug_log("Enter %s - interrupt handler\n", __func__); | ||
31 | |||
32 | if (pc->flags & PC_FLAG_TIMEDOUT) { | ||
33 | pc->callback(drive); | ||
34 | return ide_stopped; | ||
35 | } | ||
36 | |||
37 | /* Clear the interrupt */ | ||
38 | stat = ide_read_status(drive); | ||
39 | |||
40 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
41 | if (hwif->dma_ops->dma_end(drive) || | ||
42 | (drive->media == ide_tape && !scsi && (stat & ERR_STAT))) { | ||
43 | if (drive->media == ide_floppy && !scsi) | ||
44 | printk(KERN_ERR "%s: DMA %s error\n", | ||
45 | drive->name, rq_data_dir(pc->rq) | ||
46 | ? "write" : "read"); | ||
47 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
48 | } else { | ||
49 | pc->xferred = pc->req_xfer; | ||
50 | if (update_buffers) | ||
51 | update_buffers(drive, pc); | ||
52 | } | ||
53 | debug_log("%s: DMA finished\n", drive->name); | ||
54 | } | ||
55 | |||
56 | /* No more interrupts */ | ||
57 | if ((stat & DRQ_STAT) == 0) { | ||
58 | debug_log("Packet command completed, %d bytes transferred\n", | ||
59 | pc->xferred); | ||
60 | |||
61 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
62 | |||
63 | local_irq_enable_in_hardirq(); | ||
64 | |||
65 | if (drive->media == ide_tape && !scsi && | ||
66 | (stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | ||
67 | stat &= ~ERR_STAT; | ||
68 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | ||
69 | /* Error detected */ | ||
70 | debug_log("%s: I/O error\n", drive->name); | ||
71 | |||
72 | if (drive->media != ide_tape || scsi) { | ||
73 | pc->rq->errors++; | ||
74 | if (scsi) | ||
75 | goto cmd_finished; | ||
76 | } | ||
77 | |||
78 | if (pc->c[0] == REQUEST_SENSE) { | ||
79 | printk(KERN_ERR "%s: I/O error in request sense" | ||
80 | " command\n", drive->name); | ||
81 | return ide_do_reset(drive); | ||
82 | } | ||
83 | |||
84 | debug_log("[cmd %x]: check condition\n", pc->c[0]); | ||
85 | |||
86 | /* Retry operation */ | ||
87 | retry_pc(drive); | ||
88 | /* queued, but not started */ | ||
89 | return ide_stopped; | ||
90 | } | ||
91 | cmd_finished: | ||
92 | pc->error = 0; | ||
93 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && | ||
94 | (stat & SEEK_STAT) == 0) { | ||
95 | dsc_handle(drive); | ||
96 | return ide_stopped; | ||
97 | } | ||
98 | /* Command finished - Call the callback function */ | ||
99 | pc->callback(drive); | ||
100 | return ide_stopped; | ||
101 | } | ||
102 | |||
103 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
104 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
105 | printk(KERN_ERR "%s: The device wants to issue more interrupts " | ||
106 | "in DMA mode\n", drive->name); | ||
107 | ide_dma_off(drive); | ||
108 | return ide_do_reset(drive); | ||
109 | } | ||
110 | /* Get the number of bytes to transfer on this interrupt. */ | ||
111 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
112 | hwif->INB(hwif->io_ports.lbam_addr); | ||
113 | |||
114 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
115 | |||
116 | if (ireason & CD) { | ||
117 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); | ||
118 | return ide_do_reset(drive); | ||
119 | } | ||
120 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | ||
121 | /* Hopefully, we will never get here */ | ||
122 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " | ||
123 | "to %s!\n", drive->name, | ||
124 | (ireason & IO) ? "Write" : "Read", | ||
125 | (ireason & IO) ? "Read" : "Write"); | ||
126 | return ide_do_reset(drive); | ||
127 | } | ||
128 | if (!(pc->flags & PC_FLAG_WRITING)) { | ||
129 | /* Reading - Check that we have enough space */ | ||
130 | temp = pc->xferred + bcount; | ||
131 | if (temp > pc->req_xfer) { | ||
132 | if (temp > pc->buf_size) { | ||
133 | printk(KERN_ERR "%s: The device wants to send " | ||
134 | "us more data than expected - " | ||
135 | "discarding data\n", | ||
136 | drive->name); | ||
137 | if (scsi) | ||
138 | temp = pc->buf_size - pc->xferred; | ||
139 | else | ||
140 | temp = 0; | ||
141 | if (temp) { | ||
142 | if (pc->sg) | ||
143 | io_buffers(drive, pc, temp, 0); | ||
144 | else | ||
145 | hwif->input_data(drive, NULL, | ||
146 | pc->cur_pos, temp); | ||
147 | printk(KERN_ERR "%s: transferred %d of " | ||
148 | "%d bytes\n", | ||
149 | drive->name, | ||
150 | temp, bcount); | ||
151 | } | ||
152 | pc->xferred += temp; | ||
153 | pc->cur_pos += temp; | ||
154 | ide_pad_transfer(drive, 0, bcount - temp); | ||
155 | ide_set_handler(drive, handler, timeout, | ||
156 | expiry); | ||
157 | return ide_started; | ||
158 | } | ||
159 | debug_log("The device wants to send us more data than " | ||
160 | "expected - allowing transfer\n"); | ||
161 | } | ||
162 | xferfunc = hwif->input_data; | ||
163 | } else | ||
164 | xferfunc = hwif->output_data; | ||
165 | |||
166 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || | ||
167 | (drive->media == ide_tape && !scsi && pc->bh) || | ||
168 | (scsi && pc->sg)) | ||
169 | io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING)); | ||
170 | else | ||
171 | xferfunc(drive, NULL, pc->cur_pos, bcount); | ||
172 | |||
173 | /* Update the current position */ | ||
174 | pc->xferred += bcount; | ||
175 | pc->cur_pos += bcount; | ||
176 | |||
177 | debug_log("[cmd %x] transferred %d bytes on that intr.\n", | ||
178 | pc->c[0], bcount); | ||
179 | |||
180 | /* And set the interrupt handler again */ | ||
181 | ide_set_handler(drive, handler, timeout, expiry); | ||
182 | return ide_started; | ||
183 | } | ||
184 | EXPORT_SYMBOL_GPL(ide_pc_intr); | ||
185 | |||
186 | static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | ||
187 | { | ||
188 | ide_hwif_t *hwif = drive->hwif; | ||
189 | int retries = 100; | ||
190 | |||
191 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | ||
192 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | ||
193 | "a packet command, retrying\n", drive->name); | ||
194 | udelay(100); | ||
195 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
196 | if (retries == 0) { | ||
197 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | ||
198 | "a packet command, ignoring\n", | ||
199 | drive->name); | ||
200 | ireason |= CD; | ||
201 | ireason &= ~IO; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | return ireason; | ||
206 | } | ||
207 | |||
208 | ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
209 | ide_handler_t *handler, unsigned int timeout, | ||
210 | ide_expiry_t *expiry) | ||
211 | { | ||
212 | ide_hwif_t *hwif = drive->hwif; | ||
213 | ide_startstop_t startstop; | ||
214 | u8 ireason; | ||
215 | |||
216 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
217 | printk(KERN_ERR "%s: Strange, packet command initiated yet " | ||
218 | "DRQ isn't asserted\n", drive->name); | ||
219 | return startstop; | ||
220 | } | ||
221 | |||
222 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
223 | if (drive->media == ide_tape && !drive->scsi) | ||
224 | ireason = ide_wait_ireason(drive, ireason); | ||
225 | |||
226 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
227 | printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " | ||
228 | "a packet command\n", drive->name); | ||
229 | return ide_do_reset(drive); | ||
230 | } | ||
231 | |||
232 | /* Set the interrupt routine */ | ||
233 | ide_set_handler(drive, handler, timeout, expiry); | ||
234 | |||
235 | /* Begin DMA, if necessary */ | ||
236 | if (pc->flags & PC_FLAG_DMA_OK) { | ||
237 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
238 | hwif->dma_ops->dma_start(drive); | ||
239 | } | ||
240 | |||
241 | /* Send the actual packet */ | ||
242 | if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0) | ||
243 | hwif->output_data(drive, NULL, pc->c, 12); | ||
244 | |||
245 | return ide_started; | ||
246 | } | ||
247 | EXPORT_SYMBOL_GPL(ide_transfer_pc); | ||
248 | |||
249 | ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
250 | ide_handler_t *handler, unsigned int timeout, | ||
251 | ide_expiry_t *expiry) | ||
252 | { | ||
253 | ide_hwif_t *hwif = drive->hwif; | ||
254 | u16 bcount; | ||
255 | u8 dma = 0; | ||
256 | |||
257 | /* We haven't transferred any data yet */ | ||
258 | pc->xferred = 0; | ||
259 | pc->cur_pos = pc->buf; | ||
260 | |||
261 | /* Request to transfer the entire buffer at once */ | ||
262 | if (drive->media == ide_tape && !drive->scsi) | ||
263 | bcount = pc->req_xfer; | ||
264 | else | ||
265 | bcount = min(pc->req_xfer, 63 * 1024); | ||
266 | |||
267 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
268 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
269 | ide_dma_off(drive); | ||
270 | } | ||
271 | |||
272 | if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) { | ||
273 | if (drive->scsi) | ||
274 | hwif->sg_mapped = 1; | ||
275 | dma = !hwif->dma_ops->dma_setup(drive); | ||
276 | if (drive->scsi) | ||
277 | hwif->sg_mapped = 0; | ||
278 | } | ||
279 | |||
280 | if (!dma) | ||
281 | pc->flags &= ~PC_FLAG_DMA_OK; | ||
282 | |||
283 | ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE, | ||
284 | bcount, dma); | ||
285 | |||
286 | /* Issue the packet command */ | ||
287 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | ||
288 | ide_execute_command(drive, WIN_PACKETCMD, handler, | ||
289 | timeout, NULL); | ||
290 | return ide_started; | ||
291 | } else { | ||
292 | ide_execute_pkt_cmd(drive); | ||
293 | return (*handler)(drive); | ||
294 | } | ||
295 | } | ||
296 | EXPORT_SYMBOL_GPL(ide_issue_pc); | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 68e7f19dc036..d99847157186 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -188,16 +188,6 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
188 | ide_cd_log_error(drive->name, failed_command, sense); | 188 | ide_cd_log_error(drive->name, failed_command, sense); |
189 | } | 189 | } |
190 | 190 | ||
191 | /* Initialize a ide-cd packet command request */ | ||
192 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) | ||
193 | { | ||
194 | struct cdrom_info *cd = drive->driver_data; | ||
195 | |||
196 | ide_init_drive_cmd(rq); | ||
197 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
198 | rq->rq_disk = cd->disk; | ||
199 | } | ||
200 | |||
201 | static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | 191 | static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, |
202 | struct request *failed_command) | 192 | struct request *failed_command) |
203 | { | 193 | { |
@@ -208,7 +198,9 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
208 | sense = &info->sense_data; | 198 | sense = &info->sense_data; |
209 | 199 | ||
210 | /* stuff the sense request in front of our current request */ | 200 | /* stuff the sense request in front of our current request */ |
211 | ide_cd_init_rq(drive, rq); | 201 | blk_rq_init(NULL, rq); |
202 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
203 | rq->rq_disk = info->disk; | ||
212 | 204 | ||
213 | rq->data = sense; | 205 | rq->data = sense; |
214 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | 206 | rq->cmd[0] = GPCMD_REQUEST_SENSE; |
@@ -216,11 +208,12 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
216 | rq->data_len = 18; | 208 | rq->data_len = 18; |
217 | 209 | ||
218 | rq->cmd_type = REQ_TYPE_SENSE; | 210 | rq->cmd_type = REQ_TYPE_SENSE; |
211 | rq->cmd_flags |= REQ_PREEMPT; | ||
219 | 212 | ||
220 | /* NOTE! Save the failed command in "rq->buffer" */ | 213 | /* NOTE! Save the failed command in "rq->buffer" */ |
221 | rq->buffer = (void *) failed_command; | 214 | rq->buffer = (void *) failed_command; |
222 | 215 | ||
223 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 216 | ide_do_drive_cmd(drive, rq); |
224 | } | 217 | } |
225 | 218 | ||
226 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) | 219 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) |
@@ -537,8 +530,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
537 | info->dma = !hwif->dma_ops->dma_setup(drive); | 530 | info->dma = !hwif->dma_ops->dma_setup(drive); |
538 | 531 | ||
539 | /* set up the controller registers */ | 532 | /* set up the controller registers */ |
540 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | | 533 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, |
541 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); | 534 | xferlen, info->dma); |
542 | 535 | ||
543 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 536 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
544 | /* waiting for CDB interrupt, not DMA yet. */ | 537 | /* waiting for CDB interrupt, not DMA yet. */ |
@@ -838,34 +831,54 @@ static void ide_cd_request_sense_fixup(struct request *rq) | |||
838 | } | 831 | } |
839 | } | 832 | } |
840 | 833 | ||
841 | int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | 834 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, |
835 | int write, void *buffer, unsigned *bufflen, | ||
836 | struct request_sense *sense, int timeout, | ||
837 | unsigned int cmd_flags) | ||
842 | { | 838 | { |
843 | struct request_sense sense; | 839 | struct cdrom_info *info = drive->driver_data; |
840 | struct request_sense local_sense; | ||
844 | int retries = 10; | 841 | int retries = 10; |
845 | unsigned int flags = rq->cmd_flags; | 842 | unsigned int flags = 0; |
846 | 843 | ||
847 | if (rq->sense == NULL) | 844 | if (!sense) |
848 | rq->sense = &sense; | 845 | sense = &local_sense; |
849 | 846 | ||
850 | /* start of retry loop */ | 847 | /* start of retry loop */ |
851 | do { | 848 | do { |
849 | struct request *rq; | ||
852 | int error; | 850 | int error; |
853 | unsigned long time = jiffies; | ||
854 | rq->cmd_flags = flags; | ||
855 | 851 | ||
856 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 852 | rq = blk_get_request(drive->queue, write, __GFP_WAIT); |
857 | time = jiffies - time; | 853 | |
854 | memcpy(rq->cmd, cmd, BLK_MAX_CDB); | ||
855 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
856 | rq->sense = sense; | ||
857 | rq->cmd_flags |= cmd_flags; | ||
858 | rq->timeout = timeout; | ||
859 | if (buffer) { | ||
860 | rq->data = buffer; | ||
861 | rq->data_len = *bufflen; | ||
862 | } | ||
863 | |||
864 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); | ||
865 | |||
866 | if (buffer) | ||
867 | *bufflen = rq->data_len; | ||
868 | |||
869 | flags = rq->cmd_flags; | ||
870 | blk_put_request(rq); | ||
858 | 871 | ||
859 | /* | 872 | /* |
860 | * FIXME: we should probably abort/retry or something in case of | 873 | * FIXME: we should probably abort/retry or something in case of |
861 | * failure. | 874 | * failure. |
862 | */ | 875 | */ |
863 | if (rq->cmd_flags & REQ_FAILED) { | 876 | if (flags & REQ_FAILED) { |
864 | /* | 877 | /* |
865 | * The request failed. Retry if it was due to a unit | 878 | * The request failed. Retry if it was due to a unit |
866 | * attention status (usually means media was changed). | 879 | * attention status (usually means media was changed). |
867 | */ | 880 | */ |
868 | struct request_sense *reqbuf = rq->sense; | 881 | struct request_sense *reqbuf = sense; |
869 | 882 | ||
870 | if (reqbuf->sense_key == UNIT_ATTENTION) | 883 | if (reqbuf->sense_key == UNIT_ATTENTION) |
871 | cdrom_saw_media_change(drive); | 884 | cdrom_saw_media_change(drive); |
@@ -885,10 +898,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
885 | } | 898 | } |
886 | 899 | ||
887 | /* end of retry loop */ | 900 | /* end of retry loop */ |
888 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); | 901 | } while ((flags & REQ_FAILED) && retries >= 0); |
889 | 902 | ||
890 | /* return an error if the command failed */ | 903 | /* return an error if the command failed */ |
891 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; | 904 | return (flags & REQ_FAILED) ? -EIO : 0; |
892 | } | 905 | } |
893 | 906 | ||
894 | /* | 907 | /* |
@@ -1268,23 +1281,20 @@ static void msf_from_bcd(struct atapi_msf *msf) | |||
1268 | 1281 | ||
1269 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | 1282 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) |
1270 | { | 1283 | { |
1271 | struct request req; | ||
1272 | struct cdrom_info *info = drive->driver_data; | 1284 | struct cdrom_info *info = drive->driver_data; |
1273 | struct cdrom_device_info *cdi = &info->devinfo; | 1285 | struct cdrom_device_info *cdi = &info->devinfo; |
1286 | unsigned char cmd[BLK_MAX_CDB]; | ||
1274 | 1287 | ||
1275 | ide_cd_init_rq(drive, &req); | 1288 | memset(cmd, 0, BLK_MAX_CDB); |
1276 | 1289 | cmd[0] = GPCMD_TEST_UNIT_READY; | |
1277 | req.sense = sense; | ||
1278 | req.cmd[0] = GPCMD_TEST_UNIT_READY; | ||
1279 | req.cmd_flags |= REQ_QUIET; | ||
1280 | 1290 | ||
1281 | /* | 1291 | /* |
1282 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs | 1292 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs |
1283 | * instead of supporting the LOAD_UNLOAD opcode. | 1293 | * instead of supporting the LOAD_UNLOAD opcode. |
1284 | */ | 1294 | */ |
1285 | req.cmd[7] = cdi->sanyo_slot % 3; | 1295 | cmd[7] = cdi->sanyo_slot % 3; |
1286 | 1296 | ||
1287 | return ide_cd_queue_pc(drive, &req); | 1297 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, REQ_QUIET); |
1288 | } | 1298 | } |
1289 | 1299 | ||
1290 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | 1300 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, |
@@ -1297,17 +1307,14 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
1297 | } capbuf; | 1307 | } capbuf; |
1298 | 1308 | ||
1299 | int stat; | 1309 | int stat; |
1300 | struct request req; | 1310 | unsigned char cmd[BLK_MAX_CDB]; |
1301 | 1311 | unsigned len = sizeof(capbuf); | |
1302 | ide_cd_init_rq(drive, &req); | ||
1303 | 1312 | ||
1304 | req.sense = sense; | 1313 | memset(cmd, 0, BLK_MAX_CDB); |
1305 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; | 1314 | cmd[0] = GPCMD_READ_CDVD_CAPACITY; |
1306 | req.data = (char *)&capbuf; | ||
1307 | req.data_len = sizeof(capbuf); | ||
1308 | req.cmd_flags |= REQ_QUIET; | ||
1309 | 1315 | ||
1310 | stat = ide_cd_queue_pc(drive, &req); | 1316 | stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0, |
1317 | REQ_QUIET); | ||
1311 | if (stat == 0) { | 1318 | if (stat == 0) { |
1312 | *capacity = 1 + be32_to_cpu(capbuf.lba); | 1319 | *capacity = 1 + be32_to_cpu(capbuf.lba); |
1313 | *sectors_per_frame = | 1320 | *sectors_per_frame = |
@@ -1321,24 +1328,20 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | |||
1321 | int format, char *buf, int buflen, | 1328 | int format, char *buf, int buflen, |
1322 | struct request_sense *sense) | 1329 | struct request_sense *sense) |
1323 | { | 1330 | { |
1324 | struct request req; | 1331 | unsigned char cmd[BLK_MAX_CDB]; |
1325 | 1332 | ||
1326 | ide_cd_init_rq(drive, &req); | 1333 | memset(cmd, 0, BLK_MAX_CDB); |
1327 | 1334 | ||
1328 | req.sense = sense; | 1335 | cmd[0] = GPCMD_READ_TOC_PMA_ATIP; |
1329 | req.data = buf; | 1336 | cmd[6] = trackno; |
1330 | req.data_len = buflen; | 1337 | cmd[7] = (buflen >> 8); |
1331 | req.cmd_flags |= REQ_QUIET; | 1338 | cmd[8] = (buflen & 0xff); |
1332 | req.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; | 1339 | cmd[9] = (format << 6); |
1333 | req.cmd[6] = trackno; | ||
1334 | req.cmd[7] = (buflen >> 8); | ||
1335 | req.cmd[8] = (buflen & 0xff); | ||
1336 | req.cmd[9] = (format << 6); | ||
1337 | 1340 | ||
1338 | if (msf_flag) | 1341 | if (msf_flag) |
1339 | req.cmd[1] = 2; | 1342 | cmd[1] = 2; |
1340 | 1343 | ||
1341 | return ide_cd_queue_pc(drive, &req); | 1344 | return ide_cd_queue_pc(drive, cmd, 0, buf, &buflen, sense, 0, REQ_QUIET); |
1342 | } | 1345 | } |
1343 | 1346 | ||
1344 | /* Try to read the entire TOC for the disk into our internal buffer. */ | 1347 | /* Try to read the entire TOC for the disk into our internal buffer. */ |
@@ -2103,11 +2106,6 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2103 | goto failed; | 2106 | goto failed; |
2104 | } | 2107 | } |
2105 | } | 2108 | } |
2106 | if (drive->scsi) { | ||
2107 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " | ||
2108 | "emulation.\n", drive->name); | ||
2109 | goto failed; | ||
2110 | } | ||
2111 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 2109 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2112 | if (info == NULL) { | 2110 | if (info == NULL) { |
2113 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", | 2111 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index a58801c4484d..fe0ea36e4124 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -143,8 +143,8 @@ struct cdrom_info { | |||
143 | void ide_cd_log_error(const char *, struct request *, struct request_sense *); | 143 | void ide_cd_log_error(const char *, struct request *, struct request_sense *); |
144 | 144 | ||
145 | /* ide-cd.c functions used by ide-cd_ioctl.c */ | 145 | /* ide-cd.c functions used by ide-cd_ioctl.c */ |
146 | void ide_cd_init_rq(ide_drive_t *, struct request *); | 146 | int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *, |
147 | int ide_cd_queue_pc(ide_drive_t *, struct request *); | 147 | unsigned *, struct request_sense *, int, unsigned int); |
148 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); | 148 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); |
149 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); | 149 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); |
150 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); | 150 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); |
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c index 6d147ce6782f..24d002addf73 100644 --- a/drivers/ide/ide-cd_ioctl.c +++ b/drivers/ide/ide-cd_ioctl.c | |||
@@ -104,8 +104,8 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
104 | { | 104 | { |
105 | struct cdrom_info *cd = drive->driver_data; | 105 | struct cdrom_info *cd = drive->driver_data; |
106 | struct cdrom_device_info *cdi = &cd->devinfo; | 106 | struct cdrom_device_info *cdi = &cd->devinfo; |
107 | struct request req; | ||
108 | char loej = 0x02; | 107 | char loej = 0x02; |
108 | unsigned char cmd[BLK_MAX_CDB]; | ||
109 | 109 | ||
110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) | 110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) |
111 | return -EDRIVE_CANT_DO_THIS; | 111 | return -EDRIVE_CANT_DO_THIS; |
@@ -114,17 +114,16 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) | 114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) |
115 | return 0; | 115 | return 0; |
116 | 116 | ||
117 | ide_cd_init_rq(drive, &req); | ||
118 | |||
119 | /* only tell drive to close tray if open, if it can do that */ | 117 | /* only tell drive to close tray if open, if it can do that */ |
120 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) | 118 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) |
121 | loej = 0; | 119 | loej = 0; |
122 | 120 | ||
123 | req.sense = sense; | 121 | memset(cmd, 0, BLK_MAX_CDB); |
124 | req.cmd[0] = GPCMD_START_STOP_UNIT; | 122 | |
125 | req.cmd[4] = loej | (ejectflag != 0); | 123 | cmd[0] = GPCMD_START_STOP_UNIT; |
124 | cmd[4] = loej | (ejectflag != 0); | ||
126 | 125 | ||
127 | return ide_cd_queue_pc(drive, &req); | 126 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, 0); |
128 | } | 127 | } |
129 | 128 | ||
130 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ | 129 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ |
@@ -134,7 +133,6 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
134 | { | 133 | { |
135 | struct cdrom_info *cd = drive->driver_data; | 134 | struct cdrom_info *cd = drive->driver_data; |
136 | struct request_sense my_sense; | 135 | struct request_sense my_sense; |
137 | struct request req; | ||
138 | int stat; | 136 | int stat; |
139 | 137 | ||
140 | if (sense == NULL) | 138 | if (sense == NULL) |
@@ -144,11 +142,15 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
144 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { | 142 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { |
145 | stat = 0; | 143 | stat = 0; |
146 | } else { | 144 | } else { |
147 | ide_cd_init_rq(drive, &req); | 145 | unsigned char cmd[BLK_MAX_CDB]; |
148 | req.sense = sense; | 146 | |
149 | req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | 147 | memset(cmd, 0, BLK_MAX_CDB); |
150 | req.cmd[4] = lockflag ? 1 : 0; | 148 | |
151 | stat = ide_cd_queue_pc(drive, &req); | 149 | cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; |
150 | cmd[4] = lockflag ? 1 : 0; | ||
151 | |||
152 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, | ||
153 | sense, 0, 0); | ||
152 | } | 154 | } |
153 | 155 | ||
154 | /* If we got an illegal field error, the drive | 156 | /* If we got an illegal field error, the drive |
@@ -206,32 +208,30 @@ int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) | |||
206 | { | 208 | { |
207 | ide_drive_t *drive = cdi->handle; | 209 | ide_drive_t *drive = cdi->handle; |
208 | struct cdrom_info *cd = drive->driver_data; | 210 | struct cdrom_info *cd = drive->driver_data; |
209 | struct request rq; | ||
210 | struct request_sense sense; | 211 | struct request_sense sense; |
211 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; | 212 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
212 | int stat; | 213 | int stat; |
213 | 214 | unsigned char cmd[BLK_MAX_CDB]; | |
214 | ide_cd_init_rq(drive, &rq); | ||
215 | |||
216 | rq.sense = &sense; | ||
217 | 215 | ||
218 | if (speed == 0) | 216 | if (speed == 0) |
219 | speed = 0xffff; /* set to max */ | 217 | speed = 0xffff; /* set to max */ |
220 | else | 218 | else |
221 | speed *= 177; /* Nx to kbytes/s */ | 219 | speed *= 177; /* Nx to kbytes/s */ |
222 | 220 | ||
223 | rq.cmd[0] = GPCMD_SET_SPEED; | 221 | memset(cmd, 0, BLK_MAX_CDB); |
222 | |||
223 | cmd[0] = GPCMD_SET_SPEED; | ||
224 | /* Read Drive speed in kbytes/second MSB/LSB */ | 224 | /* Read Drive speed in kbytes/second MSB/LSB */ |
225 | rq.cmd[2] = (speed >> 8) & 0xff; | 225 | cmd[2] = (speed >> 8) & 0xff; |
226 | rq.cmd[3] = speed & 0xff; | 226 | cmd[3] = speed & 0xff; |
227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != | 227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != |
228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { | 228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { |
229 | /* Write Drive speed in kbytes/second MSB/LSB */ | 229 | /* Write Drive speed in kbytes/second MSB/LSB */ |
230 | rq.cmd[4] = (speed >> 8) & 0xff; | 230 | cmd[4] = (speed >> 8) & 0xff; |
231 | rq.cmd[5] = speed & 0xff; | 231 | cmd[5] = speed & 0xff; |
232 | } | 232 | } |
233 | 233 | ||
234 | stat = ide_cd_queue_pc(drive, &rq); | 234 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); |
235 | 235 | ||
236 | if (!ide_cdrom_get_capabilities(drive, buf)) { | 236 | if (!ide_cdrom_get_capabilities(drive, buf)) { |
237 | ide_cdrom_update_speed(drive, buf); | 237 | ide_cdrom_update_speed(drive, buf); |
@@ -268,21 +268,19 @@ int ide_cdrom_get_mcn(struct cdrom_device_info *cdi, | |||
268 | { | 268 | { |
269 | ide_drive_t *drive = cdi->handle; | 269 | ide_drive_t *drive = cdi->handle; |
270 | int stat, mcnlen; | 270 | int stat, mcnlen; |
271 | struct request rq; | ||
272 | char buf[24]; | 271 | char buf[24]; |
272 | unsigned char cmd[BLK_MAX_CDB]; | ||
273 | unsigned len = sizeof(buf); | ||
273 | 274 | ||
274 | ide_cd_init_rq(drive, &rq); | 275 | memset(cmd, 0, BLK_MAX_CDB); |
275 | 276 | ||
276 | rq.data = buf; | 277 | cmd[0] = GPCMD_READ_SUBCHANNEL; |
277 | rq.data_len = sizeof(buf); | 278 | cmd[1] = 2; /* MSF addressing */ |
279 | cmd[2] = 0x40; /* request subQ data */ | ||
280 | cmd[3] = 2; /* format */ | ||
281 | cmd[8] = len; | ||
278 | 282 | ||
279 | rq.cmd[0] = GPCMD_READ_SUBCHANNEL; | 283 | stat = ide_cd_queue_pc(drive, cmd, 0, buf, &len, NULL, 0, 0); |
280 | rq.cmd[1] = 2; /* MSF addressing */ | ||
281 | rq.cmd[2] = 0x40; /* request subQ data */ | ||
282 | rq.cmd[3] = 2; /* format */ | ||
283 | rq.cmd[8] = sizeof(buf); | ||
284 | |||
285 | stat = ide_cd_queue_pc(drive, &rq); | ||
286 | if (stat) | 284 | if (stat) |
287 | return stat; | 285 | return stat; |
288 | 286 | ||
@@ -298,14 +296,14 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi) | |||
298 | ide_drive_t *drive = cdi->handle; | 296 | ide_drive_t *drive = cdi->handle; |
299 | struct cdrom_info *cd = drive->driver_data; | 297 | struct cdrom_info *cd = drive->driver_data; |
300 | struct request_sense sense; | 298 | struct request_sense sense; |
301 | struct request req; | 299 | struct request *rq; |
302 | int ret; | 300 | int ret; |
303 | 301 | ||
304 | ide_cd_init_rq(drive, &req); | 302 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
305 | req.cmd_type = REQ_TYPE_SPECIAL; | 303 | rq->cmd_type = REQ_TYPE_SPECIAL; |
306 | req.cmd_flags = REQ_QUIET; | 304 | rq->cmd_flags = REQ_QUIET; |
307 | ret = ide_do_drive_cmd(drive, &req, ide_wait); | 305 | ret = blk_execute_rq(drive->queue, cd->disk, rq, 0); |
308 | 306 | blk_put_request(rq); | |
309 | /* | 307 | /* |
310 | * A reset will unlock the door. If it was previously locked, | 308 | * A reset will unlock the door. If it was previously locked, |
311 | * lock it again. | 309 | * lock it again. |
@@ -351,8 +349,8 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
351 | struct atapi_toc_entry *first_toc, *last_toc; | 349 | struct atapi_toc_entry *first_toc, *last_toc; |
352 | unsigned long lba_start, lba_end; | 350 | unsigned long lba_start, lba_end; |
353 | int stat; | 351 | int stat; |
354 | struct request rq; | ||
355 | struct request_sense sense; | 352 | struct request_sense sense; |
353 | unsigned char cmd[BLK_MAX_CDB]; | ||
356 | 354 | ||
357 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); | 355 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); |
358 | if (stat) | 356 | if (stat) |
@@ -370,14 +368,13 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
370 | if (lba_end <= lba_start) | 368 | if (lba_end <= lba_start) |
371 | return -EINVAL; | 369 | return -EINVAL; |
372 | 370 | ||
373 | ide_cd_init_rq(drive, &rq); | 371 | memset(cmd, 0, BLK_MAX_CDB); |
374 | 372 | ||
375 | rq.sense = &sense; | 373 | cmd[0] = GPCMD_PLAY_AUDIO_MSF; |
376 | rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; | 374 | lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]); |
377 | lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); | 375 | lba_to_msf(lba_end - 1, &cmd[6], &cmd[7], &cmd[8]); |
378 | lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]); | ||
379 | 376 | ||
380 | return ide_cd_queue_pc(drive, &rq); | 377 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); |
381 | } | 378 | } |
382 | 379 | ||
383 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) | 380 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) |
@@ -447,8 +444,9 @@ int ide_cdrom_audio_ioctl(struct cdrom_device_info *cdi, | |||
447 | int ide_cdrom_packet(struct cdrom_device_info *cdi, | 444 | int ide_cdrom_packet(struct cdrom_device_info *cdi, |
448 | struct packet_command *cgc) | 445 | struct packet_command *cgc) |
449 | { | 446 | { |
450 | struct request req; | ||
451 | ide_drive_t *drive = cdi->handle; | 447 | ide_drive_t *drive = cdi->handle; |
448 | unsigned int flags = 0; | ||
449 | unsigned len = cgc->buflen; | ||
452 | 450 | ||
453 | if (cgc->timeout <= 0) | 451 | if (cgc->timeout <= 0) |
454 | cgc->timeout = ATAPI_WAIT_PC; | 452 | cgc->timeout = ATAPI_WAIT_PC; |
@@ -456,24 +454,21 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
456 | /* here we queue the commands from the uniform CD-ROM | 454 | /* here we queue the commands from the uniform CD-ROM |
457 | layer. the packet must be complete, as we do not | 455 | layer. the packet must be complete, as we do not |
458 | touch it at all. */ | 456 | touch it at all. */ |
459 | ide_cd_init_rq(drive, &req); | ||
460 | 457 | ||
461 | if (cgc->data_direction == CGC_DATA_WRITE) | 458 | if (cgc->data_direction == CGC_DATA_WRITE) |
462 | req.cmd_flags |= REQ_RW; | 459 | flags |= REQ_RW; |
463 | 460 | ||
464 | memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); | ||
465 | if (cgc->sense) | 461 | if (cgc->sense) |
466 | memset(cgc->sense, 0, sizeof(struct request_sense)); | 462 | memset(cgc->sense, 0, sizeof(struct request_sense)); |
467 | req.data = cgc->buffer; | ||
468 | req.data_len = cgc->buflen; | ||
469 | req.timeout = cgc->timeout; | ||
470 | 463 | ||
471 | if (cgc->quiet) | 464 | if (cgc->quiet) |
472 | req.cmd_flags |= REQ_QUIET; | 465 | flags |= REQ_QUIET; |
473 | 466 | ||
474 | req.sense = cgc->sense; | 467 | cgc->stat = ide_cd_queue_pc(drive, cgc->cmd, |
475 | cgc->stat = ide_cd_queue_pc(drive, &req); | 468 | cgc->data_direction == CGC_DATA_WRITE, |
469 | cgc->buffer, &len, | ||
470 | cgc->sense, cgc->timeout, flags); | ||
476 | if (!cgc->stat) | 471 | if (!cgc->stat) |
477 | cgc->buflen -= req.data_len; | 472 | cgc->buflen -= len; |
478 | return cgc->stat; | 473 | return cgc->stat; |
479 | } | 474 | } |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 8e08d083fce9..5f49a4ae9dd8 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -198,8 +198,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
198 | } | 198 | } |
199 | 199 | ||
200 | memset(&task, 0, sizeof(task)); | 200 | memset(&task, 0, sizeof(task)); |
201 | task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ | 201 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
202 | task.tf_flags |= (IDE_TFLAG_TF | IDE_TFLAG_DEVICE); | ||
203 | 202 | ||
204 | if (drive->select.b.lba) { | 203 | if (drive->select.b.lba) { |
205 | if (lba48) { | 204 | if (lba48) { |
@@ -617,7 +616,8 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | |||
617 | */ | 616 | */ |
618 | static int set_multcount(ide_drive_t *drive, int arg) | 617 | static int set_multcount(ide_drive_t *drive, int arg) |
619 | { | 618 | { |
620 | struct request rq; | 619 | struct request *rq; |
620 | int error; | ||
621 | 621 | ||
622 | if (arg < 0 || arg > drive->id->max_multsect) | 622 | if (arg < 0 || arg > drive->id->max_multsect) |
623 | return -EINVAL; | 623 | return -EINVAL; |
@@ -625,12 +625,13 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
625 | if (drive->special.b.set_multmode) | 625 | if (drive->special.b.set_multmode) |
626 | return -EBUSY; | 626 | return -EBUSY; |
627 | 627 | ||
628 | ide_init_drive_cmd(&rq); | 628 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
629 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 629 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
630 | 630 | ||
631 | drive->mult_req = arg; | 631 | drive->mult_req = arg; |
632 | drive->special.b.set_multmode = 1; | 632 | drive->special.b.set_multmode = 1; |
633 | (void)ide_do_drive_cmd(drive, &rq, ide_wait); | 633 | error = blk_execute_rq(drive->queue, NULL, rq, 0); |
634 | blk_put_request(rq); | ||
634 | 635 | ||
635 | return (drive->mult_count == arg) ? 0 : -EIO; | 636 | return (drive->mult_count == arg) ? 0 : -EIO; |
636 | } | 637 | } |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 653b1ade13d3..7ee44f86bc54 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -463,7 +463,7 @@ int ide_dma_setup(ide_drive_t *drive) | |||
463 | } | 463 | } |
464 | 464 | ||
465 | /* PRD table */ | 465 | /* PRD table */ |
466 | if (hwif->mmio) | 466 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
467 | writel(hwif->dmatable_dma, | 467 | writel(hwif->dmatable_dma, |
468 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); | 468 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); |
469 | else | 469 | else |
@@ -692,7 +692,7 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
692 | ide_hwif_t *hwif = drive->hwif; | 692 | ide_hwif_t *hwif = drive->hwif; |
693 | u8 speed; | 693 | u8 speed; |
694 | 694 | ||
695 | if (noautodma || drive->nodma || (drive->id->capability & 1) == 0) | 695 | if (drive->nodma || (drive->id->capability & 1) == 0) |
696 | return 0; | 696 | return 0; |
697 | 697 | ||
698 | /* consult the list of known "bad" drives */ | 698 | /* consult the list of known "bad" drives */ |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index f05fbc2bd7a8..b3689437269f 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -286,11 +286,12 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
286 | { | 286 | { |
287 | struct ide_floppy_obj *floppy = drive->driver_data; | 287 | struct ide_floppy_obj *floppy = drive->driver_data; |
288 | 288 | ||
289 | ide_init_drive_cmd(rq); | 289 | blk_rq_init(NULL, rq); |
290 | rq->buffer = (char *) pc; | 290 | rq->buffer = (char *) pc; |
291 | rq->cmd_type = REQ_TYPE_SPECIAL; | 291 | rq->cmd_type = REQ_TYPE_SPECIAL; |
292 | rq->cmd_flags |= REQ_PREEMPT; | ||
292 | rq->rq_disk = floppy->disk; | 293 | rq->rq_disk = floppy->disk; |
293 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 294 | ide_do_drive_cmd(drive, rq); |
294 | } | 295 | } |
295 | 296 | ||
296 | static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) | 297 | static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) |
@@ -311,50 +312,41 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) | |||
311 | return (&floppy->rq_stack[floppy->rq_stack_index++]); | 312 | return (&floppy->rq_stack[floppy->rq_stack_index++]); |
312 | } | 313 | } |
313 | 314 | ||
314 | static void idefloppy_request_sense_callback(ide_drive_t *drive) | 315 | static void ide_floppy_callback(ide_drive_t *drive) |
315 | { | 316 | { |
316 | idefloppy_floppy_t *floppy = drive->driver_data; | 317 | idefloppy_floppy_t *floppy = drive->driver_data; |
317 | u8 *buf = floppy->pc->buf; | 318 | struct ide_atapi_pc *pc = floppy->pc; |
319 | int uptodate = pc->error ? 0 : 1; | ||
318 | 320 | ||
319 | debug_log("Reached %s\n", __func__); | 321 | debug_log("Reached %s\n", __func__); |
320 | 322 | ||
321 | if (!floppy->pc->error) { | 323 | if (floppy->failed_pc == pc) |
322 | floppy->sense_key = buf[2] & 0x0F; | 324 | floppy->failed_pc = NULL; |
323 | floppy->asc = buf[12]; | ||
324 | floppy->ascq = buf[13]; | ||
325 | floppy->progress_indication = buf[15] & 0x80 ? | ||
326 | (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; | ||
327 | 325 | ||
328 | if (floppy->failed_pc) | 326 | if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || |
329 | debug_log("pc = %x, sense key = %x, asc = %x," | 327 | (pc->rq && blk_pc_request(pc->rq))) |
330 | " ascq = %x\n", | 328 | uptodate = 1; /* FIXME */ |
331 | floppy->failed_pc->c[0], | 329 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { |
332 | floppy->sense_key, | 330 | u8 *buf = floppy->pc->buf; |
333 | floppy->asc, | ||
334 | floppy->ascq); | ||
335 | else | ||
336 | debug_log("sense key = %x, asc = %x, ascq = %x\n", | ||
337 | floppy->sense_key, | ||
338 | floppy->asc, | ||
339 | floppy->ascq); | ||
340 | 331 | ||
332 | if (!pc->error) { | ||
333 | floppy->sense_key = buf[2] & 0x0F; | ||
334 | floppy->asc = buf[12]; | ||
335 | floppy->ascq = buf[13]; | ||
336 | floppy->progress_indication = buf[15] & 0x80 ? | ||
337 | (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; | ||
341 | 338 | ||
342 | idefloppy_end_request(drive, 1, 0); | 339 | if (floppy->failed_pc) |
343 | } else { | 340 | debug_log("pc = %x, ", floppy->failed_pc->c[0]); |
344 | printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting" | ||
345 | " request!\n"); | ||
346 | idefloppy_end_request(drive, 0, 0); | ||
347 | } | ||
348 | } | ||
349 | 341 | ||
350 | /* General packet command callback function. */ | 342 | debug_log("sense key = %x, asc = %x, ascq = %x\n", |
351 | static void idefloppy_pc_callback(ide_drive_t *drive) | 343 | floppy->sense_key, floppy->asc, floppy->ascq); |
352 | { | 344 | } else |
353 | idefloppy_floppy_t *floppy = drive->driver_data; | 345 | printk(KERN_ERR "Error in REQUEST SENSE itself - " |
354 | 346 | "Aborting request!\n"); | |
355 | debug_log("Reached %s\n", __func__); | 347 | } |
356 | 348 | ||
357 | idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0); | 349 | idefloppy_end_request(drive, uptodate, 0); |
358 | } | 350 | } |
359 | 351 | ||
360 | static void idefloppy_init_pc(struct ide_atapi_pc *pc) | 352 | static void idefloppy_init_pc(struct ide_atapi_pc *pc) |
@@ -365,7 +357,7 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc) | |||
365 | pc->req_xfer = 0; | 357 | pc->req_xfer = 0; |
366 | pc->buf = pc->pc_buf; | 358 | pc->buf = pc->pc_buf; |
367 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; | 359 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; |
368 | pc->idefloppy_callback = &idefloppy_pc_callback; | 360 | pc->callback = ide_floppy_callback; |
369 | } | 361 | } |
370 | 362 | ||
371 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | 363 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) |
@@ -374,7 +366,6 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
374 | pc->c[0] = GPCMD_REQUEST_SENSE; | 366 | pc->c[0] = GPCMD_REQUEST_SENSE; |
375 | pc->c[4] = 255; | 367 | pc->c[4] = 255; |
376 | pc->req_xfer = 18; | 368 | pc->req_xfer = 18; |
377 | pc->idefloppy_callback = &idefloppy_request_sense_callback; | ||
378 | } | 369 | } |
379 | 370 | ||
380 | /* | 371 | /* |
@@ -397,174 +388,19 @@ static void idefloppy_retry_pc(ide_drive_t *drive) | |||
397 | static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) | 388 | static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) |
398 | { | 389 | { |
399 | idefloppy_floppy_t *floppy = drive->driver_data; | 390 | idefloppy_floppy_t *floppy = drive->driver_data; |
400 | ide_hwif_t *hwif = drive->hwif; | ||
401 | struct ide_atapi_pc *pc = floppy->pc; | ||
402 | struct request *rq = pc->rq; | ||
403 | xfer_func_t *xferfunc; | ||
404 | unsigned int temp; | ||
405 | int dma_error = 0; | ||
406 | u16 bcount; | ||
407 | u8 stat, ireason; | ||
408 | |||
409 | debug_log("Reached %s interrupt handler\n", __func__); | ||
410 | |||
411 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
412 | dma_error = hwif->dma_ops->dma_end(drive); | ||
413 | if (dma_error) { | ||
414 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | ||
415 | rq_data_dir(rq) ? "write" : "read"); | ||
416 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
417 | } else { | ||
418 | pc->xferred = pc->req_xfer; | ||
419 | idefloppy_update_buffers(drive, pc); | ||
420 | } | ||
421 | debug_log("DMA finished\n"); | ||
422 | } | ||
423 | |||
424 | /* Clear the interrupt */ | ||
425 | stat = ide_read_status(drive); | ||
426 | |||
427 | /* No more interrupts */ | ||
428 | if ((stat & DRQ_STAT) == 0) { | ||
429 | debug_log("Packet command completed, %d bytes transferred\n", | ||
430 | pc->xferred); | ||
431 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
432 | |||
433 | local_irq_enable_in_hardirq(); | ||
434 | |||
435 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | ||
436 | /* Error detected */ | ||
437 | debug_log("%s: I/O error\n", drive->name); | ||
438 | rq->errors++; | ||
439 | if (pc->c[0] == GPCMD_REQUEST_SENSE) { | ||
440 | printk(KERN_ERR "ide-floppy: I/O error in " | ||
441 | "request sense command\n"); | ||
442 | return ide_do_reset(drive); | ||
443 | } | ||
444 | /* Retry operation */ | ||
445 | idefloppy_retry_pc(drive); | ||
446 | /* queued, but not started */ | ||
447 | return ide_stopped; | ||
448 | } | ||
449 | pc->error = 0; | ||
450 | if (floppy->failed_pc == pc) | ||
451 | floppy->failed_pc = NULL; | ||
452 | /* Command finished - Call the callback function */ | ||
453 | pc->idefloppy_callback(drive); | ||
454 | return ide_stopped; | ||
455 | } | ||
456 | |||
457 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
458 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
459 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " | ||
460 | "more interrupts in DMA mode\n"); | ||
461 | ide_dma_off(drive); | ||
462 | return ide_do_reset(drive); | ||
463 | } | ||
464 | |||
465 | /* Get the number of bytes to transfer */ | ||
466 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
467 | hwif->INB(hwif->io_ports.lbam_addr); | ||
468 | /* on this interrupt */ | ||
469 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
470 | |||
471 | if (ireason & CD) { | ||
472 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); | ||
473 | return ide_do_reset(drive); | ||
474 | } | ||
475 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | ||
476 | /* Hopefully, we will never get here */ | ||
477 | printk(KERN_ERR "ide-floppy: We wanted to %s, ", | ||
478 | (ireason & IO) ? "Write" : "Read"); | ||
479 | printk(KERN_ERR "but the floppy wants us to %s !\n", | ||
480 | (ireason & IO) ? "Read" : "Write"); | ||
481 | return ide_do_reset(drive); | ||
482 | } | ||
483 | if (!(pc->flags & PC_FLAG_WRITING)) { | ||
484 | /* Reading - Check that we have enough space */ | ||
485 | temp = pc->xferred + bcount; | ||
486 | if (temp > pc->req_xfer) { | ||
487 | if (temp > pc->buf_size) { | ||
488 | printk(KERN_ERR "ide-floppy: The floppy wants " | ||
489 | "to send us more data than expected " | ||
490 | "- discarding data\n"); | ||
491 | ide_pad_transfer(drive, 0, bcount); | ||
492 | |||
493 | ide_set_handler(drive, | ||
494 | &idefloppy_pc_intr, | ||
495 | IDEFLOPPY_WAIT_CMD, | ||
496 | NULL); | ||
497 | return ide_started; | ||
498 | } | ||
499 | debug_log("The floppy wants to send us more data than" | ||
500 | " expected - allowing transfer\n"); | ||
501 | } | ||
502 | } | ||
503 | if (pc->flags & PC_FLAG_WRITING) | ||
504 | xferfunc = hwif->output_data; | ||
505 | else | ||
506 | xferfunc = hwif->input_data; | ||
507 | |||
508 | if (pc->buf) | ||
509 | xferfunc(drive, NULL, pc->cur_pos, bcount); | ||
510 | else | ||
511 | ide_floppy_io_buffers(drive, pc, bcount, | ||
512 | !!(pc->flags & PC_FLAG_WRITING)); | ||
513 | |||
514 | /* Update the current position */ | ||
515 | pc->xferred += bcount; | ||
516 | pc->cur_pos += bcount; | ||
517 | |||
518 | /* And set the interrupt handler again */ | ||
519 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); | ||
520 | return ide_started; | ||
521 | } | ||
522 | |||
523 | /* | ||
524 | * This is the original routine that did the packet transfer. | ||
525 | * It fails at high speeds on the Iomega ZIP drive, so there's a slower version | ||
526 | * for that drive below. The algorithm is chosen based on drive type | ||
527 | */ | ||
528 | static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) | ||
529 | { | ||
530 | ide_hwif_t *hwif = drive->hwif; | ||
531 | ide_startstop_t startstop; | ||
532 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
533 | u8 ireason; | ||
534 | |||
535 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
536 | printk(KERN_ERR "ide-floppy: Strange, packet command " | ||
537 | "initiated yet DRQ isn't asserted\n"); | ||
538 | return startstop; | ||
539 | } | ||
540 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
541 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
542 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " | ||
543 | "issuing a packet command\n"); | ||
544 | return ide_do_reset(drive); | ||
545 | } | ||
546 | 391 | ||
547 | /* Set the interrupt routine */ | 392 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, |
548 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); | 393 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, |
549 | 394 | idefloppy_retry_pc, NULL, ide_floppy_io_buffers); | |
550 | /* Send the actual packet */ | ||
551 | hwif->output_data(drive, NULL, floppy->pc->c, 12); | ||
552 | |||
553 | return ide_started; | ||
554 | } | 395 | } |
555 | 396 | ||
556 | |||
557 | /* | 397 | /* |
558 | * What we have here is a classic case of a top half / bottom half interrupt | 398 | * What we have here is a classic case of a top half / bottom half interrupt |
559 | * service routine. In interrupt mode, the device sends an interrupt to signal | 399 | * service routine. In interrupt mode, the device sends an interrupt to signal |
560 | * that it is ready to receive a packet. However, we need to delay about 2-3 | 400 | * that it is ready to receive a packet. However, we need to delay about 2-3 |
561 | * ticks before issuing the packet or we gets in trouble. | 401 | * ticks before issuing the packet or we gets in trouble. |
562 | * | ||
563 | * So, follow carefully. transfer_pc1 is called as an interrupt (or directly). | ||
564 | * In either case, when the device says it's ready for a packet, we schedule | ||
565 | * the packet transfer to occur about 2-3 ticks later in transfer_pc2. | ||
566 | */ | 402 | */ |
567 | static int idefloppy_transfer_pc2(ide_drive_t *drive) | 403 | static int idefloppy_transfer_pc(ide_drive_t *drive) |
568 | { | 404 | { |
569 | idefloppy_floppy_t *floppy = drive->driver_data; | 405 | idefloppy_floppy_t *floppy = drive->driver_data; |
570 | 406 | ||
@@ -575,24 +411,19 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive) | |||
575 | return IDEFLOPPY_WAIT_CMD; | 411 | return IDEFLOPPY_WAIT_CMD; |
576 | } | 412 | } |
577 | 413 | ||
578 | static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) | 414 | |
415 | /* | ||
416 | * Called as an interrupt (or directly). When the device says it's ready for a | ||
417 | * packet, we schedule the packet transfer to occur about 2-3 ticks later in | ||
418 | * transfer_pc. | ||
419 | */ | ||
420 | static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive) | ||
579 | { | 421 | { |
580 | ide_hwif_t *hwif = drive->hwif; | ||
581 | idefloppy_floppy_t *floppy = drive->driver_data; | 422 | idefloppy_floppy_t *floppy = drive->driver_data; |
582 | ide_startstop_t startstop; | 423 | struct ide_atapi_pc *pc = floppy->pc; |
583 | u8 ireason; | 424 | ide_expiry_t *expiry; |
425 | unsigned int timeout; | ||
584 | 426 | ||
585 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
586 | printk(KERN_ERR "ide-floppy: Strange, packet command " | ||
587 | "initiated yet DRQ isn't asserted\n"); | ||
588 | return startstop; | ||
589 | } | ||
590 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
591 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
592 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " | ||
593 | "while issuing a packet command\n"); | ||
594 | return ide_do_reset(drive); | ||
595 | } | ||
596 | /* | 427 | /* |
597 | * The following delay solves a problem with ATAPI Zip 100 drives | 428 | * The following delay solves a problem with ATAPI Zip 100 drives |
598 | * where the Busy flag was apparently being deasserted before the | 429 | * where the Busy flag was apparently being deasserted before the |
@@ -601,10 +432,15 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) | |||
601 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually | 432 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually |
602 | * used until after the packet is moved in about 50 msec. | 433 | * used until after the packet is moved in about 50 msec. |
603 | */ | 434 | */ |
435 | if (pc->flags & PC_FLAG_ZIP_DRIVE) { | ||
436 | timeout = floppy->ticks; | ||
437 | expiry = &idefloppy_transfer_pc; | ||
438 | } else { | ||
439 | timeout = IDEFLOPPY_WAIT_CMD; | ||
440 | expiry = NULL; | ||
441 | } | ||
604 | 442 | ||
605 | ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, | 443 | return ide_transfer_pc(drive, pc, idefloppy_pc_intr, timeout, expiry); |
606 | &idefloppy_transfer_pc2); | ||
607 | return ide_started; | ||
608 | } | 444 | } |
609 | 445 | ||
610 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, | 446 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, |
@@ -627,10 +463,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
627 | struct ide_atapi_pc *pc) | 463 | struct ide_atapi_pc *pc) |
628 | { | 464 | { |
629 | idefloppy_floppy_t *floppy = drive->driver_data; | 465 | idefloppy_floppy_t *floppy = drive->driver_data; |
630 | ide_hwif_t *hwif = drive->hwif; | ||
631 | ide_handler_t *pkt_xfer_routine; | ||
632 | u16 bcount; | ||
633 | u8 dma; | ||
634 | 466 | ||
635 | if (floppy->failed_pc == NULL && | 467 | if (floppy->failed_pc == NULL && |
636 | pc->c[0] != GPCMD_REQUEST_SENSE) | 468 | pc->c[0] != GPCMD_REQUEST_SENSE) |
@@ -645,65 +477,16 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
645 | pc->error = IDEFLOPPY_ERROR_GENERAL; | 477 | pc->error = IDEFLOPPY_ERROR_GENERAL; |
646 | 478 | ||
647 | floppy->failed_pc = NULL; | 479 | floppy->failed_pc = NULL; |
648 | pc->idefloppy_callback(drive); | 480 | pc->callback(drive); |
649 | return ide_stopped; | 481 | return ide_stopped; |
650 | } | 482 | } |
651 | 483 | ||
652 | debug_log("Retry number - %d\n", pc->retries); | 484 | debug_log("Retry number - %d\n", pc->retries); |
653 | 485 | ||
654 | pc->retries++; | 486 | pc->retries++; |
655 | /* We haven't transferred any data yet */ | ||
656 | pc->xferred = 0; | ||
657 | pc->cur_pos = pc->buf; | ||
658 | bcount = min(pc->req_xfer, 63 * 1024); | ||
659 | |||
660 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
661 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
662 | ide_dma_off(drive); | ||
663 | } | ||
664 | dma = 0; | ||
665 | |||
666 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | ||
667 | dma = !hwif->dma_ops->dma_setup(drive); | ||
668 | 487 | ||
669 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 488 | return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer, |
670 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | 489 | IDEFLOPPY_WAIT_CMD, NULL); |
671 | |||
672 | if (dma) { | ||
673 | /* Begin DMA, if necessary */ | ||
674 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
675 | hwif->dma_ops->dma_start(drive); | ||
676 | } | ||
677 | |||
678 | /* Can we transfer the packet when we get the interrupt or wait? */ | ||
679 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) { | ||
680 | /* wait */ | ||
681 | pkt_xfer_routine = &idefloppy_transfer_pc1; | ||
682 | } else { | ||
683 | /* immediate */ | ||
684 | pkt_xfer_routine = &idefloppy_transfer_pc; | ||
685 | } | ||
686 | |||
687 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { | ||
688 | /* Issue the packet command */ | ||
689 | ide_execute_command(drive, WIN_PACKETCMD, | ||
690 | pkt_xfer_routine, | ||
691 | IDEFLOPPY_WAIT_CMD, | ||
692 | NULL); | ||
693 | return ide_started; | ||
694 | } else { | ||
695 | /* Issue the packet command */ | ||
696 | ide_execute_pkt_cmd(drive); | ||
697 | return (*pkt_xfer_routine) (drive); | ||
698 | } | ||
699 | } | ||
700 | |||
701 | static void idefloppy_rw_callback(ide_drive_t *drive) | ||
702 | { | ||
703 | debug_log("Reached %s\n", __func__); | ||
704 | |||
705 | idefloppy_end_request(drive, 1, 0); | ||
706 | return; | ||
707 | } | 490 | } |
708 | 491 | ||
709 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) | 492 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) |
@@ -800,21 +583,19 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
800 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); | 583 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
801 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); | 584 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
802 | 585 | ||
803 | pc->idefloppy_callback = &idefloppy_rw_callback; | ||
804 | pc->rq = rq; | 586 | pc->rq = rq; |
805 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 587 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; |
806 | if (rq->cmd_flags & REQ_RW) | 588 | if (rq->cmd_flags & REQ_RW) |
807 | pc->flags |= PC_FLAG_WRITING; | 589 | pc->flags |= PC_FLAG_WRITING; |
808 | pc->buf = NULL; | 590 | pc->buf = NULL; |
809 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; | 591 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; |
810 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 592 | pc->flags |= PC_FLAG_DMA_OK; |
811 | } | 593 | } |
812 | 594 | ||
813 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, | 595 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, |
814 | struct ide_atapi_pc *pc, struct request *rq) | 596 | struct ide_atapi_pc *pc, struct request *rq) |
815 | { | 597 | { |
816 | idefloppy_init_pc(pc); | 598 | idefloppy_init_pc(pc); |
817 | pc->idefloppy_callback = &idefloppy_rw_callback; | ||
818 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); | 599 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); |
819 | pc->rq = rq; | 600 | pc->rq = rq; |
820 | pc->b_count = rq->data_len; | 601 | pc->b_count = rq->data_len; |
@@ -822,7 +603,7 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, | |||
822 | pc->flags |= PC_FLAG_WRITING; | 603 | pc->flags |= PC_FLAG_WRITING; |
823 | pc->buf = rq->data; | 604 | pc->buf = rq->data; |
824 | if (rq->bio) | 605 | if (rq->bio) |
825 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 606 | pc->flags |= PC_FLAG_DMA_OK; |
826 | /* | 607 | /* |
827 | * possibly problematic, doesn't look like ide-floppy correctly | 608 | * possibly problematic, doesn't look like ide-floppy correctly |
828 | * handled scattered requests if dma fails... | 609 | * handled scattered requests if dma fails... |
@@ -875,7 +656,14 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
875 | return ide_stopped; | 656 | return ide_stopped; |
876 | } | 657 | } |
877 | 658 | ||
659 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) | ||
660 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
661 | |||
662 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) | ||
663 | pc->flags |= PC_FLAG_ZIP_DRIVE; | ||
664 | |||
878 | pc->rq = rq; | 665 | pc->rq = rq; |
666 | |||
879 | return idefloppy_issue_pc(drive, pc); | 667 | return idefloppy_issue_pc(drive, pc); |
880 | } | 668 | } |
881 | 669 | ||
@@ -886,14 +674,16 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
886 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | 674 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
887 | { | 675 | { |
888 | struct ide_floppy_obj *floppy = drive->driver_data; | 676 | struct ide_floppy_obj *floppy = drive->driver_data; |
889 | struct request rq; | 677 | struct request *rq; |
678 | int error; | ||
890 | 679 | ||
891 | ide_init_drive_cmd(&rq); | 680 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
892 | rq.buffer = (char *) pc; | 681 | rq->buffer = (char *) pc; |
893 | rq.cmd_type = REQ_TYPE_SPECIAL; | 682 | rq->cmd_type = REQ_TYPE_SPECIAL; |
894 | rq.rq_disk = floppy->disk; | 683 | error = blk_execute_rq(drive->queue, floppy->disk, rq, 0); |
684 | blk_put_request(rq); | ||
895 | 685 | ||
896 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 686 | return error; |
897 | } | 687 | } |
898 | 688 | ||
899 | /* | 689 | /* |
@@ -1622,11 +1412,6 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
1622 | " of ide-floppy\n", drive->name); | 1412 | " of ide-floppy\n", drive->name); |
1623 | goto failed; | 1413 | goto failed; |
1624 | } | 1414 | } |
1625 | if (drive->scsi) { | ||
1626 | printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi" | ||
1627 | " emulation.\n", drive->name); | ||
1628 | goto failed; | ||
1629 | } | ||
1630 | floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); | 1415 | floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); |
1631 | if (!floppy) { | 1416 | if (!floppy) { |
1632 | printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" | 1417 | printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 696525342e9a..28057747c1f8 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -358,31 +358,6 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | |||
358 | 358 | ||
359 | EXPORT_SYMBOL(ide_end_drive_cmd); | 359 | EXPORT_SYMBOL(ide_end_drive_cmd); |
360 | 360 | ||
361 | /** | ||
362 | * try_to_flush_leftover_data - flush junk | ||
363 | * @drive: drive to flush | ||
364 | * | ||
365 | * try_to_flush_leftover_data() is invoked in response to a drive | ||
366 | * unexpectedly having its DRQ_STAT bit set. As an alternative to | ||
367 | * resetting the drive, this routine tries to clear the condition | ||
368 | * by read a sector's worth of data from the drive. Of course, | ||
369 | * this may not help if the drive is *waiting* for data from *us*. | ||
370 | */ | ||
371 | static void try_to_flush_leftover_data (ide_drive_t *drive) | ||
372 | { | ||
373 | int i = (drive->mult_count ? drive->mult_count : 1) * SECTOR_WORDS; | ||
374 | |||
375 | if (drive->media != ide_disk) | ||
376 | return; | ||
377 | while (i > 0) { | ||
378 | u32 buffer[16]; | ||
379 | u32 wcount = (i > 16) ? 16 : i; | ||
380 | |||
381 | i -= wcount; | ||
382 | drive->hwif->input_data(drive, NULL, buffer, wcount * 4); | ||
383 | } | ||
384 | } | ||
385 | |||
386 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) | 361 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) |
387 | { | 362 | { |
388 | if (rq->rq_disk) { | 363 | if (rq->rq_disk) { |
@@ -422,8 +397,11 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
422 | } | 397 | } |
423 | 398 | ||
424 | if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && | 399 | if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && |
425 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) | 400 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) { |
426 | try_to_flush_leftover_data(drive); | 401 | int nsect = drive->mult_count ? drive->mult_count : 1; |
402 | |||
403 | ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE); | ||
404 | } | ||
427 | 405 | ||
428 | if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { | 406 | if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { |
429 | ide_kill_rq(drive, rq); | 407 | ide_kill_rq(drive, rq); |
@@ -459,7 +437,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u | |||
459 | 437 | ||
460 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) | 438 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) |
461 | /* force an abort */ | 439 | /* force an abort */ |
462 | hwif->OUTBSYNC(drive, WIN_IDLEIMMEDIATE, | 440 | hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE, |
463 | hwif->io_ports.command_addr); | 441 | hwif->io_ports.command_addr); |
464 | 442 | ||
465 | if (rq->errors >= ERROR_MAX) { | 443 | if (rq->errors >= ERROR_MAX) { |
@@ -1539,88 +1517,30 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1539 | } | 1517 | } |
1540 | 1518 | ||
1541 | /** | 1519 | /** |
1542 | * ide_init_drive_cmd - initialize a drive command request | ||
1543 | * @rq: request object | ||
1544 | * | ||
1545 | * Initialize a request before we fill it in and send it down to | ||
1546 | * ide_do_drive_cmd. Commands must be set up by this function. Right | ||
1547 | * now it doesn't do a lot, but if that changes abusers will have a | ||
1548 | * nasty surprise. | ||
1549 | */ | ||
1550 | |||
1551 | void ide_init_drive_cmd (struct request *rq) | ||
1552 | { | ||
1553 | blk_rq_init(NULL, rq); | ||
1554 | } | ||
1555 | |||
1556 | EXPORT_SYMBOL(ide_init_drive_cmd); | ||
1557 | |||
1558 | /** | ||
1559 | * ide_do_drive_cmd - issue IDE special command | 1520 | * ide_do_drive_cmd - issue IDE special command |
1560 | * @drive: device to issue command | 1521 | * @drive: device to issue command |
1561 | * @rq: request to issue | 1522 | * @rq: request to issue |
1562 | * @action: action for processing | ||
1563 | * | 1523 | * |
1564 | * This function issues a special IDE device request | 1524 | * This function issues a special IDE device request |
1565 | * onto the request queue. | 1525 | * onto the request queue. |
1566 | * | 1526 | * |
1567 | * If action is ide_wait, then the rq is queued at the end of the | 1527 | * the rq is queued at the head of the request queue, displacing |
1568 | * request queue, and the function sleeps until it has been processed. | 1528 | * the currently-being-processed request and this function |
1569 | * This is for use when invoked from an ioctl handler. | 1529 | * returns immediately without waiting for the new rq to be |
1570 | * | 1530 | * completed. This is VERY DANGEROUS, and is intended for |
1571 | * If action is ide_preempt, then the rq is queued at the head of | 1531 | * careful use by the ATAPI tape/cdrom driver code. |
1572 | * the request queue, displacing the currently-being-processed | ||
1573 | * request and this function returns immediately without waiting | ||
1574 | * for the new rq to be completed. This is VERY DANGEROUS, and is | ||
1575 | * intended for careful use by the ATAPI tape/cdrom driver code. | ||
1576 | * | ||
1577 | * If action is ide_end, then the rq is queued at the end of the | ||
1578 | * request queue, and the function returns immediately without waiting | ||
1579 | * for the new rq to be completed. This is again intended for careful | ||
1580 | * use by the ATAPI tape/cdrom driver code. | ||
1581 | */ | 1532 | */ |
1582 | 1533 | ||
1583 | int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action) | 1534 | void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq) |
1584 | { | 1535 | { |
1585 | unsigned long flags; | 1536 | unsigned long flags; |
1586 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 1537 | ide_hwgroup_t *hwgroup = HWGROUP(drive); |
1587 | DECLARE_COMPLETION_ONSTACK(wait); | ||
1588 | int where = ELEVATOR_INSERT_BACK, err; | ||
1589 | int must_wait = (action == ide_wait || action == ide_head_wait); | ||
1590 | |||
1591 | rq->errors = 0; | ||
1592 | |||
1593 | /* | ||
1594 | * we need to hold an extra reference to request for safe inspection | ||
1595 | * after completion | ||
1596 | */ | ||
1597 | if (must_wait) { | ||
1598 | rq->ref_count++; | ||
1599 | rq->end_io_data = &wait; | ||
1600 | rq->end_io = blk_end_sync_rq; | ||
1601 | } | ||
1602 | 1538 | ||
1603 | spin_lock_irqsave(&ide_lock, flags); | 1539 | spin_lock_irqsave(&ide_lock, flags); |
1604 | if (action == ide_preempt) | 1540 | hwgroup->rq = NULL; |
1605 | hwgroup->rq = NULL; | 1541 | __elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 1); |
1606 | if (action == ide_preempt || action == ide_head_wait) { | 1542 | __generic_unplug_device(drive->queue); |
1607 | where = ELEVATOR_INSERT_FRONT; | ||
1608 | rq->cmd_flags |= REQ_PREEMPT; | ||
1609 | } | ||
1610 | __elv_add_request(drive->queue, rq, where, 0); | ||
1611 | ide_do_request(hwgroup, IDE_NO_IRQ); | ||
1612 | spin_unlock_irqrestore(&ide_lock, flags); | 1543 | spin_unlock_irqrestore(&ide_lock, flags); |
1613 | |||
1614 | err = 0; | ||
1615 | if (must_wait) { | ||
1616 | wait_for_completion(&wait); | ||
1617 | if (rq->errors) | ||
1618 | err = -EIO; | ||
1619 | |||
1620 | blk_put_request(rq); | ||
1621 | } | ||
1622 | |||
1623 | return err; | ||
1624 | } | 1544 | } |
1625 | 1545 | ||
1626 | EXPORT_SYMBOL(ide_do_drive_cmd); | 1546 | EXPORT_SYMBOL(ide_do_drive_cmd); |
@@ -1637,6 +1557,8 @@ void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) | |||
1637 | task.tf.lbah = (bcount >> 8) & 0xff; | 1557 | task.tf.lbah = (bcount >> 8) & 0xff; |
1638 | 1558 | ||
1639 | ide_tf_dump(drive->name, &task.tf); | 1559 | ide_tf_dump(drive->name, &task.tf); |
1560 | ide_set_irq(drive, 1); | ||
1561 | SELECT_MASK(drive, 0); | ||
1640 | drive->hwif->tf_load(drive, &task); | 1562 | drive->hwif->tf_load(drive, &task); |
1641 | } | 1563 | } |
1642 | 1564 | ||
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 0daf923541ff..80ad4f234f3f 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -42,7 +42,7 @@ static void ide_outb (u8 val, unsigned long port) | |||
42 | outb(val, port); | 42 | outb(val, port); |
43 | } | 43 | } |
44 | 44 | ||
45 | static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) | 45 | static void ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port) |
46 | { | 46 | { |
47 | outb(addr, port); | 47 | outb(addr, port); |
48 | } | 48 | } |
@@ -68,7 +68,7 @@ static void ide_mm_outb (u8 value, unsigned long port) | |||
68 | writeb(value, (void __iomem *) port); | 68 | writeb(value, (void __iomem *) port); |
69 | } | 69 | } |
70 | 70 | ||
71 | static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port) | 71 | static void ide_mm_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) |
72 | { | 72 | { |
73 | writeb(value, (void __iomem *) port); | 73 | writeb(value, (void __iomem *) port); |
74 | } | 74 | } |
@@ -95,7 +95,7 @@ void SELECT_DRIVE (ide_drive_t *drive) | |||
95 | hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); | 95 | hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); |
96 | } | 96 | } |
97 | 97 | ||
98 | static void SELECT_MASK(ide_drive_t *drive, int mask) | 98 | void SELECT_MASK(ide_drive_t *drive, int mask) |
99 | { | 99 | { |
100 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; | 100 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; |
101 | 101 | ||
@@ -120,11 +120,6 @@ static void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
120 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | 120 | if (task->tf_flags & IDE_TFLAG_FLAGGED) |
121 | HIHI = 0xFF; | 121 | HIHI = 0xFF; |
122 | 122 | ||
123 | ide_set_irq(drive, 1); | ||
124 | |||
125 | if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0) | ||
126 | SELECT_MASK(drive, 0); | ||
127 | |||
128 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { | 123 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { |
129 | u16 data = (tf->hob_data << 8) | tf->data; | 124 | u16 data = (tf->hob_data << 8) | tf->data; |
130 | 125 | ||
@@ -191,7 +186,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
191 | } | 186 | } |
192 | 187 | ||
193 | /* be sure we're looking at the low order bits */ | 188 | /* be sure we're looking at the low order bits */ |
194 | tf_outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 189 | tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
195 | 190 | ||
196 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 191 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
197 | tf->nsect = tf_inb(io_ports->nsect_addr); | 192 | tf->nsect = tf_inb(io_ports->nsect_addr); |
@@ -205,7 +200,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
205 | tf->device = tf_inb(io_ports->device_addr); | 200 | tf->device = tf_inb(io_ports->device_addr); |
206 | 201 | ||
207 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 202 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
208 | tf_outb(drive->ctl | 0x80, io_ports->ctl_addr); | 203 | tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
209 | 204 | ||
210 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 205 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
211 | tf->hob_feature = tf_inb(io_ports->feature_addr); | 206 | tf->hob_feature = tf_inb(io_ports->feature_addr); |
@@ -689,9 +684,9 @@ int ide_driveid_update(ide_drive_t *drive) | |||
689 | */ | 684 | */ |
690 | 685 | ||
691 | SELECT_MASK(drive, 1); | 686 | SELECT_MASK(drive, 1); |
692 | ide_set_irq(drive, 1); | 687 | ide_set_irq(drive, 0); |
693 | msleep(50); | 688 | msleep(50); |
694 | hwif->OUTBSYNC(drive, WIN_IDENTIFY, hwif->io_ports.command_addr); | 689 | hwif->OUTBSYNC(hwif, WIN_IDENTIFY, hwif->io_ports.command_addr); |
695 | timeout = jiffies + WAIT_WORSTCASE; | 690 | timeout = jiffies + WAIT_WORSTCASE; |
696 | do { | 691 | do { |
697 | if (time_after(jiffies, timeout)) { | 692 | if (time_after(jiffies, timeout)) { |
@@ -744,9 +739,6 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
744 | int error = 0; | 739 | int error = 0; |
745 | u8 stat; | 740 | u8 stat; |
746 | 741 | ||
747 | // while (HWGROUP(drive)->busy) | ||
748 | // msleep(50); | ||
749 | |||
750 | #ifdef CONFIG_BLK_DEV_IDEDMA | 742 | #ifdef CONFIG_BLK_DEV_IDEDMA |
751 | if (hwif->dma_ops) /* check if host supports DMA */ | 743 | if (hwif->dma_ops) /* check if host supports DMA */ |
752 | hwif->dma_ops->dma_host_set(drive, 0); | 744 | hwif->dma_ops->dma_host_set(drive, 0); |
@@ -781,7 +773,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
781 | ide_set_irq(drive, 0); | 773 | ide_set_irq(drive, 0); |
782 | hwif->OUTB(speed, io_ports->nsect_addr); | 774 | hwif->OUTB(speed, io_ports->nsect_addr); |
783 | hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); | 775 | hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); |
784 | hwif->OUTBSYNC(drive, WIN_SETFEATURES, io_ports->command_addr); | 776 | hwif->OUTBSYNC(hwif, WIN_SETFEATURES, io_ports->command_addr); |
785 | if (drive->quirk_list == 2) | 777 | if (drive->quirk_list == 2) |
786 | ide_set_irq(drive, 1); | 778 | ide_set_irq(drive, 1); |
787 | 779 | ||
@@ -889,7 +881,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
889 | 881 | ||
890 | spin_lock_irqsave(&ide_lock, flags); | 882 | spin_lock_irqsave(&ide_lock, flags); |
891 | __ide_set_handler(drive, handler, timeout, expiry); | 883 | __ide_set_handler(drive, handler, timeout, expiry); |
892 | hwif->OUTBSYNC(drive, cmd, hwif->io_ports.command_addr); | 884 | hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr); |
893 | /* | 885 | /* |
894 | * Drive takes 400nS to respond, we must avoid the IRQ being | 886 | * Drive takes 400nS to respond, we must avoid the IRQ being |
895 | * serviced before that. | 887 | * serviced before that. |
@@ -907,7 +899,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive) | |||
907 | unsigned long flags; | 899 | unsigned long flags; |
908 | 900 | ||
909 | spin_lock_irqsave(&ide_lock, flags); | 901 | spin_lock_irqsave(&ide_lock, flags); |
910 | hwif->OUTBSYNC(drive, WIN_PACKETCMD, hwif->io_ports.command_addr); | 902 | hwif->OUTBSYNC(hwif, WIN_PACKETCMD, hwif->io_ports.command_addr); |
911 | ndelay(400); | 903 | ndelay(400); |
912 | spin_unlock_irqrestore(&ide_lock, flags); | 904 | spin_unlock_irqrestore(&ide_lock, flags); |
913 | } | 905 | } |
@@ -1102,7 +1094,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1102 | pre_reset(drive); | 1094 | pre_reset(drive); |
1103 | SELECT_DRIVE(drive); | 1095 | SELECT_DRIVE(drive); |
1104 | udelay (20); | 1096 | udelay (20); |
1105 | hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); | 1097 | hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr); |
1106 | ndelay(400); | 1098 | ndelay(400); |
1107 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1099 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
1108 | hwgroup->polling = 1; | 1100 | hwgroup->polling = 1; |
@@ -1133,14 +1125,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1133 | * recover from reset very quickly, saving us the first 50ms wait time. | 1125 | * recover from reset very quickly, saving us the first 50ms wait time. |
1134 | */ | 1126 | */ |
1135 | /* set SRST and nIEN */ | 1127 | /* set SRST and nIEN */ |
1136 | hwif->OUTBSYNC(drive, drive->ctl|6, io_ports->ctl_addr); | 1128 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | 6, io_ports->ctl_addr); |
1137 | /* more than enough time */ | 1129 | /* more than enough time */ |
1138 | udelay(10); | 1130 | udelay(10); |
1139 | if (drive->quirk_list == 2) | 1131 | if (drive->quirk_list == 2) |
1140 | ctl = drive->ctl; /* clear SRST and nIEN */ | 1132 | ctl = ATA_DEVCTL_OBS; /* clear SRST and nIEN */ |
1141 | else | 1133 | else |
1142 | ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ | 1134 | ctl = ATA_DEVCTL_OBS | 2; /* clear SRST, leave nIEN */ |
1143 | hwif->OUTBSYNC(drive, ctl, io_ports->ctl_addr); | 1135 | hwif->OUTBSYNC(hwif, ctl, io_ports->ctl_addr); |
1144 | /* more than enough time */ | 1136 | /* more than enough time */ |
1145 | udelay(10); | 1137 | udelay(10); |
1146 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1138 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 26e68b65b7cf..d21e51a02c3e 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -293,7 +293,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
293 | hwif->OUTB(0, io_ports->feature_addr); | 293 | hwif->OUTB(0, io_ports->feature_addr); |
294 | 294 | ||
295 | /* ask drive for ID */ | 295 | /* ask drive for ID */ |
296 | hwif->OUTBSYNC(drive, cmd, io_ports->command_addr); | 296 | hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr); |
297 | 297 | ||
298 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 298 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
299 | timeout += jiffies; | 299 | timeout += jiffies; |
@@ -478,9 +478,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " | 478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " |
479 | "resetting drive\n", drive->name, stat); | 479 | "resetting drive\n", drive->name, stat); |
480 | msleep(50); | 480 | msleep(50); |
481 | hwif->OUTB(drive->select.all, io_ports->device_addr); | 481 | SELECT_DRIVE(drive); |
482 | msleep(50); | 482 | msleep(50); |
483 | hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); | 483 | hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr); |
484 | (void)ide_busy_sleep(hwif); | 484 | (void)ide_busy_sleep(hwif); |
485 | rc = try_to_identify(drive, cmd); | 485 | rc = try_to_identify(drive, cmd); |
486 | } | 486 | } |
@@ -516,7 +516,7 @@ static void enable_nest (ide_drive_t *drive) | |||
516 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 516 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); |
517 | SELECT_DRIVE(drive); | 517 | SELECT_DRIVE(drive); |
518 | msleep(50); | 518 | msleep(50); |
519 | hwif->OUTBSYNC(drive, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); | 519 | hwif->OUTBSYNC(hwif, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); |
520 | 520 | ||
521 | if (ide_busy_sleep(hwif)) { | 521 | if (ide_busy_sleep(hwif)) { |
522 | printk(KERN_CONT "failed (timeout)\n"); | 522 | printk(KERN_CONT "failed (timeout)\n"); |
@@ -1065,7 +1065,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
1065 | 1065 | ||
1066 | if (io_ports->ctl_addr) | 1066 | if (io_ports->ctl_addr) |
1067 | /* clear nIEN */ | 1067 | /* clear nIEN */ |
1068 | hwif->OUTB(0x08, io_ports->ctl_addr); | 1068 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS, io_ports->ctl_addr); |
1069 | 1069 | ||
1070 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) | 1070 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) |
1071 | goto out_unlink; | 1071 | goto out_unlink; |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index a3d228302d20..f9cf1670e4e1 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -144,9 +144,6 @@ enum { | |||
144 | 144 | ||
145 | /*************************** End of tunable parameters ***********************/ | 145 | /*************************** End of tunable parameters ***********************/ |
146 | 146 | ||
147 | /* Read/Write error simulation */ | ||
148 | #define SIMULATE_ERRORS 0 | ||
149 | |||
150 | /* tape directions */ | 147 | /* tape directions */ |
151 | enum { | 148 | enum { |
152 | IDETAPE_DIR_NONE = (1 << 0), | 149 | IDETAPE_DIR_NONE = (1 << 0), |
@@ -442,7 +439,7 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
442 | } | 439 | } |
443 | } | 440 | } |
444 | 441 | ||
445 | static void idetape_update_buffers(struct ide_atapi_pc *pc) | 442 | static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) |
446 | { | 443 | { |
447 | struct idetape_bh *bh = pc->bh; | 444 | struct idetape_bh *bh = pc->bh; |
448 | int count; | 445 | int count; |
@@ -506,18 +503,6 @@ static struct request *idetape_next_rq_storage(ide_drive_t *drive) | |||
506 | return (&tape->rq_stack[tape->rq_stack_index++]); | 503 | return (&tape->rq_stack[tape->rq_stack_index++]); |
507 | } | 504 | } |
508 | 505 | ||
509 | static void idetape_init_pc(struct ide_atapi_pc *pc) | ||
510 | { | ||
511 | memset(pc->c, 0, 12); | ||
512 | pc->retries = 0; | ||
513 | pc->flags = 0; | ||
514 | pc->req_xfer = 0; | ||
515 | pc->buf = pc->pc_buf; | ||
516 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; | ||
517 | pc->bh = NULL; | ||
518 | pc->b_data = NULL; | ||
519 | } | ||
520 | |||
521 | /* | 506 | /* |
522 | * called on each failed packet command retry to analyze the request sense. We | 507 | * called on each failed packet command retry to analyze the request sense. We |
523 | * currently do not utilize this information. | 508 | * currently do not utilize this information. |
@@ -538,8 +523,8 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
538 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 523 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
539 | pc->xferred = pc->req_xfer - | 524 | pc->xferred = pc->req_xfer - |
540 | tape->blk_size * | 525 | tape->blk_size * |
541 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); | 526 | get_unaligned_be32(&sense[3]); |
542 | idetape_update_buffers(pc); | 527 | idetape_update_buffers(drive, pc); |
543 | } | 528 | } |
544 | 529 | ||
545 | /* | 530 | /* |
@@ -634,21 +619,78 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
634 | return 0; | 619 | return 0; |
635 | } | 620 | } |
636 | 621 | ||
637 | static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) | 622 | static void ide_tape_callback(ide_drive_t *drive) |
638 | { | 623 | { |
639 | idetape_tape_t *tape = drive->driver_data; | 624 | idetape_tape_t *tape = drive->driver_data; |
625 | struct ide_atapi_pc *pc = tape->pc; | ||
626 | int uptodate = pc->error ? 0 : 1; | ||
640 | 627 | ||
641 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 628 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
642 | 629 | ||
643 | if (!tape->pc->error) { | 630 | if (tape->failed_pc == pc) |
644 | idetape_analyze_error(drive, tape->pc->buf); | 631 | tape->failed_pc = NULL; |
645 | idetape_end_request(drive, 1, 0); | 632 | |
646 | } else { | 633 | if (pc->c[0] == REQUEST_SENSE) { |
647 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " | 634 | if (uptodate) |
648 | "Aborting request!\n"); | 635 | idetape_analyze_error(drive, pc->buf); |
649 | idetape_end_request(drive, 0, 0); | 636 | else |
637 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | ||
638 | "itself - Aborting request!\n"); | ||
639 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | ||
640 | struct request *rq = drive->hwif->hwgroup->rq; | ||
641 | int blocks = pc->xferred / tape->blk_size; | ||
642 | |||
643 | tape->avg_size += blocks * tape->blk_size; | ||
644 | |||
645 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { | ||
646 | tape->avg_speed = tape->avg_size * HZ / | ||
647 | (jiffies - tape->avg_time) / 1024; | ||
648 | tape->avg_size = 0; | ||
649 | tape->avg_time = jiffies; | ||
650 | } | ||
651 | |||
652 | tape->first_frame += blocks; | ||
653 | rq->current_nr_sectors -= blocks; | ||
654 | |||
655 | if (pc->error) | ||
656 | uptodate = pc->error; | ||
657 | } else if (pc->c[0] == READ_POSITION && uptodate) { | ||
658 | u8 *readpos = tape->pc->buf; | ||
659 | |||
660 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
661 | (readpos[0] & 0x80) ? "Yes" : "No"); | ||
662 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
663 | (readpos[0] & 0x40) ? "Yes" : "No"); | ||
664 | |||
665 | if (readpos[0] & 0x4) { | ||
666 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
667 | "to the tape\n"); | ||
668 | clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
669 | uptodate = 0; | ||
670 | } else { | ||
671 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
672 | be32_to_cpu(*(u32 *)&readpos[4])); | ||
673 | |||
674 | tape->partition = readpos[1]; | ||
675 | tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); | ||
676 | set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
677 | } | ||
650 | } | 678 | } |
651 | return ide_stopped; | 679 | |
680 | idetape_end_request(drive, uptodate, 0); | ||
681 | } | ||
682 | |||
683 | static void idetape_init_pc(struct ide_atapi_pc *pc) | ||
684 | { | ||
685 | memset(pc->c, 0, 12); | ||
686 | pc->retries = 0; | ||
687 | pc->flags = 0; | ||
688 | pc->req_xfer = 0; | ||
689 | pc->buf = pc->pc_buf; | ||
690 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; | ||
691 | pc->bh = NULL; | ||
692 | pc->b_data = NULL; | ||
693 | pc->callback = ide_tape_callback; | ||
652 | } | 694 | } |
653 | 695 | ||
654 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | 696 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) |
@@ -657,7 +699,6 @@ static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
657 | pc->c[0] = REQUEST_SENSE; | 699 | pc->c[0] = REQUEST_SENSE; |
658 | pc->c[4] = 20; | 700 | pc->c[4] = 20; |
659 | pc->req_xfer = 20; | 701 | pc->req_xfer = 20; |
660 | pc->idetape_callback = &idetape_request_sense_callback; | ||
661 | } | 702 | } |
662 | 703 | ||
663 | static void idetape_init_rq(struct request *rq, u8 cmd) | 704 | static void idetape_init_rq(struct request *rq, u8 cmd) |
@@ -688,9 +729,10 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
688 | struct ide_tape_obj *tape = drive->driver_data; | 729 | struct ide_tape_obj *tape = drive->driver_data; |
689 | 730 | ||
690 | idetape_init_rq(rq, REQ_IDETAPE_PC1); | 731 | idetape_init_rq(rq, REQ_IDETAPE_PC1); |
732 | rq->cmd_flags |= REQ_PREEMPT; | ||
691 | rq->buffer = (char *) pc; | 733 | rq->buffer = (char *) pc; |
692 | rq->rq_disk = tape->disk; | 734 | rq->rq_disk = tape->disk; |
693 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 735 | ide_do_drive_cmd(drive, rq); |
694 | } | 736 | } |
695 | 737 | ||
696 | /* | 738 | /* |
@@ -698,7 +740,7 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
698 | * last packet command. We queue a request sense packet command in | 740 | * last packet command. We queue a request sense packet command in |
699 | * the head of the request list. | 741 | * the head of the request list. |
700 | */ | 742 | */ |
701 | static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) | 743 | static void idetape_retry_pc(ide_drive_t *drive) |
702 | { | 744 | { |
703 | idetape_tape_t *tape = drive->driver_data; | 745 | idetape_tape_t *tape = drive->driver_data; |
704 | struct ide_atapi_pc *pc; | 746 | struct ide_atapi_pc *pc; |
@@ -710,7 +752,6 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) | |||
710 | idetape_create_request_sense_cmd(pc); | 752 | idetape_create_request_sense_cmd(pc); |
711 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); | 753 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); |
712 | idetape_queue_pc_head(drive, pc, rq); | 754 | idetape_queue_pc_head(drive, pc, rq); |
713 | return ide_stopped; | ||
714 | } | 755 | } |
715 | 756 | ||
716 | /* | 757 | /* |
@@ -727,7 +768,26 @@ static void idetape_postpone_request(ide_drive_t *drive) | |||
727 | ide_stall_queue(drive, tape->dsc_poll_freq); | 768 | ide_stall_queue(drive, tape->dsc_poll_freq); |
728 | } | 769 | } |
729 | 770 | ||
730 | typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int); | 771 | static void ide_tape_handle_dsc(ide_drive_t *drive) |
772 | { | ||
773 | idetape_tape_t *tape = drive->driver_data; | ||
774 | |||
775 | /* Media access command */ | ||
776 | tape->dsc_polling_start = jiffies; | ||
777 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; | ||
778 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; | ||
779 | /* Allow ide.c to handle other requests */ | ||
780 | idetape_postpone_request(drive); | ||
781 | } | ||
782 | |||
783 | static void ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
784 | unsigned int bcount, int write) | ||
785 | { | ||
786 | if (write) | ||
787 | idetape_output_buffers(drive, pc, bcount); | ||
788 | else | ||
789 | idetape_input_buffers(drive, pc, bcount); | ||
790 | } | ||
731 | 791 | ||
732 | /* | 792 | /* |
733 | * This is the usual interrupt handler which will be called during a packet | 793 | * This is the usual interrupt handler which will be called during a packet |
@@ -738,169 +798,11 @@ typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int); | |||
738 | */ | 798 | */ |
739 | static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | 799 | static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) |
740 | { | 800 | { |
741 | ide_hwif_t *hwif = drive->hwif; | ||
742 | idetape_tape_t *tape = drive->driver_data; | 801 | idetape_tape_t *tape = drive->driver_data; |
743 | struct ide_atapi_pc *pc = tape->pc; | ||
744 | xfer_func_t *xferfunc; | ||
745 | idetape_io_buf *iobuf; | ||
746 | unsigned int temp; | ||
747 | #if SIMULATE_ERRORS | ||
748 | static int error_sim_count; | ||
749 | #endif | ||
750 | u16 bcount; | ||
751 | u8 stat, ireason; | ||
752 | |||
753 | debug_log(DBG_PROCS, "Enter %s - interrupt handler\n", __func__); | ||
754 | |||
755 | /* Clear the interrupt */ | ||
756 | stat = ide_read_status(drive); | ||
757 | |||
758 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
759 | if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) { | ||
760 | /* | ||
761 | * A DMA error is sometimes expected. For example, | ||
762 | * if the tape is crossing a filemark during a | ||
763 | * READ command, it will issue an irq and position | ||
764 | * itself before the filemark, so that only a partial | ||
765 | * data transfer will occur (which causes the DMA | ||
766 | * error). In that case, we will later ask the tape | ||
767 | * how much bytes of the original request were | ||
768 | * actually transferred (we can't receive that | ||
769 | * information from the DMA engine on most chipsets). | ||
770 | */ | ||
771 | |||
772 | /* | ||
773 | * On the contrary, a DMA error is never expected; | ||
774 | * it usually indicates a hardware error or abort. | ||
775 | * If the tape crosses a filemark during a READ | ||
776 | * command, it will issue an irq and position itself | ||
777 | * after the filemark (not before). Only a partial | ||
778 | * data transfer will occur, but no DMA error. | ||
779 | * (AS, 19 Apr 2001) | ||
780 | */ | ||
781 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
782 | } else { | ||
783 | pc->xferred = pc->req_xfer; | ||
784 | idetape_update_buffers(pc); | ||
785 | } | ||
786 | debug_log(DBG_PROCS, "DMA finished\n"); | ||
787 | |||
788 | } | ||
789 | |||
790 | /* No more interrupts */ | ||
791 | if ((stat & DRQ_STAT) == 0) { | ||
792 | debug_log(DBG_SENSE, "Packet command completed, %d bytes" | ||
793 | " transferred\n", pc->xferred); | ||
794 | |||
795 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
796 | local_irq_enable(); | ||
797 | |||
798 | #if SIMULATE_ERRORS | ||
799 | if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) && | ||
800 | (++error_sim_count % 100) == 0) { | ||
801 | printk(KERN_INFO "ide-tape: %s: simulating error\n", | ||
802 | tape->name); | ||
803 | stat |= ERR_STAT; | ||
804 | } | ||
805 | #endif | ||
806 | if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | ||
807 | stat &= ~ERR_STAT; | ||
808 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | ||
809 | /* Error detected */ | ||
810 | debug_log(DBG_ERR, "%s: I/O error\n", tape->name); | ||
811 | |||
812 | if (pc->c[0] == REQUEST_SENSE) { | ||
813 | printk(KERN_ERR "ide-tape: I/O error in request" | ||
814 | " sense command\n"); | ||
815 | return ide_do_reset(drive); | ||
816 | } | ||
817 | debug_log(DBG_ERR, "[cmd %x]: check condition\n", | ||
818 | pc->c[0]); | ||
819 | |||
820 | /* Retry operation */ | ||
821 | return idetape_retry_pc(drive); | ||
822 | } | ||
823 | pc->error = 0; | ||
824 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && | ||
825 | (stat & SEEK_STAT) == 0) { | ||
826 | /* Media access command */ | ||
827 | tape->dsc_polling_start = jiffies; | ||
828 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; | ||
829 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; | ||
830 | /* Allow ide.c to handle other requests */ | ||
831 | idetape_postpone_request(drive); | ||
832 | return ide_stopped; | ||
833 | } | ||
834 | if (tape->failed_pc == pc) | ||
835 | tape->failed_pc = NULL; | ||
836 | /* Command finished - Call the callback function */ | ||
837 | return pc->idetape_callback(drive); | ||
838 | } | ||
839 | |||
840 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
841 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
842 | printk(KERN_ERR "ide-tape: The tape wants to issue more " | ||
843 | "interrupts in DMA mode\n"); | ||
844 | printk(KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n"); | ||
845 | ide_dma_off(drive); | ||
846 | return ide_do_reset(drive); | ||
847 | } | ||
848 | /* Get the number of bytes to transfer on this interrupt. */ | ||
849 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
850 | hwif->INB(hwif->io_ports.lbam_addr); | ||
851 | |||
852 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
853 | |||
854 | if (ireason & CD) { | ||
855 | printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); | ||
856 | return ide_do_reset(drive); | ||
857 | } | ||
858 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | ||
859 | /* Hopefully, we will never get here */ | ||
860 | printk(KERN_ERR "ide-tape: We wanted to %s, ", | ||
861 | (ireason & IO) ? "Write" : "Read"); | ||
862 | printk(KERN_ERR "ide-tape: but the tape wants us to %s !\n", | ||
863 | (ireason & IO) ? "Read" : "Write"); | ||
864 | return ide_do_reset(drive); | ||
865 | } | ||
866 | if (!(pc->flags & PC_FLAG_WRITING)) { | ||
867 | /* Reading - Check that we have enough space */ | ||
868 | temp = pc->xferred + bcount; | ||
869 | if (temp > pc->req_xfer) { | ||
870 | if (temp > pc->buf_size) { | ||
871 | printk(KERN_ERR "ide-tape: The tape wants to " | ||
872 | "send us more data than expected " | ||
873 | "- discarding data\n"); | ||
874 | ide_pad_transfer(drive, 0, bcount); | ||
875 | ide_set_handler(drive, &idetape_pc_intr, | ||
876 | IDETAPE_WAIT_CMD, NULL); | ||
877 | return ide_started; | ||
878 | } | ||
879 | debug_log(DBG_SENSE, "The tape wants to send us more " | ||
880 | "data than expected - allowing transfer\n"); | ||
881 | } | ||
882 | iobuf = &idetape_input_buffers; | ||
883 | xferfunc = hwif->input_data; | ||
884 | } else { | ||
885 | iobuf = &idetape_output_buffers; | ||
886 | xferfunc = hwif->output_data; | ||
887 | } | ||
888 | |||
889 | if (pc->bh) | ||
890 | iobuf(drive, pc, bcount); | ||
891 | else | ||
892 | xferfunc(drive, NULL, pc->cur_pos, bcount); | ||
893 | |||
894 | /* Update the current position */ | ||
895 | pc->xferred += bcount; | ||
896 | pc->cur_pos += bcount; | ||
897 | |||
898 | debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n", | ||
899 | pc->c[0], bcount); | ||
900 | 802 | ||
901 | /* And set the interrupt handler again */ | 803 | return ide_pc_intr(drive, tape->pc, idetape_pc_intr, IDETAPE_WAIT_CMD, |
902 | ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); | 804 | NULL, idetape_update_buffers, idetape_retry_pc, |
903 | return ide_started; | 805 | ide_tape_handle_dsc, ide_tape_io_buffers); |
904 | } | 806 | } |
905 | 807 | ||
906 | /* | 808 | /* |
@@ -941,56 +843,16 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
941 | */ | 843 | */ |
942 | static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | 844 | static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) |
943 | { | 845 | { |
944 | ide_hwif_t *hwif = drive->hwif; | ||
945 | idetape_tape_t *tape = drive->driver_data; | 846 | idetape_tape_t *tape = drive->driver_data; |
946 | struct ide_atapi_pc *pc = tape->pc; | ||
947 | int retries = 100; | ||
948 | ide_startstop_t startstop; | ||
949 | u8 ireason; | ||
950 | |||
951 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
952 | printk(KERN_ERR "ide-tape: Strange, packet command initiated " | ||
953 | "yet DRQ isn't asserted\n"); | ||
954 | return startstop; | ||
955 | } | ||
956 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
957 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | ||
958 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " | ||
959 | "a packet command, retrying\n"); | ||
960 | udelay(100); | ||
961 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
962 | if (retries == 0) { | ||
963 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " | ||
964 | "issuing a packet command, ignoring\n"); | ||
965 | ireason |= CD; | ||
966 | ireason &= ~IO; | ||
967 | } | ||
968 | } | ||
969 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
970 | printk(KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing " | ||
971 | "a packet command\n"); | ||
972 | return ide_do_reset(drive); | ||
973 | } | ||
974 | /* Set the interrupt routine */ | ||
975 | ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); | ||
976 | #ifdef CONFIG_BLK_DEV_IDEDMA | ||
977 | /* Begin DMA, if necessary */ | ||
978 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) | ||
979 | hwif->dma_ops->dma_start(drive); | ||
980 | #endif | ||
981 | /* Send the actual packet */ | ||
982 | hwif->output_data(drive, NULL, pc->c, 12); | ||
983 | 847 | ||
984 | return ide_started; | 848 | return ide_transfer_pc(drive, tape->pc, idetape_pc_intr, |
849 | IDETAPE_WAIT_CMD, NULL); | ||
985 | } | 850 | } |
986 | 851 | ||
987 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | 852 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, |
988 | struct ide_atapi_pc *pc) | 853 | struct ide_atapi_pc *pc) |
989 | { | 854 | { |
990 | ide_hwif_t *hwif = drive->hwif; | ||
991 | idetape_tape_t *tape = drive->driver_data; | 855 | idetape_tape_t *tape = drive->driver_data; |
992 | int dma_ok = 0; | ||
993 | u16 bcount; | ||
994 | 856 | ||
995 | if (tape->pc->c[0] == REQUEST_SENSE && | 857 | if (tape->pc->c[0] == REQUEST_SENSE && |
996 | pc->c[0] == REQUEST_SENSE) { | 858 | pc->c[0] == REQUEST_SENSE) { |
@@ -1025,50 +887,15 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
1025 | pc->error = IDETAPE_ERROR_GENERAL; | 887 | pc->error = IDETAPE_ERROR_GENERAL; |
1026 | } | 888 | } |
1027 | tape->failed_pc = NULL; | 889 | tape->failed_pc = NULL; |
1028 | return pc->idetape_callback(drive); | 890 | pc->callback(drive); |
891 | return ide_stopped; | ||
1029 | } | 892 | } |
1030 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 893 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
1031 | 894 | ||
1032 | pc->retries++; | 895 | pc->retries++; |
1033 | /* We haven't transferred any data yet */ | ||
1034 | pc->xferred = 0; | ||
1035 | pc->cur_pos = pc->buf; | ||
1036 | /* Request to transfer the entire buffer at once */ | ||
1037 | bcount = pc->req_xfer; | ||
1038 | 896 | ||
1039 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 897 | return ide_issue_pc(drive, pc, idetape_transfer_pc, |
1040 | pc->flags &= ~PC_FLAG_DMA_ERROR; | 898 | IDETAPE_WAIT_CMD, NULL); |
1041 | printk(KERN_WARNING "ide-tape: DMA disabled, " | ||
1042 | "reverting to PIO\n"); | ||
1043 | ide_dma_off(drive); | ||
1044 | } | ||
1045 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | ||
1046 | dma_ok = !hwif->dma_ops->dma_setup(drive); | ||
1047 | |||
1048 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | ||
1049 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); | ||
1050 | |||
1051 | if (dma_ok) | ||
1052 | /* Will begin DMA later */ | ||
1053 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
1054 | if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) { | ||
1055 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, | ||
1056 | IDETAPE_WAIT_CMD, NULL); | ||
1057 | return ide_started; | ||
1058 | } else { | ||
1059 | ide_execute_pkt_cmd(drive); | ||
1060 | return idetape_transfer_pc(drive); | ||
1061 | } | ||
1062 | } | ||
1063 | |||
1064 | static ide_startstop_t idetape_pc_callback(ide_drive_t *drive) | ||
1065 | { | ||
1066 | idetape_tape_t *tape = drive->driver_data; | ||
1067 | |||
1068 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1069 | |||
1070 | idetape_end_request(drive, tape->pc->error ? 0 : 1, 0); | ||
1071 | return ide_stopped; | ||
1072 | } | 899 | } |
1073 | 900 | ||
1074 | /* A mode sense command is used to "sense" tape parameters. */ | 901 | /* A mode sense command is used to "sense" tape parameters. */ |
@@ -1096,7 +923,6 @@ static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) | |||
1096 | pc->req_xfer = 24; | 923 | pc->req_xfer = 24; |
1097 | else | 924 | else |
1098 | pc->req_xfer = 50; | 925 | pc->req_xfer = 50; |
1099 | pc->idetape_callback = &idetape_pc_callback; | ||
1100 | } | 926 | } |
1101 | 927 | ||
1102 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | 928 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
@@ -1114,80 +940,41 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | |||
1114 | printk(KERN_ERR "ide-tape: %s: I/O error, ", | 940 | printk(KERN_ERR "ide-tape: %s: I/O error, ", |
1115 | tape->name); | 941 | tape->name); |
1116 | /* Retry operation */ | 942 | /* Retry operation */ |
1117 | return idetape_retry_pc(drive); | 943 | idetape_retry_pc(drive); |
944 | return ide_stopped; | ||
1118 | } | 945 | } |
1119 | pc->error = 0; | 946 | pc->error = 0; |
1120 | if (tape->failed_pc == pc) | ||
1121 | tape->failed_pc = NULL; | ||
1122 | } else { | 947 | } else { |
1123 | pc->error = IDETAPE_ERROR_GENERAL; | 948 | pc->error = IDETAPE_ERROR_GENERAL; |
1124 | tape->failed_pc = NULL; | 949 | tape->failed_pc = NULL; |
1125 | } | 950 | } |
1126 | return pc->idetape_callback(drive); | 951 | pc->callback(drive); |
1127 | } | ||
1128 | |||
1129 | static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) | ||
1130 | { | ||
1131 | idetape_tape_t *tape = drive->driver_data; | ||
1132 | struct request *rq = HWGROUP(drive)->rq; | ||
1133 | int blocks = tape->pc->xferred / tape->blk_size; | ||
1134 | |||
1135 | tape->avg_size += blocks * tape->blk_size; | ||
1136 | |||
1137 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { | ||
1138 | tape->avg_speed = tape->avg_size * HZ / | ||
1139 | (jiffies - tape->avg_time) / 1024; | ||
1140 | tape->avg_size = 0; | ||
1141 | tape->avg_time = jiffies; | ||
1142 | } | ||
1143 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1144 | |||
1145 | tape->first_frame += blocks; | ||
1146 | rq->current_nr_sectors -= blocks; | ||
1147 | |||
1148 | if (!tape->pc->error) | ||
1149 | idetape_end_request(drive, 1, 0); | ||
1150 | else | ||
1151 | idetape_end_request(drive, tape->pc->error, 0); | ||
1152 | return ide_stopped; | 952 | return ide_stopped; |
1153 | } | 953 | } |
1154 | 954 | ||
1155 | static void idetape_create_read_cmd(idetape_tape_t *tape, | 955 | static void ide_tape_create_rw_cmd(idetape_tape_t *tape, |
1156 | struct ide_atapi_pc *pc, | 956 | struct ide_atapi_pc *pc, unsigned int length, |
1157 | unsigned int length, struct idetape_bh *bh) | 957 | struct idetape_bh *bh, u8 opcode) |
1158 | { | 958 | { |
1159 | idetape_init_pc(pc); | 959 | idetape_init_pc(pc); |
1160 | pc->c[0] = READ_6; | ||
1161 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 960 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
1162 | pc->c[1] = 1; | 961 | pc->c[1] = 1; |
1163 | pc->idetape_callback = &idetape_rw_callback; | ||
1164 | pc->bh = bh; | 962 | pc->bh = bh; |
1165 | atomic_set(&bh->b_count, 0); | ||
1166 | pc->buf = NULL; | 963 | pc->buf = NULL; |
1167 | pc->buf_size = length * tape->blk_size; | 964 | pc->buf_size = length * tape->blk_size; |
1168 | pc->req_xfer = pc->buf_size; | 965 | pc->req_xfer = pc->buf_size; |
1169 | if (pc->req_xfer == tape->buffer_size) | 966 | if (pc->req_xfer == tape->buffer_size) |
1170 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 967 | pc->flags |= PC_FLAG_DMA_OK; |
1171 | } | ||
1172 | 968 | ||
1173 | static void idetape_create_write_cmd(idetape_tape_t *tape, | 969 | if (opcode == READ_6) { |
1174 | struct ide_atapi_pc *pc, | 970 | pc->c[0] = READ_6; |
1175 | unsigned int length, struct idetape_bh *bh) | 971 | atomic_set(&bh->b_count, 0); |
1176 | { | 972 | } else if (opcode == WRITE_6) { |
1177 | idetape_init_pc(pc); | 973 | pc->c[0] = WRITE_6; |
1178 | pc->c[0] = WRITE_6; | 974 | pc->flags |= PC_FLAG_WRITING; |
1179 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 975 | pc->b_data = bh->b_data; |
1180 | pc->c[1] = 1; | 976 | pc->b_count = atomic_read(&bh->b_count); |
1181 | pc->idetape_callback = &idetape_rw_callback; | 977 | } |
1182 | pc->flags |= PC_FLAG_WRITING; | ||
1183 | pc->bh = bh; | ||
1184 | pc->b_data = bh->b_data; | ||
1185 | pc->b_count = atomic_read(&bh->b_count); | ||
1186 | pc->buf = NULL; | ||
1187 | pc->buf_size = length * tape->blk_size; | ||
1188 | pc->req_xfer = pc->buf_size; | ||
1189 | if (pc->req_xfer == tape->buffer_size) | ||
1190 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | ||
1191 | } | 978 | } |
1192 | 979 | ||
1193 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, | 980 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, |
@@ -1211,8 +998,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1211 | } | 998 | } |
1212 | 999 | ||
1213 | /* Retry a failed packet command */ | 1000 | /* Retry a failed packet command */ |
1214 | if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) | 1001 | if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) { |
1215 | return idetape_issue_pc(drive, tape->failed_pc); | 1002 | pc = tape->failed_pc; |
1003 | goto out; | ||
1004 | } | ||
1216 | 1005 | ||
1217 | if (postponed_rq != NULL) | 1006 | if (postponed_rq != NULL) |
1218 | if (rq != postponed_rq) { | 1007 | if (rq != postponed_rq) { |
@@ -1262,14 +1051,16 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1262 | } | 1051 | } |
1263 | if (rq->cmd[0] & REQ_IDETAPE_READ) { | 1052 | if (rq->cmd[0] & REQ_IDETAPE_READ) { |
1264 | pc = idetape_next_pc_storage(drive); | 1053 | pc = idetape_next_pc_storage(drive); |
1265 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, | 1054 | ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors, |
1266 | (struct idetape_bh *)rq->special); | 1055 | (struct idetape_bh *)rq->special, |
1056 | READ_6); | ||
1267 | goto out; | 1057 | goto out; |
1268 | } | 1058 | } |
1269 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 1059 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
1270 | pc = idetape_next_pc_storage(drive); | 1060 | pc = idetape_next_pc_storage(drive); |
1271 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, | 1061 | ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors, |
1272 | (struct idetape_bh *)rq->special); | 1062 | (struct idetape_bh *)rq->special, |
1063 | WRITE_6); | ||
1273 | goto out; | 1064 | goto out; |
1274 | } | 1065 | } |
1275 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { | 1066 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { |
@@ -1284,6 +1075,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1284 | } | 1075 | } |
1285 | BUG(); | 1076 | BUG(); |
1286 | out: | 1077 | out: |
1078 | if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) | ||
1079 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
1080 | |||
1287 | return idetape_issue_pc(drive, pc); | 1081 | return idetape_issue_pc(drive, pc); |
1288 | } | 1082 | } |
1289 | 1083 | ||
@@ -1447,40 +1241,6 @@ static void idetape_init_merge_buffer(idetape_tape_t *tape) | |||
1447 | } | 1241 | } |
1448 | } | 1242 | } |
1449 | 1243 | ||
1450 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | ||
1451 | { | ||
1452 | idetape_tape_t *tape = drive->driver_data; | ||
1453 | u8 *readpos = tape->pc->buf; | ||
1454 | |||
1455 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1456 | |||
1457 | if (!tape->pc->error) { | ||
1458 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
1459 | (readpos[0] & 0x80) ? "Yes" : "No"); | ||
1460 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
1461 | (readpos[0] & 0x40) ? "Yes" : "No"); | ||
1462 | |||
1463 | if (readpos[0] & 0x4) { | ||
1464 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
1465 | "to the tape\n"); | ||
1466 | clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
1467 | idetape_end_request(drive, 0, 0); | ||
1468 | } else { | ||
1469 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
1470 | be32_to_cpu(*(u32 *)&readpos[4])); | ||
1471 | |||
1472 | tape->partition = readpos[1]; | ||
1473 | tape->first_frame = | ||
1474 | be32_to_cpu(*(u32 *)&readpos[4]); | ||
1475 | set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
1476 | idetape_end_request(drive, 1, 0); | ||
1477 | } | ||
1478 | } else { | ||
1479 | idetape_end_request(drive, 0, 0); | ||
1480 | } | ||
1481 | return ide_stopped; | ||
1482 | } | ||
1483 | |||
1484 | /* | 1244 | /* |
1485 | * Write a filemark if write_filemark=1. Flush the device buffers without | 1245 | * Write a filemark if write_filemark=1. Flush the device buffers without |
1486 | * writing a filemark otherwise. | 1246 | * writing a filemark otherwise. |
@@ -1492,14 +1252,12 @@ static void idetape_create_write_filemark_cmd(ide_drive_t *drive, | |||
1492 | pc->c[0] = WRITE_FILEMARKS; | 1252 | pc->c[0] = WRITE_FILEMARKS; |
1493 | pc->c[4] = write_filemark; | 1253 | pc->c[4] = write_filemark; |
1494 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1254 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1495 | pc->idetape_callback = &idetape_pc_callback; | ||
1496 | } | 1255 | } |
1497 | 1256 | ||
1498 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | 1257 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) |
1499 | { | 1258 | { |
1500 | idetape_init_pc(pc); | 1259 | idetape_init_pc(pc); |
1501 | pc->c[0] = TEST_UNIT_READY; | 1260 | pc->c[0] = TEST_UNIT_READY; |
1502 | pc->idetape_callback = &idetape_pc_callback; | ||
1503 | } | 1261 | } |
1504 | 1262 | ||
1505 | /* | 1263 | /* |
@@ -1518,12 +1276,16 @@ static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | |||
1518 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | 1276 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
1519 | { | 1277 | { |
1520 | struct ide_tape_obj *tape = drive->driver_data; | 1278 | struct ide_tape_obj *tape = drive->driver_data; |
1521 | struct request rq; | 1279 | struct request *rq; |
1280 | int error; | ||
1522 | 1281 | ||
1523 | idetape_init_rq(&rq, REQ_IDETAPE_PC1); | 1282 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1524 | rq.buffer = (char *) pc; | 1283 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1525 | rq.rq_disk = tape->disk; | 1284 | rq->cmd[0] = REQ_IDETAPE_PC1; |
1526 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 1285 | rq->buffer = (char *)pc; |
1286 | error = blk_execute_rq(drive->queue, tape->disk, rq, 0); | ||
1287 | blk_put_request(rq); | ||
1288 | return error; | ||
1527 | } | 1289 | } |
1528 | 1290 | ||
1529 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, | 1291 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, |
@@ -1533,7 +1295,6 @@ static void idetape_create_load_unload_cmd(ide_drive_t *drive, | |||
1533 | pc->c[0] = START_STOP; | 1295 | pc->c[0] = START_STOP; |
1534 | pc->c[4] = cmd; | 1296 | pc->c[4] = cmd; |
1535 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1297 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1536 | pc->idetape_callback = &idetape_pc_callback; | ||
1537 | } | 1298 | } |
1538 | 1299 | ||
1539 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | 1300 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) |
@@ -1585,7 +1346,6 @@ static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) | |||
1585 | idetape_init_pc(pc); | 1346 | idetape_init_pc(pc); |
1586 | pc->c[0] = READ_POSITION; | 1347 | pc->c[0] = READ_POSITION; |
1587 | pc->req_xfer = 20; | 1348 | pc->req_xfer = 20; |
1588 | pc->idetape_callback = &idetape_read_position_callback; | ||
1589 | } | 1349 | } |
1590 | 1350 | ||
1591 | static int idetape_read_position(ide_drive_t *drive) | 1351 | static int idetape_read_position(ide_drive_t *drive) |
@@ -1613,7 +1373,6 @@ static void idetape_create_locate_cmd(ide_drive_t *drive, | |||
1613 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); | 1373 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); |
1614 | pc->c[8] = partition; | 1374 | pc->c[8] = partition; |
1615 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1375 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1616 | pc->idetape_callback = &idetape_pc_callback; | ||
1617 | } | 1376 | } |
1618 | 1377 | ||
1619 | static int idetape_create_prevent_cmd(ide_drive_t *drive, | 1378 | static int idetape_create_prevent_cmd(ide_drive_t *drive, |
@@ -1628,7 +1387,6 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive, | |||
1628 | idetape_init_pc(pc); | 1387 | idetape_init_pc(pc); |
1629 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; | 1388 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; |
1630 | pc->c[4] = prevent; | 1389 | pc->c[4] = prevent; |
1631 | pc->idetape_callback = &idetape_pc_callback; | ||
1632 | return 1; | 1390 | return 1; |
1633 | } | 1391 | } |
1634 | 1392 | ||
@@ -1700,26 +1458,33 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
1700 | struct idetape_bh *bh) | 1458 | struct idetape_bh *bh) |
1701 | { | 1459 | { |
1702 | idetape_tape_t *tape = drive->driver_data; | 1460 | idetape_tape_t *tape = drive->driver_data; |
1703 | struct request rq; | 1461 | struct request *rq; |
1462 | int ret, errors; | ||
1704 | 1463 | ||
1705 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); | 1464 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); |
1706 | 1465 | ||
1707 | idetape_init_rq(&rq, cmd); | 1466 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1708 | rq.rq_disk = tape->disk; | 1467 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1709 | rq.special = (void *)bh; | 1468 | rq->cmd[0] = cmd; |
1710 | rq.sector = tape->first_frame; | 1469 | rq->rq_disk = tape->disk; |
1711 | rq.nr_sectors = blocks; | 1470 | rq->special = (void *)bh; |
1712 | rq.current_nr_sectors = blocks; | 1471 | rq->sector = tape->first_frame; |
1713 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); | 1472 | rq->nr_sectors = blocks; |
1473 | rq->current_nr_sectors = blocks; | ||
1474 | blk_execute_rq(drive->queue, tape->disk, rq, 0); | ||
1475 | |||
1476 | errors = rq->errors; | ||
1477 | ret = tape->blk_size * (blocks - rq->current_nr_sectors); | ||
1478 | blk_put_request(rq); | ||
1714 | 1479 | ||
1715 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) | 1480 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) |
1716 | return 0; | 1481 | return 0; |
1717 | 1482 | ||
1718 | if (tape->merge_bh) | 1483 | if (tape->merge_bh) |
1719 | idetape_init_merge_buffer(tape); | 1484 | idetape_init_merge_buffer(tape); |
1720 | if (rq.errors == IDETAPE_ERROR_GENERAL) | 1485 | if (errors == IDETAPE_ERROR_GENERAL) |
1721 | return -EIO; | 1486 | return -EIO; |
1722 | return (tape->blk_size * (blocks-rq.current_nr_sectors)); | 1487 | return ret; |
1723 | } | 1488 | } |
1724 | 1489 | ||
1725 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | 1490 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) |
@@ -1728,7 +1493,6 @@ static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | |||
1728 | pc->c[0] = INQUIRY; | 1493 | pc->c[0] = INQUIRY; |
1729 | pc->c[4] = 254; | 1494 | pc->c[4] = 254; |
1730 | pc->req_xfer = 254; | 1495 | pc->req_xfer = 254; |
1731 | pc->idetape_callback = &idetape_pc_callback; | ||
1732 | } | 1496 | } |
1733 | 1497 | ||
1734 | static void idetape_create_rewind_cmd(ide_drive_t *drive, | 1498 | static void idetape_create_rewind_cmd(ide_drive_t *drive, |
@@ -1737,7 +1501,6 @@ static void idetape_create_rewind_cmd(ide_drive_t *drive, | |||
1737 | idetape_init_pc(pc); | 1501 | idetape_init_pc(pc); |
1738 | pc->c[0] = REZERO_UNIT; | 1502 | pc->c[0] = REZERO_UNIT; |
1739 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1503 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1740 | pc->idetape_callback = &idetape_pc_callback; | ||
1741 | } | 1504 | } |
1742 | 1505 | ||
1743 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) | 1506 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) |
@@ -1746,7 +1509,6 @@ static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) | |||
1746 | pc->c[0] = ERASE; | 1509 | pc->c[0] = ERASE; |
1747 | pc->c[1] = 1; | 1510 | pc->c[1] = 1; |
1748 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1511 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1749 | pc->idetape_callback = &idetape_pc_callback; | ||
1750 | } | 1512 | } |
1751 | 1513 | ||
1752 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | 1514 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) |
@@ -1756,7 +1518,6 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | |||
1756 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); | 1518 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); |
1757 | pc->c[1] = cmd; | 1519 | pc->c[1] = cmd; |
1758 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1520 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1759 | pc->idetape_callback = &idetape_pc_callback; | ||
1760 | } | 1521 | } |
1761 | 1522 | ||
1762 | /* Queue up a character device originated write request. */ | 1523 | /* Queue up a character device originated write request. */ |
@@ -2751,9 +2512,8 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
2751 | * Ensure that the number we got makes sense; limit it within | 2512 | * Ensure that the number we got makes sense; limit it within |
2752 | * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. | 2513 | * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. |
2753 | */ | 2514 | */ |
2754 | tape->best_dsc_rw_freq = max_t(unsigned long, | 2515 | tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN, |
2755 | min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), | 2516 | IDETAPE_DSC_RW_MAX); |
2756 | IDETAPE_DSC_RW_MIN); | ||
2757 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " | 2517 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " |
2758 | "%lums tDSC%s\n", | 2518 | "%lums tDSC%s\n", |
2759 | drive->name, tape->name, *(u16 *)&tape->caps[14], | 2519 | drive->name, tape->name, *(u16 *)&tape->caps[14], |
@@ -2905,11 +2665,6 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
2905 | " the driver\n", drive->name); | 2665 | " the driver\n", drive->name); |
2906 | goto failed; | 2666 | goto failed; |
2907 | } | 2667 | } |
2908 | if (drive->scsi) { | ||
2909 | printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi" | ||
2910 | " emulation.\n", drive->name); | ||
2911 | goto failed; | ||
2912 | } | ||
2913 | tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); | 2668 | tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); |
2914 | if (tape == NULL) { | 2669 | if (tape == NULL) { |
2915 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", | 2670 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index ab545ffa1549..cf55a48a7dd2 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -109,13 +109,15 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
109 | 109 | ||
110 | if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { | 110 | if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { |
111 | ide_tf_dump(drive->name, tf); | 111 | ide_tf_dump(drive->name, tf); |
112 | ide_set_irq(drive, 1); | ||
113 | SELECT_MASK(drive, 0); | ||
112 | hwif->tf_load(drive, task); | 114 | hwif->tf_load(drive, task); |
113 | } | 115 | } |
114 | 116 | ||
115 | switch (task->data_phase) { | 117 | switch (task->data_phase) { |
116 | case TASKFILE_MULTI_OUT: | 118 | case TASKFILE_MULTI_OUT: |
117 | case TASKFILE_OUT: | 119 | case TASKFILE_OUT: |
118 | hwif->OUTBSYNC(drive, tf->command, hwif->io_ports.command_addr); | 120 | hwif->OUTBSYNC(hwif, tf->command, hwif->io_ports.command_addr); |
119 | ndelay(400); /* FIXME */ | 121 | ndelay(400); /* FIXME */ |
120 | return pre_task_out_intr(drive, task->rq); | 122 | return pre_task_out_intr(drive, task->rq); |
121 | case TASKFILE_MULTI_IN: | 123 | case TASKFILE_MULTI_IN: |
@@ -492,11 +494,12 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq) | |||
492 | 494 | ||
493 | int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) | 495 | int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) |
494 | { | 496 | { |
495 | struct request rq; | 497 | struct request *rq; |
498 | int error; | ||
496 | 499 | ||
497 | blk_rq_init(NULL, &rq); | 500 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
498 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 501 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
499 | rq.buffer = buf; | 502 | rq->buffer = buf; |
500 | 503 | ||
501 | /* | 504 | /* |
502 | * (ks) We transfer currently only whole sectors. | 505 | * (ks) We transfer currently only whole sectors. |
@@ -504,16 +507,19 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) | |||
504 | * if we would find a solution to transfer any size. | 507 | * if we would find a solution to transfer any size. |
505 | * To support special commands like READ LONG. | 508 | * To support special commands like READ LONG. |
506 | */ | 509 | */ |
507 | rq.hard_nr_sectors = rq.nr_sectors = nsect; | 510 | rq->hard_nr_sectors = rq->nr_sectors = nsect; |
508 | rq.hard_cur_sectors = rq.current_nr_sectors = nsect; | 511 | rq->hard_cur_sectors = rq->current_nr_sectors = nsect; |
509 | 512 | ||
510 | if (task->tf_flags & IDE_TFLAG_WRITE) | 513 | if (task->tf_flags & IDE_TFLAG_WRITE) |
511 | rq.cmd_flags |= REQ_RW; | 514 | rq->cmd_flags |= REQ_RW; |
512 | 515 | ||
513 | rq.special = task; | 516 | rq->special = task; |
514 | task->rq = &rq; | 517 | task->rq = rq; |
515 | 518 | ||
516 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 519 | error = blk_execute_rq(drive->queue, NULL, rq, 0); |
520 | blk_put_request(rq); | ||
521 | |||
522 | return error; | ||
517 | } | 523 | } |
518 | 524 | ||
519 | EXPORT_SYMBOL(ide_raw_taskfile); | 525 | EXPORT_SYMBOL(ide_raw_taskfile); |
@@ -739,12 +745,14 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
739 | struct hd_driveid *id = drive->id; | 745 | struct hd_driveid *id = drive->id; |
740 | 746 | ||
741 | if (NULL == (void *) arg) { | 747 | if (NULL == (void *) arg) { |
742 | struct request rq; | 748 | struct request *rq; |
743 | 749 | ||
744 | ide_init_drive_cmd(&rq); | 750 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
745 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 751 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
752 | err = blk_execute_rq(drive->queue, NULL, rq, 0); | ||
753 | blk_put_request(rq); | ||
746 | 754 | ||
747 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 755 | return err; |
748 | } | 756 | } |
749 | 757 | ||
750 | if (copy_from_user(args, (void __user *)arg, 4)) | 758 | if (copy_from_user(args, (void __user *)arg, 4)) |
diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timing.h index 3b12ffe77071..2e91c5870b4c 100644 --- a/drivers/ide/ide-timing.h +++ b/drivers/ide/ide-timing.h | |||
@@ -95,7 +95,6 @@ static struct ide_timing ide_timing[] = { | |||
95 | #define IDE_TIMING_UDMA 0x80 | 95 | #define IDE_TIMING_UDMA 0x80 |
96 | #define IDE_TIMING_ALL 0xff | 96 | #define IDE_TIMING_ALL 0xff |
97 | 97 | ||
98 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | ||
99 | #define ENOUGH(v,unit) (((v)-1)/(unit)+1) | 98 | #define ENOUGH(v,unit) (((v)-1)/(unit)+1) |
100 | #define EZ(v,unit) ((v)?ENOUGH(v,unit):0) | 99 | #define EZ(v,unit) ((v)?ENOUGH(v,unit):0) |
101 | 100 | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 300431d080a9..2b8453510e09 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -86,13 +86,10 @@ static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR, | |||
86 | IDE6_MAJOR, IDE7_MAJOR, | 86 | IDE6_MAJOR, IDE7_MAJOR, |
87 | IDE8_MAJOR, IDE9_MAJOR }; | 87 | IDE8_MAJOR, IDE9_MAJOR }; |
88 | 88 | ||
89 | static int idebus_parameter; /* holds the "idebus=" parameter */ | ||
90 | static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */ | ||
91 | |||
92 | DEFINE_MUTEX(ide_cfg_mtx); | 89 | DEFINE_MUTEX(ide_cfg_mtx); |
93 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); | ||
94 | 90 | ||
95 | int noautodma = 0; | 91 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); |
92 | EXPORT_SYMBOL(ide_lock); | ||
96 | 93 | ||
97 | ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ | 94 | ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ |
98 | 95 | ||
@@ -139,7 +136,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
139 | drive->media = ide_disk; | 136 | drive->media = ide_disk; |
140 | drive->select.all = (unit<<4)|0xa0; | 137 | drive->select.all = (unit<<4)|0xa0; |
141 | drive->hwif = hwif; | 138 | drive->hwif = hwif; |
142 | drive->ctl = 0x08; | ||
143 | drive->ready_stat = READY_STAT; | 139 | drive->ready_stat = READY_STAT; |
144 | drive->bad_wstat = BAD_W_STAT; | 140 | drive->bad_wstat = BAD_W_STAT; |
145 | drive->special.b.recalibrate = 1; | 141 | drive->special.b.recalibrate = 1; |
@@ -154,32 +150,9 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
154 | } | 150 | } |
155 | } | 151 | } |
156 | 152 | ||
157 | /* | ||
158 | * init_ide_data() sets reasonable default values into all fields | ||
159 | * of all instances of the hwifs and drives, but only on the first call. | ||
160 | * Subsequent calls have no effect (they don't wipe out anything). | ||
161 | * | ||
162 | * This routine is normally called at driver initialization time, | ||
163 | * but may also be called MUCH earlier during kernel "command-line" | ||
164 | * parameter processing. As such, we cannot depend on any other parts | ||
165 | * of the kernel (such as memory allocation) to be functioning yet. | ||
166 | * | ||
167 | * This is too bad, as otherwise we could dynamically allocate the | ||
168 | * ide_drive_t structs as needed, rather than always consuming memory | ||
169 | * for the max possible number (MAX_HWIFS * MAX_DRIVES) of them. | ||
170 | * | ||
171 | * FIXME: We should stuff the setup data into __init and copy the | ||
172 | * relevant hwifs/allocate them properly during boot. | ||
173 | */ | ||
174 | #define MAGIC_COOKIE 0x12345678 | ||
175 | static void __init init_ide_data (void) | 153 | static void __init init_ide_data (void) |
176 | { | 154 | { |
177 | unsigned int index; | 155 | unsigned int index; |
178 | static unsigned long magic_cookie = MAGIC_COOKIE; | ||
179 | |||
180 | if (magic_cookie != MAGIC_COOKIE) | ||
181 | return; /* already initialized */ | ||
182 | magic_cookie = 0; | ||
183 | 156 | ||
184 | /* Initialise all interface structures */ | 157 | /* Initialise all interface structures */ |
185 | for (index = 0; index < MAX_HWIFS; ++index) { | 158 | for (index = 0; index < MAX_HWIFS; ++index) { |
@@ -189,38 +162,6 @@ static void __init init_ide_data (void) | |||
189 | } | 162 | } |
190 | } | 163 | } |
191 | 164 | ||
192 | /** | ||
193 | * ide_system_bus_speed - guess bus speed | ||
194 | * | ||
195 | * ide_system_bus_speed() returns what we think is the system VESA/PCI | ||
196 | * bus speed (in MHz). This is used for calculating interface PIO timings. | ||
197 | * The default is 40 for known PCI systems, 50 otherwise. | ||
198 | * The "idebus=xx" parameter can be used to override this value. | ||
199 | * The actual value to be used is computed/displayed the first time | ||
200 | * through. Drivers should only use this as a last resort. | ||
201 | * | ||
202 | * Returns a guessed speed in MHz. | ||
203 | */ | ||
204 | |||
205 | static int ide_system_bus_speed(void) | ||
206 | { | ||
207 | #ifdef CONFIG_PCI | ||
208 | static struct pci_device_id pci_default[] = { | ||
209 | { PCI_DEVICE(PCI_ANY_ID, PCI_ANY_ID) }, | ||
210 | { } | ||
211 | }; | ||
212 | #else | ||
213 | #define pci_default 0 | ||
214 | #endif /* CONFIG_PCI */ | ||
215 | |||
216 | /* user supplied value */ | ||
217 | if (idebus_parameter) | ||
218 | return idebus_parameter; | ||
219 | |||
220 | /* safe default value for PCI or VESA and PCI*/ | ||
221 | return pci_dev_present(pci_default) ? 33 : 50; | ||
222 | } | ||
223 | |||
224 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | 165 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) |
225 | { | 166 | { |
226 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 167 | ide_hwgroup_t *hwgroup = hwif->hwgroup; |
@@ -498,7 +439,7 @@ out: | |||
498 | 439 | ||
499 | int set_pio_mode(ide_drive_t *drive, int arg) | 440 | int set_pio_mode(ide_drive_t *drive, int arg) |
500 | { | 441 | { |
501 | struct request rq; | 442 | struct request *rq; |
502 | ide_hwif_t *hwif = drive->hwif; | 443 | ide_hwif_t *hwif = drive->hwif; |
503 | const struct ide_port_ops *port_ops = hwif->port_ops; | 444 | const struct ide_port_ops *port_ops = hwif->port_ops; |
504 | 445 | ||
@@ -512,12 +453,15 @@ int set_pio_mode(ide_drive_t *drive, int arg) | |||
512 | if (drive->special.b.set_tune) | 453 | if (drive->special.b.set_tune) |
513 | return -EBUSY; | 454 | return -EBUSY; |
514 | 455 | ||
515 | ide_init_drive_cmd(&rq); | 456 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
516 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 457 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
517 | 458 | ||
518 | drive->tune_req = (u8) arg; | 459 | drive->tune_req = (u8) arg; |
519 | drive->special.b.set_tune = 1; | 460 | drive->special.b.set_tune = 1; |
520 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); | 461 | |
462 | blk_execute_rq(drive->queue, NULL, rq, 0); | ||
463 | blk_put_request(rq); | ||
464 | |||
521 | return 0; | 465 | return 0; |
522 | } | 466 | } |
523 | 467 | ||
@@ -537,25 +481,11 @@ static int set_unmaskirq(ide_drive_t *drive, int arg) | |||
537 | return 0; | 481 | return 0; |
538 | } | 482 | } |
539 | 483 | ||
540 | /** | ||
541 | * system_bus_clock - clock guess | ||
542 | * | ||
543 | * External version of the bus clock guess used by very old IDE drivers | ||
544 | * for things like VLB timings. Should not be used. | ||
545 | */ | ||
546 | |||
547 | int system_bus_clock (void) | ||
548 | { | ||
549 | return system_bus_speed; | ||
550 | } | ||
551 | |||
552 | EXPORT_SYMBOL(system_bus_clock); | ||
553 | |||
554 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) | 484 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) |
555 | { | 485 | { |
556 | ide_drive_t *drive = dev->driver_data; | 486 | ide_drive_t *drive = dev->driver_data; |
557 | ide_hwif_t *hwif = HWIF(drive); | 487 | ide_hwif_t *hwif = HWIF(drive); |
558 | struct request rq; | 488 | struct request *rq; |
559 | struct request_pm_state rqpm; | 489 | struct request_pm_state rqpm; |
560 | ide_task_t args; | 490 | ide_task_t args; |
561 | int ret; | 491 | int ret; |
@@ -564,18 +494,19 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg) | |||
564 | if (!(drive->dn % 2)) | 494 | if (!(drive->dn % 2)) |
565 | ide_acpi_get_timing(hwif); | 495 | ide_acpi_get_timing(hwif); |
566 | 496 | ||
567 | blk_rq_init(NULL, &rq); | ||
568 | memset(&rqpm, 0, sizeof(rqpm)); | 497 | memset(&rqpm, 0, sizeof(rqpm)); |
569 | memset(&args, 0, sizeof(args)); | 498 | memset(&args, 0, sizeof(args)); |
570 | rq.cmd_type = REQ_TYPE_PM_SUSPEND; | 499 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
571 | rq.special = &args; | 500 | rq->cmd_type = REQ_TYPE_PM_SUSPEND; |
572 | rq.data = &rqpm; | 501 | rq->special = &args; |
502 | rq->data = &rqpm; | ||
573 | rqpm.pm_step = ide_pm_state_start_suspend; | 503 | rqpm.pm_step = ide_pm_state_start_suspend; |
574 | if (mesg.event == PM_EVENT_PRETHAW) | 504 | if (mesg.event == PM_EVENT_PRETHAW) |
575 | mesg.event = PM_EVENT_FREEZE; | 505 | mesg.event = PM_EVENT_FREEZE; |
576 | rqpm.pm_state = mesg.event; | 506 | rqpm.pm_state = mesg.event; |
577 | 507 | ||
578 | ret = ide_do_drive_cmd(drive, &rq, ide_wait); | 508 | ret = blk_execute_rq(drive->queue, NULL, rq, 0); |
509 | blk_put_request(rq); | ||
579 | /* only call ACPI _PS3 after both drivers are suspended */ | 510 | /* only call ACPI _PS3 after both drivers are suspended */ |
580 | if (!ret && (((drive->dn % 2) && hwif->drives[0].present | 511 | if (!ret && (((drive->dn % 2) && hwif->drives[0].present |
581 | && hwif->drives[1].present) | 512 | && hwif->drives[1].present) |
@@ -589,7 +520,7 @@ static int generic_ide_resume(struct device *dev) | |||
589 | { | 520 | { |
590 | ide_drive_t *drive = dev->driver_data; | 521 | ide_drive_t *drive = dev->driver_data; |
591 | ide_hwif_t *hwif = HWIF(drive); | 522 | ide_hwif_t *hwif = HWIF(drive); |
592 | struct request rq; | 523 | struct request *rq; |
593 | struct request_pm_state rqpm; | 524 | struct request_pm_state rqpm; |
594 | ide_task_t args; | 525 | ide_task_t args; |
595 | int err; | 526 | int err; |
@@ -602,16 +533,18 @@ static int generic_ide_resume(struct device *dev) | |||
602 | 533 | ||
603 | ide_acpi_exec_tfs(drive); | 534 | ide_acpi_exec_tfs(drive); |
604 | 535 | ||
605 | blk_rq_init(NULL, &rq); | ||
606 | memset(&rqpm, 0, sizeof(rqpm)); | 536 | memset(&rqpm, 0, sizeof(rqpm)); |
607 | memset(&args, 0, sizeof(args)); | 537 | memset(&args, 0, sizeof(args)); |
608 | rq.cmd_type = REQ_TYPE_PM_RESUME; | 538 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
609 | rq.special = &args; | 539 | rq->cmd_type = REQ_TYPE_PM_RESUME; |
610 | rq.data = &rqpm; | 540 | rq->cmd_flags |= REQ_PREEMPT; |
541 | rq->special = &args; | ||
542 | rq->data = &rqpm; | ||
611 | rqpm.pm_step = ide_pm_state_start_resume; | 543 | rqpm.pm_step = ide_pm_state_start_resume; |
612 | rqpm.pm_state = PM_EVENT_ON; | 544 | rqpm.pm_state = PM_EVENT_ON; |
613 | 545 | ||
614 | err = ide_do_drive_cmd(drive, &rq, ide_head_wait); | 546 | err = blk_execute_rq(drive->queue, NULL, rq, 1); |
547 | blk_put_request(rq); | ||
615 | 548 | ||
616 | if (err == 0 && dev->driver) { | 549 | if (err == 0 && dev->driver) { |
617 | ide_driver_t *drv = to_ide_driver(dev->driver); | 550 | ide_driver_t *drv = to_ide_driver(dev->driver); |
@@ -764,212 +697,6 @@ set_val: | |||
764 | 697 | ||
765 | EXPORT_SYMBOL(generic_ide_ioctl); | 698 | EXPORT_SYMBOL(generic_ide_ioctl); |
766 | 699 | ||
767 | /* | ||
768 | * stridx() returns the offset of c within s, | ||
769 | * or -1 if c is '\0' or not found within s. | ||
770 | */ | ||
771 | static int __init stridx (const char *s, char c) | ||
772 | { | ||
773 | char *i = strchr(s, c); | ||
774 | return (i && c) ? i - s : -1; | ||
775 | } | ||
776 | |||
777 | /* | ||
778 | * match_parm() does parsing for ide_setup(): | ||
779 | * | ||
780 | * 1. the first char of s must be '='. | ||
781 | * 2. if the remainder matches one of the supplied keywords, | ||
782 | * the index (1 based) of the keyword is negated and returned. | ||
783 | * 3. if the remainder is a series of no more than max_vals numbers | ||
784 | * separated by commas, the numbers are saved in vals[] and a | ||
785 | * count of how many were saved is returned. Base10 is assumed, | ||
786 | * and base16 is allowed when prefixed with "0x". | ||
787 | * 4. otherwise, zero is returned. | ||
788 | */ | ||
789 | static int __init match_parm (char *s, const char *keywords[], int vals[], int max_vals) | ||
790 | { | ||
791 | static const char *decimal = "0123456789"; | ||
792 | static const char *hex = "0123456789abcdef"; | ||
793 | int i, n; | ||
794 | |||
795 | if (*s++ == '=') { | ||
796 | /* | ||
797 | * Try matching against the supplied keywords, | ||
798 | * and return -(index+1) if we match one | ||
799 | */ | ||
800 | if (keywords != NULL) { | ||
801 | for (i = 0; *keywords != NULL; ++i) { | ||
802 | if (!strcmp(s, *keywords++)) | ||
803 | return -(i+1); | ||
804 | } | ||
805 | } | ||
806 | /* | ||
807 | * Look for a series of no more than "max_vals" | ||
808 | * numeric values separated by commas, in base10, | ||
809 | * or base16 when prefixed with "0x". | ||
810 | * Return a count of how many were found. | ||
811 | */ | ||
812 | for (n = 0; (i = stridx(decimal, *s)) >= 0;) { | ||
813 | vals[n] = i; | ||
814 | while ((i = stridx(decimal, *++s)) >= 0) | ||
815 | vals[n] = (vals[n] * 10) + i; | ||
816 | if (*s == 'x' && !vals[n]) { | ||
817 | while ((i = stridx(hex, *++s)) >= 0) | ||
818 | vals[n] = (vals[n] * 0x10) + i; | ||
819 | } | ||
820 | if (++n == max_vals) | ||
821 | break; | ||
822 | if (*s == ',' || *s == ';') | ||
823 | ++s; | ||
824 | } | ||
825 | if (!*s) | ||
826 | return n; | ||
827 | } | ||
828 | return 0; /* zero = nothing matched */ | ||
829 | } | ||
830 | |||
831 | /* | ||
832 | * ide_setup() gets called VERY EARLY during initialization, | ||
833 | * to handle kernel "command line" strings beginning with "hdx=" or "ide". | ||
834 | * | ||
835 | * Remember to update Documentation/ide/ide.txt if you change something here. | ||
836 | */ | ||
837 | static int __init ide_setup(char *s) | ||
838 | { | ||
839 | ide_hwif_t *hwif; | ||
840 | ide_drive_t *drive; | ||
841 | unsigned int hw, unit; | ||
842 | int vals[3]; | ||
843 | const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1); | ||
844 | |||
845 | if (strncmp(s,"hd",2) == 0 && s[2] == '=') /* hd= is for hd.c */ | ||
846 | return 0; /* driver and not us */ | ||
847 | |||
848 | if (strncmp(s,"ide",3) && strncmp(s,"idebus",6) && strncmp(s,"hd",2)) | ||
849 | return 0; | ||
850 | |||
851 | printk(KERN_INFO "ide_setup: %s", s); | ||
852 | init_ide_data (); | ||
853 | |||
854 | #ifdef CONFIG_BLK_DEV_IDEDOUBLER | ||
855 | if (!strcmp(s, "ide=doubler")) { | ||
856 | extern int ide_doubler; | ||
857 | |||
858 | printk(" : Enabled support for IDE doublers\n"); | ||
859 | ide_doubler = 1; | ||
860 | goto obsolete_option; | ||
861 | } | ||
862 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ | ||
863 | |||
864 | if (!strcmp(s, "ide=nodma")) { | ||
865 | printk(" : Prevented DMA\n"); | ||
866 | noautodma = 1; | ||
867 | goto obsolete_option; | ||
868 | } | ||
869 | |||
870 | #ifdef CONFIG_BLK_DEV_IDEACPI | ||
871 | if (!strcmp(s, "ide=noacpi")) { | ||
872 | //printk(" : Disable IDE ACPI support.\n"); | ||
873 | ide_noacpi = 1; | ||
874 | goto obsolete_option; | ||
875 | } | ||
876 | if (!strcmp(s, "ide=acpigtf")) { | ||
877 | //printk(" : Enable IDE ACPI _GTF support.\n"); | ||
878 | ide_acpigtf = 1; | ||
879 | goto obsolete_option; | ||
880 | } | ||
881 | if (!strcmp(s, "ide=acpionboot")) { | ||
882 | //printk(" : Call IDE ACPI methods on boot.\n"); | ||
883 | ide_acpionboot = 1; | ||
884 | goto obsolete_option; | ||
885 | } | ||
886 | #endif /* CONFIG_BLK_DEV_IDEACPI */ | ||
887 | |||
888 | /* | ||
889 | * Look for drive options: "hdx=" | ||
890 | */ | ||
891 | if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { | ||
892 | const char *hd_words[] = { | ||
893 | "none", "noprobe", "nowerr", "cdrom", "nodma", | ||
894 | "-6", "-7", "-8", "-9", "-10", | ||
895 | "noflush", "remap", "remap63", "scsi", NULL }; | ||
896 | unit = s[2] - 'a'; | ||
897 | hw = unit / MAX_DRIVES; | ||
898 | unit = unit % MAX_DRIVES; | ||
899 | hwif = &ide_hwifs[hw]; | ||
900 | drive = &hwif->drives[unit]; | ||
901 | if (strncmp(s + 4, "ide-", 4) == 0) { | ||
902 | strlcpy(drive->driver_req, s + 4, sizeof(drive->driver_req)); | ||
903 | goto obsolete_option; | ||
904 | } | ||
905 | switch (match_parm(&s[3], hd_words, vals, 3)) { | ||
906 | case -1: /* "none" */ | ||
907 | case -2: /* "noprobe" */ | ||
908 | drive->noprobe = 1; | ||
909 | goto obsolete_option; | ||
910 | case -3: /* "nowerr" */ | ||
911 | drive->bad_wstat = BAD_R_STAT; | ||
912 | goto obsolete_option; | ||
913 | case -4: /* "cdrom" */ | ||
914 | drive->present = 1; | ||
915 | drive->media = ide_cdrom; | ||
916 | /* an ATAPI device ignores DRDY */ | ||
917 | drive->ready_stat = 0; | ||
918 | goto obsolete_option; | ||
919 | case -5: /* nodma */ | ||
920 | drive->nodma = 1; | ||
921 | goto obsolete_option; | ||
922 | case -11: /* noflush */ | ||
923 | drive->noflush = 1; | ||
924 | goto obsolete_option; | ||
925 | case -12: /* "remap" */ | ||
926 | drive->remap_0_to_1 = 1; | ||
927 | goto obsolete_option; | ||
928 | case -13: /* "remap63" */ | ||
929 | drive->sect0 = 63; | ||
930 | goto obsolete_option; | ||
931 | case -14: /* "scsi" */ | ||
932 | drive->scsi = 1; | ||
933 | goto obsolete_option; | ||
934 | case 3: /* cyl,head,sect */ | ||
935 | drive->media = ide_disk; | ||
936 | drive->ready_stat = READY_STAT; | ||
937 | drive->cyl = drive->bios_cyl = vals[0]; | ||
938 | drive->head = drive->bios_head = vals[1]; | ||
939 | drive->sect = drive->bios_sect = vals[2]; | ||
940 | drive->present = 1; | ||
941 | drive->forced_geom = 1; | ||
942 | goto obsolete_option; | ||
943 | default: | ||
944 | goto bad_option; | ||
945 | } | ||
946 | } | ||
947 | |||
948 | if (s[0] != 'i' || s[1] != 'd' || s[2] != 'e') | ||
949 | goto bad_option; | ||
950 | /* | ||
951 | * Look for bus speed option: "idebus=" | ||
952 | */ | ||
953 | if (s[3] == 'b' && s[4] == 'u' && s[5] == 's') { | ||
954 | if (match_parm(&s[6], NULL, vals, 1) != 1) | ||
955 | goto bad_option; | ||
956 | if (vals[0] >= 20 && vals[0] <= 66) { | ||
957 | idebus_parameter = vals[0]; | ||
958 | } else | ||
959 | printk(" -- BAD BUS SPEED! Expected value from 20 to 66"); | ||
960 | goto obsolete_option; | ||
961 | } | ||
962 | |||
963 | bad_option: | ||
964 | printk(" -- BAD OPTION\n"); | ||
965 | return 1; | ||
966 | obsolete_option: | ||
967 | printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n"); | ||
968 | return 1; | ||
969 | } | ||
970 | |||
971 | EXPORT_SYMBOL(ide_lock); | ||
972 | |||
973 | static int ide_bus_match(struct device *dev, struct device_driver *drv) | 700 | static int ide_bus_match(struct device *dev, struct device_driver *drv) |
974 | { | 701 | { |
975 | return 1; | 702 | return 1; |
@@ -1281,11 +1008,6 @@ static int __init ide_init(void) | |||
1281 | int ret; | 1008 | int ret; |
1282 | 1009 | ||
1283 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); | 1010 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); |
1284 | system_bus_speed = ide_system_bus_speed(); | ||
1285 | |||
1286 | printk(KERN_INFO "ide: Assuming %dMHz system bus speed " | ||
1287 | "for PIO modes%s\n", system_bus_speed, | ||
1288 | idebus_parameter ? "" : "; override with idebus=xx"); | ||
1289 | 1011 | ||
1290 | ret = bus_register(&ide_bus_type); | 1012 | ret = bus_register(&ide_bus_type); |
1291 | if (ret < 0) { | 1013 | if (ret < 0) { |
@@ -1311,32 +1033,7 @@ out_port_class: | |||
1311 | return ret; | 1033 | return ret; |
1312 | } | 1034 | } |
1313 | 1035 | ||
1314 | #ifdef MODULE | 1036 | static void __exit ide_exit(void) |
1315 | static char *options = NULL; | ||
1316 | module_param(options, charp, 0); | ||
1317 | MODULE_LICENSE("GPL"); | ||
1318 | |||
1319 | static void __init parse_options (char *line) | ||
1320 | { | ||
1321 | char *next = line; | ||
1322 | |||
1323 | if (line == NULL || !*line) | ||
1324 | return; | ||
1325 | while ((line = next) != NULL) { | ||
1326 | if ((next = strchr(line,' ')) != NULL) | ||
1327 | *next++ = 0; | ||
1328 | if (!ide_setup(line)) | ||
1329 | printk (KERN_INFO "Unknown option '%s'\n", line); | ||
1330 | } | ||
1331 | } | ||
1332 | |||
1333 | int __init init_module (void) | ||
1334 | { | ||
1335 | parse_options(options); | ||
1336 | return ide_init(); | ||
1337 | } | ||
1338 | |||
1339 | void __exit cleanup_module (void) | ||
1340 | { | 1037 | { |
1341 | proc_ide_destroy(); | 1038 | proc_ide_destroy(); |
1342 | 1039 | ||
@@ -1345,10 +1042,7 @@ void __exit cleanup_module (void) | |||
1345 | bus_unregister(&ide_bus_type); | 1042 | bus_unregister(&ide_bus_type); |
1346 | } | 1043 | } |
1347 | 1044 | ||
1348 | #else /* !MODULE */ | ||
1349 | |||
1350 | __setup("", ide_setup); | ||
1351 | |||
1352 | module_init(ide_init); | 1045 | module_init(ide_init); |
1046 | module_exit(ide_exit); | ||
1353 | 1047 | ||
1354 | #endif /* MODULE */ | 1048 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 90c65cf97448..052125fafcfa 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -116,7 +116,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
116 | int time1, time2; | 116 | int time1, time2; |
117 | u8 param1, param2, param3, param4; | 117 | u8 param1, param2, param3, param4; |
118 | unsigned long flags; | 118 | unsigned long flags; |
119 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 119 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
120 | 120 | ||
121 | /* calculate timing, according to PIO mode */ | 121 | /* calculate timing, according to PIO mode */ |
122 | time1 = ide_pio_cycle_time(drive, pio); | 122 | time1 = ide_pio_cycle_time(drive, pio); |
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index fed7d812761c..b78941680c32 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -64,9 +64,7 @@ | |||
64 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) | 64 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) |
65 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) | 65 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) |
66 | 66 | ||
67 | int ide_doubler = 0; /* support IDE doublers? */ | 67 | static int ide_doubler; |
68 | EXPORT_SYMBOL_GPL(ide_doubler); | ||
69 | |||
70 | module_param_named(doubler, ide_doubler, bool, 0); | 68 | module_param_named(doubler, ide_doubler, bool, 0); |
71 | MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); | 69 | MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); |
72 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ | 70 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 4fe516df9f74..dd6dfb32e853 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -212,7 +212,7 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) | |||
212 | { | 212 | { |
213 | int active_time, recovery_time; | 213 | int active_time, recovery_time; |
214 | int active_cycles, recovery_cycles; | 214 | int active_cycles, recovery_cycles; |
215 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 215 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
216 | 216 | ||
217 | if (pio) { | 217 | if (pio) { |
218 | unsigned int cycle_time; | 218 | unsigned int cycle_time; |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 6424af154325..51dba82f8812 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -110,7 +110,7 @@ static void qd65xx_select(ide_drive_t *drive) | |||
110 | 110 | ||
111 | static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) | 111 | static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) |
112 | { | 112 | { |
113 | int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 113 | int clk = ide_vlb_clk ? ide_vlb_clk : 50; |
114 | u8 act_cyc, rec_cyc; | 114 | u8 act_cyc, rec_cyc; |
115 | 115 | ||
116 | if (clk <= 33) { | 116 | if (clk <= 33) { |
@@ -132,7 +132,7 @@ static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery | |||
132 | 132 | ||
133 | static u8 qd6580_compute_timing (int active_time, int recovery_time) | 133 | static u8 qd6580_compute_timing (int active_time, int recovery_time) |
134 | { | 134 | { |
135 | int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 135 | int clk = ide_vlb_clk ? ide_vlb_clk : 50; |
136 | u8 act_cyc, rec_cyc; | 136 | u8 act_cyc, rec_cyc; |
137 | 137 | ||
138 | act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17); | 138 | act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17); |
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 7f46c224b7c4..ae7a4329a581 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -140,7 +140,7 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
140 | 140 | ||
141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) | 141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) |
142 | { | 142 | { |
143 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); | 143 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
144 | 144 | ||
145 | if (bus_speed <= 33) | 145 | if (bus_speed <= 33) |
146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); | 146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index f2129d5e07f2..f2de00adf147 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -72,7 +72,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
72 | int s_time, a_time, c_time; | 72 | int s_time, a_time, c_time; |
73 | u8 s_clc, a_clc, r_clc; | 73 | u8 s_clc, a_clc, r_clc; |
74 | unsigned long flags; | 74 | unsigned long flags; |
75 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); | 75 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
76 | int port = hwif->channel ? 0x5c : 0x58; | 76 | int port = hwif->channel ? 0x5c : 0x58; |
77 | int portFIFO = hwif->channel ? 0x55 : 0x54; | 77 | int portFIFO = hwif->channel ? 0x55 : 0x54; |
78 | u8 cd_dma_fifo = 0; | 78 | u8 cd_dma_fifo = 0; |
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index efcf54338be7..ad222206a429 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -53,20 +53,20 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask, | |||
53 | u8 t = 0, offset = amd_offset(dev); | 53 | u8 t = 0, offset = amd_offset(dev); |
54 | 54 | ||
55 | pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); | 55 | pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); |
56 | t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); | 56 | t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); |
57 | pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); | 57 | pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); |
58 | 58 | ||
59 | pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), | 59 | pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), |
60 | ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); | 60 | ((clamp_val(timing->act8b, 1, 16) - 1) << 4) | (clamp_val(timing->rec8b, 1, 16) - 1)); |
61 | 61 | ||
62 | pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), | 62 | pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), |
63 | ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); | 63 | ((clamp_val(timing->active, 1, 16) - 1) << 4) | (clamp_val(timing->recover, 1, 16) - 1)); |
64 | 64 | ||
65 | switch (udma_mask) { | 65 | switch (udma_mask) { |
66 | case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; | 66 | case ATA_UDMA2: t = timing->udma ? (0xc0 | (clamp_val(timing->udma, 2, 5) - 2)) : 0x03; break; |
67 | case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; | 67 | case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 2, 10)]) : 0x03; break; |
68 | case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; | 68 | case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 1, 10)]) : 0x03; break; |
69 | case ATA_UDMA6: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 15)]) : 0x03; break; | 69 | case ATA_UDMA6: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 1, 15)]) : 0x03; break; |
70 | default: return; | 70 | default: return; |
71 | } | 71 | } |
72 | 72 | ||
@@ -179,7 +179,7 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
179 | * Determine the system bus clock. | 179 | * Determine the system bus clock. |
180 | */ | 180 | */ |
181 | 181 | ||
182 | amd_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; | 182 | amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; |
183 | 183 | ||
184 | switch (amd_clock) { | 184 | switch (amd_clock) { |
185 | case 33000: amd_clock = 33333; break; | 185 | case 33000: amd_clock = 33333; break; |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index b38a1980dcd5..cd1ba14984ab 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -525,12 +525,10 @@ static void cmd640_set_mode(ide_drive_t *drive, unsigned int index, | |||
525 | u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count; | 525 | u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count; |
526 | int bus_speed; | 526 | int bus_speed; |
527 | 527 | ||
528 | if (cmd640_vlb && ide_vlb_clk) | 528 | if (cmd640_vlb) |
529 | bus_speed = ide_vlb_clk; | 529 | bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
530 | else if (!cmd640_vlb && ide_pci_clk) | ||
531 | bus_speed = ide_pci_clk; | ||
532 | else | 530 | else |
533 | bus_speed = system_bus_clock(); | 531 | bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
534 | 532 | ||
535 | if (pio_mode > 5) | 533 | if (pio_mode > 5) |
536 | pio_mode = 5; | 534 | pio_mode = 5; |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 08674711d089..ca4774aa27ee 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -69,7 +69,7 @@ static u8 quantize_timing(int timing, int quant) | |||
69 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) | 69 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) |
70 | { | 70 | { |
71 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 71 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
72 | int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock()); | 72 | int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : 33); |
73 | u8 cycle_count, active_count, recovery_count, drwtim; | 73 | u8 cycle_count, active_count, recovery_count, drwtim; |
74 | static const u8 recovery_values[] = | 74 | static const u8 recovery_values[] = |
75 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; | 75 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; |
@@ -128,7 +128,7 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | |||
128 | ide_pio_timings[pio].active_time); | 128 | ide_pio_timings[pio].active_time); |
129 | 129 | ||
130 | setup_count = quantize_timing(ide_pio_timings[pio].setup_time, | 130 | setup_count = quantize_timing(ide_pio_timings[pio].setup_time, |
131 | 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock())); | 131 | 1000 / (ide_pci_clk ? ide_pci_clk : 33)); |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * The primary channel has individual address setup timing registers | 134 | * The primary channel has individual address setup timing registers |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 77cc22c2ad45..8c534afcb6c8 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -134,7 +134,7 @@ static int calc_clk(int time, int bus_speed) | |||
134 | static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) | 134 | static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) |
135 | { | 135 | { |
136 | int clk1, clk2; | 136 | int clk1, clk2; |
137 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); | 137 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
138 | 138 | ||
139 | /* we don't check against CY82C693's min and max speed, | 139 | /* we don't check against CY82C693's min and max speed, |
140 | * so you can play with the idebus=xx parameter | 140 | * so you can play with the idebus=xx parameter |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index c929dadaaaff..397c6cbe953c 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -759,8 +759,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | |||
759 | enable_irq (hwif->irq); | 759 | enable_irq (hwif->irq); |
760 | } | 760 | } |
761 | } else | 761 | } else |
762 | outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), | 762 | outb(ATA_DEVCTL_OBS | (mask ? 2 : 0), hwif->io_ports.ctl_addr); |
763 | hwif->io_ports.ctl_addr); | ||
764 | } | 763 | } |
765 | 764 | ||
766 | /* | 765 | /* |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index a7a41bb82778..45ba71a7182f 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -76,7 +76,7 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | /* be sure we're looking at the low order bits */ | 78 | /* be sure we're looking at the low order bits */ |
79 | outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 79 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
80 | 80 | ||
81 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 81 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
82 | tf->nsect = inb(io_ports->nsect_addr); | 82 | tf->nsect = inb(io_ports->nsect_addr); |
@@ -90,7 +90,7 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
90 | tf->device = superio_ide_inb(io_ports->device_addr); | 90 | tf->device = superio_ide_inb(io_ports->device_addr); |
91 | 91 | ||
92 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 92 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
93 | outb(drive->ctl | 0x80, io_ports->ctl_addr); | 93 | outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
94 | 94 | ||
95 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 95 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
96 | tf->hob_feature = inb(io_ports->feature_addr); | 96 | tf->hob_feature = inb(io_ports->feature_addr); |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 910fb00deb71..1584ebb6a185 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -148,11 +148,8 @@ static void scc_ide_outb(u8 addr, unsigned long port) | |||
148 | out_be32((void*)port, addr); | 148 | out_be32((void*)port, addr); |
149 | } | 149 | } |
150 | 150 | ||
151 | static void | 151 | static void scc_ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port) |
152 | scc_ide_outbsync(ide_drive_t * drive, u8 addr, unsigned long port) | ||
153 | { | 152 | { |
154 | ide_hwif_t *hwif = HWIF(drive); | ||
155 | |||
156 | out_be32((void*)port, addr); | 153 | out_be32((void*)port, addr); |
157 | eieio(); | 154 | eieio(); |
158 | in_be32((void*)(hwif->dma_base + 0x01c)); | 155 | in_be32((void*)(hwif->dma_base + 0x01c)); |
@@ -662,8 +659,6 @@ static void scc_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
662 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | 659 | if (task->tf_flags & IDE_TFLAG_FLAGGED) |
663 | HIHI = 0xFF; | 660 | HIHI = 0xFF; |
664 | 661 | ||
665 | ide_set_irq(drive, 1); | ||
666 | |||
667 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) | 662 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) |
668 | out_be32((void *)io_ports->data_addr, | 663 | out_be32((void *)io_ports->data_addr, |
669 | (tf->hob_data << 8) | tf->data); | 664 | (tf->hob_data << 8) | tf->data); |
@@ -708,7 +703,7 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
708 | } | 703 | } |
709 | 704 | ||
710 | /* be sure we're looking at the low order bits */ | 705 | /* be sure we're looking at the low order bits */ |
711 | scc_ide_outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 706 | scc_ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
712 | 707 | ||
713 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 708 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
714 | tf->nsect = scc_ide_inb(io_ports->nsect_addr); | 709 | tf->nsect = scc_ide_inb(io_ports->nsect_addr); |
@@ -722,7 +717,7 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
722 | tf->device = scc_ide_inb(io_ports->device_addr); | 717 | tf->device = scc_ide_inb(io_ports->device_addr); |
723 | 718 | ||
724 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 719 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
725 | scc_ide_outb(drive->ctl | 0x80, io_ports->ctl_addr); | 720 | scc_ide_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
726 | 721 | ||
727 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 722 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
728 | tf->hob_feature = scc_ide_inb(io_ports->feature_addr); | 723 | tf->hob_feature = scc_ide_inb(io_ports->feature_addr); |
@@ -795,7 +790,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
795 | 790 | ||
796 | hwif->dma_base = dma_base; | 791 | hwif->dma_base = dma_base; |
797 | hwif->config_data = ports->ctl; | 792 | hwif->config_data = ports->ctl; |
798 | hwif->mmio = 1; | ||
799 | } | 793 | } |
800 | 794 | ||
801 | /** | 795 | /** |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 16a0bce17d69..24513e3dcd6b 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -111,7 +111,7 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port, | |||
111 | static void | 111 | static void |
112 | sgiioc4_maskproc(ide_drive_t * drive, int mask) | 112 | sgiioc4_maskproc(ide_drive_t * drive, int mask) |
113 | { | 113 | { |
114 | writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), | 114 | writeb(ATA_DEVCTL_OBS | (mask ? 2 : 0), |
115 | (void __iomem *)drive->hwif->io_ports.ctl_addr); | 115 | (void __iomem *)drive->hwif->io_ports.ctl_addr); |
116 | } | 116 | } |
117 | 117 | ||
@@ -369,8 +369,7 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
369 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; | 369 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; |
370 | 370 | ||
371 | pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, | 371 | pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, |
372 | (dma_addr_t *) &(hwif->dma_status)); | 372 | (dma_addr_t *)&hwif->extra_base); |
373 | |||
374 | if (pad) { | 373 | if (pad) { |
375 | ide_set_hwifdata(hwif, pad); | 374 | ide_set_hwifdata(hwif, pad); |
376 | return 0; | 375 | return 0; |
@@ -439,7 +438,7 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
439 | 438 | ||
440 | /* Address of the Ending DMA */ | 439 | /* Address of the Ending DMA */ |
441 | memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE); | 440 | memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE); |
442 | ending_dma_addr = cpu_to_le32(hwif->dma_status); | 441 | ending_dma_addr = cpu_to_le32(hwif->extra_base); |
443 | writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4)); | 442 | writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4)); |
444 | 443 | ||
445 | writel(dma_direction, (void __iomem *)ioc4_dma_addr); | 444 | writel(dma_direction, (void __iomem *)ioc4_dma_addr); |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 0006b9e58567..b75e9bb390a7 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -94,7 +94,7 @@ static unsigned long siimage_selreg(ide_hwif_t *hwif, int r) | |||
94 | unsigned long base = (unsigned long)hwif->hwif_data; | 94 | unsigned long base = (unsigned long)hwif->hwif_data; |
95 | 95 | ||
96 | base += 0xA0 + r; | 96 | base += 0xA0 + r; |
97 | if (hwif->mmio) | 97 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
98 | base += hwif->channel << 6; | 98 | base += hwif->channel << 6; |
99 | else | 99 | else |
100 | base += hwif->channel << 4; | 100 | base += hwif->channel << 4; |
@@ -117,7 +117,7 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) | |||
117 | unsigned long base = (unsigned long)hwif->hwif_data; | 117 | unsigned long base = (unsigned long)hwif->hwif_data; |
118 | 118 | ||
119 | base += 0xA0 + r; | 119 | base += 0xA0 + r; |
120 | if (hwif->mmio) | 120 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
121 | base += hwif->channel << 6; | 121 | base += hwif->channel << 6; |
122 | else | 122 | else |
123 | base += hwif->channel << 4; | 123 | base += hwif->channel << 4; |
@@ -190,7 +190,9 @@ static u8 sil_pata_udma_filter(ide_drive_t *drive) | |||
190 | unsigned long base = (unsigned long)hwif->hwif_data; | 190 | unsigned long base = (unsigned long)hwif->hwif_data; |
191 | u8 scsc, mask = 0; | 191 | u8 scsc, mask = 0; |
192 | 192 | ||
193 | scsc = sil_ioread8(dev, base + (hwif->mmio ? 0x4A : 0x8A)); | 193 | base += (hwif->host_flags & IDE_HFLAG_MMIO) ? 0x4A : 0x8A; |
194 | |||
195 | scsc = sil_ioread8(dev, base); | ||
194 | 196 | ||
195 | switch (scsc & 0x30) { | 197 | switch (scsc & 0x30) { |
196 | case 0x10: /* 133 */ | 198 | case 0x10: /* 133 */ |
@@ -238,8 +240,9 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
238 | unsigned long tfaddr = siimage_selreg(hwif, 0x02); | 240 | unsigned long tfaddr = siimage_selreg(hwif, 0x02); |
239 | unsigned long base = (unsigned long)hwif->hwif_data; | 241 | unsigned long base = (unsigned long)hwif->hwif_data; |
240 | u8 tf_pio = pio; | 242 | u8 tf_pio = pio; |
241 | u8 addr_mask = hwif->channel ? (hwif->mmio ? 0xF4 : 0x84) | 243 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
242 | : (hwif->mmio ? 0xB4 : 0x80); | 244 | u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) |
245 | : (mmio ? 0xB4 : 0x80); | ||
243 | u8 mode = 0; | 246 | u8 mode = 0; |
244 | u8 unit = drive->select.b.unit; | 247 | u8 unit = drive->select.b.unit; |
245 | 248 | ||
@@ -290,13 +293,13 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
290 | u16 ultra = 0, multi = 0; | 293 | u16 ultra = 0, multi = 0; |
291 | u8 mode = 0, unit = drive->select.b.unit; | 294 | u8 mode = 0, unit = drive->select.b.unit; |
292 | unsigned long base = (unsigned long)hwif->hwif_data; | 295 | unsigned long base = (unsigned long)hwif->hwif_data; |
293 | u8 scsc = 0, addr_mask = hwif->channel ? | 296 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
294 | (hwif->mmio ? 0xF4 : 0x84) : | 297 | u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) |
295 | (hwif->mmio ? 0xB4 : 0x80); | 298 | : (mmio ? 0xB4 : 0x80); |
296 | unsigned long ma = siimage_seldev(drive, 0x08); | 299 | unsigned long ma = siimage_seldev(drive, 0x08); |
297 | unsigned long ua = siimage_seldev(drive, 0x0C); | 300 | unsigned long ua = siimage_seldev(drive, 0x0C); |
298 | 301 | ||
299 | scsc = sil_ioread8 (dev, base + (hwif->mmio ? 0x4A : 0x8A)); | 302 | scsc = sil_ioread8 (dev, base + (mmio ? 0x4A : 0x8A)); |
300 | mode = sil_ioread8 (dev, base + addr_mask); | 303 | mode = sil_ioread8 (dev, base + addr_mask); |
301 | multi = sil_ioread16(dev, ma); | 304 | multi = sil_ioread16(dev, ma); |
302 | ultra = sil_ioread16(dev, ua); | 305 | ultra = sil_ioread16(dev, ua); |
@@ -391,7 +394,7 @@ static int siimage_mmio_dma_test_irq(ide_drive_t *drive) | |||
391 | 394 | ||
392 | static int siimage_dma_test_irq(ide_drive_t *drive) | 395 | static int siimage_dma_test_irq(ide_drive_t *drive) |
393 | { | 396 | { |
394 | if (drive->hwif->mmio) | 397 | if (drive->hwif->host_flags & IDE_HFLAG_MMIO) |
395 | return siimage_mmio_dma_test_irq(drive); | 398 | return siimage_mmio_dma_test_irq(drive); |
396 | else | 399 | else |
397 | return siimage_io_dma_test_irq(drive); | 400 | return siimage_io_dma_test_irq(drive); |
@@ -640,8 +643,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
640 | hwif->irq = dev->irq; | 643 | hwif->irq = dev->irq; |
641 | 644 | ||
642 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); | 645 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); |
643 | |||
644 | hwif->mmio = 1; | ||
645 | } | 646 | } |
646 | 647 | ||
647 | static int is_dev_seagate_sata(ide_drive_t *drive) | 648 | static int is_dev_seagate_sata(ide_drive_t *drive) |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 566e0ecb8db1..3ed9728abd24 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -120,21 +120,21 @@ static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | |||
120 | 120 | ||
121 | if (~vdev->via_config->flags & VIA_BAD_AST) { | 121 | if (~vdev->via_config->flags & VIA_BAD_AST) { |
122 | pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); | 122 | pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); |
123 | t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); | 123 | t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); |
124 | pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); | 124 | pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); |
125 | } | 125 | } |
126 | 126 | ||
127 | pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)), | 127 | pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)), |
128 | ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); | 128 | ((clamp_val(timing->act8b, 1, 16) - 1) << 4) | (clamp_val(timing->rec8b, 1, 16) - 1)); |
129 | 129 | ||
130 | pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), | 130 | pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), |
131 | ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); | 131 | ((clamp_val(timing->active, 1, 16) - 1) << 4) | (clamp_val(timing->recover, 1, 16) - 1)); |
132 | 132 | ||
133 | switch (vdev->via_config->udma_mask) { | 133 | switch (vdev->via_config->udma_mask) { |
134 | case ATA_UDMA2: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; | 134 | case ATA_UDMA2: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 5) - 2)) : 0x03; break; |
135 | case ATA_UDMA4: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; | 135 | case ATA_UDMA4: t = timing->udma ? (0xe8 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x0f; break; |
136 | case ATA_UDMA5: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; | 136 | case ATA_UDMA5: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; |
137 | case ATA_UDMA6: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; | 137 | case ATA_UDMA6: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; |
138 | default: return; | 138 | default: return; |
139 | } | 139 | } |
140 | 140 | ||
@@ -340,7 +340,7 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const | |||
340 | * Determine system bus clock. | 340 | * Determine system bus clock. |
341 | */ | 341 | */ |
342 | 342 | ||
343 | via_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; | 343 | via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; |
344 | 344 | ||
345 | switch (via_clock) { | 345 | switch (via_clock) { |
346 | case 33000: via_clock = 33333; break; | 346 | case 33000: via_clock = 33333; break; |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index ba2d58727964..dcb2c466bb97 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -480,13 +480,13 @@ pmac_ide_do_update_timings(ide_drive_t *drive) | |||
480 | pmac_ide_selectproc(drive); | 480 | pmac_ide_selectproc(drive); |
481 | } | 481 | } |
482 | 482 | ||
483 | static void | 483 | static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) |
484 | pmac_outbsync(ide_drive_t *drive, u8 value, unsigned long port) | ||
485 | { | 484 | { |
486 | u32 tmp; | 485 | u32 tmp; |
487 | 486 | ||
488 | writeb(value, (void __iomem *) port); | 487 | writeb(value, (void __iomem *) port); |
489 | tmp = readl(PMAC_IDE_REG(IDE_TIMING_CONFIG)); | 488 | tmp = readl((void __iomem *)(hwif->io_ports.data_addr |
489 | + IDE_TIMING_CONFIG)); | ||
490 | } | 490 | } |
491 | 491 | ||
492 | /* | 492 | /* |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 5171601fb255..abcfb1739d4d 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -87,7 +87,7 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
87 | unsigned long dma_base = 0; | 87 | unsigned long dma_base = 0; |
88 | u8 dma_stat = 0; | 88 | u8 dma_stat = 0; |
89 | 89 | ||
90 | if (hwif->mmio) | 90 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
91 | return hwif->dma_base; | 91 | return hwif->dma_base; |
92 | 92 | ||
93 | if (hwif->mate && hwif->mate->dma_base) { | 93 | if (hwif->mate && hwif->mate->dma_base) { |
@@ -374,7 +374,7 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
374 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | 374 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
375 | return -1; | 375 | return -1; |
376 | 376 | ||
377 | if (hwif->mmio) | 377 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
378 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); | 378 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
379 | else | 379 | else |
380 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", | 380 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |