diff mbox series

[02/11] wifi: rtw89: load BB parameters to PHY-1

Message ID 20240208022857.14379-3-pkshih@realtek.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wifi: rtw89: enable DBCC for WiFi 7 chips by default | expand

Commit Message

Ping-Ke Shih Feb. 8, 2024, 2:28 a.m. UTC
We are going to support MLO/DBCC, so need to load parameter table to
PHY-1 as well.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/phy.c | 29 ++++++++++++++++--------
 1 file changed, 20 insertions(+), 9 deletions(-)

Comments

kernel test robot Feb. 9, 2024, 12:50 a.m. UTC | #1
Hi Ping-Ke,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on next-20240208]
[cannot apply to wireless/main linus/master v6.8-rc3]
[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/Ping-Ke-Shih/wifi-rtw89-correct-PHY-register-offset-for-PHY-1/20240208-103413
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20240208022857.14379-3-pkshih%40realtek.com
patch subject: [PATCH 02/11] wifi: rtw89: load BB parameters to PHY-1
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240209/202402090838.S5xcKIlg-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 7dd790db8b77c4a833c06632e903dc4f13877a64)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240209/202402090838.S5xcKIlg-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402090838.S5xcKIlg-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/realtek/rtw89/phy.c:1047:7: warning: cast to smaller integer type 'enum rtw89_phy_idx' from 'void *' [-Wvoid-pointer-to-enum-cast]
    1047 |                 if ((enum rtw89_phy_idx)extra_data == RTW89_PHY_1)
         |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.


vim +1047 drivers/net/wireless/realtek/rtw89/phy.c

  1022	
  1023	static void rtw89_phy_config_bb_reg(struct rtw89_dev *rtwdev,
  1024					    const struct rtw89_reg2_def *reg,
  1025					    enum rtw89_rf_path rf_path,
  1026					    void *extra_data)
  1027	{
  1028		u32 addr;
  1029	
  1030		if (reg->addr == 0xfe) {
  1031			mdelay(50);
  1032		} else if (reg->addr == 0xfd) {
  1033			mdelay(5);
  1034		} else if (reg->addr == 0xfc) {
  1035			mdelay(1);
  1036		} else if (reg->addr == 0xfb) {
  1037			udelay(50);
  1038		} else if (reg->addr == 0xfa) {
  1039			udelay(5);
  1040		} else if (reg->addr == 0xf9) {
  1041			udelay(1);
  1042		} else if (reg->data == BYPASS_CR_DATA) {
  1043			rtw89_debug(rtwdev, RTW89_DBG_PHY_TRACK, "Bypass CR 0x%x\n", reg->addr);
  1044		} else {
  1045			addr = reg->addr;
  1046	
> 1047			if ((enum rtw89_phy_idx)extra_data == RTW89_PHY_1)
  1048				addr += rtw89_phy0_phy1_offset(rtwdev, reg->addr);
  1049	
  1050			rtw89_phy_write32(rtwdev, addr, reg->data);
  1051		}
  1052	}
  1053
Ping-Ke Shih Feb. 9, 2024, 7:03 a.m. UTC | #2
On Fri, 2024-02-09 at 08:50 +0800, kernel test robot wrote:
> 
> 
> > > drivers/net/wireless/realtek/rtw89/phy.c:1047:7: warning: cast to smaller integer type 'enum
> > > rtw89_phy_idx' from 'void *' [-Wvoid-pointer-to-enum-cast]
>     1047 |                 if ((enum rtw89_phy_idx)extra_data == RTW89_PHY_1)
>          |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    1 warning generated.
> 
> 
> vim +1047 drivers/net/wireless/realtek/rtw89/phy.c
> 
>   1022
>   1023  static void rtw89_phy_config_bb_reg(struct rtw89_dev *rtwdev,
>   1024                                      const struct rtw89_reg2_def *reg,
>   1025                                      enum rtw89_rf_path rf_path,
>   1026                                      void *extra_data)
>   1027  {
>   1028          u32 addr;
>   1029
>   1030          if (reg->addr == 0xfe) {
>   1031                  mdelay(50);
>   1032          } else if (reg->addr == 0xfd) {
>   1033                  mdelay(5);
>   1034          } else if (reg->addr == 0xfc) {
>   1035                  mdelay(1);
>   1036          } else if (reg->addr == 0xfb) {
>   1037                  udelay(50);
>   1038          } else if (reg->addr == 0xfa) {
>   1039                  udelay(5);
>   1040          } else if (reg->addr == 0xf9) {
>   1041                  udelay(1);
>   1042          } else if (reg->data == BYPASS_CR_DATA) {
>   1043                  rtw89_debug(rtwdev, RTW89_DBG_PHY_TRACK, "Bypass CR 0x%x\n", reg->addr);
>   1044          } else {
>   1045                  addr = reg->addr;
>   1046
> > 1047                  if ((enum rtw89_phy_idx)extra_data == RTW89_PHY_1)
>   1048                          addr += rtw89_phy0_phy1_offset(rtwdev, reg->addr);
>   1049
>   1050                  rtw89_phy_write32(rtwdev, addr, reg->data);
>   1051          }
>   1052  }
> 

This function is one of callback function of 'config' argument of rtw89_phy_init_reg().

static void rtw89_phy_init_reg(struct rtw89_dev *rtwdev,
			       const struct rtw89_phy_table *table,
			       void (*config)(struct rtw89_dev *rtwdev,
					      const struct rtw89_reg2_def *reg,
					      enum rtw89_rf_path rf_path,
					      void *data),
			       void *extra_data)

The 'void *extra_data' is explained by callback function 'config', and there are
many existing callback functions. To simply suppress this warning , I plan to
cast 'extra_data' from 'void *' by 'uintptr_t' to avoid clang warning, and gcc
can also accept this. I did this by v2.


Ping-Ke
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index 7c2f0ba996b1..389eb01d303c 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -1025,22 +1025,30 @@  static void rtw89_phy_config_bb_reg(struct rtw89_dev *rtwdev,
 				    enum rtw89_rf_path rf_path,
 				    void *extra_data)
 {
-	if (reg->addr == 0xfe)
+	u32 addr;
+
+	if (reg->addr == 0xfe) {
 		mdelay(50);
-	else if (reg->addr == 0xfd)
+	} else if (reg->addr == 0xfd) {
 		mdelay(5);
-	else if (reg->addr == 0xfc)
+	} else if (reg->addr == 0xfc) {
 		mdelay(1);
-	else if (reg->addr == 0xfb)
+	} else if (reg->addr == 0xfb) {
 		udelay(50);
-	else if (reg->addr == 0xfa)
+	} else if (reg->addr == 0xfa) {
 		udelay(5);
-	else if (reg->addr == 0xf9)
+	} else if (reg->addr == 0xf9) {
 		udelay(1);
-	else if (reg->data == BYPASS_CR_DATA)
+	} else if (reg->data == BYPASS_CR_DATA) {
 		rtw89_debug(rtwdev, RTW89_DBG_PHY_TRACK, "Bypass CR 0x%x\n", reg->addr);
-	else
-		rtw89_phy_write32(rtwdev, reg->addr, reg->data);
+	} else {
+		addr = reg->addr;
+
+		if ((enum rtw89_phy_idx)extra_data == RTW89_PHY_1)
+			addr += rtw89_phy0_phy1_offset(rtwdev, reg->addr);
+
+		rtw89_phy_write32(rtwdev, addr, reg->data);
+	}
 }
 
 union rtw89_phy_bb_gain_arg {
@@ -1554,6 +1562,9 @@  void rtw89_phy_init_bb_reg(struct rtw89_dev *rtwdev)
 
 	bb_table = elm_info->bb_tbl ? elm_info->bb_tbl : chip->bb_table;
 	rtw89_phy_init_reg(rtwdev, bb_table, rtw89_phy_config_bb_reg, NULL);
+	if (rtwdev->dbcc_en)
+		rtw89_phy_init_reg(rtwdev, bb_table, rtw89_phy_config_bb_reg,
+				   (void *)RTW89_PHY_1);
 	rtw89_chip_init_txpwr_unit(rtwdev, RTW89_PHY_0);
 
 	bb_gain_table = elm_info->bb_gain ? elm_info->bb_gain : chip->bb_gain_table;