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