Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp510990iog; Thu, 30 Jun 2022 05:16:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjaj9UXaxhYiDj8JpycGn+9N59jm/NqgoMqHdsw2K8gwR1E0kXlLlnx/usbJX46AIE3tkD X-Received: by 2002:a17:903:2305:b0:16a:6b9c:2b4c with SMTP id d5-20020a170903230500b0016a6b9c2b4cmr14541494plh.100.1656591380492; Thu, 30 Jun 2022 05:16:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656591380; cv=none; d=google.com; s=arc-20160816; b=rHFa5IbhYpiuQJ+fWh3QdbDz/+GveTXBABT4nFX+kk11OyhqOadDnq2MOJQn2IZ/IK Zs6vZWmMniPHdzWWQWtB6NBFXl/F3qwDcE53hoMnU0Ac5uC9OLdaBmVthcf/ulCouVGu CralbEt0TKhWLQD6bVytizXkLAtNqwx68Y6Ce+1TkbNWf7JDNGQrSeefiKOz/BEr8H6l oUnVVvGCRp7Skd25zzmVXXRIvxqQrOgaHccG9ekB4Rf+cKU1oVyusClGubxSbjsisOZd cz93vf5vgzqeOQCbmoVgdu6SMU8KKV8njr/03nSJmVvguOjDC6HtMbPs+cPHBzFxdMvK akfA== 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=+0TPAx8GtcQlVql5f7cG0trFDnnmW6wSB329K5QU844=; b=F1CkWSBaoWFyuge6PsrJp1FtENmidxnN00WHwNbHuPN0FAv9dAQWWFy9TX1aIm4OPe qyHwKU6IUkjLupdTD5fmTLasHanrtgvzw1lBfEkrRQHNXH8UaMoZyh1I9jN7KJZqR1wE 4tBG+P14JJIsrlvF4yzcyhQKbGVJm+W3sBg++UXhfXRjvn47jgu8M9caXXRB7VqbVuxx /RwpbTxlkkecjgj7sh2X3Oqzj9EjR9+B+l7mJLn9AefNb+pubYNHVXpDMGaVZuXo+TNs SitnrUp185TEK7eLTQtaFHh6+FUzz7xVpbeXCzs4CU40WabziPAL5Lk1uc50yfYcbj4R EiVg== 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 bv1-20020a17090af18100b001ed2faf0f3bsi6525170pjb.63.2022.06.30.05.16.09; Thu, 30 Jun 2022 05:16:20 -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 S235096AbiF3MOu (ORCPT + 99 others); Thu, 30 Jun 2022 08:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233150AbiF3MOc (ORCPT ); Thu, 30 Jun 2022 08:14:32 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7391FCCB; Thu, 30 Jun 2022 05:14:31 -0700 (PDT) Received: from fraeml712-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LYcdf44x1z6H7vr; Thu, 30 Jun 2022 20:12:06 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml712-chm.china.huawei.com (10.206.15.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 30 Jun 2022 14:14:30 +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, 30 Jun 2022 13:14:26 +0100 From: John Garry To: , , , , , , , CC: , , , , , , , John Garry Subject: [PATCH v5 3/5] scsi: core: Cap shost max_sectors according to DMA limits only once Date: Thu, 30 Jun 2022 20:08:10 +0800 Message-ID: <1656590892-42307-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1656590892-42307-1-git-send-email-john.garry@huawei.com> References: <1656590892-42307-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: dggems706-chm.china.huawei.com (10.3.19.183) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 --- 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