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=-2.2 required=3.0 tests=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 42F7BC76192 for ; Tue, 16 Jul 2019 12:10:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2756620651 for ; Tue, 16 Jul 2019 12:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732081AbfGPMK3 (ORCPT ); Tue, 16 Jul 2019 08:10:29 -0400 Received: from verein.lst.de ([213.95.11.211]:41209 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbfGPMK3 (ORCPT ); Tue, 16 Jul 2019 08:10:29 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 9A83F227A81; Tue, 16 Jul 2019 14:10:26 +0200 (CEST) Date: Tue, 16 Jul 2019 14:10:26 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Pankaj Suryawanshi , linux-kernel@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Vlastimil Babka , Michal Hocko , pankaj.suryawanshi@einfochips.com, minchan@kernel.org, minchan.kim@gmail.com, Christoph Hellwig Subject: Re: cma_remap when using dma_alloc_attr :- DMA_ATTR_NO_KERNEL_MAPPING Message-ID: <20190716121026.GB2388@lst.de> References: <57f8aa35-d460-9933-a547-fbf578ea42d3@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57f8aa35-d460-9933-a547-fbf578ea42d3@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 16, 2019 at 01:02:19PM +0100, Robin Murphy wrote: >> Lets say 4k video allocation required 300MB cma memory but not required >> virtual mapping for all the 300MB, its require only 20MB virtually mapped >> at some specific use case/point of video, and unmap virtual mapping after >> uses, at that time this functions will be useful, it works like ioremap() >> for cma_alloc() using dma apis. > > Hmm, is there any significant reason that this case couldn't be handled > with just get_vm_area() plus dma_mmap_attrs(). I know it's only *intended* > for userspace mappings, but since the basic machinery is there... Because the dma helper really are a black box abstraction. That being said DMA_ATTR_NO_KERNEL_MAPPING and DMA_ATTR_NON_CONSISTENT have been a constant pain in the b**t. I've been toying with replacing them with a dma_alloc_pages or similar abstraction that just returns a struct page that is guaranteed to be dma addressable by the passed in device. Then the driver can call dma_map_page / dma_unmap_page / dma_sync_* on it at well. This would replace DMA_ATTR_NON_CONSISTENT with a sensible API, and also DMA_ATTR_NO_KERNEL_MAPPING when called with PageHighmem, while providing an easy to understand API and something that can easily be fed into the various page based APIs in the kernel. That being said until we get arm moved over the common dma direct and dma-iommu code, and x86 fully moved over to dma-iommu it just seems way too much work to even get it into the various architectures that matter, never mind all the fringe IOMMUs. So for now I've just been trying to contain the DMA_ATTR_NON_CONSISTENT and DMA_ATTR_NO_KERNEL_MAPPING in fewer places while also killing bogus or pointless users of these APIs.