From: Huazhong Tan <tanhuazhong@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
<linuxarm@huawei.com>
Subject: [Patch net-next 01/12] net: hns3: use HNS3_NIC_STATE_INITED to indicate the initialization state of enet
Date: Wed, 7 Nov 2018 12:06:07 +0800 [thread overview]
Message-ID: <1541563578-28973-2-git-send-email-tanhuazhong@huawei.com> (raw)
In-Reply-To: <1541563578-28973-1-git-send-email-tanhuazhong@huawei.com>
Besides of module_init and module_exit, the process of reset will
also uninitialize and initialize the enet client. When reset process
fails with enet client uninitialized, the module_exit does not need
to uninitialize the enet client, otherwise it may cause double
uninitialization problem.
So we need the HNS3_NIC_STATE_INITED flag to indicate whether
the enet client is initialized.
Also HNS3_NIC_STATE_REINITING is previously unused, so change it to
HNS3_NIC_STATE_INITED.
Fixes: bb6b94a896d4 ("net: hns3: Add reset interface implementation in client")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 17 +++++++++++++++++
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 3f96aa3..d51469c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -3397,6 +3397,8 @@ static int hns3_client_init(struct hnae3_handle *handle)
/* MTU range: (ETH_MIN_MTU(kernel default) - 9706) */
netdev->max_mtu = HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
+ set_bit(HNS3_NIC_STATE_INITED, &priv->state);
+
return ret;
out_reg_netdev_fail:
@@ -3423,6 +3425,11 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
if (netdev->reg_state != NETREG_UNINITIALIZED)
unregister_netdev(netdev);
+ if (!test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
+ netdev_warn(netdev, "already uninitialized\n");
+ goto out_netdev_free;
+ }
+
hns3_del_all_fd_rules(netdev, true);
hns3_force_clear_all_rx_ring(handle);
@@ -3443,6 +3450,7 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
priv->ring_data = NULL;
+out_netdev_free:
free_netdev(netdev);
}
@@ -3782,6 +3790,8 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
priv->ring_data = NULL;
}
+ set_bit(HNS3_NIC_STATE_INITED, &priv->state);
+
return ret;
}
@@ -3792,6 +3802,11 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
struct hns3_nic_priv *priv = netdev_priv(netdev);
int ret;
+ if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
+ netdev_warn(netdev, "already uninitialized\n");
+ return 0;
+ }
+
hns3_force_clear_all_rx_ring(handle);
ret = hns3_nic_uninit_vector_data(priv);
@@ -3815,6 +3830,8 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
hns3_del_all_fd_rules(netdev, false);
}
+ clear_bit(HNS3_NIC_STATE_INITED, &priv->state);
+
return ret;
}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index d3636d0..7b759e4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -15,7 +15,7 @@ extern const char hns3_driver_version[];
enum hns3_nic_state {
HNS3_NIC_STATE_TESTING,
HNS3_NIC_STATE_RESETTING,
- HNS3_NIC_STATE_REINITING,
+ HNS3_NIC_STATE_INITED,
HNS3_NIC_STATE_DOWN,
HNS3_NIC_STATE_DISABLED,
HNS3_NIC_STATE_REMOVING,
--
2.7.4
next prev parent reply other threads:[~2018-11-07 4:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 4:06 [Patch net-next 00/12] provide new interfaces & bugfixes & code optimization Huazhong Tan
2018-11-07 4:06 ` Huazhong Tan [this message]
2018-11-07 4:06 ` [Patch net-next 02/12] net: hns3: add set_default_reset_request in the hnae3_ae_ops Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 03/12] net: hns3: provide some interface & information for the client Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 04/12] net: hns3: adjust the location of clearing the table when doing reset Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 05/12] net: hns3: enable/disable ring in the enet while doing UP/DOWN Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 06/12] net: hns3: use HNS3_NIC_STATE_RESETTING to indicate resetting Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 07/12] net: hns3: ignore new coming low-level reset while doing high-level reset Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 08/12] net: hns3: move some reset information from hnae3_handle into hclge_dev/hclgevf_dev Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 09/12] net: hns3: adjust the process of PF reset Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 10/12] net: hns3: call roce's reset notify callback when resetting Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 11/12] net: hns3: add error handler for hclge_reset() Huazhong Tan
2018-11-07 4:06 ` [Patch net-next 12/12] net: hns3: fix for cmd queue memory not freed problem during reset Huazhong Tan
2018-11-07 19:42 ` [Patch net-next 00/12] provide new interfaces & bugfixes & code optimization David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1541563578-28973-2-git-send-email-tanhuazhong@huawei.com \
--to=tanhuazhong@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).