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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58F94C49361 for ; Fri, 18 Jun 2021 04:25:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46ACE6117A for ; Fri, 18 Jun 2021 04:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231585AbhFRE1l (ORCPT ); Fri, 18 Jun 2021 00:27:41 -0400 Received: from verein.lst.de ([213.95.11.211]:33052 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbhFRE1i (ORCPT ); Fri, 18 Jun 2021 00:27:38 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 3506468D12; Fri, 18 Jun 2021 06:25:26 +0200 (CEST) Date: Fri, 18 Jun 2021 06:25:26 +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: <20210618042526.GA17794@lst.de> References: <20210427131344.139443-1-senozhatsky@chromium.org> <20210427131344.139443-9-senozhatsky@chromium.org> <10a0903a-e295-5cba-683a-1eb89a0804ed@xs4all.nl> <20210617080107.GA1422@lst.de> <20210617085233.GA4702@lst.de> <20210617100656.GA11107@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 12:21:33PM +0900, Tomasz Figa wrote: > > On Thu, Jun 17, 2021 at 06:40:58PM +0900, Tomasz Figa wrote: > > > Sorry, I meant dma_alloc_attrs() and yes, it's indeed a misnomer. Our > > > use case basically has no need for the additional coherent mapping, so > > > creation of it can be skipped to save some vmalloc space. (Yes, it > > > probably only matters for 32-bit architectures.) > > > > Yes, that is the normal use case, and it is solved by using > > dma_alloc_noncoherent or dma_alloc_noncontigous without the vmap > > step. > > True, silly me. Probably not enough coffee at the time I was looking at it. > > With that, wouldn't it be possible to completely get rid of > dma_alloc_{coherent,attrs}() and use dma_alloc_noncontiguous() + > optional kernel and/or userspace mapping helper everywhere? (Possibly > renaming it to something as simple as dma_alloc(). 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 And even without that dma_alloc_noncoherent causes less overhead than dma_alloc_noncontigious if you only need a single contiguous range. 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.