Received: by 10.192.165.148 with SMTP id m20csp1791063imm; Thu, 26 Apr 2018 02:15:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnC/AlBkUC3qVOgZc/KwTE0E6PiWHg+8CZ7dcRr44GWuzp3EuVjsjLzvENkpdhZcPf4taB X-Received: by 2002:a17:902:b7ca:: with SMTP id v10-v6mr4797621plz.275.1524734114197; Thu, 26 Apr 2018 02:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524734114; cv=none; d=google.com; s=arc-20160816; b=cRJYXM859OMrKr+YDe34Vc9Q8vt1uEMcqznFbpcCi41K4k15cMhzIBPGsbFpIL6Bp6 lQJnZPHj8GV9lyBuQeylxQRstGx1iHURCevQJaORhzqFhqfFK5ZKpKtKbJbhy/xAdt71 WqD9gKQmRbU+EuMnCJAoAq1BOQQhB4LRdbai1GCislTFxsU49HlP5n0kcJzE6CaPYDqX G6W6ZBdQDHtwp/2MDwaogD/tkKfGswflks0UOwdQMpDPasxCx+9HxM+ediCwR0mDLCSw h+ZeXQVG3P9ZhBMTLOQtd9ZtbaERz+k9UF3/rnViEXur14CC+aahA3Wdd8tci12iC5/0 uAqQ== 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:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ENuzGzUlnpGsRG+05tedOf7O9SPt6lEnPViKbEosH78=; b=meRQzZ+z/cMkvKdxq9bH0O02hyTwZtoWTpzxb/cDwvqzg8m2+1feTLCftoF2c7LJHG xMf9/wW70vCbJkYkGpf6Oh9oSlNnfmOFl90xLitlXq65BVG8I7p3tBrAVDERSwU3Kxsn fG8ouuW0A3nFnN29h2CyNwDl/38M6FuFJEVuXcNdkUudNi2U5G5cESDYALf8sVZYoZsK C/eFveFb5OyWoa6H1+KaYDyjX4YM87zwmI/3LfCv/Ye9+d2Sw61n2FROUt25R2huExij wiXOoupdT/HM9wVQNdbE8fI+1sXCSVmyQo2UQHSp5mcuf1+edVd3lCnLaf60cejnJqBP P6qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PcYZfhi3; 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 z1-v6si18151634plo.263.2018.04.26.02.14.59; Thu, 26 Apr 2018 02:15:14 -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=PcYZfhi3; 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 S1754696AbeDZJNT (ORCPT + 99 others); Thu, 26 Apr 2018 05:13:19 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47548 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754781AbeDZJNO (ORCPT ); Thu, 26 Apr 2018 05:13:14 -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:Cc:To:From:Date:Sender:Reply-To: 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=ENuzGzUlnpGsRG+05tedOf7O9SPt6lEnPViKbEosH78=; b=PcYZfhi3hLkWdilcCWaQszrkX gdvc8ypDDSpr/zkYDifaCWNLEXNiIcor7ShPJu5Zox68UJ5mTaG/E+/47qy+SKb9ET1yHPqxnM+ZT 8e7Se738HMp3mCwe25N1Jnsw6+M50T7W7YnPBPwxHBE9E4QUvcUlOAH0DgdH0PWzK5EEcIAQ1G5Du 334cOPTavG3xKqT4Eh9t+pUPHwh3S6JtM0+0nmPBZM3JjqfgZuDVvVvVbVmPBAfc1qb2mUBkEqCKB 578XG7BIWL2ukf3vtUp60JysibkrfEm7u2ScPrSxipxBJ1pNXznsyhHMIj1U1H7OonkI/oDv895SH SpZIocAVw==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBcxi-0001go-V2; Thu, 26 Apr 2018 09:13:10 +0000 Date: Thu, 26 Apr 2018 02:13:10 -0700 From: Christoph Hellwig To: Russell King - ARM Linux Cc: 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: <20180426091310.GB18811@infradead.org> References: <20180425054855.GA17038@infradead.org> <20180425064335.GB28100@infradead.org> <20180425074151.GA2271@ulmo> <20180425085439.GA29996@infradead.org> <20180425100429.GR25142@phenom.ffwll.local> <20180425153312.GD27076@infradead.org> <20180425225443.GQ16141@n2100.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180425225443.GQ16141@n2100.armlinux.org.uk> 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 11:54:43PM +0100, Russell King - ARM Linux wrote: > > if the memory was previously dirty (iow, CPU has written), you need to > flush the dirty cache lines _before_ the GPU writes happen, but you > don't know whether the CPU has speculatively prefetched, so you need > to flush any prefetched cache lines before reading from the cacheable > memory _after_ the GPU has finished writing. > > Also note that "flush" there can be "clean the cache", "clean and > invalidate the cache" or "invalidate the cache" as appropriate - some > CPUs are able to perform those three operations, and the appropriate > one depends on not only where in the above sequence it's being used, > but also on what the operations are. Agreed on all these counts. > If we can agree a set of interfaces that allows _proper_ use of these > facilities, one which can be used appropriately, then there shouldn't > be a problem. The DMA API does that via it's ideas about who owns a > particular buffer (because of the above problem) and that's something > which would need to be carried over to such a cache flushing API (it > should be pretty obvious that having a GPU read or write memory while > the cache for that memory is being cleaned will lead to unexpected > results.) I've been trying to come up with such an interface, for now only for internal use in a generic set of noncoherent ops. The API is basically a variant of the existing dma_sync_single_to_device/cpu calls: http://git.infradead.org/users/hch/misc.git/commitdiff/044dae5f94509288f4655de2f22cb0bea85778af Review welcome! > The next issue, which I've brought up before, is that exposing cache > flushing to userspace on architectures where it isn't already exposed > comes. As has been shown by Google Project Zero, this risks exposing > those architectures to Spectre and Meltdown exploits where they weren't > at such a risk before. (I've pretty much shown here that you _do_ > need to control which cache lines get flushed to make these exploits > work, and flushing the cache by reading lots of data in liu of having > the ability to explicitly flush bits of cache makes it very difficult > to impossible for them to work.) Extending dma coherence to userspace is going to be the next major nightmare indeed. I'm not sure how much of that actually still is going on in the graphics world, but we'll need a coherent (pun intended) plan how to deal with it.