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: (32 commits)
ide-atapi: start dma in a drive-specific way
ide-atapi: put the rest of non-ide-cd code into the else-clause of ide_transfer_pc
ide-atapi: remove timeout arg to ide_issue_pc
ide-cd: remove handler wrappers
ide-cd: remove xferlen arg to cdrom_start_packet_command
ide-atapi: split drive-specific functionality in ide_issue_pc
ide-atapi: assign expiry and timeout based on device type
ide-atapi: compute cmd_len based on device type in ide_transfer_pc
ide: remove the last ide-scsi remnants
ide-atapi: remove ide-scsi remnants from ide_pc_intr()
ide-atapi: remove ide-scsi remnants from ide_transfer_pc()
ide-atapi: remove ide-scsi remnants from ide_issue_pc
ide-cd: move cdrom_timer_expiry to ide-atapi.c
ide-atapi: teach ide atapi about drive->waiting_for_dma
ide-atapi: accomodate transfer length calculation for ide-cd
ide-atapi: setup dma for ide-cd
ide-atapi: combine drive-specific assignments
ide-atapi: add a dev_is_idecd-inline
remove ide-scsi
ide-floppy: allocate only toplevel packet commands
...

+618 -1613
-9
Documentation/feature-removal-schedule.txt
··· 310 310 311 311 --------------------------- 312 312 313 - What: ide-scsi (BLK_DEV_IDESCSI) 314 - When: 2.6.29 315 - Why: The 2.6 kernel supports direct writing to ide CD drives, which 316 - eliminates the need for ide-scsi. The new method is more 317 - efficient in every way. 318 - Who: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> 319 - 320 - --------------------------- 321 - 322 313 What: i2c_attach_client(), i2c_detach_client(), i2c_driver->detach_client() 323 314 When: 2.6.29 (ideally) or 2.6.30 (more likely) 324 315 Why: Deprecated by the new (standard) device driver binding model. Use
-5
MAINTAINERS
··· 2152 2152 L: linux-kernel@vger.kernel.org 2153 2153 S: Maintained 2154 2154 2155 - IDE-SCSI DRIVER 2156 - L: linux-ide@vger.kernel.org 2157 - L: linux-scsi@vger.kernel.org 2158 - S: Orphan 2159 - 2160 2155 IDLE-I7300 2161 2156 P: Andy Henroid 2162 2157 M: andrew.d.henroid@intel.com
+1 -17
drivers/ide/Kconfig
··· 137 137 138 138 config BLK_DEV_IDECD 139 139 tristate "Include IDE/ATAPI CDROM support" 140 + select IDE_ATAPI 140 141 ---help--- 141 142 If you have a CD-ROM drive using the ATAPI protocol, say Y. ATAPI is 142 143 a newer protocol used by IDE CD-ROM and TAPE drives, similar to the ··· 185 184 186 185 To compile this driver as a module, choose M here: the 187 186 module will be called ide-tape. 188 - 189 - config BLK_DEV_IDESCSI 190 - tristate "SCSI emulation support (DEPRECATED)" 191 - depends on SCSI 192 - select IDE_ATAPI 193 - ---help--- 194 - WARNING: ide-scsi is no longer needed for cd writing applications! 195 - The 2.6 kernel supports direct writing to ide-cd, which eliminates 196 - the need for ide-scsi + the entire scsi stack just for writing a 197 - cd. The new method is more efficient in every way. 198 - 199 - This will provide SCSI host adapter emulation for IDE ATAPI devices, 200 - and will allow you to use a SCSI device driver instead of a native 201 - ATAPI driver. 202 - 203 - If both this SCSI emulation and native ATAPI support are compiled 204 - into the kernel, the native support will be used. 205 187 206 188 config BLK_DEV_IDEACPI 207 189 bool "IDE ACPI support"
+1 -1
drivers/ide/Makefile
··· 5 5 EXTRA_CFLAGS += -Idrivers/ide 6 6 7 7 ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ 8 - ide-taskfile.o ide-pm.o ide-park.o ide-pio-blacklist.o 8 + ide-taskfile.o ide-pm.o ide-park.o ide-pio-blacklist.o ide-sysfs.o 9 9 10 10 # core IDE code 11 11 ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o
+145 -111
drivers/ide/ide-atapi.c
··· 3 3 */ 4 4 5 5 #include <linux/kernel.h> 6 + #include <linux/cdrom.h> 6 7 #include <linux/delay.h> 7 8 #include <linux/ide.h> 8 9 #include <scsi/scsi.h> ··· 14 13 #else 15 14 #define debug_log(fmt, args...) do {} while (0) 16 15 #endif 16 + 17 + #define ATAPI_MIN_CDB_BYTES 12 18 + 19 + static inline int dev_is_idecd(ide_drive_t *drive) 20 + { 21 + return drive->media == ide_cdrom || drive->media == ide_optical; 22 + } 17 23 18 24 /* 19 25 * Check whether we can support a device, ··· 241 233 } 242 234 EXPORT_SYMBOL_GPL(ide_retry_pc); 243 235 244 - int ide_scsi_expiry(ide_drive_t *drive) 236 + int ide_cd_expiry(ide_drive_t *drive) 245 237 { 246 - struct ide_atapi_pc *pc = drive->pc; 238 + struct request *rq = HWGROUP(drive)->rq; 239 + unsigned long wait = 0; 247 240 248 - debug_log("%s called for %lu at %lu\n", __func__, 249 - pc->scsi_cmd->serial_number, jiffies); 241 + debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]); 250 242 251 - pc->flags |= PC_FLAG_TIMEDOUT; 252 - 253 - return 0; /* we do not want the IDE subsystem to retry */ 243 + /* 244 + * Some commands are *slow* and normally take a long time to complete. 245 + * Usually we can use the ATAPI "disconnect" to bypass this, but not all 246 + * commands/drives support that. Let ide_timer_expiry keep polling us 247 + * for these. 248 + */ 249 + switch (rq->cmd[0]) { 250 + case GPCMD_BLANK: 251 + case GPCMD_FORMAT_UNIT: 252 + case GPCMD_RESERVE_RZONE_TRACK: 253 + case GPCMD_CLOSE_TRACK: 254 + case GPCMD_FLUSH_CACHE: 255 + wait = ATAPI_WAIT_PC; 256 + break; 257 + default: 258 + if (!(rq->cmd_flags & REQ_QUIET)) 259 + printk(KERN_INFO "cmd 0x%x timed out\n", 260 + rq->cmd[0]); 261 + wait = 0; 262 + break; 263 + } 264 + return wait; 254 265 } 255 - EXPORT_SYMBOL_GPL(ide_scsi_expiry); 266 + EXPORT_SYMBOL_GPL(ide_cd_expiry); 267 + 268 + int ide_cd_get_xferlen(struct request *rq) 269 + { 270 + if (blk_fs_request(rq)) 271 + return 32768; 272 + else if (blk_sense_request(rq) || blk_pc_request(rq) || 273 + rq->cmd_type == REQ_TYPE_ATA_PC) 274 + return rq->data_len; 275 + else 276 + return 0; 277 + } 278 + EXPORT_SYMBOL_GPL(ide_cd_get_xferlen); 256 279 257 280 /* 258 281 * This is the usual interrupt handler which will be called during a packet ··· 297 258 struct request *rq = hwif->hwgroup->rq; 298 259 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 299 260 xfer_func_t *xferfunc; 300 - ide_expiry_t *expiry; 301 261 unsigned int timeout, temp; 302 262 u16 bcount; 303 - u8 stat, ireason, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI), dsc = 0; 263 + u8 stat, ireason, dsc = 0; 304 264 305 265 debug_log("Enter %s - interrupt handler\n", __func__); 306 266 307 - if (scsi) { 308 - timeout = ide_scsi_get_timeout(pc); 309 - expiry = ide_scsi_expiry; 310 - } else { 311 - timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD 312 - : WAIT_TAPE_CMD; 313 - expiry = NULL; 314 - } 267 + timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD 268 + : WAIT_TAPE_CMD; 315 269 316 270 if (pc->flags & PC_FLAG_TIMEDOUT) { 317 271 drive->pc_callback(drive, 0); ··· 316 284 317 285 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { 318 286 if (hwif->dma_ops->dma_end(drive) || 319 - (drive->media == ide_tape && !scsi && (stat & ATA_ERR))) { 320 - if (drive->media == ide_floppy && !scsi) 287 + (drive->media == ide_tape && (stat & ATA_ERR))) { 288 + if (drive->media == ide_floppy) 321 289 printk(KERN_ERR "%s: DMA %s error\n", 322 290 drive->name, rq_data_dir(pc->rq) 323 291 ? "write" : "read"); ··· 339 307 340 308 local_irq_enable_in_hardirq(); 341 309 342 - if (drive->media == ide_tape && !scsi && 310 + if (drive->media == ide_tape && 343 311 (stat & ATA_ERR) && rq->cmd[0] == REQUEST_SENSE) 344 312 stat &= ~ATA_ERR; 345 313 ··· 347 315 /* Error detected */ 348 316 debug_log("%s: I/O error\n", drive->name); 349 317 350 - if (drive->media != ide_tape || scsi) { 318 + if (drive->media != ide_tape) 351 319 pc->rq->errors++; 352 - if (scsi) 353 - goto cmd_finished; 354 - } 355 320 356 321 if (rq->cmd[0] == REQUEST_SENSE) { 357 322 printk(KERN_ERR "%s: I/O error in request sense" ··· 364 335 /* queued, but not started */ 365 336 return ide_stopped; 366 337 } 367 - cmd_finished: 368 338 pc->error = 0; 369 339 370 340 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && (stat & ATA_DSC) == 0) ··· 410 382 "us more data than expected - " 411 383 "discarding data\n", 412 384 drive->name); 413 - if (scsi) 414 - temp = pc->buf_size - pc->xferred; 415 - else 416 - temp = 0; 417 - if (temp) { 418 - if (pc->sg) 419 - drive->pc_io_buffers(drive, pc, 420 - temp, 0); 421 - else 422 - tp_ops->input_data(drive, NULL, 423 - pc->cur_pos, temp); 424 - printk(KERN_ERR "%s: transferred %d of " 425 - "%d bytes\n", 426 - drive->name, 427 - temp, bcount); 428 - } 429 - pc->xferred += temp; 430 - pc->cur_pos += temp; 431 - ide_pad_transfer(drive, 0, bcount - temp); 385 + 386 + ide_pad_transfer(drive, 0, bcount); 432 387 goto next_irq; 433 388 } 434 389 debug_log("The device wants to send us more data than " ··· 421 410 } else 422 411 xferfunc = tp_ops->output_data; 423 412 424 - if ((drive->media == ide_floppy && !scsi && !pc->buf) || 425 - (drive->media == ide_tape && !scsi && pc->bh) || 426 - (scsi && pc->sg)) { 413 + if ((drive->media == ide_floppy && !pc->buf) || 414 + (drive->media == ide_tape && pc->bh)) { 427 415 int done = drive->pc_io_buffers(drive, pc, bcount, 428 416 !!(pc->flags & PC_FLAG_WRITING)); 429 417 430 418 /* FIXME: don't do partial completions */ 431 - if (drive->media == ide_floppy && !scsi) 419 + if (drive->media == ide_floppy) 432 420 ide_end_request(drive, 1, done >> 9); 433 421 } else 434 422 xferfunc(drive, NULL, pc->cur_pos, bcount); ··· 440 430 rq->cmd[0], bcount); 441 431 next_irq: 442 432 /* And set the interrupt handler again */ 443 - ide_set_handler(drive, ide_pc_intr, timeout, expiry); 433 + ide_set_handler(drive, ide_pc_intr, timeout, NULL); 444 434 return ide_started; 445 435 } 446 436 ··· 489 479 490 480 static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) 491 481 { 492 - struct ide_atapi_pc *pc = drive->pc; 482 + struct ide_atapi_pc *uninitialized_var(pc); 493 483 ide_hwif_t *hwif = drive->hwif; 494 484 struct request *rq = hwif->hwgroup->rq; 495 485 ide_expiry_t *expiry; 496 486 unsigned int timeout; 487 + int cmd_len; 497 488 ide_startstop_t startstop; 498 489 u8 ireason; 499 490 ··· 504 493 return startstop; 505 494 } 506 495 507 - ireason = ide_read_ireason(drive); 508 - if (drive->media == ide_tape && 509 - (drive->dev_flags & IDE_DFLAG_SCSI) == 0) 510 - ireason = ide_wait_ireason(drive, ireason); 511 - 512 - if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { 513 - printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " 514 - "a packet command\n", drive->name); 515 - return ide_do_reset(drive); 496 + if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 497 + if (drive->dma) 498 + drive->waiting_for_dma = 1; 516 499 } 517 500 518 - /* 519 - * If necessary schedule the packet transfer to occur 'timeout' 520 - * miliseconds later in ide_delayed_transfer_pc() after the device 521 - * says it's ready for a packet. 522 - */ 523 - if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { 524 - timeout = drive->pc_delay; 525 - expiry = &ide_delayed_transfer_pc; 501 + if (dev_is_idecd(drive)) { 502 + /* ATAPI commands get padded out to 12 bytes minimum */ 503 + cmd_len = COMMAND_SIZE(rq->cmd[0]); 504 + if (cmd_len < ATAPI_MIN_CDB_BYTES) 505 + cmd_len = ATAPI_MIN_CDB_BYTES; 506 + 507 + timeout = rq->timeout; 508 + expiry = ide_cd_expiry; 526 509 } else { 527 - if (drive->dev_flags & IDE_DFLAG_SCSI) { 528 - timeout = ide_scsi_get_timeout(pc); 529 - expiry = ide_scsi_expiry; 510 + pc = drive->pc; 511 + 512 + cmd_len = ATAPI_MIN_CDB_BYTES; 513 + 514 + /* 515 + * If necessary schedule the packet transfer to occur 'timeout' 516 + * miliseconds later in ide_delayed_transfer_pc() after the 517 + * device says it's ready for a packet. 518 + */ 519 + if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { 520 + timeout = drive->pc_delay; 521 + expiry = &ide_delayed_transfer_pc; 530 522 } else { 531 523 timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD 532 524 : WAIT_TAPE_CMD; 533 525 expiry = NULL; 526 + } 527 + 528 + ireason = ide_read_ireason(drive); 529 + if (drive->media == ide_tape) 530 + ireason = ide_wait_ireason(drive, ireason); 531 + 532 + if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { 533 + printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " 534 + "a packet command\n", drive->name); 535 + 536 + return ide_do_reset(drive); 534 537 } 535 538 } 536 539 ··· 552 527 ide_set_handler(drive, ide_pc_intr, timeout, expiry); 553 528 554 529 /* Begin DMA, if necessary */ 555 - if (pc->flags & PC_FLAG_DMA_OK) { 556 - pc->flags |= PC_FLAG_DMA_IN_PROGRESS; 557 - hwif->dma_ops->dma_start(drive); 530 + if (dev_is_idecd(drive)) { 531 + if (drive->dma) 532 + hwif->dma_ops->dma_start(drive); 533 + } else { 534 + if (pc->flags & PC_FLAG_DMA_OK) { 535 + pc->flags |= PC_FLAG_DMA_IN_PROGRESS; 536 + hwif->dma_ops->dma_start(drive); 537 + } 558 538 } 559 539 560 540 /* Send the actual packet */ 561 541 if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0) 562 - hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12); 542 + hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len); 563 543 564 544 return ide_started; 565 545 } 566 546 567 - ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, 568 - ide_expiry_t *expiry) 547 + ide_startstop_t ide_issue_pc(ide_drive_t *drive) 569 548 { 570 - struct ide_atapi_pc *pc = drive->pc; 549 + struct ide_atapi_pc *pc; 571 550 ide_hwif_t *hwif = drive->hwif; 551 + ide_expiry_t *expiry = NULL; 552 + unsigned int timeout; 572 553 u32 tf_flags; 573 554 u16 bcount; 574 - u8 scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI); 575 555 576 - /* We haven't transferred any data yet */ 577 - pc->xferred = 0; 578 - pc->cur_pos = pc->buf; 579 - 580 - /* Request to transfer the entire buffer at once */ 581 - if (drive->media == ide_tape && scsi == 0) 582 - bcount = pc->req_xfer; 583 - else 584 - bcount = min(pc->req_xfer, 63 * 1024); 585 - 586 - if (pc->flags & PC_FLAG_DMA_ERROR) { 587 - pc->flags &= ~PC_FLAG_DMA_ERROR; 588 - ide_dma_off(drive); 589 - } 590 - 591 - if ((pc->flags & PC_FLAG_DMA_OK) && 592 - (drive->dev_flags & IDE_DFLAG_USING_DMA)) { 593 - if (scsi) 594 - hwif->sg_mapped = 1; 595 - drive->dma = !hwif->dma_ops->dma_setup(drive); 596 - if (scsi) 597 - hwif->sg_mapped = 0; 598 - } 599 - 600 - if (!drive->dma) 601 - pc->flags &= ~PC_FLAG_DMA_OK; 602 - 603 - if (scsi) 604 - tf_flags = 0; 605 - else if (drive->media == ide_cdrom || drive->media == ide_optical) 556 + if (dev_is_idecd(drive)) { 606 557 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; 607 - else 558 + bcount = ide_cd_get_xferlen(hwif->hwgroup->rq); 559 + expiry = ide_cd_expiry; 560 + timeout = ATAPI_WAIT_PC; 561 + 562 + if (drive->dma) 563 + drive->dma = !hwif->dma_ops->dma_setup(drive); 564 + } else { 565 + pc = drive->pc; 566 + 567 + /* We haven't transferred any data yet */ 568 + pc->xferred = 0; 569 + pc->cur_pos = pc->buf; 570 + 608 571 tf_flags = IDE_TFLAG_OUT_DEVICE; 572 + bcount = ((drive->media == ide_tape) ? 573 + pc->req_xfer : 574 + min(pc->req_xfer, 63 * 1024)); 575 + 576 + if (pc->flags & PC_FLAG_DMA_ERROR) { 577 + pc->flags &= ~PC_FLAG_DMA_ERROR; 578 + ide_dma_off(drive); 579 + } 580 + 581 + if ((pc->flags & PC_FLAG_DMA_OK) && 582 + (drive->dev_flags & IDE_DFLAG_USING_DMA)) 583 + drive->dma = !hwif->dma_ops->dma_setup(drive); 584 + 585 + if (!drive->dma) 586 + pc->flags &= ~PC_FLAG_DMA_OK; 587 + 588 + timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD 589 + : WAIT_TAPE_CMD; 590 + } 609 591 610 592 ide_pktcmd_tf_load(drive, tf_flags, bcount, drive->dma); 611 593 612 594 /* Issue the packet command */ 613 595 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 596 + if (drive->dma) 597 + drive->waiting_for_dma = 0; 614 598 ide_execute_command(drive, ATA_CMD_PACKET, ide_transfer_pc, 615 - timeout, NULL); 599 + timeout, expiry); 616 600 return ide_started; 617 601 } else { 618 602 ide_execute_pkt_cmd(drive);
+16 -83
drivers/ide/ide-cd.c
··· 53 53 54 54 #include "ide-cd.h" 55 55 56 - #define IDECD_DEBUG_LOG 1 57 - 58 - #if IDECD_DEBUG_LOG 59 - #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args) 60 - #else 61 - #define ide_debug_log(lvl, fmt, args...) do {} while (0) 62 - #endif 63 - 64 56 static DEFINE_MUTEX(idecd_ref_mutex); 65 57 66 58 static void ide_cd_release(struct kref *); ··· 511 519 return 1; 512 520 } 513 521 514 - static int cdrom_timer_expiry(ide_drive_t *drive) 515 - { 516 - struct request *rq = HWGROUP(drive)->rq; 517 - unsigned long wait = 0; 518 - 519 - ide_debug_log(IDE_DBG_RQ, "Call %s: rq->cmd[0]: 0x%x\n", __func__, 520 - rq->cmd[0]); 521 - 522 - /* 523 - * Some commands are *slow* and normally take a long time to complete. 524 - * Usually we can use the ATAPI "disconnect" to bypass this, but not all 525 - * commands/drives support that. Let ide_timer_expiry keep polling us 526 - * for these. 527 - */ 528 - switch (rq->cmd[0]) { 529 - case GPCMD_BLANK: 530 - case GPCMD_FORMAT_UNIT: 531 - case GPCMD_RESERVE_RZONE_TRACK: 532 - case GPCMD_CLOSE_TRACK: 533 - case GPCMD_FLUSH_CACHE: 534 - wait = ATAPI_WAIT_PC; 535 - break; 536 - default: 537 - if (!(rq->cmd_flags & REQ_QUIET)) 538 - printk(KERN_INFO PFX "cmd 0x%x timed out\n", 539 - rq->cmd[0]); 540 - wait = 0; 541 - break; 542 - } 543 - return wait; 544 - } 522 + static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *); 523 + static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); 545 524 546 525 /* 547 526 * Set up the device registers for transferring a packet command on DEV, ··· 522 559 * called when the interrupt from the drive arrives. Otherwise, HANDLER 523 560 * will be called immediately after the drive is prepared for the transfer. 524 561 */ 525 - static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, 526 - int xferlen, 527 - ide_handler_t *handler) 562 + static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive) 528 563 { 529 564 ide_hwif_t *hwif = drive->hwif; 565 + struct request *rq = hwif->hwgroup->rq; 566 + int xferlen; 567 + 568 + xferlen = ide_cd_get_xferlen(rq); 530 569 531 570 ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen); 532 571 ··· 546 581 drive->waiting_for_dma = 0; 547 582 548 583 /* packet command */ 549 - ide_execute_command(drive, ATA_CMD_PACKET, handler, 550 - ATAPI_WAIT_PC, cdrom_timer_expiry); 584 + ide_execute_command(drive, ATA_CMD_PACKET, 585 + cdrom_transfer_packet_command, 586 + ATAPI_WAIT_PC, ide_cd_expiry); 551 587 return ide_started; 552 588 } else { 553 589 ide_execute_pkt_cmd(drive); 554 590 555 - return (*handler) (drive); 591 + return cdrom_transfer_packet_command(drive); 556 592 } 557 593 } 558 594 ··· 564 598 * there's data ready. 565 599 */ 566 600 #define ATAPI_MIN_CDB_BYTES 12 567 - static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, 568 - struct request *rq, 569 - ide_handler_t *handler) 601 + static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive) 570 602 { 571 603 ide_hwif_t *hwif = drive->hwif; 604 + struct request *rq = hwif->hwgroup->rq; 572 605 int cmd_len; 573 606 ide_startstop_t startstop; 574 607 ··· 594 629 } 595 630 596 631 /* arm the interrupt handler */ 597 - ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); 632 + ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, ide_cd_expiry); 598 633 599 634 /* ATAPI commands get padded out to 12 bytes minimum */ 600 635 cmd_len = COMMAND_SIZE(rq->cmd[0]); ··· 682 717 return 1; 683 718 } 684 719 685 - static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); 686 - 687 720 static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, 688 721 struct request *rq) 689 722 { ··· 721 758 rq->timeout = ATAPI_WAIT_PC; 722 759 723 760 return ide_started; 724 - } 725 - 726 - /* 727 - * Routine to send a read/write packet command to the drive. This is usually 728 - * called directly from cdrom_start_{read,write}(). However, for drq_interrupt 729 - * devices, it is called from an interrupt when the drive is ready to accept 730 - * the command. 731 - */ 732 - static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) 733 - { 734 - struct request *rq = drive->hwif->hwgroup->rq; 735 - 736 - /* send the command to the drive and return */ 737 - return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); 738 761 } 739 762 740 763 /* ··· 1045 1096 } else { 1046 1097 timeout = ATAPI_WAIT_PC; 1047 1098 if (!blk_fs_request(rq)) 1048 - expiry = cdrom_timer_expiry; 1099 + expiry = ide_cd_expiry; 1049 1100 } 1050 1101 1051 1102 ide_set_handler(drive, cdrom_newpc_intr, timeout, expiry); ··· 1112 1163 return ide_started; 1113 1164 } 1114 1165 1115 - static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) 1116 - { 1117 - struct request *rq = HWGROUP(drive)->rq; 1118 - 1119 - return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); 1120 - } 1121 - 1122 1166 static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) 1123 1167 { 1124 1168 ··· 1156 1214 static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, 1157 1215 sector_t block) 1158 1216 { 1159 - ide_handler_t *fn; 1160 - int xferlen; 1161 - 1162 1217 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, " 1163 1218 "rq->cmd_type: 0x%x, block: %llu\n", 1164 1219 __func__, rq->cmd[0], rq->cmd_type, 1165 1220 (unsigned long long)block); 1166 1221 1167 1222 if (blk_fs_request(rq)) { 1168 - xferlen = 32768; 1169 - fn = cdrom_start_rw_cont; 1170 - 1171 1223 if (cdrom_start_rw(drive, rq) == ide_stopped) 1172 1224 return ide_stopped; 1173 1225 ··· 1169 1233 return ide_stopped; 1170 1234 } else if (blk_sense_request(rq) || blk_pc_request(rq) || 1171 1235 rq->cmd_type == REQ_TYPE_ATA_PC) { 1172 - xferlen = rq->data_len; 1173 - fn = cdrom_do_newpc_cont; 1174 - 1175 1236 if (!rq->timeout) 1176 1237 rq->timeout = ATAPI_WAIT_PC; 1177 1238 ··· 1183 1250 return ide_stopped; 1184 1251 } 1185 1252 1186 - return cdrom_start_packet_command(drive, xferlen, fn); 1253 + return cdrom_start_packet_command(drive); 1187 1254 } 1188 1255 1189 1256 /*
+8 -4
drivers/ide/ide-cd.h
··· 8 8 #include <linux/cdrom.h> 9 9 #include <asm/byteorder.h> 10 10 11 - /* 12 - * typical timeout for packet command 13 - */ 14 - #define ATAPI_WAIT_PC (60 * HZ) 11 + #define IDECD_DEBUG_LOG 0 12 + 13 + #if IDECD_DEBUG_LOG 14 + #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args) 15 + #else 16 + #define ide_debug_log(lvl, fmt, args...) do {} while (0) 17 + #endif 18 + 15 19 #define ATAPI_WAIT_WRITE_BUSY (10 * HZ) 16 20 17 21 /************************************************************************/
+14 -14
drivers/ide/ide-floppy.c
··· 197 197 198 198 pc->retries++; 199 199 200 - return ide_issue_pc(drive, WAIT_FLOPPY_CMD, NULL); 200 + return ide_issue_pc(drive); 201 201 } 202 202 203 203 void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) ··· 342 342 * Look at the flexible disk page parameters. We ignore the CHS capacity 343 343 * parameters and use the LBA parameters instead. 344 344 */ 345 - static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) 345 + static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive, 346 + struct ide_atapi_pc *pc) 346 347 { 347 348 struct ide_disk_obj *floppy = drive->driver_data; 348 349 struct gendisk *disk = floppy->disk; 349 - struct ide_atapi_pc pc; 350 350 u8 *page; 351 351 int capacity, lba_capacity; 352 352 u16 transfer_rate, sector_size, cyls, rpm; 353 353 u8 heads, sectors; 354 354 355 - ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); 355 + ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); 356 356 357 - if (ide_queue_pc_tail(drive, disk, &pc)) { 357 + if (ide_queue_pc_tail(drive, disk, pc)) { 358 358 printk(KERN_ERR PFX "Can't get flexible disk page params\n"); 359 359 return 1; 360 360 } 361 361 362 - if (pc.buf[3] & 0x80) 362 + if (pc->buf[3] & 0x80) 363 363 drive->dev_flags |= IDE_DFLAG_WP; 364 364 else 365 365 drive->dev_flags &= ~IDE_DFLAG_WP; 366 366 367 367 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); 368 368 369 - page = &pc.buf[8]; 369 + page = &pc->buf[8]; 370 370 371 - transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); 372 - sector_size = be16_to_cpup((__be16 *)&pc.buf[8 + 6]); 373 - cyls = be16_to_cpup((__be16 *)&pc.buf[8 + 8]); 374 - rpm = be16_to_cpup((__be16 *)&pc.buf[8 + 28]); 375 - heads = pc.buf[8 + 4]; 376 - sectors = pc.buf[8 + 5]; 371 + transfer_rate = be16_to_cpup((__be16 *)&pc->buf[8 + 2]); 372 + sector_size = be16_to_cpup((__be16 *)&pc->buf[8 + 6]); 373 + cyls = be16_to_cpup((__be16 *)&pc->buf[8 + 8]); 374 + rpm = be16_to_cpup((__be16 *)&pc->buf[8 + 28]); 375 + heads = pc->buf[8 + 4]; 376 + sectors = pc->buf[8 + 5]; 377 377 378 378 capacity = cyls * heads * sectors * sector_size; 379 379 ··· 499 499 500 500 /* Clik! disk does not support get_flexible_disk_page */ 501 501 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) 502 - (void) ide_floppy_get_flexible_disk_page(drive); 502 + (void) ide_floppy_get_flexible_disk_page(drive, &pc); 503 503 504 504 return rc; 505 505 }
+30 -28
drivers/ide/ide-floppy_ioctl.c
··· 31 31 * On exit we set nformats to the number of records we've actually initialized. 32 32 */ 33 33 34 - static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) 34 + static int ide_floppy_get_format_capacities(ide_drive_t *drive, 35 + struct ide_atapi_pc *pc, 36 + int __user *arg) 35 37 { 36 38 struct ide_disk_obj *floppy = drive->driver_data; 37 - struct ide_atapi_pc pc; 38 39 u8 header_len, desc_cnt; 39 40 int i, blocks, length, u_array_size, u_index; 40 41 int __user *argp; ··· 46 45 if (u_array_size <= 0) 47 46 return -EINVAL; 48 47 49 - ide_floppy_create_read_capacity_cmd(&pc); 50 - if (ide_queue_pc_tail(drive, floppy->disk, &pc)) { 48 + ide_floppy_create_read_capacity_cmd(pc); 49 + if (ide_queue_pc_tail(drive, floppy->disk, pc)) { 51 50 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); 52 51 return -EIO; 53 52 } 54 53 55 - header_len = pc.buf[3]; 54 + header_len = pc->buf[3]; 56 55 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ 57 56 58 57 u_index = 0; ··· 69 68 if (u_index >= u_array_size) 70 69 break; /* User-supplied buffer too small */ 71 70 72 - blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); 73 - length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); 71 + blocks = be32_to_cpup((__be32 *)&pc->buf[desc_start]); 72 + length = be16_to_cpup((__be16 *)&pc->buf[desc_start + 6]); 74 73 75 74 if (put_user(blocks, argp)) 76 75 return -EFAULT; ··· 112 111 pc->flags |= PC_FLAG_WRITING; 113 112 } 114 113 115 - static int ide_floppy_get_sfrp_bit(ide_drive_t *drive) 114 + static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) 116 115 { 117 116 struct ide_disk_obj *floppy = drive->driver_data; 118 - struct ide_atapi_pc pc; 119 117 120 118 drive->atapi_flags &= ~IDE_AFLAG_SRFP; 121 119 122 - ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE); 123 - pc.flags |= PC_FLAG_SUPPRESS_ERROR; 120 + ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_CAPABILITIES_PAGE); 121 + pc->flags |= PC_FLAG_SUPPRESS_ERROR; 124 122 125 - if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 123 + if (ide_queue_pc_tail(drive, floppy->disk, pc)) 126 124 return 1; 127 125 128 - if (pc.buf[8 + 2] & 0x40) 126 + if (pc->buf[8 + 2] & 0x40) 129 127 drive->atapi_flags |= IDE_AFLAG_SRFP; 130 128 131 129 return 0; 132 130 } 133 131 134 - static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) 132 + static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, 133 + int __user *arg) 135 134 { 136 135 struct ide_disk_obj *floppy = drive->driver_data; 137 - struct ide_atapi_pc pc; 138 136 int blocks, length, flags, err = 0; 139 137 140 138 if (floppy->openers > 1) { ··· 166 166 goto out; 167 167 } 168 168 169 - (void)ide_floppy_get_sfrp_bit(drive); 170 - ide_floppy_create_format_unit_cmd(&pc, blocks, length, flags); 169 + ide_floppy_get_sfrp_bit(drive, pc); 170 + ide_floppy_create_format_unit_cmd(pc, blocks, length, flags); 171 171 172 - if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 172 + if (ide_queue_pc_tail(drive, floppy->disk, pc)) 173 173 err = -EIO; 174 174 175 175 out: ··· 188 188 * the dsc bit, and return either 0 or 65536. 189 189 */ 190 190 191 - static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) 191 + static int ide_floppy_get_format_progress(ide_drive_t *drive, 192 + struct ide_atapi_pc *pc, 193 + int __user *arg) 192 194 { 193 195 struct ide_disk_obj *floppy = drive->driver_data; 194 - struct ide_atapi_pc pc; 195 196 int progress_indication = 0x10000; 196 197 197 198 if (drive->atapi_flags & IDE_AFLAG_SRFP) { 198 - ide_create_request_sense_cmd(drive, &pc); 199 - if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 199 + ide_create_request_sense_cmd(drive, pc); 200 + if (ide_queue_pc_tail(drive, floppy->disk, pc)) 200 201 return -EIO; 201 202 202 203 if (floppy->sense_key == 2 && ··· 242 241 return 0; 243 242 } 244 243 245 - static int ide_floppy_format_ioctl(ide_drive_t *drive, fmode_t mode, 246 - unsigned int cmd, void __user *argp) 244 + static int ide_floppy_format_ioctl(ide_drive_t *drive, struct ide_atapi_pc *pc, 245 + fmode_t mode, unsigned int cmd, 246 + void __user *argp) 247 247 { 248 248 switch (cmd) { 249 249 case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: 250 250 return 0; 251 251 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: 252 - return ide_floppy_get_format_capacities(drive, argp); 252 + return ide_floppy_get_format_capacities(drive, pc, argp); 253 253 case IDEFLOPPY_IOCTL_FORMAT_START: 254 254 if (!(mode & FMODE_WRITE)) 255 255 return -EPERM; 256 - return ide_floppy_format_unit(drive, (int __user *)argp); 256 + return ide_floppy_format_unit(drive, pc, (int __user *)argp); 257 257 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: 258 - return ide_floppy_get_format_progress(drive, argp); 258 + return ide_floppy_get_format_progress(drive, pc, argp); 259 259 default: 260 260 return -ENOTTY; 261 261 } ··· 272 270 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) 273 271 return ide_floppy_lockdoor(drive, &pc, arg, cmd); 274 272 275 - err = ide_floppy_format_ioctl(drive, mode, cmd, argp); 273 + err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp); 276 274 if (err != -ENOTTY) 277 275 return err; 278 276
+84 -196
drivers/ide/ide-io.c
··· 426 426 ide_hwif_t *hwif = drive->hwif; 427 427 struct scatterlist *sg = hwif->sg_table; 428 428 429 - if (hwif->sg_mapped) /* needed by ide-scsi */ 430 - return; 431 - 432 429 if (rq->cmd_type != REQ_TYPE_ATA_TASKFILE) { 433 430 hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); 434 431 } else { ··· 664 667 drive->sleep = timeout + jiffies; 665 668 drive->dev_flags |= IDE_DFLAG_SLEEPING; 666 669 } 667 - 668 670 EXPORT_SYMBOL(ide_stall_queue); 669 - 670 - #define WAKEUP(drive) ((drive)->service_start + 2 * (drive)->service_time) 671 - 672 - /** 673 - * choose_drive - select a drive to service 674 - * @hwgroup: hardware group to select on 675 - * 676 - * choose_drive() selects the next drive which will be serviced. 677 - * This is necessary because the IDE layer can't issue commands 678 - * to both drives on the same cable, unlike SCSI. 679 - */ 680 - 681 - static inline ide_drive_t *choose_drive (ide_hwgroup_t *hwgroup) 682 - { 683 - ide_drive_t *drive, *best; 684 - 685 - repeat: 686 - best = NULL; 687 - drive = hwgroup->drive; 688 - 689 - /* 690 - * drive is doing pre-flush, ordered write, post-flush sequence. even 691 - * though that is 3 requests, it must be seen as a single transaction. 692 - * we must not preempt this drive until that is complete 693 - */ 694 - if (blk_queue_flushing(drive->queue)) { 695 - /* 696 - * small race where queue could get replugged during 697 - * the 3-request flush cycle, just yank the plug since 698 - * we want it to finish asap 699 - */ 700 - blk_remove_plug(drive->queue); 701 - return drive; 702 - } 703 - 704 - do { 705 - u8 dev_s = !!(drive->dev_flags & IDE_DFLAG_SLEEPING); 706 - u8 best_s = (best && !!(best->dev_flags & IDE_DFLAG_SLEEPING)); 707 - 708 - if ((dev_s == 0 || time_after_eq(jiffies, drive->sleep)) && 709 - !elv_queue_empty(drive->queue)) { 710 - if (best == NULL || 711 - (dev_s && (best_s == 0 || time_before(drive->sleep, best->sleep))) || 712 - (best_s == 0 && time_before(WAKEUP(drive), WAKEUP(best)))) { 713 - if (!blk_queue_plugged(drive->queue)) 714 - best = drive; 715 - } 716 - } 717 - } while ((drive = drive->next) != hwgroup->drive); 718 - 719 - if (best && (best->dev_flags & IDE_DFLAG_NICE1) && 720 - (best->dev_flags & IDE_DFLAG_SLEEPING) == 0 && 721 - best != hwgroup->drive && best->service_time > WAIT_MIN_SLEEP) { 722 - long t = (signed long)(WAKEUP(best) - jiffies); 723 - if (t >= WAIT_MIN_SLEEP) { 724 - /* 725 - * We *may* have some time to spare, but first let's see if 726 - * someone can potentially benefit from our nice mood today.. 727 - */ 728 - drive = best->next; 729 - do { 730 - if ((drive->dev_flags & IDE_DFLAG_SLEEPING) == 0 731 - && time_before(jiffies - best->service_time, WAKEUP(drive)) 732 - && time_before(WAKEUP(drive), jiffies + t)) 733 - { 734 - ide_stall_queue(best, min_t(long, t, 10 * WAIT_MIN_SLEEP)); 735 - goto repeat; 736 - } 737 - } while ((drive = drive->next) != best); 738 - } 739 - } 740 - return best; 741 - } 742 671 743 672 /* 744 673 * Issue a new request to a drive from hwgroup 745 - * Caller must have already done spin_lock_irqsave(&hwgroup->lock, ..); 746 674 * 747 675 * A hwgroup is a serialized group of IDE interfaces. Usually there is 748 676 * exactly one hwif (interface) per hwgroup, but buggy controllers (eg. CMD640) ··· 679 757 * possibly along with many other devices. This is especially common in 680 758 * PCI-based systems with off-board IDE controller cards. 681 759 * 682 - * The IDE driver uses a per-hwgroup spinlock to protect 683 - * access to the request queues, and to protect the hwgroup->busy flag. 760 + * The IDE driver uses a per-hwgroup lock to protect the hwgroup->busy flag. 684 761 * 685 762 * The first thread into the driver for a particular hwgroup sets the 686 763 * hwgroup->busy flag to indicate that this hwgroup is now active, ··· 699 778 * the driver. This makes the driver much more friendlier to shared IRQs 700 779 * than previous designs, while remaining 100% (?) SMP safe and capable. 701 780 */ 702 - static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) 781 + void do_ide_request(struct request_queue *q) 703 782 { 704 - ide_drive_t *drive; 705 - ide_hwif_t *hwif; 783 + ide_drive_t *drive = q->queuedata; 784 + ide_hwif_t *hwif = drive->hwif; 785 + ide_hwgroup_t *hwgroup = hwif->hwgroup; 706 786 struct request *rq; 707 787 ide_startstop_t startstop; 708 - int loops = 0; 709 788 710 - /* caller must own hwgroup->lock */ 711 - BUG_ON(!irqs_disabled()); 712 - 713 - while (!hwgroup->busy) { 714 - hwgroup->busy = 1; 715 - /* for atari only */ 716 - ide_get_lock(ide_intr, hwgroup); 717 - drive = choose_drive(hwgroup); 718 - if (drive == NULL) { 719 - int sleeping = 0; 720 - unsigned long sleep = 0; /* shut up, gcc */ 721 - hwgroup->rq = NULL; 722 - drive = hwgroup->drive; 723 - do { 724 - if ((drive->dev_flags & IDE_DFLAG_SLEEPING) && 725 - (sleeping == 0 || 726 - time_before(drive->sleep, sleep))) { 727 - sleeping = 1; 728 - sleep = drive->sleep; 729 - } 730 - } while ((drive = drive->next) != hwgroup->drive); 731 - if (sleeping) { 789 + /* 790 + * drive is doing pre-flush, ordered write, post-flush sequence. even 791 + * though that is 3 requests, it must be seen as a single transaction. 792 + * we must not preempt this drive until that is complete 793 + */ 794 + if (blk_queue_flushing(q)) 732 795 /* 733 - * Take a short snooze, and then wake up this hwgroup again. 734 - * This gives other hwgroups on the same a chance to 735 - * play fairly with us, just in case there are big differences 736 - * in relative throughputs.. don't want to hog the cpu too much. 796 + * small race where queue could get replugged during 797 + * the 3-request flush cycle, just yank the plug since 798 + * we want it to finish asap 737 799 */ 738 - if (time_before(sleep, jiffies + WAIT_MIN_SLEEP)) 739 - sleep = jiffies + WAIT_MIN_SLEEP; 740 - #if 1 741 - if (timer_pending(&hwgroup->timer)) 742 - printk(KERN_CRIT "ide_set_handler: timer already active\n"); 743 - #endif 744 - /* so that ide_timer_expiry knows what to do */ 745 - hwgroup->sleeping = 1; 746 - hwgroup->req_gen_timer = hwgroup->req_gen; 747 - mod_timer(&hwgroup->timer, sleep); 748 - /* we purposely leave hwgroup->busy==1 749 - * while sleeping */ 750 - } else { 751 - /* Ugly, but how can we sleep for the lock 752 - * otherwise? perhaps from tq_disk? 753 - */ 800 + blk_remove_plug(q); 754 801 755 - /* for atari only */ 756 - ide_release_lock(); 757 - hwgroup->busy = 0; 802 + spin_unlock_irq(q->queue_lock); 803 + spin_lock_irq(&hwgroup->lock); 804 + 805 + if (!ide_lock_hwgroup(hwgroup)) { 806 + repeat: 807 + hwgroup->rq = NULL; 808 + 809 + if (drive->dev_flags & IDE_DFLAG_SLEEPING) { 810 + if (time_before(drive->sleep, jiffies)) { 811 + ide_unlock_hwgroup(hwgroup); 812 + goto plug_device; 758 813 } 759 - 760 - /* no more work for this hwgroup (for now) */ 761 - return; 762 814 } 763 - again: 764 - hwif = HWIF(drive); 815 + 765 816 if (hwif != hwgroup->hwif) { 766 817 /* 767 818 * set nIEN for previous hwif, drives in the ··· 745 852 hwgroup->hwif = hwif; 746 853 hwgroup->drive = drive; 747 854 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); 748 - drive->service_start = jiffies; 749 855 856 + spin_unlock_irq(&hwgroup->lock); 857 + spin_lock_irq(q->queue_lock); 750 858 /* 751 859 * we know that the queue isn't empty, but this can happen 752 860 * if the q->prep_rq_fn() decides to kill a request 753 861 */ 754 862 rq = elv_next_request(drive->queue); 863 + spin_unlock_irq(q->queue_lock); 864 + spin_lock_irq(&hwgroup->lock); 865 + 755 866 if (!rq) { 756 - hwgroup->busy = 0; 757 - break; 867 + ide_unlock_hwgroup(hwgroup); 868 + goto out; 758 869 } 759 870 760 871 /* ··· 773 876 * though. I hope that doesn't happen too much, hopefully not 774 877 * unless the subdriver triggers such a thing in its own PM 775 878 * state machine. 776 - * 777 - * We count how many times we loop here to make sure we service 778 - * all drives in the hwgroup without looping for ever 779 879 */ 780 880 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && 781 881 blk_pm_request(rq) == 0 && 782 882 (rq->cmd_flags & REQ_PREEMPT) == 0) { 783 - drive = drive->next ? drive->next : hwgroup->drive; 784 - if (loops++ < 4 && !blk_queue_plugged(drive->queue)) 785 - goto again; 786 - /* We clear busy, there should be no pending ATA command at this point. */ 787 - hwgroup->busy = 0; 788 - break; 883 + /* there should be no pending command at this point */ 884 + ide_unlock_hwgroup(hwgroup); 885 + goto plug_device; 789 886 } 790 887 791 888 hwgroup->rq = rq; 792 889 793 - /* 794 - * Some systems have trouble with IDE IRQs arriving while 795 - * the driver is still setting things up. So, here we disable 796 - * the IRQ used by this interface while the request is being started. 797 - * This may look bad at first, but pretty much the same thing 798 - * happens anyway when any interrupt comes in, IDE or otherwise 799 - * -- the kernel masks the IRQ while it is being handled. 800 - */ 801 - if (masked_irq != IDE_NO_IRQ && hwif->irq != masked_irq) 802 - disable_irq_nosync(hwif->irq); 803 - spin_unlock(&hwgroup->lock); 804 - local_irq_enable_in_hardirq(); 805 - /* allow other IRQs while we start this request */ 890 + spin_unlock_irq(&hwgroup->lock); 806 891 startstop = start_request(drive, rq); 807 892 spin_lock_irq(&hwgroup->lock); 808 - if (masked_irq != IDE_NO_IRQ && hwif->irq != masked_irq) 809 - enable_irq(hwif->irq); 893 + 810 894 if (startstop == ide_stopped) 811 - hwgroup->busy = 0; 812 - } 813 - } 895 + goto repeat; 896 + } else 897 + goto plug_device; 898 + out: 899 + spin_unlock_irq(&hwgroup->lock); 900 + spin_lock_irq(q->queue_lock); 901 + return; 814 902 815 - /* 816 - * Passes the stuff to ide_do_request 817 - */ 818 - void do_ide_request(struct request_queue *q) 819 - { 820 - ide_drive_t *drive = q->queuedata; 903 + plug_device: 904 + spin_unlock_irq(&hwgroup->lock); 905 + spin_lock_irq(q->queue_lock); 821 906 822 - ide_do_request(HWGROUP(drive), IDE_NO_IRQ); 907 + if (!elv_queue_empty(q)) 908 + blk_plug_device(q); 823 909 } 824 910 825 911 /* ··· 863 983 return ret; 864 984 } 865 985 986 + static void ide_plug_device(ide_drive_t *drive) 987 + { 988 + struct request_queue *q = drive->queue; 989 + unsigned long flags; 990 + 991 + spin_lock_irqsave(q->queue_lock, flags); 992 + if (!elv_queue_empty(q)) 993 + blk_plug_device(q); 994 + spin_unlock_irqrestore(q->queue_lock, flags); 995 + } 996 + 866 997 /** 867 998 * ide_timer_expiry - handle lack of an IDE interrupt 868 999 * @data: timer callback magic (hwgroup) ··· 891 1000 void ide_timer_expiry (unsigned long data) 892 1001 { 893 1002 ide_hwgroup_t *hwgroup = (ide_hwgroup_t *) data; 1003 + ide_drive_t *uninitialized_var(drive); 894 1004 ide_handler_t *handler; 895 1005 ide_expiry_t *expiry; 896 1006 unsigned long flags; 897 1007 unsigned long wait = -1; 1008 + int plug_device = 0; 898 1009 899 1010 spin_lock_irqsave(&hwgroup->lock, flags); 900 1011 ··· 908 1015 * or we were "sleeping" to give other devices a chance. 909 1016 * Either way, we don't really want to complain about anything. 910 1017 */ 911 - if (hwgroup->sleeping) { 912 - hwgroup->sleeping = 0; 913 - hwgroup->busy = 0; 914 - } 915 1018 } else { 916 - ide_drive_t *drive = hwgroup->drive; 1019 + drive = hwgroup->drive; 917 1020 if (!drive) { 918 1021 printk(KERN_ERR "ide_timer_expiry: hwgroup->drive was NULL\n"); 919 1022 hwgroup->handler = NULL; 920 1023 } else { 921 1024 ide_hwif_t *hwif; 922 1025 ide_startstop_t startstop = ide_stopped; 923 - if (!hwgroup->busy) { 924 - hwgroup->busy = 1; /* paranoia */ 925 - printk(KERN_ERR "%s: ide_timer_expiry: hwgroup->busy was 0 ??\n", drive->name); 926 - } 1026 + 927 1027 if ((expiry = hwgroup->expiry) != NULL) { 928 1028 /* continue */ 929 1029 if ((wait = expiry(drive)) > 0) { ··· 957 1071 ide_error(drive, "irq timeout", 958 1072 hwif->tp_ops->read_status(hwif)); 959 1073 } 960 - drive->service_time = jiffies - drive->service_start; 961 1074 spin_lock_irq(&hwgroup->lock); 962 1075 enable_irq(hwif->irq); 963 - if (startstop == ide_stopped) 964 - hwgroup->busy = 0; 1076 + if (startstop == ide_stopped) { 1077 + ide_unlock_hwgroup(hwgroup); 1078 + plug_device = 1; 1079 + } 965 1080 } 966 1081 } 967 - ide_do_request(hwgroup, IDE_NO_IRQ); 968 1082 spin_unlock_irqrestore(&hwgroup->lock, flags); 1083 + 1084 + if (plug_device) 1085 + ide_plug_device(drive); 969 1086 } 970 1087 971 1088 /** ··· 1062 1173 unsigned long flags; 1063 1174 ide_hwgroup_t *hwgroup = (ide_hwgroup_t *)dev_id; 1064 1175 ide_hwif_t *hwif = hwgroup->hwif; 1065 - ide_drive_t *drive; 1176 + ide_drive_t *uninitialized_var(drive); 1066 1177 ide_handler_t *handler; 1067 1178 ide_startstop_t startstop; 1068 1179 irqreturn_t irq_ret = IRQ_NONE; 1180 + int plug_device = 0; 1069 1181 1070 1182 spin_lock_irqsave(&hwgroup->lock, flags); 1071 1183 ··· 1131 1241 */ 1132 1242 goto out; 1133 1243 1134 - if (!hwgroup->busy) { 1135 - hwgroup->busy = 1; /* paranoia */ 1136 - printk(KERN_ERR "%s: ide_intr: hwgroup->busy was 0 ??\n", drive->name); 1137 - } 1138 1244 hwgroup->handler = NULL; 1139 1245 hwgroup->req_gen++; 1140 1246 del_timer(&hwgroup->timer); ··· 1153 1267 * same irq as is currently being serviced here, and Linux 1154 1268 * won't allow another of the same (on any CPU) until we return. 1155 1269 */ 1156 - drive->service_time = jiffies - drive->service_start; 1157 1270 if (startstop == ide_stopped) { 1158 1271 if (hwgroup->handler == NULL) { /* paranoia */ 1159 - hwgroup->busy = 0; 1160 - ide_do_request(hwgroup, hwif->irq); 1161 - } else { 1162 - printk(KERN_ERR "%s: ide_intr: huh? expected NULL handler " 1163 - "on exit\n", drive->name); 1164 - } 1272 + ide_unlock_hwgroup(hwgroup); 1273 + plug_device = 1; 1274 + } else 1275 + printk(KERN_ERR "%s: %s: huh? expected NULL handler " 1276 + "on exit\n", __func__, drive->name); 1165 1277 } 1166 1278 out_handled: 1167 1279 irq_ret = IRQ_HANDLED; 1168 1280 out: 1169 1281 spin_unlock_irqrestore(&hwgroup->lock, flags); 1282 + 1283 + if (plug_device) 1284 + ide_plug_device(drive); 1285 + 1170 1286 return irq_ret; 1171 1287 } 1172 1288
+1 -2
drivers/ide/ide-ioctls.c
··· 95 95 return -EPERM; 96 96 97 97 if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) && 98 - (drive->media != ide_tape || 99 - (drive->dev_flags & IDE_DFLAG_SCSI))) 98 + (drive->media != ide_tape)) 100 99 return -EPERM; 101 100 102 101 if ((arg >> IDE_NICE_DSC_OVERLAP) & 1)
+9 -6
drivers/ide/ide-park.c
··· 16 16 spin_lock_irq(&hwgroup->lock); 17 17 if (drive->dev_flags & IDE_DFLAG_PARKED) { 18 18 int reset_timer = time_before(timeout, drive->sleep); 19 + int start_queue = 0; 19 20 20 21 drive->sleep = timeout; 21 22 wake_up_all(&ide_park_wq); 22 - if (reset_timer && hwgroup->sleeping && 23 - del_timer(&hwgroup->timer)) { 24 - hwgroup->sleeping = 0; 25 - hwgroup->busy = 0; 26 - blk_start_queueing(q); 27 - } 23 + if (reset_timer && del_timer(&hwgroup->timer)) 24 + start_queue = 1; 28 25 spin_unlock_irq(&hwgroup->lock); 26 + 27 + if (start_queue) { 28 + spin_lock_irq(q->queue_lock); 29 + blk_start_queueing(q); 30 + spin_unlock_irq(q->queue_lock); 31 + } 29 32 return; 30 33 } 31 34 spin_unlock_irq(&hwgroup->lock);
+84 -139
drivers/ide/ide-probe.c
··· 101 101 } 102 102 } 103 103 104 + static void ide_classify_ata_dev(ide_drive_t *drive) 105 + { 106 + u16 *id = drive->id; 107 + char *m = (char *)&id[ATA_ID_PROD]; 108 + int is_cfa = ata_id_is_cfa(id); 109 + 110 + /* CF devices are *not* removable in Linux definition of the term */ 111 + if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) 112 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 113 + 114 + drive->media = ide_disk; 115 + 116 + if (!ata_id_has_unload(drive->id)) 117 + drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 118 + 119 + printk(KERN_INFO "%s: %s, %s DISK drive\n", drive->name, m, 120 + is_cfa ? "CFA" : "ATA"); 121 + } 122 + 123 + static void ide_classify_atapi_dev(ide_drive_t *drive) 124 + { 125 + u16 *id = drive->id; 126 + char *m = (char *)&id[ATA_ID_PROD]; 127 + u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f; 128 + 129 + printk(KERN_INFO "%s: %s, ATAPI ", drive->name, m); 130 + switch (type) { 131 + case ide_floppy: 132 + if (!strstr(m, "CD-ROM")) { 133 + if (!strstr(m, "oppy") && 134 + !strstr(m, "poyp") && 135 + !strstr(m, "ZIP")) 136 + printk(KERN_CONT "cdrom or floppy?, assuming "); 137 + if (drive->media != ide_cdrom) { 138 + printk(KERN_CONT "FLOPPY"); 139 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 140 + break; 141 + } 142 + } 143 + /* Early cdrom models used zero */ 144 + type = ide_cdrom; 145 + case ide_cdrom: 146 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 147 + #ifdef CONFIG_PPC 148 + /* kludge for Apple PowerBook internal zip */ 149 + if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { 150 + printk(KERN_CONT "FLOPPY"); 151 + type = ide_floppy; 152 + break; 153 + } 154 + #endif 155 + printk(KERN_CONT "CD/DVD-ROM"); 156 + break; 157 + case ide_tape: 158 + printk(KERN_CONT "TAPE"); 159 + break; 160 + case ide_optical: 161 + printk(KERN_CONT "OPTICAL"); 162 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 163 + break; 164 + default: 165 + printk(KERN_CONT "UNKNOWN (type %d)", type); 166 + break; 167 + } 168 + 169 + printk(KERN_CONT " drive\n"); 170 + drive->media = type; 171 + /* an ATAPI device ignores DRDY */ 172 + drive->ready_stat = 0; 173 + if (ata_id_cdb_intr(id)) 174 + drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 175 + drive->dev_flags |= IDE_DFLAG_DOORLOCKING; 176 + /* we don't do head unloading on ATAPI devices */ 177 + drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 178 + } 179 + 104 180 /** 105 181 * do_identify - identify a drive 106 182 * @drive: drive to identify ··· 193 117 u16 *id = drive->id; 194 118 char *m = (char *)&id[ATA_ID_PROD]; 195 119 unsigned long flags; 196 - int bswap = 1, is_cfa; 120 + int bswap = 1; 197 121 198 122 /* local CPU only; some systems need this */ 199 123 local_irq_save(flags); ··· 230 154 if (strstr(m, "E X A B Y T E N E S T")) 231 155 goto err_misc; 232 156 233 - printk(KERN_INFO "%s: %s, ", drive->name, m); 234 - 235 157 drive->dev_flags |= IDE_DFLAG_PRESENT; 236 158 drive->dev_flags &= ~IDE_DFLAG_DEAD; 237 159 238 160 /* 239 161 * Check for an ATAPI device 240 162 */ 241 - if (cmd == ATA_CMD_ID_ATAPI) { 242 - u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f; 243 - 244 - printk(KERN_CONT "ATAPI "); 245 - switch (type) { 246 - case ide_floppy: 247 - if (!strstr(m, "CD-ROM")) { 248 - if (!strstr(m, "oppy") && 249 - !strstr(m, "poyp") && 250 - !strstr(m, "ZIP")) 251 - printk(KERN_CONT "cdrom or floppy?, assuming "); 252 - if (drive->media != ide_cdrom) { 253 - printk(KERN_CONT "FLOPPY"); 254 - drive->dev_flags |= IDE_DFLAG_REMOVABLE; 255 - break; 256 - } 257 - } 258 - /* Early cdrom models used zero */ 259 - type = ide_cdrom; 260 - case ide_cdrom: 261 - drive->dev_flags |= IDE_DFLAG_REMOVABLE; 262 - #ifdef CONFIG_PPC 263 - /* kludge for Apple PowerBook internal zip */ 264 - if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { 265 - printk(KERN_CONT "FLOPPY"); 266 - type = ide_floppy; 267 - break; 268 - } 269 - #endif 270 - printk(KERN_CONT "CD/DVD-ROM"); 271 - break; 272 - case ide_tape: 273 - printk(KERN_CONT "TAPE"); 274 - break; 275 - case ide_optical: 276 - printk(KERN_CONT "OPTICAL"); 277 - drive->dev_flags |= IDE_DFLAG_REMOVABLE; 278 - break; 279 - default: 280 - printk(KERN_CONT "UNKNOWN (type %d)", type); 281 - break; 282 - } 283 - printk(KERN_CONT " drive\n"); 284 - drive->media = type; 285 - /* an ATAPI device ignores DRDY */ 286 - drive->ready_stat = 0; 287 - if (ata_id_cdb_intr(id)) 288 - drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 289 - drive->dev_flags |= IDE_DFLAG_DOORLOCKING; 290 - /* we don't do head unloading on ATAPI devices */ 291 - drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 292 - return; 293 - } 294 - 163 + if (cmd == ATA_CMD_ID_ATAPI) 164 + ide_classify_atapi_dev(drive); 165 + else 295 166 /* 296 167 * Not an ATAPI device: looks like a "regular" hard disk 297 168 */ 298 - 299 - is_cfa = ata_id_is_cfa(id); 300 - 301 - /* CF devices are *not* removable in Linux definition of the term */ 302 - if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) 303 - drive->dev_flags |= IDE_DFLAG_REMOVABLE; 304 - 305 - drive->media = ide_disk; 306 - 307 - if (!ata_id_has_unload(drive->id)) 308 - drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 309 - 310 - printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA"); 311 - 169 + ide_classify_ata_dev(drive); 312 170 return; 313 - 314 171 err_misc: 315 172 kfree(id); 316 173 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 317 - return; 318 174 } 319 175 320 176 /** ··· 649 641 /* register with global device tree */ 650 642 dev_set_name(&hwif->gendev, hwif->name); 651 643 hwif->gendev.driver_data = hwif; 652 - if (hwif->gendev.parent == NULL) { 653 - if (hwif->dev) 654 - hwif->gendev.parent = hwif->dev; 655 - else 656 - /* Would like to do = &device_legacy */ 657 - hwif->gendev.parent = NULL; 658 - } 644 + hwif->gendev.parent = hwif->dev; 659 645 hwif->gendev.release = hwif_release_dev; 646 + 660 647 ret = device_register(&hwif->gendev); 661 648 if (ret < 0) { 662 649 printk(KERN_WARNING "IDE: %s: device_register error: %d\n", ··· 881 878 * do not. 882 879 */ 883 880 884 - q = blk_init_queue_node(do_ide_request, &hwif->hwgroup->lock, 885 - hwif_to_node(hwif)); 881 + q = blk_init_queue_node(do_ide_request, NULL, hwif_to_node(hwif)); 886 882 if (!q) 887 883 return 1; 888 884 ··· 1141 1139 1142 1140 if (drive->media == ide_disk) 1143 1141 request_module("ide-disk"); 1144 - if (drive->dev_flags & IDE_DFLAG_SCSI) 1145 - request_module("ide-scsi"); 1146 1142 if (drive->media == ide_cdrom || drive->media == ide_optical) 1147 1143 request_module("ide-cd"); 1148 1144 if (drive->media == ide_tape) ··· 1417 1417 } 1418 1418 } 1419 1419 1420 - static ssize_t store_delete_devices(struct device *portdev, 1421 - struct device_attribute *attr, 1422 - const char *buf, size_t n) 1423 - { 1424 - ide_hwif_t *hwif = dev_get_drvdata(portdev); 1425 - 1426 - if (strncmp(buf, "1", n)) 1427 - return -EINVAL; 1428 - 1429 - ide_port_unregister_devices(hwif); 1430 - 1431 - return n; 1432 - }; 1433 - 1434 - static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices); 1435 - 1436 - static ssize_t store_scan(struct device *portdev, 1437 - struct device_attribute *attr, 1438 - const char *buf, size_t n) 1439 - { 1440 - ide_hwif_t *hwif = dev_get_drvdata(portdev); 1441 - 1442 - if (strncmp(buf, "1", n)) 1443 - return -EINVAL; 1444 - 1445 - ide_port_unregister_devices(hwif); 1446 - ide_port_scan(hwif); 1447 - 1448 - return n; 1449 - }; 1450 - 1451 - static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); 1452 - 1453 - static struct device_attribute *ide_port_attrs[] = { 1454 - &dev_attr_delete_devices, 1455 - &dev_attr_scan, 1456 - NULL 1457 - }; 1458 - 1459 - static int ide_sysfs_register_port(ide_hwif_t *hwif) 1460 - { 1461 - int i, uninitialized_var(rc); 1462 - 1463 - for (i = 0; ide_port_attrs[i]; i++) { 1464 - rc = device_create_file(hwif->portdev, ide_port_attrs[i]); 1465 - if (rc) 1466 - break; 1467 - } 1468 - 1469 - return rc; 1470 - } 1471 - 1472 1420 static unsigned int ide_indexes; 1473 1421 1474 1422 /** ··· 1602 1654 1603 1655 if (hwif == NULL) 1604 1656 continue; 1605 - 1606 - if (hwif->chipset == ide_unknown) 1607 - hwif->chipset = ide_generic; 1608 1657 1609 1658 if (hwif->present) 1610 1659 hwif_register_devices(hwif);
+125
drivers/ide/ide-sysfs.c
··· 1 + #include <linux/kernel.h> 2 + #include <linux/ide.h> 3 + 4 + char *ide_media_string(ide_drive_t *drive) 5 + { 6 + switch (drive->media) { 7 + case ide_disk: 8 + return "disk"; 9 + case ide_cdrom: 10 + return "cdrom"; 11 + case ide_tape: 12 + return "tape"; 13 + case ide_floppy: 14 + return "floppy"; 15 + case ide_optical: 16 + return "optical"; 17 + default: 18 + return "UNKNOWN"; 19 + } 20 + } 21 + 22 + static ssize_t media_show(struct device *dev, struct device_attribute *attr, 23 + char *buf) 24 + { 25 + ide_drive_t *drive = to_ide_device(dev); 26 + return sprintf(buf, "%s\n", ide_media_string(drive)); 27 + } 28 + 29 + static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, 30 + char *buf) 31 + { 32 + ide_drive_t *drive = to_ide_device(dev); 33 + return sprintf(buf, "%s\n", drive->name); 34 + } 35 + 36 + static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, 37 + char *buf) 38 + { 39 + ide_drive_t *drive = to_ide_device(dev); 40 + return sprintf(buf, "ide:m-%s\n", ide_media_string(drive)); 41 + } 42 + 43 + static ssize_t model_show(struct device *dev, struct device_attribute *attr, 44 + char *buf) 45 + { 46 + ide_drive_t *drive = to_ide_device(dev); 47 + return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]); 48 + } 49 + 50 + static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, 51 + char *buf) 52 + { 53 + ide_drive_t *drive = to_ide_device(dev); 54 + return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]); 55 + } 56 + 57 + static ssize_t serial_show(struct device *dev, struct device_attribute *attr, 58 + char *buf) 59 + { 60 + ide_drive_t *drive = to_ide_device(dev); 61 + return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]); 62 + } 63 + 64 + struct device_attribute ide_dev_attrs[] = { 65 + __ATTR_RO(media), 66 + __ATTR_RO(drivename), 67 + __ATTR_RO(modalias), 68 + __ATTR_RO(model), 69 + __ATTR_RO(firmware), 70 + __ATTR(serial, 0400, serial_show, NULL), 71 + __ATTR(unload_heads, 0644, ide_park_show, ide_park_store), 72 + __ATTR_NULL 73 + }; 74 + 75 + static ssize_t store_delete_devices(struct device *portdev, 76 + struct device_attribute *attr, 77 + const char *buf, size_t n) 78 + { 79 + ide_hwif_t *hwif = dev_get_drvdata(portdev); 80 + 81 + if (strncmp(buf, "1", n)) 82 + return -EINVAL; 83 + 84 + ide_port_unregister_devices(hwif); 85 + 86 + return n; 87 + }; 88 + 89 + static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices); 90 + 91 + static ssize_t store_scan(struct device *portdev, 92 + struct device_attribute *attr, 93 + const char *buf, size_t n) 94 + { 95 + ide_hwif_t *hwif = dev_get_drvdata(portdev); 96 + 97 + if (strncmp(buf, "1", n)) 98 + return -EINVAL; 99 + 100 + ide_port_unregister_devices(hwif); 101 + ide_port_scan(hwif); 102 + 103 + return n; 104 + }; 105 + 106 + static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); 107 + 108 + static struct device_attribute *ide_port_attrs[] = { 109 + &dev_attr_delete_devices, 110 + &dev_attr_scan, 111 + NULL 112 + }; 113 + 114 + int ide_sysfs_register_port(ide_hwif_t *hwif) 115 + { 116 + int i, uninitialized_var(rc); 117 + 118 + for (i = 0; ide_port_attrs[i]; i++) { 119 + rc = device_create_file(hwif->portdev, ide_port_attrs[i]); 120 + if (rc) 121 + break; 122 + } 123 + 124 + return rc; 125 + }
+1 -1
drivers/ide/ide-tape.c
··· 694 694 695 695 pc->retries++; 696 696 697 - return ide_issue_pc(drive, WAIT_TAPE_CMD, NULL); 697 + return ide_issue_pc(drive); 698 698 } 699 699 700 700 /* A mode sense command is used to "sense" tape parameters. */
+2 -70
drivers/ide/ide.c
··· 440 440 return 1; 441 441 } 442 442 443 - static char *media_string(ide_drive_t *drive) 444 - { 445 - switch (drive->media) { 446 - case ide_disk: 447 - return "disk"; 448 - case ide_cdrom: 449 - return "cdrom"; 450 - case ide_tape: 451 - return "tape"; 452 - case ide_floppy: 453 - return "floppy"; 454 - case ide_optical: 455 - return "optical"; 456 - default: 457 - return "UNKNOWN"; 458 - } 459 - } 460 - 461 - static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf) 462 - { 463 - ide_drive_t *drive = to_ide_device(dev); 464 - return sprintf(buf, "%s\n", media_string(drive)); 465 - } 466 - 467 - static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf) 468 - { 469 - ide_drive_t *drive = to_ide_device(dev); 470 - return sprintf(buf, "%s\n", drive->name); 471 - } 472 - 473 - static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) 474 - { 475 - ide_drive_t *drive = to_ide_device(dev); 476 - return sprintf(buf, "ide:m-%s\n", media_string(drive)); 477 - } 478 - 479 - static ssize_t model_show(struct device *dev, struct device_attribute *attr, 480 - char *buf) 481 - { 482 - ide_drive_t *drive = to_ide_device(dev); 483 - return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]); 484 - } 485 - 486 - static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, 487 - char *buf) 488 - { 489 - ide_drive_t *drive = to_ide_device(dev); 490 - return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]); 491 - } 492 - 493 - static ssize_t serial_show(struct device *dev, struct device_attribute *attr, 494 - char *buf) 495 - { 496 - ide_drive_t *drive = to_ide_device(dev); 497 - return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]); 498 - } 499 - 500 - static struct device_attribute ide_dev_attrs[] = { 501 - __ATTR_RO(media), 502 - __ATTR_RO(drivename), 503 - __ATTR_RO(modalias), 504 - __ATTR_RO(model), 505 - __ATTR_RO(firmware), 506 - __ATTR(serial, 0400, serial_show, NULL), 507 - __ATTR(unload_heads, 0644, ide_park_show, ide_park_store), 508 - __ATTR_NULL 509 - }; 510 - 511 443 static int ide_uevent(struct device *dev, struct kobj_uevent_env *env) 512 444 { 513 445 ide_drive_t *drive = to_ide_device(dev); 514 446 515 - add_uevent_var(env, "MEDIA=%s", media_string(drive)); 447 + add_uevent_var(env, "MEDIA=%s", ide_media_string(drive)); 516 448 add_uevent_var(env, "DRIVENAME=%s", drive->name); 517 - add_uevent_var(env, "MODALIAS=ide:m-%s", media_string(drive)); 449 + add_uevent_var(env, "MODALIAS=ide:m-%s", ide_media_string(drive)); 518 450 return 0; 519 451 } 520 452
+6 -5
drivers/ide/tx4938ide.c
··· 216 216 #endif /* __BIG_ENDIAN */ 217 217 218 218 static const struct ide_port_ops tx4938ide_port_ops = { 219 - .set_pio_mode = tx4938ide_set_pio_mode, 219 + .set_pio_mode = tx4938ide_set_pio_mode, 220 220 }; 221 221 222 222 static const struct ide_port_info tx4938ide_port_info __initdata = { 223 - .port_ops = &tx4938ide_port_ops, 223 + .port_ops = &tx4938ide_port_ops, 224 224 #ifdef __BIG_ENDIAN 225 - .tp_ops = &tx4938ide_tp_ops, 225 + .tp_ops = &tx4938ide_tp_ops, 226 226 #endif 227 - .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 228 - .pio_mask = ATA_PIO5, 227 + .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 228 + .pio_mask = ATA_PIO5, 229 + .chipset = ide_generic, 229 230 }; 230 231 231 232 static int __init tx4938ide_probe(struct platform_device *pdev)
+22 -21
drivers/ide/tx4939ide.c
··· 623 623 #endif /* __LITTLE_ENDIAN */ 624 624 625 625 static const struct ide_port_ops tx4939ide_port_ops = { 626 - .set_pio_mode = tx4939ide_set_pio_mode, 627 - .set_dma_mode = tx4939ide_set_dma_mode, 628 - .clear_irq = tx4939ide_clear_irq, 629 - .cable_detect = tx4939ide_cable_detect, 626 + .set_pio_mode = tx4939ide_set_pio_mode, 627 + .set_dma_mode = tx4939ide_set_dma_mode, 628 + .clear_irq = tx4939ide_clear_irq, 629 + .cable_detect = tx4939ide_cable_detect, 630 630 }; 631 631 632 632 static const struct ide_dma_ops tx4939ide_dma_ops = { 633 - .dma_host_set = tx4939ide_dma_host_set, 634 - .dma_setup = tx4939ide_dma_setup, 635 - .dma_exec_cmd = ide_dma_exec_cmd, 636 - .dma_start = ide_dma_start, 637 - .dma_end = tx4939ide_dma_end, 638 - .dma_test_irq = tx4939ide_dma_test_irq, 639 - .dma_lost_irq = ide_dma_lost_irq, 640 - .dma_timeout = ide_dma_timeout, 633 + .dma_host_set = tx4939ide_dma_host_set, 634 + .dma_setup = tx4939ide_dma_setup, 635 + .dma_exec_cmd = ide_dma_exec_cmd, 636 + .dma_start = ide_dma_start, 637 + .dma_end = tx4939ide_dma_end, 638 + .dma_test_irq = tx4939ide_dma_test_irq, 639 + .dma_lost_irq = ide_dma_lost_irq, 640 + .dma_timeout = ide_dma_timeout, 641 641 }; 642 642 643 643 static const struct ide_port_info tx4939ide_port_info __initdata = { 644 - .init_hwif = tx4939ide_init_hwif, 645 - .init_dma = tx4939ide_init_dma, 646 - .port_ops = &tx4939ide_port_ops, 647 - .dma_ops = &tx4939ide_dma_ops, 648 - .tp_ops = &tx4939ide_tp_ops, 649 - .host_flags = IDE_HFLAG_MMIO, 650 - .pio_mask = ATA_PIO4, 651 - .mwdma_mask = ATA_MWDMA2, 652 - .udma_mask = ATA_UDMA5, 644 + .init_hwif = tx4939ide_init_hwif, 645 + .init_dma = tx4939ide_init_dma, 646 + .port_ops = &tx4939ide_port_ops, 647 + .dma_ops = &tx4939ide_dma_ops, 648 + .tp_ops = &tx4939ide_tp_ops, 649 + .host_flags = IDE_HFLAG_MMIO, 650 + .pio_mask = ATA_PIO4, 651 + .mwdma_mask = ATA_MWDMA2, 652 + .udma_mask = ATA_UDMA5, 653 + .chipset = ide_generic, 653 654 }; 654 655 655 656 static int __init tx4939ide_probe(struct platform_device *pdev)
+4 -4
drivers/scsi/Kconfig
··· 21 21 You also need to say Y here if you have a device which speaks 22 22 the SCSI protocol. Examples of this include the parallel port 23 23 version of the IOMEGA ZIP drive, USB storage devices, Fibre 24 - Channel, FireWire storage and the IDE-SCSI emulation driver. 24 + Channel, and FireWire storage. 25 25 26 26 To compile this driver as a module, choose M here and read 27 27 <file:Documentation/scsi/scsi.txt>. ··· 101 101 ---help--- 102 102 The OnStream SC-x0 SCSI tape drives cannot be driven by the 103 103 standard st driver, but instead need this special osst driver and 104 - use the /dev/osstX char device nodes (major 206). Via usb-storage 105 - and ide-scsi, you may be able to drive the USB-x0 and DI-x0 drives 106 - as well. Note that there is also a second generation of OnStream 104 + use the /dev/osstX char device nodes (major 206). Via usb-storage, 105 + you may be able to drive the USB-x0 and DI-x0 drives as well. 106 + Note that there is also a second generation of OnStream 107 107 tape drives (ADR-x0) that supports the standard SCSI-2 commands for 108 108 tapes (QIC-157) and can be driven by the standard driver st. 109 109 For more information, you may have a look at the SCSI-HOWTO
-1
drivers/scsi/Makefile
··· 105 105 obj-$(CONFIG_SCSI_INITIO) += initio.o 106 106 obj-$(CONFIG_SCSI_INIA100) += a100u2w.o 107 107 obj-$(CONFIG_SCSI_QLOGICPTI) += qlogicpti.o 108 - obj-$(CONFIG_BLK_DEV_IDESCSI) += ide-scsi.o 109 108 obj-$(CONFIG_SCSI_MESH) += mesh.o 110 109 obj-$(CONFIG_SCSI_MAC53C94) += mac53c94.o 111 110 obj-$(CONFIG_BLK_DEV_3W_XXXX_RAID) += 3w-xxxx.o
-840
drivers/scsi/ide-scsi.c
··· 1 - /* 2 - * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> 3 - * Copyright (C) 2004-2005 Bartlomiej Zolnierkiewicz 4 - */ 5 - 6 - /* 7 - * Emulation of a SCSI host adapter for IDE ATAPI devices. 8 - * 9 - * With this driver, one can use the Linux SCSI drivers instead of the 10 - * native IDE ATAPI drivers. 11 - * 12 - * Ver 0.1 Dec 3 96 Initial version. 13 - * Ver 0.2 Jan 26 97 Fixed bug in cleanup_module() and added emulation 14 - * of MODE_SENSE_6/MODE_SELECT_6 for cdroms. Thanks 15 - * to Janos Farkas for pointing this out. 16 - * Avoid using bitfields in structures for m68k. 17 - * Added Scatter/Gather and DMA support. 18 - * Ver 0.4 Dec 7 97 Add support for ATAPI PD/CD drives. 19 - * Use variable timeout for each command. 20 - * Ver 0.5 Jan 2 98 Fix previous PD/CD support. 21 - * Allow disabling of SCSI-6 to SCSI-10 transformation. 22 - * Ver 0.6 Jan 27 98 Allow disabling of SCSI command translation layer 23 - * for access through /dev/sg. 24 - * Fix MODE_SENSE_6/MODE_SELECT_6/INQUIRY translation. 25 - * Ver 0.7 Dec 04 98 Ignore commands where lun != 0 to avoid multiple 26 - * detection of devices with CONFIG_SCSI_MULTI_LUN 27 - * Ver 0.8 Feb 05 99 Optical media need translation too. Reverse 0.7. 28 - * Ver 0.9 Jul 04 99 Fix a bug in SG_SET_TRANSFORM. 29 - * Ver 0.91 Jun 10 02 Fix "off by one" error in transforms 30 - * Ver 0.92 Dec 31 02 Implement new SCSI mid level API 31 - */ 32 - 33 - #define IDESCSI_VERSION "0.92" 34 - 35 - #include <linux/module.h> 36 - #include <linux/types.h> 37 - #include <linux/string.h> 38 - #include <linux/kernel.h> 39 - #include <linux/mm.h> 40 - #include <linux/ioport.h> 41 - #include <linux/blkdev.h> 42 - #include <linux/errno.h> 43 - #include <linux/slab.h> 44 - #include <linux/ide.h> 45 - #include <linux/scatterlist.h> 46 - #include <linux/delay.h> 47 - #include <linux/mutex.h> 48 - #include <linux/bitops.h> 49 - 50 - #include <asm/io.h> 51 - #include <asm/uaccess.h> 52 - 53 - #include <scsi/scsi.h> 54 - #include <scsi/scsi_cmnd.h> 55 - #include <scsi/scsi_device.h> 56 - #include <scsi/scsi_host.h> 57 - #include <scsi/scsi_tcq.h> 58 - #include <scsi/sg.h> 59 - 60 - #define IDESCSI_DEBUG_LOG 0 61 - 62 - #if IDESCSI_DEBUG_LOG 63 - #define debug_log(fmt, args...) \ 64 - printk(KERN_INFO "ide-scsi: " fmt, ## args) 65 - #else 66 - #define debug_log(fmt, args...) do {} while (0) 67 - #endif 68 - 69 - /* 70 - * SCSI command transformation layer 71 - */ 72 - #define IDESCSI_SG_TRANSFORM 1 /* /dev/sg transformation */ 73 - 74 - /* 75 - * Log flags 76 - */ 77 - #define IDESCSI_LOG_CMD 0 /* Log SCSI commands */ 78 - 79 - typedef struct ide_scsi_obj { 80 - ide_drive_t *drive; 81 - ide_driver_t *driver; 82 - struct gendisk *disk; 83 - struct Scsi_Host *host; 84 - 85 - unsigned long transform; /* SCSI cmd translation layer */ 86 - unsigned long log; /* log flags */ 87 - } idescsi_scsi_t; 88 - 89 - static DEFINE_MUTEX(idescsi_ref_mutex); 90 - /* Set by module param to skip cd */ 91 - static int idescsi_nocd; 92 - 93 - #define ide_scsi_g(disk) \ 94 - container_of((disk)->private_data, struct ide_scsi_obj, driver) 95 - 96 - static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk) 97 - { 98 - struct ide_scsi_obj *scsi = NULL; 99 - 100 - mutex_lock(&idescsi_ref_mutex); 101 - scsi = ide_scsi_g(disk); 102 - if (scsi) { 103 - if (ide_device_get(scsi->drive)) 104 - scsi = NULL; 105 - else 106 - scsi_host_get(scsi->host); 107 - } 108 - mutex_unlock(&idescsi_ref_mutex); 109 - return scsi; 110 - } 111 - 112 - static void ide_scsi_put(struct ide_scsi_obj *scsi) 113 - { 114 - ide_drive_t *drive = scsi->drive; 115 - 116 - mutex_lock(&idescsi_ref_mutex); 117 - scsi_host_put(scsi->host); 118 - ide_device_put(drive); 119 - mutex_unlock(&idescsi_ref_mutex); 120 - } 121 - 122 - static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) 123 - { 124 - return (idescsi_scsi_t*) (&host[1]); 125 - } 126 - 127 - static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive) 128 - { 129 - return scsihost_to_idescsi(ide_drive->driver_data); 130 - } 131 - 132 - static void ide_scsi_hex_dump(u8 *data, int len) 133 - { 134 - print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); 135 - } 136 - 137 - static int idescsi_end_request(ide_drive_t *, int, int); 138 - 139 - static void ide_scsi_callback(ide_drive_t *drive, int dsc) 140 - { 141 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 142 - struct ide_atapi_pc *pc = drive->pc; 143 - 144 - if (pc->flags & PC_FLAG_TIMEDOUT) 145 - debug_log("%s: got timed out packet %lu at %lu\n", __func__, 146 - pc->scsi_cmd->serial_number, jiffies); 147 - /* end this request now - scsi should retry it*/ 148 - else if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 149 - printk(KERN_INFO "Packet command completed, %d bytes" 150 - " transferred\n", pc->xferred); 151 - 152 - idescsi_end_request(drive, 1, 0); 153 - } 154 - 155 - static int idescsi_check_condition(ide_drive_t *drive, 156 - struct request *failed_cmd) 157 - { 158 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 159 - struct ide_atapi_pc *pc; 160 - struct request *rq; 161 - u8 *buf; 162 - 163 - /* stuff a sense request in front of our current request */ 164 - pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 165 - rq = blk_get_request(drive->queue, READ, GFP_ATOMIC); 166 - buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); 167 - if (!pc || !rq || !buf) { 168 - kfree(buf); 169 - if (rq) 170 - blk_put_request(rq); 171 - kfree(pc); 172 - return -ENOMEM; 173 - } 174 - rq->special = (char *) pc; 175 - pc->rq = rq; 176 - pc->buf = buf; 177 - pc->c[0] = REQUEST_SENSE; 178 - pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE; 179 - rq->cmd_type = REQ_TYPE_SENSE; 180 - rq->cmd_flags |= REQ_PREEMPT; 181 - pc->timeout = jiffies + WAIT_READY; 182 - /* NOTE! Save the failed packet command in "rq->buffer" */ 183 - rq->buffer = (void *) failed_cmd->special; 184 - pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd; 185 - if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { 186 - printk ("ide-scsi: %s: queue cmd = ", drive->name); 187 - ide_scsi_hex_dump(pc->c, 6); 188 - } 189 - rq->rq_disk = scsi->disk; 190 - rq->ref_count++; 191 - memcpy(rq->cmd, pc->c, 12); 192 - ide_do_drive_cmd(drive, rq); 193 - return 0; 194 - } 195 - 196 - static ide_startstop_t 197 - idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) 198 - { 199 - ide_hwif_t *hwif = drive->hwif; 200 - 201 - if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) 202 - /* force an abort */ 203 - hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE); 204 - 205 - rq->errors++; 206 - 207 - idescsi_end_request(drive, 0, 0); 208 - 209 - return ide_stopped; 210 - } 211 - 212 - static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) 213 - { 214 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 215 - struct request *rq = HWGROUP(drive)->rq; 216 - struct ide_atapi_pc *pc = (struct ide_atapi_pc *) rq->special; 217 - int log = test_bit(IDESCSI_LOG_CMD, &scsi->log); 218 - struct Scsi_Host *host; 219 - int errors = rq->errors; 220 - unsigned long flags; 221 - 222 - if (!blk_special_request(rq) && !blk_sense_request(rq)) { 223 - ide_end_request(drive, uptodate, nrsecs); 224 - return 0; 225 - } 226 - ide_end_drive_cmd (drive, 0, 0); 227 - if (blk_sense_request(rq)) { 228 - struct ide_atapi_pc *opc = (struct ide_atapi_pc *) rq->buffer; 229 - if (log) { 230 - printk ("ide-scsi: %s: wrap up check %lu, rst = ", drive->name, opc->scsi_cmd->serial_number); 231 - ide_scsi_hex_dump(pc->buf, 16); 232 - } 233 - memcpy((void *) opc->scsi_cmd->sense_buffer, pc->buf, 234 - SCSI_SENSE_BUFFERSIZE); 235 - kfree(pc->buf); 236 - kfree(pc); 237 - blk_put_request(rq); 238 - pc = opc; 239 - rq = pc->rq; 240 - pc->scsi_cmd->result = (CHECK_CONDITION << 1) | 241 - (((pc->flags & PC_FLAG_TIMEDOUT) ? 242 - DID_TIME_OUT : 243 - DID_OK) << 16); 244 - } else if (pc->flags & PC_FLAG_TIMEDOUT) { 245 - if (log) 246 - printk (KERN_WARNING "ide-scsi: %s: timed out for %lu\n", 247 - drive->name, pc->scsi_cmd->serial_number); 248 - pc->scsi_cmd->result = DID_TIME_OUT << 16; 249 - } else if (errors >= ERROR_MAX) { 250 - pc->scsi_cmd->result = DID_ERROR << 16; 251 - if (log) 252 - printk ("ide-scsi: %s: I/O error for %lu\n", drive->name, pc->scsi_cmd->serial_number); 253 - } else if (errors) { 254 - if (log) 255 - printk ("ide-scsi: %s: check condition for %lu\n", drive->name, pc->scsi_cmd->serial_number); 256 - if (!idescsi_check_condition(drive, rq)) 257 - /* we started a request sense, so we'll be back, exit for now */ 258 - return 0; 259 - pc->scsi_cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16); 260 - } else { 261 - pc->scsi_cmd->result = DID_OK << 16; 262 - } 263 - host = pc->scsi_cmd->device->host; 264 - spin_lock_irqsave(host->host_lock, flags); 265 - pc->done(pc->scsi_cmd); 266 - spin_unlock_irqrestore(host->host_lock, flags); 267 - kfree(pc); 268 - blk_put_request(rq); 269 - drive->pc = NULL; 270 - return 0; 271 - } 272 - 273 - static inline int idescsi_set_direction(struct ide_atapi_pc *pc) 274 - { 275 - switch (pc->c[0]) { 276 - case READ_6: case READ_10: case READ_12: 277 - pc->flags &= ~PC_FLAG_WRITING; 278 - return 0; 279 - case WRITE_6: case WRITE_10: case WRITE_12: 280 - pc->flags |= PC_FLAG_WRITING; 281 - return 0; 282 - default: 283 - return 1; 284 - } 285 - } 286 - 287 - static int idescsi_map_sg(ide_drive_t *drive, struct ide_atapi_pc *pc) 288 - { 289 - ide_hwif_t *hwif = drive->hwif; 290 - struct scatterlist *sg, *scsi_sg; 291 - int segments; 292 - 293 - if (!pc->req_xfer || pc->req_xfer % 1024) 294 - return 1; 295 - 296 - if (idescsi_set_direction(pc)) 297 - return 1; 298 - 299 - sg = hwif->sg_table; 300 - scsi_sg = scsi_sglist(pc->scsi_cmd); 301 - segments = scsi_sg_count(pc->scsi_cmd); 302 - 303 - if (segments > hwif->sg_max_nents) 304 - return 1; 305 - 306 - hwif->sg_nents = segments; 307 - memcpy(sg, scsi_sg, sizeof(*sg) * segments); 308 - 309 - return 0; 310 - } 311 - 312 - static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, 313 - struct ide_atapi_pc *pc) 314 - { 315 - /* Set the current packet command */ 316 - drive->pc = pc; 317 - 318 - return ide_issue_pc(drive, ide_scsi_get_timeout(pc), ide_scsi_expiry); 319 - } 320 - 321 - /* 322 - * idescsi_do_request is our request handling function. 323 - */ 324 - static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *rq, sector_t block) 325 - { 326 - debug_log("dev: %s, cmd: %x, errors: %d\n", rq->rq_disk->disk_name, 327 - rq->cmd[0], rq->errors); 328 - debug_log("sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n", 329 - rq->sector, rq->nr_sectors, rq->current_nr_sectors); 330 - 331 - if (blk_sense_request(rq) || blk_special_request(rq)) { 332 - struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special; 333 - 334 - if ((drive->dev_flags & IDE_DFLAG_USING_DMA) && 335 - idescsi_map_sg(drive, pc) == 0) 336 - pc->flags |= PC_FLAG_DMA_OK; 337 - 338 - return idescsi_issue_pc(drive, pc); 339 - } 340 - blk_dump_rq_flags(rq, "ide-scsi: unsup command"); 341 - idescsi_end_request (drive, 0, 0); 342 - return ide_stopped; 343 - } 344 - 345 - #ifdef CONFIG_IDE_PROC_FS 346 - static ide_proc_entry_t idescsi_proc[] = { 347 - { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL }, 348 - { NULL, 0, NULL, NULL } 349 - }; 350 - 351 - #define ide_scsi_devset_get(name, field) \ 352 - static int get_##name(ide_drive_t *drive) \ 353 - { \ 354 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); \ 355 - return scsi->field; \ 356 - } 357 - 358 - #define ide_scsi_devset_set(name, field) \ 359 - static int set_##name(ide_drive_t *drive, int arg) \ 360 - { \ 361 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); \ 362 - scsi->field = arg; \ 363 - return 0; \ 364 - } 365 - 366 - #define ide_scsi_devset_rw_field(_name, _field) \ 367 - ide_scsi_devset_get(_name, _field); \ 368 - ide_scsi_devset_set(_name, _field); \ 369 - IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name); 370 - 371 - ide_devset_rw_field(bios_cyl, bios_cyl); 372 - ide_devset_rw_field(bios_head, bios_head); 373 - ide_devset_rw_field(bios_sect, bios_sect); 374 - 375 - ide_scsi_devset_rw_field(transform, transform); 376 - ide_scsi_devset_rw_field(log, log); 377 - 378 - static const struct ide_proc_devset idescsi_settings[] = { 379 - IDE_PROC_DEVSET(bios_cyl, 0, 1023), 380 - IDE_PROC_DEVSET(bios_head, 0, 255), 381 - IDE_PROC_DEVSET(bios_sect, 0, 63), 382 - IDE_PROC_DEVSET(log, 0, 1), 383 - IDE_PROC_DEVSET(transform, 0, 3), 384 - { 0 }, 385 - }; 386 - 387 - static ide_proc_entry_t *ide_scsi_proc_entries(ide_drive_t *drive) 388 - { 389 - return idescsi_proc; 390 - } 391 - 392 - static const struct ide_proc_devset *ide_scsi_proc_devsets(ide_drive_t *drive) 393 - { 394 - return idescsi_settings; 395 - } 396 - #endif 397 - 398 - /* 399 - * Driver initialization. 400 - */ 401 - static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) 402 - { 403 - clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); 404 - #if IDESCSI_DEBUG_LOG 405 - set_bit(IDESCSI_LOG_CMD, &scsi->log); 406 - #endif /* IDESCSI_DEBUG_LOG */ 407 - 408 - drive->pc_callback = ide_scsi_callback; 409 - drive->pc_update_buffers = NULL; 410 - drive->pc_io_buffers = ide_io_buffers; 411 - 412 - ide_proc_register_driver(drive, scsi->driver); 413 - } 414 - 415 - static void ide_scsi_remove(ide_drive_t *drive) 416 - { 417 - struct Scsi_Host *scsihost = drive->driver_data; 418 - struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost); 419 - struct gendisk *g = scsi->disk; 420 - 421 - scsi_remove_host(scsihost); 422 - ide_proc_unregister_driver(drive, scsi->driver); 423 - 424 - ide_unregister_region(g); 425 - 426 - drive->driver_data = NULL; 427 - g->private_data = NULL; 428 - put_disk(g); 429 - 430 - ide_scsi_put(scsi); 431 - 432 - drive->dev_flags &= ~IDE_DFLAG_SCSI; 433 - } 434 - 435 - static int ide_scsi_probe(ide_drive_t *); 436 - 437 - static ide_driver_t idescsi_driver = { 438 - .gen_driver = { 439 - .owner = THIS_MODULE, 440 - .name = "ide-scsi", 441 - .bus = &ide_bus_type, 442 - }, 443 - .probe = ide_scsi_probe, 444 - .remove = ide_scsi_remove, 445 - .version = IDESCSI_VERSION, 446 - .do_request = idescsi_do_request, 447 - .end_request = idescsi_end_request, 448 - .error = idescsi_atapi_error, 449 - #ifdef CONFIG_IDE_PROC_FS 450 - .proc_entries = ide_scsi_proc_entries, 451 - .proc_devsets = ide_scsi_proc_devsets, 452 - #endif 453 - }; 454 - 455 - static int idescsi_ide_open(struct block_device *bdev, fmode_t mode) 456 - { 457 - struct ide_scsi_obj *scsi = ide_scsi_get(bdev->bd_disk); 458 - 459 - if (!scsi) 460 - return -ENXIO; 461 - 462 - return 0; 463 - } 464 - 465 - static int idescsi_ide_release(struct gendisk *disk, fmode_t mode) 466 - { 467 - ide_scsi_put(ide_scsi_g(disk)); 468 - return 0; 469 - } 470 - 471 - static int idescsi_ide_ioctl(struct block_device *bdev, fmode_t mode, 472 - unsigned int cmd, unsigned long arg) 473 - { 474 - struct ide_scsi_obj *scsi = ide_scsi_g(bdev->bd_disk); 475 - return generic_ide_ioctl(scsi->drive, bdev, cmd, arg); 476 - } 477 - 478 - static struct block_device_operations idescsi_ops = { 479 - .owner = THIS_MODULE, 480 - .open = idescsi_ide_open, 481 - .release = idescsi_ide_release, 482 - .locked_ioctl = idescsi_ide_ioctl, 483 - }; 484 - 485 - static int idescsi_slave_configure(struct scsi_device * sdp) 486 - { 487 - /* Configure detected device */ 488 - sdp->use_10_for_rw = 1; 489 - sdp->use_10_for_ms = 1; 490 - scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, sdp->host->cmd_per_lun); 491 - return 0; 492 - } 493 - 494 - static const char *idescsi_info (struct Scsi_Host *host) 495 - { 496 - return "SCSI host adapter emulation for IDE ATAPI devices"; 497 - } 498 - 499 - static int idescsi_ioctl (struct scsi_device *dev, int cmd, void __user *arg) 500 - { 501 - idescsi_scsi_t *scsi = scsihost_to_idescsi(dev->host); 502 - 503 - if (cmd == SG_SET_TRANSFORM) { 504 - if (arg) 505 - set_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); 506 - else 507 - clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); 508 - return 0; 509 - } else if (cmd == SG_GET_TRANSFORM) 510 - return put_user(test_bit(IDESCSI_SG_TRANSFORM, &scsi->transform), (int __user *) arg); 511 - return -EINVAL; 512 - } 513 - 514 - static int idescsi_queue (struct scsi_cmnd *cmd, 515 - void (*done)(struct scsi_cmnd *)) 516 - { 517 - struct Scsi_Host *host = cmd->device->host; 518 - idescsi_scsi_t *scsi = scsihost_to_idescsi(host); 519 - ide_drive_t *drive = scsi->drive; 520 - struct request *rq = NULL; 521 - struct ide_atapi_pc *pc = NULL; 522 - int write = cmd->sc_data_direction == DMA_TO_DEVICE; 523 - 524 - if (!drive) { 525 - scmd_printk (KERN_ERR, cmd, "drive not present\n"); 526 - goto abort; 527 - } 528 - scsi = drive_to_idescsi(drive); 529 - pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 530 - rq = blk_get_request(drive->queue, write, GFP_ATOMIC); 531 - if (rq == NULL || pc == NULL) { 532 - printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); 533 - goto abort; 534 - } 535 - 536 - memset (pc->c, 0, 12); 537 - pc->flags = 0; 538 - if (cmd->sc_data_direction == DMA_TO_DEVICE) 539 - pc->flags |= PC_FLAG_WRITING; 540 - pc->rq = rq; 541 - memcpy (pc->c, cmd->cmnd, cmd->cmd_len); 542 - pc->buf = NULL; 543 - pc->sg = scsi_sglist(cmd); 544 - pc->sg_cnt = scsi_sg_count(cmd); 545 - pc->b_count = 0; 546 - pc->req_xfer = pc->buf_size = scsi_bufflen(cmd); 547 - pc->scsi_cmd = cmd; 548 - pc->done = done; 549 - pc->timeout = jiffies + cmd->request->timeout; 550 - 551 - if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { 552 - printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); 553 - ide_scsi_hex_dump(cmd->cmnd, cmd->cmd_len); 554 - if (memcmp(pc->c, cmd->cmnd, cmd->cmd_len)) { 555 - printk ("ide-scsi: %s: que %lu, tsl = ", drive->name, cmd->serial_number); 556 - ide_scsi_hex_dump(pc->c, 12); 557 - } 558 - } 559 - 560 - rq->special = (char *) pc; 561 - rq->cmd_type = REQ_TYPE_SPECIAL; 562 - spin_unlock_irq(host->host_lock); 563 - rq->ref_count++; 564 - memcpy(rq->cmd, pc->c, 12); 565 - blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); 566 - spin_lock_irq(host->host_lock); 567 - return 0; 568 - abort: 569 - kfree (pc); 570 - if (rq) 571 - blk_put_request(rq); 572 - cmd->result = DID_ERROR << 16; 573 - done(cmd); 574 - return 0; 575 - } 576 - 577 - static int idescsi_eh_abort (struct scsi_cmnd *cmd) 578 - { 579 - idescsi_scsi_t *scsi = scsihost_to_idescsi(cmd->device->host); 580 - ide_drive_t *drive = scsi->drive; 581 - ide_hwif_t *hwif; 582 - ide_hwgroup_t *hwgroup; 583 - int busy; 584 - int ret = FAILED; 585 - 586 - struct ide_atapi_pc *pc; 587 - 588 - /* In idescsi_eh_abort we try to gently pry our command from the ide subsystem */ 589 - 590 - if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 591 - printk (KERN_WARNING "ide-scsi: abort called for %lu\n", cmd->serial_number); 592 - 593 - if (!drive) { 594 - printk (KERN_WARNING "ide-scsi: Drive not set in idescsi_eh_abort\n"); 595 - WARN_ON(1); 596 - goto no_drive; 597 - } 598 - 599 - hwif = drive->hwif; 600 - hwgroup = hwif->hwgroup; 601 - 602 - /* First give it some more time, how much is "right" is hard to say :-( 603 - FIXME - uses mdelay which causes latency? */ 604 - busy = ide_wait_not_busy(hwif, 100); 605 - if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 606 - printk (KERN_WARNING "ide-scsi: drive did%s become ready\n", busy?" not":""); 607 - 608 - spin_lock_irq(&hwgroup->lock); 609 - 610 - /* If there is no pc running we're done (our interrupt took care of it) */ 611 - pc = drive->pc; 612 - if (pc == NULL) { 613 - ret = SUCCESS; 614 - goto ide_unlock; 615 - } 616 - 617 - /* It's somewhere in flight. Does ide subsystem agree? */ 618 - if (pc->scsi_cmd->serial_number == cmd->serial_number && !busy && 619 - elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != pc->rq) { 620 - /* 621 - * FIXME - not sure this condition can ever occur 622 - */ 623 - printk (KERN_ERR "ide-scsi: cmd aborted!\n"); 624 - 625 - if (blk_sense_request(pc->rq)) 626 - kfree(pc->buf); 627 - /* we need to call blk_put_request twice. */ 628 - blk_put_request(pc->rq); 629 - blk_put_request(pc->rq); 630 - kfree(pc); 631 - drive->pc = NULL; 632 - 633 - ret = SUCCESS; 634 - } 635 - 636 - ide_unlock: 637 - spin_unlock_irq(&hwgroup->lock); 638 - no_drive: 639 - if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 640 - printk (KERN_WARNING "ide-scsi: abort returns %s\n", ret == SUCCESS?"success":"failed"); 641 - 642 - return ret; 643 - } 644 - 645 - static int idescsi_eh_reset (struct scsi_cmnd *cmd) 646 - { 647 - struct request *req; 648 - idescsi_scsi_t *scsi = scsihost_to_idescsi(cmd->device->host); 649 - ide_drive_t *drive = scsi->drive; 650 - ide_hwgroup_t *hwgroup; 651 - int ready = 0; 652 - int ret = SUCCESS; 653 - 654 - struct ide_atapi_pc *pc; 655 - 656 - /* In idescsi_eh_reset we forcefully remove the command from the ide subsystem and reset the device. */ 657 - 658 - if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 659 - printk (KERN_WARNING "ide-scsi: reset called for %lu\n", cmd->serial_number); 660 - 661 - if (!drive) { 662 - printk (KERN_WARNING "ide-scsi: Drive not set in idescsi_eh_reset\n"); 663 - WARN_ON(1); 664 - return FAILED; 665 - } 666 - 667 - hwgroup = drive->hwif->hwgroup; 668 - 669 - spin_lock_irq(cmd->device->host->host_lock); 670 - spin_lock(&hwgroup->lock); 671 - 672 - pc = drive->pc; 673 - if (pc) 674 - req = pc->rq; 675 - 676 - if (pc == NULL || req != hwgroup->rq || hwgroup->handler == NULL) { 677 - printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n"); 678 - spin_unlock(&hwgroup->lock); 679 - spin_unlock_irq(cmd->device->host->host_lock); 680 - return FAILED; 681 - } 682 - 683 - /* kill current request */ 684 - if (__blk_end_request(req, -EIO, 0)) 685 - BUG(); 686 - if (blk_sense_request(req)) 687 - kfree(pc->buf); 688 - kfree(pc); 689 - drive->pc = NULL; 690 - blk_put_request(req); 691 - 692 - /* now nuke the drive queue */ 693 - while ((req = elv_next_request(drive->queue))) { 694 - if (__blk_end_request(req, -EIO, 0)) 695 - BUG(); 696 - } 697 - 698 - hwgroup->rq = NULL; 699 - hwgroup->handler = NULL; 700 - hwgroup->busy = 1; /* will set this to zero when ide reset finished */ 701 - spin_unlock(&hwgroup->lock); 702 - 703 - ide_do_reset(drive); 704 - 705 - /* ide_do_reset starts a polling handler which restarts itself every 50ms until the reset finishes */ 706 - 707 - do { 708 - spin_unlock_irq(cmd->device->host->host_lock); 709 - msleep(50); 710 - spin_lock_irq(cmd->device->host->host_lock); 711 - } while ( HWGROUP(drive)->handler ); 712 - 713 - ready = drive_is_ready(drive); 714 - HWGROUP(drive)->busy--; 715 - if (!ready) { 716 - printk (KERN_ERR "ide-scsi: reset failed!\n"); 717 - ret = FAILED; 718 - } 719 - 720 - spin_unlock_irq(cmd->device->host->host_lock); 721 - return ret; 722 - } 723 - 724 - static int idescsi_bios(struct scsi_device *sdev, struct block_device *bdev, 725 - sector_t capacity, int *parm) 726 - { 727 - idescsi_scsi_t *idescsi = scsihost_to_idescsi(sdev->host); 728 - ide_drive_t *drive = idescsi->drive; 729 - 730 - if (drive->bios_cyl && drive->bios_head && drive->bios_sect) { 731 - parm[0] = drive->bios_head; 732 - parm[1] = drive->bios_sect; 733 - parm[2] = drive->bios_cyl; 734 - } 735 - return 0; 736 - } 737 - 738 - static struct scsi_host_template idescsi_template = { 739 - .module = THIS_MODULE, 740 - .name = "idescsi", 741 - .info = idescsi_info, 742 - .slave_configure = idescsi_slave_configure, 743 - .ioctl = idescsi_ioctl, 744 - .queuecommand = idescsi_queue, 745 - .eh_abort_handler = idescsi_eh_abort, 746 - .eh_host_reset_handler = idescsi_eh_reset, 747 - .bios_param = idescsi_bios, 748 - .can_queue = 40, 749 - .this_id = -1, 750 - .sg_tablesize = 256, 751 - .cmd_per_lun = 5, 752 - .max_sectors = 128, 753 - .use_clustering = DISABLE_CLUSTERING, 754 - .emulated = 1, 755 - .proc_name = "ide-scsi", 756 - }; 757 - 758 - static int ide_scsi_probe(ide_drive_t *drive) 759 - { 760 - idescsi_scsi_t *idescsi; 761 - struct Scsi_Host *host; 762 - struct gendisk *g; 763 - static int warned; 764 - int err = -ENOMEM; 765 - u16 last_lun; 766 - 767 - if (!warned && drive->media == ide_cdrom) { 768 - printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n"); 769 - warned = 1; 770 - } 771 - 772 - if (idescsi_nocd && drive->media == ide_cdrom) 773 - return -ENODEV; 774 - 775 - if (!strstr("ide-scsi", drive->driver_req) || 776 - drive->media == ide_disk || 777 - !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) 778 - return -ENODEV; 779 - 780 - drive->dev_flags |= IDE_DFLAG_SCSI; 781 - 782 - g = alloc_disk(1 << PARTN_BITS); 783 - if (!g) 784 - goto out_host_put; 785 - 786 - ide_init_disk(g, drive); 787 - 788 - host->max_id = 1; 789 - 790 - last_lun = drive->id[ATA_ID_LAST_LUN]; 791 - if (last_lun) 792 - debug_log("%s: last_lun=%u\n", drive->name, last_lun); 793 - 794 - if ((last_lun & 7) != 7) 795 - host->max_lun = (last_lun & 7) + 1; 796 - else 797 - host->max_lun = 1; 798 - 799 - drive->driver_data = host; 800 - idescsi = scsihost_to_idescsi(host); 801 - idescsi->drive = drive; 802 - idescsi->driver = &idescsi_driver; 803 - idescsi->host = host; 804 - idescsi->disk = g; 805 - g->private_data = &idescsi->driver; 806 - err = 0; 807 - idescsi_setup(drive, idescsi); 808 - g->fops = &idescsi_ops; 809 - ide_register_region(g); 810 - err = scsi_add_host(host, &drive->gendev); 811 - if (!err) { 812 - scsi_scan_host(host); 813 - return 0; 814 - } 815 - /* fall through on error */ 816 - ide_unregister_region(g); 817 - ide_proc_unregister_driver(drive, &idescsi_driver); 818 - 819 - put_disk(g); 820 - out_host_put: 821 - drive->dev_flags &= ~IDE_DFLAG_SCSI; 822 - scsi_host_put(host); 823 - return err; 824 - } 825 - 826 - static int __init init_idescsi_module(void) 827 - { 828 - return driver_register(&idescsi_driver.gen_driver); 829 - } 830 - 831 - static void __exit exit_idescsi_module(void) 832 - { 833 - driver_unregister(&idescsi_driver.gen_driver); 834 - } 835 - 836 - module_param(idescsi_nocd, int, 0600); 837 - MODULE_PARM_DESC(idescsi_nocd, "Disable handling of CD-ROMs so they may be driven by ide-cd"); 838 - module_init(init_idescsi_module); 839 - module_exit(exit_idescsi_module); 840 - MODULE_LICENSE("GPL");
+65 -56
include/linux/ide.h
··· 32 32 # define SUPPORT_VLB_SYNC 1 33 33 #endif 34 34 35 - /* 36 - * Used to indicate "no IRQ", should be a value that cannot be an IRQ 37 - * number. 38 - */ 39 - 40 - #define IDE_NO_IRQ (-1) 41 - 42 35 typedef unsigned char byte; /* used everywhere */ 43 36 44 37 /* ··· 396 403 * This is used for several packet commands (not for READ/WRITE commands). 397 404 */ 398 405 #define IDE_PC_BUFFER_SIZE 256 406 + #define ATAPI_WAIT_PC (60 * HZ) 399 407 400 408 struct ide_atapi_pc { 401 409 /* actual packet bytes */ ··· 474 480 475 481 /* ide-cd */ 476 482 /* Drive cannot eject the disc. */ 477 - IDE_AFLAG_NO_EJECT = (1 << 3), 483 + IDE_AFLAG_NO_EJECT = (1 << 1), 478 484 /* Drive is a pre ATAPI 1.2 drive. */ 479 - IDE_AFLAG_PRE_ATAPI12 = (1 << 4), 485 + IDE_AFLAG_PRE_ATAPI12 = (1 << 2), 480 486 /* TOC addresses are in BCD. */ 481 - IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5), 487 + IDE_AFLAG_TOCADDR_AS_BCD = (1 << 3), 482 488 /* TOC track numbers are in BCD. */ 483 - IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6), 489 + IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 4), 484 490 /* 485 491 * Drive does not provide data in multiples of SECTOR_SIZE 486 492 * when more than one interrupt is needed. 487 493 */ 488 - IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), 494 + IDE_AFLAG_LIMIT_NFRAMES = (1 << 5), 489 495 /* Saved TOC information is current. */ 490 - IDE_AFLAG_TOC_VALID = (1 << 9), 496 + IDE_AFLAG_TOC_VALID = (1 << 6), 491 497 /* We think that the drive door is locked. */ 492 - IDE_AFLAG_DOOR_LOCKED = (1 << 10), 498 + IDE_AFLAG_DOOR_LOCKED = (1 << 7), 493 499 /* SET_CD_SPEED command is unsupported. */ 494 - IDE_AFLAG_NO_SPEED_SELECT = (1 << 11), 495 - IDE_AFLAG_VERTOS_300_SSD = (1 << 12), 496 - IDE_AFLAG_VERTOS_600_ESD = (1 << 13), 497 - IDE_AFLAG_SANYO_3CD = (1 << 14), 498 - IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15), 499 - IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16), 500 - IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), 500 + IDE_AFLAG_NO_SPEED_SELECT = (1 << 8), 501 + IDE_AFLAG_VERTOS_300_SSD = (1 << 9), 502 + IDE_AFLAG_VERTOS_600_ESD = (1 << 10), 503 + IDE_AFLAG_SANYO_3CD = (1 << 11), 504 + IDE_AFLAG_FULL_CAPS_PAGE = (1 << 12), 505 + IDE_AFLAG_PLAY_AUDIO_OK = (1 << 13), 506 + IDE_AFLAG_LE_SPEED_FIELDS = (1 << 14), 501 507 502 508 /* ide-floppy */ 503 509 /* Avoid commands not supported in Clik drive */ 504 - IDE_AFLAG_CLIK_DRIVE = (1 << 19), 510 + IDE_AFLAG_CLIK_DRIVE = (1 << 15), 505 511 /* Requires BH algorithm for packets */ 506 - IDE_AFLAG_ZIP_DRIVE = (1 << 20), 512 + IDE_AFLAG_ZIP_DRIVE = (1 << 16), 507 513 /* Supports format progress report */ 508 - IDE_AFLAG_SRFP = (1 << 22), 514 + IDE_AFLAG_SRFP = (1 << 17), 509 515 510 516 /* ide-tape */ 511 - IDE_AFLAG_IGNORE_DSC = (1 << 23), 517 + IDE_AFLAG_IGNORE_DSC = (1 << 18), 512 518 /* 0 When the tape position is unknown */ 513 - IDE_AFLAG_ADDRESS_VALID = (1 << 24), 519 + IDE_AFLAG_ADDRESS_VALID = (1 << 19), 514 520 /* Device already opened */ 515 - IDE_AFLAG_BUSY = (1 << 25), 521 + IDE_AFLAG_BUSY = (1 << 20), 516 522 /* Attempt to auto-detect the current user block size */ 517 - IDE_AFLAG_DETECT_BS = (1 << 26), 523 + IDE_AFLAG_DETECT_BS = (1 << 21), 518 524 /* Currently on a filemark */ 519 - IDE_AFLAG_FILEMARK = (1 << 27), 525 + IDE_AFLAG_FILEMARK = (1 << 22), 520 526 /* 0 = no tape is loaded, so we don't rewind after ejecting */ 521 - IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), 527 + IDE_AFLAG_MEDIUM_PRESENT = (1 << 23), 522 528 523 - IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), 529 + IDE_AFLAG_NO_AUTOCLOSE = (1 << 24), 524 530 }; 525 531 526 532 /* device flags */ ··· 559 565 IDE_DFLAG_NODMA = (1 << 16), 560 566 /* powermanagment told us not to do anything, so sleep nicely */ 561 567 IDE_DFLAG_BLOCKED = (1 << 17), 562 - /* ide-scsi emulation */ 563 - IDE_DFLAG_SCSI = (1 << 18), 564 568 /* sleeping & sleep field valid */ 565 - IDE_DFLAG_SLEEPING = (1 << 19), 566 - IDE_DFLAG_POST_RESET = (1 << 20), 567 - IDE_DFLAG_UDMA33_WARNED = (1 << 21), 568 - IDE_DFLAG_LBA48 = (1 << 22), 569 + IDE_DFLAG_SLEEPING = (1 << 18), 570 + IDE_DFLAG_POST_RESET = (1 << 19), 571 + IDE_DFLAG_UDMA33_WARNED = (1 << 20), 572 + IDE_DFLAG_LBA48 = (1 << 21), 569 573 /* status of write cache */ 570 - IDE_DFLAG_WCACHE = (1 << 23), 574 + IDE_DFLAG_WCACHE = (1 << 22), 571 575 /* used for ignoring ATA_DF */ 572 - IDE_DFLAG_NOWERR = (1 << 24), 576 + IDE_DFLAG_NOWERR = (1 << 23), 573 577 /* retrying in PIO */ 574 - IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), 575 - IDE_DFLAG_LBA = (1 << 26), 578 + IDE_DFLAG_DMA_PIO_RETRY = (1 << 24), 579 + IDE_DFLAG_LBA = (1 << 25), 576 580 /* don't unload heads */ 577 - IDE_DFLAG_NO_UNLOAD = (1 << 27), 581 + IDE_DFLAG_NO_UNLOAD = (1 << 26), 578 582 /* heads unloaded, please don't reset port */ 579 - IDE_DFLAG_PARKED = (1 << 28), 580 - IDE_DFLAG_MEDIA_CHANGED = (1 << 29), 583 + IDE_DFLAG_PARKED = (1 << 27), 584 + IDE_DFLAG_MEDIA_CHANGED = (1 << 28), 581 585 /* write protect */ 582 - IDE_DFLAG_WP = (1 << 30), 583 - IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 31), 586 + IDE_DFLAG_WP = (1 << 29), 587 + IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 30), 584 588 }; 585 589 586 590 struct ide_drive_s { ··· 602 610 unsigned long dev_flags; 603 611 604 612 unsigned long sleep; /* sleep until this time */ 605 - unsigned long service_start; /* time we started last request */ 606 - unsigned long service_time; /* service time of last request */ 607 613 unsigned long timeout; /* max time to wait for irq */ 608 614 609 615 special_t special; /* special action flags */ ··· 869 879 870 880 /* BOOL: protects all fields below */ 871 881 volatile int busy; 872 - /* BOOL: wake us up on timer expiry */ 873 - unsigned int sleeping : 1; 874 882 /* BOOL: polling active & poll_timeout field valid */ 875 883 unsigned int polling : 1; 876 884 ··· 1246 1258 void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); 1247 1259 void ide_retry_pc(ide_drive_t *, struct gendisk *); 1248 1260 1249 - static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) 1250 - { 1251 - return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); 1252 - } 1261 + int ide_cd_expiry(ide_drive_t *); 1253 1262 1254 - int ide_scsi_expiry(ide_drive_t *); 1263 + int ide_cd_get_xferlen(struct request *); 1255 1264 1256 - ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); 1265 + ide_startstop_t ide_issue_pc(ide_drive_t *); 1257 1266 1258 1267 ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1259 1268 ··· 1272 1287 1273 1288 extern void ide_timer_expiry(unsigned long); 1274 1289 extern irqreturn_t ide_intr(int irq, void *dev_id); 1290 + 1291 + static inline int ide_lock_hwgroup(ide_hwgroup_t *hwgroup) 1292 + { 1293 + if (hwgroup->busy) 1294 + return 1; 1295 + 1296 + hwgroup->busy = 1; 1297 + /* for atari only */ 1298 + ide_get_lock(ide_intr, hwgroup); 1299 + 1300 + return 0; 1301 + } 1302 + 1303 + static inline void ide_unlock_hwgroup(ide_hwgroup_t *hwgroup) 1304 + { 1305 + /* for atari only */ 1306 + ide_release_lock(); 1307 + hwgroup->busy = 0; 1308 + } 1309 + 1275 1310 extern void do_ide_request(struct request_queue *); 1276 1311 1277 1312 void ide_init_disk(struct gendisk *, ide_drive_t *); ··· 1538 1533 void ide_undecoded_slave(ide_drive_t *); 1539 1534 1540 1535 void ide_port_apply_params(ide_hwif_t *); 1536 + int ide_sysfs_register_port(ide_hwif_t *); 1541 1537 1542 1538 struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); 1543 1539 void ide_host_free(struct ide_host *); ··· 1633 1627 1634 1628 #define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0) 1635 1629 1630 + char *ide_media_string(ide_drive_t *); 1631 + 1632 + extern struct device_attribute ide_dev_attrs[]; 1636 1633 extern struct bus_type ide_bus_type; 1637 1634 extern struct class *ide_port_class; 1638 1635