View | Details | Raw Unified | Return to bug 278084
Collapse All | Expand All

(-)b/sys/dev/qlnx/qlnxe/bcm_osal.h (-4 / +4 lines)
Lines 81-87 extern void qlnx_dma_free_coherent(void *ecore_dev, void *v_addr, Link Here
81
                        bus_addr_t phys, uint32_t size);
81
                        bus_addr_t phys, uint32_t size);
82
82
83
extern void qlnx_link_update(void *p_hwfn);
83
extern void qlnx_link_update(void *p_hwfn);
84
extern void qlnx_barrier(void *p_hwfn);
84
extern void qlnx_barrier(void *p_dev);
85
85
86
extern void *qlnx_zalloc(uint32_t size);
86
extern void *qlnx_zalloc(uint32_t size);
87
87
Lines 223-236 typedef struct osal_list_t Link Here
223
#define OSAL_SPIN_LOCK_ALLOC(p_hwfn, mutex)
223
#define OSAL_SPIN_LOCK_ALLOC(p_hwfn, mutex)
224
#define OSAL_SPIN_LOCK_DEALLOC(mutex) mtx_destroy(mutex)
224
#define OSAL_SPIN_LOCK_DEALLOC(mutex) mtx_destroy(mutex)
225
#define OSAL_SPIN_LOCK_INIT(lock) {\
225
#define OSAL_SPIN_LOCK_INIT(lock) {\
226
		mtx_init(lock, __func__, MTX_NETWORK_LOCK, MTX_SPIN); \
226
		mtx_init(lock, __func__, "OSAL spin lock", MTX_SPIN); \
227
	}
227
	}
228
228
229
#define OSAL_SPIN_UNLOCK(lock) {\
229
#define OSAL_SPIN_UNLOCK(lock) {\
230
		mtx_unlock(lock); \
230
		mtx_unlock_spin(lock); \
231
	}
231
	}
232
#define OSAL_SPIN_LOCK(lock) {\
232
#define OSAL_SPIN_LOCK(lock) {\
233
		mtx_lock(lock); \
233
		mtx_lock_spin(lock); \
234
	}
234
	}
235
235
236
#define OSAL_MUTEX_ALLOC(p_hwfn, mutex)
236
#define OSAL_MUTEX_ALLOC(p_hwfn, mutex)
(-)b/sys/dev/qlnx/qlnxe/ecore.h (+1 lines)
Lines 789-794 struct ecore_dev { Link Here
789
	u8				dp_level;
789
	u8				dp_level;
790
	char				name[NAME_SIZE];
790
	char				name[NAME_SIZE];
791
	void				*dp_ctx;
791
	void				*dp_ctx;
792
	void				*ha;
792
793
793
	enum ecore_dev_type		type;
794
	enum ecore_dev_type		type;
794
/* Translate type/revision combo into the proper conditions */
795
/* Translate type/revision combo into the proper conditions */
(-)b/sys/dev/qlnx/qlnxe/ecore_mcp.c (-24 / +24 lines)
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,
(-)b/sys/dev/qlnx/qlnxe/ecore_mcp.h (-3 / +3 lines)
Lines 51-60 struct ecore_mcp_info { Link Here
51
	/* List for mailbox commands which were sent and wait for a response */
51
	/* List for mailbox commands which were sent and wait for a response */
52
	osal_list_t cmd_list;
52
	osal_list_t cmd_list;
53
53
54
	/* Spinlock used for protecting the access to the mailbox commands list
54
	/* Lock used for protecting the access to the mailbox commands list
55
	 * and the sending of the commands.
55
	 * and the sending of the commands.
56
	 */
56
	 */
57
	osal_spinlock_t cmd_lock;
57
	osal_mutex_t cmd_lock;
58
58
59
	/* Flag to indicate whether sending a MFW mailbox command is blocked */
59
	/* Flag to indicate whether sending a MFW mailbox command is blocked */
60
	bool b_block_cmd;
60
	bool b_block_cmd;
Lines 62-68 struct ecore_mcp_info { Link Here
62
	/* Spinlock used for syncing SW link-changes and link-changes
62
	/* Spinlock used for syncing SW link-changes and link-changes
63
	 * originating from attention context.
63
	 * originating from attention context.
64
	 */
64
	 */
65
	osal_spinlock_t link_lock;
65
	osal_mutex_t link_lock;
66
66
67
	/* Address of the MCP public area */
67
	/* Address of the MCP public area */
68
	u32 public_base;
68
	u32 public_base;
(-)b/sys/dev/qlnx/qlnxe/qlnx_def.h (-1 / +1 lines)
Lines 391-397 struct qlnx_host { Link Here
391
391
392
	int			msix_count;
392
	int			msix_count;
393
393
394
	struct mtx		hw_lock;
394
	struct sx		hw_lock;
395
395
396
	/* debug */
396
	/* debug */
397
397
(-)b/sys/dev/qlnx/qlnxe/qlnx_os.c (-4 / +5 lines)
Lines 785-791 qlnx_pci_attach(device_t dev) Link Here
785
785
786
        ha->pci_dev = dev;
786
        ha->pci_dev = dev;
787
787
788
	mtx_init(&ha->hw_lock, "qlnx_hw_lock", MTX_NETWORK_LOCK, MTX_DEF);
788
	sx_init(&ha->hw_lock, "qlnx_hw_lock");
789
789
790
        ha->flags.lock_init = 1;
790
        ha->flags.lock_init = 1;
791
791
Lines 1232-1237 qlnx_init_hw(qlnx_host_t *ha) Link Here
1232
	int				rval = 0;
1232
	int				rval = 0;
1233
	struct ecore_hw_prepare_params	params;
1233
	struct ecore_hw_prepare_params	params;
1234
1234
1235
        ha->cdev.ha = ha;
1235
	ecore_init_struct(&ha->cdev);
1236
	ecore_init_struct(&ha->cdev);
1236
1237
1237
	/* ha->dp_module = ECORE_MSG_PROBE |
1238
	/* ha->dp_module = ECORE_MSG_PROBE |
Lines 1376-1382 qlnx_release(qlnx_host_t *ha) Link Here
1376
                pci_release_msi(dev);
1377
                pci_release_msi(dev);
1377
1378
1378
        if (ha->flags.lock_init) {
1379
        if (ha->flags.lock_init) {
1379
                mtx_destroy(&ha->hw_lock);
1380
                sx_destroy(&ha->hw_lock);
1380
        }
1381
        }
1381
1382
1382
        if (ha->pci_reg)
1383
        if (ha->pci_reg)
Lines 5488-5498 qlnx_zalloc(uint32_t size) Link Here
5488
}
5489
}
5489
5490
5490
void
5491
void
5491
qlnx_barrier(void *p_hwfn)
5492
qlnx_barrier(void *p_dev)
5492
{
5493
{
5493
	qlnx_host_t	*ha;
5494
	qlnx_host_t	*ha;
5494
5495
5495
	ha = (qlnx_host_t *)((struct ecore_hwfn *)p_hwfn)->p_dev;
5496
	ha = ((struct ecore_dev *) p_dev)->ha;
5496
	bus_barrier(ha->pci_reg,  0, 0, BUS_SPACE_BARRIER_WRITE);
5497
	bus_barrier(ha->pci_reg,  0, 0, BUS_SPACE_BARRIER_WRITE);
5497
}
5498
}
5498
5499
(-)b/sys/dev/qlnx/qlnxe/qlnx_os.h (-2 / +2 lines)
Lines 140-147 MALLOC_DECLARE(M_QLNXBUF); Link Here
140
/*
140
/*
141
 * Locks
141
 * Locks
142
 */
142
 */
143
#define QLNX_LOCK(ha)		mtx_lock(&ha->hw_lock)
143
#define QLNX_LOCK(ha)		sx_xlock(&ha->hw_lock)
144
#define QLNX_UNLOCK(ha)		mtx_unlock(&ha->hw_lock)
144
#define QLNX_UNLOCK(ha)		sx_xunlock(&ha->hw_lock)
145
145
146
/*
146
/*
147
 * structure encapsulating a DMA buffer
147
 * structure encapsulating a DMA buffer

Return to bug 278084