From 3cc41ffd63552134bd3ae99501665db127d07bdd Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 20 Aug 2018 19:33:31 +0000 Subject: [PATCH] Add arm64 support. On ARM write-combining translates into the normal uncached memory attribute and uncached translates into device-nGnRnE memory. This complicates the mapping onto PMAP_WC, PMAP_NOCACHE and PMAP_DEVICE a bit since the requirements of the drm(4) subsystem don't quite match the natural definitions for these. ok jsg@, mpi@, visa@ --- sys/dev/pci/drm/drm_linux.h | 22 +++++++++++++++++++++- sys/dev/pci/drm/ttm/ttm_bo_util.c | 9 +++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h index 40f0da1f614..ba24e5faa83 100644 --- a/sys/dev/pci/drm/drm_linux.h +++ b/sys/dev/pci/drm/drm_linux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.h,v 1.90 2018/07/27 21:11:31 kettenis Exp $ */ +/* $OpenBSD: drm_linux.h,v 1.91 2018/08/20 19:33:31 kettenis Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2017 Martin Pieuchot @@ -2120,6 +2120,26 @@ typedef int pgprot_t; #define pgprot_val(v) (v) #define PAGE_KERNEL 0 +static inline pgprot_t +pgprot_writecombine(pgprot_t prot) +{ +#ifdef PMAP_WC + return prot | PMAP_WC; +#else + return prot | PMAP_NOCACHE; +#endif +} + +static inline pgprot_t +pgprot_noncached(pgprot_t prot) +{ +#ifdef PMAP_DEVICE + return prot | PMAP_DEVICE; +#else + return prot | PMAP_NOCACHE; +#endif +} + void *kmap(struct vm_page *); void kunmap(void *addr); void *vmap(struct vm_page **, unsigned int, unsigned long, pgprot_t); diff --git a/sys/dev/pci/drm/ttm/ttm_bo_util.c b/sys/dev/pci/drm/ttm/ttm_bo_util.c index 13f408af6df..b065bba5b3e 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo_util.c +++ b/sys/dev/pci/drm/ttm/ttm_bo_util.c @@ -517,12 +517,13 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp) /* Cached mappings need no adjustment */ if (caching_flags & TTM_PL_FLAG_CACHED) return tmp; -#ifdef PMAP_WC + if (caching_flags & TTM_PL_FLAG_WC) - return PMAP_WC; + tmp = pgprot_writecombine(tmp); else -#endif - return PMAP_NOCACHE; + tmp = pgprot_noncached(tmp); + + return tmp; } static int ttm_bo_ioremap(struct ttm_buffer_object *bo, -- 2.20.1