Make the drm2 module depend on linuxkpi

Use linux memory allocation to reduce diff with upstream
This commit is contained in:
Baptiste Daroussin 2017-01-28 15:43:19 +00:00
parent f00e79c847
commit 2e8e6c3a4f
6 changed files with 14 additions and 13 deletions

View File

@ -35,6 +35,7 @@
__FBSDID("$FreeBSD$");
#include <dev/drm2/drmP.h>
#include <linux/slab.h>
#if __OS_HAS_AGP
@ -208,15 +209,13 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
if (!(entry = malloc(sizeof(*entry), DRM_MEM_AGPLISTS, M_NOWAIT)))
if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
return -ENOMEM;
memset(entry, 0, sizeof(*entry));
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request->type;
if (!(memory = agp_alloc_memory(dev->agp->bridge, type, pages << PAGE_SHIFT))) {
free(entry, DRM_MEM_AGPLISTS);
kfree(entry);
return -ENOMEM;
}
@ -376,7 +375,7 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
list_del(&entry->head);
drm_free_agp(entry->memory, entry->pages);
free(entry, DRM_MEM_AGPLISTS);
kfree(entry);
return 0;
}
EXPORT_SYMBOL(drm_agp_free);
@ -404,12 +403,11 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
{
struct drm_agp_head *head = NULL;
if (!(head = malloc(sizeof(*head), DRM_MEM_AGPLISTS, M_NOWAIT)))
if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
return NULL;
memset((void *)head, 0, sizeof(*head));
head->bridge = agp_find_device();
if (!head->bridge) {
free(head, DRM_MEM_AGPLISTS);
kfree(head);
return NULL;
} else {
agp_get_info(head->bridge, &head->agp_info);

View File

@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysent.h>
#include <linux/slab.h>
#include <dev/drm2/drmP.h>
#include <dev/drm2/drm_core.h>
#include <dev/drm2/drm_global.h>
@ -211,7 +212,7 @@ int drm_lastclose(struct drm_device * dev)
if (entry->bound)
drm_unbind_agp(entry->memory);
drm_free_agp(entry->memory, entry->pages);
free(entry, DRM_MEM_AGPLISTS);
kfree(entry);
}
INIT_LIST_HEAD(&dev->agp->memory);

View File

@ -24,7 +24,6 @@ MALLOC_DEFINE(DRM_MEM_QUEUES, "drm_queues", "DRM QUEUE Data Structures");
MALLOC_DEFINE(DRM_MEM_CMDS, "drm_cmds", "DRM COMMAND Data Structures");
MALLOC_DEFINE(DRM_MEM_MAPPINGS, "drm_mapping", "DRM MAPPING Data Structures");
MALLOC_DEFINE(DRM_MEM_BUFLISTS, "drm_buflists", "DRM BUFLISTS Data Structures");
MALLOC_DEFINE(DRM_MEM_AGPLISTS, "drm_agplists", "DRM AGPLISTS Data Structures");
MALLOC_DEFINE(DRM_MEM_CTXBITMAP, "drm_ctxbitmap",
"DRM CTXBITMAP Data Structures");
MALLOC_DEFINE(DRM_MEM_SGLISTS, "drm_sglists", "DRM SGLISTS Data Structures");
@ -496,4 +495,5 @@ MODULE_VERSION(drmn, 1);
MODULE_DEPEND(drmn, agp, 1, 1, 1);
MODULE_DEPEND(drmn, pci, 1, 1, 1);
MODULE_DEPEND(drmn, mem, 1, 1, 1);
MODULE_DEPEND(drmn, linuxkpi, 1, 1, 1);
MODULE_DEPEND(drmn, iicbus, 1, 1, 1);

View File

@ -552,7 +552,6 @@ MALLOC_DECLARE(DRM_MEM_QUEUES);
MALLOC_DECLARE(DRM_MEM_CMDS);
MALLOC_DECLARE(DRM_MEM_MAPPINGS);
MALLOC_DECLARE(DRM_MEM_BUFLISTS);
MALLOC_DECLARE(DRM_MEM_AGPLISTS);
MALLOC_DECLARE(DRM_MEM_CTXBITMAP);
MALLOC_DECLARE(DRM_MEM_SGLISTS);
MALLOC_DECLARE(DRM_MEM_MM);

View File

@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <dev/drm2/drmP.h>
#include <dev/drm2/drm_core.h>
#include <linux/slab.h>
#ifdef DRM_DEBUG_DEFAULT_ON
unsigned int drm_debug = (DRM_DEBUGBITS_DEBUG | DRM_DEBUGBITS_KMS |
@ -315,7 +316,7 @@ void drm_cancel_fill_in_dev(struct drm_device *dev)
DRM_MTRR_WC);
DRM_DEBUG("mtrr_del=%d\n", retval);
}
free(dev->agp, DRM_MEM_AGPLISTS);
kfree(dev->agp);
dev->agp = NULL;
drm_ht_remove(&dev->map_hash);
@ -467,7 +468,7 @@ void drm_put_dev(struct drm_device *dev)
drm_sysctl_cleanup(dev);
if (drm_core_has_AGP(dev) && dev->agp) {
free(dev->agp, DRM_MEM_AGPLISTS);
kfree(dev->agp);
dev->agp = NULL;
}

View File

@ -48,6 +48,8 @@ SRCS = \
ati_pcigart.c
#ttm_page_alloc_dma.c
CFLAGS+= -I${.CURDIR}/../../../compat/linuxkpi/common/include
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64"
SRCS += drm_ioc32.c
.endif