wd33c93.c (87a0b2fafc09766d8c55461a18345a1cfb10a7fe) | wd33c93.c (dbb2da557a6a87c88bbb4b1fef037091b57f701b) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) 1996 John Shifflett, GeoLog Consulting 4 * john@geolog.com 5 * jshiffle@netcom.com 6 */ 7 8/* --- 350 unchanged lines hidden (view full) --- 359 if (offset && fast) 360 period /= 2; 361 msg[0] = period; 362 msg[1] = offset; 363} 364 365static int wd33c93_queuecommand_lck(struct scsi_cmnd *cmd) 366{ | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) 1996 John Shifflett, GeoLog Consulting 4 * john@geolog.com 5 * jshiffle@netcom.com 6 */ 7 8/* --- 350 unchanged lines hidden (view full) --- 359 if (offset && fast) 360 period /= 2; 361 msg[0] = period; 362 msg[1] = offset; 363} 364 365static int wd33c93_queuecommand_lck(struct scsi_cmnd *cmd) 366{ |
367 struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); |
|
367 struct WD33C93_hostdata *hostdata; 368 struct scsi_cmnd *tmp; 369 370 hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata; 371 372 DB(DB_QUEUE_COMMAND, 373 printk("Q-%d-%02x( ", cmd->device->id, cmd->cmnd[0])) 374 --- 15 unchanged lines hidden (view full) --- 390 * - SCp.buffer points to the current scatter-gather buffer 391 * - SCp.buffers_residual tells us how many S.G. buffers there are 392 * - SCp.have_data_in is not used 393 * - SCp.sent_command is not used 394 * - SCp.phase records this command's SRCID_ER bit setting 395 */ 396 397 if (scsi_bufflen(cmd)) { | 368 struct WD33C93_hostdata *hostdata; 369 struct scsi_cmnd *tmp; 370 371 hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata; 372 373 DB(DB_QUEUE_COMMAND, 374 printk("Q-%d-%02x( ", cmd->device->id, cmd->cmnd[0])) 375 --- 15 unchanged lines hidden (view full) --- 391 * - SCp.buffer points to the current scatter-gather buffer 392 * - SCp.buffers_residual tells us how many S.G. buffers there are 393 * - SCp.have_data_in is not used 394 * - SCp.sent_command is not used 395 * - SCp.phase records this command's SRCID_ER bit setting 396 */ 397 398 if (scsi_bufflen(cmd)) { |
398 cmd->SCp.buffer = scsi_sglist(cmd); 399 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; 400 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); 401 cmd->SCp.this_residual = cmd->SCp.buffer->length; | 399 scsi_pointer->buffer = scsi_sglist(cmd); 400 scsi_pointer->buffers_residual = scsi_sg_count(cmd) - 1; 401 scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); 402 scsi_pointer->this_residual = scsi_pointer->buffer->length; |
402 } else { | 403 } else { |
403 cmd->SCp.buffer = NULL; 404 cmd->SCp.buffers_residual = 0; 405 cmd->SCp.ptr = NULL; 406 cmd->SCp.this_residual = 0; | 404 scsi_pointer->buffer = NULL; 405 scsi_pointer->buffers_residual = 0; 406 scsi_pointer->ptr = NULL; 407 scsi_pointer->this_residual = 0; |
407 } 408 409/* WD docs state that at the conclusion of a "LEVEL2" command, the 410 * status byte can be retrieved from the LUN register. Apparently, 411 * this is the case only for *uninterrupted* LEVEL2 commands! If 412 * there are any unexpected phases entered, even if they are 100% 413 * legal (different devices may choose to do things differently), 414 * the LEVEL2 command sequence is exited. This often occurs prior 415 * to receiving the status byte, in which case the driver does a 416 * status phase interrupt and gets the status byte on its own. 417 * While such a command can then be "resumed" (ie restarted to 418 * finish up as a LEVEL2 command), the LUN register will NOT be 419 * a valid status byte at the command's conclusion, and we must 420 * use the byte obtained during the earlier interrupt. Here, we 421 * preset SCp.Status to an illegal value (0xff) so that when 422 * this command finally completes, we can tell where the actual 423 * status byte is stored. 424 */ 425 | 408 } 409 410/* WD docs state that at the conclusion of a "LEVEL2" command, the 411 * status byte can be retrieved from the LUN register. Apparently, 412 * this is the case only for *uninterrupted* LEVEL2 commands! If 413 * there are any unexpected phases entered, even if they are 100% 414 * legal (different devices may choose to do things differently), 415 * the LEVEL2 command sequence is exited. This often occurs prior 416 * to receiving the status byte, in which case the driver does a 417 * status phase interrupt and gets the status byte on its own. 418 * While such a command can then be "resumed" (ie restarted to 419 * finish up as a LEVEL2 command), the LUN register will NOT be 420 * a valid status byte at the command's conclusion, and we must 421 * use the byte obtained during the earlier interrupt. Here, we 422 * preset SCp.Status to an illegal value (0xff) so that when 423 * this command finally completes, we can tell where the actual 424 * status byte is stored. 425 */ 426 |
426 cmd->SCp.Status = ILLEGAL_STATUS_BYTE; | 427 scsi_pointer->Status = ILLEGAL_STATUS_BYTE; |
427 428 /* 429 * Add the cmd to the end of 'input_Q'. Note that REQUEST SENSE 430 * commands are added to the head of the queue so that the desired 431 * sense data is not lost before REQUEST_SENSE executes. 432 */ 433 434 spin_lock_irq(&hostdata->lock); --- 30 unchanged lines hidden (view full) --- 465 * 466 * wd33c93_execute() is always called with interrupts disabled or from 467 * the wd33c93_intr itself, which means that a wd33c93 interrupt 468 * cannot occur while we are in here. 469 */ 470static void 471wd33c93_execute(struct Scsi_Host *instance) 472{ | 428 429 /* 430 * Add the cmd to the end of 'input_Q'. Note that REQUEST SENSE 431 * commands are added to the head of the queue so that the desired 432 * sense data is not lost before REQUEST_SENSE executes. 433 */ 434 435 spin_lock_irq(&hostdata->lock); --- 30 unchanged lines hidden (view full) --- 466 * 467 * wd33c93_execute() is always called with interrupts disabled or from 468 * the wd33c93_intr itself, which means that a wd33c93 interrupt 469 * cannot occur while we are in here. 470 */ 471static void 472wd33c93_execute(struct Scsi_Host *instance) 473{ |
474 struct scsi_pointer *scsi_pointer; |
|
473 struct WD33C93_hostdata *hostdata = 474 (struct WD33C93_hostdata *) instance->hostdata; 475 const wd33c93_regs regs = hostdata->regs; 476 struct scsi_cmnd *cmd, *prev; 477 478 DB(DB_EXECUTE, printk("EX(")) 479 if (hostdata->selecting || hostdata->connected) { 480 DB(DB_EXECUTE, printk(")EX-0 ")) --- 60 unchanged lines hidden (view full) --- 541 * for a different target/lun. In this case, the other commands 542 * should be made disconnect-able, if not already. 543 * 544 * I know, I know - this code would flunk me out of any 545 * "C Programming 101" class ever offered. But it's easy 546 * to change around and experiment with for now. 547 */ 548 | 475 struct WD33C93_hostdata *hostdata = 476 (struct WD33C93_hostdata *) instance->hostdata; 477 const wd33c93_regs regs = hostdata->regs; 478 struct scsi_cmnd *cmd, *prev; 479 480 DB(DB_EXECUTE, printk("EX(")) 481 if (hostdata->selecting || hostdata->connected) { 482 DB(DB_EXECUTE, printk(")EX-0 ")) --- 60 unchanged lines hidden (view full) --- 543 * for a different target/lun. In this case, the other commands 544 * should be made disconnect-able, if not already. 545 * 546 * I know, I know - this code would flunk me out of any 547 * "C Programming 101" class ever offered. But it's easy 548 * to change around and experiment with for now. 549 */ 550 |
549 cmd->SCp.phase = 0; /* assume no disconnect */ | 551 scsi_pointer = WD33C93_scsi_pointer(cmd); 552 scsi_pointer->phase = 0; /* assume no disconnect */ |
550 if (hostdata->disconnect == DIS_NEVER) 551 goto no; 552 if (hostdata->disconnect == DIS_ALWAYS) 553 goto yes; 554 if (cmd->device->type == 1) /* tape drive? */ 555 goto yes; 556 if (hostdata->disconnected_Q) /* other commands disconnected? */ 557 goto yes; 558 if (!(hostdata->input_Q)) /* input_Q empty? */ 559 goto no; 560 for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev; 561 prev = (struct scsi_cmnd *) prev->host_scribble) { 562 if ((prev->device->id != cmd->device->id) || 563 (prev->device->lun != cmd->device->lun)) { 564 for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev; 565 prev = (struct scsi_cmnd *) prev->host_scribble) | 553 if (hostdata->disconnect == DIS_NEVER) 554 goto no; 555 if (hostdata->disconnect == DIS_ALWAYS) 556 goto yes; 557 if (cmd->device->type == 1) /* tape drive? */ 558 goto yes; 559 if (hostdata->disconnected_Q) /* other commands disconnected? */ 560 goto yes; 561 if (!(hostdata->input_Q)) /* input_Q empty? */ 562 goto no; 563 for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev; 564 prev = (struct scsi_cmnd *) prev->host_scribble) { 565 if ((prev->device->id != cmd->device->id) || 566 (prev->device->lun != cmd->device->lun)) { 567 for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev; 568 prev = (struct scsi_cmnd *) prev->host_scribble) |
566 prev->SCp.phase = 1; | 569 WD33C93_scsi_pointer(prev)->phase = 1; |
567 goto yes; 568 } 569 } 570 571 goto no; 572 573 yes: | 570 goto yes; 571 } 572 } 573 574 goto no; 575 576 yes: |
574 cmd->SCp.phase = 1; | 577 scsi_pointer->phase = 1; |
575 576#ifdef PROC_STATISTICS 577 hostdata->disc_allowed_cnt[cmd->device->id]++; 578#endif 579 580 no: 581 | 578 579#ifdef PROC_STATISTICS 580 hostdata->disc_allowed_cnt[cmd->device->id]++; 581#endif 582 583 no: 584 |
582 write_wd33c93(regs, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0)); | 585 write_wd33c93(regs, WD_SOURCE_ID, scsi_pointer->phase ? SRCID_ER : 0); |
583 584 write_wd33c93(regs, WD_TARGET_LUN, (u8)cmd->device->lun); 585 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER, 586 hostdata->sync_xfer[cmd->device->id]); 587 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF)); 588 589 if ((hostdata->level2 == L2_NONE) || 590 (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) { --- 52 unchanged lines hidden (view full) --- 643 644 write_wd33c93(regs, WD_OWN_ID, cmd->cmd_len); 645 646 /* When doing a non-disconnect command with DMA, we can save 647 * ourselves a DATA phase interrupt later by setting everything 648 * up ahead of time. 649 */ 650 | 586 587 write_wd33c93(regs, WD_TARGET_LUN, (u8)cmd->device->lun); 588 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER, 589 hostdata->sync_xfer[cmd->device->id]); 590 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF)); 591 592 if ((hostdata->level2 == L2_NONE) || 593 (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) { --- 52 unchanged lines hidden (view full) --- 646 647 write_wd33c93(regs, WD_OWN_ID, cmd->cmd_len); 648 649 /* When doing a non-disconnect command with DMA, we can save 650 * ourselves a DATA phase interrupt later by setting everything 651 * up ahead of time. 652 */ 653 |
651 if ((cmd->SCp.phase == 0) && (hostdata->no_dma == 0)) { | 654 if (scsi_pointer->phase == 0 && hostdata->no_dma == 0) { |
652 if (hostdata->dma_setup(cmd, 653 (cmd->sc_data_direction == DMA_TO_DEVICE) ? 654 DATA_OUT_DIR : DATA_IN_DIR)) 655 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */ 656 else { 657 write_wd33c93_count(regs, | 655 if (hostdata->dma_setup(cmd, 656 (cmd->sc_data_direction == DMA_TO_DEVICE) ? 657 DATA_OUT_DIR : DATA_IN_DIR)) 658 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */ 659 else { 660 write_wd33c93_count(regs, |
658 cmd->SCp.this_residual); | 661 scsi_pointer->this_residual); |
659 write_wd33c93(regs, WD_CONTROL, 660 CTRL_IDI | CTRL_EDI | hostdata->dma_mode); 661 hostdata->dma = D_DMA_RUNNING; 662 } 663 } else 664 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */ 665 666 hostdata->state = S_RUNNING_LEVEL2; 667 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); 668 } 669 670 /* 671 * Since the SCSI bus can handle only 1 connection at a time, 672 * we get out of here now. If the selection fails, or when 673 * the command disconnects, we'll come back to this routine 674 * to search the input_Q again... 675 */ 676 677 DB(DB_EXECUTE, | 662 write_wd33c93(regs, WD_CONTROL, 663 CTRL_IDI | CTRL_EDI | hostdata->dma_mode); 664 hostdata->dma = D_DMA_RUNNING; 665 } 666 } else 667 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */ 668 669 hostdata->state = S_RUNNING_LEVEL2; 670 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); 671 } 672 673 /* 674 * Since the SCSI bus can handle only 1 connection at a time, 675 * we get out of here now. If the selection fails, or when 676 * the command disconnects, we'll come back to this routine 677 * to search the input_Q again... 678 */ 679 680 DB(DB_EXECUTE, |
678 printk("%s)EX-2 ", (cmd->SCp.phase) ? "d:" : "")) | 681 printk("%s)EX-2 ", scsi_pointer->phase ? "d:" : "")) |
679} 680 681static void 682transfer_pio(const wd33c93_regs regs, uchar * buf, int cnt, 683 int data_in_dir, struct WD33C93_hostdata *hostdata) 684{ 685 uchar asr; 686 --- 25 unchanged lines hidden (view full) --- 712 */ 713 714} 715 716static void 717transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, 718 int data_in_dir) 719{ | 682} 683 684static void 685transfer_pio(const wd33c93_regs regs, uchar * buf, int cnt, 686 int data_in_dir, struct WD33C93_hostdata *hostdata) 687{ 688 uchar asr; 689 --- 25 unchanged lines hidden (view full) --- 715 */ 716 717} 718 719static void 720transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, 721 int data_in_dir) 722{ |
723 struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); |
|
720 struct WD33C93_hostdata *hostdata; 721 unsigned long length; 722 723 hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata; 724 725/* Normally, you'd expect 'this_residual' to be non-zero here. 726 * In a series of scatter-gather transfers, however, this 727 * routine will usually be called with 'this_residual' equal 728 * to 0 and 'buffers_residual' non-zero. This means that a 729 * previous transfer completed, clearing 'this_residual', and 730 * now we need to setup the next scatter-gather buffer as the 731 * source or destination for THIS transfer. 732 */ | 724 struct WD33C93_hostdata *hostdata; 725 unsigned long length; 726 727 hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata; 728 729/* Normally, you'd expect 'this_residual' to be non-zero here. 730 * In a series of scatter-gather transfers, however, this 731 * routine will usually be called with 'this_residual' equal 732 * to 0 and 'buffers_residual' non-zero. This means that a 733 * previous transfer completed, clearing 'this_residual', and 734 * now we need to setup the next scatter-gather buffer as the 735 * source or destination for THIS transfer. 736 */ |
733 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { 734 cmd->SCp.buffer = sg_next(cmd->SCp.buffer); 735 --cmd->SCp.buffers_residual; 736 cmd->SCp.this_residual = cmd->SCp.buffer->length; 737 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); | 737 if (!scsi_pointer->this_residual && scsi_pointer->buffers_residual) { 738 scsi_pointer->buffer = sg_next(scsi_pointer->buffer); 739 --scsi_pointer->buffers_residual; 740 scsi_pointer->this_residual = scsi_pointer->buffer->length; 741 scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); |
738 } | 742 } |
739 if (!cmd->SCp.this_residual) /* avoid bogus setups */ | 743 if (!scsi_pointer->this_residual) /* avoid bogus setups */ |
740 return; 741 742 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER, 743 hostdata->sync_xfer[cmd->device->id]); 744 745/* 'hostdata->no_dma' is TRUE if we don't even want to try DMA. 746 * Update 'this_residual' and 'ptr' after 'transfer_pio()' returns. 747 */ 748 749 if (hostdata->no_dma || hostdata->dma_setup(cmd, data_in_dir)) { 750#ifdef PROC_STATISTICS 751 hostdata->pio_cnt++; 752#endif | 744 return; 745 746 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER, 747 hostdata->sync_xfer[cmd->device->id]); 748 749/* 'hostdata->no_dma' is TRUE if we don't even want to try DMA. 750 * Update 'this_residual' and 'ptr' after 'transfer_pio()' returns. 751 */ 752 753 if (hostdata->no_dma || hostdata->dma_setup(cmd, data_in_dir)) { 754#ifdef PROC_STATISTICS 755 hostdata->pio_cnt++; 756#endif |
753 transfer_pio(regs, (uchar *) cmd->SCp.ptr, 754 cmd->SCp.this_residual, data_in_dir, hostdata); 755 length = cmd->SCp.this_residual; 756 cmd->SCp.this_residual = read_wd33c93_count(regs); 757 cmd->SCp.ptr += (length - cmd->SCp.this_residual); | 757 transfer_pio(regs, (uchar *) scsi_pointer->ptr, 758 scsi_pointer->this_residual, data_in_dir, 759 hostdata); 760 length = scsi_pointer->this_residual; 761 scsi_pointer->this_residual = read_wd33c93_count(regs); 762 scsi_pointer->ptr += length - scsi_pointer->this_residual; |
758 } 759 760/* We are able to do DMA (in fact, the Amiga hardware is 761 * already going!), so start up the wd33c93 in DMA mode. 762 * We set 'hostdata->dma' = D_DMA_RUNNING so that when the 763 * transfer completes and causes an interrupt, we're 764 * reminded to tell the Amiga to shut down its end. We'll 765 * postpone the updating of 'this_residual' and 'ptr' 766 * until then. 767 */ 768 769 else { 770#ifdef PROC_STATISTICS 771 hostdata->dma_cnt++; 772#endif 773 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | hostdata->dma_mode); | 763 } 764 765/* We are able to do DMA (in fact, the Amiga hardware is 766 * already going!), so start up the wd33c93 in DMA mode. 767 * We set 'hostdata->dma' = D_DMA_RUNNING so that when the 768 * transfer completes and causes an interrupt, we're 769 * reminded to tell the Amiga to shut down its end. We'll 770 * postpone the updating of 'this_residual' and 'ptr' 771 * until then. 772 */ 773 774 else { 775#ifdef PROC_STATISTICS 776 hostdata->dma_cnt++; 777#endif 778 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | hostdata->dma_mode); |
774 write_wd33c93_count(regs, cmd->SCp.this_residual); | 779 write_wd33c93_count(regs, scsi_pointer->this_residual); |
775 776 if ((hostdata->level2 >= L2_DATA) || | 780 781 if ((hostdata->level2 >= L2_DATA) || |
777 (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) { | 782 (hostdata->level2 == L2_BASIC && scsi_pointer->phase == 0)) { |
778 write_wd33c93(regs, WD_COMMAND_PHASE, 0x45); 779 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); 780 hostdata->state = S_RUNNING_LEVEL2; 781 } else 782 write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO); 783 784 hostdata->dma = D_DMA_RUNNING; 785 } 786} 787 788void 789wd33c93_intr(struct Scsi_Host *instance) 790{ | 783 write_wd33c93(regs, WD_COMMAND_PHASE, 0x45); 784 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); 785 hostdata->state = S_RUNNING_LEVEL2; 786 } else 787 write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO); 788 789 hostdata->dma = D_DMA_RUNNING; 790 } 791} 792 793void 794wd33c93_intr(struct Scsi_Host *instance) 795{ |
796 struct scsi_pointer *scsi_pointer; |
|
791 struct WD33C93_hostdata *hostdata = 792 (struct WD33C93_hostdata *) instance->hostdata; 793 const wd33c93_regs regs = hostdata->regs; 794 struct scsi_cmnd *patch, *cmd; 795 uchar asr, sr, phs, id, lun, *ucp, msg; 796 unsigned long length, flags; 797 798 asr = read_aux_stat(regs); 799 if (!(asr & ASR_INT) || (asr & ASR_BSY)) 800 return; 801 802 spin_lock_irqsave(&hostdata->lock, flags); 803 804#ifdef PROC_STATISTICS 805 hostdata->int_cnt++; 806#endif 807 808 cmd = (struct scsi_cmnd *) hostdata->connected; /* assume we're connected */ | 797 struct WD33C93_hostdata *hostdata = 798 (struct WD33C93_hostdata *) instance->hostdata; 799 const wd33c93_regs regs = hostdata->regs; 800 struct scsi_cmnd *patch, *cmd; 801 uchar asr, sr, phs, id, lun, *ucp, msg; 802 unsigned long length, flags; 803 804 asr = read_aux_stat(regs); 805 if (!(asr & ASR_INT) || (asr & ASR_BSY)) 806 return; 807 808 spin_lock_irqsave(&hostdata->lock, flags); 809 810#ifdef PROC_STATISTICS 811 hostdata->int_cnt++; 812#endif 813 814 cmd = (struct scsi_cmnd *) hostdata->connected; /* assume we're connected */ |
815 scsi_pointer = WD33C93_scsi_pointer(cmd); |
|
809 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear the interrupt */ 810 phs = read_wd33c93(regs, WD_COMMAND_PHASE); 811 812 DB(DB_INTR, printk("{%02x:%02x-", asr, sr)) 813 814/* After starting a DMA transfer, the next interrupt 815 * is guaranteed to be in response to completion of 816 * the transfer. Since the Amiga DMA hardware runs in --- 5 unchanged lines hidden (view full) --- 822 * disconnect (a device may do this if it has to do a 823 * seek, or just to be nice and let other devices have 824 * some bus time during long transfers). After doing 825 * whatever is needed, we go on and service the WD3393 826 * interrupt normally. 827 */ 828 if (hostdata->dma == D_DMA_RUNNING) { 829 DB(DB_TRANSFER, | 816 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear the interrupt */ 817 phs = read_wd33c93(regs, WD_COMMAND_PHASE); 818 819 DB(DB_INTR, printk("{%02x:%02x-", asr, sr)) 820 821/* After starting a DMA transfer, the next interrupt 822 * is guaranteed to be in response to completion of 823 * the transfer. Since the Amiga DMA hardware runs in --- 5 unchanged lines hidden (view full) --- 829 * disconnect (a device may do this if it has to do a 830 * seek, or just to be nice and let other devices have 831 * some bus time during long transfers). After doing 832 * whatever is needed, we go on and service the WD3393 833 * interrupt normally. 834 */ 835 if (hostdata->dma == D_DMA_RUNNING) { 836 DB(DB_TRANSFER, |
830 printk("[%p/%d:", cmd->SCp.ptr, cmd->SCp.this_residual)) | 837 printk("[%p/%d:", scsi_pointer->ptr, scsi_pointer->this_residual)) |
831 hostdata->dma_stop(cmd->device->host, cmd, 1); 832 hostdata->dma = D_DMA_OFF; | 838 hostdata->dma_stop(cmd->device->host, cmd, 1); 839 hostdata->dma = D_DMA_OFF; |
833 length = cmd->SCp.this_residual; 834 cmd->SCp.this_residual = read_wd33c93_count(regs); 835 cmd->SCp.ptr += (length - cmd->SCp.this_residual); | 840 length = scsi_pointer->this_residual; 841 scsi_pointer->this_residual = read_wd33c93_count(regs); 842 scsi_pointer->ptr += length - scsi_pointer->this_residual; |
836 DB(DB_TRANSFER, | 843 DB(DB_TRANSFER, |
837 printk("%p/%d]", cmd->SCp.ptr, cmd->SCp.this_residual)) | 844 printk("%p/%d]", scsi_pointer->ptr, scsi_pointer->this_residual)) |
838 } 839 840/* Respond to the specific WD3393 interrupt - there are quite a few! */ 841 switch (sr) { 842 case CSR_TIMEOUT: 843 DB(DB_INTR, printk("TIMEOUT")) 844 845 if (hostdata->state == S_RUNNING_LEVEL2) --- 33 unchanged lines hidden (view full) --- 879 DB(DB_INTR, printk("SELECT")) 880 hostdata->connected = cmd = 881 (struct scsi_cmnd *) hostdata->selecting; 882 hostdata->selecting = NULL; 883 884 /* construct an IDENTIFY message with correct disconnect bit */ 885 886 hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun); | 845 } 846 847/* Respond to the specific WD3393 interrupt - there are quite a few! */ 848 switch (sr) { 849 case CSR_TIMEOUT: 850 DB(DB_INTR, printk("TIMEOUT")) 851 852 if (hostdata->state == S_RUNNING_LEVEL2) --- 33 unchanged lines hidden (view full) --- 886 DB(DB_INTR, printk("SELECT")) 887 hostdata->connected = cmd = 888 (struct scsi_cmnd *) hostdata->selecting; 889 hostdata->selecting = NULL; 890 891 /* construct an IDENTIFY message with correct disconnect bit */ 892 893 hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun); |
887 if (cmd->SCp.phase) | 894 if (scsi_pointer->phase) |
888 hostdata->outgoing_msg[0] |= 0x40; 889 890 if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) { 891 892 hostdata->sync_stat[cmd->device->id] = SS_WAITING; 893 894/* Tack on a 2nd message to ask about synchronous transfers. If we've 895 * been asked to do only asynchronous transfers on this device, we --- 25 unchanged lines hidden (view full) --- 921 hostdata->state = S_CONNECTED; 922 spin_unlock_irqrestore(&hostdata->lock, flags); 923 break; 924 925 case CSR_XFER_DONE | PHS_DATA_IN: 926 case CSR_UNEXP | PHS_DATA_IN: 927 case CSR_SRV_REQ | PHS_DATA_IN: 928 DB(DB_INTR, | 895 hostdata->outgoing_msg[0] |= 0x40; 896 897 if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) { 898 899 hostdata->sync_stat[cmd->device->id] = SS_WAITING; 900 901/* Tack on a 2nd message to ask about synchronous transfers. If we've 902 * been asked to do only asynchronous transfers on this device, we --- 25 unchanged lines hidden (view full) --- 928 hostdata->state = S_CONNECTED; 929 spin_unlock_irqrestore(&hostdata->lock, flags); 930 break; 931 932 case CSR_XFER_DONE | PHS_DATA_IN: 933 case CSR_UNEXP | PHS_DATA_IN: 934 case CSR_SRV_REQ | PHS_DATA_IN: 935 DB(DB_INTR, |
929 printk("IN-%d.%d", cmd->SCp.this_residual, 930 cmd->SCp.buffers_residual)) | 936 printk("IN-%d.%d", scsi_pointer->this_residual, 937 scsi_pointer->buffers_residual)) |
931 transfer_bytes(regs, cmd, DATA_IN_DIR); 932 if (hostdata->state != S_RUNNING_LEVEL2) 933 hostdata->state = S_CONNECTED; 934 spin_unlock_irqrestore(&hostdata->lock, flags); 935 break; 936 937 case CSR_XFER_DONE | PHS_DATA_OUT: 938 case CSR_UNEXP | PHS_DATA_OUT: 939 case CSR_SRV_REQ | PHS_DATA_OUT: 940 DB(DB_INTR, | 938 transfer_bytes(regs, cmd, DATA_IN_DIR); 939 if (hostdata->state != S_RUNNING_LEVEL2) 940 hostdata->state = S_CONNECTED; 941 spin_unlock_irqrestore(&hostdata->lock, flags); 942 break; 943 944 case CSR_XFER_DONE | PHS_DATA_OUT: 945 case CSR_UNEXP | PHS_DATA_OUT: 946 case CSR_SRV_REQ | PHS_DATA_OUT: 947 DB(DB_INTR, |
941 printk("OUT-%d.%d", cmd->SCp.this_residual, 942 cmd->SCp.buffers_residual)) | 948 printk("OUT-%d.%d", scsi_pointer->this_residual, 949 scsi_pointer->buffers_residual)) |
943 transfer_bytes(regs, cmd, DATA_OUT_DIR); 944 if (hostdata->state != S_RUNNING_LEVEL2) 945 hostdata->state = S_CONNECTED; 946 spin_unlock_irqrestore(&hostdata->lock, flags); 947 break; 948 949/* Note: this interrupt should not occur in a LEVEL2 command */ 950 --- 6 unchanged lines hidden (view full) --- 957 hostdata->state = S_CONNECTED; 958 spin_unlock_irqrestore(&hostdata->lock, flags); 959 break; 960 961 case CSR_XFER_DONE | PHS_STATUS: 962 case CSR_UNEXP | PHS_STATUS: 963 case CSR_SRV_REQ | PHS_STATUS: 964 DB(DB_INTR, printk("STATUS=")) | 950 transfer_bytes(regs, cmd, DATA_OUT_DIR); 951 if (hostdata->state != S_RUNNING_LEVEL2) 952 hostdata->state = S_CONNECTED; 953 spin_unlock_irqrestore(&hostdata->lock, flags); 954 break; 955 956/* Note: this interrupt should not occur in a LEVEL2 command */ 957 --- 6 unchanged lines hidden (view full) --- 964 hostdata->state = S_CONNECTED; 965 spin_unlock_irqrestore(&hostdata->lock, flags); 966 break; 967 968 case CSR_XFER_DONE | PHS_STATUS: 969 case CSR_UNEXP | PHS_STATUS: 970 case CSR_SRV_REQ | PHS_STATUS: 971 DB(DB_INTR, printk("STATUS=")) |
965 cmd->SCp.Status = read_1_byte(regs); 966 DB(DB_INTR, printk("%02x", cmd->SCp.Status)) | 972 scsi_pointer->Status = read_1_byte(regs); 973 DB(DB_INTR, printk("%02x", scsi_pointer->Status)) |
967 if (hostdata->level2 >= L2_BASIC) { 968 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */ 969 udelay(7); 970 hostdata->state = S_RUNNING_LEVEL2; 971 write_wd33c93(regs, WD_COMMAND_PHASE, 0x50); 972 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); 973 } else { 974 hostdata->state = S_CONNECTED; --- 11 unchanged lines hidden (view full) --- 986 udelay(7); 987 988 hostdata->incoming_msg[hostdata->incoming_ptr] = msg; 989 if (hostdata->incoming_msg[0] == EXTENDED_MESSAGE) 990 msg = EXTENDED_MESSAGE; 991 else 992 hostdata->incoming_ptr = 0; 993 | 974 if (hostdata->level2 >= L2_BASIC) { 975 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */ 976 udelay(7); 977 hostdata->state = S_RUNNING_LEVEL2; 978 write_wd33c93(regs, WD_COMMAND_PHASE, 0x50); 979 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); 980 } else { 981 hostdata->state = S_CONNECTED; --- 11 unchanged lines hidden (view full) --- 993 udelay(7); 994 995 hostdata->incoming_msg[hostdata->incoming_ptr] = msg; 996 if (hostdata->incoming_msg[0] == EXTENDED_MESSAGE) 997 msg = EXTENDED_MESSAGE; 998 else 999 hostdata->incoming_ptr = 0; 1000 |
994 cmd->SCp.Message = msg; | 1001 scsi_pointer->Message = msg; |
995 switch (msg) { 996 997 case COMMAND_COMPLETE: 998 DB(DB_INTR, printk("CCMP")) 999 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK); 1000 hostdata->state = S_PRE_CMP_DISC; 1001 break; 1002 --- 155 unchanged lines hidden (view full) --- 1158 1159/* Make sure that reselection is enabled at this point - it may 1160 * have been turned off for the command that just completed. 1161 */ 1162 1163 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER); 1164 if (phs == 0x60) { 1165 DB(DB_INTR, printk("SX-DONE")) | 1002 switch (msg) { 1003 1004 case COMMAND_COMPLETE: 1005 DB(DB_INTR, printk("CCMP")) 1006 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK); 1007 hostdata->state = S_PRE_CMP_DISC; 1008 break; 1009 --- 155 unchanged lines hidden (view full) --- 1165 1166/* Make sure that reselection is enabled at this point - it may 1167 * have been turned off for the command that just completed. 1168 */ 1169 1170 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER); 1171 if (phs == 0x60) { 1172 DB(DB_INTR, printk("SX-DONE")) |
1166 cmd->SCp.Message = COMMAND_COMPLETE; | 1173 scsi_pointer->Message = COMMAND_COMPLETE; |
1167 lun = read_wd33c93(regs, WD_TARGET_LUN); | 1174 lun = read_wd33c93(regs, WD_TARGET_LUN); |
1168 DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun)) | 1175 DB(DB_INTR, printk(":%d.%d", scsi_pointer->Status, lun)) |
1169 hostdata->connected = NULL; 1170 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1171 hostdata->state = S_UNCONNECTED; | 1176 hostdata->connected = NULL; 1177 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1178 hostdata->state = S_UNCONNECTED; |
1172 if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE) 1173 cmd->SCp.Status = lun; | 1179 if (scsi_pointer->Status == ILLEGAL_STATUS_BYTE) 1180 scsi_pointer->Status = lun; |
1174 if (cmd->cmnd[0] == REQUEST_SENSE | 1181 if (cmd->cmnd[0] == REQUEST_SENSE |
1175 && cmd->SCp.Status != SAM_STAT_GOOD) { | 1182 && scsi_pointer->Status != SAM_STAT_GOOD) { |
1176 set_host_byte(cmd, DID_ERROR); 1177 } else { 1178 set_host_byte(cmd, DID_OK); | 1183 set_host_byte(cmd, DID_ERROR); 1184 } else { 1185 set_host_byte(cmd, DID_OK); |
1179 scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 1180 set_status_byte(cmd, cmd->SCp.Status); | 1186 scsi_msg_to_host_byte(cmd, scsi_pointer->Message); 1187 set_status_byte(cmd, scsi_pointer->Status); |
1181 } 1182 scsi_done(cmd); 1183 1184/* We are no longer connected to a target - check to see if 1185 * there are commands waiting to be executed. 1186 */ 1187 spin_unlock_irqrestore(&hostdata->lock, flags); 1188 wd33c93_execute(instance); --- 65 unchanged lines hidden (view full) --- 1254 spin_unlock_irqrestore(&hostdata->lock, flags); 1255 return; 1256 } 1257 DB(DB_INTR, printk("UNEXP_DISC")) 1258 hostdata->connected = NULL; 1259 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1260 hostdata->state = S_UNCONNECTED; 1261 if (cmd->cmnd[0] == REQUEST_SENSE && | 1188 } 1189 scsi_done(cmd); 1190 1191/* We are no longer connected to a target - check to see if 1192 * there are commands waiting to be executed. 1193 */ 1194 spin_unlock_irqrestore(&hostdata->lock, flags); 1195 wd33c93_execute(instance); --- 65 unchanged lines hidden (view full) --- 1261 spin_unlock_irqrestore(&hostdata->lock, flags); 1262 return; 1263 } 1264 DB(DB_INTR, printk("UNEXP_DISC")) 1265 hostdata->connected = NULL; 1266 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1267 hostdata->state = S_UNCONNECTED; 1268 if (cmd->cmnd[0] == REQUEST_SENSE && |
1262 cmd->SCp.Status != SAM_STAT_GOOD) { | 1269 scsi_pointer->Status != SAM_STAT_GOOD) { |
1263 set_host_byte(cmd, DID_ERROR); 1264 } else { 1265 set_host_byte(cmd, DID_OK); | 1270 set_host_byte(cmd, DID_ERROR); 1271 } else { 1272 set_host_byte(cmd, DID_OK); |
1266 scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 1267 set_status_byte(cmd, cmd->SCp.Status); | 1273 scsi_msg_to_host_byte(cmd, scsi_pointer->Message); 1274 set_status_byte(cmd, scsi_pointer->Status); |
1268 } 1269 scsi_done(cmd); 1270 1271/* We are no longer connected to a target - check to see if 1272 * there are commands waiting to be executed. 1273 */ 1274 /* look above for comments on scsi_done() */ 1275 spin_unlock_irqrestore(&hostdata->lock, flags); --- 12 unchanged lines hidden (view full) --- 1288 printk(" - Already disconnected! "); 1289 hostdata->state = S_UNCONNECTED; 1290 } 1291 switch (hostdata->state) { 1292 case S_PRE_CMP_DISC: 1293 hostdata->connected = NULL; 1294 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1295 hostdata->state = S_UNCONNECTED; | 1275 } 1276 scsi_done(cmd); 1277 1278/* We are no longer connected to a target - check to see if 1279 * there are commands waiting to be executed. 1280 */ 1281 /* look above for comments on scsi_done() */ 1282 spin_unlock_irqrestore(&hostdata->lock, flags); --- 12 unchanged lines hidden (view full) --- 1295 printk(" - Already disconnected! "); 1296 hostdata->state = S_UNCONNECTED; 1297 } 1298 switch (hostdata->state) { 1299 case S_PRE_CMP_DISC: 1300 hostdata->connected = NULL; 1301 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); 1302 hostdata->state = S_UNCONNECTED; |
1296 DB(DB_INTR, printk(":%d", cmd->SCp.Status)) | 1303 DB(DB_INTR, printk(":%d", scsi_pointer->Status)) |
1297 if (cmd->cmnd[0] == REQUEST_SENSE | 1304 if (cmd->cmnd[0] == REQUEST_SENSE |
1298 && cmd->SCp.Status != SAM_STAT_GOOD) { | 1305 && scsi_pointer->Status != SAM_STAT_GOOD) { |
1299 set_host_byte(cmd, DID_ERROR); 1300 } else { 1301 set_host_byte(cmd, DID_OK); | 1306 set_host_byte(cmd, DID_ERROR); 1307 } else { 1308 set_host_byte(cmd, DID_OK); |
1302 scsi_msg_to_host_byte(cmd, cmd->SCp.Message); 1303 set_status_byte(cmd, cmd->SCp.Status); | 1309 scsi_msg_to_host_byte(cmd, scsi_pointer->Message); 1310 set_status_byte(cmd, scsi_pointer->Status); |
1304 } 1305 scsi_done(cmd); 1306 break; 1307 case S_PRE_TMP_DISC: 1308 case S_RUNNING_LEVEL2: 1309 cmd->host_scribble = (uchar *) hostdata->disconnected_Q; 1310 hostdata->disconnected_Q = cmd; 1311 hostdata->connected = NULL; --- 889 unchanged lines hidden --- | 1311 } 1312 scsi_done(cmd); 1313 break; 1314 case S_PRE_TMP_DISC: 1315 case S_RUNNING_LEVEL2: 1316 cmd->host_scribble = (uchar *) hostdata->disconnected_Q; 1317 hostdata->disconnected_Q = cmd; 1318 hostdata->connected = NULL; --- 889 unchanged lines hidden --- |