Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5 from polachok/new

Mostly FreeBSD fixes
  • Loading branch information...
commit 05fc1a32334e560fe52bfc2d73290952465f4b50 2 parents d0bdb2f + 8a59ccb
@cbergstrom cbergstrom authored
View
10 libpscnv/BSDmakefile
@@ -0,0 +1,10 @@
+CFLAGS+=-I/usr/X11R6/include -I/usr/local/include/libdrm -I../pscnv
+
+all: libpscnv.a
+
+libpscnv.a: libpscnv.o libpscnv_ib.o
+ ar cru $@ $>
+ ranlib $@
+
+clean:
+ rm -f *.o *.a
View
8 pscnv/BSDmakefile
@@ -7,4 +7,10 @@ SRCS=$(HEADERS) $(C_SRCS) bus_if.h device_if.h pci_if.h opt_drm.h vnode_if.h iic
.include <bsd.kmod.mk>
-CFLAGS+=-std=gnu99 -Wno-format -Wno-pointer-arith -I$(SYSDIR)/dev/drm # -I$(SYSDIR)/ofed/include
+CFLAGS+=-std=gnu99 -Wno-format -Wno-pointer-arith -I@/dev/drm2 \
+ -DPSCNV_KAPI_DRM_CONNECTOR_DETECT_2 \
+ -DPSCNV_KAPI_DRM_MODE_FB_CMD2 \
+ -DPSCNV_KAPI_GAMMA_SET_6 \
+ -DINVARIANTS \
+ -Ipreassembled
+# -I$(SYSDIR)/ofed/include
View
1  pscnv/drm_encoder_slave_proto.h
@@ -28,6 +28,7 @@
#define __DRM_ENCODER_SLAVE_H__
#include "drmP.h"
+#include "drm_mode.h"
#include "drm_crtc.h"
/**
View
78 pscnv/nouveau_bsddrv.c
@@ -155,7 +155,7 @@ pscnv_attach(device_t kdev)
if (nouveau_modeset == 1)
driver.driver_features |= DRIVER_MODESET;
dev->driver = &driver;
- drm_sleep_locking_init(dev);
+ /* drm_sleep_locking_init(dev); XXX PLHK */
return (drm_attach(kdev, pciidlist));
}
@@ -200,7 +200,7 @@ static driver_t pscnv_driver = {
extern devclass_t drm_devclass;
DRIVER_MODULE_ORDERED(pscnv, vgapci, pscnv_driver, drm_devclass, 0, 0,
SI_ORDER_ANY);
-MODULE_DEPEND(pscnv, drm, 1, 1, 1);
+MODULE_DEPEND(pscnv, drmn, 1, 1, 1);
MODULE_DEPEND(pscnv, agp, 1, 1, 1);
MODULE_DEPEND(pscnv, iicbus, 1, 1, 1);
MODULE_DEPEND(pscnv, iic, 1, 1, 1);
@@ -233,21 +233,15 @@ pscnv_gem_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot,
int ret;
*color = 0; /* ...? */
- if (!bo->fake_pages) {
- bo->fake_pages = kzalloc(OFF_TO_IDX(bo->size) * sizeof(*bo->fake_pages), GFP_KERNEL);
- if (!bo->fake_pages)
- return (ENOMEM);
- }
-
if (!bo->chan && !bo->dmapages && (ret = -dev_priv->vm->map_user(bo)))
return (ret);
if (bo->chan)
pscnv_chan_ref(bo->chan);
- else
+ /* else */
drm_gem_object_reference(gem_obj);
- NV_WARN(dev, "Mapping %p\n", bo);
+ NV_WARN(dev, "Mapping bo %p, handle %p, chan %p\n", bo, handle, bo->chan);
return (0);
}
@@ -260,6 +254,7 @@ pscnv_gem_pager_fault(vm_object_t vm_obj, vm_ooffset_t offset, int prot,
struct drm_device *dev = gem_obj->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
vm_page_t m = NULL;
+ vm_page_t oldm;
vm_memattr_t mattr;
vm_paddr_t paddr;
const char *what;
@@ -291,27 +286,51 @@ pscnv_gem_pager_fault(vm_object_t vm_obj, vm_ooffset_t offset, int prot,
bo, offset, what, bo->size);
return (VM_PAGER_ERROR);
}
+ DRM_LOCK(dev);
if (pscnv_mem_debug > 0)
NV_WARN(dev, "Connecting %p+%08llx (%s) at phys %010llx\n",
bo, offset, what, paddr);
+ vm_object_pip_add(vm_obj, 1);
+
+ if (*mres != NULL) {
+ oldm = *mres;
+ vm_page_lock(oldm);
+ vm_page_remove(oldm);
+ vm_page_unlock(oldm);
+ *mres = NULL;
+ } else
+ oldm = NULL;
+ //VM_OBJECT_LOCK(vm_obj);
+ m = vm_phys_fictitious_to_vm_page(paddr);
+ if (m == NULL) {
+ DRM_UNLOCK(dev);
+ return -EFAULT;
+ }
+ KASSERT((m->flags & PG_FICTITIOUS) != 0,
+ ("not fictitious %p", m));
+ KASSERT(m->wire_count == 1, ("wire_count not 1 %p", m));
- m = &bo->fake_pages[OFF_TO_IDX(offset)];
- /*
- * Replace the passed in reqpage page with our own fake page and
- * free up the all of the original pages.
- */
- if (*mres)
- vm_page_putfake(*mres);
- *mres = m;
-
- vm_page_initfake(m, paddr, mattr);
- pmap_page_init(m);
- m->oflags &= ~(VPO_BUSY | VPO_UNMANAGED);
+ if ((m->flags & VPO_BUSY) != 0) {
+ DRM_UNLOCK(dev);
+ return -EFAULT;
+ }
+ pmap_page_set_memattr(m, mattr);
m->valid = VM_PAGE_BITS_ALL;
+ *mres = m;
vm_page_lock(m);
vm_page_insert(m, vm_obj, OFF_TO_IDX(offset));
vm_page_unlock(m);
vm_page_busy(m);
+
+ printf("fault %p %jx %x phys %x", gem_obj, offset, prot,
+ m->phys_addr);
+ DRM_UNLOCK(dev);
+ if (oldm != NULL) {
+ vm_page_lock(oldm);
+ vm_page_free(oldm);
+ vm_page_unlock(oldm);
+ }
+ vm_object_pip_wakeup(vm_obj);
return (VM_PAGER_OK);
}
@@ -321,7 +340,10 @@ pscnv_gem_pager_dtor(void *handle)
struct drm_gem_object *gem_obj = handle;
struct pscnv_bo *bo = gem_obj->driver_private;
struct drm_device *dev = gem_obj->dev;
- vm_object_t devobj = cdev_pager_lookup(handle);
+ vm_object_t devobj;
+
+ DRM_LOCK(dev);
+ devobj = cdev_pager_lookup(handle);
if (devobj != NULL) {
vm_size_t page_count = OFF_TO_IDX(bo->size);
@@ -339,16 +361,20 @@ pscnv_gem_pager_dtor(void *handle)
VM_OBJECT_UNLOCK(devobj);
vm_object_deallocate(devobj);
}
- else
- NV_ERROR(dev, "Could not find handle %p\n", handle);
+ else {
+ DRM_UNLOCK(dev);
+ NV_ERROR(dev, "Could not find handle %p bo %p\n", handle, bo);
+ return;
+ }
if (pscnv_mem_debug > 0)
NV_WARN(dev, "Freed %010llx (%p)\n", bo->start, bo);
- kfree(bo->fake_pages);
+ //kfree(bo->fake_pages);
if (bo->chan)
pscnv_chan_unref(bo->chan);
else
drm_gem_object_unreference_unlocked(gem_obj);
+ DRM_UNLOCK(dev);
}
static struct cdev_pager_ops pscnv_gem_pager_ops = {
View
4 pscnv/nouveau_fbcon.c
@@ -264,7 +264,7 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
info->par = nfbdev;
#else
- DRM_LOCK();
+ DRM_LOCK(dev);
#endif // __linux__
nouveau_framebuffer_init(dev, &nfbdev->nouveau_fb, &mode_cmd, nvbo);
@@ -322,7 +322,7 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
mutex_unlock(&dev->struct_mutex);
#else // __linux__
- DRM_UNLOCK();
+ DRM_UNLOCK(dev);
#endif
#if 0
if (dev_priv->channel && !nouveau_nofbaccel) {
View
15 pscnv/nouveau_state.c
@@ -383,9 +383,9 @@ nouveau_card_init(struct drm_device *dev)
ret = drm_irq_install(dev);
#else
// SIGH
- DRM_UNLOCK();
+ DRM_UNLOCK(dev);
ret = drm_irq_install(dev);
- DRM_LOCK();
+ DRM_LOCK(dev);
#endif
if (ret)
goto out_display;
@@ -414,9 +414,9 @@ nouveau_card_init(struct drm_device *dev)
nouveau_fbcon_init(dev);
#else
// SIGH
- DRM_UNLOCK();
+ DRM_UNLOCK(dev);
nouveau_fbcon_init(dev);
- DRM_LOCK();
+ DRM_LOCK(dev);
#endif
drm_kms_helper_poll_init(dev);
}
@@ -508,6 +508,7 @@ static void nouveau_card_takedown(struct drm_device *dev)
* file_priv */
void nouveau_preclose(struct drm_device *dev, struct drm_file *file_priv)
{
+ DRM_LOCK_ASSERT(dev);
pscnv_chan_cleanup(dev, file_priv);
pscnv_vspace_cleanup(dev, file_priv);
}
@@ -750,6 +751,12 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
if (ret)
return ret;
}
+ device_printf(dev->device,
+ "taking over the fictitious range 0x%lx-0x%lx...",
+ dev_priv->fb_phys, dev_priv->fb_phys + dev_priv->fb_size);
+ if ((ret = -vm_phys_fictitious_reg_range(dev_priv->fb_phys, dev_priv->fb_phys + dev_priv->fb_size, 0 /* PLHK FIXME */)))
+ return (ret);
+ device_printf(dev->device, "OK\n");
return 0;
}
View
1  pscnv/nv50_chan.c
@@ -146,6 +146,7 @@ static void nv50_chan_free(struct pscnv_chan *ch) {
ch->handle = 0;
spin_unlock_irqrestore(&dev_priv->chan->ch_lock, flags);
pscnv_mem_free(ch->bo);
+ ch->bo = NULL;
if (ch->cache)
pscnv_mem_free(ch->cache);
mutex_lock(&ch->vspace->lock);
View
1  pscnv/nvc0_chan.c
@@ -45,6 +45,7 @@ static void nvc0_chan_free(struct pscnv_chan *ch)
ch->handle = 0;
spin_unlock_irqrestore(&dev_priv->chan->ch_lock, flags);
pscnv_mem_free(ch->bo);
+ ch->bo = NULL;
}
static void
View
2  pscnv/pscnv_chan.c
@@ -127,7 +127,7 @@ void pscnv_chan_ref_free(struct kref *ref) {
}
dev_priv->chan->do_chan_free(ch);
pscnv_chan_unbind(ch);
- if (ch->bo->gem)
+ if (ch->bo && ch->bo->gem)
drm_gem_object_unreference_unlocked(ch->bo->gem);
if (ch->vspace)
pscnv_vspace_unref(ch->vspace);
View
2  pscnv/pscnv_ioctl.c
@@ -122,7 +122,7 @@ int pscnv_ioctl_gem_new(struct drm_device *dev, void *data,
ret = drm_gem_handle_create(file_priv, obj, &info->handle);
if (pscnv_gem_debug >= 1)
- NV_INFO(dev, "GEM handle %x is VO %x/%d\n", info->handle, bo->cookie, bo->serial);
+ NV_INFO(dev, "GEM handle %x (obj handle %p) is VO %x/%d\n", info->handle, bo->gem, bo->cookie, bo->serial);
#ifdef __linux__
info->map_handle = (uint64_t)info->handle << 32;
View
4 pscnv/pscnv_mem.c
@@ -156,8 +156,8 @@ pscnv_mem_free(struct pscnv_bo *bo)
{
struct drm_nouveau_private *dev_priv = bo->dev->dev_private;
if (pscnv_mem_debug >= 1)
- NV_INFO(bo->dev, "Freeing %d, %#llx-byte %sBO of type %08x, tile_flags %x\n", bo->serial, bo->size,
- (bo->flags & PSCNV_GEM_CONTIG ? "contig " : ""), bo->cookie, bo->tile_flags);
+ NV_INFO(bo->dev, "Freeing %d, %#llx-byte %sBO(%p) of type %08x, tile_flags %x\n", bo->serial, bo->size,
+ (bo->flags & PSCNV_GEM_CONTIG ? "contig " : ""), bo, bo->cookie, bo->tile_flags);
if (dev_priv->vm_ok && bo->map1)
pscnv_vspace_unmap_node(bo->map1);
View
4 pscnv/pscnv_mem.h
@@ -58,10 +58,6 @@ struct pscnv_bo {
dma_addr_t *dmapages;
/* CHAN only, pointer to a channel (FreeBSD doesn't allow overriding mmap) */
struct pscnv_chan *chan;
-#ifndef __linux__
- /* freebsd: Allocate an array of fake pages we can populate if user-space mappable */
- vm_page_t fake_pages;
-#endif
};
#define PSCNV_GEM_NOUSER 0x10
View
3  pscnv/pscnv_vm.c
@@ -101,7 +101,8 @@ pscnv_vspace_new (struct drm_device *dev, uint64_t size, uint32_t flags, int fak
static void
pscnv_vspace_free_unmap(struct pscnv_mm_node *node) {
struct pscnv_bo *bo = node->tag;
- drm_gem_object_unreference_unlocked(bo->gem);
+ DRM_LOCK_ASSERT(bo->dev);
+ drm_gem_object_unreference(bo->gem);
pscnv_mm_free(node);
}
View
46 test/BSDmakefile
@@ -0,0 +1,46 @@
+CPPFLAGS+=-I/usr/X11R6/include -I/usr/local/include/libdrm -I../libpscnv
+LDFLAGS+=-ldrm -L/usr/X11R6/lib -L/usr/local/lib
+LDADD=../libpscnv/libpscnv.a
+CFLAGS+=${CPPFLAGS}
+
+PROGS = get_param gem map m2mf loop subc0 ib mem_test 902d
+all: ../libpscnv/libpscnv.a ${PROGS}
+
+get_param: get_param.c
+ ${CC} ${CFLAGS} -c $<
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+gem: gem.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+map: map.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+m2mf: m2mf.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+loop: loop.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+subc0: subc0.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+ib: ib.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+mem_test: mem_test.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+902d: 902d.c
+ ${CC} ${CFLAGS} -c $< -o $@.o
+ ${CC} ${LDFLAGS} $@.o ${LDADD} -o $@
+
+clean:
+ rm -f $(PROGS)
Please sign in to comment.
Something went wrong with that request. Please try again.