Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1540026pxb; Thu, 16 Sep 2021 09:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4vcBk93UBAEU/QJit8A67edPNcG4L3HOZ8DhEkWw2yxCXYaNuGBlr93Unw6zNSvGqekU4 X-Received: by 2002:a02:958e:: with SMTP id b14mr5109777jai.123.1631809881504; Thu, 16 Sep 2021 09:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809881; cv=none; d=google.com; s=arc-20160816; b=ugX9R7xuuMznaZcvPKFOV5NoC2fWptJwcDoeGTeYGhk2/bjtVPletlQpTLFt3vMRx/ tkMTD3LdggpVie4kWfFfsXHG4gxoC0kUTUS3g1jiMzW9ON3W1bfQbnSa9NdQBhNnzI9I /UTXu1oHzp6+YVPcqnRsYcgCgP7hk1SgFTgqATqmVhpHHbW4E4g/MnwvBJgVl2C6juHn UjuVYm2ZUJ317AfVzHvFYEc1UKCQCDD1vqwR61vmZ0CLr0a2bjn3ODnTbaAEKQzbcd/9 RaEsEYqX9zncKPx2rZW3aSiLBQzCMQBRySuO5vDso01vXtXl0o8n5+rThkQBzRWPulbg phVA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g8cH209NrhT4zD7t+lr79PrD3plM9A+zyX7zC0ETu6M=; b=QsTAmwDdjYM+ANQkQszuzFA2M/kuKiqQTdH2pgS2e557pFaSGo+jfGaxY5a/0KNrCu Isx/bd1gElSyCg595MFQ7A1f8lX7KonZX45L1YmfsaAJf/m9K13Fks6PsMV1w3qyd7OQ Y6imyl64GNuP/GYCkUbAC51/p0H/AJrITQMTkjGXEsjWp7GLkAUvG/xLZjfqJglfqVfQ zhKHLOscrtyegsf+T2pnhm0YSJDng0RJxqORSQ2ML+qLeAFLwA5418Azq2pKC8+dyKiu MuUM2uU8CZ7cghP5yEhEQVgmXBMVA1aK7j3OqN5pCCiJxtuowVdJevsizicmoup3b7Nm 9JUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NzuBYgf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si2993530ios.58.2021.09.16.09.31.06; Thu, 16 Sep 2021 09:31:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NzuBYgf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241458AbhIPQa3 (ORCPT + 99 others); Thu, 16 Sep 2021 12:30:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240632AbhIPQVV (ORCPT ); Thu, 16 Sep 2021 12:21:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A9B8613A9; Thu, 16 Sep 2021 16:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808891; bh=BZrkluB2099K/J1qS8KSKoiffuQQBK2F02rugxMspQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzuBYgf5al87MWapcPX97wtEuPNpclgoTyrSUBZ6E2ZjHRYsML2YLDc7MhmaSKvvS Fjs/sM4onvBtYb9MZ2oMKd9vbPiuDpIXsOqTVk3Kb2Y8VP3ik2rF/IO7eBRggBpNmY S7IhY7M7+Md+xOLP3idikl0SpR3mQdlSwhBV1GHc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH 5.10 261/306] iwlwifi: pcie: free RBs during configure Date: Thu, 16 Sep 2021 18:00:06 +0200 Message-Id: <20210916155802.970532519@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 6ac5720086c8b176794eb74c5cc09f8b79017f38 ] When switching op-modes, or more generally when reconfiguring, we might switch the RB size. In _iwl_pcie_rx_init() we have a comment saying we must free all RBs since we might switch the size, but this is actually too late: the switch has been done and we'll free the buffers with the wrong size. Fix this by always freeing the buffers, if any, at the start of configure, instead of only after the size may have changed. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20210802170640.42d7c93279c4.I07f74e65aab0e3d965a81206fcb289dc92d74878@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 5 ++++- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index 94299f259518..2c13fa8f2820 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -544,6 +544,9 @@ void iwl_pcie_free_rbs_pool(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); int i; + if (!trans_pcie->rx_pool) + return; + for (i = 0; i < RX_POOL_SIZE(trans_pcie->num_rx_bufs); i++) { if (!trans_pcie->rx_pool[i].page) continue; @@ -1094,7 +1097,7 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans) INIT_LIST_HEAD(&rba->rbd_empty); spin_unlock(&rba->lock); - /* free all first - we might be reconfigured for a different size */ + /* free all first - we overwrite everything here */ iwl_pcie_free_rbs_pool(trans); for (i = 0; i < RX_QUEUE_SIZE; i++) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index bb990be7c870..082768ec8aa8 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -1909,6 +1909,9 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans, { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + /* free all first - we might be reconfigured for a different size */ + iwl_pcie_free_rbs_pool(trans); + trans->txqs.cmd.q_id = trans_cfg->cmd_queue; trans->txqs.cmd.fifo = trans_cfg->cmd_fifo; trans->txqs.cmd.wdg_timeout = trans_cfg->cmd_q_wdg_timeout; -- 2.30.2