From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from az33egw02.freescale.net (az33egw02.freescale.net [192.88.158.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "az33egw02.freescale.net", Issuer "Thawte Premium Server CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id E7A02B7BE9 for ; Fri, 30 Oct 2009 10:30:43 +1100 (EST) Received: from az33smr02.freescale.net (az33smr02.freescale.net [10.64.34.200]) by az33egw02.freescale.net (8.14.3/az33egw02) with ESMTP id n9TNUdP2021117 for ; Thu, 29 Oct 2009 16:30:39 -0700 (MST) Received: from b07421-ec1.am.freescale.net (b07421-ec1.am.freescale.net [10.82.121.43]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id n9TNUdFf005788 for ; Thu, 29 Oct 2009 18:30:40 -0500 (CDT) Date: Thu, 29 Oct 2009 18:30:38 -0500 From: Scott Wood To: Joakim Tjernlund Subject: Re: Accessing flash directly from User Space [SOLVED] Message-ID: <20091029233038.GA21587@b07421-ec1.am.freescale.net> References: <4AE7545F.80805@billgatliff.com> <4AE75859.5050108@billgatliff.com> <20091028112430.GO22408@zod.rchland.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Cc: Bill Gatliff , "linuxppc-dev@lists.ozlabs.org" , Jonathan Haws List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Oct 29, 2009 at 10:00:28AM +0100, Joakim Tjernlund wrote: > > I have found the problem. It occurred to me in the shower (okay not really, > > but most good ideas happen there). > > > > What was happening is that I was in fact able to write to the correct > > registers. However, I would try and write to them in a batch. But the way > > mmap works (at least according to the man page) with MAP_SHARED is that the > > file may not be updated until msync() is called. Now, I thought that O_SYNC > > would take care of that when I open /dev/mem, but that was not the case. > > > > Anyway, to make a long story short, I inserted an msync() after each > > assignment to the flash. This resolved my problem and I can now program my flash. > > Ouch, this was news to me too. Calling msync() after every write kills performance. > We use mmap(/dev/mem) to access HW and havn't seen any issues yet. Is this > perhaps a new behaviour for mmap(/dev/mem) and is there a way > to avoid calling msync()? I suspect that the msync() was merely serving as a very heavyweight memory barrier. -Scott