From patchwork Tue Feb 3 17:15:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 5770181 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8AD33BF440 for ; Tue, 3 Feb 2015 17:15:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7BEA201FA for ; Tue, 3 Feb 2015 17:15:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D27D0200E8 for ; Tue, 3 Feb 2015 17:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966232AbbBCRPb (ORCPT ); Tue, 3 Feb 2015 12:15:31 -0500 Received: from mail-ob0-f172.google.com ([209.85.214.172]:46926 "EHLO mail-ob0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965676AbbBCRP2 (ORCPT ); Tue, 3 Feb 2015 12:15:28 -0500 Received: by mail-ob0-f172.google.com with SMTP id nt9so19952109obb.3; Tue, 03 Feb 2015 09:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZgRqhGw3O0uHtQ+PN48TiYNhh1DFsDqvg1HzxTWQs6k=; b=lTSqUOkSBEplAHhT1ghD8mS0ykRCHK15gHlV1iWHoGh6U/SBTTXAVxSry86yRh4Anh FWuVySGWW+tB7XNKOsOGzZHC5E2bjk6U22sAKZ2My6/REls1kc2kux7cZVWc6mRPLycF cm5AjST9ZVNfL/+qYi5IBqIHXSu3ss+yJpZ/AROZVNk9FuCg/tnQh+WasE8WKKte3W71 6j6QsROfnpsn9dHevQqupU9wYW8Zw/ZP9K4fpZypooH/KgABO+wSLm9oMCpo1TTdPYBy 5PSkviPKh8BRL9ZvVTFsJHUdivaV1fgRrbQKFiVV/j844/sSgJ2eQq0yVN3VSoNsPdp0 T31g== X-Received: by 10.182.28.196 with SMTP id d4mr16480260obh.66.1422983727643; Tue, 03 Feb 2015 09:15:27 -0800 (PST) Received: from linux.site ([69.76.245.152]) by mx.google.com with ESMTPSA id rt10sm11183286obb.7.2015.02.03.09.15.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Feb 2015 09:15:27 -0800 (PST) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Larry Finger , Stable Subject: [PATCH RESEND 2/2] rtlwifi: rtl8192ee: Fix problems with calculating free space in FIFO Date: Tue, 3 Feb 2015 11:15:18 -0600 Message-Id: <1422983718-21432-3-git-send-email-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422983718-21432-1-git-send-email-Larry.Finger@lwfinger.net> References: <1422983718-21432-1-git-send-email-Larry.Finger@lwfinger.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This driver utilizes a FIFO buffer for RX descriptors. There are four places in the code where it calculates the number of free slots. Several of those locations do the calculation incorrectly. To fix these and to prevent future mistakes, a common inline routine is created. Signed-off-by: Larry Finger Cc: Stable [V3.18] --- drivers/net/wireless/rtlwifi/pci.h | 7 +++++++ drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 9 +-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h index 5e83230..d4567d1 100644 --- a/drivers/net/wireless/rtlwifi/pci.h +++ b/drivers/net/wireless/rtlwifi/pci.h @@ -325,4 +325,11 @@ static inline void pci_write32_async(struct rtl_priv *rtlpriv, writel(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); } +static inline u16 calc_fifo_space(u16 rp, u16 wp) +{ + if (rp <= wp) + return RTL_PCI_MAX_RX_COUNT - 1 + rp - wp; + return rp - wp - 1; +} + #endif diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c index 1245e2f..d39ee67 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c @@ -499,14 +499,7 @@ u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw, u8 queue_index) if (!start_rx) return 0; - if ((last_read_point > (RX_DESC_NUM_92E / 2)) && - (read_point <= (RX_DESC_NUM_92E / 2))) { - remind_cnt = RX_DESC_NUM_92E - write_point; - } else { - remind_cnt = (read_point >= write_point) ? - (read_point - write_point) : - (RX_DESC_NUM_92E - write_point + read_point); - } + remind_cnt = calc_fifo_space(read_point, write_point); if (remind_cnt == 0) return 0;