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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D5C6D132A2 for ; Mon, 4 Nov 2024 09:15:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30DA46B0083; Mon, 4 Nov 2024 04:15:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2962F6B0085; Mon, 4 Nov 2024 04:15:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 137566B0088; Mon, 4 Nov 2024 04:15:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E5FB96B0083 for ; Mon, 4 Nov 2024 04:15:45 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 74EFC1C7B1F for ; Mon, 4 Nov 2024 09:15:45 +0000 (UTC) X-FDA: 82747854756.29.F956F3A Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf24.hostedemail.com (Postfix) with ESMTP id 6461F180011 for ; Mon, 4 Nov 2024 09:15:39 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of hch@lst.de designates 213.95.11.211 as permitted sender) smtp.mailfrom=hch@lst.de; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730711579; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cejgD+JsxZqAlNgtg45X0wzmaS1EcMCbAdOV/14Efl8=; b=U3MuWeueagBVPFchvk9PE/aN5DHbU6tSzaeIZgWQS8Lz40xZl2lBMHlcrvog6ZXa0nCQGU 1jj/zTOrcibFZQVm0SsBRkhpni7I5imA9k6/sbG+Hzxy7Wj2w9n8zM/PC9H/4by4VsWMQ/ JVh9GOHJnjY/sb4qN8W0U7X8BoWF420= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of hch@lst.de designates 213.95.11.211 as permitted sender) smtp.mailfrom=hch@lst.de; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730711579; a=rsa-sha256; cv=none; b=5kr9Ytmtdsp6qlbmH6IwrWgUMzLYPxn+8TH0VwAXjxw+2XinPQ77Sm4ABKPbyTkT3GTrug HY6sc8yQ6DbPdDtvpqPFgKydTfcd44tZdU/qcg0R/grw/P0mhququwcpaRHMFZbGyYeS9c iojPNfxrkR0YubCzGHGesPftRcDMNLQ= Received: by verein.lst.de (Postfix, from userid 2407) id 95A03227AAD; Mon, 4 Nov 2024 10:15:38 +0100 (CET) Date: Mon, 4 Nov 2024 10:15:38 +0100 From: Christoph Hellwig To: Robin Murphy Cc: Leon Romanovsky , Jens Axboe , Jason Gunthorpe , Joerg Roedel , Will Deacon , Christoph Hellwig , Sagi Grimberg , Keith Busch , Bjorn Helgaas , Logan Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , Marek Szyprowski , =?iso-8859-1?B?Suly9G1l?= Glisse , Andrew Morton , Jonathan Corbet , 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, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 08/17] dma-mapping: add a dma_need_unmap helper Message-ID: <20241104091538.GB25041@lst.de> References: <00385b3557fa074865d37b0ac613d2cb28bcb741.1730298502.git.leon@kernel.org> <7e362d8b-c02a-4327-9c5d-af1c4725ddc7@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7e362d8b-c02a-4327-9c5d-af1c4725ddc7@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6461F180011 X-Stat-Signature: nsofdrhfc3z9i9f9t7xpbyhahh4qnccp X-Rspam-User: X-HE-Tag: 1730711739-644779 X-HE-Meta: U2FsdGVkX1+3Nw7KiA0J49V7YX7ZFKWgIyu2ewWB0pjiz9gNqC26oinpX98vMMt+RJBdZgbTTKOz2bhSafUOFR1yL5zeXSkEuQjH9q0nqni4PS7yESd6/QPXfbXRw4M/N3ab/sKKkMWjcbhl+MWwoh6TYXpQHd3F2yQUAehd7fcbHhbOKSXZtbLfx1Eb3NmZdxtoGZPM5YAKskOESbHuMuLBL7qbwNDjDtVscPoH1xhWGGqEsF/k8H4OhCVw4f20OwpqbhKrqLoayBzKiPQcf24GqTcW9ApBJTc4LgTOL+8/CIvcj18guu+iPc6xlrDOwYwkHXjaAvbCTmsNM5qVW312JS7vmnRZQQCnPmE5YYw7SbK4tKQLHehn45nQY/H/jnLYal514OhbnaotLUUm8wbuk+cAQr9lRFb+6J2cSwNnhc+/Uxnw1P1oIGK5HlgcifPexfOgHOUBxQfPfSAGf1N5NVkUKLzeFX6Ey9blvM0JC75ckxALRm74BYySV4MPXf7Qvvrv9oh+xxp+dPxS14u8k76uMF2wi/7AINIyiFeXFcz7PKrljWmNOq8vW+JkBX24GgbYG/skBJTuXa4cTdsM35u70ziJzXyPGxfP6TMzKAhMxjZyA6HYDASpLagFherv3qLUkUhQIAWzxORS8gpkxB/r+etikrMpCgOLph9OVLb1uK2J2HtQh5bar3F9RxhsIXvVq9YtDeC/pbtDHz4gn9Jg0UfrnXwBna6OFJNOEgWBaae1O2VZYJ8vanOY68c9Iuc7cxZUJTVffalF9Mxz8qtfD0S2KWp0AQO7KLkwpdFZ9Ghk9mnA/XxvlRIyTvlYFSoYfAaEuw6DfTXcPhCnCIdJ+q3DCcgXazz2Gqy51YMCP60KwmNwVdJgkxOLLs86s7Ft6NbXg0Wa58l+O5SsOrDZnXwmUTcvzXaEMO8OzqB4ekDaARuNZlo8fqiJY/uAE6Vxal47zdLvHyY DYtM4A0j 5u6vKpZRJdhpDq+WCyu9CxAQJ/8Zn3uefZh9BCxMdj+bC2lXgz9b/+w1m9NoYjzhODDQcMhV2w6XajmWnYuFrdAVKXRW6Ew3vl6HpNb+IOuteQJrDtP5lO6hizA== 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: List-Subscribe: List-Unsubscribe: On Thu, Oct 31, 2024 at 09:18:11PM +0000, Robin Murphy wrote: >> +/** >> + * dma_need_unmap - does this device need dma_unmap_* operations >> + * @dev: device to check >> + * >> + * If this function returns %false, drivers can skip calling dma_unmap_* after >> + * finishing an I/O. This function must be called after all mappings that might >> + * need to be unmapped have been performed. > > In terms of the unmap call itself, why don't we just use dma_skip_sync to > short-cut dma_direct_unmap_*() and make sure it's as cheap as possible? > > In terms of not having to unmap implying not having to store addresses at > all, it doesn't seem super-useful when you still have to store them for > long enough to find out that you don't :/ I don't fully understand the comment, mostly because the way I read the two sentences appear to contradict each other. Bypassing dma_direct_unmap_ is not the important part, because it already is pretty cheap. Storing the addresses is not. That being said now that we never check need_unmap in the iova path it might make sense to not have a separate helper, but it needs to be exposed and documented.