diff options
| -rw-r--r-- | drivers/scsi/aha1542.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index ec432763a29a..b95d2779f467 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
| @@ -375,9 +375,10 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) | |||
| 375 | u8 lun = cmd->device->lun; | 375 | u8 lun = cmd->device->lun; |
| 376 | unsigned long flags; | 376 | unsigned long flags; |
| 377 | int bufflen = scsi_bufflen(cmd); | 377 | int bufflen = scsi_bufflen(cmd); |
| 378 | int mbo; | 378 | int mbo, sg_count; |
| 379 | struct mailbox *mb = aha1542->mb; | 379 | struct mailbox *mb = aha1542->mb; |
| 380 | struct ccb *ccb = aha1542->ccb; | 380 | struct ccb *ccb = aha1542->ccb; |
| 381 | struct chain *cptr; | ||
| 381 | 382 | ||
| 382 | if (*cmd->cmnd == REQUEST_SENSE) { | 383 | if (*cmd->cmnd == REQUEST_SENSE) { |
| 383 | /* Don't do the command - we have the sense data already */ | 384 | /* Don't do the command - we have the sense data already */ |
| @@ -397,6 +398,13 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) | |||
| 397 | print_hex_dump_bytes("command: ", DUMP_PREFIX_NONE, cmd->cmnd, cmd->cmd_len); | 398 | print_hex_dump_bytes("command: ", DUMP_PREFIX_NONE, cmd->cmnd, cmd->cmd_len); |
| 398 | } | 399 | } |
| 399 | #endif | 400 | #endif |
| 401 | if (bufflen) { /* allocate memory before taking host_lock */ | ||
| 402 | sg_count = scsi_sg_count(cmd); | ||
| 403 | cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA); | ||
| 404 | if (!cptr) | ||
| 405 | return SCSI_MLQUEUE_HOST_BUSY; | ||
| 406 | } | ||
| 407 | |||
| 400 | /* Use the outgoing mailboxes in a round-robin fashion, because this | 408 | /* Use the outgoing mailboxes in a round-robin fashion, because this |
| 401 | is how the host adapter will scan for them */ | 409 | is how the host adapter will scan for them */ |
| 402 | 410 | ||
| @@ -441,19 +449,10 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) | |||
| 441 | 449 | ||
| 442 | if (bufflen) { | 450 | if (bufflen) { |
| 443 | struct scatterlist *sg; | 451 | struct scatterlist *sg; |
| 444 | struct chain *cptr; | 452 | int i; |
| 445 | int i, sg_count = scsi_sg_count(cmd); | ||
| 446 | 453 | ||
| 447 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ | 454 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ |
| 448 | cmd->host_scribble = kmalloc(sizeof(*cptr)*sg_count, | 455 | cmd->host_scribble = (void *)cptr; |
| 449 | GFP_KERNEL | GFP_DMA); | ||
| 450 | cptr = (struct chain *) cmd->host_scribble; | ||
| 451 | if (cptr == NULL) { | ||
| 452 | /* free the claimed mailbox slot */ | ||
| 453 | aha1542->int_cmds[mbo] = NULL; | ||
| 454 | spin_unlock_irqrestore(sh->host_lock, flags); | ||
| 455 | return SCSI_MLQUEUE_HOST_BUSY; | ||
| 456 | } | ||
| 457 | scsi_for_each_sg(cmd, sg, sg_count, i) { | 456 | scsi_for_each_sg(cmd, sg, sg_count, i) { |
| 458 | any2scsi(cptr[i].dataptr, isa_page_to_bus(sg_page(sg)) | 457 | any2scsi(cptr[i].dataptr, isa_page_to_bus(sg_page(sg)) |
| 459 | + sg->offset); | 458 | + sg->offset); |
