Port-xen archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Xen patches
Hi,
Here's a bunch of drm patches for dom0. Works on my ivybridge with
dom0_mem=2046M
They will *not* work if you allocate more ram than your h/w dma can
address.
I need this tested on other hardware to wiggle out some pa<->ma
translations that I can't seem to spot in the dma alloc code that I'm
currently working on.
Thanks,
--
Cherry
# HG changeset patch
# User Cherry G. Mathew <cherry%zyx.in@localhost>
# Date 1442891037 -19800
# Tue Sep 22 08:33:57 2015 +0530
# Node ID 4bfdcac4f67e98b528b5a18a27547e42d27ddef3
# Parent 0b3902dbe2749423d609e3fc607106c87f7d3c22
[mq]: xen_poc
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/amd64/conf/XEN3_DOM0
--- a/sys/arch/amd64/conf/XEN3_DOM0 Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/amd64/conf/XEN3_DOM0 Tue Sep 22 08:33:57 2015 +0530
@@ -229,8 +229,19 @@
acpibut* at acpi? # ACPI Button
acpidalb* at acpi? # ACPI Direct Application Launch Button
acpiec* at acpi? # ACPI Embedded Controller
+acpiecdt* at acpi? # ACPI Embedded Controller (early)
+acpifan* at acpi? # ACPI Fan
acpilid* at acpi? # ACPI Lid Switch
+#acpipmtr* at acpi? # ACPI Power Meter (experimental)
+#acpismbus* at acpi? # ACPI SMBus CMI (experimental)
acpitz* at acpi? # ACPI Thermal Zone
+acpivga* at acpi? # ACPI Display Adapter
+acpiout* at acpivga? # ACPI Display Output Device
+acpiwdrt* at acpi? # ACPI Watchdog Resource Table
+acpiwmi* at acpi? # ACPI WMI Mapper
+
+
+# Mainboard devices
aibs* at acpi? # ASUSTeK AI Booster hardware monitor
hpqlb* at acpi? # HP Quick Launch Buttons
pckbc* at acpi? # PC keyboard controller
@@ -537,9 +548,12 @@
options PMS_SYNAPTICS_TOUCHPAD # Enable support for Synaptics Touchpads
#vga0 at isa?
vga* at pci? dev ? function ?
+genfb* at pci? dev ? function ?
+options VCONS_DRAW_INTR
#pcdisplay0 at isa? # CGA, MDA, EGA, HGA
#machfb* at pci? dev ? function ? # ATI Mach64 framebuffer driver
wsdisplay* at vga? console ?
+wsdisplay* at wsemuldisplaydev?
#wsdisplay* at pcdisplay? console ?
#wsdisplay* at machfb? console ?
wskbd* at pckbd? console ?
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/amd64/conf/XEN3_DOM0_DRMKMS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/conf/XEN3_DOM0_DRMKMS Tue Sep 22 08:33:57 2015 +0530
@@ -0,0 +1,23 @@
+include "arch/amd64/conf/XEN3_DOM0"
+
+i915drmkms* at pci? dev ? function ?
+intelfb* at intelfbbus?
+
+radeon* at pci? dev ? function ?
+radeondrmkmsfb* at radeonfbbus?
+
+#nouveau* at pci? dev ? function ?
+#nouveaufb* at nouveaufbbus
+
+no options DIAGNOSTIC
+options DIAGNOSTIC # inexpensive kernel consistency checks
+options DEBUG # expensive debugging checks/support
+options LOCKDEBUG # debug locks
+makeoptions DEBUG="-g" # compile full symbol table
+
+#options ACPIVERBOSE # verbose ACPI device autoconfig messages
+options PCIVERBOSE # verbose PCI device autoconfig messages
+options USBVERBOSE # verbose USB device autoconfig messages
+
+# XXX: Investigate if we actually need this ?
+#options VGA_POST # in-kernel support for VGA POST
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/amd64/include/bus_private.h
--- a/sys/arch/amd64/include/bus_private.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/amd64/include/bus_private.h Tue Sep 22 08:33:57 2015 +0530
@@ -1,3 +1,7 @@
/* $NetBSD: bus_private.h,v 1.2 2005/12/11 12:16:25 christos Exp $ */
+#ifndef XEN
#include <x86/bus_private.h>
+#else
+#include <xen/bus_private.h>
+#endif
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/amd64/include/mtrr.h
--- a/sys/arch/amd64/include/mtrr.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/amd64/include/mtrr.h Tue Sep 22 08:33:57 2015 +0530
@@ -1,3 +1,155 @@
-/* $NetBSD: mtrr.h,v 1.1 2003/04/26 18:39:44 fvdl Exp $ */
+/* $NetBSD: mtrr.h,v 1.5 2011/12/15 09:38:21 abs Exp $ */
-#include <x86/mtrr.h>
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Bill Sommerfeld
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _X86_MTRR_H_
+#define _X86_MTRR_H_
+
+#define MTRR_I686_FIXED_IDX64K 0
+#define MTRR_I686_FIXED_IDX16K 1
+#define MTRR_I686_FIXED_IDX4K 3
+
+#define MTRR_I686_NVAR_MAX 16 /* could be upto 255? */
+
+#define MTRR_I686_64K_START 0x00000
+#define MTRR_I686_16K_START 0x80000
+#define MTRR_I686_4K_START 0xc0000
+
+#define MTRR_I686_NFIXED_64K 1
+#define MTRR_I686_NFIXED_16K 2
+#define MTRR_I686_NFIXED_4K 8
+#define MTRR_I686_NFIXED 11
+#define MTRR_I686_NFIXED_SOFT_64K (MTRR_I686_NFIXED_64K * 8)
+#define MTRR_I686_NFIXED_SOFT_16K (MTRR_I686_NFIXED_16K * 8)
+#define MTRR_I686_NFIXED_SOFT_4K (MTRR_I686_NFIXED_4K * 8)
+#define MTRR_I686_NFIXED_SOFT (MTRR_I686_NFIXED * 8)
+
+#define MTRR_I686_ENABLE_MASK 0x0800
+#define MTRR_I686_FIXED_ENABLE_MASK 0x0400
+
+#define MTRR_I686_CAP_VCNT_MASK 0x00ff
+#define MTRR_I686_CAP_FIX_MASK 0x0100
+#define MTRR_I686_CAP_WC_MASK 0x0400
+
+#define MTRR_TYPE_UC 0
+#define MTRR_TYPE_WC 1
+#define MTRR_TYPE_UNDEF1 2
+#define MTRR_TYPE_UNDEF2 3
+#define MTRR_TYPE_WT 4
+#define MTRR_TYPE_WP 5
+#define MTRR_TYPE_WB 6
+
+struct mtrr_state {
+ uint32_t msraddr;
+ uint64_t msrval;
+};
+
+#define MTRR_PRIVATE 0x0001 /* 'own' range, reset at exit */
+#define MTRR_FIXED 0x0002 /* use fixed range mtrr */
+#define MTRR_VALID 0x0004 /* entry is valid */
+
+#define MTRR_CANTSET MTRR_FIXED
+
+#define MTRR_I686_MASK_VALID (1 << 11)
+
+/*
+ * AMD K6 MTRRs.
+ *
+ * There are two of these MTRR-like registers in the UWCRR.
+ */
+
+#define MTRR_K6_ADDR_SHIFT 17
+#define MTRR_K6_ADDR (0x7fffU << MTRR_K6_ADDR_SHIFT)
+#define MTRR_K6_MASK_SHIFT 2
+#define MTRR_K6_MASK (0x7fffU << MTRR_K6_MASK_SHIFT)
+#define MTRR_K6_WC (1U << 1) /* write-combine */
+#define MTRR_K6_UC (1U << 0) /* uncached */
+
+#define MTRR_K6_NVAR 2
+
+#ifdef _KERNEL
+
+#define mtrr_base_value(mtrrp) \
+ (((uint64_t)(mtrrp)->base) | ((uint64_t)(mtrrp)->type))
+#define mtrr_mask_value(mtrrp) \
+ ((~((mtrrp)->len - 1) & 0x0000000ffffff000LL))
+
+
+#define mtrr_len(val) \
+ ((~((val) & 0x0000000ffffff000LL)+1) & 0x0000000ffffff000LL)
+#define mtrr_base(val) ((val) & 0x0000000ffffff000LL)
+#define mtrr_type(val) ((uint8_t)((val) & 0x00000000000000ffLL))
+#define mtrr_valid(val) (((val) & MTRR_I686_MASK_VALID) != 0)
+
+struct proc;
+struct mtrr;
+
+void i686_mtrr_init_first(void);
+void k6_mtrr_init_first(void);
+#if defined(XEN)
+void xen_mtrr_init_first(void);
+#endif /* XEN */
+
+struct mtrr_funcs {
+ void (*init_cpu)(struct cpu_info *ci);
+ void (*reload_cpu)(struct cpu_info *ci);
+ void (*clean)(struct proc *p);
+ int (*set)(struct mtrr *, int *n, struct proc *p, int flags);
+ int (*get)(struct mtrr *, int *n, struct proc *p, int flags);
+ void (*commit)(void);
+ void (*dump)(const char *tag);
+};
+
+extern struct mtrr_funcs i686_mtrr_funcs;
+extern struct mtrr_funcs k6_mtrr_funcs;
+extern struct mtrr_funcs *mtrr_funcs;
+
+#define mtrr_init_cpu(ci) mtrr_funcs->init_cpu(ci)
+#define mtrr_reload_cpu(ci) mtrr_funcs->reload_cpu(ci)
+#define mtrr_clean(p) mtrr_funcs->clean(p)
+#define mtrr_set(mp,n,p,f) mtrr_funcs->set(mp,n,p,f)
+#define mtrr_get(mp,n,p,f) mtrr_funcs->get(mp,n,p,f)
+#define mtrr_dump(s) mtrr_funcs->dump(s)
+#define mtrr_commit() mtrr_funcs->commit()
+
+#define MTRR_GETSET_USER 0x0001
+#define MTRR_GETSET_KERNEL 0x0002
+
+#endif /* _KERNEL */
+
+struct mtrr {
+ uint64_t base; /* physical base address */
+ uint64_t len;
+ uint8_t type;
+ int flags;
+ pid_t owner; /* valid if MTRR_PRIVATE set in flags */
+};
+
+#endif /* _X86_MTRR_H_ */
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/amd64/include/pmap.h
--- a/sys/arch/amd64/include/pmap.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/amd64/include/pmap.h Tue Sep 22 08:33:57 2015 +0530
@@ -250,13 +250,28 @@
static __inline pt_entry_t
pmap_pa2pte(paddr_t pa)
{
+ extern paddr_t pmap_pa_start; /* PA of first physical page for this domain */
+ extern paddr_t pmap_pa_end; /* PA of last physical page for this domain */
+ if (pa < pmap_pa_start || pa >= pmap_pa_end) {
+ return pa;
+ }
return (pt_entry_t)xpmap_ptom_masked(pa);
}
static __inline paddr_t
pmap_pte2pa(pt_entry_t pte)
{
- return xpmap_mtop_masked(pte & PG_FRAME);
+ extern paddr_t pmap_pa_start; /* PA of first physical page for this domain */
+ extern paddr_t pmap_pa_end; /* PA of last physical page for this domain */
+
+ paddr_t ma = (pte & PG_FRAME);
+ paddr_t pa = xpmap_mtop_masked(ma);
+
+ if (pa >= pmap_pa_start &&
+ pa < pmap_pa_end)
+ return pa;
+ else
+ return ma;
}
static __inline void
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/i386/include/bus_private.h
--- a/sys/arch/i386/include/bus_private.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/i386/include/bus_private.h Tue Sep 22 08:33:57 2015 +0530
@@ -1,3 +1,8 @@
/* $NetBSD: bus_private.h,v 1.2 2005/12/11 12:17:43 christos Exp $ */
+#ifndef XEN
#include <x86/bus_private.h>
+#else
+#include <xen/bus_private.h>
+#endif
+
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/x86/include/mtrr.h
--- a/sys/arch/x86/include/mtrr.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/x86/include/mtrr.h Tue Sep 22 08:33:57 2015 +0530
@@ -113,6 +113,9 @@
void i686_mtrr_init_first(void);
void k6_mtrr_init_first(void);
+#ifdef XEN
+void xen_mtrr_init_first(void);
+#endif
struct mtrr_funcs {
void (*init_cpu)(struct cpu_info *ci);
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/x86/pci/pci_machdep.c
--- a/sys/arch/x86/pci/pci_machdep.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/x86/pci/pci_machdep.c Tue Sep 22 08:33:57 2015 +0530
@@ -938,6 +938,7 @@
}
# if NACPICA > 0 && defined(VGA_POST)
+ (void) curmode;
curmode = newmode;
# endif
#endif
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/x86/x86/genfb_machdep.c
--- a/sys/arch/x86/x86/genfb_machdep.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/x86/x86/genfb_machdep.c Tue Sep 22 08:33:57 2015 +0530
@@ -63,7 +63,11 @@
struct vcons_screen x86_genfb_console_screen;
#if NACPICA > 0
+#ifndef XEN
extern int acpi_md_vesa_modenum;
+#else
+int acpi_md_vesa_modenum;
+#endif
#endif
static device_t x86_genfb_console_dev = NULL;
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/x86/x86/pmap.c Tue Sep 22 08:33:57 2015 +0530
@@ -4062,12 +4062,15 @@
*/
__strict_weak_alias(pmap_enter, pmap_enter_default);
+#ifndef XEN
+#define DOMID_SELF 0
+#endif
int
pmap_enter_default(pmap_t pmap, vaddr_t va, paddr_t pa, vm_prot_t prot,
u_int flags)
{
- return pmap_enter_ma(pmap, va, pa, pa, prot, flags, 0);
+ return pmap_enter_ma(pmap, va, pa, pa, prot, flags, DOMID_SELF);
}
/*
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/xen/conf/files.xen Tue Sep 22 08:33:57 2015 +0530
@@ -85,7 +85,7 @@
file arch/x86/x86/db_trace.c ddb
file arch/x86/x86/fpu.c
file arch/xen/x86/hypervisor_machdep.c
-# file arch/x86/x86/mtrr_i686.c mtrr
+file arch/xen/x86/mtrr_xen.c mtrr
file arch/x86/x86/syscall.c
file arch/xen/x86/x86_xpmap.c
file arch/xen/x86/xen_pmap.c
@@ -134,6 +134,7 @@
file arch/xen/x86/xen_bus_dma.c machdep
file arch/x86/x86/bus_space.c machdep
file arch/xen/x86/consinit.c machdep
+file arch/x86/x86/genfb_machdep.c machdep
file arch/x86/x86/identcpu.c machdep
file arch/xen/x86/intr.c machdep
file arch/xen/x86/xen_ipi.c multiprocessor
@@ -273,6 +274,7 @@
file arch/x86/x86/nmi.c
file arch/x86/acpi/acpi_machdep.c acpi
+#file arch/x86/acpi/acpi_wakeup.c acpi
file arch/x86/acpi/acpi_pdc.c acpi
device ioapic
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/xen/include/amd64/vmparam.h
--- a/sys/arch/xen/include/amd64/vmparam.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/xen/include/amd64/vmparam.h Tue Sep 22 08:33:57 2015 +0530
@@ -33,6 +33,6 @@
#define VM_PHYSSEG_MAX 1
#undef VM_NFREELIST
-#undef VM_FREELIST_FIRST16
#define VM_NFREELIST 1
+
#endif /* _VMPARAM_H_ */
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/xen/include/bus_private.h
--- a/sys/arch/xen/include/bus_private.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/xen/include/bus_private.h Tue Sep 22 08:33:57 2015 +0530
@@ -26,6 +26,9 @@
* SUCH DAMAGE.
*/
+#if !defined(_XEN_BUS_PRIVATE_H_)
+#define _XEN_BUS_PRIVATE_H_
+
#include <uvm/uvm_extern.h>
#include "opt_xen.h"
@@ -67,3 +70,4 @@
#endif
#include <x86/bus_private.h>
+#endif /* !defined(_XEN_BUS_PRIVATE_H_) */
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/arch/xen/x86/cpu.c Tue Sep 22 08:33:57 2015 +0530
@@ -535,7 +535,14 @@
void
cpu_init(struct cpu_info *ci)
{
+#ifdef MTRR
+ if ((ci->ci_flags & CPUF_AP) == 0)
+ xen_mtrr_init_first();
+ mtrr_init_cpu(ci);
+
+#endif /* MTRR */
+
/*
* If we have FXSAVE/FXRESTOR, use them.
*/
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/xen/x86/mtrr_xen.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/xen/x86/mtrr_xen.c Tue Sep 22 08:33:57 2015 +0530
@@ -0,0 +1,346 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2015 Cherry G. Mathew <cherry%zyx.in@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/cpu.h>
+#include <sys/proc.h>
+#include <sys/pool.h>
+#include <sys/queue.h>
+
+#include <machine/mtrr.h>
+
+#include <xen/xenpmap.h>
+
+#define MTRR_NMAX 255
+
+struct pool mtrr_span_items_pool;
+
+SLIST_HEAD(mtrr_list_head_t, mtrr_list_entry_t) mtrr_list_head =
+ SLIST_HEAD_INITIALIZER(mtrr_list_head);
+
+struct xen_mtrr {
+ struct mtrr x86_mtrr;
+
+ /*
+ * Mirror the xen specific data ( see xen-public/platform.h )
+ * to keep track of.
+ */
+
+ uint32_t handle;
+ uint32_t reg;
+};
+
+struct mtrr_list_entry_t {
+ SLIST_ENTRY(mtrr_list_entry_t) mtrr_list_entries;
+ struct xen_mtrr mtrr_entry;
+
+};
+
+
+static void mtrr_xen_init_cpu(struct cpu_info *ci);
+static void mtrr_xen_reload_cpu(struct cpu_info *ci);
+static void mtrr_xen_clean(struct proc *p);
+static int mtrr_xen_set(struct mtrr *mtrr, int *n,
+ struct proc *p, int flags);
+static int mtrr_xen_get(struct mtrr *, int *n,
+ struct proc *p, int flags);
+static void mtrr_xen_commit(void);
+static void mtrr_xen_dump(const char *tag);
+
+static struct mtrr_funcs mtrr_xen_funcs = {
+ mtrr_xen_init_cpu,
+ mtrr_xen_reload_cpu,
+ mtrr_xen_clean,
+ mtrr_xen_set,
+ mtrr_xen_get,
+ mtrr_xen_commit,
+ mtrr_xen_dump
+};
+
+void
+xen_mtrr_init_first(void)
+{
+ KASSERT(CPU_IS_PRIMARY(curcpu()));
+ mtrr_funcs = &mtrr_xen_funcs;
+}
+
+static int
+xen_set_mtrr(struct xen_mtrr *xmtrr)
+{
+ int error = EINVAL;
+ struct xen_platform_op op;
+
+ /* XXX: */
+ KASSERT(xmtrr != NULL);
+
+ if (!(xmtrr->x86_mtrr.flags & MTRR_VALID))
+ return EINVAL;
+
+ /* XXX: Rest of the flags ? */
+ op.u.add_memtype.mfn = btop(xpmap_ptom(xmtrr->x86_mtrr.base));
+ op.u.add_memtype.nr_mfns = btop(xmtrr->x86_mtrr.len);
+ op.u.add_memtype.type = xmtrr->x86_mtrr.type;
+
+ error = -HYPERVISOR_platform_op(&op);
+
+ xmtrr->handle = op.u.add_memtype.handle;
+ xmtrr->reg = op.u.add_memtype.reg;
+
+ return error;
+}
+
+static int
+xen_del_mtrr(struct xen_mtrr *xmtrr)
+{
+ /* XXX: */
+ return EINVAL;
+}
+static void
+mtrr_xen_init_cpu(struct cpu_info *ci)
+{
+ KASSERT(ci != NULL);
+
+ if (CPU_IS_PRIMARY(ci)) {
+ pool_init(&mtrr_span_items_pool, sizeof(struct mtrr_list_entry_t),
+ 0, 0, 0, "xen:mtrr_list_entry_t", NULL, IPL_NONE /* XXX: */);
+
+ if (pool_prime(&mtrr_span_items_pool, MTRR_NMAX) != 0) {
+ panic("%s: can't prime pool for %d entries\n",
+ __func__, MTRR_NMAX);
+ }
+ }
+}
+
+static void
+mtrr_xen_reload_cpu(struct cpu_info *ci)
+{
+ /* Nothing to do - Xen manages ranges for us. */
+ return;
+}
+
+static void
+mtrr_xen_clean(struct proc *p)
+{
+ KASSERT(p != NULL);
+ struct mtrr_list_entry_t *mtrr_this_item;
+ SLIST_FOREACH(mtrr_this_item, &mtrr_list_head, mtrr_list_entries) {
+ if (mtrr_this_item->mtrr_entry.x86_mtrr.owner == p->p_pid) {
+ /* XXX: remove it */
+ }
+ }
+
+ return;
+}
+
+/* Helper function */
+/* Try to merge given mtrr with existing entries */
+/* Returns 0 on success */
+static int
+xen_try_merge_mtrr(struct xen_mtrr xmtrr)
+{
+ int error = 0;
+
+ struct xen_mtrr *xmtrr_new = &xmtrr;
+ struct mtrr_list_entry_t *mtrr_this_item;
+
+ SLIST_FOREACH(mtrr_this_item, &mtrr_list_head, mtrr_list_entries) {
+ struct xen_mtrr *xmtrr_this;
+
+ xmtrr_this = &mtrr_this_item->mtrr_entry;
+
+ /*
+ * Is it compatible ?
+ * We let Xen do the finer validations/compat
+ * checks - we only coalesce MTRR ranges for
+ * *exact* type matches.
+ */
+
+ if (xmtrr_new->x86_mtrr.flags & MTRR_PRIVATE) {
+ if (xmtrr_new->x86_mtrr.owner != xmtrr_this->x86_mtrr.owner) {
+ continue;
+ }
+ }
+
+ if (xmtrr_new->x86_mtrr.type == xmtrr_this->x86_mtrr.type) {
+
+ /* Is it enclosed ? */
+ if (xmtrr_new->x86_mtrr.base >= xmtrr_this->x86_mtrr.base &&
+ (xmtrr_new->x86_mtrr.base + xmtrr_new->x86_mtrr.len) <=
+ (xmtrr_this->x86_mtrr.base + xmtrr_this->x86_mtrr.len)) {
+ /* Nothing more to do */
+ return 0;
+ }
+
+ /* Is it enclosing ? */
+ if (xmtrr_new->x86_mtrr.base <= xmtrr_this->x86_mtrr.base &&
+ (xmtrr_new->x86_mtrr.base + xmtrr_new->x86_mtrr.len) >=
+ (xmtrr_this->x86_mtrr.base + xmtrr_this->x86_mtrr.len)) {
+
+ error = xen_del_mtrr(xmtrr_this);
+ if (error != 0) return error;
+
+ error = xen_set_mtrr(xmtrr_new);
+ /* Note: We don't undo the "delete" above */
+ if (error !=0) return error;
+
+ /* Update our record of the entry */
+ xmtrr_this->x86_mtrr.base = xmtrr_new->x86_mtrr.base;
+ xmtrr_this->x86_mtrr.len = xmtrr_new->x86_mtrr.len;
+ return 0;
+ }
+
+ /* Is it adjacent ? */
+ if (xmtrr_new->x86_mtrr.base == (xmtrr_this->x86_mtrr.base + xmtrr_this->x86_mtrr.len) ||
+ xmtrr_this->x86_mtrr.base == (xmtrr_new->x86_mtrr.base + xmtrr_new->x86_mtrr.len)) {
+
+ error = xen_del_mtrr(xmtrr_this);
+ if (error !=0) return error;
+
+ /* Update the entry */
+ if (xmtrr_new->x86_mtrr.base == (xmtrr_this->x86_mtrr.base + xmtrr_this->x86_mtrr.len)) {
+ xmtrr_this->x86_mtrr.len += xmtrr_new->x86_mtrr.len;
+ }
+ else {
+ xmtrr_this->x86_mtrr.base = xmtrr_new->x86_mtrr.base;
+ xmtrr_this->x86_mtrr.len += xmtrr_new->x86_mtrr.len;
+ }
+
+ error = xen_set_mtrr(xmtrr_this);
+ if (error !=0) return error;
+
+ return 0;
+ }
+
+ }
+ }
+
+ return ERANGE;
+}
+
+static int
+mtrr_xen_set(struct mtrr *mtrrp, int *n,
+ struct proc *p, int flags)
+{
+ int i, pool_flags, error = 0;
+ struct xen_mtrr xmtrr_tmp, *xmtrr_new = &xmtrr_tmp;
+
+ struct mtrr_list_entry_t *mtrr_new_item;
+
+
+ KASSERT(mtrrp != NULL);
+ KASSERT(n != NULL);
+
+ printf("%s(%d): *n == %d\n", __func__, __LINE__, *n);
+
+ if (*n > MTRR_NMAX) { /* XXX: 255 is arbitrary - make this pool size */
+ *n = 0;
+ return EINVAL;
+ }
+
+ /* Only wait for Userland mtrr ops */
+ pool_flags = (flags & MTRR_GETSET_USER) ? PR_WAITOK : PR_NOWAIT;
+
+ i = *n;
+
+ for (*n = 0; *n < i; (*n)++) {
+ switch (flags & (MTRR_GETSET_USER | MTRR_GETSET_KERNEL)) {
+ case MTRR_GETSET_USER:
+ error = copyin(&mtrrp[i], &xmtrr_new->x86_mtrr, sizeof xmtrr_new->x86_mtrr);
+ if (error != 0) return error;
+
+ case MTRR_GETSET_KERNEL:
+ xmtrr_new->x86_mtrr = mtrrp[i];
+ break;
+ default:
+ /* XXX: Do we need to return entries to pool, on abort ? */
+ return EINVAL;
+ }
+
+ /* Private mappings are per-process */
+ if (xmtrr_new->x86_mtrr.flags & MTRR_PRIVATE) {
+ if (p == NULL) {
+ return EINVAL;
+ }
+
+ if (p->p_pid != xmtrr_new->x86_mtrr.owner) {
+ return EBUSY;
+ }
+
+ xmtrr_new->x86_mtrr.owner = p->p_pid;
+
+ p->p_md.md_flags |= MDP_USEDMTRR;
+ }
+
+ error = xen_try_merge_mtrr(xmtrr_tmp);
+
+ if (error == 0) return 0; /* Merge successful */
+ printf("%s(%d): error = %d\n", __func__, __LINE__, error);
+
+ /* Something other than merge failure - abort
+ */
+ if (error != ERANGE) return error;
+ printf("%s(%d): error = %d\n", __func__, __LINE__, error);
+
+ /* Add new entry */
+
+ error = xen_set_mtrr(xmtrr_new);
+ if (error !=0) return error;
+
+ mtrr_new_item = pool_get(&mtrr_span_items_pool, pool_flags);
+
+ if (mtrr_new_item == NULL) {
+ panic("Ran out of mtrr pool entries for kernel mtrr set!");
+ }
+ mtrr_new_item->mtrr_entry = *xmtrr_new;
+ SLIST_INSERT_HEAD(&mtrr_list_head, mtrr_new_item, mtrr_list_entries);
+ }
+
+ return error;
+}
+static int
+mtrr_xen_get(struct mtrr *mtrr, int *n,
+ struct proc *p, int flags)
+{
+ return -1;
+}
+
+static void
+mtrr_xen_commit(void)
+{
+ /* Nothing to do - Xen manages ranges for us. */
+ return;
+}
+
+static void
+mtrr_xen_dump(const char *tag)
+{
+ return;
+}
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/arch/xen/xen/mtrr_xen.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/xen/xen/mtrr_xen.c Tue Sep 22 08:33:57 2015 +0530
@@ -0,0 +1,160 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2015 Cherry G. Mathew <cherry%zyx.in@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/cpu.h>
+#include <sys/proc.h>
+#include <sys/pool.h>
+#include <sys/queue.h>
+
+#include <machine/mtrr.h>
+
+struct pool mtrr_span_items_pool;
+
+SLIST_HEAD(mtrr_list_head_t, mtrr_list_entry_t) mtrr_list_head =
+ SLIST_HEAD_INITIALIZER(mtrr_list_head);
+struct mtrr_list_head_t *mtrr_list_headp;
+
+struct mtrr_list_entry_t {
+ SLIST_ENTRY(mtrr_list_entry_t) mtrr_list_entries;
+};
+
+
+static void mtrr_xen_init_cpu(struct cpu_info *ci);
+static void mtrr_xen_reload_cpu(struct cpu_info *ci);
+static void mtrr_xen_clean(struct proc *p);
+static int mtrr_xen_set(struct mtrr *mtrr, int *n,
+ struct proc *p, int flags);
+static int mtrr_xen_get(struct mtrr *, int *n,
+ struct proc *p, int flags);
+static void mtrr_xen_commit(void);
+static void mtrr_xen_dump(const char *tag);
+
+struct mtrr_funcs mtrr_xen_funcs = {
+ mtrr_xen_init_cpu,
+ mtrr_xen_reload_cpu,
+ mtrr_xen_clean,
+ mtrr_xen_set,
+ mtrr_xen_get,
+ mtrr_xen_commit,
+ mtrr_xen_dump
+};
+
+static void
+mtrr_xen_init_cpu(struct cpu_info *ci)
+{
+ KASSERT(ci != NULL);
+
+ if (ci != &cpu_info_primary)
+ return;
+
+ /* Nothing to do - Xen sets up for us. */
+ pool_init(&mtrr_span_items_pool, sizeof(struct mtrr),
+ 0, 0, 0,/*XXX: wchan*/, NULL, IPL_XXX);
+ return;
+}
+
+static void
+mtrr_xen_reload_cpu(struct cpu_info *ci)
+{
+ /* Nothing to do - Xen manages ranges for us. */
+ return;
+}
+
+static void
+mtrr_xen_clean(struct proc *p)
+{
+ return;
+}
+
+static int
+mtrr_xen_set(struct mtrr *mtrrp, int *n,
+ struct proc *p, int flags)
+{
+ int i, error = EINVAL;
+
+ struct mtrr mtrr;
+
+ KASSERT(mtrrp != NULL);
+ KASSERT(n != NULL);
+
+ if (*n > 255) { /* XXX: 255 is arbitrary - make this pool size */
+ *n = 0;
+ return EINVAL;
+ }
+
+ if (p == NULL && /* Private mappings are per-process */
+ (flags & MTRR_PRIVATE)) {
+ return EBUSY;
+ }
+
+ /* XXX: SLIST_FOREACH(np, &head, entries)
+ np-> ...
+ */
+
+ for (i = 0; i < *n; i++) {
+ switch (flags & (MTRR_GETSET_USER | MTRR_GETSET_KERNEL)) {
+ case MTRR_GETSET_USER:
+ error = copyin(&mtrrp[*n], &mtrr, sizeof mtrr);
+ if (error != 0) break;
+
+ case MTRR_GETSET_KERNEL:
+ mtrr = mtrrp[*n];
+ break;
+ default:
+ return EINVAL;
+ }
+
+ /* XXX: Update mtrr */
+ }
+
+ return error;
+}
+
+static int
+mtrr_xen_get(struct mtrr *mtrr, int *n,
+ struct proc *p, int flags)
+{
+ return -1;
+}
+
+static void
+mtrr_xen_commit(void)
+{
+ /* Nothing to do - Xen manages ranges for us. */
+ return;
+}
+
+static void
+mtrr_xen_dump(const char *tag)
+{
+ return;
+}
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/drm_gem.c
--- a/sys/external/bsd/drm2/dist/drm/drm_gem.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/drm_gem.c Tue Sep 22 08:33:57 2015 +0530
@@ -569,7 +569,7 @@
* See this thread: http://lkml.org/lkml/2011/7/11/238
*/
BUG_ON((gfpmask & __GFP_DMA32) &&
- (page_to_pfn(p) >= 0x00100000UL));
+ (atop(_BUS_VM_PAGE_TO_BUS(p)) >= 0x00100000UL));
}
return pages;
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Tue Sep 22 08:33:57 2015 +0530
@@ -732,7 +732,7 @@
page_length = PAGE_SIZE - shmem_page_offset;
page_do_bit17_swizzling = obj_do_bit17_swizzling &&
- (page_to_phys(page) & (1 << 17)) != 0;
+ (page_to_bus(page) & (1 << 17)) != 0;
ret = shmem_pread_fast(page, shmem_page_offset, page_length,
user_data, page_do_bit17_swizzling,
@@ -1089,7 +1089,7 @@
((shmem_page_offset | page_length) & flush_mask);
page_do_bit17_swizzling = obj_do_bit17_swizzling &&
- (page_to_phys(page) & (1 << 17)) != 0;
+ (page_to_bus(page) & (1 << 17)) != 0;
ret = shmem_pwrite_fast(page, shmem_page_offset, page_length,
user_data, page_do_bit17_swizzling,
@@ -1949,7 +1949,7 @@
UVMHIST_LOG(maphist,
" MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d",
ufi->orig_map->pmap, curr_va, paddr, mapprot);
- if (pmap_enter_default(ufi->orig_map->pmap, curr_va, paddr, mapprot,
+ if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, mapprot,
PMAP_CANFAIL | mapprot | mmapflags) != 0) {
/*
* pmap_enter() didn't have the resource to
@@ -2596,11 +2596,11 @@
const uint64_t mask =
(IS_BROADWATER(dev) || IS_CRESTLINE(dev)?
0xffffffffULL : 0xffffffffffULL);
- if (VM_PAGE_TO_PHYS(page) & ~mask) {
+ if (_BUS_VM_PAGE_TO_BUS(page) & ~mask) {
DRM_ERROR("GEM physical address exceeds %u bits"
": %"PRIxMAX"\n",
popcount64(mask),
- (uintmax_t)VM_PAGE_TO_PHYS(page));
+ (uintmax_t)_BUS_VM_PAGE_TO_BUS(page));
error = -EIO;
goto fail2;
}
@@ -2711,7 +2711,7 @@
last_pfn = page_to_pfn(page);
/* Check that the i965g/gm workaround works. */
- WARN_ON((gfp & __GFP_DMA32) && (last_pfn >= 0x00100000UL));
+ WARN_ON((gfp & __GFP_DMA32) && (atop(_BUS_VM_PAGE_TO_BUS(page)) >= 0x00100000UL));
}
#ifdef CONFIG_SWIOTLB
if (!swiotlb_nr_tbl())
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem_gtt.c Tue Sep 22 08:33:57 2015 +0530
@@ -2557,7 +2557,7 @@
if (pci_dma_mapping_error(dev->pdev, dma_addr))
return -EINVAL;
#else
- dma_addr = page_to_phys(page);
+ dma_addr = page_to_bus(page);
#endif
dev_priv->gtt.base.scratch.page = page;
dev_priv->gtt.base.scratch.addr = dma_addr;
@@ -2866,7 +2866,12 @@
return ret;
#ifdef __NetBSD__
+#ifndef XEN
dev_priv->gtt.pgfl = x86_select_freelist(dev_priv->gtt.max_paddr);
+#else
+ /* On Xen we just have one range of addresses for dom0 */
+ dev_priv->gtt.pgfl = VM_FREELIST_DEFAULT;
+#endif
ret = drm_limit_dma_space(dev, 0, dev_priv->gtt.max_paddr);
if (ret) {
DRM_ERROR("Unable to limit DMA paddr allocations: %d!\n", ret);
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/i915/i915_gem_tiling.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem_tiling.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem_tiling.c Tue Sep 22 08:33:57 2015 +0530
@@ -494,7 +494,7 @@
#ifdef __NetBSD__
i = 0;
TAILQ_FOREACH(page, &obj->igo_pageq, pageq.queue) {
- unsigned char new_bit_17 = VM_PAGE_TO_PHYS(page) >> 17;
+ unsigned char new_bit_17 = _BUS_VM_PAGE_TO_BUS(page) >> 17;
if ((new_bit_17 & 0x1) !=
(test_bit(i, obj->bit_17) != 0)) {
i915_gem_swizzle_page(container_of(page, struct page,
@@ -507,7 +507,7 @@
i = 0;
for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0) {
struct page *page = sg_page_iter_page(&sg_iter);
- char new_bit_17 = page_to_phys(page) >> 17;
+ char new_bit_17 = page_to_bus(page) >> 17;
if ((new_bit_17 & 0x1) !=
(test_bit(i, obj->bit_17) != 0)) {
i915_gem_swizzle_page(page);
@@ -542,7 +542,7 @@
i = 0;
#ifdef __NetBSD__
TAILQ_FOREACH(page, &obj->igo_pageq, pageq.queue) {
- if (ISSET(VM_PAGE_TO_PHYS(page), __BIT(17)))
+ if (ISSET(_BUS_VM_PAGE_TO_BUS(page), __BIT(17)))
__set_bit(i, obj->bit_17);
else
__clear_bit(i, obj->bit_17);
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/i915/intel_display.c
--- a/sys/external/bsd/drm2/dist/drm/i915/intel_display.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/i915/intel_display.c Tue Sep 22 08:33:57 2015 +0530
@@ -1969,6 +1969,7 @@
u32 alignment;
int ret;
+ DRM_ERROR("Enter)\n");
switch (obj->tiling_mode) {
case I915_TILING_NONE:
if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
@@ -1999,8 +2000,10 @@
dev_priv->mm.interruptible = false;
ret = i915_gem_object_pin_to_display_plane(obj, alignment, pipelined);
- if (ret)
+ if (ret) {
+ DRM_ERROR("Failed to i915_gem_object_pin_to_display_plane(obj, alignment, pipelined)\n");
goto err_interruptible;
+ }
/* Install a fence for tiled scan-out. Pre-i965 always needs a
* fence, whereas 965+ only requires a fence if using
@@ -2008,8 +2011,10 @@
* a fence as the cost is not that onerous.
*/
ret = i915_gem_object_get_fence(obj);
- if (ret)
+ if (ret) {
+ DRM_ERROR("i915_gem_object_get_fence(obj);\n");
goto err_unpin;
+ }
i915_gem_object_pin_fence(obj);
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c Tue Sep 22 08:33:57 2015 +0530
@@ -586,7 +586,7 @@
if (pci_dma_mapping_error(device->pdev, ret))
ret = 0;
} else {
- ret = page_to_phys(page);
+ ret = page_to_bus(page);
}
return ret;
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/ttm/ttm_memory.c
--- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_memory.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_memory.c Tue Sep 22 08:33:57 2015 +0530
@@ -598,7 +598,7 @@
if (PageHighMem(page) && glob->zone_highmem != NULL)
zone = glob->zone_highmem;
#else
- if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL)
+ if (glob->zone_dma32 && page_to_bfn(page) > 0x00100000UL)
zone = glob->zone_kernel;
#endif
return ttm_mem_global_alloc_zone(glob, zone, PAGE_SIZE, no_wait,
@@ -613,7 +613,7 @@
if (PageHighMem(page) && glob->zone_highmem != NULL)
zone = glob->zone_highmem;
#else
- if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL)
+ if (glob->zone_dma32 && page_to_bfn(page) > 0x00100000UL)
zone = glob->zone_kernel;
#endif
ttm_mem_global_free_zone(glob, zone, PAGE_SIZE);
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_buffer.c
--- a/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_buffer.c Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/dist/drm/vmwgfx/vmwgfx_buffer.c Tue Sep 22 08:33:57 2015 +0530
@@ -231,7 +231,7 @@
*/
static dma_addr_t __vmw_piter_phys_addr(struct vmw_piter *viter)
{
- return page_to_phys(viter->pages[viter->i]);
+ return page_to_bus(viter->pages[viter->i]);
}
static dma_addr_t __vmw_piter_dma_addr(struct vmw_piter *viter)
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/include/asm/page.h
--- a/sys/external/bsd/drm2/include/asm/page.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/include/asm/page.h Tue Sep 22 08:33:57 2015 +0530
@@ -33,7 +33,10 @@
#define _ASM_PAGE_H_
#include <sys/bus.h>
+#include <machine/bus_private.h>
+#include <uvm/uvm.h>
+#include <uvm/uvm_extern.h>
#include <uvm/uvm_page.h>
#include <linux/mm_types.h>
@@ -56,4 +59,16 @@
return (page_to_phys(page) >> PAGE_SHIFT);
}
+static inline bus_addr_t
+page_to_bus(struct page *page)
+{
+ return _BUS_VM_PAGE_TO_BUS(&page->p_vmp);
+}
+
+static inline unsigned long
+page_to_bfn(struct page *page)
+{
+ return (page_to_bus(page) >> PAGE_SHIFT);
+}
+
#endif /* _ASM_PAGE_H_ */
diff -r 0b3902dbe274 -r 4bfdcac4f67e sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
--- a/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h Sun Sep 13 09:15:02 2015 +0530
+++ b/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h Tue Sep 22 08:33:57 2015 +0530
@@ -45,9 +45,10 @@
#error DRM GEM/TTM need new MI bus_dma APIs! Halp!
#endif
-#include <x86/bus_private.h>
#include <x86/machdep.h>
+#include <machine/bus_private.h>
+
static inline int
bus_dmamem_wire_uvm_object(bus_dma_tag_t tag, struct uvm_object *uobj,
off_t start, bus_size_t size, struct pglist *pages, bus_size_t alignment,
@@ -90,7 +91,7 @@
error = EFBIG;
goto fail1;
}
- segs[i].ds_addr = VM_PAGE_TO_PHYS(page);
+ segs[i].ds_addr = _BUS_VM_PAGE_TO_BUS(page);
segs[i].ds_len = MIN(PAGE_SIZE, size);
size -= PAGE_SIZE;
page = TAILQ_NEXT(page, pageq.queue);
@@ -116,7 +117,12 @@
static inline int
bus_dmamem_pgfl(bus_dma_tag_t tag)
{
+#ifndef XEN
return x86_select_freelist(tag->_bounce_alloc_hi - 1);
+#else
+ /* XXX: Needs more XEN support */
+ return VM_FREELIST_DEFAULT;
+#endif
}
static inline int
@@ -148,7 +154,7 @@
seg = 0;
TAILQ_FOREACH(page, pglist, pageq.queue) {
- segs[seg].ds_addr = VM_PAGE_TO_PHYS(page);
+ segs[seg].ds_addr = _BUS_VM_PAGE_TO_BUS(page);
segs[seg].ds_len = PAGE_SIZE;
seg++;
}
Home |
Main Index |
Thread Index |
Old Index