From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Subject: Re: MMIO and gcc re-ordering issue Date: Wed, 28 May 2008 09:04:13 +1000 Message-ID: <18492.37741.798622.696166@cargo.ozlabs.ibm.com> References: <1211852026.3286.36.camel@pasglop> <20080526.184047.88207142.davem@davemloft.net> <1211854540.3286.42.camel@pasglop> <20080526.192812.184590464.davem@davemloft.net> <20080526204233.75b71bb8@infradead.org> <1211872130.3286.64.camel@pasglop> <1211906268.3435.44.camel@localhost.localdomain> <1211910825.7160.1.camel@localhost.localdomain> <483C7BE7.10204@nortel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from ozlabs.org ([203.10.76.45]:50312 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750911AbYE0XEU (ORCPT ); Tue, 27 May 2008 19:04:20 -0400 In-Reply-To: <483C7BE7.10204@nortel.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Chris Friesen Cc: Roland Dreier , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, tpiepho@freescale.com, James Bottomley , linuxppc-dev@ozlabs.org, scottwood@freescale.com, torvalds@linux-foundation.org, David Miller , alan@lxorguk.ukuu.org.uk, Arjan van de Ven Chris Friesen writes: > Roland Dreier wrote: > > > Writes are posted yes, but not reordered arbitrarily. If I have code like: > > > > spin_lock(&mmio_lock); > > writel(val1, reg1); > > writel(val2, reg2); > > spin_unlock(&mmio_lock); > > > > then I have a reasonable expectation that if two CPUs run this at the > > same time, their writes to reg1/reg2 won't be interleaved with each > > other (because the whole section is inside a spinlock). And Altix > > violates that expectation. > > Does that necessarily follow? > > If you've got a large system with multiple pci bridges, could you end up > with posted writes coming from different cpus taking a different amount > of time to propagate to a device and thus colliding? On powerpc we explicitly make sure that can't happen. That's the "do a sync in spin_unlock if there were any writels since the last spin_lock" magic. The sync instruction makes sure the writes have got to the host bridge before the spinlock is unlocked. Paul.