From owner-svn-src-all@FreeBSD.ORG Sat Jul 16 20:34:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9173106566B; Sat, 16 Jul 2011 20:34:02 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8FCC68FC0A; Sat, 16 Jul 2011 20:34:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6GKY2ZN043281; Sat, 16 Jul 2011 20:34:02 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6GKY2bd043279; Sat, 16 Jul 2011 20:34:02 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201107162034.p6GKY2bd043279@svn.freebsd.org> From: Marcel Moolenaar Date: Sat, 16 Jul 2011 20:34:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224116 - head/sys/ia64/ia64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jul 2011 20:34:02 -0000 Author: marcel Date: Sat Jul 16 20:34:02 2011 New Revision: 224116 URL: http://svn.freebsd.org/changeset/base/224116 Log: Don't assume pmap_mapdev() gets called only for memory mapped I/O addresses (i.e. uncacheable). ACPI in particular uses pmap_mapdev() rather excessively (number of calls) just to get a valid KVA. To that end, have pmap_mapdev(): 1. cache the last result so that we don't waste time for multiple consecutive invocations with the same PA/SZ. 2. find the memory descriptor that covers the PA and return NULL if none was found or when the PA is for a common DRAM address. 3. Use either a region 6 or region 7 KVA, in accordance with the memory attribute. Modified: head/sys/ia64/ia64/pmap.c Modified: head/sys/ia64/ia64/pmap.c ============================================================================== --- head/sys/ia64/ia64/pmap.c Sat Jul 16 20:31:29 2011 (r224115) +++ head/sys/ia64/ia64/pmap.c Sat Jul 16 20:34:02 2011 (r224116) @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -2235,12 +2236,37 @@ pmap_remove_write(vm_page_t m) * NOT real memory. */ void * -pmap_mapdev(vm_paddr_t pa, vm_size_t size) +pmap_mapdev(vm_paddr_t pa, vm_size_t sz) { + static void *last_va = NULL; + static vm_paddr_t last_pa = 0; + static vm_size_t last_sz = 0; + struct efi_md *md; vm_offset_t va; - va = pa | IA64_RR_BASE(6); - return ((void *)va); + if (pa == last_pa && sz == last_sz) + return (last_va); + + md = efi_md_find(pa); + if (md == NULL) { + printf("%s: [%#lx..%#lx] not covered by memory descriptor\n", + __func__, pa, pa + sz - 1); + return (NULL); + } + + if (md->md_type == EFI_MD_TYPE_FREE) { + printf("%s: [%#lx..%#lx] is in DRAM\n", __func__, pa, + pa + sz - 1); + return (NULL); + } + + va = (md->md_attr & EFI_MD_ATTR_WB) ? IA64_PHYS_TO_RR7(pa) : + IA64_PHYS_TO_RR6(pa); + + last_va = (void *)va; + last_pa = pa; + last_sz = sz; + return (last_va); } /*