Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5583412img; Wed, 27 Mar 2019 11:08:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+WQCYVoqPo9Rxd499m/iCRpuS6eUOWh2Bu+aXeR5mpFzfKcrjK42XrQQyaE9J78za0y1p X-Received: by 2002:a17:902:bccc:: with SMTP id o12mr36755372pls.70.1553710097798; Wed, 27 Mar 2019 11:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710097; cv=none; d=google.com; s=arc-20160816; b=aQtkqUHr7Z+QecXW1dNuJmymRDRLqVnT7tr3cJtX6ohcuIqOw0tkvLRKdfPQjFe/a7 KAwR5BzTTkQ2Ih2XvpL94iD2jtV2k4tB/0V1/QQXauZfmJTPD8fVOXaqakYxvg1RGGMU jdzZto9DyzIY4bgjQqwq9YPuom92r0w9mmVqO2g50K2wWy1pVMvQtDXrr2cofuc16laB dQM0W6bzLK0WOjVshV39YBn6jc1hgl9CNAzRZ8fkLdQmMngxBhQ7JQZKcM3z7rm1QpjI p1nH1eOTx47im6MY9HEN0We7cGQO3ELS/GVW4j+rHCeJs0t2G8YRIo3C4D1lmWlQ4nQv IACw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o4K7VAP8E7UbgAAJh/8XBHRNlXN/4StrCBwkck07E8U=; b=Cz/m/oOiI1GoXWuazsmbOY4jwu7cLKM3HEXt7BLo0p91rADlxzsA7cTRiHrO9ghDom K3TUiWzV3T+3N26RdUcoiHUPOLDTycnip1kEeBBc+IbMmvL9I41uHW39EwqC1EniDGIX GN4lnBl9cKzZSTZugUgaEIphVEyk1KneLr280WfyA/zTj8aKIsy+g2D0BywMp/BInh13 jed7dkVh0j03Ce6tz5qh1ACiPN9wXeL5wyw7UinCXGV/sv9hWaz1cPnsEk6LW61/itdf GZ5/obcbipSx1E+7vZmSPbBbOXbEjLJcrxaVv6mwPgyD09FETWGZXSbA4WYW6Z9vlt/Q X2Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B3ynSZJY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si16667934pgr.158.2019.03.27.11.08.02; Wed, 27 Mar 2019 11:08:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B3ynSZJY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387972AbfC0SGh (ORCPT + 99 others); Wed, 27 Mar 2019 14:06:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:48096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733208AbfC0SGa (ORCPT ); Wed, 27 Mar 2019 14:06:30 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BCBFB2063F; Wed, 27 Mar 2019 18:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709989; bh=1s7RgBUl01/7/jLP5KHqoctGZubsKT0vnWmhrEcD3UA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B3ynSZJYbQJnzO68cIbJ4UjQqODjCtt8QHEtbNE5pAYnpSoPoV4B8MjGm+tvDjX8O c6y2xPzWeWsip/mKx0iTs9OuYuRfaEsM4xuoCnp2SH9/Hgdgl7hbLFYB4/Uw3zcLmP RI8YkivKC+WTvAK8H7BwBft8QihgjOVVzYxB/0mI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sara Sharon , Luca Coelho , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 145/262] iwlwifi: pcie: fix emergency path Date: Wed, 27 Mar 2019 14:00:00 -0400 Message-Id: <20190327180158.10245-145-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sara Sharon [ Upstream commit c6ac9f9fb98851f47b978a9476594fc3c477a34d ] Allocator swaps the pending requests with 0 when it starts working. This means that relying on it n RX path to decide if to move to emergency is not always a good idea, since it may be zero, but there are still a lot of unallocated RBs in the system. Change allocator to decrement the pending requests on real time. It is more expensive since it accesses the atomic variable more times, but it gives the RX path a better idea of the system's status. Reported-by: Ilan Peer Signed-off-by: Sara Sharon Fixes: 868a1e863f95 ("iwlwifi: pcie: avoid empty free RB queue") Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index 9e850c25877b..c596c7b13504 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -499,7 +499,7 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_rb_allocator *rba = &trans_pcie->rba; struct list_head local_empty; - int pending = atomic_xchg(&rba->req_pending, 0); + int pending = atomic_read(&rba->req_pending); IWL_DEBUG_RX(trans, "Pending allocation requests = %d\n", pending); @@ -554,11 +554,13 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans) i++; } + atomic_dec(&rba->req_pending); pending--; + if (!pending) { - pending = atomic_xchg(&rba->req_pending, 0); + pending = atomic_read(&rba->req_pending); IWL_DEBUG_RX(trans, - "Pending allocation requests = %d\n", + "Got more pending allocation requests = %d\n", pending); } @@ -570,12 +572,15 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans) spin_unlock(&rba->lock); atomic_inc(&rba->req_ready); + } spin_lock(&rba->lock); /* return unused rbds to the allocator empty list */ list_splice_tail(&local_empty, &rba->rbd_empty); spin_unlock(&rba->lock); + + IWL_DEBUG_RX(trans, "%s, exit.\n", __func__); } /* -- 2.19.1