Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4373373pxf; Tue, 30 Mar 2021 06:26:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp2mwDmZVSaVZ8i6aI3dAqWW49emLAFycRVakBYrOUJjKvu03Iq+LZUg1PXowHITjuaaAJ X-Received: by 2002:a50:8524:: with SMTP id 33mr34022328edr.110.1617110800306; Tue, 30 Mar 2021 06:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617110800; cv=none; d=google.com; s=arc-20160816; b=pEVCBlKpQlRgPjr3J4JUdx6JZjuAgoFIoO/XI7Qs7tX43RKOh2LYGKN6ppIZ4n+ZbH ikq0amhAX6wSfFgp3+30jjliqF5UrDy+Y68QF25Lfd1+6ErKCeaM4fnCUFqqjEr9PkfU Svoc/2iSKpa33253mU293thHEL+f+JChgcrgemtXwTNOWWvAyc9tl8zLEmjvylaJ160H DrliMWk4FIlu6vweLyCzUG9xyN4+1+6KlLP9HsmXIQWo8LGEiRVPEGrg4PVjgN3zwGIJ L2aR9nKU1JJZ0ciCgr9O0aQvXRZ0baWRZJ9LWrkV47ipU9zyfZDYL9r/zMRxhFUbzSZF kQlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=98VvZ+opIePIM+jIykJDrpACPJEHV+nN6NU8ab98iSg=; b=EUMrnRMhMPPRDbzpyFiecRtoWx6utU9P9BTIFH93CVzWzy6Ldm544A3z0+YgQs/xag nBQYqM9o/wH6mGDKgLN3C1D53e6z/mbulbN5AN2MPCNiOQ7Kpcq7MrEN8rhngrQYjoXR sG7R0pBDFL3ie+ufZq7Zxz94kDNteSG5Dk9L6htPLysnk8Y8v6xomDj4t/gc+pFJDoMT r60lSPBKH/WoDIv2O6Y5RWQo4UdDAjuThrUFfkqQXxnb0tdvpaUFVKITqEO0H9VR/ipN pnQIBH+Ps4zAXVABLSrnKU1b9Nt+325OwfR9OQBp+Q0sb73z97vtRtIbm2z5ptyYISrp L9Cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si14879532edc.377.2021.03.30.06.26.13; Tue, 30 Mar 2021 06:26:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232163AbhC3NZp (ORCPT + 99 others); Tue, 30 Mar 2021 09:25:45 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:43600 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232016AbhC3NZH (ORCPT ); Tue, 30 Mar 2021 09:25:07 -0400 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=kveik.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lREMg-0007fg-LY; Tue, 30 Mar 2021 16:25:04 +0300 From: Luca Coelho To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org Date: Tue, 30 Mar 2021 16:24:51 +0300 Message-Id: X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210330132500.468321-1-luca@coelho.fi> References: <20210330132500.468321-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.5-pre1 Subject: [PATCH 03/12] iwlwifi: pcie: normally grab NIC access for inflight-hcmd Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg We currently have a special, separate, code path to acquire NIC access for the in-flight host-command workaround on 7000 series hardware. However, the normal code path here has grown a number of additional workarounds/semantics over time, such as reprobing the device if things fail. Rather than try to replicate any of this logic, call the normal grab_nic_access logic for the workaround. This changes the spinlock to _bh, but that's OK since it's just redundant, we already have soft-IRQs disabled when we get here, and so didn't (have to) do it again. Since it's only for commands there's however no point in making the code more complex just to not use _bh here. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 33 +++++++------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c index ac200e6e941e..4ea353734665 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c @@ -629,7 +629,6 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans, const struct iwl_host_cmd *cmd) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - int ret = 0; /* Make sure the NIC is still alive in the bus */ if (test_bit(STATUS_TRANS_DEAD, &trans->status)) @@ -638,34 +637,24 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans, if (!trans->trans_cfg->base_params->apmg_wake_up_wa) return 0; - spin_lock(&trans_pcie->reg_lock); /* * wake up the NIC to make sure that the firmware will see the host * command - we will let the NIC sleep once all the host commands * returned. This needs to be done only on NICs that have * apmg_wake_up_wa set (see above.) */ - if (!trans_pcie->cmd_hold_nic_awake) { - __iwl_trans_pcie_set_bit(trans, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - - ret = iwl_poll_bit(trans, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, - (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | - CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), - 15000); - if (ret < 0) { - __iwl_trans_pcie_clear_bit(trans, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - IWL_ERR(trans, "Failed to wake NIC for hcmd\n"); - ret = -EIO; - } else { - trans_pcie->cmd_hold_nic_awake = true; - } - } - spin_unlock(&trans_pcie->reg_lock); + if (!iwl_trans_grab_nic_access(trans)) + return -EIO; - return ret; + /* + * In iwl_trans_grab_nic_access(), we've acquired the reg_lock. + * There, we also returned immediately if cmd_hold_nic_awake is + * already true, so it's OK to unconditionally set it to true. + */ + trans_pcie->cmd_hold_nic_awake = true; + spin_unlock_bh(&trans_pcie->reg_lock); + + return 0; } /* -- 2.31.0