Re: [PATCH net-next 12/18] net/smc: implement DMB-related operations of loopback

Wen Gu
2023-09-24T08:54:15Z

On 2023/9/23 23:24, kernel test robot wrote:
> Hi Wen,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on net-next/main]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Wen-Gu/net-smc-decouple-ism_dev-from-SMC-D-device-dump/20230920-010019
> base: net-next/main
> patch link: https://lore.kernel.org/r/1695134522-126655-13-git-send-email-guwen%40linux.alibaba.com
> patch subject: [PATCH net-next 12/18] net/smc: implement DMB-related operations of loopback
> config: arc-allmodconfig (https://download.01.org/0day-ci/archive/20230923/202309232327.nzXalNsH-lkp@intel.com/config)
> compiler: arceb-elf-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230923/202309232327.nzXalNsH-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/202309232327.nzXalNsH-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> net/smc/smc_loopback.c: In function 'smc_lo_register_dmb':
>>> net/smc/smc_loopback.c:107:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 107 | dmb_node->dma_addr = (dma_addr_t)dmb_node->cpu_addr;
> | ^
>
>

Will fix it on v4. Thanks!

> vim +107 net/smc/smc_loopback.c
>
> 76
> 77 static int smc_lo_register_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb,
> 78 void *client_priv)
> 79 {
> 80 struct smc_lo_dmb_node *dmb_node, *tmp_node;
> 81 struct smc_lo_dev *ldev = smcd->priv;
> 82 int sba_idx, rc;
> 83
> 84 /* check space for new dmb */
> 85 for_each_clear_bit(sba_idx, ldev->sba_idx_mask, SMC_LODEV_MAX_DMBS) {
> 86 if (!test_and_set_bit(sba_idx, ldev->sba_idx_mask))
> 87 break;
> 88 }
> 89 if (sba_idx == SMC_LODEV_MAX_DMBS)
> 90 return -ENOSPC;
> 91
> 92 dmb_node = kzalloc(sizeof(*dmb_node), GFP_KERNEL);
> 93 if (!dmb_node) {
> 94 rc = -ENOMEM;
> 95 goto err_bit;
> 96 }
> 97
> 98 dmb_node->sba_idx = sba_idx;
> 99 dmb_node->cpu_addr = kzalloc(dmb->dmb_len, GFP_KERNEL |
> 100 __GFP_NOWARN | __GFP_NORETRY |
> 101 __GFP_NOMEMALLOC);
> 102 if (!dmb_node->cpu_addr) {
> 103 rc = -ENOMEM;
> 104 goto err_node;
> 105 }
> 106 dmb_node->len = dmb->dmb_len;
> > 107 dmb_node->dma_addr = (dma_addr_t)dmb_node->cpu_addr;
> 108
> 109 again:
> 110 /* add new dmb into hash table */
> 111 get_random_bytes(&dmb_node->token, sizeof(dmb_node->token));
> 112 write_lock(&ldev->dmb_ht_lock);
> 113 hash_for_each_possible(ldev->dmb_ht, tmp_node, list, dmb_node->token) {
> 114 if (tmp_node->token == dmb_node->token) {
> 115 write_unlock(&ldev->dmb_ht_lock);
> 116 goto again;
> 117 }
> 118 }
> 119 hash_add(ldev->dmb_ht, &dmb_node->list, dmb_node->token);
> 120 write_unlock(&ldev->dmb_ht_lock);
> 121
> 122 dmb->sba_idx = dmb_node->sba_idx;
> 123 dmb->dmb_tok = dmb_node->token;
> 124 dmb->cpu_addr = dmb_node->cpu_addr;
> 125 dmb->dma_addr = dmb_node->dma_addr;
> 126 dmb->dmb_len = dmb_node->len;
> 127
> 128 return 0;
> 129
> 130 err_node:
> 131 kfree(dmb_node);
> 132 err_bit:
> 133 clear_bit(sba_idx, ldev->sba_idx_mask);
> 134 return rc;
> 135 }
> 136
>