aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 17:55:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 17:55:09 -0400
commitb5684b83b1e1579bbbc80e703e990c0cccf5892c (patch)
tree3f1b62b2320bce4d658d2ad0d4b77856499ac533 /drivers/scsi
parent1481b9109fe771ec8b035d7760f42e36d2bed5d4 (diff)
parent1b8ebad87b459e2e1333fbf28005977245ff5402 (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: (76 commits) ide: use proper printk() KERN_* levels in ide-probe.c ide: fix for EATA SCSI HBA in ATA emulating mode ide: remove stale comments from drivers/ide/Makefile ide: enable local IRQs in all handlers for TASKFILE_NO_DATA data phase ide-scsi: remove kmalloced struct request ht6560b: remove old history ht6560b: update email address ide-cd: fix oops when using growisofs gayle: release resources on ide_host_add() failure palm_bk3710: add UltraDMA/100 support ide: trivial sparse annotations ide: ide-tape.c sparse annotations and unaligned access removal ide: drop 'name' parameter from ->init_chipset method ide: prefix messages from IDE PCI host drivers by driver name it821x: remove DECLARE_ITE_DEV() macro it8213: remove DECLARE_ITE_DEV() macro ide: include PCI device name in messages from IDE PCI host drivers ide: remove <asm/ide.h> for some archs ide-generic: remove ide_default_{io_base,irq}() inlines (take 3) ide-generic: is no longer needed on ppc32 ...
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ide-scsi.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 538552495d48..b40a673985aa 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -101,8 +101,13 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
101 101
102 mutex_lock(&idescsi_ref_mutex); 102 mutex_lock(&idescsi_ref_mutex);
103 scsi = ide_scsi_g(disk); 103 scsi = ide_scsi_g(disk);
104 if (scsi) 104 if (scsi) {
105 scsi_host_get(scsi->host); 105 scsi_host_get(scsi->host);
106 if (ide_device_get(scsi->drive)) {
107 scsi_host_put(scsi->host);
108 scsi = NULL;
109 }
110 }
106 mutex_unlock(&idescsi_ref_mutex); 111 mutex_unlock(&idescsi_ref_mutex);
107 return scsi; 112 return scsi;
108} 113}
@@ -110,6 +115,7 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
110static void ide_scsi_put(struct ide_scsi_obj *scsi) 115static void ide_scsi_put(struct ide_scsi_obj *scsi)
111{ 116{
112 mutex_lock(&idescsi_ref_mutex); 117 mutex_lock(&idescsi_ref_mutex);
118 ide_device_put(scsi->drive);
113 scsi_host_put(scsi->host); 119 scsi_host_put(scsi->host);
114 mutex_unlock(&idescsi_ref_mutex); 120 mutex_unlock(&idescsi_ref_mutex);
115} 121}
@@ -201,15 +207,15 @@ static int idescsi_check_condition(ide_drive_t *drive,
201 207
202 /* stuff a sense request in front of our current request */ 208 /* stuff a sense request in front of our current request */
203 pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 209 pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC);
204 rq = kmalloc(sizeof(struct request), GFP_ATOMIC); 210 rq = blk_get_request(drive->queue, READ, GFP_ATOMIC);
205 buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); 211 buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
206 if (!pc || !rq || !buf) { 212 if (!pc || !rq || !buf) {
207 kfree(buf); 213 kfree(buf);
208 kfree(rq); 214 if (rq)
215 blk_put_request(rq);
209 kfree(pc); 216 kfree(pc);
210 return -ENOMEM; 217 return -ENOMEM;
211 } 218 }
212 blk_rq_init(NULL, rq);
213 rq->special = (char *) pc; 219 rq->special = (char *) pc;
214 pc->rq = rq; 220 pc->rq = rq;
215 pc->buf = buf; 221 pc->buf = buf;
@@ -226,6 +232,7 @@ static int idescsi_check_condition(ide_drive_t *drive,
226 ide_scsi_hex_dump(pc->c, 6); 232 ide_scsi_hex_dump(pc->c, 6);
227 } 233 }
228 rq->rq_disk = scsi->disk; 234 rq->rq_disk = scsi->disk;
235 rq->ref_count++;
229 memcpy(rq->cmd, pc->c, 12); 236 memcpy(rq->cmd, pc->c, 12);
230 ide_do_drive_cmd(drive, rq); 237 ide_do_drive_cmd(drive, rq);
231 return 0; 238 return 0;
@@ -272,7 +279,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
272 SCSI_SENSE_BUFFERSIZE); 279 SCSI_SENSE_BUFFERSIZE);
273 kfree(pc->buf); 280 kfree(pc->buf);
274 kfree(pc); 281 kfree(pc);
275 kfree(rq); 282 blk_put_request(rq);
276 pc = opc; 283 pc = opc;
277 rq = pc->rq; 284 rq = pc->rq;
278 pc->scsi_cmd->result = (CHECK_CONDITION << 1) | 285 pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
@@ -303,7 +310,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
303 pc->done(pc->scsi_cmd); 310 pc->done(pc->scsi_cmd);
304 spin_unlock_irqrestore(host->host_lock, flags); 311 spin_unlock_irqrestore(host->host_lock, flags);
305 kfree(pc); 312 kfree(pc);
306 kfree(rq); 313 blk_put_request(rq);
307 scsi->pc = NULL; 314 scsi->pc = NULL;
308 return 0; 315 return 0;
309} 316}
@@ -577,6 +584,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
577 ide_drive_t *drive = scsi->drive; 584 ide_drive_t *drive = scsi->drive;
578 struct request *rq = NULL; 585 struct request *rq = NULL;
579 struct ide_atapi_pc *pc = NULL; 586 struct ide_atapi_pc *pc = NULL;
587 int write = cmd->sc_data_direction == DMA_TO_DEVICE;
580 588
581 if (!drive) { 589 if (!drive) {
582 scmd_printk (KERN_ERR, cmd, "drive not present\n"); 590 scmd_printk (KERN_ERR, cmd, "drive not present\n");
@@ -584,7 +592,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
584 } 592 }
585 scsi = drive_to_idescsi(drive); 593 scsi = drive_to_idescsi(drive);
586 pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 594 pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC);
587 rq = kmalloc(sizeof(struct request), GFP_ATOMIC); 595 rq = blk_get_request(drive->queue, write, GFP_ATOMIC);
588 if (rq == NULL || pc == NULL) { 596 if (rq == NULL || pc == NULL) {
589 printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); 597 printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name);
590 goto abort; 598 goto abort;
@@ -614,17 +622,18 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
614 } 622 }
615 } 623 }
616 624
617 blk_rq_init(NULL, rq);
618 rq->special = (char *) pc; 625 rq->special = (char *) pc;
619 rq->cmd_type = REQ_TYPE_SPECIAL; 626 rq->cmd_type = REQ_TYPE_SPECIAL;
620 spin_unlock_irq(host->host_lock); 627 spin_unlock_irq(host->host_lock);
628 rq->ref_count++;
621 memcpy(rq->cmd, pc->c, 12); 629 memcpy(rq->cmd, pc->c, 12);
622 blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); 630 blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL);
623 spin_lock_irq(host->host_lock); 631 spin_lock_irq(host->host_lock);
624 return 0; 632 return 0;
625abort: 633abort:
626 kfree (pc); 634 kfree (pc);
627 kfree (rq); 635 if (rq)
636 blk_put_request(rq);
628 cmd->result = DID_ERROR << 16; 637 cmd->result = DID_ERROR << 16;
629 done(cmd); 638 done(cmd);
630 return 0; 639 return 0;
@@ -672,7 +681,9 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd)
672 681
673 if (blk_sense_request(scsi->pc->rq)) 682 if (blk_sense_request(scsi->pc->rq))
674 kfree(scsi->pc->buf); 683 kfree(scsi->pc->buf);
675 kfree(scsi->pc->rq); 684 /* we need to call blk_put_request twice. */
685 blk_put_request(scsi->pc->rq);
686 blk_put_request(scsi->pc->rq);
676 kfree(scsi->pc); 687 kfree(scsi->pc);
677 scsi->pc = NULL; 688 scsi->pc = NULL;
678 689
@@ -724,7 +735,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
724 kfree(scsi->pc->buf); 735 kfree(scsi->pc->buf);
725 kfree(scsi->pc); 736 kfree(scsi->pc);
726 scsi->pc = NULL; 737 scsi->pc = NULL;
727 kfree(req); 738 blk_put_request(req);
728 739
729 /* now nuke the drive queue */ 740 /* now nuke the drive queue */
730 while ((req = elv_next_request(drive->queue))) { 741 while ((req = elv_next_request(drive->queue))) {