Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp529721iog; Thu, 30 Jun 2022 05:37:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u+Ctzb8hcddkfmRr1Fo3BAvGbdmpY8PXhEuCSYzXSm4dO77RrSOptEULiO2xUHGr0zcyyq X-Received: by 2002:a17:902:b7c4:b0:16b:844a:5697 with SMTP id v4-20020a170902b7c400b0016b844a5697mr14178709plz.29.1656592658060; Thu, 30 Jun 2022 05:37:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656592658; cv=none; d=google.com; s=arc-20160816; b=bTFmH8CqzIgzawT6ZyGQFC3Arw8zFTkTd9k5piYkwDli6VLDLy0O+ZbKjj7ShWxfx1 yEO3t13hgdKd1rLdoxFILY7BHXnCXSJeFiCpSmTItePdc4Ytygp/nq0OmUXt5dJyEFm5 Bx2fYbZCYFI+B1UFhapwnO83qqyZldMHrm67j9NeuBfvkWatSb6dbenPncsbk7L7b5X+ LNTkktkQBd4O+IGj+flJFFj/mgJV45tpAIbk7rypyqKyrjNeaUhguS5zwVLeQ874DVQR sdrnaTboqtgbONx6fcIHUGcn9JZqLftA2nF6UgDSL3+/fr822QnhTRGDBBOoQ/wZnuof KyIQ== 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=YwYrBFxe5cHtP4lFxjgu3qvVQrUlGQXzFGrUDu/jNZM=; b=WYX+KEQuKgY8JdN+Wxbzw2zEnlKOnJSoKE/FuROe7WOs/ZiZj5CY6dXmpa7VEMFE7S hnZcf70rOCkDY3Xq7dKFEcdKWhYyXqVZAtnmCwSnrstTOkVf96qiLmqHfyaU6+ReX+ii nQhQNJBbh2YSf9rwCiIs/i8wTBBWjKKR6EXS8bsFiMzVEO6VDipFPnQMfwnKKv8S5xgf G3SwJqnJkiAQjRskqeyd2WpRLCsT/a4Wk3ON1w0hl2A2+UpvtbCocBXyWhvZr4B9x4R1 EO1Qq6tOJQ9nzwr2xHfFHkw+mxp62eDbMAEl1l01qSrjP/LgwPjrhVR+FiuSj4m5Qq1L EIcQ== 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 r186-20020a632bc3000000b0040d91e3faf2si2793563pgr.170.2022.06.30.05.37.22; Thu, 30 Jun 2022 05:37:38 -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 S235133AbiF3MOz (ORCPT + 99 others); Thu, 30 Jun 2022 08:14:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234721AbiF3MOr (ORCPT ); Thu, 30 Jun 2022 08:14:47 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3182220185; Thu, 30 Jun 2022 05:14:36 -0700 (PDT) Received: from fraeml711-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LYcbp2794z6878R; Thu, 30 Jun 2022 20:10:30 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml711-chm.china.huawei.com (10.206.15.60) 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:34 +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:30 +0100 From: John Garry To: , , , , , , , CC: , , , , , , , John Garry Subject: [PATCH v5 4/5] scsi: scsi_transport_sas: Cap shost max_sectors according to DMA optimal limit Date: Thu, 30 Jun 2022 20:08:11 +0800 Message-ID: <1656590892-42307-5-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 Streaming DMA mappings may be considerably slower when mappings go through an IOMMU and the total mapping length is somewhat long. This is because the IOMMU IOVA code allocates and free an IOVA for each mapping, which may affect performance. For performance reasons set the request queue max_sectors from dma_opt_mapping_size(), which knows this mapping limit. Signed-off-by: John Garry --- drivers/scsi/scsi_transport_sas.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 12bff64dade6..1b45248748e0 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -225,6 +225,7 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev, { struct Scsi_Host *shost = dev_to_shost(dev); struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); + struct device *dma_dev = shost->dma_dev; INIT_LIST_HEAD(&sas_host->rphy_list); mutex_init(&sas_host->lock); @@ -236,6 +237,11 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev, dev_printk(KERN_ERR, dev, "fail to a bsg device %d\n", shost->host_no); + if (dma_dev) { + shost->max_sectors = min_t(unsigned int, shost->max_sectors, + dma_opt_mapping_size(dma_dev) >> SECTOR_SHIFT); + } + return 0; } -- 2.35.3