From patchwork Mon Feb 5 18:38:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 10201247 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 918DA6056A for ; Mon, 5 Feb 2018 18:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 804E028727 for ; Mon, 5 Feb 2018 18:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71B2E24B44; Mon, 5 Feb 2018 18:38:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_BLACK autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC5124B44 for ; Mon, 5 Feb 2018 18:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753529AbeBESiZ (ORCPT ); Mon, 5 Feb 2018 13:38:25 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:44048 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753956AbeBESiR (ORCPT ); Mon, 5 Feb 2018 13:38:17 -0500 Received: by mail-ot0-f193.google.com with SMTP id l5so21693955otj.11; Mon, 05 Feb 2018 10:38:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=7ebygFiHyrvkYUxF5xVwH75+3xh3sIYVfvQfeEM1T9M=; b=vIWmJ4eS0U5+vWfbY3cBKr/z3xiaKLF8Sf9aUsqxakrALvqDoycnKRsvq30EM2wtoE VeRCS3RWD49jO/03zwaFft8NChhdzk/0S0mM6btMjzZRYG4MzcsA/9+7fpYMO7ELtMRI I496RTdlC9/emmab1+pNGzK9urrsxomOanXJc5HA1fQvI/XUoxcch91Dis6XhinPBQL8 LZBAdWzW6M9Q75Y71A4++1JwCLH0MFRkO+w71kBj5JA7rOXGX1Dps5w18DpJyoWtWc/s jBPaajg3i8hF3O/DU+HgRiYz3JE6qO687jabf91MO96SFC1cAELT5Kik0KRzXtTwmEWO E3ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=7ebygFiHyrvkYUxF5xVwH75+3xh3sIYVfvQfeEM1T9M=; b=YIub0Qi9PXbM2FfXgPX+0yjKi1JVZjQ3Ztr1A3v0fHvm/Aoz66JcdrzrIbyx2nBANk feQwNkhKxRHZOBDzronGxeQ9rtdlj+3+gz4kgFfSfE0c27I8cEAkmrWtKRce6hX0hVDr lWmzS9ajc5QE1xatx7uHtYJCqnAFvwHnD4g4BgBEPIwRAf+gmspvvXPiYRpTiWL7PmGv EO6NxyizF8L73hgL7SDIf/NMPdpmbep25XsdQqcr9b6K0OKG1vsH4YYtI+kmYlucbr93 v2+t6noQ/r5+MqQz1ypR5rlvfLvlFxccwjAC1lzC1hg6zbQmIlIw6jgE3j3QW+6fZTxT C6Nw== X-Gm-Message-State: AKwxytd9PrOE53SCy3oaZQUhO9IHkwbRaoWQimnFmw4zqjrBYpUdps2r igeruzbUeqSfcCVLICCZxNbleA== X-Google-Smtp-Source: AH8x2266j39Txpfwhf0b/yIJctonB8JU4TwMEHyHJDyxzPJ18L0PP6dpoEFrET8fADEslbSK2LH2rA== X-Received: by 10.157.31.112 with SMTP id x45mr17822694otx.248.1517855896361; Mon, 05 Feb 2018 10:38:16 -0800 (PST) Received: from Larrylap.localdomain (cpe-24-31-251-255.kc.res.rr.com. [24.31.251.255]) by smtp.gmail.com with ESMTPSA id k32sm4913393otb.69.2018.02.05.10.38.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 10:38:15 -0800 (PST) From: Larry Finger To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, Larry Finger , Stable Subject: [PATCH] rtlwifi: rtl8821ae: Fix connection lost problem correctly Date: Mon, 5 Feb 2018 12:38:11 -0600 Message-Id: <20180205183811.19526-1-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.16.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There has been a coding error in rtl8821ae since it was first introduced, namely that an 8-bit register was read using a 16-bit read in _rtl8821ae_dbi_read(). This error was fixed with commit 40b368af4b75 ("rtlwifi: Fix alignment issues"); however, this change led to instability in the connection. To restore stability, this change was reverted in commit b8b8b16352cd ("rtlwifi: rtl8821ae: Fix connection lost problem"). Unfortunately, the unaligned access causes machine checks in ARM architecture, and we were finally forced to find the actual cause of the problem on x86 platforms. Following a suggestion from Pkshih , it was found that increasing the ASPM L1 latency from 0 to 7 fixed the instability. This parameter was varied to see if a smaller value would work; however, it appears that 7 is the safest value. A new symbol is defined for this quantity, thus it can be easily changed if necessary. Fixes: b8b8b16352cd ("rtlwifi: rtl8821ae: Fix connection lost problem") Cc: Stable # 4.14+ Fix-suggested-by: Pkshih Signed-off-by: Larry Finger Tested-by: James Cameron # x86_64 OLPC NL3 --- Kalle, This patch should be submitted to 4.16. Larry --- drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c | 5 +++-- drivers/net/wireless/realtek/rtlwifi/wifi.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c index f20e77b4bb65..317c1b3101da 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c @@ -1123,7 +1123,7 @@ static u8 _rtl8821ae_dbi_read(struct rtl_priv *rtlpriv, u16 addr) } if (0 == tmp) { read_addr = REG_DBI_RDATA + addr % 4; - ret = rtl_read_word(rtlpriv, read_addr); + ret = rtl_read_byte(rtlpriv, read_addr); } return ret; } @@ -1165,7 +1165,8 @@ static void _rtl8821ae_enable_aspm_back_door(struct ieee80211_hw *hw) } tmp = _rtl8821ae_dbi_read(rtlpriv, 0x70f); - _rtl8821ae_dbi_write(rtlpriv, 0x70f, tmp | BIT(7)); + _rtl8821ae_dbi_write(rtlpriv, 0x70f, tmp | BIT(7) | + ASPM_L1_LATENCY << 3); tmp = _rtl8821ae_dbi_read(rtlpriv, 0x719); _rtl8821ae_dbi_write(rtlpriv, 0x719, tmp | BIT(3) | BIT(4)); diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h index 1c9ed28b42da..4f48b934ec01 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -99,6 +99,7 @@ #define RTL_USB_MAX_RX_COUNT 100 #define QBSS_LOAD_SIZE 5 #define MAX_WMMELE_LENGTH 64 +#define ASPM_L1_LATENCY 7 #define TOTAL_CAM_ENTRY 32