From 72d457fc1973a61f906a42d049c1c160cc7dee4e Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 29 Mar 2007 21:33:41 +0200 Subject: Make sure CMA (Can't map aperture) pages are mapped uncached. (Should really make this write-combined using PATs, at some point). --- linux-core/drm_compat.c | 8 +++++--- linux-core/drm_vm.c | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index 23441811..9ac5658c 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -275,12 +275,14 @@ static struct page *drm_bo_vm_fault(struct vm_area_struct *vma, goto out_unlock; } pfn = page_to_pfn(page); - vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); + vma->vm_page_prot = (bo->mem.flags & DRM_BO_FLAG_CACHED) ? + vm_get_page_prot(vma->vm_flags) : + drm_io_prot(_DRM_TTM, vma); } - + err = vm_insert_pfn(vma, address, pfn); - if (!err || err == -EBUSY) + if (!err || err == -EBUSY) data->type = VM_FAULT_MINOR; else data->type = VM_FAULT_OOM; diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 54a0849f..1f905fba 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -796,7 +796,9 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, goto out_unlock; } pfn = page_to_pfn(page); - vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); + vma->vm_page_prot = (bo->mem.flags & DRM_BO_FLAG_CACHED) ? + vm_get_page_prot(vma->vm_flags) : + drm_io_prot(_DRM_TTM, vma); } err = vm_insert_pfn(vma, address, pfn); -- cgit v1.2.3 From d85e243259259d7702db0d344ae1ff7d26598227 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Fri, 30 Mar 2007 12:23:22 +0200 Subject: Fix an oops when trying to clean a not yet initialized memory type. --- linux-core/drm_bo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 1bdc6fef..cea6ef62 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1991,10 +1991,16 @@ static int drm_bo_lock_mm(drm_device_t * dev, unsigned mem_type) drm_mem_type_manager_t *man = &bm->man[mem_type]; if (mem_type == 0 || mem_type >= DRM_BO_MEM_TYPES) { - DRM_ERROR("Illegal memory manager memory type %u,\n", mem_type); + DRM_ERROR("Illegal memory manager memory type %u.\n", mem_type); return -EINVAL; } + if (!man->has_type) { + DRM_ERROR("Memory type %u has not been initialized.\n", + mem_type); + return 0; + } + drm_bo_clean_unfenced(dev); ret = drm_bo_force_list_clean(dev, &man->lru, mem_type, 0, 1, 0); if (ret) -- cgit v1.2.3 From 7743af94492681f5aaf7cfdef78d695a6db7cbd0 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Fri, 30 Mar 2007 14:14:26 +0200 Subject: Evicted no-move buffers can get lost if they end up in another memory type than local. --- linux-core/drm_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index cea6ef62..17d6fbc0 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -75,7 +75,8 @@ void drm_bo_add_to_lru(drm_buffer_object_t * bo) { drm_mem_type_manager_t *man; - if (!(bo->mem.mask & (DRM_BO_FLAG_NO_MOVE | DRM_BO_FLAG_NO_EVICT))) { + if (!(bo->mem.mask & (DRM_BO_FLAG_NO_MOVE | DRM_BO_FLAG_NO_EVICT)) + || bo->mem.mem_type != bo->pinned_mem_type) { man = &bo->dev->bm.man[bo->mem.mem_type]; list_add_tail(&bo->lru, &man->lru); } else { -- cgit v1.2.3 From 38d18acb8f3617d79735f71564d9f49e608461ec Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 3 Apr 2007 10:24:06 +0200 Subject: Add a fence flush event to each fence-signaled check when lazy-waiting to make sure we don't lose any sequence numbers if, for some reason, they don't generate an IRQ. --- linux-core/drm_fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index 6dd04a35..be075bb3 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -301,7 +301,7 @@ static int drm_fence_lazy_wait(drm_device_t *dev, do { DRM_WAIT_ON(ret, fc->fence_queue, 3 * DRM_HZ, - fence_signaled(dev, fence, mask, 0)); + fence_signaled(dev, fence, mask, 1)); if (time_after_eq(jiffies, _end)) break; } while (ret == -EINTR && ignore_signals); -- cgit v1.2.3 From c4968279218cf246323e38bbbd44ce2774871fde Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 3 Apr 2007 10:54:23 +0200 Subject: Fix user object reference when caller is not object creator. (Reported by Dave Airlie). --- linux-core/drm_object.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_object.c b/linux-core/drm_object.c index 23412ed0..03906034 100644 --- a/linux-core/drm_object.c +++ b/linux-core/drm_object.c @@ -240,11 +240,17 @@ int drm_user_object_ref(drm_file_t * priv, uint32_t user_token, { drm_device_t *dev = priv->head->dev; drm_user_object_t *uo; + drm_hash_item_t *hash; int ret; mutex_lock(&dev->struct_mutex); - uo = drm_lookup_user_object(priv, user_token); - if (!uo || (uo->type != type)) { + ret = drm_ht_find_item(&dev->object_hash, user_token, &hash); + if (ret) { + DRM_ERROR("Could not find user object to reference.\n"); + goto out_err; + } + uo = drm_hash_entry(hash, drm_user_object_t, hash); + if (uo->type != type) { ret = -EINVAL; goto out_err; } @@ -253,7 +259,6 @@ int drm_user_object_ref(drm_file_t * priv, uint32_t user_token, goto out_err; mutex_unlock(&dev->struct_mutex); *object = uo; - DRM_ERROR("Referenced an object\n"); return 0; out_err: mutex_unlock(&dev->struct_mutex); @@ -281,7 +286,6 @@ int drm_user_object_unref(drm_file_t * priv, uint32_t user_token, } drm_remove_ref_object(priv, ro); mutex_unlock(&dev->struct_mutex); - DRM_ERROR("Unreferenced an object\n"); return 0; out_err: mutex_unlock(&dev->struct_mutex); -- cgit v1.2.3 From 9c793716591c141d7bb1796f5dc6473c45d9545c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 5 Apr 2007 11:18:00 +1000 Subject: add an install target to the drm modules makefile --- linux-core/Makefile | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'linux-core') diff --git a/linux-core/Makefile b/linux-core/Makefile index bca8210d..effc2061 100644 --- a/linux-core/Makefile +++ b/linux-core/Makefile @@ -237,6 +237,11 @@ dristat: dristat.c drmstat: drmstat.c $(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS) +install: + echo "Installing DRM modules to "$(O) + install *.ko $(O)/driver/char/drm + depmod -a + else # Check for kernel versions that we don't support. -- cgit v1.2.3 From b25558bb7377f6df6d457b50067a1d245f7911fd Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 7 Apr 2007 07:21:05 +1000 Subject: fixup install target, not sure what I was smokin... --- linux-core/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'linux-core') diff --git a/linux-core/Makefile b/linux-core/Makefile index effc2061..af29bd6a 100644 --- a/linux-core/Makefile +++ b/linux-core/Makefile @@ -238,9 +238,7 @@ drmstat: drmstat.c $(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS) install: - echo "Installing DRM modules to "$(O) - install *.ko $(O)/driver/char/drm - depmod -a + make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules_install else -- cgit v1.2.3 From a70f8e0ab265cc4a26ed2f9e92ab0618bd920a93 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 9 Apr 2007 21:52:59 +1000 Subject: radeon: add support for reverse engineered xpress200m The IGPGART setup code was traced using mmio-trace on fglrx by myself and Phillip Ezolt on dri-devel. This code doesn't let the 3D driver work properly as the card has no vertex shader support. Thanks to Matthew Garrett + Ubuntu for providing me some hardware to do this work on. --- linux-core/ati_pcigart.c | 12 ++++++++++-- linux-core/drmP.h | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'linux-core') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index bb30dd74..52bf8922 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -205,10 +205,18 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) page_base = (u32) entry->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { - if (gart_info->is_pcie) + switch(gart_info->gart_reg_if) { + case DRM_ATI_GART_IGP: + *pci_gart = cpu_to_le32((page_base) | 0xc); + break; + case DRM_ATI_GART_PCIE: *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); - else + break; + default: + case DRM_ATI_GART_PCI: *pci_gart = cpu_to_le32(page_base); + break; + } pci_gart++; page_base += ATI_PCIGART_PAGE_SIZE; } diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 648e29bc..d879c2a2 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -587,9 +587,13 @@ typedef struct drm_vbl_sig { #define DRM_ATI_GART_MAIN 1 #define DRM_ATI_GART_FB 2 +#define DRM_ATI_GART_PCI 1 +#define DRM_ATI_GART_PCIE 2 +#define DRM_ATI_GART_IGP 3 + typedef struct ati_pcigart_info { int gart_table_location; - int is_pcie; + int gart_reg_if; void *addr; dma_addr_t bus_addr; drm_local_map_t mapping; -- cgit v1.2.3 From e6e4946c82ab6f63143df7f49f38fa56f7e8980a Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Mon, 16 Apr 2007 16:23:05 +0200 Subject: Require the hardware lock for buffer creation (since that implies a validate). Fix drm_bo_wait_unfenced error messages and codes. Fix some return codes from libdrm. --- linux-core/drm_bo.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 17d6fbc0..b08700a3 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1024,30 +1024,23 @@ static int drm_bo_wait_unfenced(drm_buffer_object_t * bo, int no_wait, int eagain_if_wait) { int ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED); - unsigned long _end = jiffies + 3 * DRM_HZ; if (ret && no_wait) return -EBUSY; else if (!ret) return 0; - do { - mutex_unlock(&bo->mutex); - DRM_WAIT_ON(ret, bo->event_queue, 3 * DRM_HZ, - !drm_bo_check_unfenced(bo)); - mutex_lock(&bo->mutex); - if (ret == -EINTR) - return -EAGAIN; - if (ret) { - DRM_ERROR - ("Error waiting for buffer to become fenced\n"); - return ret; - } - ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED); - } while (ret && !time_after_eq(jiffies, _end)); + ret = 0; + mutex_unlock(&bo->mutex); + DRM_WAIT_ON(ret, bo->event_queue, 3 * DRM_HZ, + !drm_bo_check_unfenced(bo)); + mutex_lock(&bo->mutex); + if (ret == -EINTR) + return -EAGAIN; + ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED); if (ret) { DRM_ERROR("Timeout waiting for buffer to become fenced\n"); - return ret; + return -EBUSY; } if (eagain_if_wait) return -EAGAIN; @@ -1669,6 +1662,9 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS) rep.ret = 0; switch (req->op) { case drm_bo_create: + rep.ret = drm_bo_lock_test(dev, filp); + if (rep.ret) + break; rep.ret = drm_buffer_object_create(priv, req->size, req->type, -- cgit v1.2.3 From e91ceff6c98661bfae5db008e024b71a8a0f5129 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 17 Apr 2007 08:46:45 +0200 Subject: Add a code comment. --- linux-core/drm_bo.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index b08700a3..4ecfb79c 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1715,6 +1715,13 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS) drm_buffer_type, &uo); if (rep.ret) break; + + /* + * Note: The following code is only to + * fill in the rep argument. drm_lookup_user_object ups the + * refcount which is decreased again when we're done with the bo. + */ + mutex_lock(&dev->struct_mutex); uo = drm_lookup_user_object(priv, req->handle); entry = -- cgit v1.2.3 From 5432cc4abf672ed3adb10fd5d61a6a5716089a98 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 17 Apr 2007 10:53:19 +0200 Subject: Fix buffer object reference problems. (Reported by Dave Airlie). --- linux-core/drm_bo.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 4ecfb79c..88adfc98 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1716,22 +1716,7 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS) if (rep.ret) break; - /* - * Note: The following code is only to - * fill in the rep argument. drm_lookup_user_object ups the - * refcount which is decreased again when we're done with the bo. - */ - - mutex_lock(&dev->struct_mutex); - uo = drm_lookup_user_object(priv, req->handle); - entry = - drm_user_object_entry(uo, drm_buffer_object_t, - base); - atomic_dec(&entry->usage); - mutex_unlock(&dev->struct_mutex); - mutex_lock(&entry->mutex); - drm_bo_fill_rep_arg(entry, &rep); - mutex_unlock(&entry->mutex); + rep.ret = drm_bo_handle_info(priv, req->handle, &rep); break; case drm_bo_unreference: rep.ret = drm_user_object_unref(priv, req->handle, -- cgit v1.2.3 From 5a96d59ce9d9ad5816e2d0e195afa9902445f594 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 17 Apr 2007 14:15:37 +0200 Subject: Don't always free up memory space when we unpin buffers. --- linux-core/drm_bo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 88adfc98..450e448c 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1399,7 +1399,10 @@ static int drm_buffer_object_validate(drm_buffer_object_t * bo, } else if (bo->pinned_node != NULL) { mutex_lock(&dev->struct_mutex); - drm_mm_put_block(bo->pinned_node); + + if (bo->pinned_node != bo->mem.mm_node) + drm_mm_put_block(bo->pinned_node); + list_del_init(&bo->pinned_lru); bo->pinned_node = NULL; mutex_unlock(&dev->struct_mutex); -- cgit v1.2.3 From 2df2c70e20caa3d6d1a1ac12da6fe3cc0689d51f Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 18 Apr 2007 16:33:28 +0200 Subject: Simplify the ttm backend interface and the agp ttm backend. --- linux-core/drmP.h | 11 ++--- linux-core/drm_agpsupport.c | 105 ++++++++++++++++++++------------------------ linux-core/drm_objects.h | 13 ++++-- linux-core/drm_ttm.c | 10 ++--- linux-core/i915_buffer.c | 2 +- 5 files changed, 66 insertions(+), 75 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index d879c2a2..271c6c8e 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -834,14 +834,12 @@ typedef struct drm_device { } drm_device_t; #if __OS_HAS_AGP -typedef struct drm_agp_ttm_priv { +typedef struct drm_agp_ttm_backend { + drm_ttm_backend_t backend; DRM_AGP_MEM *mem; struct agp_bridge_data *bridge; - unsigned alloc_type; - unsigned cached_type; - unsigned uncached_type; int populated; -} drm_agp_ttm_priv; +} drm_agp_ttm_backend_t; #endif @@ -1118,8 +1116,7 @@ extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size extern int drm_agp_free_memory(DRM_AGP_MEM * handle); extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start); extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); -extern drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev, - drm_ttm_backend_t *backend); +extern drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev); /* Stub support (drm_stub.h) */ extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver *driver); diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 0f7b1d2e..7d8f0737 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -570,7 +570,8 @@ static int drm_agp_needs_unbind_cache_adjust(drm_ttm_backend_t *backend) { static int drm_agp_populate(drm_ttm_backend_t *backend, unsigned long num_pages, struct page **pages) { - drm_agp_ttm_priv *agp_priv = (drm_agp_ttm_priv *) backend->private; + drm_agp_ttm_backend_t *agp_be = + container_of(backend, drm_agp_ttm_backend_t, backend); struct page **cur_page, **last_page = pages + num_pages; DRM_AGP_MEM *mem; @@ -579,9 +580,9 @@ static int drm_agp_populate(drm_ttm_backend_t *backend, unsigned long num_pages, DRM_DEBUG("drm_agp_populate_ttm\n"); #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) - mem = drm_agp_allocate_memory(num_pages, agp_priv->alloc_type); + mem = drm_agp_allocate_memory(num_pages, AGP_USER_MEMORY); #else - mem = drm_agp_allocate_memory(agp_priv->bridge, num_pages, agp_priv->alloc_type); + mem = drm_agp_allocate_memory(agp_be->bridge, num_pages, AGP_USER_MEMORY); #endif if (!mem) { drm_free_memctl(num_pages *sizeof(void *)); @@ -593,7 +594,7 @@ static int drm_agp_populate(drm_ttm_backend_t *backend, unsigned long num_pages, for (cur_page = pages; cur_page < last_page; ++cur_page) { mem->memory[mem->page_count++] = phys_to_gart(page_to_phys(*cur_page)); } - agp_priv->mem = mem; + agp_be->mem = mem; return 0; } @@ -601,76 +602,82 @@ static int drm_agp_bind_ttm(drm_ttm_backend_t *backend, unsigned long offset, int cached) { - drm_agp_ttm_priv *agp_priv = (drm_agp_ttm_priv *) backend->private; - DRM_AGP_MEM *mem = agp_priv->mem; + drm_agp_ttm_backend_t *agp_be = + container_of(backend, drm_agp_ttm_backend_t, backend); + DRM_AGP_MEM *mem = agp_be->mem; int ret; DRM_DEBUG("drm_agp_bind_ttm\n"); - DRM_FLAG_MASKED(backend->flags, (cached) ? DRM_BE_FLAG_BOUND_CACHED : 0, - DRM_BE_FLAG_BOUND_CACHED); mem->is_flushed = TRUE; - mem->type = (cached) ? agp_priv->cached_type : agp_priv->uncached_type; + mem->type = (cached) ? AGP_USER_CACHED_MEMORY : + AGP_USER_MEMORY; ret = drm_agp_bind_memory(mem, offset); if (ret) { DRM_ERROR("AGP Bind memory failed\n"); } + DRM_FLAG_MASKED(backend->flags, (cached) ? DRM_BE_FLAG_BOUND_CACHED : 0, + DRM_BE_FLAG_BOUND_CACHED); return ret; } static int drm_agp_unbind_ttm(drm_ttm_backend_t *backend) { - drm_agp_ttm_priv *agp_priv = (drm_agp_ttm_priv *) backend->private; + drm_agp_ttm_backend_t *agp_be = + container_of(backend, drm_agp_ttm_backend_t, backend); DRM_DEBUG("drm_agp_unbind_ttm\n"); - if (agp_priv->mem->is_bound) - return drm_agp_unbind_memory(agp_priv->mem); + if (agp_be->mem->is_bound) + return drm_agp_unbind_memory(agp_be->mem); else return 0; } static void drm_agp_clear_ttm(drm_ttm_backend_t *backend) { - drm_agp_ttm_priv *agp_priv = (drm_agp_ttm_priv *) backend->private; - DRM_AGP_MEM *mem = agp_priv->mem; + drm_agp_ttm_backend_t *agp_be = + container_of(backend, drm_agp_ttm_backend_t, backend); + DRM_AGP_MEM *mem = agp_be->mem; DRM_DEBUG("drm_agp_clear_ttm\n"); if (mem) { unsigned long num_pages = mem->page_count; - backend->unbind(backend); + backend->func->unbind(backend); agp_free_memory(mem); drm_free_memctl(num_pages *sizeof(void *)); } - - agp_priv->mem = NULL; + agp_be->mem = NULL; } static void drm_agp_destroy_ttm(drm_ttm_backend_t *backend) { - drm_agp_ttm_priv *agp_priv; + drm_agp_ttm_backend_t *agp_be; if (backend) { DRM_DEBUG("drm_agp_destroy_ttm\n"); - agp_priv = (drm_agp_ttm_priv *) backend->private; - if (agp_priv) { - if (agp_priv->mem) { - backend->clear(backend); + agp_be = container_of(backend, drm_agp_ttm_backend_t, backend); + if (agp_be) { + if (agp_be->mem) { + backend->func->clear(backend); } - drm_ctl_free(agp_priv, sizeof(*agp_priv), DRM_MEM_MAPPINGS); - backend->private = NULL; - } - if (backend->flags & DRM_BE_FLAG_NEEDS_FREE) { - drm_ctl_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS); + drm_ctl_free(agp_be, sizeof(*agp_be), DRM_MEM_TTM); } } } - -drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev, - drm_ttm_backend_t *backend) +static drm_ttm_backend_func_t agp_ttm_backend = +{ + .needs_ub_cache_adjust = drm_agp_needs_unbind_cache_adjust, + .populate = drm_agp_populate, + .clear = drm_agp_clear_ttm, + .bind = drm_agp_bind_ttm, + .unbind = drm_agp_unbind_ttm, + .destroy = drm_agp_destroy_ttm, +}; + +drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev) { - drm_ttm_backend_t *agp_be; - drm_agp_ttm_priv *agp_priv; + drm_agp_ttm_backend_t *agp_be; struct agp_kern_info *info; if (!dev->agp) { @@ -690,37 +697,19 @@ drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev, return NULL; } - agp_be = (backend != NULL) ? backend: - drm_ctl_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS); - + + agp_be = drm_ctl_calloc(1, sizeof(*agp_be), DRM_MEM_TTM); if (!agp_be) return NULL; - agp_priv = drm_ctl_calloc(1, sizeof(*agp_priv), DRM_MEM_MAPPINGS); - - if (!agp_priv) { - drm_ctl_free(agp_be, sizeof(*agp_be), DRM_MEM_MAPPINGS); - return NULL; - } + agp_be->mem = NULL; + agp_be->bridge = dev->agp->bridge; + agp_be->populated = FALSE; + agp_be->backend.func = &agp_ttm_backend; + agp_be->backend.mem_type = DRM_BO_MEM_TT; - agp_priv->mem = NULL; - agp_priv->alloc_type = AGP_USER_MEMORY; - agp_priv->cached_type = AGP_USER_CACHED_MEMORY; - agp_priv->uncached_type = AGP_USER_MEMORY; - agp_priv->bridge = dev->agp->bridge; - agp_priv->populated = FALSE; - agp_be->private = (void *) agp_priv; - agp_be->needs_ub_cache_adjust = drm_agp_needs_unbind_cache_adjust; - agp_be->populate = drm_agp_populate; - agp_be->clear = drm_agp_clear_ttm; - agp_be->bind = drm_agp_bind_ttm; - agp_be->unbind = drm_agp_unbind_ttm; - agp_be->destroy = drm_agp_destroy_ttm; - DRM_FLAG_MASKED(agp_be->flags, (backend == NULL) ? DRM_BE_FLAG_NEEDS_FREE : 0, - DRM_BE_FLAG_NEEDS_FREE); - agp_be->drm_map_type = _DRM_AGP; - return agp_be; + return &agp_be->backend; } EXPORT_SYMBOL(drm_agp_init_ttm); diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index b3155af1..fa26e915 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -234,10 +234,8 @@ extern int drm_fence_ioctl(DRM_IOCTL_ARGS); #define DRM_BE_FLAG_NEEDS_FREE 0x00000001 #define DRM_BE_FLAG_BOUND_CACHED 0x00000002 -typedef struct drm_ttm_backend { - void *private; - uint32_t flags; - uint32_t drm_map_type; +struct drm_ttm_backend; +typedef struct drm_ttm_backend_func { int (*needs_ub_cache_adjust) (struct drm_ttm_backend * backend); int (*populate) (struct drm_ttm_backend * backend, unsigned long num_pages, struct page ** pages); @@ -246,6 +244,13 @@ typedef struct drm_ttm_backend { unsigned long offset, int cached); int (*unbind) (struct drm_ttm_backend * backend); void (*destroy) (struct drm_ttm_backend * backend); +} drm_ttm_backend_func_t; + + +typedef struct drm_ttm_backend { + uint32_t flags; + int mem_type; + drm_ttm_backend_func_t *func; } drm_ttm_backend_t; typedef struct drm_ttm { diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index 25566340..31503c9c 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -154,7 +154,7 @@ int drm_destroy_ttm(drm_ttm_t * ttm) be = ttm->be; if (be) { - be->destroy(be); + be->func->destroy(be); ttm->be = NULL; } @@ -222,7 +222,7 @@ static int drm_ttm_populate(drm_ttm_t * ttm) if (!page) return -ENOMEM; } - be->populate(be, ttm->num_pages, ttm->pages); + be->func->populate(be, ttm->num_pages, ttm->pages); ttm->state = ttm_unbound; return 0; } @@ -281,7 +281,7 @@ void drm_ttm_evict(drm_ttm_t * ttm) int ret; if (ttm->state == ttm_bound) { - ret = be->unbind(be); + ret = be->func->unbind(be); BUG_ON(ret); } @@ -293,7 +293,7 @@ void drm_ttm_fixup_caching(drm_ttm_t * ttm) if (ttm->state == ttm_evicted) { drm_ttm_backend_t *be = ttm->be; - if (be->needs_ub_cache_adjust(be)) { + if (be->func->needs_ub_cache_adjust(be)) { drm_set_caching(ttm, 0); } ttm->state = ttm_unbound; @@ -329,7 +329,7 @@ int drm_bind_ttm(drm_ttm_t * ttm, int cached, unsigned long aper_offset) drm_set_caching(ttm, DRM_TTM_PAGE_UNCACHED); } - if ((ret = be->bind(be, aper_offset, cached))) { + if ((ret = be->func->bind(be, aper_offset, cached))) { ttm->state = ttm_evicted; DRM_ERROR("Couldn't bind backend.\n"); return ret; diff --git a/linux-core/i915_buffer.c b/linux-core/i915_buffer.c index 8797de89..8589f467 100644 --- a/linux-core/i915_buffer.c +++ b/linux-core/i915_buffer.c @@ -35,7 +35,7 @@ drm_ttm_backend_t *i915_create_ttm_backend_entry(drm_device_t * dev) { - return drm_agp_init_ttm(dev, NULL); + return drm_agp_init_ttm(dev); } int i915_fence_types(drm_buffer_object_t *bo, uint32_t * class, uint32_t * type) -- cgit v1.2.3 From 1ce9c092314ddf005cdadc6937e36d4dc59788ce Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Fri, 20 Apr 2007 15:49:31 +0200 Subject: Fix via compile error (Reported by Benno Schulenberg.) --- linux-core/via_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/via_buffer.c b/linux-core/via_buffer.c index f156ee6d..ebc8c371 100644 --- a/linux-core/via_buffer.c +++ b/linux-core/via_buffer.c @@ -34,7 +34,7 @@ drm_ttm_backend_t *via_create_ttm_backend_entry(drm_device_t * dev) { - return drm_agp_init_ttm(dev, NULL); + return drm_agp_init_ttm(dev); } int via_fence_types(drm_buffer_object_t *bo, uint32_t * class, uint32_t * type) -- cgit v1.2.3 From a8a8108e459977ec8b334e517abd67e1b264337e Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 19 Apr 2007 23:25:14 +0200 Subject: Avoid a fence timeout problem when a signal is pending. --- linux-core/drm_fence.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index be075bb3..441e7631 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -295,17 +295,21 @@ static int drm_fence_lazy_wait(drm_device_t *dev, { drm_fence_manager_t *fm = &dev->fm; drm_fence_class_manager_t *fc = &fm->class[fence->class]; - + int signaled; unsigned long _end = jiffies + 3*DRM_HZ; int ret = 0; do { DRM_WAIT_ON(ret, fc->fence_queue, 3 * DRM_HZ, - fence_signaled(dev, fence, mask, 1)); + (signaled = fence_signaled(dev, fence, mask, 1))); + if (signaled) + return 0; if (time_after_eq(jiffies, _end)) break; } while (ret == -EINTR && ignore_signals); - if (time_after_eq(jiffies, _end) && (ret != 0)) + if (fence_signaled(dev, fence, mask, 0)) + return 0; + if (time_after_eq(jiffies, _end)) ret = -EBUSY; if (ret) { if (ret == -EBUSY) { -- cgit v1.2.3 From af3ffcd822e562b02fe0671e7e88d9c5a6225658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 20 Apr 2007 18:06:31 -0400 Subject: Initialize rwlock using rwlock_init to appease lockdep validator. --- linux-core/drm_fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index 441e7631..088c50d6 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -499,7 +499,7 @@ void drm_fence_manager_init(drm_device_t * dev) int i; - fm->lock = RW_LOCK_UNLOCKED; + rwlock_init(&fm->lock); write_lock(&fm->lock); fm->initialized = 0; if (!fed) -- cgit v1.2.3 From 3c384a9ad5f964709a237cfe035ea5d6df2da5fa Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Wed, 11 Apr 2007 12:51:52 -0700 Subject: Add new buffer object type for kernel allocations that don't initially have a user mapping. (cherry picked from commit 2e21779992bd5026d8ec4dea52466377dbe5a0ed) --- linux-core/drm_bo.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 450e448c..9501ba6e 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -89,6 +89,9 @@ static int drm_bo_vm_pre_move(drm_buffer_object_t * bo, int old_is_pci) #ifdef DRM_ODD_MM_COMPAT int ret; + if (!bo->map_list.map) + return 0; + ret = drm_bo_lock_kmm(bo); if (ret) return ret; @@ -96,6 +99,9 @@ static int drm_bo_vm_pre_move(drm_buffer_object_t * bo, int old_is_pci) if (old_is_pci) drm_bo_finish_unmap(bo); #else + if (!bo->map_list.map) + return 0; + drm_bo_unmap_virtual(bo); #endif return 0; @@ -106,6 +112,9 @@ static void drm_bo_vm_post_move(drm_buffer_object_t * bo) #ifdef DRM_ODD_MM_COMPAT int ret; + if (!bo->map_list.map) + return; + ret = drm_bo_remap_bound(bo); if (ret) { DRM_ERROR("Failed to remap a bound buffer object.\n" @@ -131,6 +140,11 @@ static int drm_bo_add_ttm(drm_buffer_object_t * bo) if (!bo->ttm) ret = -ENOMEM; break; + case drm_bo_type_kernel: + bo->ttm = drm_ttm_init(dev, bo->mem.num_pages << PAGE_SHIFT); + if (!bo->ttm) + ret = -ENOMEM; + break; case drm_bo_type_user: case drm_bo_type_fake: break; -- cgit v1.2.3 From 71d44cda52f239b543cb1fad93ef35adc3093d38 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 26 Apr 2007 16:09:24 +1000 Subject: drm/ttm: allow drm_buffer_object_create to be used in-kernel --- linux-core/drm_bo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 9501ba6e..1c7013b3 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1540,7 +1540,7 @@ static int drm_bo_handle_wait(drm_file_t * priv, uint32_t handle, return ret; } -int drm_buffer_object_create(drm_file_t * priv, +int drm_buffer_object_create(drm_device_t *dev, unsigned long size, drm_bo_type_t type, uint32_t mask, @@ -1549,7 +1549,6 @@ int drm_buffer_object_create(drm_file_t * priv, unsigned long buffer_start, drm_buffer_object_t ** buf_obj) { - drm_device_t *dev = priv->head->dev; drm_buffer_manager_t *bm = &dev->bm; drm_buffer_object_t *bo; int ret = 0; @@ -1683,7 +1682,8 @@ int drm_bo_ioctl(DRM_IOCTL_ARGS) if (rep.ret) break; rep.ret = - drm_buffer_object_create(priv, req->size, + drm_buffer_object_create(priv->head->dev, + req->size, req->type, req->mask, req->hint, @@ -2306,6 +2306,9 @@ void drm_bo_unmap_virtual(drm_buffer_object_t * bo) loff_t offset = ((loff_t) bo->map_list.hash.key) << PAGE_SHIFT; loff_t holelen = ((loff_t) bo->mem.num_pages) << PAGE_SHIFT; + if (!dev->dev_mapping) + return; + unmap_mapping_range(dev->dev_mapping, offset, holelen, 1); } -- cgit v1.2.3 From 4b72759b307f046d71c08d9008b7467e0b3bb0ba Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 26 Apr 2007 16:22:11 +1000 Subject: drm: nopfn warning on 64-bit --- linux-core/drm_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 1f905fba..d39dfc77 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -739,7 +739,7 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, unsigned long bus_base; unsigned long bus_offset; unsigned long bus_size; - int ret = NOPFN_REFAULT; + unsigned long ret = NOPFN_REFAULT; if (address > vma->vm_end) return NOPFN_SIGBUS; -- cgit v1.2.3 From e5c1f1caa2a6b8c63aa6d0f8a70372eaf72f1840 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 26 Apr 2007 16:22:28 +1000 Subject: remove some whitespace violation --- linux-core/drm_objects.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index fa26e915..737f0f5d 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -248,9 +248,9 @@ typedef struct drm_ttm_backend_func { typedef struct drm_ttm_backend { - uint32_t flags; - int mem_type; - drm_ttm_backend_func_t *func; + uint32_t flags; + int mem_type; + drm_ttm_backend_func_t *func; } drm_ttm_backend_t; typedef struct drm_ttm { -- cgit v1.2.3 From afc029e935a8f4667aff786c51818712487d185d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 26 Apr 2007 16:25:43 +1000 Subject: whitespace cleanup --- linux-core/drm_fence.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index 088c50d6..ce161dc3 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright (c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA * All Rights Reserved. - * + * * 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 @@ -10,17 +10,17 @@ * distribute, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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 + * 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. * **************************************************************************/ @@ -49,8 +49,6 @@ void drm_fence_handler(drm_device_t * dev, uint32_t class, int is_exe = (type & DRM_FENCE_TYPE_EXE); int ge_last_exe; - - diff = (sequence - fc->exe_flush_sequence) & driver->sequence_mask; if (fc->pending_exe_flush && is_exe && diff < driver->wrap_diff) @@ -59,13 +57,13 @@ void drm_fence_handler(drm_device_t * dev, uint32_t class, diff = (sequence - fc->last_exe_flush) & driver->sequence_mask; ge_last_exe = diff < driver->wrap_diff; - if (ge_last_exe) + if (ge_last_exe) fc->pending_flush &= ~type; if (is_exe && ge_last_exe) { fc->last_exe_flush = sequence; } - + if (list_empty(&fc->ring)) return; @@ -107,9 +105,8 @@ void drm_fence_handler(drm_device_t * dev, uint32_t class, fence->base.hash.key); list_del_init(&fence->ring); } - } - + if (wake) { DRM_WAKEUP(&fc->fence_queue); } @@ -266,7 +263,7 @@ void drm_fence_flush_old(drm_device_t * dev, uint32_t class, uint32_t sequence) fc->exe_flush_sequence = sequence - (driver->flush_diff / 2); } write_unlock_irqrestore(&fm->lock, flags); - + mutex_lock(&dev->struct_mutex); read_lock_irqsave(&fm->lock, flags); @@ -413,7 +410,7 @@ int drm_fence_object_emit(drm_device_t * dev, drm_fence_object_t * fence, fence->signaled = 0x00; fence->sequence = sequence; fence->native_type = native_type; - if (list_empty(&fc->ring)) + if (list_empty(&fc->ring)) fc->last_exe_flush = sequence - 1; list_add_tail(&fence->ring, &fc->ring); write_unlock_irqrestore(&fm->lock, flags); @@ -498,7 +495,6 @@ void drm_fence_manager_init(drm_device_t * dev) drm_fence_driver_t *fed = dev->driver->fence_driver; int i; - rwlock_init(&fm->lock); write_lock(&fm->lock); fm->initialized = 0; -- cgit v1.2.3 From 3a2c9f46212328a44533a45523d2a9f9b72a15da Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 26 Apr 2007 14:16:28 +0300 Subject: linux: minor indent. --- linux-core/drm_vm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index d39dfc77..b8871539 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -516,8 +516,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) return -EINVAL; } - if (!capable(CAP_SYS_ADMIN) && - (dma->flags & _DRM_DMA_USE_PCI_RO)) { + if (!capable(CAP_SYS_ADMIN) && (dma->flags & _DRM_DMA_USE_PCI_RO)) { vma->vm_flags &= ~(VM_WRITE | VM_MAYWRITE); #if defined(__i386__) || defined(__x86_64__) pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; -- cgit v1.2.3 From 9f9c19065cecde16aa2994b6f777336a6e5f3409 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 28 Apr 2007 14:49:27 +1000 Subject: remove DRM_GETSAREA and replace with drm_getsarea function --- linux-core/drmP.h | 2 ++ linux-core/drm_drv.c | 14 ++++++++++++++ linux-core/drm_os_linux.h | 18 ------------------ 3 files changed, 16 insertions(+), 18 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 271c6c8e..37b93525 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -1128,6 +1128,8 @@ extern drm_head_t **drm_heads; extern struct drm_sysfs_class *drm_class; extern struct proc_dir_entry *drm_proc_root; +extern drm_local_map_t *drm_getsarea(struct drm_device *dev); + /* Proc support (drm_proc.h) */ extern int drm_proc_init(drm_device_t * dev, int minor, diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index b95f796f..3dc4d53c 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -622,3 +622,17 @@ err_i1: return retcode; } EXPORT_SYMBOL(drm_ioctl); + +drm_local_map_t *drm_getsarea(struct drm_device *dev) +{ + drm_map_list_t *entry; + + list_for_each_entry(entry, &dev->maplist->head, head) { + if (entry->map && entry->map->type == _DRM_SHM && + (entry->map->flags & _DRM_CONTAINS_LOCK)) { + return entry->map; + } + } + return NULL; +} +EXPORT_SYMBOL(drm_getsarea); diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h index 816959e8..2ea105c5 100644 --- a/linux-core/drm_os_linux.h +++ b/linux-core/drm_os_linux.h @@ -119,24 +119,6 @@ static __inline__ int mtrr_del(int reg, unsigned long base, unsigned long size) #define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data -/** - * Get the pointer to the SAREA. - * - * Searches the SAREA on the mapping lists and points drm_device::sarea to it. - */ -#define DRM_GETSAREA() \ -do { \ - drm_map_list_t *entry; \ - list_for_each_entry( entry, &dev->maplist->head, head ) { \ - if ( entry->map && \ - entry->map->type == _DRM_SHM && \ - (entry->map->flags & _DRM_CONTAINS_LOCK) ) { \ - dev_priv->sarea = entry->map; \ - break; \ - } \ - } \ -} while (0) - #define DRM_HZ HZ #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ -- cgit v1.2.3 From e9b3acd25733517420f7b9fea01cfd529d909348 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 28 Apr 2007 15:04:49 +1000 Subject: remove register usage --- linux-core/drm_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index 86c869f1..759e1f15 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -47,7 +47,7 @@ static struct { static inline size_t drm_size_align(size_t size) { - register size_t tmpSize = 4; + size_t tmpSize = 4; if (size > PAGE_SIZE) return PAGE_ALIGN(size); -- cgit v1.2.3 From 6e860d08d0f5b1e9a2d711aaf9fd6b982aa8039e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 28 Apr 2007 15:05:20 +1000 Subject: drm: add new drm_wait_on function to replace macro --- linux-core/drmP.h | 4 +++- linux-core/drm_drv.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 37b93525..a3f9ca86 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -1129,7 +1129,9 @@ extern struct drm_sysfs_class *drm_class; extern struct proc_dir_entry *drm_proc_root; extern drm_local_map_t *drm_getsarea(struct drm_device *dev); - +extern int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, + int timeout, int (*fn)(drm_device_t *dev, void *priv), + void *priv); /* Proc support (drm_proc.h) */ extern int drm_proc_init(drm_device_t * dev, int minor, diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 3dc4d53c..e5788d76 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -623,6 +623,34 @@ err_i1: } EXPORT_SYMBOL(drm_ioctl); +int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, int timeout, + int (*fn)(drm_device_t *dev, void *priv), void *priv) +{ + DECLARE_WAITQUEUE(entry, current); + unsigned long end = jiffies + (timeout); + int ret = 0; + add_wait_queue(queue, &entry); + + for (;;) { + __set_current_state(TASK_INTERRUPTIBLE); + if ((*fn)(dev, priv)) + break; + if (time_after_eq(jiffies, end)) { + ret = -EBUSY; + break; + } + schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); + if (signal_pending(current)) { + ret = -EINTR; + break; + } + } + __set_current_state(TASK_RUNNING); + remove_wait_queue(queue, &entry); + return ret; +} +EXPORT_SYMBOL(drm_wait_on); + drm_local_map_t *drm_getsarea(struct drm_device *dev) { drm_map_list_t *entry; -- cgit v1.2.3 From c9cd2c768bd37adadb87476f55f95e7b2336bc6b Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 6 May 2007 10:50:10 +1000 Subject: drm: remove unused define DRM_HAS_TTM --- linux-core/drm_objects.h | 1 - 1 file changed, 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 737f0f5d..ea300c18 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -30,7 +30,6 @@ #ifndef _DRM_OBJECTS_H #define _DRM_OJBECTS_H -#define DRM_HAS_TTM struct drm_device; -- cgit v1.2.3 From c4e2caec44c5c1837d676ff0f5ad0747b2e570a7 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 6 May 2007 10:09:59 -0600 Subject: s/OJBECTS/OBJECTS/ --- linux-core/drm_objects.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index ea300c18..03ea927e 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -29,7 +29,7 @@ */ #ifndef _DRM_OBJECTS_H -#define _DRM_OJBECTS_H +#define _DRM_OBJECTS_H struct drm_device; -- cgit v1.2.3 From ea98d7e79657469545b865a353784d79fc8cff9d Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Thu, 17 May 2007 17:35:14 +0200 Subject: nouveau: don't build the module by default --- linux-core/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'linux-core') diff --git a/linux-core/Makefile b/linux-core/Makefile index af29bd6a..1758777c 100644 --- a/linux-core/Makefile +++ b/linux-core/Makefile @@ -283,6 +283,7 @@ CONFIG_DRM_SAVAGE := n CONFIG_DRM_VIA := n CONFIG_DRM_MACH64 := n CONFIG_DRM_NV := n +CONFIG_DRM_NOUVEAU := n # Enable module builds for the modules requested/supported. -- cgit v1.2.3 From 7b48f0022a24bc5f565ae64b450dda77dee616c1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 26 May 2007 04:26:24 +1000 Subject: drm: cleanup use of Linux list handling macros This makes the drms use of the list handling macros a lot cleaner and more along the lines of how they should be used. --- linux-core/drmP.h | 32 ++++++++++++------------------- linux-core/drm_agpsupport.c | 28 ++++++++++----------------- linux-core/drm_bufs.c | 43 +++++++++++++++++++----------------------- linux-core/drm_context.c | 12 +++++------- linux-core/drm_drv.c | 44 ++++++++++++++++--------------------------- linux-core/drm_fops.c | 46 ++++++++++++--------------------------------- linux-core/drm_ioctl.c | 14 ++++++++++---- linux-core/drm_irq.c | 20 +++++++++----------- linux-core/drm_memory.c | 2 +- linux-core/drm_proc.c | 19 ++++++++----------- linux-core/drm_stub.c | 9 ++------- linux-core/drm_vm.c | 33 +++++++++----------------------- linux-core/i810_dma.c | 6 ++---- linux-core/sis_mm.c | 2 +- 14 files changed, 116 insertions(+), 194 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index a3f9ca86..6cede35e 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -300,19 +300,14 @@ typedef struct drm_devstate { } drm_devstate_t; typedef struct drm_magic_entry { - drm_hash_item_t hash_item; struct list_head head; + drm_hash_item_t hash_item; struct drm_file *priv; } drm_magic_entry_t; -typedef struct drm_magic_head { - struct drm_magic_entry *head; - struct drm_magic_entry *tail; -} drm_magic_head_t; - typedef struct drm_vma_entry { + struct list_head head; struct vm_area_struct *vma; - struct drm_vma_entry *next; pid_t pid; } drm_vma_entry_t; @@ -411,8 +406,7 @@ typedef struct drm_file { uid_t uid; drm_magic_t magic; unsigned long ioctl_count; - struct drm_file *next; - struct drm_file *prev; + struct list_head lhead; struct drm_head *head; int remove_auth_on_close; unsigned long lock_count; @@ -493,8 +487,7 @@ typedef struct drm_agp_mem { DRM_AGP_MEM *memory; unsigned long bound; /**< address */ int pages; - struct drm_agp_mem *prev; /**< previous entry */ - struct drm_agp_mem *next; /**< next entry */ + struct list_head head; } drm_agp_mem_t; /** @@ -504,7 +497,7 @@ typedef struct drm_agp_mem { */ typedef struct drm_agp_head { DRM_AGP_KERN agp_info; /**< AGP device information */ - drm_agp_mem_t *memory; /**< memory entries */ + struct list_head memory; unsigned long mode; /**< AGP mode */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11) struct agp_bridge_data *bridge; @@ -726,15 +719,14 @@ typedef struct drm_device { /** \name Authentication */ /*@{ */ - drm_file_t *file_first; /**< file list head */ - drm_file_t *file_last; /**< file list tail */ + struct list_head filelist; drm_open_hash_t magiclist; struct list_head magicfree; /*@} */ /** \name Memory management */ /*@{ */ - drm_map_list_t *maplist; /**< Linked list of regions */ + struct list_head maplist; /**< Linked list of regions */ int map_count; /**< Number of mappable regions */ drm_open_hash_t map_hash; /**< User token hash table for maps */ drm_mm_t offset_manager; /**< User token manager */ @@ -744,14 +736,14 @@ typedef struct drm_device { /** \name Context handle management */ /*@{ */ - drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ + struct list_head ctxlist; /**< Linked list of context handles */ int ctx_count; /**< Number of context handles */ struct mutex ctxlist_mutex; /**< For ctxlist */ drm_map_t **context_sareas; /**< per-context SAREA's */ int max_context; - drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */ + struct list_head vmalist; /**< List of vmas (for debugging) */ drm_lock_data_t lock; /**< Information on hardware lock */ /*@} */ @@ -787,8 +779,8 @@ typedef struct drm_device { atomic_t vbl_received; atomic_t vbl_received2; /**< number of secondary VBLANK interrupts */ spinlock_t vbl_lock; - drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */ - drm_vbl_sig_t vbl_sigs2; /**< signals to send on secondary VBLANK */ + struct list_head vbl_sigs; /**< signal list to send on VBLANK */ + struct list_head vbl_sigs2; /**< signals to send on secondary VBLANK */ unsigned int vbl_pending; spinlock_t tasklet_lock; /**< For drm_locked_tasklet */ void (*locked_tasklet_func)(struct drm_device *dev); @@ -1194,7 +1186,7 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsigned int token) { drm_map_list_t *_entry; - list_for_each_entry(_entry, &dev->maplist->head, head) + list_for_each_entry(_entry, &dev->maplist, head) if (_entry->user_token == token) return _entry->map; return NULL; diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 7d8f0737..f134563a 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -249,11 +249,7 @@ int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) entry->memory = memory; entry->bound = 0; entry->pages = pages; - entry->prev = NULL; - entry->next = dev->agp->memory; - if (dev->agp->memory) - dev->agp->memory->prev = entry; - dev->agp->memory = entry; + list_add(&entry->head, &dev->agp->memory); request->handle = entry->handle; request->physical = memory->physical; @@ -280,10 +276,12 @@ int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, return err; if (copy_to_user(argp, &request, sizeof(request))) { - drm_agp_mem_t *entry = dev->agp->memory; - - dev->agp->memory = entry->next; - dev->agp->memory->prev = NULL; + drm_agp_mem_t *entry; + list_for_each_entry(entry, &dev->agp->memory, head) { + if (entry->handle == request.handle) + break; + } + list_del(&entry->head); drm_free_agp(entry->memory, entry->pages); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return -EFAULT; @@ -306,7 +304,7 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev, { drm_agp_mem_t *entry; - for (entry = dev->agp->memory; entry; entry = entry->next) { + list_for_each_entry(entry, &dev->agp->memory, head) { if (entry->handle == handle) return entry; } @@ -435,13 +433,7 @@ int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) if (entry->bound) drm_unbind_agp(entry->memory); - if (entry->prev) - entry->prev->next = entry->next; - else - dev->agp->memory = entry->next; - - if (entry->next) - entry->next->prev = entry->prev; + list_del(&entry->head); drm_free_agp(entry->memory, entry->pages); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); @@ -502,7 +494,7 @@ drm_agp_head_t *drm_agp_init(drm_device_t *dev) drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); return NULL; } - head->memory = NULL; + INIT_LIST_HEAD(&head->memory); head->cant_use_aperture = head->agp_info.cant_use_aperture; head->page_mask = head->agp_info.page_mask; return head; diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 8793ba0e..a2c8a75e 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -51,10 +51,8 @@ EXPORT_SYMBOL(drm_get_resource_len); static drm_map_list_t *drm_find_matching_map(drm_device_t *dev, drm_local_map_t *map) { - struct list_head *list; - - list_for_each(list, &dev->maplist->head) { - drm_map_list_t *entry = list_entry(list, drm_map_list_t, head); + drm_map_list_t *entry; + list_for_each_entry(entry, &dev->maplist, head) { if (entry->map && map->type == entry->map->type && ((entry->map->offset == map->offset) || (map->type == _DRM_SHM && map->flags==_DRM_CONTAINS_LOCK))) { @@ -237,14 +235,14 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, * skipped and we double check that dev->agp->memory is * actually set as well as being invalid before EPERM'ing */ - for (entry = dev->agp->memory; entry; entry = entry->next) { + list_for_each_entry(entry, &dev->agp->memory, head) { if ((map->offset >= entry->bound) && (map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) { valid = 1; break; } } - if (dev->agp->memory && !valid) { + if (!list_empty(&dev->agp->memory) && !valid) { drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EPERM; } @@ -288,7 +286,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, list->map = map; mutex_lock(&dev->struct_mutex); - list_add(&list->head, &dev->maplist->head); + list_add(&list->head, &dev->maplist); /* Assign a 32-bit handle */ @@ -380,29 +378,28 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp, */ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map) { - struct list_head *list; - drm_map_list_t *r_list = NULL; + drm_map_list_t *r_list = NULL, *list_t; drm_dma_handle_t dmah; + int found = 0; /* Find the list entry for the map and remove it */ - list_for_each(list, &dev->maplist->head) { - r_list = list_entry(list, drm_map_list_t, head); - + list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) { if (r_list->map == map) { - list_del(list); + list_del(&r_list->head); drm_ht_remove_key(&dev->map_hash, r_list->user_token >> PAGE_SHIFT); - drm_free(list, sizeof(*list), DRM_MEM_MAPS); + drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS); + found = 1; break; } } + if (!found) { + return -EINVAL; + } /* List has wrapped around to the head pointer, or it's empty and we * didn't find anything. */ - if (list == (&dev->maplist->head)) { - return -EINVAL; - } switch (map->type) { case _DRM_REGISTERS: @@ -464,7 +461,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp, drm_device_t *dev = priv->head->dev; drm_map_t request; drm_local_map_t *map = NULL; - struct list_head *list; + drm_map_list_t *r_list; int ret; if (copy_from_user(&request, (drm_map_t __user *) arg, sizeof(request))) { @@ -472,9 +469,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp, } mutex_lock(&dev->struct_mutex); - list_for_each(list, &dev->maplist->head) { - drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); - + list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map && r_list->user_token == (unsigned long)request.handle && r_list->map->flags & _DRM_REMOVABLE) { @@ -486,7 +481,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp, /* List has wrapped around to the head pointer, or its empty we didn't * find anything. */ - if (list == (&dev->maplist->head)) { + if (list_empty(&dev->maplist) || !map) { mutex_unlock(&dev->struct_mutex); return -EINVAL; } @@ -610,14 +605,14 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) /* Make sure buffers are located in AGP memory that we own */ valid = 0; - for (agp_entry = dev->agp->memory; agp_entry; agp_entry = agp_entry->next) { + list_for_each_entry(agp_entry, &dev->agp->memory, head) { if ((agp_offset >= agp_entry->bound) && (agp_offset + total * count <= agp_entry->bound + agp_entry->pages * PAGE_SIZE)) { valid = 1; break; } } - if (dev->agp->memory && !valid) { + if (!list_empty(&dev->agp->memory) && !valid) { DRM_DEBUG("zone invalid\n"); return -EINVAL; } diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c index 49042272..3bfee127 100644 --- a/linux-core/drm_context.c +++ b/linux-core/drm_context.c @@ -233,7 +233,7 @@ int drm_getsareactx(struct inode *inode, struct file *filp, mutex_unlock(&dev->struct_mutex); request.handle = NULL; - list_for_each_entry(_entry, &dev->maplist->head,head) { + list_for_each_entry(_entry, &dev->maplist, head) { if (_entry->map == map) { request.handle = (void *)(unsigned long)_entry->user_token; @@ -268,15 +268,13 @@ int drm_setsareactx(struct inode *inode, struct file *filp, drm_ctx_priv_map_t request; drm_map_t *map = NULL; drm_map_list_t *r_list = NULL; - struct list_head *list; if (copy_from_user(&request, (drm_ctx_priv_map_t __user *) arg, sizeof(request))) return -EFAULT; mutex_lock(&dev->struct_mutex); - list_for_each(list, &dev->maplist->head) { - r_list = list_entry(list, drm_map_list_t, head); + list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map && r_list->user_token == (unsigned long) request.handle) goto found; @@ -449,7 +447,7 @@ int drm_addctx(struct inode *inode, struct file *filp, ctx_entry->tag = priv; mutex_lock(&dev->ctxlist_mutex); - list_add(&ctx_entry->head, &dev->ctxlist->head); + list_add(&ctx_entry->head, &dev->ctxlist); ++dev->ctx_count; mutex_unlock(&dev->ctxlist_mutex); @@ -575,10 +573,10 @@ int drm_rmctx(struct inode *inode, struct file *filp, } mutex_lock(&dev->ctxlist_mutex); - if (!list_empty(&dev->ctxlist->head)) { + if (!list_empty(&dev->ctxlist)) { drm_ctx_list_t *pos, *n; - list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { + list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { if (pos->handle == ctx.handle) { list_del(&pos->head); drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index e5788d76..9a0ecdf8 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -140,8 +140,8 @@ static drm_ioctl_desc_t drm_ioctls[] = { int drm_lastclose(drm_device_t * dev) { drm_magic_entry_t *pt, *next; - drm_map_list_t *r_list; - drm_vma_entry_t *vma, *vma_next; + drm_map_list_t *r_list, *list_t; + drm_vma_entry_t *vma, *vma_temp; int i; DRM_DEBUG("\n"); @@ -198,19 +198,17 @@ int drm_lastclose(drm_device_t * dev) /* Clear AGP information */ if (drm_core_has_AGP(dev) && dev->agp) { - drm_agp_mem_t *entry; - drm_agp_mem_t *nexte; + drm_agp_mem_t *entry, *tempe; /* Remove AGP resources, but leave dev->agp intact until drv_cleanup is called. */ - for (entry = dev->agp->memory; entry; entry = nexte) { - nexte = entry->next; + list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) { if (entry->bound) drm_unbind_agp(entry->memory); drm_free_agp(entry->memory, entry->pages); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } - dev->agp->memory = NULL; + INIT_LIST_HEAD(&dev->agp->memory); if (dev->agp->acquired) drm_agp_release(dev); @@ -224,20 +222,14 @@ int drm_lastclose(drm_device_t * dev) } /* Clear vma list (only built for debugging) */ - if (dev->vmalist) { - for (vma = dev->vmalist; vma; vma = vma_next) { - vma_next = vma->next; - drm_ctl_free(vma, sizeof(*vma), DRM_MEM_VMAS); - } - dev->vmalist = NULL; + list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { + list_del(&vma->head); + drm_ctl_free(vma, sizeof(*vma), DRM_MEM_VMAS); } - - if (dev->maplist) { - while (!list_empty(&dev->maplist->head)) { - struct list_head *list = dev->maplist->head.next; - r_list = list_entry(list, drm_map_list_t, head); - drm_rmmap_locked(dev, r_list->map); - } + + list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) { + drm_rmmap_locked(dev, r_list->map); + r_list = NULL; } if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { @@ -372,13 +364,9 @@ static void drm_cleanup(drm_device_t * dev) drm_lastclose(dev); drm_fence_manager_takedown(dev); - if (dev->maplist) { - drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); - dev->maplist = NULL; - drm_ht_remove(&dev->map_hash); - drm_mm_takedown(&dev->offset_manager); - drm_ht_remove(&dev->object_hash); - } + drm_ht_remove(&dev->map_hash); + drm_mm_takedown(&dev->offset_manager); + drm_ht_remove(&dev->object_hash); if (!drm_fb_loaded) pci_disable_device(dev->pdev); @@ -655,7 +643,7 @@ drm_local_map_t *drm_getsarea(struct drm_device *dev) { drm_map_list_t *entry; - list_for_each_entry(entry, &dev->maplist->head, head) { + list_for_each_entry(entry, &dev->maplist, head) { if (entry->map && entry->map->type == _DRM_SHM && (entry->map->flags & _DRM_CONTAINS_LOCK)) { return entry->map; diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index d400a4d5..fce2be97 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -79,13 +79,9 @@ static int drm_setup(drm_device_t * dev) drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); INIT_LIST_HEAD(&dev->magicfree); - dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST); - if (dev->ctxlist == NULL) - return -ENOMEM; - memset(dev->ctxlist, 0, sizeof(*dev->ctxlist)); - INIT_LIST_HEAD(&dev->ctxlist->head); + INIT_LIST_HEAD(&dev->ctxlist); + INIT_LIST_HEAD(&dev->vmalist); - dev->vmalist = NULL; dev->sigdata.lock = NULL; init_waitqueue_head(&dev->lock.lock_queue); dev->queue_count = 0; @@ -268,6 +264,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; + INIT_LIST_HEAD(&priv->lhead); INIT_LIST_HEAD(&priv->user_objects); INIT_LIST_HEAD(&priv->refd_objects); @@ -291,19 +288,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp, } mutex_lock(&dev->struct_mutex); - if (!dev->file_last) { - priv->next = NULL; - priv->prev = NULL; - dev->file_first = priv; - dev->file_last = priv; - /* first opener automatically becomes master */ + if (list_empty(&dev->filelist)) priv->master = 1; - } else { - priv->next = NULL; - priv->prev = dev->file_last; - dev->file_last->next = priv; - dev->file_last = priv; - } + + list_add(&priv->lhead, &dev->filelist); mutex_unlock(&dev->struct_mutex); #ifdef __alpha__ @@ -480,10 +468,10 @@ int drm_release(struct inode *inode, struct file *filp) mutex_lock(&dev->ctxlist_mutex); - if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { + if (!list_empty(&dev->ctxlist)) { drm_ctx_list_t *pos, *n; - list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { + list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { if (pos->tag == priv && pos->handle != DRM_KERNEL_CONTEXT) { if (dev->driver->context_dtor) @@ -503,22 +491,12 @@ int drm_release(struct inode *inode, struct file *filp) mutex_lock(&dev->struct_mutex); drm_object_release(filp); if (priv->remove_auth_on_close == 1) { - drm_file_t *temp = dev->file_first; - while (temp) { + drm_file_t *temp; + + list_for_each_entry(temp, &dev->filelist, lhead) temp->authenticated = 0; - temp = temp->next; - } - } - if (priv->prev) { - priv->prev->next = priv->next; - } else { - dev->file_first = priv->next; - } - if (priv->next) { - priv->next->prev = priv->prev; - } else { - dev->file_last = priv->prev; } + list_del(&priv->lhead); mutex_unlock(&dev->struct_mutex); if (dev->driver->postclose) diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c index f790a4b3..97df972f 100644 --- a/linux-core/drm_ioctl.c +++ b/linux-core/drm_ioctl.c @@ -199,7 +199,7 @@ int drm_getmap(struct inode *inode, struct file *filp, } i = 0; - list_for_each(list, &dev->maplist->head) { + list_for_each(list, &dev->maplist) { if (i == idx) { r_list = list_entry(list, drm_map_list_t, head); break; @@ -252,12 +252,18 @@ int drm_getclient(struct inode *inode, struct file *filp, return -EFAULT; idx = client.idx; mutex_lock(&dev->struct_mutex); - for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ; - - if (!pt) { + + if (list_empty(&dev->filelist)) { mutex_unlock(&dev->struct_mutex); return -EINVAL; } + + i = 0; + list_for_each_entry(pt, &dev->filelist, lhead) { + if (i++ >= idx) + break; + } + client.auth = pt->authenticated; client.pid = pt->pid; client.uid = pt->uid; diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c index b0f6e3e1..88716712 100644 --- a/linux-core/drm_irq.c +++ b/linux-core/drm_irq.c @@ -119,8 +119,8 @@ static int drm_irq_install(drm_device_t * dev) spin_lock_init(&dev->vbl_lock); - INIT_LIST_HEAD(&dev->vbl_sigs.head); - INIT_LIST_HEAD(&dev->vbl_sigs2.head); + INIT_LIST_HEAD(&dev->vbl_sigs); + INIT_LIST_HEAD(&dev->vbl_sigs2); dev->vbl_pending = 0; } @@ -290,7 +290,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) if (flags & _DRM_VBLANK_SIGNAL) { unsigned long irqflags; - drm_vbl_sig_t *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY) + struct list_head *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY) ? &dev->vbl_sigs2 : &dev->vbl_sigs; drm_vbl_sig_t *vbl_sig; @@ -300,7 +300,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) * for the same vblank sequence number; nothing to be done in * that case */ - list_for_each_entry(vbl_sig, &vbl_sigs->head, head) { + list_for_each_entry(vbl_sig, vbl_sigs, head) { if (vbl_sig->sequence == vblwait.request.sequence && vbl_sig->info.si_signo == vblwait.request.signal && vbl_sig->task == current) { @@ -334,7 +334,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) spin_lock_irqsave(&dev->vbl_lock, irqflags); - list_add_tail((struct list_head *)vbl_sig, &vbl_sigs->head); + list_add_tail(&vbl_sig->head, vbl_sigs); spin_unlock_irqrestore(&dev->vbl_lock, irqflags); @@ -377,20 +377,18 @@ void drm_vbl_send_signals(drm_device_t * dev) spin_lock_irqsave(&dev->vbl_lock, flags); for (i = 0; i < 2; i++) { - struct list_head *list, *tmp; - drm_vbl_sig_t *vbl_sig; - drm_vbl_sig_t *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs; + drm_vbl_sig_t *vbl_sig, *tmp; + struct list_head *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs; unsigned int vbl_seq = atomic_read(i ? &dev->vbl_received2 : &dev->vbl_received); - list_for_each_safe(list, tmp, &vbl_sigs->head) { - vbl_sig = list_entry(list, drm_vbl_sig_t, head); + list_for_each_entry_safe(vbl_sig, tmp, vbl_sigs, head) { if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) { vbl_sig->info.si_code = vbl_seq; send_sig_info(vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task); - list_del(list); + list_del(&vbl_sig->head); drm_free(vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER); diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index 759e1f15..b1423c12 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -228,7 +228,7 @@ static void *agp_remap(unsigned long offset, unsigned long size, offset -= dev->hose->mem_space->start; #endif - for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) + list_for_each_entry(agpmem, &dev->agp->memory, head) if (agpmem->bound <= offset && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= (offset + size)) diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index af62c62a..e93a0406 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -211,7 +211,6 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, int len = 0; drm_map_t *map; drm_map_list_t *r_list; - struct list_head *list; /* Hardcoded from _DRM_FRAME_BUFFER, _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, @@ -231,9 +230,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, DRM_PROC_PRINT("slot offset size type flags " "address mtrr\n\n"); i = 0; - if (dev->maplist != NULL) - list_for_each(list, &dev->maplist->head) { - r_list = list_entry(list, drm_map_list_t, head); + list_for_each_entry(r_list, &dev->maplist, head) { map = r_list->map; if (!map) continue; @@ -242,10 +239,10 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, else type = types[map->type]; DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ", - i, - map->offset, - map->size, type, map->flags, - (unsigned long) r_list->user_token); + i, + map->offset, + map->size, type, map->flags, + (unsigned long) r_list->user_token); if (map->mtrr < 0) { DRM_PROC_PRINT("none\n"); @@ -253,7 +250,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, DRM_PROC_PRINT("%4d\n", map->mtrr); } i++; - } + } if (len > request + offset) return request; @@ -535,7 +532,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset, *eof = 0; DRM_PROC_PRINT("a dev pid uid magic ioctls\n\n"); - for (priv = dev->file_first; priv; priv = priv->next) { + list_for_each_entry(priv, &dev->filelist, lhead) { DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n", priv->authenticated ? 'y' : 'n', priv->minor, @@ -588,7 +585,7 @@ static int drm__vma_info(char *buf, char **start, off_t offset, int request, DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n", atomic_read(&dev->vma_count), high_memory, virt_to_phys(high_memory)); - for (pt = dev->vmalist; pt; pt = pt->next) { + list_for_each_entry(pt, &dev->vmalist, head) { if (!(vma = pt->vma)) continue; DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000", diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index f4da7dac..bcbabf8d 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -60,6 +60,7 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, { int retcode; + INIT_LIST_HEAD(&dev->filelist); spin_lock_init(&dev->count_lock); spin_lock_init(&dev->drw_lock); spin_lock_init(&dev->tasklet_lock); @@ -80,27 +81,21 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, dev->irq = pdev->irq; if (drm_ht_create(&dev->map_hash, DRM_MAP_HASH_ORDER)) { - drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); return -ENOMEM; } if (drm_mm_init(&dev->offset_manager, DRM_FILE_PAGE_OFFSET_START, DRM_FILE_PAGE_OFFSET_SIZE)) { - drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); drm_ht_remove(&dev->map_hash); return -ENOMEM; } if (drm_ht_create(&dev->object_hash, DRM_OBJECT_HASH_ORDER)) { - drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); drm_ht_remove(&dev->map_hash); drm_mm_takedown(&dev->offset_manager); return -ENOMEM; } - dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS); - if (dev->maplist == NULL) - return -ENOMEM; - INIT_LIST_HEAD(&dev->maplist->head); + INIT_LIST_HEAD(&dev->maplist); /* the DRM has 6 counters */ dev->counters = 6; diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index b8871539..f2c43508 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -122,7 +122,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, /* * It's AGP memory - find the real physical page to map */ - for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) { + list_for_each_entry(agpmem, &dev->agp->memory, head) { if (agpmem->bound <= baddr && agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) break; @@ -205,10 +205,9 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->head->dev; - drm_vma_entry_t *pt, *prev, *next; + drm_vma_entry_t *pt, *temp; drm_map_t *map; drm_map_list_t *r_list; - struct list_head *list; int found_maps = 0; DRM_DEBUG("0x%08lx,0x%08lx\n", @@ -218,19 +217,12 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) map = vma->vm_private_data; mutex_lock(&dev->struct_mutex); - for (pt = dev->vmalist, prev = NULL; pt; pt = next) { - next = pt->next; + list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { if (pt->vma->vm_private_data == map) found_maps++; if (pt->vma == vma) { - if (prev) { - prev->next = pt->next; - } else { - dev->vmalist = pt->next; - } + list_del(&pt->head); drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS); - } else { - prev = pt; } } /* We were the only map that was found */ @@ -239,9 +231,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) * we delete this mappings information. */ found_maps = 0; - list = &dev->maplist->head; - list_for_each(list, &dev->maplist->head) { - r_list = list_entry(list, drm_map_list_t, head); + list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map == map) found_maps++; } @@ -439,9 +429,8 @@ static void drm_vm_open_locked(struct vm_area_struct *vma) vma_entry = drm_ctl_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); if (vma_entry) { vma_entry->vma = vma; - vma_entry->next = dev->vmalist; vma_entry->pid = current->pid; - dev->vmalist = vma_entry; + list_add(&vma_entry->head, &dev->vmalist); } } @@ -467,20 +456,16 @@ static void drm_vm_close(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->head->dev; - drm_vma_entry_t *pt, *prev; + drm_vma_entry_t *pt, *temp; DRM_DEBUG("0x%08lx,0x%08lx\n", vma->vm_start, vma->vm_end - vma->vm_start); atomic_dec(&dev->vma_count); mutex_lock(&dev->struct_mutex); - for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { + list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { if (pt->vma == vma) { - if (prev) { - prev->next = pt->next; - } else { - dev->vmalist = pt->next; - } + list_del(&pt->head); drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS); break; } diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c index 3f2dad38..49379434 100644 --- a/linux-core/i810_dma.c +++ b/linux-core/i810_dma.c @@ -346,12 +346,10 @@ static int i810_dma_initialize(drm_device_t * dev, drm_i810_private_t * dev_priv, drm_i810_init_t * init) { - struct list_head *list; - + drm_map_list_t *r_list; memset(dev_priv, 0, sizeof(drm_i810_private_t)); - list_for_each(list, &dev->maplist->head) { - drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); + list_for_each_entry(r_list, &dev->maplist, head) { if (r_list->map && r_list->map->type == _DRM_SHM && r_list->map->flags & _DRM_CONTAINS_LOCK) { diff --git a/linux-core/sis_mm.c b/linux-core/sis_mm.c index 5efbada4..21c1f2d7 100644 --- a/linux-core/sis_mm.c +++ b/linux-core/sis_mm.c @@ -233,7 +233,7 @@ static drm_local_map_t *sis_reg_init(drm_device_t *dev) drm_map_list_t *entry; drm_local_map_t *map; - list_for_each_entry(entry, &dev->maplist->head, head) { + list_for_each_entry(entry, &dev->maplist, head) { map = entry->map; if (!map) continue; -- cgit v1.2.3 From 3fdef0dc2000308b16907b95f637c60acde80a74 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 6 May 2007 11:17:30 +1000 Subject: drm/ttm: cleanup mm_ioctl ioctls to be separate ioctls. This is the first bunch of ioctls --- linux-core/drm_bo.c | 160 ++++++++++++++++++++++++++++++++--------------- linux-core/drm_compat.c | 3 +- linux-core/drm_drv.c | 12 +++- linux-core/drm_objects.h | 3 + 4 files changed, 123 insertions(+), 55 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 1c7013b3..f78a6f95 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -2158,11 +2158,48 @@ EXPORT_SYMBOL(drm_bo_driver_init); int drm_mm_init_ioctl(DRM_IOCTL_ARGS) { DRM_DEVICE; + struct drm_mm_init_arg arg; + drm_buffer_manager_t *bm = &dev->bm; + drm_bo_driver_t *driver = dev->driver->bo_driver; + int ret; - int ret = 0; - drm_mm_init_arg_t arg; + if (!driver) { + DRM_ERROR("Buffer objects are not supported by this driver\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + ret = -EINVAL; + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + if (!bm->initialized) { + DRM_ERROR("DRM memory manager was not initialized.\n"); + goto out; + } + if (arg.mem_type == 0) { + DRM_ERROR("System memory buffers already initialized.\n"); + goto out; + } + ret = drm_bo_init_mm(dev, arg.mem_type, + arg.p_offset, arg.p_size); + +out: + mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->bm.init_mutex); + if (ret) + return ret; + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return 0; +} + +int drm_mm_takedown_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + struct drm_mm_type_arg arg; drm_buffer_manager_t *bm = &dev->bm; drm_bo_driver_t *driver = dev->driver->bo_driver; + int ret; if (!driver) { DRM_ERROR("Buffer objects are not supported by this driver\n"); @@ -2171,59 +2208,78 @@ int drm_mm_init_ioctl(DRM_IOCTL_ARGS) DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - switch (arg.req.op) { - case mm_init: - ret = -EINVAL; - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - if (!bm->initialized) { - DRM_ERROR("DRM memory manager was not initialized.\n"); - break; - } - if (arg.req.mem_type == 0) { - DRM_ERROR - ("System memory buffers already initialized.\n"); - break; - } - ret = drm_bo_init_mm(dev, arg.req.mem_type, - arg.req.p_offset, arg.req.p_size); - break; - case mm_takedown: - LOCK_TEST_WITH_RETURN(dev, filp); - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - ret = -EINVAL; - if (!bm->initialized) { - DRM_ERROR("DRM memory manager was not initialized\n"); - break; - } - if (arg.req.mem_type == 0) { - DRM_ERROR("No takedown for System memory buffers.\n"); - break; - } - ret = 0; - if (drm_bo_clean_mm(dev, arg.req.mem_type)) { - DRM_ERROR("Memory manager type %d not clean. " - "Delaying takedown\n", arg.req.mem_type); - } - break; - case mm_lock: - LOCK_TEST_WITH_RETURN(dev, filp); - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - ret = drm_bo_lock_mm(dev, arg.req.mem_type); - break; - case mm_unlock: - LOCK_TEST_WITH_RETURN(dev, filp); - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - ret = 0; - break; - default: - DRM_ERROR("Function not implemented yet\n"); + LOCK_TEST_WITH_RETURN(dev, filp); + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + ret = -EINVAL; + if (!bm->initialized) { + DRM_ERROR("DRM memory manager was not initialized\n"); + goto out; + } + if (arg.mem_type == 0) { + DRM_ERROR("No takedown for System memory buffers.\n"); + goto out; + } + ret = 0; + if (drm_bo_clean_mm(dev, arg.mem_type)) { + DRM_ERROR("Memory manager type %d not clean. " + "Delaying takedown\n", arg.mem_type); + } +out: + mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->bm.init_mutex); + if (ret) + return ret; + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return 0; +} + +int drm_mm_lock_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + struct drm_mm_type_arg arg; + drm_bo_driver_t *driver = dev->driver->bo_driver; + int ret; + + if (!driver) { + DRM_ERROR("Buffer objects are not supported by this driver\n"); return -EINVAL; } + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + LOCK_TEST_WITH_RETURN(dev, filp); + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + ret = drm_bo_lock_mm(dev, arg.mem_type); + mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->bm.init_mutex); + if (ret) + return ret; + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return 0; +} + +int drm_mm_unlock_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + struct drm_mm_type_arg arg; + drm_bo_driver_t *driver = dev->driver->bo_driver; + int ret; + + if (!driver) { + DRM_ERROR("Buffer objects are not supported by this driver\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + LOCK_TEST_WITH_RETURN(dev, filp); + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + ret = 0; + mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->bm.init_mutex); if (ret) diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index 9ac5658c..867cee85 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -184,7 +184,7 @@ static int drm_pte_is_clear(struct vm_area_struct *vma, spin_unlock(&mm->page_table_lock); return ret; } - +#if 0 static int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) { @@ -195,6 +195,7 @@ static int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, ret = io_remap_pfn_range(vma, addr, pfn, PAGE_SIZE, vma->vm_page_prot); return ret; } +#endif static struct page *drm_bo_vm_fault(struct vm_area_struct *vma, struct fault_data *data) diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 9a0ecdf8..0ee5062b 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -119,10 +119,18 @@ static drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0}, [DRM_IOCTL_NR(DRM_IOCTL_FENCE)] = {drm_fence_ioctl, DRM_AUTH}, [DRM_IOCTL_NR(DRM_IOCTL_BUFOBJ)] = {drm_bo_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_MM_INIT)] = {drm_mm_init_ioctl, - DRM_AUTH }, [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, + + + [DRM_IOCTL_NR(DRM_IOCTL_MM_INIT)] = {drm_mm_init_ioctl, + DRM_AUTH }, + [DRM_IOCTL_NR(DRM_IOCTL_MM_TAKEDOWN)] = {drm_mm_takedown_ioctl, + DRM_AUTH }, + [DRM_IOCTL_NR(DRM_IOCTL_MM_LOCK)] = {drm_mm_lock_ioctl, + DRM_AUTH }, + [DRM_IOCTL_NR(DRM_IOCTL_MM_UNLOCK)] = {drm_mm_unlock_ioctl, + DRM_AUTH }, }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 03ea927e..7f9c8c37 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -430,6 +430,9 @@ typedef struct drm_bo_driver { extern int drm_bo_ioctl(DRM_IOCTL_ARGS); extern int drm_mm_init_ioctl(DRM_IOCTL_ARGS); +extern int drm_mm_takedown_ioctl(DRM_IOCTL_ARGS); +extern int drm_mm_lock_ioctl(DRM_IOCTL_ARGS); +extern int drm_mm_unlock_ioctl(DRM_IOCTL_ARGS); extern int drm_bo_driver_finish(struct drm_device *dev); extern int drm_bo_driver_init(struct drm_device *dev); extern int drm_bo_pci_offset(struct drm_device *dev, -- cgit v1.2.3 From 3dfc1400e9fc58c69292d7cf7c2e1653fa5e6991 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 6 May 2007 11:35:11 +1000 Subject: drm/ttm: cleanup most of fence ioctl split out --- linux-core/drm_drv.c | 13 +- linux-core/drm_fence.c | 310 +++++++++++++++++++++++++++++++++++++++++++++++ linux-core/drm_objects.h | 10 +- 3 files changed, 331 insertions(+), 2 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 0ee5062b..adba8f98 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -117,7 +117,7 @@ static drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE)] = {drm_fence_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_BUFOBJ)] = {drm_bo_ioctl, DRM_AUTH}, [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, @@ -131,6 +131,17 @@ static drm_ioctl_desc_t drm_ioctls[] = { DRM_AUTH }, [DRM_IOCTL_NR(DRM_IOCTL_MM_UNLOCK)] = {drm_mm_unlock_ioctl, DRM_AUTH }, + + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_CREATE)] = {drm_fence_create_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_DESTROY)] = {drm_fence_destroy_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_REFERENCE)] = {drm_fence_reference_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_UNREFERENCE)] = {drm_fence_unreference_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_SIGNALED)] = {drm_fence_signaled_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_FLUSH)] = {drm_fence_flush_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_WAIT)] = {drm_fence_wait_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_EMIT)] = {drm_fence_emit_ioctl, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_IOCTL_FENCE_BUFFERS)] = {drm_fence_buffers_ioctl, DRM_AUTH}, + }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index ce161dc3..fe11e87b 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -659,3 +659,313 @@ int drm_fence_ioctl(DRM_IOCTL_ARGS) DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } + +int drm_fence_create_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + if (arg.flags & DRM_FENCE_FLAG_EMIT) + LOCK_TEST_WITH_RETURN(dev, filp); + ret = drm_fence_object_create(dev, arg.class, + arg.type, arg.flags, &fence); + if (ret) + return ret; + ret = drm_fence_add_user_object(priv, fence, + arg.flags & + DRM_FENCE_FLAG_SHAREABLE); + if (ret) { + drm_fence_usage_deref_unlocked(dev, fence); + return ret; + } + + /* + * usage > 0. No need to lock dev->struct_mutex; + */ + + atomic_inc(&fence->usage); + arg.handle = fence->base.hash.key; + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} + +int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_user_object_t *uo; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + mutex_lock(&dev->struct_mutex); + uo = drm_lookup_user_object(priv, arg.handle); + if (!uo || (uo->type != drm_fence_type) || uo->owner != priv) { + mutex_unlock(&dev->struct_mutex); + return -EINVAL; + } + ret = drm_remove_user_object(priv, uo); + mutex_unlock(&dev->struct_mutex); + return ret; +} + + +int drm_fence_reference_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + drm_user_object_t *uo; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + ret = drm_user_object_ref(priv, arg.handle, drm_fence_type, &uo); + if (ret) + return ret; + fence = drm_lookup_fence_object(priv, arg.handle); + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} + + +int drm_fence_unreference_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + return drm_user_object_unref(priv, arg.handle, drm_fence_type); +} + +int drm_fence_signaled_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + fence = drm_lookup_fence_object(priv, arg.handle); + if (!fence) + return -EINVAL; + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} + +int drm_fence_flush_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + fence = drm_lookup_fence_object(priv, arg.handle); + if (!fence) + return -EINVAL; + ret = drm_fence_object_flush(dev, fence, arg.type); + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} + + +int drm_fence_wait_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + fence = drm_lookup_fence_object(priv, arg.handle); + if (!fence) + return -EINVAL; + ret = drm_fence_object_wait(dev, fence, + arg.flags & DRM_FENCE_FLAG_WAIT_LAZY, + 0, arg.type); + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} + + +int drm_fence_emit_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + LOCK_TEST_WITH_RETURN(dev, filp); + fence = drm_lookup_fence_object(priv, arg.handle); + if (!fence) + return -EINVAL; + ret = drm_fence_object_emit(dev, fence, arg.flags, arg.class, + arg.type); + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} + +int drm_fence_buffers_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + int ret; + drm_fence_manager_t *fm = &dev->fm; + drm_fence_arg_t arg; + drm_fence_object_t *fence; + unsigned long flags; + ret = 0; + + if (!fm->initialized) { + DRM_ERROR("The DRM driver does not support fencing.\n"); + return -EINVAL; + } + + DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); + + if (!dev->bm.initialized) { + DRM_ERROR("Buffer object manager is not initialized\n"); + return -EINVAL; + } + LOCK_TEST_WITH_RETURN(dev, filp); + ret = drm_fence_buffer_objects(priv, NULL, arg.flags, + NULL, &fence); + if (ret) + return ret; + ret = drm_fence_add_user_object(priv, fence, + arg.flags & + DRM_FENCE_FLAG_SHAREABLE); + if (ret) + return ret; + atomic_inc(&fence->usage); + arg.handle = fence->base.hash.key; + + read_lock_irqsave(&fm->lock, flags); + arg.class = fence->class; + arg.type = fence->type; + arg.signaled = fence->signaled; + read_unlock_irqrestore(&fm->lock, flags); + drm_fence_usage_deref_unlocked(dev, fence); + + DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); + return ret; +} diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 7f9c8c37..9576f28a 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -211,8 +211,16 @@ extern int drm_fence_object_create(struct drm_device *dev, uint32_t type, drm_fence_object_t ** c_fence); extern int drm_fence_add_user_object(drm_file_t * priv, drm_fence_object_t * fence, int shareable); -extern int drm_fence_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_create_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_reference_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_unreference_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_signaled_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_flush_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_wait_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_emit_ioctl(DRM_IOCTL_ARGS); +extern int drm_fence_buffers_ioctl(DRM_IOCTL_ARGS); /************************************************** *TTMs */ -- cgit v1.2.3 From adee6f52e65ca67a9773fa23537c424fac9f0da8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 8 May 2007 15:09:48 +1000 Subject: ati_pcigart: cut to 80 chars --- linux-core/ati_pcigart.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'linux-core') diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index 52bf8922..524618a8 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -151,7 +151,8 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n"); - order = drm_order((gart_info->table_size + (PAGE_SIZE-1)) / PAGE_SIZE); + order = drm_order((gart_info->table_size + + (PAGE_SIZE-1)) / PAGE_SIZE); num_pages = 1 << order; address = drm_ati_alloc_pcigart_table(order); if (!address) { @@ -169,7 +170,8 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) PCI_DMA_TODEVICE); if (bus_address == 0) { DRM_ERROR("unable to map PCIGART pages!\n"); - order = drm_order((gart_info->table_size + (PAGE_SIZE-1)) / PAGE_SIZE); + order = drm_order((gart_info->table_size + + (PAGE_SIZE-1)) / PAGE_SIZE); drm_ati_free_pcigart_table(address, order); address = NULL; goto done; -- cgit v1.2.3 From ce58e53a01e61818210ebf65623e35a3af20167b Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 8 May 2007 15:43:29 +1000 Subject: whitespace fixups from kernel --- linux-core/drm_drv.c | 2 +- linux-core/drm_pci.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index adba8f98..edf22d4c 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -601,7 +601,7 @@ int drm_ioctl(struct inode *inode, struct file *filp, goto err_i1; if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) && (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) - ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE]; + ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE]; else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) ioctl = &drm_ioctls[nr]; else diff --git a/linux-core/drm_pci.c b/linux-core/drm_pci.c index 40a65f3e..76252204 100644 --- a/linux-core/drm_pci.c +++ b/linux-core/drm_pci.c @@ -51,10 +51,8 @@ drm_dma_handle_t *drm_pci_alloc(drm_device_t * dev, size_t size, size_t align, dma_addr_t maxaddr) { drm_dma_handle_t *dmah; -#if 1 unsigned long addr; size_t sz; -#endif #ifdef DRM_DEBUG_MEMORY int area = DRM_MEM_DMA; -- cgit v1.2.3 From 375f3f2884cd1437e9ec2608647face0c3cbef3a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 26 May 2007 03:47:48 +1000 Subject: Revert "drm/ttm: cleanup most of fence ioctl split out" This reverts commit 3dfc1400e9fc58c69292d7cf7c2e1653fa5e6991. this shouldn't have gone on master yet --- linux-core/drm_drv.c | 13 +- linux-core/drm_fence.c | 310 ----------------------------------------------- linux-core/drm_objects.h | 10 +- 3 files changed, 2 insertions(+), 331 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index edf22d4c..43a9858d 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -117,7 +117,7 @@ static drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0}, - + [DRM_IOCTL_NR(DRM_IOCTL_FENCE)] = {drm_fence_ioctl, DRM_AUTH}, [DRM_IOCTL_NR(DRM_IOCTL_BUFOBJ)] = {drm_bo_ioctl, DRM_AUTH}, [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, @@ -131,17 +131,6 @@ static drm_ioctl_desc_t drm_ioctls[] = { DRM_AUTH }, [DRM_IOCTL_NR(DRM_IOCTL_MM_UNLOCK)] = {drm_mm_unlock_ioctl, DRM_AUTH }, - - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_CREATE)] = {drm_fence_create_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_DESTROY)] = {drm_fence_destroy_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_REFERENCE)] = {drm_fence_reference_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_UNREFERENCE)] = {drm_fence_unreference_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_SIGNALED)] = {drm_fence_signaled_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_FLUSH)] = {drm_fence_flush_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_WAIT)] = {drm_fence_wait_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_EMIT)] = {drm_fence_emit_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_IOCTL_FENCE_BUFFERS)] = {drm_fence_buffers_ioctl, DRM_AUTH}, - }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index fe11e87b..ce161dc3 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -659,313 +659,3 @@ int drm_fence_ioctl(DRM_IOCTL_ARGS) DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); return ret; } - -int drm_fence_create_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - if (arg.flags & DRM_FENCE_FLAG_EMIT) - LOCK_TEST_WITH_RETURN(dev, filp); - ret = drm_fence_object_create(dev, arg.class, - arg.type, arg.flags, &fence); - if (ret) - return ret; - ret = drm_fence_add_user_object(priv, fence, - arg.flags & - DRM_FENCE_FLAG_SHAREABLE); - if (ret) { - drm_fence_usage_deref_unlocked(dev, fence); - return ret; - } - - /* - * usage > 0. No need to lock dev->struct_mutex; - */ - - atomic_inc(&fence->usage); - arg.handle = fence->base.hash.key; - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} - -int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_user_object_t *uo; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - mutex_lock(&dev->struct_mutex); - uo = drm_lookup_user_object(priv, arg.handle); - if (!uo || (uo->type != drm_fence_type) || uo->owner != priv) { - mutex_unlock(&dev->struct_mutex); - return -EINVAL; - } - ret = drm_remove_user_object(priv, uo); - mutex_unlock(&dev->struct_mutex); - return ret; -} - - -int drm_fence_reference_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - drm_user_object_t *uo; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - ret = drm_user_object_ref(priv, arg.handle, drm_fence_type, &uo); - if (ret) - return ret; - fence = drm_lookup_fence_object(priv, arg.handle); - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} - - -int drm_fence_unreference_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - return drm_user_object_unref(priv, arg.handle, drm_fence_type); -} - -int drm_fence_signaled_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - fence = drm_lookup_fence_object(priv, arg.handle); - if (!fence) - return -EINVAL; - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} - -int drm_fence_flush_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - fence = drm_lookup_fence_object(priv, arg.handle); - if (!fence) - return -EINVAL; - ret = drm_fence_object_flush(dev, fence, arg.type); - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} - - -int drm_fence_wait_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - fence = drm_lookup_fence_object(priv, arg.handle); - if (!fence) - return -EINVAL; - ret = drm_fence_object_wait(dev, fence, - arg.flags & DRM_FENCE_FLAG_WAIT_LAZY, - 0, arg.type); - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} - - -int drm_fence_emit_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - LOCK_TEST_WITH_RETURN(dev, filp); - fence = drm_lookup_fence_object(priv, arg.handle); - if (!fence) - return -EINVAL; - ret = drm_fence_object_emit(dev, fence, arg.flags, arg.class, - arg.type); - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} - -int drm_fence_buffers_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - int ret; - drm_fence_manager_t *fm = &dev->fm; - drm_fence_arg_t arg; - drm_fence_object_t *fence; - unsigned long flags; - ret = 0; - - if (!fm->initialized) { - DRM_ERROR("The DRM driver does not support fencing.\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - if (!dev->bm.initialized) { - DRM_ERROR("Buffer object manager is not initialized\n"); - return -EINVAL; - } - LOCK_TEST_WITH_RETURN(dev, filp); - ret = drm_fence_buffer_objects(priv, NULL, arg.flags, - NULL, &fence); - if (ret) - return ret; - ret = drm_fence_add_user_object(priv, fence, - arg.flags & - DRM_FENCE_FLAG_SHAREABLE); - if (ret) - return ret; - atomic_inc(&fence->usage); - arg.handle = fence->base.hash.key; - - read_lock_irqsave(&fm->lock, flags); - arg.class = fence->class; - arg.type = fence->type; - arg.signaled = fence->signaled; - read_unlock_irqrestore(&fm->lock, flags); - drm_fence_usage_deref_unlocked(dev, fence); - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return ret; -} diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 9576f28a..7f9c8c37 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -211,16 +211,8 @@ extern int drm_fence_object_create(struct drm_device *dev, uint32_t type, drm_fence_object_t ** c_fence); extern int drm_fence_add_user_object(drm_file_t * priv, drm_fence_object_t * fence, int shareable); +extern int drm_fence_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_create_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_destroy_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_reference_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_unreference_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_signaled_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_flush_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_wait_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_emit_ioctl(DRM_IOCTL_ARGS); -extern int drm_fence_buffers_ioctl(DRM_IOCTL_ARGS); /************************************************** *TTMs */ -- cgit v1.2.3 From 58b2ed78329305d5760c6df55175f958477f89ae Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 26 May 2007 03:48:08 +1000 Subject: Revert "drm/ttm: cleanup mm_ioctl ioctls to be separate ioctls." This reverts commit 3fdef0dc2000308b16907b95f637c60acde80a74. ditto not on master yet --- linux-core/drm_bo.c | 160 +++++++++++++++-------------------------------- linux-core/drm_compat.c | 3 +- linux-core/drm_drv.c | 12 +--- linux-core/drm_objects.h | 3 - 4 files changed, 55 insertions(+), 123 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index f78a6f95..1c7013b3 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -2158,89 +2158,11 @@ EXPORT_SYMBOL(drm_bo_driver_init); int drm_mm_init_ioctl(DRM_IOCTL_ARGS) { DRM_DEVICE; - struct drm_mm_init_arg arg; - drm_buffer_manager_t *bm = &dev->bm; - drm_bo_driver_t *driver = dev->driver->bo_driver; - int ret; - - if (!driver) { - DRM_ERROR("Buffer objects are not supported by this driver\n"); - return -EINVAL; - } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - ret = -EINVAL; - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - if (!bm->initialized) { - DRM_ERROR("DRM memory manager was not initialized.\n"); - goto out; - } - if (arg.mem_type == 0) { - DRM_ERROR("System memory buffers already initialized.\n"); - goto out; - } - ret = drm_bo_init_mm(dev, arg.mem_type, - arg.p_offset, arg.p_size); - -out: - mutex_unlock(&dev->struct_mutex); - mutex_unlock(&dev->bm.init_mutex); - if (ret) - return ret; - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return 0; -} - -int drm_mm_takedown_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - struct drm_mm_type_arg arg; + int ret = 0; + drm_mm_init_arg_t arg; drm_buffer_manager_t *bm = &dev->bm; drm_bo_driver_t *driver = dev->driver->bo_driver; - int ret; - - if (!driver) { - DRM_ERROR("Buffer objects are not supported by this driver\n"); - return -EINVAL; - } - - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - - LOCK_TEST_WITH_RETURN(dev, filp); - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - ret = -EINVAL; - if (!bm->initialized) { - DRM_ERROR("DRM memory manager was not initialized\n"); - goto out; - } - if (arg.mem_type == 0) { - DRM_ERROR("No takedown for System memory buffers.\n"); - goto out; - } - ret = 0; - if (drm_bo_clean_mm(dev, arg.mem_type)) { - DRM_ERROR("Memory manager type %d not clean. " - "Delaying takedown\n", arg.mem_type); - } -out: - mutex_unlock(&dev->struct_mutex); - mutex_unlock(&dev->bm.init_mutex); - if (ret) - return ret; - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return 0; -} - -int drm_mm_lock_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - struct drm_mm_type_arg arg; - drm_bo_driver_t *driver = dev->driver->bo_driver; - int ret; if (!driver) { DRM_ERROR("Buffer objects are not supported by this driver\n"); @@ -2249,37 +2171,59 @@ int drm_mm_lock_ioctl(DRM_IOCTL_ARGS) DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - LOCK_TEST_WITH_RETURN(dev, filp); - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - ret = drm_bo_lock_mm(dev, arg.mem_type); - mutex_unlock(&dev->struct_mutex); - mutex_unlock(&dev->bm.init_mutex); - if (ret) - return ret; - - DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg)); - return 0; -} - -int drm_mm_unlock_ioctl(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - struct drm_mm_type_arg arg; - drm_bo_driver_t *driver = dev->driver->bo_driver; - int ret; - - if (!driver) { - DRM_ERROR("Buffer objects are not supported by this driver\n"); + switch (arg.req.op) { + case mm_init: + ret = -EINVAL; + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + if (!bm->initialized) { + DRM_ERROR("DRM memory manager was not initialized.\n"); + break; + } + if (arg.req.mem_type == 0) { + DRM_ERROR + ("System memory buffers already initialized.\n"); + break; + } + ret = drm_bo_init_mm(dev, arg.req.mem_type, + arg.req.p_offset, arg.req.p_size); + break; + case mm_takedown: + LOCK_TEST_WITH_RETURN(dev, filp); + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + ret = -EINVAL; + if (!bm->initialized) { + DRM_ERROR("DRM memory manager was not initialized\n"); + break; + } + if (arg.req.mem_type == 0) { + DRM_ERROR("No takedown for System memory buffers.\n"); + break; + } + ret = 0; + if (drm_bo_clean_mm(dev, arg.req.mem_type)) { + DRM_ERROR("Memory manager type %d not clean. " + "Delaying takedown\n", arg.req.mem_type); + } + break; + case mm_lock: + LOCK_TEST_WITH_RETURN(dev, filp); + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + ret = drm_bo_lock_mm(dev, arg.req.mem_type); + break; + case mm_unlock: + LOCK_TEST_WITH_RETURN(dev, filp); + mutex_lock(&dev->bm.init_mutex); + mutex_lock(&dev->struct_mutex); + ret = 0; + break; + default: + DRM_ERROR("Function not implemented yet\n"); return -EINVAL; } - DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg)); - LOCK_TEST_WITH_RETURN(dev, filp); - mutex_lock(&dev->bm.init_mutex); - mutex_lock(&dev->struct_mutex); - ret = 0; - mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->bm.init_mutex); if (ret) diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index 867cee85..9ac5658c 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -184,7 +184,7 @@ static int drm_pte_is_clear(struct vm_area_struct *vma, spin_unlock(&mm->page_table_lock); return ret; } -#if 0 + static int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) { @@ -195,7 +195,6 @@ static int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, ret = io_remap_pfn_range(vma, addr, pfn, PAGE_SIZE, vma->vm_page_prot); return ret; } -#endif static struct page *drm_bo_vm_fault(struct vm_area_struct *vma, struct fault_data *data) diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 43a9858d..8754a8e4 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -119,18 +119,10 @@ static drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0}, [DRM_IOCTL_NR(DRM_IOCTL_FENCE)] = {drm_fence_ioctl, DRM_AUTH}, [DRM_IOCTL_NR(DRM_IOCTL_BUFOBJ)] = {drm_bo_ioctl, DRM_AUTH}, - - [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, - - [DRM_IOCTL_NR(DRM_IOCTL_MM_INIT)] = {drm_mm_init_ioctl, DRM_AUTH }, - [DRM_IOCTL_NR(DRM_IOCTL_MM_TAKEDOWN)] = {drm_mm_takedown_ioctl, - DRM_AUTH }, - [DRM_IOCTL_NR(DRM_IOCTL_MM_LOCK)] = {drm_mm_lock_ioctl, - DRM_AUTH }, - [DRM_IOCTL_NR(DRM_IOCTL_MM_UNLOCK)] = {drm_mm_unlock_ioctl, - DRM_AUTH }, + + [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 7f9c8c37..03ea927e 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -430,9 +430,6 @@ typedef struct drm_bo_driver { extern int drm_bo_ioctl(DRM_IOCTL_ARGS); extern int drm_mm_init_ioctl(DRM_IOCTL_ARGS); -extern int drm_mm_takedown_ioctl(DRM_IOCTL_ARGS); -extern int drm_mm_lock_ioctl(DRM_IOCTL_ARGS); -extern int drm_mm_unlock_ioctl(DRM_IOCTL_ARGS); extern int drm_bo_driver_finish(struct drm_device *dev); extern int drm_bo_driver_init(struct drm_device *dev); extern int drm_bo_pci_offset(struct drm_device *dev, -- cgit v1.2.3 From 8e083c522e73f27af7e97e0d202f56f0323abe81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sat, 26 May 2007 04:35:54 +1000 Subject: drm: make sure the drawable code doesn't call malloc(0). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michel Dänzer Signed-off-by: Dave Airlie --- linux-core/drm_drawable.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index 0817e321..b540a0e7 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -172,38 +172,49 @@ int drm_rmdraw(DRM_IOCTL_ARGS) bitfield_length = idx + 1; - if (idx != id / (8 * sizeof(*bitfield))) - bitfield = drm_alloc(bitfield_length * - sizeof(*bitfield), DRM_MEM_BUFS); + bitfield = NULL; - if (!bitfield && bitfield_length) { - bitfield = dev->drw_bitfield; - bitfield_length = dev->drw_bitfield_length; + if (bitfield_length) { + if (bitfield_length != dev->drw_bitfield_length) + bitfield = drm_alloc(bitfield_length * + sizeof(*bitfield), + DRM_MEM_BUFS); + + if (!bitfield) { + bitfield = dev->drw_bitfield; + bitfield_length = dev->drw_bitfield_length; + } } } if (bitfield != dev->drw_bitfield) { info_length = 8 * sizeof(*bitfield) * bitfield_length; - info = drm_alloc(info_length * sizeof(*info), DRM_MEM_BUFS); + if (info_length) { + info = drm_alloc(info_length * sizeof(*info), + DRM_MEM_BUFS); - if (!info && info_length) { - info = dev->drw_info; - info_length = dev->drw_info_length; - } + if (!info) { + info = dev->drw_info; + info_length = dev->drw_info_length; + } + } else + info = NULL; spin_lock_irqsave(&dev->drw_lock, irqflags); - memcpy(bitfield, dev->drw_bitfield, bitfield_length * - sizeof(*bitfield)); + if (bitfield) + memcpy(bitfield, dev->drw_bitfield, bitfield_length * + sizeof(*bitfield)); drm_free(dev->drw_bitfield, sizeof(*bitfield) * dev->drw_bitfield_length, DRM_MEM_BUFS); dev->drw_bitfield = bitfield; dev->drw_bitfield_length = bitfield_length; if (info != dev->drw_info) { - memcpy(info, dev->drw_info, info_length * - sizeof(*info)); + if (info) + memcpy(info, dev->drw_info, info_length * + sizeof(*info)); drm_free(dev->drw_info, sizeof(*info) * dev->drw_info_length, DRM_MEM_BUFS); dev->drw_info = info; -- cgit v1.2.3 From f64674743a49c242e4f24cbb7599c1c21c035a4f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 27 May 2007 07:26:52 +1000 Subject: drm: convert drawable handling to use Linux idr This cleans this code up a lot and uses the generic Linux idr which is designed for this. Signed-off-by: Dave Airlie --- linux-core/drmP.h | 12 ++- linux-core/drm_drawable.c | 224 +++++++++------------------------------------- linux-core/drm_drv.c | 17 ++-- linux-core/drm_fops.c | 3 + 4 files changed, 61 insertions(+), 195 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 6cede35e..16d7dbbf 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -76,6 +76,7 @@ #include #include "drm.h" #include +#include #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) @@ -593,6 +594,11 @@ typedef struct ati_pcigart_info { int table_size; } drm_ati_pcigart_info; +struct drm_drawable_list { + struct list_head head; + int id; + drm_drawable_info_t info; +}; #include "drm_objects.h" @@ -818,10 +824,8 @@ typedef struct drm_device { /** \name Drawable information */ /*@{ */ spinlock_t drw_lock; - unsigned int drw_bitfield_length; - u32 *drw_bitfield; - unsigned int drw_info_length; - drm_drawable_info_t **drw_info; + struct idr drw_idr; + struct list_head drwlist; /*@} */ } drm_device_t; diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index b540a0e7..d599430b 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -44,82 +44,38 @@ int drm_adddraw(DRM_IOCTL_ARGS) { DRM_DEVICE; unsigned long irqflags; - int i, j; - u32 *bitfield = dev->drw_bitfield; - unsigned int bitfield_length = dev->drw_bitfield_length; - drm_drawable_info_t **info = dev->drw_info; - unsigned int info_length = dev->drw_info_length; + struct drm_drawable_list *draw_info; drm_draw_t draw; - - for (i = 0, j = 0; i < bitfield_length; i++) { - if (bitfield[i] == ~0) - continue; - - for (; j < 8 * sizeof(*bitfield); j++) - if (!(bitfield[i] & (1 << j))) - goto done; - } -done: - - if (i == bitfield_length) { - bitfield_length++; - - bitfield = drm_alloc(bitfield_length * sizeof(*bitfield), - DRM_MEM_BUFS); - - if (!bitfield) { - DRM_ERROR("Failed to allocate new drawable bitfield\n"); - return DRM_ERR(ENOMEM); - } - - if (8 * sizeof(*bitfield) * bitfield_length > info_length) { - info_length += 8 * sizeof(*bitfield); - - info = drm_alloc(info_length * sizeof(*info), - DRM_MEM_BUFS); - - if (!info) { - DRM_ERROR("Failed to allocate new drawable info" - " array\n"); - - drm_free(bitfield, - bitfield_length * sizeof(*bitfield), - DRM_MEM_BUFS); - return DRM_ERR(ENOMEM); - } - } - - bitfield[i] = 0; + int new_id = 0; + int ret; + + draw_info = drm_calloc(1, sizeof(struct drm_drawable_list), DRM_MEM_BUFS); + if (!draw_info) + return -ENOMEM; + +again: + if (idr_pre_get(&dev->drw_idr, GFP_KERNEL) == 0) { + DRM_ERROR("Out of memory expanding drawable idr\n"); + drm_free(draw_info, sizeof(struct drm_drawable_list), DRM_MEM_BUFS); + return -ENOMEM; } - draw.handle = i * 8 * sizeof(*bitfield) + j + 1; - DRM_DEBUG("%d\n", draw.handle); - spin_lock_irqsave(&dev->drw_lock, irqflags); - - bitfield[i] |= 1 << j; - info[draw.handle - 1] = NULL; - - if (bitfield != dev->drw_bitfield) { - memcpy(bitfield, dev->drw_bitfield, dev->drw_bitfield_length * - sizeof(*bitfield)); - drm_free(dev->drw_bitfield, sizeof(*bitfield) * - dev->drw_bitfield_length, DRM_MEM_BUFS); - dev->drw_bitfield = bitfield; - dev->drw_bitfield_length = bitfield_length; + ret = idr_get_new_above(&dev->drw_idr, draw_info, 1, &new_id); + if (ret == -EAGAIN) { + spin_unlock_irqrestore(&dev->drw_lock, irqflags); + goto again; } - if (info != dev->drw_info) { - memcpy(info, dev->drw_info, dev->drw_info_length * - sizeof(*info)); - drm_free(dev->drw_info, sizeof(*info) * dev->drw_info_length, - DRM_MEM_BUFS); - dev->drw_info = info; - dev->drw_info_length = info_length; - } + list_add(&draw_info->head, &dev->drwlist); spin_unlock_irqrestore(&dev->drw_lock, irqflags); + draw_info->id = new_id; + draw.handle = new_id; + + DRM_DEBUG("%d\n", draw.handle); + DRM_COPY_TO_USER_IOCTL((drm_draw_t __user *)data, draw, sizeof(draw)); return 0; @@ -132,98 +88,25 @@ int drm_rmdraw(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_draw_t draw; - int id, idx; - unsigned int shift; unsigned long irqflags; - u32 *bitfield = dev->drw_bitfield; - unsigned int bitfield_length = dev->drw_bitfield_length; - drm_drawable_info_t **info = dev->drw_info; - unsigned int info_length = dev->drw_info_length; + struct drm_drawable_list *draw_info; DRM_COPY_FROM_USER_IOCTL(draw, (drm_draw_t __user *) data, sizeof(draw)); - id = draw.handle - 1; - idx = id / (8 * sizeof(*bitfield)); - shift = id % (8 * sizeof(*bitfield)); - - if (idx < 0 || idx >= bitfield_length || - !(bitfield[idx] & (1 << shift))) { + draw_info = idr_find(&dev->drw_idr, draw.handle); + if (!draw_info) { DRM_DEBUG("No such drawable %d\n", draw.handle); - return 0; + return -EINVAL; } spin_lock_irqsave(&dev->drw_lock, irqflags); - bitfield[idx] &= ~(1 << shift); + list_del(&draw_info->head); + idr_remove(&dev->drw_idr, draw.handle); + drm_free(draw_info, sizeof(struct drm_drawable_list), DRM_MEM_BUFS); spin_unlock_irqrestore(&dev->drw_lock, irqflags); - - if (info[id]) { - drm_free(info[id]->rects, info[id]->num_rects * - sizeof(drm_clip_rect_t), DRM_MEM_BUFS); - drm_free(info[id], sizeof(**info), DRM_MEM_BUFS); - } - - /* Can we shrink the arrays? */ - if (idx == bitfield_length - 1) { - while (idx >= 0 && !bitfield[idx]) - --idx; - - bitfield_length = idx + 1; - - bitfield = NULL; - - if (bitfield_length) { - if (bitfield_length != dev->drw_bitfield_length) - bitfield = drm_alloc(bitfield_length * - sizeof(*bitfield), - DRM_MEM_BUFS); - - if (!bitfield) { - bitfield = dev->drw_bitfield; - bitfield_length = dev->drw_bitfield_length; - } - } - } - - if (bitfield != dev->drw_bitfield) { - info_length = 8 * sizeof(*bitfield) * bitfield_length; - - if (info_length) { - info = drm_alloc(info_length * sizeof(*info), - DRM_MEM_BUFS); - - if (!info) { - info = dev->drw_info; - info_length = dev->drw_info_length; - } - } else - info = NULL; - - spin_lock_irqsave(&dev->drw_lock, irqflags); - - if (bitfield) - memcpy(bitfield, dev->drw_bitfield, bitfield_length * - sizeof(*bitfield)); - drm_free(dev->drw_bitfield, sizeof(*bitfield) * - dev->drw_bitfield_length, DRM_MEM_BUFS); - dev->drw_bitfield = bitfield; - dev->drw_bitfield_length = bitfield_length; - - if (info != dev->drw_info) { - if (info) - memcpy(info, dev->drw_info, info_length * - sizeof(*info)); - drm_free(dev->drw_info, sizeof(*info) * - dev->drw_info_length, DRM_MEM_BUFS); - dev->drw_info = info; - dev->drw_info_length = info_length; - } - - spin_unlock_irqrestore(&dev->drw_lock, irqflags); - } - DRM_DEBUG("%d\n", draw.handle); return 0; } @@ -231,36 +114,22 @@ int drm_rmdraw(DRM_IOCTL_ARGS) int drm_update_drawable_info(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_update_draw_t update; - unsigned int id, idx, shift, bitfield_length = dev->drw_bitfield_length; - u32 *bitfield = dev->drw_bitfield; unsigned long irqflags; drm_drawable_info_t *info; drm_clip_rect_t *rects; + struct drm_drawable_list *draw_info; int err; DRM_COPY_FROM_USER_IOCTL(update, (drm_update_draw_t __user *) data, sizeof(update)); - id = update.handle - 1; - idx = id / (8 * sizeof(*bitfield)); - shift = id % (8 * sizeof(*bitfield)); - - if (idx < 0 || idx >= bitfield_length || - !(bitfield[idx] & (1 << shift))) { + draw_info = idr_find(&dev->drw_idr, update.handle); + if (!draw_info) { DRM_ERROR("No such drawable %d\n", update.handle); return DRM_ERR(EINVAL); } - info = dev->drw_info[id]; - - if (!info) { - info = drm_calloc(1, sizeof(drm_drawable_info_t), DRM_MEM_BUFS); - - if (!info) { - DRM_ERROR("Failed to allocate drawable info memory\n"); - return DRM_ERR(ENOMEM); - } - } + info = &draw_info->info; switch (update.type) { case DRM_DRAWABLE_CLIPRECTS: @@ -295,12 +164,11 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) { info->rects = rects; info->num_rects = update.num; - dev->drw_info[id] = info; spin_unlock_irqrestore(&dev->drw_lock, irqflags); DRM_DEBUG("Updated %d cliprects for drawable %d\n", - info->num_rects, id); + info->num_rects, update.handle); break; default: DRM_ERROR("Invalid update type %d\n", update.type); @@ -310,11 +178,9 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) { return 0; error: - if (!dev->drw_info[id]) - drm_free(info, sizeof(*info), DRM_MEM_BUFS); - else if (rects != dev->drw_info[id]->rects) - drm_free(rects, update.num * - sizeof(drm_clip_rect_t), DRM_MEM_BUFS); + if (rects != info->rects) + drm_free(rects, update.num * sizeof(drm_clip_rect_t), + DRM_MEM_BUFS); return err; } @@ -323,19 +189,13 @@ error: * Caller must hold the drawable spinlock! */ drm_drawable_info_t *drm_get_drawable_info(drm_device_t *dev, drm_drawable_t id) { - u32 *bitfield = dev->drw_bitfield; - unsigned int idx, shift; - - id--; - idx = id / (8 * sizeof(*bitfield)); - shift = id % (8 * sizeof(*bitfield)); - - if (idx < 0 || idx >= dev->drw_bitfield_length || - !(bitfield[idx] & (1 << shift))) { + struct drm_drawable_list *draw_info; + draw_info = idr_find(&dev->drw_idr, id); + if (!draw_info) { DRM_DEBUG("No such drawable %d\n", id); return NULL; } - return dev->drw_info[id]; + return &draw_info->info; } EXPORT_SYMBOL(drm_get_drawable_info); diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 8754a8e4..f64959fb 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -142,6 +142,7 @@ int drm_lastclose(drm_device_t * dev) drm_magic_entry_t *pt, *next; drm_map_list_t *r_list, *list_t; drm_vma_entry_t *vma, *vma_temp; + struct drm_drawable_list *drw_entry, *drw_temp; int i; DRM_DEBUG("\n"); @@ -166,15 +167,13 @@ int drm_lastclose(drm_device_t * dev) drm_irq_uninstall(dev); /* Free drawable information memory */ - for (i = 0; i < dev->drw_bitfield_length / sizeof(*dev->drw_bitfield); - i++) { - drm_drawable_info_t *info = drm_get_drawable_info(dev, i); - - if (info) { - drm_free(info->rects, info->num_rects * - sizeof(drm_clip_rect_t), DRM_MEM_BUFS); - drm_free(info, sizeof(*info), DRM_MEM_BUFS); - } + list_for_each_entry_safe(drw_entry, drw_temp, &dev->drwlist, head) { + drm_free(drw_entry->info.rects, drw_entry->info.num_rects * + sizeof(drm_clip_rect_t), DRM_MEM_BUFS); + + idr_remove(&dev->drw_idr, drw_entry->id); + list_del(&drw_entry->head); + drm_free(drw_entry, sizeof(struct drm_drawable_list), DRM_MEM_BUFS); } mutex_lock(&dev->struct_mutex); diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index fce2be97..9625d8f5 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -82,6 +82,9 @@ static int drm_setup(drm_device_t * dev) INIT_LIST_HEAD(&dev->ctxlist); INIT_LIST_HEAD(&dev->vmalist); + INIT_LIST_HEAD(&dev->drwlist); + idr_init(&dev->drw_idr); + dev->sigdata.lock = NULL; init_waitqueue_head(&dev->lock.lock_queue); dev->queue_count = 0; -- cgit v1.2.3 From 056c2f249a61ba7078bae3d767a59f2be4c6556e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 27 May 2007 08:44:38 +1000 Subject: drm: move context handling code to use linux idr --- linux-core/drmP.h | 11 +++- linux-core/drm_context.c | 142 ++++++++++++++++++----------------------------- 2 files changed, 61 insertions(+), 92 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 16d7dbbf..f988db35 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -570,6 +570,12 @@ typedef struct drm_ctx_list { drm_file_t *tag; /**< associated fd private data */ } drm_ctx_list_t; +struct drm_ctx_sarea_list { + struct list_head head; + int ctx_id; + drm_map_t *map; +}; + typedef struct drm_vbl_sig { struct list_head head; unsigned int sequence; @@ -746,8 +752,8 @@ typedef struct drm_device { int ctx_count; /**< Number of context handles */ struct mutex ctxlist_mutex; /**< For ctxlist */ - drm_map_t **context_sareas; /**< per-context SAREA's */ - int max_context; + struct idr ctx_idr; + struct list_head context_sarealist; struct list_head vmalist; /**< List of vmas (for debugging) */ drm_lock_data_t lock; /**< Information on hardware lock */ @@ -808,7 +814,6 @@ typedef struct drm_device { struct pci_controller *hose; #endif drm_sg_mem_t *sg; /**< Scatter gather memory */ - unsigned long *ctx_bitmap; /**< context bitmap */ void *dev_private; /**< device private data */ drm_sigdata_t sigdata; /**< For block_all_signals */ sigset_t sigmask; diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c index 3bfee127..5cb79b14 100644 --- a/linux-core/drm_context.c +++ b/linux-core/drm_context.c @@ -58,20 +58,17 @@ */ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) { - if (ctx_handle < 0) - goto failed; - if (!dev->ctx_bitmap) - goto failed; - - if (ctx_handle < DRM_MAX_CTXBITMAP) { - mutex_lock(&dev->struct_mutex); - clear_bit(ctx_handle, dev->ctx_bitmap); - dev->context_sareas[ctx_handle] = NULL; - mutex_unlock(&dev->struct_mutex); - return; - } - failed: - DRM_ERROR("Attempt to free invalid context handle: %d\n", ctx_handle); + struct drm_ctx_sarea_list *ctx_sarea; + + mutex_lock(&dev->struct_mutex); + ctx_sarea = idr_find(&dev->ctx_idr, ctx_handle); + if (ctx_sarea) { + idr_remove(&dev->ctx_idr, ctx_handle); + list_del(&ctx_sarea->head); + drm_free(ctx_sarea, sizeof(struct drm_ctx_sarea_list), DRM_MEM_BUFS); + } else + DRM_ERROR("Attempt to free invalid context handle: %d\n", ctx_handle); + mutex_unlock(&dev->struct_mutex); return; } @@ -87,56 +84,32 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) */ static int drm_ctxbitmap_next(drm_device_t * dev) { - int bit; + int new_id; + int ret; + struct drm_ctx_sarea_list *new_ctx; - if (!dev->ctx_bitmap) + new_ctx = drm_calloc(1, sizeof(struct drm_ctx_sarea_list), DRM_MEM_BUFS); + if (!new_ctx) return -1; +again: + if (idr_pre_get(&dev->ctx_idr, GFP_KERNEL) == 0) { + DRM_ERROR("Out of memory expanding drawable idr\n"); + drm_free(new_ctx, sizeof(struct drm_ctx_sarea_list), DRM_MEM_BUFS); + return -ENOMEM; + } mutex_lock(&dev->struct_mutex); - bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); - if (bit < DRM_MAX_CTXBITMAP) { - set_bit(bit, dev->ctx_bitmap); - DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit); - if ((bit + 1) > dev->max_context) { - dev->max_context = (bit + 1); - if (dev->context_sareas) { - drm_map_t **ctx_sareas; - - ctx_sareas = drm_realloc(dev->context_sareas, - (dev->max_context - - 1) * - sizeof(*dev-> - context_sareas), - dev->max_context * - sizeof(*dev-> - context_sareas), - DRM_MEM_MAPS); - if (!ctx_sareas) { - clear_bit(bit, dev->ctx_bitmap); - mutex_unlock(&dev->struct_mutex); - return -1; - } - dev->context_sareas = ctx_sareas; - dev->context_sareas[bit] = NULL; - } else { - /* max_context == 1 at this point */ - dev->context_sareas = - drm_alloc(dev->max_context * - sizeof(*dev->context_sareas), - DRM_MEM_MAPS); - if (!dev->context_sareas) { - clear_bit(bit, dev->ctx_bitmap); - mutex_unlock(&dev->struct_mutex); - return -1; - } - dev->context_sareas[bit] = NULL; - } - } + ret = idr_get_new_above(&dev->ctx_idr, new_ctx, DRM_RESERVED_CONTEXTS, &new_id); + if (ret == -EAGAIN) { mutex_unlock(&dev->struct_mutex); - return bit; + goto again; } + mutex_unlock(&dev->struct_mutex); - return -1; + + new_ctx->ctx_id = new_id; + list_add(&new_ctx->head, &dev->context_sarealist); + return new_id; } /** @@ -149,25 +122,8 @@ static int drm_ctxbitmap_next(drm_device_t * dev) */ int drm_ctxbitmap_init(drm_device_t * dev) { - int i; - int temp; - - mutex_lock(&dev->struct_mutex); - dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE, - DRM_MEM_CTXBITMAP); - if (dev->ctx_bitmap == NULL) { - mutex_unlock(&dev->struct_mutex); - return -ENOMEM; - } - memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE); - dev->context_sareas = NULL; - dev->max_context = -1; - mutex_unlock(&dev->struct_mutex); - - for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { - temp = drm_ctxbitmap_next(dev); - DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp); - } + idr_init(&dev->ctx_idr); + INIT_LIST_HEAD(&dev->context_sarealist); return 0; } @@ -182,12 +138,13 @@ int drm_ctxbitmap_init(drm_device_t * dev) */ void drm_ctxbitmap_cleanup(drm_device_t * dev) { + struct drm_ctx_sarea_list *ctx_entry, *ctx_temp; + mutex_lock(&dev->struct_mutex); - if (dev->context_sareas) - drm_free(dev->context_sareas, - sizeof(*dev->context_sareas) * - dev->max_context, DRM_MEM_MAPS); - drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); + list_for_each_entry_safe(ctx_entry, ctx_temp, &dev->context_sarealist, head) { + idr_remove(&dev->ctx_idr, ctx_entry->ctx_id); + drm_free(ctx_entry, sizeof(struct drm_ctx_sarea_list), DRM_MEM_MAPS); + } mutex_unlock(&dev->struct_mutex); } @@ -218,18 +175,20 @@ int drm_getsareactx(struct inode *inode, struct file *filp, drm_ctx_priv_map_t request; drm_map_t *map; drm_map_list_t *_entry; + struct drm_ctx_sarea_list *ctx_sarea; if (copy_from_user(&request, argp, sizeof(request))) return -EFAULT; mutex_lock(&dev->struct_mutex); - if (dev->max_context < 0 - || request.ctx_id >= (unsigned)dev->max_context) { + + ctx_sarea = idr_find(&dev->ctx_idr, request.ctx_id); + if (!ctx_sarea) { mutex_unlock(&dev->struct_mutex); return -EINVAL; } - - map = dev->context_sareas[request.ctx_id]; + + map = ctx_sarea->map; mutex_unlock(&dev->struct_mutex); request.handle = NULL; @@ -268,6 +227,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp, drm_ctx_priv_map_t request; drm_map_t *map = NULL; drm_map_list_t *r_list = NULL; + struct drm_ctx_sarea_list *ctx_sarea; if (copy_from_user(&request, (drm_ctx_priv_map_t __user *) arg, sizeof(request))) @@ -287,11 +247,15 @@ int drm_setsareactx(struct inode *inode, struct file *filp, map = r_list->map; if (!map) goto bad; - if (dev->max_context < 0) - goto bad; - if (request.ctx_id >= (unsigned)dev->max_context) + + mutex_lock(&dev->struct_mutex); + + ctx_sarea = idr_find(&dev->ctx_idr, request.ctx_id); + if (!ctx_sarea) { goto bad; - dev->context_sareas[request.ctx_id] = map; + } + + ctx_sarea->map = map; mutex_unlock(&dev->struct_mutex); return 0; } -- cgit v1.2.3 From 638c8087deecdf489eb4f70e82590d1be0c8c942 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 1 Jun 2007 19:00:24 +1000 Subject: drm: fixup initialisation of list heads and idr --- linux-core/drm_fops.c | 6 ------ linux-core/drm_stub.c | 9 +++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index 9625d8f5..e54d5079 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -79,12 +79,6 @@ static int drm_setup(drm_device_t * dev) drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); INIT_LIST_HEAD(&dev->magicfree); - INIT_LIST_HEAD(&dev->ctxlist); - INIT_LIST_HEAD(&dev->vmalist); - - INIT_LIST_HEAD(&dev->drwlist); - idr_init(&dev->drw_idr); - dev->sigdata.lock = NULL; init_waitqueue_head(&dev->lock.lock_queue); dev->queue_count = 0; diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index bcbabf8d..7b0a0f97 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -60,7 +60,12 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, { int retcode; + INIT_LIST_HEAD(&dev->drwlist); INIT_LIST_HEAD(&dev->filelist); + INIT_LIST_HEAD(&dev->ctxlist); + INIT_LIST_HEAD(&dev->vmalist); + INIT_LIST_HEAD(&dev->maplist); + spin_lock_init(&dev->count_lock); spin_lock_init(&dev->drw_lock); spin_lock_init(&dev->tasklet_lock); @@ -71,6 +76,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, mutex_init(&dev->bm.init_mutex); mutex_init(&dev->bm.evict_mutex); + idr_init(&dev->drw_idr); + dev->pdev = pdev; dev->pci_device = pdev->device; dev->pci_vendor = pdev->vendor; @@ -95,8 +102,6 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, return -ENOMEM; } - INIT_LIST_HEAD(&dev->maplist); - /* the DRM has 6 counters */ dev->counters = 6; dev->types[0] = _DRM_STAT_LOCK; -- cgit v1.2.3 From 4e9d215bdfe72588cbacdb17ab9b60a42a43aefb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 3 Jun 2007 16:28:21 +1000 Subject: radeon: add support for vblank on crtc2 This add support for CRTC2 vblank on radeon similiar to the i915 support --- linux-core/radeon_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linux-core') diff --git a/linux-core/radeon_drv.c b/linux-core/radeon_drv.c index 43b9aca0..327a6a97 100644 --- a/linux-core/radeon_drv.c +++ b/linux-core/radeon_drv.c @@ -61,7 +61,7 @@ static struct drm_driver driver = { .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | - DRIVER_IRQ_VBL, + DRIVER_IRQ_VBL | DRIVER_IRQ_VBL2, .dev_priv_size = sizeof(drm_radeon_buf_priv_t), .load = radeon_driver_load, .firstopen = radeon_driver_firstopen, @@ -71,6 +71,7 @@ static struct drm_driver driver = { .lastclose = radeon_driver_lastclose, .unload = radeon_driver_unload, .vblank_wait = radeon_driver_vblank_wait, + .vblank_wait2 = radeon_driver_vblank_wait2, .dri_library_name = dri_library_name, .irq_preinstall = radeon_driver_irq_preinstall, .irq_postinstall = radeon_driver_irq_postinstall, -- cgit v1.2.3 From a4cddc6596b30dfa781eb7803de5b60aca50f112 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 Jun 2007 18:12:28 +1000 Subject: Revert "drm: add new drm_wait_on function to replace macro" This reverts commit 6e860d08d0f5b1e9a2d711aaf9fd6b982aa8039e. As I said not a good plan - this macro will have to stay for now, trying to do the vbl code with the inline was a bit messy - may need specialised drm wait on functions --- linux-core/drmP.h | 4 +--- linux-core/drm_drv.c | 28 ---------------------------- 2 files changed, 1 insertion(+), 31 deletions(-) (limited to 'linux-core') diff --git a/linux-core/drmP.h b/linux-core/drmP.h index f988db35..94cb4eee 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -1130,9 +1130,7 @@ extern struct drm_sysfs_class *drm_class; extern struct proc_dir_entry *drm_proc_root; extern drm_local_map_t *drm_getsarea(struct drm_device *dev); -extern int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, - int timeout, int (*fn)(drm_device_t *dev, void *priv), - void *priv); + /* Proc support (drm_proc.h) */ extern int drm_proc_init(drm_device_t * dev, int minor, diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index f64959fb..1695a792 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -610,34 +610,6 @@ err_i1: } EXPORT_SYMBOL(drm_ioctl); -int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, int timeout, - int (*fn)(drm_device_t *dev, void *priv), void *priv) -{ - DECLARE_WAITQUEUE(entry, current); - unsigned long end = jiffies + (timeout); - int ret = 0; - add_wait_queue(queue, &entry); - - for (;;) { - __set_current_state(TASK_INTERRUPTIBLE); - if ((*fn)(dev, priv)) - break; - if (time_after_eq(jiffies, end)) { - ret = -EBUSY; - break; - } - schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); - if (signal_pending(current)) { - ret = -EINTR; - break; - } - } - __set_current_state(TASK_RUNNING); - remove_wait_queue(queue, &entry); - return ret; -} -EXPORT_SYMBOL(drm_wait_on); - drm_local_map_t *drm_getsarea(struct drm_device *dev) { drm_map_list_t *entry; -- cgit v1.2.3