Received: by 10.192.165.148 with SMTP id m20csp322996imm; Tue, 24 Apr 2018 23:26:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Z3Q7o3T9ED7UfvNbqwejrQfIRFrQDSajsFLxqUNYZs9yzdwoJEY/xG3xkqozyVPCcuTqU X-Received: by 10.98.46.5 with SMTP id u5mr26567313pfu.247.1524637568708; Tue, 24 Apr 2018 23:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524637568; cv=none; d=google.com; s=arc-20160816; b=KI6VOTdAfi1Q3ZGxQXtXbKevH1uB9rvGnxMrfI4SMB8LXjoLMtJT572qhvNu8fIrwv i3ArzG07a2Isy1+EMTHQt6ceO6sC6dj977uW3Fm72qr3g/rkJj7uJgy3UQj4wV/N4vEl T4pqIE3BXo5I6txkbql849oY6IrvMNUT90KihRnQJM7C4u8Gpsw2o915ejCAQj2GivnI xBh3RJy6OwSMrBbkMkrNMP73ah4WI45kOPLMZjWZ5pbATrZAlPKpckR24UDnZG9ufVfk V6pV7+FVgpLzAgCB+4hxfkUZV3AVMEt1/ePUOzh8oEB9Z+2BIg+DAkJEPgbzFlllPwD2 Wxrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=e/oez1q4FPDpFJFhlTI79XQqNUeNcQFuNP3i6NW3wIU=; b=cHkp9Le82na3dVVr2t3mrZpBIkdH6ZRtLRIyTsmRdFic7ZTxTJObByq2ZDUAY9Zbrf ylaU+BOMjpEhy7bfXTR2r0cFiwLimaDjZJeZl4etn3uqxtIxDO1zV7wCdr7CyHmKpJps 0z9tIpDde0CXzOwPckFXAgio5PBbQQCD0PY6TJJuKog9VkrqPT5OVYB2jDh63FUS798Z qofbAU2x0LI0BeUeU7awIhhHXHrwmsdyEMSCI7Bb6VS28bh1tTsAv3CTItXim/8AI9oq BuDXdU8hWpGfHgNIH3QFyvrSSuGCtI8o8Yn+eoVUY7ZNlIonb0Nrtm4bTIndXkFwLsCf kDHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EhM+xIE7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si13124287plr.6.2018.04.24.23.25.54; Tue, 24 Apr 2018 23:26:08 -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=pass header.i=@gmail.com header.s=20161025 header.b=EhM+xIE7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbeDYGYm (ORCPT + 99 others); Wed, 25 Apr 2018 02:24:42 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:40366 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbeDYGYi (ORCPT ); Wed, 25 Apr 2018 02:24:38 -0400 Received: by mail-wm0-f49.google.com with SMTP id j5so4657519wme.5; Tue, 24 Apr 2018 23:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=e/oez1q4FPDpFJFhlTI79XQqNUeNcQFuNP3i6NW3wIU=; b=EhM+xIE7mJBZ90Lp2jvK1oNnTc3ZnP3rXFsdCijcQjzQMdA5WunynMSX0oDoIV8XPi sEAyVwyoiambnoF/K8nGQ9VDcvkVzCiMMsMQGfZYWoHveyOcM1pGzYj/dvHnKp3veKmP MouZD7ArNnOaCUCkMUpXQptaZh05lblbNnfgV24BVZXnvmqouinyuzKWSx4NK81sI/8I N7noC/6mPMcg1iZggINn9ezXtu34Rp08Gtqj+NlbIq1P0InmF8s1QzOhfjaFqrSWJaBU Sl8lVRbJ5trW4g/gB1d96wAm5po/HhkDrV17gi58e0usYb8P+XW2yn3fdZRpQFtRZVvH OPWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=e/oez1q4FPDpFJFhlTI79XQqNUeNcQFuNP3i6NW3wIU=; b=ErNROR/PwH8Tv+9XguZfmjrrEIfFkpsy6aJIWLANTpWVQLVDBir7QmnT6fnJVhBEl/ skS1SWaYNV0uJxkx2ezvINDEQlbMvVhY21x63M2kQx4hcgGBroAasOQoLCiReAYYFTPs 73lN5TUT+T7UbiunyaICgZ631gQQWQF3E3pv3SpekwIodAMwCOwiPUHa6wokn6osian4 ligViVmfIZEFHICmnTAty8ldHU6NAPT8gBlGuXQOiD+gTUTQSmLi18ojB6Ss/k0BwzKc 3sxFB8gnnPJD7MwT9QczvTCyvQvctJPmO400x+827BAnayQKL7MG+Y/WCYv6WjG+CVLp +6GA== X-Gm-Message-State: ALQs6tARkbiiFRzceMPmzYit6S8fEHdjnF1KpVPu0cMHehxF5ziBtWXK VjF9iN/YVxfsbXogQ8vVEa4EBW9J9KdnRj6Rpl8= X-Received: by 10.28.18.206 with SMTP id 197mr13121665wms.22.1524637477441; Tue, 24 Apr 2018 23:24:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.175.76 with HTTP; Tue, 24 Apr 2018 23:24:36 -0700 (PDT) In-Reply-To: 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> <20180425054855.GA17038@infradead.org> From: Alex Deucher Date: Wed, 25 Apr 2018 02:24:36 -0400 Message-ID: Subject: Re: [Linaro-mm-sig] [PATCH 4/8] dma-buf: add peer2peer flag To: Daniel Vetter Cc: Christoph Hellwig , Linux Kernel Mailing List , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Jerome Glisse , amd-gfx list , Dan Williams , Logan Gunthorpe , =?UTF-8?Q?Christian_K=C3=B6nig?= , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 2:13 AM, Daniel Vetter wrote: > On Wed, Apr 25, 2018 at 7:48 AM, Christoph Hellwig wr= ote: >> 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 =D1=95eems to do both virtually and physically based ops, furthe= r >> 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. > > I think by number most drm drivers require contiguous memory (or an > iommu that makes it look contiguous). But there's plenty others who > have another set of pagetables on the gpu itself and can > scatter-gather. Usually it's the former for display/video blocks, and > the latter for rendering. > >>> 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? > > It has a non-coherent transaction mode (which the chipset can opt to > not implement and still flush), to make sure the AGP horror show > doesn't happen again and GPU folks are happy with PCIe. That's at > least my understanding from digging around in amd the last time we had > coherency issues between intel and amd gpus. GPUs have some bits > somewhere (in the pagetables, or in the buffer object description > table created by userspace) to control that stuff. Right. We have a bit in the GPU page table entries that determines whether we snoop the CPU's cache or not. Alex > > For anything on the SoC it's presented as pci device, but that's > extremely fake, and we can definitely do non-snooped transactions on > drm/i915. Again, controlled by a mix of pagetables and > userspace-provided buffer object description tables. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx