Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1024208yba; Thu, 4 Apr 2019 02:40:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSawFYJhMRlgpsRwaVSko6XX2DCYh481UwftrutxgrWZEZPxxYztzc2ln3mohGzXR8Tj0v X-Received: by 2002:a63:d854:: with SMTP id k20mr4872745pgj.107.1554370835569; Thu, 04 Apr 2019 02:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370835; cv=none; d=google.com; s=arc-20160816; b=ltPqD6Kmk9pUbER0yB2x85A/KIr9Ysb5JFU2gqj5y3V5yYlbLesNu1IzVXoZWxDySo n8j5mfsgr4cnh/rJ2EB85pWkpE9UtdYOvm7u0AogrvoMit0KjB9ijbl+p6FJPlROY3hu jlyol41mlySSk9lpKpnHE6cSU/tU5jlVWVcAx5QEARVQkG3bhsrPYqRauxzMk3L5J3q8 3/ZYo0kK0x1HGh176a1nbtKH6YL4JUL1TlZ25hyynZyVxyyCmdypwy59HNjkIr282cC4 Z2qKOlmol6Wq3AIOEHFViqJ5JzK1l4Y7/G/w+2CP4TIoL28GyQmMknmmGmar1jwSIFYU VWRA== 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=VAxJlMo8Nr9Bou4XHuVHuKyRNIgYiZImEGaFzM7zIqE=; b=IcYEQAm8Ydoh4s/Tk/VjtloiRyWoc44CUS1Hs1Wp+d2V0FZgKEz8ohIZJctqia2eB1 DKXxDQoECtlBphPrdE8aKbx4eW/QFsTyAKbYJi4QHh3JirQRaiP631no+sndAf6WGH7I UUW5WvWdQY7CA2sbPrTooup/XL0EkUABxk8ZIGuQ/VqrEiQaA+D892xgbMTE8U6ZAGee 2c/5IVt70bzBKZS/JSsOfK7nSJ6Z2H5eiqQ4PlQUmN1tSlLeaJ5wfRPRg6+KRtic0Li7 jtP1H9kYDRK/KLqyMTzTu7fAWQhd+ZMq7AbuW1Vo5nFWvgV71GScY0/NkU+De0nIwmiy VpIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LsZIoq7G; 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 e6si16588116pfe.141.2019.04.04.02.40.20; Thu, 04 Apr 2019 02:40:35 -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=LsZIoq7G; 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 S1731931AbfDDJjs (ORCPT + 99 others); Thu, 4 Apr 2019 05:39:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:40974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731552AbfDDJDU (ORCPT ); Thu, 4 Apr 2019 05:03:20 -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 9B91621741; Thu, 4 Apr 2019 09:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368600; bh=2snY4cQy5W7AF5jpYt/98j6lNleW//3elI+uvbEQ5M8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsZIoq7GXAklIYnUUO4h5vXvg71stVcswnZ3Hq67++bVlmzXJMqoktUb7eWmDOERz OC025JB7zv+JamTWcFdKWTDtR09lO1retzL5o5QRbyVLu3J7zqMiTWc0Hex8bKwLUT OnRSMNVnwRGVAxNKACjBATWQDZ//P26ZnC+1PzF0= 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.19 099/187] iwlwifi: pcie: fix emergency path Date: Thu, 4 Apr 2019 10:47:16 +0200 Message-Id: <20190404084607.844819877@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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.19-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 d4a31e014c82..b2905f01b7df 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -502,7 +502,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); @@ -557,11 +557,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); } @@ -573,12 +575,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