From owner-svn-src-all@freebsd.org  Thu May 16 19:10:50 2019
Return-Path: <owner-svn-src-all@freebsd.org>
Delivered-To: svn-src-all@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F74015A4F9A;
 Thu, 16 May 2019 19:10:50 +0000 (UTC) (envelope-from cem@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id A7A1A70DC1;
 Thu, 16 May 2019 19:10:49 +0000 (UTC) (envelope-from cem@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E30C2513D;
 Thu, 16 May 2019 19:10:49 +0000 (UTC) (envelope-from cem@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4GJAnfa062697;
 Thu, 16 May 2019 19:10:49 GMT (envelope-from cem@FreeBSD.org)
Received: (from cem@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4GJAndf062696;
 Thu, 16 May 2019 19:10:49 GMT (envelope-from cem@FreeBSD.org)
Message-Id: <201905161910.x4GJAndf062696@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org
 using -f
From: Conrad Meyer <cem@FreeBSD.org>
Date: Thu, 16 May 2019 19:10:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r347888 - in head/sys/mips: include mips
X-SVN-Group: head
X-SVN-Commit-Author: cem
X-SVN-Commit-Paths: in head/sys/mips: include mips
X-SVN-Commit-Revision: 347888
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Rspamd-Queue-Id: A7A1A70DC1
X-Spamd-Bar: --
Authentication-Results: mx1.freebsd.org
X-Spamd-Result: default: False [-2.99 / 15.00];
 local_wl_from(0.00)[FreeBSD.org];
 NEURAL_HAM_MEDIUM(-1.00)[-0.999,0];
 NEURAL_HAM_SHORT(-0.99)[-0.989,0];
 ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US];
 NEURAL_HAM_LONG(-1.00)[-1.000,0]
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
 user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all/>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-all>,
 <mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 16 May 2019 19:10:50 -0000

Author: cem
Date: Thu May 16 19:10:48 2019
New Revision: 347888
URL: https://svnweb.freebsd.org/changeset/base/347888

Log:
  mips: Implement basic pmap_kenter_device, pmap_kremove_device
  
  Unbreak mips.BERI_DE4_SDROOT build, which uses device xdma. Device xdma
  depends on the pmap_kenter_device APIs.
  
  Reported by:	tinderbox (local)
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/mips/include/pmap.h
  head/sys/mips/mips/pmap.c

Modified: head/sys/mips/include/pmap.h
==============================================================================
--- head/sys/mips/include/pmap.h	Thu May 16 19:09:41 2019	(r347887)
+++ head/sys/mips/include/pmap.h	Thu May 16 19:10:48 2019	(r347888)
@@ -177,7 +177,9 @@ void pmap_unmapdev(vm_offset_t, vm_size_t);
 vm_offset_t pmap_steal_memory(vm_size_t size);
 void pmap_kenter(vm_offset_t va, vm_paddr_t pa);
 void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t attr);
+void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
 void pmap_kremove(vm_offset_t va);
+void pmap_kremove_device(vm_offset_t, vm_size_t);
 void *pmap_kenter_temporary(vm_paddr_t pa, int i);
 void pmap_kenter_temporary_free(vm_paddr_t pa);
 void pmap_flush_pvcache(vm_page_t m);

Modified: head/sys/mips/mips/pmap.c
==============================================================================
--- head/sys/mips/mips/pmap.c	Thu May 16 19:09:41 2019	(r347887)
+++ head/sys/mips/mips/pmap.c	Thu May 16 19:10:48 2019	(r347888)
@@ -854,6 +854,44 @@ pmap_kenter(vm_offset_t va, vm_paddr_t pa)
 	pmap_kenter_attr(va, pa, VM_MEMATTR_DEFAULT);
 }
 
+void
+pmap_kenter_device(vm_offset_t va, vm_size_t size, vm_paddr_t pa)
+{
+
+	KASSERT((size & PAGE_MASK) == 0,
+	    ("%s: device mapping not page-sized", __func__));
+
+	for (; size > 0; size -= PAGE_SIZE) {
+		/*
+		 * XXXCEM: this is somewhat inefficient on SMP systems in that
+		 * every single page is individually TLB-invalidated via
+		 * rendezvous (pmap_update_page()), instead of invalidating the
+		 * entire range via a single rendezvous.
+		 */
+		pmap_kenter_attr(va, pa, VM_MEMATTR_UNCACHEABLE);
+		va += PAGE_SIZE;
+		pa += PAGE_SIZE;
+	}
+}
+
+void
+pmap_kremove_device(vm_offset_t va, vm_size_t size)
+{
+
+	KASSERT((size & PAGE_MASK) == 0,
+	    ("%s: device mapping not page-sized", __func__));
+
+	/*
+	 * XXXCEM: Similar to pmap_kenter_device, this is inefficient on SMP,
+	 * in that pages are invalidated individually instead of a single range
+	 * rendezvous.
+	 */
+	for (; size > 0; size -= PAGE_SIZE) {
+		pmap_kremove(va);
+		va += PAGE_SIZE;
+	}
+}
+
 /*
  * remove a page from the kernel pagetables
  */