[ammarfaizi2-block:netdev/net-next/master 14/42] drivers/net/ethernet/mediatek/mtk_wed.c:150:36: sparse: sparse: incorrect type in assignment (different base types)

From: kernel test robot
Date: Fri Apr 08 2022 - 02:27:29 EST


tree: https://github.com/ammarfaizi2/linux-block netdev/net-next/master
head: 26894cd971168d14fd8f4c05435aef59188c9514
commit: 804775dfc2885e93a0a4b35db1914c2cc25172b5 [14/42] net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20220408/202204081425.TYsvmLDr-lkp@xxxxxxxxx/config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/ammarfaizi2/linux-block/commit/804775dfc2885e93a0a4b35db1914c2cc25172b5
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block netdev/net-next/master
git checkout 804775dfc2885e93a0a4b35db1914c2cc25172b5
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=m68k SHELL=/bin/bash drivers/net/ethernet/mediatek/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/mediatek/mtk_wed.c:150:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] buf0 @@ got unsigned int [assigned] [usertype] buf_phys @@
drivers/net/ethernet/mediatek/mtk_wed.c:150:36: sparse: expected restricted __le32 [usertype] buf0
drivers/net/ethernet/mediatek/mtk_wed.c:150:36: sparse: got unsigned int [assigned] [usertype] buf_phys
>> drivers/net/ethernet/mediatek/mtk_wed.c:151:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] buf1 @@ got unsigned int @@
drivers/net/ethernet/mediatek/mtk_wed.c:151:36: sparse: expected restricted __le32 [usertype] buf1
drivers/net/ethernet/mediatek/mtk_wed.c:151:36: sparse: got unsigned int
>> drivers/net/ethernet/mediatek/mtk_wed.c:152:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] ctrl @@ got unsigned long @@
drivers/net/ethernet/mediatek/mtk_wed.c:152:36: sparse: expected restricted __le32 [usertype] ctrl
drivers/net/ethernet/mediatek/mtk_wed.c:152:36: sparse: got unsigned long
>> drivers/net/ethernet/mediatek/mtk_wed.c:191:17: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [usertype] addr @@ got restricted __le32 [usertype] buf0 @@
drivers/net/ethernet/mediatek/mtk_wed.c:191:17: sparse: expected unsigned int [usertype] addr
drivers/net/ethernet/mediatek/mtk_wed.c:191:17: sparse: got restricted __le32 [usertype] buf0

vim +150 drivers/net/ethernet/mediatek/mtk_wed.c

91
92 static int
93 mtk_wed_buffer_alloc(struct mtk_wed_device *dev)
94 {
95 struct mtk_wdma_desc *desc;
96 dma_addr_t desc_phys;
97 void **page_list;
98 int token = dev->wlan.token_start;
99 int ring_size;
100 int n_pages;
101 int i, page_idx;
102
103 ring_size = dev->wlan.nbuf & ~(MTK_WED_BUF_PER_PAGE - 1);
104 n_pages = ring_size / MTK_WED_BUF_PER_PAGE;
105
106 page_list = kcalloc(n_pages, sizeof(*page_list), GFP_KERNEL);
107 if (!page_list)
108 return -ENOMEM;
109
110 dev->buf_ring.size = ring_size;
111 dev->buf_ring.pages = page_list;
112
113 desc = dma_alloc_coherent(dev->hw->dev, ring_size * sizeof(*desc),
114 &desc_phys, GFP_KERNEL);
115 if (!desc)
116 return -ENOMEM;
117
118 dev->buf_ring.desc = desc;
119 dev->buf_ring.desc_phys = desc_phys;
120
121 for (i = 0, page_idx = 0; i < ring_size; i += MTK_WED_BUF_PER_PAGE) {
122 dma_addr_t page_phys, buf_phys;
123 struct page *page;
124 void *buf;
125 int s;
126
127 page = __dev_alloc_pages(GFP_KERNEL, 0);
128 if (!page)
129 return -ENOMEM;
130
131 page_phys = dma_map_page(dev->hw->dev, page, 0, PAGE_SIZE,
132 DMA_BIDIRECTIONAL);
133 if (dma_mapping_error(dev->hw->dev, page_phys)) {
134 __free_page(page);
135 return -ENOMEM;
136 }
137
138 page_list[page_idx++] = page;
139 dma_sync_single_for_cpu(dev->hw->dev, page_phys, PAGE_SIZE,
140 DMA_BIDIRECTIONAL);
141
142 buf = page_to_virt(page);
143 buf_phys = page_phys;
144
145 for (s = 0; s < MTK_WED_BUF_PER_PAGE; s++) {
146 u32 txd_size;
147
148 txd_size = dev->wlan.init_buf(buf, buf_phys, token++);
149
> 150 desc->buf0 = buf_phys;
> 151 desc->buf1 = buf_phys + txd_size;
> 152 desc->ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0,
153 txd_size) |
154 FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1,
155 MTK_WED_BUF_SIZE - txd_size) |
156 MTK_WDMA_DESC_CTRL_LAST_SEG1;
157 desc->info = 0;
158 desc++;
159
160 buf += MTK_WED_BUF_SIZE;
161 buf_phys += MTK_WED_BUF_SIZE;
162 }
163
164 dma_sync_single_for_device(dev->hw->dev, page_phys, PAGE_SIZE,
165 DMA_BIDIRECTIONAL);
166 }
167
168 return 0;
169 }
170
171 static void
172 mtk_wed_free_buffer(struct mtk_wed_device *dev)
173 {
174 struct mtk_wdma_desc *desc = dev->buf_ring.desc;
175 void **page_list = dev->buf_ring.pages;
176 int page_idx;
177 int i;
178
179 if (!page_list)
180 return;
181
182 if (!desc)
183 goto free_pagelist;
184
185 for (i = 0, page_idx = 0; i < dev->buf_ring.size; i += MTK_WED_BUF_PER_PAGE) {
186 void *page = page_list[page_idx++];
187
188 if (!page)
189 break;
190
> 191 dma_unmap_page(dev->hw->dev, desc[i].buf0,
192 PAGE_SIZE, DMA_BIDIRECTIONAL);
193 __free_page(page);
194 }
195
196 dma_free_coherent(dev->hw->dev, dev->buf_ring.size * sizeof(*desc),
197 desc, dev->buf_ring.desc_phys);
198
199 free_pagelist:
200 kfree(page_list);
201 }
202

--
0-DAY CI Kernel Test Service
https://01.org/lkp