Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3124874pxk; Mon, 5 Oct 2020 01:28:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7zMHKJi2YUl4w5al7ELUbkz/jTuCNtljxkjFkHgplfjv5u5kX5TEKshvV3SCniV+pd8xi X-Received: by 2002:a17:906:b01a:: with SMTP id v26mr15073812ejy.166.1601886480403; Mon, 05 Oct 2020 01:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601886480; cv=none; d=google.com; s=arc-20160816; b=1G9klWNTgYOlAmAFw07B+kqp4JGzkHcrLc3ovVSZG6iGfRDVvaG6RdGhBfJ2XFTEuZ tMPQvN2fsJQrJggBKDPBc4HwipM3jbK8qkCfH6llBV98uieAaIX8eT9o21ITwn3Z/I4k ZnoI1L2tJ3fTESBypOk3BkT91TtTevItz2kH1VMn3jQt8YKORKTreHyyQwMsTlevuQAJ NzxfmxTZG/RxzBspTXt1xDQUu2tNkf+fmC38RujTWz/uIPKhiLRSFcP+wnByoRsW2CRY VgISLeFzKlm+Bjq04uhmIxre0uQfOwVpwyrnl6TIlVo4lm9Zo8ONirSxoNqbk8q/V/u7 OV6w== 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=D4VIdFJU/xFLtOZ5cMzKak84ajF8Ic9wv+t8zOevTFU=; b=cs+Ct/ZRwAhKMKI6ueL0vMKO+/t+AY69bQg0Sr626p2CVu2kEqYaxwsufa+VSu+ytp 2e3Z9LoikVosvk02uh68se3bxMwxQWe3MIaWU31zLrhy+v7TkSL2yoQsvZIsh14XbFWr twcT/Gk4K+UROLeL0VbuGaTbPdy2sAqObxxJzR4ma44jt35MK4I7CBxteFijvCkaSnoJ 6knD9x1EZT+/bN3Xl8xqSR2Kt9WvEFw4jfY9GocXrxNmGYF1iVqs3cb4RqF6qAzSB2x3 nEvGVBUHREfxlriZZYXfhzrHsyXd8foelGlgo9TC+8esrSehtgkWegbEUJ7XWePCKbDa 6zJg== 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 c9si5819196edr.568.2020.10.05.01.27.38; Mon, 05 Oct 2020 01:28:00 -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 S1726058AbgJEI0c (ORCPT + 99 others); Mon, 5 Oct 2020 04:26:32 -0400 Received: from verein.lst.de ([213.95.11.211]:58080 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgJEI0c (ORCPT ); Mon, 5 Oct 2020 04:26:32 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 5D8DD67373; Mon, 5 Oct 2020 10:26:29 +0200 (CEST) Date: Mon, 5 Oct 2020 10:26:29 +0200 From: Christoph Hellwig To: Tomasz Figa Cc: Christoph Hellwig , Mauro Carvalho Chehab , Marek Szyprowski , iommu@lists.linux-foundation.org, Robin Murphy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH 8/8] WIP: add a dma_alloc_contiguous API Message-ID: <20201005082629.GA13850@lst.de> References: <20200930160917.1234225-1-hch@lst.de> <20200930160917.1234225-9-hch@lst.de> <20201002175040.GA1131147@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201002175040.GA1131147@chromium.org> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.