From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754174AbdCHUKW (ORCPT ); Wed, 8 Mar 2017 15:10:22 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:35730 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbdCHUKT (ORCPT ); Wed, 8 Mar 2017 15:10:19 -0500 Date: Wed, 8 Mar 2017 19:59:01 +0000 From: Russell King - ARM Linux To: Lars-Peter Clausen Cc: Masahiro Yamada , Robin Murphy , dmaengine@vger.kernel.org, linux-arm-kernel , Arnd Bergmann , Linux Kernel Mailing List , "James E.J. Bottomley" , Tejun Heo , "David S. Miller" Subject: Re: [Question] devm_kmalloc() for DMA ? Message-ID: <20170308195901.GD21222@n2100.armlinux.org.uk> References: 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 Wed, Mar 08, 2017 at 08:48:31PM +0100, Lars-Peter Clausen wrote: > When the DMA memory is mapped for reading from the device the associated > cachelines are invalidated without writeback. There is no guarantee that > the changes made to the devres_node have made it to main memory yet, or > is there? That is incorrect. Overlapping cache lines are always written back on transitions from CPU to device ownership of the buffer (eg, dma_map_*().) Updates that are made by the CPU on overlapping cache lines while the memory is mapped for DMA may end up doing one of two things: either overwriting the newly DMA'd data, or being lost altogether. In the case of devm_* list manipulations, these should only ever happen during device probe and tear down, and if DMA is active at those times, the driver is seriously buggy. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.