From patchwork Thu Feb 29 22:32:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 777422 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 24EC71E531 for ; Thu, 29 Feb 2024 22:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709245971; cv=none; b=umdk5pLjpNGd+mnINAbvPY528eBDF8sC/1d6aASQgrdbsluOukqIek1kBhk5H9ShPVRXzznBCxZRmWi5pf+b47s54AvQF5ws/Mn2qVAeCUUImDKvqaBT8yCicQBIiABtBLwFnM5Tb6rxRx+aqsuYHdwcaZK2BlRwhmgGWe3IrdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709245971; c=relaxed/simple; bh=6Lf6QcisGSJb9jN+FYFboIAnPn8rBJqoU2uteBNkI+s=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=faS9YLwLuBN7x2gR8ajeXnznwlx13ao0c/Brks+evSbB1aVFE9mcaaYm79q3eIfkvhdUkEdkpIr1QRnAOolkI02IBWBj1k5KJwR8CAziOvVU2K91EPwmbzWvt3PsEfpS5EPxhPRKxhaR86TCmiwFA9EJ2UhBOA52WgvvyIoltgk= 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=YyS7vMYS; arc=none smtp.client-ip=209.85.208.169 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="YyS7vMYS" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d23d301452so16051711fa.1 for ; Thu, 29 Feb 2024 14:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709245968; x=1709850768; darn=vger.kernel.org; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=zoeNQ8kAfls9o1BZEGh0fB/dpADJEynRThwySqfJIb0=; b=YyS7vMYSD65jAEbL5ZjZU1WlhMGRIWaRegFHPBdH1AJPC8cpZDqUvbpHGQiN1kk3GU gWtA2B2ZS7TX0fpsZOERkteYd0MpCUekiSCIqxck9qaVdeOSKkKiHBk0vn897v6epFYL SbRew45/0gELgfHvqKQXEkP7MWnpF6ZzV4EbVeWq9aOlhsTKWSkX7JKzL1H7u1BfS2Nm c1n3qF0g3Owho3FMM3Eg9Qgl7NL/XLKFQ39N4yOD2KAiBE2JNGepgYblNh1Dn/6WMp9T s6OdU868yFOGEAZGq3ZjnfgRQXTWiHOjDC5amUZK8XViWWj8SLx53gA8ZGw2w55d2xN7 V7nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709245968; x=1709850768; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=zoeNQ8kAfls9o1BZEGh0fB/dpADJEynRThwySqfJIb0=; b=WAkdVMGjKNMFmL6UbcauxOWoKiBHXqcJgrRJYQAcuvtiP5XZT4pu/BGaz9D3e5qaNx fzlnY2QXWOR9bMWOG45WmIbvzsrOppBPBq1WCDg9p6QxjS7Xx2FNiX65JlAi5DAw1Iw5 rZE8VCYEECMKRgWvjCkrOr5wRN7Ps9vG+ZSdz7cieNMpj/lUpEKyIGIvCec7KHI/oVKM ZSnSG5RurAfBPnGlghq2QZLc0kc5KUfoBiAvQ3/3vWpzfRG+hr/PeWb+813bKkQColbT WaVm6WaZcFvdMM6n6eh1AmVzzC9EgvskLks9H66WvdCOS2bj9HyhL9xgXJ+Lbb0KOAKk 92tQ== X-Gm-Message-State: AOJu0YyBUAUMpSI3DQpqLgwjiW+KoFBgiZFBKPQnzdyMAQa0xSnOTWuh TBjMLMVd9tWsnKN8xlTI7W/ER6R95GPWF9JLek4uuHlM7+r1QGJlwQv0bwNd X-Google-Smtp-Source: AGHT+IHxPcQw4iyH2grEpfpRsqz8MWVNiFjyRaQfZTkDd5w3+sRoKvdNW7Pul4FiTYi9lGVP1DGy+g== X-Received: by 2002:a05:651c:10a2:b0:2d2:5668:3a40 with SMTP id k2-20020a05651c10a200b002d256683a40mr2588418ljn.4.1709245968042; Thu, 29 Feb 2024 14:32:48 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b00412b68cc169sm3360442wmg.16.2024.02.29.14.32.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 14:32:47 -0800 (PST) Message-ID: Date: Fri, 1 Mar 2024 00:32:45 +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 Content-Language: en-US To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer , Sean Mollet From: Bitterblue Smith Subject: [PATCH v2 1/4] wifi: rtw88: 8821cu: Fix firmware upload fail 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 --- v2: - Simplify the code and add comments, as suggested. --- drivers/net/wireless/realtek/rtw88/usb.c | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 3c4f28c306a9..3be6cbbf9ad8 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -33,6 +33,36 @@ static void rtw_usb_fill_tx_checksum(struct rtw_usb *rtwusb, rtw_tx_fill_txdesc_checksum(rtwdev, &pkt_info, skb->data); } +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; + bool reg_on_section = false; + u16 t_reg = 0x4e0; + u8 t_len = 1; + int status; + + /* There are three sections: + * 1. on (0x00~0xFF; 0x1000~0x10FF): this section is always powered on + * 2. off (< 0xFE00, excluding "on" section): this section could be + * powered off + * 3. local (>= 0xFE00): usb specific registers section + */ + if (addr <= 0xff || (addr >= 0x1000 && addr <= 0x10ff)) + reg_on_section = true; + + if (!reg_on_section) + 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 +88,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 +146,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 Thu Feb 29 22:34:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 777035 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 EF4EC208DA for ; Thu, 29 Feb 2024 22:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246057; cv=none; b=QUX/xfYJ/BFBgC6hqV5XRSzgFbgZt6+SQVsMMHQKFSi6VRQ7FrRO456JAkLYb6qN2oNnOQ14vqdgriZ5+sSXpqpIk38IwieEpp9DvtY+hpU10HZNL/v2gEbZTBM5KRDFnRLJ7TgiBGxrf3UD4v2Y1IsnowYH5c5jgrSUx4zfLsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246057; c=relaxed/simple; bh=fD/xamvG6zR8Ouxc+TXsK8mP2JejVEg2rAqhlxbaink=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=pKhIr2Ig9K37T+5xzhBFV7tpLXgeTHmkCdg3SmOwqODMJ+KR3/M25OxR+1sxk1BWxDSVaFf1jtgVSeK/i7VBComwlDz+uD5zFzL/1mLipkijDj5aQO0bR4HCOPATrNnUEni8k5Mkbo18rx5As/jZMRudwf7aKuZnvCznzVzH0+s= 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=WuwgwAhn; arc=none smtp.client-ip=209.85.167.47 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="WuwgwAhn" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5131f3fc695so1578684e87.1 for ; Thu, 29 Feb 2024 14:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709246054; x=1709850854; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=a3JZvTB/m4fw2x2v8iZTUePG8qieB3qG0XBnMg/1QpA=; b=WuwgwAhnPKsArJ9LRtOTepnI8D40WJIo53K9/IGgRfmJSf09vDyVHrmeOfwPv6dKAT 6xiFfkDlAK7An5DS4w4m1MKK+9F0PBUY3A1vW53NrYtI3kxNqyR/Xcq/u8P6q6K54CFC +to4nA84j5Lo2bb0V+6YsG/gMdbH7WurUNL/wbKxl80HLK9L9KE/JtdsJ9l+N6DmcsMv G+IGzp0K3VlMsWtlq6QNQpL24eCbQrwTlaWALiCAEPOA/dk2Y1tOqhy3jzGHbVe3QArX O2CKx5s/0hJuMJNOKioie400Q+EfsjpEiYmrJ3Bwf5bDcnMfsk9oEx2eGIO+dzuhnF7L Jivw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709246054; x=1709850854; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a3JZvTB/m4fw2x2v8iZTUePG8qieB3qG0XBnMg/1QpA=; b=rhK7AM4avTonovIDjPkLD2HyFqDDeiWuKyLSzFpJLQ/SHe+YAh7w0KINVbpCYXDtfJ 0QpX82q9tcf7WQ4XwAVTIaQHxYMHSh4Xa9qI8hODniY9RKArCkrx2m69m3O4coHe5x+E YU+53AsbJMFrVQLRUiDb+060NeeDvKdf8bC39oVGtIakIXsW4HqTMJBiHqLgnjIVEFb2 Zqvm1/+F3dBFzRCEjSPR+00rIBLWSucdmnG5pQshPuRwZVoPdnqKxU/rZNfnkMkoOtNG rSzWvBkJSjgLzsAk5H8F1yeieIWKjS9BJqPh9AWv2kBpid6JYh5YzDLGwjkLKrxUTBg+ AfUA== X-Gm-Message-State: AOJu0YwSUpx/KaNQpJuhF6wIizdjrExkg7x3joE2qYdzgzaPOni5kpZ1 q7862I9531OZiGa6sjkPeZhq2bOq3zMFORkBGEPJFxEjqd2mQmpxMLk8M7vk X-Google-Smtp-Source: AGHT+IG6+6mhadPMKfVleb/i0CgUM8XUrNH7ZO4wOH2WHMUhvLW917ZKiW8scjoTu052y0gCPR9gPA== X-Received: by 2002:a05:6512:31ca:b0:513:1cfd:14b2 with SMTP id j10-20020a05651231ca00b005131cfd14b2mr2628041lfe.33.1709246054046; Thu, 29 Feb 2024 14:34:14 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b00412b68cc169sm3360442wmg.16.2024.02.29.14.34.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 14:34:13 -0800 (PST) Message-ID: Date: Fri, 1 Mar 2024 00:34:13 +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 Subject: [PATCH v2 2/4] wifi: rtw88: 8821cu: Fix connection failure Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: In-Reply-To: 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 Acked-by: Ping-Ke Shih --- v2: - Check for pwr_on instead of pwr_seq == chip->pwr_on_seq. --- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/mac.c b/drivers/net/wireless/realtek/rtw88/mac.c index 298663b03580..0c1c1ff31085 100644 --- a/drivers/net/wireless/realtek/rtw88/mac.c +++ b/drivers/net/wireless/realtek/rtw88/mac.c @@ -309,6 +309,13 @@ 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_on && 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 Thu Feb 29 22:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 777421 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 03EDE200D6 for ; Thu, 29 Feb 2024 22:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246113; cv=none; b=h1qN1fQpoEf1h6fQV6hQLm3Bw5G/fENEgHvnJiuqBmdOdm8euMipJ9f5Ew7rbwvZISnFhzG+hBW/GPVUuSOcgp7cFCCcNWkLZXOQfIfv8KeDkJEpH4sEXfumdndgj7VBRh/SQWSyS9tpuoicOvxIRh0jxUjOohoYrw3+hQz243A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246113; c=relaxed/simple; bh=Y9ZNtBb2i8bkQqqVZSFI03rn3V2CJEjmODvUowGdR2o=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=MnbuSN69X7VKpYnfd3PMF5Ss3GggyihC+DekM2rAltexxBJRGG8mby/pDa8o4/h3+9kDm2B9On2iV9+kDqeIfKbN3aHyz7DLlzOabIrqjSdnSFhlnY9KOwq8oKzQoznuAQFSE73F8xhJTg90gf547S3KV/MTTNmOalBcykKKeZI= 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=h5TVpGzz; arc=none smtp.client-ip=209.85.167.45 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="h5TVpGzz" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-512f54fc2dbso1232777e87.1 for ; Thu, 29 Feb 2024 14:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709246110; x=1709850910; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=u8QSQ/xkN8iJeY3GCsJrJUDcbOEjNrSo0xZqIJB6tho=; b=h5TVpGzzU6s+yp+mbkoUxL3bdkq9vV8q01CQMnV3O6WmwtiSx/L83L70eWmR8vaerr tacMwPePDMx91Pb4Qme3eShHrpgOUdcVAhOpc2QypQpOSIa63yLKKLc2//9sZTp3LuZd eDsjA0mLy2AFf6w/yrGOcUEXjQeH0VEVRg1NVfa2GXraKUp70ga1BBnCQXsLj80CZyHi aYm4p1Gzf/e9cPYz9f012Kwu/nTlvlPls/p9sKksN56cEnhcE7zUGgjJPbnXfKv+FvDS skV5hNy7YEPau8/XxNkGmThQvG+WzoKwG6Ejy+v9DoLYJxfUhJOvM8m4gDUKe9M8vImZ hztQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709246110; x=1709850910; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u8QSQ/xkN8iJeY3GCsJrJUDcbOEjNrSo0xZqIJB6tho=; b=omIQPxs2FTetNjYH9Gsr3Fl77b3Lh7E5smW79bgIHNZJSGUuD9PBaQeqUw2Knl4ILa poTBlj3YT9hZ7RReSl0TnHj6SKbWJwYnGGjFNJyWRhbBUEilpuyChFD/sYD+qRYnnYa5 n3dTecRuLabuTNVwmm7Pc4z9umELFVhNUS5kj68kkDaV6CRZoCgbUN+6kQixsFYyl1pP JlPvANcwTig1/Gp+U6dIK7a8YbOt1l+OTMHvFPazSy6BmIzkS7a6ITl2OiHmj6gmJeNW nQn1a7MYyBf9Qq0cDJQRshjMyjj9MNbEXETU0aDwnPAy27bdmxtTfty4ocDIes+sJW1K /IDw== X-Gm-Message-State: AOJu0YyHgIebzH2zuEgv+wyDtG4JV0OrW3+27BGnOzSdnK0VDuFT9+kF D4qLCVDNIQLwIM+af+6InUm6ObeP4DV8/1t76GaVwKci6R0zP0KZxgaYxDvs X-Google-Smtp-Source: AGHT+IGZjHzV9RxE+21jdyL1swDMuMZybAcsxLWU+yiIkxTSNEVpjLjxzAaoWQsGeqdnMCvsHviXEw== X-Received: by 2002:a05:6512:3493:b0:512:ed78:a840 with SMTP id v19-20020a056512349300b00512ed78a840mr2075171lfr.61.1709246110142; Thu, 29 Feb 2024 14:35:10 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b00412b68cc169sm3360442wmg.16.2024.02.29.14.35.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 14:35:09 -0800 (PST) Message-ID: <276c31d8-b9a8-4e54-a3ac-09b74657aff7@gmail.com> Date: Fri, 1 Mar 2024 00:35:09 +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 Subject: [PATCH v2 3/4] wifi: rtw88: 8821c: Fix beacon loss and disconnect Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: In-Reply-To: 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, in rtw_chip_board_info_setup(). Move the extra AGC table loading to the right place, in rtw_phy_load_tables(). The rtw_chip_board_info_setup() can only do "software" things, and rtw_phy_load_tables() can really do IO. Fixes: 5d6651fe8583 ("rtw88: 8821c: support RFE type2 wifi NIC") Signed-off-by: Bitterblue Smith --- v2: - Add more information in the commit message. --- 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 Thu Feb 29 22:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 777034 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 1BC83200D2 for ; Thu, 29 Feb 2024 22:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246163; cv=none; b=txLh8KVJzaeHyjV8UD/w2vHzItGprac3uWQ10QHEzfGTrbpfGy5wQ7ulA8iNar/xQ9GoEyDmVNJVZv2ZEzmXLu80F/BTZ3zpZFeNIE9khZiKPTGW6JaoqWMNQ/k2C9+ZUpGWVs4mO/gCJcWhscCbzzvok2495FRdF9vQJix8N+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246163; c=relaxed/simple; bh=cb97msDWtnE4Qdtc6BLZ22e1WsjXWlfwXBJTw4CYFRs=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=UH4pCAVHFWylxz7Z0hRQXDvGkE7TdOkfh0z5chOsBYCe0z+6+DG9VrdtzzPzdicEEkSMDIIPDfrxin+yu0bpPz5MILuRMgK+3tsv2UCs5ldmJQ6lHoItRo5Nkz2GekouFhDWSnV2cwUGgV5iHRoyK3d2vH/ceWRIiotuGV0ZyvM= 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=efaYidMa; arc=none smtp.client-ip=209.85.167.48 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="efaYidMa" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-512b3b04995so1314275e87.3 for ; Thu, 29 Feb 2024 14:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709246160; x=1709850960; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=5zb66jO9LcwwLFlmdvbIbnbvhJ5fEvEL6G6MxWHGK/k=; b=efaYidMaIWhOPBV3+2OCIyan3rQQByM53+EWs3lFU+ZQsUgsS4fUqVhXwz2tSYFQ0z +fZCkqWa/sjR800pM0u1XOnnBuYOsoJdXtGxYbUPQXwJpo16YQrW5l9kbCqfi7qVIspE KEWAJPdps/9zONlFn12PBong4RmZ2l1CVsd7Knas0jSMUyfP0wLdjyZ9Nc0OdvyDkeg7 5VcUHo8sH/Dfsw8NUTNabwBv2gRHg/oIXODpW54j1Apy+R0MEMWZYf5mLWskd/vOjEer L1KQkqfNagXiLDFbS9FDkmntsgiLx6raJYt+H1hHBj4YBWCj4NnYOGPfId98++rPWVNK bpEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709246160; x=1709850960; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5zb66jO9LcwwLFlmdvbIbnbvhJ5fEvEL6G6MxWHGK/k=; b=GQ6B0C8LCzJkr0t1TXz25rU4edbc7m50N/WIqhrxkRzRf7u4R0FwSTrLZYhmUjIQ6/ f4eW0bvJxaMwlWxqjCV0ovejpKpt8tcuy9pzMbWYi+IKm5Ezkf/6ohAcuMsfiBFXsg1g 5dXE/yi99IFMONiCi4/uIy9RA8p6+JthU0yjZ0xjNLVGzpk7xh70HNFI97p+GDurkUrq L2PqENTUO8paOgIrgh5ml+XNbjbVpL96RbWwKVM80KRn49uh340dwIam94C2mAN6dc13 /pGK112YJqBG8614L0GzUj93ZwJsu4RKWpl9A1Vt09S8Tvrs/+c/wOiTN1VuV0QPvjZ3 G4Uw== X-Gm-Message-State: AOJu0YzFeMIJSHtoRDo93Pyyt/+nhY3LYUNbdJPpf0jE8oCfRwpl7ghS A/i0QZkP2yfC8SL2SAmZFzjp4/7dzBH2zZBHBun12ROsvPyHj8mf28ynxueq X-Google-Smtp-Source: AGHT+IHPdx0h6C9/1YI82SIjFjjWLHR+hJF4wwYNY5zbwE6g1qRczLH3d7sgx88cGUffntyfUO4jHQ== X-Received: by 2002:a05:6512:619:b0:512:e85f:175b with SMTP id b25-20020a056512061900b00512e85f175bmr1907773lfe.16.1709246159954; Thu, 29 Feb 2024 14:35:59 -0800 (PST) Received: from [192.168.1.50] ([79.119.240.211]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b00412b68cc169sm3360442wmg.16.2024.02.29.14.35.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 14:35:59 -0800 (PST) Message-ID: Date: Fri, 1 Mar 2024 00:35:58 +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 Subject: [PATCH v2 4/4] wifi: rtw88: 8821c: Fix false alarm count Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: In-Reply-To: total_fa_cnt is supposed to include 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 --- v2: - No change. --- 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);