Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp990104yba; Thu, 4 Apr 2019 01:53:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH9JLDh19avTZPSz7XXpx7kA/f0REng3oYYiGARxtbRzIloKiAfqa15v4GP7ReK8zXGSS6 X-Received: by 2002:a17:902:7b93:: with SMTP id w19mr5134003pll.137.1554368035360; Thu, 04 Apr 2019 01:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368035; cv=none; d=google.com; s=arc-20160816; b=Ka4s1K43/BKGfZ/U/NjfYskXIQiX2qE14rIJjOn1znRtVa4IoNmnCZY+E2hHHm8Z/6 hNGaEE8eoZ5NAiPuE/2QpEiD208SEG8fe+6or+W44JKU7m5PaHG4w2ksmME7iFXX8rcX t9YBOXPXASsex19EG+gxQTA0EoN3qW2f4pmtHDi1yCBTcpVk7CPJItQtAfH4ai9Vc6o3 m6Tel+IzYBfDPeOk9JX8BuAjrQ6UH1ZPLzpMvAipEQjujVvK92eWQ1tLMyC3qb1brQ5e qAoiiS6L4exkKvZ0EhtvqOjGpdWQ3lpOsu9TIF0yEEhqyQ2pAG1+3S5vv2SSVcX2m709 R6Cg== 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=K5TQnflcRDxPbwn9gS5AZ/Ddg7NQ+E14Wi028gnApgw=; b=cPJfqdYgv8eblWic7LdrXlNijFCTn+1DILm93n3eSporNfGGwqeRPQa2wil8KsUHiy mgWq1S9iaaOIBfrjAamJmS+TJNncNvHIwculroAzeg3HJMPh3CSWf4fjBp0AmfnxsoES 4ZqQ4czgLd9e/y7dn5+QZBUhF9HZjyu4ypRmqQqxs6CfCZLIjInv8HPPi7TK8x1o6tfk mLOF/d+j6eU8lVVF7ZA28iQDuC/Aj3W9TiYKT3S275osHYRcAue7vm9GaMd9cjIUiZ6l yzm6dYXiseeRrKSvNciThMyIXTCeUJILfUx+KU2pgkfvQt8G+kouToywzaONzhM0jyV8 SOJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oAydh6Tj; 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 s26si16154922pgm.223.2019.04.04.01.53.40; Thu, 04 Apr 2019 01:53:55 -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=oAydh6Tj; 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 S1729582AbfDDIwT (ORCPT + 99 others); Thu, 4 Apr 2019 04:52:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:54334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729563AbfDDIwP (ORCPT ); Thu, 4 Apr 2019 04:52:15 -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 733ED20855; Thu, 4 Apr 2019 08:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554367934; bh=hiBG1pkORZZU+hNiR6kMoxMtEWgeH78To8J3buKfp5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oAydh6Tj4J7qcC/NGuJnZHZNUekmB2sGWmQy61v4l9OoXXvddpKWtWA/g7wXvpXJA ZNOz9/n+e6jJXKna00lWwno4OF5wLenNUsF8jRXHhCVlwmik0pAafmGz65rLJxjGxu lPozqhEv6fIrkdNNWhOzf6aGtsIe4LjqnsiBQCGs= 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.9 52/91] iwlwifi: pcie: fix emergency path Date: Thu, 4 Apr 2019 10:47:36 +0200 Message-Id: <20190404084538.484571534@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084535.450029272@linuxfoundation.org> References: <20190404084535.450029272@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.9-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 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