Received: by 10.192.165.148 with SMTP id m20csp296480imm; Tue, 24 Apr 2018 22:50:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/pVDXmrzTk8BNJtIpPYmJDSCA/Ee8Nsba7PCF6c6uJlS24hQJBeEnjteqvHNXZQpGFHAj X-Received: by 2002:a17:902:284b:: with SMTP id e69-v6mr27284786plb.240.1524635455072; Tue, 24 Apr 2018 22:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524635455; cv=none; d=google.com; s=arc-20160816; b=k5nig/TRI6a8aBvUe4nhG9b+ORS9p/SghlALYHn6JPufVfzrjuywJYb/4mwaf6Q26k kd9ydHk8uoDtru6LFYx5+nz6Hw6T55PBDpy3GGzLari5uxZEbfdGVVudoa8FwLAXgteY qCyAdEGkjd11kkgXh2Zk8NXJa3BoTrAs9+s0Z+X+OZ6BmXUwLSfbFuZIXnH1rLGCh+pB JmjRwQjuwUmhFI7ZpJl3cnH4XEsOD6AnbBVTQocTPbRftfic9FvhsIigLmKSPhUdQIX4 MEfenSxwLwyVBgJwm+0nPrjE/RtlAiZjXkxOdzfazV2urF7Zsfb6fOh4j65Du3BY6muL 46LQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=fdE00mParKLn5+6rIew3CnF0Md8CRjOSdrUR0PUD45Y=; b=W0oodsJ0Ya7JO9Q8FgXcrOY2aDrIv+Y2buoglR2u4o2LyjI0Z/17Zyi/WpE/qogxOk 7iV20JfVP4XO3jmlOikZqGoQ2CV9aG6wmcultxxO6iPoOg/rHD4tluj86AbLf4P3vMXR 3mUcNH0425Cg0j4DBGZIl60H4ZH9pcfvttOQ1uzB2AIE6yyyPIf8UvQjhdbAKBZ3Gp6q 9AZg1D28aqqPrDhCZ6Wp37VqcNflc2IzEfuDxpi2Zh50IQhGoWK4WYf6UdZqScQeGe4F pIarY3BtgFys15RhEACFs/2G+3yXKukqCUdHaVSDBrQirmWjmpbhIJn55IfitiwZR9+U SCtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=isToohgV; 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 j67si2682776pgc.509.2018.04.24.22.50.40; Tue, 24 Apr 2018 22:50:55 -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=isToohgV; 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 S1751554AbeDYFtD (ORCPT + 99 others); Wed, 25 Apr 2018 01:49:03 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35094 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbeDYFtA (ORCPT ); Wed, 25 Apr 2018 01:49:00 -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-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=fdE00mParKLn5+6rIew3CnF0Md8CRjOSdrUR0PUD45Y=; b=isToohgV/2pJkfuJEQC+UjXMfQ g34xwH2YvbyaH2F5Fg46TD7QaAot+Ve75sDfO9q3WQeWGlEPT1Szi6SVbVt9mjAzdc5SmU+yKLnxx fGoYte3IxoRT1l1NG4fjB4bi3tFNPfKp24/wGYJ/3JLqNN/ZuwRLzOy3LLi7+I68/XCxswJOZEgQ/ 4EEBRybEYsdElCCmt4ZgcEEuA1c8EAvyyrk5Cc044F3O+RAn7QspXO+AfCFHKCor+tZ8B1i0iI9Xe PtiAv4Cnf3l13aeRf755ONKgVU6CY+SwynRbURD+cta1E9N4lVl3nyZ8GsOEopn8Z36cc2VRdzNfF kE8sgH9w==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBDIV-0007iL-RT; Wed, 25 Apr 2018 05:48:55 +0000 Date: Tue, 24 Apr 2018 22:48:55 -0700 From: Christoph Hellwig To: Daniel Vetter Cc: Christoph Hellwig , 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" Subject: Re: [Linaro-mm-sig] [PATCH 4/8] dma-buf: add peer2peer flag Message-ID: <20180425054855.GA17038@infradead.org> References: <20180419081657.GA16735@infradead.org> <20180420071312.GF31310@phenom.ffwll.local> <3e17afc5-7d6c-5795-07bd-f23e34cf8d4b@gmail.com> <20180420101755.GA11400@infradead.org> <20180420124625.GA31078@infradead.org> <20180420152111.GR31310@phenom.ffwll.local> <20180424184847.GA3247@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Tue, Apr 24, 2018 at 09:32:20PM +0200, Daniel Vetter wrote: > Out of curiosity, how much virtual flushing stuff is there still out > there? At least in drm we've pretty much ignore this, and seem to be > getting away without a huge uproar (at least from driver developers > and users, core folks are less amused about that). As I've just been wading through the code, the following architectures have non-coherent dma that flushes by virtual address for at least some platforms: - arm [1], arm64, hexagon, nds32, nios2, parisc, sh, xtensa, mips, powerpc These have non-coherent dma ops that flush by physical address: - arc, arm [1], c6x, m68k, microblaze, openrisc, sparc And these do not have non-coherent dma ops at all: - alpha, h8300, riscv, unicore32, x86 [1] arm Ń•eems to do both virtually and physically based ops, further audit needed. Note that using virtual addresses in the cache flushing interface doesn't mean that the cache actually is virtually indexed, but it at least allows for the possibility. > > I think the most important thing about such a buffer object is that > > it can distinguish the underlying mapping types. While > > dma_alloc_coherent, dma_alloc_attrs with DMA_ATTR_NON_CONSISTENT, > > dma_map_page/dma_map_single/dma_map_sg and dma_map_resource all give > > back a dma_addr_t they are in now way interchangable. And trying to > > stuff them all into a structure like struct scatterlist that has > > no indication what kind of mapping you are dealing with is just > > asking for trouble. > > Well the idea was to have 1 interface to allow all drivers to share > buffers with anything else, no matter how exactly they're allocated. Isn't that interface supposed to be dmabuf? Currently dma_map leaks a scatterlist through the sg_table in dma_buf_map_attachment / ->map_dma_buf, but looking at a few of the callers it seems like they really do not even want a scatterlist to start with, but check that is contains a physically contiguous range first. So kicking the scatterlist our there will probably improve the interface in general. > dma-buf has all the functions for flushing, so you can have coherent > mappings, non-coherent mappings and pretty much anything else. Or well > could, because in practice people hack up layering violations until it > works for the 2-3 drivers they care about. On top of that there's the > small issue that x86 insists that dma is coherent (and that's true for > most devices, including v4l drivers you might want to share stuff > with), and gpus really, really really do want to make almost > everything incoherent. How do discrete GPUs manage to be incoherent when attached over PCIe?