From patchwork Thu Jul 7 02:46:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 951912 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p672kTA3000883 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 02:46:50 GMT Received: from canuck.infradead.org ([134.117.69.58]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qeeba-0002rC-EH; Thu, 07 Jul 2011 02:46:19 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qeeba-0003iH-1r; Thu, 07 Jul 2011 02:46:18 +0000 Received: from mail-qy0-f170.google.com ([209.85.216.170]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QeebW-0003hy-KZ for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2011 02:46:15 +0000 Received: by qyg14 with SMTP id 14so2915929qyg.15 for ; Wed, 06 Jul 2011 19:46:05 -0700 (PDT) Received: by 10.224.212.71 with SMTP id gr7mr192788qab.198.1310006765195; Wed, 06 Jul 2011 19:46:05 -0700 (PDT) Received: from xanadu.home (modemcable092.28-130-66.mc.videotron.ca [66.130.28.92]) by mx.google.com with ESMTPS id u15sm6896582qcq.36.2011.07.06.19.46.03 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 06 Jul 2011 19:46:04 -0700 (PDT) Date: Wed, 6 Jul 2011 22:46:03 -0400 (EDT) From: Nicolas Pitre X-X-Sender: nico@xanadu.home To: Russell King - ARM Linux Subject: Re: [PATCH 01/10] ARM: change ARM_DMA_ZONE_SIZE into a variable In-Reply-To: <20110706230455.GZ8286@n2100.arm.linux.org.uk> Message-ID: References: <1309919442-20451-1-git-send-email-nicolas.pitre@linaro.org> <20110706230455.GZ8286@n2100.arm.linux.org.uk> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110706_224614_833406_F3875D7B X-CRM114-Status: GOOD ( 22.49 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.216.170 listed in list.dnswl.org] Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 07 Jul 2011 02:46:50 +0000 (UTC) On Thu, 7 Jul 2011, Russell King - ARM Linux wrote: > On Tue, Jul 05, 2011 at 10:30:33PM -0400, Nicolas Pitre wrote: > > +extern unsigned long arm_dma_zone_size; > > +#define MAX_DMA_ADDRESS (PAGE_OFFSET + arm_dma_zone_size) > ... > > -#ifndef ARM_DMA_ZONE_SIZE > > +#ifndef CONFIG_ZONE_DMA > > #define ISA_DMA_THRESHOLD (0xffffffffULL) > > #else > > -#define ISA_DMA_THRESHOLD (PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1) > > +#define ISA_DMA_THRESHOLD ({ \ > > + extern unsigned long arm_dma_zone_size; \ > > + arm_dma_zone_size ? \ > > + (PHYS_OFFSET + arm_dma_zone_size - 1) : 0xffffffffULL; }) > > These two usages do not agree. With unrestricted DMA, both > MAX_DMA_ADDRESS and ISA_DMA_THRESHOLD should be 0xffffffff. However, > you get that with arm_dma_zone_size=0 for ISA_DMA_THRESHOLD, which > then gives a MAX_DMA_ADDRESS of PAGE_OFFSET. So this potentially > changes the behaviour of these macros. Looking at what other architectures do, we have: avr32, parisc, powerpc, sparc -> 0xffffffff cris, frv, h8300, m68k, mips -> PAGE_OFFSET microblaze, score, xtensa -> 0 So I wonder if this macro makes any sense when there is no DMA zone. OTOH, since it is almost never used, it is best to make it behave like the original. Fixed tusly in my tree: Yet, excluding sound/oss/dmabuf.c, this is used by only 6 drivers in the whole tree which appear to be old ISA based drivers which would use a a DMA zone already. The exception is cs89x0.c, however MAX_DMA_ADDRESS is only used in the context of ISA DMA. What is more worrisome is its usage in a few places in the mm code where it is always passed to __pa(). Certainly __pa(0xffffffff) is not going to produce sensible results. One thing is for sure: ISA_DMA_THRESHOLD is not used anywhere in the whole tree except in arch/arm/mm/dma-mapping.c:get_coherent_dma_mask() and arch/arm/include/asm/dma-mapping.h:dma_supported() where its usage is certainly not ISA specific. Maybe this should be renamed? Nicolas diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h index 1d34c11..fcf15de 100644 --- a/arch/arm/include/asm/dma.h +++ b/arch/arm/include/asm/dma.h @@ -9,8 +9,10 @@ #ifndef CONFIG_ZONE_DMA #define MAX_DMA_ADDRESS 0xffffffffUL #else -extern unsigned long arm_dma_zone_size; -#define MAX_DMA_ADDRESS (PAGE_OFFSET + arm_dma_zone_size) +#define MAX_DMA_ADDRESS ({ \ + extern unsigned long arm_dma_zone_size; \ + arm_dma_zone_size ? \ + (PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; }) #endif #ifdef CONFIG_ISA_DMA_API