Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4470498pxj; Tue, 22 Jun 2021 00:35:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYKkvOQQIEBdiZPEubnat5SYMBNxU97AFXouuIEThMNHhZUANDpbSTScuI3upQGHar5+8E X-Received: by 2002:a92:8e04:: with SMTP id c4mr1735537ild.219.1624347320177; Tue, 22 Jun 2021 00:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624347320; cv=none; d=google.com; s=arc-20160816; b=RTRXTcU9Tuoxg8I6z+gldLlYoC7YbzVUpHYyiFlKQVb0oOp7/ypyYQJER8g8N8MAMA dnAth3DZW4uIBXVTMF+9pT2qh0SDBu2IT7Rr+uKDhos/eKjMRoOTgsAvof+aSUZEbU9z 29bgIlXnrqGL/fnzoQbj67h4oh2fbusITZ2TPOD4TaSraNXEDYRET65UwUKPrnuDf6kI +hZU9s36rZWTOXlElwgX3Kb1vZuf2ARyeKU2y1mfAEpfm7j7NVrX1QzJ28Kwz005MGfa ndGF0hV2d97Xwh6XyieGcjb0N/VU9mlaykJiw49Tcl9gWByA3XwLO3um7M7P0GWqyJ3n jZ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=cftS82h6Lvlu1N7dr24WCUbc/Kf/ihLvTWku+Fk+w1I=; b=ihjx4iyTfRim8AMUB8rdIeRr2pML6kYPBnKssizGzaTCC6lRVH6bd+dXTIehzmwq6c FvosNwvm5kOzUiVPVSQtdOzWt1eh4SE9d6GCJwh8WY5GHVRY6i5YEo+eo+1Eh/Dn8YUc oNiRdcvyOEWbrSjVZ8UYa7K/cVUi4IMaRL2nIF7on6Mrxgl20Cd3CRWZVb9qk99yeU0R IQSXBvsAIVTYDxXvcp+twNZs3MTo2xIDaTXaMtvtCDu/RkVZDyOqKh5xLF5Pg2cD5uYc akPUAL78L9gXVRXmesI94TkTFNFFl+3SPzHnp5SVU5ba3WbhxFhlRC4R3S2m0x3W17q7 5Zwg== 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 h19si12662187jaj.37.2021.06.22.00.35.07; Tue, 22 Jun 2021 00:35:20 -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 S230006AbhFVHf0 (ORCPT + 99 others); Tue, 22 Jun 2021 03:35:26 -0400 Received: from verein.lst.de ([213.95.11.211]:45444 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbhFVHf0 (ORCPT ); Tue, 22 Jun 2021 03:35:26 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A866167373; Tue, 22 Jun 2021 09:33:08 +0200 (CEST) Date: Tue, 22 Jun 2021 09:33:08 +0200 From: Christoph Hellwig To: Tomasz Figa Cc: Christoph Hellwig , Sergey Senozhatsky , Hans Verkuil , Ricardo Ribalda , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List Subject: Re: [PATCHv2 8/8] videobuf2: handle non-contiguous DMA allocations Message-ID: <20210622073308.GA32231@lst.de> References: <10a0903a-e295-5cba-683a-1eb89a0804ed@xs4all.nl> <20210617080107.GA1422@lst.de> <20210617085233.GA4702@lst.de> <20210617100656.GA11107@lst.de> <20210618042526.GA17794@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 18, 2021 at 01:44:08PM +0900, Tomasz Figa wrote: > > Well, dma_alloc_coherent users want a non-cached mapping. And while > > some architectures provide that using a vmap with "uncached" bits in the > > PTE to provide that, this: > > > > a) is not possibly everywhere > > b) even where possible is not always the best idea as it creates mappings > > with differnet cachability bets > > I think this could be addressed by having a dma_vmap() helper that > does the right thing, whether it's vmap() or dma_common_pages_remap() > as appropriate. Or would be this still insufficient for some > architectures? It can't always do the right thing. E.g. for the case where uncached memory needs to be allocated from a special boot time fixed pool. > > And even without that dma_alloc_noncoherent causes less overhead than > > dma_alloc_noncontigious if you only need a single contiguous range. > > > > Given that behind the scenes dma_alloc_noncontiguous() would also just > call __dma_alloc_pages() for devices that need contiguous pages, would > the overhead be basically the creation of a single-entry sgtable? In the best case: yes. > > So while I'm happy we have something useful for more complex drivers like > > v4l I think the simple dma_alloc_coherent API, including some of the less > > crazy flags for dma_alloc_attrs is the right thing to use for more than > > 90% of the use cases. > > One thing to take into account here is that many drivers use the > existing "simple" way, just because there wasn't a viable alternative > to do something better. Agreed, though, that we shouldn't optimize for > the rare cases. While that might be true for a few drivers, it is absolutely not true for the wide majority. I think you media people are a little special, with only the GPU folks contending for "specialness" :) (although media handles it way better, gpu folks just create local hacks that can't work portably).