Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4779638pxy; Tue, 27 Apr 2021 12:24:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQSAlY6692hUNCRA5xPPnTTB+5kjVYBtsmPCyrFE7KXELV6aEXjfdE1znbhGhwPcVFlKUZ X-Received: by 2002:a17:906:86d0:: with SMTP id j16mr24642525ejy.444.1619551485252; Tue, 27 Apr 2021 12:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619551485; cv=none; d=google.com; s=arc-20160816; b=lcIzfwZyoND9pfeUzaKc5thzQ2R3/3JAE0IHWTHtsoTQd8bmzUR1ks7kmvwf+LB3x0 2dra0ExgVvUYVT8nCgXkP01xwgmCDK3saHxXuBPmI2ttRyyMrLlX7D6iDjUSGNfqnrIh DASMCCZq4EmtTwgsdJASCZjlrW7EdB6WOa/P+NiB6ZZ31ksKVFIWpFLy2PbjQadOU/tL GSvYGtE7GLS9zZ2LR6Usu8gBexDCj4zs6blICubSJJK32NOkJWvm8u5b175UuQY0UYPO gTH67FJYIKwHvv+xTkeA0NZy5d/oX0C92WcA1BzCcSvDVWaHMqk9JGEbB8rARBXy5orc hMTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9A9KdhpIimzuD5OzCChHO2CjGhCpPan1yRAo2/CAv+c=; b=PrbQr90GLCiXAsPucOlvRp6L4BE1TKydOesbSkbISqmOjavfHI44OthBEixQJNIySp N2nXqqx+Ejbcu008+Jd8nqD5Zs5tvMYBfpVIALOsxpYs1rSILcNiama/tw6n7wmC/e9a Zv/ExXTBhNoKoVg5r8r32YibzU7qZVg88Rmv7VOk4uGPSM9tjsqVkH6Sl7Xa1fdeHqFf egzaFUcBl3QrUB226dtjbRzuywxpkyUuivHfGkXQH+1QuU+4sj19G93yBc7rSXFVljS+ UBggua6QELz+iV9EO7ZKzxapsrpbLK5Qtadsqxpnlv6awxtwQ6kjN5OfBzQfzd+Gloe+ WvXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=KmmcN+wJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si605266ejs.614.2021.04.27.12.24.19; Tue, 27 Apr 2021 12:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=KmmcN+wJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238009AbhD0TXT (ORCPT + 99 others); Tue, 27 Apr 2021 15:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbhD0TXT (ORCPT ); Tue, 27 Apr 2021 15:23:19 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88781C061574 for ; Tue, 27 Apr 2021 12:22:35 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id i22so7642318ila.11 for ; Tue, 27 Apr 2021 12:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9A9KdhpIimzuD5OzCChHO2CjGhCpPan1yRAo2/CAv+c=; b=KmmcN+wJO4XJEW8i1n4M8fdsVxKICGd+cicWY6PhIyfMntf61DWDbN0lYONPfv7avX 7FxH4J1DcHU+d/BPW07cIeL7M0+KsL2H3xjnwnUShzOsbwp4p1Mstgek0/DJDywqlAvj pvQ4AeQxgT8d2B9boE2xCyb2V/QcKRwgqazkbOV36nIXZRCI1I41ENBc9O94GPWzuGWn ZoVb91ruebPuMOxROumRJF1bkL3LMcW5p3RL67vEkcYBqN+97GnMi303v4vqdgIYcysj J3wZPapZMjRdKb47N21dcq6V8IXSfFXXFfDtIZJD9rm1L4Cs5YgpeYsNB9gao99MRN+M bnKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9A9KdhpIimzuD5OzCChHO2CjGhCpPan1yRAo2/CAv+c=; b=XiyBBT0PRbzOWuGjbRvImIv4wm0bPnLtt3EoNTfI3NN4JG2jB/SFMWMQUShe+tcihz DnlJ0JS+J/dkTkKSQdhoXRH6mdOhAYYKpecVM/HyVaSQGQzN2CVa6o3e9AuCrpDdf86Y sBLT1qv8qdN9xi/ogGSsaWaS8IZHPBR10iEKWua1Fdj3mDHyODQxufs2itGCzNPRAOsO UEaX5SnlyRTBb9dFXbZdBIxrMgRw5O1fMGupu1jpWdtJfVT65jWvlW2Xg0TlYvSCKQqB kUWT7e5QE4gxuAgnC0shg21S4AzogqabPUQ+AWA/E58wyCAS3kKbkvFWzxBVmOUb8v3D NGsA== X-Gm-Message-State: AOAM532QCwUFjqXpERG5gQgZlYiioTbGyaBFH/Wc1s7GkcuHYZaykgPP QTWWkGVIP1V9eYjbCp4jun3N3w== X-Received: by 2002:a05:6e02:13ca:: with SMTP id v10mr18478934ilj.191.1619551354939; Tue, 27 Apr 2021 12:22:34 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id d2sm1817918ile.18.2021.04.27.12.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 12:22:34 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lbTI0-00Dglq-Rs; Tue, 27 Apr 2021 16:22:32 -0300 Date: Tue, 27 Apr 2021 16:22:32 -0300 From: Jason Gunthorpe To: Logan 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 , Christian =?utf-8?B?S8O2bmln?= , 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 Subject: Re: [PATCH 05/16] dma-mapping: Introduce dma_map_sg_p2pdma() Message-ID: <20210427192232.GO2047089@ziepe.ca> References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-6-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210408170123.8788-6-logang@deltatee.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Jason