Re: [PATCH for-next 1/1] IB/{hw,sw}: remove 'uobject->context' dependency in object creation APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Shamir,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on next-20190116]
[cannot apply to v5.0-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Shamir-Rabinovitch/IB-hw-sw-remove-uobject-context-dependency-in-object-creation-APIs/20190118-132047
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=xtensa 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/infiniband/hw/mlx4/srq.c: In function 'mlx4_ib_create_srq':
>> drivers/infiniband/hw/mlx4/srq.c:212:3: warning: 'ib_ucontext' may be used uninitialized in this function [-Wmaybe-uninitialized]
      mlx4_ib_db_unmap_user(to_mucontext(ib_ucontext), &srq->db);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/ib_ucontext +212 drivers/infiniband/hw/mlx4/srq.c

    70	
    71	struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd,
    72					  struct ib_srq_init_attr *init_attr,
    73					  struct ib_udata *udata)
    74	{
    75		struct mlx4_ib_dev *dev = to_mdev(pd->device);
    76		struct mlx4_ib_srq *srq;
    77		struct mlx4_wqe_srq_next_seg *next;
    78		struct mlx4_wqe_data_seg *scatter;
    79		struct ib_ucontext *ib_ucontext;
    80		u32 cqn;
    81		u16 xrcdn;
    82		int desc_size;
    83		int buf_size;
    84		int err;
    85		int i;
    86	
    87		/* Sanity check SRQ size before proceeding */
    88		if (init_attr->attr.max_wr  >= dev->dev->caps.max_srq_wqes ||
    89		    init_attr->attr.max_sge >  dev->dev->caps.max_srq_sge)
    90			return ERR_PTR(-EINVAL);
    91	
    92		srq = kmalloc(sizeof *srq, GFP_KERNEL);
    93		if (!srq)
    94			return ERR_PTR(-ENOMEM);
    95	
    96		mutex_init(&srq->mutex);
    97		spin_lock_init(&srq->lock);
    98		srq->msrq.max    = roundup_pow_of_two(init_attr->attr.max_wr + 1);
    99		srq->msrq.max_gs = init_attr->attr.max_sge;
   100	
   101		desc_size = max(32UL,
   102				roundup_pow_of_two(sizeof (struct mlx4_wqe_srq_next_seg) +
   103						   srq->msrq.max_gs *
   104						   sizeof (struct mlx4_wqe_data_seg)));
   105		srq->msrq.wqe_shift = ilog2(desc_size);
   106	
   107		buf_size = srq->msrq.max * desc_size;
   108	
   109		if (udata) {
   110			struct mlx4_ib_create_srq ucmd;
   111	
   112			ib_ucontext = rdma_get_ucontext(udata);
   113			if (IS_ERR(ib_ucontext)) {
   114				err = PTR_ERR(ib_ucontext);
   115				goto err_srq;
   116			}
   117	
   118			if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
   119				err = -EFAULT;
   120				goto err_srq;
   121			}
   122	
   123			srq->umem = ib_umem_get(udata, ucmd.buf_addr, buf_size, 0, 0);
   124			if (IS_ERR(srq->umem)) {
   125				err = PTR_ERR(srq->umem);
   126				goto err_srq;
   127			}
   128	
   129			err = mlx4_mtt_init(dev->dev, ib_umem_page_count(srq->umem),
   130					    srq->umem->page_shift, &srq->mtt);
   131			if (err)
   132				goto err_buf;
   133	
   134			err = mlx4_ib_umem_write_mtt(dev, &srq->mtt, srq->umem);
   135			if (err)
   136				goto err_mtt;
   137	
   138			err = mlx4_ib_db_map_user(to_mucontext(ib_ucontext), udata,
   139						  ucmd.db_addr, &srq->db);
   140			if (err)
   141				goto err_mtt;
   142		} else {
   143			err = mlx4_db_alloc(dev->dev, &srq->db, 0);
   144			if (err)
   145				goto err_srq;
   146	
   147			*srq->db.db = 0;
   148	
   149			if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2,
   150					   &srq->buf)) {
   151				err = -ENOMEM;
   152				goto err_db;
   153			}
   154	
   155			srq->head    = 0;
   156			srq->tail    = srq->msrq.max - 1;
   157			srq->wqe_ctr = 0;
   158	
   159			for (i = 0; i < srq->msrq.max; ++i) {
   160				next = get_wqe(srq, i);
   161				next->next_wqe_index =
   162					cpu_to_be16((i + 1) & (srq->msrq.max - 1));
   163	
   164				for (scatter = (void *) (next + 1);
   165				     (void *) scatter < (void *) next + desc_size;
   166				     ++scatter)
   167					scatter->lkey = cpu_to_be32(MLX4_INVALID_LKEY);
   168			}
   169	
   170			err = mlx4_mtt_init(dev->dev, srq->buf.npages, srq->buf.page_shift,
   171					    &srq->mtt);
   172			if (err)
   173				goto err_buf;
   174	
   175			err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf);
   176			if (err)
   177				goto err_mtt;
   178	
   179			srq->wrid = kvmalloc_array(srq->msrq.max,
   180						   sizeof(u64), GFP_KERNEL);
   181			if (!srq->wrid) {
   182				err = -ENOMEM;
   183				goto err_mtt;
   184			}
   185		}
   186	
   187		cqn = ib_srq_has_cq(init_attr->srq_type) ?
   188			to_mcq(init_attr->ext.cq)->mcq.cqn : 0;
   189		xrcdn = (init_attr->srq_type == IB_SRQT_XRC) ?
   190			to_mxrcd(init_attr->ext.xrc.xrcd)->xrcdn :
   191			(u16) dev->dev->caps.reserved_xrcds;
   192		err = mlx4_srq_alloc(dev->dev, to_mpd(pd)->pdn, cqn, xrcdn, &srq->mtt,
   193				     srq->db.dma, &srq->msrq);
   194		if (err)
   195			goto err_wrid;
   196	
   197		srq->msrq.event = mlx4_ib_srq_event;
   198		srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn;
   199	
   200		if (udata)
   201			if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof (__u32))) {
   202				err = -EFAULT;
   203				goto err_wrid;
   204			}
   205	
   206		init_attr->attr.max_wr = srq->msrq.max - 1;
   207	
   208		return &srq->ibsrq;
   209	
   210	err_wrid:
   211		if (udata)
 > 212			mlx4_ib_db_unmap_user(to_mucontext(ib_ucontext), &srq->db);
   213		else
   214			kvfree(srq->wrid);
   215	
   216	err_mtt:
   217		mlx4_mtt_cleanup(dev->dev, &srq->mtt);
   218	
   219	err_buf:
   220		if (srq->umem)
   221			ib_umem_release(srq->umem);
   222		else
   223			mlx4_buf_free(dev->dev, buf_size, &srq->buf);
   224	
   225	err_db:
   226		if (!udata)
   227			mlx4_db_free(dev->dev, &srq->db);
   228	
   229	err_srq:
   230		kfree(srq);
   231	
   232		return ERR_PTR(err);
   233	}
   234	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux