linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/6] net: hns3: add some fixes for -net
@ 2022-03-26  9:50 Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue Guangbin Huang
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:50 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

This series adds some fixes for the HNS3 ethernet driver.

Guangbin Huang (1):
  net: hns3: fix phy can not link up when autoneg off and reset

Hao Chen (4):
  net: hns3: fix ethtool tx copybreak buf size indicating not aligned
    issue
  net: hns3: add max order judgement for tx spare buffer
  net: hns3: add netdev reset check for hns3_set_tunable()
  net: hns3: add NULL pointer check for hns3_set/get_ringparam()

Peng Li (1):
  net: hns3: clean residual vf config after disable sriov

 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  3 ++
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 44 +++++++++++++---
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 23 ++++++---
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 50 +++++++++++++++++++
 .../hisilicon/hns3/hns3pf/hclge_mdio.c        |  4 +-
 5 files changed, 107 insertions(+), 17 deletions(-)

-- 
2.33.0


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

* [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
@ 2022-03-26  9:51 ` Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 2/6] net: hns3: add max order judgement for tx spare buffer Guangbin Huang
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:51 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

From: Hao Chen <chenhao288@hisilicon.com>

When use ethtoool set tx copybreak buf size to a large value
which causes order exceeding 10 or memory is not enough,
it causes allocating tx copybreak buffer failed and print
"the active tx spare buf is 0, not enabled tx spare buffer",
however, use --get-tunable parameter query tx copybreak buf
size and it indicates setting value not 0.

So, it's necessary to change the print value from setting
value to 0.

Set kinfo.tx_spare_buf_size to 0 when set tx copybreak buf size failed.

Fixes: e445f08af2b1 ("net: hns3: add support to set/get tx copybreak buf size via ethtool for hns3 driver")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 20 +++++++++++--------
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  3 ++-
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 0b8a73c40b12..16137238ddbf 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1028,13 +1028,12 @@ static bool hns3_can_use_tx_sgl(struct hns3_enet_ring *ring,
 
 static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
 {
+	u32 alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size;
 	struct hns3_tx_spare *tx_spare;
 	struct page *page;
-	u32 alloc_size;
 	dma_addr_t dma;
 	int order;
 
-	alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size;
 	if (!alloc_size)
 		return;
 
@@ -1044,30 +1043,35 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
 	if (!tx_spare) {
 		/* The driver still work without the tx spare buffer */
 		dev_warn(ring_to_dev(ring), "failed to allocate hns3_tx_spare\n");
-		return;
+		goto devm_kzalloc_error;
 	}
 
 	page = alloc_pages_node(dev_to_node(ring_to_dev(ring)),
 				GFP_KERNEL, order);
 	if (!page) {
 		dev_warn(ring_to_dev(ring), "failed to allocate tx spare pages\n");
-		devm_kfree(ring_to_dev(ring), tx_spare);
-		return;
+		goto alloc_pages_error;
 	}
 
 	dma = dma_map_page(ring_to_dev(ring), page, 0,
 			   PAGE_SIZE << order, DMA_TO_DEVICE);
 	if (dma_mapping_error(ring_to_dev(ring), dma)) {
 		dev_warn(ring_to_dev(ring), "failed to map pages for tx spare\n");
-		put_page(page);
-		devm_kfree(ring_to_dev(ring), tx_spare);
-		return;
+		goto dma_mapping_error;
 	}
 
 	tx_spare->dma = dma;
 	tx_spare->buf = page_address(page);
 	tx_spare->len = PAGE_SIZE << order;
 	ring->tx_spare = tx_spare;
+	return;
+
+dma_mapping_error:
+	put_page(page);
+alloc_pages_error:
+	devm_kfree(ring_to_dev(ring), tx_spare);
+devm_kzalloc_error:
+	ring->tqp->handle->kinfo.tx_spare_buf_size = 0;
 }
 
 /* Use hns3_tx_spare_space() to make sure there is enough buffer
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 6469238ae090..ae30dbe7ef52 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1818,7 +1818,8 @@ static int hns3_set_tunable(struct net_device *netdev,
 		old_tx_spare_buf_size = h->kinfo.tx_spare_buf_size;
 		new_tx_spare_buf_size = *(u32 *)data;
 		ret = hns3_set_tx_spare_buf_size(netdev, new_tx_spare_buf_size);
-		if (ret) {
+		if (ret ||
+		    (!priv->ring->tx_spare && new_tx_spare_buf_size != 0)) {
 			int ret1;
 
 			netdev_warn(netdev,
-- 
2.33.0


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

* [PATCH net 2/6] net: hns3: add max order judgement for tx spare buffer
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue Guangbin Huang
@ 2022-03-26  9:51 ` Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 3/6] net: hns3: clean residual vf config after disable sriov Guangbin Huang
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:51 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

From: Hao Chen <chenhao288@hisilicon.com>

Add max order judgement for tx spare buffer to avoid triggering
call trace, print related fail information instead, when user
set tx spare buf size to a large value which causes order
exceeding 10.

Fixes: e445f08af2b1 ("net: hns3: add support to set/get tx copybreak buf size via ethtool for hns3 driver")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 16137238ddbf..530ba8bef503 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1038,6 +1038,12 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
 		return;
 
 	order = get_order(alloc_size);
+	if (order >= MAX_ORDER) {
+		if (net_ratelimit())
+			dev_warn(ring_to_dev(ring), "failed to allocate tx spare buffer, exceed to max order\n");
+		return;
+	}
+
 	tx_spare = devm_kzalloc(ring_to_dev(ring), sizeof(*tx_spare),
 				GFP_KERNEL);
 	if (!tx_spare) {
-- 
2.33.0


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

* [PATCH net 3/6] net: hns3: clean residual vf config after disable sriov
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 2/6] net: hns3: add max order judgement for tx spare buffer Guangbin Huang
@ 2022-03-26  9:51 ` Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 4/6] net: hns3: add netdev reset check for hns3_set_tunable() Guangbin Huang
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:51 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

From: Peng Li <lipeng321@huawei.com>

After disable sriov, VF still has some config and info need to be
cleaned, which configured by PF. This patch clean the HW config
and SW struct vport->vf_info.

Fixes: fa8d82e853e8 ("net: hns3: Add support of .sriov_configure in HNS3 driver")
Signed-off-by: Peng Li<lipeng321@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  3 ++
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 18 +++++++
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 50 +++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 6f18c9a03231..d44dd7091fa1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -537,6 +537,8 @@ struct hnae3_ae_dev {
  *   Get 1588 rx hwstamp
  * get_ts_info
  *   Get phc info
+ * clean_vf_config
+ *   Clean residual vf info after disable sriov
  */
 struct hnae3_ae_ops {
 	int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -730,6 +732,7 @@ struct hnae3_ae_ops {
 			   struct ethtool_ts_info *info);
 	int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
 				       u32 *status_code);
+	void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
 };
 
 struct hnae3_dcb_ops {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 530ba8bef503..14dc12c2155d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -3060,6 +3060,21 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	return ret;
 }
 
+/**
+ * hns3_clean_vf_config
+ * @pdev: pointer to a pci_dev structure
+ * @num_vfs: number of VFs allocated
+ *
+ * Clean residual vf config after disable sriov
+ **/
+static void hns3_clean_vf_config(struct pci_dev *pdev, int num_vfs)
+{
+	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
+
+	if (ae_dev->ops->clean_vf_config)
+		ae_dev->ops->clean_vf_config(ae_dev, num_vfs);
+}
+
 /* hns3_remove - Device removal routine
  * @pdev: PCI device information struct
  */
@@ -3098,7 +3113,10 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
 		else
 			return num_vfs;
 	} else if (!pci_vfs_assigned(pdev)) {
+		int num_vfs_pre = pci_num_vf(pdev);
+
 		pci_disable_sriov(pdev);
+		hns3_clean_vf_config(pdev, num_vfs_pre);
 	} else {
 		dev_warn(&pdev->dev,
 			 "Unable to free VFs because some are assigned to VMs.\n");
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 279a1771fe7c..2a5e6a241d52 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -12724,6 +12724,55 @@ static int hclge_get_link_diagnosis_info(struct hnae3_handle *handle,
 	return 0;
 }
 
+/* After disable sriov, VF still has some config and info need clean,
+ * which configed by PF.
+ */
+static void hclge_clear_vport_vf_info(struct hclge_vport *vport, int vfid)
+{
+	struct hclge_dev *hdev = vport->back;
+	struct hclge_vlan_info vlan_info;
+	int ret;
+
+	/* after disable sriov, clean VF rate configured by PF */
+	ret = hclge_tm_qs_shaper_cfg(vport, 0);
+	if (ret)
+		dev_err(&hdev->pdev->dev,
+			"failed to clean vf%d rate config, ret = %d\n",
+			vfid, ret);
+
+	vlan_info.vlan_tag = 0;
+	vlan_info.qos = 0;
+	vlan_info.vlan_proto = ETH_P_8021Q;
+	ret = hclge_update_port_base_vlan_cfg(vport,
+					      HNAE3_PORT_BASE_VLAN_DISABLE,
+					      &vlan_info);
+	if (ret)
+		dev_err(&hdev->pdev->dev,
+			"failed to clean vf%d port base vlan, ret = %d\n",
+			vfid, ret);
+
+	ret = hclge_set_vf_spoofchk_hw(hdev, vport->vport_id, false);
+	if (ret)
+		dev_err(&hdev->pdev->dev,
+			"failed to clean vf%d spoof config, ret = %d\n",
+			vfid, ret);
+
+	memset(&vport->vf_info, 0, sizeof(vport->vf_info));
+}
+
+static void hclge_clean_vport_config(struct hnae3_ae_dev *ae_dev, int num_vfs)
+{
+	struct hclge_dev *hdev = ae_dev->priv;
+	struct hclge_vport *vport;
+	int i;
+
+	for (i = 0; i < num_vfs; i++) {
+		vport = &hdev->vport[i + HCLGE_VF_VPORT_START_NUM];
+
+		hclge_clear_vport_vf_info(vport, i);
+	}
+}
+
 static const struct hnae3_ae_ops hclge_ops = {
 	.init_ae_dev = hclge_init_ae_dev,
 	.uninit_ae_dev = hclge_uninit_ae_dev,
@@ -12825,6 +12874,7 @@ static const struct hnae3_ae_ops hclge_ops = {
 	.get_rx_hwts = hclge_ptp_get_rx_hwts,
 	.get_ts_info = hclge_ptp_get_ts_info,
 	.get_link_diagnosis_info = hclge_get_link_diagnosis_info,
+	.clean_vf_config = hclge_clean_vport_config,
 };
 
 static struct hnae3_ae_algo ae_algo = {
-- 
2.33.0


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

* [PATCH net 4/6] net: hns3: add netdev reset check for hns3_set_tunable()
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (2 preceding siblings ...)
  2022-03-26  9:51 ` [PATCH net 3/6] net: hns3: clean residual vf config after disable sriov Guangbin Huang
@ 2022-03-26  9:51 ` Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 5/6] net: hns3: add NULL pointer check for hns3_set/get_ringparam() Guangbin Huang
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:51 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

From: Hao Chen <chenhao288@hisilicon.com>

When pci device reset failed, it does uninit operation and priv->ring
is NULL, it causes accessing NULL pointer error.

Add netdev reset check for hns3_set_tunable() to fix it.

Fixes: 99f6b5fb5f63 ("net: hns3: use bounce buffer when rx page can not be reused")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index ae30dbe7ef52..49e7b022caaa 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1766,9 +1766,6 @@ static int hns3_set_tx_spare_buf_size(struct net_device *netdev,
 	struct hnae3_handle *h = priv->ae_handle;
 	int ret;
 
-	if (hns3_nic_resetting(netdev))
-		return -EBUSY;
-
 	h->kinfo.tx_spare_buf_size = data;
 
 	ret = hns3_reset_notify(h, HNAE3_DOWN_CLIENT);
@@ -1799,6 +1796,11 @@ static int hns3_set_tunable(struct net_device *netdev,
 	struct hnae3_handle *h = priv->ae_handle;
 	int i, ret = 0;
 
+	if (hns3_nic_resetting(netdev) || !priv->ring) {
+		netdev_err(netdev, "failed to set tunable value, dev resetting!");
+		return -EBUSY;
+	}
+
 	switch (tuna->id) {
 	case ETHTOOL_TX_COPYBREAK:
 		priv->tx_copybreak = *(u32 *)data;
-- 
2.33.0


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

* [PATCH net 5/6] net: hns3: add NULL pointer check for hns3_set/get_ringparam()
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (3 preceding siblings ...)
  2022-03-26  9:51 ` [PATCH net 4/6] net: hns3: add netdev reset check for hns3_set_tunable() Guangbin Huang
@ 2022-03-26  9:51 ` Guangbin Huang
  2022-03-26  9:51 ` [PATCH net 6/6] net: hns3: fix phy can not link up when autoneg off and reset Guangbin Huang
  2022-03-26 16:20 ` [PATCH net 0/6] net: hns3: add some fixes for -net patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:51 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

From: Hao Chen <chenhao288@hisilicon.com>

When pci devices init failed and haven't reinit, priv->ring is
NULL and hns3_set/get_ringparam() will access priv->ring. it
causes call trace.

So, add NULL pointer check for hns3_set/get_ringparam() to
avoid this situation.

Fixes: 5668abda0931 ("net: hns3: add support for set_ringparam")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 49e7b022caaa..f4da77452126 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -653,8 +653,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
 	struct hnae3_handle *h = priv->ae_handle;
 	int rx_queue_index = h->kinfo.num_tqps;
 
-	if (hns3_nic_resetting(netdev)) {
-		netdev_err(netdev, "dev resetting!");
+	if (hns3_nic_resetting(netdev) || !priv->ring) {
+		netdev_err(netdev, "failed to get ringparam value, due to dev resetting or uninited\n");
 		return;
 	}
 
@@ -1074,8 +1074,14 @@ static int hns3_check_ringparam(struct net_device *ndev,
 {
 #define RX_BUF_LEN_2K 2048
 #define RX_BUF_LEN_4K 4096
-	if (hns3_nic_resetting(ndev))
+
+	struct hns3_nic_priv *priv = netdev_priv(ndev);
+
+	if (hns3_nic_resetting(ndev) || !priv->ring) {
+		netdev_err(ndev, "failed to set ringparam value, due to dev resetting or uninited\n");
 		return -EBUSY;
+	}
+
 
 	if (param->rx_mini_pending || param->rx_jumbo_pending)
 		return -EINVAL;
-- 
2.33.0


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

* [PATCH net 6/6] net: hns3: fix phy can not link up when autoneg off and reset
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (4 preceding siblings ...)
  2022-03-26  9:51 ` [PATCH net 5/6] net: hns3: add NULL pointer check for hns3_set/get_ringparam() Guangbin Huang
@ 2022-03-26  9:51 ` Guangbin Huang
  2022-03-26 16:20 ` [PATCH net 0/6] net: hns3: add some fixes for -net patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Guangbin Huang @ 2022-03-26  9:51 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2, chenhao288

Currently, function hclge_mdio_read() will return 0 if during reset(the
cmd state will be set to disable).

If use general phy driver, the phy_state_machine() will update phy speed
every second in function genphy_read_status_fixed() when PHY is set to
autoneg off, no matter of link down or link up.

If phy driver happens to read BMCR register during reset, phy speed will
be updated to 10Mpbs as BMCR register value is 0. So it may call phy can
not link up if previous speed is not 10Mpbs.

To fix this problem, function hclge_mdio_read() should return -EBUSY if
the cmd state is disable. So does function hclge_mdio_write().

Fixes: 1c1249380992 ("net: hns3: bugfix for hclge_mdio_write and hclge_mdio_read")
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index 63d2be4349e3..03d63b6a9b2b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -48,7 +48,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum,
 	int ret;
 
 	if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state))
-		return 0;
+		return -EBUSY;
 
 	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false);
 
@@ -86,7 +86,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum)
 	int ret;
 
 	if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state))
-		return 0;
+		return -EBUSY;
 
 	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true);
 
-- 
2.33.0


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

* Re: [PATCH net 0/6] net: hns3: add some fixes for -net
  2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (5 preceding siblings ...)
  2022-03-26  9:51 ` [PATCH net 6/6] net: hns3: fix phy can not link up when autoneg off and reset Guangbin Huang
@ 2022-03-26 16:20 ` patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-26 16:20 UTC (permalink / raw)
  To: Guangbin Huang; +Cc: davem, kuba, netdev, linux-kernel, lipeng321, chenhao288

Hello:

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

On Sat, 26 Mar 2022 17:50:59 +0800 you wrote:
> This series adds some fixes for the HNS3 ethernet driver.
> 
> Guangbin Huang (1):
>   net: hns3: fix phy can not link up when autoneg off and reset
> 
> Hao Chen (4):
>   net: hns3: fix ethtool tx copybreak buf size indicating not aligned
>     issue
>   net: hns3: add max order judgement for tx spare buffer
>   net: hns3: add netdev reset check for hns3_set_tunable()
>   net: hns3: add NULL pointer check for hns3_set/get_ringparam()
> 
> [...]

Here is the summary with links:
  - [net,1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue
    https://git.kernel.org/netdev/net/c/877837211802
  - [net,2/6] net: hns3: add max order judgement for tx spare buffer
    https://git.kernel.org/netdev/net/c/a89cbb16995b
  - [net,3/6] net: hns3: clean residual vf config after disable sriov
    https://git.kernel.org/netdev/net/c/671cb8cbb9c9
  - [net,4/6] net: hns3: add netdev reset check for hns3_set_tunable()
    https://git.kernel.org/netdev/net/c/f5cd60169f98
  - [net,5/6] net: hns3: add NULL pointer check for hns3_set/get_ringparam()
    https://git.kernel.org/netdev/net/c/4d07c5936c25
  - [net,6/6] net: hns3: fix phy can not link up when autoneg off and reset
    https://git.kernel.org/netdev/net/c/ad0ecaef6a2c

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] 8+ messages in thread

end of thread, other threads:[~2022-03-26 16:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-26  9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
2022-03-26  9:51 ` [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue Guangbin Huang
2022-03-26  9:51 ` [PATCH net 2/6] net: hns3: add max order judgement for tx spare buffer Guangbin Huang
2022-03-26  9:51 ` [PATCH net 3/6] net: hns3: clean residual vf config after disable sriov Guangbin Huang
2022-03-26  9:51 ` [PATCH net 4/6] net: hns3: add netdev reset check for hns3_set_tunable() Guangbin Huang
2022-03-26  9:51 ` [PATCH net 5/6] net: hns3: add NULL pointer check for hns3_set/get_ringparam() Guangbin Huang
2022-03-26  9:51 ` [PATCH net 6/6] net: hns3: fix phy can not link up when autoneg off and reset Guangbin Huang
2022-03-26 16:20 ` [PATCH net 0/6] net: hns3: add some fixes for -net patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).