From patchwork Mon Jun 1 19:12:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jonathan (Zhixiong) Zhang" X-Patchwork-Id: 6524281 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 038BB9F1C1 for ; Mon, 1 Jun 2015 19:13:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A72020501 for ; Mon, 1 Jun 2015 19:13:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13F472050B for ; Mon, 1 Jun 2015 19:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753629AbbFATM6 (ORCPT ); Mon, 1 Jun 2015 15:12:58 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38872 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932130AbbFATMn (ORCPT ); Mon, 1 Jun 2015 15:12:43 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id D0DE31417F1; Mon, 1 Jun 2015 19:12:42 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id BE92C1417F5; Mon, 1 Jun 2015 19:12:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from zjzhang-lab.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: zjzhang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id EB2ED1417F1; Mon, 1 Jun 2015 19:12:41 +0000 (UTC) From: "Jonathan (Zhixiong) Zhang" To: Matt Fleming , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, leif.lindholm@linaro.org, al.stone@linaro.org, fu.wei@linaro.org Cc: "Jonathan (Zhixiong) Zhang" , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linaro-acpi@lists.linaro.org, vgandhi@codeaurora.org Subject: [PATCH V2 2/3] efi: add efi_remap() Date: Mon, 1 Jun 2015 12:12:19 -0700 Message-Id: <1433185940-24770-3-git-send-email-zjzhang@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1433185940-24770-1-git-send-email-zjzhang@codeaurora.org> References: <1433185940-24770-1-git-send-email-zjzhang@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Jonathan (Zhixiong) Zhang" If it is a EFI system, if EFI memmap is enabled and if a memory region has attribute of EFI_MEMORY_UC, map it as uncached. On x86, EFI memmap is unmapped in efi_free_boot_services(), before kernel finishes booting. So when efi_remap() is called during runtime on x86, it maps the region as cached. Signed-off-by: Jonathan (Zhixiong) Zhang --- drivers/firmware/efi/efi.c | 9 +++++++++ include/linux/efi.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 86da85368778..5b42bb6d1fde 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -535,3 +535,12 @@ u64 efi_mem_attributes(unsigned long phys_addr) } return 0; } + +void __iomem *efi_remap(phys_addr_t phys_addr, size_t size) +{ + if (efi_enabled(EFI_MEMMAP) && + (efi_mem_attributes(phys_addr) & EFI_MEMORY_UC)) + return ioremap(phys_addr, size); + else + return ioremap_cache(phys_addr, size); +} diff --git a/include/linux/efi.h b/include/linux/efi.h index af5be0368dec..0a0aa25d44d7 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -888,6 +888,7 @@ extern void efi_get_time(struct timespec *now); extern void efi_reserve_boot_services(void); extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose); extern struct efi_memory_map memmap; +extern void __iomem *efi_remap(phys_addr_t phys_addr, size_t size); extern int efi_reboot_quirk_mode; extern bool efi_poweroff_required(void);