Re: [PATCH rdma-next v6] RDMA: Change capability fields in ib_device_attr from int to u32

Bart Van Assche <[email protected]>
Newsgroups gmane.linux.scsi.target.devel,gmane.linux.drivers.rdma,gmane.linux.kernel,gmane.linux.kernel.cifs,gmane.network.samba.internals,gmane.linux.nfs
Message-ID <[email protected]>
On 6/1/26 2:25 AM, Erni Sri Satya Vennela wrote:
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index b58868e1cf11..dc30d069ab3d 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -557,7 +557,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
>   	init_attr->cap.max_send_wr     = m * target->queue_size;
>   	init_attr->cap.max_recv_wr     = target->queue_size + 1;
>   	init_attr->cap.max_recv_sge    = 1;
> -	init_attr->cap.max_send_sge    = min(SRP_MAX_SGE, attr->max_send_sge);
> +	init_attr->cap.max_send_sge    = min_t(u32, SRP_MAX_SGE, attr->max_send_sge);
>   	init_attr->sq_sig_type         = IB_SIGNAL_REQ_WR;
>   	init_attr->qp_type             = IB_QPT_RC;
>   	init_attr->send_cq             = send_cq;
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 9aec5d80117f..2ffa4f54cd4e 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -1884,7 +1884,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
>   	 * both both, as RDMA contexts will also post completions for the
>   	 * RDMA READ case.
>   	 */
> -	qp_init->cap.max_send_wr = min(sq_size / 2, attrs->max_qp_wr);
> +	qp_init->cap.max_send_wr = min_t(u32, sq_size / 2, attrs->max_qp_wr);
>   	qp_init->cap.max_rdma_ctxs = sq_size / 2;
>   	qp_init->cap.max_send_sge = attrs->max_send_sge;
>   	qp_init->cap.max_recv_sge = 1;
> @@ -2298,7 +2298,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>   	 * depth to avoid that the initiator driver has to report QUEUE_FULL
>   	 * to the SCSI mid-layer.
>   	 */
> -	ch->rq_size = min(MAX_SRPT_RQ_SIZE, sdev->device->attrs.max_qp_wr);
> +	ch->rq_size = min_t(u32, MAX_SRPT_RQ_SIZE, sdev->device->attrs.max_qp_wr);
>   	spin_lock_init(&ch->spinlock);
>   	ch->state = CH_CONNECTING;
>   	INIT_LIST_HEAD(&ch->cmd_wait_list);
> @@ -3225,7 +3225,7 @@ static int srpt_add_one(struct ib_device *device)
>   
>   	sdev->lkey = sdev->pd->local_dma_lkey;
>   
> -	sdev->srq_size = min(srpt_srq_size, sdev->device->attrs.max_srq_wr);
> +	sdev->srq_size = min_t(u32, srpt_srq_size, sdev->device->attrs.max_srq_wr);
>   
>   	srpt_use_srq(sdev, sdev->port[0].port_attrib.use_srq);

min_t() shouldn't be used if there is an alternative available. For the
SRP drivers, please make sure that both arguments of min() are unsigned
instead of using min_t().

Thanks,

Bart.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.