netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Brady <alan.brady@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Alan Brady <alan.brady@intel.com>,
	Alexander Lobakin <aleksander.lobakin@intel.com>
Subject: [PATCH v6 09/11 iwl-next] idpf: prevent deinit uninitialized virtchnl core
Date: Thu, 22 Feb 2024 11:04:39 -0800	[thread overview]
Message-ID: <20240222190441.2610930-10-alan.brady@intel.com> (raw)
In-Reply-To: <20240222190441.2610930-1-alan.brady@intel.com>

In idpf_remove we need to tear down the virtchnl core with
idpf_vc_core_deinit so we can free up resources and leave things in a
good state. However, in the case where we failed to establish VC
communications we may not have ever actually successfully initialized
the virtchnl core.

This fixes it by setting a bit once we successfully init the virtchnl
core.  Then, in deinit, we'll check for it before going on further,
otherwise we just return. Also clear the bit at the end of deinit so we
know it's gone now.

Tested-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Alan Brady <alan.brady@intel.com>
---
 drivers/net/ethernet/intel/idpf/idpf.h          |  2 ++
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
index 5ed08be1dbc0..e7a036538246 100644
--- a/drivers/net/ethernet/intel/idpf/idpf.h
+++ b/drivers/net/ethernet/intel/idpf/idpf.h
@@ -83,6 +83,7 @@ enum idpf_state {
  * @IDPF_HR_RESET_IN_PROG: Reset in progress
  * @IDPF_REMOVE_IN_PROG: Driver remove in progress
  * @IDPF_MB_INTR_MODE: Mailbox in interrupt mode
+ * @IDPF_VC_CORE_INIT: virtchnl core has been init
  * @IDPF_FLAGS_NBITS: Must be last
  */
 enum idpf_flags {
@@ -91,6 +92,7 @@ enum idpf_flags {
 	IDPF_HR_RESET_IN_PROG,
 	IDPF_REMOVE_IN_PROG,
 	IDPF_MB_INTR_MODE,
+	IDPF_VC_CORE_INIT,
 	IDPF_FLAGS_NBITS,
 };
 
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index e89e2bad460d..a602ff8d74e0 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -2990,7 +2990,9 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
 	queue_delayed_work(adapter->init_wq, &adapter->init_task,
 			   msecs_to_jiffies(5 * (adapter->pdev->devfn & 0x07)));
 
-	goto no_err;
+	set_bit(IDPF_VC_CORE_INIT, adapter->flags);
+
+	return 0;
 
 err_intr_req:
 	cancel_delayed_work_sync(&adapter->serv_task);
@@ -2999,7 +3001,6 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
 err_netdev_alloc:
 	kfree(adapter->vports);
 	adapter->vports = NULL;
-no_err:
 	return err;
 
 init_failed:
@@ -3034,6 +3035,9 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
  */
 void idpf_vc_core_deinit(struct idpf_adapter *adapter)
 {
+	if (!test_bit(IDPF_VC_CORE_INIT, adapter->flags))
+		return;
+
 	idpf_vc_xn_shutdown(adapter->vcxn_mngr);
 	idpf_deinit_task(adapter);
 	idpf_intr_rel(adapter);
@@ -3045,6 +3049,8 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
 
 	kfree(adapter->vports);
 	adapter->vports = NULL;
+
+	clear_bit(IDPF_VC_CORE_INIT, adapter->flags);
 }
 
 /**
-- 
2.43.0


  parent reply	other threads:[~2024-02-22 19:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 19:04 [PATCH v6 00/11 iwl-next] idpf: refactor virtchnl messages Alan Brady
2024-02-22 19:04 ` [PATCH v6 01/11 iwl-next] idpf: add idpf_virtchnl.h Alan Brady
2024-03-02  4:32   ` Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 02/11 iwl-next] idpf: implement virtchnl transaction manager Alan Brady
2024-03-02  4:33   ` [Intel-wired-lan] " Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 03/11 iwl-next] idpf: refactor vport virtchnl messages Alan Brady
2024-03-02  4:33   ` [Intel-wired-lan] " Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 04/11 iwl-next] idpf: refactor queue related " Alan Brady
2024-03-02  4:34   ` Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 05/11 iwl-next] idpf: refactor remaining " Alan Brady
2024-03-02  4:37   ` Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 06/11 iwl-next] idpf: add async_handler for MAC filter messages Alan Brady
2024-03-02  4:38   ` Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 07/11 iwl-next] idpf: refactor idpf_recv_mb_msg Alan Brady
2024-03-02  4:38   ` Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 08/11 iwl-next] idpf: cleanup virtchnl cruft Alan Brady
2024-03-02  4:39   ` Singh, Krishneil K
2024-02-22 19:04 ` Alan Brady [this message]
2024-03-02  4:39   ` [PATCH v6 09/11 iwl-next] idpf: prevent deinit uninitialized virtchnl core Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 10/11 iwl-next] idpf: fix minor controlq issues Alan Brady
2024-03-02  4:39   ` Singh, Krishneil K
2024-02-22 19:04 ` [PATCH v6 11/11 iwl-next] idpf: remove dealloc vector msg err in idpf_intr_rel Alan Brady
2024-03-02  4:40   ` Singh, Krishneil K

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=20240222190441.2610930-10-alan.brady@intel.com \
    --to=alan.brady@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=netdev@vger.kernel.org \
    /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).