From patchwork Tue Aug 21 17:23:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 1356981 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 71B13DFB34 for ; Tue, 21 Aug 2012 17:28:10 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T3sBM-0002uN-1E; Tue, 21 Aug 2012 17:24:00 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T3sBI-0002u9-QE for linux-arm-kernel@lists.infradead.org; Tue, 21 Aug 2012 17:23:57 +0000 X-IronPort-AV: E=McAfee;i="5400,1158,6809"; a="227810718" Received: from pdmz-ns-snip_115_219.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.115.219]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Aug 2012 10:23:53 -0700 Received: from [10.46.166.175] (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 37AA010004C2; Tue, 21 Aug 2012 10:23:52 -0700 (PDT) Message-ID: <5033C428.2050607@codeaurora.org> Date: Tue, 21 Aug 2012 10:23:52 -0700 From: Laura Abbott User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Murali Nalajala Subject: Re: ioremap() fail on physical address 0x0 in 3.4 kernel References: <50339AF6.1060601@codeaurora.org> In-Reply-To: <50339AF6.1060601@codeaurora.org> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.254 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "linux-arm-msm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 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 On 8/21/2012 7:28 AM, Murali Nalajala wrote: > Hi All, > I am doing a below call in my driver to get the virtual address > equivalent to physical address 0x0. > > pdata->v_addr = ioremap(pdata->p_addr, PAGE_SIZE); /* pdata->p_addr=0 */ > > Above call returns me a valid virtual address i.e: 0xfa200000. After > that when i try to access the address i am getting a kernel panic like > below. > [ 0.161784] ioremap: pfn=0x0 phys=0x0 offset=0x0 size=0x1000 > [ 0.161813] ioremap: area da0fbdc0: phys_addr=0xc0100000 pfn=0xc0100 > size=0x1000 > [ 0.161838] ioremap: area da0fbe20: phys_addr=0xa8600000 pfn=0xa8600 > size=0x1000 > [ 0.161861] ioremap: area da0fbd80: phys_addr=0xc0000000 pfn=0xc0000 > size=0x1000 > [ 0.161886] ioremap: area da0fbda0: phys_addr=0xc0100000 pfn=0xc0100 > size=0x1000 > [ 0.161909] ioremap: area da0fbde0: phys_addr=0xa9200000 pfn=0xa9200 > size=0x1000 > [ 0.161933] ioremap: area da0fbe00: phys_addr=0xa9300000 pfn=0xa9300 > size=0x1000 > [ 0.161956] ioremap: area da0fbd40: phys_addr=0x0 pfn=0x0 size=0x100000 > [ 0.161979] ioremap: found: addr fa200000 => 0xfa200000 => 0xfa200000 > [ 0.161999] *** reset_vector = 0xfa200000 > > > Can someone know me what is wrong in ioremap call? > Why i am not seeing a crash after i commented out the loop above? > Looks like you are hitting the empty section gap: 0xfa200000-0xfa300000 1048576 pmd_empty_section_gap+0x0/0x3c ioremap pmd_empty_section_gap ends up with vm->phys_addr = 0x0 because it was never set. This section isn't actually mapped so when searching for the range in the static io map it finds this address and returns it but it isn't actually a valid address to return. Perhaps ioremap should not bother trying to re-use the static iomap if the address is zero and let pmd_empty_section_gap use 0x0 as a dummy value? continue; > > Thanks, > Murali N > Thanks, Laura diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -228,7 +228,8 @@ void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, */ read_lock(&vmlist_lock); for (area = vmlist; area; area = area->next) { - if (!size || (sizeof(phys_addr_t) == 4 && pfn >= 0x100000)) + if (!size || !pfn || (sizeof(phys_addr_t) == 4 && + pfn >= 0x100000)) break; if (!(area->flags & VM_ARM_STATIC_MAPPING))