Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1151581lqs; Wed, 6 Mar 2024 07:44:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4d7P/ufwy7WjdSiGvtudsTv3Hubb1zI29GUe1TgNK4Vs30TSXvzWkekH/Qw+GygMLAwQ+iINXUefB4Rrnir3Jkeg7T0Wegfr7RYRWAQ== X-Google-Smtp-Source: AGHT+IFAfvXU4BA8mKTBMslTMnhXVRmZ6tkbxPyam3RXAE62HWRlWLIqooQvOm7w6/Dx8t7VKwB/ X-Received: by 2002:a2e:99d2:0:b0:2d2:44df:b112 with SMTP id l18-20020a2e99d2000000b002d244dfb112mr3264049ljj.41.1709739843674; Wed, 06 Mar 2024 07:44:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709739843; cv=pass; d=google.com; s=arc-20160816; b=yiYMDzfy+DC4278j4w3WCouW5Xl/apxCYxrc94fwpb79x8H2twzehE3yAPqqI1MK2Q I+G4FGIUN6L89haaSbVhRI6EJauXwGNSPMMQE7kr489HGlR+gmWbBjE44ZWirFcjAZmB YpMB+z4EtvNLBVCcyiYVm2i6r4BBqYb0S+a+X3Hf1oL2XGIXH5AHFNZJ/cAqhx7g+Fi8 ZeSpbIALyV/I9kD4Oxf73mO3qNrj/VHpfCdg0fO6lxHwsoiVeH7nXSUxZKmH8Ox1VTNh eCtIp9fDyBDFPEClfmuLaXim8zQMehmDnIFWaXCWe6MyyRqzfmap3iQ+V4Ho5/j33/HM xMPA== 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=k1cN5gYBP45I54WCStxe7DUVSwP4yg1UztQaoI/QgCY=; fh=rCRNPNO/QUZc0la38AboMRwsRoi476SSH4kOpg/OmGo=; b=wHhLUmRzRVbT/DUautn9OvUX3k0Q/FshOr4mEZ5I/7gZxYFZOn1yJglUTsoi/iSsUr gD6dqdzLbq9ab+lEQWkt7KnQD7SzJ4vynN44et+7SnE7Yqd59B32nxS4hG9DDZaJod2Y DiVG0lV4PdP7Has6WzjgRw0TYNPwS+x8pyRUhUqxsUyLJe9Ch3c/MWJhp7DMyEkwWYcV sH/ziHrvpCqFFlofH2Sy9PcbR1EyePvxLUM57lzDQ21aCKD1bx9Ld+9Srh1oUD4NSW7f tw3MPnwm+btK8JG/JwmRGIeruQ3FfEkKB2oQ5F2ICXVNeG3OIh6tWKQ0iG79e9Uo/Emo 51HQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=EHbRTffY; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-94182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94182-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i19-20020a05640242d300b005643bb8fa4asi6399784edc.152.2024.03.06.07.44.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 07:44:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=EHbRTffY; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-94182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94182-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3F1301F2A453 for ; Wed, 6 Mar 2024 15:44:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F000136661; Wed, 6 Mar 2024 15:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="EHbRTffY" Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 6403C136650 for ; Wed, 6 Mar 2024 15:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709739813; cv=none; b=cgVqOhP1LZwHVfoNlwP53vTj9t+mzgl70SHzPtzAarnN52tvGDt3xbhVlUYVLK9opkHCa/uRnQ+kMsTp9dmyXbsA5vpjmJzREX1K9vpXPdQxWjlTy6qrrjAFdc7Rov09glwb35vrnZF04YC/Z45MKE78eVgahklS3kQAp83TIa8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709739813; c=relaxed/simple; bh=pGaDc0TLwfeotZCgvBcO4BGO9qk0bmKODRVmJ9jH1RY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=olqPzeZsyW2DL1Fn8lwVBz5vQsJIIFeLydlLqc1yQp0bJ5yk6MNprZynvGTuCOWr0XPgjRog3AwiZg2ukuEuzQpJiliPa3osuZ4q6P822etWkVU9WPYTzlfFQ3cZy0nw18vlwb4WHzExfFlhCKFQATWvTEBFi9A59HHJLr/BIcI= 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=EHbRTffY; arc=none smtp.client-ip=209.85.161.46 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-oo1-f46.google.com with SMTP id 006d021491bc7-5a1a069bd16so169910eaf.3 for ; Wed, 06 Mar 2024 07:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1709739810; x=1710344610; 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=k1cN5gYBP45I54WCStxe7DUVSwP4yg1UztQaoI/QgCY=; b=EHbRTffYRUPXi/5DH5IevGwnWlcrTDhMcLaL1V7n8fKyTJ3zWc9GzowCcApsqb4F/j OAvS90y7UEP4b6YqKcflqWW3qa+9Cpai4UMVePHbjxruVuIK6Qpvw+95onDilF2IwIYz gzkxxOC+kczjYtmKUDMoOV4dtPdPMkdCIcC0Z2rAD8AIp8thVggKPrA61LG0p/82v8S7 HHX0rK4u0RDL59n+x6QuLIprN12eVoVIiAm8geP4mTuO8hkg66lhfAgl9I/sRRkS9z0p OPtl/BDe2lWdfFN+MtXlT70pUOfAog7UHhd9W2RvAXQcH7aWmTVfsVi5orHgjUUAPLDK Qd5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709739810; x=1710344610; 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=k1cN5gYBP45I54WCStxe7DUVSwP4yg1UztQaoI/QgCY=; b=J5ygRwk0SrG9QIArS2aDlJUZphDz2rGYdDj2rbAMJeCOI2hXR7pMjSjKmnHqfakVVo eu25KDeqgVY900fX3UQNnnQgq7OCB7qRkc/P0ebSjJ3rL6YBVNyOYY5lXtu6U2dAzhVE Mluq67j6HOeHTZnL3RQoR17ZjMXtu0WU2vagR0Q7jXM5E+50yMOBVY/ybpjpk8NgyKU5 oAU+yFla0G6wj+HQFtTqAuptIQiDNr9HxYmy6kQet8dQXMj+cshp5YT/TSU9X2rRDZuK UQi/Xz5cOpMeDs5h5gEsHuahVUkzVtX8cTvy+dztJedTGoVcbBGPfgcIK1pQSchIXKlR Ll4g== X-Forwarded-Encrypted: i=1; AJvYcCXPcUWNTsz3zYMfZbqRyRrbm3edPdXh1d2IR+9+6ej2vZp6tt95sPKXRH0u/2IS7sI/ooIa6O1b/5ViIqOaLyW5ULi75roLFJ8LzB/I X-Gm-Message-State: AOJu0YzMflcFUfFLGUS3AG7sxXULqf20lRm7HeDX7B6m6HruId7STlaG KIhhSVeJWoLIuTMY2uzUtaj1psAr8NRcECPHq9uu+DjgmjOf+GMLi9hnhTAUSSg= X-Received: by 2002:a05:6358:78a:b0:17c:1bc7:16d5 with SMTP id n10-20020a056358078a00b0017c1bc716d5mr5567125rwj.5.1709739810357; Wed, 06 Mar 2024 07:43:30 -0800 (PST) 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 j10-20020ae9c20a000000b007871bac855fsm6707680qkg.47.2024.03.06.07.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 07:43:29 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rhtQW-001c2D-PU; Wed, 06 Mar 2024 11:43:28 -0400 Date: Wed, 6 Mar 2024 11:43:28 -0400 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: <20240306154328.GM9225@ziepe.ca> References: <47afacda-3023-4eb7-b227-5f725c3187c2@arm.com> <20240305122935.GB36868@unreal> <20240306144416.GB19711@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: <20240306144416.GB19711@lst.de> On Wed, Mar 06, 2024 at 03:44:16PM +0100, Christoph Hellwig wrote: > Except that the flows are fundamentally different for the "can coalesce" > vs "can't coalesce" case. In the former we have one dma_addr_t range, > and in the latter as many as there are input vectors (this is ignoring > the weird iommu merging case where we we coalesce some but not all > segments, but I'd rather not have that in a new API). I don't think they are so fundamentally different, at least in our past conversations I never came out with the idea we should burden the driver with two different flows based on what kind of alignment the transfer happens to have. Certainly if we split the API to focus one API on doing only page-aligned transfers the aligned part does become a little. At least the RDMA drivers could productively use just a page aligned interface. But I didn't think this would make BIO users happy so never even thought about it.. > The total transfer size should just be passed in by the callers and > be known, and there should be no offset. The API needs the caller to figure out the total number of IOVA pages it needs, rounding up the CPU ranges to full aligned pages. That becomes the IOVA allocation. offset is something that arises to support non-aligned transfers. > So if we want to efficiently be able to handle these cases we need > two APIs in the driver and a good framework to switch between them. But, what does the non-page-aligned version look like? Doesn't it still look basically like this? And what is the actual difference if the input is aligned? The caller can assume it doesn't need to provide a per-range dma_addr_t during unmap. It still can't assume the HW programming will be linear due to the P2P !ACS support. And it still has to call an API per-cpu range to actually program the IOMMU. So are they really so different to want different APIs? That strikes me as a big driver cost. > I'd still prefer to wrap it with dma callers to handle things like > swiotlb and maybe Xen grant tables and to avoid the type confusion > between dma_addr_t and then untyped iova in the iommu layer, but > having this layer or not is probably worth a discussion. I'm surprised by the idea of random drivers reaching past dma-iommu.c and into the iommu layer to setup DMA directly on the DMA API's iommu_domain?? That seems like completely giving up on the DMA API abstraction to me. :( IMHO, it needs to be wrapped, the wrapper needs to do all the special P2P stuff, at a minimum. The wrapper should multiplex to all the non-iommu cases for the driver too. We still need to achieve some kind of abstraction here that doesn't bruden every driver with different code paths for each DMA back end! Don't we?? Jason