Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85D3CC433B4 for ; Tue, 27 Apr 2021 22:50:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F16C3611ED for ; Tue, 27 Apr 2021 22:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F16C3611ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=deltatee.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 716216B0036; Tue, 27 Apr 2021 18:50:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EC0F6B006E; Tue, 27 Apr 2021 18:50:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B4526B0070; Tue, 27 Apr 2021 18:50:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 3FC6D6B0036 for ; Tue, 27 Apr 2021 18:50:25 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id ED01A8249980 for ; Tue, 27 Apr 2021 22:50:24 +0000 (UTC) X-FDA: 78079642368.22.35FB74F Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by imf30.hostedemail.com (Postfix) with ESMTP id 06A40E000111 for ; Tue, 27 Apr 2021 22:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=PBZp6uxAp8nlNU5Rm16hkR47Rwe8xrGWtpeD+dKWkk4=; b=c2SnI7NAl3/gr4SFEOqWfEjO9J 1JGnC7Zf5KDX7iHl6Y4Xf/2xqN/Sf5EK4N3LedlbB9Fd00L3W9uy4hRpaf9AzRR6bhJRwlUH+3jQV JGHEoIAnzvnTbXFFloa9dmt/bebMlHu8p0eMd7ujtwQMFSXPtCaCZfLSEapIfvrwoLvjkcmHaak0S os4Ry++J+BA4Zjy4rlpJGfScH23wq+QuJ1EnvUrl/i2hoEb1GA+PElTtZrctT7avrcp051HeAQJHt MommdMIRXxQ8f7+NTw6YINNchc1V2k8mSpMibhQPjTbiWcdM3d674C2MzQOyDshqLUX3ERNg5eNxi Yzo0Jtug==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1lbWWo-0002hR-Kh; Tue, 27 Apr 2021 16:50:04 -0600 To: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , =?UTF-8?Q?Christian_K=c3=b6nig?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-6-logang@deltatee.com> <20210427192232.GO2047089@ziepe.ca> From: Logan Gunthorpe Message-ID: <74473159-b4d7-89c8-9dae-7e983b22ef2b@deltatee.com> Date: Tue, 27 Apr 2021 16:49:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210427192232.GO2047089@ziepe.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: robin.murphy@arm.com, ira.weiny@intel.com, helgaas@kernel.org, jianxin.xiong@intel.com, dave.hansen@linux.intel.com, jason@jlekstrand.net, dave.b.minturn@intel.com, andrzej.jakowski@intel.com, daniel.vetter@ffwll.ch, willy@infradead.org, ddutile@redhat.com, jhubbard@nvidia.com, christian.koenig@amd.com, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, jgg@ziepe.ca X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH 05/16] dma-mapping: Introduce dma_map_sg_p2pdma() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 06A40E000111 X-Stat-Signature: fbcjjbn6bf8z78z8ft5393ogque5nfs6 Received-SPF: none (deltatee.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=ale.deltatee.com; client-ip=204.191.154.188 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619563804-397832 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2021-04-27 1:22 p.m., Jason Gunthorpe wrote: > On Thu, Apr 08, 2021 at 11:01:12AM -0600, Logan Gunthorpe wrote: >> dma_map_sg() either returns a positive number indicating the number >> of entries mapped or zero indicating that resources were not available >> to create the mapping. When zero is returned, it is always safe to retry >> the mapping later once resources have been freed. >> >> Once P2PDMA pages are mixed into the SGL there may be pages that may >> never be successfully mapped with a given device because that device may >> not actually be able to access those pages. Thus, multiple error >> conditions will need to be distinguished to determine weather a retry >> is safe. >> >> Introduce dma_map_sg_p2pdma[_attrs]() with a different calling >> convention from dma_map_sg(). The function will return a positive >> integer on success or a negative errno on failure. >> >> ENOMEM will be used to indicate a resource failure and EREMOTEIO to >> indicate that a P2PDMA page is not mappable. >> >> The __DMA_ATTR_PCI_P2PDMA attribute is introduced to inform the lower >> level implementations that P2PDMA pages are allowed and to warn if a >> caller introduces them into the regular dma_map_sg() interface. > > So this new API is all about being able to return an error code > because auditing the old API is basically terrifying? > > OK, but why name everything new P2PDMA? It seems nicer to give this > some generic name and have some general program to gradually deprecate > normal non-error-capable dma_map_sg() ? > > I think that will raise less questions when subsystem people see the > changes, as I was wondering why RW was being moved to use what looked > like a p2pdma only API. > > dma_map_sg_or_err() would have been clearer > > The flag is also clearer as to the purpose if it is named > __DMA_ATTR_ERROR_ALLOWED I'm not opposed to these names. I can use them for v2 if there are no other opinions. Logan