Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5614788img; Wed, 27 Mar 2019 11:45:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRyYOqH61A/+hO95mwY5gV+b3ErCkJ4bOYn/VTnVy337K2nfeLlh9re7kOc0uOdkGxqvqE X-Received: by 2002:aa7:8589:: with SMTP id w9mr36755731pfn.97.1553712320308; Wed, 27 Mar 2019 11:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712320; cv=none; d=google.com; s=arc-20160816; b=Nsewps2zjkZDGLck8I1A4uKRHqDKGfJpRCa+Kx1GrGMUnLuoWE07YNT/wciASc+ShR y4PNTlyJeJGMwlYwiO3gToHwDLzrNwwWaDIc2fXmvzQxVJk6mprTHhtBKJkP/3oT4Z5J 6il9PJKIM7W8rpiTTwW4kBOyQMrcLe3IZCNK2hHkGT9wrTo6FSxo1EjWvrGoCuuaL0Kg hRRQUF+pMf+xJex6ev0XhZHRy9cZMfOQ1cXn50vQ0jWi0ESt7Hq6cnPW0KVe1Bc802Qm cVz61nyQXDcWXUHv7B+pKm0J8V64caWdXKXBGRIFuEAtEC2JKojLq3TKs4wWJaZlprmU zZKg== 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=YBx5FhHdAOS1qCUj7CMqD1CJhg/ye9X6th0RBvoRZqM=; b=Grmh34l0grIWSm5tHgrOLbx04JYMU4zyCGgyEkeGnPT1Q2BhECSH5UWXNs9+CGM1ev ztgGf/mE2eT1pzQwpSa94dtudSS+jXzPNFHLpXCDV4u7gYF9ak3OJ8ahZje73V0dc8SZ rILRhekBWwIdaNEn70FHpBoXGr6SN8uvMKmEQzgzzkx6MYLhdalc9Ab1Mn3SXzhS6XqZ wDtta+RzNTWwP4zKZxmt7owHAwcRVO7rtiIdHMY5k0XpXNKfy3llKlMbuugcee6SvOO8 kO933n+yZFLFzUZa/xdQiLZcQCb81b0/EVEDqlHM+ODVYcAGZtPVtk6cyboKuoPtaCTq i3uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=inkKAhDr; 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 z184si13136162pgd.588.2019.03.27.11.45.04; Wed, 27 Mar 2019 11:45:20 -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=inkKAhDr; 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 S2403806AbfC0SWB (ORCPT + 99 others); Wed, 27 Mar 2019 14:22:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:39966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403782AbfC0SV7 (ORCPT ); Wed, 27 Mar 2019 14:21:59 -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 D6CF620643; Wed, 27 Mar 2019 18:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710918; bh=ks2YUMp0EyQpEs3Ow1PHCEffpB9rW8iO8XuspyGU/Jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=inkKAhDrh/9Q5iJlc1STDmdW47o7SPKprgTAJnouqOTRMibk3qU1QPg/UvXuTcrFH rAvqyXvmac0JxlTWwMmpA7ju8tCFPKZdiqLH2DWRAyOABcCmcHYx7WD69rSrps9FVg u9ssViHJZhb1tNN7oigzcjQC5uHiyGqXRm+Mw7SI= 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 4.9 46/87] iwlwifi: pcie: fix emergency path Date: Wed, 27 Mar 2019 14:19:59 -0400 Message-Id: <20190327182040.17444-46-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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 e58a50d31d96..c21f8bd32d08 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -475,7 +475,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); @@ -530,11 +530,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); } @@ -546,12 +548,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