From patchwork Tue Feb 6 03:38:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Brady X-Patchwork-Id: 13546611 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22B0574E07 for ; Tue, 6 Feb 2024 03:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707190720; cv=none; b=aT+xAdLiQH9IC2hVLiDO5j8UZbwcUyfXqvJKOuulDhs00jh9Mr6zrHf+N975ty5R62+WTXpNUHsNoe9wqB7FYekGyAejz3/7psHxT7Mn8v9dof8GPczxlw4CC+v3k8sIYwd/cX9TeHU3NbryM/rZ6YuGrCjn5wjWEon+Chj4B6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707190720; c=relaxed/simple; bh=0YfsILo7bm0hFofTrESnj/p34BcdQReA5WCY2ajEa6g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=epePCmgeu0XF0LD9rDAQcd/TrUqKEVol9+eBrlHzedI8dIV6gap71PRH7yWKbxhdzJqFNa0UW/CKCHKYauMC+UfFQDeFjXcfhmSSmDinB9cvM3cs/1G4fA0YjShmS1IEgSNqCfpxrYishHxW1+YEVKk6uPPhHOtXrZNp22huGLM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BN+4fFm4; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BN+4fFm4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707190720; x=1738726720; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0YfsILo7bm0hFofTrESnj/p34BcdQReA5WCY2ajEa6g=; b=BN+4fFm4oBOVcsncdgxOZAsaA8s3hhzwXFaCB+vE078EgaSHqDqrCgk1 Ca5EMB7QakblnBT3x/GGAZCT/CZBX2t5zzPpUIphkixseheuDyZCfNA+S aqAC63Pz6/lBsyv5fvKtK7BpctmASDPGUP8sOalTvf6hm+2uIr7Mq22M5 krtSG0jTxYb/TUBpLHyQkVMADK853qaXLr0jeBbAT18V9LXcszvIahW00 UI1nZsccxPxWIrdTTy7doRdUphFRny8uRZ7WO05xxYv9aUsnTrMnqtpDU NX8uHxA2hoq6HN0eSbcZg9eiwJrPJ8M9RRcdKyy7b+dcILLHASYydazN5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="824848" X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="824848" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 19:38:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="5653947" Received: from dev1-atbrady.jf.intel.com ([10.166.241.35]) by orviesa004.jf.intel.com with ESMTP; 05 Feb 2024 19:38:39 -0800 From: Alan Brady To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, willemdebruijn.kernel@gmail.com, przemyslaw.kitszel@intel.com, igor.bagnucki@intel.com, aleksander.lobakin@intel.com, Alan Brady Subject: [PATCH v4 08/10 iwl-next] idpf: prevent deinit uninitialized virtchnl core Date: Mon, 5 Feb 2024 19:38:02 -0800 Message-Id: <20240206033804.1198416-9-alan.brady@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240206033804.1198416-1-alan.brady@intel.com> References: <20240206033804.1198416-1-alan.brady@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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. Signed-off-by: Alan Brady --- 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 0793173bb36d..e7a2fbf9e6cd 100644 --- a/drivers/net/ethernet/intel/idpf/idpf.h +++ b/drivers/net/ethernet/intel/idpf/idpf.h @@ -88,6 +88,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 { @@ -96,6 +97,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 f6e6e3eff29e..2bf67f13079d 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c @@ -2886,7 +2886,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); @@ -2895,7 +2897,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: @@ -2929,6 +2930,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); @@ -2940,6 +2944,8 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter) kfree(adapter->vports); adapter->vports = NULL; + + clear_bit(IDPF_VC_CORE_INIT, adapter->flags); } /**