2023-01-05 11:48:20

by Peter Chiu

[permalink] [raw]
Subject: [PATCH 1/2] wifi: mt76: mt7915: set sku initial value to zero

Set sku initial value before mcu starts to prevent mcu from getting an
invalid value.

Signed-off-by: Peter Chiu <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7915/soc.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
index 686c9bbd5929..2ac0a0f2859c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
@@ -883,6 +883,8 @@ static int mt7986_wmac_wm_enable(struct mt7915_dev *dev, bool enable)
{
u32 cur;

+ mt76_wr(dev, MT_CONNINFRA_SKU_DEC_ADDR, 0);
+
mt76_rmw_field(dev, MT7986_TOP_WM_RESET,
MT7986_TOP_WM_RESET_MASK, enable);
if (!enable)
--
2.18.0


2023-01-05 11:48:24

by Peter Chiu

[permalink] [raw]
Subject: [PATCH 2/2] wifi: mt76: mt7915: wed: enable red per-band token drop

Enable RED to limit the number of token used by each band. If single band
uses too many tokens, it would hurt the throughput of the other bands.The
software path can solve this problem by AQL so enable RED for HW path only.

Reviewed-by: Shayne Chen <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
---
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 +
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 54 ++++++++++++++++++-
.../net/wireless/mediatek/mt76/mt7915/mcu.h | 1 +
3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index f1e942b9a887..855a434ecf54 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1171,6 +1171,7 @@ enum {
MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
MCU_EXT_CMD_TXDPD_CAL = 0x60,
MCU_EXT_CMD_CAL_CACHE = 0x67,
+ MCU_EXT_CMD_RED_ENABLE = 0x68,
MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 37a3c1f082d9..a7bc2043a0db 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -2291,6 +2291,57 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev)
sizeof(req), true);
}

+static int mt7915_red_set_watermark(struct mt7915_dev *dev)
+{
+#define RED_GLOBAL_TOKEN_WATERMARK 2
+ u16 nbuf = dev->mt76.mmio.wed.wlan.nbuf;
+ struct {
+ __le32 args[3];
+
+ u8 cmd;
+ u8 version;
+ u8 __rsv1[4];
+ u16 len;
+
+ __le16 high_mark;
+ __le16 low_mark;
+ u8 __rsv2[12];
+ } __packed req = {
+ .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
+ .cmd = RED_GLOBAL_TOKEN_WATERMARK,
+ .len = cpu_to_le16(sizeof(req) - sizeof(req.args)),
+
+ .high_mark = cpu_to_le16(nbuf - 256),
+ .low_mark = cpu_to_le16(nbuf - 256 - 1536),
+ };
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
+ sizeof(req), false);
+}
+
+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
+{
+#define RED_DISABLE 0
+#define RED_BY_WA_ENABLE 2
+ int ret;
+ u32 red_type = enabled ? RED_BY_WA_ENABLE : RED_DISABLE;
+ __le32 req = cpu_to_le32(red_type);
+
+ if (enabled) {
+ ret = mt7915_red_set_watermark(dev);
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
+ sizeof(req), false);
+ if (ret < 0)
+ return ret;
+
+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
+ MCU_WA_PARAM_RED, enabled, 0);
+}
+
int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
{
int ret;
@@ -2339,8 +2390,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
if (ret)
return ret;

- return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
- MCU_WA_PARAM_RED, 0, 0);
+ return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed));
}

int mt7915_mcu_init(struct mt7915_dev *dev)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
index 29b5434bfdb8..b9ea297f382c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
@@ -278,6 +278,7 @@ enum {
MCU_WA_PARAM_PDMA_RX = 0x04,
MCU_WA_PARAM_CPU_UTIL = 0x0b,
MCU_WA_PARAM_RED = 0x0e,
+ MCU_WA_PARAM_RED_SETTING = 0x40,
};

enum mcu_mmps_mode {
--
2.18.0

2023-01-05 12:25:12

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH 2/2] wifi: mt76: mt7915: wed: enable red per-band token drop

> Enable RED to limit the number of token used by each band. If single band
> uses too many tokens, it would hurt the throughput of the other bands.The
> software path can solve this problem by AQL so enable RED for HW path only.
>
> Reviewed-by: Shayne Chen <[email protected]>
> Signed-off-by: Peter Chiu <[email protected]>
> ---
> .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 +
> .../net/wireless/mediatek/mt76/mt7915/mcu.c | 54 ++++++++++++++++++-
> .../net/wireless/mediatek/mt76/mt7915/mcu.h | 1 +
> 3 files changed, 54 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> index f1e942b9a887..855a434ecf54 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> @@ -1171,6 +1171,7 @@ enum {
> MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
> MCU_EXT_CMD_TXDPD_CAL = 0x60,
> MCU_EXT_CMD_CAL_CACHE = 0x67,
> + MCU_EXT_CMD_RED_ENABLE = 0x68,
> MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
> MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
> MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
> index 37a3c1f082d9..a7bc2043a0db 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
> @@ -2291,6 +2291,57 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev)
> sizeof(req), true);
> }
>
> +static int mt7915_red_set_watermark(struct mt7915_dev *dev)
> +{
> +#define RED_GLOBAL_TOKEN_WATERMARK 2
> + u16 nbuf = dev->mt76.mmio.wed.wlan.nbuf;

I do not think this patch compile if CONFIG_NET_MEDIATEK_SOC_WED is not enabled

> + struct {
> + __le32 args[3];

please remove blank lines.

> +
> + u8 cmd;
> + u8 version;
> + u8 __rsv1[4];
> + u16 len;

I guess it should be __le16 here

> +
> + __le16 high_mark;
> + __le16 low_mark;
> + u8 __rsv2[12];
> + } __packed req = {
> + .args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
> + .cmd = RED_GLOBAL_TOKEN_WATERMARK,
> + .len = cpu_to_le16(sizeof(req) - sizeof(req.args)),
> +
> + .high_mark = cpu_to_le16(nbuf - 256),
> + .low_mark = cpu_to_le16(nbuf - 256 - 1536),
> + };
> +
> + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
> + sizeof(req), false);
> +}
> +
> +int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
> +{
> +#define RED_DISABLE 0
> +#define RED_BY_WA_ENABLE 2
> + int ret;
> + u32 red_type = enabled ? RED_BY_WA_ENABLE : RED_DISABLE;
> + __le32 req = cpu_to_le32(red_type);
> +
> + if (enabled) {
> + ret = mt7915_red_set_watermark(dev);
> + if (ret < 0)
> + return ret;
> + }
> +
> + ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
> + sizeof(req), false);
> + if (ret < 0)
> + return ret;
> +
> + return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
> + MCU_WA_PARAM_RED, enabled, 0);
> +}
> +
> int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
> {
> int ret;
> @@ -2339,8 +2390,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
> if (ret)
> return ret;
>
> - return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
> - MCU_WA_PARAM_RED, 0, 0);
> + return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed));
> }
>
> int mt7915_mcu_init(struct mt7915_dev *dev)
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
> index 29b5434bfdb8..b9ea297f382c 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
> @@ -278,6 +278,7 @@ enum {
> MCU_WA_PARAM_PDMA_RX = 0x04,
> MCU_WA_PARAM_CPU_UTIL = 0x0b,
> MCU_WA_PARAM_RED = 0x0e,
> + MCU_WA_PARAM_RED_SETTING = 0x40,
> };
>
> enum mcu_mmps_mode {
> --
> 2.18.0
>


Attachments:
(No filename) (3.91 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-05 13:58:20

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] wifi: mt76: mt7915: wed: enable red per-band token drop

Hi Peter,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.2-rc2 next-20230105]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Peter-Chiu/wifi-mt76-mt7915-wed-enable-red-per-band-token-drop/20230105-194846
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link: https://lore.kernel.org/r/20230105114711.31430-2-chui-hao.chiu%40mediatek.com
patch subject: [PATCH 2/2] wifi: mt76: mt7915: wed: enable red per-band token drop
config: mips-allmodconfig
compiler: mips-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/344aa22b401e8335d2cdc69d6a4db8d3df5b0a10
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Peter-Chiu/wifi-mt76-mt7915-wed-enable-red-per-band-token-drop/20230105-194846
git checkout 344aa22b401e8335d2cdc69d6a4db8d3df5b0a10
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/net/wireless/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2322:5: warning: no previous prototype for 'mt7915_mcu_set_red' [-Wmissing-prototypes]
2322 | int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
| ^~~~~~~~~~~~~~~~~~


vim +/mt7915_mcu_set_red +2322 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

2321
> 2322 int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
2323 {
2324 #define RED_DISABLE 0
2325 #define RED_BY_WA_ENABLE 2
2326 int ret;
2327 u32 red_type = enabled ? RED_BY_WA_ENABLE : RED_DISABLE;
2328 __le32 req = cpu_to_le32(red_type);
2329
2330 if (enabled) {
2331 ret = mt7915_red_set_watermark(dev);
2332 if (ret < 0)
2333 return ret;
2334 }
2335
2336 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
2337 sizeof(req), false);
2338 if (ret < 0)
2339 return ret;
2340
2341 return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
2342 MCU_WA_PARAM_RED, enabled, 0);
2343 }
2344

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (2.97 kB)
config (328.00 kB)
Download all attachments