From 292da616fe1f936ca78a3fa8e1b1b19883e343b6 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 9 Dec 2011 16:11:06 +1000 Subject: nouveau: pull in major libdrm rewrite Redesigned primarily to allow us to better take advantage of BO's having fixed GPU virtual addresses on GeForce 8 and up, and to reduce the overhead of handling relocations on earlier chipsets. Signed-off-by: Ben Skeggs Signed-off-by: Christoph Bumiller --- nouveau/nouveau_grobj.c | 148 ------------------------------------------------ 1 file changed, 148 deletions(-) delete mode 100644 nouveau/nouveau_grobj.c (limited to 'nouveau/nouveau_grobj.c') diff --git a/nouveau/nouveau_grobj.c b/nouveau/nouveau_grobj.c deleted file mode 100644 index 36344b99..00000000 --- a/nouveau/nouveau_grobj.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2007 Nouveau Project - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#include "nouveau_private.h" - -int -nouveau_grobj_alloc(struct nouveau_channel *chan, uint32_t handle, - int class, struct nouveau_grobj **grobj) -{ - struct nouveau_device_priv *nvdev = nouveau_device(chan->device); - struct nouveau_grobj_priv *nvgrobj; - struct drm_nouveau_grobj_alloc g; - int ret; - - if (!nvdev || !grobj || *grobj) - return -EINVAL; - - nvgrobj = calloc(1, sizeof(*nvgrobj)); - if (!nvgrobj) - return -ENOMEM; - nvgrobj->base.channel = chan; - nvgrobj->base.handle = handle; - nvgrobj->base.grclass = class; - nvgrobj->base.bound = NOUVEAU_GROBJ_UNBOUND; - nvgrobj->base.subc = -1; - - g.channel = chan->id; - g.handle = handle; - g.class = class; - ret = drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GROBJ_ALLOC, - &g, sizeof(g)); - if (ret) { - nouveau_grobj_free((void *)&nvgrobj); - return ret; - } - - *grobj = &nvgrobj->base; - return 0; -} - -int -nouveau_grobj_ref(struct nouveau_channel *chan, uint32_t handle, - struct nouveau_grobj **grobj) -{ - struct nouveau_grobj_priv *nvgrobj; - - if (!chan || !grobj || *grobj) - return -EINVAL; - - nvgrobj = calloc(1, sizeof(struct nouveau_grobj_priv)); - if (!nvgrobj) - return -ENOMEM; - nvgrobj->base.channel = chan; - nvgrobj->base.handle = handle; - nvgrobj->base.grclass = 0; - - *grobj = &nvgrobj->base; - return 0; -} - -void -nouveau_grobj_free(struct nouveau_grobj **grobj) -{ - struct nouveau_device_priv *nvdev; - struct nouveau_channel_priv *chan; - struct nouveau_grobj_priv *nvgrobj; - - if (!grobj || !*grobj) - return; - nvgrobj = nouveau_grobj(*grobj); - *grobj = NULL; - - - chan = nouveau_channel(nvgrobj->base.channel); - nvdev = nouveau_device(chan->base.device); - - if (nvgrobj->base.grclass) { - struct drm_nouveau_gpuobj_free f; - - FIRE_RING(&chan->base); - f.channel = chan->drm.channel; - f.handle = nvgrobj->base.handle; - drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GPUOBJ_FREE, - &f, sizeof(f)); - } - if (nvgrobj->base.bound != NOUVEAU_GROBJ_UNBOUND) - chan->base.subc[nvgrobj->base.subc].gr = NULL; - free(nvgrobj); -} - -void -nouveau_grobj_autobind(struct nouveau_grobj *grobj) -{ - struct nouveau_channel *chan = grobj->channel; - struct nouveau_subchannel *subc = NULL; - int i; - - for (i = 0; i < 8; i++) { - struct nouveau_subchannel *scc = &grobj->channel->subc[i]; - - if (scc->gr && scc->gr->bound == NOUVEAU_GROBJ_BOUND_EXPLICIT) - continue; - - if (!subc || scc->sequence < subc->sequence) - subc = scc; - } - - if (subc->gr) { - subc->gr->bound = NOUVEAU_GROBJ_UNBOUND; - subc->gr->subc = -1; - } - - subc->gr = grobj; - subc->gr->bound = NOUVEAU_GROBJ_BOUND; - subc->gr->subc = subc - &grobj->channel->subc[0]; - - WAIT_RING(chan, 2); - if (chan->device->chipset < 0xc0) { - OUT_RING (chan, (1 << 18) | (grobj->subc << 13)); - OUT_RING (chan, grobj->handle); - } else { - OUT_RING (chan, (2 << 28) | (1 << 16) | (grobj->subc << 13)); - OUT_RING (chan, grobj->grclass); - } -} - -- cgit v1.2.3