summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2019-01-10 01:20:02 +0000
committerjsg <jsg@openbsd.org>2019-01-10 01:20:02 +0000
commit09b4a5bba6e951eece8b1a3e1c37417f9656e0c4 (patch)
treec377bb7b1c25bad11b9eda6e636119936579d850
parentadd efifb_stolen() to get the size of the efifb framebuffer (diff)
downloadwireguard-openbsd-09b4a5bba6e951eece8b1a3e1c37417f9656e0c4.tar.xz
wireguard-openbsd-09b4a5bba6e951eece8b1a3e1c37417f9656e0c4.zip
Use efifb_stolen() to prevent radeondrm from using aperture memory
overlapping the framebuffer. Prompted by ring tests failing. Diagnosed, fix suggested by and ok kettenis@
-rw-r--r--sys/dev/pci/drm/radeon/radeon_ttm.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/dev/pci/drm/radeon/radeon_ttm.c b/sys/dev/pci/drm/radeon/radeon_ttm.c
index 0ce9fed2931..faf9f8310e8 100644
--- a/sys/dev/pci/drm/radeon/radeon_ttm.c
+++ b/sys/dev/pci/drm/radeon/radeon_ttm.c
@@ -39,6 +39,14 @@
#include "radeon_reg.h"
#include "radeon.h"
+#ifdef __amd64__
+#include "efifb.h"
+#endif
+
+#if NEFIFB > 0
+#include <machine/efifbvar.h>
+#endif
+
#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
static int radeon_ttm_debugfs_init(struct radeon_device *rdev);
@@ -923,6 +931,13 @@ static struct ttm_bo_driver radeon_bo_driver = {
int radeon_ttm_init(struct radeon_device *rdev)
{
int r;
+ unsigned long stolen_size = 0;
+
+#if NEFIFB > 0
+ stolen_size = efifb_stolen();
+#endif
+ if (stolen_size == 0)
+ stolen_size = 256 * 1024;
r = radeon_ttm_global_init(rdev);
if (r) {
@@ -966,7 +981,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
RADEON_GEM_DOMAIN_VRAM, 0, NULL,
NULL, &rdev->stollen_vga_memory);
#else
- r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true,
+ r = radeon_bo_create(rdev, stolen_size, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_VRAM, 0, NULL,
NULL, &rdev->stollen_vga_memory);
#endif