Automatic merge of rsync://www.parisc-linux.org/~jejb/git/scsi-for-linus-2.6.git

+548 -1328
+1 -51
drivers/scsi/aic7xxx/aic7770_osm.c
··· 41 42 #include "aic7xxx_osm.h" 43 44 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 45 #include <linux/device.h> 46 #include <linux/eisa.h> 47 ··· 61 }; 62 63 typedef struct device *aic7770_dev_t; 64 - #else 65 - #define MINSLOT 1 66 - #define NUMSLOTS 16 67 - #define IDOFFSET 0x80 68 - 69 - typedef void *aic7770_dev_t; 70 - #endif 71 72 static int aic7770_linux_config(struct aic7770_identity *entry, 73 aic7770_dev_t dev, u_int eisaBase); ··· 68 int 69 ahc_linux_eisa_init(void) 70 { 71 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 72 struct eisa_device_id *eid; 73 struct aic7770_identity *id; 74 int i; ··· 101 eid->sig[0] = 0; 102 103 return eisa_driver_register(&aic7770_driver); 104 - #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */ 105 - struct aic7770_identity *entry; 106 - u_int slot; 107 - u_int eisaBase; 108 - u_int i; 109 - int ret = -ENODEV; 110 - 111 - if (aic7xxx_probe_eisa_vl == 0) 112 - return ret; 113 - 114 - eisaBase = 0x1000 + AHC_EISA_SLOT_OFFSET; 115 - for (slot = 1; slot < NUMSLOTS; eisaBase+=0x1000, slot++) { 116 - uint32_t eisa_id; 117 - size_t id_size; 118 - 119 - if (request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx") == 0) 120 - continue; 121 - 122 - eisa_id = 0; 123 - id_size = sizeof(eisa_id); 124 - for (i = 0; i < 4; i++) { 125 - /* VLcards require priming*/ 126 - outb(0x80 + i, eisaBase + IDOFFSET); 127 - eisa_id |= inb(eisaBase + IDOFFSET + i) 128 - << ((id_size-i-1) * 8); 129 - } 130 - release_region(eisaBase, AHC_EISA_IOSIZE); 131 - if (eisa_id & 0x80000000) 132 - continue; /* no EISA card in slot */ 133 - 134 - entry = aic7770_find_device(eisa_id); 135 - if (entry != NULL) { 136 - aic7770_linux_config(entry, NULL, eisaBase); 137 - ret = 0; 138 - } 139 - } 140 - return ret; 141 - #endif 142 } 143 144 void ··· 140 ahc_free(ahc); 141 return (error); 142 } 143 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 144 dev->driver_data = (void *)ahc; 145 if (aic7xxx_detect_complete) 146 error = ahc_linux_register_host(ahc, &aic7xxx_driver_template); 147 - #endif 148 return (error); 149 } 150 ··· 177 return (-error); 178 } 179 180 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 181 static int 182 aic7770_eisa_dev_probe(struct device *dev) 183 { ··· 212 213 return (0); 214 } 215 - #endif
··· 41 42 #include "aic7xxx_osm.h" 43 44 #include <linux/device.h> 45 #include <linux/eisa.h> 46 ··· 62 }; 63 64 typedef struct device *aic7770_dev_t; 65 66 static int aic7770_linux_config(struct aic7770_identity *entry, 67 aic7770_dev_t dev, u_int eisaBase); ··· 76 int 77 ahc_linux_eisa_init(void) 78 { 79 struct eisa_device_id *eid; 80 struct aic7770_identity *id; 81 int i; ··· 110 eid->sig[0] = 0; 111 112 return eisa_driver_register(&aic7770_driver); 113 } 114 115 void ··· 187 ahc_free(ahc); 188 return (error); 189 } 190 + 191 dev->driver_data = (void *)ahc; 192 if (aic7xxx_detect_complete) 193 error = ahc_linux_register_host(ahc, &aic7xxx_driver_template); 194 return (error); 195 } 196 ··· 225 return (-error); 226 } 227 228 static int 229 aic7770_eisa_dev_probe(struct device *dev) 230 { ··· 261 262 return (0); 263 }
+354 -1082
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 134 #include "aiclib.c" 135 136 #include <linux/init.h> /* __setup */ 137 - 138 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 139 - #include "sd.h" /* For geometry detection */ 140 - #endif 141 - 142 #include <linux/mm.h> /* For fetching system memory size */ 143 #include <linux/blkdev.h> /* For block_size() */ 144 #include <linux/delay.h> /* For ssleep/msleep */ ··· 142 * Lock protecting manipulation of the ahc softc list. 143 */ 144 spinlock_t ahc_list_spinlock; 145 - 146 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 147 - /* For dynamic sglist size calculation. */ 148 - u_int ahc_linux_nseg; 149 - #endif 150 151 /* 152 * Set this to the delay in seconds after SCSI bus reset. ··· 426 struct ahc_linux_device *, 427 struct scb *); 428 static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, 429 - Scsi_Cmnd *cmd); 430 static void ahc_linux_sem_timeout(u_long arg); 431 static void ahc_linux_freeze_simq(struct ahc_softc *ahc); 432 static void ahc_linux_release_simq(u_long arg); 433 - static void ahc_linux_dev_timed_unfreeze(u_long arg); 434 - static int ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag); 435 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 436 - static void ahc_linux_size_nseg(void); 437 - static void ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc); 438 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 439 struct ahc_devinfo *devinfo); 440 static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, ··· 445 u_int); 446 static void ahc_linux_free_device(struct ahc_softc*, 447 struct ahc_linux_device*); 448 - static void ahc_linux_run_device_queue(struct ahc_softc*, 449 - struct ahc_linux_device*); 450 static void ahc_linux_setup_tag_info_global(char *p); 451 static aic_option_callback_t ahc_linux_setup_tag_info; 452 static int aic7xxx_setup(char *s); 453 static int ahc_linux_next_unit(void); 454 - static void ahc_runq_tasklet(unsigned long data); 455 - static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc); 456 457 /********************************* Inlines ************************************/ 458 - static __inline void ahc_schedule_runq(struct ahc_softc *ahc); 459 static __inline struct ahc_linux_device* 460 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, 461 - u_int target, u_int lun, int alloc); 462 - static __inline void ahc_schedule_completeq(struct ahc_softc *ahc); 463 - static __inline void ahc_linux_check_device_queue(struct ahc_softc *ahc, 464 - struct ahc_linux_device *dev); 465 - static __inline struct ahc_linux_device * 466 - ahc_linux_next_device_to_run(struct ahc_softc *ahc); 467 - static __inline void ahc_linux_run_device_queues(struct ahc_softc *ahc); 468 static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 469 470 static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 471 struct ahc_dma_seg *sg, 472 dma_addr_t addr, bus_size_t len); 473 474 - static __inline void 475 - ahc_schedule_completeq(struct ahc_softc *ahc) 476 - { 477 - if ((ahc->platform_data->flags & AHC_RUN_CMPLT_Q_TIMER) == 0) { 478 - ahc->platform_data->flags |= AHC_RUN_CMPLT_Q_TIMER; 479 - ahc->platform_data->completeq_timer.expires = jiffies; 480 - add_timer(&ahc->platform_data->completeq_timer); 481 - } 482 - } 483 - 484 - /* 485 - * Must be called with our lock held. 486 - */ 487 - static __inline void 488 - ahc_schedule_runq(struct ahc_softc *ahc) 489 - { 490 - tasklet_schedule(&ahc->platform_data->runq_tasklet); 491 - } 492 - 493 static __inline struct ahc_linux_device* 494 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, 495 - u_int lun, int alloc) 496 { 497 struct ahc_linux_target *targ; 498 struct ahc_linux_device *dev; ··· 475 if (channel != 0) 476 target_offset += 8; 477 targ = ahc->platform_data->targets[target_offset]; 478 - if (targ == NULL) { 479 - if (alloc != 0) { 480 - targ = ahc_linux_alloc_target(ahc, channel, target); 481 - if (targ == NULL) 482 - return (NULL); 483 - } else 484 - return (NULL); 485 - } 486 dev = targ->devices[lun]; 487 - if (dev == NULL && alloc != 0) 488 - dev = ahc_linux_alloc_device(ahc, targ, lun); 489 - return (dev); 490 - } 491 - 492 - #define AHC_LINUX_MAX_RETURNED_ERRORS 4 493 - static struct ahc_cmd * 494 - ahc_linux_run_complete_queue(struct ahc_softc *ahc) 495 - { 496 - struct ahc_cmd *acmd; 497 - u_long done_flags; 498 - int with_errors; 499 - 500 - with_errors = 0; 501 - ahc_done_lock(ahc, &done_flags); 502 - while ((acmd = TAILQ_FIRST(&ahc->platform_data->completeq)) != NULL) { 503 - Scsi_Cmnd *cmd; 504 - 505 - if (with_errors > AHC_LINUX_MAX_RETURNED_ERRORS) { 506 - /* 507 - * Linux uses stack recursion to requeue 508 - * commands that need to be retried. Avoid 509 - * blowing out the stack by "spoon feeding" 510 - * commands that completed with error back 511 - * the operating system in case they are going 512 - * to be retried. "ick" 513 - */ 514 - ahc_schedule_completeq(ahc); 515 - break; 516 - } 517 - TAILQ_REMOVE(&ahc->platform_data->completeq, 518 - acmd, acmd_links.tqe); 519 - cmd = &acmd_scsi_cmd(acmd); 520 - cmd->host_scribble = NULL; 521 - if (ahc_cmd_get_transaction_status(cmd) != DID_OK 522 - || (cmd->result & 0xFF) != SCSI_STATUS_OK) 523 - with_errors++; 524 - 525 - cmd->scsi_done(cmd); 526 - } 527 - ahc_done_unlock(ahc, &done_flags); 528 - return (acmd); 529 - } 530 - 531 - static __inline void 532 - ahc_linux_check_device_queue(struct ahc_softc *ahc, 533 - struct ahc_linux_device *dev) 534 - { 535 - if ((dev->flags & AHC_DEV_FREEZE_TIL_EMPTY) != 0 536 - && dev->active == 0) { 537 - dev->flags &= ~AHC_DEV_FREEZE_TIL_EMPTY; 538 - dev->qfrozen--; 539 - } 540 - 541 - if (TAILQ_FIRST(&dev->busyq) == NULL 542 - || dev->openings == 0 || dev->qfrozen != 0) 543 - return; 544 - 545 - ahc_linux_run_device_queue(ahc, dev); 546 - } 547 - 548 - static __inline struct ahc_linux_device * 549 - ahc_linux_next_device_to_run(struct ahc_softc *ahc) 550 - { 551 - 552 - if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0 553 - || (ahc->platform_data->qfrozen != 0)) 554 - return (NULL); 555 - return (TAILQ_FIRST(&ahc->platform_data->device_runq)); 556 - } 557 - 558 - static __inline void 559 - ahc_linux_run_device_queues(struct ahc_softc *ahc) 560 - { 561 - struct ahc_linux_device *dev; 562 - 563 - while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) { 564 - TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links); 565 - dev->flags &= ~AHC_DEV_ON_RUN_LIST; 566 - ahc_linux_check_device_queue(ahc, dev); 567 - } 568 } 569 570 static __inline void 571 ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) 572 { 573 - Scsi_Cmnd *cmd; 574 575 cmd = scb->io_ctx; 576 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE); ··· 523 return (consumed); 524 } 525 526 - /************************ Host template entry points *************************/ 527 - static int ahc_linux_detect(Scsi_Host_Template *); 528 - static int ahc_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *)); 529 - static const char *ahc_linux_info(struct Scsi_Host *); 530 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 531 - static int ahc_linux_slave_alloc(Scsi_Device *); 532 - static int ahc_linux_slave_configure(Scsi_Device *); 533 - static void ahc_linux_slave_destroy(Scsi_Device *); 534 - #if defined(__i386__) 535 - static int ahc_linux_biosparam(struct scsi_device*, 536 - struct block_device*, 537 - sector_t, int[]); 538 - #endif 539 - #else 540 - static int ahc_linux_release(struct Scsi_Host *); 541 - static void ahc_linux_select_queue_depth(struct Scsi_Host *host, 542 - Scsi_Device *scsi_devs); 543 - #if defined(__i386__) 544 - static int ahc_linux_biosparam(Disk *, kdev_t, int[]); 545 - #endif 546 - #endif 547 - static int ahc_linux_bus_reset(Scsi_Cmnd *); 548 - static int ahc_linux_dev_reset(Scsi_Cmnd *); 549 - static int ahc_linux_abort(Scsi_Cmnd *); 550 - 551 - /* 552 - * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg). 553 - * 554 - * In pre-2.5.X... 555 - * The midlayer allocates an S/G array dynamically when a command is issued 556 - * using SCSI malloc. This array, which is in an OS dependent format that 557 - * must later be copied to our private S/G list, is sized to house just the 558 - * number of segments needed for the current transfer. Since the code that 559 - * sizes the SCSI malloc pool does not take into consideration fragmentation 560 - * of the pool, executing transactions numbering just a fraction of our 561 - * concurrent transaction limit with list lengths aproaching AHC_NSEG will 562 - * quickly depleat the SCSI malloc pool of usable space. Unfortunately, the 563 - * mid-layer does not properly handle this scsi malloc failures for the S/G 564 - * array and the result can be a lockup of the I/O subsystem. We try to size 565 - * our S/G list so that it satisfies our drivers allocation requirements in 566 - * addition to avoiding fragmentation of the SCSI malloc pool. 567 - */ 568 - static void 569 - ahc_linux_size_nseg(void) 570 - { 571 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 572 - u_int cur_size; 573 - u_int best_size; 574 - 575 - /* 576 - * The SCSI allocator rounds to the nearest 512 bytes 577 - * an cannot allocate across a page boundary. Our algorithm 578 - * is to start at 1K of scsi malloc space per-command and 579 - * loop through all factors of the PAGE_SIZE and pick the best. 580 - */ 581 - best_size = 0; 582 - for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) { 583 - u_int nseg; 584 - 585 - nseg = cur_size / sizeof(struct scatterlist); 586 - if (nseg < AHC_LINUX_MIN_NSEG) 587 - continue; 588 - 589 - if (best_size == 0) { 590 - best_size = cur_size; 591 - ahc_linux_nseg = nseg; 592 - } else { 593 - u_int best_rem; 594 - u_int cur_rem; 595 - 596 - /* 597 - * Compare the traits of the current "best_size" 598 - * with the current size to determine if the 599 - * current size is a better size. 600 - */ 601 - best_rem = best_size % sizeof(struct scatterlist); 602 - cur_rem = cur_size % sizeof(struct scatterlist); 603 - if (cur_rem < best_rem) { 604 - best_size = cur_size; 605 - ahc_linux_nseg = nseg; 606 - } 607 - } 608 - } 609 - #endif 610 - } 611 - 612 /* 613 * Try to detect an Adaptec 7XXX controller. 614 */ 615 static int 616 - ahc_linux_detect(Scsi_Host_Template *template) 617 { 618 struct ahc_softc *ahc; 619 int found = 0; 620 - 621 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 622 - /* 623 - * It is a bug that the upper layer takes 624 - * this lock just prior to calling us. 625 - */ 626 - spin_unlock_irq(&io_request_lock); 627 - #endif 628 629 /* 630 * Sanity checking of Linux SCSI data structures so ··· 543 printf("ahc_linux_detect: Unable to attach\n"); 544 return (0); 545 } 546 - ahc_linux_size_nseg(); 547 /* 548 * If we've been passed any parameters, process them now. 549 */ ··· 571 found++; 572 } 573 574 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 575 - spin_lock_irq(&io_request_lock); 576 - #endif 577 aic7xxx_detect_complete++; 578 579 return (found); 580 } 581 - 582 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 583 - /* 584 - * Free the passed in Scsi_Host memory structures prior to unloading the 585 - * module. 586 - */ 587 - int 588 - ahc_linux_release(struct Scsi_Host * host) 589 - { 590 - struct ahc_softc *ahc; 591 - u_long l; 592 - 593 - ahc_list_lock(&l); 594 - if (host != NULL) { 595 - 596 - /* 597 - * We should be able to just perform 598 - * the free directly, but check our 599 - * list for extra sanity. 600 - */ 601 - ahc = ahc_find_softc(*(struct ahc_softc **)host->hostdata); 602 - if (ahc != NULL) { 603 - u_long s; 604 - 605 - ahc_lock(ahc, &s); 606 - ahc_intr_enable(ahc, FALSE); 607 - ahc_unlock(ahc, &s); 608 - ahc_free(ahc); 609 - } 610 - } 611 - ahc_list_unlock(&l); 612 - return (0); 613 - } 614 - #endif 615 616 /* 617 * Return a string describing the driver. ··· 608 * Queue an SCB to the controller. 609 */ 610 static int 611 - ahc_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) 612 { 613 struct ahc_softc *ahc; 614 struct ahc_linux_device *dev; 615 - u_long flags; 616 617 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 618 ··· 620 */ 621 cmd->scsi_done = scsi_done; 622 623 - ahc_midlayer_entrypoint_lock(ahc, &flags); 624 - 625 /* 626 * Close the race of a command that was in the process of 627 * being queued to us just as our simq was frozen. Let 628 * DV commands through so long as we are only frozen to 629 * perform DV. 630 */ 631 - if (ahc->platform_data->qfrozen != 0) { 632 633 - ahc_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ); 634 - ahc_linux_queue_cmd_complete(ahc, cmd); 635 - ahc_schedule_completeq(ahc); 636 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 637 - return (0); 638 - } 639 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 640 - cmd->device->lun, /*alloc*/TRUE); 641 - if (dev == NULL) { 642 - ahc_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL); 643 - ahc_linux_queue_cmd_complete(ahc, cmd); 644 - ahc_schedule_completeq(ahc); 645 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 646 - printf("%s: aic7xxx_linux_queue - Unable to allocate device!\n", 647 - ahc_name(ahc)); 648 - return (0); 649 - } 650 cmd->result = CAM_REQ_INPROG << 16; 651 - TAILQ_INSERT_TAIL(&dev->busyq, (struct ahc_cmd *)cmd, acmd_links.tqe); 652 - if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) { 653 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links); 654 - dev->flags |= AHC_DEV_ON_RUN_LIST; 655 - ahc_linux_run_device_queues(ahc); 656 - } 657 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 658 - return (0); 659 } 660 661 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 662 static int 663 - ahc_linux_slave_alloc(Scsi_Device *device) 664 { 665 struct ahc_softc *ahc; 666 667 ahc = *((struct ahc_softc **)device->host->hostdata); 668 if (bootverbose) 669 printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id); 670 - return (0); 671 } 672 673 static int 674 - ahc_linux_slave_configure(Scsi_Device *device) 675 { 676 struct ahc_softc *ahc; 677 struct ahc_linux_device *dev; 678 - u_long flags; 679 680 ahc = *((struct ahc_softc **)device->host->hostdata); 681 if (bootverbose) 682 printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id); 683 - ahc_midlayer_entrypoint_lock(ahc, &flags); 684 - /* 685 - * Since Linux has attached to the device, configure 686 - * it so we don't free and allocate the device 687 - * structure on every command. 688 - */ 689 - dev = ahc_linux_get_device(ahc, device->channel, 690 - device->id, device->lun, 691 - /*alloc*/TRUE); 692 - if (dev != NULL) { 693 - dev->flags &= ~AHC_DEV_UNCONFIGURED; 694 - dev->scsi_device = device; 695 - ahc_linux_device_queue_depth(ahc, dev); 696 - } 697 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 698 699 /* Initial Domain Validation */ 700 if (!spi_initial_dv(device->sdev_target)) 701 spi_dv_device(device); 702 703 - return (0); 704 } 705 706 static void 707 - ahc_linux_slave_destroy(Scsi_Device *device) 708 { 709 struct ahc_softc *ahc; 710 struct ahc_linux_device *dev; 711 - u_long flags; 712 713 ahc = *((struct ahc_softc **)device->host->hostdata); 714 if (bootverbose) 715 printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id); 716 - ahc_midlayer_entrypoint_lock(ahc, &flags); 717 dev = ahc_linux_get_device(ahc, device->channel, 718 - device->id, device->lun, 719 - /*alloc*/FALSE); 720 - /* 721 - * Filter out "silly" deletions of real devices by only 722 - * deleting devices that have had slave_configure() 723 - * called on them. All other devices that have not 724 - * been configured will automatically be deleted by 725 - * the refcounting process. 726 - */ 727 - if (dev != NULL 728 - && (dev->flags & AHC_DEV_SLAVE_CONFIGURED) != 0) { 729 - dev->flags |= AHC_DEV_UNCONFIGURED; 730 - if (TAILQ_EMPTY(&dev->busyq) 731 - && dev->active == 0 732 - && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0) 733 - ahc_linux_free_device(ahc, dev); 734 - } 735 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 736 } 737 - #else 738 - /* 739 - * Sets the queue depth for each SCSI device hanging 740 - * off the input host adapter. 741 - */ 742 - static void 743 - ahc_linux_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs) 744 - { 745 - Scsi_Device *device; 746 - Scsi_Device *ldev; 747 - struct ahc_softc *ahc; 748 - u_long flags; 749 - 750 - ahc = *((struct ahc_softc **)host->hostdata); 751 - ahc_lock(ahc, &flags); 752 - for (device = scsi_devs; device != NULL; device = device->next) { 753 - 754 - /* 755 - * Watch out for duplicate devices. This works around 756 - * some quirks in how the SCSI scanning code does its 757 - * device management. 758 - */ 759 - for (ldev = scsi_devs; ldev != device; ldev = ldev->next) { 760 - if (ldev->host == device->host 761 - && ldev->channel == device->channel 762 - && ldev->id == device->id 763 - && ldev->lun == device->lun) 764 - break; 765 - } 766 - /* Skip duplicate. */ 767 - if (ldev != device) 768 - continue; 769 - 770 - if (device->host == host) { 771 - struct ahc_linux_device *dev; 772 - 773 - /* 774 - * Since Linux has attached to the device, configure 775 - * it so we don't free and allocate the device 776 - * structure on every command. 777 - */ 778 - dev = ahc_linux_get_device(ahc, device->channel, 779 - device->id, device->lun, 780 - /*alloc*/TRUE); 781 - if (dev != NULL) { 782 - dev->flags &= ~AHC_DEV_UNCONFIGURED; 783 - dev->scsi_device = device; 784 - ahc_linux_device_queue_depth(ahc, dev); 785 - device->queue_depth = dev->openings 786 - + dev->active; 787 - if ((dev->flags & (AHC_DEV_Q_BASIC 788 - | AHC_DEV_Q_TAGGED)) == 0) { 789 - /* 790 - * We allow the OS to queue 2 untagged 791 - * transactions to us at any time even 792 - * though we can only execute them 793 - * serially on the controller/device. 794 - * This should remove some latency. 795 - */ 796 - device->queue_depth = 2; 797 - } 798 - } 799 - } 800 - } 801 - ahc_unlock(ahc, &flags); 802 - } 803 - #endif 804 805 #if defined(__i386__) 806 /* 807 * Return the disk geometry for the given SCSI device. 808 */ 809 static int 810 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 811 ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, 812 sector_t capacity, int geom[]) 813 { 814 uint8_t *bh; 815 - #else 816 - ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[]) 817 - { 818 - struct scsi_device *sdev = disk->device; 819 - u_long capacity = disk->capacity; 820 - struct buffer_head *bh; 821 - #endif 822 int heads; 823 int sectors; 824 int cylinders; ··· 774 ahc = *((struct ahc_softc **)sdev->host->hostdata); 775 channel = sdev->channel; 776 777 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 778 bh = scsi_bios_ptable(bdev); 779 - #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17) 780 - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev)); 781 - #else 782 - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024); 783 - #endif 784 - 785 if (bh) { 786 ret = scsi_partsize(bh, capacity, 787 &geom[2], &geom[0], &geom[1]); 788 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 789 kfree(bh); 790 - #else 791 - brelse(bh); 792 - #endif 793 if (ret != -1) 794 return (ret); 795 } ··· 808 * Abort the current SCSI command(s). 809 */ 810 static int 811 - ahc_linux_abort(Scsi_Cmnd *cmd) 812 { 813 int error; 814 ··· 822 * Attempt to send a target reset message to the device that timed out. 823 */ 824 static int 825 - ahc_linux_dev_reset(Scsi_Cmnd *cmd) 826 { 827 int error; 828 ··· 836 * Reset the SCSI bus. 837 */ 838 static int 839 - ahc_linux_bus_reset(Scsi_Cmnd *cmd) 840 { 841 struct ahc_softc *ahc; 842 - u_long s; 843 int found; 844 845 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 846 - ahc_midlayer_entrypoint_lock(ahc, &s); 847 found = ahc_reset_channel(ahc, cmd->device->channel + 'A', 848 /*initiate reset*/TRUE); 849 - ahc_linux_run_complete_queue(ahc); 850 - ahc_midlayer_entrypoint_unlock(ahc, &s); 851 852 if (bootverbose) 853 printf("%s: SCSI bus reset delivered. " ··· 852 return SUCCESS; 853 } 854 855 - Scsi_Host_Template aic7xxx_driver_template = { 856 .module = THIS_MODULE, 857 .name = "aic7xxx", 858 .proc_info = ahc_linux_proc_info, ··· 874 }; 875 876 /**************************** Tasklet Handler *********************************/ 877 - 878 - /* 879 - * In 2.4.X and above, this routine is called from a tasklet, 880 - * so we must re-acquire our lock prior to executing this code. 881 - * In all prior kernels, ahc_schedule_runq() calls this routine 882 - * directly and ahc_schedule_runq() is called with our lock held. 883 - */ 884 - static void 885 - ahc_runq_tasklet(unsigned long data) 886 - { 887 - struct ahc_softc* ahc; 888 - struct ahc_linux_device *dev; 889 - u_long flags; 890 - 891 - ahc = (struct ahc_softc *)data; 892 - ahc_lock(ahc, &flags); 893 - while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) { 894 - 895 - TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links); 896 - dev->flags &= ~AHC_DEV_ON_RUN_LIST; 897 - ahc_linux_check_device_queue(ahc, dev); 898 - /* Yeild to our interrupt handler */ 899 - ahc_unlock(ahc, &flags); 900 - ahc_lock(ahc, &flags); 901 - } 902 - ahc_unlock(ahc, &flags); 903 - } 904 905 /******************************** Macros **************************************/ 906 #define BUILD_SCSIID(ahc, cmd) \ ··· 920 ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, 921 int flags, bus_dmamap_t *mapp) 922 { 923 - bus_dmamap_t map; 924 - 925 - map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT); 926 - if (map == NULL) 927 - return (ENOMEM); 928 - /* 929 - * Although we can dma data above 4GB, our 930 - * "consistent" memory is below 4GB for 931 - * space efficiency reasons (only need a 4byte 932 - * address). For this reason, we have to reset 933 - * our dma mask when doing allocations. 934 - */ 935 - if (ahc->dev_softc != NULL) 936 - if (pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) { 937 - printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 938 - kfree(map); 939 - return (ENODEV); 940 - } 941 *vaddr = pci_alloc_consistent(ahc->dev_softc, 942 - dmat->maxsize, &map->bus_addr); 943 - if (ahc->dev_softc != NULL) 944 - if (pci_set_dma_mask(ahc->dev_softc, 945 - ahc->platform_data->hw_dma_mask)) { 946 - printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 947 - kfree(map); 948 - return (ENODEV); 949 - } 950 if (*vaddr == NULL) 951 - return (ENOMEM); 952 - *mapp = map; 953 - return(0); 954 } 955 956 void ··· 932 void* vaddr, bus_dmamap_t map) 933 { 934 pci_free_consistent(ahc->dev_softc, dmat->maxsize, 935 - vaddr, map->bus_addr); 936 } 937 938 int ··· 946 */ 947 bus_dma_segment_t stack_sg; 948 949 - stack_sg.ds_addr = map->bus_addr; 950 stack_sg.ds_len = dmat->maxsize; 951 cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); 952 return (0); ··· 955 void 956 ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map) 957 { 958 - /* 959 - * The map may is NULL in our < 2.3.X implementation. 960 - * Now it's 2.6.5, but just in case... 961 - */ 962 - BUG_ON(map == NULL); 963 - free(map, M_DEVBUF); 964 } 965 966 int ··· 1160 uint32_t aic7xxx_verbose; 1161 1162 int 1163 - ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template) 1164 { 1165 char buf[80]; 1166 struct Scsi_Host *host; ··· 1174 1175 *((struct ahc_softc **)host->hostdata) = ahc; 1176 ahc_lock(ahc, &s); 1177 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1178 scsi_assign_lock(host, &ahc->platform_data->spin_lock); 1179 - #elif AHC_SCSI_HAS_HOST_LOCK != 0 1180 - host->lock = &ahc->platform_data->spin_lock; 1181 - #endif 1182 ahc->platform_data->host = host; 1183 host->can_queue = AHC_MAX_QUEUE; 1184 host->cmd_per_lun = 2; ··· 1193 ahc_set_name(ahc, new_name); 1194 } 1195 host->unique_id = ahc->unit; 1196 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 1197 - scsi_set_pci_device(host, ahc->dev_softc); 1198 - #endif 1199 ahc_linux_initialize_scsi_bus(ahc); 1200 ahc_intr_enable(ahc, TRUE); 1201 ahc_unlock(ahc, &s); 1202 1203 host->transportt = ahc_linux_transport_template; 1204 1205 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1206 scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */ 1207 scsi_scan_host(host); 1208 - #endif 1209 return (0); 1210 } 1211 ··· 1318 if (ahc->platform_data == NULL) 1319 return (ENOMEM); 1320 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); 1321 - TAILQ_INIT(&ahc->platform_data->completeq); 1322 - TAILQ_INIT(&ahc->platform_data->device_runq); 1323 ahc->platform_data->irq = AHC_LINUX_NOIRQ; 1324 - ahc->platform_data->hw_dma_mask = 0xFFFFFFFF; 1325 ahc_lockinit(ahc); 1326 - ahc_done_lockinit(ahc); 1327 - init_timer(&ahc->platform_data->completeq_timer); 1328 - ahc->platform_data->completeq_timer.data = (u_long)ahc; 1329 - ahc->platform_data->completeq_timer.function = 1330 - (ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue; 1331 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); 1332 - tasklet_init(&ahc->platform_data->runq_tasklet, ahc_runq_tasklet, 1333 - (unsigned long)ahc); 1334 ahc->seltime = (aic7xxx_seltime & 0x3) << 4; 1335 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; 1336 if (aic7xxx_pci_parity == 0) ··· 1337 int i, j; 1338 1339 if (ahc->platform_data != NULL) { 1340 - del_timer_sync(&ahc->platform_data->completeq_timer); 1341 - tasklet_kill(&ahc->platform_data->runq_tasklet); 1342 if (ahc->platform_data->host != NULL) { 1343 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1344 scsi_remove_host(ahc->platform_data->host); 1345 - #endif 1346 scsi_host_put(ahc->platform_data->host); 1347 } 1348 ··· 1374 release_mem_region(ahc->platform_data->mem_busaddr, 1375 0x1000); 1376 } 1377 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 1378 - /* 1379 - * In 2.4 we detach from the scsi midlayer before the PCI 1380 - * layer invokes our remove callback. No per-instance 1381 - * detach is provided, so we must reach inside the PCI 1382 - * subsystem's internals and detach our driver manually. 1383 - */ 1384 - if (ahc->dev_softc != NULL) 1385 - ahc->dev_softc->driver = NULL; 1386 - #endif 1387 free(ahc->platform_data, M_DEVBUF); 1388 } 1389 } ··· 1398 1399 dev = ahc_linux_get_device(ahc, devinfo->channel - 'A', 1400 devinfo->target, 1401 - devinfo->lun, /*alloc*/FALSE); 1402 if (dev == NULL) 1403 return; 1404 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); ··· 1451 dev->maxtags = 0; 1452 dev->openings = 1 - dev->active; 1453 } 1454 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1455 if (dev->scsi_device != NULL) { 1456 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { 1457 case AHC_DEV_Q_BASIC: ··· 1476 break; 1477 } 1478 } 1479 - #endif 1480 } 1481 1482 int 1483 ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel, 1484 int lun, u_int tag, role_t role, uint32_t status) 1485 { 1486 - int chan; 1487 - int maxchan; 1488 - int targ; 1489 - int maxtarg; 1490 - int clun; 1491 - int maxlun; 1492 - int count; 1493 - 1494 - if (tag != SCB_LIST_NULL) 1495 - return (0); 1496 - 1497 - chan = 0; 1498 - if (channel != ALL_CHANNELS) { 1499 - chan = channel - 'A'; 1500 - maxchan = chan + 1; 1501 - } else { 1502 - maxchan = (ahc->features & AHC_TWIN) ? 2 : 1; 1503 - } 1504 - targ = 0; 1505 - if (target != CAM_TARGET_WILDCARD) { 1506 - targ = target; 1507 - maxtarg = targ + 1; 1508 - } else { 1509 - maxtarg = (ahc->features & AHC_WIDE) ? 16 : 8; 1510 - } 1511 - clun = 0; 1512 - if (lun != CAM_LUN_WILDCARD) { 1513 - clun = lun; 1514 - maxlun = clun + 1; 1515 - } else { 1516 - maxlun = AHC_NUM_LUNS; 1517 - } 1518 - 1519 - count = 0; 1520 - for (; chan < maxchan; chan++) { 1521 - 1522 - for (; targ < maxtarg; targ++) { 1523 - 1524 - for (; clun < maxlun; clun++) { 1525 - struct ahc_linux_device *dev; 1526 - struct ahc_busyq *busyq; 1527 - struct ahc_cmd *acmd; 1528 - 1529 - dev = ahc_linux_get_device(ahc, chan, 1530 - targ, clun, 1531 - /*alloc*/FALSE); 1532 - if (dev == NULL) 1533 - continue; 1534 - 1535 - busyq = &dev->busyq; 1536 - while ((acmd = TAILQ_FIRST(busyq)) != NULL) { 1537 - Scsi_Cmnd *cmd; 1538 - 1539 - cmd = &acmd_scsi_cmd(acmd); 1540 - TAILQ_REMOVE(busyq, acmd, 1541 - acmd_links.tqe); 1542 - count++; 1543 - cmd->result = status << 16; 1544 - ahc_linux_queue_cmd_complete(ahc, cmd); 1545 - } 1546 - } 1547 - } 1548 - } 1549 - 1550 - return (count); 1551 - } 1552 - 1553 - static void 1554 - ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc) 1555 - { 1556 - u_long flags; 1557 - 1558 - ahc_lock(ahc, &flags); 1559 - del_timer(&ahc->platform_data->completeq_timer); 1560 - ahc->platform_data->flags &= ~AHC_RUN_CMPLT_Q_TIMER; 1561 - ahc_linux_run_complete_queue(ahc); 1562 - ahc_unlock(ahc, &flags); 1563 } 1564 1565 static u_int ··· 1545 } 1546 } 1547 1548 - static void 1549 - ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1550 { 1551 - struct ahc_cmd *acmd; 1552 - struct scsi_cmnd *cmd; 1553 struct scb *scb; 1554 struct hardware_scb *hscb; 1555 struct ahc_initiator_tinfo *tinfo; 1556 struct ahc_tmode_tstate *tstate; 1557 uint16_t mask; 1558 1559 - if ((dev->flags & AHC_DEV_ON_RUN_LIST) != 0) 1560 - panic("running device on run list"); 1561 1562 - while ((acmd = TAILQ_FIRST(&dev->busyq)) != NULL 1563 - && dev->openings > 0 && dev->qfrozen == 0) { 1564 1565 - /* 1566 - * Schedule us to run later. The only reason we are not 1567 - * running is because the whole controller Q is frozen. 1568 - */ 1569 - if (ahc->platform_data->qfrozen != 0) { 1570 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, 1571 - dev, links); 1572 - dev->flags |= AHC_DEV_ON_RUN_LIST; 1573 - return; 1574 - } 1575 - /* 1576 - * Get an scb to use. 1577 - */ 1578 - if ((scb = ahc_get_scb(ahc)) == NULL) { 1579 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, 1580 - dev, links); 1581 - dev->flags |= AHC_DEV_ON_RUN_LIST; 1582 - ahc->flags |= AHC_RESOURCE_SHORTAGE; 1583 - return; 1584 - } 1585 - TAILQ_REMOVE(&dev->busyq, acmd, acmd_links.tqe); 1586 - cmd = &acmd_scsi_cmd(acmd); 1587 - scb->io_ctx = cmd; 1588 - scb->platform_data->dev = dev; 1589 - hscb = scb->hscb; 1590 - cmd->host_scribble = (char *)scb; 1591 - 1592 - /* 1593 - * Fill out basics of the HSCB. 1594 - */ 1595 - hscb->control = 0; 1596 - hscb->scsiid = BUILD_SCSIID(ahc, cmd); 1597 - hscb->lun = cmd->device->lun; 1598 - mask = SCB_GET_TARGET_MASK(ahc, scb); 1599 - tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb), 1600 - SCB_GET_OUR_ID(scb), 1601 - SCB_GET_TARGET(ahc, scb), &tstate); 1602 - hscb->scsirate = tinfo->scsirate; 1603 - hscb->scsioffset = tinfo->curr.offset; 1604 - if ((tstate->ultraenb & mask) != 0) 1605 - hscb->control |= ULTRAENB; 1606 - 1607 - if ((ahc->user_discenable & mask) != 0) 1608 - hscb->control |= DISCENB; 1609 - 1610 - if ((tstate->auto_negotiate & mask) != 0) { 1611 - scb->flags |= SCB_AUTO_NEGOTIATE; 1612 - scb->hscb->control |= MK_MESSAGE; 1613 - } 1614 - 1615 - if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) { 1616 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1617 - int msg_bytes; 1618 - uint8_t tag_msgs[2]; 1619 - 1620 - msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); 1621 - if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { 1622 - hscb->control |= tag_msgs[0]; 1623 - if (tag_msgs[0] == MSG_ORDERED_TASK) 1624 - dev->commands_since_idle_or_otag = 0; 1625 - } else 1626 - #endif 1627 - if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH 1628 - && (dev->flags & AHC_DEV_Q_TAGGED) != 0) { 1629 - hscb->control |= MSG_ORDERED_TASK; 1630 - dev->commands_since_idle_or_otag = 0; 1631 - } else { 1632 - hscb->control |= MSG_SIMPLE_TASK; 1633 - } 1634 - } 1635 - 1636 - hscb->cdb_len = cmd->cmd_len; 1637 - if (hscb->cdb_len <= 12) { 1638 - memcpy(hscb->shared_data.cdb, cmd->cmnd, hscb->cdb_len); 1639 - } else { 1640 - memcpy(hscb->cdb32, cmd->cmnd, hscb->cdb_len); 1641 - scb->flags |= SCB_CDB32_PTR; 1642 - } 1643 - 1644 - scb->platform_data->xfer_len = 0; 1645 - ahc_set_residual(scb, 0); 1646 - ahc_set_sense_residual(scb, 0); 1647 - scb->sg_count = 0; 1648 - if (cmd->use_sg != 0) { 1649 - struct ahc_dma_seg *sg; 1650 - struct scatterlist *cur_seg; 1651 - struct scatterlist *end_seg; 1652 - int nseg; 1653 - 1654 - cur_seg = (struct scatterlist *)cmd->request_buffer; 1655 - nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg, 1656 - cmd->sc_data_direction); 1657 - end_seg = cur_seg + nseg; 1658 - /* Copy the segments into the SG list. */ 1659 - sg = scb->sg_list; 1660 - /* 1661 - * The sg_count may be larger than nseg if 1662 - * a transfer crosses a 32bit page. 1663 - */ 1664 - while (cur_seg < end_seg) { 1665 - dma_addr_t addr; 1666 - bus_size_t len; 1667 - int consumed; 1668 - 1669 - addr = sg_dma_address(cur_seg); 1670 - len = sg_dma_len(cur_seg); 1671 - consumed = ahc_linux_map_seg(ahc, scb, 1672 - sg, addr, len); 1673 - sg += consumed; 1674 - scb->sg_count += consumed; 1675 - cur_seg++; 1676 - } 1677 - sg--; 1678 - sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 1679 - 1680 - /* 1681 - * Reset the sg list pointer. 1682 - */ 1683 - scb->hscb->sgptr = 1684 - ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 1685 - 1686 - /* 1687 - * Copy the first SG into the "current" 1688 - * data pointer area. 1689 - */ 1690 - scb->hscb->dataptr = scb->sg_list->addr; 1691 - scb->hscb->datacnt = scb->sg_list->len; 1692 - } else if (cmd->request_bufflen != 0) { 1693 - struct ahc_dma_seg *sg; 1694 - dma_addr_t addr; 1695 - 1696 - sg = scb->sg_list; 1697 - addr = pci_map_single(ahc->dev_softc, 1698 - cmd->request_buffer, 1699 - cmd->request_bufflen, 1700 - cmd->sc_data_direction); 1701 - scb->platform_data->buf_busaddr = addr; 1702 - scb->sg_count = ahc_linux_map_seg(ahc, scb, 1703 - sg, addr, 1704 - cmd->request_bufflen); 1705 - sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 1706 - 1707 - /* 1708 - * Reset the sg list pointer. 1709 - */ 1710 - scb->hscb->sgptr = 1711 - ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 1712 - 1713 - /* 1714 - * Copy the first SG into the "current" 1715 - * data pointer area. 1716 - */ 1717 - scb->hscb->dataptr = sg->addr; 1718 - scb->hscb->datacnt = sg->len; 1719 - } else { 1720 - scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL); 1721 - scb->hscb->dataptr = 0; 1722 - scb->hscb->datacnt = 0; 1723 - scb->sg_count = 0; 1724 - } 1725 - 1726 - ahc_sync_sglist(ahc, scb, BUS_DMASYNC_PREWRITE); 1727 - LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links); 1728 - dev->openings--; 1729 - dev->active++; 1730 - dev->commands_issued++; 1731 - if ((dev->flags & AHC_DEV_PERIODIC_OTAG) != 0) 1732 - dev->commands_since_idle_or_otag++; 1733 - 1734 - /* 1735 - * We only allow one untagged transaction 1736 - * per target in the initiator role unless 1737 - * we are storing a full busy target *lun* 1738 - * table in SCB space. 1739 - */ 1740 - if ((scb->hscb->control & (TARGET_SCB|TAG_ENB)) == 0 1741 - && (ahc->features & AHC_SCB_BTT) == 0) { 1742 - struct scb_tailq *untagged_q; 1743 - int target_offset; 1744 - 1745 - target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 1746 - untagged_q = &(ahc->untagged_queues[target_offset]); 1747 - TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe); 1748 - scb->flags |= SCB_UNTAGGEDQ; 1749 - if (TAILQ_FIRST(untagged_q) != scb) 1750 - continue; 1751 - } 1752 - scb->flags |= SCB_ACTIVE; 1753 - ahc_queue_scb(ahc, scb); 1754 } 1755 } 1756 1757 /* ··· 1754 ahc = (struct ahc_softc *) dev_id; 1755 ahc_lock(ahc, &flags); 1756 ours = ahc_intr(ahc); 1757 - if (ahc_linux_next_device_to_run(ahc) != NULL) 1758 - ahc_schedule_runq(ahc); 1759 - ahc_linux_run_complete_queue(ahc); 1760 ahc_unlock(ahc, &flags); 1761 return IRQ_RETVAL(ours); 1762 } ··· 1762 ahc_platform_flushwork(struct ahc_softc *ahc) 1763 { 1764 1765 - while (ahc_linux_run_complete_queue(ahc) != NULL) 1766 - ; 1767 } 1768 1769 static struct ahc_linux_target* ··· 1830 if (dev == NULL) 1831 return (NULL); 1832 memset(dev, 0, sizeof(*dev)); 1833 - init_timer(&dev->timer); 1834 - TAILQ_INIT(&dev->busyq); 1835 - dev->flags = AHC_DEV_UNCONFIGURED; 1836 dev->lun = lun; 1837 dev->target = targ; 1838 ··· 1852 } 1853 1854 static void 1855 - __ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1856 { 1857 struct ahc_linux_target *targ; 1858 ··· 1862 targ->refcount--; 1863 if (targ->refcount == 0) 1864 ahc_linux_free_target(ahc, targ); 1865 - } 1866 - 1867 - static void 1868 - ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1869 - { 1870 - del_timer_sync(&dev->timer); 1871 - __ahc_linux_free_device(ahc, dev); 1872 } 1873 1874 void ··· 1935 } 1936 case AC_SENT_BDR: 1937 { 1938 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1939 WARN_ON(lun != CAM_LUN_WILDCARD); 1940 scsi_report_device_reset(ahc->platform_data->host, 1941 channel - 'A', target); 1942 - #else 1943 - Scsi_Device *scsi_dev; 1944 - 1945 - /* 1946 - * Find the SCSI device associated with this 1947 - * request and indicate that a UA is expected. 1948 - */ 1949 - for (scsi_dev = ahc->platform_data->host->host_queue; 1950 - scsi_dev != NULL; scsi_dev = scsi_dev->next) { 1951 - if (channel - 'A' == scsi_dev->channel 1952 - && target == scsi_dev->id 1953 - && (lun == CAM_LUN_WILDCARD 1954 - || lun == scsi_dev->lun)) { 1955 - scsi_dev->was_reset = 1; 1956 - scsi_dev->expecting_cc_ua = 1; 1957 - } 1958 - } 1959 - #endif 1960 break; 1961 } 1962 case AC_BUS_RESET: ··· 1957 void 1958 ahc_done(struct ahc_softc *ahc, struct scb *scb) 1959 { 1960 - Scsi_Cmnd *cmd; 1961 struct ahc_linux_device *dev; 1962 1963 LIST_REMOVE(scb, pending_links); ··· 1968 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 1969 untagged_q = &(ahc->untagged_queues[target_offset]); 1970 TAILQ_REMOVE(untagged_q, scb, links.tqe); 1971 - ahc_run_untagged_queue(ahc, untagged_q); 1972 } 1973 1974 if ((scb->flags & SCB_ACTIVE) == 0) { ··· 2036 } 2037 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { 2038 ahc_linux_handle_scsi_status(ahc, dev, scb); 2039 - } else if (ahc_get_transaction_status(scb) == CAM_SEL_TIMEOUT) { 2040 - dev->flags |= AHC_DEV_UNCONFIGURED; 2041 } 2042 2043 if (dev->openings == 1 ··· 2056 2057 if (dev->active == 0) 2058 dev->commands_since_idle_or_otag = 0; 2059 - 2060 - if (TAILQ_EMPTY(&dev->busyq)) { 2061 - if ((dev->flags & AHC_DEV_UNCONFIGURED) != 0 2062 - && dev->active == 0 2063 - && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0) 2064 - ahc_linux_free_device(ahc, dev); 2065 - } else if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) { 2066 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links); 2067 - dev->flags |= AHC_DEV_ON_RUN_LIST; 2068 - } 2069 2070 if ((scb->flags & SCB_RECOVERY_SCB) != 0) { 2071 printf("Recovery SCB completes\n"); ··· 2100 case SCSI_STATUS_CHECK_COND: 2101 case SCSI_STATUS_CMD_TERMINATED: 2102 { 2103 - Scsi_Cmnd *cmd; 2104 2105 /* 2106 * Copy sense information to the OS's cmd ··· 2195 ahc_platform_set_tags(ahc, &devinfo, 2196 (dev->flags & AHC_DEV_Q_BASIC) 2197 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 2198 - /* FALLTHROUGH */ 2199 - } 2200 - case SCSI_STATUS_BUSY: 2201 - { 2202 - /* 2203 - * Set a short timer to defer sending commands for 2204 - * a bit since Linux will not delay in this case. 2205 - */ 2206 - if ((dev->flags & AHC_DEV_TIMER_ACTIVE) != 0) { 2207 - printf("%s:%c:%d: Device Timer still active during " 2208 - "busy processing\n", ahc_name(ahc), 2209 - dev->target->channel, dev->target->target); 2210 - break; 2211 - } 2212 - dev->flags |= AHC_DEV_TIMER_ACTIVE; 2213 - dev->qfrozen++; 2214 - init_timer(&dev->timer); 2215 - dev->timer.data = (u_long)dev; 2216 - dev->timer.expires = jiffies + (HZ/2); 2217 - dev->timer.function = ahc_linux_dev_timed_unfreeze; 2218 - add_timer(&dev->timer); 2219 break; 2220 } 2221 } 2222 } 2223 2224 static void 2225 - ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd) 2226 { 2227 - /* 2228 - * Typically, the complete queue has very few entries 2229 - * queued to it before the queue is emptied by 2230 - * ahc_linux_run_complete_queue, so sorting the entries 2231 - * by generation number should be inexpensive. 2232 - * We perform the sort so that commands that complete 2233 - * with an error are retuned in the order origionally 2234 - * queued to the controller so that any subsequent retries 2235 - * are performed in order. The underlying ahc routines do 2236 - * not guarantee the order that aborted commands will be 2237 - * returned to us. 2238 - */ 2239 - struct ahc_completeq *completeq; 2240 - struct ahc_cmd *list_cmd; 2241 - struct ahc_cmd *acmd; 2242 - 2243 /* 2244 * Map CAM error codes into Linux Error codes. We 2245 * avoid the conversion so that the DV code has the ··· 2256 new_status = DID_ERROR; 2257 break; 2258 case CAM_REQUEUE_REQ: 2259 - /* 2260 - * If we want the request requeued, make sure there 2261 - * are sufficent retries. In the old scsi error code, 2262 - * we used to be able to specify a result code that 2263 - * bypassed the retry count. Now we must use this 2264 - * hack. We also "fake" a check condition with 2265 - * a sense code of ABORTED COMMAND. This seems to 2266 - * evoke a retry even if this command is being sent 2267 - * via the eh thread. Ick! Ick! Ick! 2268 - */ 2269 - if (cmd->retries > 0) 2270 - cmd->retries--; 2271 - new_status = DID_OK; 2272 - ahc_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND); 2273 - cmd->result |= (DRIVER_SENSE << 24); 2274 - memset(cmd->sense_buffer, 0, 2275 - sizeof(cmd->sense_buffer)); 2276 - cmd->sense_buffer[0] = SSD_ERRCODE_VALID 2277 - | SSD_CURRENT_ERROR; 2278 - cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND; 2279 break; 2280 default: 2281 /* We should never get here */ ··· 2267 ahc_cmd_set_transaction_status(cmd, new_status); 2268 } 2269 2270 - completeq = &ahc->platform_data->completeq; 2271 - list_cmd = TAILQ_FIRST(completeq); 2272 - acmd = (struct ahc_cmd *)cmd; 2273 - while (list_cmd != NULL 2274 - && acmd_scsi_cmd(list_cmd).serial_number 2275 - < acmd_scsi_cmd(acmd).serial_number) 2276 - list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe); 2277 - if (list_cmd != NULL) 2278 - TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe); 2279 - else 2280 - TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe); 2281 } 2282 2283 static void ··· 2315 ahc->platform_data->qfrozen--; 2316 if (ahc->platform_data->qfrozen == 0) 2317 unblock_reqs = 1; 2318 - ahc_schedule_runq(ahc); 2319 ahc_unlock(ahc, &s); 2320 /* 2321 * There is still a race here. The mid-layer ··· 2326 scsi_unblock_requests(ahc->platform_data->host); 2327 } 2328 2329 - static void 2330 - ahc_linux_dev_timed_unfreeze(u_long arg) 2331 - { 2332 - struct ahc_linux_device *dev; 2333 - struct ahc_softc *ahc; 2334 - u_long s; 2335 - 2336 - dev = (struct ahc_linux_device *)arg; 2337 - ahc = dev->target->ahc; 2338 - ahc_lock(ahc, &s); 2339 - dev->flags &= ~AHC_DEV_TIMER_ACTIVE; 2340 - if (dev->qfrozen > 0) 2341 - dev->qfrozen--; 2342 - if (dev->qfrozen == 0 2343 - && (dev->flags & AHC_DEV_ON_RUN_LIST) == 0) 2344 - ahc_linux_run_device_queue(ahc, dev); 2345 - if (TAILQ_EMPTY(&dev->busyq) 2346 - && dev->active == 0) 2347 - __ahc_linux_free_device(ahc, dev); 2348 - ahc_unlock(ahc, &s); 2349 - } 2350 - 2351 static int 2352 - ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag) 2353 { 2354 struct ahc_softc *ahc; 2355 - struct ahc_cmd *acmd; 2356 - struct ahc_cmd *list_acmd; 2357 struct ahc_linux_device *dev; 2358 struct scb *pending_scb; 2359 - u_long s; 2360 u_int saved_scbptr; 2361 u_int active_scb_index; 2362 u_int last_phase; ··· 2347 paused = FALSE; 2348 wait = FALSE; 2349 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 2350 - acmd = (struct ahc_cmd *)cmd; 2351 2352 printf("%s:%d:%d:%d: Attempting to queue a%s message\n", 2353 ahc_name(ahc), cmd->device->channel, ··· 2359 printf("\n"); 2360 2361 /* 2362 - * In all versions of Linux, we have to work around 2363 - * a major flaw in how the mid-layer is locked down 2364 - * if we are to sleep successfully in our error handler 2365 - * while allowing our interrupt handler to run. Since 2366 - * the midlayer acquires either the io_request_lock or 2367 - * our lock prior to calling us, we must use the 2368 - * spin_unlock_irq() method for unlocking our lock. 2369 - * This will force interrupts to be enabled on the 2370 - * current CPU. Since the EH thread should not have 2371 - * been running with CPU interrupts disabled other than 2372 - * by acquiring either the io_request_lock or our own 2373 - * lock, this *should* be safe. 2374 - */ 2375 - ahc_midlayer_entrypoint_lock(ahc, &s); 2376 - 2377 - /* 2378 * First determine if we currently own this command. 2379 * Start by searching the device queue. If not found 2380 * there, check the pending_scb list. If not found ··· 2366 * command, return success. 2367 */ 2368 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 2369 - cmd->device->lun, /*alloc*/FALSE); 2370 2371 if (dev == NULL) { 2372 /* ··· 2378 cmd->device->lun); 2379 retval = SUCCESS; 2380 goto no_cmd; 2381 - } 2382 - 2383 - TAILQ_FOREACH(list_acmd, &dev->busyq, acmd_links.tqe) { 2384 - if (list_acmd == acmd) 2385 - break; 2386 - } 2387 - 2388 - if (list_acmd != NULL) { 2389 - printf("%s:%d:%d:%d: Command found on device queue\n", 2390 - ahc_name(ahc), cmd->device->channel, cmd->device->id, 2391 - cmd->device->lun); 2392 - if (flag == SCB_ABORT) { 2393 - TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe); 2394 - cmd->result = DID_ABORT << 16; 2395 - ahc_linux_queue_cmd_complete(ahc, cmd); 2396 - retval = SUCCESS; 2397 - goto done; 2398 - } 2399 } 2400 2401 if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0 ··· 2613 } 2614 spin_lock_irq(&ahc->platform_data->spin_lock); 2615 } 2616 - ahc_schedule_runq(ahc); 2617 - ahc_linux_run_complete_queue(ahc); 2618 - ahc_midlayer_entrypoint_unlock(ahc, &s); 2619 return (retval); 2620 } 2621 2622 void 2623 ahc_platform_dump_card_state(struct ahc_softc *ahc) 2624 { 2625 - struct ahc_linux_device *dev; 2626 - int channel; 2627 - int maxchannel; 2628 - int target; 2629 - int maxtarget; 2630 - int lun; 2631 - int i; 2632 - 2633 - maxchannel = (ahc->features & AHC_TWIN) ? 1 : 0; 2634 - maxtarget = (ahc->features & AHC_WIDE) ? 15 : 7; 2635 - for (channel = 0; channel <= maxchannel; channel++) { 2636 - 2637 - for (target = 0; target <=maxtarget; target++) { 2638 - 2639 - for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 2640 - struct ahc_cmd *acmd; 2641 - 2642 - dev = ahc_linux_get_device(ahc, channel, target, 2643 - lun, /*alloc*/FALSE); 2644 - if (dev == NULL) 2645 - continue; 2646 - 2647 - printf("DevQ(%d:%d:%d): ", 2648 - channel, target, lun); 2649 - i = 0; 2650 - TAILQ_FOREACH(acmd, &dev->busyq, 2651 - acmd_links.tqe) { 2652 - if (i++ > AHC_SCB_MAX) 2653 - break; 2654 - } 2655 - printf("%d waiting\n", i); 2656 - } 2657 - } 2658 - } 2659 } 2660 2661 static void ahc_linux_exit(void); 2662 2663 static void ahc_linux_get_period(struct scsi_target *starget) 2664 { ··· 2679 if (offset == 0) 2680 offset = MAX_OFFSET; 2681 2682 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2683 starget->channel + 'A', ROLE_INITIATOR); 2684 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 2685 ahc_lock(ahc, &flags); 2686 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset, ··· 2741 ahc_unlock(ahc, &flags); 2742 } 2743 2744 - static void ahc_linux_get_width(struct scsi_target *starget) 2745 - { 2746 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2747 - struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 2748 - struct ahc_tmode_tstate *tstate; 2749 - struct ahc_initiator_tinfo *tinfo 2750 - = ahc_fetch_transinfo(ahc, 2751 - starget->channel + 'A', 2752 - shost->this_id, starget->id, &tstate); 2753 - spi_width(starget) = tinfo->curr.width; 2754 - } 2755 - 2756 - static void ahc_linux_set_width(struct scsi_target *starget, int width) 2757 - { 2758 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2759 - struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 2760 - struct ahc_devinfo devinfo; 2761 - unsigned long flags; 2762 - 2763 - ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2764 - starget->channel + 'A', ROLE_INITIATOR); 2765 - ahc_lock(ahc, &flags); 2766 - ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE); 2767 - ahc_unlock(ahc, &flags); 2768 - } 2769 - 2770 static void ahc_linux_get_dt(struct scsi_target *starget) 2771 { 2772 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); ··· 2769 unsigned long flags; 2770 struct ahc_syncrate *syncrate; 2771 2772 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2773 starget->channel + 'A', ROLE_INITIATOR); 2774 - syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2775 - dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2); 2776 ahc_lock(ahc, &flags); 2777 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2778 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 2809 unsigned int ppr_options = tinfo->curr.ppr_options 2810 & ~MSG_EXT_PPR_QAS_REQ; 2811 unsigned int period = tinfo->curr.period; 2812 - unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; 2813 unsigned long flags; 2814 struct ahc_syncrate *syncrate; 2815 ··· 2817 2818 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2819 starget->channel + 'A', ROLE_INITIATOR); 2820 - syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2821 - dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2); 2822 ahc_lock(ahc, &flags); 2823 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2824 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 2849 unsigned int ppr_options = tinfo->curr.ppr_options 2850 & ~MSG_EXT_PPR_IU_REQ; 2851 unsigned int period = tinfo->curr.period; 2852 - unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; 2853 unsigned long flags; 2854 struct ahc_syncrate *syncrate; 2855 ··· 2857 2858 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2859 starget->channel + 'A', ROLE_INITIATOR); 2860 - syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2861 - dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2); 2862 ahc_lock(ahc, &flags); 2863 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2864 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 2890 static int __init 2891 ahc_linux_init(void) 2892 { 2893 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 2894 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); 2895 if (!ahc_linux_transport_template) 2896 return -ENODEV; ··· 2898 spi_release_transport(ahc_linux_transport_template); 2899 ahc_linux_exit(); 2900 return -ENODEV; 2901 - #else 2902 - scsi_register_module(MODULE_SCSI_HA, &aic7xxx_driver_template); 2903 - if (aic7xxx_driver_template.present == 0) { 2904 - scsi_unregister_module(MODULE_SCSI_HA, 2905 - &aic7xxx_driver_template); 2906 - return (-ENODEV); 2907 - } 2908 - 2909 - return (0); 2910 - #endif 2911 } 2912 2913 static void 2914 ahc_linux_exit(void) 2915 { 2916 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 2917 - /* 2918 - * In 2.4 we have to unregister from the PCI core _after_ 2919 - * unregistering from the scsi midlayer to avoid dangling 2920 - * references. 2921 - */ 2922 - scsi_unregister_module(MODULE_SCSI_HA, &aic7xxx_driver_template); 2923 - #endif 2924 ahc_linux_pci_exit(); 2925 ahc_linux_eisa_exit(); 2926 spi_release_transport(ahc_linux_transport_template);
··· 134 #include "aiclib.c" 135 136 #include <linux/init.h> /* __setup */ 137 #include <linux/mm.h> /* For fetching system memory size */ 138 #include <linux/blkdev.h> /* For block_size() */ 139 #include <linux/delay.h> /* For ssleep/msleep */ ··· 147 * Lock protecting manipulation of the ahc softc list. 148 */ 149 spinlock_t ahc_list_spinlock; 150 151 /* 152 * Set this to the delay in seconds after SCSI bus reset. ··· 436 struct ahc_linux_device *, 437 struct scb *); 438 static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, 439 + struct scsi_cmnd *cmd); 440 static void ahc_linux_sem_timeout(u_long arg); 441 static void ahc_linux_freeze_simq(struct ahc_softc *ahc); 442 static void ahc_linux_release_simq(u_long arg); 443 + static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); 444 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 445 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 446 struct ahc_devinfo *devinfo); 447 static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, ··· 458 u_int); 459 static void ahc_linux_free_device(struct ahc_softc*, 460 struct ahc_linux_device*); 461 + static int ahc_linux_run_command(struct ahc_softc*, 462 + struct ahc_linux_device *, 463 + struct scsi_cmnd *); 464 static void ahc_linux_setup_tag_info_global(char *p); 465 static aic_option_callback_t ahc_linux_setup_tag_info; 466 static int aic7xxx_setup(char *s); 467 static int ahc_linux_next_unit(void); 468 469 /********************************* Inlines ************************************/ 470 static __inline struct ahc_linux_device* 471 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, 472 + u_int target, u_int lun); 473 static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 474 475 static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 476 struct ahc_dma_seg *sg, 477 dma_addr_t addr, bus_size_t len); 478 479 static __inline struct ahc_linux_device* 480 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, 481 + u_int lun) 482 { 483 struct ahc_linux_target *targ; 484 struct ahc_linux_device *dev; ··· 515 if (channel != 0) 516 target_offset += 8; 517 targ = ahc->platform_data->targets[target_offset]; 518 + BUG_ON(targ == NULL); 519 dev = targ->devices[lun]; 520 + return dev; 521 } 522 523 static __inline void 524 ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) 525 { 526 + struct scsi_cmnd *cmd; 527 528 cmd = scb->io_ctx; 529 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE); ··· 650 return (consumed); 651 } 652 653 /* 654 * Try to detect an Adaptec 7XXX controller. 655 */ 656 static int 657 + ahc_linux_detect(struct scsi_host_template *template) 658 { 659 struct ahc_softc *ahc; 660 int found = 0; 661 662 /* 663 * Sanity checking of Linux SCSI data structures so ··· 764 printf("ahc_linux_detect: Unable to attach\n"); 765 return (0); 766 } 767 /* 768 * If we've been passed any parameters, process them now. 769 */ ··· 793 found++; 794 } 795 796 aic7xxx_detect_complete++; 797 798 return (found); 799 } 800 801 /* 802 * Return a string describing the driver. ··· 867 * Queue an SCB to the controller. 868 */ 869 static int 870 + ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) 871 { 872 struct ahc_softc *ahc; 873 struct ahc_linux_device *dev; 874 875 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 876 ··· 880 */ 881 cmd->scsi_done = scsi_done; 882 883 /* 884 * Close the race of a command that was in the process of 885 * being queued to us just as our simq was frozen. Let 886 * DV commands through so long as we are only frozen to 887 * perform DV. 888 */ 889 + if (ahc->platform_data->qfrozen != 0) 890 + return SCSI_MLQUEUE_HOST_BUSY; 891 892 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 893 + cmd->device->lun); 894 + BUG_ON(dev == NULL); 895 + 896 cmd->result = CAM_REQ_INPROG << 16; 897 + 898 + return ahc_linux_run_command(ahc, dev, cmd); 899 } 900 901 static int 902 + ahc_linux_slave_alloc(struct scsi_device *device) 903 { 904 struct ahc_softc *ahc; 905 + struct ahc_linux_target *targ; 906 + struct scsi_target *starget = device->sdev_target; 907 + struct ahc_linux_device *dev; 908 + unsigned int target_offset; 909 + unsigned long flags; 910 + int retval = -ENOMEM; 911 + 912 + target_offset = starget->id; 913 + if (starget->channel != 0) 914 + target_offset += 8; 915 916 ahc = *((struct ahc_softc **)device->host->hostdata); 917 if (bootverbose) 918 printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id); 919 + ahc_lock(ahc, &flags); 920 + targ = ahc->platform_data->targets[target_offset]; 921 + if (targ == NULL) { 922 + targ = ahc_linux_alloc_target(ahc, starget->channel, starget->id); 923 + struct seeprom_config *sc = ahc->seep_config; 924 + if (targ == NULL) 925 + goto out; 926 + 927 + if (sc) { 928 + unsigned short scsirate; 929 + struct ahc_devinfo devinfo; 930 + struct ahc_initiator_tinfo *tinfo; 931 + struct ahc_tmode_tstate *tstate; 932 + char channel = starget->channel + 'A'; 933 + unsigned int our_id = ahc->our_id; 934 + 935 + if (starget->channel) 936 + our_id = ahc->our_id_b; 937 + 938 + if ((ahc->features & AHC_ULTRA2) != 0) { 939 + scsirate = sc->device_flags[target_offset] & CFXFER; 940 + } else { 941 + scsirate = (sc->device_flags[target_offset] & CFXFER) << 4; 942 + if (sc->device_flags[target_offset] & CFSYNCH) 943 + scsirate |= SOFS; 944 + } 945 + if (sc->device_flags[target_offset] & CFWIDEB) { 946 + scsirate |= WIDEXFER; 947 + spi_max_width(starget) = 1; 948 + } else 949 + spi_max_width(starget) = 0; 950 + spi_min_period(starget) = 951 + ahc_find_period(ahc, scsirate, AHC_SYNCRATE_DT); 952 + tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id, 953 + targ->target, &tstate); 954 + ahc_compile_devinfo(&devinfo, our_id, targ->target, 955 + CAM_LUN_WILDCARD, channel, 956 + ROLE_INITIATOR); 957 + ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0, 958 + AHC_TRANS_GOAL, /*paused*/FALSE); 959 + ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, 960 + AHC_TRANS_GOAL, /*paused*/FALSE); 961 + } 962 + 963 + } 964 + dev = targ->devices[device->lun]; 965 + if (dev == NULL) { 966 + dev = ahc_linux_alloc_device(ahc, targ, device->lun); 967 + if (dev == NULL) 968 + goto out; 969 + } 970 + retval = 0; 971 + 972 + out: 973 + ahc_unlock(ahc, &flags); 974 + return retval; 975 } 976 977 static int 978 + ahc_linux_slave_configure(struct scsi_device *device) 979 { 980 struct ahc_softc *ahc; 981 struct ahc_linux_device *dev; 982 983 ahc = *((struct ahc_softc **)device->host->hostdata); 984 + 985 if (bootverbose) 986 printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id); 987 + 988 + dev = ahc_linux_get_device(ahc, device->channel, device->id, 989 + device->lun); 990 + dev->scsi_device = device; 991 + ahc_linux_device_queue_depth(ahc, dev); 992 993 /* Initial Domain Validation */ 994 if (!spi_initial_dv(device->sdev_target)) 995 spi_dv_device(device); 996 997 + return 0; 998 } 999 1000 static void 1001 + ahc_linux_slave_destroy(struct scsi_device *device) 1002 { 1003 struct ahc_softc *ahc; 1004 struct ahc_linux_device *dev; 1005 1006 ahc = *((struct ahc_softc **)device->host->hostdata); 1007 if (bootverbose) 1008 printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id); 1009 dev = ahc_linux_get_device(ahc, device->channel, 1010 + device->id, device->lun); 1011 + 1012 + BUG_ON(dev->active); 1013 + 1014 + ahc_linux_free_device(ahc, dev); 1015 } 1016 1017 #if defined(__i386__) 1018 /* 1019 * Return the disk geometry for the given SCSI device. 1020 */ 1021 static int 1022 ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, 1023 sector_t capacity, int geom[]) 1024 { 1025 uint8_t *bh; 1026 int heads; 1027 int sectors; 1028 int cylinders; ··· 1090 ahc = *((struct ahc_softc **)sdev->host->hostdata); 1091 channel = sdev->channel; 1092 1093 bh = scsi_bios_ptable(bdev); 1094 if (bh) { 1095 ret = scsi_partsize(bh, capacity, 1096 &geom[2], &geom[0], &geom[1]); 1097 kfree(bh); 1098 if (ret != -1) 1099 return (ret); 1100 } ··· 1135 * Abort the current SCSI command(s). 1136 */ 1137 static int 1138 + ahc_linux_abort(struct scsi_cmnd *cmd) 1139 { 1140 int error; 1141 ··· 1149 * Attempt to send a target reset message to the device that timed out. 1150 */ 1151 static int 1152 + ahc_linux_dev_reset(struct scsi_cmnd *cmd) 1153 { 1154 int error; 1155 ··· 1163 * Reset the SCSI bus. 1164 */ 1165 static int 1166 + ahc_linux_bus_reset(struct scsi_cmnd *cmd) 1167 { 1168 struct ahc_softc *ahc; 1169 int found; 1170 1171 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 1172 found = ahc_reset_channel(ahc, cmd->device->channel + 'A', 1173 /*initiate reset*/TRUE); 1174 1175 if (bootverbose) 1176 printf("%s: SCSI bus reset delivered. " ··· 1183 return SUCCESS; 1184 } 1185 1186 + struct scsi_host_template aic7xxx_driver_template = { 1187 .module = THIS_MODULE, 1188 .name = "aic7xxx", 1189 .proc_info = ahc_linux_proc_info, ··· 1205 }; 1206 1207 /**************************** Tasklet Handler *********************************/ 1208 1209 /******************************** Macros **************************************/ 1210 #define BUILD_SCSIID(ahc, cmd) \ ··· 1278 ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, 1279 int flags, bus_dmamap_t *mapp) 1280 { 1281 *vaddr = pci_alloc_consistent(ahc->dev_softc, 1282 + dmat->maxsize, mapp); 1283 if (*vaddr == NULL) 1284 + return ENOMEM; 1285 + return 0; 1286 } 1287 1288 void ··· 1316 void* vaddr, bus_dmamap_t map) 1317 { 1318 pci_free_consistent(ahc->dev_softc, dmat->maxsize, 1319 + vaddr, map); 1320 } 1321 1322 int ··· 1330 */ 1331 bus_dma_segment_t stack_sg; 1332 1333 + stack_sg.ds_addr = map; 1334 stack_sg.ds_len = dmat->maxsize; 1335 cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); 1336 return (0); ··· 1339 void 1340 ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map) 1341 { 1342 } 1343 1344 int ··· 1550 uint32_t aic7xxx_verbose; 1551 1552 int 1553 + ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template) 1554 { 1555 char buf[80]; 1556 struct Scsi_Host *host; ··· 1564 1565 *((struct ahc_softc **)host->hostdata) = ahc; 1566 ahc_lock(ahc, &s); 1567 scsi_assign_lock(host, &ahc->platform_data->spin_lock); 1568 ahc->platform_data->host = host; 1569 host->can_queue = AHC_MAX_QUEUE; 1570 host->cmd_per_lun = 2; ··· 1587 ahc_set_name(ahc, new_name); 1588 } 1589 host->unique_id = ahc->unit; 1590 ahc_linux_initialize_scsi_bus(ahc); 1591 ahc_intr_enable(ahc, TRUE); 1592 ahc_unlock(ahc, &s); 1593 1594 host->transportt = ahc_linux_transport_template; 1595 1596 scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */ 1597 scsi_scan_host(host); 1598 return (0); 1599 } 1600 ··· 1717 if (ahc->platform_data == NULL) 1718 return (ENOMEM); 1719 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); 1720 ahc->platform_data->irq = AHC_LINUX_NOIRQ; 1721 ahc_lockinit(ahc); 1722 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); 1723 ahc->seltime = (aic7xxx_seltime & 0x3) << 4; 1724 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; 1725 if (aic7xxx_pci_parity == 0) ··· 1746 int i, j; 1747 1748 if (ahc->platform_data != NULL) { 1749 if (ahc->platform_data->host != NULL) { 1750 scsi_remove_host(ahc->platform_data->host); 1751 scsi_host_put(ahc->platform_data->host); 1752 } 1753 ··· 1787 release_mem_region(ahc->platform_data->mem_busaddr, 1788 0x1000); 1789 } 1790 + 1791 free(ahc->platform_data, M_DEVBUF); 1792 } 1793 } ··· 1820 1821 dev = ahc_linux_get_device(ahc, devinfo->channel - 'A', 1822 devinfo->target, 1823 + devinfo->lun); 1824 if (dev == NULL) 1825 return; 1826 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); ··· 1873 dev->maxtags = 0; 1874 dev->openings = 1 - dev->active; 1875 } 1876 if (dev->scsi_device != NULL) { 1877 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { 1878 case AHC_DEV_Q_BASIC: ··· 1899 break; 1900 } 1901 } 1902 } 1903 1904 int 1905 ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel, 1906 int lun, u_int tag, role_t role, uint32_t status) 1907 { 1908 + return 0; 1909 } 1910 1911 static u_int ··· 2045 } 2046 } 2047 2048 + static int 2049 + ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, 2050 + struct scsi_cmnd *cmd) 2051 { 2052 struct scb *scb; 2053 struct hardware_scb *hscb; 2054 struct ahc_initiator_tinfo *tinfo; 2055 struct ahc_tmode_tstate *tstate; 2056 uint16_t mask; 2057 + struct scb_tailq *untagged_q = NULL; 2058 2059 + /* 2060 + * Schedule us to run later. The only reason we are not 2061 + * running is because the whole controller Q is frozen. 2062 + */ 2063 + if (ahc->platform_data->qfrozen != 0) 2064 + return SCSI_MLQUEUE_HOST_BUSY; 2065 2066 + /* 2067 + * We only allow one untagged transaction 2068 + * per target in the initiator role unless 2069 + * we are storing a full busy target *lun* 2070 + * table in SCB space. 2071 + */ 2072 + if (!blk_rq_tagged(cmd->request) 2073 + && (ahc->features & AHC_SCB_BTT) == 0) { 2074 + int target_offset; 2075 2076 + target_offset = cmd->device->id + cmd->device->channel * 8; 2077 + untagged_q = &(ahc->untagged_queues[target_offset]); 2078 + if (!TAILQ_EMPTY(untagged_q)) 2079 + /* if we're already executing an untagged command 2080 + * we're busy to another */ 2081 + return SCSI_MLQUEUE_DEVICE_BUSY; 2082 } 2083 + 2084 + /* 2085 + * Get an scb to use. 2086 + */ 2087 + if ((scb = ahc_get_scb(ahc)) == NULL) { 2088 + ahc->flags |= AHC_RESOURCE_SHORTAGE; 2089 + return SCSI_MLQUEUE_HOST_BUSY; 2090 + } 2091 + 2092 + scb->io_ctx = cmd; 2093 + scb->platform_data->dev = dev; 2094 + hscb = scb->hscb; 2095 + cmd->host_scribble = (char *)scb; 2096 + 2097 + /* 2098 + * Fill out basics of the HSCB. 2099 + */ 2100 + hscb->control = 0; 2101 + hscb->scsiid = BUILD_SCSIID(ahc, cmd); 2102 + hscb->lun = cmd->device->lun; 2103 + mask = SCB_GET_TARGET_MASK(ahc, scb); 2104 + tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb), 2105 + SCB_GET_OUR_ID(scb), 2106 + SCB_GET_TARGET(ahc, scb), &tstate); 2107 + hscb->scsirate = tinfo->scsirate; 2108 + hscb->scsioffset = tinfo->curr.offset; 2109 + if ((tstate->ultraenb & mask) != 0) 2110 + hscb->control |= ULTRAENB; 2111 + 2112 + if ((ahc->user_discenable & mask) != 0) 2113 + hscb->control |= DISCENB; 2114 + 2115 + if ((tstate->auto_negotiate & mask) != 0) { 2116 + scb->flags |= SCB_AUTO_NEGOTIATE; 2117 + scb->hscb->control |= MK_MESSAGE; 2118 + } 2119 + 2120 + if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) { 2121 + int msg_bytes; 2122 + uint8_t tag_msgs[2]; 2123 + 2124 + msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); 2125 + if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { 2126 + hscb->control |= tag_msgs[0]; 2127 + if (tag_msgs[0] == MSG_ORDERED_TASK) 2128 + dev->commands_since_idle_or_otag = 0; 2129 + } else if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH 2130 + && (dev->flags & AHC_DEV_Q_TAGGED) != 0) { 2131 + hscb->control |= MSG_ORDERED_TASK; 2132 + dev->commands_since_idle_or_otag = 0; 2133 + } else { 2134 + hscb->control |= MSG_SIMPLE_TASK; 2135 + } 2136 + } 2137 + 2138 + hscb->cdb_len = cmd->cmd_len; 2139 + if (hscb->cdb_len <= 12) { 2140 + memcpy(hscb->shared_data.cdb, cmd->cmnd, hscb->cdb_len); 2141 + } else { 2142 + memcpy(hscb->cdb32, cmd->cmnd, hscb->cdb_len); 2143 + scb->flags |= SCB_CDB32_PTR; 2144 + } 2145 + 2146 + scb->platform_data->xfer_len = 0; 2147 + ahc_set_residual(scb, 0); 2148 + ahc_set_sense_residual(scb, 0); 2149 + scb->sg_count = 0; 2150 + if (cmd->use_sg != 0) { 2151 + struct ahc_dma_seg *sg; 2152 + struct scatterlist *cur_seg; 2153 + struct scatterlist *end_seg; 2154 + int nseg; 2155 + 2156 + cur_seg = (struct scatterlist *)cmd->request_buffer; 2157 + nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg, 2158 + cmd->sc_data_direction); 2159 + end_seg = cur_seg + nseg; 2160 + /* Copy the segments into the SG list. */ 2161 + sg = scb->sg_list; 2162 + /* 2163 + * The sg_count may be larger than nseg if 2164 + * a transfer crosses a 32bit page. 2165 + */ 2166 + while (cur_seg < end_seg) { 2167 + dma_addr_t addr; 2168 + bus_size_t len; 2169 + int consumed; 2170 + 2171 + addr = sg_dma_address(cur_seg); 2172 + len = sg_dma_len(cur_seg); 2173 + consumed = ahc_linux_map_seg(ahc, scb, 2174 + sg, addr, len); 2175 + sg += consumed; 2176 + scb->sg_count += consumed; 2177 + cur_seg++; 2178 + } 2179 + sg--; 2180 + sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 2181 + 2182 + /* 2183 + * Reset the sg list pointer. 2184 + */ 2185 + scb->hscb->sgptr = 2186 + ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 2187 + 2188 + /* 2189 + * Copy the first SG into the "current" 2190 + * data pointer area. 2191 + */ 2192 + scb->hscb->dataptr = scb->sg_list->addr; 2193 + scb->hscb->datacnt = scb->sg_list->len; 2194 + } else if (cmd->request_bufflen != 0) { 2195 + struct ahc_dma_seg *sg; 2196 + dma_addr_t addr; 2197 + 2198 + sg = scb->sg_list; 2199 + addr = pci_map_single(ahc->dev_softc, 2200 + cmd->request_buffer, 2201 + cmd->request_bufflen, 2202 + cmd->sc_data_direction); 2203 + scb->platform_data->buf_busaddr = addr; 2204 + scb->sg_count = ahc_linux_map_seg(ahc, scb, 2205 + sg, addr, 2206 + cmd->request_bufflen); 2207 + sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 2208 + 2209 + /* 2210 + * Reset the sg list pointer. 2211 + */ 2212 + scb->hscb->sgptr = 2213 + ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 2214 + 2215 + /* 2216 + * Copy the first SG into the "current" 2217 + * data pointer area. 2218 + */ 2219 + scb->hscb->dataptr = sg->addr; 2220 + scb->hscb->datacnt = sg->len; 2221 + } else { 2222 + scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL); 2223 + scb->hscb->dataptr = 0; 2224 + scb->hscb->datacnt = 0; 2225 + scb->sg_count = 0; 2226 + } 2227 + 2228 + LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links); 2229 + dev->openings--; 2230 + dev->active++; 2231 + dev->commands_issued++; 2232 + if ((dev->flags & AHC_DEV_PERIODIC_OTAG) != 0) 2233 + dev->commands_since_idle_or_otag++; 2234 + 2235 + scb->flags |= SCB_ACTIVE; 2236 + if (untagged_q) { 2237 + TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe); 2238 + scb->flags |= SCB_UNTAGGEDQ; 2239 + } 2240 + ahc_queue_scb(ahc, scb); 2241 + return 0; 2242 } 2243 2244 /* ··· 2267 ahc = (struct ahc_softc *) dev_id; 2268 ahc_lock(ahc, &flags); 2269 ours = ahc_intr(ahc); 2270 ahc_unlock(ahc, &flags); 2271 return IRQ_RETVAL(ours); 2272 } ··· 2278 ahc_platform_flushwork(struct ahc_softc *ahc) 2279 { 2280 2281 } 2282 2283 static struct ahc_linux_target* ··· 2348 if (dev == NULL) 2349 return (NULL); 2350 memset(dev, 0, sizeof(*dev)); 2351 dev->lun = lun; 2352 dev->target = targ; 2353 ··· 2373 } 2374 2375 static void 2376 + ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 2377 { 2378 struct ahc_linux_target *targ; 2379 ··· 2383 targ->refcount--; 2384 if (targ->refcount == 0) 2385 ahc_linux_free_target(ahc, targ); 2386 } 2387 2388 void ··· 2463 } 2464 case AC_SENT_BDR: 2465 { 2466 WARN_ON(lun != CAM_LUN_WILDCARD); 2467 scsi_report_device_reset(ahc->platform_data->host, 2468 channel - 'A', target); 2469 break; 2470 } 2471 case AC_BUS_RESET: ··· 2504 void 2505 ahc_done(struct ahc_softc *ahc, struct scb *scb) 2506 { 2507 + struct scsi_cmnd *cmd; 2508 struct ahc_linux_device *dev; 2509 2510 LIST_REMOVE(scb, pending_links); ··· 2515 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 2516 untagged_q = &(ahc->untagged_queues[target_offset]); 2517 TAILQ_REMOVE(untagged_q, scb, links.tqe); 2518 + BUG_ON(!TAILQ_EMPTY(untagged_q)); 2519 } 2520 2521 if ((scb->flags & SCB_ACTIVE) == 0) { ··· 2583 } 2584 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { 2585 ahc_linux_handle_scsi_status(ahc, dev, scb); 2586 } 2587 2588 if (dev->openings == 1 ··· 2605 2606 if (dev->active == 0) 2607 dev->commands_since_idle_or_otag = 0; 2608 2609 if ((scb->flags & SCB_RECOVERY_SCB) != 0) { 2610 printf("Recovery SCB completes\n"); ··· 2659 case SCSI_STATUS_CHECK_COND: 2660 case SCSI_STATUS_CMD_TERMINATED: 2661 { 2662 + struct scsi_cmnd *cmd; 2663 2664 /* 2665 * Copy sense information to the OS's cmd ··· 2754 ahc_platform_set_tags(ahc, &devinfo, 2755 (dev->flags & AHC_DEV_Q_BASIC) 2756 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 2757 break; 2758 } 2759 } 2760 } 2761 2762 static void 2763 + ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd) 2764 { 2765 /* 2766 * Map CAM error codes into Linux Error codes. We 2767 * avoid the conversion so that the DV code has the ··· 2852 new_status = DID_ERROR; 2853 break; 2854 case CAM_REQUEUE_REQ: 2855 + new_status = DID_REQUEUE; 2856 break; 2857 default: 2858 /* We should never get here */ ··· 2882 ahc_cmd_set_transaction_status(cmd, new_status); 2883 } 2884 2885 + cmd->scsi_done(cmd); 2886 } 2887 2888 static void ··· 2940 ahc->platform_data->qfrozen--; 2941 if (ahc->platform_data->qfrozen == 0) 2942 unblock_reqs = 1; 2943 ahc_unlock(ahc, &s); 2944 /* 2945 * There is still a race here. The mid-layer ··· 2952 scsi_unblock_requests(ahc->platform_data->host); 2953 } 2954 2955 static int 2956 + ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) 2957 { 2958 struct ahc_softc *ahc; 2959 struct ahc_linux_device *dev; 2960 struct scb *pending_scb; 2961 u_int saved_scbptr; 2962 u_int active_scb_index; 2963 u_int last_phase; ··· 2998 paused = FALSE; 2999 wait = FALSE; 3000 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 3001 3002 printf("%s:%d:%d:%d: Attempting to queue a%s message\n", 3003 ahc_name(ahc), cmd->device->channel, ··· 3011 printf("\n"); 3012 3013 /* 3014 * First determine if we currently own this command. 3015 * Start by searching the device queue. If not found 3016 * there, check the pending_scb list. If not found ··· 3034 * command, return success. 3035 */ 3036 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 3037 + cmd->device->lun); 3038 3039 if (dev == NULL) { 3040 /* ··· 3046 cmd->device->lun); 3047 retval = SUCCESS; 3048 goto no_cmd; 3049 } 3050 3051 if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0 ··· 3299 } 3300 spin_lock_irq(&ahc->platform_data->spin_lock); 3301 } 3302 return (retval); 3303 } 3304 3305 void 3306 ahc_platform_dump_card_state(struct ahc_softc *ahc) 3307 { 3308 } 3309 3310 static void ahc_linux_exit(void); 3311 + 3312 + static void ahc_linux_get_width(struct scsi_target *starget) 3313 + { 3314 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 3315 + struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 3316 + struct ahc_tmode_tstate *tstate; 3317 + struct ahc_initiator_tinfo *tinfo 3318 + = ahc_fetch_transinfo(ahc, 3319 + starget->channel + 'A', 3320 + shost->this_id, starget->id, &tstate); 3321 + spi_width(starget) = tinfo->curr.width; 3322 + } 3323 + 3324 + static void ahc_linux_set_width(struct scsi_target *starget, int width) 3325 + { 3326 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 3327 + struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 3328 + struct ahc_devinfo devinfo; 3329 + unsigned long flags; 3330 + 3331 + ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 3332 + starget->channel + 'A', ROLE_INITIATOR); 3333 + ahc_lock(ahc, &flags); 3334 + ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE); 3335 + ahc_unlock(ahc, &flags); 3336 + } 3337 3338 static void ahc_linux_get_period(struct scsi_target *starget) 3339 { ··· 3376 if (offset == 0) 3377 offset = MAX_OFFSET; 3378 3379 + if (period < 9) 3380 + period = 9; /* 12.5ns is our minimum */ 3381 + if (period == 9) 3382 + ppr_options |= MSG_EXT_PPR_DT_REQ; 3383 + 3384 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 3385 starget->channel + 'A', ROLE_INITIATOR); 3386 + 3387 + /* all PPR requests apart from QAS require wide transfers */ 3388 + if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) { 3389 + ahc_linux_get_width(starget); 3390 + if (spi_width(starget) == 0) 3391 + ppr_options &= MSG_EXT_PPR_QAS_REQ; 3392 + } 3393 + 3394 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 3395 ahc_lock(ahc, &flags); 3396 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset, ··· 3425 ahc_unlock(ahc, &flags); 3426 } 3427 3428 static void ahc_linux_get_dt(struct scsi_target *starget) 3429 { 3430 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); ··· 3479 unsigned long flags; 3480 struct ahc_syncrate *syncrate; 3481 3482 + if (dt) { 3483 + period = 9; /* 12.5ns is the only period valid for DT */ 3484 + ppr_options |= MSG_EXT_PPR_DT_REQ; 3485 + } else if (period == 9) 3486 + period = 10; /* if resetting DT, period must be >= 25ns */ 3487 + 3488 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 3489 starget->channel + 'A', ROLE_INITIATOR); 3490 + syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT); 3491 ahc_lock(ahc, &flags); 3492 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 3493 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 3514 unsigned int ppr_options = tinfo->curr.ppr_options 3515 & ~MSG_EXT_PPR_QAS_REQ; 3516 unsigned int period = tinfo->curr.period; 3517 unsigned long flags; 3518 struct ahc_syncrate *syncrate; 3519 ··· 3523 3524 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 3525 starget->channel + 'A', ROLE_INITIATOR); 3526 + syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 3527 ahc_lock(ahc, &flags); 3528 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 3529 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 3556 unsigned int ppr_options = tinfo->curr.ppr_options 3557 & ~MSG_EXT_PPR_IU_REQ; 3558 unsigned int period = tinfo->curr.period; 3559 unsigned long flags; 3560 struct ahc_syncrate *syncrate; 3561 ··· 3565 3566 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 3567 starget->channel + 'A', ROLE_INITIATOR); 3568 + syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 3569 ahc_lock(ahc, &flags); 3570 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 3571 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 3599 static int __init 3600 ahc_linux_init(void) 3601 { 3602 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); 3603 if (!ahc_linux_transport_template) 3604 return -ENODEV; ··· 3608 spi_release_transport(ahc_linux_transport_template); 3609 ahc_linux_exit(); 3610 return -ENODEV; 3611 } 3612 3613 static void 3614 ahc_linux_exit(void) 3615 { 3616 ahc_linux_pci_exit(); 3617 ahc_linux_eisa_exit(); 3618 spi_release_transport(ahc_linux_transport_template);
+25 -144
drivers/scsi/aic7xxx/aic7xxx_osm.h
··· 59 #ifndef _AIC7XXX_LINUX_H_ 60 #define _AIC7XXX_LINUX_H_ 61 62 #include <linux/types.h> 63 #include <linux/blkdev.h> 64 #include <linux/delay.h> ··· 67 #include <linux/pci.h> 68 #include <linux/smp_lock.h> 69 #include <linux/version.h> 70 #include <linux/module.h> 71 #include <asm/byteorder.h> 72 #include <asm/io.h> 73 74 - #include <linux/interrupt.h> /* For tasklet support. */ 75 - #include <linux/config.h> 76 - #include <linux/slab.h> 77 78 /* Core SCSI definitions */ 79 #define AIC_LIB_PREFIX ahc 80 - #include "scsi.h" 81 - #include <scsi/scsi_host.h> 82 83 /* Name space conflict with BSD queue macros */ 84 #ifdef LIST_HEAD ··· 110 /************************* Forward Declarations *******************************/ 111 struct ahc_softc; 112 typedef struct pci_dev *ahc_dev_softc_t; 113 - typedef Scsi_Cmnd *ahc_io_ctx_t; 114 115 /******************************* Byte Order ***********************************/ 116 #define ahc_htobe16(x) cpu_to_be16(x) ··· 148 extern u_int aic7xxx_no_probe; 149 extern u_int aic7xxx_allow_memio; 150 extern int aic7xxx_detect_complete; 151 - extern Scsi_Host_Template aic7xxx_driver_template; 152 153 /***************************** Bus Space/DMA **********************************/ 154 ··· 178 }; 179 typedef struct ahc_linux_dma_tag* bus_dma_tag_t; 180 181 - struct ahc_linux_dmamap 182 - { 183 - dma_addr_t bus_addr; 184 - }; 185 - typedef struct ahc_linux_dmamap* bus_dmamap_t; 186 187 typedef int bus_dma_filter_t(void*, dma_addr_t); 188 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); ··· 281 /***************************** SMP support ************************************/ 282 #include <linux/spinlock.h> 283 284 - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK)) 285 - #define AHC_SCSI_HAS_HOST_LOCK 1 286 - #else 287 - #define AHC_SCSI_HAS_HOST_LOCK 0 288 - #endif 289 - 290 #define AIC7XXX_DRIVER_VERSION "6.2.36" 291 292 /**************************** Front End Queues ********************************/ ··· 322 */ 323 TAILQ_HEAD(ahc_busyq, ahc_cmd); 324 typedef enum { 325 - AHC_DEV_UNCONFIGURED = 0x01, 326 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ 327 - AHC_DEV_TIMER_ACTIVE = 0x04, /* Our timer is active */ 328 - AHC_DEV_ON_RUN_LIST = 0x08, /* Queued to be run later */ 329 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ 330 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ 331 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 332 - AHC_DEV_SLAVE_CONFIGURED = 0x80 /* slave_configure() has been called */ 333 } ahc_linux_dev_flags; 334 335 struct ahc_linux_target; 336 struct ahc_linux_device { 337 TAILQ_ENTRY(ahc_linux_device) links; 338 - struct ahc_busyq busyq; 339 340 /* 341 * The number of transactions currently ··· 371 ahc_linux_dev_flags flags; 372 373 /* 374 - * Per device timer. 375 - */ 376 - struct timer_list timer; 377 - 378 - /* 379 * The high limit for the tags variable. 380 */ 381 u_int maxtags; ··· 403 #define AHC_OTAG_THRESH 500 404 405 int lun; 406 - Scsi_Device *scsi_device; 407 struct ahc_linux_target *target; 408 }; 409 ··· 423 * manner and are allocated below 4GB, the number of S/G segments is 424 * unrestricted. 425 */ 426 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 427 - /* 428 - * We dynamically adjust the number of segments in pre-2.5 kernels to 429 - * avoid fragmentation issues in the SCSI mid-layer's private memory 430 - * allocator. See aic7xxx_osm.c ahc_linux_size_nseg() for details. 431 - */ 432 - extern u_int ahc_linux_nseg; 433 - #define AHC_NSEG ahc_linux_nseg 434 - #define AHC_LINUX_MIN_NSEG 64 435 - #else 436 #define AHC_NSEG 128 437 - #endif 438 439 /* 440 * Per-SCB OSM storage. 441 */ 442 - typedef enum { 443 - AHC_UP_EH_SEMAPHORE = 0x1 444 - } ahc_linux_scb_flags; 445 - 446 struct scb_platform_data { 447 struct ahc_linux_device *dev; 448 dma_addr_t buf_busaddr; 449 uint32_t xfer_len; 450 uint32_t sense_resid; /* Auto-Sense residual */ 451 - ahc_linux_scb_flags flags; 452 }; 453 454 /* ··· 441 * alignment restrictions of the various platforms supported by 442 * this driver. 443 */ 444 - typedef enum { 445 - AHC_RUN_CMPLT_Q_TIMER = 0x10 446 - } ahc_linux_softc_flags; 447 - 448 - TAILQ_HEAD(ahc_completeq, ahc_cmd); 449 - 450 struct ahc_platform_data { 451 /* 452 * Fields accessed from interrupt context. 453 */ 454 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 455 - TAILQ_HEAD(, ahc_linux_device) device_runq; 456 - struct ahc_completeq completeq; 457 458 spinlock_t spin_lock; 459 - struct tasklet_struct runq_tasklet; 460 u_int qfrozen; 461 - pid_t dv_pid; 462 - struct timer_list completeq_timer; 463 struct timer_list reset_timer; 464 struct semaphore eh_sem; 465 - struct semaphore dv_sem; 466 - struct semaphore dv_cmd_sem; /* XXX This needs to be in 467 - * the target struct 468 - */ 469 - struct scsi_device *dv_scsi_dev; 470 struct Scsi_Host *host; /* pointer to scsi host */ 471 #define AHC_LINUX_NOIRQ ((uint32_t)~0) 472 uint32_t irq; /* IRQ for this adapter */ 473 uint32_t bios_address; 474 uint32_t mem_busaddr; /* Mem Base Addr */ 475 - uint64_t hw_dma_mask; 476 - ahc_linux_softc_flags flags; 477 }; 478 479 /************************** OS Utility Wrappers *******************************/ ··· 547 548 /**************************** Initialization **********************************/ 549 int ahc_linux_register_host(struct ahc_softc *, 550 - Scsi_Host_Template *); 551 552 uint64_t ahc_linux_get_memsize(void); 553 ··· 567 static __inline void ahc_lockinit(struct ahc_softc *); 568 static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 569 static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 570 - 571 - /* Lock acquisition and release of the above lock in midlayer entry points. */ 572 - static __inline void ahc_midlayer_entrypoint_lock(struct ahc_softc *, 573 - unsigned long *flags); 574 - static __inline void ahc_midlayer_entrypoint_unlock(struct ahc_softc *, 575 - unsigned long *flags); 576 - 577 - /* Lock held during command compeletion to the upper layer */ 578 - static __inline void ahc_done_lockinit(struct ahc_softc *); 579 - static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags); 580 - static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags); 581 582 /* Lock held during ahc_list manipulation and ahc softc frees */ 583 extern spinlock_t ahc_list_spinlock; ··· 590 ahc_unlock(struct ahc_softc *ahc, unsigned long *flags) 591 { 592 spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags); 593 - } 594 - 595 - static __inline void 596 - ahc_midlayer_entrypoint_lock(struct ahc_softc *ahc, unsigned long *flags) 597 - { 598 - /* 599 - * In 2.5.X and some 2.4.X versions, the midlayer takes our 600 - * lock just before calling us, so we avoid locking again. 601 - * For other kernel versions, the io_request_lock is taken 602 - * just before our entry point is called. In this case, we 603 - * trade the io_request_lock for our per-softc lock. 604 - */ 605 - #if AHC_SCSI_HAS_HOST_LOCK == 0 606 - spin_unlock(&io_request_lock); 607 - spin_lock(&ahc->platform_data->spin_lock); 608 - #endif 609 - } 610 - 611 - static __inline void 612 - ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags) 613 - { 614 - #if AHC_SCSI_HAS_HOST_LOCK == 0 615 - spin_unlock(&ahc->platform_data->spin_lock); 616 - spin_lock(&io_request_lock); 617 - #endif 618 - } 619 - 620 - static __inline void 621 - ahc_done_lockinit(struct ahc_softc *ahc) 622 - { 623 - /* 624 - * In 2.5.X, our own lock is held during completions. 625 - * In previous versions, the io_request_lock is used. 626 - * In either case, we can't initialize this lock again. 627 - */ 628 - } 629 - 630 - static __inline void 631 - ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags) 632 - { 633 - #if AHC_SCSI_HAS_HOST_LOCK == 0 634 - spin_lock_irqsave(&io_request_lock, *flags); 635 - #endif 636 - } 637 - 638 - static __inline void 639 - ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags) 640 - { 641 - #if AHC_SCSI_HAS_HOST_LOCK == 0 642 - spin_unlock_irqrestore(&io_request_lock, *flags); 643 - #endif 644 } 645 646 static __inline void ··· 658 } ahc_power_state; 659 660 /**************************** VL/EISA Routines ********************************/ 661 - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) \ 662 - && (defined(__i386__) || defined(__alpha__)) \ 663 - && (!defined(CONFIG_EISA))) 664 - #define CONFIG_EISA 665 - #endif 666 - 667 #ifdef CONFIG_EISA 668 extern uint32_t aic7xxx_probe_eisa_vl; 669 int ahc_linux_eisa_init(void); ··· 773 } 774 775 /**************************** Proc FS Support *********************************/ 776 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 777 - int ahc_linux_proc_info(char *, char **, off_t, int, int, int); 778 - #else 779 int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 780 off_t, int, int); 781 - #endif 782 783 /*************************** Domain Validation ********************************/ 784 /*********************** Transaction Access Wrappers *************************/ 785 - static __inline void ahc_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); 786 static __inline void ahc_set_transaction_status(struct scb *, uint32_t); 787 - static __inline void ahc_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); 788 static __inline void ahc_set_scsi_status(struct scb *, uint32_t); 789 - static __inline uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd); 790 static __inline uint32_t ahc_get_transaction_status(struct scb *); 791 - static __inline uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd); 792 static __inline uint32_t ahc_get_scsi_status(struct scb *); 793 static __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 794 static __inline u_long ahc_get_transfer_length(struct scb *); ··· 803 static __inline void ahc_freeze_scb(struct scb *scb); 804 805 static __inline 806 - void ahc_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) 807 { 808 cmd->result &= ~(CAM_STATUS_MASK << 16); 809 cmd->result |= status << 16; ··· 816 } 817 818 static __inline 819 - void ahc_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) 820 { 821 cmd->result &= ~0xFFFF; 822 cmd->result |= status; ··· 829 } 830 831 static __inline 832 - uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd) 833 { 834 return ((cmd->result >> 16) & CAM_STATUS_MASK); 835 } ··· 841 } 842 843 static __inline 844 - uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd) 845 { 846 return (cmd->result & 0xFFFF); 847 }
··· 59 #ifndef _AIC7XXX_LINUX_H_ 60 #define _AIC7XXX_LINUX_H_ 61 62 + #include <linux/config.h> 63 #include <linux/types.h> 64 #include <linux/blkdev.h> 65 #include <linux/delay.h> ··· 66 #include <linux/pci.h> 67 #include <linux/smp_lock.h> 68 #include <linux/version.h> 69 + #include <linux/interrupt.h> 70 #include <linux/module.h> 71 + #include <linux/slab.h> 72 #include <asm/byteorder.h> 73 #include <asm/io.h> 74 75 + #include <scsi/scsi.h> 76 + #include <scsi/scsi_cmnd.h> 77 + #include <scsi/scsi_eh.h> 78 + #include <scsi/scsi_device.h> 79 + #include <scsi/scsi_host.h> 80 + #include <scsi/scsi_tcq.h> 81 82 /* Core SCSI definitions */ 83 #define AIC_LIB_PREFIX ahc 84 85 /* Name space conflict with BSD queue macros */ 86 #ifdef LIST_HEAD ··· 106 /************************* Forward Declarations *******************************/ 107 struct ahc_softc; 108 typedef struct pci_dev *ahc_dev_softc_t; 109 + typedef struct scsi_cmnd *ahc_io_ctx_t; 110 111 /******************************* Byte Order ***********************************/ 112 #define ahc_htobe16(x) cpu_to_be16(x) ··· 144 extern u_int aic7xxx_no_probe; 145 extern u_int aic7xxx_allow_memio; 146 extern int aic7xxx_detect_complete; 147 + extern struct scsi_host_template aic7xxx_driver_template; 148 149 /***************************** Bus Space/DMA **********************************/ 150 ··· 174 }; 175 typedef struct ahc_linux_dma_tag* bus_dma_tag_t; 176 177 + typedef dma_addr_t bus_dmamap_t; 178 179 typedef int bus_dma_filter_t(void*, dma_addr_t); 180 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); ··· 281 /***************************** SMP support ************************************/ 282 #include <linux/spinlock.h> 283 284 #define AIC7XXX_DRIVER_VERSION "6.2.36" 285 286 /**************************** Front End Queues ********************************/ ··· 328 */ 329 TAILQ_HEAD(ahc_busyq, ahc_cmd); 330 typedef enum { 331 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ 332 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ 333 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ 334 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 335 } ahc_linux_dev_flags; 336 337 struct ahc_linux_target; 338 struct ahc_linux_device { 339 TAILQ_ENTRY(ahc_linux_device) links; 340 341 /* 342 * The number of transactions currently ··· 382 ahc_linux_dev_flags flags; 383 384 /* 385 * The high limit for the tags variable. 386 */ 387 u_int maxtags; ··· 419 #define AHC_OTAG_THRESH 500 420 421 int lun; 422 + struct scsi_device *scsi_device; 423 struct ahc_linux_target *target; 424 }; 425 ··· 439 * manner and are allocated below 4GB, the number of S/G segments is 440 * unrestricted. 441 */ 442 #define AHC_NSEG 128 443 444 /* 445 * Per-SCB OSM storage. 446 */ 447 struct scb_platform_data { 448 struct ahc_linux_device *dev; 449 dma_addr_t buf_busaddr; 450 uint32_t xfer_len; 451 uint32_t sense_resid; /* Auto-Sense residual */ 452 }; 453 454 /* ··· 473 * alignment restrictions of the various platforms supported by 474 * this driver. 475 */ 476 struct ahc_platform_data { 477 /* 478 * Fields accessed from interrupt context. 479 */ 480 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 481 482 spinlock_t spin_lock; 483 u_int qfrozen; 484 struct timer_list reset_timer; 485 struct semaphore eh_sem; 486 struct Scsi_Host *host; /* pointer to scsi host */ 487 #define AHC_LINUX_NOIRQ ((uint32_t)~0) 488 uint32_t irq; /* IRQ for this adapter */ 489 uint32_t bios_address; 490 uint32_t mem_busaddr; /* Mem Base Addr */ 491 + 492 + #define AHC_UP_EH_SEMAPHORE 0x1 493 + uint32_t flags; 494 }; 495 496 /************************** OS Utility Wrappers *******************************/ ··· 594 595 /**************************** Initialization **********************************/ 596 int ahc_linux_register_host(struct ahc_softc *, 597 + struct scsi_host_template *); 598 599 uint64_t ahc_linux_get_memsize(void); 600 ··· 614 static __inline void ahc_lockinit(struct ahc_softc *); 615 static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 616 static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 617 618 /* Lock held during ahc_list manipulation and ahc softc frees */ 619 extern spinlock_t ahc_list_spinlock; ··· 648 ahc_unlock(struct ahc_softc *ahc, unsigned long *flags) 649 { 650 spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags); 651 } 652 653 static __inline void ··· 767 } ahc_power_state; 768 769 /**************************** VL/EISA Routines ********************************/ 770 #ifdef CONFIG_EISA 771 extern uint32_t aic7xxx_probe_eisa_vl; 772 int ahc_linux_eisa_init(void); ··· 888 } 889 890 /**************************** Proc FS Support *********************************/ 891 int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 892 off_t, int, int); 893 894 /*************************** Domain Validation ********************************/ 895 /*********************** Transaction Access Wrappers *************************/ 896 + static __inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t); 897 static __inline void ahc_set_transaction_status(struct scb *, uint32_t); 898 + static __inline void ahc_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t); 899 static __inline void ahc_set_scsi_status(struct scb *, uint32_t); 900 + static __inline uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd); 901 static __inline uint32_t ahc_get_transaction_status(struct scb *); 902 + static __inline uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd); 903 static __inline uint32_t ahc_get_scsi_status(struct scb *); 904 static __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 905 static __inline u_long ahc_get_transfer_length(struct scb *); ··· 922 static __inline void ahc_freeze_scb(struct scb *scb); 923 924 static __inline 925 + void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status) 926 { 927 cmd->result &= ~(CAM_STATUS_MASK << 16); 928 cmd->result |= status << 16; ··· 935 } 936 937 static __inline 938 + void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status) 939 { 940 cmd->result &= ~0xFFFF; 941 cmd->result |= status; ··· 948 } 949 950 static __inline 951 + uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd) 952 { 953 return ((cmd->result >> 16) & CAM_STATUS_MASK); 954 } ··· 960 } 961 962 static __inline 963 + uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd) 964 { 965 return (cmd->result & 0xFFFF); 966 }
+1 -10
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
··· 221 && ahc_linux_get_memsize() > 0x80000000 222 && pci_set_dma_mask(pdev, mask_39bit) == 0) { 223 ahc->flags |= AHC_39BIT_ADDRESSING; 224 - ahc->platform_data->hw_dma_mask = mask_39bit; 225 } else { 226 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 227 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 228 return (-ENODEV); 229 } 230 - ahc->platform_data->hw_dma_mask = DMA_32BIT_MASK; 231 } 232 ahc->dev_softc = pci; 233 error = ahc_pci_config(ahc, entry); ··· 234 return (-error); 235 } 236 pci_set_drvdata(pdev, ahc); 237 - if (aic7xxx_detect_complete) { 238 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 239 ahc_linux_register_host(ahc, &aic7xxx_driver_template); 240 - #else 241 - printf("aic7xxx: ignoring PCI device found after " 242 - "initialization\n"); 243 - return (-ENODEV); 244 - #endif 245 - } 246 return (0); 247 } 248
··· 221 && ahc_linux_get_memsize() > 0x80000000 222 && pci_set_dma_mask(pdev, mask_39bit) == 0) { 223 ahc->flags |= AHC_39BIT_ADDRESSING; 224 } else { 225 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 226 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 227 return (-ENODEV); 228 } 229 } 230 ahc->dev_softc = pci; 231 error = ahc_pci_config(ahc, entry); ··· 236 return (-error); 237 } 238 pci_set_drvdata(pdev, ahc); 239 + if (aic7xxx_detect_complete) 240 ahc_linux_register_host(ahc, &aic7xxx_driver_template); 241 return (0); 242 } 243
-13
drivers/scsi/aic7xxx/aic7xxx_proc.c
··· 289 * Return information to handle /proc support for the driver. 290 */ 291 int 292 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 293 - ahc_linux_proc_info(char *buffer, char **start, off_t offset, 294 - int length, int hostno, int inout) 295 - #else 296 ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 297 off_t offset, int length, int inout) 298 - #endif 299 { 300 struct ahc_softc *ahc; 301 struct info_str info; ··· 302 303 retval = -EINVAL; 304 ahc_list_lock(&s); 305 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 306 - TAILQ_FOREACH(ahc, &ahc_tailq, links) { 307 - if (ahc->platform_data->host->host_no == hostno) 308 - break; 309 - } 310 - #else 311 ahc = ahc_find_softc(*(struct ahc_softc **)shost->hostdata); 312 - #endif 313 - 314 if (ahc == NULL) 315 goto done; 316
··· 289 * Return information to handle /proc support for the driver. 290 */ 291 int 292 ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 293 off_t offset, int length, int inout) 294 { 295 struct ahc_softc *ahc; 296 struct info_str info; ··· 307 308 retval = -EINVAL; 309 ahc_list_lock(&s); 310 ahc = ahc_find_softc(*(struct ahc_softc **)shost->hostdata); 311 if (ahc == NULL) 312 goto done; 313
-1
drivers/scsi/aic7xxx/aiclib.c
··· 35 #include <linux/version.h> 36 37 /* Core SCSI definitions */ 38 - #include "scsi.h" 39 #include <scsi/scsi_host.h> 40 #include "aiclib.h" 41 #include "cam.h"
··· 35 #include <linux/version.h> 36 37 /* Core SCSI definitions */ 38 #include <scsi/scsi_host.h> 39 #include "aiclib.h" 40 #include "cam.h"
+161 -27
drivers/scsi/scsi_transport_spi.c
··· 35 36 #define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a) 37 38 - #define SPI_NUM_ATTRS 10 /* increase this if you add attributes */ 39 #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always 40 * on" attributes */ 41 #define SPI_HOST_ATTRS 1 ··· 219 struct scsi_target *starget = to_scsi_target(dev); 220 221 spi_period(starget) = -1; /* illegal value */ 222 spi_offset(starget) = 0; /* async */ 223 spi_width(starget) = 0; /* narrow */ 224 spi_iu(starget) = 0; /* no IU */ 225 spi_dt(starget) = 0; /* ST */ 226 spi_qas(starget) = 0; ··· 236 init_MUTEX(&spi_dv_sem(starget)); 237 238 return 0; 239 } 240 241 #define spi_transport_show_function(field, format_string) \ ··· 292 struct spi_internal *i = to_spi_internal(shost->transportt); \ 293 \ 294 val = simple_strtoul(buf, NULL, 0); \ 295 i->f->set_##field(starget, val); \ 296 return count; \ 297 } ··· 322 show_spi_transport_##field, \ 323 store_spi_transport_##field); 324 325 /* The Parallel SCSI Tranport Attributes: */ 326 - spi_transport_rd_attr(offset, "%d\n"); 327 - spi_transport_rd_attr(width, "%d\n"); 328 spi_transport_rd_attr(iu, "%d\n"); 329 spi_transport_rd_attr(dt, "%d\n"); 330 spi_transport_rd_attr(qas, "%d\n"); ··· 365 366 /* Translate the period into ns according to the current spec 367 * for SDTR/PPR messages */ 368 - static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf) 369 - 370 { 371 - struct scsi_target *starget = transport_class_to_starget(cdev); 372 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 373 - struct spi_transport_attrs *tp; 374 int len, picosec; 375 - struct spi_internal *i = to_spi_internal(shost->transportt); 376 377 - tp = (struct spi_transport_attrs *)&starget->starget_data; 378 - 379 - if (i->f->get_period) 380 - i->f->get_period(starget); 381 - 382 - if (tp->period < 0 || tp->period > 0xff) { 383 picosec = -1; 384 - } else if (tp->period <= SPI_STATIC_PPR) { 385 - picosec = ppr_to_ps[tp->period]; 386 } else { 387 - picosec = tp->period * 4000; 388 } 389 390 if (picosec == -1) { ··· 391 } 392 393 static ssize_t 394 - store_spi_transport_period(struct class_device *cdev, const char *buf, 395 - size_t count) 396 { 397 - struct scsi_target *starget = transport_class_to_starget(cdev); 398 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 399 - struct spi_internal *i = to_spi_internal(shost->transportt); 400 int j, picosec, period = -1; 401 char *endp; 402 ··· 422 if (period > 0xff) 423 period = 0xff; 424 425 - i->f->set_period(starget, period); 426 427 return count; 428 } 429 430 static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR, 431 show_spi_transport_period, 432 store_spi_transport_period); 433 434 static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) 435 { ··· 760 { 761 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); 762 struct scsi_device *sdev = sreq->sr_device; 763 int len = sdev->inquiry_len; 764 /* first set us up for narrow async */ 765 DV_SET(offset, 0); ··· 774 } 775 776 /* test width */ 777 - if (i->f->set_width && sdev->wdtr) { 778 i->f->set_width(sdev->sdev_target, 1); 779 780 if (spi_dv_device_compare_inquiry(sreq, buffer, 781 buffer + len, ··· 805 retry: 806 807 /* now set up to the maximum */ 808 - DV_SET(offset, 255); 809 - DV_SET(period, 1); 810 811 if (len == 0) { 812 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n"); ··· 1013 if (i->f->show_##field) \ 1014 count++ 1015 1016 #define SETUP_HOST_ATTRIBUTE(field) \ 1017 i->private_host_attrs[count] = class_device_attr_##field; \ 1018 if (!i->f->set_##field) { \ ··· 1106 i->f = ft; 1107 1108 SETUP_ATTRIBUTE(period); 1109 SETUP_ATTRIBUTE(offset); 1110 SETUP_ATTRIBUTE(width); 1111 SETUP_ATTRIBUTE(iu); 1112 SETUP_ATTRIBUTE(dt); 1113 SETUP_ATTRIBUTE(qas);
··· 35 36 #define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a) 37 38 + #define SPI_NUM_ATTRS 13 /* increase this if you add attributes */ 39 #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always 40 * on" attributes */ 41 #define SPI_HOST_ATTRS 1 ··· 219 struct scsi_target *starget = to_scsi_target(dev); 220 221 spi_period(starget) = -1; /* illegal value */ 222 + spi_min_period(starget) = 0; 223 spi_offset(starget) = 0; /* async */ 224 + spi_max_offset(starget) = 255; 225 spi_width(starget) = 0; /* narrow */ 226 + spi_max_width(starget) = 1; 227 spi_iu(starget) = 0; /* no IU */ 228 spi_dt(starget) = 0; /* ST */ 229 spi_qas(starget) = 0; ··· 233 init_MUTEX(&spi_dv_sem(starget)); 234 235 return 0; 236 + } 237 + 238 + #define spi_transport_show_simple(field, format_string) \ 239 + \ 240 + static ssize_t \ 241 + show_spi_transport_##field(struct class_device *cdev, char *buf) \ 242 + { \ 243 + struct scsi_target *starget = transport_class_to_starget(cdev); \ 244 + struct spi_transport_attrs *tp; \ 245 + \ 246 + tp = (struct spi_transport_attrs *)&starget->starget_data; \ 247 + return snprintf(buf, 20, format_string, tp->field); \ 248 + } 249 + 250 + #define spi_transport_store_simple(field, format_string) \ 251 + \ 252 + static ssize_t \ 253 + store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 254 + size_t count) \ 255 + { \ 256 + int val; \ 257 + struct scsi_target *starget = transport_class_to_starget(cdev); \ 258 + struct spi_transport_attrs *tp; \ 259 + \ 260 + tp = (struct spi_transport_attrs *)&starget->starget_data; \ 261 + val = simple_strtoul(buf, NULL, 0); \ 262 + tp->field = val; \ 263 + return count; \ 264 } 265 266 #define spi_transport_show_function(field, format_string) \ ··· 261 struct spi_internal *i = to_spi_internal(shost->transportt); \ 262 \ 263 val = simple_strtoul(buf, NULL, 0); \ 264 + i->f->set_##field(starget, val); \ 265 + return count; \ 266 + } 267 + 268 + #define spi_transport_store_max(field, format_string) \ 269 + static ssize_t \ 270 + store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 271 + size_t count) \ 272 + { \ 273 + int val; \ 274 + struct scsi_target *starget = transport_class_to_starget(cdev); \ 275 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 276 + struct spi_internal *i = to_spi_internal(shost->transportt); \ 277 + struct spi_transport_attrs *tp \ 278 + = (struct spi_transport_attrs *)&starget->starget_data; \ 279 + \ 280 + val = simple_strtoul(buf, NULL, 0); \ 281 + if (val > tp->max_##field) \ 282 + val = tp->max_##field; \ 283 i->f->set_##field(starget, val); \ 284 return count; \ 285 } ··· 272 show_spi_transport_##field, \ 273 store_spi_transport_##field); 274 275 + #define spi_transport_simple_attr(field, format_string) \ 276 + spi_transport_show_simple(field, format_string) \ 277 + spi_transport_store_simple(field, format_string) \ 278 + static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \ 279 + show_spi_transport_##field, \ 280 + store_spi_transport_##field); 281 + 282 + #define spi_transport_max_attr(field, format_string) \ 283 + spi_transport_show_function(field, format_string) \ 284 + spi_transport_store_max(field, format_string) \ 285 + spi_transport_simple_attr(max_##field, format_string) \ 286 + static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \ 287 + show_spi_transport_##field, \ 288 + store_spi_transport_##field); 289 + 290 /* The Parallel SCSI Tranport Attributes: */ 291 + spi_transport_max_attr(offset, "%d\n"); 292 + spi_transport_max_attr(width, "%d\n"); 293 spi_transport_rd_attr(iu, "%d\n"); 294 spi_transport_rd_attr(dt, "%d\n"); 295 spi_transport_rd_attr(qas, "%d\n"); ··· 300 301 /* Translate the period into ns according to the current spec 302 * for SDTR/PPR messages */ 303 + static ssize_t 304 + show_spi_transport_period_helper(struct class_device *cdev, char *buf, 305 + int period) 306 { 307 int len, picosec; 308 309 + if (period < 0 || period > 0xff) { 310 picosec = -1; 311 + } else if (period <= SPI_STATIC_PPR) { 312 + picosec = ppr_to_ps[period]; 313 } else { 314 + picosec = period * 4000; 315 } 316 317 if (picosec == -1) { ··· 334 } 335 336 static ssize_t 337 + store_spi_transport_period_helper(struct class_device *cdev, const char *buf, 338 + size_t count, int *periodp) 339 { 340 int j, picosec, period = -1; 341 char *endp; 342 ··· 368 if (period > 0xff) 369 period = 0xff; 370 371 + *periodp = period; 372 373 return count; 374 + } 375 + 376 + static ssize_t 377 + show_spi_transport_period(struct class_device *cdev, char *buf) 378 + { 379 + struct scsi_target *starget = transport_class_to_starget(cdev); 380 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 381 + struct spi_internal *i = to_spi_internal(shost->transportt); 382 + struct spi_transport_attrs *tp = 383 + (struct spi_transport_attrs *)&starget->starget_data; 384 + 385 + if (i->f->get_period) 386 + i->f->get_period(starget); 387 + 388 + return show_spi_transport_period_helper(cdev, buf, tp->period); 389 + } 390 + 391 + static ssize_t 392 + store_spi_transport_period(struct class_device *cdev, const char *buf, 393 + size_t count) 394 + { 395 + struct scsi_target *starget = transport_class_to_starget(cdev); 396 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 397 + struct spi_internal *i = to_spi_internal(shost->transportt); 398 + struct spi_transport_attrs *tp = 399 + (struct spi_transport_attrs *)&starget->starget_data; 400 + int period, retval; 401 + 402 + retval = store_spi_transport_period_helper(cdev, buf, count, &period); 403 + 404 + if (period < tp->min_period) 405 + period = tp->min_period; 406 + 407 + i->f->set_period(starget, period); 408 + 409 + return retval; 410 } 411 412 static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR, 413 show_spi_transport_period, 414 store_spi_transport_period); 415 + 416 + static ssize_t 417 + show_spi_transport_min_period(struct class_device *cdev, char *buf) 418 + { 419 + struct scsi_target *starget = transport_class_to_starget(cdev); 420 + struct spi_transport_attrs *tp = 421 + (struct spi_transport_attrs *)&starget->starget_data; 422 + 423 + return show_spi_transport_period_helper(cdev, buf, tp->min_period); 424 + } 425 + 426 + static ssize_t 427 + store_spi_transport_min_period(struct class_device *cdev, const char *buf, 428 + size_t count) 429 + { 430 + struct scsi_target *starget = transport_class_to_starget(cdev); 431 + struct spi_transport_attrs *tp = 432 + (struct spi_transport_attrs *)&starget->starget_data; 433 + 434 + return store_spi_transport_period_helper(cdev, buf, count, 435 + &tp->min_period); 436 + } 437 + 438 + 439 + static CLASS_DEVICE_ATTR(min_period, S_IRUGO | S_IWUSR, 440 + show_spi_transport_min_period, 441 + store_spi_transport_min_period); 442 + 443 444 static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) 445 { ··· 642 { 643 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); 644 struct scsi_device *sdev = sreq->sr_device; 645 + struct scsi_target *starget = sdev->sdev_target; 646 int len = sdev->inquiry_len; 647 /* first set us up for narrow async */ 648 DV_SET(offset, 0); ··· 655 } 656 657 /* test width */ 658 + if (i->f->set_width && spi_max_width(starget) && sdev->wdtr) { 659 i->f->set_width(sdev->sdev_target, 1); 660 + 661 + printk("WIDTH IS %d\n", spi_max_width(starget)); 662 663 if (spi_dv_device_compare_inquiry(sreq, buffer, 664 buffer + len, ··· 684 retry: 685 686 /* now set up to the maximum */ 687 + DV_SET(offset, spi_max_offset(starget)); 688 + DV_SET(period, spi_min_period(starget)); 689 690 if (len == 0) { 691 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n"); ··· 892 if (i->f->show_##field) \ 893 count++ 894 895 + #define SETUP_RELATED_ATTRIBUTE(field, rel_field) \ 896 + i->private_attrs[count] = class_device_attr_##field; \ 897 + if (!i->f->set_##rel_field) { \ 898 + i->private_attrs[count].attr.mode = S_IRUGO; \ 899 + i->private_attrs[count].store = NULL; \ 900 + } \ 901 + i->attrs[count] = &i->private_attrs[count]; \ 902 + if (i->f->show_##rel_field) \ 903 + count++ 904 + 905 #define SETUP_HOST_ATTRIBUTE(field) \ 906 i->private_host_attrs[count] = class_device_attr_##field; \ 907 if (!i->f->set_##field) { \ ··· 975 i->f = ft; 976 977 SETUP_ATTRIBUTE(period); 978 + SETUP_RELATED_ATTRIBUTE(min_period, period); 979 SETUP_ATTRIBUTE(offset); 980 + SETUP_RELATED_ATTRIBUTE(max_offset, offset); 981 SETUP_ATTRIBUTE(width); 982 + SETUP_RELATED_ATTRIBUTE(max_width, width); 983 SETUP_ATTRIBUTE(iu); 984 SETUP_ATTRIBUTE(dt); 985 SETUP_ATTRIBUTE(qas);
+6
include/scsi/scsi_transport_spi.h
··· 27 28 struct spi_transport_attrs { 29 int period; /* value in the PPR/SDTR command */ 30 int offset; 31 unsigned int width:1; /* 0 - narrow, 1 - wide */ 32 unsigned int iu:1; /* Information Units enabled */ 33 unsigned int dt:1; /* DT clocking enabled */ 34 unsigned int qas:1; /* Quick Arbitration and Selection enabled */ ··· 66 67 /* accessor functions */ 68 #define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period) 69 #define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset) 70 #define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width) 71 #define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu) 72 #define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt) 73 #define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
··· 27 28 struct spi_transport_attrs { 29 int period; /* value in the PPR/SDTR command */ 30 + int min_period; 31 int offset; 32 + int max_offset; 33 unsigned int width:1; /* 0 - narrow, 1 - wide */ 34 + unsigned int max_width:1; 35 unsigned int iu:1; /* Information Units enabled */ 36 unsigned int dt:1; /* DT clocking enabled */ 37 unsigned int qas:1; /* Quick Arbitration and Selection enabled */ ··· 63 64 /* accessor functions */ 65 #define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period) 66 + #define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period) 67 #define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset) 68 + #define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset) 69 #define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width) 70 + #define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width) 71 #define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu) 72 #define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt) 73 #define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)