Lines Matching +full:t +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
19 /* ---------- EMPTY SCB ---------- */
36 static void get_lrate_mode(struct asd_phy *phy, u8 oob_mode) in get_lrate_mode() argument
38 struct sas_phy *sas_phy = phy->sas_phy.phy; in get_lrate_mode()
42 /* FIXME: sas transport class doesn't have this */ in get_lrate_mode()
43 phy->sas_phy.linkrate = SAS_LINK_RATE_6_0_GBPS; in get_lrate_mode()
44 phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_6_0_GBPS; in get_lrate_mode()
47 phy->sas_phy.linkrate = SAS_LINK_RATE_3_0_GBPS; in get_lrate_mode()
48 phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS; in get_lrate_mode()
51 phy->sas_phy.linkrate = SAS_LINK_RATE_1_5_GBPS; in get_lrate_mode()
52 phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS; in get_lrate_mode()
55 sas_phy->negotiated_linkrate = phy->sas_phy.linkrate; in get_lrate_mode()
56 sas_phy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; in get_lrate_mode()
57 sas_phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; in get_lrate_mode()
58 sas_phy->maximum_linkrate = phy->phy_desc->max_sas_lrate; in get_lrate_mode()
59 sas_phy->minimum_linkrate = phy->phy_desc->min_sas_lrate; in get_lrate_mode()
62 phy->sas_phy.oob_mode = SAS_OOB_MODE; in get_lrate_mode()
64 phy->sas_phy.oob_mode = SATA_OOB_MODE; in get_lrate_mode()
70 struct asd_ha_struct *asd_ha = ascb->ha; in asd_phy_event_tasklet()
71 int phy_id = dl->status_block[0] & DL_PHY_MASK; in asd_phy_event_tasklet()
72 struct asd_phy *phy = &asd_ha->phys[phy_id]; in asd_phy_event_tasklet() local
74 u8 oob_status = dl->status_block[1] & PHY_EVENTS_STATUS; in asd_phy_event_tasklet()
75 u8 oob_mode = dl->status_block[2]; in asd_phy_event_tasklet()
80 ASD_DPRINTK("phy%d: device unplugged\n", phy_id); in asd_phy_event_tasklet()
82 sas_phy_disconnected(&phy->sas_phy); in asd_phy_event_tasklet()
83 sas_notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL, in asd_phy_event_tasklet()
89 get_lrate_mode(phy, oob_mode); in asd_phy_event_tasklet()
90 ASD_DPRINTK("phy%d device plugged: lrate:0x%x, proto:0x%x\n", in asd_phy_event_tasklet()
91 phy_id, phy->sas_phy.linkrate, phy->sas_phy.iproto); in asd_phy_event_tasklet()
92 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE, GFP_ATOMIC); in asd_phy_event_tasklet()
97 sas_notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD, in asd_phy_event_tasklet()
102 ASD_DPRINTK("phy%d error while OOB: oob status:0x%x\n", phy_id, in asd_phy_event_tasklet()
103 dl->status_block[1]); in asd_phy_event_tasklet()
105 sas_phy_disconnected(&phy->sas_phy); in asd_phy_event_tasklet()
106 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR, GFP_ATOMIC); in asd_phy_event_tasklet()
112 static unsigned ord_phy(struct asd_ha_struct *asd_ha, struct asd_phy *phy) in ord_phy() argument
114 u8 enabled_mask = asd_ha->hw_prof.enabled_phys; in ord_phy()
118 if (&asd_ha->phys[i] == phy) in ord_phy()
126 * asd_get_attached_sas_addr -- extract/generate attached SAS address
127 * @phy: pointer to asd_phy
137 static void asd_get_attached_sas_addr(struct asd_phy *phy, u8 *sas_addr) in asd_get_attached_sas_addr() argument
139 if (phy->sas_phy.frame_rcvd[0] == 0x34 in asd_get_attached_sas_addr()
140 && phy->sas_phy.oob_mode == SATA_OOB_MODE) { in asd_get_attached_sas_addr()
141 struct asd_ha_struct *asd_ha = phy->sas_phy.ha->lldd_ha; in asd_get_attached_sas_addr()
142 /* FIS device-to-host */ in asd_get_attached_sas_addr()
143 u64 addr = be64_to_cpu(*(__be64 *)phy->phy_desc->sas_addr); in asd_get_attached_sas_addr()
145 addr += asd_ha->hw_prof.sata_name_base + ord_phy(asd_ha, phy); in asd_get_attached_sas_addr()
149 (void *) phy->sas_phy.frame_rcvd; in asd_get_attached_sas_addr()
150 memcpy(sas_addr, idframe->sas_addr, SAS_ADDR_SIZE); in asd_get_attached_sas_addr()
154 static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy) in asd_form_port() argument
159 struct asd_sas_phy *sas_phy = &phy->sas_phy; in asd_form_port()
162 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags); in asd_form_port()
163 if (!phy->asd_port) { in asd_form_port()
165 port = &asd_ha->asd_ports[i]; in asd_form_port()
168 if (port->num_phys > 0 && in asd_form_port()
169 memcmp(port->sas_addr, sas_phy->sas_addr, in asd_form_port()
171 memcmp(port->attached_sas_addr, in asd_form_port()
172 sas_phy->attached_sas_addr, in asd_form_port()
178 if (port->num_phys == 0 && free_port == NULL) { in asd_form_port()
183 /* Use a free port if this doesn't form a wide port */ in asd_form_port()
187 memcpy(port->sas_addr, sas_phy->sas_addr, in asd_form_port()
189 memcpy(port->attached_sas_addr, in asd_form_port()
190 sas_phy->attached_sas_addr, in asd_form_port()
193 port->num_phys++; in asd_form_port()
194 port->phy_mask |= (1U << sas_phy->id); in asd_form_port()
195 phy->asd_port = port; in asd_form_port()
197 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n", in asd_form_port()
198 __func__, phy->asd_port->phy_mask, sas_phy->id); in asd_form_port()
199 asd_update_port_links(asd_ha, phy); in asd_form_port()
200 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags); in asd_form_port()
203 static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy) in asd_deform_port() argument
205 struct asd_port *port = phy->asd_port; in asd_deform_port()
206 struct asd_sas_phy *sas_phy = &phy->sas_phy; in asd_deform_port()
209 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags); in asd_deform_port()
211 port->num_phys--; in asd_deform_port()
212 port->phy_mask &= ~(1U << sas_phy->id); in asd_deform_port()
213 phy->asd_port = NULL; in asd_deform_port()
215 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags); in asd_deform_port()
223 int edb_el = edb_id + ascb->edb_index; in asd_bytes_dmaed_tasklet()
224 struct asd_dma_tok *edb = ascb->ha->seq.edb_arr[edb_el]; in asd_bytes_dmaed_tasklet()
225 struct asd_phy *phy = &ascb->ha->phys[phy_id]; in asd_bytes_dmaed_tasklet() local
226 u16 size = ((dl->status_block[3] & 7) << 8) | dl->status_block[2]; in asd_bytes_dmaed_tasklet()
228 size = min(size, (u16) sizeof(phy->frame_rcvd)); in asd_bytes_dmaed_tasklet()
230 spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); in asd_bytes_dmaed_tasklet()
231 memcpy(phy->sas_phy.frame_rcvd, edb->vaddr, size); in asd_bytes_dmaed_tasklet()
232 phy->sas_phy.frame_rcvd_size = size; in asd_bytes_dmaed_tasklet()
233 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); in asd_bytes_dmaed_tasklet()
234 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); in asd_bytes_dmaed_tasklet()
235 asd_dump_frame_rcvd(phy, dl); in asd_bytes_dmaed_tasklet()
236 asd_form_port(ascb->ha, phy); in asd_bytes_dmaed_tasklet()
237 sas_notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED, GFP_ATOMIC); in asd_bytes_dmaed_tasklet()
244 struct asd_ha_struct *asd_ha = ascb->ha; in asd_link_reset_err_tasklet()
245 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; in asd_link_reset_err_tasklet()
246 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in asd_link_reset_err_tasklet()
247 struct asd_phy *phy = &asd_ha->phys[phy_id]; in asd_link_reset_err_tasklet() local
248 u8 lr_error = dl->status_block[1]; in asd_link_reset_err_tasklet()
249 u8 retries_left = dl->status_block[2]; in asd_link_reset_err_tasklet()
253 ASD_DPRINTK("phy%d: Receive ID timer expired\n", phy_id); in asd_link_reset_err_tasklet()
256 ASD_DPRINTK("phy%d: Loss of signal\n", phy_id); in asd_link_reset_err_tasklet()
259 ASD_DPRINTK("phy%d: Loss of dword sync\n", phy_id); in asd_link_reset_err_tasklet()
262 ASD_DPRINTK("phy%d: Receive FIS timeout\n", phy_id); in asd_link_reset_err_tasklet()
265 ASD_DPRINTK("phy%d: unknown link reset error code: 0x%x\n", in asd_link_reset_err_tasklet()
272 asd_deform_port(asd_ha, phy); in asd_link_reset_err_tasklet()
277 struct asd_ascb *cp = asd_ascb_alloc_list(ascb->ha, &num, in asd_link_reset_err_tasklet()
283 ASD_DPRINTK("phy%d: retries:0 performing link reset seq\n", in asd_link_reset_err_tasklet()
286 if (asd_post_ascb_list(ascb->ha, cp, 1) != 0) in asd_link_reset_err_tasklet()
298 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; in asd_primitive_rcvd_tasklet()
299 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in asd_primitive_rcvd_tasklet()
300 struct asd_ha_struct *asd_ha = ascb->ha; in asd_primitive_rcvd_tasklet()
301 struct asd_phy *phy = &asd_ha->phys[phy_id]; in asd_primitive_rcvd_tasklet() local
302 u8 reg = dl->status_block[1]; in asd_primitive_rcvd_tasklet()
303 u32 cont = dl->status_block[2] << ((reg & 3)*8); in asd_primitive_rcvd_tasklet()
313 ASD_DPRINTK("phy%d: BROADCAST change received:%d\n", in asd_primitive_rcvd_tasklet()
315 spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); in asd_primitive_rcvd_tasklet()
316 sas_phy->sas_prim = ffs(cont); in asd_primitive_rcvd_tasklet()
317 spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); in asd_primitive_rcvd_tasklet()
323 ASD_DPRINTK("phy%d: unknown BREAK\n", phy_id); in asd_primitive_rcvd_tasklet()
327 ASD_DPRINTK("phy%d: primitive reg:0x%x, cont:0x%04x\n", in asd_primitive_rcvd_tasklet()
335 ASD_DPRINTK("phy%d: HARD_RESET primitive rcvd\n", in asd_primitive_rcvd_tasklet()
338 * We have to re-enable the phys ourselves. */ in asd_primitive_rcvd_tasklet()
339 asd_deform_port(asd_ha, phy); in asd_primitive_rcvd_tasklet()
345 ASD_DPRINTK("phy%d: primitive reg:0x%x, cont:0x%04x\n", in asd_primitive_rcvd_tasklet()
352 dl->status_block[1]); in asd_primitive_rcvd_tasklet()
358 * asd_invalidate_edb -- invalidate an EDB and if necessary post the ESCB
368 struct asd_seq_data *seq = &ascb->ha->seq; in asd_invalidate_edb()
369 struct empty_scb *escb = &ascb->scb->escb; in asd_invalidate_edb()
370 struct sg_el *eb = &escb->eb[edb_id]; in asd_invalidate_edb()
371 struct asd_dma_tok *edb = seq->edb_arr[ascb->edb_index + edb_id]; in asd_invalidate_edb()
373 memset(edb->vaddr, 0, ASD_EDB_SIZE); in asd_invalidate_edb()
374 eb->flags |= ELEMENT_NOT_VALID; in asd_invalidate_edb()
375 escb->num_valid--; in asd_invalidate_edb()
377 if (escb->num_valid == 0) { in asd_invalidate_edb()
382 ascb->dma_scb.vaddr, in asd_invalidate_edb()
383 (u64)ascb->dma_scb.dma_handle, in asd_invalidate_edb()
384 le64_to_cpu(ascb->scb->header.next_scb), in asd_invalidate_edb()
385 le16_to_cpu(ascb->scb->header.index), in asd_invalidate_edb()
386 ascb->scb->header.opcode); in asd_invalidate_edb()
388 escb->num_valid = ASD_EDBS_PER_SCB; in asd_invalidate_edb()
390 escb->eb[i].flags = 0; in asd_invalidate_edb()
391 if (!list_empty(&ascb->list)) in asd_invalidate_edb()
392 list_del_init(&ascb->list); in asd_invalidate_edb()
393 i = asd_post_escb_list(ascb->ha, ascb, 1); in asd_invalidate_edb()
395 asd_printk("couldn't post escb, err:%d\n", i); in asd_invalidate_edb()
402 struct asd_ha_struct *asd_ha = ascb->ha; in escb_tasklet_complete()
403 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; in escb_tasklet_complete()
404 int edb = (dl->opcode & DL_PHY_MASK) - 1; /* [0xc1,0xc7] -> [0,6] */ in escb_tasklet_complete()
405 u8 sb_opcode = dl->status_block[0]; in escb_tasklet_complete()
407 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in escb_tasklet_complete()
408 struct asd_phy *phy = &asd_ha->phys[phy_id]; in escb_tasklet_complete() local
411 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", in escb_tasklet_complete()
412 edb, dl->opcode); in escb_tasklet_complete()
418 ascb->dma_scb.vaddr, in escb_tasklet_complete()
419 (unsigned long long)ascb->dma_scb.dma_handle, in escb_tasklet_complete()
421 le64_to_cpu(ascb->scb->header.next_scb), in escb_tasklet_complete()
422 le16_to_cpu(ascb->scb->header.index), in escb_tasklet_complete()
423 ascb->scb->header.opcode); in escb_tasklet_complete()
434 __func__, dl->status_block[3]); in escb_tasklet_complete()
438 * The sequencer won't put anything on the done list until in escb_tasklet_complete()
441 tc_abort = *((u16*)(&dl->status_block[1])); in escb_tasklet_complete()
444 list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
445 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
447 if (a->tc_index != tc_abort) in escb_tasklet_complete()
451 failed_dev = task->dev; in escb_tasklet_complete()
455 a->scb->header.opcode); in escb_tasklet_complete()
461 ASD_DPRINTK("%s: Can't find task (tc=%d) to abort!\n", in escb_tasklet_complete()
470 list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
471 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
474 task->dev == failed_dev && in escb_tasklet_complete()
475 a->tc_index != tc_abort) in escb_tasklet_complete()
487 conn_handle = *((u16*)(&dl->status_block[1])); in escb_tasklet_complete()
491 dl->status_block[3]); in escb_tasklet_complete()
494 list_for_each_entry(a, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
497 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
501 dev = task->dev; in escb_tasklet_complete()
503 x = (unsigned long)dev->lldd_dev; in escb_tasklet_complete()
515 spin_lock_irqsave(&last_dev_task->task_state_lock, flags); in escb_tasklet_complete()
516 last_dev_task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; in escb_tasklet_complete()
517 spin_unlock_irqrestore(&last_dev_task->task_state_lock, flags); in escb_tasklet_complete()
520 list_for_each_entry(a, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
523 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
527 dev = task->dev; in escb_tasklet_complete()
529 x = (unsigned long)dev->lldd_dev; in escb_tasklet_complete()
548 ASD_DPRINTK("%s: phy%d: BYTES_DMAED\n", __func__, phy_id); in escb_tasklet_complete()
552 ASD_DPRINTK("%s: phy%d: PRIMITIVE_RECVD\n", __func__, in escb_tasklet_complete()
557 ASD_DPRINTK("%s: phy%d: PHY_EVENT\n", __func__, phy_id); in escb_tasklet_complete()
561 ASD_DPRINTK("%s: phy%d: LINK_RESET_ERROR\n", __func__, in escb_tasklet_complete()
566 ASD_DPRINTK("%s: phy%d: TIMER_EVENT, lost dw sync\n", in escb_tasklet_complete()
571 asd_deform_port(asd_ha, phy); in escb_tasklet_complete()
575 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __func__, in escb_tasklet_complete()
577 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", in escb_tasklet_complete()
578 edb, dl->opcode); in escb_tasklet_complete()
584 ascb->dma_scb.vaddr, in escb_tasklet_complete()
585 (unsigned long long)ascb->dma_scb.dma_handle, in escb_tasklet_complete()
587 le64_to_cpu(ascb->scb->header.next_scb), in escb_tasklet_complete()
588 le16_to_cpu(ascb->scb->header.index), in escb_tasklet_complete()
589 ascb->scb->header.opcode); in escb_tasklet_complete()
599 struct asd_seq_data *seq = &asd_ha->seq; in asd_init_post_escbs()
602 for (i = 0; i < seq->num_escbs; i++) in asd_init_post_escbs()
603 seq->escb_arr[i]->tasklet_complete = escb_tasklet_complete; in asd_init_post_escbs()
606 return asd_post_escb_list(asd_ha, seq->escb_arr[0], seq->num_escbs); in asd_init_post_escbs()
609 /* ---------- CONTROL PHY ---------- */
616 * control_phy_tasklet_complete -- tasklet complete for CONTROL PHY ascb
620 * This function completes a CONTROL PHY scb and frees the ascb.
622 * - an LED blinks if there is IO though it,
623 * - if a device is connected to the LED, it is lit,
624 * - if no device is connected to the LED, is is dimmed (off).
629 struct asd_ha_struct *asd_ha = ascb->ha; in control_phy_tasklet_complete()
630 struct scb *scb = ascb->scb; in control_phy_tasklet_complete()
631 struct control_phy *control_phy = &scb->control_phy; in control_phy_tasklet_complete()
632 u8 phy_id = control_phy->phy_id; in control_phy_tasklet_complete()
633 struct asd_phy *phy = &ascb->ha->phys[phy_id]; in control_phy_tasklet_complete() local
635 u8 status = dl->status_block[0]; in control_phy_tasklet_complete()
636 u8 oob_status = dl->status_block[1]; in control_phy_tasklet_complete()
637 u8 oob_mode = dl->status_block[2]; in control_phy_tasklet_complete()
638 /* u8 oob_signals= dl->status_block[3]; */ in control_phy_tasklet_complete()
641 ASD_DPRINTK("%s: phy%d status block opcode:0x%x\n", in control_phy_tasklet_complete()
646 switch (control_phy->sub_func) { in control_phy_tasklet_complete()
648 asd_ha->hw_prof.enabled_phys &= ~(1 << phy_id); in control_phy_tasklet_complete()
651 ASD_DPRINTK("%s: disable phy%d\n", __func__, phy_id); in control_phy_tasklet_complete()
657 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
658 get_lrate_mode(phy, oob_mode); in control_phy_tasklet_complete()
660 ASD_DPRINTK("%s: phy%d, lrate:0x%x, proto:0x%x\n", in control_phy_tasklet_complete()
661 __func__, phy_id,phy->sas_phy.linkrate, in control_phy_tasklet_complete()
662 phy->sas_phy.iproto); in control_phy_tasklet_complete()
664 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
666 ASD_DPRINTK("%s: phy%d, spinup hold\n", __func__, in control_phy_tasklet_complete()
670 ASD_DPRINTK("%s: phy%d: error: oob status:0x%02x\n", in control_phy_tasklet_complete()
674 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
676 ASD_DPRINTK("%s: phy%d: hot plug or device present\n", in control_phy_tasklet_complete()
679 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
681 ASD_DPRINTK("%s: phy%d: no device present: " in control_phy_tasklet_complete()
689 ASD_DPRINTK("%s: phy%d: sub_func:0x%x\n", __func__, in control_phy_tasklet_complete()
690 phy_id, control_phy->sub_func); in control_phy_tasklet_complete()
694 ASD_DPRINTK("%s: phy%d: sub_func:0x%x?\n", __func__, in control_phy_tasklet_complete()
695 phy_id, control_phy->sub_func); in control_phy_tasklet_complete()
708 switch (pd->max_sas_lrate) { in set_speed_mask()
720 switch (pd->min_sas_lrate) { in set_speed_mask()
733 switch (pd->max_sata_lrate) { in set_speed_mask()
742 switch (pd->min_sata_lrate) { in set_speed_mask()
754 * asd_build_control_phy -- build a CONTROL PHY SCB
756 * @phy_id: phy id to control, integer
757 * @subfunc: subfunction, what to actually to do the phy
759 * This function builds a CONTROL PHY scb. No allocation of any kind
761 * The caller can override the ascb->tasklet_complete to point
768 struct asd_phy *phy = &ascb->ha->phys[phy_id]; in asd_build_control_phy() local
769 struct scb *scb = ascb->scb; in asd_build_control_phy()
770 struct control_phy *control_phy = &scb->control_phy; in asd_build_control_phy()
772 scb->header.opcode = CONTROL_PHY; in asd_build_control_phy()
773 control_phy->phy_id = (u8) phy_id; in asd_build_control_phy()
774 control_phy->sub_func = subfunc; in asd_build_control_phy()
780 control_phy->hot_plug_delay = HOTPLUG_DELAY_TIMEOUT; in asd_build_control_phy()
783 set_speed_mask(&control_phy->speed_mask, phy->phy_desc); in asd_build_control_phy()
786 if (phy->sas_phy.role == PHY_ROLE_INITIATOR) in asd_build_control_phy()
787 control_phy->port_type = SAS_PROTOCOL_ALL << 4; in asd_build_control_phy()
788 else if (phy->sas_phy.role == PHY_ROLE_TARGET) in asd_build_control_phy()
789 control_phy->port_type = SAS_PROTOCOL_ALL; in asd_build_control_phy()
791 control_phy->port_type = in asd_build_control_phy()
795 control_phy->link_reset_retries = 10; in asd_build_control_phy()
800 control_phy->func_mask = FUNCTION_MASK_DEFAULT; in asd_build_control_phy()
801 if (phy->phy_desc->flags & ASD_SATA_SPINUP_HOLD) in asd_build_control_phy()
802 control_phy->func_mask &= ~SPINUP_HOLD_DIS; in asd_build_control_phy()
804 control_phy->func_mask |= SPINUP_HOLD_DIS; in asd_build_control_phy()
807 control_phy->conn_handle = cpu_to_le16(0xFFFF); in asd_build_control_phy()
809 ascb->tasklet_complete = control_phy_tasklet_complete; in asd_build_control_phy()
812 /* ---------- INITIATE LINK ADM TASK ---------- */
819 u8 opcode = dl->opcode;
820 struct initiate_link_adm *link_adm = &ascb->scb->link_adm;
821 u8 phy_id = link_adm->phy_id;
824 asd_printk("phy%d: link adm task 0x%x completed with error "
825 "0x%x\n", phy_id, link_adm->sub_func, opcode);
827 ASD_DPRINTK("phy%d: link adm task 0x%x: 0x%x\n",
828 phy_id, link_adm->sub_func, opcode);
836 struct scb *scb = ascb->scb;
837 struct initiate_link_adm *link_adm = &scb->link_adm;
839 scb->header.opcode = INITIATE_LINK_ADM_TASK;
841 link_adm->phy_id = phy_id;
842 link_adm->sub_func = subfunc;
843 link_adm->conn_handle = cpu_to_le16(0xFFFF);
845 ascb->tasklet_complete = link_adm_tasklet_complete;
850 /* ---------- SCB timer ---------- */
853 * asd_ascb_timedout -- called when a pending SCB's timer has expired
854 * @t: Timer context used to fetch the SCB
860 * the ascb->timer.{function, expires} prior to calling the post
863 void asd_ascb_timedout(struct timer_list *t) in asd_ascb_timedout() argument
865 struct asd_ascb *ascb = from_timer(ascb, t, timer); in asd_ascb_timedout()
866 struct asd_seq_data *seq = &ascb->ha->seq; in asd_ascb_timedout()
869 ASD_DPRINTK("scb:0x%x timed out\n", ascb->scb->header.opcode); in asd_ascb_timedout()
871 spin_lock_irqsave(&seq->pend_q_lock, flags); in asd_ascb_timedout()
872 seq->pending--; in asd_ascb_timedout()
873 list_del_init(&ascb->list); in asd_ascb_timedout()
874 spin_unlock_irqrestore(&seq->pend_q_lock, flags); in asd_ascb_timedout()
879 /* ---------- CONTROL PHY ---------- */
890 int asd_control_phy(struct asd_sas_phy *phy, enum phy_func func, void *arg) in asd_control_phy() argument
892 struct asd_ha_struct *asd_ha = phy->ha->lldd_ha; in asd_control_phy()
893 struct asd_phy_desc *pd = asd_ha->phys[phy->id].phy_desc; in asd_control_phy()
901 return -ENOSYS; in asd_control_phy()
904 if (rates->minimum_linkrate) { in asd_control_phy()
905 pd->min_sas_lrate = rates->minimum_linkrate; in asd_control_phy()
906 pd->min_sata_lrate = rates->minimum_linkrate; in asd_control_phy()
908 if (rates->maximum_linkrate) { in asd_control_phy()
909 pd->max_sas_lrate = rates->maximum_linkrate; in asd_control_phy()
910 pd->max_sata_lrate = rates->maximum_linkrate; in asd_control_phy()
920 return -ENOMEM; in asd_control_phy()
922 asd_build_control_phy(ascb, phy->id, phy_func_table[func]); in asd_control_phy()