From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbbKIKIJ (ORCPT ); Mon, 9 Nov 2015 05:08:09 -0500 Received: from foss.arm.com ([217.140.101.70]:49765 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753112AbbKIKIG (ORCPT ); Mon, 9 Nov 2015 05:08:06 -0500 Date: Mon, 9 Nov 2015 10:08:05 +0000 From: Will Deacon To: sanjeev sharma Cc: "Sharma, Sanjeev" , Russell King - ARM Linux , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "m.szyprowski@samsung.com" Subject: Re: [PATCH] ARM:dma-mapping: Handle DMA_BIDIRECTIONAL in _dma_page_cpu_to_dev() Message-ID: <20151109100804.GA24936@arm.com> References: <1446631008-5854-1-git-send-email-sanjeev_sharma@mentor.com> <20151104103913.GC5405@arm.com> <20151104105420.GL8644@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 09, 2015 at 11:29:17AM +0530, sanjeev sharma wrote: > On Wed, Nov 04, 2015 at 10:39:13AM +0000, Will Deacon wrote: > > On Wed, Nov 04, 2015 at 03:26:48PM +0530, Sanjeev Sharma wrote: > > > _dma_page_cpu_to_dev() treat DMA_BIDIRECTIONAL similar to > > > DMA_TO_DEVICE which means that destination buffer is device > > > memory,means cpu may have written some data to source buffer and > > > data may be in cache line.For cleaner operation we need to call > > > outer_flush_range() which will clean and invalidate outer cache lines. > > > > Why isn't the clean sufficient in this case? We're mapping the buffer > > to the device, so we clean the dirty lines in the CPU caches and make > > them visible to the device. If the CPU later wants to read the buffer > > (i.e. after the device has DMA'd into it), you'll need to map the > > buffer to the CPU, which will perform the invalidation of the CPU caches. > > Indeed. bidirectional mode is already handled prefectly well by this > code. No patches are required. > > Thanks Russell & Will for providing input. > > Let's assume , CPU don't read the buffer then there could be the problem > correct ? IMO, to handle every use case outer_flush_range can be used ? > If still it doesn't make sense to use flush on bidirectional mappings, then > FIXME comment should be removed from the function to avoid any > Confusion. > > > > Please let me know what you think on above comment ? I still don't understand the problem that you're trying to fix. Sorry, Will