summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Joachim <svenjoac@gmx.de>2010-12-14 14:24:26 +0100
committerSven Joachim <svenjoac@gmx.de>2010-12-14 14:24:26 +0100
commit028439cd47efb8e8c762ca8be46387318f7da48e (patch)
tree31b26f6117f23580606e912db119ff9d675593f5
parent2589d4b9c64fb34dbcd4b0d815806b4fd2731b16 (diff)
parent760c01a6af12c013bca0ad1f17c793ca813be4cc (diff)
Merge branch 'upstream-experimental' into debian-experimental
-rw-r--r--configure.ac2
-rw-r--r--include/drm/nouveau_drm.h8
-rw-r--r--intel/intel_bufmgr.c14
-rw-r--r--intel/intel_bufmgr.h6
-rw-r--r--intel/intel_bufmgr_fake.c18
-rw-r--r--intel/intel_bufmgr_gem.c144
-rw-r--r--nouveau/nouveau_bo.c12
-rw-r--r--nouveau/nouveau_bo.h6
-rw-r--r--nouveau/nouveau_channel.c5
-rw-r--r--nouveau/nouveau_channel.h2
-rw-r--r--nouveau/nouveau_device.c5
-rw-r--r--nouveau/nouveau_drmif.h1
-rw-r--r--nouveau/nouveau_grobj.c2
-rw-r--r--nouveau/nouveau_notifier.c2
-rw-r--r--nouveau/nouveau_private.h7
-rw-r--r--nouveau/nouveau_pushbuf.c8
-rw-r--r--radeon/radeon_bo_gem.c2
-rw-r--r--radeon/radeon_cs_gem.c2
-rw-r--r--tests/gem_flink.c2
-rw-r--r--tests/gem_mmap.c2
-rw-r--r--tests/gem_readwrite.c4
-rw-r--r--xf86drm.c27
22 files changed, 154 insertions, 127 deletions
diff --git a/configure.ac b/configure.ac
index 179f29fd..b064665b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.60)
-AC_INIT([libdrm], 2.4.22, [dri-devel@lists.sourceforge.net], libdrm)
+AC_INIT([libdrm], 2.4.23, [dri-devel@lists.sourceforge.net], libdrm)
AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h
index fe917dee..b18cad02 100644
--- a/include/drm/nouveau_drm.h
+++ b/include/drm/nouveau_drm.h
@@ -80,6 +80,8 @@ struct drm_nouveau_gpuobj_free {
#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
#define NOUVEAU_GETPARAM_GRAPH_UNITS 13
#define NOUVEAU_GETPARAM_PTIMER_TIME 14
+#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
+#define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16
struct drm_nouveau_getparam {
uint64_t param;
uint64_t value;
@@ -95,6 +97,12 @@ struct drm_nouveau_setparam {
#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
+#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
+#define NOUVEAU_GEM_TILE_16BPP 0x00000001
+#define NOUVEAU_GEM_TILE_32BPP 0x00000002
+#define NOUVEAU_GEM_TILE_ZETA 0x00000004
+#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
+
struct drm_nouveau_gem_info {
uint32_t handle;
uint32_t domain;
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
index 2b4e8883..f93a8707 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -94,19 +94,7 @@ int
drm_intel_bo_subdata(drm_intel_bo *bo, unsigned long offset,
unsigned long size, const void *data)
{
- int ret;
-
- if (bo->bufmgr->bo_subdata)
- return bo->bufmgr->bo_subdata(bo, offset, size, data);
- if (size == 0 || data == NULL)
- return 0;
-
- ret = drm_intel_bo_map(bo, 1);
- if (ret)
- return ret;
- memcpy((unsigned char *)bo->virtual + offset, data, size);
- drm_intel_bo_unmap(bo);
- return 0;
+ return bo->bufmgr->bo_subdata(bo, offset, size, data);
}
int
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 9df51686..e1b4c454 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -36,6 +36,8 @@
#include <stdint.h>
+struct drm_clip_rect;
+
typedef struct _drm_intel_bufmgr drm_intel_bufmgr;
typedef struct _drm_intel_bo drm_intel_bo;
@@ -109,9 +111,9 @@ void drm_intel_bo_wait_rendering(drm_intel_bo *bo);
void drm_intel_bufmgr_set_debug(drm_intel_bufmgr *bufmgr, int enable_debug);
void drm_intel_bufmgr_destroy(drm_intel_bufmgr *bufmgr);
int drm_intel_bo_exec(drm_intel_bo *bo, int used,
- drm_clip_rect_t * cliprects, int num_cliprects, int DR4);
+ struct drm_clip_rect *cliprects, int num_cliprects, int DR4);
int drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
- drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
+ struct drm_clip_rect *cliprects, int num_cliprects, int DR4,
int ring_flag);
int drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** bo_array, int count);
diff --git a/intel/intel_bufmgr_fake.c b/intel/intel_bufmgr_fake.c
index bc4a2ff9..d9b5cfdc 100644
--- a/intel/intel_bufmgr_fake.c
+++ b/intel/intel_bufmgr_fake.c
@@ -1121,6 +1121,23 @@ static int drm_intel_fake_bo_unmap(drm_intel_bo *bo)
return ret;
}
+static int
+drm_intel_fake_bo_subdata(drm_intel_bo *bo, unsigned long offset,
+ unsigned long size, const void *data)
+{
+ int ret;
+
+ if (size == 0 || data == NULL)
+ return 0;
+
+ ret = drm_intel_bo_map(bo, 1);
+ if (ret)
+ return ret;
+ memcpy((unsigned char *)bo->virtual + offset, data, size);
+ drm_intel_bo_unmap(bo);
+ return 0;
+}
+
static void
drm_intel_fake_kick_all_locked(drm_intel_bufmgr_fake *bufmgr_fake)
{
@@ -1599,6 +1616,7 @@ drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd,
bufmgr_fake->bufmgr.bo_unreference = drm_intel_fake_bo_unreference;
bufmgr_fake->bufmgr.bo_map = drm_intel_fake_bo_map;
bufmgr_fake->bufmgr.bo_unmap = drm_intel_fake_bo_unmap;
+ bufmgr_fake->bufmgr.bo_subdata = drm_intel_fake_bo_subdata;
bufmgr_fake->bufmgr.bo_wait_rendering =
drm_intel_fake_bo_wait_rendering;
bufmgr_fake->bufmgr.bo_emit_reloc = drm_intel_fake_emit_reloc;
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 7aff8674..c5bb5885 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -351,7 +351,6 @@ drm_intel_gem_bo_reference(drm_intel_bo *bo)
{
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
- assert(atomic_read(&bo_gem->refcount) > 0);
atomic_inc(&bo_gem->refcount);
}
@@ -468,8 +467,23 @@ drm_intel_bo_gem_set_in_aperture_size(drm_intel_bufmgr_gem *bufmgr_gem,
* aperture. Optimal packing is for wimps.
*/
size = bo_gem->bo.size;
- if (bufmgr_gem->gen < 4 && bo_gem->tiling_mode != I915_TILING_NONE)
- size *= 2;
+ if (bufmgr_gem->gen < 4 && bo_gem->tiling_mode != I915_TILING_NONE) {
+ int min_size;
+
+ if (bufmgr_gem->has_relaxed_fencing) {
+ if (bufmgr_gem->gen == 3)
+ min_size = 1024*1024;
+ else
+ min_size = 512*1024;
+
+ while (min_size < size)
+ min_size *= 2;
+ } else
+ min_size = size;
+
+ /* Account for worst-case alignment. */
+ size = 2 * min_size;
+ }
bo_gem->reloc_tree_size = size;
}
@@ -789,8 +803,8 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
DRM_IOCTL_GEM_OPEN,
&open_arg);
if (ret != 0) {
- fprintf(stderr, "Couldn't reference %s handle 0x%08x: %s\n",
- name, handle, strerror(errno));
+ DBG("Couldn't reference %s handle 0x%08x: %s\n",
+ name, handle, strerror(errno));
free(bo_gem);
return NULL;
}
@@ -842,9 +856,8 @@ drm_intel_gem_bo_free(drm_intel_bo *bo)
close.handle = bo_gem->gem_handle;
ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close);
if (ret != 0) {
- fprintf(stderr,
- "DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n",
- bo_gem->gem_handle, bo_gem->name, strerror(errno));
+ DBG("DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n",
+ bo_gem->gem_handle, bo_gem->name, strerror(errno));
}
free(bo);
}
@@ -982,10 +995,9 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable)
&mmap_arg);
if (ret != 0) {
ret = -errno;
- fprintf(stderr,
- "%s:%d: Error mapping buffer %d (%s): %s .\n",
- __FILE__, __LINE__, bo_gem->gem_handle,
- bo_gem->name, strerror(errno));
+ DBG("%s:%d: Error mapping buffer %d (%s): %s .\n",
+ __FILE__, __LINE__, bo_gem->gem_handle,
+ bo_gem->name, strerror(errno));
pthread_mutex_unlock(&bufmgr_gem->lock);
return ret;
}
@@ -1005,9 +1017,9 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable)
DRM_IOCTL_I915_GEM_SET_DOMAIN,
&set_domain);
if (ret != 0) {
- fprintf(stderr, "%s:%d: Error setting to CPU domain %d: %s\n",
- __FILE__, __LINE__, bo_gem->gem_handle,
- strerror(errno));
+ DBG("%s:%d: Error setting to CPU domain %d: %s\n",
+ __FILE__, __LINE__, bo_gem->gem_handle,
+ strerror(errno));
}
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -1040,11 +1052,10 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
&mmap_arg);
if (ret != 0) {
ret = -errno;
- fprintf(stderr,
- "%s:%d: Error preparing buffer map %d (%s): %s .\n",
- __FILE__, __LINE__,
- bo_gem->gem_handle, bo_gem->name,
- strerror(errno));
+ DBG("%s:%d: Error preparing buffer map %d (%s): %s .\n",
+ __FILE__, __LINE__,
+ bo_gem->gem_handle, bo_gem->name,
+ strerror(errno));
pthread_mutex_unlock(&bufmgr_gem->lock);
return ret;
}
@@ -1056,11 +1067,10 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
if (bo_gem->gtt_virtual == MAP_FAILED) {
bo_gem->gtt_virtual = NULL;
ret = -errno;
- fprintf(stderr,
- "%s:%d: Error mapping buffer %d (%s): %s .\n",
- __FILE__, __LINE__,
- bo_gem->gem_handle, bo_gem->name,
- strerror(errno));
+ DBG("%s:%d: Error mapping buffer %d (%s): %s .\n",
+ __FILE__, __LINE__,
+ bo_gem->gem_handle, bo_gem->name,
+ strerror(errno));
pthread_mutex_unlock(&bufmgr_gem->lock);
return ret;
}
@@ -1079,9 +1089,9 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
DRM_IOCTL_I915_GEM_SET_DOMAIN,
&set_domain);
if (ret != 0) {
- fprintf(stderr, "%s:%d: Error setting domain %d: %s\n",
- __FILE__, __LINE__, bo_gem->gem_handle,
- strerror(errno));
+ DBG("%s:%d: Error setting domain %d: %s\n",
+ __FILE__, __LINE__, bo_gem->gem_handle,
+ strerror(errno));
}
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -1092,14 +1102,11 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
- drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
int ret = 0;
if (bo == NULL)
return 0;
- assert(bo_gem->gtt_virtual != NULL);
-
pthread_mutex_lock(&bufmgr_gem->lock);
bo->virtual = NULL;
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -1117,8 +1124,6 @@ static int drm_intel_gem_bo_unmap(drm_intel_bo *bo)
if (bo == NULL)
return 0;
- assert(bo_gem->mem_virtual != NULL);
-
pthread_mutex_lock(&bufmgr_gem->lock);
/* Cause a flush to happen if the buffer's pinned for scanout, so the
@@ -1155,10 +1160,9 @@ drm_intel_gem_bo_subdata(drm_intel_bo *bo, unsigned long offset,
&pwrite);
if (ret != 0) {
ret = -errno;
- fprintf(stderr,
- "%s:%d: Error writing data to buffer %d: (%d %d) %s .\n",
- __FILE__, __LINE__, bo_gem->gem_handle, (int)offset,
- (int)size, strerror(errno));
+ DBG("%s:%d: Error writing data to buffer %d: (%d %d) %s .\n",
+ __FILE__, __LINE__, bo_gem->gem_handle, (int)offset,
+ (int)size, strerror(errno));
}
return ret;
@@ -1207,20 +1211,19 @@ drm_intel_gem_bo_get_subdata(drm_intel_bo *bo, unsigned long offset,
&pread);
if (ret != 0) {
ret = -errno;
- fprintf(stderr,
- "%s:%d: Error reading data from buffer %d: (%d %d) %s .\n",
- __FILE__, __LINE__, bo_gem->gem_handle, (int)offset,
- (int)size, strerror(errno));
+ DBG("%s:%d: Error reading data from buffer %d: (%d %d) %s .\n",
+ __FILE__, __LINE__, bo_gem->gem_handle, (int)offset,
+ (int)size, strerror(errno));
}
return ret;
}
-/** Waits for all GPU rendering to the object to have completed. */
+/** Waits for all GPU rendering with the object to have completed. */
static void
drm_intel_gem_bo_wait_rendering(drm_intel_bo *bo)
{
- drm_intel_gem_bo_start_gtt_access(bo, 0);
+ drm_intel_gem_bo_start_gtt_access(bo, 1);
}
/**
@@ -1245,11 +1248,10 @@ drm_intel_gem_bo_start_gtt_access(drm_intel_bo *bo, int write_enable)
DRM_IOCTL_I915_GEM_SET_DOMAIN,
&set_domain);
if (ret != 0) {
- fprintf(stderr,
- "%s:%d: Error setting memory domains %d (%08x %08x): %s .\n",
- __FILE__, __LINE__, bo_gem->gem_handle,
- set_domain.read_domains, set_domain.write_domain,
- strerror(errno));
+ DBG("%s:%d: Error setting memory domains %d (%08x %08x): %s .\n",
+ __FILE__, __LINE__, bo_gem->gem_handle,
+ set_domain.read_domains, set_domain.write_domain,
+ strerror(errno));
}
}
@@ -1301,6 +1303,7 @@ do_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *) target_bo;
+ int fenced_command;
if (bo_gem->has_error)
return -ENOMEM;
@@ -1310,13 +1313,14 @@ do_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
return -ENOMEM;
}
- if (target_bo_gem->tiling_mode == I915_TILING_NONE)
- need_fence = 0;
-
/* We never use HW fences for rendering on 965+ */
if (bufmgr_gem->gen >= 4)
need_fence = 0;
+ fenced_command = need_fence;
+ if (target_bo_gem->tiling_mode == I915_TILING_NONE)
+ need_fence = 0;
+
/* Create a new relocation list if needed */
if (bo_gem->relocs == NULL && drm_intel_setup_reloc_list(bo))
return -ENOMEM;
@@ -1343,8 +1347,6 @@ do_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
target_bo_gem->reloc_tree_fences = 1;
bo_gem->reloc_tree_fences += target_bo_gem->reloc_tree_fences;
- /* Flag the target to disallow further relocations in it. */
-
bo_gem->relocs[bo_gem->reloc_count].offset = offset;
bo_gem->relocs[bo_gem->reloc_count].delta = target_offset;
bo_gem->relocs[bo_gem->reloc_count].target_handle =
@@ -1356,7 +1358,7 @@ do_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
bo_gem->reloc_target_info[bo_gem->reloc_count].bo = target_bo;
if (target_bo != bo)
drm_intel_gem_bo_reference(target_bo);
- if (need_fence)
+ if (fenced_command)
bo_gem->reloc_target_info[bo_gem->reloc_count].flags =
DRM_INTEL_RELOC_FENCE;
else
@@ -1520,16 +1522,15 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
if (ret != 0) {
ret = -errno;
if (errno == ENOSPC) {
- fprintf(stderr,
- "Execbuffer fails to pin. "
- "Estimate: %u. Actual: %u. Available: %u\n",
- drm_intel_gem_estimate_batch_space(bufmgr_gem->exec_bos,
- bufmgr_gem->
- exec_count),
- drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos,
- bufmgr_gem->
- exec_count),
- (unsigned int)bufmgr_gem->gtt_size);
+ DBG("Execbuffer fails to pin. "
+ "Estimate: %u. Actual: %u. Available: %u\n",
+ drm_intel_gem_estimate_batch_space(bufmgr_gem->exec_bos,
+ bufmgr_gem->
+ exec_count),
+ drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos,
+ bufmgr_gem->
+ exec_count),
+ (unsigned int)bufmgr_gem->gtt_size);
}
}
drm_intel_update_buffer_offsets(bufmgr_gem);
@@ -1603,14 +1604,13 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
if (ret != 0) {
ret = -errno;
if (ret == -ENOSPC) {
- fprintf(stderr,
- "Execbuffer fails to pin. "
- "Estimate: %u. Actual: %u. Available: %u\n",
- drm_intel_gem_estimate_batch_space(bufmgr_gem->exec_bos,
- bufmgr_gem->exec_count),
- drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos,
- bufmgr_gem->exec_count),
- (unsigned int) bufmgr_gem->gtt_size);
+ DBG("Execbuffer fails to pin. "
+ "Estimate: %u. Actual: %u. Available: %u\n",
+ drm_intel_gem_estimate_batch_space(bufmgr_gem->exec_bos,
+ bufmgr_gem->exec_count),
+ drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos,
+ bufmgr_gem->exec_count),
+ (unsigned int) bufmgr_gem->gtt_size);
}
}
drm_intel_update_buffer_offsets2(bufmgr_gem);
diff --git a/nouveau/nouveau_bo.c b/nouveau/nouveau_bo.c
index 32b23b65..d6bb22de 100644
--- a/nouveau/nouveau_bo.c
+++ b/nouveau/nouveau_bo.c
@@ -52,7 +52,8 @@ nouveau_bo_info(struct nouveau_bo_priv *nvbo, struct drm_nouveau_gem_info *arg)
nvbo->offset = arg->offset;
nvbo->map_handle = arg->map_handle;
nvbo->base.tile_mode = arg->tile_mode;
- nvbo->base.tile_flags = arg->tile_flags;
+ /* XXX - flag inverted for backwards compatibility */
+ nvbo->base.tile_flags = arg->tile_flags ^ NOUVEAU_GEM_TILE_NONCONTIG;
return 0;
}
@@ -140,6 +141,10 @@ nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan)
info->tile_mode = nvbo->base.tile_mode;
info->tile_flags = nvbo->base.tile_flags;
+ /* XXX - flag inverted for backwards compatibility */
+ info->tile_flags ^= NOUVEAU_GEM_TILE_NONCONTIG;
+ if (!nvdev->has_bo_usage)
+ info->tile_flags &= NOUVEAU_GEM_TILE_LAYOUT_MASK;
ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_NEW,
&req, sizeof(req));
@@ -429,6 +434,8 @@ nouveau_bo_map_range(struct nouveau_bo *bo, uint32_t delta, uint32_t size,
(flags & NOUVEAU_BO_NOWAIT), 0);
if (ret)
return ret;
+
+ nvbo->map_refcnt++;
}
bo->map = (char *)nvbo->map + delta;
@@ -453,13 +460,14 @@ nouveau_bo_unmap(struct nouveau_bo *bo)
{
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
- if (bo->map && !nvbo->sysmem) {
+ if (bo->map && !nvbo->sysmem && nvbo->map_refcnt) {
struct nouveau_device_priv *nvdev = nouveau_device(bo->device);
struct drm_nouveau_gem_cpu_fini req;
req.handle = nvbo->handle;
drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_FINI,
&req, sizeof(req));
+ nvbo->map_refcnt--;
}
bo->map = NULL;
diff --git a/nouveau/nouveau_bo.h b/nouveau/nouveau_bo.h
index 1e77ab0f..3a1f2d4a 100644
--- a/nouveau/nouveau_bo.h
+++ b/nouveau/nouveau_bo.h
@@ -39,6 +39,12 @@
#define NOUVEAU_BO_IFLUSH (1 << 15)
#define NOUVEAU_BO_DUMMY (1 << 31)
+#define NOUVEAU_BO_TILE_LAYOUT_MASK 0x0000ff00
+#define NOUVEAU_BO_TILE_16BPP 0x00000001
+#define NOUVEAU_BO_TILE_32BPP 0x00000002
+#define NOUVEAU_BO_TILE_ZETA 0x00000004
+#define NOUVEAU_BO_TILE_SCANOUT 0x00000008
+
struct nouveau_bo {
struct nouveau_device *device;
uint32_t handle;
diff --git a/nouveau/nouveau_channel.c b/nouveau/nouveau_channel.c
index 40a0b344..ded54241 100644
--- a/nouveau/nouveau_channel.c
+++ b/nouveau/nouveau_channel.c
@@ -28,7 +28,8 @@
int
nouveau_channel_alloc(struct nouveau_device *dev, uint32_t fb_ctxdma,
- uint32_t tt_ctxdma, struct nouveau_channel **chan)
+ uint32_t tt_ctxdma, int pushbuf_size,
+ struct nouveau_channel **chan)
{
struct nouveau_device_priv *nvdev = nouveau_device(dev);
struct nouveau_channel_priv *nvchan;
@@ -90,7 +91,7 @@ nouveau_channel_alloc(struct nouveau_device *dev, uint32_t fb_ctxdma,
return ret;
}
- ret = nouveau_pushbuf_init(&nvchan->base);
+ ret = nouveau_pushbuf_init(&nvchan->base, pushbuf_size);
if (ret) {
nouveau_channel_free((void *)&nvchan);
return ret;
diff --git a/nouveau/nouveau_channel.h b/nouveau/nouveau_channel.h
index ddcf8e49..d61a4c0d 100644
--- a/nouveau/nouveau_channel.h
+++ b/nouveau/nouveau_channel.h
@@ -49,7 +49,7 @@ struct nouveau_channel {
int
nouveau_channel_alloc(struct nouveau_device *, uint32_t fb, uint32_t tt,
- struct nouveau_channel **);
+ int pushbuf_size, struct nouveau_channel **);
void
nouveau_channel_free(struct nouveau_channel **);
diff --git a/nouveau/nouveau_device.c b/nouveau/nouveau_device.c
index 9a091fba..2ffcba6f 100644
--- a/nouveau/nouveau_device.c
+++ b/nouveau/nouveau_device.c
@@ -95,6 +95,11 @@ nouveau_device_open_existing(struct nouveau_device **dev, int close,
}
nvdev->base.chipset = value;
+ ret = nouveau_device_get_param(&nvdev->base,
+ NOUVEAU_GETPARAM_HAS_BO_USAGE, &value);
+ if (!ret)
+ nvdev->has_bo_usage = value;
+
*dev = &nvdev->base;
return 0;
}
diff --git a/nouveau/nouveau_drmif.h b/nouveau/nouveau_drmif.h
index bc860d2e..ec226a22 100644
--- a/nouveau/nouveau_drmif.h
+++ b/nouveau/nouveau_drmif.h
@@ -35,6 +35,7 @@ struct nouveau_device_priv {
drm_context_t ctx;
drmLock *lock;
int needs_close;
+ int has_bo_usage;
};
#define nouveau_device(n) ((struct nouveau_device_priv *)(n))
diff --git a/nouveau/nouveau_grobj.c b/nouveau/nouveau_grobj.c
index 2b6e53a5..df2ffb91 100644
--- a/nouveau/nouveau_grobj.c
+++ b/nouveau/nouveau_grobj.c
@@ -99,6 +99,8 @@ nouveau_grobj_free(struct nouveau_grobj **grobj)
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,
diff --git a/nouveau/nouveau_notifier.c b/nouveau/nouveau_notifier.c
index f8cfd8b9..513fa635 100644
--- a/nouveau/nouveau_notifier.c
+++ b/nouveau/nouveau_notifier.c
@@ -80,6 +80,8 @@ nouveau_notifier_free(struct nouveau_notifier **notifier)
nvchan = nouveau_channel(nvnotify->base.channel);
nvdev = nouveau_device(nvchan->base.device);
+ FIRE_RING(&nvchan->base);
+
f.channel = nvchan->drm.channel;
f.handle = nvnotify->base.handle;
drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GPUOBJ_FREE, &f, sizeof(f));
diff --git a/nouveau/nouveau_private.h b/nouveau/nouveau_private.h
index 5a952f73..124fe870 100644
--- a/nouveau/nouveau_private.h
+++ b/nouveau/nouveau_private.h
@@ -37,8 +37,8 @@
#include "nouveau_pushbuf.h"
#include "nouveau_reloc.h"
-#define CALPB_BUFFERS 4
-#define CALPB_BUFSZ 16384
+#define CALPB_BUFFERS 3
+
struct nouveau_pushbuf_priv {
uint32_t cal_suffix0;
uint32_t cal_suffix1;
@@ -64,7 +64,7 @@ struct nouveau_pushbuf_priv {
#define nouveau_pushbuf(n) ((struct nouveau_pushbuf_priv *)(n))
int
-nouveau_pushbuf_init(struct nouveau_channel *);
+nouveau_pushbuf_init(struct nouveau_channel *, int buf_size);
void
nouveau_pushbuf_fini(struct nouveau_channel *);
@@ -115,6 +115,7 @@ struct nouveau_bo_priv {
uint32_t global_handle;
drm_handle_t handle;
uint64_t map_handle;
+ int map_refcnt;
void *map;
/* Last known information from kernel on buffer status */
diff --git a/nouveau/nouveau_pushbuf.c b/nouveau/nouveau_pushbuf.c
index 28b8018a..90836bcd 100644
--- a/nouveau/nouveau_pushbuf.c
+++ b/nouveau/nouveau_pushbuf.c
@@ -78,7 +78,7 @@ nouveau_pushbuf_fini_call(struct nouveau_channel *chan)
}
static int
-nouveau_pushbuf_init_call(struct nouveau_channel *chan)
+nouveau_pushbuf_init_call(struct nouveau_channel *chan, int buf_size)
{
struct drm_nouveau_gem_pushbuf req;
struct nouveau_channel_priv *nvchan = nouveau_channel(chan);
@@ -101,7 +101,7 @@ nouveau_pushbuf_init_call(struct nouveau_channel *chan)
for (i = 0; i < CALPB_BUFFERS; i++) {
ret = nouveau_bo_new(dev, flags | NOUVEAU_BO_MAP,
- 0, CALPB_BUFSZ, &nvpb->buffer[i]);
+ 0, buf_size, &nvpb->buffer[i]);
if (ret) {
nouveau_pushbuf_fini_call(chan);
return ret;
@@ -114,13 +114,13 @@ nouveau_pushbuf_init_call(struct nouveau_channel *chan)
}
int
-nouveau_pushbuf_init(struct nouveau_channel *chan)
+nouveau_pushbuf_init(struct nouveau_channel *chan, int buf_size)
{
struct nouveau_channel_priv *nvchan = nouveau_channel(chan);
struct nouveau_pushbuf_priv *nvpb = &nvchan->pb;
int ret;
- ret = nouveau_pushbuf_init_call(chan);
+ ret = nouveau_pushbuf_init_call(chan, buf_size);
if (ret)
return ret;
diff --git a/radeon/radeon_bo_gem.c b/radeon/radeon_bo_gem.c
index 081ccb9f..719fba7c 100644
--- a/radeon/radeon_bo_gem.c
+++ b/radeon/radeon_bo_gem.c
@@ -252,7 +252,7 @@ static int bo_set_tiling(struct radeon_bo_int *boi, uint32_t tiling_flags,
static int bo_get_tiling(struct radeon_bo_int *boi, uint32_t *tiling_flags,
uint32_t *pitch)
{
- struct drm_radeon_gem_set_tiling args;
+ struct drm_radeon_gem_set_tiling args = {};
int r;
args.handle = boi->handle;
diff --git a/radeon/radeon_cs_gem.c b/radeon/radeon_cs_gem.c
index 81bd3939..9834bcf1 100644
--- a/radeon/radeon_cs_gem.c
+++ b/radeon/radeon_cs_gem.c
@@ -517,7 +517,7 @@ static struct radeon_cs_funcs radeon_cs_gem_funcs = {
static int radeon_get_device_id(int fd, uint32_t *device_id)
{
- struct drm_radeon_info info;
+ struct drm_radeon_info info = {};
int r;
*device_id = 0;
diff --git a/tests/gem_flink.c b/tests/gem_flink.c
index ff999d2e..8dc88320 100644
--- a/tests/gem_flink.c
+++ b/tests/gem_flink.c
@@ -96,7 +96,7 @@ test_bad_flink(int fd)
flink.handle = 0x10101010;
ret = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
- assert(ret == -1 && errno == EBADF);
+ assert(ret == -1 && errno == ENOENT);
}
static void
diff --git a/tests/gem_mmap.c b/tests/gem_mmap.c
index d24005ba..2239789f 100644
--- a/tests/gem_mmap.c
+++ b/tests/gem_mmap.c
@@ -93,7 +93,7 @@ int main(int argc, char **argv)
mmap.size = 4096;
printf("Testing mmaping of bad object.\n");
ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &mmap);
- assert(ret == -1 && errno == EBADF);
+ assert(ret == -1 && errno == ENOENT);
memset(&create, 0, sizeof(create));
create.size = OBJECT_SIZE;
diff --git a/tests/gem_readwrite.c b/tests/gem_readwrite.c
index 4f5cde6c..07dc853a 100644
--- a/tests/gem_readwrite.c
+++ b/tests/gem_readwrite.c
@@ -127,11 +127,11 @@ int main(int argc, char **argv)
printf("Testing read of bad buffer handle\n");
ret = do_read(fd, 1234, buf, 0, 1024);
- assert(ret == -1 && errno == EBADF);
+ assert(ret == -1 && errno == ENOENT);
printf("Testing write of bad buffer handle\n");
ret = do_write(fd, 1234, buf, 0, 1024);
- assert(ret == -1 && errno == EBADF);
+ assert(ret == -1 && errno == ENOENT);
close(fd);
diff --git a/xf86drm.c b/xf86drm.c
index e48b9c99..799fcddf 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -155,23 +155,6 @@ void drmFree(void *pt)
free(pt);
}
-/* drmStrdup can't use strdup(3), since it doesn't call _DRM_MALLOC... */
-static char *drmStrdup(const char *s)
-{
- char *retval;
-
- if (!s)
- return NULL;
-
- retval = malloc(strlen(s)+1);
- if (!retval)
- return NULL;
-
- strcpy(retval, s);
-
- return retval;
-}
-
/**
* Call ioctl, restarting if it is interupted
*/
@@ -387,6 +370,7 @@ wait_for_udev:
if (fd >= 0)
return fd;
+#if !defined(UDEV)
/* Check if the device node is not what we expect it to be, and recreate it
* and try again if so.
*/
@@ -408,6 +392,7 @@ wait_for_udev:
drmMsg("drmOpenDevice: Open failed\n");
remove(buf);
+#endif
return -errno;
}
@@ -726,11 +711,11 @@ static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s)
d->version_minor = s->version_minor;
d->version_patchlevel = s->version_patchlevel;
d->name_len = s->name_len;
- d->name = drmStrdup(s->name);
+ d->name = strdup(s->name);
d->date_len = s->date_len;
- d->date = drmStrdup(s->date);
+ d->date = strdup(s->date);
d->desc_len = s->desc_len;
- d->desc = drmStrdup(s->desc);
+ d->desc = strdup(s->desc);
}
@@ -2543,5 +2528,5 @@ char *drmGetDeviceNameFromFd(int fd)
if (i == DRM_MAX_MINOR)
return NULL;
- return drmStrdup(name);
+ return strdup(name);
}