aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c18
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.h12
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sas.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c72
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.c5
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.h2
7 files changed, 106 insertions, 6 deletions
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 3c2d7a379931..af7e01134364 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -112,6 +112,21 @@ static int asd_init_phy(struct asd_phy *phy)
112 return 0; 112 return 0;
113} 113}
114 114
115static void asd_init_ports(struct asd_ha_struct *asd_ha)
116{
117 int i;
118
119 spin_lock_init(&asd_ha->asd_ports_lock);
120 for (i = 0; i < ASD_MAX_PHYS; i++) {
121 struct asd_port *asd_port = &asd_ha->asd_ports[i];
122
123 memset(asd_port->sas_addr, 0, SAS_ADDR_SIZE);
124 memset(asd_port->attached_sas_addr, 0, SAS_ADDR_SIZE);
125 asd_port->phy_mask = 0;
126 asd_port->num_phys = 0;
127 }
128}
129
115static int asd_init_phys(struct asd_ha_struct *asd_ha) 130static int asd_init_phys(struct asd_ha_struct *asd_ha)
116{ 131{
117 u8 i; 132 u8 i;
@@ -121,6 +136,7 @@ static int asd_init_phys(struct asd_ha_struct *asd_ha)
121 struct asd_phy *phy = &asd_ha->phys[i]; 136 struct asd_phy *phy = &asd_ha->phys[i];
122 137
123 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i]; 138 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i];
139 phy->asd_port = NULL;
124 140
125 phy->sas_phy.enabled = 0; 141 phy->sas_phy.enabled = 0;
126 phy->sas_phy.id = i; 142 phy->sas_phy.id = i;
@@ -658,6 +674,8 @@ int asd_init_hw(struct asd_ha_struct *asd_ha)
658 goto Out; 674 goto Out;
659 } 675 }
660 676
677 asd_init_ports(asd_ha);
678
661 err = asd_init_scbs(asd_ha); 679 err = asd_init_scbs(asd_ha);
662 if (err) { 680 if (err) {
663 asd_printk("couldn't initialize scbs for %s\n", 681 asd_printk("couldn't initialize scbs for %s\n",
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h b/drivers/scsi/aic94xx/aic94xx_hwi.h
index 7b6aca02cf70..c6c3d18222fa 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.h
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.h
@@ -193,6 +193,16 @@ struct asd_seq_data {
193 struct asd_ascb **escb_arr; /* array of pointers to escbs */ 193 struct asd_ascb **escb_arr; /* array of pointers to escbs */
194}; 194};
195 195
196/* This is an internal port structure. These are used to get accurate
197 * phy_mask for updating DDB 0.
198 */
199struct asd_port {
200 u8 sas_addr[SAS_ADDR_SIZE];
201 u8 attached_sas_addr[SAS_ADDR_SIZE];
202 u32 phy_mask;
203 int num_phys;
204};
205
196/* This is the Host Adapter structure. It describes the hardware 206/* This is the Host Adapter structure. It describes the hardware
197 * SAS adapter. 207 * SAS adapter.
198 */ 208 */
@@ -211,6 +221,8 @@ struct asd_ha_struct {
211 struct hw_profile hw_prof; 221 struct hw_profile hw_prof;
212 222
213 struct asd_phy phys[ASD_MAX_PHYS]; 223 struct asd_phy phys[ASD_MAX_PHYS];
224 spinlock_t asd_ports_lock;
225 struct asd_port asd_ports[ASD_MAX_PHYS];
214 struct asd_sas_port ports[ASD_MAX_PHYS]; 226 struct asd_sas_port ports[ASD_MAX_PHYS];
215 227
216 struct dma_pool *scb_pool; 228 struct dma_pool *scb_pool;
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index a4cc432bbdab..57c5ba4043f2 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -786,8 +786,6 @@ static void asd_remove_driver_attrs(struct device_driver *driver)
786} 786}
787 787
788static struct sas_domain_function_template aic94xx_transport_functions = { 788static struct sas_domain_function_template aic94xx_transport_functions = {
789 .lldd_port_formed = asd_update_port_links,
790
791 .lldd_dev_found = asd_dev_found, 789 .lldd_dev_found = asd_dev_found,
792 .lldd_dev_gone = asd_dev_gone, 790 .lldd_dev_gone = asd_dev_gone,
793 791
diff --git a/drivers/scsi/aic94xx/aic94xx_sas.h b/drivers/scsi/aic94xx/aic94xx_sas.h
index 64d231712345..9050e93bfd5e 100644
--- a/drivers/scsi/aic94xx/aic94xx_sas.h
+++ b/drivers/scsi/aic94xx/aic94xx_sas.h
@@ -733,6 +733,7 @@ struct asd_phy {
733 733
734 struct sas_identify_frame *identify_frame; 734 struct sas_identify_frame *identify_frame;
735 struct asd_dma_tok *id_frm_tok; 735 struct asd_dma_tok *id_frm_tok;
736 struct asd_port *asd_port;
736 737
737 u8 frame_rcvd[ASD_EDB_SIZE]; 738 u8 frame_rcvd[ASD_EDB_SIZE];
738}; 739};
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 7ee49b51b724..b15caf1c8fa2 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -168,6 +168,70 @@ static inline void asd_get_attached_sas_addr(struct asd_phy *phy, u8 *sas_addr)
168 } 168 }
169} 169}
170 170
171static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
172{
173 int i;
174 struct asd_port *free_port = NULL;
175 struct asd_port *port;
176 struct asd_sas_phy *sas_phy = &phy->sas_phy;
177 unsigned long flags;
178
179 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
180 if (!phy->asd_port) {
181 for (i = 0; i < ASD_MAX_PHYS; i++) {
182 port = &asd_ha->asd_ports[i];
183
184 /* Check for wide port */
185 if (port->num_phys > 0 &&
186 memcmp(port->sas_addr, sas_phy->sas_addr,
187 SAS_ADDR_SIZE) == 0 &&
188 memcmp(port->attached_sas_addr,
189 sas_phy->attached_sas_addr,
190 SAS_ADDR_SIZE) == 0) {
191 break;
192 }
193
194 /* Find a free port */
195 if (port->num_phys == 0 && free_port == NULL) {
196 free_port = port;
197 }
198 }
199
200 /* Use a free port if this doesn't form a wide port */
201 if (i >= ASD_MAX_PHYS) {
202 port = free_port;
203 BUG_ON(!port);
204 memcpy(port->sas_addr, sas_phy->sas_addr,
205 SAS_ADDR_SIZE);
206 memcpy(port->attached_sas_addr,
207 sas_phy->attached_sas_addr,
208 SAS_ADDR_SIZE);
209 }
210 port->num_phys++;
211 port->phy_mask |= (1U << sas_phy->id);
212 phy->asd_port = port;
213 }
214 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n",
215 __FUNCTION__, phy->asd_port->phy_mask, sas_phy->id);
216 asd_update_port_links(asd_ha, phy);
217 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
218}
219
220static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
221{
222 struct asd_port *port = phy->asd_port;
223 struct asd_sas_phy *sas_phy = &phy->sas_phy;
224 unsigned long flags;
225
226 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
227 if (port) {
228 port->num_phys--;
229 port->phy_mask &= ~(1U << sas_phy->id);
230 phy->asd_port = NULL;
231 }
232 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
233}
234
171static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb, 235static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
172 struct done_list_struct *dl, 236 struct done_list_struct *dl,
173 int edb_id, int phy_id) 237 int edb_id, int phy_id)
@@ -187,6 +251,7 @@ static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
187 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 251 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr);
188 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 252 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
189 asd_dump_frame_rcvd(phy, dl); 253 asd_dump_frame_rcvd(phy, dl);
254 asd_form_port(ascb->ha, phy);
190 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED); 255 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED);
191} 256}
192 257
@@ -197,6 +262,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
197 struct asd_ha_struct *asd_ha = ascb->ha; 262 struct asd_ha_struct *asd_ha = ascb->ha;
198 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; 263 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
199 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 264 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
265 struct asd_phy *phy = &asd_ha->phys[phy_id];
200 u8 lr_error = dl->status_block[1]; 266 u8 lr_error = dl->status_block[1];
201 u8 retries_left = dl->status_block[2]; 267 u8 retries_left = dl->status_block[2];
202 268
@@ -221,6 +287,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
221 287
222 asd_turn_led(asd_ha, phy_id, 0); 288 asd_turn_led(asd_ha, phy_id, 0);
223 sas_phy_disconnected(sas_phy); 289 sas_phy_disconnected(sas_phy);
290 asd_deform_port(asd_ha, phy);
224 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 291 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR);
225 292
226 if (retries_left == 0) { 293 if (retries_left == 0) {
@@ -248,6 +315,8 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
248 unsigned long flags; 315 unsigned long flags;
249 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; 316 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha;
250 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 317 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
318 struct asd_ha_struct *asd_ha = ascb->ha;
319 struct asd_phy *phy = &asd_ha->phys[phy_id];
251 u8 reg = dl->status_block[1]; 320 u8 reg = dl->status_block[1];
252 u32 cont = dl->status_block[2] << ((reg & 3)*8); 321 u32 cont = dl->status_block[2] << ((reg & 3)*8);
253 322
@@ -284,6 +353,7 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
284 phy_id); 353 phy_id);
285 /* The sequencer disables all phys on that port. 354 /* The sequencer disables all phys on that port.
286 * We have to re-enable the phys ourselves. */ 355 * We have to re-enable the phys ourselves. */
356 asd_deform_port(asd_ha, phy);
287 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET); 357 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET);
288 break; 358 break;
289 359
@@ -351,6 +421,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
351 u8 sb_opcode = dl->status_block[0]; 421 u8 sb_opcode = dl->status_block[0];
352 int phy_id = sb_opcode & DL_PHY_MASK; 422 int phy_id = sb_opcode & DL_PHY_MASK;
353 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 423 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
424 struct asd_phy *phy = &asd_ha->phys[phy_id];
354 425
355 if (edb > 6 || edb < 0) { 426 if (edb > 6 || edb < 0) {
356 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", 427 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n",
@@ -395,6 +466,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
395 asd_turn_led(asd_ha, phy_id, 0); 466 asd_turn_led(asd_ha, phy_id, 0);
396 /* the device is gone */ 467 /* the device is gone */
397 sas_phy_disconnected(sas_phy); 468 sas_phy_disconnected(sas_phy);
469 asd_deform_port(asd_ha, phy);
398 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 470 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
399 break; 471 break;
400 case REQ_TASK_ABORT: 472 case REQ_TASK_ABORT:
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
index 56e4b3ba6a08..845112539d05 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.c
+++ b/drivers/scsi/aic94xx/aic94xx_seq.c
@@ -1369,10 +1369,9 @@ int asd_start_seqs(struct asd_ha_struct *asd_ha)
1369 * port_map_by_links is also used as the conn_mask byte in the 1369 * port_map_by_links is also used as the conn_mask byte in the
1370 * initiator/target port DDB. 1370 * initiator/target port DDB.
1371 */ 1371 */
1372void asd_update_port_links(struct asd_sas_phy *sas_phy) 1372void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
1373{ 1373{
1374 struct asd_ha_struct *asd_ha = sas_phy->ha->lldd_ha; 1374 const u8 phy_mask = (u8) phy->asd_port->phy_mask;
1375 const u8 phy_mask = (u8) sas_phy->port->phy_mask;
1376 u8 phy_is_up; 1375 u8 phy_is_up;
1377 u8 mask; 1376 u8 mask;
1378 int i, err; 1377 int i, err;
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.h b/drivers/scsi/aic94xx/aic94xx_seq.h
index 42281c36153b..9e715e5496af 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.h
+++ b/drivers/scsi/aic94xx/aic94xx_seq.h
@@ -64,7 +64,7 @@ int asd_unpause_lseq(struct asd_ha_struct *asd_ha, u8 lseq_mask);
64int asd_init_seqs(struct asd_ha_struct *asd_ha); 64int asd_init_seqs(struct asd_ha_struct *asd_ha);
65int asd_start_seqs(struct asd_ha_struct *asd_ha); 65int asd_start_seqs(struct asd_ha_struct *asd_ha);
66 66
67void asd_update_port_links(struct asd_sas_phy *phy); 67void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy);
68#endif 68#endif
69 69
70#endif 70#endif