From patchwork Thu Jun 29 07:29:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1801388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=OJA9vA1U; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qs98W0YJcz20bX for ; Thu, 29 Jun 2023 17:30:18 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qEm6V-0000Op-Bb; Thu, 29 Jun 2023 07:30:11 +0000 Received: from mail-oa1-f50.google.com ([209.85.160.50]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qEm6A-0000KQ-8K for kernel-team@lists.ubuntu.com; Thu, 29 Jun 2023 07:29:50 +0000 Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-1b00b0ab0daso366140fac.0 for ; Thu, 29 Jun 2023 00:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688023788; x=1690615788; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=qRlrJ8//db6YdxOy8nQmgZWpbKALRVMIPDKEbs6V+uI=; b=OJA9vA1U+t7cg98uctfpv6eskIvhp4MJ0ePGYYZNMdr/hV4kkOJbyLj/NLusdqJr4g BldOUdRQH2V49xyJLArcht07xUlGGJcSMrgIjTKObNMcyA7uDpFy2uPlaRXg4yP/5g+8 44NxrfhBPWI1blN/n015HvUGRpiwyar1EP3KEXZCBobypyYtSMxW55BeyTEAhhKu64Kp WmNm3P4GMlQt8HsVSTbqiS42Gy3zu6F8IOtsroB+vOgPeeCDIve/suBFnyJYpMXEMRlf BqgxEEh0EVwUhNDy8VRzFe8uXiJQVVbSb0+p1efN0c1N3JMCFqPYSB3LCoNz1yRunl87 nTBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688023788; x=1690615788; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=qRlrJ8//db6YdxOy8nQmgZWpbKALRVMIPDKEbs6V+uI=; b=KAJCS7KtQewYFjTVAAs0iqE5KskaVhs78CEA6og2VfqvKX8vgY3aJWaN6djNnnhqdt G1C1gWriVuJIYLz1+7tKOFwKeomQVcvTpY6aXM/2Mle20JNRwKicPyiEWe8K5n/QPqZw kZ6QiASVlzCYN08K8iJ3qvigvLVF5K0MBIqbdJnrTz6u2tc0UrxhsCv8fKxKb/RCQI0x k5xgFWAbyTvHqKgsm9pD8ZmOWbBkERr6FWECHxOdoYrNUupw5zKJ+KIQlJMX21FL3D1j Nu2D2U/I28AAj3ZGZBfX8eZpuzD9fPvS1exuURMB4fW+iEORlZf5IG7jza/m28/3LE9+ KZcA== X-Gm-Message-State: AC+VfDx1Z+HPPLvLaMpmRlFZl+pI5L8/rzcyzdBXemFp1i8H7xVsUunA 86MWFFEzdLeBoV0/l8GnMsEj2OdEGXY= X-Google-Smtp-Source: ACHHUZ7p2FJeFaNPOY3lsnPhql7/rsk/uQ23j6qwSDMrSyL9xn2xst41YLtcDY7KHn+M+8zF8rjqDA== X-Received: by 2002:a05:6808:1a97:b0:3a1:d8bc:ff8b with SMTP id bm23-20020a0568081a9700b003a1d8bcff8bmr9911846oib.38.1688023788261; Thu, 29 Jun 2023 00:29:48 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id x13-20020a17090a1f8d00b0025bf9e02e1bsm9383312pja.51.2023.06.29.00.29.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 00:29:47 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/5][SRU][L] wifi: rtw89: fix potential race condition between napi_init and napi_enable Date: Thu, 29 Jun 2023 15:29:39 +0800 Message-Id: <20230629072943.477754-2-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230629072943.477754-1-acelan.kao@canonical.com> References: <20230629072943.477754-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.160.50; envelope-from=acelan@gmail.com; helo=mail-oa1-f50.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Ping-Ke Shih BugLink: https://launchpad.net/bugs/2023952 A race condition can happen if netdev is registered, but NAPI isn't initialized yet, and meanwhile user space starts the netdev that will enable NAPI. Then, it hits BUG_ON(): kernel BUG at net/core/dev.c:6423! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 417 Comm: iwd Not tainted 6.2.7-slab-dirty #3 eb0f5a8a9d91 Hardware name: LENOVO 21DL/LNVNB161216, BIOS JPCN20WW(V1.06) 09/20/2022 RIP: 0010:napi_enable+0x3f/0x50 Code: 48 89 c2 48 83 e2 f6 f6 81 89 08 00 00 02 74 0d 48 83 ... RSP: 0018:ffffada1414f3548 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffffa01425802080 RCX: 0000000000000000 RDX: 00000000000002ff RSI: ffffada14e50c614 RDI: ffffa01425808dc0 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000100 R12: ffffa01425808f58 R13: 0000000000000000 R14: ffffa01423498940 R15: 0000000000000001 FS: 00007f5577c0a740(0000) GS:ffffa0169fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f5577a19972 CR3: 0000000125a7a000 CR4: 0000000000750ef0 PKRU: 55555554 Call Trace: rtw89_pci_ops_start+0x1c/0x70 [rtw89_pci 6cbc75429515c181cbc386478d5cfb32ffc5a0f8] rtw89_core_start+0xbe/0x160 [rtw89_core fe07ecb874820b6d778370d4acb6ef8a37847f22] rtw89_ops_start+0x26/0x40 [rtw89_core fe07ecb874820b6d778370d4acb6ef8a37847f22] drv_start+0x42/0x100 [mac80211 c07fa22af8c3cf3f7d7ab3884ca990784d72e2d2] ieee80211_do_open+0x311/0x7d0 [mac80211 c07fa22af8c3cf3f7d7ab3884ca990784d72e2d2] ieee80211_open+0x6a/0x90 [mac80211 c07fa22af8c3cf3f7d7ab3884ca990784d72e2d2] __dev_open+0xe0/0x180 __dev_change_flags+0x1da/0x250 dev_change_flags+0x26/0x70 do_setlink+0x37c/0x12c0 ? ep_poll_callback+0x246/0x290 ? __nla_validate_parse+0x61/0xd00 ? __wake_up_common_lock+0x8f/0xd0 To fix this, follow Jonas' suggestion to switch the order of these functions and move register netdev to be the last step of PCI probe. Also, correct the error handling of rtw89_core_register_hw(). Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver") Cc: stable@vger.kernel.org Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Link: https://lore.kernel.org/linux-wireless/CAOiHx=n7EwK2B9CnBR07FVA=sEzFagb8TkS4XC_qBNq8OwcYUg@mail.gmail.com/T/#t Suggested-by: Jonas Gorski Tested-by: Larry Finger Reviewed-by: Larry Finger Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230323082839.20474-1-pkshih@realtek.com (cherry picked from commit 47515664ecfbde11425dff121f298ae4499425c9) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/core.c | 10 +++++++--- drivers/net/wireless/realtek/rtw89/pci.c | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c index e99eccf11c76..08c6d1a8c712 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -3374,18 +3374,22 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev) ret = ieee80211_register_hw(hw); if (ret) { rtw89_err(rtwdev, "failed to register hw\n"); - goto err; + goto err_free_supported_band; } ret = rtw89_regd_init(rtwdev, rtw89_regd_notifier); if (ret) { rtw89_err(rtwdev, "failed to init regd\n"); - goto err; + goto err_unregister_hw; } return 0; -err: +err_unregister_hw: + ieee80211_unregister_hw(hw); +err_free_supported_band: + rtw89_core_clr_supported_band(rtwdev); + return ret; } diff --git a/drivers/net/wireless/realtek/rtw89/pci.c b/drivers/net/wireless/realtek/rtw89/pci.c index ec8bb5f10482..4025aabe0604 100644 --- a/drivers/net/wireless/realtek/rtw89/pci.c +++ b/drivers/net/wireless/realtek/rtw89/pci.c @@ -3874,25 +3874,26 @@ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) rtw89_pci_link_cfg(rtwdev); rtw89_pci_l1ss_cfg(rtwdev); - ret = rtw89_core_register(rtwdev); - if (ret) { - rtw89_err(rtwdev, "failed to register core\n"); - goto err_clear_resource; - } - rtw89_core_napi_init(rtwdev); ret = rtw89_pci_request_irq(rtwdev, pdev); if (ret) { rtw89_err(rtwdev, "failed to request pci irq\n"); - goto err_unregister; + goto err_deinit_napi; + } + + ret = rtw89_core_register(rtwdev); + if (ret) { + rtw89_err(rtwdev, "failed to register core\n"); + goto err_free_irq; } return 0; -err_unregister: +err_free_irq: + rtw89_pci_free_irq(rtwdev, pdev); +err_deinit_napi: rtw89_core_napi_deinit(rtwdev); - rtw89_core_unregister(rtwdev); err_clear_resource: rtw89_pci_clear_resource(rtwdev, pdev); err_declaim_pci: From patchwork Thu Jun 29 07:29:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1801391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=cP4O+IN2; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qs98V55q6z20ZC for ; Thu, 29 Jun 2023 17:30:17 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qEm6T-0000Ng-U0; Thu, 29 Jun 2023 07:30:09 +0000 Received: from mail-pj1-f43.google.com ([209.85.216.43]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qEm6D-0000Kd-Ay for kernel-team@lists.ubuntu.com; Thu, 29 Jun 2023 07:29:53 +0000 Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-262fa79e9b3so188176a91.0 for ; Thu, 29 Jun 2023 00:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688023791; x=1690615791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=GLEESYG1nc+wIz7PUg1EjOEnR85zF4GBqTXErLvwHjw=; b=cP4O+IN2FbJYCXQnDnfM6Vtb8iW76wA33cs4bZVHWrxGzH8seVbCv+knPw5dPB1Wx3 DyTTIQLo0v2I0k4sqNzuLK1+5+tS1SWpBruSofJwZtnGUmtPSL+Y064p1/B5pDObL2gS NH+aXTZcEsFbMWXwey/i6yRD3DyKJyVKaWZmOOQbLsyMFQMaUg6P3bfUtnNQj+U5VNoF yATiSzPpQJZoLSmZq1z5CCvCVcwgWigktZGBgy5EjuHNWSG3g+5ET1duE0liHOWGegah wCQuLYPZ8ZKQiK8AyIBc6uRAnVEqWqOCL+dMkvGf957eQbxWh8VAJrQHWSRJr8qWG5iU /uZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688023791; x=1690615791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=GLEESYG1nc+wIz7PUg1EjOEnR85zF4GBqTXErLvwHjw=; b=dsdV+XpJd4cHqO8YAY0jFahxYa+V+KwiyvcP1XDxTExrqVJGPGB3rAO3V5TzP2Bt7s PzDPNXbThYStFpun/VqsLwsRpjEcQ3RnStimX4xbma657HqKeJgI+q3OWyQbIbKWj7hW YHwvxC6NncZ4NxpZct72RhXe11QLLYnsGDafejTvCqpIVzJ8R+YC8B+tAozvmVOjNMf0 jj7yHNbu6M0W5ryqNpgMrmYG23OmNzVAH1XvIMAd+yuid5h9SneWAbCuxH1ABGZkQXqd sx1LKRC9Yr+FV/j90+9DFgGvaSuIdAM15ByPnqi2wHKc/qBrc+2yvA/VSrG/nXqE6dyh QlhA== X-Gm-Message-State: AC+VfDweacvKgdzWhOP8x1cHXKI9kisNrbFCV6p/iZmNnudsdp0AIT2s aq6VweuWsPuhd5LVBotThbdQMUDF7gw= X-Google-Smtp-Source: ACHHUZ5XXGdqb/XkBJ4ERfa4+uAGcGJyooFY3rZQheBmTuDsfAl2FkBV4kq4uZ4dA6vNrpBPRc1cQg== X-Received: by 2002:a17:90b:3141:b0:259:548b:d394 with SMTP id ip1-20020a17090b314100b00259548bd394mr26878430pjb.28.1688023790760; Thu, 29 Jun 2023 00:29:50 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id bb2-20020a17090b008200b00262fb769a10sm5730998pjb.11.2023.06.29.00.29.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 00:29:50 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/5][SRU][L][M] wifi: rtw89: 8851b: add 8851B basic chip_info Date: Thu, 29 Jun 2023 15:29:40 +0800 Message-Id: <20230629072943.477754-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230629072943.477754-1-acelan.kao@canonical.com> References: <20230629072943.477754-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.43; envelope-from=acelan@gmail.com; helo=mail-pj1-f43.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Ping-Ke Shih BugLink: https://launchpad.net/bugs/2023952 8851B is a 1x1 80 MHz bandwidth chip working on 2/5 GHz. Add these basic information, and more settings will be added by functions. Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230421024551.29994-2-pkshih@realtek.com (cherry picked from commit c8d89bf6b82f421dda16526233aba264d1331332) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/rtw8851b.c | 101 ++++++++++++++++++ drivers/net/wireless/realtek/rtw89/rtw8851b.h | 15 +++ 2 files changed, 116 insertions(+) create mode 100644 drivers/net/wireless/realtek/rtw89/rtw8851b.c create mode 100644 drivers/net/wireless/realtek/rtw89/rtw8851b.h diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851b.c b/drivers/net/wireless/realtek/rtw89/rtw8851b.c new file mode 100644 index 000000000000..a0aaac74b0ec --- /dev/null +++ b/drivers/net/wireless/realtek/rtw89/rtw8851b.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* Copyright(c) 2022-2023 Realtek Corporation + */ + +#include "coex.h" +#include "fw.h" +#include "mac.h" +#include "phy.h" +#include "reg.h" +#include "rtw8851b.h" +#include "rtw8851b_table.h" +#include "txrx.h" +#include "util.h" + +#define RTW8851B_FW_FORMAT_MAX 0 +#define RTW8851B_FW_BASENAME "rtw89/rtw8851b_fw" +#define RTW8851B_MODULE_FIRMWARE \ + RTW8851B_FW_BASENAME ".bin" + +static const struct rtw89_chip_ops rtw8851b_chip_ops = { + .fem_setup = NULL, + .fill_txdesc = rtw89_core_fill_txdesc, + .fill_txdesc_fwcmd = rtw89_core_fill_txdesc, + .h2c_dctl_sec_cam = NULL, +}; + +const struct rtw89_chip_info rtw8851b_chip_info = { + .chip_id = RTL8851B, + .ops = &rtw8851b_chip_ops, + .fw_basename = RTW8851B_FW_BASENAME, + .fw_format_max = RTW8851B_FW_FORMAT_MAX, + .try_ce_fw = true, + .fifo_size = 196608, + .dle_scc_rsvd_size = 98304, + .max_amsdu_limit = 3500, + .dis_2g_40m_ul_ofdma = true, + .rsvd_ple_ofst = 0x2f800, + .wde_qempty_acq_num = 4, + .wde_qempty_mgq_sel = 4, + .rf_base_addr = {0xe000}, + .pwr_on_seq = NULL, + .pwr_off_seq = NULL, + .bb_table = &rtw89_8851b_phy_bb_table, + .bb_gain_table = &rtw89_8851b_phy_bb_gain_table, + .rf_table = {&rtw89_8851b_phy_radioa_table,}, + .nctl_table = &rtw89_8851b_phy_nctl_table, + .byr_table = &rtw89_8851b_byr_table, + .dflt_parms = &rtw89_8851b_dflt_parms, + .rfe_parms_conf = rtw89_8851b_rfe_parms_conf, + .txpwr_factor_rf = 2, + .txpwr_factor_mac = 1, + .dig_table = NULL, + .tssi_dbw_table = NULL, + .support_chanctx_num = 0, + .support_bands = BIT(NL80211_BAND_2GHZ) | + BIT(NL80211_BAND_5GHZ), + .support_bw160 = false, + .support_ul_tb_ctrl = true, + .hw_sec_hdr = false, + .rf_path_num = 1, + .tx_nss = 1, + .rx_nss = 1, + .acam_num = 32, + .bcam_num = 20, + .scam_num = 128, + .bacam_num = 2, + .bacam_dynamic_num = 4, + .bacam_v1 = false, + .sec_ctrl_efuse_size = 4, + .physical_efuse_size = 1216, + .logical_efuse_size = 2048, + .limit_efuse_size = 1280, + .dav_phy_efuse_size = 0, + .dav_log_efuse_size = 0, + .phycap_addr = 0x580, + .phycap_size = 128, + .para_ver = 0, + .wlcx_desired = 0x06000000, + .btcx_desired = 0x7, + .scbd = 0x1, + .mailbox = 0x1, + + .ps_mode_supported = BIT(RTW89_PS_MODE_RFOFF) | + BIT(RTW89_PS_MODE_CLK_GATED), + .low_power_hci_modes = 0, + .h2c_cctl_func_id = H2C_FUNC_MAC_CCTLINFO_UD, + .hci_func_en_addr = R_AX_HCI_FUNC_EN, + .h2c_desc_size = sizeof(struct rtw89_txwd_body), + .txwd_body_size = sizeof(struct rtw89_txwd_body), + .bss_clr_map_reg = R_BSS_CLR_MAP_V1, + .dma_ch_mask = BIT(RTW89_DMA_ACH4) | BIT(RTW89_DMA_ACH5) | + BIT(RTW89_DMA_ACH6) | BIT(RTW89_DMA_ACH7) | + BIT(RTW89_DMA_B1MG) | BIT(RTW89_DMA_B1HI), + .edcca_lvl_reg = R_SEG0R_EDCCA_LVL_V1, +}; +EXPORT_SYMBOL(rtw8851b_chip_info); + +MODULE_FIRMWARE(RTW8851B_MODULE_FIRMWARE); +MODULE_AUTHOR("Realtek Corporation"); +MODULE_DESCRIPTION("Realtek 802.11ax wireless 8851B driver"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851b.h b/drivers/net/wireless/realtek/rtw89/rtw8851b.h new file mode 100644 index 000000000000..e34b7d09ad6d --- /dev/null +++ b/drivers/net/wireless/realtek/rtw89/rtw8851b.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2022-2023 Realtek Corporation + */ + +#ifndef __RTW89_8851B_H__ +#define __RTW89_8851B_H__ + +#include "core.h" + +#define RF_PATH_NUM_8851B 1 +#define BB_PATH_NUM_8851B 1 + +extern const struct rtw89_chip_info rtw8851b_chip_info; + +#endif From patchwork Thu Jun 29 07:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1801390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=DSrzx+3m; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qs98V6DD7z20Zc for ; Thu, 29 Jun 2023 17:30:17 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qEm6Q-0000Ma-ON; Thu, 29 Jun 2023 07:30:06 +0000 Received: from mail-oi1-f179.google.com ([209.85.167.179]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qEm6F-0000Kl-1o for kernel-team@lists.ubuntu.com; Thu, 29 Jun 2023 07:29:55 +0000 Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-39ea511930eso289443b6e.1 for ; Thu, 29 Jun 2023 00:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688023793; x=1690615793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=lM4WnYZLUa4it8mGOvPA55t+bWMTnu9Uq1OfzDxlb6A=; b=DSrzx+3mqiJSF/5vu8fj2T9/9t39JQWQOokH9qZunpheKyv7h1+QgaLX7wv4QsAb0r 8UDrkwl/H4vCzqFh1PY1c7ahd6Crh7TbG2oFAfTmssgcfduP+2AgJEgkXWGxYe2syKDm n+yGD2iWDF3/Uym9RMnFJoriu9OdSbm4SZiJj0/T8SRAe9lWFKoT/EqpZMQcy3FrYkqg Mk4/Jd2wczDttrKB6U1d7N+ZlV5HVL6wNXatw5/DUqCuHHHHqYjBY/FOLW7TwCtDa/mU Yc6/LJv6AR9DLSVoAJ1vJovZrtj943mCEzYx3Eot+JPPPjPw4rhGrLrgoCrAZ3t2LCOa yI/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688023793; x=1690615793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=lM4WnYZLUa4it8mGOvPA55t+bWMTnu9Uq1OfzDxlb6A=; b=N3UBTPirUA1PxFx4sEOOZ//AH+QXm+1BTFime6mgt6d/b/63+tm6wDajudAP/k7abz iRZd0NxpPLNw2G4QECsidV+zOg7XYGbRY415+/2pX/zLuyTO+3jQjSQDlSUjz7vnTj5F 2OslGksVA/FW6NYQKyJPaUDdm9u72lz/VXQjWsYh/BBL9lsel3KLApZZAbtsaVmeh7Sd Ydw37bgj6WlPxn0K4nY3yzRORDBph75fG1X5Ud/ByqnEicX77Ewpdav1+WUlQSQ0+c6c tRSj++OImPh21f7rVqJzwDgJWO1Tq5fSJG/6iY5SJexgTO9H6n7fCvGtSAQwEY1T7C7P TX8A== X-Gm-Message-State: AC+VfDyTOXR+bKbhqfEEgDXwT5nycljxKOqwYh9+NLbvENOox7aQ9YqQ oYsV8j+4KVpvLoV6hmEazlFDjeUIaX4= X-Google-Smtp-Source: ACHHUZ5Zq7kQ7m0Wl0O/hZ8KLRLTrLrTNXD95CI9IkomQgVo3zntn2gESvoeJdPHQvmaA9HQ28HZlw== X-Received: by 2002:aca:2109:0:b0:39c:9173:31f1 with SMTP id 9-20020aca2109000000b0039c917331f1mr39718160oiz.28.1688023793375; Thu, 29 Jun 2023 00:29:53 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id c19-20020aa78813000000b00671aa6b4962sm6727064pfo.114.2023.06.29.00.29.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 00:29:53 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/5][SRU][L][M] wifi: rtw89: introduce realtek ACPI DSM method Date: Thu, 29 Jun 2023 15:29:41 +0800 Message-Id: <20230629072943.477754-4-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230629072943.477754-1-acelan.kao@canonical.com> References: <20230629072943.477754-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.167.179; envelope-from=acelan@gmail.com; helo=mail-oi1-f179.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Zong-Zhe Yang BugLink: https://launchpad.net/bugs/2023952 Introduce realtek ACPI DSM method to get required BIOS configurations. It will be used in the following commits. And, enum rtw89_acpi_dsm_func is added for listing the functions which are currently recognized. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230508081211.38760-2-pkshih@realtek.com (cherry picked from commit e897b0bef38a8b40101c0e6e009395506c256460) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/Makefile | 3 +- drivers/net/wireless/realtek/rtw89/acpi.c | 52 +++++++++++++++++++++ drivers/net/wireless/realtek/rtw89/acpi.h | 21 +++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 drivers/net/wireless/realtek/rtw89/acpi.c create mode 100644 drivers/net/wireless/realtek/rtw89/acpi.h diff --git a/drivers/net/wireless/realtek/rtw89/Makefile b/drivers/net/wireless/realtek/rtw89/Makefile index 2dc48fa10c6b..99e870d6a7d7 100644 --- a/drivers/net/wireless/realtek/rtw89/Makefile +++ b/drivers/net/wireless/realtek/rtw89/Makefile @@ -13,7 +13,8 @@ rtw89_core-y += core.o \ coex.o \ ps.o \ chan.o \ - ser.o + ser.o \ + acpi.o rtw89_core-$(CONFIG_PM) += wow.o diff --git a/drivers/net/wireless/realtek/rtw89/acpi.c b/drivers/net/wireless/realtek/rtw89/acpi.c new file mode 100644 index 000000000000..8aaf83a2a6b4 --- /dev/null +++ b/drivers/net/wireless/realtek/rtw89/acpi.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* Copyright(c) 2021-2023 Realtek Corporation + */ + +#include +#include + +#include "acpi.h" +#include "debug.h" + +static const guid_t rtw89_guid = GUID_INIT(0xD2A8C3E8, 0x4B69, 0x4F00, + 0x82, 0xBD, 0xFE, 0x86, + 0x07, 0x80, 0x3A, 0xA7); + +static int rtw89_acpi_dsm_get(struct rtw89_dev *rtwdev, union acpi_object *obj, + u8 *value) +{ + switch (obj->type) { + case ACPI_TYPE_INTEGER: + *value = (u8)obj->integer.value; + break; + case ACPI_TYPE_BUFFER: + *value = obj->buffer.pointer[0]; + break; + default: + rtw89_debug(rtwdev, RTW89_DBG_UNEXP, + "acpi dsm return unhandled type: %d\n", obj->type); + return -EINVAL; + } + + return 0; +} + +int rtw89_acpi_evaluate_dsm(struct rtw89_dev *rtwdev, + enum rtw89_acpi_dsm_func func, u8 *value) +{ + union acpi_object *obj; + int ret; + + obj = acpi_evaluate_dsm(ACPI_HANDLE(rtwdev->dev), &rtw89_guid, + 0, func, NULL); + if (!obj) { + rtw89_debug(rtwdev, RTW89_DBG_UNEXP, + "acpi dsm fail to evaluate func: %d\n", func); + return -ENOENT; + } + + ret = rtw89_acpi_dsm_get(rtwdev, obj, value); + + ACPI_FREE(obj); + return ret; +} diff --git a/drivers/net/wireless/realtek/rtw89/acpi.h b/drivers/net/wireless/realtek/rtw89/acpi.h new file mode 100644 index 000000000000..ed74d8ceb733 --- /dev/null +++ b/drivers/net/wireless/realtek/rtw89/acpi.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2021-2023 Realtek Corporation + */ + +#ifndef __RTW89_ACPI_H__ +#define __RTW89_ACPI_H__ + +#include "core.h" + +enum rtw89_acpi_dsm_func { + RTW89_ACPI_DSM_FUNC_IDN_BAND_SUP = 2, + RTW89_ACPI_DSM_FUNC_6G_DIS = 3, + RTW89_ACPI_DSM_FUNC_6G_BP = 4, + RTW89_ACPI_DSM_FUNC_TAS_EN = 5, + RTW89_ACPI_DSM_FUNC_59G_EN = 6, +}; + +int rtw89_acpi_evaluate_dsm(struct rtw89_dev *rtwdev, + enum rtw89_acpi_dsm_func func, u8 *value); + +#endif From patchwork Thu Jun 29 07:29:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1801393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=l96lJ5E4; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qs98W73syz242F for ; Thu, 29 Jun 2023 17:30:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qEm6W-0000Q8-Op; Thu, 29 Jun 2023 07:30:12 +0000 Received: from mail-pf1-f179.google.com ([209.85.210.179]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qEm6I-0000Ku-1k for kernel-team@lists.ubuntu.com; Thu, 29 Jun 2023 07:29:58 +0000 Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6686ef86110so218383b3a.2 for ; Thu, 29 Jun 2023 00:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688023796; x=1690615796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=lV7P4VbEK2ryrwGuLDIBsHSyH95c+E1vSuVuS97PNtI=; b=l96lJ5E4TXJ9z1LnBU4l0uiJ7EOSPZgbJZ84wpvJNuwPc4otBJfRfveDtKzcigLtTH w3AstCUERqmYrrwOH1sPueDCOWCt1Vboj52b0/T/gIGuGNtf+yz0Ds3ugMRCED5xHxZk n065z+CcQZaQqS/iGDVmmmwtBTABJV+r9DukefmCYghH8qsgw9iDuvPx03cMigI/0Gv2 V6hOxtDcJCUvngn/iI8VqKniRH9EBPcECzGds3l2htA61jEOpdKK81gEiL6VBiwafyVs fNZuSHENoUKq6mHPwYNFlM3PZdkCwafPpgHpaRnIaBKSyAeKUSra28PRK9C4mZKqP/2x NngA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688023796; x=1690615796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=lV7P4VbEK2ryrwGuLDIBsHSyH95c+E1vSuVuS97PNtI=; b=YM6goWN7LE9J63ZFsdCNfYqhrMHk4bH6ClnJdLTXh78F6SVF1luk6oVOV6vz270Etd f2f+EUrOZdGaI3OoD9VUZDriBNqw4kj88neK/PScZYgDilIGZZhRazO3X2m1ZwSeOGVh HmrOs9L4B+BZCXjg5O+CCJ0u2nFQWA6ODPEMXjoiiTjwc8ZBQnx1xKf/eXmQ7dMX+hhq FboB9s1ZYITyg4NI+sr/HqdRX+bfVU+kjg0RdjiCvGt0gQYhAvbZ6eFBvAMCiGf4K7Ob uAUqnCxwEilsmUN1EhQN57pmfqXXwyDF9Cye9Q9iZ1nHnqJ/WfhPDt5xpSzinRU/6CAp 3bgg== X-Gm-Message-State: AC+VfDwj6DmFcPzhyZ9eAYRnOsqivhac0THBCC64U8F1I8K2bWAzS23h 7KOmvkMVJRHu65/b8YMMO1do6vXJrU0= X-Google-Smtp-Source: ACHHUZ64vn2xq/6UpI2LVY/FIdKt3I9mtLD/EPCl8ubV+/3cuMbJ3jzETJK76Qn4liaRka/JJGyBig== X-Received: by 2002:a05:6a20:7f9f:b0:12b:93d4:4967 with SMTP id d31-20020a056a207f9f00b0012b93d44967mr6627159pzj.26.1688023795644; Thu, 29 Jun 2023 00:29:55 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id a25-20020aa78659000000b0067738f65039sm5929799pfo.83.2023.06.29.00.29.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 00:29:55 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/5][SRU][L][M] wifi: rtw89: regd: judge UNII-4 according to BIOS and chip Date: Thu, 29 Jun 2023 15:29:42 +0800 Message-Id: <20230629072943.477754-5-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230629072943.477754-1-acelan.kao@canonical.com> References: <20230629072943.477754-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.179; envelope-from=acelan@gmail.com; helo=mail-pf1-f179.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Zong-Zhe Yang BugLink: https://launchpad.net/bugs/2023952 For realtek regulatory, there are following two kinds of configurations to determine whether to allow UNII-4 band, i.e. 5.9GHz channels. 1. default setting according to whether chip support it or not 2. evaluate realtek ACPI DSM with RTW89_ACPI_DSM_FUNC_59G_EN (func. 6) If (1) is false, we won't try (2) and just disallow UNII-4. Otherwise, if (2) is not supported or returns a non-specific value, we follow the default setting either. Besides, this commit aims to add decision logic in rtw89 regulatory. Actually, driver doesn't register UNII-4 yet. That will be handled by another commit. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230508081211.38760-3-pkshih@realtek.com (cherry picked from commit a002f98123dd5e6b6d66c1b42a37dfd6e25ade4c) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/core.c | 7 ++- drivers/net/wireless/realtek/rtw89/core.h | 2 + drivers/net/wireless/realtek/rtw89/regd.c | 51 +++++++++++++++++++ drivers/net/wireless/realtek/rtw89/rtw8851b.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852a.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852b.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852c.c | 1 + 7 files changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c index 08c6d1a8c712..6dd060f70ae7 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -3368,7 +3368,12 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev) return ret; } - hw->wiphy->reg_notifier = rtw89_regd_notifier; + ret = rtw89_regd_setup(rtwdev); + if (ret) { + rtw89_err(rtwdev, "failed to set up regd\n"); + goto err_free_supported_band; + } + hw->wiphy->sar_capa = &rtw89_sar_capa; ret = ieee80211_register_hw(hw); diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h index d9cc1005351e..359c283fb529 100644 --- a/drivers/net/wireless/realtek/rtw89/core.h +++ b/drivers/net/wireless/realtek/rtw89/core.h @@ -2673,6 +2673,7 @@ struct rtw89_chip_info { u8 support_chanctx_num; u8 support_bands; bool support_bw160; + bool support_unii4; bool support_ul_tb_ctrl; bool hw_sec_hdr; u8 rf_path_num; @@ -4498,6 +4499,7 @@ int rtw89_core_release_sta_ba_entry(struct rtw89_dev *rtwdev, void rtw89_vif_type_mapping(struct ieee80211_vif *vif, bool assoc); int rtw89_chip_info_setup(struct rtw89_dev *rtwdev); bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate); +int rtw89_regd_setup(struct rtw89_dev *rtwdev); int rtw89_regd_init(struct rtw89_dev *rtwdev, void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request)); void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request); diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c index 6e5a740b128f..7800ca36bc13 100644 --- a/drivers/net/wireless/realtek/rtw89/regd.c +++ b/drivers/net/wireless/realtek/rtw89/regd.c @@ -2,6 +2,7 @@ /* Copyright(c) 2019-2020 Realtek Corporation */ +#include "acpi.h" #include "debug.h" #include "ps.h" @@ -282,6 +283,56 @@ do { \ __r->txpwr_regd[RTW89_BAND_6G]); \ } while (0) +static void rtw89_regd_setup_unii4(struct rtw89_dev *rtwdev, + struct wiphy *wiphy) +{ + const struct rtw89_chip_info *chip = rtwdev->chip; + bool regd_allow_unii_4 = chip->support_unii4; + int ret; + u8 val; + + if (!chip->support_unii4) + goto bottom; + + ret = rtw89_acpi_evaluate_dsm(rtwdev, RTW89_ACPI_DSM_FUNC_59G_EN, &val); + if (ret) { + rtw89_debug(rtwdev, RTW89_DBG_REGD, + "acpi: cannot eval unii 4: %d\n", ret); + goto bottom; + } + + rtw89_debug(rtwdev, RTW89_DBG_REGD, + "acpi: eval if allow unii 4: %d\n", val); + + switch (val) { + case 0: + regd_allow_unii_4 = false; + break; + case 1: + regd_allow_unii_4 = true; + break; + default: + break; + } + +bottom: + rtw89_debug(rtwdev, RTW89_DBG_REGD, "regd: allow unii 4: %d\n", + regd_allow_unii_4); +} + +int rtw89_regd_setup(struct rtw89_dev *rtwdev) +{ + struct wiphy *wiphy = rtwdev->hw->wiphy; + + if (!wiphy) + return -EINVAL; + + rtw89_regd_setup_unii4(rtwdev, wiphy); + + wiphy->reg_notifier = rtw89_regd_notifier; + return 0; +} + int rtw89_regd_init(struct rtw89_dev *rtwdev, void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request)) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851b.c b/drivers/net/wireless/realtek/rtw89/rtw8851b.c index a0aaac74b0ec..7192802bd540 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8851b.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8851b.c @@ -55,6 +55,7 @@ const struct rtw89_chip_info rtw8851b_chip_info = { .support_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ), .support_bw160 = false, + .support_unii4 = true, .support_ul_tb_ctrl = true, .hw_sec_hdr = false, .rf_path_num = 1, diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852a.c b/drivers/net/wireless/realtek/rtw89/rtw8852a.c index eff6519cf019..73a7f630bf45 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852a.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852a.c @@ -2082,6 +2082,7 @@ const struct rtw89_chip_info rtw8852a_chip_info = { .support_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ), .support_bw160 = false, + .support_unii4 = false, .support_ul_tb_ctrl = false, .hw_sec_hdr = false, .rf_path_num = 2, diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b.c b/drivers/net/wireless/realtek/rtw89/rtw8852b.c index b635ac1d1ca2..ab6b017fc438 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852b.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852b.c @@ -2459,6 +2459,7 @@ const struct rtw89_chip_info rtw8852b_chip_info = { .support_bands = BIT(NL80211_BAND_2GHZ) | BIT(NL80211_BAND_5GHZ), .support_bw160 = false, + .support_unii4 = true, .support_ul_tb_ctrl = true, .hw_sec_hdr = false, .rf_path_num = 2, diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852c.c b/drivers/net/wireless/realtek/rtw89/rtw8852c.c index a87482cc25f5..04eaee59a284 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852c.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852c.c @@ -2891,6 +2891,7 @@ const struct rtw89_chip_info rtw8852c_chip_info = { BIT(NL80211_BAND_5GHZ) | BIT(NL80211_BAND_6GHZ), .support_bw160 = true, + .support_unii4 = true, .support_ul_tb_ctrl = false, .hw_sec_hdr = true, .rf_path_num = 2, From patchwork Thu Jun 29 07:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1801392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Op9C/Xgb; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qs98X0bq1z242H for ; Thu, 29 Jun 2023 17:30:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qEm6X-0000Qe-3i; Thu, 29 Jun 2023 07:30:13 +0000 Received: from mail-pf1-f179.google.com ([209.85.210.179]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qEm6J-0000L1-EL for kernel-team@lists.ubuntu.com; Thu, 29 Jun 2023 07:29:59 +0000 Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-66872d4a141so313708b3a.1 for ; Thu, 29 Jun 2023 00:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688023797; x=1690615797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=v+5MjmlEyGtvaHGAR5moU0/nu7Hd7lbr1LW9UfcqZXk=; b=Op9C/XgbBZz9Z5UFvGvatECvBQGbiyEF+TiZVQBniOgW4n2kdfna/6s53lbOnDPHFR BkJuB6ub52q5HqsecKR+ee/xEeqE+Q7X6Mcx1eqeyYt7DY5WAMcsDioquiO343PHm54d 4X9na7SREE/b2jVXu60Z+ZVvnx//gbPEDyajUA/m9D2v5Q7AeUxoch+avFGyr6krI3T4 mM4jRvobU7MJ5trWetuIcn4kShM+SbN+0Oy1u89qkMqFIvPptnH5qVgBNt+tNoiD1Fly TgOqSd65kHji4m2LtzPn0HM3B4qcCs18dRr8szriSPCcP6zuj3sCFu3uynH5A1E0O2mh NAGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688023797; x=1690615797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=v+5MjmlEyGtvaHGAR5moU0/nu7Hd7lbr1LW9UfcqZXk=; b=Tuce5XkuXKyNWupxbBZlWLHADTuB4sZ6P60/U9m37ioBgBsNmllPz43fZuajkJFqo7 jU9M9yeMUgfI3zChkA7M9UOvhq0LOSauyXtJQnVzPmOMmgsGxa0eFm2Mt0JtUSudgtDH JMcGieQYtUlwkHiitJ7yFvQIRI7kpOU+M2NVpELrSvXhMOkKBqgoyht+sTizQLLPmsEX snRoSpcmhL8ffUpSGtdDCORmjTW08axid6rGBS0BBy1yuHnJ9+L4cPZti3YleV8mhDvc 09H0EQAxJ1eKqT1calTiJYXWtt8HobGMEGxvHgtfN8VnTsTJ5rvwA3ztvdJfwiio8M1u wKKA== X-Gm-Message-State: AC+VfDxkDJHvYyJCQ+XsyPKUSutVXLpSWXxyMNSVwULh2SyQIBEJZXGP ie7tYO6xuXubLTKNY1wS4MkPUto01jI= X-Google-Smtp-Source: ACHHUZ4lvaygqMkw2R+evecP9LvQTlOkO6H5Vbs5ND2d1hli7xJbl1A1Xxm2td1S2bfUDUmz+bT5oQ== X-Received: by 2002:a05:6a20:3c90:b0:123:b57:a3de with SMTP id b16-20020a056a203c9000b001230b57a3demr22507712pzj.46.1688023797434; Thu, 29 Jun 2023 00:29:57 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id c30-20020a634e1e000000b0053b92b26412sm8244531pgb.14.2023.06.29.00.29.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 00:29:57 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/5][SRU][L][M] wifi: rtw89: support U-NII-4 channels on 5GHz band Date: Thu, 29 Jun 2023 15:29:43 +0800 Message-Id: <20230629072943.477754-6-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230629072943.477754-1-acelan.kao@canonical.com> References: <20230629072943.477754-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.179; envelope-from=acelan@gmail.com; helo=mail-pf1-f179.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Zong-Zhe Yang BugLink: https://launchpad.net/bugs/2023952 U-NII-4 band, i.e 5.9GHz channels, can be supported by chip 8852C, 8852B and 8851B. But, it is not supported by chip 8852A. Flag support_unii4 is added in chip info and defined by chip accordingly to indicate that. We reference this flag of runtime chip to decide whether to register 5.9GHz channels. After that, we consider if U-NII-4 band is allowed by our regulatory rule of U-NII-4. If chip::support_unii4 but not regd::allow_unii4, we stll do not register 5.9GHz channels. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230508081211.38760-4-pkshih@realtek.com (cherry picked from commit e3b77c06c8863a53a0d80f7dcaff923c590e3edd) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/core.c | 3 +++ drivers/net/wireless/realtek/rtw89/regd.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c index 6dd060f70ae7..73bd3b6379b7 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -77,6 +77,9 @@ static struct ieee80211_channel rtw89_channels_5ghz[] = { RTW89_DEF_CHAN_5G(5785, 157), RTW89_DEF_CHAN_5G(5805, 161), RTW89_DEF_CHAN_5G_NO_HT40MINUS(5825, 165), + RTW89_DEF_CHAN_5G(5845, 169), + RTW89_DEF_CHAN_5G(5865, 173), + RTW89_DEF_CHAN_5G(5885, 177), }; static struct ieee80211_channel rtw89_channels_6ghz[] = { diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c index 7800ca36bc13..377a7a1c560b 100644 --- a/drivers/net/wireless/realtek/rtw89/regd.c +++ b/drivers/net/wireless/realtek/rtw89/regd.c @@ -288,6 +288,7 @@ static void rtw89_regd_setup_unii4(struct rtw89_dev *rtwdev, { const struct rtw89_chip_info *chip = rtwdev->chip; bool regd_allow_unii_4 = chip->support_unii4; + struct ieee80211_supported_band *sband; int ret; u8 val; @@ -318,6 +319,15 @@ static void rtw89_regd_setup_unii4(struct rtw89_dev *rtwdev, bottom: rtw89_debug(rtwdev, RTW89_DBG_REGD, "regd: allow unii 4: %d\n", regd_allow_unii_4); + + if (regd_allow_unii_4) + return; + + sband = wiphy->bands[NL80211_BAND_5GHZ]; + if (!sband) + return; + + sband->n_channels -= 3; } int rtw89_regd_setup(struct rtw89_dev *rtwdev)