[openib-general] Re: [PATCH 1/2] (fixed) mthca: max_inline_data support

Michael S. Tsirkin mst at mellanox.co.il
Mon May 16 12:16:51 PDT 2005


Quoting r. Roland Dreier <roland at topspin.com>:
> Subject: Re: [PATCH 1/2] (fixed) mthca: max_inline_data support
> 
>     Michael> Roland, roundup_pow_of_two assumes that it gets a non-0
>     Michael> parameter, while I think its legal to have one of
>     Michael> max_recv_wr / max_send_wr equal 0.  Is that right?
> 
> Yes, good point.  I forgot about the possibility of zero-length work queues.
> 
> --- infiniband/hw/mthca/mthca_qp.c	(revision 2347)
> +++ infiniband/hw/mthca/mthca_qp.c	(working copy)
> @@ -1211,8 +1211,10 @@ static int mthca_set_qp_size(struct mthc
>  			     struct mthca_qp *qp)
>  {
>  	if (mthca_is_memfree(dev)) {
> -		qp->rq.max = roundup_pow_of_two(cap->max_recv_wr);
> -		qp->sq.max = roundup_pow_of_two(cap->max_send_wr);
> +		qp->rq.max = cap->max_recv_wr ?
> +			roundup_pow_of_two(cap->max_recv_wr) : 0;
> +		qp->sq.max = cap->max_send_wr ?
> +			roundup_pow_of_two(cap->max_send_wr) : 0;

Another problem is that fls may return 32 and you end up with
1 << 32 which AFAIK has undefined behaviour in C.
I guess kernel clients can be trusted not to, but uverbs better
check this.

-- 
MST - Michael S. Tsirkin



More information about the general mailing list