From patchwork Tue Apr 12 14:13:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 8810881 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 97295C0553 for ; Tue, 12 Apr 2016 14:13:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1EE32028D for ; Tue, 12 Apr 2016 14:13:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D811F202D1 for ; Tue, 12 Apr 2016 14:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934110AbcDLONh (ORCPT ); Tue, 12 Apr 2016 10:13:37 -0400 Received: from casper.infradead.org ([85.118.1.10]:49160 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934105AbcDLONg (ORCPT ); Tue, 12 Apr 2016 10:13:36 -0400 Received: from [198.0.48.213] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.85_2 #1 (Red Hat Linux)) id 1apz4Q-0005z3-K4; Tue, 12 Apr 2016 14:13:35 +0000 From: Christoph Hellwig To: linux-rdma@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH 1/2] scsi: add a max_segment_size limitation to struct Scsi_Host Date: Tue, 12 Apr 2016 07:13:24 -0700 Message-Id: <1460470405-11673-2-git-send-email-hch@lst.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460470405-11673-1-git-send-email-hch@lst.de> References: <1460470405-11673-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP RDMA drivers need segments that aren't larger than a single HCA page for memory registrations to work properly, so wire up this limitation in the host. While we could just call blk_queue_max_segment_size from ->slave_configure, that would override the global limit based on the DMA device, so let's do it the traditional way by adding a field to the Scsi_Host structure. Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- drivers/scsi/scsi_lib.c | 3 ++- include/scsi/scsi_host.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 8106515..ad79372 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2120,7 +2120,8 @@ static void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) blk_queue_segment_boundary(q, shost->dma_boundary); dma_set_seg_boundary(dev, shost->dma_boundary); - blk_queue_max_segment_size(q, dma_get_max_seg_size(dev)); + blk_queue_max_segment_size(q, min_not_zero(shost->max_segment_size, + dma_get_max_seg_size(dev))); if (!shost->use_clustering) q->limits.cluster = 0; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index fcfa3d7..f11d3fe 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -621,6 +621,7 @@ struct Scsi_Host { short unsigned int sg_tablesize; short unsigned int sg_prot_tablesize; unsigned int max_sectors; + unsigned int max_segment_size; unsigned long dma_boundary; /* * In scsi-mq mode, the number of hardware queues supported by the LLD.