Received: by 10.192.165.148 with SMTP id m20csp848528imm; Wed, 25 Apr 2018 08:35:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+jfFWtl7UKfa38Ir6D22YB4Ubfxp2bZWpesl0sS5h6OuY+UI1iRft5qd3w+k16qrnCL6Jk X-Received: by 10.98.58.28 with SMTP id h28mr21678456pfa.209.1524670511061; Wed, 25 Apr 2018 08:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524670511; cv=none; d=google.com; s=arc-20160816; b=GS0hIESYHR2SIknl2EyqZr6TcEX2nVwGqqf6qouHrdXR7NdjXJ9TYafHqw1ITNZYU6 XjNrwmJWJAo+A203Ld5hWnAGWH5Ris+hiv6mDSWIrTvod9lUTiaurkQtw6aJaHcgdvVh DrM5K+o0ubmUpvRAep+sl1Q58I/r6VhRP1l0nNa9NesCrPrDlD03HrCaye9xkkHHUFbv fbP6m4/hFlG010P/ntaMEyeQuTegTDRT6i467gBL4fPMHmrTG8RAeYG2anW2jMammmo7 gSxL/vCbvyWzIl5Nb9I9LwwbQVa+ntZFFwzvHYIkHXkYm0DqTQ/jNNeR4IaUInUw5+mH mcRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature:arc-authentication-results; bh=yXXuKVLGfnYdLTP1TV+fdjnLuDIS/PjwlrE2D9ATuTs=; b=vVQnP2pSKoLzlr7NVdHvvEw32EOZ4H1xmsoNhfu7TtkgZeiWurok+kGBmnIw2rx2s5 +PhRTUTpk0EOOgq5KFAc71ZBopupF39Mp2rCecbXEu7knrmtFew8Qu6f/IOHN1KgD+x3 6N5lV/trE4CcvewAJzCttxHTV3btP4j77D1ROdLngNmb72/4ijlAN3sSr59G2HrPbJne y3sTlvthb91FNEiosHVaqTKLsWANdi4E011F2kmZDymgomW9TP//Ekg90ACFR9+HLqZU i/9EFMKAFBNjM5K2kMZ1MMNVsdStBw//yU2D2e+axOk5gqqr0mmlJTb1eYflTmaQVFua Sdyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dPv5B6c1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z24si13794236pgn.55.2018.04.25.08.34.55; Wed, 25 Apr 2018 08:35:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dPv5B6c1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755110AbeDYPdV (ORCPT + 99 others); Wed, 25 Apr 2018 11:33:21 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60696 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755071AbeDYPdP (ORCPT ); Wed, 25 Apr 2018 11:33:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yXXuKVLGfnYdLTP1TV+fdjnLuDIS/PjwlrE2D9ATuTs=; b=dPv5B6c1naM8jwW+O/828aoKD UDMc41Vvp8wFQmDcgijVSvkajyjmochpYmKVOEiItTU1fWxvU+OKwAj41/0TZefk4nrYi2aXsi8kJ kPk/OkW+3y0YjdrdCMVqSqB2eAMgVT7PdnXRO/PjwqkE4MbUa31/3BZAahfvjwgbP9zZobKsz8moo EtHgE2cUHzFxmK+oBsCS5kHq9FSkxrQP1fVnsY91X+7vMxXWlQO8cgVj0dc1jzlYzhZ/KtoUFXu36 t9o7QaHqKhzelXJc//bZHAB/haAPN5cuzBbe7whlm2cA9gDCfQjP3pDzHETCF8mA9OJOSA7OzA7po fXiZjEuiQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBMPw-00041o-KB; Wed, 25 Apr 2018 15:33:12 +0000 Date: Wed, 25 Apr 2018 08:33:12 -0700 From: Christoph Hellwig To: Christoph Hellwig , Thierry Reding , Christian =?iso-8859-1?Q?K=F6nig?= , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Linux Kernel Mailing List , amd-gfx list , Jerome Glisse , dri-devel , Dan Williams , Logan Gunthorpe , "open list:DMA BUFFER SHARING FRAMEWORK" , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org Subject: Re: noveau vs arm dma ops Message-ID: <20180425153312.GD27076@infradead.org> References: <20180420152111.GR31310@phenom.ffwll.local> <20180424184847.GA3247@infradead.org> <20180425054855.GA17038@infradead.org> <20180425064335.GB28100@infradead.org> <20180425074151.GA2271@ulmo> <20180425085439.GA29996@infradead.org> <20180425100429.GR25142@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180425100429.GR25142@phenom.ffwll.local> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 25, 2018 at 12:04:29PM +0200, Daniel Vetter wrote: > > Coordinating the backport of a trivial helper in the arm tree is not > > the end of the world. Really, this cowboy attitude is a good reason > > why graphics folks have such a bad rep. You keep poking into random > > kernel internals, don't talk to anoyone and then complain if people > > are upset. This shouldn't be surprising. > > Not really agreeing on the cowboy thing. The fundamental problem is that > the dma api provides abstraction that seriously gets in the way of writing > a gpu driver. Some examples: So talk to other people. Maybe people share your frustation. Or maybe other people have a way to help. > - We never want bounce buffers, ever. dma_map_sg gives us that, so there's > hacks to fall back to a cache of pages allocated using > dma_alloc_coherent if you build a kernel with bounce buffers. get_required_mask() is supposed to tell you if you are safe. However we are missing lots of implementations of it for iommus so you might get some false negatives, improvements welcome. It's been on my list of things to fix in the DMA API, but it is nowhere near the top. > - dma api hides the cache flushing requirements from us. GPUs love > non-snooped access, and worse give userspace control over that. We want > a strict separation between mapping stuff and flushing stuff. With the > IOMMU api we mostly have the former, but for the later arch maintainers > regularly tells they won't allow that. So we have drm_clflush.c. The problem is that a cache flushing API entirely separate is hard. That being said if you look at my generic dma-noncoherent API series it tries to move that way. So far it is in early stages and apparently rather buggy unfortunately. > - dma api hides how/where memory is allocated. Kinda similar problem, > except now for CMA or address limits. So either we roll our own > allocators and then dma_map_sg (and pray it doesn't bounce buffer), or > we use dma_alloc_coherent and then grab the sgt to get at the CMA > allocations because that's the only way. Which sucks, because we can't > directly tell CMA how to back off if there's some way to make CMA memory > available through other means (gpus love to hog all of memory, so we > have shrinkers and everything). If you really care about doing explicitly cache flushing anyway (see above) allocating your own memory and mapping it where needed is by far the superior solution. On cache coherent architectures dma_alloc_coherent is nothing but allocate memory + dma_map_single. On non coherent allocations the memory might come through a special pool or must be used through a special virtual address mapping that is set up either statically or dynamically. For that case splitting allocation and mapping is a good idea in many ways, and I plan to move towards that once the number of dma mapping implementations is down to a reasonable number so that it can actually be done.