Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4421677imw; Tue, 19 Jul 2022 06:24:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tI9bXbsN0ez8Q+PNq3qd51e+fdJio+CEaHE8Cj6UTV8lD0ZySpc/Y1w13/tH6KIFMkh7gw X-Received: by 2002:a05:6402:26c3:b0:43a:a846:b2c1 with SMTP id x3-20020a05640226c300b0043aa846b2c1mr44309586edd.133.1658237050750; Tue, 19 Jul 2022 06:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658237050; cv=none; d=google.com; s=arc-20160816; b=qR4fxcG+DbWYytWp+gdPJo68FTTy/quwrsMymcySMEmTU+pp9IKxyoYY4jy69LO+xr w9mwAl4Qyp/z5onf0T3EnJGecbxlF5EKFpwI4JAJi4ZE4k7EmawriorcOHmbditEfCOr EjUzxH7nZbxcc9dkxQWLgKOX3FUwbPh47ofvWstAul8v+Szo7MK+yC6ZKCdlARrxkbUf ecZ6bmtmWBdoGoEDc/+mYMg4dDag9/wPiVH+t9ejqGJuD+tZ6jeEFQXmwrbcXFd+tnVx 2Rrl71QUngINc4oJYJj4xtqtdDdFsZbzY1Q2qU6atEWajbWTwYrhcN++zg1IQOWPvnoV XD3Q== 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=OXAowH2YK6P2mXMxSW+1iHFaaZapTZlNi73gl1w5dis=; b=BXwbwx4tgk8a5eZssB2OiwLN/kPz4G4AJbTPlHvlXMhfJ/6XCTpV+rJfx7GxuvNxSv nMX4vBx/bMvIYBeeXLrXltDF290pV19ljiIo9D5eVHvI1M0fdiDL0Izb6CqloJ4myKky Gxdh4chmdSC9zy8wnFWqOlDSjR+p5KSxRR8ilxlCz3TYopOe5kYYDB0FXjMc3CjzJAeQ oYZgmwOw+hTeegtEO11cwo4yOoJn/UY0H5OTX2Xh2YFpTtqgbd16EknDGKGrYZRXwPcS 8TnhN+ZqSE0iXgiUSH7lqhWbtEIC15cBo6mgxyby2teug+mkOppKCR7evPgKnr2jsU6/ bZwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hp3f07ta; 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 y7-20020a056402440700b0043a6defcbafsi20321643eda.219.2022.07.19.06.23.46; Tue, 19 Jul 2022 06:24:10 -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=hp3f07ta; 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 S239825AbiGSM0B (ORCPT + 99 others); Tue, 19 Jul 2022 08:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240080AbiGSMYc (ORCPT ); Tue, 19 Jul 2022 08:24:32 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6489E61D79; Tue, 19 Jul 2022 05:09:22 -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 sin.source.kernel.org (Postfix) with ESMTPS id AA81ECE1BEB; Tue, 19 Jul 2022 12:08:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9D63C341C6; Tue, 19 Jul 2022 12:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232505; bh=p6qGrvHgRDnRT9BPQODceA8NfL4N4wtAVuvREEfaigQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hp3f07tann+G+6Pa6Mc1vP5PSPC8ZDMuQx6YR13vuU4bQcsGk4hrNIQInw6WzLU4R sljXmdcyoK8Wlv5xhjMQRA47EQwTuPLvYosje0vHwLVb11hmVGgTLrI39cy3c7hiN0 3rYCljc5c+1tE0BSccjFiTII1rFra16z6I0UPbXs= 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.10 080/112] scsi: hisi_sas: Limit max hw sectors for v3 HW Date: Tue, 19 Jul 2022 13:54:13 +0200 Message-Id: <20220719114634.297664218@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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 cd41dc061d87..dfe7e6370d84 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2738,6 +2738,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; @@ -2755,6 +2756,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