Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/drm Add support for DRM GEM/CM...
details: https://anonhg.NetBSD.org/src/rev/69186fce13d9
branches: trunk
changeset: 966591:69186fce13d9
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Nov 05 23:29:28 2019 +0000
description:
Add support for DRM GEM/CMA helpers using a driver provided vmem arena.
diffstat:
sys/external/bsd/drm2/dist/include/drm/drmP.h | 3 +-
sys/external/bsd/drm2/dist/include/drm/drm_gem_cma_helper.h | 4 +-
sys/external/bsd/drm2/drm/drm_gem_cma_helper.c | 34 +++++++++++-
sys/external/bsd/drm2/include/drm/drm_os_netbsd.h | 4 +-
4 files changed, 37 insertions(+), 8 deletions(-)
diffs (123 lines):
diff -r 5f34017a4615 -r 69186fce13d9 sys/external/bsd/drm2/dist/include/drm/drmP.h
--- a/sys/external/bsd/drm2/dist/include/drm/drmP.h Tue Nov 05 23:27:23 2019 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drmP.h Tue Nov 05 23:29:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drmP.h,v 1.35 2018/12/21 07:51:18 maya Exp $ */
+/* $NetBSD: drmP.h,v 1.36 2019/11/05 23:29:28 jmcneill Exp $ */
/*
* Internal Header for the Direct Rendering Manager
@@ -931,6 +931,7 @@
bool dmat_subregion_p;
bus_addr_t dmat_subregion_min;
bus_addr_t dmat_subregion_max;
+ vmem_t *cma_pool;
#endif
struct drm_sg_mem *sg; /**< Scatter gather memory */
diff -r 5f34017a4615 -r 69186fce13d9 sys/external/bsd/drm2/dist/include/drm/drm_gem_cma_helper.h
--- a/sys/external/bsd/drm2/dist/include/drm/drm_gem_cma_helper.h Tue Nov 05 23:27:23 2019 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/drm_gem_cma_helper.h Tue Nov 05 23:29:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_gem_cma_helper.h,v 1.5 2018/08/27 15:26:15 riastradh Exp $ */
+/* $NetBSD: drm_gem_cma_helper.h,v 1.6 2019/11/05 23:29:28 jmcneill Exp $ */
#ifndef __DRM_GEM_CMA_HELPER_H__
#define __DRM_GEM_CMA_HELPER_H__
@@ -20,6 +20,8 @@
bus_dma_segment_t dmasegs[1];
bus_size_t dmasize;
bus_dmamap_t dmamap;
+ vmem_t *vmem_pool;
+ vmem_addr_t vmem_addr;
#else
dma_addr_t paddr;
#endif
diff -r 5f34017a4615 -r 69186fce13d9 sys/external/bsd/drm2/drm/drm_gem_cma_helper.c
--- a/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c Tue Nov 05 23:27:23 2019 +0000
+++ b/sys/external/bsd/drm2/drm/drm_gem_cma_helper.c Tue Nov 05 23:29:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_gem_cma_helper.c,v 1.8 2019/11/05 09:59:16 jmcneill Exp $ */
+/* $NetBSD: drm_gem_cma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,10 +27,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.8 2019/11/05 09:59:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem_cma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $");
#include <drm/drmP.h>
#include <drm/drm_gem_cma_helper.h>
+#include <drm/bus_dma_hacks.h>
#include <uvm/uvm.h>
@@ -49,8 +50,24 @@
error = -drm_prime_sg_to_bus_dmamem(obj->dmat, obj->dmasegs, 1,
&nsegs, sgt);
} else {
- error = bus_dmamem_alloc(obj->dmat, obj->dmasize, PAGE_SIZE, 0,
- obj->dmasegs, 1, &nsegs, BUS_DMA_WAITOK);
+ if (ddev->cma_pool != NULL) {
+ error = vmem_xalloc(ddev->cma_pool, obj->dmasize,
+ PAGE_SIZE, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
+ VM_BESTFIT | VM_NOSLEEP, &obj->vmem_addr);
+ if (!error) {
+ obj->vmem_pool = ddev->cma_pool;
+ obj->dmasegs[0].ds_addr =
+ PHYS_TO_BUS_MEM(obj->dmat, obj->vmem_addr);
+ obj->dmasegs[0].ds_len =
+ roundup(obj->dmasize, PAGE_SIZE);
+ nsegs = 1;
+ }
+ }
+ if (obj->vmem_pool == NULL) {
+ error = bus_dmamem_alloc(obj->dmat, obj->dmasize,
+ PAGE_SIZE, 0, obj->dmasegs, 1, &nsegs,
+ BUS_DMA_WAITOK);
+ }
}
if (error)
goto failed;
@@ -80,7 +97,12 @@
unmap:
bus_dmamem_unmap(obj->dmat, obj->vaddr, obj->dmasize);
free:
- bus_dmamem_free(obj->dmat, obj->dmasegs, nsegs);
+ if (obj->sgt)
+ drm_prime_sg_free(obj->sgt);
+ else if (obj->vmem_pool)
+ vmem_xfree(obj->vmem_pool, obj->vmem_addr, obj->dmasize);
+ else
+ bus_dmamem_free(obj->dmat, obj->dmasegs, nsegs);
failed:
kmem_free(obj, sizeof(*obj));
@@ -103,6 +125,8 @@
bus_dmamem_unmap(obj->dmat, obj->vaddr, obj->dmasize);
if (obj->sgt)
drm_prime_sg_free(obj->sgt);
+ else if (obj->vmem_pool)
+ vmem_xfree(obj->vmem_pool, obj->vmem_addr, obj->dmasize);
else
bus_dmamem_free(obj->dmat, obj->dmasegs, 1);
kmem_free(obj, sizeof(*obj));
diff -r 5f34017a4615 -r 69186fce13d9 sys/external/bsd/drm2/include/drm/drm_os_netbsd.h
--- a/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h Tue Nov 05 23:27:23 2019 +0000
+++ b/sys/external/bsd/drm2/include/drm/drm_os_netbsd.h Tue Nov 05 23:29:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_os_netbsd.h,v 1.14 2019/04/07 20:28:41 maya Exp $ */
+/* $NetBSD: drm_os_netbsd.h,v 1.15 2019/11/05 23:29:28 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -72,4 +72,6 @@
#include <drm/drm_irq_netbsd.h>
#include <drm/drm_wait_netbsd.h>
+#include <sys/vmem.h>
+
#endif /* _DRM_DRM_OS_NETBSD_H_ */
Home |
Main Index |
Thread Index |
Old Index