From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 D8ACBC43460 for ; Tue, 27 Apr 2021 19:22:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 620F5613F9 for ; Tue, 27 Apr 2021 19:22:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 620F5613F9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7FFCB6B0036; Tue, 27 Apr 2021 15:22:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AE396B006E; Tue, 27 Apr 2021 15:22:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6286B6B0070; Tue, 27 Apr 2021 15:22:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 4853C6B0036 for ; Tue, 27 Apr 2021 15:22:36 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F09B64DDC for ; Tue, 27 Apr 2021 19:22:35 +0000 (UTC) X-FDA: 78079118670.30.CC1A2AD Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) by imf22.hostedemail.com (Postfix) with ESMTP id 14EFFC0007C9 for ; Tue, 27 Apr 2021 19:22:28 +0000 (UTC) Received: by mail-il1-f170.google.com with SMTP id e14so26694190ils.12 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=gkEKUhYd5UUQqDrh1ZD3nh0UPEk5ZzKOphksV0grSF/mwkDHT7KgLPR54PtwubUnNc 4tGlviNsOlun76yNdpBmZbgUlgiyW1UWwdURN+FFeI1fnTpHmolO/+VxF13UoGFlo+sS W2U8SOWtWvwovYnXv43kPNgdt6l1/DILDwreQWwMoA7hOaeUblej8qQdTpMDDK3+Szgz ComqzZi+YRHIT+STPlVX9abchtT56TlXceyJFHGabPGCkFvDtFscyHuq15bO3Yu/FpET cm94n++gN5annjzXLE5Smz+OFIvowtkHVKTThq36OgxsmsuBFhfpzRrFuO0pXVf3dwXy h4Xw== X-Gm-Message-State: AOAM5306VzBOYMfTfGbftB4SHV86UvTp/4oOAJ7YxusALYgAkMuNnIK/ /KVZDg71ocQBtjvs6H5saGieOA== X-Google-Smtp-Source: ABdhPJx4F96uXqpXKJbkwUaij1OmBpJfBrZ4CVUAcProKFEqjv4XzeMalTF3wkg8sv23tVBPaKB/YA== 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> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 14EFFC0007C9 X-Stat-Signature: 5jcsti1ffq1j9ubf8wc56c491ergnufk Received-SPF: none (ziepe.ca>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=mail-il1-f170.google.com; client-ip=209.85.166.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619551348-716095 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 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