aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2009-05-26 14:14:04 +1000
committerBen Skeggs <bskeggs@redhat.com>2009-05-26 15:47:14 +1000
commitc65a343ed29c24f812ca919f40dfeee948b6f14a (patch)
tree5b63add0322f8ebff56a8c5d1483e4f2b84698db
parent85b9f737db0d2a845e4d7e2bbf9ad12ff9e2227c (diff)
nouveau: bump for 0.0.13
-rw-r--r--libdrm/nouveau/nouveau_bo.c123
-rw-r--r--libdrm/nouveau/nouveau_bo.h3
-rw-r--r--libdrm/nouveau/nouveau_device.c6
-rw-r--r--libdrm/nouveau/nouveau_device.h2
-rw-r--r--libdrm/nouveau/nouveau_drmif.h3
-rw-r--r--libdrm/nouveau/nouveau_private.h1
-rw-r--r--shared-core/nouveau_drm.h31
-rw-r--r--shared-core/nouveau_drv.h2
8 files changed, 111 insertions, 60 deletions
diff --git a/libdrm/nouveau/nouveau_bo.c b/libdrm/nouveau/nouveau_bo.c
index 66466e38..1bf6612f 100644
--- a/libdrm/nouveau/nouveau_bo.c
+++ b/libdrm/nouveau/nouveau_bo.c
@@ -42,6 +42,17 @@ nouveau_bo_takedown(struct nouveau_device *dev)
}
static int
+nouveau_bo_info(struct nouveau_bo_priv *nvbo, struct drm_nouveau_gem_info *arg)
+{
+ nvbo->handle = nvbo->base.handle = arg->handle;
+ nvbo->domain = arg->domain;
+ nvbo->size = nvbo->base.size = arg->size;
+ nvbo->offset = arg->offset;
+ nvbo->map_handle = arg->map_handle;
+ return 0;
+}
+
+static int
nouveau_bo_allocated(struct nouveau_bo_priv *nvbo)
{
if (nvbo->sysmem || nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN))
@@ -152,7 +163,8 @@ nouveau_bo_kalloc_nomm(struct nouveau_bo_priv *nvbo)
if (ret)
return ret;
- nvbo->handle = req.map_handle;
+ nvbo->handle =
+ nvbo->map_handle = req.map_handle;
nvbo->size = req.size;
nvbo->offset = req.offset;
if (req.flags & (NOUVEAU_MEM_AGP | NOUVEAU_MEM_PCI))
@@ -169,6 +181,7 @@ nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan)
{
struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device);
struct drm_nouveau_gem_new req;
+ struct drm_nouveau_gem_info *info = &req.info;
int ret;
if (nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN))
@@ -178,38 +191,36 @@ nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan)
return nouveau_bo_kalloc_nomm(nvbo);
req.channel_hint = chan ? chan->id : 0;
-
- req.size = nvbo->size;
req.align = nvbo->align;
- req.domain = 0;
- if (nvbo->flags & NOUVEAU_BO_VRAM)
- req.domain |= NOUVEAU_GEM_DOMAIN_VRAM;
+ info->size = nvbo->size;
+ info->domain = 0;
+ if (nvbo->flags & NOUVEAU_BO_VRAM)
+ info->domain |= NOUVEAU_GEM_DOMAIN_VRAM;
if (nvbo->flags & NOUVEAU_BO_GART)
- req.domain |= NOUVEAU_GEM_DOMAIN_GART;
+ info->domain |= NOUVEAU_GEM_DOMAIN_GART;
+ if (!info->domain) {
+ info->domain |= (NOUVEAU_GEM_DOMAIN_VRAM |
+ NOUVEAU_GEM_DOMAIN_GART);
+ }
if (nvbo->flags & NOUVEAU_BO_TILED) {
- req.domain |= NOUVEAU_GEM_DOMAIN_TILE;
+ info->domain |= NOUVEAU_GEM_DOMAIN_TILE;
if (nvbo->flags & NOUVEAU_BO_ZTILE)
- req.domain |= NOUVEAU_GEM_DOMAIN_TILE_ZETA;
+ info->domain |= NOUVEAU_GEM_DOMAIN_TILE_ZETA;
}
- if (!req.domain) {
- req.domain |= (NOUVEAU_GEM_DOMAIN_VRAM |
- NOUVEAU_GEM_DOMAIN_GART);
- }
+ if (nvbo->flags & NOUVEAU_BO_MAP)
+ info->domain |= NOUVEAU_GEM_DOMAIN_MAPPABLE;
ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_NEW,
&req, sizeof(req));
if (ret)
return ret;
- nvbo->handle = nvbo->base.handle = req.handle;
- nvbo->size = req.size;
- nvbo->domain = req.domain;
- nvbo->offset = req.offset;
+ nouveau_bo_info(nvbo, &req.info);
return 0;
}
@@ -232,25 +243,23 @@ static int
nouveau_bo_kmap(struct nouveau_bo_priv *nvbo)
{
struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device);
- struct drm_nouveau_gem_mmap req;
- int ret;
if (nvbo->map)
return 0;
- if (!nvbo->handle)
+ if (!nvbo->map_handle)
return -EINVAL;
if (!nvdev->mm_enabled)
return nouveau_bo_kmap_nomm(nvbo);
- req.handle = nvbo->handle;
- ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_MMAP,
- &req, sizeof(req));
- if (ret)
- return ret;
+ nvbo->map = mmap(0, nvbo->size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, nvdev->fd, nvbo->map_handle);
+ if (nvbo->map == MAP_FAILED) {
+ nvbo->map = NULL;
+ return -errno;
+ }
- nvbo->map = (void *)(unsigned long)req.vaddr;
return 0;
}
@@ -338,6 +347,35 @@ nouveau_bo_fake(struct nouveau_device *dev, uint64_t offset, uint32_t flags,
}
int
+nouveau_bo_wrap(struct nouveau_device *dev, uint32_t handle,
+ struct nouveau_bo **bo)
+{
+ struct nouveau_device_priv *nvdev = nouveau_device(dev);
+ struct drm_nouveau_gem_info req;
+ struct nouveau_bo_priv *nvbo;
+ int ret;
+
+ if (!nvdev->mm_enabled)
+ return -ENODEV;
+
+ ret = nouveau_bo_new(dev, 0, 0, 0, bo);
+ if (ret)
+ return ret;
+ nvbo = nouveau_bo(*bo);
+
+ req.handle = handle;
+ ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_INFO,
+ &req, sizeof(req));
+ if (ret) {
+ nouveau_bo_ref(NULL, bo);
+ return ret;
+ }
+
+ nouveau_bo_info(nvbo, &req);
+ return 0;
+}
+
+int
nouveau_bo_handle_get(struct nouveau_bo *bo, uint32_t *handle)
{
struct nouveau_device_priv *nvdev = nouveau_device(bo->device);
@@ -381,12 +419,12 @@ nouveau_bo_handle_ref(struct nouveau_device *dev, uint32_t handle,
struct drm_gem_open req;
int ret;
- ret = nouveau_bo_new(dev, 0, 0, 0, bo);
- if (ret)
- return ret;
- nvbo = nouveau_bo(*bo);
-
if (!nvdev->mm_enabled) {
+ ret = nouveau_bo_new(dev, 0, 0, 0, bo);
+ if (ret)
+ return ret;
+ nvbo = nouveau_bo(*bo);
+
nvbo->handle = 0;
nvbo->offset = handle;
nvbo->domain = NOUVEAU_BO_VRAM;
@@ -401,8 +439,13 @@ nouveau_bo_handle_ref(struct nouveau_device *dev, uint32_t handle,
return ret;
}
- nvbo->size = req.size;
- nvbo->handle = req.handle;
+ ret = nouveau_bo_wrap(dev, req.handle, bo);
+ if (ret) {
+ nouveau_bo_ref(NULL, bo);
+ return ret;
+ }
+
+ nvbo = nouveau_bo(*bo);
}
nvbo->base.handle = nvbo->handle;
@@ -507,12 +550,15 @@ nouveau_bo_wait(struct nouveau_bo *bo, int cpu_write)
return nouveau_bo_wait_nomm(bo, cpu_write);
req.handle = nvbo->handle;
- ret = drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_PREP,
- &req, sizeof(req));
+ do {
+ ret = drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_PREP,
+ &req, sizeof(req));
+ } while (ret == -EAGAIN);
if (ret)
return ret;
- nvbo->write_marker = 0;
+ if (ret == 0)
+ nvbo->write_marker = 0;
return 0;
}
@@ -578,7 +624,7 @@ int
nouveau_bo_validate_nomm(struct nouveau_bo_priv *nvbo, uint32_t flags)
{
struct nouveau_bo *new = NULL;
- uint32_t t_handle, t_domain, t_offset, t_size;
+ uint32_t t_handle, t_domain, t_offset, t_size, t_maph;
void *t_map;
int ret;
@@ -614,18 +660,21 @@ nouveau_bo_validate_nomm(struct nouveau_bo_priv *nvbo, uint32_t flags)
}
t_handle = nvbo->handle;
+ t_maph = nvbo->map_handle;
t_domain = nvbo->domain;
t_offset = nvbo->offset;
t_size = nvbo->size;
t_map = nvbo->map;
nvbo->handle = nouveau_bo(new)->handle;
+ nvbo->map_handle = nouveau_bo(new)->map_handle;
nvbo->domain = nouveau_bo(new)->domain;
nvbo->offset = nouveau_bo(new)->offset;
nvbo->size = nouveau_bo(new)->size;
nvbo->map = nouveau_bo(new)->map;
nouveau_bo(new)->handle = t_handle;
+ nouveau_bo(new)->map_handle = t_maph;
nouveau_bo(new)->domain = t_domain;
nouveau_bo(new)->offset = t_offset;
nouveau_bo(new)->size = t_size;
diff --git a/libdrm/nouveau/nouveau_bo.h b/libdrm/nouveau/nouveau_bo.h
index 84a43487..f0ae09be 100644
--- a/libdrm/nouveau/nouveau_bo.h
+++ b/libdrm/nouveau/nouveau_bo.h
@@ -66,6 +66,9 @@ nouveau_bo_fake(struct nouveau_device *dev, uint64_t offset, uint32_t flags,
uint32_t size, void *map, struct nouveau_bo **);
int
+nouveau_bo_wrap(struct nouveau_device *, uint32_t handle, struct nouveau_bo **);
+
+int
nouveau_bo_handle_get(struct nouveau_bo *, uint32_t *);
int
diff --git a/libdrm/nouveau/nouveau_device.c b/libdrm/nouveau/nouveau_device.c
index a61abb42..48db23d8 100644
--- a/libdrm/nouveau/nouveau_device.c
+++ b/libdrm/nouveau/nouveau_device.c
@@ -26,7 +26,7 @@
#include "nouveau_private.h"
-#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
+#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 13
#error nouveau_drm.h does not match expected patchlevel, update libdrm.
#endif
@@ -82,7 +82,7 @@ nouveau_device_open_existing(struct nouveau_device **dev, int close,
nouveau_device_close((void *)&nvdev);
return ret;
}
- nvdev->vram_aper_size = value;
+ nvdev->base.vm_vram_size = value;
ret = nouveau_device_get_param(&nvdev->base,
NOUVEAU_GETPARAM_AGP_SIZE, &value);
@@ -90,7 +90,7 @@ nouveau_device_open_existing(struct nouveau_device **dev, int close,
nouveau_device_close((void *)&nvdev);
return ret;
}
- nvdev->gart_aper_size = value;
+ nvdev->base.vm_gart_size = value;
ret = nouveau_bo_init(&nvdev->base);
if (ret) {
diff --git a/libdrm/nouveau/nouveau_device.h b/libdrm/nouveau/nouveau_device.h
index 76b7b954..c0d93335 100644
--- a/libdrm/nouveau/nouveau_device.h
+++ b/libdrm/nouveau/nouveau_device.h
@@ -26,6 +26,8 @@
struct nouveau_device {
unsigned chipset;
uint64_t vm_vram_base;
+ uint64_t vm_vram_size;
+ uint64_t vm_gart_size;
};
#endif
diff --git a/libdrm/nouveau/nouveau_drmif.h b/libdrm/nouveau/nouveau_drmif.h
index 37913257..c21fba2d 100644
--- a/libdrm/nouveau/nouveau_drmif.h
+++ b/libdrm/nouveau/nouveau_drmif.h
@@ -37,9 +37,6 @@ struct nouveau_device_priv {
int needs_close;
int mm_enabled;
-/*XXX: move to nouveau_device when interface gets bumped */
- uint64_t vram_aper_size;
- uint64_t gart_aper_size;
};
#define nouveau_device(n) ((struct nouveau_device_priv *)(n))
diff --git a/libdrm/nouveau/nouveau_private.h b/libdrm/nouveau/nouveau_private.h
index 32a90529..e92cb1f7 100644
--- a/libdrm/nouveau/nouveau_private.h
+++ b/libdrm/nouveau/nouveau_private.h
@@ -174,6 +174,7 @@ struct nouveau_bo_priv {
/* Kernel object */
uint32_t global_handle;
drm_handle_t handle;
+ uint64_t map_handle;
void *map;
/* Last known information from kernel on buffer status */
diff --git a/shared-core/nouveau_drm.h b/shared-core/nouveau_drm.h
index 4147f357..e999d20d 100644
--- a/shared-core/nouveau_drm.h
+++ b/shared-core/nouveau_drm.h
@@ -25,7 +25,7 @@
#ifndef __NOUVEAU_DRM_H__
#define __NOUVEAU_DRM_H__
-#define NOUVEAU_DRM_HEADER_PATCHLEVEL 12
+#define NOUVEAU_DRM_HEADER_PATCHLEVEL 13
struct drm_nouveau_channel_alloc {
uint32_t fb_ctxdma_handle;
@@ -153,17 +153,22 @@ struct drm_nouveau_setparam {
#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
-#define NOUVEAU_GEM_DOMAIN_NOMAP (1 << 3)
+#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
#define NOUVEAU_GEM_DOMAIN_TILE (1 << 30)
#define NOUVEAU_GEM_DOMAIN_TILE_ZETA (1 << 31)
-struct drm_nouveau_gem_new {
+struct drm_nouveau_gem_info {
+ uint32_t handle;
+ uint32_t domain;
uint64_t size;
+ uint64_t offset;
+ uint64_t map_handle;
+};
+
+struct drm_nouveau_gem_new {
+ struct drm_nouveau_gem_info info;
uint32_t channel_hint;
uint32_t align;
- uint32_t handle;
- uint32_t domain;
- uint32_t offset;
};
struct drm_nouveau_gem_pushbuf_bo {
@@ -223,12 +228,6 @@ struct drm_nouveau_gem_unpin {
uint32_t handle;
};
-struct drm_nouveau_gem_mmap {
- uint32_t handle;
- uint32_t pad;
- uint64_t vaddr;
-};
-
struct drm_nouveau_gem_cpu_prep {
uint32_t handle;
};
@@ -291,9 +290,9 @@ struct drm_nouveau_sarea {
#define DRM_NOUVEAU_GEM_PUSHBUF_CALL 0x42
#define DRM_NOUVEAU_GEM_PIN 0x43
#define DRM_NOUVEAU_GEM_UNPIN 0x44
-#define DRM_NOUVEAU_GEM_MMAP 0x45
-#define DRM_NOUVEAU_GEM_CPU_PREP 0x46
-#define DRM_NOUVEAU_GEM_CPU_FINI 0x47
-#define DRM_NOUVEAU_GEM_TILE 0x48
+#define DRM_NOUVEAU_GEM_CPU_PREP 0x45
+#define DRM_NOUVEAU_GEM_CPU_FINI 0x46
+#define DRM_NOUVEAU_GEM_TILE 0x47
+#define DRM_NOUVEAU_GEM_INFO 0x48
#endif /* __NOUVEAU_DRM_H__ */
diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h
index 1cd10bf9..ce52ce27 100644
--- a/shared-core/nouveau_drv.h
+++ b/shared-core/nouveau_drv.h
@@ -34,7 +34,7 @@
#define DRIVER_MAJOR 0
#define DRIVER_MINOR 0
-#define DRIVER_PATCHLEVEL 12
+#define DRIVER_PATCHLEVEL 13
#define NOUVEAU_FAMILY 0x0000FFFF
#define NOUVEAU_FLAGS 0xFFFF0000