Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp435677imw; Thu, 14 Jul 2022 04:25:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vrQMYW07f8O+zJ6HlCmuJsgwrLfD1AMD8mcvlKnrnrpUxg5CrsIfMnBz+HRD9gxISPt5Ao X-Received: by 2002:a05:6402:3681:b0:43a:7c29:466a with SMTP id ej1-20020a056402368100b0043a7c29466amr11500537edb.367.1657797903105; Thu, 14 Jul 2022 04:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657797903; cv=none; d=google.com; s=arc-20160816; b=FEuLG4YD3A7Bd6J4AaoJwlf7Fd3dTKkZgVH3rq3UwhfYHt1vM6NdZW68hjPV7vdzUk oHRgyG1NWD8cffP2lu++BlwW+YqP9pIVKE4a/d3LTpuC48b4eI3R4DnpwNw7XIx+wiVw m/bvpD0PhjcfKmXaQHeozpH9tX9dv5EDnYrmRpdeuu9+QqE1GZHpzeVyHWvdInAg9e1z WjiXykqlzaDbEyRtYfrKwA+nknqnpDSCopYQZ8ZHg7wPMRifHeBefBbW57VJB3Wt0Agv 63/Oy9BxMekLmLv8TbbPbNp7GTDGO4o2cyBLeKWtMAcg4Y1EN1himIqOkZHVXhdfuIF+ mTGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=K0UGBzPzK2xOYnwCkpf1AIZVK992up+u3yQgHHDTKVo=; b=pl7gbyUFF5DRRGsG8FkzzFYEHbeNnciti2yKEuGr2qZ9ygrm4TQ0bDMro3yHVQ+pxq h8yTBr+W7d/GX+y7cvx8UUD3tW7Rg9qS12F9IoNYqcXbq+d5NQWKw5qGIbc0E7oEt87f VipdE0i4UzU+AvbWLFhdZ9FriIAzRYzFeCxC9Us0CAvseyiRDiG59ltHc0Et+qecFXuH JYOZMNYWppS8fHi7PGhaDMZAC5oErLhNViwEpG8sgBWM/VOh8pO3dzhBpdGKv55i7H9r +AKu4PFNkQvJmnichIKHkgajEdToE1Fo/tExYgT0RiSRZ1D5ktG/E4FZ2M2YkZ4CToHJ 81HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du22-20020a17090772d600b007121245807esi2093014ejc.708.2022.07.14.04.24.38; Thu, 14 Jul 2022 04:25:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238671AbiGNLWg (ORCPT + 99 others); Thu, 14 Jul 2022 07:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238636AbiGNLWX (ORCPT ); Thu, 14 Jul 2022 07:22:23 -0400 Received: from sinmsgout03.his.huawei.com (sinmsgout03.his.huawei.com [119.8.177.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7318558FA; Thu, 14 Jul 2022 04:22:20 -0700 (PDT) Received: from fraeml740-chm.china.huawei.com (unknown [172.18.156.148]) by sinmsgout03.his.huawei.com (SkyGuard) with ESMTP id 4LkBrQ6KWpz9v7Bs; Thu, 14 Jul 2022 19:21:10 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml740-chm.china.huawei.com (10.206.15.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Jul 2022 13:22:15 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 14 Jul 2022 12:22:11 +0100 From: John Garry To: , , , , , , , CC: , , , , , , John Garry Subject: [PATCH v6 3/6] scsi: core: Cap shost max_sectors according to DMA limits only once Date: Thu, 14 Jul 2022 19:15:26 +0800 Message-ID: <1657797329-98541-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1657797329-98541-1-git-send-email-john.garry@huawei.com> References: <1657797329-98541-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The shost->max_sectors is repeatedly capped according to the host DMA mapping limit for each sdev in __scsi_init_queue(). This is unnecessary, so set only once when adding the host. Signed-off-by: John Garry Reviewed-by: Damien Le Moal Acked-by: Martin K. Petersen --- drivers/scsi/hosts.c | 5 +++++ drivers/scsi/scsi_lib.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 8352f90d997d..d04bd2c7c9f1 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -236,6 +236,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, shost->dma_dev = dma_dev; + if (dma_dev->dma_mask) { + shost->max_sectors = min_t(unsigned int, shost->max_sectors, + dma_max_mapping_size(dma_dev) >> SECTOR_SHIFT); + } + error = scsi_mq_setup_tags(shost); if (error) goto fail; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 6ffc9e4258a8..6ce8acea322a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1884,10 +1884,6 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) blk_queue_max_integrity_segments(q, shost->sg_prot_tablesize); } - if (dev->dma_mask) { - shost->max_sectors = min_t(unsigned int, shost->max_sectors, - dma_max_mapping_size(dev) >> SECTOR_SHIFT); - } blk_queue_max_hw_sectors(q, shost->max_sectors); blk_queue_segment_boundary(q, shost->dma_boundary); dma_set_seg_boundary(dev, shost->dma_boundary); -- 2.35.3