Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4446914imw; Tue, 19 Jul 2022 06:49:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sytzNjMeU9OsHy/5Q8hVxIenqKgsoTSCOvfSoihRegwIoMd3flN5uISXv2s8YmSUl4sa+W X-Received: by 2002:a05:6402:2483:b0:43b:3b1c:899 with SMTP id q3-20020a056402248300b0043b3b1c0899mr30351227eda.137.1658238577047; Tue, 19 Jul 2022 06:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238577; cv=none; d=google.com; s=arc-20160816; b=Tx5TMA1+KYZnEgS8Z77LO9jdXvSe6hTKabrM5VN2ZkfICHR4Avy70+3bHw+HyKAoBj w0S2++RM5dX5+fcHNjQDPQCn1oSHNQRfNiqfiUFvtDlzMjJFqx/t7pjynCRBCbVxJIPB 6fU3JTWkI18gfr9onmsrJJGffktoyqIXi37zgqciDTKO3iF9WhwRRxA4JRq2MEUt0fv9 m+jCB/0hO4G5RdbXGkZjHb7R16uRU9HmFpK3/zntxo23o9nJjJ9jyVjYtCK9pqNqshJl errJu7HmJM3WDTQcQdJVBRzPhENpJW/KVV9PkbrhDVlgFPDzMh+kGWIxnZaU4az1EDsn 8CNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=39c4rkOJzLa5ae3vhRg06jOaFZbIb4rM+op+5iyZZTU=; b=dyl8N6qmrBPV2gDCOR8O7Slx4FwYXADTpQ7VLN50Lnx9elUn4J0cNL/mGswUwf3UiP odrzi7/milE9TbhsheXNeqs4G4LGI2QMWlZmeaEdnQlxVJ+C3a9tnq8nChyfTqcYLiY3 IQEviq0JUgGHJxZNeic0RYETU6dlQ5BKVgO0D9yVGvFBWFVtYCnTPKXLX0qj3aCv33Nr vui/JqjPlD3x2M89angznRpnYfY8GBIk8J27paNAoE1a6JVnsJES8E830Bw0IVzrBHG2 1PMJpDJrELHa9P/yWzsKGTfkXmUKFcVHoNzZgglWyeZKZVp3lJR59BtgWnOiewHwgCYy dYKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CCXD63i1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb11-20020a170907784b00b0070d8de4e431si19860602ejc.206.2022.07.19.06.49.12; Tue, 19 Jul 2022 06:49:37 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CCXD63i1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237959AbiGSMpK (ORCPT + 99 others); Tue, 19 Jul 2022 08:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238568AbiGSMnm (ORCPT ); Tue, 19 Jul 2022 08:43:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1FBF54C9E; Tue, 19 Jul 2022 05:17:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4188861772; Tue, 19 Jul 2022 12:16:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 330E8C341C6; Tue, 19 Jul 2022 12:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233016; bh=ftRCXwc4371VseYpxVHNBx88Hlwn+pfvaap8UhlLLAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CCXD63i1slASWQYDX5IaGbB/Di3eFqKxpqU5r4Tvv0jnypgxWH1k6pKl+REJr3xTY ifySHH6KzLzrTVfoT5s8YwRa6o+t2mD6AS5L9qVrViSx0MK3RKBMscOYKiGdFkCRVN hYu/BgjN63sFhmaMOly9Zlw5iZJTFYvoejTqpIN4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 120/167] scsi: hisi_sas: Limit max hw sectors for v3 HW Date: Tue, 19 Jul 2022 13:54:12 +0200 Message-Id: <20220719114708.176498383@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: John Garry [ Upstream commit fce54ed027577517df1e74b7d54dc2b1bd536887 ] 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/ Link: https://lore.kernel.org/r/1655988119-223714-1-git-send-email-john.garry@huawei.com Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 1f5e0688c0c8..15c7451fb30f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2758,6 +2758,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; @@ -2775,6 +2776,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.1