Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1050256imi; Fri, 1 Jul 2022 01:51:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3YiNHwksix8UjW+y9vXKcK424leA60RRMbAWjgHXcxDJ9QmXel/Eznva6rWd0z6rQzfvd X-Received: by 2002:a17:907:75cc:b0:726:f11c:4c5c with SMTP id jl12-20020a17090775cc00b00726f11c4c5cmr13213985ejc.404.1656665478183; Fri, 01 Jul 2022 01:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656665478; cv=none; d=google.com; s=arc-20160816; b=Q/doJptrWiHXC4g2CudD8eM6WOtIHt+q8AsynPWTZc4/PnbEyGt0CgKlfFEJRINoSR fJ1c/T7ibso7D3+f4SIDbOShd/6usnMbxXR7C3iYsUqiY2vslxG8YVqRAYJNg/Ol9qPE Dk1n23LzxbqVruL9Vk13W7P8THgdn9yYqRTwKKkl2UaPdsiUrm1qfjkpVk7+X5zKs1oP 3wehb2rVvDAwJnyxx0TkniUpO+3H0gH1vfR7qeURPoLBKYhtPPxKFkyKh6rvBZtvreHE DWRFHS4NcbxqBvsFk5FMAIb8VVYTWPg+vtQCEBCeSJR8OQ9q8Fn3WlQOXT23IF1hpSb4 lHkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=/BAPlJV+Q0LUOW9pRZxFim3PuAkP4jhz0gSe4Dre+ME=; b=aYxyQqG1mcvyoMDWtjsxujoYEwsZeA/90uVbgIVZC1JMiogwZEhoRmS6xRknqk6+dl XXIfAgh1aGcs+I5Q31VuSZ73TN0W82zPktVk4wR2sBbnrqU6saYEAKRY/XddlV9W+hig awzQYQc4dD8tieUHPiCCgcc2BULOMImaNNjSf6K9Bbc6nuNkRJUDiqpF+UsOT2LCgqWW duvcAY8Q4Rm4jqWsfKvJ4W/vhDp6pBk+kLo+s9GlnCM534zy76LuMpI8qTMlCJIYB5t+ IYXURt8/gEjYtB5sxG+8LfsUNLBE+57fsisnCAAFIBZL87scAVGQXKOBEwVjrDeZ+72I OGNw== 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 qw3-20020a1709066a0300b00726e8b63a88si1107405ejc.814.2022.07.01.01.50.52; Fri, 01 Jul 2022 01:51:18 -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 S229966AbiGAIqj (ORCPT + 99 others); Fri, 1 Jul 2022 04:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234741AbiGAIqg (ORCPT ); Fri, 1 Jul 2022 04:46:36 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1CF573596; Fri, 1 Jul 2022 01:46:34 -0700 (PDT) Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LZ7zB3G1wz67VqM; Fri, 1 Jul 2022 16:44:06 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Fri, 1 Jul 2022 10:46:32 +0200 Received: from [10.126.173.51] (10.126.173.51) 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; Fri, 1 Jul 2022 09:46:31 +0100 Message-ID: <42505bbc-7319-f266-f282-e76ba505725e@huawei.com> Date: Fri, 1 Jul 2022 09:46:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v5 4/5] scsi: scsi_transport_sas: Cap shost max_sectors according to DMA optimal limit To: Damien Le Moal , , , , , , , CC: , , , , , , References: <1656590892-42307-1-git-send-email-john.garry@huawei.com> <1656590892-42307-5-git-send-email-john.garry@huawei.com> <2e6475e5-4899-1e3a-1418-918b9510ec6d@opensource.wdc.com> From: John Garry In-Reply-To: <2e6475e5-4899-1e3a-1418-918b9510ec6d@opensource.wdc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.126.173.51] X-ClientProxiedBy: lhreml712-chm.china.huawei.com (10.201.108.63) 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,NICE_REPLY_A, 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 On 01/07/2022 00:49, Damien Le Moal wrote: >> >> + if (dma_dev) { >> + shost->max_sectors = min_t(unsigned int, shost->max_sectors, >> + dma_opt_mapping_size(dma_dev) >> SECTOR_SHIFT); >> + } Hi Damien, > Hmm... shost->max_sectors becomes the max_hw_sectors limit for the block > dev. So using dma_max_mapping_size(dma_dev) for that limit makes sense. > Shouldn't dma_opt_mapping_size(dma_dev) be used to limit only the default > "soft" limit (queue max_sectors limit) instead of the hard limit ? > Sure, it would sensible to use dma_opt_mapping_size() to limit the default queue max sectors limit, while dma_max_mapping_size() limits the host max sectors. But I didn't see in practice how limiting the shost max sectors to dma_opt_mapping_size() makes a difference: - block queue max_hw_sectors_kb file is read-only, so we cannot change the queue max sectors from there - And no SAS driver actually tries to modify upwards from the default. I do note that USB storage driver as an example of a scsi driver which does (modify from shost max sectors): see scsiglue.c::slave_configure() Finally there is no common method to limit the default request queue max sectors for those SAS drivers - I would need to add this limit in each of their slave_configure callbacks, and I didn't think that its worth it. Thanks, John