Received: by 10.192.165.148 with SMTP id m20csp321897imm; Tue, 24 Apr 2018 23:24:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx493JVTp940OX53Vxtu0MqCsz0E/wp6z74W43ZwoSsE/LmmfcznGJN3y/lUy/3+7fHNbhm/T X-Received: by 10.101.82.70 with SMTP id q6mr14116637pgp.45.1524637476587; Tue, 24 Apr 2018 23:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524637476; cv=none; d=google.com; s=arc-20160816; b=C/gLMJ7fe02czCV27arsPhAZkw7yu8hz9Ltz3d8DvBlcDcDfG5b2Gmp5PyuVu/XgAa AI3UrrGYTM2zkk2OVG/u2PN0+fr//tZlDy/eJIFmcJOKlw7kJOGIQwwB+YQq68IH0HMK 2H4V5RqphVUcN1EaVk8ju0twChQIzBBTcgLsFbfAULI0piD8iRZgkC5uHEU2tDbtK+US sMQECCil76HlFYqEpFVh0/ybzk77uplOPQOI++FOaeBmdbHP2uMy8wU44V5jXzETWF+N bz9BewmOcMbTCbsC0tP2/YtgOCHzwlVCym9pnGbAKFI7BQniXrdlIEBaCHcKxCnSPVKM VZjw== 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=5dWSQg5ZUaB/xy/l2Ez992zQSk4rLONE4DBcAfS8TX4=; b=sJK842rQrQEI06TLuBbWr3zEdpu4uTNXkXZq+lg143dYffc6ifMriwZZNwZwG9Iwok 8/7gh7AMBDcKjlOTm5p35mlzkjzC3W/h6sMuwJuEHujJeVOR/CTALLHs/QTKy8A2HDOJ GMY31UzEK0QLarMVs0m1Q29cNB6PN+ZSsXTMQTxwx5WjddG7ASgDVMLqCUm+fEEaNCel klPrWaNBiib5gnlr7gXpfOlNEd4u/rwUWYoBGF91KxDBB26pf8XatoVOqz5EV5ZoulFH aO6eXrzJVzTQX6wiYPSz5+Kx1jWKsHiMFCvLyvHIUi4+Pjn8QCSsso7V7+9KNYRgQJLd LnzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=O0sndNa7; 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 q1-v6si15511153plb.549.2018.04.24.23.24.21; Tue, 24 Apr 2018 23:24:36 -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=@ffwll.ch header.s=google header.b=O0sndNa7; 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 S1751281AbeDYGXS (ORCPT + 99 others); Wed, 25 Apr 2018 02:23:18 -0400 Received: from mail-it0-f48.google.com ([209.85.214.48]:34841 "EHLO mail-it0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbeDYGXQ (ORCPT ); Wed, 25 Apr 2018 02:23:16 -0400 Received: by mail-it0-f48.google.com with SMTP id 186-v6so18074941itu.0 for ; Tue, 24 Apr 2018 23:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=5dWSQg5ZUaB/xy/l2Ez992zQSk4rLONE4DBcAfS8TX4=; b=O0sndNa7qkl08sAkuDC8LNwL/eZSAU1ZOweKhpK4v6cslvDxCiNkjXOScuzIFQrEKi e0cLRyweAX4IWvLEaiM5N3GlIHYaPvmaENAM3nItPqft7RGmHQRltXHgvPI9VuBVE3rG tQAepR4b+VbNs+jjvr2xuggVYmppiPE2KgEPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=5dWSQg5ZUaB/xy/l2Ez992zQSk4rLONE4DBcAfS8TX4=; b=chmjNfZyRi65/6clCeoly7dgvIj8vK4ebdcZWcA4ImpRs1fwNXHVe7Qs2uEXkN42Wg 0iOOJDKvBMtN7aLND5UW5tTZ+PcEOWPE/ui+qyoZPRSBf+U4NHj9k5BMV8PM4wois0N/ bkPq3cXrY/uzXvSlNxIRd1PUqXi9lfOYk1sZa0+EkuiPK7eTyef9xnMU0H7byy4uLZwT M+60HiR3nZ/GmWHARaVpBYJTSbA/sc8RA4SGTLq77tJQ7yBh+0rOEkt4AzNoB1U39Rqx KXuVxKh9Ukm99urxifeHfuYcuRlgk3xceZ8t4dYDlKWQ+CG67GaFxm0MbZSyxfXru2md Wrxg== X-Gm-Message-State: ALQs6tBONoXvPWV1DF2o/X2VBI8yfbczehchgZJpv6B447HsqPFI2uYo ZWIXAXHiwP7GDtLC6NSuMinRZTsGLl44gne5OB27WQ== X-Received: by 2002:a24:468a:: with SMTP id j132-v6mr20611077itb.23.1524637395630; Tue, 24 Apr 2018 23:23:15 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:5b42:0:0:0:0:0 with HTTP; Tue, 24 Apr 2018 23:23:15 -0700 (PDT) X-Originating-IP: [2a02:168:5635:0:39d2:f87e:2033:9f6] 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: Daniel Vetter Date: Wed, 25 Apr 2018 08:23:15 +0200 X-Google-Sender-Auth: tm5mnx6783NFxPx6KwcQTzE4nCU Message-ID: Subject: Re: [Linaro-mm-sig] [PATCH 4/8] dma-buf: add peer2peer flag To: Christoph Hellwig Cc: =?UTF-8?Q?Christian_K=C3=B6nig?= , "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" 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 8: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. For more fun: https://www.spinics.net/lists/dri-devel/msg173630.html Yeah, sometimes we want to disable the iommu because the on-gpu pagetables are faster ... -Daniel >>> 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. > > 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 --=20 Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch