Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp588790pxu; Tue, 6 Oct 2020 13:57:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx11WzeWMghgAg62ybv+lGAEIHS8E7QFmozfTRbcQmUC+sNN73qcWzPxbPhHQm0YHmzLW6J X-Received: by 2002:aa7:d9c9:: with SMTP id v9mr7761686eds.103.1602017878514; Tue, 06 Oct 2020 13:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602017878; cv=none; d=google.com; s=arc-20160816; b=Ka+485DVQ4yLGBovel3DCb2h/dCjP+k8QOJ7usdUokhz9jpz2Bob8+9epxVB5Yr2sZ EM4xL8QdmWd0u1gX5w2ap5nGK261ZKDBPZdnpNBm4J2o0C1keQqsEBbTb59u9QEdngIQ AZ/WEDCzPSZ1XpffPDI5+OLKlrr8vF8YW8s9fslPsPMLsd8yZ7136rlXWUdh18lhHQKS 2UVxvuUqROdEec8U+OonqPmpTJr7/Glhbc2NJwjUoJ63QKBK7ynWa61wS9UX9rJ00UJP 9E9jHKtMlHiEglFP5FZuk7bWw7gd6iGjTqbXk10JJ1zlWRKy8ihAD+1RO7RIWBF0sSK5 UT4A== 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=kZ33m0een3FmBO5zM6YS30Fhun5lzxt8LRsuBmJ9np8=; b=c5Gp2mZxNSKggZ0BN8PmL1Q9Z7Wh5h6r3t0pMiPx7hpuKAn5lqo9Rag4Em3klNsMd3 hT4GwTgB1bKJLbQeoDdfDbnHuKuUQR+gSZdxJoVD/u0EdeIf47JNHQSbjKKs03blcncM 7bg88bKfbq76Ly/iy9EDtnr+4kESbSIZ+0jbJIlyB16ZpKnDAUXgWUGz7DnRacn6mDxE z93/NQK4fVHPr5B2Vmt2/O7mlMHAwQuPmWPTVcvweLS+a/zjxCmkAzWXcsOMCT60b7Xn v3KVVbNAv/EMWwNYjLfF1hF+1egHsoOg4rzrr9Ug/CHBu9jIzO2zKjhnJG00Mm56xY21 HYCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Qfg5p3wm; 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 f8si3013611ejh.452.2020.10.06.13.57.34; Tue, 06 Oct 2020 13:57:58 -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=Qfg5p3wm; 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 S1727345AbgJFU4U (ORCPT + 99 others); Tue, 6 Oct 2020 16:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727333AbgJFU4U (ORCPT ); Tue, 6 Oct 2020 16:56:20 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1195C0613D3 for ; Tue, 6 Oct 2020 13:56:19 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id p13so9136543edi.7 for ; Tue, 06 Oct 2020 13:56:19 -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=kZ33m0een3FmBO5zM6YS30Fhun5lzxt8LRsuBmJ9np8=; b=Qfg5p3wmaIK8FSiIu4IdCn4X7nejDPhFFZhUVBVUejoaklw0Xl8abJMx/NPlE+GAYD GFFRBTXhLKiSTLhMEWACUyrBty03El/kGu4Ye5XJJWvvK/JT9MZ2EHl/BwOPsWpbvWqd 6hSErfchiydyFBZt3FeeoxPWw3eNiC6MJ1Mv4= 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=kZ33m0een3FmBO5zM6YS30Fhun5lzxt8LRsuBmJ9np8=; b=C28QhRaqk8BDbHFVv8g3aE8ZlIG6GDJYaUd2U1RCjWrk7PucvOtU1aIRHqjB8NOeUO 89+7oqgdvcjrSv9noS56PVxi7/yQDGXMc/2huCWwNsxRPn6ThyOoctjQG49Xka0huiOO H8UnHIXWjkCHVlZEkI8zPsZTn1BJnTG4IqcW1ZHmjJnPMoyq6kGSRQFiISR4iGy4cVwH uV7S5Xhp1j4BZWSl7VXj15U3K1WevymjLm0xhbkoFeCZ1MSvchK4xVk74BlCBdUQ0vAC NdeVXj5W/VvhEFAF6CbhtSeP1qqiWw2pJsCpYYDzEC9eoeL12637zZCPvIznxN5CO5QF aRpw== X-Gm-Message-State: AOAM5304p7T3Evr5eJyyURLF0WWouGaEz25S3TWi7rp3lKv+QS6lNTkB d7PvBVikrQzHnIaWoKgjFj70WXTLVifvbA== X-Received: by 2002:a05:6402:1515:: with SMTP id f21mr7909613edw.175.1602017778160; Tue, 06 Oct 2020 13:56:18 -0700 (PDT) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com. [209.85.221.54]) by smtp.gmail.com with ESMTPSA id s25sm1941786ejc.29.2020.10.06.13.56.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Oct 2020 13:56:16 -0700 (PDT) Received: by mail-wr1-f54.google.com with SMTP id n18so7180828wrs.5 for ; Tue, 06 Oct 2020 13:56:16 -0700 (PDT) X-Received: by 2002:adf:df8e:: with SMTP id z14mr6756108wrl.32.1602017775603; Tue, 06 Oct 2020 13:56:15 -0700 (PDT) MIME-Version: 1.0 References: <20200930160917.1234225-1-hch@lst.de> <20200930160917.1234225-9-hch@lst.de> <20201002175040.GA1131147@chromium.org> <20201005082629.GA13850@lst.de> In-Reply-To: <20201005082629.GA13850@lst.de> From: Tomasz Figa Date: Tue, 6 Oct 2020 22:56:04 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API To: Christoph Hellwig , Sergey Senozhatsky Cc: Mauro Carvalho Chehab , Marek Szyprowski , "open list:IOMMU DRIVERS" , Robin Murphy , Linux Doc Mailing List , Linux Kernel Mailing List , Linux Media Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 5, 2020 at 10:26 AM Christoph Hellwig wrote: > > On Fri, Oct 02, 2020 at 05:50:40PM +0000, Tomasz Figa wrote: > > Hi Christoph, > > > > On Wed, Sep 30, 2020 at 06:09:17PM +0200, Christoph Hellwig wrote: > > > Add a new API that returns a virtually non-contigous array of pages > > > and dma address. This API is only implemented for dma-iommu and will > > > not be implemented for non-iommu DMA API instances that have to allocate > > > contiguous memory. It is up to the caller to check if the API is > > > available. > > > > Would you mind scheding some more light on what made the previous attempt > > not work well? I liked the previous API because it was more consistent with > > the regular dma_alloc_coherent(). > > The problem is that with a dma_alloc_noncoherent that can return pages > not in the kernel mapping we can't just use virt_to_page to fill in > scatterlists or mmap the buffer to userspace, but would need new helpers > and another two methods. > > > > - no kernel mapping or only temporary kernel mappings are required. > > > That is as a better replacement for DMA_ATTR_NO_KERNEL_MAPPING > > > - a kernel mapping is required for cached and DMA mapped pages, but > > > the driver also needs the pages to e.g. map them to userspace. > > > In that sense it is a replacement for some aspects of the recently > > > removed and never fully implemented DMA_ATTR_NON_CONSISTENT > > > > What's the expected allocation and mapping flow with the latter? Would that be > > > > pages = dma_alloc_noncoherent(...) > > vaddr = vmap(pages, ...); > > > > ? > > Yes. Witht the vmap step optional for replacements of > DMA_ATTR_NO_KERNEL_MAPPING, which is another nightmare to deal with. > > > Would one just use the usual dma_sync_for_{cpu,device}() for cache > > invallidate/clean, while keeping the mapping in place? > > Yes. And make sure the API isn't implemented when VIVT caches are > used, but that isn't really different from the current interface. Okay, thanks. Let's see if we can make necessary changes to the videobuf2. +Sergey Senozhatsky for awareness too. Best regrards, Tomasz