All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver
@ 2023-11-10  9:37 Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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

---
ChangeLog:
v1 -> v2:
  - net: hns3: fix add VLAN fail issue, net: hns3: fix VF reset fail issue
    are modified suggested by Paolo
  v1: https://lore.kernel.org/all/20231028025917.314305-1-shaojijie@huawei.com/
---

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        | 33 ++++++++++++++-----
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      | 25 ++++++++++++--
 .../hisilicon/hns3/hns3vf/hclgevf_main.h      |  1 +
 .../hisilicon/hns3/hns3vf/hclgevf_mbx.c       |  7 ++++
 6 files changed, 62 insertions(+), 15 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V2 net 1/7] net: hns3: fix add VLAN fail issue
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 2/7] net: hns3: add barrier in vf mailbox reply process Jijie Shao
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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>
---
ChangeLog:
v1 -> v2:
  - Fix 'hclge_rm_vport_vlan_table()' happen with the vport_lock unlocked suggested by Paolo
  v1: https://lore.kernel.org/all/20231028025917.314305-2-shaojijie@huawei.com/
---
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 28 +++++++++++++------
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      | 11 ++++++--
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 66e5807903a0..e22279e5d43f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10025,8 +10025,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)
@@ -10041,8 +10039,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)
@@ -10451,11 +10447,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
@@ -10470,17 +10471,22 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
 	}
 
 	if (!ret) {
-		if (!is_kill)
+		if (!is_kill) {
 			hclge_add_vport_vlan_table(vport, vlan_id,
 						   writen_to_tbl);
-		else if (is_kill && vlan_id != 0)
+		} else if (is_kill && vlan_id != 0) {
+			mutex_lock(&hdev->vport_lock);
 			hclge_rm_vport_vlan_table(vport, vlan_id, false);
+			mutex_unlock(&hdev->vport_lock);
+		}
 	} else if (is_kill) {
 		/* when remove hw vlan filter failed, record the vlan id,
 		 * 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);
@@ -10520,6 +10526,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];
@@ -10530,21 +10537,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 related	[flat|nested] 11+ messages in thread

* [PATCH V2 net 2/7] net: hns3: add barrier in vf mailbox reply process
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 3/7] net: hns3: fix incorrect capability bit display for copper port Jijie Shao
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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 related	[flat|nested] 11+ messages in thread

* [PATCH V2 net 3/7] net: hns3: fix incorrect capability bit display for copper port
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 2/7] net: hns3: add barrier in vf mailbox reply process Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs Jijie Shao
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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 e22279e5d43f..c393b4ee4a32 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -11663,6 +11663,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 related	[flat|nested] 11+ messages in thread

* [PATCH V2 net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
                   ` (2 preceding siblings ...)
  2023-11-10  9:37 ` [PATCH V2 net 3/7] net: hns3: fix incorrect capability bit display for copper port Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() Jijie Shao
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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 0b138635bafa..c083d1d10767 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -503,11 +503,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 related	[flat|nested] 11+ messages in thread

* [PATCH V2 net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr()
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
                   ` (3 preceding siblings ...)
  2023-11-10  9:37 ` [PATCH V2 net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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 06117502001f..b618797a7e8d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -5139,7 +5139,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 related	[flat|nested] 11+ messages in thread

* [PATCH V2 net 6/7] net: hns3: fix VF reset fail issue
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
                   ` (4 preceding siblings ...)
  2023-11-10  9:37 ` [PATCH V2 net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-10  9:37 ` [PATCH V2 net 7/7] net: hns3: fix VF wrong speed and duplex issue Jijie Shao
  2023-11-13  9:38 ` [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver patchwork-bot+netdevbpf
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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>
---
ChangeLog:
v1 -> v2:
  - Use timer_list to replace the 5 ms delay in irq handle suggested by Paolo
  v1: https://lore.kernel.org/all/20231028025917.314305-7-shaojijie@huawei.com/
---
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 14 +++++++++++++-
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h  |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 1c62e58ff6d8..0aa9beefd1c7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1981,8 +1981,18 @@ 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(hdev, 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)
 {
+#define HCLGEVF_RESET_DELAY	5
+
 	enum hclgevf_evt_cause event_cause;
 	struct hclgevf_dev *hdev = data;
 	u32 clearval;
@@ -1994,7 +2004,8 @@ static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data)
 
 	switch (event_cause) {
 	case HCLGEVF_VECTOR0_EVENT_RST:
-		hclgevf_reset_task_schedule(hdev);
+		mod_timer(&hdev->reset_timer,
+			  jiffies + msecs_to_jiffies(HCLGEVF_RESET_DELAY));
 		break;
 	case HCLGEVF_VECTOR0_EVENT_MBX:
 		hclgevf_mbx_handler(hdev);
@@ -2937,6 +2948,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
 		 HCLGEVF_DRIVER_NAME);
 
 	hclgevf_task_schedule(hdev, round_jiffies_relative(HZ));
+	timer_setup(&hdev->reset_timer, hclgevf_reset_timer, 0);
 
 	return 0;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
index 81c16b8c8da2..a73f2bf3a56a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
@@ -219,6 +219,7 @@ struct hclgevf_dev {
 	enum hnae3_reset_type reset_level;
 	unsigned long reset_pending;
 	enum hnae3_reset_type reset_type;
+	struct timer_list reset_timer;
 
 #define HCLGEVF_RESET_REQUESTED		0
 #define HCLGEVF_RESET_PENDING		1
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V2 net 7/7] net: hns3: fix VF wrong speed and duplex issue
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
                   ` (5 preceding siblings ...)
  2023-11-10  9:37 ` [PATCH V2 net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
@ 2023-11-10  9:37 ` Jijie Shao
  2023-11-13  9:38 ` [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver patchwork-bot+netdevbpf
  7 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2023-11-10  9:37 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 c393b4ee4a32..5ea9e59569ef 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;
 
@@ -3041,6 +3042,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 related	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver
  2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
                   ` (6 preceding siblings ...)
  2023-11-10  9:37 ` [PATCH V2 net 7/7] net: hns3: fix VF wrong speed and duplex issue Jijie Shao
@ 2023-11-13  9:38 ` patchwork-bot+netdevbpf
  7 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-13  9:38 UTC (permalink / raw)
  To: Jijie Shao
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	shenjian15, wangjie125, liuyonglong, netdev, linux-kernel

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri, 10 Nov 2023 17:37:06 +0800 you wrote:
> There are some bugfix for the HNS3 ethernet driver
> 
> ---
> ChangeLog:
> v1 -> v2:
>   - net: hns3: fix add VLAN fail issue, net: hns3: fix VF reset fail issue
>     are modified suggested by Paolo
>   v1: https://lore.kernel.org/all/20231028025917.314305-1-shaojijie@huawei.com/
> 
> [...]

Here is the summary with links:
  - [V2,net,1/7] net: hns3: fix add VLAN fail issue
    https://git.kernel.org/netdev/net/c/472a2ff63efb
  - [V2,net,2/7] net: hns3: add barrier in vf mailbox reply process
    https://git.kernel.org/netdev/net/c/ac92c0a9a060
  - [V2,net,3/7] net: hns3: fix incorrect capability bit display for copper port
    https://git.kernel.org/netdev/net/c/75b247b57d8b
  - [V2,net,4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs
    https://git.kernel.org/netdev/net/c/53aba458f238
  - [V2,net,5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr()
    https://git.kernel.org/netdev/net/c/dbd2f3b20c6a
  - [V2,net,6/7] net: hns3: fix VF reset fail issue
    https://git.kernel.org/netdev/net/c/65e98bb56fa3
  - [V2,net,7/7] net: hns3: fix VF wrong speed and duplex issue
    https://git.kernel.org/netdev/net/c/dff655e82faf

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver
@ 2024-04-26 10:00 Jijie Shao
  0 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2024-04-26 10:00 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, jiri
  Cc: shenjian15, wangjie125, liuyonglong, shaojijie, chenhao418,
	netdev, linux-kernel

There are some bugfix for the HNS3 ethernet driver

---
changeLog:
v1 -> v2:
  - Adjust the code sequence to completely eliminate the race window, suggested by Jiri Pirko
  v1: https://lore.kernel.org/all/20240422134327.3160587-1-shaojijie@huawei.com/
---

Jian Shen (1):
  net: hns3: direct return when receive a unknown mailbox message

Peiyang Wang (4):
  net: hns3: change type of numa_node_mask as nodemask_t
  net: hns3: release PTP resources if pf initialization failed
  net: hns3: use appropriate barrier function after setting a bit value
  net: hns3: using user configure after hardware reset

Yonglong Liu (2):
  net: hns3: fix port vlan filter not disabled issue
  net: hns3: fix kernel crash when devlink reload during initialization

 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  2 +-
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 52 +++++++++++--------
 .../hisilicon/hns3/hns3pf/hclge_main.h        |  5 +-
 .../hisilicon/hns3/hns3pf/hclge_mbx.c         |  7 +--
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      | 20 ++++---
 .../hisilicon/hns3/hns3vf/hclgevf_main.h      |  2 +-
 6 files changed, 49 insertions(+), 39 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver
@ 2024-12-16 13:23 Jijie Shao
  0 siblings, 0 replies; 11+ messages in thread
From: Jijie Shao @ 2024-12-16 13:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, shaojijie

There's a series of bugfix that's been accepted:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=d80a3091308491455b6501b1c4b68698c4a7cd24

However, The series is making the driver poke into IOMMU internals instead of
implementing appropriate IOMMU workarounds. After discussion, the series was reverted:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=249cfa318fb1b77eb726c2ff4f74c9685f04e568

But only two patches are related to the IOMMU.
Other patches involve only the modification of the driver.
This series resends other patches.

---
ChangeLog:
v1 -> v2:
  - Fix a data inconsistency issue caused by simultaneous access of multiple readers,
    suggested by Jakub.
  v1: https://lore.kernel.org/all/20241107133023.3813095-1-shaojijie@huawei.com/
---
Hao Lan (4):
  net: hns3: fixed reset failure issues caused by the incorrect reset
    type
  net: hns3: fix missing features due to dev->features configuration too
    early
  net: hns3: Resolved the issue that the debugfs query result is
    inconsistent.
  net: hns3: fixed hclge_fetch_pf_reg accesses bar space out of bounds
    issue

Jian Shen (2):
  net: hns3: don't auto enable misc vector
  net: hns3: initialize reset_timer before hclgevf_misc_irq_init()

Jie Wang (1):
  net: hns3: fix kernel crash when 1588 is sent on HIP08 devices

 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  3 -
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    | 96 ++++++-------------
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |  1 -
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 45 +++++++--
 .../hisilicon/hns3/hns3pf/hclge_ptp.c         |  3 +
 .../hisilicon/hns3/hns3pf/hclge_regs.c        |  9 +-
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      | 40 ++++++--
 .../hisilicon/hns3/hns3vf/hclgevf_regs.c      |  9 +-
 8 files changed, 113 insertions(+), 93 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-12-16 13:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10  9:37 [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 1/7] net: hns3: fix add VLAN fail issue Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 2/7] net: hns3: add barrier in vf mailbox reply process Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 3/7] net: hns3: fix incorrect capability bit display for copper port Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 4/7] net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 5/7] net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 6/7] net: hns3: fix VF reset fail issue Jijie Shao
2023-11-10  9:37 ` [PATCH V2 net 7/7] net: hns3: fix VF wrong speed and duplex issue Jijie Shao
2023-11-13  9:38 ` [PATCH V2 net 0/7] There are some bugfix for the HNS3 ethernet driver patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2024-04-26 10:00 Jijie Shao
2024-12-16 13:23 Jijie Shao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.