Re: drivers/net/ethernet/toshiba/ps3_gelic_net.c:330:33: sparse: sparse: incorrect type in assignment (different base types)
From: Geoff Levand
Date: Fri Dec 15 2023 - 03:14:22 EST
Hi,
On 12/14/23 23:51, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 5bd7ef53ffe5ca580e93e74eb8c81ed191ddc4bd
> commit: bebe933d35a63d4f042fbf4dce4f22e689ba0fcd net/ps3_gelic_net: Use dma_mapping_error
> date: 9 months ago
> config: powerpc64-randconfig-r122-20231213 (https://download.01.org/0day-ci/archive/20231214/202312142250.7GMllD1E-lkp@xxxxxxxxx/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> reproduce: (https://download.01.org/0day-ci/archive/20231214/202312142250.7GMllD1E-lkp@xxxxxxxxx/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@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202312142250.7GMllD1E-lkp@xxxxxxxxx/
>
> sparse warnings: (new ones prefixed by >>)
>>> drivers/net/ethernet/toshiba/ps3_gelic_net.c:330:33: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long long [usertype] bus_addr @@ got restricted __be32 [usertype] @@
> drivers/net/ethernet/toshiba/ps3_gelic_net.c:330:33: sparse: expected unsigned long long [usertype] bus_addr
> drivers/net/ethernet/toshiba/ps3_gelic_net.c:330:33: sparse: got restricted __be32 [usertype]
>
> vim +330 drivers/net/ethernet/toshiba/ps3_gelic_net.c
>
> 295
> 296 /**
> 297 * gelic_card_init_chain - links descriptor chain
> 298 * @card: card structure
> 299 * @chain: address of chain
> 300 * @start_descr: address of descriptor array
> 301 * @no: number of descriptors
> 302 *
> 303 * we manage a circular list that mirrors the hardware structure,
> 304 * except that the hardware uses bus addresses.
> 305 *
> 306 * returns 0 on success, <0 on failure
> 307 */
> 308 static int gelic_card_init_chain(struct gelic_card *card,
> 309 struct gelic_descr_chain *chain,
> 310 struct gelic_descr *start_descr, int no)
> 311 {
> 312 int i;
> 313 struct gelic_descr *descr;
> 314
> 315 descr = start_descr;
> 316 memset(descr, 0, sizeof(*descr) * no);
> 317
> 318 /* set up the hardware pointers in each descriptor */
> 319 for (i = 0; i < no; i++, descr++) {
> 320 dma_addr_t cpu_addr;
> 321
> 322 gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
> 323
> 324 cpu_addr = dma_map_single(ctodev(card), descr,
> 325 GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL);
> 326
> 327 if (dma_mapping_error(ctodev(card), cpu_addr))
> 328 goto iommu_error;
> 329
> > 330 descr->bus_addr = cpu_to_be32(cpu_addr);
The values of the gelic hardware descriptors are all be32. I think what we
want is to force cpu_addr to be32 so the conversion to be32 won't give a
warning, so something like this:
descr->bus_addr = cpu_to_be32((__force __be32)cpu_addr);
I'll prepare a patch and submit after some testing.
-Geoff