diff options
Diffstat (limited to 'drivers/scsi/esp_scsi.c')
-rw-r--r-- | drivers/scsi/esp_scsi.c | 428 |
1 files changed, 247 insertions, 181 deletions
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 55548dc5cec3..ce5bd52fe692 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c | |||
@@ -49,55 +49,67 @@ static u32 esp_debug; | |||
49 | #define ESP_DEBUG_DATADONE 0x00000100 | 49 | #define ESP_DEBUG_DATADONE 0x00000100 |
50 | #define ESP_DEBUG_RECONNECT 0x00000200 | 50 | #define ESP_DEBUG_RECONNECT 0x00000200 |
51 | #define ESP_DEBUG_AUTOSENSE 0x00000400 | 51 | #define ESP_DEBUG_AUTOSENSE 0x00000400 |
52 | #define ESP_DEBUG_EVENT 0x00000800 | ||
53 | #define ESP_DEBUG_COMMAND 0x00001000 | ||
52 | 54 | ||
53 | #define esp_log_intr(f, a...) \ | 55 | #define esp_log_intr(f, a...) \ |
54 | do { if (esp_debug & ESP_DEBUG_INTR) \ | 56 | do { if (esp_debug & ESP_DEBUG_INTR) \ |
55 | printk(f, ## a); \ | 57 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
56 | } while (0) | 58 | } while (0) |
57 | 59 | ||
58 | #define esp_log_reset(f, a...) \ | 60 | #define esp_log_reset(f, a...) \ |
59 | do { if (esp_debug & ESP_DEBUG_RESET) \ | 61 | do { if (esp_debug & ESP_DEBUG_RESET) \ |
60 | printk(f, ## a); \ | 62 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
61 | } while (0) | 63 | } while (0) |
62 | 64 | ||
63 | #define esp_log_msgin(f, a...) \ | 65 | #define esp_log_msgin(f, a...) \ |
64 | do { if (esp_debug & ESP_DEBUG_MSGIN) \ | 66 | do { if (esp_debug & ESP_DEBUG_MSGIN) \ |
65 | printk(f, ## a); \ | 67 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
66 | } while (0) | 68 | } while (0) |
67 | 69 | ||
68 | #define esp_log_msgout(f, a...) \ | 70 | #define esp_log_msgout(f, a...) \ |
69 | do { if (esp_debug & ESP_DEBUG_MSGOUT) \ | 71 | do { if (esp_debug & ESP_DEBUG_MSGOUT) \ |
70 | printk(f, ## a); \ | 72 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
71 | } while (0) | 73 | } while (0) |
72 | 74 | ||
73 | #define esp_log_cmddone(f, a...) \ | 75 | #define esp_log_cmddone(f, a...) \ |
74 | do { if (esp_debug & ESP_DEBUG_CMDDONE) \ | 76 | do { if (esp_debug & ESP_DEBUG_CMDDONE) \ |
75 | printk(f, ## a); \ | 77 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
76 | } while (0) | 78 | } while (0) |
77 | 79 | ||
78 | #define esp_log_disconnect(f, a...) \ | 80 | #define esp_log_disconnect(f, a...) \ |
79 | do { if (esp_debug & ESP_DEBUG_DISCONNECT) \ | 81 | do { if (esp_debug & ESP_DEBUG_DISCONNECT) \ |
80 | printk(f, ## a); \ | 82 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
81 | } while (0) | 83 | } while (0) |
82 | 84 | ||
83 | #define esp_log_datastart(f, a...) \ | 85 | #define esp_log_datastart(f, a...) \ |
84 | do { if (esp_debug & ESP_DEBUG_DATASTART) \ | 86 | do { if (esp_debug & ESP_DEBUG_DATASTART) \ |
85 | printk(f, ## a); \ | 87 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
86 | } while (0) | 88 | } while (0) |
87 | 89 | ||
88 | #define esp_log_datadone(f, a...) \ | 90 | #define esp_log_datadone(f, a...) \ |
89 | do { if (esp_debug & ESP_DEBUG_DATADONE) \ | 91 | do { if (esp_debug & ESP_DEBUG_DATADONE) \ |
90 | printk(f, ## a); \ | 92 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
91 | } while (0) | 93 | } while (0) |
92 | 94 | ||
93 | #define esp_log_reconnect(f, a...) \ | 95 | #define esp_log_reconnect(f, a...) \ |
94 | do { if (esp_debug & ESP_DEBUG_RECONNECT) \ | 96 | do { if (esp_debug & ESP_DEBUG_RECONNECT) \ |
95 | printk(f, ## a); \ | 97 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
96 | } while (0) | 98 | } while (0) |
97 | 99 | ||
98 | #define esp_log_autosense(f, a...) \ | 100 | #define esp_log_autosense(f, a...) \ |
99 | do { if (esp_debug & ESP_DEBUG_AUTOSENSE) \ | 101 | do { if (esp_debug & ESP_DEBUG_AUTOSENSE) \ |
100 | printk(f, ## a); \ | 102 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ |
103 | } while (0) | ||
104 | |||
105 | #define esp_log_event(f, a...) \ | ||
106 | do { if (esp_debug & ESP_DEBUG_EVENT) \ | ||
107 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ | ||
108 | } while (0) | ||
109 | |||
110 | #define esp_log_command(f, a...) \ | ||
111 | do { if (esp_debug & ESP_DEBUG_COMMAND) \ | ||
112 | shost_printk(KERN_DEBUG, esp->host, f, ## a); \ | ||
101 | } while (0) | 113 | } while (0) |
102 | 114 | ||
103 | #define esp_read8(REG) esp->ops->esp_read8(esp, REG) | 115 | #define esp_read8(REG) esp->ops->esp_read8(esp, REG) |
@@ -126,10 +138,29 @@ void scsi_esp_cmd(struct esp *esp, u8 val) | |||
126 | 138 | ||
127 | esp->esp_event_cur = (idx + 1) & (ESP_EVENT_LOG_SZ - 1); | 139 | esp->esp_event_cur = (idx + 1) & (ESP_EVENT_LOG_SZ - 1); |
128 | 140 | ||
141 | esp_log_command("cmd[%02x]\n", val); | ||
129 | esp_write8(val, ESP_CMD); | 142 | esp_write8(val, ESP_CMD); |
130 | } | 143 | } |
131 | EXPORT_SYMBOL(scsi_esp_cmd); | 144 | EXPORT_SYMBOL(scsi_esp_cmd); |
132 | 145 | ||
146 | static void esp_send_dma_cmd(struct esp *esp, int len, int max_len, int cmd) | ||
147 | { | ||
148 | if (esp->flags & ESP_FLAG_USE_FIFO) { | ||
149 | int i; | ||
150 | |||
151 | scsi_esp_cmd(esp, ESP_CMD_FLUSH); | ||
152 | for (i = 0; i < len; i++) | ||
153 | esp_write8(esp->command_block[i], ESP_FDATA); | ||
154 | scsi_esp_cmd(esp, cmd); | ||
155 | } else { | ||
156 | if (esp->rev == FASHME) | ||
157 | scsi_esp_cmd(esp, ESP_CMD_FLUSH); | ||
158 | cmd |= ESP_CMD_DMA; | ||
159 | esp->ops->send_dma_cmd(esp, esp->command_block_dma, | ||
160 | len, max_len, 0, cmd); | ||
161 | } | ||
162 | } | ||
163 | |||
133 | static void esp_event(struct esp *esp, u8 val) | 164 | static void esp_event(struct esp *esp, u8 val) |
134 | { | 165 | { |
135 | struct esp_event_ent *p; | 166 | struct esp_event_ent *p; |
@@ -150,19 +181,17 @@ static void esp_dump_cmd_log(struct esp *esp) | |||
150 | int idx = esp->esp_event_cur; | 181 | int idx = esp->esp_event_cur; |
151 | int stop = idx; | 182 | int stop = idx; |
152 | 183 | ||
153 | printk(KERN_INFO PFX "esp%d: Dumping command log\n", | 184 | shost_printk(KERN_INFO, esp->host, "Dumping command log\n"); |
154 | esp->host->unique_id); | ||
155 | do { | 185 | do { |
156 | struct esp_event_ent *p = &esp->esp_event_log[idx]; | 186 | struct esp_event_ent *p = &esp->esp_event_log[idx]; |
157 | 187 | ||
158 | printk(KERN_INFO PFX "esp%d: ent[%d] %s ", | 188 | shost_printk(KERN_INFO, esp->host, |
159 | esp->host->unique_id, idx, | 189 | "ent[%d] %s val[%02x] sreg[%02x] seqreg[%02x] " |
160 | p->type == ESP_EVENT_TYPE_CMD ? "CMD" : "EVENT"); | 190 | "sreg2[%02x] ireg[%02x] ss[%02x] event[%02x]\n", |
161 | 191 | idx, | |
162 | printk("val[%02x] sreg[%02x] seqreg[%02x] " | 192 | p->type == ESP_EVENT_TYPE_CMD ? "CMD" : "EVENT", |
163 | "sreg2[%02x] ireg[%02x] ss[%02x] event[%02x]\n", | 193 | p->val, p->sreg, p->seqreg, |
164 | p->val, p->sreg, p->seqreg, | 194 | p->sreg2, p->ireg, p->select_state, p->event); |
165 | p->sreg2, p->ireg, p->select_state, p->event); | ||
166 | 195 | ||
167 | idx = (idx + 1) & (ESP_EVENT_LOG_SZ - 1); | 196 | idx = (idx + 1) & (ESP_EVENT_LOG_SZ - 1); |
168 | } while (idx != stop); | 197 | } while (idx != stop); |
@@ -176,9 +205,8 @@ static void esp_flush_fifo(struct esp *esp) | |||
176 | 205 | ||
177 | while (esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES) { | 206 | while (esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES) { |
178 | if (--lim == 0) { | 207 | if (--lim == 0) { |
179 | printk(KERN_ALERT PFX "esp%d: ESP_FF_BYTES " | 208 | shost_printk(KERN_ALERT, esp->host, |
180 | "will not clear!\n", | 209 | "ESP_FF_BYTES will not clear!\n"); |
181 | esp->host->unique_id); | ||
182 | break; | 210 | break; |
183 | } | 211 | } |
184 | udelay(1); | 212 | udelay(1); |
@@ -240,6 +268,19 @@ static void esp_reset_esp(struct esp *esp) | |||
240 | } else { | 268 | } else { |
241 | esp->min_period = ((5 * esp->ccycle) / 1000); | 269 | esp->min_period = ((5 * esp->ccycle) / 1000); |
242 | } | 270 | } |
271 | if (esp->rev == FAS236) { | ||
272 | /* | ||
273 | * The AM53c974 chip returns the same ID as FAS236; | ||
274 | * try to configure glitch eater. | ||
275 | */ | ||
276 | u8 config4 = ESP_CONFIG4_GE1; | ||
277 | esp_write8(config4, ESP_CFG4); | ||
278 | config4 = esp_read8(ESP_CFG4); | ||
279 | if (config4 & ESP_CONFIG4_GE1) { | ||
280 | esp->rev = PCSCSI; | ||
281 | esp_write8(esp->config4, ESP_CFG4); | ||
282 | } | ||
283 | } | ||
243 | esp->max_period = (esp->max_period + 3)>>2; | 284 | esp->max_period = (esp->max_period + 3)>>2; |
244 | esp->min_period = (esp->min_period + 3)>>2; | 285 | esp->min_period = (esp->min_period + 3)>>2; |
245 | 286 | ||
@@ -265,7 +306,8 @@ static void esp_reset_esp(struct esp *esp) | |||
265 | /* fallthrough... */ | 306 | /* fallthrough... */ |
266 | 307 | ||
267 | case FAS236: | 308 | case FAS236: |
268 | /* Fast 236 or HME */ | 309 | case PCSCSI: |
310 | /* Fast 236, AM53c974 or HME */ | ||
269 | esp_write8(esp->config2, ESP_CFG2); | 311 | esp_write8(esp->config2, ESP_CFG2); |
270 | if (esp->rev == FASHME) { | 312 | if (esp->rev == FASHME) { |
271 | u8 cfg3 = esp->target[0].esp_config3; | 313 | u8 cfg3 = esp->target[0].esp_config3; |
@@ -383,12 +425,11 @@ static void esp_advance_dma(struct esp *esp, struct esp_cmd_entry *ent, | |||
383 | p->cur_residue -= len; | 425 | p->cur_residue -= len; |
384 | p->tot_residue -= len; | 426 | p->tot_residue -= len; |
385 | if (p->cur_residue < 0 || p->tot_residue < 0) { | 427 | if (p->cur_residue < 0 || p->tot_residue < 0) { |
386 | printk(KERN_ERR PFX "esp%d: Data transfer overflow.\n", | 428 | shost_printk(KERN_ERR, esp->host, |
387 | esp->host->unique_id); | 429 | "Data transfer overflow.\n"); |
388 | printk(KERN_ERR PFX "esp%d: cur_residue[%d] tot_residue[%d] " | 430 | shost_printk(KERN_ERR, esp->host, |
389 | "len[%u]\n", | 431 | "cur_residue[%d] tot_residue[%d] len[%u]\n", |
390 | esp->host->unique_id, | 432 | p->cur_residue, p->tot_residue, len); |
391 | p->cur_residue, p->tot_residue, len); | ||
392 | p->cur_residue = 0; | 433 | p->cur_residue = 0; |
393 | p->tot_residue = 0; | 434 | p->tot_residue = 0; |
394 | } | 435 | } |
@@ -604,9 +645,8 @@ static void esp_autosense(struct esp *esp, struct esp_cmd_entry *ent) | |||
604 | 645 | ||
605 | 646 | ||
606 | if (!ent->sense_ptr) { | 647 | if (!ent->sense_ptr) { |
607 | esp_log_autosense("esp%d: Doing auto-sense for " | 648 | esp_log_autosense("Doing auto-sense for tgt[%d] lun[%d]\n", |
608 | "tgt[%d] lun[%d]\n", | 649 | tgt, lun); |
609 | esp->host->unique_id, tgt, lun); | ||
610 | 650 | ||
611 | ent->sense_ptr = cmd->sense_buffer; | 651 | ent->sense_ptr = cmd->sense_buffer; |
612 | ent->sense_dma = esp->ops->map_single(esp, | 652 | ent->sense_dma = esp->ops->map_single(esp, |
@@ -642,10 +682,7 @@ static void esp_autosense(struct esp *esp, struct esp_cmd_entry *ent) | |||
642 | 682 | ||
643 | val = (p - esp->command_block); | 683 | val = (p - esp->command_block); |
644 | 684 | ||
645 | if (esp->rev == FASHME) | 685 | esp_send_dma_cmd(esp, val, 16, ESP_CMD_SELA); |
646 | scsi_esp_cmd(esp, ESP_CMD_FLUSH); | ||
647 | esp->ops->send_dma_cmd(esp, esp->command_block_dma, | ||
648 | val, 16, 0, ESP_CMD_DMA | ESP_CMD_SELA); | ||
649 | } | 686 | } |
650 | 687 | ||
651 | static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp) | 688 | static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp) |
@@ -663,7 +700,7 @@ static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp) | |||
663 | return ent; | 700 | return ent; |
664 | } | 701 | } |
665 | 702 | ||
666 | if (!scsi_populate_tag_msg(cmd, &ent->tag[0])) { | 703 | if (!spi_populate_tag_msg(&ent->tag[0], cmd)) { |
667 | ent->tag[0] = 0; | 704 | ent->tag[0] = 0; |
668 | ent->tag[1] = 0; | 705 | ent->tag[1] = 0; |
669 | } | 706 | } |
@@ -781,12 +818,12 @@ build_identify: | |||
781 | } | 818 | } |
782 | 819 | ||
783 | if (!(esp->flags & ESP_FLAG_DOING_SLOWCMD)) { | 820 | if (!(esp->flags & ESP_FLAG_DOING_SLOWCMD)) { |
784 | start_cmd = ESP_CMD_DMA | ESP_CMD_SELA; | 821 | start_cmd = ESP_CMD_SELA; |
785 | if (ent->tag[0]) { | 822 | if (ent->tag[0]) { |
786 | *p++ = ent->tag[0]; | 823 | *p++ = ent->tag[0]; |
787 | *p++ = ent->tag[1]; | 824 | *p++ = ent->tag[1]; |
788 | 825 | ||
789 | start_cmd = ESP_CMD_DMA | ESP_CMD_SA3; | 826 | start_cmd = ESP_CMD_SA3; |
790 | } | 827 | } |
791 | 828 | ||
792 | for (i = 0; i < cmd->cmd_len; i++) | 829 | for (i = 0; i < cmd->cmd_len; i++) |
@@ -806,7 +843,7 @@ build_identify: | |||
806 | esp->msg_out_len += 2; | 843 | esp->msg_out_len += 2; |
807 | } | 844 | } |
808 | 845 | ||
809 | start_cmd = ESP_CMD_DMA | ESP_CMD_SELAS; | 846 | start_cmd = ESP_CMD_SELAS; |
810 | esp->select_state = ESP_SELECT_MSGOUT; | 847 | esp->select_state = ESP_SELECT_MSGOUT; |
811 | } | 848 | } |
812 | val = tgt; | 849 | val = tgt; |
@@ -826,10 +863,7 @@ build_identify: | |||
826 | printk("]\n"); | 863 | printk("]\n"); |
827 | } | 864 | } |
828 | 865 | ||
829 | if (esp->rev == FASHME) | 866 | esp_send_dma_cmd(esp, val, 16, start_cmd); |
830 | scsi_esp_cmd(esp, ESP_CMD_FLUSH); | ||
831 | esp->ops->send_dma_cmd(esp, esp->command_block_dma, | ||
832 | val, 16, 0, start_cmd); | ||
833 | } | 867 | } |
834 | 868 | ||
835 | static struct esp_cmd_entry *esp_get_ent(struct esp *esp) | 869 | static struct esp_cmd_entry *esp_get_ent(struct esp *esp) |
@@ -953,8 +987,8 @@ static int esp_check_gross_error(struct esp *esp) | |||
953 | * - DMA programmed with wrong direction | 987 | * - DMA programmed with wrong direction |
954 | * - improper phase change | 988 | * - improper phase change |
955 | */ | 989 | */ |
956 | printk(KERN_ERR PFX "esp%d: Gross error sreg[%02x]\n", | 990 | shost_printk(KERN_ERR, esp->host, |
957 | esp->host->unique_id, esp->sreg); | 991 | "Gross error sreg[%02x]\n", esp->sreg); |
958 | /* XXX Reset the chip. XXX */ | 992 | /* XXX Reset the chip. XXX */ |
959 | return 1; | 993 | return 1; |
960 | } | 994 | } |
@@ -974,7 +1008,6 @@ static int esp_check_spur_intr(struct esp *esp) | |||
974 | 1008 | ||
975 | default: | 1009 | default: |
976 | if (!(esp->sreg & ESP_STAT_INTR)) { | 1010 | if (!(esp->sreg & ESP_STAT_INTR)) { |
977 | esp->ireg = esp_read8(ESP_INTRPT); | ||
978 | if (esp->ireg & ESP_INTR_SR) | 1011 | if (esp->ireg & ESP_INTR_SR) |
979 | return 1; | 1012 | return 1; |
980 | 1013 | ||
@@ -982,14 +1015,13 @@ static int esp_check_spur_intr(struct esp *esp) | |||
982 | * ESP is not, the only possibility is a DMA error. | 1015 | * ESP is not, the only possibility is a DMA error. |
983 | */ | 1016 | */ |
984 | if (!esp->ops->dma_error(esp)) { | 1017 | if (!esp->ops->dma_error(esp)) { |
985 | printk(KERN_ERR PFX "esp%d: Spurious irq, " | 1018 | shost_printk(KERN_ERR, esp->host, |
986 | "sreg=%02x.\n", | 1019 | "Spurious irq, sreg=%02x.\n", |
987 | esp->host->unique_id, esp->sreg); | 1020 | esp->sreg); |
988 | return -1; | 1021 | return -1; |
989 | } | 1022 | } |
990 | 1023 | ||
991 | printk(KERN_ERR PFX "esp%d: DMA error\n", | 1024 | shost_printk(KERN_ERR, esp->host, "DMA error\n"); |
992 | esp->host->unique_id); | ||
993 | 1025 | ||
994 | /* XXX Reset the chip. XXX */ | 1026 | /* XXX Reset the chip. XXX */ |
995 | return -1; | 1027 | return -1; |
@@ -1002,7 +1034,7 @@ static int esp_check_spur_intr(struct esp *esp) | |||
1002 | 1034 | ||
1003 | static void esp_schedule_reset(struct esp *esp) | 1035 | static void esp_schedule_reset(struct esp *esp) |
1004 | { | 1036 | { |
1005 | esp_log_reset("ESP: esp_schedule_reset() from %pf\n", | 1037 | esp_log_reset("esp_schedule_reset() from %pf\n", |
1006 | __builtin_return_address(0)); | 1038 | __builtin_return_address(0)); |
1007 | esp->flags |= ESP_FLAG_RESETTING; | 1039 | esp->flags |= ESP_FLAG_RESETTING; |
1008 | esp_event(esp, ESP_EVENT_RESET); | 1040 | esp_event(esp, ESP_EVENT_RESET); |
@@ -1019,20 +1051,20 @@ static struct esp_cmd_entry *esp_reconnect_with_tag(struct esp *esp, | |||
1019 | int i; | 1051 | int i; |
1020 | 1052 | ||
1021 | if (!lp->num_tagged) { | 1053 | if (!lp->num_tagged) { |
1022 | printk(KERN_ERR PFX "esp%d: Reconnect w/num_tagged==0\n", | 1054 | shost_printk(KERN_ERR, esp->host, |
1023 | esp->host->unique_id); | 1055 | "Reconnect w/num_tagged==0\n"); |
1024 | return NULL; | 1056 | return NULL; |
1025 | } | 1057 | } |
1026 | 1058 | ||
1027 | esp_log_reconnect("ESP: reconnect tag, "); | 1059 | esp_log_reconnect("reconnect tag, "); |
1028 | 1060 | ||
1029 | for (i = 0; i < ESP_QUICKIRQ_LIMIT; i++) { | 1061 | for (i = 0; i < ESP_QUICKIRQ_LIMIT; i++) { |
1030 | if (esp->ops->irq_pending(esp)) | 1062 | if (esp->ops->irq_pending(esp)) |
1031 | break; | 1063 | break; |
1032 | } | 1064 | } |
1033 | if (i == ESP_QUICKIRQ_LIMIT) { | 1065 | if (i == ESP_QUICKIRQ_LIMIT) { |
1034 | printk(KERN_ERR PFX "esp%d: Reconnect IRQ1 timeout\n", | 1066 | shost_printk(KERN_ERR, esp->host, |
1035 | esp->host->unique_id); | 1067 | "Reconnect IRQ1 timeout\n"); |
1036 | return NULL; | 1068 | return NULL; |
1037 | } | 1069 | } |
1038 | 1070 | ||
@@ -1043,14 +1075,14 @@ static struct esp_cmd_entry *esp_reconnect_with_tag(struct esp *esp, | |||
1043 | i, esp->ireg, esp->sreg); | 1075 | i, esp->ireg, esp->sreg); |
1044 | 1076 | ||
1045 | if (esp->ireg & ESP_INTR_DC) { | 1077 | if (esp->ireg & ESP_INTR_DC) { |
1046 | printk(KERN_ERR PFX "esp%d: Reconnect, got disconnect.\n", | 1078 | shost_printk(KERN_ERR, esp->host, |
1047 | esp->host->unique_id); | 1079 | "Reconnect, got disconnect.\n"); |
1048 | return NULL; | 1080 | return NULL; |
1049 | } | 1081 | } |
1050 | 1082 | ||
1051 | if ((esp->sreg & ESP_STAT_PMASK) != ESP_MIP) { | 1083 | if ((esp->sreg & ESP_STAT_PMASK) != ESP_MIP) { |
1052 | printk(KERN_ERR PFX "esp%d: Reconnect, not MIP sreg[%02x].\n", | 1084 | shost_printk(KERN_ERR, esp->host, |
1053 | esp->host->unique_id, esp->sreg); | 1085 | "Reconnect, not MIP sreg[%02x].\n", esp->sreg); |
1054 | return NULL; | 1086 | return NULL; |
1055 | } | 1087 | } |
1056 | 1088 | ||
@@ -1073,8 +1105,7 @@ static struct esp_cmd_entry *esp_reconnect_with_tag(struct esp *esp, | |||
1073 | udelay(1); | 1105 | udelay(1); |
1074 | } | 1106 | } |
1075 | if (i == ESP_RESELECT_TAG_LIMIT) { | 1107 | if (i == ESP_RESELECT_TAG_LIMIT) { |
1076 | printk(KERN_ERR PFX "esp%d: Reconnect IRQ2 timeout\n", | 1108 | shost_printk(KERN_ERR, esp->host, "Reconnect IRQ2 timeout\n"); |
1077 | esp->host->unique_id); | ||
1078 | return NULL; | 1109 | return NULL; |
1079 | } | 1110 | } |
1080 | esp->ops->dma_drain(esp); | 1111 | esp->ops->dma_drain(esp); |
@@ -1087,17 +1118,17 @@ static struct esp_cmd_entry *esp_reconnect_with_tag(struct esp *esp, | |||
1087 | 1118 | ||
1088 | if (esp->command_block[0] < SIMPLE_QUEUE_TAG || | 1119 | if (esp->command_block[0] < SIMPLE_QUEUE_TAG || |
1089 | esp->command_block[0] > ORDERED_QUEUE_TAG) { | 1120 | esp->command_block[0] > ORDERED_QUEUE_TAG) { |
1090 | printk(KERN_ERR PFX "esp%d: Reconnect, bad tag " | 1121 | shost_printk(KERN_ERR, esp->host, |
1091 | "type %02x.\n", | 1122 | "Reconnect, bad tag type %02x.\n", |
1092 | esp->host->unique_id, esp->command_block[0]); | 1123 | esp->command_block[0]); |
1093 | return NULL; | 1124 | return NULL; |
1094 | } | 1125 | } |
1095 | 1126 | ||
1096 | ent = lp->tagged_cmds[esp->command_block[1]]; | 1127 | ent = lp->tagged_cmds[esp->command_block[1]]; |
1097 | if (!ent) { | 1128 | if (!ent) { |
1098 | printk(KERN_ERR PFX "esp%d: Reconnect, no entry for " | 1129 | shost_printk(KERN_ERR, esp->host, |
1099 | "tag %02x.\n", | 1130 | "Reconnect, no entry for tag %02x.\n", |
1100 | esp->host->unique_id, esp->command_block[1]); | 1131 | esp->command_block[1]); |
1101 | return NULL; | 1132 | return NULL; |
1102 | } | 1133 | } |
1103 | 1134 | ||
@@ -1163,9 +1194,9 @@ static int esp_reconnect(struct esp *esp) | |||
1163 | tp = &esp->target[target]; | 1194 | tp = &esp->target[target]; |
1164 | dev = __scsi_device_lookup_by_target(tp->starget, lun); | 1195 | dev = __scsi_device_lookup_by_target(tp->starget, lun); |
1165 | if (!dev) { | 1196 | if (!dev) { |
1166 | printk(KERN_ERR PFX "esp%d: Reconnect, no lp " | 1197 | shost_printk(KERN_ERR, esp->host, |
1167 | "tgt[%u] lun[%u]\n", | 1198 | "Reconnect, no lp tgt[%u] lun[%u]\n", |
1168 | esp->host->unique_id, target, lun); | 1199 | target, lun); |
1169 | goto do_reset; | 1200 | goto do_reset; |
1170 | } | 1201 | } |
1171 | lp = dev->hostdata; | 1202 | lp = dev->hostdata; |
@@ -1291,8 +1322,8 @@ static int esp_finish_select(struct esp *esp) | |||
1291 | return 0; | 1322 | return 0; |
1292 | } | 1323 | } |
1293 | 1324 | ||
1294 | printk("ESP: Unexpected selection completion ireg[%x].\n", | 1325 | shost_printk(KERN_INFO, esp->host, |
1295 | esp->ireg); | 1326 | "Unexpected selection completion ireg[%x]\n", esp->ireg); |
1296 | esp_schedule_reset(esp); | 1327 | esp_schedule_reset(esp); |
1297 | return 0; | 1328 | return 0; |
1298 | } | 1329 | } |
@@ -1312,11 +1343,42 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent, | |||
1312 | (((unsigned int)esp_read8(ESP_TCMED)) << 8)); | 1343 | (((unsigned int)esp_read8(ESP_TCMED)) << 8)); |
1313 | if (esp->rev == FASHME) | 1344 | if (esp->rev == FASHME) |
1314 | ecount |= ((unsigned int)esp_read8(FAS_RLO)) << 16; | 1345 | ecount |= ((unsigned int)esp_read8(FAS_RLO)) << 16; |
1346 | if (esp->rev == PCSCSI && (esp->config2 & ESP_CONFIG2_FENAB)) | ||
1347 | ecount |= ((unsigned int)esp_read8(ESP_TCHI)) << 16; | ||
1315 | } | 1348 | } |
1316 | 1349 | ||
1317 | bytes_sent = esp->data_dma_len; | 1350 | bytes_sent = esp->data_dma_len; |
1318 | bytes_sent -= ecount; | 1351 | bytes_sent -= ecount; |
1319 | 1352 | ||
1353 | /* | ||
1354 | * The am53c974 has a DMA 'pecularity'. The doc states: | ||
1355 | * In some odd byte conditions, one residual byte will | ||
1356 | * be left in the SCSI FIFO, and the FIFO Flags will | ||
1357 | * never count to '0 '. When this happens, the residual | ||
1358 | * byte should be retrieved via PIO following completion | ||
1359 | * of the BLAST operation. | ||
1360 | */ | ||
1361 | if (fifo_cnt == 1 && ent->flags & ESP_CMD_FLAG_RESIDUAL) { | ||
1362 | size_t count = 1; | ||
1363 | size_t offset = bytes_sent; | ||
1364 | u8 bval = esp_read8(ESP_FDATA); | ||
1365 | |||
1366 | if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) | ||
1367 | ent->sense_ptr[bytes_sent] = bval; | ||
1368 | else { | ||
1369 | struct esp_cmd_priv *p = ESP_CMD_PRIV(cmd); | ||
1370 | u8 *ptr; | ||
1371 | |||
1372 | ptr = scsi_kmap_atomic_sg(p->cur_sg, p->u.num_sg, | ||
1373 | &offset, &count); | ||
1374 | if (likely(ptr)) { | ||
1375 | *(ptr + offset) = bval; | ||
1376 | scsi_kunmap_atomic_sg(ptr); | ||
1377 | } | ||
1378 | } | ||
1379 | bytes_sent += fifo_cnt; | ||
1380 | ent->flags &= ~ESP_CMD_FLAG_RESIDUAL; | ||
1381 | } | ||
1320 | if (!(ent->flags & ESP_CMD_FLAG_WRITE)) | 1382 | if (!(ent->flags & ESP_CMD_FLAG_WRITE)) |
1321 | bytes_sent -= fifo_cnt; | 1383 | bytes_sent -= fifo_cnt; |
1322 | 1384 | ||
@@ -1556,8 +1618,8 @@ static void esp_msgin_extended(struct esp *esp) | |||
1556 | return; | 1618 | return; |
1557 | } | 1619 | } |
1558 | 1620 | ||
1559 | printk("ESP: Unexpected extended msg type %x\n", | 1621 | shost_printk(KERN_INFO, esp->host, |
1560 | esp->msg_in[2]); | 1622 | "Unexpected extended msg type %x\n", esp->msg_in[2]); |
1561 | 1623 | ||
1562 | esp->msg_out[0] = ABORT_TASK_SET; | 1624 | esp->msg_out[0] = ABORT_TASK_SET; |
1563 | esp->msg_out_len = 1; | 1625 | esp->msg_out_len = 1; |
@@ -1574,7 +1636,8 @@ static int esp_msgin_process(struct esp *esp) | |||
1574 | 1636 | ||
1575 | if (msg0 & 0x80) { | 1637 | if (msg0 & 0x80) { |
1576 | /* Identify */ | 1638 | /* Identify */ |
1577 | printk("ESP: Unexpected msgin identify\n"); | 1639 | shost_printk(KERN_INFO, esp->host, |
1640 | "Unexpected msgin identify\n"); | ||
1578 | return 0; | 1641 | return 0; |
1579 | } | 1642 | } |
1580 | 1643 | ||
@@ -1640,10 +1703,12 @@ static int esp_msgin_process(struct esp *esp) | |||
1640 | 1703 | ||
1641 | static int esp_process_event(struct esp *esp) | 1704 | static int esp_process_event(struct esp *esp) |
1642 | { | 1705 | { |
1643 | int write; | 1706 | int write, i; |
1644 | 1707 | ||
1645 | again: | 1708 | again: |
1646 | write = 0; | 1709 | write = 0; |
1710 | esp_log_event("process event %d phase %x\n", | ||
1711 | esp->event, esp->sreg & ESP_STAT_PMASK); | ||
1647 | switch (esp->event) { | 1712 | switch (esp->event) { |
1648 | case ESP_EVENT_CHECK_PHASE: | 1713 | case ESP_EVENT_CHECK_PHASE: |
1649 | switch (esp->sreg & ESP_STAT_PMASK) { | 1714 | switch (esp->sreg & ESP_STAT_PMASK) { |
@@ -1673,8 +1738,9 @@ again: | |||
1673 | break; | 1738 | break; |
1674 | 1739 | ||
1675 | default: | 1740 | default: |
1676 | printk("ESP: Unexpected phase, sreg=%02x\n", | 1741 | shost_printk(KERN_INFO, esp->host, |
1677 | esp->sreg); | 1742 | "Unexpected phase, sreg=%02x\n", |
1743 | esp->sreg); | ||
1678 | esp_schedule_reset(esp); | 1744 | esp_schedule_reset(esp); |
1679 | return 0; | 1745 | return 0; |
1680 | } | 1746 | } |
@@ -1708,18 +1774,17 @@ again: | |||
1708 | esp->data_dma_len = dma_len; | 1774 | esp->data_dma_len = dma_len; |
1709 | 1775 | ||
1710 | if (!dma_len) { | 1776 | if (!dma_len) { |
1711 | printk(KERN_ERR PFX "esp%d: DMA length is zero!\n", | 1777 | shost_printk(KERN_ERR, esp->host, |
1712 | esp->host->unique_id); | 1778 | "DMA length is zero!\n"); |
1713 | printk(KERN_ERR PFX "esp%d: cur adr[%08llx] len[%08x]\n", | 1779 | shost_printk(KERN_ERR, esp->host, |
1714 | esp->host->unique_id, | 1780 | "cur adr[%08llx] len[%08x]\n", |
1715 | (unsigned long long)esp_cur_dma_addr(ent, cmd), | 1781 | (unsigned long long)esp_cur_dma_addr(ent, cmd), |
1716 | esp_cur_dma_len(ent, cmd)); | 1782 | esp_cur_dma_len(ent, cmd)); |
1717 | esp_schedule_reset(esp); | 1783 | esp_schedule_reset(esp); |
1718 | return 0; | 1784 | return 0; |
1719 | } | 1785 | } |
1720 | 1786 | ||
1721 | esp_log_datastart("ESP: start data addr[%08llx] len[%u] " | 1787 | esp_log_datastart("start data addr[%08llx] len[%u] write(%d)\n", |
1722 | "write(%d)\n", | ||
1723 | (unsigned long long)dma_addr, dma_len, write); | 1788 | (unsigned long long)dma_addr, dma_len, write); |
1724 | 1789 | ||
1725 | esp->ops->send_dma_cmd(esp, dma_addr, dma_len, dma_len, | 1790 | esp->ops->send_dma_cmd(esp, dma_addr, dma_len, dma_len, |
@@ -1733,7 +1798,8 @@ again: | |||
1733 | int bytes_sent; | 1798 | int bytes_sent; |
1734 | 1799 | ||
1735 | if (esp->ops->dma_error(esp)) { | 1800 | if (esp->ops->dma_error(esp)) { |
1736 | printk("ESP: data done, DMA error, resetting\n"); | 1801 | shost_printk(KERN_INFO, esp->host, |
1802 | "data done, DMA error, resetting\n"); | ||
1737 | esp_schedule_reset(esp); | 1803 | esp_schedule_reset(esp); |
1738 | return 0; | 1804 | return 0; |
1739 | } | 1805 | } |
@@ -1749,14 +1815,15 @@ again: | |||
1749 | /* We should always see exactly a bus-service | 1815 | /* We should always see exactly a bus-service |
1750 | * interrupt at the end of a successful transfer. | 1816 | * interrupt at the end of a successful transfer. |
1751 | */ | 1817 | */ |
1752 | printk("ESP: data done, not BSERV, resetting\n"); | 1818 | shost_printk(KERN_INFO, esp->host, |
1819 | "data done, not BSERV, resetting\n"); | ||
1753 | esp_schedule_reset(esp); | 1820 | esp_schedule_reset(esp); |
1754 | return 0; | 1821 | return 0; |
1755 | } | 1822 | } |
1756 | 1823 | ||
1757 | bytes_sent = esp_data_bytes_sent(esp, ent, cmd); | 1824 | bytes_sent = esp_data_bytes_sent(esp, ent, cmd); |
1758 | 1825 | ||
1759 | esp_log_datadone("ESP: data done flgs[%x] sent[%d]\n", | 1826 | esp_log_datadone("data done flgs[%x] sent[%d]\n", |
1760 | ent->flags, bytes_sent); | 1827 | ent->flags, bytes_sent); |
1761 | 1828 | ||
1762 | if (bytes_sent < 0) { | 1829 | if (bytes_sent < 0) { |
@@ -1785,8 +1852,9 @@ again: | |||
1785 | } | 1852 | } |
1786 | 1853 | ||
1787 | if (ent->message != COMMAND_COMPLETE) { | 1854 | if (ent->message != COMMAND_COMPLETE) { |
1788 | printk("ESP: Unexpected message %x in status\n", | 1855 | shost_printk(KERN_INFO, esp->host, |
1789 | ent->message); | 1856 | "Unexpected message %x in status\n", |
1857 | ent->message); | ||
1790 | esp_schedule_reset(esp); | 1858 | esp_schedule_reset(esp); |
1791 | return 0; | 1859 | return 0; |
1792 | } | 1860 | } |
@@ -1804,8 +1872,7 @@ again: | |||
1804 | scsi_esp_cmd(esp, ESP_CMD_ESEL); | 1872 | scsi_esp_cmd(esp, ESP_CMD_ESEL); |
1805 | 1873 | ||
1806 | if (ent->message == COMMAND_COMPLETE) { | 1874 | if (ent->message == COMMAND_COMPLETE) { |
1807 | esp_log_cmddone("ESP: Command done status[%x] " | 1875 | esp_log_cmddone("Command done status[%x] message[%x]\n", |
1808 | "message[%x]\n", | ||
1809 | ent->status, ent->message); | 1876 | ent->status, ent->message); |
1810 | if (ent->status == SAM_STAT_TASK_SET_FULL) | 1877 | if (ent->status == SAM_STAT_TASK_SET_FULL) |
1811 | esp_event_queue_full(esp, ent); | 1878 | esp_event_queue_full(esp, ent); |
@@ -1821,16 +1888,16 @@ again: | |||
1821 | DID_OK)); | 1888 | DID_OK)); |
1822 | } | 1889 | } |
1823 | } else if (ent->message == DISCONNECT) { | 1890 | } else if (ent->message == DISCONNECT) { |
1824 | esp_log_disconnect("ESP: Disconnecting tgt[%d] " | 1891 | esp_log_disconnect("Disconnecting tgt[%d] tag[%x:%x]\n", |
1825 | "tag[%x:%x]\n", | ||
1826 | cmd->device->id, | 1892 | cmd->device->id, |
1827 | ent->tag[0], ent->tag[1]); | 1893 | ent->tag[0], ent->tag[1]); |
1828 | 1894 | ||
1829 | esp->active_cmd = NULL; | 1895 | esp->active_cmd = NULL; |
1830 | esp_maybe_execute_command(esp); | 1896 | esp_maybe_execute_command(esp); |
1831 | } else { | 1897 | } else { |
1832 | printk("ESP: Unexpected message %x in freebus\n", | 1898 | shost_printk(KERN_INFO, esp->host, |
1833 | ent->message); | 1899 | "Unexpected message %x in freebus\n", |
1900 | ent->message); | ||
1834 | esp_schedule_reset(esp); | 1901 | esp_schedule_reset(esp); |
1835 | return 0; | 1902 | return 0; |
1836 | } | 1903 | } |
@@ -1862,6 +1929,10 @@ again: | |||
1862 | if (esp->msg_out_len == 1) { | 1929 | if (esp->msg_out_len == 1) { |
1863 | esp_write8(esp->msg_out[0], ESP_FDATA); | 1930 | esp_write8(esp->msg_out[0], ESP_FDATA); |
1864 | scsi_esp_cmd(esp, ESP_CMD_TI); | 1931 | scsi_esp_cmd(esp, ESP_CMD_TI); |
1932 | } else if (esp->flags & ESP_FLAG_USE_FIFO) { | ||
1933 | for (i = 0; i < esp->msg_out_len; i++) | ||
1934 | esp_write8(esp->msg_out[i], ESP_FDATA); | ||
1935 | scsi_esp_cmd(esp, ESP_CMD_TI); | ||
1865 | } else { | 1936 | } else { |
1866 | /* Use DMA. */ | 1937 | /* Use DMA. */ |
1867 | memcpy(esp->command_block, | 1938 | memcpy(esp->command_block, |
@@ -1917,7 +1988,7 @@ again: | |||
1917 | val = esp_read8(ESP_FDATA); | 1988 | val = esp_read8(ESP_FDATA); |
1918 | esp->msg_in[esp->msg_in_len++] = val; | 1989 | esp->msg_in[esp->msg_in_len++] = val; |
1919 | 1990 | ||
1920 | esp_log_msgin("ESP: Got msgin byte %x\n", val); | 1991 | esp_log_msgin("Got msgin byte %x\n", val); |
1921 | 1992 | ||
1922 | if (!esp_msgin_process(esp)) | 1993 | if (!esp_msgin_process(esp)) |
1923 | esp->msg_in_len = 0; | 1994 | esp->msg_in_len = 0; |
@@ -1930,7 +2001,8 @@ again: | |||
1930 | if (esp->event != ESP_EVENT_FREE_BUS) | 2001 | if (esp->event != ESP_EVENT_FREE_BUS) |
1931 | esp_event(esp, ESP_EVENT_CHECK_PHASE); | 2002 | esp_event(esp, ESP_EVENT_CHECK_PHASE); |
1932 | } else { | 2003 | } else { |
1933 | printk("ESP: MSGIN neither BSERV not FDON, resetting"); | 2004 | shost_printk(KERN_INFO, esp->host, |
2005 | "MSGIN neither BSERV not FDON, resetting"); | ||
1934 | esp_schedule_reset(esp); | 2006 | esp_schedule_reset(esp); |
1935 | return 0; | 2007 | return 0; |
1936 | } | 2008 | } |
@@ -1938,11 +2010,7 @@ again: | |||
1938 | case ESP_EVENT_CMD_START: | 2010 | case ESP_EVENT_CMD_START: |
1939 | memcpy(esp->command_block, esp->cmd_bytes_ptr, | 2011 | memcpy(esp->command_block, esp->cmd_bytes_ptr, |
1940 | esp->cmd_bytes_left); | 2012 | esp->cmd_bytes_left); |
1941 | if (esp->rev == FASHME) | 2013 | esp_send_dma_cmd(esp, esp->cmd_bytes_left, 16, ESP_CMD_TI); |
1942 | scsi_esp_cmd(esp, ESP_CMD_FLUSH); | ||
1943 | esp->ops->send_dma_cmd(esp, esp->command_block_dma, | ||
1944 | esp->cmd_bytes_left, 16, 0, | ||
1945 | ESP_CMD_DMA | ESP_CMD_TI); | ||
1946 | esp_event(esp, ESP_EVENT_CMD_DONE); | 2014 | esp_event(esp, ESP_EVENT_CMD_DONE); |
1947 | esp->flags |= ESP_FLAG_QUICKIRQ_CHECK; | 2015 | esp->flags |= ESP_FLAG_QUICKIRQ_CHECK; |
1948 | break; | 2016 | break; |
@@ -1961,8 +2029,8 @@ again: | |||
1961 | break; | 2029 | break; |
1962 | 2030 | ||
1963 | default: | 2031 | default: |
1964 | printk("ESP: Unexpected event %x, resetting\n", | 2032 | shost_printk(KERN_INFO, esp->host, |
1965 | esp->event); | 2033 | "Unexpected event %x, resetting\n", esp->event); |
1966 | esp_schedule_reset(esp); | 2034 | esp_schedule_reset(esp); |
1967 | return 0; | 2035 | return 0; |
1968 | break; | 2036 | break; |
@@ -2044,7 +2112,12 @@ static void __esp_interrupt(struct esp *esp) | |||
2044 | int finish_reset, intr_done; | 2112 | int finish_reset, intr_done; |
2045 | u8 phase; | 2113 | u8 phase; |
2046 | 2114 | ||
2115 | /* | ||
2116 | * Once INTRPT is read STATUS and SSTEP are cleared. | ||
2117 | */ | ||
2047 | esp->sreg = esp_read8(ESP_STATUS); | 2118 | esp->sreg = esp_read8(ESP_STATUS); |
2119 | esp->seqreg = esp_read8(ESP_SSTEP); | ||
2120 | esp->ireg = esp_read8(ESP_INTRPT); | ||
2048 | 2121 | ||
2049 | if (esp->flags & ESP_FLAG_RESETTING) { | 2122 | if (esp->flags & ESP_FLAG_RESETTING) { |
2050 | finish_reset = 1; | 2123 | finish_reset = 1; |
@@ -2057,8 +2130,6 @@ static void __esp_interrupt(struct esp *esp) | |||
2057 | return; | 2130 | return; |
2058 | } | 2131 | } |
2059 | 2132 | ||
2060 | esp->ireg = esp_read8(ESP_INTRPT); | ||
2061 | |||
2062 | if (esp->ireg & ESP_INTR_SR) | 2133 | if (esp->ireg & ESP_INTR_SR) |
2063 | finish_reset = 1; | 2134 | finish_reset = 1; |
2064 | 2135 | ||
@@ -2085,14 +2156,15 @@ static void __esp_interrupt(struct esp *esp) | |||
2085 | } | 2156 | } |
2086 | } | 2157 | } |
2087 | 2158 | ||
2088 | esp_log_intr("ESP: intr sreg[%02x] seqreg[%02x] " | 2159 | esp_log_intr("intr sreg[%02x] seqreg[%02x] " |
2089 | "sreg2[%02x] ireg[%02x]\n", | 2160 | "sreg2[%02x] ireg[%02x]\n", |
2090 | esp->sreg, esp->seqreg, esp->sreg2, esp->ireg); | 2161 | esp->sreg, esp->seqreg, esp->sreg2, esp->ireg); |
2091 | 2162 | ||
2092 | intr_done = 0; | 2163 | intr_done = 0; |
2093 | 2164 | ||
2094 | if (esp->ireg & (ESP_INTR_S | ESP_INTR_SATN | ESP_INTR_IC)) { | 2165 | if (esp->ireg & (ESP_INTR_S | ESP_INTR_SATN | ESP_INTR_IC)) { |
2095 | printk("ESP: unexpected IREG %02x\n", esp->ireg); | 2166 | shost_printk(KERN_INFO, esp->host, |
2167 | "unexpected IREG %02x\n", esp->ireg); | ||
2096 | if (esp->ireg & ESP_INTR_IC) | 2168 | if (esp->ireg & ESP_INTR_IC) |
2097 | esp_dump_cmd_log(esp); | 2169 | esp_dump_cmd_log(esp); |
2098 | 2170 | ||
@@ -2149,46 +2221,50 @@ static void esp_get_revision(struct esp *esp) | |||
2149 | u8 val; | 2221 | u8 val; |
2150 | 2222 | ||
2151 | esp->config1 = (ESP_CONFIG1_PENABLE | (esp->scsi_id & 7)); | 2223 | esp->config1 = (ESP_CONFIG1_PENABLE | (esp->scsi_id & 7)); |
2152 | esp->config2 = (ESP_CONFIG2_SCSI2ENAB | ESP_CONFIG2_REGPARITY); | 2224 | if (esp->config2 == 0) { |
2225 | esp->config2 = (ESP_CONFIG2_SCSI2ENAB | ESP_CONFIG2_REGPARITY); | ||
2226 | esp_write8(esp->config2, ESP_CFG2); | ||
2227 | |||
2228 | val = esp_read8(ESP_CFG2); | ||
2229 | val &= ~ESP_CONFIG2_MAGIC; | ||
2230 | |||
2231 | esp->config2 = 0; | ||
2232 | if (val != (ESP_CONFIG2_SCSI2ENAB | ESP_CONFIG2_REGPARITY)) { | ||
2233 | /* | ||
2234 | * If what we write to cfg2 does not come back, | ||
2235 | * cfg2 is not implemented. | ||
2236 | * Therefore this must be a plain esp100. | ||
2237 | */ | ||
2238 | esp->rev = ESP100; | ||
2239 | return; | ||
2240 | } | ||
2241 | } | ||
2242 | |||
2243 | esp_set_all_config3(esp, 5); | ||
2244 | esp->prev_cfg3 = 5; | ||
2153 | esp_write8(esp->config2, ESP_CFG2); | 2245 | esp_write8(esp->config2, ESP_CFG2); |
2246 | esp_write8(0, ESP_CFG3); | ||
2247 | esp_write8(esp->prev_cfg3, ESP_CFG3); | ||
2154 | 2248 | ||
2155 | val = esp_read8(ESP_CFG2); | 2249 | val = esp_read8(ESP_CFG3); |
2156 | val &= ~ESP_CONFIG2_MAGIC; | 2250 | if (val != 5) { |
2157 | if (val != (ESP_CONFIG2_SCSI2ENAB | ESP_CONFIG2_REGPARITY)) { | 2251 | /* The cfg2 register is implemented, however |
2158 | /* If what we write to cfg2 does not come back, cfg2 is not | 2252 | * cfg3 is not, must be esp100a. |
2159 | * implemented, therefore this must be a plain esp100. | ||
2160 | */ | 2253 | */ |
2161 | esp->rev = ESP100; | 2254 | esp->rev = ESP100A; |
2162 | } else { | 2255 | } else { |
2163 | esp->config2 = 0; | 2256 | esp_set_all_config3(esp, 0); |
2164 | esp_set_all_config3(esp, 5); | 2257 | esp->prev_cfg3 = 0; |
2165 | esp->prev_cfg3 = 5; | ||
2166 | esp_write8(esp->config2, ESP_CFG2); | ||
2167 | esp_write8(0, ESP_CFG3); | ||
2168 | esp_write8(esp->prev_cfg3, ESP_CFG3); | 2258 | esp_write8(esp->prev_cfg3, ESP_CFG3); |
2169 | 2259 | ||
2170 | val = esp_read8(ESP_CFG3); | 2260 | /* All of cfg{1,2,3} implemented, must be one of |
2171 | if (val != 5) { | 2261 | * the fas variants, figure out which one. |
2172 | /* The cfg2 register is implemented, however | 2262 | */ |
2173 | * cfg3 is not, must be esp100a. | 2263 | if (esp->cfact == 0 || esp->cfact > ESP_CCF_F5) { |
2174 | */ | 2264 | esp->rev = FAST; |
2175 | esp->rev = ESP100A; | 2265 | esp->sync_defp = SYNC_DEFP_FAST; |
2176 | } else { | 2266 | } else { |
2177 | esp_set_all_config3(esp, 0); | 2267 | esp->rev = ESP236; |
2178 | esp->prev_cfg3 = 0; | ||
2179 | esp_write8(esp->prev_cfg3, ESP_CFG3); | ||
2180 | |||
2181 | /* All of cfg{1,2,3} implemented, must be one of | ||
2182 | * the fas variants, figure out which one. | ||
2183 | */ | ||
2184 | if (esp->cfact == 0 || esp->cfact > ESP_CCF_F5) { | ||
2185 | esp->rev = FAST; | ||
2186 | esp->sync_defp = SYNC_DEFP_FAST; | ||
2187 | } else { | ||
2188 | esp->rev = ESP236; | ||
2189 | } | ||
2190 | esp->config2 = 0; | ||
2191 | esp_write8(esp->config2, ESP_CFG2); | ||
2192 | } | 2268 | } |
2193 | } | 2269 | } |
2194 | } | 2270 | } |
@@ -2308,6 +2384,7 @@ static const char *esp_chip_names[] = { | |||
2308 | "FAS100A", | 2384 | "FAS100A", |
2309 | "FAST", | 2385 | "FAST", |
2310 | "FASHME", | 2386 | "FASHME", |
2387 | "AM53C974", | ||
2311 | }; | 2388 | }; |
2312 | 2389 | ||
2313 | static struct scsi_transport_template *esp_transport_template; | 2390 | static struct scsi_transport_template *esp_transport_template; |
@@ -2317,6 +2394,10 @@ int scsi_esp_register(struct esp *esp, struct device *dev) | |||
2317 | static int instance; | 2394 | static int instance; |
2318 | int err; | 2395 | int err; |
2319 | 2396 | ||
2397 | if (!esp->num_tags) | ||
2398 | esp->num_tags = ESP_DEFAULT_TAGS; | ||
2399 | else if (esp->num_tags >= ESP_MAX_TAG) | ||
2400 | esp->num_tags = ESP_MAX_TAG - 1; | ||
2320 | esp->host->transportt = esp_transport_template; | 2401 | esp->host->transportt = esp_transport_template; |
2321 | esp->host->max_lun = ESP_MAX_LUN; | 2402 | esp->host->max_lun = ESP_MAX_LUN; |
2322 | esp->host->cmd_per_lun = 2; | 2403 | esp->host->cmd_per_lun = 2; |
@@ -2330,12 +2411,13 @@ int scsi_esp_register(struct esp *esp, struct device *dev) | |||
2330 | 2411 | ||
2331 | esp_bootup_reset(esp); | 2412 | esp_bootup_reset(esp); |
2332 | 2413 | ||
2333 | printk(KERN_INFO PFX "esp%u, regs[%1p:%1p] irq[%u]\n", | 2414 | dev_printk(KERN_INFO, dev, "esp%u: regs[%1p:%1p] irq[%u]\n", |
2334 | esp->host->unique_id, esp->regs, esp->dma_regs, | 2415 | esp->host->unique_id, esp->regs, esp->dma_regs, |
2335 | esp->host->irq); | 2416 | esp->host->irq); |
2336 | printk(KERN_INFO PFX "esp%u is a %s, %u MHz (ccf=%u), SCSI ID %u\n", | 2417 | dev_printk(KERN_INFO, dev, |
2337 | esp->host->unique_id, esp_chip_names[esp->rev], | 2418 | "esp%u: is a %s, %u MHz (ccf=%u), SCSI ID %u\n", |
2338 | esp->cfreq / 1000000, esp->cfact, esp->scsi_id); | 2419 | esp->host->unique_id, esp_chip_names[esp->rev], |
2420 | esp->cfreq / 1000000, esp->cfact, esp->scsi_id); | ||
2339 | 2421 | ||
2340 | /* Let the SCSI bus reset settle. */ | 2422 | /* Let the SCSI bus reset settle. */ |
2341 | ssleep(esp_bus_reset_settle); | 2423 | ssleep(esp_bus_reset_settle); |
@@ -2402,28 +2484,10 @@ static int esp_slave_configure(struct scsi_device *dev) | |||
2402 | { | 2484 | { |
2403 | struct esp *esp = shost_priv(dev->host); | 2485 | struct esp *esp = shost_priv(dev->host); |
2404 | struct esp_target_data *tp = &esp->target[dev->id]; | 2486 | struct esp_target_data *tp = &esp->target[dev->id]; |
2405 | int goal_tags, queue_depth; | ||
2406 | |||
2407 | goal_tags = 0; | ||
2408 | 2487 | ||
2409 | if (dev->tagged_supported) { | 2488 | if (dev->tagged_supported) |
2410 | /* XXX make this configurable somehow XXX */ | 2489 | scsi_change_queue_depth(dev, esp->num_tags); |
2411 | goal_tags = ESP_DEFAULT_TAGS; | ||
2412 | |||
2413 | if (goal_tags > ESP_MAX_TAG) | ||
2414 | goal_tags = ESP_MAX_TAG; | ||
2415 | } | ||
2416 | 2490 | ||
2417 | queue_depth = goal_tags; | ||
2418 | if (queue_depth < dev->host->cmd_per_lun) | ||
2419 | queue_depth = dev->host->cmd_per_lun; | ||
2420 | |||
2421 | if (goal_tags) { | ||
2422 | scsi_set_tag_type(dev, MSG_ORDERED_TAG); | ||
2423 | scsi_activate_tcq(dev, queue_depth); | ||
2424 | } else { | ||
2425 | scsi_deactivate_tcq(dev, queue_depth); | ||
2426 | } | ||
2427 | tp->flags |= ESP_TGT_DISCONNECT; | 2491 | tp->flags |= ESP_TGT_DISCONNECT; |
2428 | 2492 | ||
2429 | if (!spi_initial_dv(dev->sdev_target)) | 2493 | if (!spi_initial_dv(dev->sdev_target)) |
@@ -2451,19 +2515,20 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd) | |||
2451 | * XXX much for the final driver. | 2515 | * XXX much for the final driver. |
2452 | */ | 2516 | */ |
2453 | spin_lock_irqsave(esp->host->host_lock, flags); | 2517 | spin_lock_irqsave(esp->host->host_lock, flags); |
2454 | printk(KERN_ERR PFX "esp%d: Aborting command [%p:%02x]\n", | 2518 | shost_printk(KERN_ERR, esp->host, "Aborting command [%p:%02x]\n", |
2455 | esp->host->unique_id, cmd, cmd->cmnd[0]); | 2519 | cmd, cmd->cmnd[0]); |
2456 | ent = esp->active_cmd; | 2520 | ent = esp->active_cmd; |
2457 | if (ent) | 2521 | if (ent) |
2458 | printk(KERN_ERR PFX "esp%d: Current command [%p:%02x]\n", | 2522 | shost_printk(KERN_ERR, esp->host, |
2459 | esp->host->unique_id, ent->cmd, ent->cmd->cmnd[0]); | 2523 | "Current command [%p:%02x]\n", |
2524 | ent->cmd, ent->cmd->cmnd[0]); | ||
2460 | list_for_each_entry(ent, &esp->queued_cmds, list) { | 2525 | list_for_each_entry(ent, &esp->queued_cmds, list) { |
2461 | printk(KERN_ERR PFX "esp%d: Queued command [%p:%02x]\n", | 2526 | shost_printk(KERN_ERR, esp->host, "Queued command [%p:%02x]\n", |
2462 | esp->host->unique_id, ent->cmd, ent->cmd->cmnd[0]); | 2527 | ent->cmd, ent->cmd->cmnd[0]); |
2463 | } | 2528 | } |
2464 | list_for_each_entry(ent, &esp->active_cmds, list) { | 2529 | list_for_each_entry(ent, &esp->active_cmds, list) { |
2465 | printk(KERN_ERR PFX "esp%d: Active command [%p:%02x]\n", | 2530 | shost_printk(KERN_ERR, esp->host, " Active command [%p:%02x]\n", |
2466 | esp->host->unique_id, ent->cmd, ent->cmd->cmnd[0]); | 2531 | ent->cmd, ent->cmd->cmnd[0]); |
2467 | } | 2532 | } |
2468 | esp_dump_cmd_log(esp); | 2533 | esp_dump_cmd_log(esp); |
2469 | spin_unlock_irqrestore(esp->host->host_lock, flags); | 2534 | spin_unlock_irqrestore(esp->host->host_lock, flags); |
@@ -2631,6 +2696,7 @@ struct scsi_host_template scsi_esp_template = { | |||
2631 | .use_clustering = ENABLE_CLUSTERING, | 2696 | .use_clustering = ENABLE_CLUSTERING, |
2632 | .max_sectors = 0xffff, | 2697 | .max_sectors = 0xffff, |
2633 | .skip_settle_delay = 1, | 2698 | .skip_settle_delay = 1, |
2699 | .use_blk_tags = 1, | ||
2634 | }; | 2700 | }; |
2635 | EXPORT_SYMBOL(scsi_esp_template); | 2701 | EXPORT_SYMBOL(scsi_esp_template); |
2636 | 2702 | ||