From patchwork Fri May 10 15:11:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 16861 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA894238F6 for ; Fri, 10 May 2013 15:12:58 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id 15sf5237014vea.9 for ; Fri, 10 May 2013 08:12:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=etsaCWog4A3ai4xlA5NMtiPQCEOuqEpwwcbmIkhldRA=; b=H4H7NXLjfmDeKsfPqH5SiSLuBGShxSgLkJWPQY56pfjUMWk/XFrWn+Li/kslQb8EsT F/qQZdaCQN8gcEpiZQUuqp1+AoHAOSiS8+HBvQhJRQQwQTTrNXP8SEtgKdS6dBUDiGY/ 3AYSx3rOiNX8HGm4e7wPTh1e89X6POlVWEbGndwJt9rfIwGYH3DxYHXjDCk7InQHlfBt VDTSxCqqOYPpVgR9vy2Fz7DyvTQfwhPIhtuhwT080LcN8CVS1h2wCFTET3QGkZweubgZ cSBNcKyHaaDQWgarOl3Y8gj7qAdKce9Y3qZBavluMRWrDKF9FOE6+4Tytz8SD0nD1Xr/ npnw== X-Received: by 10.224.130.195 with SMTP id u3mr12315716qas.1.1368198752864; Fri, 10 May 2013 08:12:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.4 with SMTP id h4ls426766qen.50.gmail; Fri, 10 May 2013 08:12:32 -0700 (PDT) X-Received: by 10.220.83.138 with SMTP id f10mr11433961vcl.7.1368198752608; Fri, 10 May 2013 08:12:32 -0700 (PDT) Received: from mail-vb0-x22e.google.com (mail-vb0-x22e.google.com [2607:f8b0:400c:c02::22e]) by mx.google.com with ESMTPS id ec8si1493982vdb.20.2013.05.10.08.12.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 May 2013 08:12:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22e; Received: by mail-vb0-f46.google.com with SMTP id 10so3576230vbe.33 for ; Fri, 10 May 2013 08:12:32 -0700 (PDT) X-Received: by 10.52.66.101 with SMTP id e5mr9702076vdt.57.1368198752426; Fri, 10 May 2013 08:12:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.217.15 with SMTP id hk15csp59258vcb; Fri, 10 May 2013 08:12:30 -0700 (PDT) X-Received: by 10.194.176.164 with SMTP id cj4mr25500790wjc.58.1368198750092; Fri, 10 May 2013 08:12:30 -0700 (PDT) Received: from mail-we0-x22b.google.com (mail-we0-x22b.google.com [2a00:1450:400c:c03::22b]) by mx.google.com with ESMTPS id h4si786250wiy.30.2013.05.10.08.12.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 May 2013 08:12:30 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22b is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=2a00:1450:400c:c03::22b; Received: by mail-we0-f171.google.com with SMTP id u55so4185803wes.16 for ; Fri, 10 May 2013 08:12:29 -0700 (PDT) X-Received: by 10.194.58.163 with SMTP id s3mr25590739wjq.6.1368198747879; Fri, 10 May 2013 08:12:27 -0700 (PDT) Received: from belegaer.uk.xensource.com. (firewall.ctxuk.citrix.com. [46.33.159.2]) by mx.google.com with ESMTPSA id e8sm4080359wic.5.2013.05.10.08.12.26 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 May 2013 08:12:26 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: Stefano.Stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, Julien Grall Subject: [PATCH V4 03/32] xen/arm: Introduce ioremap_attr, ioremap_cache, ioremap_nocache, ioremap_wc Date: Fri, 10 May 2013 16:11:55 +0100 Message-Id: <1368198723-24639-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368198723-24639-1-git-send-email-julien.grall@linaro.org> References: <1368198723-24639-1-git-send-email-julien.grall@linaro.org> X-Gm-Message-State: ALoCoQndPmDbITV5zPljPUSyeCBsALcRFHAElZ6QSLZs/ceVzQUl8JMMtF3lghqFqMcbUcxEbYCi X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22e 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Map physical range in virtual memory with a specific mapping attribute. Also add new mapping attributes for ARM: PAGE_HYPERVISOR_NOCACHE and PAGE_HYPERVISOR_WC. This function replaces early_ioremap which is only able to deal with 2Mb aligned mapping. Therefore, vmap initialization has been moved earlier. Signed-off-by: Julien Grall Changes in v4: - Update comment - Merge "Remove early_ioremap" in this commit - Add ioremap_nocache, ioremap_cache, ioremap_wc for future use when, for instance, SYS MMU will be ported from Linux Acked-by: Ian Campbell --- xen/arch/arm/mm.c | 48 +++++++++++------------------------------ xen/arch/arm/setup.c | 4 ++-- xen/drivers/video/arm_hdlcd.c | 2 +- xen/include/asm-arm/mm.h | 19 ++++++++++++++-- xen/include/asm-arm/page.h | 2 ++ 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index bd7eb1a..d1290cd 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -38,6 +38,7 @@ #include #include #include +#include struct domain *dom_xen, *dom_io, *dom_cow; @@ -567,45 +568,22 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) frametable_virt_end = FRAMETABLE_VIRT_START + (nr_pages * sizeof(struct page_info)); } -/* Map the physical memory range start - start + len into virtual - * memory and return the virtual address of the mapping. - * start has to be 2MB aligned. - * len has to be < VMAP_VIRT_END - VMAP_VIRT_START. - */ -static __initdata unsigned long early_vmap_start = VMAP_VIRT_END; -void* __init early_ioremap(paddr_t start, size_t len, unsigned attributes) +void *__init arch_vmap_virt_end(void) { - paddr_t end = start + len; - unsigned long map_start; - - len = (len + SECOND_SIZE - 1) & ~SECOND_MASK; - early_vmap_start -= len; - - ASSERT(!(start & (~SECOND_MASK))); - ASSERT(!(early_vmap_start & (~SECOND_MASK))); - - /* The range we need to map is too big */ - if ( early_vmap_start >= VMAP_VIRT_START ) - return NULL; - - map_start = early_vmap_start; - while ( start < end ) - { - lpae_t e = mfn_to_xen_entry(start >> PAGE_SHIFT); - e.pt.ai = attributes; - write_pte(xen_second + second_table_offset(map_start), e); - - start += SECOND_SIZE; - map_start += SECOND_SIZE; - } - flush_xen_data_tlb_range_va(early_vmap_start, len); - - return (void*)early_vmap_start; + return (void *)VMAP_VIRT_END; } -void *__init arch_vmap_virt_end(void) +/* + * This function should only be used to remap device address ranges + * TODO: add a check to verify this assumption + */ +void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes) { - return (void *)early_vmap_start; + unsigned long pfn = PFN_DOWN(pa); + unsigned int offs = pa & (PAGE_SIZE - 1); + unsigned int nr = PFN_UP(offs + len); + + return (__vmap(&pfn, nr, 1, 1, attributes) + offs); } static int create_xen_table(lpae_t *entry) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 29447ef..a667db4 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -429,6 +429,8 @@ void __init start_xen(unsigned long boot_phys_offset, setup_pagetables(boot_phys_offset, get_xen_paddr()); setup_mm(fdt_paddr, fdt_size); + vm_init(); + #ifdef EARLY_UART_ADDRESS /* TODO Need to get device tree or command line for UART address */ pl011_init(0, FIXMAP_ADDR(FIXMAP_CONSOLE)); @@ -483,8 +485,6 @@ void __init start_xen(unsigned long boot_phys_offset, console_init_postirq(); - vm_init(); - do_presmp_initcalls(); for_each_present_cpu ( i ) diff --git a/xen/drivers/video/arm_hdlcd.c b/xen/drivers/video/arm_hdlcd.c index d0ec13d..72979ea 100644 --- a/xen/drivers/video/arm_hdlcd.c +++ b/xen/drivers/video/arm_hdlcd.c @@ -211,7 +211,7 @@ void __init video_init(void) printk(KERN_INFO "Initializing HDLCD driver\n"); - lfb = early_ioremap(framebuffer_start, framebuffer_size, DEV_WC); + lfb = ioremap_wc(framebuffer_start, framebuffer_size); if ( !lfb ) { printk(KERN_ERR "Couldn't map the framebuffer\n"); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 26c271e..63e1069 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -153,8 +153,23 @@ extern void setup_frametable_mappings(paddr_t ps, paddr_t pe); extern void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes); /* Remove a mapping from a fixmap entry */ extern void clear_fixmap(unsigned map); -/* map a 2MB aligned physical range in virtual memory. */ -void* early_ioremap(paddr_t start, size_t len, unsigned attributes); +/* map a physical range in virtual memory */ +void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes); + +static inline void __iomem *ioremap_nocache(paddr_t start, size_t len) +{ + return ioremap_attr(start, len, PAGE_HYPERVISOR_NOCACHE); +} + +static inline void __iomem *ioremap_cache(paddr_t start, size_t len) +{ + return ioremap_attr(start, len, PAGE_HYPERVISOR); +} + +static inline void __iomem *ioremap_wc(paddr_t start, size_t len) +{ + return ioremap_attr(start, len, PAGE_HYPERVISOR_WC); +} #define mfn_valid(mfn) ({ \ unsigned long __m_f_n = (mfn); \ diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index fd6946e..13fbd78 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -59,6 +59,8 @@ #define DEV_CACHED WRITEBACK #define PAGE_HYPERVISOR (MATTR_MEM) +#define PAGE_HYPERVISOR_NOCACHE (DEV_SHARED) +#define PAGE_HYPERVISOR_WC (DEV_WC) #define MAP_SMALL_PAGES PAGE_HYPERVISOR /*