diff options
Diffstat (limited to 'drivers/scsi/aic7xxx/aic7xxx_osm.c')
-rw-r--r-- | drivers/scsi/aic7xxx/aic7xxx_osm.c | 660 |
1 files changed, 240 insertions, 420 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index c13e5632001..b89094db14c 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c | |||
@@ -122,8 +122,6 @@ | |||
122 | #include "aic7xxx_osm.h" | 122 | #include "aic7xxx_osm.h" |
123 | #include "aic7xxx_inline.h" | 123 | #include "aic7xxx_inline.h" |
124 | #include <scsi/scsicam.h> | 124 | #include <scsi/scsicam.h> |
125 | #include <scsi/scsi_transport.h> | ||
126 | #include <scsi/scsi_transport_spi.h> | ||
127 | 125 | ||
128 | static struct scsi_transport_template *ahc_linux_transport_template = NULL; | 126 | static struct scsi_transport_template *ahc_linux_transport_template = NULL; |
129 | 127 | ||
@@ -332,22 +330,6 @@ static uint32_t aic7xxx_extended; | |||
332 | static uint32_t aic7xxx_pci_parity = ~0; | 330 | static uint32_t aic7xxx_pci_parity = ~0; |
333 | 331 | ||
334 | /* | 332 | /* |
335 | * Certain newer motherboards have put new PCI based devices into the | ||
336 | * IO spaces that used to typically be occupied by VLB or EISA cards. | ||
337 | * This overlap can cause these newer motherboards to lock up when scanned | ||
338 | * for older EISA and VLB devices. Setting this option to non-0 will | ||
339 | * cause the driver to skip scanning for any VLB or EISA controllers and | ||
340 | * only support the PCI controllers. NOTE: this means that if the kernel | ||
341 | * os compiled with PCI support disabled, then setting this to non-0 | ||
342 | * would result in never finding any devices :) | ||
343 | */ | ||
344 | #ifndef CONFIG_AIC7XXX_PROBE_EISA_VL | ||
345 | uint32_t aic7xxx_probe_eisa_vl; | ||
346 | #else | ||
347 | uint32_t aic7xxx_probe_eisa_vl = ~0; | ||
348 | #endif | ||
349 | |||
350 | /* | ||
351 | * There are lots of broken chipsets in the world. Some of them will | 333 | * There are lots of broken chipsets in the world. Some of them will |
352 | * violate the PCI spec when we issue byte sized memory writes to our | 334 | * violate the PCI spec when we issue byte sized memory writes to our |
353 | * controller. I/O mapped register access, if allowed by the given | 335 | * controller. I/O mapped register access, if allowed by the given |
@@ -423,7 +405,7 @@ MODULE_PARM_DESC(aic7xxx, | |||
423 | ); | 405 | ); |
424 | 406 | ||
425 | static void ahc_linux_handle_scsi_status(struct ahc_softc *, | 407 | static void ahc_linux_handle_scsi_status(struct ahc_softc *, |
426 | struct ahc_linux_device *, | 408 | struct scsi_device *, |
427 | struct scb *); | 409 | struct scb *); |
428 | static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, | 410 | static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, |
429 | struct scsi_cmnd *cmd); | 411 | struct scsi_cmnd *cmd); |
@@ -434,17 +416,7 @@ static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); | |||
434 | static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); | 416 | static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); |
435 | static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, | 417 | static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, |
436 | struct ahc_devinfo *devinfo); | 418 | struct ahc_devinfo *devinfo); |
437 | static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, | 419 | static void ahc_linux_device_queue_depth(struct scsi_device *); |
438 | struct ahc_linux_device *dev); | ||
439 | static struct ahc_linux_target* ahc_linux_alloc_target(struct ahc_softc*, | ||
440 | u_int, u_int); | ||
441 | static void ahc_linux_free_target(struct ahc_softc*, | ||
442 | struct ahc_linux_target*); | ||
443 | static struct ahc_linux_device* ahc_linux_alloc_device(struct ahc_softc*, | ||
444 | struct ahc_linux_target*, | ||
445 | u_int); | ||
446 | static void ahc_linux_free_device(struct ahc_softc*, | ||
447 | struct ahc_linux_device*); | ||
448 | static int ahc_linux_run_command(struct ahc_softc*, | 420 | static int ahc_linux_run_command(struct ahc_softc*, |
449 | struct ahc_linux_device *, | 421 | struct ahc_linux_device *, |
450 | struct scsi_cmnd *); | 422 | struct scsi_cmnd *); |
@@ -454,32 +426,12 @@ static int aic7xxx_setup(char *s); | |||
454 | static int ahc_linux_next_unit(void); | 426 | static int ahc_linux_next_unit(void); |
455 | 427 | ||
456 | /********************************* Inlines ************************************/ | 428 | /********************************* Inlines ************************************/ |
457 | static __inline struct ahc_linux_device* | ||
458 | ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, | ||
459 | u_int target, u_int lun); | ||
460 | static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); | 429 | static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); |
461 | 430 | ||
462 | static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, | 431 | static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, |
463 | struct ahc_dma_seg *sg, | 432 | struct ahc_dma_seg *sg, |
464 | dma_addr_t addr, bus_size_t len); | 433 | dma_addr_t addr, bus_size_t len); |
465 | 434 | ||
466 | static __inline struct ahc_linux_device* | ||
467 | ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, | ||
468 | u_int lun) | ||
469 | { | ||
470 | struct ahc_linux_target *targ; | ||
471 | struct ahc_linux_device *dev; | ||
472 | u_int target_offset; | ||
473 | |||
474 | target_offset = target; | ||
475 | if (channel != 0) | ||
476 | target_offset += 8; | ||
477 | targ = ahc->platform_data->targets[target_offset]; | ||
478 | BUG_ON(targ == NULL); | ||
479 | dev = targ->devices[lun]; | ||
480 | return dev; | ||
481 | } | ||
482 | |||
483 | static __inline void | 435 | static __inline void |
484 | ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) | 436 | ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) |
485 | { | 437 | { |
@@ -533,17 +485,6 @@ ahc_linux_detect(struct scsi_host_template *template) | |||
533 | int found = 0; | 485 | int found = 0; |
534 | 486 | ||
535 | /* | 487 | /* |
536 | * Sanity checking of Linux SCSI data structures so | ||
537 | * that some of our hacks^H^H^H^H^Hassumptions aren't | ||
538 | * violated. | ||
539 | */ | ||
540 | if (offsetof(struct ahc_cmd_internal, end) | ||
541 | > offsetof(struct scsi_cmnd, host_scribble)) { | ||
542 | printf("ahc_linux_detect: SCSI data structures changed.\n"); | ||
543 | printf("ahc_linux_detect: Unable to attach\n"); | ||
544 | return (0); | ||
545 | } | ||
546 | /* | ||
547 | * If we've been passed any parameters, process them now. | 488 | * If we've been passed any parameters, process them now. |
548 | */ | 489 | */ |
549 | if (aic7xxx) | 490 | if (aic7xxx) |
@@ -611,7 +552,7 @@ static int | |||
611 | ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) | 552 | ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) |
612 | { | 553 | { |
613 | struct ahc_softc *ahc; | 554 | struct ahc_softc *ahc; |
614 | struct ahc_linux_device *dev; | 555 | struct ahc_linux_device *dev = scsi_transport_device_data(cmd->device); |
615 | 556 | ||
616 | ahc = *(struct ahc_softc **)cmd->device->host->hostdata; | 557 | ahc = *(struct ahc_softc **)cmd->device->host->hostdata; |
617 | 558 | ||
@@ -629,132 +570,177 @@ ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) | |||
629 | if (ahc->platform_data->qfrozen != 0) | 570 | if (ahc->platform_data->qfrozen != 0) |
630 | return SCSI_MLQUEUE_HOST_BUSY; | 571 | return SCSI_MLQUEUE_HOST_BUSY; |
631 | 572 | ||
632 | dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, | ||
633 | cmd->device->lun); | ||
634 | BUG_ON(dev == NULL); | ||
635 | |||
636 | cmd->result = CAM_REQ_INPROG << 16; | 573 | cmd->result = CAM_REQ_INPROG << 16; |
637 | 574 | ||
638 | return ahc_linux_run_command(ahc, dev, cmd); | 575 | return ahc_linux_run_command(ahc, dev, cmd); |
639 | } | 576 | } |
640 | 577 | ||
641 | static int | 578 | static inline struct scsi_target ** |
642 | ahc_linux_slave_alloc(struct scsi_device *device) | 579 | ahc_linux_target_in_softc(struct scsi_target *starget) |
643 | { | 580 | { |
644 | struct ahc_softc *ahc; | 581 | struct ahc_softc *ahc = |
645 | struct ahc_linux_target *targ; | 582 | *((struct ahc_softc **)dev_to_shost(&starget->dev)->hostdata); |
646 | struct scsi_target *starget = device->sdev_target; | ||
647 | struct ahc_linux_device *dev; | ||
648 | unsigned int target_offset; | 583 | unsigned int target_offset; |
584 | |||
585 | target_offset = starget->id; | ||
586 | if (starget->channel != 0) | ||
587 | target_offset += 8; | ||
588 | |||
589 | return &ahc->platform_data->starget[target_offset]; | ||
590 | } | ||
591 | |||
592 | static int | ||
593 | ahc_linux_target_alloc(struct scsi_target *starget) | ||
594 | { | ||
595 | struct ahc_softc *ahc = | ||
596 | *((struct ahc_softc **)dev_to_shost(&starget->dev)->hostdata); | ||
597 | struct seeprom_config *sc = ahc->seep_config; | ||
649 | unsigned long flags; | 598 | unsigned long flags; |
650 | int retval = -ENOMEM; | 599 | struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget); |
600 | struct ahc_linux_target *targ = scsi_transport_target_data(starget); | ||
601 | unsigned short scsirate; | ||
602 | struct ahc_devinfo devinfo; | ||
603 | struct ahc_initiator_tinfo *tinfo; | ||
604 | struct ahc_tmode_tstate *tstate; | ||
605 | char channel = starget->channel + 'A'; | ||
606 | unsigned int our_id = ahc->our_id; | ||
607 | unsigned int target_offset; | ||
651 | 608 | ||
652 | target_offset = starget->id; | 609 | target_offset = starget->id; |
653 | if (starget->channel != 0) | 610 | if (starget->channel != 0) |
654 | target_offset += 8; | 611 | target_offset += 8; |
612 | |||
613 | if (starget->channel) | ||
614 | our_id = ahc->our_id_b; | ||
655 | 615 | ||
656 | ahc = *((struct ahc_softc **)device->host->hostdata); | ||
657 | if (bootverbose) | ||
658 | printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id); | ||
659 | ahc_lock(ahc, &flags); | 616 | ahc_lock(ahc, &flags); |
660 | targ = ahc->platform_data->targets[target_offset]; | ||
661 | if (targ == NULL) { | ||
662 | struct seeprom_config *sc; | ||
663 | 617 | ||
664 | targ = ahc_linux_alloc_target(ahc, starget->channel, | 618 | BUG_ON(*ahc_targp != NULL); |
665 | starget->id); | ||
666 | sc = ahc->seep_config; | ||
667 | if (targ == NULL) | ||
668 | goto out; | ||
669 | 619 | ||
670 | if (sc) { | 620 | *ahc_targp = starget; |
671 | unsigned short scsirate; | 621 | memset(targ, 0, sizeof(*targ)); |
672 | struct ahc_devinfo devinfo; | ||
673 | struct ahc_initiator_tinfo *tinfo; | ||
674 | struct ahc_tmode_tstate *tstate; | ||
675 | char channel = starget->channel + 'A'; | ||
676 | unsigned int our_id = ahc->our_id; | ||
677 | |||
678 | if (starget->channel) | ||
679 | our_id = ahc->our_id_b; | ||
680 | 622 | ||
681 | if ((ahc->features & AHC_ULTRA2) != 0) { | 623 | if (sc) { |
682 | scsirate = sc->device_flags[target_offset] & CFXFER; | 624 | int maxsync = AHC_SYNCRATE_DT; |
683 | } else { | 625 | int ultra = 0; |
684 | scsirate = (sc->device_flags[target_offset] & CFXFER) << 4; | 626 | int flags = sc->device_flags[target_offset]; |
685 | if (sc->device_flags[target_offset] & CFSYNCH) | 627 | |
686 | scsirate |= SOFS; | 628 | if (ahc->flags & AHC_NEWEEPROM_FMT) { |
687 | } | 629 | if (flags & CFSYNCHISULTRA) |
688 | if (sc->device_flags[target_offset] & CFWIDEB) { | 630 | ultra = 1; |
689 | scsirate |= WIDEXFER; | 631 | } else if (flags & CFULTRAEN) |
690 | spi_max_width(starget) = 1; | 632 | ultra = 1; |
691 | } else | 633 | /* AIC nutcase; 10MHz appears as ultra = 1, CFXFER = 0x04 |
692 | spi_max_width(starget) = 0; | 634 | * change it to ultra=0, CFXFER = 0 */ |
693 | spi_min_period(starget) = | 635 | if(ultra && (flags & CFXFER) == 0x04) { |
694 | ahc_find_period(ahc, scsirate, AHC_SYNCRATE_DT); | 636 | ultra = 0; |
695 | tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id, | 637 | flags &= ~CFXFER; |
696 | targ->target, &tstate); | ||
697 | ahc_compile_devinfo(&devinfo, our_id, targ->target, | ||
698 | CAM_LUN_WILDCARD, channel, | ||
699 | ROLE_INITIATOR); | ||
700 | ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0, | ||
701 | AHC_TRANS_GOAL, /*paused*/FALSE); | ||
702 | ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, | ||
703 | AHC_TRANS_GOAL, /*paused*/FALSE); | ||
704 | } | 638 | } |
705 | 639 | ||
706 | } | 640 | if ((ahc->features & AHC_ULTRA2) != 0) { |
707 | dev = targ->devices[device->lun]; | 641 | scsirate = (flags & CFXFER) | (ultra ? 0x8 : 0); |
708 | if (dev == NULL) { | 642 | } else { |
709 | dev = ahc_linux_alloc_device(ahc, targ, device->lun); | 643 | scsirate = (flags & CFXFER) << 4; |
710 | if (dev == NULL) | 644 | maxsync = ultra ? AHC_SYNCRATE_ULTRA : |
711 | goto out; | 645 | AHC_SYNCRATE_FAST; |
646 | } | ||
647 | spi_max_width(starget) = (flags & CFWIDEB) ? 1 : 0; | ||
648 | if (!(flags & CFSYNCH)) | ||
649 | spi_max_offset(starget) = 0; | ||
650 | spi_min_period(starget) = | ||
651 | ahc_find_period(ahc, scsirate, maxsync); | ||
652 | |||
653 | tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id, | ||
654 | starget->id, &tstate); | ||
712 | } | 655 | } |
713 | retval = 0; | 656 | ahc_compile_devinfo(&devinfo, our_id, starget->id, |
714 | 657 | CAM_LUN_WILDCARD, channel, | |
715 | out: | 658 | ROLE_INITIATOR); |
659 | ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0, | ||
660 | AHC_TRANS_GOAL, /*paused*/FALSE); | ||
661 | ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, | ||
662 | AHC_TRANS_GOAL, /*paused*/FALSE); | ||
716 | ahc_unlock(ahc, &flags); | 663 | ahc_unlock(ahc, &flags); |
717 | return retval; | 664 | |
665 | return 0; | ||
666 | } | ||
667 | |||
668 | static void | ||
669 | ahc_linux_target_destroy(struct scsi_target *starget) | ||
670 | { | ||
671 | struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget); | ||
672 | |||
673 | *ahc_targp = NULL; | ||
718 | } | 674 | } |
719 | 675 | ||
720 | static int | 676 | static int |
721 | ahc_linux_slave_configure(struct scsi_device *device) | 677 | ahc_linux_slave_alloc(struct scsi_device *sdev) |
678 | { | ||
679 | struct ahc_softc *ahc = | ||
680 | *((struct ahc_softc **)sdev->host->hostdata); | ||
681 | struct scsi_target *starget = sdev->sdev_target; | ||
682 | struct ahc_linux_target *targ = scsi_transport_target_data(starget); | ||
683 | struct ahc_linux_device *dev; | ||
684 | |||
685 | if (bootverbose) | ||
686 | printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id); | ||
687 | |||
688 | BUG_ON(targ->sdev[sdev->lun] != NULL); | ||
689 | |||
690 | dev = scsi_transport_device_data(sdev); | ||
691 | memset(dev, 0, sizeof(*dev)); | ||
692 | |||
693 | /* | ||
694 | * We start out life using untagged | ||
695 | * transactions of which we allow one. | ||
696 | */ | ||
697 | dev->openings = 1; | ||
698 | |||
699 | /* | ||
700 | * Set maxtags to 0. This will be changed if we | ||
701 | * later determine that we are dealing with | ||
702 | * a tagged queuing capable device. | ||
703 | */ | ||
704 | dev->maxtags = 0; | ||
705 | |||
706 | targ->sdev[sdev->lun] = sdev; | ||
707 | |||
708 | return 0; | ||
709 | } | ||
710 | |||
711 | static int | ||
712 | ahc_linux_slave_configure(struct scsi_device *sdev) | ||
722 | { | 713 | { |
723 | struct ahc_softc *ahc; | 714 | struct ahc_softc *ahc; |
724 | struct ahc_linux_device *dev; | ||
725 | 715 | ||
726 | ahc = *((struct ahc_softc **)device->host->hostdata); | 716 | ahc = *((struct ahc_softc **)sdev->host->hostdata); |
727 | 717 | ||
728 | if (bootverbose) | 718 | if (bootverbose) |
729 | printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id); | 719 | printf("%s: Slave Configure %d\n", ahc_name(ahc), sdev->id); |
730 | 720 | ||
731 | dev = ahc_linux_get_device(ahc, device->channel, device->id, | 721 | ahc_linux_device_queue_depth(sdev); |
732 | device->lun); | ||
733 | dev->scsi_device = device; | ||
734 | ahc_linux_device_queue_depth(ahc, dev); | ||
735 | 722 | ||
736 | /* Initial Domain Validation */ | 723 | /* Initial Domain Validation */ |
737 | if (!spi_initial_dv(device->sdev_target)) | 724 | if (!spi_initial_dv(sdev->sdev_target)) |
738 | spi_dv_device(device); | 725 | spi_dv_device(sdev); |
739 | 726 | ||
740 | return 0; | 727 | return 0; |
741 | } | 728 | } |
742 | 729 | ||
743 | static void | 730 | static void |
744 | ahc_linux_slave_destroy(struct scsi_device *device) | 731 | ahc_linux_slave_destroy(struct scsi_device *sdev) |
745 | { | 732 | { |
746 | struct ahc_softc *ahc; | 733 | struct ahc_softc *ahc; |
747 | struct ahc_linux_device *dev; | 734 | struct ahc_linux_device *dev = scsi_transport_device_data(sdev); |
735 | struct ahc_linux_target *targ = scsi_transport_target_data(sdev->sdev_target); | ||
748 | 736 | ||
749 | ahc = *((struct ahc_softc **)device->host->hostdata); | 737 | ahc = *((struct ahc_softc **)sdev->host->hostdata); |
750 | if (bootverbose) | 738 | if (bootverbose) |
751 | printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id); | 739 | printf("%s: Slave Destroy %d\n", ahc_name(ahc), sdev->id); |
752 | dev = ahc_linux_get_device(ahc, device->channel, | ||
753 | device->id, device->lun); | ||
754 | 740 | ||
755 | BUG_ON(dev->active); | 741 | BUG_ON(dev->active); |
756 | 742 | ||
757 | ahc_linux_free_device(ahc, dev); | 743 | targ->sdev[sdev->lun] = NULL; |
758 | } | 744 | } |
759 | 745 | ||
760 | #if defined(__i386__) | 746 | #if defined(__i386__) |
@@ -843,10 +829,14 @@ ahc_linux_bus_reset(struct scsi_cmnd *cmd) | |||
843 | { | 829 | { |
844 | struct ahc_softc *ahc; | 830 | struct ahc_softc *ahc; |
845 | int found; | 831 | int found; |
832 | unsigned long flags; | ||
846 | 833 | ||
847 | ahc = *(struct ahc_softc **)cmd->device->host->hostdata; | 834 | ahc = *(struct ahc_softc **)cmd->device->host->hostdata; |
835 | |||
836 | ahc_lock(ahc, &flags); | ||
848 | found = ahc_reset_channel(ahc, cmd->device->channel + 'A', | 837 | found = ahc_reset_channel(ahc, cmd->device->channel + 'A', |
849 | /*initiate reset*/TRUE); | 838 | /*initiate reset*/TRUE); |
839 | ahc_unlock(ahc, &flags); | ||
850 | 840 | ||
851 | if (bootverbose) | 841 | if (bootverbose) |
852 | printf("%s: SCSI bus reset delivered. " | 842 | printf("%s: SCSI bus reset delivered. " |
@@ -874,6 +864,8 @@ struct scsi_host_template aic7xxx_driver_template = { | |||
874 | .slave_alloc = ahc_linux_slave_alloc, | 864 | .slave_alloc = ahc_linux_slave_alloc, |
875 | .slave_configure = ahc_linux_slave_configure, | 865 | .slave_configure = ahc_linux_slave_configure, |
876 | .slave_destroy = ahc_linux_slave_destroy, | 866 | .slave_destroy = ahc_linux_slave_destroy, |
867 | .target_alloc = ahc_linux_target_alloc, | ||
868 | .target_destroy = ahc_linux_target_destroy, | ||
877 | }; | 869 | }; |
878 | 870 | ||
879 | /**************************** Tasklet Handler *********************************/ | 871 | /**************************** Tasklet Handler *********************************/ |
@@ -1112,8 +1104,6 @@ aic7xxx_setup(char *s) | |||
1112 | { "debug", &ahc_debug }, | 1104 | { "debug", &ahc_debug }, |
1113 | #endif | 1105 | #endif |
1114 | { "reverse_scan", &aic7xxx_reverse_scan }, | 1106 | { "reverse_scan", &aic7xxx_reverse_scan }, |
1115 | { "no_probe", &aic7xxx_probe_eisa_vl }, | ||
1116 | { "probe_eisa_vl", &aic7xxx_probe_eisa_vl }, | ||
1117 | { "periodic_otag", &aic7xxx_periodic_otag }, | 1107 | { "periodic_otag", &aic7xxx_periodic_otag }, |
1118 | { "pci_parity", &aic7xxx_pci_parity }, | 1108 | { "pci_parity", &aic7xxx_pci_parity }, |
1119 | { "seltime", &aic7xxx_seltime }, | 1109 | { "seltime", &aic7xxx_seltime }, |
@@ -1335,8 +1325,7 @@ ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg) | |||
1335 | void | 1325 | void |
1336 | ahc_platform_free(struct ahc_softc *ahc) | 1326 | ahc_platform_free(struct ahc_softc *ahc) |
1337 | { | 1327 | { |
1338 | struct ahc_linux_target *targ; | 1328 | struct scsi_target *starget; |
1339 | struct ahc_linux_device *dev; | ||
1340 | int i, j; | 1329 | int i, j; |
1341 | 1330 | ||
1342 | if (ahc->platform_data != NULL) { | 1331 | if (ahc->platform_data != NULL) { |
@@ -1347,22 +1336,17 @@ ahc_platform_free(struct ahc_softc *ahc) | |||
1347 | 1336 | ||
1348 | /* destroy all of the device and target objects */ | 1337 | /* destroy all of the device and target objects */ |
1349 | for (i = 0; i < AHC_NUM_TARGETS; i++) { | 1338 | for (i = 0; i < AHC_NUM_TARGETS; i++) { |
1350 | targ = ahc->platform_data->targets[i]; | 1339 | starget = ahc->platform_data->starget[i]; |
1351 | if (targ != NULL) { | 1340 | if (starget != NULL) { |
1352 | /* Keep target around through the loop. */ | ||
1353 | targ->refcount++; | ||
1354 | for (j = 0; j < AHC_NUM_LUNS; j++) { | 1341 | for (j = 0; j < AHC_NUM_LUNS; j++) { |
1342 | struct ahc_linux_target *targ = | ||
1343 | scsi_transport_target_data(starget); | ||
1355 | 1344 | ||
1356 | if (targ->devices[j] == NULL) | 1345 | if (targ->sdev[j] == NULL) |
1357 | continue; | 1346 | continue; |
1358 | dev = targ->devices[j]; | 1347 | targ->sdev[j] = NULL; |
1359 | ahc_linux_free_device(ahc, dev); | ||
1360 | } | 1348 | } |
1361 | /* | 1349 | ahc->platform_data->starget[i] = NULL; |
1362 | * Forcibly free the target now that | ||
1363 | * all devices are gone. | ||
1364 | */ | ||
1365 | ahc_linux_free_target(ahc, targ); | ||
1366 | } | 1350 | } |
1367 | } | 1351 | } |
1368 | 1352 | ||
@@ -1395,15 +1379,25 @@ void | |||
1395 | ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, | 1379 | ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, |
1396 | ahc_queue_alg alg) | 1380 | ahc_queue_alg alg) |
1397 | { | 1381 | { |
1382 | struct scsi_target *starget; | ||
1383 | struct ahc_linux_target *targ; | ||
1398 | struct ahc_linux_device *dev; | 1384 | struct ahc_linux_device *dev; |
1385 | struct scsi_device *sdev; | ||
1386 | u_int target_offset; | ||
1399 | int was_queuing; | 1387 | int was_queuing; |
1400 | int now_queuing; | 1388 | int now_queuing; |
1401 | 1389 | ||
1402 | dev = ahc_linux_get_device(ahc, devinfo->channel - 'A', | 1390 | target_offset = devinfo->target; |
1403 | devinfo->target, | 1391 | if (devinfo->channel != 'A') |
1404 | devinfo->lun); | 1392 | target_offset += 8; |
1405 | if (dev == NULL) | 1393 | starget = ahc->platform_data->starget[target_offset]; |
1394 | targ = scsi_transport_target_data(starget); | ||
1395 | BUG_ON(targ == NULL); | ||
1396 | sdev = targ->sdev[devinfo->lun]; | ||
1397 | if (sdev == NULL) | ||
1406 | return; | 1398 | return; |
1399 | dev = scsi_transport_device_data(sdev); | ||
1400 | |||
1407 | was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); | 1401 | was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); |
1408 | switch (alg) { | 1402 | switch (alg) { |
1409 | default: | 1403 | default: |
@@ -1454,30 +1448,28 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, | |||
1454 | dev->maxtags = 0; | 1448 | dev->maxtags = 0; |
1455 | dev->openings = 1 - dev->active; | 1449 | dev->openings = 1 - dev->active; |
1456 | } | 1450 | } |
1457 | if (dev->scsi_device != NULL) { | 1451 | switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { |
1458 | switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { | 1452 | case AHC_DEV_Q_BASIC: |
1459 | case AHC_DEV_Q_BASIC: | 1453 | scsi_adjust_queue_depth(sdev, |
1460 | scsi_adjust_queue_depth(dev->scsi_device, | 1454 | MSG_SIMPLE_TASK, |
1461 | MSG_SIMPLE_TASK, | 1455 | dev->openings + dev->active); |
1462 | dev->openings + dev->active); | 1456 | break; |
1463 | break; | 1457 | case AHC_DEV_Q_TAGGED: |
1464 | case AHC_DEV_Q_TAGGED: | 1458 | scsi_adjust_queue_depth(sdev, |
1465 | scsi_adjust_queue_depth(dev->scsi_device, | 1459 | MSG_ORDERED_TASK, |
1466 | MSG_ORDERED_TASK, | 1460 | dev->openings + dev->active); |
1467 | dev->openings + dev->active); | 1461 | break; |
1468 | break; | 1462 | default: |
1469 | default: | 1463 | /* |
1470 | /* | 1464 | * We allow the OS to queue 2 untagged transactions to |
1471 | * We allow the OS to queue 2 untagged transactions to | 1465 | * us at any time even though we can only execute them |
1472 | * us at any time even though we can only execute them | 1466 | * serially on the controller/device. This should |
1473 | * serially on the controller/device. This should | 1467 | * remove some latency. |
1474 | * remove some latency. | 1468 | */ |
1475 | */ | 1469 | scsi_adjust_queue_depth(sdev, |
1476 | scsi_adjust_queue_depth(dev->scsi_device, | 1470 | /*NON-TAGGED*/0, |
1477 | /*NON-TAGGED*/0, | 1471 | /*queue depth*/2); |
1478 | /*queue depth*/2); | 1472 | break; |
1479 | break; | ||
1480 | } | ||
1481 | } | 1473 | } |
1482 | } | 1474 | } |
1483 | 1475 | ||
@@ -1523,22 +1515,20 @@ ahc_linux_user_tagdepth(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) | |||
1523 | * Determines the queue depth for a given device. | 1515 | * Determines the queue depth for a given device. |
1524 | */ | 1516 | */ |
1525 | static void | 1517 | static void |
1526 | ahc_linux_device_queue_depth(struct ahc_softc *ahc, | 1518 | ahc_linux_device_queue_depth(struct scsi_device *sdev) |
1527 | struct ahc_linux_device *dev) | ||
1528 | { | 1519 | { |
1529 | struct ahc_devinfo devinfo; | 1520 | struct ahc_devinfo devinfo; |
1530 | u_int tags; | 1521 | u_int tags; |
1522 | struct ahc_softc *ahc = *((struct ahc_softc **)sdev->host->hostdata); | ||
1531 | 1523 | ||
1532 | ahc_compile_devinfo(&devinfo, | 1524 | ahc_compile_devinfo(&devinfo, |
1533 | dev->target->channel == 0 | 1525 | sdev->sdev_target->channel == 0 |
1534 | ? ahc->our_id : ahc->our_id_b, | 1526 | ? ahc->our_id : ahc->our_id_b, |
1535 | dev->target->target, dev->lun, | 1527 | sdev->sdev_target->id, sdev->lun, |
1536 | dev->target->channel == 0 ? 'A' : 'B', | 1528 | sdev->sdev_target->channel == 0 ? 'A' : 'B', |
1537 | ROLE_INITIATOR); | 1529 | ROLE_INITIATOR); |
1538 | tags = ahc_linux_user_tagdepth(ahc, &devinfo); | 1530 | tags = ahc_linux_user_tagdepth(ahc, &devinfo); |
1539 | if (tags != 0 | 1531 | if (tags != 0 && sdev->tagged_supported != 0) { |
1540 | && dev->scsi_device != NULL | ||
1541 | && dev->scsi_device->tagged_supported != 0) { | ||
1542 | 1532 | ||
1543 | ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED); | 1533 | ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED); |
1544 | ahc_print_devinfo(ahc, &devinfo); | 1534 | ahc_print_devinfo(ahc, &devinfo); |
@@ -1587,10 +1577,9 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, | |||
1587 | /* | 1577 | /* |
1588 | * Get an scb to use. | 1578 | * Get an scb to use. |
1589 | */ | 1579 | */ |
1590 | if ((scb = ahc_get_scb(ahc)) == NULL) { | 1580 | scb = ahc_get_scb(ahc); |
1591 | ahc->flags |= AHC_RESOURCE_SHORTAGE; | 1581 | if (!scb) |
1592 | return SCSI_MLQUEUE_HOST_BUSY; | 1582 | return SCSI_MLQUEUE_HOST_BUSY; |
1593 | } | ||
1594 | 1583 | ||
1595 | scb->io_ctx = cmd; | 1584 | scb->io_ctx = cmd; |
1596 | scb->platform_data->dev = dev; | 1585 | scb->platform_data->dev = dev; |
@@ -1767,106 +1756,6 @@ ahc_platform_flushwork(struct ahc_softc *ahc) | |||
1767 | 1756 | ||
1768 | } | 1757 | } |
1769 | 1758 | ||
1770 | static struct ahc_linux_target* | ||
1771 | ahc_linux_alloc_target(struct ahc_softc *ahc, u_int channel, u_int target) | ||
1772 | { | ||
1773 | struct ahc_linux_target *targ; | ||
1774 | u_int target_offset; | ||
1775 | |||
1776 | target_offset = target; | ||
1777 | if (channel != 0) | ||
1778 | target_offset += 8; | ||
1779 | |||
1780 | targ = malloc(sizeof(*targ), M_DEVBUG, M_NOWAIT); | ||
1781 | if (targ == NULL) | ||
1782 | return (NULL); | ||
1783 | memset(targ, 0, sizeof(*targ)); | ||
1784 | targ->channel = channel; | ||
1785 | targ->target = target; | ||
1786 | targ->ahc = ahc; | ||
1787 | ahc->platform_data->targets[target_offset] = targ; | ||
1788 | return (targ); | ||
1789 | } | ||
1790 | |||
1791 | static void | ||
1792 | ahc_linux_free_target(struct ahc_softc *ahc, struct ahc_linux_target *targ) | ||
1793 | { | ||
1794 | struct ahc_devinfo devinfo; | ||
1795 | struct ahc_initiator_tinfo *tinfo; | ||
1796 | struct ahc_tmode_tstate *tstate; | ||
1797 | u_int our_id; | ||
1798 | u_int target_offset; | ||
1799 | char channel; | ||
1800 | |||
1801 | /* | ||
1802 | * Force a negotiation to async/narrow on any | ||
1803 | * future command to this device unless a bus | ||
1804 | * reset occurs between now and that command. | ||
1805 | */ | ||
1806 | channel = 'A' + targ->channel; | ||
1807 | our_id = ahc->our_id; | ||
1808 | target_offset = targ->target; | ||
1809 | if (targ->channel != 0) { | ||
1810 | target_offset += 8; | ||
1811 | our_id = ahc->our_id_b; | ||
1812 | } | ||
1813 | tinfo = ahc_fetch_transinfo(ahc, channel, our_id, | ||
1814 | targ->target, &tstate); | ||
1815 | ahc_compile_devinfo(&devinfo, our_id, targ->target, CAM_LUN_WILDCARD, | ||
1816 | channel, ROLE_INITIATOR); | ||
1817 | ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0, | ||
1818 | AHC_TRANS_GOAL, /*paused*/FALSE); | ||
1819 | ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, | ||
1820 | AHC_TRANS_GOAL, /*paused*/FALSE); | ||
1821 | ahc_update_neg_request(ahc, &devinfo, tstate, tinfo, AHC_NEG_ALWAYS); | ||
1822 | ahc->platform_data->targets[target_offset] = NULL; | ||
1823 | free(targ, M_DEVBUF); | ||
1824 | } | ||
1825 | |||
1826 | static struct ahc_linux_device* | ||
1827 | ahc_linux_alloc_device(struct ahc_softc *ahc, | ||
1828 | struct ahc_linux_target *targ, u_int lun) | ||
1829 | { | ||
1830 | struct ahc_linux_device *dev; | ||
1831 | |||
1832 | dev = malloc(sizeof(*dev), M_DEVBUG, M_NOWAIT); | ||
1833 | if (dev == NULL) | ||
1834 | return (NULL); | ||
1835 | memset(dev, 0, sizeof(*dev)); | ||
1836 | dev->lun = lun; | ||
1837 | dev->target = targ; | ||
1838 | |||
1839 | /* | ||
1840 | * We start out life using untagged | ||
1841 | * transactions of which we allow one. | ||
1842 | */ | ||
1843 | dev->openings = 1; | ||
1844 | |||
1845 | /* | ||
1846 | * Set maxtags to 0. This will be changed if we | ||
1847 | * later determine that we are dealing with | ||
1848 | * a tagged queuing capable device. | ||
1849 | */ | ||
1850 | dev->maxtags = 0; | ||
1851 | |||
1852 | targ->refcount++; | ||
1853 | targ->devices[lun] = dev; | ||
1854 | return (dev); | ||
1855 | } | ||
1856 | |||
1857 | static void | ||
1858 | ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) | ||
1859 | { | ||
1860 | struct ahc_linux_target *targ; | ||
1861 | |||
1862 | targ = dev->target; | ||
1863 | targ->devices[dev->lun] = NULL; | ||
1864 | free(dev, M_DEVBUF); | ||
1865 | targ->refcount--; | ||
1866 | if (targ->refcount == 0) | ||
1867 | ahc_linux_free_target(ahc, targ); | ||
1868 | } | ||
1869 | |||
1870 | void | 1759 | void |
1871 | ahc_send_async(struct ahc_softc *ahc, char channel, | 1760 | ahc_send_async(struct ahc_softc *ahc, char channel, |
1872 | u_int target, u_int lun, ac_code code, void *arg) | 1761 | u_int target, u_int lun, ac_code code, void *arg) |
@@ -1875,11 +1764,15 @@ ahc_send_async(struct ahc_softc *ahc, char channel, | |||
1875 | case AC_TRANSFER_NEG: | 1764 | case AC_TRANSFER_NEG: |
1876 | { | 1765 | { |
1877 | char buf[80]; | 1766 | char buf[80]; |
1767 | struct scsi_target *starget; | ||
1878 | struct ahc_linux_target *targ; | 1768 | struct ahc_linux_target *targ; |
1879 | struct info_str info; | 1769 | struct info_str info; |
1880 | struct ahc_initiator_tinfo *tinfo; | 1770 | struct ahc_initiator_tinfo *tinfo; |
1881 | struct ahc_tmode_tstate *tstate; | 1771 | struct ahc_tmode_tstate *tstate; |
1882 | int target_offset; | 1772 | int target_offset; |
1773 | unsigned int target_ppr_options; | ||
1774 | |||
1775 | BUG_ON(target == CAM_TARGET_WILDCARD); | ||
1883 | 1776 | ||
1884 | info.buffer = buf; | 1777 | info.buffer = buf; |
1885 | info.length = sizeof(buf); | 1778 | info.length = sizeof(buf); |
@@ -1908,32 +1801,30 @@ ahc_send_async(struct ahc_softc *ahc, char channel, | |||
1908 | target_offset = target; | 1801 | target_offset = target; |
1909 | if (channel == 'B') | 1802 | if (channel == 'B') |
1910 | target_offset += 8; | 1803 | target_offset += 8; |
1911 | targ = ahc->platform_data->targets[target_offset]; | 1804 | starget = ahc->platform_data->starget[target_offset]; |
1805 | targ = scsi_transport_target_data(starget); | ||
1912 | if (targ == NULL) | 1806 | if (targ == NULL) |
1913 | break; | 1807 | break; |
1914 | if (tinfo->curr.period == targ->last_tinfo.period | 1808 | |
1915 | && tinfo->curr.width == targ->last_tinfo.width | 1809 | target_ppr_options = |
1916 | && tinfo->curr.offset == targ->last_tinfo.offset | 1810 | (spi_dt(starget) ? MSG_EXT_PPR_DT_REQ : 0) |
1917 | && tinfo->curr.ppr_options == targ->last_tinfo.ppr_options) | 1811 | + (spi_qas(starget) ? MSG_EXT_PPR_QAS_REQ : 0) |
1812 | + (spi_iu(starget) ? MSG_EXT_PPR_IU_REQ : 0); | ||
1813 | |||
1814 | if (tinfo->curr.period == spi_period(starget) | ||
1815 | && tinfo->curr.width == spi_width(starget) | ||
1816 | && tinfo->curr.offset == spi_offset(starget) | ||
1817 | && tinfo->curr.ppr_options == target_ppr_options) | ||
1918 | if (bootverbose == 0) | 1818 | if (bootverbose == 0) |
1919 | break; | 1819 | break; |
1920 | 1820 | ||
1921 | targ->last_tinfo.period = tinfo->curr.period; | 1821 | spi_period(starget) = tinfo->curr.period; |
1922 | targ->last_tinfo.width = tinfo->curr.width; | 1822 | spi_width(starget) = tinfo->curr.width; |
1923 | targ->last_tinfo.offset = tinfo->curr.offset; | 1823 | spi_offset(starget) = tinfo->curr.offset; |
1924 | targ->last_tinfo.ppr_options = tinfo->curr.ppr_options; | 1824 | spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ; |
1925 | 1825 | spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ; | |
1926 | printf("(%s:%c:", ahc_name(ahc), channel); | 1826 | spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ; |
1927 | if (target == CAM_TARGET_WILDCARD) | 1827 | spi_display_xfer_agreement(starget); |
1928 | printf("*): "); | ||
1929 | else | ||
1930 | printf("%d): ", target); | ||
1931 | ahc_format_transinfo(&info, &tinfo->curr); | ||
1932 | if (info.pos < info.length) | ||
1933 | *info.buffer = '\0'; | ||
1934 | else | ||
1935 | buf[info.length - 1] = '\0'; | ||
1936 | printf("%s", buf); | ||
1937 | break; | 1828 | break; |
1938 | } | 1829 | } |
1939 | case AC_SENT_BDR: | 1830 | case AC_SENT_BDR: |
@@ -2038,7 +1929,7 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb) | |||
2038 | ahc_set_transaction_status(scb, CAM_REQ_CMP); | 1929 | ahc_set_transaction_status(scb, CAM_REQ_CMP); |
2039 | } | 1930 | } |
2040 | } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { | 1931 | } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { |
2041 | ahc_linux_handle_scsi_status(ahc, dev, scb); | 1932 | ahc_linux_handle_scsi_status(ahc, cmd->device, scb); |
2042 | } | 1933 | } |
2043 | 1934 | ||
2044 | if (dev->openings == 1 | 1935 | if (dev->openings == 1 |
@@ -2077,14 +1968,15 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb) | |||
2077 | 1968 | ||
2078 | static void | 1969 | static void |
2079 | ahc_linux_handle_scsi_status(struct ahc_softc *ahc, | 1970 | ahc_linux_handle_scsi_status(struct ahc_softc *ahc, |
2080 | struct ahc_linux_device *dev, struct scb *scb) | 1971 | struct scsi_device *sdev, struct scb *scb) |
2081 | { | 1972 | { |
2082 | struct ahc_devinfo devinfo; | 1973 | struct ahc_devinfo devinfo; |
1974 | struct ahc_linux_device *dev = scsi_transport_device_data(sdev); | ||
2083 | 1975 | ||
2084 | ahc_compile_devinfo(&devinfo, | 1976 | ahc_compile_devinfo(&devinfo, |
2085 | ahc->our_id, | 1977 | ahc->our_id, |
2086 | dev->target->target, dev->lun, | 1978 | sdev->sdev_target->id, sdev->lun, |
2087 | dev->target->channel == 0 ? 'A' : 'B', | 1979 | sdev->sdev_target->channel == 0 ? 'A' : 'B', |
2088 | ROLE_INITIATOR); | 1980 | ROLE_INITIATOR); |
2089 | 1981 | ||
2090 | /* | 1982 | /* |
@@ -2361,6 +2253,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) | |||
2361 | printf(" 0x%x", cmd->cmnd[cdb_byte]); | 2253 | printf(" 0x%x", cmd->cmnd[cdb_byte]); |
2362 | printf("\n"); | 2254 | printf("\n"); |
2363 | 2255 | ||
2256 | spin_lock_irq(&ahc->platform_data->spin_lock); | ||
2257 | |||
2364 | /* | 2258 | /* |
2365 | * First determine if we currently own this command. | 2259 | * First determine if we currently own this command. |
2366 | * Start by searching the device queue. If not found | 2260 | * Start by searching the device queue. If not found |
@@ -2368,8 +2262,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) | |||
2368 | * at all, and the system wanted us to just abort the | 2262 | * at all, and the system wanted us to just abort the |
2369 | * command, return success. | 2263 | * command, return success. |
2370 | */ | 2264 | */ |
2371 | dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, | 2265 | dev = scsi_transport_device_data(cmd->device); |
2372 | cmd->device->lun); | ||
2373 | 2266 | ||
2374 | if (dev == NULL) { | 2267 | if (dev == NULL) { |
2375 | /* | 2268 | /* |
@@ -2616,6 +2509,8 @@ done: | |||
2616 | } | 2509 | } |
2617 | spin_lock_irq(&ahc->platform_data->spin_lock); | 2510 | spin_lock_irq(&ahc->platform_data->spin_lock); |
2618 | } | 2511 | } |
2512 | |||
2513 | spin_unlock_irq(&ahc->platform_data->spin_lock); | ||
2619 | return (retval); | 2514 | return (retval); |
2620 | } | 2515 | } |
2621 | 2516 | ||
@@ -2626,18 +2521,6 @@ ahc_platform_dump_card_state(struct ahc_softc *ahc) | |||
2626 | 2521 | ||
2627 | static void ahc_linux_exit(void); | 2522 | static void ahc_linux_exit(void); |
2628 | 2523 | ||
2629 | static void ahc_linux_get_width(struct scsi_target *starget) | ||
2630 | { | ||
2631 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
2632 | struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); | ||
2633 | struct ahc_tmode_tstate *tstate; | ||
2634 | struct ahc_initiator_tinfo *tinfo | ||
2635 | = ahc_fetch_transinfo(ahc, | ||
2636 | starget->channel + 'A', | ||
2637 | shost->this_id, starget->id, &tstate); | ||
2638 | spi_width(starget) = tinfo->curr.width; | ||
2639 | } | ||
2640 | |||
2641 | static void ahc_linux_set_width(struct scsi_target *starget, int width) | 2524 | static void ahc_linux_set_width(struct scsi_target *starget, int width) |
2642 | { | 2525 | { |
2643 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 2526 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -2652,18 +2535,6 @@ static void ahc_linux_set_width(struct scsi_target *starget, int width) | |||
2652 | ahc_unlock(ahc, &flags); | 2535 | ahc_unlock(ahc, &flags); |
2653 | } | 2536 | } |
2654 | 2537 | ||
2655 | static void ahc_linux_get_period(struct scsi_target *starget) | ||
2656 | { | ||
2657 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
2658 | struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); | ||
2659 | struct ahc_tmode_tstate *tstate; | ||
2660 | struct ahc_initiator_tinfo *tinfo | ||
2661 | = ahc_fetch_transinfo(ahc, | ||
2662 | starget->channel + 'A', | ||
2663 | shost->this_id, starget->id, &tstate); | ||
2664 | spi_period(starget) = tinfo->curr.period; | ||
2665 | } | ||
2666 | |||
2667 | static void ahc_linux_set_period(struct scsi_target *starget, int period) | 2538 | static void ahc_linux_set_period(struct scsi_target *starget, int period) |
2668 | { | 2539 | { |
2669 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 2540 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -2674,9 +2545,9 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period) | |||
2674 | starget->channel + 'A', | 2545 | starget->channel + 'A', |
2675 | shost->this_id, starget->id, &tstate); | 2546 | shost->this_id, starget->id, &tstate); |
2676 | struct ahc_devinfo devinfo; | 2547 | struct ahc_devinfo devinfo; |
2677 | unsigned int ppr_options = tinfo->curr.ppr_options; | 2548 | unsigned int ppr_options = tinfo->goal.ppr_options; |
2678 | unsigned long flags; | 2549 | unsigned long flags; |
2679 | unsigned long offset = tinfo->curr.offset; | 2550 | unsigned long offset = tinfo->goal.offset; |
2680 | struct ahc_syncrate *syncrate; | 2551 | struct ahc_syncrate *syncrate; |
2681 | 2552 | ||
2682 | if (offset == 0) | 2553 | if (offset == 0) |
@@ -2692,7 +2563,6 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period) | |||
2692 | 2563 | ||
2693 | /* all PPR requests apart from QAS require wide transfers */ | 2564 | /* all PPR requests apart from QAS require wide transfers */ |
2694 | if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) { | 2565 | if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) { |
2695 | ahc_linux_get_width(starget); | ||
2696 | if (spi_width(starget) == 0) | 2566 | if (spi_width(starget) == 0) |
2697 | ppr_options &= MSG_EXT_PPR_QAS_REQ; | 2567 | ppr_options &= MSG_EXT_PPR_QAS_REQ; |
2698 | } | 2568 | } |
@@ -2704,18 +2574,6 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period) | |||
2704 | ahc_unlock(ahc, &flags); | 2574 | ahc_unlock(ahc, &flags); |
2705 | } | 2575 | } |
2706 | 2576 | ||
2707 | static void ahc_linux_get_offset(struct scsi_target *starget) | ||
2708 | { | ||
2709 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
2710 | struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); | ||
2711 | struct ahc_tmode_tstate *tstate; | ||
2712 | struct ahc_initiator_tinfo *tinfo | ||
2713 | = ahc_fetch_transinfo(ahc, | ||
2714 | starget->channel + 'A', | ||
2715 | shost->this_id, starget->id, &tstate); | ||
2716 | spi_offset(starget) = tinfo->curr.offset; | ||
2717 | } | ||
2718 | |||
2719 | static void ahc_linux_set_offset(struct scsi_target *starget, int offset) | 2577 | static void ahc_linux_set_offset(struct scsi_target *starget, int offset) |
2720 | { | 2578 | { |
2721 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 2579 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -2735,8 +2593,8 @@ static void ahc_linux_set_offset(struct scsi_target *starget, int offset) | |||
2735 | starget->channel + 'A', ROLE_INITIATOR); | 2593 | starget->channel + 'A', ROLE_INITIATOR); |
2736 | if (offset != 0) { | 2594 | if (offset != 0) { |
2737 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); | 2595 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); |
2738 | period = tinfo->curr.period; | 2596 | period = tinfo->goal.period; |
2739 | ppr_options = tinfo->curr.ppr_options; | 2597 | ppr_options = tinfo->goal.ppr_options; |
2740 | } | 2598 | } |
2741 | ahc_lock(ahc, &flags); | 2599 | ahc_lock(ahc, &flags); |
2742 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset, | 2600 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset, |
@@ -2744,18 +2602,6 @@ static void ahc_linux_set_offset(struct scsi_target *starget, int offset) | |||
2744 | ahc_unlock(ahc, &flags); | 2602 | ahc_unlock(ahc, &flags); |
2745 | } | 2603 | } |
2746 | 2604 | ||
2747 | static void ahc_linux_get_dt(struct scsi_target *starget) | ||
2748 | { | ||
2749 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
2750 | struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); | ||
2751 | struct ahc_tmode_tstate *tstate; | ||
2752 | struct ahc_initiator_tinfo *tinfo | ||
2753 | = ahc_fetch_transinfo(ahc, | ||
2754 | starget->channel + 'A', | ||
2755 | shost->this_id, starget->id, &tstate); | ||
2756 | spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ; | ||
2757 | } | ||
2758 | |||
2759 | static void ahc_linux_set_dt(struct scsi_target *starget, int dt) | 2605 | static void ahc_linux_set_dt(struct scsi_target *starget, int dt) |
2760 | { | 2606 | { |
2761 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 2607 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -2766,9 +2612,9 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt) | |||
2766 | starget->channel + 'A', | 2612 | starget->channel + 'A', |
2767 | shost->this_id, starget->id, &tstate); | 2613 | shost->this_id, starget->id, &tstate); |
2768 | struct ahc_devinfo devinfo; | 2614 | struct ahc_devinfo devinfo; |
2769 | unsigned int ppr_options = tinfo->curr.ppr_options | 2615 | unsigned int ppr_options = tinfo->goal.ppr_options |
2770 | & ~MSG_EXT_PPR_DT_REQ; | 2616 | & ~MSG_EXT_PPR_DT_REQ; |
2771 | unsigned int period = tinfo->curr.period; | 2617 | unsigned int period = tinfo->goal.period; |
2772 | unsigned long flags; | 2618 | unsigned long flags; |
2773 | struct ahc_syncrate *syncrate; | 2619 | struct ahc_syncrate *syncrate; |
2774 | 2620 | ||
@@ -2782,23 +2628,11 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt) | |||
2782 | starget->channel + 'A', ROLE_INITIATOR); | 2628 | starget->channel + 'A', ROLE_INITIATOR); |
2783 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT); | 2629 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT); |
2784 | ahc_lock(ahc, &flags); | 2630 | ahc_lock(ahc, &flags); |
2785 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, | 2631 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset, |
2786 | ppr_options, AHC_TRANS_GOAL, FALSE); | 2632 | ppr_options, AHC_TRANS_GOAL, FALSE); |
2787 | ahc_unlock(ahc, &flags); | 2633 | ahc_unlock(ahc, &flags); |
2788 | } | 2634 | } |
2789 | 2635 | ||
2790 | static void ahc_linux_get_qas(struct scsi_target *starget) | ||
2791 | { | ||
2792 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
2793 | struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); | ||
2794 | struct ahc_tmode_tstate *tstate; | ||
2795 | struct ahc_initiator_tinfo *tinfo | ||
2796 | = ahc_fetch_transinfo(ahc, | ||
2797 | starget->channel + 'A', | ||
2798 | shost->this_id, starget->id, &tstate); | ||
2799 | spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ; | ||
2800 | } | ||
2801 | |||
2802 | static void ahc_linux_set_qas(struct scsi_target *starget, int qas) | 2636 | static void ahc_linux_set_qas(struct scsi_target *starget, int qas) |
2803 | { | 2637 | { |
2804 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 2638 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -2809,9 +2643,9 @@ static void ahc_linux_set_qas(struct scsi_target *starget, int qas) | |||
2809 | starget->channel + 'A', | 2643 | starget->channel + 'A', |
2810 | shost->this_id, starget->id, &tstate); | 2644 | shost->this_id, starget->id, &tstate); |
2811 | struct ahc_devinfo devinfo; | 2645 | struct ahc_devinfo devinfo; |
2812 | unsigned int ppr_options = tinfo->curr.ppr_options | 2646 | unsigned int ppr_options = tinfo->goal.ppr_options |
2813 | & ~MSG_EXT_PPR_QAS_REQ; | 2647 | & ~MSG_EXT_PPR_QAS_REQ; |
2814 | unsigned int period = tinfo->curr.period; | 2648 | unsigned int period = tinfo->goal.period; |
2815 | unsigned long flags; | 2649 | unsigned long flags; |
2816 | struct ahc_syncrate *syncrate; | 2650 | struct ahc_syncrate *syncrate; |
2817 | 2651 | ||
@@ -2822,23 +2656,11 @@ static void ahc_linux_set_qas(struct scsi_target *starget, int qas) | |||
2822 | starget->channel + 'A', ROLE_INITIATOR); | 2656 | starget->channel + 'A', ROLE_INITIATOR); |
2823 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); | 2657 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); |
2824 | ahc_lock(ahc, &flags); | 2658 | ahc_lock(ahc, &flags); |
2825 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, | 2659 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset, |
2826 | ppr_options, AHC_TRANS_GOAL, FALSE); | 2660 | ppr_options, AHC_TRANS_GOAL, FALSE); |
2827 | ahc_unlock(ahc, &flags); | 2661 | ahc_unlock(ahc, &flags); |
2828 | } | 2662 | } |
2829 | 2663 | ||
2830 | static void ahc_linux_get_iu(struct scsi_target *starget) | ||
2831 | { | ||
2832 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
2833 | struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); | ||
2834 | struct ahc_tmode_tstate *tstate; | ||
2835 | struct ahc_initiator_tinfo *tinfo | ||
2836 | = ahc_fetch_transinfo(ahc, | ||
2837 | starget->channel + 'A', | ||
2838 | shost->this_id, starget->id, &tstate); | ||
2839 | spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ; | ||
2840 | } | ||
2841 | |||
2842 | static void ahc_linux_set_iu(struct scsi_target *starget, int iu) | 2664 | static void ahc_linux_set_iu(struct scsi_target *starget, int iu) |
2843 | { | 2665 | { |
2844 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 2666 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -2849,9 +2671,9 @@ static void ahc_linux_set_iu(struct scsi_target *starget, int iu) | |||
2849 | starget->channel + 'A', | 2671 | starget->channel + 'A', |
2850 | shost->this_id, starget->id, &tstate); | 2672 | shost->this_id, starget->id, &tstate); |
2851 | struct ahc_devinfo devinfo; | 2673 | struct ahc_devinfo devinfo; |
2852 | unsigned int ppr_options = tinfo->curr.ppr_options | 2674 | unsigned int ppr_options = tinfo->goal.ppr_options |
2853 | & ~MSG_EXT_PPR_IU_REQ; | 2675 | & ~MSG_EXT_PPR_IU_REQ; |
2854 | unsigned int period = tinfo->curr.period; | 2676 | unsigned int period = tinfo->goal.period; |
2855 | unsigned long flags; | 2677 | unsigned long flags; |
2856 | struct ahc_syncrate *syncrate; | 2678 | struct ahc_syncrate *syncrate; |
2857 | 2679 | ||
@@ -2862,28 +2684,22 @@ static void ahc_linux_set_iu(struct scsi_target *starget, int iu) | |||
2862 | starget->channel + 'A', ROLE_INITIATOR); | 2684 | starget->channel + 'A', ROLE_INITIATOR); |
2863 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); | 2685 | syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); |
2864 | ahc_lock(ahc, &flags); | 2686 | ahc_lock(ahc, &flags); |
2865 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, | 2687 | ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->goal.offset, |
2866 | ppr_options, AHC_TRANS_GOAL, FALSE); | 2688 | ppr_options, AHC_TRANS_GOAL, FALSE); |
2867 | ahc_unlock(ahc, &flags); | 2689 | ahc_unlock(ahc, &flags); |
2868 | } | 2690 | } |
2869 | 2691 | ||
2870 | static struct spi_function_template ahc_linux_transport_functions = { | 2692 | static struct spi_function_template ahc_linux_transport_functions = { |
2871 | .get_offset = ahc_linux_get_offset, | ||
2872 | .set_offset = ahc_linux_set_offset, | 2693 | .set_offset = ahc_linux_set_offset, |
2873 | .show_offset = 1, | 2694 | .show_offset = 1, |
2874 | .get_period = ahc_linux_get_period, | ||
2875 | .set_period = ahc_linux_set_period, | 2695 | .set_period = ahc_linux_set_period, |
2876 | .show_period = 1, | 2696 | .show_period = 1, |
2877 | .get_width = ahc_linux_get_width, | ||
2878 | .set_width = ahc_linux_set_width, | 2697 | .set_width = ahc_linux_set_width, |
2879 | .show_width = 1, | 2698 | .show_width = 1, |
2880 | .get_dt = ahc_linux_get_dt, | ||
2881 | .set_dt = ahc_linux_set_dt, | 2699 | .set_dt = ahc_linux_set_dt, |
2882 | .show_dt = 1, | 2700 | .show_dt = 1, |
2883 | .get_iu = ahc_linux_get_iu, | ||
2884 | .set_iu = ahc_linux_set_iu, | 2701 | .set_iu = ahc_linux_set_iu, |
2885 | .show_iu = 1, | 2702 | .show_iu = 1, |
2886 | .get_qas = ahc_linux_get_qas, | ||
2887 | .set_qas = ahc_linux_set_qas, | 2703 | .set_qas = ahc_linux_set_qas, |
2888 | .show_qas = 1, | 2704 | .show_qas = 1, |
2889 | }; | 2705 | }; |
@@ -2896,6 +2712,10 @@ ahc_linux_init(void) | |||
2896 | ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); | 2712 | ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); |
2897 | if (!ahc_linux_transport_template) | 2713 | if (!ahc_linux_transport_template) |
2898 | return -ENODEV; | 2714 | return -ENODEV; |
2715 | scsi_transport_reserve_target(ahc_linux_transport_template, | ||
2716 | sizeof(struct ahc_linux_target)); | ||
2717 | scsi_transport_reserve_device(ahc_linux_transport_template, | ||
2718 | sizeof(struct ahc_linux_device)); | ||
2899 | if (ahc_linux_detect(&aic7xxx_driver_template)) | 2719 | if (ahc_linux_detect(&aic7xxx_driver_template)) |
2900 | return 0; | 2720 | return 0; |
2901 | spi_release_transport(ahc_linux_transport_template); | 2721 | spi_release_transport(ahc_linux_transport_template); |