Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp701624rdg; Wed, 11 Oct 2023 03:11:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTuZ5MBUC7jpwV+fau56GckzDKNeR3+n6I02/HgjW2ROgaX4CDHG0OsTSuE5VeMbfKRgbQ X-Received: by 2002:a05:6870:ac1f:b0:1b3:8d35:c85f with SMTP id kw31-20020a056870ac1f00b001b38d35c85fmr23130202oab.1.1697019069634; Wed, 11 Oct 2023 03:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019069; cv=none; d=google.com; s=arc-20160816; b=RjP3NaMYyBDCXW2/Pkb2Tr+QX/HpX36aHEFINUli0gkzaTmBJ2CQJMMZ2WKiSBle6N xvzrPSRgJx5Scb6z6k0p0bMOl91Sy2XHwv9PNeVsOG8IFA3ClcgIRkVGuoCJHULOoBWg rYAutYPXA1AGfFYQ7M8RXvmIeDOaDVJZLsn+wMYm5fPrH7ltKywF6blFI7H76qoFUV89 WOQPO7nUoex4k4UqcFL/nshm1miN/s4bfH2Ot8TJvcg6XwpM/aDiaTg4VRLSWwYNJBS7 BbIo7pVlloIA5yVz3WykgURi2ydjto62N5UcoUhS2kN7WiAGTsvy98Y9Bkc3GUaTlaQt mesw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d2fSw6Tb5saZRZq3y55JqrkpfM4vRFbha32HXtQVk10=; fh=T6y/oS++RIYqEuqxIx2phDO2xU+34wOH47oi8kJGCZk=; b=QS0B2bH8Wl5tVAHVSQh0WQM6ezi/KRB0PcRhDZSHCfut9oF1SmFFaRsjX0Y8wGaavr C/gm5lqg16HjXEZFA8bPl+AHqfVS6rW+Rtp+bVtLlyUmesfebuIbb/zq3hAyyvxdtM5K +3liyu+9NkoSjwUMDUck/mNoxCXVCqqZ9nPaveSE1PazrgclskNlJ0B9nfo1euQab65A IclMC83W2B2oGSieZjXEcfVtYEFIFgKo8UDlS9QIj7vVl790FiQG8keQQs9l3UzO2pcX x6wWCrVRCxxfIafMUZZKA/pRFQj0jMQS1jfBrT+D6UNetZTuOwNAWtdI55nNUlxs8Ify V7gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UqV8vMHj; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id n2-20020a635c42000000b00578a2142861si13715705pgm.531.2023.10.11.03.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UqV8vMHj; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9FAF080EE72B; Wed, 11 Oct 2023 03:11:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346078AbjJKKJl (ORCPT + 52 others); Wed, 11 Oct 2023 06:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234658AbjJKKJC (ORCPT ); Wed, 11 Oct 2023 06:09:02 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1699195 for ; Wed, 11 Oct 2023 03:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697018885; x=1728554885; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4tfEmY9OCD/myEiMa2J3W1rCJRFWM0zU1Pz3yrw5QhI=; b=UqV8vMHjEfTJYvGv4WdtZFS0X9vUYNTVnOheU0hWRkc0em7cn9PyhgK0 1shVjZTjtzTVuxSNX/bh8tOy0A/HsOB0ghm8NSFulNRlh3Reby9sZu+ej tmpDb7nlGe19wNyJsRixuZvojVCxn2q5mzaGOQu4YJ9ZmUboOVxzdli2+ bPRc8RQSZIw2nbk7cduPSvBNGsRWMm6W6V7Xi/j05Z2N2BR71AuZIyz1I D5lCfB/0vZIwtMSnkD4U0U3wm7CdUL6yt3w7+GlgsB/m7TxLN4Sv4D8Cx vRhX7mbQ7zfR85lsQqOf1AN1qPgdvIwISi5hRJb7ycnxHEQJRo6tUl4In Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="415670610" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="415670610" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 03:08:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="1001050306" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="1001050306" Received: from mzarix-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.intel.com) ([10.249.94.125]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 03:08:03 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Emmanuel Grumbach , Gregory Greenman Subject: [PATCH 10/16] wifi: iwlwifi: mvm: fold the ref++ into iwl_mvm_phy_ctxt_add Date: Wed, 11 Oct 2023 13:07:25 +0300 Message-Id: <20231011130030.c19c07746b26.I5b0cbe0760811631a320218a10b88870b5bf0897@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231011100731.361200-1-gregory.greenman@intel.com> References: <20231011100731.361200-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 03:11:03 -0700 (PDT) X-Spam-Level: ** From: Emmanuel Grumbach When we want to add a phy_ctxt, we need to increase the ref. Note that all the WARN_ONs are already in place: * We check that we don't add a context with ref != 0 * We check that we don't modify a context with ref = 0 Signed-off-by: Emmanuel Grumbach Signed-off-by: Gregory Greenman --- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 2 -- .../net/wireless/intel/iwlwifi/mvm/phy-ctxt.c | 20 ++++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index 0d78a9efbe2f..d161e2ea1ac5 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -4716,7 +4716,6 @@ int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif, goto out_unlock; } - iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt); goto link_and_start_p2p_roc; } @@ -4812,7 +4811,6 @@ static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm, goto out; } - iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); *phy_ctxt_id = phy_ctxt->id; out: return ret; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c index c3c1b57a05ce..8baf261888a7 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c @@ -265,6 +265,8 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, struct cfg80211_chan_def *chandef, u8 chains_static, u8 chains_dynamic) { + int ret; + WARN_ON(!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && ctxt->ref); lockdep_assert_held(&mvm->mutex); @@ -273,9 +275,16 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, ctxt->width = chandef->width; ctxt->center_freq1 = chandef->center_freq1; - return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, - chains_static, chains_dynamic, - FW_CTXT_ACTION_ADD); + ret = iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, + chains_static, chains_dynamic, + FW_CTXT_ACTION_ADD); + + if (ret) + return ret; + + ctxt->ref++; + + return 0; } /* @@ -285,6 +294,11 @@ int iwl_mvm_phy_ctxt_add(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt, void iwl_mvm_phy_ctxt_ref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt) { lockdep_assert_held(&mvm->mutex); + + /* If we were taking the first ref, we should have + * called iwl_mvm_phy_ctxt_add. + */ + WARN_ON(!ctxt->ref); ctxt->ref++; } -- 2.38.1