Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp788452ybt; Mon, 6 Jul 2020 23:48:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZn704WE9nh3CYB3Qy3ByULV6IyTAT1P75K73/NvUKMic0Rh9iv3jTljgE4USSBGeJurTf X-Received: by 2002:a50:fe16:: with SMTP id f22mr53451570edt.315.1594104501637; Mon, 06 Jul 2020 23:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594104501; cv=none; d=google.com; s=arc-20160816; b=FxEisCue25Mn4yhL27+y0ZQmxGNuky8sYGjtDJ87CL9C4euO6EKtksTQ+ObYwWzZ73 iKIHiFrLyQ453ESwpohjoEWmBKRyJsyWhiXCz9GaQvtSnPy/q7Wuy3+dStNeFH9U+i2V vM0HEtgo8Cid1bWn8qBG95ec7UfGioNLvm2Gdcmesplzie0mE0/GgfH7vYreEigSySxK JJrSViE6ROZqZ8BguyulOpVfXGCIVlpOHVTTNbbWwOI48Sg6H9kzjoYNV0Wk0FSYdqpg 7QQfEbQ/7zClAgsXvtGSGiHTTFajK90msDwLpGWi0WIM93+D8sAL80CGSG7rrpY+I74/ C73w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=6g2MheZq33VWIU8UaRA2StCkj5nAe+Y1EbxKwNYbecU=; b=y1T9C4MNAxown3/c0tUPRTb5CQqTJGAJSkURYzDe3lf4XsYpd36jZPaFiBEpHTHxLm OENyzebuxMzQSkCdXmg/zdBWLOwwTP0Uy66JZhH0ObU1lHuAgPJJR+qYmoe1SGC3/UbP slLLWXA9LOP0O3BRQnqTRAPPb9KW+6XvI+X4lzmWqGKPqqsBRNVSX0JqOUVPrTpLhAD5 FPj74bWLSR3R6cezMkxVQCUMZ7iI/LROCEfEf0+4FvJRlplZNO/j8RYjU1a3e655HVK8 2YCN0Qw3jBfgquU5D0ix4qBCsqNB8SHmLkwLHZk86X5mBgoc6QAfM3jOOZErVCYk4ZHw GuJA== ARC-Authentication-Results: i=1; mx.google.com; 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 i18si14206053ejy.71.2020.07.06.23.47.58; Mon, 06 Jul 2020 23:48:21 -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; 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 S1728182AbgGGGre (ORCPT + 99 others); Tue, 7 Jul 2020 02:47:34 -0400 Received: from verein.lst.de ([213.95.11.211]:57348 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGGrd (ORCPT ); Tue, 7 Jul 2020 02:47:33 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id AD38268AFE; Tue, 7 Jul 2020 08:47:30 +0200 (CEST) Date: Tue, 7 Jul 2020 08:47:30 +0200 From: Christoph Hellwig To: Jonathan Lemon Cc: Christoph Hellwig , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Magnus Karlsson , iommu@lists.linux-foundation.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] dma-mapping: add a new dma_need_sync API Message-ID: <20200707064730.GA23602@lst.de> References: <20200629130359.2690853-1-hch@lst.de> <20200629130359.2690853-2-hch@lst.de> <20200706194227.vfhv5o4lporxjxmq@bsd-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706194227.vfhv5o4lporxjxmq@bsd-mbp.dhcp.thefacebook.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 06, 2020 at 12:42:27PM -0700, Jonathan Lemon wrote: > On Mon, Jun 29, 2020 at 03:03:56PM +0200, Christoph Hellwig wrote: > > Add a new API to check if calls to dma_sync_single_for_{device,cpu} are > > required for a given DMA streaming mapping. > > > > +:: > > + > > + bool > > + dma_need_sync(struct device *dev, dma_addr_t dma_addr); > > + > > +Returns %true if dma_sync_single_for_{device,cpu} calls are required to > > +transfer memory ownership. Returns %false if those calls can be skipped. > > Hi Christoph - > > Thie call above is for a specific dma_addr. For correctness, would I > need to check every addr, or can I assume that for a specific memory > type (pages returned from malloc), that the answer would be identical? You need to check every mapping. E.g. this API pairs with a dma_map_single/page call. For S/G mappings you'd need to call it for each entry, although if you have a use case for that we really should add a dma_sg_need_sync helper instea of open coding the scatterlist walk.