Skip to content

Commit de21ec4

Browse files
Kalesh APkuba-moo
authored andcommitted
bnxt_en: Add a mutex to synchronize ULP operations
The current scheme relies heavily on the RTNL lock for all ULP operations between the L2 and the RoCE driver. Add a new en_dev_lock mutex so that the asynchronous ULP_STOP and ULP_START operations can be serialized with bnxt_register_dev() and bnxt_unregister_dev() calls without relying on the RTNL lock. The next patch will remove the RTNL lock from the ULP_STOP and ULP_START calls. Reviewed-by: Selvin Thyparampil Xavier <[email protected]> Reviewed-by: Vikas Gupta <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Kalesh AP <[email protected]> Signed-off-by: Michael Chan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f79d7a9 commit de21ec4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ int bnxt_register_dev(struct bnxt_en_dev *edev,
113113
int rc = 0;
114114

115115
rtnl_lock();
116+
mutex_lock(&edev->en_dev_lock);
116117
if (!bp->irq_tbl) {
117118
rc = -ENODEV;
118119
goto exit;
@@ -136,6 +137,7 @@ int bnxt_register_dev(struct bnxt_en_dev *edev,
136137
bnxt_fill_msix_vecs(bp, bp->edev->msix_entries);
137138
edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
138139
exit:
140+
mutex_unlock(&edev->en_dev_lock);
139141
rtnl_unlock();
140142
return rc;
141143
}
@@ -150,6 +152,7 @@ void bnxt_unregister_dev(struct bnxt_en_dev *edev)
150152

151153
ulp = edev->ulp_tbl;
152154
rtnl_lock();
155+
mutex_lock(&edev->en_dev_lock);
153156
if (ulp->msix_requested)
154157
edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
155158
edev->ulp_tbl->msix_requested = 0;
@@ -165,6 +168,7 @@ void bnxt_unregister_dev(struct bnxt_en_dev *edev)
165168
msleep(100);
166169
i++;
167170
}
171+
mutex_unlock(&edev->en_dev_lock);
168172
rtnl_unlock();
169173
return;
170174
}
@@ -223,6 +227,12 @@ void bnxt_ulp_stop(struct bnxt *bp)
223227
if (!edev)
224228
return;
225229

230+
mutex_lock(&edev->en_dev_lock);
231+
if (!bnxt_ulp_registered(edev)) {
232+
mutex_unlock(&edev->en_dev_lock);
233+
return;
234+
}
235+
226236
edev->flags |= BNXT_EN_FLAG_ULP_STOPPED;
227237
if (aux_priv) {
228238
struct auxiliary_device *adev;
@@ -237,6 +247,7 @@ void bnxt_ulp_stop(struct bnxt *bp)
237247
adrv->suspend(adev, pm);
238248
}
239249
}
250+
mutex_unlock(&edev->en_dev_lock);
240251
}
241252

242253
void bnxt_ulp_start(struct bnxt *bp, int err)
@@ -252,6 +263,12 @@ void bnxt_ulp_start(struct bnxt *bp, int err)
252263
if (err)
253264
return;
254265

266+
mutex_lock(&edev->en_dev_lock);
267+
if (!bnxt_ulp_registered(edev)) {
268+
mutex_unlock(&edev->en_dev_lock);
269+
return;
270+
}
271+
255272
if (edev->ulp_tbl->msix_requested)
256273
bnxt_fill_msix_vecs(bp, edev->msix_entries);
257274

@@ -267,7 +284,7 @@ void bnxt_ulp_start(struct bnxt *bp, int err)
267284
adrv->resume(adev);
268285
}
269286
}
270-
287+
mutex_unlock(&edev->en_dev_lock);
271288
}
272289

273290
void bnxt_ulp_irq_stop(struct bnxt *bp)
@@ -383,6 +400,7 @@ static void bnxt_set_edev_info(struct bnxt_en_dev *edev, struct bnxt *bp)
383400
edev->l2_db_size = bp->db_size;
384401
edev->l2_db_size_nc = bp->db_size;
385402
edev->l2_db_offset = bp->db_offset;
403+
mutex_init(&edev->en_dev_lock);
386404

387405
if (bp->flags & BNXT_FLAG_ROCEV1_CAP)
388406
edev->flags |= BNXT_EN_FLAG_ROCEV1_CAP;

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ struct bnxt_en_dev {
8888

8989
u16 ulp_num_msix_vec;
9090
u16 ulp_num_ctxs;
91+
92+
/* serialize ulp operations */
93+
struct mutex en_dev_lock;
9194
};
9295

9396
static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)

0 commit comments

Comments
 (0)