From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Woodhouse Subject: Re: [LKML] Re: [PATCH v3] ad7877: keep dma rx buffers in seperate cache lines Date: Wed, 19 May 2010 13:48:45 +0100 Message-ID: <1274273325.6930.10022.camel@macbook.infradead.org> References: <1273608441.15067.1002.camel@calx> <20100511214836.GH1726@emlix.com> <20100511215359.GF7396@core.coreip.homeip.net> <522C1DF17AF50042AD8AE87F7887BD3D0163549554@exch.hq.tensilica.com> <20100512030350.GJ15903@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from casper.infradead.org ([85.118.1.10]:48231 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758067Ab0ESMtU (ORCPT ); Wed, 19 May 2010 08:49:20 -0400 In-Reply-To: <20100512030350.GJ15903@laptop> Sender: linux-input-owner@vger.kernel.org List-Id: linux-input@vger.kernel.org To: Nick Piggin Cc: Marc Gauthier , Mike Frysinger , Dmitry Torokhov , Johannes Weiner , Christoph Lameter , Pekka Enberg , Matt Mackall , Andrew Morton , Oskar Schirmer , Michael Hennerich , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Daniel =?ISO-8859-1?Q?Gl=F6ckner?= , Oliver Schneidewind , David Rientjes , David Brownell , Grant Likely , Chris Zankel , Piet Delaney On Wed, 2010-05-12 at 13:03 +1000, Nick Piggin wrote: > I don't think it's necessarily a good idea. MINALIGN is an enforced > minimum alignment and the allocator has no leeway in reducing this. > In a UP system, or in a memory constrained system, it might be a better > idea to pack objects more tightly, for example. > > If we allow drivers to assume kmalloc is cacheline aligned, it will be > (practically) impossible to revert this because it would require driver > audits. No, we definitely don't, and shouldn't, allow drivers to assume that kmalloc is cacheline-aligned. However, we _do_ allow drivers to assume that kmalloc is DMA-safe. That happens to mean "cacheline-aligned" for cache-incoherent architectures, but drivers should never really have to think about that. > So whenever strengthening API guarantees like this, it is better to be > very careful and conservative. Probably even introducing a new API with > the stronger semantics (even if it is just a wrapper in the case where > KMALLOC_MINALIGNED *is* cacheline sized). We're not talking about strengthening API guarantees. It's _always_ been this way; it's just that some architectures are buggy. But it looks like ARM, PowerPC, SH, MIPS, Microblaze, AVR32 and all unconditionally cache-coherent architectures _do_ get it right already. > I think adding to the DMA API would be a better idea. If the arch knows > that kmalloc is suitable for the job directly, it can be used. Drivers > can use the new interface, and kmalloc doesn't get saddled with > alignment requirements. No, that would be a change which would require auditing all drivers. The _current_ rule is that buffers returned from kmalloc() are OK for DMA. -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation