Lines 191-207
enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn)
Link Here
|
191 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info->mfw_mb_cur); |
191 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info->mfw_mb_cur); |
192 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info->mfw_mb_shadow); |
192 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info->mfw_mb_shadow); |
193 |
|
193 |
|
194 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock); |
194 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock); |
195 |
OSAL_LIST_FOR_EACH_ENTRY_SAFE(p_cmd_elem, p_tmp, |
195 |
OSAL_LIST_FOR_EACH_ENTRY_SAFE(p_cmd_elem, p_tmp, |
196 |
&p_hwfn->mcp_info->cmd_list, list, |
196 |
&p_hwfn->mcp_info->cmd_list, list, |
197 |
struct ecore_mcp_cmd_elem) { |
197 |
struct ecore_mcp_cmd_elem) { |
198 |
ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); |
198 |
ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); |
199 |
} |
199 |
} |
200 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
200 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
201 |
|
201 |
|
202 |
#ifdef CONFIG_ECORE_LOCK_ALLOC |
202 |
#ifdef CONFIG_ECORE_LOCK_ALLOC |
203 |
OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->mcp_info->cmd_lock); |
203 |
OSAL_MUTEX_DEALLOC(&p_hwfn->mcp_info->cmd_lock); |
204 |
OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->mcp_info->link_lock); |
204 |
OSAL_MUTEX_DEALLOC(&p_hwfn->mcp_info->link_lock); |
205 |
#endif |
205 |
#endif |
206 |
} |
206 |
} |
207 |
|
207 |
|
Lines 308-325
enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
Link Here
|
308 |
|
308 |
|
309 |
/* Initialize the MFW spinlocks */ |
309 |
/* Initialize the MFW spinlocks */ |
310 |
#ifdef CONFIG_ECORE_LOCK_ALLOC |
310 |
#ifdef CONFIG_ECORE_LOCK_ALLOC |
311 |
if (OSAL_SPIN_LOCK_ALLOC(p_hwfn, &p_info->cmd_lock)) { |
311 |
if (OSAL_MUTEX_LOCK_ALLOC(p_hwfn, &p_info->cmd_lock)) { |
312 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info); |
312 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info); |
313 |
return ECORE_NOMEM; |
313 |
return ECORE_NOMEM; |
314 |
} |
314 |
} |
315 |
if (OSAL_SPIN_LOCK_ALLOC(p_hwfn, &p_info->link_lock)) { |
315 |
if (OSAL_MUTEX_ALLOC(p_hwfn, &p_info->link_lock)) { |
316 |
OSAL_SPIN_LOCK_DEALLOC(&p_info->cmd_lock); |
316 |
OSAL_MUTEX_DEALLOC(&p_info->cmd_lock); |
317 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info); |
317 |
OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info); |
318 |
return ECORE_NOMEM; |
318 |
return ECORE_NOMEM; |
319 |
} |
319 |
} |
320 |
#endif |
320 |
#endif |
321 |
OSAL_SPIN_LOCK_INIT(&p_info->cmd_lock); |
321 |
OSAL_MUTEX_INIT(&p_info->cmd_lock); |
322 |
OSAL_SPIN_LOCK_INIT(&p_info->link_lock); |
322 |
OSAL_MUTEX_INIT(&p_info->link_lock); |
323 |
|
323 |
|
324 |
OSAL_LIST_INIT(&p_info->cmd_list); |
324 |
OSAL_LIST_INIT(&p_info->cmd_list); |
325 |
|
325 |
|
Lines 381-387
enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
Link Here
|
381 |
} |
381 |
} |
382 |
|
382 |
|
383 |
/* Ensure that only a single thread is accessing the mailbox */ |
383 |
/* Ensure that only a single thread is accessing the mailbox */ |
384 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock); |
384 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock); |
385 |
|
385 |
|
386 |
org_mcp_reset_seq = ecore_rd(p_hwfn, p_ptt, MISCS_REG_GENERIC_POR_0); |
386 |
org_mcp_reset_seq = ecore_rd(p_hwfn, p_ptt, MISCS_REG_GENERIC_POR_0); |
387 |
|
387 |
|
Lines 407-413
enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
Link Here
|
407 |
rc = ECORE_AGAIN; |
407 |
rc = ECORE_AGAIN; |
408 |
} |
408 |
} |
409 |
|
409 |
|
410 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
410 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
411 |
|
411 |
|
412 |
return rc; |
412 |
return rc; |
413 |
} |
413 |
} |
Lines 551-557
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
551 |
* The spinlock stays locked until the command is sent. |
551 |
* The spinlock stays locked until the command is sent. |
552 |
*/ |
552 |
*/ |
553 |
|
553 |
|
554 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock); |
554 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock); |
555 |
|
555 |
|
556 |
if (!ecore_mcp_has_pending_cmd(p_hwfn)) |
556 |
if (!ecore_mcp_has_pending_cmd(p_hwfn)) |
557 |
break; |
557 |
break; |
Lines 562-568
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
562 |
else if (rc != ECORE_AGAIN) |
562 |
else if (rc != ECORE_AGAIN) |
563 |
goto err; |
563 |
goto err; |
564 |
|
564 |
|
565 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
565 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
566 |
if (ECORE_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) { |
566 |
if (ECORE_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) { |
567 |
OSAL_MSLEEP(msecs); |
567 |
OSAL_MSLEEP(msecs); |
568 |
} else { |
568 |
} else { |
Lines 588-594
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
588 |
} |
588 |
} |
589 |
|
589 |
|
590 |
__ecore_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params, seq_num); |
590 |
__ecore_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params, seq_num); |
591 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
591 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
592 |
|
592 |
|
593 |
/* Wait for the MFW response */ |
593 |
/* Wait for the MFW response */ |
594 |
do { |
594 |
do { |
Lines 602-608
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
602 |
} else { |
602 |
} else { |
603 |
OSAL_UDELAY(usecs); |
603 |
OSAL_UDELAY(usecs); |
604 |
} |
604 |
} |
605 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock); |
605 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock); |
606 |
|
606 |
|
607 |
if (p_cmd_elem->b_is_completed) |
607 |
if (p_cmd_elem->b_is_completed) |
608 |
break; |
608 |
break; |
Lines 613-619
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
613 |
else if (rc != ECORE_AGAIN) |
613 |
else if (rc != ECORE_AGAIN) |
614 |
goto err; |
614 |
goto err; |
615 |
|
615 |
|
616 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
616 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
617 |
OSAL_MFW_CMD_PREEMPT(p_hwfn); |
617 |
OSAL_MFW_CMD_PREEMPT(p_hwfn); |
618 |
} while (++cnt < max_retries); |
618 |
} while (++cnt < max_retries); |
619 |
|
619 |
|
Lines 623-631
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
623 |
p_mb_params->cmd, p_mb_params->param); |
623 |
p_mb_params->cmd, p_mb_params->param); |
624 |
ecore_mcp_print_cpu_info(p_hwfn, p_ptt); |
624 |
ecore_mcp_print_cpu_info(p_hwfn, p_ptt); |
625 |
|
625 |
|
626 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock); |
626 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock); |
627 |
ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); |
627 |
ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); |
628 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
628 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
629 |
|
629 |
|
630 |
if (!ECORE_MB_FLAGS_IS_SET(p_mb_params, AVOID_BLOCK)) |
630 |
if (!ECORE_MB_FLAGS_IS_SET(p_mb_params, AVOID_BLOCK)) |
631 |
ecore_mcp_cmd_set_blocking(p_hwfn, true); |
631 |
ecore_mcp_cmd_set_blocking(p_hwfn, true); |
Lines 634-640
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
634 |
} |
634 |
} |
635 |
|
635 |
|
636 |
ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); |
636 |
ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); |
637 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
637 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
638 |
|
638 |
|
639 |
DP_VERBOSE(p_hwfn, ECORE_MSG_SP, |
639 |
DP_VERBOSE(p_hwfn, ECORE_MSG_SP, |
640 |
"MFW mailbox: response 0x%08x param 0x%08x [after %d.%03d ms]\n", |
640 |
"MFW mailbox: response 0x%08x param 0x%08x [after %d.%03d ms]\n", |
Lines 647-653
_ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
Link Here
|
647 |
return ECORE_SUCCESS; |
647 |
return ECORE_SUCCESS; |
648 |
|
648 |
|
649 |
err: |
649 |
err: |
650 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock); |
650 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock); |
651 |
return rc; |
651 |
return rc; |
652 |
} |
652 |
} |
653 |
|
653 |
|
Lines 1439-1445
static void ecore_mcp_handle_link_change(struct ecore_hwfn *p_hwfn,
Link Here
|
1439 |
u32 status = 0; |
1439 |
u32 status = 0; |
1440 |
|
1440 |
|
1441 |
/* Prevent SW/attentions from doing this at the same time */ |
1441 |
/* Prevent SW/attentions from doing this at the same time */ |
1442 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->link_lock); |
1442 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->link_lock); |
1443 |
|
1443 |
|
1444 |
p_link = &p_hwfn->mcp_info->link_output; |
1444 |
p_link = &p_hwfn->mcp_info->link_output; |
1445 |
OSAL_MEMSET(p_link, 0, sizeof(*p_link)); |
1445 |
OSAL_MEMSET(p_link, 0, sizeof(*p_link)); |
Lines 1585-1591
static void ecore_mcp_handle_link_change(struct ecore_hwfn *p_hwfn,
Link Here
|
1585 |
|
1585 |
|
1586 |
OSAL_LINK_UPDATE(p_hwfn, p_ptt); |
1586 |
OSAL_LINK_UPDATE(p_hwfn, p_ptt); |
1587 |
out: |
1587 |
out: |
1588 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->link_lock); |
1588 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->link_lock); |
1589 |
} |
1589 |
} |
1590 |
|
1590 |
|
1591 |
enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn, |
1591 |
enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn, |
Lines 1774-1780
ecore_mcp_update_bw(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
Link Here
|
1774 |
struct public_func shmem_info; |
1774 |
struct public_func shmem_info; |
1775 |
u32 resp = 0, param = 0; |
1775 |
u32 resp = 0, param = 0; |
1776 |
|
1776 |
|
1777 |
OSAL_SPIN_LOCK(&p_hwfn->mcp_info->link_lock); |
1777 |
OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->link_lock); |
1778 |
|
1778 |
|
1779 |
ecore_mcp_get_shmem_func(p_hwfn, p_ptt, &shmem_info, |
1779 |
ecore_mcp_get_shmem_func(p_hwfn, p_ptt, &shmem_info, |
1780 |
MCP_PF_ID(p_hwfn)); |
1780 |
MCP_PF_ID(p_hwfn)); |
Lines 1787-1793
ecore_mcp_update_bw(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
Link Here
|
1787 |
|
1787 |
|
1788 |
ecore_configure_pf_max_bandwidth(p_hwfn->p_dev, p_info->bandwidth_max); |
1788 |
ecore_configure_pf_max_bandwidth(p_hwfn->p_dev, p_info->bandwidth_max); |
1789 |
|
1789 |
|
1790 |
OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->link_lock); |
1790 |
OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->link_lock); |
1791 |
|
1791 |
|
1792 |
/* Acknowledge the MFW */ |
1792 |
/* Acknowledge the MFW */ |
1793 |
ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_BW_UPDATE_ACK, 0, &resp, |
1793 |
ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_BW_UPDATE_ACK, 0, &resp, |