]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/srp: Honor the max_send_sge device attribute
authorBart Van Assche <bvanassche@acm.org>
Mon, 30 Sep 2019 23:16:59 +0000 (16:16 -0700)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 4 Oct 2019 18:35:06 +0000 (15:35 -0300)
Instead of assuming that max_send_sge >= 3, restrict the number of scatter
gather elements to what is supported by the RDMA adapter.

Link: https://lore.kernel.org/r/20190930231707.48259-8-bvanassche@acm.org
Cc: Honggang LI <honli@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/ulp/srp/ib_srp.c
drivers/infiniband/ulp/srp/ib_srp.h

index f015dc4ce22cb4d2caaa618ffed2585681cfab4c..d77e7dd3e7455369598acec0f4051b11dfe3bf22 100644 (file)
@@ -552,6 +552,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch)
 {
        struct srp_target_port *target = ch->target;
        struct srp_device *dev = target->srp_host->srp_dev;
+       const struct ib_device_attr *attr = &dev->dev->attrs;
        struct ib_qp_init_attr *init_attr;
        struct ib_cq *recv_cq, *send_cq;
        struct ib_qp *qp;
@@ -583,12 +584,14 @@ 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    = SRP_MAX_SGE;
+       init_attr->cap.max_send_sge    = min(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;
        init_attr->recv_cq             = recv_cq;
 
+       ch->max_imm_sge = min(init_attr->cap.max_send_sge - 1U, 255U);
+
        if (target->using_rdma_cm) {
                ret = rdma_create_qp(ch->rdma_cm.cm_id, dev->pd, init_attr);
                qp = ch->rdma_cm.cm_id->qp;
@@ -1838,7 +1841,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,
                return -EIO;
 
        if (ch->use_imm_data &&
-           count <= SRP_MAX_IMM_SGE &&
+           count <= ch->max_imm_sge &&
            SRP_IMM_DATA_OFFSET + data_len <= ch->max_it_iu_len &&
            scmnd->sc_data_direction == DMA_TO_DEVICE) {
                struct srp_imm_buf *buf;
index af9922550ae1ccac978b8f778f1d6f9338200878..f38fbb00d0e8c2157fdbca0cfc15efb98fb0b3fb 100644 (file)
@@ -161,6 +161,7 @@ struct srp_rdma_ch {
        };
        uint32_t                max_it_iu_len;
        uint32_t                max_ti_iu_len;
+       u8                      max_imm_sge;
        bool                    use_imm_data;
 
        /* Everything above this point is used in the hot path of