Skip to content

Commit f2eb77c

Browse files
committed
net: hbl_cn: use port common cfg lock instead of asic specific
Replace the port's cfg lock from port specific into port's common code. This change is further to the common cfg lock function change. Signed-off-by: Tal Cohen <tal5.cohen@intel.com>
1 parent 12c3407 commit f2eb77c

4 files changed

Lines changed: 11 additions & 47 deletions

File tree

drivers/net/ethernet/intel/hbl_cn/common/hbl_cn.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,30 +1667,20 @@ void hbl_cn_hard_reset_prepare(struct hbl_aux_dev *cn_aux_dev, bool fw_reset, bo
16671667
}
16681668

16691669
void hbl_cn_cfg_lock(struct hbl_cn_port *cn_port)
1670+
__acquires(&cn_port->cfg_lock)
16701671
{
1671-
struct hbl_cn_device *hdev = cn_port->hdev;
1672-
struct hbl_cn_asic_port_funcs *port_funcs;
1673-
1674-
port_funcs = hdev->asic_funcs->port_funcs;
1675-
port_funcs->cfg_lock(cn_port);
1672+
mutex_lock(&cn_port->cfg_lock);
16761673
}
16771674

16781675
void hbl_cn_cfg_unlock(struct hbl_cn_port *cn_port)
1676+
__releases(&cn_port->cfg_lock)
16791677
{
1680-
struct hbl_cn_device *hdev = cn_port->hdev;
1681-
struct hbl_cn_asic_port_funcs *port_funcs;
1682-
1683-
port_funcs = hdev->asic_funcs->port_funcs;
1684-
port_funcs->cfg_unlock(cn_port);
1678+
mutex_unlock(&cn_port->cfg_lock);
16851679
}
16861680

16871681
bool hbl_cn_cfg_is_locked(struct hbl_cn_port *cn_port)
16881682
{
1689-
struct hbl_cn_device *hdev = cn_port->hdev;
1690-
struct hbl_cn_asic_port_funcs *port_funcs;
1691-
1692-
port_funcs = hdev->asic_funcs->port_funcs;
1693-
return port_funcs->cfg_is_locked(cn_port);
1683+
return mutex_is_locked(&cn_port->cfg_lock);
16941684
}
16951685

16961686
int hbl_cn_send_port_cpucp_status(struct hbl_aux_dev *aux_dev, u32 port, u8 cmd, u8 period)
@@ -4740,6 +4730,7 @@ static int cn_port_sw_init(struct hbl_cn_port *cn_port)
47404730

47414731
mutex_init(&cn_port->control_lock);
47424732
mutex_init(&cn_port->cnt_lock);
4733+
mutex_init(&cn_port->cfg_lock);
47434734

47444735
xa_init_flags(&cn_port->qp_ids, XA_FLAGS_ALLOC);
47454736
xa_init_flags(&cn_port->db_fifo_ids, XA_FLAGS_ALLOC);
@@ -4770,6 +4761,7 @@ static int cn_port_sw_init(struct hbl_cn_port *cn_port)
47704761

47714762
mutex_destroy(&cn_port->cnt_lock);
47724763
mutex_destroy(&cn_port->control_lock);
4764+
mutex_destroy(&cn_port->cfg_lock);
47734765

47744766
if (max_qp_error_syndromes)
47754767
kfree(reset_tracker);

drivers/net/ethernet/intel/hbl_cn/common/hbl_cn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,8 @@ struct hbl_cn_port {
11711171
struct mutex control_lock;
11721172
/* protects the counters from concurrent reading */
11731173
struct mutex cnt_lock;
1174+
/* Serializes the port configuration */
1175+
struct mutex cfg_lock;
11741176
struct xarray qp_ids;
11751177
struct xarray db_fifo_ids;
11761178
struct xarray cq_ids;

drivers/net/ethernet/intel/hbl_cn/gaudi2/gaudi2_cn.c

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@ static void gaudi2_cn_port_sw_fini(struct hbl_cn_port *cn_port)
755755
struct gaudi2_cn_port *gaudi2_port = cn_port->cn_specific;
756756

757757
mutex_destroy(&gaudi2_port->qp_destroy_lock);
758-
mutex_destroy(&gaudi2_port->cfg_lock);
759758

760759
hbl_cn_eq_dispatcher_fini(cn_port);
761760
gaudi2_cn_free_rings_resources(gaudi2_port);
@@ -795,7 +794,6 @@ static int gaudi2_cn_port_sw_init(struct hbl_cn_port *cn_port)
795794

796795
hbl_cn_eq_dispatcher_init(gaudi2_port->cn_port);
797796

798-
mutex_init(&gaudi2_port->cfg_lock);
799797
mutex_init(&gaudi2_port->qp_destroy_lock);
800798

801799
/* Userspace might not be notified immediately of link event from HW.
@@ -5091,11 +5089,11 @@ static void gaudi2_qp_sanity_work(struct work_struct *work)
50915089

50925090
gaudi2_port->qp_timeout_cnt = timeout_cnt;
50935091

5094-
mutex_lock(&gaudi2_port->cfg_lock);
5092+
hbl_cn_cfg_lock(cn_port);
50955093
xa_for_each(&cn_port->qp_ids, qp_id, qp)
50965094
if (qp && qp->is_req)
50975095
__qpc_sanity_check(gaudi2_port, qp_id);
5098-
mutex_unlock(&gaudi2_port->cfg_lock);
5096+
hbl_cn_cfg_unlock(cn_port);
50995097

51005098
done:
51015099
queue_delayed_work(gaudi2_port->qp_sanity_wq, &gaudi2_port->qp_sanity_work,
@@ -5270,29 +5268,6 @@ static void gaudi2_cn_get_status(struct hbl_cn_port *cn_port, struct hbl_cn_cpuc
52705268
status->high_ber_cnt = high_ber_cnt;
52715269
}
52725270

5273-
static void gaudi2_cn_cfg_lock(struct hbl_cn_port *cn_port)
5274-
__acquires(&gaudi2_port->cfg_lock)
5275-
{
5276-
struct gaudi2_cn_port *gaudi2_port = cn_port->cn_specific;
5277-
5278-
mutex_lock(&gaudi2_port->cfg_lock);
5279-
}
5280-
5281-
static void gaudi2_cn_cfg_unlock(struct hbl_cn_port *cn_port)
5282-
__releases(&gaudi2_port->cfg_lock)
5283-
{
5284-
struct gaudi2_cn_port *gaudi2_port = cn_port->cn_specific;
5285-
5286-
mutex_unlock(&gaudi2_port->cfg_lock);
5287-
}
5288-
5289-
static bool gaudi2_cn_cfg_is_locked(struct hbl_cn_port *cn_port)
5290-
{
5291-
struct gaudi2_cn_port *gaudi2_port = cn_port->cn_specific;
5292-
5293-
return mutex_is_locked(&gaudi2_port->cfg_lock);
5294-
}
5295-
52965271
static u32 gaudi2_cn_get_max_msg_sz(struct hbl_cn_device *hdev)
52975272
{
52985273
return SZ_1G;
@@ -5594,9 +5569,6 @@ static struct hbl_cn_asic_port_funcs gaudi2_cn_port_funcs = {
55945569
.collect_fec_stats = gaudi2_cn_debugfs_collect_fec_stats,
55955570
.disable_wqe_index_checker = gaudi2_cn_disable_wqe_index_checker,
55965571
.get_status = gaudi2_cn_get_status,
5597-
.cfg_lock = gaudi2_cn_cfg_lock,
5598-
.cfg_unlock = gaudi2_cn_cfg_unlock,
5599-
.cfg_is_locked = gaudi2_cn_cfg_is_locked,
56005572
.qp_pre_destroy = gaudi2_cn_qp_pre_destroy,
56015573
.qp_post_destroy = gaudi2_cn_qp_post_destroy,
56025574
.set_port_status = gaudi2_cn_set_port_status,

drivers/net/ethernet/intel/hbl_cn/gaudi2/gaudi2_cn.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ struct gaudi2_cn_port {
332332
struct delayed_work eq_work;
333333
struct delayed_work qp_sanity_work;
334334
struct workqueue_struct *qp_sanity_wq;
335-
/* Serializes the port configuration */
336-
struct mutex cfg_lock;
337335
/* protects the MAC loopback switching for QP destroy flow */
338336
struct mutex qp_destroy_lock;
339337
ktime_t pcs_link_stady_state_ts;

0 commit comments

Comments
 (0)