All of lore.kernel.org
 help / color / mirror / Atom feed
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>, Huazhong Tan <tanhuazhong@huawei.com>,
	Peng Li <lipeng321@huawei.com>
Subject: [PATCH net-next 06/12] net: hns3: use HCLGEVF_STATE_NIC_REGISTERED to indicate VF NIC client has registered
Date: Tue, 28 May 2019 17:02:56 +0800	[thread overview]
Message-ID: <1559034182-24737-7-git-send-email-tanhuazhong@huawei.com> (raw)
In-Reply-To: <1559034182-24737-1-git-send-email-tanhuazhong@huawei.com>

When VF NIC client's init_instance() succeeds, it means this client
has been registered successfully, so we use HCLGEVF_STATE_NIC_REGISTERED
to indicate that. And before calling VF NIC client's uninit_instance(),
we clear this state.

So any operation of VF NIC client from HCLGEVF is not allowed if this
state is not set.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 7 +++++++
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 5d53467..8b3f8fd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1306,6 +1306,10 @@ static int hclgevf_notify_client(struct hclgevf_dev *hdev,
 	struct hnae3_handle *handle = &hdev->nic;
 	int ret;
 
+	if (!test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state) ||
+	    !client)
+		return 0;
+
 	if (!client->ops->reset_notify)
 		return -EOPNOTSUPP;
 
@@ -2265,6 +2269,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client,
 			goto clear_nic;
 
 		hnae3_set_client_init_flag(client, ae_dev, 1);
+		set_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state);
 
 		if (netif_msg_drv(&hdev->nic))
 			hclgevf_info_show(hdev);
@@ -2342,6 +2347,8 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client,
 	/* un-init nic/unic, if this was not called by roce client */
 	if (client->ops->uninit_instance && hdev->nic_client &&
 	    client->type != HNAE3_CLIENT_ROCE) {
+		clear_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state);
+
 		client->ops->uninit_instance(&hdev->nic, 0);
 		hdev->nic_client = NULL;
 		hdev->nic.client = NULL;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
index cc52f54..eab1095 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
@@ -130,6 +130,7 @@ enum hclgevf_states {
 	HCLGEVF_STATE_DOWN,
 	HCLGEVF_STATE_DISABLED,
 	HCLGEVF_STATE_IRQ_INITED,
+	HCLGEVF_STATE_NIC_REGISTERED,
 	/* task states */
 	HCLGEVF_STATE_SERVICE_SCHED,
 	HCLGEVF_STATE_RST_SERVICE_SCHED,
-- 
2.7.4


  parent reply	other threads:[~2019-05-28  9:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28  9:02 [PATCH net-next 00/12] code optimizations & bugfixes for HNS3 driver Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 01/12] net: hns3: fix compile warning without CONFIG_RFS_ACCEL Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 02/12] net: hns3: fix for HNS3_RXD_GRO_SIZE_M macro Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 03/12] net: hns3: add support for dump firmware statistics by debugfs Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 04/12] net: hns3: use HCLGE_STATE_NIC_REGISTERED to indicate PF NIC client has registered Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 05/12] net: hns3: use HCLGE_STATE_ROCE_REGISTERED to indicate PF ROCE " Huazhong Tan
2019-05-28  9:02 ` Huazhong Tan [this message]
2019-05-28  9:02 ` [PATCH net-next 07/12] net: hns3: modify hclge_init_client_instance() Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 08/12] net: hns3: modify hclgevf_init_client_instance() Huazhong Tan
2019-05-28  9:02 ` [PATCH net-next 09/12] net: hns3: add handshake with hardware while doing reset Huazhong Tan
2019-05-28  9:03 ` [PATCH net-next 10/12] net: hns3: stop schedule reset service while unloading driver Huazhong Tan
2019-05-28  9:03 ` [PATCH net-next 11/12] net: hns3: adjust hns3_uninit_phy()'s location in the hns3_client_uninit() Huazhong Tan
2019-05-28  9:03 ` [PATCH net-next 12/12] net: hns3: fix a memory leak issue for hclge_map_unmap_ring_to_vf_vector Huazhong Tan
2019-05-29  0:39 ` [PATCH net-next 00/12] code optimizations & bugfixes for HNS3 driver 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=1559034182-24737-7-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=lipeng321@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 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.