aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:15:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:15:06 -0400
commit7591103c08abade60aeddb432ed0686ddd0de1c6 (patch)
tree523343b43b0c420666da18c64e1e9f21ff63dea5 /drivers/scsi
parent2be4ff2f084842839b041b793ed6237e8d1d315a (diff)
parent9c6102d446985bca9c426cb2d9b478ed21d2b024 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (66 commits) ata: Add documentation for hard disk shock protection interface (v3) ide: Implement disk shock protection support (v4) ide-cd: fix printk format warning piix: add Hercules EC-900 mini-notebook to ich_laptop short cable list ide-atapi: assign taskfile flags per device type ide-cd: move cdrom_info.dma to ide_drive_t.dma ide: add ide_drive_t.dma flag ide-cd: add a debug_mask module parameter ide-cd: convert driver to new ide debugging macro (v3) ide: move SFF DMA code to ide-dma-sff.c ide: cleanup ide-dma.c ide: cleanup ide_build_dmatable() ide: remove needless includes from ide-dma.c ide: switch to DMA-mapping API part #2 ide: make ide_dma_timeout() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n ide: make ide_dma_lost_irq() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n ide: __ide_dma_end() -> ide_dma_end() pmac: remove needless pmac_ide_destroy_dmatable() wrapper pmac: remove superfluous pmif == NULL checks ide: Two fixes regarding memory allocation ...
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ide-scsi.c102
1 files changed, 33 insertions, 69 deletions
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 90212ac33be3..740bad435995 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -82,7 +82,6 @@ typedef struct ide_scsi_obj {
82 struct gendisk *disk; 82 struct gendisk *disk;
83 struct Scsi_Host *host; 83 struct Scsi_Host *host;
84 84
85 struct ide_atapi_pc *pc; /* Current packet command */
86 unsigned long transform; /* SCSI cmd translation layer */ 85 unsigned long transform; /* SCSI cmd translation layer */
87 unsigned long log; /* log flags */ 86 unsigned long log; /* log flags */
88} idescsi_scsi_t; 87} idescsi_scsi_t;
@@ -137,10 +136,10 @@ static void ide_scsi_hex_dump(u8 *data, int len)
137 136
138static int idescsi_end_request(ide_drive_t *, int, int); 137static int idescsi_end_request(ide_drive_t *, int, int);
139 138
140static void ide_scsi_callback(ide_drive_t *drive) 139static void ide_scsi_callback(ide_drive_t *drive, int dsc)
141{ 140{
142 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 141 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
143 struct ide_atapi_pc *pc = scsi->pc; 142 struct ide_atapi_pc *pc = drive->pc;
144 143
145 if (pc->flags & PC_FLAG_TIMEDOUT) 144 if (pc->flags & PC_FLAG_TIMEDOUT)
146 debug_log("%s: got timed out packet %lu at %lu\n", __func__, 145 debug_log("%s: got timed out packet %lu at %lu\n", __func__,
@@ -267,49 +266,10 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
267 spin_unlock_irqrestore(host->host_lock, flags); 266 spin_unlock_irqrestore(host->host_lock, flags);
268 kfree(pc); 267 kfree(pc);
269 blk_put_request(rq); 268 blk_put_request(rq);
270 scsi->pc = NULL; 269 drive->pc = NULL;
271 return 0; 270 return 0;
272} 271}
273 272
274static inline unsigned long get_timeout(struct ide_atapi_pc *pc)
275{
276 return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies);
277}
278
279static int idescsi_expiry(ide_drive_t *drive)
280{
281 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
282 struct ide_atapi_pc *pc = scsi->pc;
283
284 debug_log("%s called for %lu at %lu\n", __func__,
285 pc->scsi_cmd->serial_number, jiffies);
286
287 pc->flags |= PC_FLAG_TIMEDOUT;
288
289 return 0; /* we do not want the ide subsystem to retry */
290}
291
292/*
293 * Our interrupt handler.
294 */
295static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
296{
297 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
298 struct ide_atapi_pc *pc = scsi->pc;
299
300 return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc),
301 idescsi_expiry, NULL, NULL, NULL,
302 ide_io_buffers);
303}
304
305static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
306{
307 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
308
309 return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr,
310 get_timeout(scsi->pc), idescsi_expiry);
311}
312
313static inline int idescsi_set_direction(struct ide_atapi_pc *pc) 273static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
314{ 274{
315 switch (pc->c[0]) { 275 switch (pc->c[0]) {
@@ -352,13 +312,10 @@ static int idescsi_map_sg(ide_drive_t *drive, struct ide_atapi_pc *pc)
352static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, 312static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
353 struct ide_atapi_pc *pc) 313 struct ide_atapi_pc *pc)
354{ 314{
355 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
356
357 /* Set the current packet command */ 315 /* Set the current packet command */
358 scsi->pc = pc; 316 drive->pc = pc;
359 317
360 return ide_issue_pc(drive, pc, idescsi_transfer_pc, 318 return ide_issue_pc(drive, ide_scsi_get_timeout(pc), ide_scsi_expiry);
361 get_timeout(pc), idescsi_expiry);
362} 319}
363 320
364/* 321/*
@@ -374,7 +331,8 @@ static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *r
374 if (blk_sense_request(rq) || blk_special_request(rq)) { 331 if (blk_sense_request(rq) || blk_special_request(rq)) {
375 struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special; 332 struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special;
376 333
377 if (drive->using_dma && !idescsi_map_sg(drive, pc)) 334 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) &&
335 idescsi_map_sg(drive, pc) == 0)
378 pc->flags |= PC_FLAG_DMA_OK; 336 pc->flags |= PC_FLAG_DMA_OK;
379 337
380 return idescsi_issue_pc(drive, pc); 338 return idescsi_issue_pc(drive, pc);
@@ -427,14 +385,14 @@ static const struct ide_proc_devset idescsi_settings[] = {
427 */ 385 */
428static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) 386static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
429{ 387{
430 if ((drive->id[ATA_ID_CONFIG] & 0x0060) == 0x20)
431 set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags);
432 clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); 388 clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform);
433#if IDESCSI_DEBUG_LOG 389#if IDESCSI_DEBUG_LOG
434 set_bit(IDESCSI_LOG_CMD, &scsi->log); 390 set_bit(IDESCSI_LOG_CMD, &scsi->log);
435#endif /* IDESCSI_DEBUG_LOG */ 391#endif /* IDESCSI_DEBUG_LOG */
436 392
437 drive->pc_callback = ide_scsi_callback; 393 drive->pc_callback = ide_scsi_callback;
394 drive->pc_update_buffers = NULL;
395 drive->pc_io_buffers = ide_io_buffers;
438 396
439 ide_proc_register_driver(drive, scsi->driver); 397 ide_proc_register_driver(drive, scsi->driver);
440} 398}
@@ -456,7 +414,7 @@ static void ide_scsi_remove(ide_drive_t *drive)
456 414
457 ide_scsi_put(scsi); 415 ide_scsi_put(scsi);
458 416
459 drive->scsi = 0; 417 drive->dev_flags &= ~IDE_DFLAG_SCSI;
460} 418}
461 419
462static int ide_scsi_probe(ide_drive_t *); 420static int ide_scsi_probe(ide_drive_t *);
@@ -477,7 +435,6 @@ static ide_driver_t idescsi_driver = {
477 .probe = ide_scsi_probe, 435 .probe = ide_scsi_probe,
478 .remove = ide_scsi_remove, 436 .remove = ide_scsi_remove,
479 .version = IDESCSI_VERSION, 437 .version = IDESCSI_VERSION,
480 .media = ide_scsi,
481 .do_request = idescsi_do_request, 438 .do_request = idescsi_do_request,
482 .end_request = idescsi_end_request, 439 .end_request = idescsi_end_request,
483 .error = idescsi_atapi_error, 440 .error = idescsi_atapi_error,
@@ -622,6 +579,8 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd)
622 int busy; 579 int busy;
623 int ret = FAILED; 580 int ret = FAILED;
624 581
582 struct ide_atapi_pc *pc;
583
625 /* In idescsi_eh_abort we try to gently pry our command from the ide subsystem */ 584 /* In idescsi_eh_abort we try to gently pry our command from the ide subsystem */
626 585
627 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 586 if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
@@ -642,26 +601,27 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd)
642 spin_lock_irq(&ide_lock); 601 spin_lock_irq(&ide_lock);
643 602
644 /* If there is no pc running we're done (our interrupt took care of it) */ 603 /* If there is no pc running we're done (our interrupt took care of it) */
645 if (!scsi->pc) { 604 pc = drive->pc;
605 if (pc == NULL) {
646 ret = SUCCESS; 606 ret = SUCCESS;
647 goto ide_unlock; 607 goto ide_unlock;
648 } 608 }
649 609
650 /* It's somewhere in flight. Does ide subsystem agree? */ 610 /* It's somewhere in flight. Does ide subsystem agree? */
651 if (scsi->pc->scsi_cmd->serial_number == cmd->serial_number && !busy && 611 if (pc->scsi_cmd->serial_number == cmd->serial_number && !busy &&
652 elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != scsi->pc->rq) { 612 elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != pc->rq) {
653 /* 613 /*
654 * FIXME - not sure this condition can ever occur 614 * FIXME - not sure this condition can ever occur
655 */ 615 */
656 printk (KERN_ERR "ide-scsi: cmd aborted!\n"); 616 printk (KERN_ERR "ide-scsi: cmd aborted!\n");
657 617
658 if (blk_sense_request(scsi->pc->rq)) 618 if (blk_sense_request(pc->rq))
659 kfree(scsi->pc->buf); 619 kfree(pc->buf);
660 /* we need to call blk_put_request twice. */ 620 /* we need to call blk_put_request twice. */
661 blk_put_request(scsi->pc->rq); 621 blk_put_request(pc->rq);
662 blk_put_request(scsi->pc->rq); 622 blk_put_request(pc->rq);
663 kfree(scsi->pc); 623 kfree(pc);
664 scsi->pc = NULL; 624 drive->pc = NULL;
665 625
666 ret = SUCCESS; 626 ret = SUCCESS;
667 } 627 }
@@ -683,6 +643,8 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
683 int ready = 0; 643 int ready = 0;
684 int ret = SUCCESS; 644 int ret = SUCCESS;
685 645
646 struct ide_atapi_pc *pc;
647
686 /* In idescsi_eh_reset we forcefully remove the command from the ide subsystem and reset the device. */ 648 /* In idescsi_eh_reset we forcefully remove the command from the ide subsystem and reset the device. */
687 649
688 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) 650 if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
@@ -697,7 +659,9 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
697 spin_lock_irq(cmd->device->host->host_lock); 659 spin_lock_irq(cmd->device->host->host_lock);
698 spin_lock(&ide_lock); 660 spin_lock(&ide_lock);
699 661
700 if (!scsi->pc || (req = scsi->pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) { 662 pc = drive->pc;
663
664 if (pc == NULL || (req = pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) {
701 printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n"); 665 printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n");
702 spin_unlock(&ide_lock); 666 spin_unlock(&ide_lock);
703 spin_unlock_irq(cmd->device->host->host_lock); 667 spin_unlock_irq(cmd->device->host->host_lock);
@@ -708,9 +672,9 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
708 if (__blk_end_request(req, -EIO, 0)) 672 if (__blk_end_request(req, -EIO, 0))
709 BUG(); 673 BUG();
710 if (blk_sense_request(req)) 674 if (blk_sense_request(req))
711 kfree(scsi->pc->buf); 675 kfree(pc->buf);
712 kfree(scsi->pc); 676 kfree(pc);
713 scsi->pc = NULL; 677 drive->pc = NULL;
714 blk_put_request(req); 678 blk_put_request(req);
715 679
716 /* now nuke the drive queue */ 680 /* now nuke the drive queue */
@@ -801,7 +765,7 @@ static int ide_scsi_probe(ide_drive_t *drive)
801 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) 765 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))
802 return -ENODEV; 766 return -ENODEV;
803 767
804 drive->scsi = 1; 768 drive->dev_flags |= IDE_DFLAG_SCSI;
805 769
806 g = alloc_disk(1 << PARTN_BITS); 770 g = alloc_disk(1 << PARTN_BITS);
807 if (!g) 771 if (!g)
@@ -842,7 +806,7 @@ static int ide_scsi_probe(ide_drive_t *drive)
842 806
843 put_disk(g); 807 put_disk(g);
844out_host_put: 808out_host_put:
845 drive->scsi = 0; 809 drive->dev_flags &= ~IDE_DFLAG_SCSI;
846 scsi_host_put(host); 810 scsi_host_put(host);
847 return err; 811 return err;
848} 812}