diff options
Diffstat (limited to 'drivers/scsi/aha1542.c')
-rw-r--r-- | drivers/scsi/aha1542.c | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index bbcc2c52d79f..190568ebea3c 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -51,15 +51,6 @@ | |||
51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) | 51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) |
52 | #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) | 52 | #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) |
53 | 53 | ||
54 | static void BAD_DMA(void *address, unsigned int length) | ||
55 | { | ||
56 | printk(KERN_CRIT "buf vaddress %p paddress 0x%lx length %d\n", | ||
57 | address, | ||
58 | SCSI_BUF_PA(address), | ||
59 | length); | ||
60 | panic("Buffer at physical address > 16Mb used for aha1542"); | ||
61 | } | ||
62 | |||
63 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, | 54 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, |
64 | struct scatterlist *sgp, | 55 | struct scatterlist *sgp, |
65 | int nseg, | 56 | int nseg, |
@@ -545,7 +536,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id) | |||
545 | we will still have it in the cdb when we come back */ | 536 | we will still have it in the cdb when we come back */ |
546 | if (ccb[mbo].tarstat == 2) | 537 | if (ccb[mbo].tarstat == 2) |
547 | memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen], | 538 | memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen], |
548 | sizeof(SCtmp->sense_buffer)); | 539 | SCSI_SENSE_BUFFERSIZE); |
549 | 540 | ||
550 | 541 | ||
551 | /* is there mail :-) */ | 542 | /* is there mail :-) */ |
@@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
597 | unchar target = SCpnt->device->id; | 588 | unchar target = SCpnt->device->id; |
598 | unchar lun = SCpnt->device->lun; | 589 | unchar lun = SCpnt->device->lun; |
599 | unsigned long flags; | 590 | unsigned long flags; |
600 | void *buff = SCpnt->request_buffer; | 591 | int bufflen = scsi_bufflen(SCpnt); |
601 | int bufflen = SCpnt->request_bufflen; | ||
602 | int mbo; | 592 | int mbo; |
603 | struct mailbox *mb; | 593 | struct mailbox *mb; |
604 | struct ccb *ccb; | 594 | struct ccb *ccb; |
@@ -619,7 +609,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
619 | #if 0 | 609 | #if 0 |
620 | /* scsi_request_sense() provides a buffer of size 256, | 610 | /* scsi_request_sense() provides a buffer of size 256, |
621 | so there is no reason to expect equality */ | 611 | so there is no reason to expect equality */ |
622 | if (bufflen != sizeof(SCpnt->sense_buffer)) | 612 | if (bufflen != SCSI_SENSE_BUFFERSIZE) |
623 | printk(KERN_CRIT "aha1542: Wrong buffer length supplied " | 613 | printk(KERN_CRIT "aha1542: Wrong buffer length supplied " |
624 | "for request sense (%d)\n", bufflen); | 614 | "for request sense (%d)\n", bufflen); |
625 | #endif | 615 | #endif |
@@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
689 | 679 | ||
690 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); | 680 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); |
691 | 681 | ||
692 | if (SCpnt->use_sg) { | 682 | if (bufflen) { |
693 | struct scatterlist *sg; | 683 | struct scatterlist *sg; |
694 | struct chain *cptr; | 684 | struct chain *cptr; |
695 | #ifdef DEBUG | 685 | #ifdef DEBUG |
696 | unsigned char *ptr; | 686 | unsigned char *ptr; |
697 | #endif | 687 | #endif |
698 | int i; | 688 | int i, sg_count = scsi_sg_count(SCpnt); |
699 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ | 689 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ |
700 | SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); | 690 | SCpnt->host_scribble = kmalloc(sizeof(*cptr)*sg_count, |
691 | GFP_KERNEL | GFP_DMA); | ||
701 | cptr = (struct chain *) SCpnt->host_scribble; | 692 | cptr = (struct chain *) SCpnt->host_scribble; |
702 | if (cptr == NULL) { | 693 | if (cptr == NULL) { |
703 | /* free the claimed mailbox slot */ | 694 | /* free the claimed mailbox slot */ |
704 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; | 695 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; |
705 | return SCSI_MLQUEUE_HOST_BUSY; | 696 | return SCSI_MLQUEUE_HOST_BUSY; |
706 | } | 697 | } |
707 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { | 698 | scsi_for_each_sg(SCpnt, sg, sg_count, i) { |
708 | if (sg->length == 0 || SCpnt->use_sg > 16 || | ||
709 | (((int) sg->offset) & 1) || (sg->length & 1)) { | ||
710 | unsigned char *ptr; | ||
711 | printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); | ||
712 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { | ||
713 | printk(KERN_CRIT "%d: %p %d\n", i, | ||
714 | sg_virt(sg), sg->length); | ||
715 | }; | ||
716 | printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); | ||
717 | ptr = (unsigned char *) &cptr[i]; | ||
718 | for (i = 0; i < 18; i++) | ||
719 | printk("%02x ", ptr[i]); | ||
720 | panic("Foooooooood fight!"); | ||
721 | }; | ||
722 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); | 699 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); |
723 | if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD) | 700 | if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD) |
724 | BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i); | 701 | BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, i); |
725 | any2scsi(cptr[i].datalen, sg->length); | 702 | any2scsi(cptr[i].datalen, sg->length); |
726 | }; | 703 | }; |
727 | any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain)); | 704 | any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain)); |
728 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); | 705 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); |
729 | #ifdef DEBUG | 706 | #ifdef DEBUG |
730 | printk("cptr %x: ", cptr); | 707 | printk("cptr %x: ", cptr); |
@@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
735 | } else { | 712 | } else { |
736 | ccb[mbo].op = 0; /* SCSI Initiator Command */ | 713 | ccb[mbo].op = 0; /* SCSI Initiator Command */ |
737 | SCpnt->host_scribble = NULL; | 714 | SCpnt->host_scribble = NULL; |
738 | any2scsi(ccb[mbo].datalen, bufflen); | 715 | any2scsi(ccb[mbo].datalen, 0); |
739 | if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD) | 716 | any2scsi(ccb[mbo].dataptr, 0); |
740 | BAD_DMA(buff, bufflen); | ||
741 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff)); | ||
742 | }; | 717 | }; |
743 | ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */ | 718 | ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */ |
744 | ccb[mbo].rsalen = 16; | 719 | ccb[mbo].rsalen = 16; |