Merge branch 'master' into drm-ttm-finalize

This commit is contained in:
Thomas Hellstrom 2007-10-25 09:24:45 +02:00
commit 07706c9b79
6 changed files with 70 additions and 45 deletions

View file

@ -538,6 +538,7 @@ static int drm_load(drm_device_t *dev)
if (dev->driver.load != NULL) { if (dev->driver.load != NULL) {
DRM_LOCK(); DRM_LOCK();
/* Shared code returns -errno. */
retcode = -dev->driver.load(dev, retcode = -dev->driver.load(dev,
dev->id_entry->driver_private); dev->id_entry->driver_private);
DRM_UNLOCK(); DRM_UNLOCK();
@ -720,6 +721,9 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
return EINVAL; return EINVAL;
} }
if (--file_priv->refs != 0)
goto done;
if (dev->driver.preclose != NULL) if (dev->driver.preclose != NULL)
dev->driver.preclose(dev, file_priv); dev->driver.preclose(dev, file_priv);
@ -795,17 +799,16 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
dev->buf_pgid = 0; dev->buf_pgid = 0;
#endif /* __NetBSD__ || __OpenBSD__ */ #endif /* __NetBSD__ || __OpenBSD__ */
if (--file_priv->refs == 0) { if (dev->driver.postclose != NULL)
if (dev->driver.postclose != NULL) dev->driver.postclose(dev, file_priv);
dev->driver.postclose(dev, file_priv); TAILQ_REMOVE(&dev->files, file_priv, link);
TAILQ_REMOVE(&dev->files, file_priv, link); free(file_priv, M_DRM);
free(file_priv, M_DRM);
}
/* ======================================================== /* ========================================================
* End inline drm_release * End inline drm_release
*/ */
done:
atomic_inc( &dev->counts[_DRM_STAT_CLOSES] ); atomic_inc( &dev->counts[_DRM_STAT_CLOSES] );
#ifdef __FreeBSD__ #ifdef __FreeBSD__
device_unbusy(dev->device); device_unbusy(dev->device);

View file

@ -133,6 +133,7 @@ static int sis_drm_alloc(struct drm_device * dev, struct drm_file *file_priv,
dev_priv->agp_initialized)) { dev_priv->agp_initialized)) {
DRM_ERROR DRM_ERROR
("Attempt to allocate from uninitialized memory manager.\n"); ("Attempt to allocate from uninitialized memory manager.\n");
mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
} }

View file

@ -495,7 +495,7 @@ static int i915_dispatch_cmdbuffer(struct drm_device * dev,
int i = 0, count, ret; int i = 0, count, ret;
if (cmd->sz & 0x3) { if (cmd->sz & 0x3) {
DRM_ERROR("alignment"); DRM_ERROR("alignment\n");
return -EINVAL; return -EINVAL;
} }
@ -533,7 +533,7 @@ static int i915_dispatch_batchbuffer(struct drm_device * dev,
RING_LOCALS; RING_LOCALS;
if ((batch->start | batch->used) & 0x7) { if ((batch->start | batch->used) & 0x7) {
DRM_ERROR("alignment"); DRM_ERROR("alignment\n");
return -EINVAL; return -EINVAL;
} }
@ -865,6 +865,9 @@ int i915_process_relocs(struct drm_file *file_priv,
} while (reloc_offset != reloc_end); } while (reloc_offset != reloc_end);
out: out:
drm_bo_kunmap(&relocatee->kmap);
relocatee->data_page = NULL;
drm_bo_kunmap(&reloc_kmap); drm_bo_kunmap(&reloc_kmap);
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -874,6 +877,42 @@ out:
return ret; return ret;
} }
static int i915_exec_reloc(struct drm_file *file_priv, drm_handle_t buf_handle,
drm_handle_t buf_reloc_handle,
struct drm_buffer_object **buffers,
uint32_t buf_count)
{
struct drm_device *dev = file_priv->head->dev;
struct i915_relocatee_info relocatee;
int ret = 0;
memset(&relocatee, 0, sizeof(relocatee));
mutex_lock(&dev->struct_mutex);
relocatee.buf = drm_lookup_buffer_object(file_priv, buf_handle, 1);
mutex_unlock(&dev->struct_mutex);
if (!relocatee.buf) {
DRM_DEBUG("relocatee buffer invalid %08x\n", buf_handle);
ret = -EINVAL;
goto out_err;
}
while (buf_reloc_handle) {
ret = i915_process_relocs(file_priv, buf_handle, &buf_reloc_handle, &relocatee, buffers, buf_count);
if (ret) {
DRM_ERROR("process relocs failed\n");
break;
}
}
mutex_lock(&dev->struct_mutex);
drm_bo_usage_deref_locked(&relocatee.buf);
mutex_unlock(&dev->struct_mutex);
out_err:
return ret;
}
/* /*
* Validate, add fence and relocate a block of bos from a userspace list * Validate, add fence and relocate a block of bos from a userspace list
*/ */
@ -890,7 +929,7 @@ int i915_validate_buffer_list(struct drm_file *file_priv,
unsigned buf_count = 0; unsigned buf_count = 0;
struct drm_device *dev = file_priv->head->dev; struct drm_device *dev = file_priv->head->dev;
uint32_t buf_reloc_handle, buf_handle; uint32_t buf_reloc_handle, buf_handle;
struct i915_relocatee_info relocatee;
do { do {
if (buf_count >= *num_buffers) { if (buf_count >= *num_buffers) {
@ -926,6 +965,13 @@ int i915_validate_buffer_list(struct drm_file *file_priv,
buf_handle = req->bo_req.handle; buf_handle = req->bo_req.handle;
buf_reloc_handle = arg.reloc_handle; buf_reloc_handle = arg.reloc_handle;
if (buf_reloc_handle) {
ret = i915_exec_reloc(file_priv, buf_handle, buf_reloc_handle, buffers, buf_count);
if (ret)
goto out_err;
DRM_MEMORYBARRIER();
}
rep.ret = drm_bo_handle_validate(file_priv, req->bo_req.handle, rep.ret = drm_bo_handle_validate(file_priv, req->bo_req.handle,
req->bo_req.fence_class, req->bo_req.fence_class,
req->bo_req.flags, req->bo_req.flags,
@ -951,35 +997,6 @@ int i915_validate_buffer_list(struct drm_file *file_priv,
data = next; data = next;
buf_count++; buf_count++;
if (buf_reloc_handle) {
memset(&relocatee, 0, sizeof(relocatee));
mutex_lock(&dev->struct_mutex);
relocatee.buf = drm_lookup_buffer_object(file_priv, buf_handle, 1);
mutex_unlock(&dev->struct_mutex);
if (!relocatee.buf) {
DRM_DEBUG("relocatee buffer invalid %08x\n", buf_handle);
ret = -EINVAL;
goto out_err;
}
while (buf_reloc_handle) {
ret = i915_process_relocs(file_priv, buf_handle, &buf_reloc_handle, &relocatee, buffers, buf_count);
if (ret) {
DRM_ERROR("process relocs failed\n");
break;
}
}
drm_bo_kunmap(&relocatee.kmap);
mutex_lock(&dev->struct_mutex);
drm_bo_usage_deref_locked(&relocatee.buf);
mutex_unlock(&dev->struct_mutex);
if (ret)
goto out_err;
}
} while (next != 0); } while (next != 0);
*num_buffers = buf_count; *num_buffers = buf_count;
return 0; return 0;
@ -1050,6 +1067,9 @@ static int i915_execbuffer(struct drm_device *dev, void *data,
if (ret) if (ret)
goto out_free; goto out_free;
/* make sure all previous memory operations have passed */
DRM_MEMORYBARRIER();
/* submit buffer */ /* submit buffer */
batch->start = buffers[num_buffers-1]->offset; batch->start = buffers[num_buffers-1]->offset;

View file

@ -223,7 +223,7 @@ void nouveau_mem_close(struct drm_device *dev)
static uint32_t static uint32_t
nouveau_mem_fb_amount_igp(struct drm_device *dev) nouveau_mem_fb_amount_igp(struct drm_device *dev)
{ {
#if defined(LINUX) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) #if defined(__linux__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct pci_dev *bridge; struct pci_dev *bridge;
uint32_t mem; uint32_t mem;

View file

@ -69,10 +69,10 @@ static void client()
int drmfd, ret; int drmfd, ret;
/* XXX: Should make sure we open the same DRM as the master */ /* XXX: Should make sure we open the same DRM as the master */
drmfd = drm_open_any();
wait_event(0, SERVER_READY); wait_event(0, SERVER_READY);
drmfd = drm_open_any();
/* Get a client magic number and pass it to the master for auth. */ /* Get a client magic number and pass it to the master for auth. */
auth.magic = 0; /* Quiet valgrind */ auth.magic = 0; /* Quiet valgrind */
ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth); ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth);

View file

@ -87,8 +87,6 @@ client_auth(int drmfd)
struct drm_auth auth; struct drm_auth auth;
int ret; int ret;
wait_event(0, SERVER_READY);
/* Get a client magic number and pass it to the master for auth. */ /* Get a client magic number and pass it to the master for auth. */
ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth); ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth);
if (ret == -1) if (ret == -1)
@ -172,8 +170,6 @@ static void test_open_close_locked(drmfd)
ret = drmUnlock(drmfd, lock1); ret = drmUnlock(drmfd, lock1);
if (ret != 0) if (ret != 0)
errx(1, "lock lost during open/close by same pid"); errx(1, "lock lost during open/close by same pid");
close(drmfd);
} }
static void client() static void client()
@ -181,6 +177,8 @@ static void client()
int drmfd, ret; int drmfd, ret;
unsigned int time; unsigned int time;
wait_event(0, SERVER_READY);
/* XXX: Should make sure we open the same DRM as the master */ /* XXX: Should make sure we open the same DRM as the master */
drmfd = drm_open_any(); drmfd = drm_open_any();
@ -201,6 +199,7 @@ static void client()
send_event(0, CLIENT_LOCKED); send_event(0, CLIENT_LOCKED);
ret = write(commfd[0], &time, sizeof(time)); ret = write(commfd[0], &time, sizeof(time));
close(drmfd);
exit(0); exit(0);
} }
@ -238,6 +237,8 @@ static void server()
if (client_time < unlock_time) if (client_time < unlock_time)
errx(1, "Client took lock before server released it"); errx(1, "Client took lock before server released it");
close(drmfd);
} }
int main(int argc, char **argv) int main(int argc, char **argv)