Skip to content

Commit 8f2fd39

Browse files
committed
Merge branch 'hns3-fixes'
Guangbin Huang says: ==================== net: hns3: add some fixes for -net This series adds some fixes for the HNS3 ethernet driver. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 3748939 + 6dde452 commit 8f2fd39

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ struct hnae3_handle {
839839

840840
u8 netdev_flags;
841841
struct dentry *hnae3_dbgfs;
842+
/* protects concurrent contention between debugfs commands */
843+
struct mutex dbgfs_lock;
842844

843845
/* Network interface message level enabled bits */
844846
u32 msg_enable;

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,7 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
12261226
if (ret)
12271227
return ret;
12281228

1229+
mutex_lock(&handle->dbgfs_lock);
12291230
save_buf = &hns3_dbg_cmd[index].buf;
12301231

12311232
if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
@@ -1238,15 +1239,15 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
12381239
read_buf = *save_buf;
12391240
} else {
12401241
read_buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL);
1241-
if (!read_buf)
1242-
return -ENOMEM;
1242+
if (!read_buf) {
1243+
ret = -ENOMEM;
1244+
goto out;
1245+
}
12431246

12441247
/* save the buffer addr until the last read operation */
12451248
*save_buf = read_buf;
1246-
}
12471249

1248-
/* get data ready for the first time to read */
1249-
if (!*ppos) {
1250+
/* get data ready for the first time to read */
12501251
ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
12511252
read_buf, hns3_dbg_cmd[index].buf_len);
12521253
if (ret)
@@ -1255,8 +1256,10 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
12551256

12561257
size = simple_read_from_buffer(buffer, count, ppos, read_buf,
12571258
strlen(read_buf));
1258-
if (size > 0)
1259+
if (size > 0) {
1260+
mutex_unlock(&handle->dbgfs_lock);
12591261
return size;
1262+
}
12601263

12611264
out:
12621265
/* free the buffer for the last read operation */
@@ -1265,6 +1268,7 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
12651268
*save_buf = NULL;
12661269
}
12671270

1271+
mutex_unlock(&handle->dbgfs_lock);
12681272
return ret;
12691273
}
12701274

@@ -1337,6 +1341,8 @@ int hns3_dbg_init(struct hnae3_handle *handle)
13371341
debugfs_create_dir(hns3_dbg_dentry[i].name,
13381342
handle->hnae3_dbgfs);
13391343

1344+
mutex_init(&handle->dbgfs_lock);
1345+
13401346
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) {
13411347
if ((hns3_dbg_cmd[i].cmd == HNAE3_DBG_CMD_TM_NODES &&
13421348
ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2) ||
@@ -1363,6 +1369,7 @@ int hns3_dbg_init(struct hnae3_handle *handle)
13631369
return 0;
13641370

13651371
out:
1372+
mutex_destroy(&handle->dbgfs_lock);
13661373
debugfs_remove_recursive(handle->hnae3_dbgfs);
13671374
handle->hnae3_dbgfs = NULL;
13681375
return ret;
@@ -1378,6 +1385,7 @@ void hns3_dbg_uninit(struct hnae3_handle *handle)
13781385
hns3_dbg_cmd[i].buf = NULL;
13791386
}
13801387

1388+
mutex_destroy(&handle->dbgfs_lock);
13811389
debugfs_remove_recursive(handle->hnae3_dbgfs);
13821390
handle->hnae3_dbgfs = NULL;
13831391
}

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev,
114114

115115
memcpy(&req->msg, send_msg, sizeof(struct hclge_vf_to_pf_msg));
116116

117-
trace_hclge_vf_mbx_send(hdev, req);
117+
if (test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state))
118+
trace_hclge_vf_mbx_send(hdev, req);
118119

119120
/* synchronous send */
120121
if (need_resp) {

0 commit comments

Comments
 (0)