Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp993768yba; Thu, 4 Apr 2019 01:59:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMwJe86/iHsLUMRYL9fabeRe0PieCHnuKAlR5LpVg8ZIr4U5aeZjldJYKr4Y5tZaxOJEcC X-Received: by 2002:a63:ff66:: with SMTP id s38mr4751121pgk.120.1554368379744; Thu, 04 Apr 2019 01:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368379; cv=none; d=google.com; s=arc-20160816; b=Y3CiADgagPbblt/ei4sCcXmljG+XZb8G40SpiFaDezw2NWbs7KK66oYzEJOqthVRfw vbk949xBEcMxQz0Hs4SZGxGepxsNrnX1ZWy86nxsaH7Cr/bVb17qQ8Wl5MfAkVGljOs4 EUN3nEeGp/i7klex7oIgRoI1EtYobvdFmfIVp1YRneAdh9/p+RufEIVFikNB5jULW1C2 LKPCIhXl59SL7pX+dhfG9pJlWROEYQQCfWtNo/vtB4eW0I1XqUu0j6RkSuSnmPcSPNgW vImbrxY5AHFnBlaK1ibOf8d4Chwvxw9bUb2TkyeWftM7D2XDrO/NsbFPIALcX4j2BmjI yVEg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6kCKqzliL79eiw8ejQzVAB5F9HBZumz3rjiVA64c/H8=; b=zRvU/oga5zeRz+k7Eh67Kh17kcwzVbdwP8L3FZ2b39IwbuZNb7Kdubxuu92vRWB1D7 cIs9zNBogI5G9H2iesAwUFWhgGgPpix/blu2UTFWUBZ7SwZxZuF7wx3n1SuTYtAi69Xl d5GsZkEibT62bgBU8w9ePq/n4Fq4PND/nDIhQ098nlVgA7iGOJxz7oifdmfAP8g6Z7dq va13TwuK/t3HHkFX1ZciPOdAfOoEMe8mgQdEuwD8I1HCJh4cVApj0kwLENMPE9cG9FP/ vQhyglV7xiYTlNSiJSjpUwnF/0+8qUC+94GBuQCPPqGONFIzTkU0b681fE7jcTMbqjWU ZxkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l1J+fh6M; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u33si16033860pga.341.2019.04.04.01.59.24; Thu, 04 Apr 2019 01:59:39 -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=l1J+fh6M; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730628AbfDDI5K (ORCPT + 99 others); Thu, 4 Apr 2019 04:57:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:60720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730614AbfDDI5G (ORCPT ); Thu, 4 Apr 2019 04:57:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7DC72177E; Thu, 4 Apr 2019 08:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368225; bh=of87jsM+rHuEVl0svtfaTXlFdX9tnwNNu0werUnqz/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l1J+fh6McxFBFpRFQoyvQLwQH7IbpaMHurIROt0xpj+P17ZMqnGef5kW9kGBfeoWN hmmXGC+uaNsy4vq0MsOqACVf1HRZGhzC3evKXMFK/JtAnuTjLiEkv0JJfSf7LaqRrK 5GBAaZtD9QbtI7rGGmKg3YVvwvWB/gBCD+oegx5M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilan Peer , Sara Sharon , Luca Coelho , Sasha Levin Subject: [PATCH 4.14 068/121] iwlwifi: pcie: fix emergency path Date: Thu, 4 Apr 2019 10:47:36 +0200 Message-Id: <20190404084548.959197639@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084545.245659903@linuxfoundation.org> References: <20190404084545.245659903@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 5a15362ef671..a40ad4675e19 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