Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3111016pxb; Sun, 31 Jan 2021 04:42:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJy19LbTGI6S0Ncxfu6Eg1iSc55+PTt3ZVOn3Y9evQToebokQ0DH604AgroScc8weMETUb1V X-Received: by 2002:a17:906:7c57:: with SMTP id g23mr12865331ejp.364.1612096979542; Sun, 31 Jan 2021 04:42:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612096979; cv=none; d=google.com; s=arc-20160816; b=UOhtYRF1d1HgaPioe1MowLL4o0sRK6vv44ev/SUcrt7Iz+AQQq0QdPe25oOC2oJjGH PKiF9DQaHhsAAZbm/MdGehdcZ/Kxaspq4HSe6k2aDLVeu9WSC4hOZHHLbWEh6k68LeCY LMj2pPjARSKMdEmaus/42fuhxShu30P++DBLWr5/2HFGHCNgLAI+TZ9UE6Gf2h0Vb18q TolS8fOTWRxEhny2i5YOQ6c0EuPOGBqfTZU3p+9YyaC3AuywzASsgAJkW1O+hoANDZ50 WUPd0UD4tuX5RoQvsCMBKZxblUj4oke1/G4Y5v9whazsGrF5Vmxt6hHDXmz3Q8gq91jf copQ== 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=TAGLTbtxTtHyiCHkjrjJrojxAgZ1yFvt7r571YTQodE=; b=z3VnDIaiJgBeZkk11FFLE7uz/BfEf/A1jpi36rHUrt+DudpYfop4HA1MIXM+Yn4ELf gbqkCiT5iUTjJaCaICCnwDqiC8FobyqABifsQcF6q6/iqDmE8my+rzemzqWs/WJvmrmW ynE5NjzO2BHYlzvxnvQSILpdKYrFVW5MxVosBysM32uYg4TuK2THzoYJG0c6I4oeVrTV hCMFii8sIEzG3d5VgfsPbN+FUuKfKwUZWLQ034d8K0XNMZ++ZHVvIkyQmSVZ72E4G6rD suPff5FqrAUTynZlN/86P6sejgpaONxaBLfEs1YoPs/BWaK/zRnU4xWnVDtEi4D46O6N x0Lg== 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 p24si9148565edw.475.2021.01.31.04.42.30; Sun, 31 Jan 2021 04:42:59 -0800 (PST) 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 S231509AbhAaLdb (ORCPT + 99 others); Sun, 31 Jan 2021 06:33:31 -0500 Received: from paleale.coelho.fi ([176.9.41.70]:42896 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231470AbhAaLbY (ORCPT ); Sun, 31 Jan 2021 06:31:24 -0500 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l6AY3-004131-F0; Sun, 31 Jan 2021 13:05:43 +0200 From: Luca Coelho To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org Date: Sun, 31 Jan 2021 13:05:31 +0200 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210131110533.887130-1-luca@coelho.fi> References: <20210131110533.887130-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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.4 Subject: [PATCH 10/12] iwlwifi: pcie: Disable softirqs during Rx queue init Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ilan Peer When Rx queues are configured during module init, NAPI is enabled while the Rx queue lock is held. However, since softirqs are not disabled, it is possible that and IRQ would fire and call iwl_pcie_rx_handle() which would also try to acquire the Rx lock. Prevent this by disabling softirqs during Rx queue configuration, as part of module init flow. Signed-off-by: Ilan Peer Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index e3e53419b526..407809c7e958 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -301,7 +301,7 @@ static void iwl_pcie_rxsq_restock(struct iwl_trans *trans, if (!test_bit(STATUS_DEVICE_ENABLED, &trans->status)) return; - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); while ((iwl_rxq_space(rxq) > 0) && (rxq->free_count)) { __le32 *bd = (__le32 *)rxq->bd; /* The overwritten rxb must be a used one */ @@ -320,14 +320,14 @@ static void iwl_pcie_rxsq_restock(struct iwl_trans *trans, rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; } - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ if (rxq->write_actual != (rxq->write & ~0x7)) { - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); iwl_pcie_rxq_inc_wr_ptr(trans, rxq); - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); } } @@ -433,28 +433,28 @@ void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority, while (1) { unsigned int offset; - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); if (list_empty(&rxq->rx_used)) { - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); return; } - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); page = iwl_pcie_rx_alloc_page(trans, &offset, priority); if (!page) return; - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); if (list_empty(&rxq->rx_used)) { - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); __free_pages(page, trans_pcie->rx_page_order); return; } rxb = list_first_entry(&rxq->rx_used, struct iwl_rx_mem_buffer, list); list_del(&rxb->list); - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); BUG_ON(rxb->page); rxb->page = page; @@ -466,19 +466,19 @@ void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority, DMA_FROM_DEVICE); if (dma_mapping_error(trans->dev, rxb->page_dma)) { rxb->page = NULL; - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); list_add(&rxb->list, &rxq->rx_used); - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); __free_pages(page, trans_pcie->rx_page_order); return; } - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); } } @@ -1112,7 +1112,7 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans) for (i = 0; i < trans->num_rx_queues; i++) { struct iwl_rxq *rxq = &trans_pcie->rxq[i]; - spin_lock(&rxq->lock); + spin_lock_bh(&rxq->lock); /* * Set read write pointer to reflect that we have processed * and used all buffers, but have not restocked the Rx queue @@ -1148,7 +1148,7 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans) napi_enable(&rxq->napi); } - spin_unlock(&rxq->lock); + spin_unlock_bh(&rxq->lock); } /* move the pool to the default queue and allocator ownerships */ @@ -1190,9 +1190,9 @@ int iwl_pcie_rx_init(struct iwl_trans *trans) iwl_pcie_rxq_restock(trans, trans_pcie->rxq); - spin_lock(&trans_pcie->rxq->lock); + spin_lock_bh(&trans_pcie->rxq->lock); iwl_pcie_rxq_inc_wr_ptr(trans, trans_pcie->rxq); - spin_unlock(&trans_pcie->rxq->lock); + spin_unlock_bh(&trans_pcie->rxq->lock); return 0; } -- 2.29.2