Commit 0fbfca57 authored by Sara Sharon's avatar Sara Sharon Committed by Greg Kroah-Hartman

iwlwifi: pcie: fix emergency path

[ Upstream commit c6ac9f9f ]

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: default avatarIlan Peer <ilan.peer@intel.com>
Signed-off-by: default avatarSara Sharon <sara.sharon@intel.com>
Fixes: 868a1e86 ("iwlwifi: pcie: avoid empty free RB queue")
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0affcd54
...@@ -475,7 +475,7 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans) ...@@ -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_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_rb_allocator *rba = &trans_pcie->rba; struct iwl_rb_allocator *rba = &trans_pcie->rba;
struct list_head local_empty; 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); IWL_DEBUG_RX(trans, "Pending allocation requests = %d\n", pending);
...@@ -530,11 +530,13 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans) ...@@ -530,11 +530,13 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
i++; i++;
} }
atomic_dec(&rba->req_pending);
pending--; pending--;
if (!pending) { if (!pending) {
pending = atomic_xchg(&rba->req_pending, 0); pending = atomic_read(&rba->req_pending);
IWL_DEBUG_RX(trans, IWL_DEBUG_RX(trans,
"Pending allocation requests = %d\n", "Got more pending allocation requests = %d\n",
pending); pending);
} }
...@@ -546,12 +548,15 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans) ...@@ -546,12 +548,15 @@ static void iwl_pcie_rx_allocator(struct iwl_trans *trans)
spin_unlock(&rba->lock); spin_unlock(&rba->lock);
atomic_inc(&rba->req_ready); atomic_inc(&rba->req_ready);
} }
spin_lock(&rba->lock); spin_lock(&rba->lock);
/* return unused rbds to the allocator empty list */ /* return unused rbds to the allocator empty list */
list_splice_tail(&local_empty, &rba->rbd_empty); list_splice_tail(&local_empty, &rba->rbd_empty);
spin_unlock(&rba->lock); spin_unlock(&rba->lock);
IWL_DEBUG_RX(trans, "%s, exit.\n", __func__);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment