Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/sunxi Make sure memory stolen from simplefb is ...
details: https://anonhg.NetBSD.org/src/rev/b07f19f521da
branches: trunk
changeset: 1005670:b07f19f521da
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Dec 16 12:40:17 2019 +0000
description:
Make sure memory stolen from simplefb is page aligned.
diffstat:
sys/arch/arm/sunxi/sunxi_drm.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diffs (60 lines):
diff -r 169f0577402d -r b07f19f521da sys/arch/arm/sunxi/sunxi_drm.c
--- a/sys/arch/arm/sunxi/sunxi_drm.c Mon Dec 16 11:00:30 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_drm.c Mon Dec 16 12:40:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.10 2019/12/15 01:00:58 mrg Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.11 2019/12/16 12:40:17 jmcneill Exp $ */
/*-
* Copyright (c) 2019 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.10 2019/12/15 01:00:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.11 2019/12/16 12:40:17 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -53,6 +53,14 @@
#define SUNXI_DRM_MAX_WIDTH 3840
#define SUNXI_DRM_MAX_HEIGHT 2160
+/*
+ * The DRM headers break trunc_page/round_page macros with a redefinition
+ * of PAGE_MASK. Use our own macros instead.
+ */
+#define SUNXI_PAGE_MASK (PAGE_SIZE - 1)
+#define SUNXI_TRUNC_PAGE(x) ((x) & ~SUNXI_PAGE_MASK)
+#define SUNXI_ROUND_PAGE(x) (((x) + SUNXI_PAGE_MASK) & ~SUNXI_PAGE_MASK)
+
static TAILQ_HEAD(, sunxi_drm_endpoint) sunxi_drm_endpoints =
TAILQ_HEAD_INITIALIZER(sunxi_drm_endpoints);
@@ -299,7 +307,8 @@
sunxi_drm_simplefb_lookup(bus_addr_t *paddr, bus_size_t *psize)
{
static const char * compat[] = { "simple-framebuffer", NULL };
- int chosen, child;
+ int chosen, child, error;
+ bus_addr_t addr_end;
chosen = OF_finddevice("/chosen");
if (chosen == -1)
@@ -310,7 +319,15 @@
continue;
if (!of_match_compatible(child, compat))
continue;
- return fdtbus_get_reg(child, 0, paddr, psize);
+ error = fdtbus_get_reg(child, 0, paddr, psize);
+ if (error != 0)
+ return error;
+
+ /* Reclaim entire pages used by the simplefb */
+ addr_end = *paddr + *psize;
+ *paddr = SUNXI_TRUNC_PAGE(*paddr);
+ *psize = SUNXI_ROUND_PAGE(addr_end - *paddr);
+ return 0;
}
return ENOENT;
Home |
Main Index |
Thread Index |
Old Index