Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2786812ybi; Thu, 4 Jul 2019 19:29:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRcsLPg0BrWm2xOTTUqC4ah56dvJxFYBZPG2meR/6p1wRWhpATaNm+fw/oPOdoGVJSJR4O X-Received: by 2002:a17:902:6b02:: with SMTP id o2mr1470150plk.99.1562293779942; Thu, 04 Jul 2019 19:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562293779; cv=none; d=google.com; s=arc-20160816; b=dVq0z1ENZjtu9PvCDqL9hmtPX+CkLmLQllPlMvpaIu6Jnjw40dkxsri5O8wJjC5WXT lbajPGKPIxdTXbLhbeAhdVp/GaFYVvVIFVgmF41tW5RskjqQC70gP/5PoDZ9NfxD2uCI vI+2mWzqdbFrhrP0wG5/YX9uVldBpfvlYQUaZGU9b54lvKmGWtNhYJ/zIjKTkvJ8RV7R NquVbjkBypa45QcW0EzeK9MpfqfreGcfd7Gq3OzxbaFcE1mxK+wSrvryoImdSAEN8PnX IJC0i5CyDabhpCR0cWQPKfLM3S/uatmSXjWe17aSe5wK9+l23VFXQt6stjgdxcnmY/3k 3TZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=O5KZM3VrT8RC6G2toh1ISaY4NA4LnxOKM8Y2rCcQe00=; b=oD+VfmHjudIGPTze51zUw6F5bp8kse6MeUFBr4uExedELZz2VUcSfcoH8J+wfZL+CD sKiq5nvqG3xQeJPQCjxKWysdF9zXw9NFYGjcKrhow6eHQEa37BmgewKdIZw5ha80AbhC MPYarfrSQvhXYp/msGSb5GyOgYys4J5K7rDEyGY45alYnmxHVBxCV5ccrMvko0XLsf7j t0KLiXJ7kSeoKNVOWHYkExjvuhqaaGjUEb2lCb5ARnIyqowvaxRbvIxqfpql53tbZQ2C zkGMbhuMRnon5xJjfCCyeu3DmdSOV+QTzdLoat4ccnAgm8+KNnvDa33QUDA6yz6BM+hh kH2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=v7bzRvkK; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 u19si7161421pgb.148.2019.07.04.19.29.12; Thu, 04 Jul 2019 19:29:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=v7bzRvkK; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727533AbfGEC1Q (ORCPT + 99 others); Thu, 4 Jul 2019 22:27:16 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33311 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727313AbfGEC1P (ORCPT ); Thu, 4 Jul 2019 22:27:15 -0400 Received: by mail-qt1-f195.google.com with SMTP id h24so9802551qto.0 for ; Thu, 04 Jul 2019 19:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O5KZM3VrT8RC6G2toh1ISaY4NA4LnxOKM8Y2rCcQe00=; b=v7bzRvkK8e6Z351NmC9om4MYfvAA5AAzqAxRqT7y5gRpXBfM9kWjSkzep04nq69Ygy 2LtMeN45mT8nePK9RETcMlaEiwCnnO6jWsbpuXaw314ks+sFIctzRp1vnNAbXYSKGlHW vnwRSluLevcfklbnV323d7Cp4xUwjgbZxNcgCMH84bqDRgTcSzyoLLDjsvLB82M5HD0x 76518+07Yuf1y1QPkS/bi8jIQLCkTPONMbqvMfgwf+SV+6m+rH11j9zPFc+cPDBz3p9W aRV3e2p99tTnNCY0q50e14jsABC9YnM3fa+7456EETLL4LFHNikpw5yiaI5n+WzX8WAp Nn1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O5KZM3VrT8RC6G2toh1ISaY4NA4LnxOKM8Y2rCcQe00=; b=mxE28jzcEOuVI+NteM6H5tfQVPoroKvfKT5bNUPRGry8wHt5l+KCyJVdYeUTCYWdmc vW/aCvfTr+BLVZUpTXh6P63ug/ZQN5CCf1cxdqW7dkfOBhLF4M0qUVrtT5wPaaDUU/vR zt8RkUZHuIeD8F7/FGmlee8CBkLDo0s9yyjAV4dXkUSxL/FPTrKGrnmHhoFQFYIaf3jW 0sLzZ+XJTvR9z86gLBanepdCviCeQEWYttt8Fcx5r4dtpri8M5GvEuuDmcvIfCgHUUSf UiNdmkh7l6LR7pgL4utPJSiLvdITAig1xr2Qakc8GvJCuYUMPJ6yfZCenkeOwIwPM9C9 gREQ== X-Gm-Message-State: APjAAAXVsIeaIuxGvn2yuvLQben7TkHpcmpyrvuiQy4WW31i78hWifG4 Wr1G2Tz9y4I88AyzkwbnSGmtw3SxEoQRp1yHNJbH3w== X-Received: by 2002:a0c:95a2:: with SMTP id s31mr1198547qvs.120.1562293634851; Thu, 04 Jul 2019 19:27:14 -0700 (PDT) MIME-Version: 1.0 References: <20190704105528.74028-1-chiu@endlessm.com> <8f1454ca-4610-03d0-82c4-06174083d463@gmail.com> In-Reply-To: <8f1454ca-4610-03d0-82c4-06174083d463@gmail.com> From: Chris Chiu Date: Fri, 5 Jul 2019 10:27:03 +0800 Message-ID: Subject: Re: [PATCH v2] rtl8xxxu: Fix wifi low signal strength issue of RTL8723BU To: Jes Sorensen Cc: Kalle Valo , David Miller , linux-wireless , netdev , Linux Kernel , Linux Upstreaming Team Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, Jul 5, 2019 at 12:43 AM Jes Sorensen wrote: > > On 7/4/19 6:55 AM, Chris Chiu wrote: > > The WiFi tx power of RTL8723BU is extremely low after booting. So > > the WiFi scan gives very limited AP list and it always fails to > > connect to the selected AP. This module only supports 1x1 antenna > > and the antenna is switched to bluetooth due to some incorrect > > register settings. > > > > Compare with the vendor driver https://github.com/lwfinger/rtl8723bu, > > we realized that the 8723bu's enable_rf() does the same thing as > > rtw_btcoex_HAL_Initialize() in vendor driver. And it by default > > sets the antenna path to BTC_ANT_PATH_BT which we verified it's > > the cause of the wifi weak tx power. The vendor driver will set > > the antenna path to BTC_ANT_PATH_PTA in the consequent btcoexist > > mechanism, by the function halbtc8723b1ant_PsTdma. > > > > This commit hand over the antenna control to PTA(Packet Traffic > > Arbitration), which compares the weight of bluetooth/wifi traffic > > then determine whether to continue current wifi traffic or not. > > After PTA take control, The wifi signal will be back to normal and > > the bluetooth scan can also work at the same time. However, the > > btcoexist still needs to be handled under different circumstances. > > If there's a BT connection established, the wifi still fails to > > connect until BT disconnected. > > > > Signed-off-by: Chris Chiu > > --- > > > > > > Note: > > v2: > > - Replace BIT(11) with the descriptive definition > > - Meaningful comment for the REG_S0S1_PATH_SWITCH setting > > > > > > drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 11 ++++++++--- > > drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 ++- > > 2 files changed, 10 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > > index 3adb1d3d47ac..ceffe05bd65b 100644 > > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c > > @@ -1525,7 +1525,7 @@ static void rtl8723b_enable_rf(struct rtl8xxxu_priv *priv) > > /* > > * WLAN action by PTA > > */ > > - rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x04); > > + rtl8xxxu_write8(priv, REG_WLAN_ACT_CONTROL_8723B, 0x0c); > > > > /* > > * BT select S0/S1 controlled by WiFi > > @@ -1568,9 +1568,14 @@ static void rtl8723b_enable_rf(struct rtl8xxxu_priv *priv) > > rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.ant_sel_rsv)); > > > > /* > > - * 0x280, 0x00, 0x200, 0x80 - not clear > > + * Different settings per different antenna position. > > + * Antenna Position: | Normal Inverse > > + * -------------------------------------------------- > > + * Antenna switch to BT: | 0x280, 0x00 > > + * Antenna switch to WiFi: | 0x0, 0x280 > > + * Antenna switch to PTA: | 0x200, 0x80 > > */ > > - rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x00); > > + rtl8xxxu_write32(priv, REG_S0S1_PATH_SWITCH, 0x80); > > Per the documentation, shouldn't this be set to 0x200 then rather than 0x80? > Per the code before REG_S0S1_PATH_SWITCH setting, the driver has told the co-processor the antenna is inverse. memset(&h2c, 0, sizeof(struct h2c_cmd)); h2c.ant_sel_rsv.cmd = H2C_8723B_ANT_SEL_RSV; h2c.ant_sel_rsv.ant_inverse = 1; h2c.ant_sel_rsv.int_switch_type = 0; rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.ant_sel_rsv)); At least the current modification is consistent with the antenna inverse setting. I'll verify on vendor driver about when/how the inverse be determined. Chris > We may need to put in place so > > Cheers, > Jesme code to detect whether we have normal > or inverse configuration of the dongle otherwise? > > I really appreciate you're digging into this!