Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp530975iog; Wed, 29 Jun 2022 05:22:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sIkk7m/dEwMHA8Vq7YeEO+DD3lffbArESkB3Xdnzn/dEkc4GeFCNaaaaBHDkpBbYb+HbmT X-Received: by 2002:a17:90b:3505:b0:1ec:db5d:794b with SMTP id ls5-20020a17090b350500b001ecdb5d794bmr3843566pjb.24.1656505336680; Wed, 29 Jun 2022 05:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656505336; cv=none; d=google.com; s=arc-20160816; b=d80cqrCmRQTPWX4cCirmKMf95iPc71+5tJPhW0Iaj6KTQ1zaTEMZ21Bk08pAIKwP/w VqDCXho3wKqkTFGDMnH/CSw+vjh4wXOeXveRRxKj7r2K2qalxnzDro1WzzAQr2nSg8j7 l1Z3wjWj2QvXwxsU8fcYGda4weh36X+SZU42foe1HMGaC2zBf/xm1j+LtFcU8s5/VBI6 4kDNgiD/bC11GL3Mhf5V5wpimFSYB/VFp5OsOfQwU74reREJXQ8bvIv2MK/5fAsTyVtb QYBn0ikYR5/gW/ezgkBQfAGuTZhoZistdfXD6IrHGit4Dpa9sR7yd27NNtx01fYwqIzc BUGA== 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=rDCTfRSYW6OSSaDUgSftIyRX6iRBdXRXay5kN7c4Rlc=; b=Tv5pj/hwR5rGjvZKgq8sdndyNRRPZDcVTB3Bo0ZpREiagEOyCScsOqKdU15iQdtU+9 gL+h/bfQdp8UpBoPEKduHXZ73dDfrGzuPSYlB53mHxgIRMuxBK/f3DkjRvuTpRlkZkFM XafwTFPyl1/SNp1Hm0lwavEPkAHjLdNwQPJisqWzVOOa9Qwfxdi9vPwPSnnU5VwSEnyi ko5NIJbHUXS9l6CdkmzR3fK108EGNDhBqrDKYi4UgbwHW/jtgKrNiq9hd1E8eKxS8BIG rApnX+9eWQ7f63r9TWmfqvCwmcXfkGK4jR0owefWpuUtVOBbNZU/vmojGgTHixwmWObG Cplw== 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 s29-20020a63451d000000b0040cf53f9b98si22100159pga.226.2022.06.29.05.22.03; Wed, 29 Jun 2022 05:22:16 -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 S230326AbiF2L6K (ORCPT + 99 others); Wed, 29 Jun 2022 07:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiF2L55 (ORCPT ); Wed, 29 Jun 2022 07:57:57 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2E8387B1; Wed, 29 Jun 2022 04:57:56 -0700 (PDT) Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LY0Lr1xbbz67yhs; Wed, 29 Jun 2022 19:57:08 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 29 Jun 2022 13:57:53 +0200 Received: from [10.195.245.77] (10.195.245.77) 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; Wed, 29 Jun 2022 12:57:52 +0100 Message-ID: <416ebe33-28ed-eef0-0001-83efd83a9d0f@huawei.com> Date: Wed, 29 Jun 2022 12:57:54 +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 v4 1/5] dma-mapping: Add dma_opt_mapping_size() To: Robin Murphy CC: , , , , , , , , , , , , , References: <1656343521-62897-1-git-send-email-john.garry@huawei.com> <1656343521-62897-2-git-send-email-john.garry@huawei.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.195.245.77] X-ClientProxiedBy: lhreml751-chm.china.huawei.com (10.201.108.201) 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 28/06/2022 12:27, John Garry via iommu wrote: > On 28/06/2022 12:23, Robin Murphy wrote: >>> + >>> +    size_t >>> +    dma_opt_mapping_size(struct device *dev); >>> + >>> +Returns the maximum optimal size of a mapping for the device. >>> Mapping large >>> +buffers may take longer so device drivers are advised to limit total >>> DMA >>> +streaming mappings length to the returned value. >> >> Nit: I'm not sure "advised" is necessarily the right thing to say in >> general - that's only really true for a caller who cares about >> throughput of churning through short-lived mappings more than anything >> else, and doesn't take a significant hit overall from splitting up >> larger requests. I do think it's good to clarify the exact context of >> "optimal" here, but I'd prefer to be objectively clear that it's for >> workloads where the up-front mapping overhead dominates. > I'm going to go with something like this: size_t dma_opt_mapping_size(struct device *dev); Returns the maximum optimal size of a mapping for the device. Mapping larger buffers may take much longer in certain scenarios. In addition, for high-rate short-lived streaming mappings the upfront time spent on the mapping may account for an appreciable part of the total request lifetime. As such, if splitting larger requests incurs no significant performance penalty, then device drivers are advised to limit total DMA streaming mappings length to the returned value. Let me know if you would like it further amended. Cheers, John