From patchwork Sat Apr 12 01:16:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 28297 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5DE7B2100C for ; Sat, 12 Apr 2014 01:22:11 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id oy12sf19797005veb.7 for ; Fri, 11 Apr 2014 18:22:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:references:in-reply-to:cc:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type; bh=xRqdaqhdLbk0+sqWx3W3Qcrl5F6JcZyIXe+RRaAMO0s=; b=F7b+P1K5DMcZkaDkaNzBUNGJm8Y3RTjfpQ2KGJBFbEMH6yD1VGn/e+AKmqL/0NvqWC fci8jAez8SokZRKujMI9KZnecSSCUesPCTSc8ouxeOk8Y6mDaeoZE5ThDlWhvBmxdsNq cSNUAXJ+ODlNNlyKG6ZVFA+7yMscNoh9A/X7TzF+lxW4l/jSp4GtpVRzXQG+C9K8z2+A LDsG8EMo/0QoLMYhNzWLVe0MVrJFoTq2Zn1zK6ZA+mMbHGQnPEYV/ba1uBQh4V9uFNis mAXAnp9wbMRygMH2FTK4KZOfmZbaC320gCtOir871OYhWugJPhFqo5qYNoErpb1GKHTS 27Hg== X-Gm-Message-State: ALoCoQkbXs3+2z97BfxnglGvNjVKcf5U6SWLsPBcJFUlzHjl4Z/9TKy7cM6aqGCNVUFZaW/l5IEj X-Received: by 10.236.39.99 with SMTP id c63mr12527205yhb.31.1397265731761; Fri, 11 Apr 2014 18:22:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.11 with SMTP id t11ls1734981qga.96.gmail; Fri, 11 Apr 2014 18:22:11 -0700 (PDT) X-Received: by 10.52.99.168 with SMTP id er8mr8294232vdb.26.1397265731681; Fri, 11 Apr 2014 18:22:11 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id j5si1665316veb.129.2014.04.11.18.22.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Apr 2014 18:22:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so5373869veb.6 for ; Fri, 11 Apr 2014 18:22:11 -0700 (PDT) X-Received: by 10.221.58.144 with SMTP id wk16mr147431vcb.23.1397265731559; Fri, 11 Apr 2014 18:22:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp100575vcb; Fri, 11 Apr 2014 18:22:10 -0700 (PDT) X-Received: by 10.224.97.69 with SMTP id k5mr27116432qan.8.1397265730711; Fri, 11 Apr 2014 18:22:10 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id t10si4070035qci.39.2014.04.11.18.22.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Apr 2014 18:22:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYmbD-0005ok-Mp; Sat, 12 Apr 2014 01:19:15 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYmbA-0005o5-Iw for linux-arm-kernel@lists.infradead.org; Sat, 12 Apr 2014 01:19:13 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3C1GgVp005483; Fri, 11 Apr 2014 20:16:42 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3C1Gfm1009155; Fri, 11 Apr 2014 20:16:41 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Fri, 11 Apr 2014 20:16:41 -0500 Received: from [172.22.129.1] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3C1GeUO013509; Fri, 11 Apr 2014 20:16:41 -0500 Message-ID: <534893F8.30309@ti.com> Date: Fri, 11 Apr 2014 21:16:40 -0400 From: Santosh Shilimkar User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Nicolas Pitre , Russell King - ARM Linux Subject: Re: commit b3a977b224 {ARM: Better virt_to_page() handling} breaks Keystone boot References: <53487A9E.70805@ti.com> <20140412002401.GS16119@n2100.arm.linux.org.uk> In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140411_181912_760577_6A7ABB32 X-CRM114-Status: GOOD ( 24.72 ) X-Spam-Score: -5.4 (-----) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-5.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.41 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Linux ARM Kernel Mailing List 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: santosh.shilimkar@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On Friday 11 April 2014 08:38 PM, Nicolas Pitre wrote: > On Sat, 12 Apr 2014, Russell King - ARM Linux wrote: > >> On Fri, Apr 11, 2014 at 08:13:23PM -0400, Nicolas Pitre wrote: >>> On Fri, 11 Apr 2014, Santosh Shilimkar wrote: >>> >>>> Russell, >>>> >>>> The subject commit breaks Keystone boot with higher address space enabled. >>>> I haven't debugged it further but reverting that patch makes it boot again. >>>> >>>> I will further look at it on Monday, but thought of letting you know. >>> >>> See my comment at the bottom of this email which might be the cause: >>> >>> http://article.gmane.org/gmane.linux.ports.arm.kernel/312721 >> >> I still don't see the relevance. Nothing touches __pv_phys_offset >> after we've booted. From what I can see, this stuff remains incomplete >> for Keystone. > > It certainly looks incomplete, and some out-of-tree might need adjusting > as mentioned before. > Sure. Here is the link[1] for the address switch patch. also attached. I should have merged this already but was waiting to sort out dma-ranges thinking to solve that one remainder issue before merging. In subject I mentioned a wrong commit id of your patch. It should have been 'e26a9e00a' Regards, Santosh [1] https://git.kernel.org/cgit/linux/kernel/git/ssantosh/linux-keystone.git/commit/?h=for_3.15/dma-ranges_v4-04&id=b9ae04710e2a9685ce2c0f5ec9676b86e5308a67 >From b9ae04710e2a9685ce2c0f5ec9676b86e5308a67 Mon Sep 17 00:00:00 2001 From: Santosh Shilimkar Date: Thu, 13 Jun 2013 19:24:39 -0400 Subject: ARM: keystone: Switch over to coherent memory address space With late code patching updates for LPAE machines has merged now and memblock conversion from bootmem is on its way, Keystone can switch to the coherent memory address space which starts beyond 4GB boundary. The idmap alias needs are managed via virt_to_idmap() for boot purpose. Signed-off-by: Santosh Shilimkar diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c index 6e6bb7d..1b43a27 100644 --- a/arch/arm/mach-keystone/keystone.c +++ b/arch/arm/mach-keystone/keystone.c @@ -20,6 +20,9 @@ #include #include #include +#include + +#include "memory.h" #include "keystone.h" @@ -45,6 +48,50 @@ static void __init keystone_init(void) of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } +static phys_addr_t keystone_virt_to_idmap(unsigned long x) +{ + return (phys_addr_t)(x) - CONFIG_PAGE_OFFSET + KEYSTONE_LOW_PHYS_START; +} + +static void __init keystone_init_meminfo(void) +{ + bool lpae = IS_ENABLED(CONFIG_ARM_LPAE); + bool pvpatch = IS_ENABLED(CONFIG_ARM_PATCH_PHYS_VIRT); + phys_addr_t offset = PHYS_OFFSET - KEYSTONE_LOW_PHYS_START; + phys_addr_t mem_start, mem_end; + + BUG_ON(meminfo.nr_banks < 1); + mem_start = meminfo.bank[0].start; + mem_end = mem_start + meminfo.bank[0].size - 1; + + /* nothing to do if we are running out of the <32-bit space */ + if (mem_start >= KEYSTONE_LOW_PHYS_START && + mem_end <= KEYSTONE_LOW_PHYS_END) + return; + + if (!lpae || !pvpatch) { + pr_crit("Enable %s%s%s to run outside 32-bit space\n", + !lpae ? __stringify(CONFIG_ARM_LPAE) : "", + (!lpae && !pvpatch) ? " and " : "", + !pvpatch ? __stringify(CONFIG_ARM_PATCH_PHYS_VIRT) : ""); + } + + if (mem_start < KEYSTONE_HIGH_PHYS_START || + mem_end > KEYSTONE_HIGH_PHYS_END) { + pr_crit("Invalid address space for memory (%08llx-%08llx)\n", + (u64)mem_start, (u64)mem_end); + } + + offset += KEYSTONE_HIGH_PHYS_START; + __pv_phys_offset = offset; + __pv_offset = (offset - PAGE_OFFSET); + + /* Populate the arch idmap hook */ + arch_virt_to_idmap = keystone_virt_to_idmap; + + pr_info("Switching to high address space at 0x%llx\n", (u64)offset); +} + static const char *keystone_match[] __initconst = { "ti,keystone-evm", NULL, @@ -76,4 +123,5 @@ DT_MACHINE_START(KEYSTONE, "Keystone") .init_machine = keystone_init, .dt_compat = keystone_match, .restart = keystone_restart, + .init_meminfo = keystone_init_meminfo, MACHINE_END diff --git a/arch/arm/mach-keystone/memory.h b/arch/arm/mach-keystone/memory.h new file mode 100644 index 0000000..b854fb1 --- /dev/null +++ b/arch/arm/mach-keystone/memory.h @@ -0,0 +1,24 @@ +/* + * Copyright 2014 Texas Instruments, Inc. + * Santosh Shilimkar + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + */ +#ifndef __MEMORY_H +#define __MEMORY_H + +#define MAX_PHYSMEM_BITS 36 +#define SECTION_SIZE_BITS 34 + +#define KEYSTONE_LOW_PHYS_START 0x80000000ULL +#define KEYSTONE_LOW_PHYS_SIZE 0x80000000ULL /* 2G */ +#define KEYSTONE_LOW_PHYS_END (KEYSTONE_LOW_PHYS_START + \ + KEYSTONE_LOW_PHYS_SIZE - 1) + +#define KEYSTONE_HIGH_PHYS_START 0x800000000ULL +#define KEYSTONE_HIGH_PHYS_SIZE 0x400000000ULL /* 16G */ +#define KEYSTONE_HIGH_PHYS_END (KEYSTONE_HIGH_PHYS_START + \ + KEYSTONE_HIGH_PHYS_SIZE - 1) +#endif /* __MEMORY_H */ diff --git a/arch/arm/mach-keystone/platsmp.c b/arch/arm/mach-keystone/platsmp.c index 5cf0683..5f46a7c 100644 --- a/arch/arm/mach-keystone/platsmp.c +++ b/arch/arm/mach-keystone/platsmp.c @@ -17,13 +17,16 @@ #include #include +#include +#include +#include #include "keystone.h" static int keystone_smp_boot_secondary(unsigned int cpu, struct task_struct *idle) { - unsigned long start = virt_to_phys(&secondary_startup); + unsigned long start = virt_to_idmap(&secondary_startup); int error; pr_debug("keystone-smp: booting cpu %d, vector %08lx\n", @@ -36,6 +39,19 @@ static int keystone_smp_boot_secondary(unsigned int cpu, return error; } +#ifdef CONFIG_ARM_LPAE +static void __cpuinit keystone_smp_secondary_initmem(unsigned int cpu) +{ + pgd_t *pgd0 = pgd_offset_k(0); + cpu_set_ttbr(1, __pa(pgd0) + TTBR1_OFFSET); + local_flush_tlb_all(); +} +#else +static inline void __cpuinit keystone_smp_secondary_initmem(unsigned int cpu) +{} +#endif + struct smp_operations keystone_smp_ops __initdata = { .smp_boot_secondary = keystone_smp_boot_secondary, + .smp_secondary_init = keystone_smp_secondary_initmem, };