Skip to content

Commit 20d130b

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 20d130b

4 files changed

Lines changed: 12 additions & 48 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);
@@ -4768,6 +4759,7 @@ static int cn_port_sw_init(struct hbl_cn_port *cn_port)
47684759
xa_destroy(&cn_port->db_fifo_ids);
47694760
xa_destroy(&cn_port->qp_ids);
47704761

4762+
mutex_destroy(&cn_port->cfg_lock);
47714763
mutex_destroy(&cn_port->cnt_lock);
47724764
mutex_destroy(&cn_port->control_lock);
47734765

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ struct hbl_cn_macro {
11071107
* @control_lock: protects from a race between port open/close and other stuff that might run in
11081108
* parallel (such as event handling).
11091109
* @cnt_lock: protects the counters from concurrent reading. Needed for SPMU and XPCS91 counters.
1110+
* @cfg_lock: serializes the port configuration
11101111
* @qp_ids: xarray to hold all QP IDs.
11111112
* @db_fifo_ids: Allocated doorbell fifo IDs.
11121113
* @cq_ids: xarray to hold all CQ IDs.
@@ -1171,6 +1172,8 @@ struct hbl_cn_port {
11711172
struct mutex control_lock;
11721173
/* protects the counters from concurrent reading */
11731174
struct mutex cnt_lock;
1175+
/* serializes the port configuration */
1176+
struct mutex cfg_lock;
11741177
struct xarray qp_ids;
11751178
struct xarray db_fifo_ids;
11761179
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ struct gaudi2_cn_port;
305305
* @eq_work: EQ work for processing events (e.g Tx completion).
306306
* @qp_sanity_work: QPC sanity check worker.
307307
* @qp_sanity_wq: QPC sanity worker thread.
308-
* @cfg_lock: Serializes the port configuration.
309308
* @qp_destroy_lock: protects the MAC loopback switching for QP destroy flow.
310309
* @pcs_link_stady_state_ts: the timestamp to move to the pcs link steady state.
311310
* @pcs_link_state: the current pcs link state.
@@ -332,8 +331,6 @@ struct gaudi2_cn_port {
332331
struct delayed_work eq_work;
333332
struct delayed_work qp_sanity_work;
334333
struct workqueue_struct *qp_sanity_wq;
335-
/* Serializes the port configuration */
336-
struct mutex cfg_lock;
337334
/* protects the MAC loopback switching for QP destroy flow */
338335
struct mutex qp_destroy_lock;
339336
ktime_t pcs_link_stady_state_ts;

0 commit comments

Comments
 (0)