* [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver
@ 2023-10-28 2:59 Jijie Shao
2023-10-28 2:59 ` [PATCH net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
` (6 more replies)
0 siblings, 7 replies; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
There are some bugfix for the HNS3 ethernet driver
Jian Shen (2):
net: hns3: fix add VLAN fail issue
net: hns3: fix incorrect capability bit display for copper port
Jijie Shao (2):
net: hns3: fix VF reset fail issue
net: hns3: fix VF wrong speed and duplex issue
Yonglong Liu (3):
net: hns3: add barrier in vf mailbox reply process
net: hns3: fix out-of-bounds access may occur when coalesce info is
read via debugfs
net: hns3: fix variable may not initialized problem in
hns3_init_mac_addr()
.../ethernet/hisilicon/hns3/hns3_debugfs.c | 9 ++++---
.../net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
.../hisilicon/hns3/hns3pf/hclge_main.c | 26 ++++++++++++++-----
.../hisilicon/hns3/hns3vf/hclgevf_main.c | 24 +++++++++++++----
.../hisilicon/hns3/hns3vf/hclgevf_mbx.c | 7 +++++
5 files changed, 53 insertions(+), 15 deletions(-)
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 1/7] net: hns3: fix add VLAN fail issue
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
2023-11-02 10:31 ` Paolo Abeni
2023-10-28 2:59 ` [PATCH net 2/7] net: hns3: add barrier in vf mailbox reply process Jijie Shao
` (5 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
From: Jian Shen <shenjian15@huawei.com>
The hclge_sync_vlan_filter is called in periodic task,
trying to remove VLAN from vlan_del_fail_bmap. It can
be concurrence with VLAN adding operation from user.
So once user failed to delete a VLAN id, and add it
again soon, it may be removed by the periodic task,
which may cause the software configuration being
inconsistent with hardware. So add mutex handling
to avoid this.
user hns3 driver
periodic task
│
add vlan 10 ───── hns3_vlan_rx_add_vid │
│ (suppose success) │
│ │
del vlan 10 ───── hns3_vlan_rx_kill_vid │
│ (suppose fail,add to │
│ vlan_del_fail_bmap) │
│ │
add vlan 10 ───── hns3_vlan_rx_add_vid │
(suppose success) │
foreach vlan_del_fail_bmp
del vlan 10
Fixes: fe4144d47eef ("net: hns3: sync VLAN filter entries when kill VLAN ID failed")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
.../hisilicon/hns3/hns3pf/hclge_main.c | 21 +++++++++++++------
.../hisilicon/hns3/hns3vf/hclgevf_main.c | 11 ++++++++--
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index c42574e29747..a3230ac928a9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10026,8 +10026,6 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
struct hclge_vport_vlan_cfg *vlan, *tmp;
struct hclge_dev *hdev = vport->back;
- mutex_lock(&hdev->vport_lock);
-
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
if (vlan->vlan_id == vlan_id) {
if (is_write_tbl && vlan->hd_tbl_status)
@@ -10042,8 +10040,6 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
break;
}
}
-
- mutex_unlock(&hdev->vport_lock);
}
void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list)
@@ -10452,11 +10448,16 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
* handle mailbox. Just record the vlan id, and remove it after
* reset finished.
*/
+ mutex_lock(&hdev->vport_lock);
if ((test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) ||
test_bit(HCLGE_STATE_RST_FAIL, &hdev->state)) && is_kill) {
set_bit(vlan_id, vport->vlan_del_fail_bmap);
+ mutex_unlock(&hdev->vport_lock);
return -EBUSY;
+ } else if (!is_kill && test_bit(vlan_id, vport->vlan_del_fail_bmap)) {
+ clear_bit(vlan_id, vport->vlan_del_fail_bmap);
}
+ mutex_unlock(&hdev->vport_lock);
/* when port base vlan enabled, we use port base vlan as the vlan
* filter entry. In this case, we don't update vlan filter table
@@ -10481,7 +10482,9 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
* and try to remove it from hw later, to be consistence
* with stack
*/
+ mutex_lock(&hdev->vport_lock);
set_bit(vlan_id, vport->vlan_del_fail_bmap);
+ mutex_unlock(&hdev->vport_lock);
}
hclge_set_vport_vlan_fltr_change(vport);
@@ -10521,6 +10524,7 @@ static void hclge_sync_vlan_filter(struct hclge_dev *hdev)
int i, ret, sync_cnt = 0;
u16 vlan_id;
+ mutex_lock(&hdev->vport_lock);
/* start from vport 1 for PF is always alive */
for (i = 0; i < hdev->num_alloc_vport; i++) {
struct hclge_vport *vport = &hdev->vport[i];
@@ -10531,21 +10535,26 @@ static void hclge_sync_vlan_filter(struct hclge_dev *hdev)
ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q),
vport->vport_id, vlan_id,
true);
- if (ret && ret != -EINVAL)
+ if (ret && ret != -EINVAL) {
+ mutex_unlock(&hdev->vport_lock);
return;
+ }
clear_bit(vlan_id, vport->vlan_del_fail_bmap);
hclge_rm_vport_vlan_table(vport, vlan_id, false);
hclge_set_vport_vlan_fltr_change(vport);
sync_cnt++;
- if (sync_cnt >= HCLGE_MAX_SYNC_COUNT)
+ if (sync_cnt >= HCLGE_MAX_SYNC_COUNT) {
+ mutex_unlock(&hdev->vport_lock);
return;
+ }
vlan_id = find_first_bit(vport->vlan_del_fail_bmap,
VLAN_N_VID);
}
}
+ mutex_unlock(&hdev->vport_lock);
hclge_sync_vlan_fltr_state(hdev);
}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index a4d68fb216fb..1c62e58ff6d8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1206,6 +1206,8 @@ static int hclgevf_set_vlan_filter(struct hnae3_handle *handle,
test_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state)) && is_kill) {
set_bit(vlan_id, hdev->vlan_del_fail_bmap);
return -EBUSY;
+ } else if (!is_kill && test_bit(vlan_id, hdev->vlan_del_fail_bmap)) {
+ clear_bit(vlan_id, hdev->vlan_del_fail_bmap);
}
hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
@@ -1233,20 +1235,25 @@ static void hclgevf_sync_vlan_filter(struct hclgevf_dev *hdev)
int ret, sync_cnt = 0;
u16 vlan_id;
+ if (bitmap_empty(hdev->vlan_del_fail_bmap, VLAN_N_VID))
+ return;
+
+ rtnl_lock();
vlan_id = find_first_bit(hdev->vlan_del_fail_bmap, VLAN_N_VID);
while (vlan_id != VLAN_N_VID) {
ret = hclgevf_set_vlan_filter(handle, htons(ETH_P_8021Q),
vlan_id, true);
if (ret)
- return;
+ break;
clear_bit(vlan_id, hdev->vlan_del_fail_bmap);
sync_cnt++;
if (sync_cnt >= HCLGEVF_MAX_SYNC_COUNT)
- return;
+ break;
vlan_id = find_first_bit(hdev->vlan_del_fail_bmap, VLAN_N_VID);
}
+ rtnl_unlock();
}
static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 2/7] net: hns3: add barrier in vf mailbox reply process
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2023-10-28 2:59 ` [PATCH net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
2023-10-28 2:59 ` [PATCH net 3/7] net: hns3: fix incorrect capability bit display for copper port Jijie Shao
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
From: Yonglong Liu <liuyonglong@huawei.com>
In hclgevf_mbx_handler() and hclgevf_get_mbx_resp() functions,
there is a typical store-store and load-load scenario between
received_resp and additional_info. This patch adds barrier
to fix the problem.
Fixes: 4671042f1ef0 ("net: hns3: add match_id to check mailbox response from PF to VF")
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
index bbf7b14079de..85c2a634c8f9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
@@ -63,6 +63,9 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1,
i++;
}
+ /* ensure additional_info will be seen after received_resp */
+ smp_rmb();
+
if (i >= HCLGEVF_MAX_TRY_TIMES) {
dev_err(&hdev->pdev->dev,
"VF could not get mbx(%u,%u) resp(=%d) from PF in %d tries\n",
@@ -178,6 +181,10 @@ static void hclgevf_handle_mbx_response(struct hclgevf_dev *hdev,
resp->resp_status = hclgevf_resp_to_errno(resp_status);
memcpy(resp->additional_info, req->msg.resp_data,
HCLGE_MBX_MAX_RESP_DATA_SIZE * sizeof(u8));
+
+ /* ensure additional_info will be seen before setting received_resp */
+ smp_wmb();
+
if (match_id) {
/* If match_id is not zero, it means PF support match_id.
* if the match_id is right, VF get the right response, or
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 3/7] net: hns3: fix incorrect capability bit display for copper port
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2023-10-28 2:59 ` [PATCH net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
2023-10-28 2:59 ` [PATCH net 2/7] net: hns3: add barrier in vf mailbox reply process Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
2023-10-28 2:59 ` [PATCH net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs Jijie Shao
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
From: Jian Shen <shenjian15@huawei.com>
Currently, the FEC capability bit is default set for device version V2.
It's incorrect for the copper port. Eventhough it doesn't make the nic
work abnormal, but the capability information display in debugfs may
confuse user. So clear it when driver get the port type inforamtion.
Fixes: 433ccce83504 ("net: hns3: use FEC capability queried from firmware")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index a3230ac928a9..7d3f4d281704 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -11661,6 +11661,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
goto err_msi_irq_uninit;
if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) {
+ clear_bit(HNAE3_DEV_SUPPORT_FEC_B, ae_dev->caps);
if (hnae3_dev_phy_imp_supported(hdev))
ret = hclge_update_tp_port_info(hdev);
else
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (2 preceding siblings ...)
2023-10-28 2:59 ` [PATCH net 3/7] net: hns3: fix incorrect capability bit display for copper port Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
2023-10-28 2:59 ` [PATCH net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() Jijie Shao
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
From: Yonglong Liu <liuyonglong@huawei.com>
The hns3 driver define an array of string to show the coalesce
info, but if the kernel adds a new mode or a new state,
out-of-bounds access may occur when coalesce info is read via
debugfs, this patch fix the problem.
Fixes: c99fead7cb07 ("net: hns3: add debugfs support for interrupt coalesce")
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index b8508533878b..4f385a18d288 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -500,11 +500,14 @@ static void hns3_get_coal_info(struct hns3_enet_tqp_vector *tqp_vector,
}
sprintf(result[j++], "%d", i);
- sprintf(result[j++], "%s", dim_state_str[dim->state]);
+ sprintf(result[j++], "%s", dim->state < ARRAY_SIZE(dim_state_str) ?
+ dim_state_str[dim->state] : "unknown");
sprintf(result[j++], "%u", dim->profile_ix);
- sprintf(result[j++], "%s", dim_cqe_mode_str[dim->mode]);
+ sprintf(result[j++], "%s", dim->mode < ARRAY_SIZE(dim_cqe_mode_str) ?
+ dim_cqe_mode_str[dim->mode] : "unknown");
sprintf(result[j++], "%s",
- dim_tune_stat_str[dim->tune_state]);
+ dim->tune_state < ARRAY_SIZE(dim_tune_stat_str) ?
+ dim_tune_stat_str[dim->tune_state] : "unknown");
sprintf(result[j++], "%u", dim->steps_left);
sprintf(result[j++], "%u", dim->steps_right);
sprintf(result[j++], "%u", dim->tired);
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr()
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (3 preceding siblings ...)
2023-10-28 2:59 ` [PATCH net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
2023-10-28 2:59 ` [PATCH net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
2023-10-28 2:59 ` [PATCH net 7/7] net: hns3: fix VF wrong speed and duplex issue Jijie Shao
6 siblings, 0 replies; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
From: Yonglong Liu <liuyonglong@huawei.com>
When a VF is calling hns3_init_mac_addr(), get_mac_addr() may
return fail, then the value of mac_addr_temp is not initialized.
Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index cf50368441b7..677cfaa5fe08 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -5140,7 +5140,7 @@ static int hns3_init_mac_addr(struct net_device *netdev)
struct hns3_nic_priv *priv = netdev_priv(netdev);
char format_mac_addr[HNAE3_FORMAT_MAC_ADDR_LEN];
struct hnae3_handle *h = priv->ae_handle;
- u8 mac_addr_temp[ETH_ALEN];
+ u8 mac_addr_temp[ETH_ALEN] = {0};
int ret = 0;
if (h->ae_algo->ops->get_mac_addr)
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 6/7] net: hns3: fix VF reset fail issue
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (4 preceding siblings ...)
2023-10-28 2:59 ` [PATCH net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
2023-11-02 10:45 ` Paolo Abeni
2023-10-28 2:59 ` [PATCH net 7/7] net: hns3: fix VF wrong speed and duplex issue Jijie Shao
6 siblings, 1 reply; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
Currently the reset process in hns3 and firmware watchdog init process is
asynchronous. We think firmware watchdog initialization is completed
before VF clear the interrupt source. However, firmware initialization
may not complete early. So VF will receive multiple reset interrupts
and fail to reset.
So we add delay before VF interrupt source and 5 ms delay
is enough to avoid second reset interrupt.
Fixes: 427900d27d86 ("net: hns3: fix the timing issue of VF clearing interrupt sources")
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
.../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 1c62e58ff6d8..7b87da031be6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1924,8 +1924,14 @@ static void hclgevf_service_task(struct work_struct *work)
hclgevf_mailbox_service_task(hdev);
}
-static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr)
+static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr,
+ bool need_dalay)
{
+#define HCLGEVF_RESET_DELAY 5
+
+ if (need_dalay)
+ mdelay(HCLGEVF_RESET_DELAY);
+
hclgevf_write_dev(&hdev->hw, HCLGE_COMM_VECTOR0_CMDQ_SRC_REG, regclr);
}
@@ -1990,7 +1996,8 @@ static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data)
hclgevf_enable_vector(&hdev->misc_vector, false);
event_cause = hclgevf_check_evt_cause(hdev, &clearval);
if (event_cause != HCLGEVF_VECTOR0_EVENT_OTHER)
- hclgevf_clear_event_cause(hdev, clearval);
+ hclgevf_clear_event_cause(hdev, clearval,
+ event_cause == HCLGEVF_VECTOR0_EVENT_RST);
switch (event_cause) {
case HCLGEVF_VECTOR0_EVENT_RST:
@@ -2340,7 +2347,7 @@ static int hclgevf_misc_irq_init(struct hclgevf_dev *hdev)
return ret;
}
- hclgevf_clear_event_cause(hdev, 0);
+ hclgevf_clear_event_cause(hdev, 0, false);
/* enable misc. vector(vector 0) */
hclgevf_enable_vector(&hdev->misc_vector, true);
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net 7/7] net: hns3: fix VF wrong speed and duplex issue
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (5 preceding siblings ...)
2023-10-28 2:59 ` [PATCH net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
@ 2023-10-28 2:59 ` Jijie Shao
6 siblings, 0 replies; 13+ messages in thread
From: Jijie Shao @ 2023-10-28 2:59 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni
Cc: shenjian15, wangjie125, liuyonglong, shaojijie, netdev, linux-kernel
If PF is down, firmware will returns 10 Mbit/s rate and half-duplex mode
when PF queries the port information from firmware.
After imp reset command is executed, PF status changes to down,
and PF will query link status and updates port information
from firmware in a periodic scheduled task.
However, there is a low probability that port information is updated
when PF is down, and then PF link status changes to up.
In this case, PF synchronizes incorrect rate and duplex mode to VF.
This patch fixes it by updating port information before
PF synchronizes the rate and duplex to the VF
when PF changes to up.
Fixes: 18b6e31f8bf4 ("net: hns3: PF add support for pushing link status to VFs")
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 7d3f4d281704..2b8f8f8c120d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -61,6 +61,7 @@ static void hclge_sync_fd_table(struct hclge_dev *hdev);
static void hclge_update_fec_stats(struct hclge_dev *hdev);
static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret,
int wait_cnt);
+static int hclge_update_port_info(struct hclge_dev *hdev);
static struct hnae3_ae_algo ae_algo;
@@ -3043,6 +3044,9 @@ static void hclge_update_link_status(struct hclge_dev *hdev)
if (state != hdev->hw.mac.link) {
hdev->hw.mac.link = state;
+ if (state == HCLGE_LINK_STATUS_UP)
+ hclge_update_port_info(hdev);
+
client->ops->link_status_change(handle, state);
hclge_config_mac_tnl_int(hdev, state);
if (rclient && rclient->ops->link_status_change)
--
2.30.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net 1/7] net: hns3: fix add VLAN fail issue
2023-10-28 2:59 ` [PATCH net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
@ 2023-11-02 10:31 ` Paolo Abeni
2023-11-02 12:29 ` Jijie Shao
0 siblings, 1 reply; 13+ messages in thread
From: Paolo Abeni @ 2023-11-02 10:31 UTC (permalink / raw)
To: Jijie Shao, yisen.zhuang, salil.mehta, davem, edumazet, kuba
Cc: shenjian15, wangjie125, liuyonglong, netdev, linux-kernel
On Sat, 2023-10-28 at 10:59 +0800, Jijie Shao wrote:
> From: Jian Shen <shenjian15@huawei.com>
>
> The hclge_sync_vlan_filter is called in periodic task,
> trying to remove VLAN from vlan_del_fail_bmap. It can
> be concurrence with VLAN adding operation from user.
> So once user failed to delete a VLAN id, and add it
> again soon, it may be removed by the periodic task,
> which may cause the software configuration being
> inconsistent with hardware. So add mutex handling
> to avoid this.
>
> user hns3 driver
>
> periodic task
> │
> add vlan 10 ───── hns3_vlan_rx_add_vid │
> │ (suppose success) │
> │ │
> del vlan 10 ───── hns3_vlan_rx_kill_vid │
> │ (suppose fail,add to │
> │ vlan_del_fail_bmap) │
> │ │
> add vlan 10 ───── hns3_vlan_rx_add_vid │
> (suppose success) │
> foreach vlan_del_fail_bmp
> del vlan 10
>
> Fixes: fe4144d47eef ("net: hns3: sync VLAN filter entries when kill VLAN ID failed")
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
> .../hisilicon/hns3/hns3pf/hclge_main.c | 21 +++++++++++++------
> .../hisilicon/hns3/hns3vf/hclgevf_main.c | 11 ++++++++--
> 2 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index c42574e29747..a3230ac928a9 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -10026,8 +10026,6 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
> struct hclge_vport_vlan_cfg *vlan, *tmp;
> struct hclge_dev *hdev = vport->back;
>
> - mutex_lock(&hdev->vport_lock);
> -
> list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
> if (vlan->vlan_id == vlan_id) {
> if (is_write_tbl && vlan->hd_tbl_status)
> @@ -10042,8 +10040,6 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
> break;
> }
> }
> -
> - mutex_unlock(&hdev->vport_lock);
> }
>
> void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list)
> @@ -10452,11 +10448,16 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
> * handle mailbox. Just record the vlan id, and remove it after
> * reset finished.
> */
> + mutex_lock(&hdev->vport_lock);
> if ((test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) ||
> test_bit(HCLGE_STATE_RST_FAIL, &hdev->state)) && is_kill) {
> set_bit(vlan_id, vport->vlan_del_fail_bmap);
> + mutex_unlock(&hdev->vport_lock);
> return -EBUSY;
> + } else if (!is_kill && test_bit(vlan_id, vport->vlan_del_fail_bmap)) {
> + clear_bit(vlan_id, vport->vlan_del_fail_bmap);
> }
> + mutex_unlock(&hdev->vport_lock);
>
> /* when port base vlan enabled, we use port base vlan as the vlan
> * filter entry. In this case, we don't update vlan filter table
> @@ -10481,7 +10482,9 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
> * and try to remove it from hw later, to be consistence
> * with stack
> */
> + mutex_lock(&hdev->vport_lock);
> set_bit(vlan_id, vport->vlan_del_fail_bmap);
> + mutex_unlock(&hdev->vport_lock);
It looks like that the 'hclge_rm_vport_vlan_table()' call a few lines
above will now happen with the vport_lock unlocked.
That looks racy and would deserve at least a comment explaining why
it's safe.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net 6/7] net: hns3: fix VF reset fail issue
2023-10-28 2:59 ` [PATCH net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
@ 2023-11-02 10:45 ` Paolo Abeni
2023-11-02 12:16 ` Jijie Shao
0 siblings, 1 reply; 13+ messages in thread
From: Paolo Abeni @ 2023-11-02 10:45 UTC (permalink / raw)
To: Jijie Shao, yisen.zhuang, salil.mehta, davem, edumazet, kuba
Cc: shenjian15, wangjie125, liuyonglong, netdev, linux-kernel
On Sat, 2023-10-28 at 10:59 +0800, Jijie Shao wrote:
> Currently the reset process in hns3 and firmware watchdog init process is
> asynchronous. We think firmware watchdog initialization is completed
> before VF clear the interrupt source. However, firmware initialization
> may not complete early. So VF will receive multiple reset interrupts
> and fail to reset.
>
> So we add delay before VF interrupt source and 5 ms delay
> is enough to avoid second reset interrupt.
>
> Fixes: 427900d27d86 ("net: hns3: fix the timing issue of VF clearing interrupt sources")
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
> .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> index 1c62e58ff6d8..7b87da031be6 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
> @@ -1924,8 +1924,14 @@ static void hclgevf_service_task(struct work_struct *work)
> hclgevf_mailbox_service_task(hdev);
> }
>
> -static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr)
> +static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr,
> + bool need_dalay)
> {
> +#define HCLGEVF_RESET_DELAY 5
> +
> + if (need_dalay)
> + mdelay(HCLGEVF_RESET_DELAY);
5ms delay in an interrupt handler is quite a lot. What about scheduling
a timer from the IH to clear the register when such delay is needed?
Thanks!
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net 6/7] net: hns3: fix VF reset fail issue
2023-11-02 10:45 ` Paolo Abeni
@ 2023-11-02 12:16 ` Jijie Shao
2023-11-02 16:24 ` Paolo Abeni
0 siblings, 1 reply; 13+ messages in thread
From: Jijie Shao @ 2023-11-02 12:16 UTC (permalink / raw)
To: Paolo Abeni, yisen.zhuang, salil.mehta, davem, edumazet, kuba
Cc: shaojijie, shenjian15, wangjie125, liuyonglong, netdev, linux-kernel
on 2023/11/2 18:45, Paolo Abeni wrote:
> On Sat, 2023-10-28 at 10:59 +0800, Jijie Shao wrote:
>>
>> -static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr)
>> +static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr,
>> + bool need_dalay)
>> {
>> +#define HCLGEVF_RESET_DELAY 5
>> +
>> + if (need_dalay)
>> + mdelay(HCLGEVF_RESET_DELAY);
> 5ms delay in an interrupt handler is quite a lot. What about scheduling
> a timer from the IH to clear the register when such delay is needed?
>
> Thanks!
>
> Paolo
Using timer in this case will complicate the code and make maintenance difficult.
We consider reducing the delay time by polling. For example,
the code cycles every 50 us to check whether the write register takes effect.
If yes, the function returns immediately. or the code cycles until 5 ms.
Is this method appropriate?
Thanks!
Jijie
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net 1/7] net: hns3: fix add VLAN fail issue
2023-11-02 10:31 ` Paolo Abeni
@ 2023-11-02 12:29 ` Jijie Shao
0 siblings, 0 replies; 13+ messages in thread
From: Jijie Shao @ 2023-11-02 12:29 UTC (permalink / raw)
To: Paolo Abeni, yisen.zhuang, salil.mehta, davem, edumazet, kuba
Cc: shaojijie, shenjian15, wangjie125, liuyonglong, netdev, linux-kernel
on 2023/11/2 18:31, Paolo Abeni wrote:
> On Sat, 2023-10-28 at 10:59 +0800, Jijie Shao wrote:
>
> /* when port base vlan enabled, we use port base vlan as the vlan
> * filter entry. In this case, we don't update vlan filter table
> @@ -10481,7 +10482,9 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
> * and try to remove it from hw later, to be consistence
> * with stack
> */
> + mutex_lock(&hdev->vport_lock);
> set_bit(vlan_id, vport->vlan_del_fail_bmap);
> + mutex_unlock(&hdev->vport_lock);
> It looks like that the 'hclge_rm_vport_vlan_table()' call a few lines
> above will now happen with the vport_lock unlocked.
>
> That looks racy and would deserve at least a comment explaining why
> it's safe.
>
> Thanks,
>
> Paolo
Yeah, this is a problem that causes the function to be invoked when it
is not locked. We'll get lock before the function be invoked in V2
Thanks, Jijie
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net 6/7] net: hns3: fix VF reset fail issue
2023-11-02 12:16 ` Jijie Shao
@ 2023-11-02 16:24 ` Paolo Abeni
0 siblings, 0 replies; 13+ messages in thread
From: Paolo Abeni @ 2023-11-02 16:24 UTC (permalink / raw)
To: Jijie Shao, yisen.zhuang, salil.mehta, davem, edumazet, kuba
Cc: shenjian15, wangjie125, liuyonglong, netdev, linux-kernel
On Thu, 2023-11-02 at 20:16 +0800, Jijie Shao wrote:
> on 2023/11/2 18:45, Paolo Abeni wrote:
> > On Sat, 2023-10-28 at 10:59 +0800, Jijie Shao wrote:
> > >
> > > -static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr)
> > > +static void hclgevf_clear_event_cause(struct hclgevf_dev *hdev, u32 regclr,
> > > + bool need_dalay)
> > > {
> > > +#define HCLGEVF_RESET_DELAY 5
> > > +
> > > + if (need_dalay)
> > > + mdelay(HCLGEVF_RESET_DELAY);
> > 5ms delay in an interrupt handler is quite a lot. What about scheduling
> > a timer from the IH to clear the register when such delay is needed?
> >
> > Thanks!
> >
> > Paolo
>
> Using timer in this case will complicate the code and make maintenance difficult.
Why?
Would something alike the following be ok? (plus reset_timer
initialization at vf creation and cleanup at vf removal time):
---
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index a4d68fb216fb..626bc67065fc 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1974,6 +1974,14 @@ static enum hclgevf_evt_cause hclgevf_check_evt_cause(struct hclgevf_dev *hdev,
return HCLGEVF_VECTOR0_EVENT_OTHER;
}
+static void hclgevf_reset_timer(struct timer_list *t)
+{
+ struct hclgevf_dev *hdev = from_timer(hclgevf_dev, t, reset_timer);
+
+ hclgevf_clear_event_cause(hdev, HCLGEVF_VECTOR0_EVENT_RST);
+ hclgevf_reset_task_schedule(hdev);
+}
+
static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data)
{
enum hclgevf_evt_cause event_cause;
@@ -1982,13 +1990,13 @@ static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data)
hclgevf_enable_vector(&hdev->misc_vector, false);
event_cause = hclgevf_check_evt_cause(hdev, &clearval);
+ if (event_cause == HCLGEVF_VECTOR0_EVENT_RST)
+ mod_timer(hdev->reset_timer, jiffies + msecs_to_jiffies(5));
+
if (event_cause != HCLGEVF_VECTOR0_EVENT_OTHER)
hclgevf_clear_event_cause(hdev, clearval);
switch (event_cause) {
- case HCLGEVF_VECTOR0_EVENT_RST:
- hclgevf_reset_task_schedule(hdev);
- break;
case HCLGEVF_VECTOR0_EVENT_MBX:
hclgevf_mbx_handler(hdev);
break;
---
> We consider reducing the delay time by polling. For example,
> the code cycles every 50 us to check whether the write register takes effect.
> If yes, the function returns immediately. or the code cycles until 5 ms.
>
> Is this method appropriate?
IMHO such solution will not remove the problem. How frequent is
expected to be the irq generating such delay?
Thanks
Paolo
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-11-02 16:25 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-28 2:59 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2023-10-28 2:59 ` [PATCH net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
2023-11-02 10:31 ` Paolo Abeni
2023-11-02 12:29 ` Jijie Shao
2023-10-28 2:59 ` [PATCH net 2/7] net: hns3: add barrier in vf mailbox reply process Jijie Shao
2023-10-28 2:59 ` [PATCH net 3/7] net: hns3: fix incorrect capability bit display for copper port Jijie Shao
2023-10-28 2:59 ` [PATCH net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs Jijie Shao
2023-10-28 2:59 ` [PATCH net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() Jijie Shao
2023-10-28 2:59 ` [PATCH net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
2023-11-02 10:45 ` Paolo Abeni
2023-11-02 12:16 ` Jijie Shao
2023-11-02 16:24 ` Paolo Abeni
2023-10-28 2:59 ` [PATCH net 7/7] net: hns3: fix VF wrong speed and duplex issue Jijie Shao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®