Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp204565lqo; Wed, 27 Mar 2024 10:37:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQQrGPjkSZocCqAdpda7ulfDNKEKte8TvVv5IDrRFACu75XMOHekWXRcZzAw4Udl73c910aiMmBn8CC+muGP6ZqJlP1kYxeCR/sjtFhA== X-Google-Smtp-Source: AGHT+IGl7Bj22RLBoO37C0Mu+k3q62J97mzeVjgD9WM3zt6mGst11jYHya1ISwVeLEsOAq9LDgFZ X-Received: by 2002:a05:6a00:2306:b0:6e6:46f2:d4c8 with SMTP id h6-20020a056a00230600b006e646f2d4c8mr450428pfh.23.1711561026933; Wed, 27 Mar 2024 10:37:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711561026; cv=pass; d=google.com; s=arc-20160816; b=o9ifMZSyVgO95DP6JD9dAIF597sRrERfHuF5/Jxjzc+JSbi5gM1na2MwHhBtysYrZh U/+pWcWtvPyEm0aISyuY3TMsoS4ssaV1Jmi4x7pqEKd2Oagj2eRWpfs+Pls/IJ0i19a0 dF+oOK2ZGPlbjal4UFFI0LQligGogcl+hupOoQJAfduEDZq9ATj/9F9vyaePtzylhSwl 6QN1RoIT4pbAgLW9/NT21oW2PLREZr7LqkExh5mq+vPp1Enf3F54BXIpQRLFZmFuBHuo OZOZkWV4ngfJ1LW03YnqU4K4NyW+fNiiROOAEN9nitDYFAojeisPtnNiBPiOboro+GR6 AAcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MyfMHWP1Z5kFosJnJ/cLT9vrDNlc6F3RpHcMzwkJjx8=; fh=sheNrNmLCfLjTJnoKyL/s5Uek2kojIKjXIktQ4w+ij8=; b=coJJv+0TGvBg6Uba/No5CJK86tAfnXiRMsTpYxbJ3PrPQn3JuMndgIaIECYV63u1Us Rb73rt15hSEt/5tKMh+ylId4o2UtHoe8p5MOMZQrljNfaTPRRkUXy8nAaMM1yBl3+Lod NjK2GBMIsIXXOTbtVKuLAr8DVprGd5MEbH9fVP3vTz0Vlu4KdwDd4L1XP5xLFtPsk2qv 6KLkd1JfLKy6cJyKBYWQ8iOZS7Dzr1gAPY0dtsV6u3FREl1pOX6pzJSCl05Syx+5B3p3 8kkhGDLSIhchYgZ5XqtTT+xKEe6LcXvFCBomPuTzB/xw2G6V5r1hqWUlIB9xcKsbG/Dt 8HRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=VBiKMhfk; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-121677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121677-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j22-20020a62b616000000b006e628dd06efsi9612879pff.260.2024.03.27.10.37.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 10:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=VBiKMhfk; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-121677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121677-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D51FEB265F2 for ; Wed, 27 Mar 2024 17:15:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C3B914D458; Wed, 27 Mar 2024 17:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="VBiKMhfk" Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3C85131BB7 for ; Wed, 27 Mar 2024 17:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559714; cv=none; b=ZOgOudeSKYl5KzDL53QQRB6f7q+iuo3jW33dXmk3JRCJT+DHq9edNtQYuVObnHGrBM8nkOGWKL1StwgEjryUskNrjaY2dm+Bsgihy8FsC0fhJzAktonHvh7cySunxuBjblfd4sPCX3nz3yxQpT/5ABUihgfUoZOXzdBYPxEI3m8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559714; c=relaxed/simple; bh=9tnsRuZ5G7QjnwFgOQWvg/3sPZordPoR8Q1151meHlI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iRxpodjs9FHlNVB1G9+NB5uWyq0DGLBI64TllqhpAITJM69nbifm71lULbsQyUYoH+QPlBz4lURRq91TtbVlAifIb7jZ/3Bv/2fJgiEocWNVLXhSgm30pGNW8oQlSk24rg70cQZEu5oF3gNW+Zrv0ryduFXuVJmhNVSV55NdsHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=VBiKMhfk; arc=none smtp.client-ip=209.85.167.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3c3ceeb2d04so61042b6e.1 for ; Wed, 27 Mar 2024 10:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1711559712; x=1712164512; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MyfMHWP1Z5kFosJnJ/cLT9vrDNlc6F3RpHcMzwkJjx8=; b=VBiKMhfksZs2FoL+Oen+l4viEArx3fv0CeCL4ZN0MJMYAEWw8lwwAI62tJyGtfypKG YStnUcuL47P28tZ74VCODBd3XogFpKIFt2I1H5LDhwe8Pn2Odk4i6oMy7YlDpsAYlPTO D75ZkxizvkQm1VAXcB2fxNhtHu0Ea13T1ePeFq0wZgDd35QrbJ5cZ4EqSMqDWXsCsUKe 11keU8SaMEgPeXAJlgGV0Cwn/tcHEdWQrseBmSzdTwvVXScPcjnQ2SynNChB5RzD6Ijn l1H2JUkGBxblVgZMs3yehBRxo1htITSlBHmahaCPeTld9P1JuWPi+Bj/28xi93o39xkl 5ohg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711559712; x=1712164512; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MyfMHWP1Z5kFosJnJ/cLT9vrDNlc6F3RpHcMzwkJjx8=; b=rfRG8v7G+E6ZU80u14vrVfxopR1/+1lLGGnkw+gLae2razZosjvFkH6j4jKFjZ/kOz sglWyYvV9n3f7Vpmwqndl7TlL77h9tZK0siS35DQvSRSfVrg4vI4Lu5abpzPJ4WO9cYZ qHAE6jLrwFzjHJAno7Jp9XrSXK3wYXity8csWR86gI9lxJikhQL8GJ2uLkYqOtZtojxR IcnWV2Wy14bf6zfN2bbyWdRQYR4pr9Ypf/i7TH3UUaLBF6shPt+Tu/A4v2Iv4mJ4Hf0n PpawJFG/EwrGf2PHpjEFCCmMtaT1Ud5Rry3T3M8G7qP0vpSLm+XRzTvzpBhrgTqlPGXL a2Rg== X-Forwarded-Encrypted: i=1; AJvYcCXLNlbowBhEskQ1N4W67WzvIwYnoAdFIdM5LeQGfGp02f7HqVXgHxaciMSRJbQE9JHebu/CimRtbKJAa/L0bHW0SuusBLc4C3sw4ihz X-Gm-Message-State: AOJu0Yxio5JdzX1xOsNMPMskVbRY2YNyLYX1ioETp/b6EA/Zqy0ZskZ9 HxWztEV0M2urR9hFh0+DXZoMgbtY3GrmzKQBak+YeeYDAOi0mdj3V+fvmOhVjyE= X-Received: by 2002:a05:6808:64b:b0:3c3:d56d:a5dd with SMTP id z11-20020a056808064b00b003c3d56da5ddmr357972oih.18.1711559712027; Wed, 27 Mar 2024 10:15:12 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id kd9-20020a056214400900b00696b117a325sm499925qvb.108.2024.03.27.10.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 10:14:48 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rpWr2-005ajV-OE; Wed, 27 Mar 2024 14:14:24 -0300 Date: Wed, 27 Mar 2024 14:14:24 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: Leon Romanovsky , Robin Murphy , Marek Szyprowski , Joerg Roedel , Will Deacon , Chaitanya Kulkarni , Jonathan Corbet , Jens Axboe , Keith Busch , Sagi Grimberg , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, Bart Van Assche , Damien Le Moal , Amir Goldstein , "josef@toxicpanda.com" , "Martin K. Petersen" , "daniel@iogearbox.net" , Dan Williams , "jack@suse.com" , Zhu Yanjun Subject: Re: [RFC RESEND 00/16] Split IOMMU DMA mapping operation to two steps Message-ID: <20240327171424.GI8419@ziepe.ca> References: <20240307000036.GP9225@ziepe.ca> <20240307150505.GA28978@lst.de> <20240307210116.GQ9225@ziepe.ca> <20240308164920.GA17991@lst.de> <20240308202342.GZ9225@ziepe.ca> <20240309161418.GA27113@lst.de> <20240319153620.GB66976@ziepe.ca> <20240321223910.GA22663@lst.de> <20240322184330.GL66976@ziepe.ca> <20240324232215.GC20765@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240324232215.GC20765@lst.de> On Mon, Mar 25, 2024 at 12:22:15AM +0100, Christoph Hellwig wrote: > On Fri, Mar 22, 2024 at 03:43:30PM -0300, Jason Gunthorpe wrote: > > If we are going to make caller provided uniformity a requirement, lets > > imagine a formal memory type idea to help keep this a little > > abstracted? > > > > DMA_MEMORY_TYPE_NORMAL > > DMA_MEMORY_TYPE_P2P_NOT_ACS > > DMA_MEMORY_TYPE_ENCRYPTED > > DMA_MEMORY_TYPE_BOUNCE_BUFFER // ?? > > > > Then maybe the driver flow looks like: > > > > if (transaction.memory_type == DMA_MEMORY_TYPE_NORMAL && dma_api_has_iommu(dev)) { > > Add a nice helper to make this somewhat readable, but yes. > > > } else if (transaction.memory_type == DMA_MEMORY_TYPE_P2P_NOT_ACS) { > > num_hwsgls = transcation.num_sgls; > > for_each_range(transaction, range) { > > hwsgl[i].addr = dma_api_p2p_not_acs_map(range.start_physical, range.length, p2p_memory_provider); > > hwsgl[i].len = range.size; > > } > > } else { > > /* Must be DMA_MEMORY_TYPE_NORMAL, DMA_MEMORY_TYPE_ENCRYPTED, DMA_MEMORY_TYPE_BOUNCE_BUFFER? */ > > num_hwsgls = transcation.num_sgls; > > for_each_range(transaction, range) { > > hwsgl[i].addr = dma_api_map_cpu_page(range.start_page, range.length); > > hwsgl[i].len = range.size; > > } > > > > And these two are really the same except that we call a different map > helper underneath. So I think as far as the driver is concerned > they should be the same, the DMA API just needs to key off the > memory tap. Yeah.. If the caller is going to have compute the memory type of the range then lets pass it to the helper dma_api_map_memory_type(transaction.memory_type, range.start_page, range.length); Then we can just hide all the differences under the API without doing duplicated work. Function names need some work ... > > > > So I take it as a requirement that RDMA MUST make single MR's out of a > > > > hodgepodge of page types. RDMA MRs cannot be split. Multiple MR's are > > > > not a functional replacement for a single MR. > > > > > > But MRs consolidate multiple dma addresses anyway. > > > > I'm not sure I understand this? > > The RDMA MRs take a a list of PFNish address, (or SGLs with the > enhanced MRs from Mellanox) and give you back a single rkey/lkey. Yes, that is the desire. > > To go back to my main thesis - I would like a high performance low > > level DMA API that is capable enough that it could implement > > scatterlist dma_map_sg() and thus also implement any future > > scatterlist_v2, bio, hmm_range_fault or any other thing we come up > > with on top of it. This is broadly what I thought we agreed to at LSF > > last year. > > I think the biggest underlying problem of the scatterlist based > DMA implementation for IOMMUs is that it's trying to handle to much, > that is magic coalescing even if the segments boundaries don't align > with the IOMMU page size. If we can get rid of that misfeature I > think we'd greatly simply the API and implementation. Yeah, that stuff is not easy at all and takes extra computation to figure out. I always assumed it was there for block... Leon & Chaitanya will make a RFC v2 along these lines, lets see how it goes. Thanks, Jason