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=-7.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 3001DC07E9B for ; Wed, 7 Jul 2021 12:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1308361CBE for ; Wed, 7 Jul 2021 12:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbhGGMpP (ORCPT ); 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-Google-Smtp-Source: ABdhPJw/2WFxQ8+vMCz9r87vQ0TlGETUCam3qnMHsTnrPR3XMQj4AuhppmqSJLgWjVcqeIJgZWCvqw== 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