Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2498932imm; Mon, 24 Sep 2018 05:30:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV602xbVYbDWgJeliOxoSblt4yhAwPy81982pDzB+ryM5RpyDl780OKYBKZCGQAoWRbLL8omk X-Received: by 2002:a63:740f:: with SMTP id p15-v6mr9504832pgc.395.1537792248038; Mon, 24 Sep 2018 05:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792248; cv=none; d=google.com; s=arc-20160816; b=EnwxEMi6bWa6xC22MH5gm2s9Madjkcmrax3hV40BtaK0VFe9pc16P0Ko5SNDzRUEvS UDoNdAgUiNm4k/dH1mk9s5KQJMokojTrZgyuRUJFo620vXd8qwSIwfgm6LAg+NAyhVfm 4GHoCjFdrAjFWspJLLB87cZSzQKTLI9ooTRsYrm0G8CqcxjJ1PBGUP6dYMoslYNBhE2Z aqEoKRrW5qkwmHiDZKPyppVxiPgaKVCYsxdk4XfBckE1rItZZHD7phPWJi/5wcPK8C+H u1EV/hPA9NKgBrc2XoDJQyAhRxXpR4ID5YwXsui8sJwVarlZct9Neeio3AsaO/hFy9jw G2Cw== 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; bh=JpdHBqL7+XwVTWs7FUKvMHmHVV4Xap/FEfH3nwta5+Y=; b=DyfV3LGqEoGNkdy4A0BZNQkLLNA+I/J2tDR5I+xT8t0N1e1JLBhCzhQ2h+tFJpbvAu ycBs5MVshsiHSy6ij0aFRhCOdSI9PJEXPION5sGo1ywMXBXTjC3HmkX/oG83vWjUzrSo VzklaxJAj7B7ui/s7NyxQEp75jpkEPwgPkKcNrGwn9BLWO0CxNsIDmnf47BMLci328s1 Vb/0/XoxAx0fsOWs2zm+zXZJxD+98lCLqJifed4axMYf29HSZotcmxhp09m/3nIhVxhb u/ZFTlAXiJZhAns7lkHvnUquAb4p20veyzStiF5Ghaw85vbaEji00hGrR7UmAOAuTtUt I/dw== ARC-Authentication-Results: i=1; mx.google.com; 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 32-v6si35626684plg.390.2018.09.24.05.30.32; Mon, 24 Sep 2018 05:30:48 -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; 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 S2387469AbeIXS37 (ORCPT + 99 others); Mon, 24 Sep 2018 14:29:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57386 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730233AbeIXS36 (ORCPT ); Mon, 24 Sep 2018 14:29:58 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 48D721018; Mon, 24 Sep 2018 12:28:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Golan Ben Ami , Luca Coelho , Sasha Levin Subject: [PATCH 4.18 026/235] iwlwifi: cancel the injective function between hw pointers to tfd entry index Date: Mon, 24 Sep 2018 13:50:12 +0200 Message-Id: <20180924113107.304828110@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Golan Ben Ami [ Upstream commit f5955a6cc3862a02d46f50b723c3172d24d749a5 ] Nowadays, the tfd queue max size is 2^8, and the reserved size in the command header sequence field for the tfd entry index is 8 bits, allowing an injective function from the hw pointers to the tfd entry index in the sequence field. In 22560 devices the tfd queue max size is 2^16, meaning that the hw pointers are 16 bit long (allowing to point to each entry in the tfd queue). However, the reserved space in the sequence field for the tfd entry doesn't change, and we are limited to 8 bit. This requires cancelling the injective function from hw pointer to tfd entry in the sequence number. Use iwl_pcie_get_cmd_index to wrap the hw pointer's to the n_window size, which is maximum 256 in tx queues, and so, keep the injective function between the window wrapped hw pointers to tfd entry index in the sequence. Signed-off-by: Golan Ben Ami Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/pcie/internal.h | 12 ++++++++---- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h @@ -660,7 +660,7 @@ static inline void iwl_enable_fw_load_in } } -static inline u8 iwl_pcie_get_cmd_index(struct iwl_txq *q, u32 index) +static inline u8 iwl_pcie_get_cmd_index(const struct iwl_txq *q, u32 index) { return index & (q->n_window - 1); } @@ -730,9 +730,13 @@ static inline void iwl_stop_queue(struct static inline bool iwl_queue_used(const struct iwl_txq *q, int i) { - return q->write_ptr >= q->read_ptr ? - (i >= q->read_ptr && i < q->write_ptr) : - !(i < q->read_ptr && i >= q->write_ptr); + int index = iwl_pcie_get_cmd_index(q, i); + int r = iwl_pcie_get_cmd_index(q, q->read_ptr); + int w = iwl_pcie_get_cmd_index(q, q->write_ptr); + + return w >= r ? + (index >= r && index < w) : + !(index < r && index >= w); } static inline bool iwl_is_rfkill_set(struct iwl_trans *trans) --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c @@ -1225,9 +1225,13 @@ static void iwl_pcie_cmdq_reclaim(struct struct iwl_txq *txq = trans_pcie->txq[txq_id]; unsigned long flags; int nfreed = 0; + u16 r; lockdep_assert_held(&txq->lock); + idx = iwl_pcie_get_cmd_index(txq, idx); + r = iwl_pcie_get_cmd_index(txq, txq->read_ptr); + if ((idx >= TFD_QUEUE_SIZE_MAX) || (!iwl_queue_used(txq, idx))) { IWL_ERR(trans, "%s: Read index for DMA queue txq id (%d), index %d is out of range [0-%d] %d %d.\n", @@ -1236,12 +1240,13 @@ static void iwl_pcie_cmdq_reclaim(struct return; } - for (idx = iwl_queue_inc_wrap(idx); txq->read_ptr != idx; - txq->read_ptr = iwl_queue_inc_wrap(txq->read_ptr)) { + for (idx = iwl_queue_inc_wrap(idx); r != idx; + r = iwl_queue_inc_wrap(r)) { + txq->read_ptr = iwl_queue_inc_wrap(txq->read_ptr); if (nfreed++ > 0) { IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n", - idx, txq->write_ptr, txq->read_ptr); + idx, txq->write_ptr, r); iwl_force_nmi(trans); } }