Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5516039pxv; Wed, 7 Jul 2021 05:44:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx71VwCxvWsWBVnO+NSHOWHHAqbmtVeOxHRekLI5jtzSHLnFfRURLwoNJ+LdrEurZsMhuFn X-Received: by 2002:a92:a304:: with SMTP id a4mr18818364ili.197.1625661858543; Wed, 07 Jul 2021 05:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625661858; cv=none; d=google.com; s=arc-20160816; b=b4oTKCBe1B0lp9nIhVP2TW1TKFB+HfzpN11IYvfRYeiy4k9KZr74jhbrrNDPnBfYij GChi69C34JWP4G6s5ZoPfocfVGa8h0QSrSOJgfqEVYUuua+6sUfjB6RAq3qtTCyy+hui 4WqJqjetJANws0iKBCa+lV86rKtNm29Mt/PisPOKDz4qFaAYOnEkqI/7i9mBatRjNYij kb2N/KapDc4k3/naRaboopzUZYwWtcG9rbqptrTuNRxOKVU2v6QY9Ll+aZulwDkI91Fb gihtkRRo3o/8enRz8Y1wjoTwcEnWmMgQIGcNGzrgRb8MdTxnF0sMJRMM7nEbjAKlmFXW tKjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1r1cMb5IuUabwy6ufnOUx/1ARsY6RZ8tdA97vkp9E0A=; b=AckLxvfeFxbG1raxil5vgQjqDdp32dAlOQ+O4JMjQgJbrDfb4vjOguz0ZQxs35Cw7I reAPU/xqdZjOFVq8BJIvAm/BUY5V3YbroPldRT0jiU490VVRtDIGH55eXKY//K3xxKGN OUBO3TQRq5mauygX5nDQVXTLgITKLgxhQYe1Now5m3FmbRkaOCdok7WPO7GkowDh9CWQ ztp0LfmHX/pHopxnQYdil6gMxSopzH7sNmQqrZfO5ZQP74JEAtfTAnBtVxmARoT8uoej ThDhSe/3ON/Cnl5A3l+3B5WWwMgR54EPeDfU79e0TrID6tgg27zzNBLOCAtvpJwt5TAB 8sNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jlsNoDpv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si9557036iob.102.2021.07.07.05.44.07; Wed, 07 Jul 2021 05:44:18 -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; dkim=pass header.i=@chromium.org header.s=google header.b=jlsNoDpv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231551AbhGGMpP (ORCPT + 99 others); Wed, 7 Jul 2021 08:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbhGGMpO (ORCPT ); Wed, 7 Jul 2021 08:45:14 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69C9BC061574 for ; Wed, 7 Jul 2021 05:42:34 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id v20so3018802eji.10 for ; Wed, 07 Jul 2021 05:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1r1cMb5IuUabwy6ufnOUx/1ARsY6RZ8tdA97vkp9E0A=; b=jlsNoDpvpRCWC7QypzC3JPWQcjf8ZHOhkIKeaatKYesEPW3wWTNizbkKYxd4y/tVg3 kVVSZDCmtCeGugvyv4otWf7HJYbtWj3dOzbTzlGnMXgAsgAtq14+dvRPtYs8hVHgtEr/ j764X5VIu9mhAFK3+BrNo1Qkv4m/tude+exeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1r1cMb5IuUabwy6ufnOUx/1ARsY6RZ8tdA97vkp9E0A=; b=EeiP8HpxlHXUbS8g9U2UXXgLdsm3YDUsGxsy4cZplEy3Ev13G4rA+13L0z/3uDEMOS 7BpEcGU4gPaeltkYbj4xRbihutlKRvhXojZ4ntlM3K92j9XKIkZKbuxKM6N3Y8vsneE9 +adJb6rCL308Txia7dcCoelUcxokane/REUszb8/Slz6J4yIPkIatecbPDn50EwGq8xG s1rlflw8ZrL8Zogtk4zlVmaYWGxV8P9FCo5eHwJc/vJugM8+zONw1bpGYQ9AQ2J6ChHR bpV7TBblmZRGUqy0Z8Kpkz/yb4E1nzXtuVoCFCHEfkjT3dzTNqVjcMXDYnP9G+iZP2vT OD0Q== X-Gm-Message-State: AOAM5331TyQiDI+JSqmLt/FX3oOBOu09FOsqZfqQYcTAb2NSsUws6Ejg wGAj9A4VyaXGlJEmC/nXrv4a3fp55EqHRg== X-Received: by 2002:a17:906:8584:: with SMTP id v4mr23654756ejx.301.1625661752563; Wed, 07 Jul 2021 05:42:32 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id s4sm8907292edu.49.2021.07.07.05.42.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jul 2021 05:42:31 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id v5so2917560wrt.3 for ; Wed, 07 Jul 2021 05:42:31 -0700 (PDT) X-Received: by 2002:a5d:4001:: with SMTP id n1mr28151059wrp.159.1625661751106; Wed, 07 Jul 2021 05:42:31 -0700 (PDT) MIME-Version: 1.0 References: <10a0903a-e295-5cba-683a-1eb89a0804ed@xs4all.nl> <20210617080107.GA1422@lst.de> <20210617085233.GA4702@lst.de> <20210617100656.GA11107@lst.de> <20210618042526.GA17794@lst.de> <20210622073308.GA32231@lst.de> In-Reply-To: <20210622073308.GA32231@lst.de> From: Tomasz Figa Date: Wed, 7 Jul 2021 21:42:19 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv2 8/8] videobuf2: handle non-contiguous DMA allocations To: Christoph Hellwig Cc: Sergey Senozhatsky , Hans Verkuil , Ricardo Ribalda , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 4:33 PM Christoph Hellwig wrote: > > 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. > Fair enough. Thanks for elaborating. > > > 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). I don't have the evidence to argue, so let's just leave it at "time will tell". I think it's great that we have the possibility to do the more special things and we can see where it goes from now on. :) Best regards, Tomasz