drm_addmap():

- for _DRM_CONSISTENT mappings, keep the handle.
- use DRM_HANDLE_NEEDS_MASK()

drm_mapbufs():
- use DRM_HANDLE_NEEDS_MASK()

drm_mmap():
- use DRM_HANDLE_NEEDS_MASK()
- for _DRM_SCATTER_GATHER and _DRM_SHM, use vtophys() on the
  adjusted offset. XXX


this is gets radeon working on amd64 with an older PCI 9250 card.

XXX: need to excise vtophys() usage.
XXX: need to finish porting these fixes to external.
This commit is contained in:
mrg 2009-03-29 19:50:17 +00:00
parent 7216702ebd
commit ac009d4632
2 changed files with 16 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_bufs.c,v 1.10 2008/06/29 12:49:08 jmcneill Exp $ */
/* $NetBSD: drm_bufs.c,v 1.11 2009/03/29 19:50:17 mrg Exp $ */
/* drm_bufs.h -- Generic buffer template -*- linux-c -*-
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_bufs.c,v 1.10 2008/06/29 12:49:08 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_bufs.c,v 1.11 2009/03/29 19:50:17 mrg Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_bufs.c,v 1.3 2005/11/28 23:13:52 anholt Exp $");
*/
@ -206,6 +206,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
return DRM_ERR(EINVAL);
}
map->offset = map->offset + dev->sg->handle;
map->handle = (void *)(uintptr_t)map->offset;
break;
case _DRM_CONSISTENT:
/* Unfortunately, we don't get any alignment specification from
@ -274,10 +275,10 @@ int drm_addmap_ioctl(DRM_IOCTL_ARGS)
request.mtrr = map->mtrr;
request.handle = map->handle;
if (request.type != _DRM_SHM) {
request.handle = (void *)request.offset;
} else {
if (DRM_HANDLE_NEEDS_MASK(request.type)) {
request.handle = (void *)DRM_NETBSD_ADDR2HANDLE((uintptr_t)map->handle);
} else {
request.handle = (void *)request.offset;
}
DRM_COPY_TO_USER_IOCTL((drm_map_t *)data, request, sizeof(drm_map_t));
@ -1054,6 +1055,8 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
}
size = round_page(map->size);
foff = map->offset;
if (DRM_HANDLE_NEEDS_MASK(map->type))
foff = DRM_NETBSD_ADDR2HANDLE(foff);
} else {
size = round_page(dma->byte_count),
foff = 0;
@ -1062,7 +1065,7 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
vaddr = p->l_proc->p_emul->e_vm_default_addr(p->l_proc,
(vaddr_t)vms->vm_daddr, size);
rsize = round_page(size);
DRM_DEBUG("mmap %lx/%ld\n", vaddr, rsize);
DRM_DEBUG("mmap %#lx/%#lx foff %#llx\n", vaddr, rsize, (long long)foff);
retcode = uvm_mmap(&vms->vm_map, &vaddr, rsize,
UVM_PROT_READ | UVM_PROT_WRITE, UVM_PROT_ALL, MAP_SHARED,
&vn->v_uobj, foff, p->l_proc->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_vm.c,v 1.16 2009/03/07 05:46:09 mrg Exp $ */
/* $NetBSD: drm_vm.c,v 1.17 2009/03/29 19:50:17 mrg Exp $ */
/*-
* Copyright 2003 Eric Anholt
@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_vm.c,v 1.16 2009/03/07 05:46:09 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_vm.c,v 1.17 2009/03/29 19:50:17 mrg Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_vm.c,v 1.2 2005/11/28 23:13:53 anholt Exp $");
*/
@ -41,8 +41,9 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
drm_file_t *priv;
drm_map_type_t type;
paddr_t phys;
uintptr_t roffset;
off_t roffset;
DRM_DEBUG("dev %llx offset %llx prot %d\n", (long long)kdev, (long long)offset, prot);
DRM_LOCK();
priv = drm_find_file_by_proc(dev, DRM_CURPROC);
DRM_UNLOCK();
@ -85,7 +86,7 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
DRM_LOCK();
roffset = DRM_NETBSD_HANDLE2ADDR(offset);
TAILQ_FOREACH(map, &dev->maplist, link) {
if (map->type == _DRM_SHM) {
if (DRM_HANDLE_NEEDS_MASK(map->type)) {
if (roffset >= (uintptr_t)map->handle && roffset < (uintptr_t)map->handle + map->size)
break;
} else {
@ -117,16 +118,15 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
phys = vtophys((paddr_t)map->handle + (offset - map->offset));
break;
case _DRM_SCATTER_GATHER:
phys = vtophys(offset);
break;
case _DRM_SHM:
phys = vtophys(DRM_NETBSD_HANDLE2ADDR(offset));
phys = vtophys(roffset);
break;
default:
DRM_ERROR("bad map type %d\n", type);
return -1; /* This should never happen. */
}
DRM_DEBUG("going to return phys %lx\n", phys);
#ifdef macppc
return phys;
#else