From patchwork Tue Feb 27 12:18:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 776438 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30FFD13B28E for ; Tue, 27 Feb 2024 12:18:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036306; cv=none; b=Ftf+EwaUlQJRfFMqVK5N5Cm1dtymCMl+vRYL4m10bIorn+gXAd/kKGb0eAhLu+PmgrGsxGTRCFqlI7iHTA8HAze0ROvoEeeqtq2VyX3NV0N/LgEG612SaD3xJu0C6hsZHaXL3sOSPmzxl9bfYGt7R9ikU7Kc5R334l1S6k5fITg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036306; c=relaxed/simple; bh=dDp/qw2ylsyt0/DErKDJpw/jlFxVReNwnvYsSO2nDd8=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:Content-Type; b=t9x4og24DVCgdPNtjOdZ8d4kC8SbWC33vY14yWPBGP31i7VVuimJmEsmYZdtkV7chI1ZnfdmlJ79rm+2cRPadv/CHzNklChFCrUMa2E+bGOxM0I/RJqTO/xf3ov9qrpR8YnPcL8lc3quc9IW+L/bVtYgFaBod0bOvgsHJTjx3PM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lTipjWCn; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lTipjWCn" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5658082d2c4so5381679a12.1 for ; Tue, 27 Feb 2024 04:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709036302; x=1709641102; darn=vger.kernel.org; h=content-transfer-encoding:content-language:cc:to:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=C7rOwWhcPG8trPkhoq+V5n2+RCXcnonYxMv5l4SIdCc=; b=lTipjWCnK8sE/2OfxFAOaFIKFzz8ZlJivFkqOx4b++37eymU3Kok4DHkH8xf65Qn1P CdB7ibfRaQRYI/1os9ElLyx6OM68U3jG0DwKRtDs2kacQ/psd4j7yP0peq3BvoVj+s5k 408ratYLAdISktuD2q3kYdGMqBjJuAgYbc2SrDHJKtQ+ihsJVcjjQfR8lyFooNNMXkvf SPZF113Tq1S8h4x1GP2Xhl8R3s+nX++6FTCDm5JBUJjycWydYuwI03T68CUDnFlsUlg1 MV7aehSJBKewQt+qhNQwRT8D2nK2tzwMTAiYqE2kCdayPW5F6faF9b967KphMicR0ZQX 44sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709036302; x=1709641102; h=content-transfer-encoding:content-language:cc:to:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=C7rOwWhcPG8trPkhoq+V5n2+RCXcnonYxMv5l4SIdCc=; b=axuD/VdIVZz1dPVIUZNJsZIZq/wbyuJox778LZhQkvLKwcD5ZT1Q4fXbqh6sQfkQnF DseTcdel9mq4jDyZsSc0kwGA1flkuoTQHSLTIl8001jHZWih7N4/5E8Oz9qnXGoA/xEr OCQvh9WNV26eSLmgJykWu9eGoRGXN0CgdmZDh4f/vS7YjCTRaE0xhtSQzQPmzTnuW4Xl jclIIQHd2bD1RgnhZSnrfDI8osQ2Hk0FG5m22NxtklKTl58dGmP9KNBOkI4lrtQ25pG3 tqz4rbcp+ZEfFIf3QYfaiMiA9KAt3oNGhx53qYHdsfTeObPwT4BAUTM407H5pLnxIpzu G/hA== X-Gm-Message-State: AOJu0YzPaJOkxfOP6lk1y6zBBu2ZT0TIZp/YlzoMyLlUQZ4PNIWsGe0l j1xBDsHYxfNyhPeHN2EZ1lHh6jAdRp8e5pUg7gjes+jtpsnY+mSKmvJQYr9Q X-Google-Smtp-Source: AGHT+IFWXyuo8btriyrstLpHaSmpf43SfaM04ny0VcQYPeBYFB5/HpG0ePMqJ85oqfIWbnl5qktj5g== X-Received: by 2002:a05:6402:3587:b0:565:a607:6c31 with SMTP id y7-20020a056402358700b00565a6076c31mr7309350edc.12.1709036302349; Tue, 27 Feb 2024 04:18:22 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id dj16-20020a05640231b000b00566317ad834sm681406edb.49.2024.02.27.04.18.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 04:18:22 -0800 (PST) Message-ID: <731ea688-04ef-4f02-9d01-3e9026981057@gmail.com> Date: Tue, 27 Feb 2024 14:18:20 +0200 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Bitterblue Smith Subject: [PATCH 1/4] wifi: rtw88: 8821cu: Fix firmware upload fail To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer Content-Language: en-US RTL8822CU, RTL8822BU, and RTL8821CU need an extra register write after reading and writing certain addresses. Without this, the firmware upload fails approximately more than 50% of the time. Tested with RTL8811CU (Tenda U9 V2.0) which is the same as RTL8821CU but without Bluetooth. Fixes: a82dfd33d123 ("wifi: rtw88: Add common USB chip support") Signed-off-by: Bitterblue Smith Tested-by: Sascha Hauer --- drivers/net/wireless/realtek/rtw88/usb.c | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 3c4f28c306a9..ff01f7056ca9 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -33,6 +33,42 @@ static void rtw_usb_fill_tx_checksum(struct rtw_usb *rtwusb, rtw_tx_fill_txdesc_checksum(rtwdev, &pkt_info, skb->data); } +#define REG_ON_SEC 0x00 +#define REG_OFF_SEC 0x01 +#define REG_LOCAL_SEC 0x02 + +static void rtw_usb_reg_sec(struct rtw_dev *rtwdev, u32 addr, __le32 *data) +{ + struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); + struct usb_device *udev = rtwusb->udev; + u8 current_reg_sec; + u16 t_reg = 0x4e0; + u8 t_len = 1; + int status; + + if (addr < 0xFE00) { + if (addr <= 0xff) + current_reg_sec = REG_ON_SEC; + else if (0x1000 <= addr && addr <= 0x10ff) + current_reg_sec = REG_ON_SEC; + else + current_reg_sec = REG_OFF_SEC; + } else { + current_reg_sec = REG_LOCAL_SEC; + } + + if (current_reg_sec != REG_ON_SEC) + return; + + status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), + RTW_USB_CMD_REQ, RTW_USB_CMD_WRITE, + t_reg, 0, data, t_len, 500); + + if (status != t_len && status != -ENODEV) + rtw_err(rtwdev, "%s: reg 0x%x, usb write %u fail, status: %d\n", + __func__, t_reg, t_len, status); +} + static u32 rtw_usb_read(struct rtw_dev *rtwdev, u32 addr, u16 len) { struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); @@ -58,6 +94,11 @@ static u32 rtw_usb_read(struct rtw_dev *rtwdev, u32 addr, u16 len) rtw_err(rtwdev, "read register 0x%x failed with %d\n", addr, ret); + if (rtwdev->chip->id == RTW_CHIP_TYPE_8822C || + rtwdev->chip->id == RTW_CHIP_TYPE_8822B || + rtwdev->chip->id == RTW_CHIP_TYPE_8821C) + rtw_usb_reg_sec(rtwdev, addr, data); + return le32_to_cpu(*data); } @@ -111,6 +152,11 @@ static void rtw_usb_write(struct rtw_dev *rtwdev, u32 addr, u32 val, int len) if (ret < 0 && ret != -ENODEV && count++ < 4) rtw_err(rtwdev, "write register 0x%x failed with %d\n", addr, ret); + + if (rtwdev->chip->id == RTW_CHIP_TYPE_8822C || + rtwdev->chip->id == RTW_CHIP_TYPE_8822B || + rtwdev->chip->id == RTW_CHIP_TYPE_8821C) + rtw_usb_reg_sec(rtwdev, addr, data); } static void rtw_usb_write8(struct rtw_dev *rtwdev, u32 addr, u8 val) From patchwork Tue Feb 27 12:19:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 776861 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 587F0145B3D for ; Tue, 27 Feb 2024 12:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036362; cv=none; b=e3Mj6OmIYsRNgcpRZ2Hai+d1CTs9IOmFxAyEfpOi+oVeMv8l2+hr1TPG8xRu9Cf1D+1lo6hkIHi5bztXZlRijBNOw7Zg/4s20HUs9QB66EPiHXpf7q+Y7gnzfaoHEGX90XSi8RVqv/ZVshUnXH2+IIEF3MovFhIOaJbHKb2UJxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036362; c=relaxed/simple; bh=BuQblpNofFIXtFSoVAR2IqO+QKBFrm+5UqSx6NOMM7I=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=jqRznN4l2FfDP7kk2aA91gV6XXEw2AACw2IKXezt+w7x8d3+rYxvoAtUE+uOJb5uM9/T/braPn/hqpkx70CvkRg2+o6FvblfmiQW1gWRzCEPDw8GmvXLJsFSbJwdov7MHG+t2FUcdv39EGqX3ye69xLKPrtjVTYmRc+5l+3iOyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c77viuDl; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c77viuDl" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-513031ce058so1237590e87.1 for ; Tue, 27 Feb 2024 04:19:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709036358; x=1709641158; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=E/wiSc2z1aN/zk1ViOrhWJAnNttJ2qgcDzL0//7StTs=; b=c77viuDlynL2FWQc9R03/OMO81p+hZM5cBZNrU2PbjyMSNPeexAYrbDonX/1F/g1Cw 8ZBvIziNRpate/n/dJ714vlPyg/BbTcGldViE7Ynn1cWKBHvqCYKxKMgJgr9Ho7XCeNh 5v8hOOBs67g9fRWMB/VuBPnyF2JE+ajua0CAgbK7qtB0QBrC3dVtvxGGihkFcxrpKixm pRXwRqtGMZ1NRsoMwK9fUzGKA90sXhWX4WoY3pDcMxxLSkcn/qB7XFi3PhDhjYZ5xT+G ObcCqN5efF5cVG/sXDmFJkmo+qILX077cyCom6L+AvO0M0LicEw6gRpGG40reTLV5evi NFcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709036358; x=1709641158; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E/wiSc2z1aN/zk1ViOrhWJAnNttJ2qgcDzL0//7StTs=; b=rNkBBGWlVepJtj+TwxO7rRVp2NhMEBDyB0Vpmcy0/hVh/Uz9pcuIUmQ+CnsI+vTS2L kzGH247E4BuS8jNJCeXZYprpIIwBH7Sd9d3pSY8bHZWjVNt8AfkW8n9wpMfMRCznUe3Z nujtRHS0o9kqY1/AFrQmr8cA3Mhp97gCkN4+eATETsm9sughHopdA8VnKFb8xEAO95LJ k5sDfzg+CAplrN1qZUFeUxuWKjLwliwTswb2empBQ02Jcl6S7v8gtFzWklNxQXET+RQL FCmaC1DyQANRqKMGwTGc6BT7sMXW9PLotWd1Y+5Fd0zO3CnrJqbUjFIW17x5kc0MJlkG izuQ== X-Gm-Message-State: AOJu0Yx19AHI4/v8J8vtKf0V/bw0CtCfIxo02rqIEosxNZ+T/5hIZlXG zvNsseLYjhBM3OSPyJdzxGR260IDqUHPGxs9ccKD1yGW24Yb3WmF521sqP8C X-Google-Smtp-Source: AGHT+IG4SCMGqbTXJnpi3xk27DeNK4mIe+TUyAzAmJo7cjR5mY1nzu2t2gggz04LG7pEqACP6XN78g== X-Received: by 2002:ac2:4204:0:b0:513:1169:af0a with SMTP id y4-20020ac24204000000b005131169af0amr609229lfh.11.1709036358262; Tue, 27 Feb 2024 04:19:18 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id dj16-20020a05640231b000b00566317ad834sm681406edb.49.2024.02.27.04.19.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 04:19:17 -0800 (PST) Message-ID: <8770f25c-1dcb-48c6-9279-cd6de158dfec@gmail.com> Date: Tue, 27 Feb 2024 14:19:17 +0200 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Bitterblue Smith Subject: [PATCH 2/4] wifi: rtw88: 8821cu: Fix connection failure To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: <909d9f75-44cd-4710-9d3f-56691fd58090@gmail.com> Content-Language: en-US In-Reply-To: <909d9f75-44cd-4710-9d3f-56691fd58090@gmail.com> Clear bit 8 of REG_SYS_STATUS1 after MAC power on. Without this, some RTL8821CU and RTL8811CU cannot connect to any network: Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed out The RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips. Tested with RTL8811CU (Tenda U9 V2.0). Signed-off-by: Bitterblue Smith --- drivers/net/wireless/realtek/rtw88/mac.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/mac.c b/drivers/net/wireless/realtek/rtw88/mac.c index 298663b03580..a3b2c57c5503 100644 --- a/drivers/net/wireless/realtek/rtw88/mac.c +++ b/drivers/net/wireless/realtek/rtw88/mac.c @@ -309,6 +309,14 @@ static int rtw_mac_power_switch(struct rtw_dev *rtwdev, bool pwr_on) pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; ret = rtw_pwr_seq_parser(rtwdev, pwr_seq); + if (pwr_seq == chip->pwr_on_seq && + rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB) { + if (chip->id == RTW_CHIP_TYPE_8822C || + chip->id == RTW_CHIP_TYPE_8822B || + chip->id == RTW_CHIP_TYPE_8821C) + rtw_write8_clr(rtwdev, REG_SYS_STATUS1 + 1, BIT(0)); + } + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO) rtw_write32(rtwdev, REG_SDIO_HIMR, imr); From patchwork Tue Feb 27 12:20:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 776437 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C600213A267 for ; Tue, 27 Feb 2024 12:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036405; cv=none; b=YiyI9fGqAidv6RZqWeQ7ucFQsFHH9Xr1/eb27tC6/dxMBsnpnIUReRhGm+EEIaJ3Gpwmcy7cc9wn9BujcnnErVEOWZbhOaKRG22tcguXk0w+isSL9N683WFmNEtr7TLRd/rkqmd75ZP11njHV+S6juFbot4s2287RCjdIU5oUxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036405; c=relaxed/simple; bh=nW7KXEEaLCPfga26i7X3zXuzpsGSjvE7OjE+DTRQwCA=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=RS0lwqpy7gDMrE8KsjjehE+ARcuRITpaSF2y6qDn80tHS9Jb4yrS7m2gXcy06J2boWN1wcBh+8WVpJQvsTE0+F5tSJdK62sepu5499JoLFRW2vZnxHG2tU1D2+tJPMrFJCSaBnK27WOKvS1tlQLC9Qtq7AVWFahAqIgntOUfUfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m1P7k4Sa; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m1P7k4Sa" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-512e39226efso5645832e87.0 for ; Tue, 27 Feb 2024 04:20:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709036402; x=1709641202; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=tCkFfO9aYHHRUW7DIEQwtmcVQre/CtrWWgRSQ2n8UI4=; b=m1P7k4Saj90GjjDGsTxc1G9phx47OMnasHUgz78MjNCEi3cEWHslgeHhXW4vs/YzWz x/6z3l4PvyqkWWasgq7T0+0W1dbXt6pxsmYEFGsIIG0g0bTDqgwNcVOmhjK9UIliYlnQ OhF6COAUG/LwuiTk5URC3QXKoOf3kOO6DHtCqs5j8sqgj3RhObTJZQ6PMbPYzTPZjhSq PxMMmfJ8HVNW/0y7WGj99gkpLfKX0GCPqzRT36Qa77yujOCLQYCHyHOxCzZmVRY47ftn AEB6S2YThQ5bsVEMG7pjagS+QyqX8Wz5T+ovNYpC1E+5BJBek7kKLeqoV5EprAVOSL7G 9edg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709036402; x=1709641202; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tCkFfO9aYHHRUW7DIEQwtmcVQre/CtrWWgRSQ2n8UI4=; b=T01fHXBQATC8T7prJI/VV4WFlGdzVHJXHww+p1qMh8whZeZrrkW7EIMawiSHMzjt+K 0ltwCKleTJmCMvxBO/y5yM7jkaZD1aMjJDHwqmZjXkkcWrvbRzR9skfV9JAZVwhkuHgA OOtGtOotWxNPKwfF63kLJOC8xTjNimSGo+zR5iExdhvVb1MGN+rpJqDWr9iYXHYrDG4h qKFe1bpgtzhkbNc4IlnmfQYcqPSCo7H71B1B1hNUQUB3LgLGOWg2XRGROcVRlzNDlaD2 9DJCZdhiY+2O214ficoOLS0R6taorERSoQmqbKw8vLs5mUXuPevZvzxy2oKrSzwnROOK z4gg== X-Gm-Message-State: AOJu0YwOZ8cCWRIeUaOVYWEZ4NHwN4jGY2t+EOB5EqghyTCSw7MT8fAT /PDiMmcaKihid+FszwVkEhCII5ClwUgBIi8Zd12MJXz2L+rFxqQXjMCvM2HJ X-Google-Smtp-Source: AGHT+IEYjmwbCD/f+oguUQl5OFl4mTGpmhJACRw0GkIX10M7+gHY6l8vczA16QhqHyqMORuqsDc5ig== X-Received: by 2002:a05:6512:38c5:b0:511:4253:3a8b with SMTP id p5-20020a05651238c500b0051142533a8bmr6076053lft.42.1709036401715; Tue, 27 Feb 2024 04:20:01 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id dj16-20020a05640231b000b00566317ad834sm681406edb.49.2024.02.27.04.20.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 04:20:01 -0800 (PST) Message-ID: Date: Tue, 27 Feb 2024 14:20:01 +0200 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Bitterblue Smith Subject: [PATCH 3/4] wifi: rtw88: 8821c: Fix beacon loss and disconnect To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih References: <909d9f75-44cd-4710-9d3f-56691fd58090@gmail.com> Content-Language: en-US In-Reply-To: <909d9f75-44cd-4710-9d3f-56691fd58090@gmail.com> Tenda U9 V2.0, which contains RTL8811CU, is practically unusable because of frequent disconnections: Feb 23 14:46:45 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:46:46 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1 Feb 23 14:46:52 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-CONNECTED - Connection to 90:55:de:__:__:__ completed [id=0 id_str=] Feb 23 14:46:54 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:46:55 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1 Feb 23 14:47:01 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-CONNECTED - Connection to 90:55:de:__:__:__ completed [id=0 id_str=] Feb 23 14:47:04 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-BEACON-LOSS Feb 23 14:47:05 ideapad2 wpa_supplicant[427]: wlp3s0f3u2: CTRL-EVENT-DISCONNECTED bssid=90:55:de:__:__:__ reason=4 locally_generated=1 This is caused by a mistake in the chip initialisation. This version of the chip requires loading an extra AGC table right after the main one, but the extra table is being loaded at the wrong time. Move the extra AGC table loading to the right place. Fixes: 5d6651fe8583 ("rtw88: 8821c: support RFE type2 wifi NIC") Signed-off-by: Bitterblue Smith Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw88/main.c | 2 -- drivers/net/wireless/realtek/rtw88/phy.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 6d22628129d0..ffba6b88f392 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -2032,8 +2032,6 @@ static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev) rtw_phy_setup_phy_cond(rtwdev, hal->pkg_type); rtw_phy_init_tx_power(rtwdev); - if (rfe_def->agc_btg_tbl) - rtw_load_table(rtwdev, rfe_def->agc_btg_tbl); rtw_load_table(rtwdev, rfe_def->phy_pg_tbl); rtw_load_table(rtwdev, rfe_def->txpwr_lmt_tbl); rtw_phy_tx_power_by_rate_config(hal); diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c index 128e75a81bf3..37ef80c9091d 100644 --- a/drivers/net/wireless/realtek/rtw88/phy.c +++ b/drivers/net/wireless/realtek/rtw88/phy.c @@ -1761,12 +1761,15 @@ static void rtw_load_rfk_table(struct rtw_dev *rtwdev) void rtw_phy_load_tables(struct rtw_dev *rtwdev) { + const struct rtw_rfe_def *rfe_def = rtw_get_rfe_def(rtwdev); const struct rtw_chip_info *chip = rtwdev->chip; u8 rf_path; rtw_load_table(rtwdev, chip->mac_tbl); rtw_load_table(rtwdev, chip->bb_tbl); rtw_load_table(rtwdev, chip->agc_tbl); + if (rfe_def->agc_btg_tbl) + rtw_load_table(rtwdev, rfe_def->agc_btg_tbl); rtw_load_rfk_table(rtwdev); for (rf_path = 0; rf_path < rtwdev->hal.rf_path_num; rf_path++) { From patchwork Tue Feb 27 12:20:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 776860 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB3413AA3C for ; Tue, 27 Feb 2024 12:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036458; cv=none; b=LKsj0vMBDpXH5jI4s5rfkgvbKbVp+KPunr2m+/blbyq8CCf1jGEU5bI8OAp5kBs3IRd9JU9KtvA8kzhvw5IQwDeNruIEyv+F86/lpzPMhIizUhAtPzaX8ZUsdqPLrZnvav3lErZ1aWX4bV79BFXOmuztD33+FkCa6AfkURhbrIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036458; c=relaxed/simple; bh=hlmUwANRaFaAu1C9VuTwPmQEJFuTEkK3YbaG7alhduE=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=Bh+dKmcY3ThA9jgPfo7eKa7KcLKcckJOiI9kscNiEeCA8l8ZxLC1mf53xA8uT1GtggWRlLJuqx/K2r0xSbEeYlATvJHSDeYi6wixxZImH+gJnLePDzYoEddtw4q2kbN2UAnyunMoT+pEKIOJqtJ3HZJOpVgqc5NmuIi815nt+jQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JDyAz7Wr; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JDyAz7Wr" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-563c403719cso5209737a12.2 for ; Tue, 27 Feb 2024 04:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709036455; x=1709641255; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=wfMeJBjMkIyQXwN/Pu/ck+cMnJNHg5FKeK4s9gmkheg=; b=JDyAz7WrGqaeP0PlghqXcC76SpYzEpbrjbShUOCJc1dLTk/Ava9/ku70X277GuEqPz lclPbexRZbaYazOXqb3v1TrvlnKHKCNaOZyBhahBpcOhsG0YN+rE31v5AhNohh8eE5nj SqETi1EGzV4sApFNS3X63aUcKQiuFz8OW5am1AFXPJvCcL4s719FKf81u/m9cwl6x3uQ Yf1RiblynAIZ2R9dfEN/+550p907QdpdfArlJFlLHwIQfOHmZqPwkRQerxDRHzat62WY O73hZIVnJKZbTSGVumehmIDKP+9AiS3NDl+EeZ1VtcIWmihsISUbx940IumY3WELqNLU HeDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709036455; x=1709641255; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wfMeJBjMkIyQXwN/Pu/ck+cMnJNHg5FKeK4s9gmkheg=; b=vc1USUvRIwK99gGSJWacG7LuRgg0sJ+j3ATUp2+fKonZQVolV5W1wMpVOpEzAJA3YG WaVtdxwbNxY4gBXZGeD4W9l5R4jeP+uNk1cubTg7aY47oEwOFRUmzKsUe2qOSMDwEbe+ AuwuUWfkN0KjpW7yWn9goBhHWRccVABm76/4UV9I0J3lSGly+kRoO3/LkMMAtax2/FUw NcDmy9hfM8tfGHW9ZrjrlatXZPeqSM2VBOxenZSO0jqHvgFXVi9R+CRyb7PZWvgZ6swc 16aKz1ZfZTnowFfXP+y3lM4LHEcXtQ0IIBD3FYWD4cbWwdGkq9oky4SaFFvLVqOOrLd2 uCCQ== X-Gm-Message-State: AOJu0Yymm002ad/1YdP33LnjqQ1GGRJ0CBRqp07UQeqDj1vtenxReLDx thK51NMLh1WnbXkEcKkwZKOu7K2OabsRRPS+OZOwq50lB8FZZwDmqXLqktWK X-Google-Smtp-Source: AGHT+IEe9ide8wgiPm2EetIvl406fr/+f/2WjWrNGUNTCjJZjGyj6G00Hx+A50zD+kqCfQAfAhhhrQ== X-Received: by 2002:a05:6402:14d4:b0:565:dce3:670c with SMTP id f20-20020a05640214d400b00565dce3670cmr3702976edx.41.1709036454992; Tue, 27 Feb 2024 04:20:54 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id dj16-20020a05640231b000b00566317ad834sm681406edb.49.2024.02.27.04.20.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 04:20:54 -0800 (PST) Message-ID: <38e3d94e-0cab-4a43-be10-c15ff5387919@gmail.com> Date: Tue, 27 Feb 2024 14:20:54 +0200 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Bitterblue Smith Subject: [PATCH 4/4] wifi: rtw88: 8821c: Fix false alarm count To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih References: <909d9f75-44cd-4710-9d3f-56691fd58090@gmail.com> Content-Language: en-US In-Reply-To: <909d9f75-44cd-4710-9d3f-56691fd58090@gmail.com> Make dm_info->total_fa_cnt the sum of cck_fa_cnt and ofdm_fa_cnt, not just ofdm_fa_cnt. Fixes: 960361238b86 ("rtw88: 8821c: add false alarm statistics") Signed-off-by: Bitterblue Smith Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index 429bb420b056..fe5d8e188350 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -773,9 +773,9 @@ static void rtw8821c_false_alarm_statistics(struct rtw_dev *rtwdev) dm_info->cck_fa_cnt = cck_fa_cnt; dm_info->ofdm_fa_cnt = ofdm_fa_cnt; + dm_info->total_fa_cnt = ofdm_fa_cnt; if (cck_enable) dm_info->total_fa_cnt += cck_fa_cnt; - dm_info->total_fa_cnt = ofdm_fa_cnt; crc32_cnt = rtw_read32(rtwdev, REG_CRC_CCK); dm_info->cck_ok_cnt = FIELD_GET(GENMASK(15, 0), crc32_cnt);