From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v6 2/5] dma-buf: heaps: Add heap helpers Date: Tue, 23 Jul 2019 23:55:30 -0700 Message-ID: <20190724065530.GA16225@infradead.org> References: <20190624194908.121273-1-john.stultz@linaro.org> <20190624194908.121273-3-john.stultz@linaro.org> <20190718100654.GA19666@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Rob Clark Cc: John Stultz , Christoph Hellwig , lkml , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , Vincent Donnefort , Sudipto Paul , "Andrew F . Davis" , Xu YiPing , "Chenfeng (puck)" , butao , "Xiaqing (A)" , Yudongbin , Chenbo Feng , Alistair Strachan , dri-devel List-Id: dri-devel@lists.freedesktop.org On Tue, Jul 23, 2019 at 01:09:55PM -0700, Rob Clark wrote: > On Mon, Jul 22, 2019 at 9:09 PM John Stultz wrote: > > > > On Thu, Jul 18, 2019 at 3:06 AM Christoph Hellwig wrote: > > > > > > Is there any exlusion between mmap / vmap and the device accessing > > > the data? Without that you are going to run into a lot of coherency > > > problems. > > dma_fence is basically the way to handle exclusion between different > device access (since device access tends to be asynchronous). For > device<->device access, each driver is expected to take care of any > cache(s) that the device might have. (Ie. device writing to buffer > should flush it's caches if needed before signalling fence to let > reading device know that it is safe to read, etc.) > > _begin/end_cpu_access() is intended to be the exclusion for CPU access > (which is synchronous) What I mean is that we need a clear state machine (preferably including ownership tracking ala dma-debug) where a piece of memory has one owner at a time that can access it. Only the owner can access is at that time, and at any owner switch we need to flush/invalidate all relevant caches. And with memory that is vmaped and mapped to userspace that can get really complicated. The above sounds like you have some of that in place, but we'll really need clear rules to make sure we don't have holes in the scheme.