]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/srp: Increase max_segment_size
authorBart Van Assche <bvanassche@acm.org>
Tue, 22 Jan 2019 18:25:20 +0000 (10:25 -0800)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 30 Jan 2019 22:04:16 +0000 (15:04 -0700)
The default behavior of the SCSI core is to set the block layer request
queue parameter max_segment_size to 64 KB. That means that elements of
scatterlists are limited to 64 KB. Since RDMA adapters support larger
sizes, increase max_segment_size for the SRP initiator.

Notes:
- The SCSI max_segment_size parameter was introduced in kernel v5.0. See
  also commit 50c2e9107f17 ("scsi: introduce a max_segment_size
  host_template parameters").
- Some other block drivers already set max_segment_size to UINT_MAX,
  e.g. nbd and rbd.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/ulp/srp/ib_srp.c
include/rdma/ib_verbs.h

index 0f855294ff3f7e64cd374646ca7c2a2ce82b0b65..29fe46dbdbf14b0731854d4f854b2fb070e7f8a5 100644 (file)
@@ -3823,6 +3823,7 @@ static ssize_t srp_create_target(struct device *dev,
        target_host->max_id      = 1;
        target_host->max_lun     = -1LL;
        target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
+       target_host->max_segment_size = ib_dma_max_seg_size(ibdev);
 
        target = host_to_target(target_host);
 
index 94b6e1dd4dab70fea70e4a2482bc17fb3b2c4c0a..71ea144ec823a2c1eedbf6a8c056dbb3c3f4873c 100644 (file)
@@ -3715,6 +3715,19 @@ static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
        return sg_dma_len(sg);
 }
 
+/**
+ * ib_dma_max_seg_size - Return the size limit of a single DMA transfer
+ * @dev: The device to query
+ *
+ * The returned value represents a size in bytes.
+ */
+static inline unsigned int ib_dma_max_seg_size(struct ib_device *dev)
+{
+       struct device_dma_parameters *p = dev->dma_device->dma_parms;
+
+       return p ? p->max_segment_size : UINT_MAX;
+}
+
 /**
  * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU
  * @dev: The device for which the DMA address was created