From patchwork Mon Jul 1 17:09:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 2809001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C2E6BF4A1 for ; Mon, 1 Jul 2013 17:10:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5196720174 for ; Mon, 1 Jul 2013 17:10:54 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8006A20170 for ; Mon, 1 Jul 2013 17:10:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UthcY-0006MV-4c; Mon, 01 Jul 2013 17:10:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UthcV-0002aH-9I; Mon, 01 Jul 2013 17:10:31 +0000 Received: from caramon.arm.linux.org.uk ([78.32.30.218]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UthcS-0002Z1-98 for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2013 17:10:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=I+B9JufSuZglUufFxJL2NqTS+wcHE+d9//fdgJ9jvNE=; b=SGH1FjQ2oVjOjVaudm2dIey1NDTXjUNOZfpgwaZbkfCmtIfIeQy/bNTZFjroMYZ//bSiVtbLrzUAKcYSrfCKDsa4xI63MC1XQipH23Yma1NhxHG/1pLHyfn9w00CmU/J8I5gUuJpbLssUzJgjeRX5BeONTlAgdZDZ7Suq2QXvYE=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:52663) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1Uthbj-0001pd-Fw; Mon, 01 Jul 2013 18:09:43 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1Uthbi-0003HE-0Q; Mon, 01 Jul 2013 18:09:42 +0100 Date: Mon, 1 Jul 2013 18:09:41 +0100 From: Russell King - ARM Linux To: Santosh Shilimkar Subject: Re: [RFC PATCH 5/6] ARM, mm: change meaning of max_low_pfn to maximum pfn for nobootmem Message-ID: <20130701170941.GC24642@n2100.arm.linux.org.uk> References: <1364184674-13798-1-git-send-email-iamjoonsoo.kim@lge.com> <1364184674-13798-6-git-send-email-iamjoonsoo.kim@lge.com> <51D18ED5.50103@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <51D18ED5.50103@ti.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130701_131028_725369_D12F875A X-CRM114-Status: GOOD ( 21.51 ) X-Spam-Score: -4.3 (----) Cc: Joonsoo Kim , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nicolas Pitre X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jul 01, 2013 at 10:14:45AM -0400, Santosh Shilimkar wrote: > I have been also carrying similar patch as yours in an attempt > to make LPAE kernel work on ARM. Your patch carries better > description, so will your version and include in my series > which I plan to post on the list after some more testing. > Will copy you. The changes are very similar to your series. And will you try to investigate and/or address my concerns with this change? Consider this code in the block layer: static int __init blk_settings_init(void) { blk_max_low_pfn = max_low_pfn - 1; blk_max_pfn = max_pfn - 1; return 0; } void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask) { unsigned long b_pfn = dma_mask >> PAGE_SHIFT; ... if (b_pfn < blk_max_low_pfn) dma = 1; q->limits.bounce_pfn = b_pfn; if (dma) { init_emergency_isa_pool(); q->bounce_gfp = GFP_NOIO | GFP_DMA; q->limits.bounce_pfn = b_pfn; } } and this in SCSI: u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost) { struct device *host_dev; u64 bounce_limit = 0xffffffff; ... host_dev = scsi_get_device(shost); if (host_dev && host_dev->dma_mask) bounce_limit = *host_dev->dma_mask; return bounce_limit; } struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, request_fn_proc *request_fn) { ... blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); Now, what happens when you have a device which can only address the first 64MB of system memory, which is at 3GB(physical), but you have 1GB of system memory available both before changing max_low_pfn, and after changing max_low_pfn. Bear in mind that you will find that virtually all places in the kernel set the device DMA mask to be "DMA_BIT_MASK(number_of_bits_driven)" and not offset by the base of physical memory. In the above case, consider what happens with a 24 bit DMA mask. So... if we make this change, I would much prefer to also see a number of other patches preceding this one: (a) blk_queue_bounce_limit()'s parameter renamed from "dma_mask" to "max_addr" or indeed just taking b_pfn directly. (b) a helper: dma_max_pfn(dev) which converts a DMA bitmask of bits to a b_pfn number which is just "dev->dma_mask >> PAGE_SHIFT" in the generic case, but ARM can override this later. (c) a patch changing max_low_pfn/max_pfn to include the physical offset of memory, and providing an ARM version of this which adds in the appropriate offset. Here's an example dma_max_pfn() helper for the generic case: Arches can then override this with: static inline unsigned long dma_max_pfn(struct device *dev) { ... } #define dma_max_pfn dma_max_pfn diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 48ef6f5..a083724 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -153,6 +153,13 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) return -EIO; } +#ifndef dma_max_pfn +static inline unsigned long dma_max_pfn(struct device *dev) +{ + return dev->dma_mask ? (*dev->dma_mask >> PAGE_SHIFT) : 0; +} +#endif + static inline void *dma_zalloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) {