summaryrefslogtreecommitdiffstats
path: root/sys/dev/drm/drm_memory.c
diff options
context:
space:
mode:
authorrnoland <rnoland@FreeBSD.org>2008-10-03 16:59:11 +0000
committerrnoland <rnoland@FreeBSD.org>2008-10-03 16:59:11 +0000
commitbbc754f502e8dc966e5d05fc4fd4d91d4c136d83 (patch)
tree2d4185c3ec896efd0d1b2735041e6ddeb6a750f1 /sys/dev/drm/drm_memory.c
parentbbe0e181656adf606748968f5803bb8cbc7d83c8 (diff)
downloadFreeBSD-src-bbc754f502e8dc966e5d05fc4fd4d91d4c136d83.zip
FreeBSD-src-bbc754f502e8dc966e5d05fc4fd4d91d4c136d83.tar.gz
resync to git master
This reverts a private patch which is causing issues with many Intel chipsets. I will review that patch and see what we need to do to fix it up later, but for the time being, we will just get these chips working again. This update contains a lot of code cleanup and is post gem merge (no, we don't have gem support). It should prove much easier to read the code now. A lot of thanks goes to vehemens for that work. I have adapted the code to use cdevpriv for tracking per open file data. That alleviates the old ugly hack that we used to try and accomplish the task and helped to clean up the open / close behavior a good bit. This also replaces the hack that was put in place a year or so ago to prevent radeons from locking up with AIGLX enabled. I have had a couple of radeon testers report that it still works as expected, though I no longer have radeon hardware to test with myself. Other various fixes from the linux crew and Intel, many of which are muddled in with the gem merge. Approved by: jhb (mentor) Obtained from: mesa/drm git master MFC after: 2 weeks
Diffstat (limited to 'sys/dev/drm/drm_memory.c')
-rw-r--r--sys/dev/drm/drm_memory.c50
1 files changed, 6 insertions, 44 deletions
diff --git a/sys/dev/drm/drm_memory.c b/sys/dev/drm/drm_memory.c
index 461d9fd..8df769f 100644
--- a/sys/dev/drm/drm_memory.c
+++ b/sys/dev/drm/drm_memory.c
@@ -45,9 +45,6 @@ MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures");
void drm_mem_init(void)
{
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- malloc_type_attach(M_DRM);
-#endif
}
void drm_mem_uninit(void)
@@ -72,7 +69,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
if (pt == NULL)
return NULL;
if (oldpt && oldsize) {
- memcpy(pt, oldpt, oldsize);
+ memcpy(pt, oldpt, DRM_MIN(oldsize,size));
free(oldpt, M_DRM);
}
return pt;
@@ -83,29 +80,21 @@ void drm_free(void *pt, size_t size, int area)
free(pt, M_DRM);
}
+void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map)
+{
+ return pmap_mapdev_attr(map->offset, map->size, PAT_WRITE_COMBINING);
+}
+
void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map)
{
-#ifdef __FreeBSD__
return pmap_mapdev(map->offset, map->size);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
- map->bst = dev->pa.pa_memt;
- if (bus_space_map(map->bst, map->offset, map->size,
- BUS_SPACE_MAP_LINEAR, &map->bsh))
- return NULL;
- return bus_space_vaddr(map->bst, map->bsh);
-#endif
}
void drm_ioremapfree(drm_local_map_t *map)
{
-#ifdef __FreeBSD__
pmap_unmapdev((vm_offset_t) map->handle, map->size);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
- bus_space_unmap(map->bst, map->bsh, map->size);
-#endif
}
-#ifdef __FreeBSD__
int
drm_mtrr_add(unsigned long offset, size_t size, int flags)
{
@@ -133,30 +122,3 @@ drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner));
return mem_range_attr_set(&mrdesc, &act);
}
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
-int
-drm_mtrr_add(unsigned long offset, size_t size, int flags)
-{
- struct mtrr mtrrmap;
- int one = 1;
-
- mtrrmap.base = offset;
- mtrrmap.len = size;
- mtrrmap.type = flags;
- mtrrmap.flags = MTRR_VALID;
- return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-}
-
-int
-drm_mtrr_del(unsigned long offset, size_t size, int flags)
-{
- struct mtrr mtrrmap;
- int one = 1;
-
- mtrrmap.base = offset;
- mtrrmap.len = size;
- mtrrmap.type = flags;
- mtrrmap.flags = 0;
- return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-}
-#endif
OpenPOWER on IntegriCloud