Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5806683iog; Thu, 23 Jun 2022 05:53:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tWXTkRT1271lkuPOJFmRd/aAjODmbY8gIqXQdzVkKzRNL2GuYsHw+ghML/UYzR9pg2aa3p X-Received: by 2002:a17:90b:3146:b0:1ec:e996:5a67 with SMTP id ip6-20020a17090b314600b001ece9965a67mr3873063pjb.111.1655988785673; Thu, 23 Jun 2022 05:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655988785; cv=none; d=google.com; s=arc-20160816; b=T85MWcBj4JuQYuhrbnzOTBUazNUlwr8Zt1UnAq5xHUUrYQdwGiUtLPQvbuIKkE/tBR ZZ/1mClnqOvo85C/utOCLCCb2nSQDx82THnAi5rrg5b8Eknz7TJbsxOgr1xMTRLCVvsg vcDz7V1eCBYW7DtxJfF3kEaB3Qk22heTNu9vEkhZHPvvSJ13LrEa4TWwOcxKdJ8GquqF YjQayEX9nBynPKv3gMyKHNFjWlBHsIj+U0wmWKVJ6uL8ipu6zHUcBze4GvzujB3MV61O YML6Z5A0d4lPswe9BRLFqVBLeke5LU8MR4t812rk2158S9ypt572cwQOuesZBuDLWldg 7q6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=SB7vjRw2FM9WA64yGK7PkDIxOJdtTTWm5Dc/i3WVGAE=; b=pyi853ACVTqV4BlBG2MVc1OjisrDCJYqEPiBR+XmlOy8L1SN3yY+EHNBeiI9kbXauA C07LPBl8oxMe/lb5VVP4yBs78SneikXlj5ric7yMnXYJ0AHtfqlxS70TkeWrT9w22IB5 76DREBt2kyziTAW/KGYuRsnIEjCtWtAv4HD/F9f3a19jk6p1gbJLhfJvrXtCIGteAc9V FLZ4o1Vi21hKf1XKGsX3G6Z5Azdh74Rlsku90aHEUlTagaFrxZuuGPmlrILKLrfUtvOy 6dLFc9tTrMvOvFoX17CclVaYZYSLkGNAu6WUX+ly8hGTfKK32zrGWgjmd4bxjEPuIGhh AWEw== 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 ls17-20020a17090b351100b001ec78eb1158si3363151pjb.136.2022.06.23.05.52.51; Thu, 23 Jun 2022 05:53:05 -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 S231586AbiFWMsQ (ORCPT + 99 others); Thu, 23 Jun 2022 08:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiFWMsH (ORCPT ); Thu, 23 Jun 2022 08:48:07 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9603444752; Thu, 23 Jun 2022 05:48:05 -0700 (PDT) Received: from fraeml715-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LTKlp4fpKz6GD3M; Thu, 23 Jun 2022 20:47:34 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml715-chm.china.huawei.com (10.206.15.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 23 Jun 2022 14:48:03 +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, 23 Jun 2022 13:48:00 +0100 From: John Garry To: , CC: , , , , John Garry Subject: [PATCH] scsi: hisi_sas: Limit max hw sectors for v3 HW Date: Thu, 23 Jun 2022 20:41:59 +0800 Message-ID: <1655988119-223714-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 If the controller is behind an IOMMU then the IOMMU IOVA caching range can affect performance, as discussed in [0]. Limit the max HW sectors to not exceed this limit. We need to hardcode the value until a proper DMA mapping API is available. [0] https://lore.kernel.org/linux-iommu/20210129092120.1482-1-thunder.leizhen@huawei.com/ Signed-off-by: John Garry --- This patch is intended as something which I can backport to stable. Series [1] is a proper fix but stuck, but I would not plan to backport it anyway. [1] https://lore.kernel.org/linux-scsi/1654507822-168026-1-git-send-email-john.garry@huawei.com/T/#m069f33edd547533301e2af156ebd6badee199dea diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 7d819fc0395e..eb86afb21aab 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2782,6 +2782,7 @@ static int slave_configure_v3_hw(struct scsi_device *sdev) struct hisi_hba *hisi_hba = shost_priv(shost); struct device *dev = hisi_hba->dev; int ret = sas_slave_configure(sdev); + unsigned int max_sectors; if (ret) return ret; @@ -2799,6 +2800,12 @@ static int slave_configure_v3_hw(struct scsi_device *sdev) } } + /* Set according to IOMMU IOVA caching limit */ + max_sectors = min_t(size_t, queue_max_hw_sectors(sdev->request_queue), + (PAGE_SIZE * 32) >> SECTOR_SHIFT); + + blk_queue_max_hw_sectors(sdev->request_queue, max_sectors); + return 0; } -- 2.35.3