From: <da...@ke...> - 2006-10-02 09:05:22
|
linux-core/drm_irq.c | 4 ++-- linux-core/drm_stub.c | 1 + shared-core/drm_drawable.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) New commits: diff-tree 3a16e615cabfed18b1891a732e7243ef41dc0ad0 (from d58389968124191a546a14b42ef84edc224be23d) Author: Michel Dänzer <mi...@tu...> Date: Mon Oct 2 11:04:42 2006 +0200 Make locked tasklet handling more robust. Initialize the spinlock unconditionally when struct drm_device is filled in, and return early in drm_locked_tasklet() if the driver doesn't support IRQs. diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c index d1a6a6b..41038fd 100644 --- a/linux-core/drm_irq.c +++ b/linux-core/drm_irq.c @@ -118,7 +118,6 @@ static int drm_irq_install(drm_device_t init_waitqueue_head(&dev->vbl_queue); spin_lock_init(&dev->vbl_lock); - spin_lock_init(&dev->tasklet_lock); INIT_LIST_HEAD(&dev->vbl_sigs.head); INIT_LIST_HEAD(&dev->vbl_sigs2.head); @@ -458,7 +457,8 @@ void drm_locked_tasklet(drm_device_t *de unsigned int irqflags; static DECLARE_TASKLET(drm_tasklet, drm_locked_tasklet_func, 0); - if (test_bit(TASKLET_STATE_SCHED, &drm_tasklet.state)) + if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ) || + test_bit(TASKLET_STATE_SCHED, &drm_tasklet.state)) return; spin_lock_irqsave(&dev->tasklet_lock, irqflags); diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index ad78dcf..839cf44 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -62,6 +62,7 @@ static int drm_fill_in_dev(drm_device_t spin_lock_init(&dev->count_lock); spin_lock_init(&dev->drw_lock); + spin_lock_init(&dev->tasklet_lock); init_timer(&dev->timer); mutex_init(&dev->struct_mutex); mutex_init(&dev->ctxlist_mutex); diff-tree d58389968124191a546a14b42ef84edc224be23d (from 7af93dd9849442270ec89cb4bbeef5bfd4f9e424) Author: Felix Kühling <fx...@gm...> Date: Mon Oct 2 10:50:40 2006 +0200 drm_rmdraw: Declare id and idx as signed so testing for < 0 works as intended. diff --git a/shared-core/drm_drawable.c b/shared-core/drm_drawable.c index 5e2fc86..d203b24 100644 --- a/shared-core/drm_drawable.c +++ b/shared-core/drm_drawable.c @@ -132,7 +132,8 @@ int drm_rmdraw(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_draw_t draw; - unsigned int id, idx, shift; + int id, idx; + unsigned int shift; unsigned int irqflags; u32 *bitfield = dev->drw_bitfield; unsigned int bitfield_length = dev->drw_bitfield_length; |
From: <th...@ke...> - 2006-10-20 13:09:38
|
linux-core/drm_agpsupport.c | 2 - linux-core/drm_compat.c | 53 +++++++++++++++++++++++++++----------------- linux-core/drm_compat.h | 22 ++++++++++-------- linux-core/drm_drv.c | 6 ++++ linux-core/drm_vm.c | 8 ++++-- 5 files changed, 57 insertions(+), 34 deletions(-) New commits: diff-tree 9321592149c031694c459bb05e7a31d1197fe5cb (from 3624e43282b0c6aad32829f116fd8f7bce66fbb6) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Fri Oct 20 15:07:21 2006 +0200 We apparently need this global cache flush anyway. diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index a5f1f9e..13a3ced 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -610,7 +610,7 @@ static int drm_agp_bind_ttm(drm_ttm_back DRM_DEBUG("drm_agp_bind_ttm\n"); DRM_MASK_VAL(backend->flags, DRM_BE_FLAG_BOUND_CACHED, (cached) ? DRM_BE_FLAG_BOUND_CACHED : 0); - mem->is_flushed = TRUE; + mem->is_flushed = FALSE; mem->type = (cached) ? agp_priv->cached_type : agp_priv->uncached_type; ret = drm_agp_bind_memory(mem, offset); if (ret) { diff-tree 3624e43282b0c6aad32829f116fd8f7bce66fbb6 (from d70347bfc07bb5e34e36684b95560df37d669db4) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Fri Oct 20 15:06:31 2006 +0200 Bug #8707, 2.6.19-rc compatibility for memory manager code. diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index 90e5341..b466f8b 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -28,6 +28,11 @@ #include "drmP.h" #if defined(CONFIG_X86) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) + +/* + * These have bad performance in the AGP module for the indicated kernel versions. + */ + int drm_map_page_into_agp(struct page *page) { int i; @@ -45,9 +50,15 @@ int drm_unmap_page_from_agp(struct page * performance reasons */ return i; } -#endif +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + +/* + * The protection map was exported in 2.6.19 + */ + pgprot_t vm_get_page_prot(unsigned long vm_flags) { #ifdef MODULE @@ -62,8 +73,17 @@ pgprot_t vm_get_page_prot(unsigned long return protection_map[vm_flags & 0x0F]; #endif }; +#endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) + +/* + * vm code for kernels below 2,6,15 in which version a major vm write + * occured. This implement a simple straightforward + * version similar to what's going to be + * in kernel 2.6.20+? + */ static int drm_pte_is_clear(struct vm_area_struct *vma, unsigned long addr) @@ -76,12 +96,7 @@ static int drm_pte_is_clear(struct vm_ar pgd_t *pgd; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) spin_lock(&mm->page_table_lock); -#else - spinlock_t *ptl; -#endif - pgd = pgd_offset(mm, addr); if (pgd_none(*pgd)) goto unlock; @@ -91,22 +106,13 @@ static int drm_pte_is_clear(struct vm_ar pmd = pmd_offset(pud, addr); if (pmd_none(*pmd)) goto unlock; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) pte = pte_offset_map(pmd, addr); -#else - pte = pte_offset_map_lock(mm, pmd, addr, &ptl); -#endif if (!pte) goto unlock; ret = pte_none(*pte); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) pte_unmap(pte); unlock: spin_unlock(&mm->page_table_lock); -#else - pte_unmap_unlock(pte, ptl); - unlock: -#endif return ret; } @@ -121,7 +127,6 @@ int vm_insert_pfn(struct vm_area_struct return ret; } - static struct { spinlock_t lock; struct page *dummy_page; @@ -154,9 +159,6 @@ void free_nopage_retry(void) spin_unlock(&drm_np_retry.lock); } } -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) struct page *drm_vm_ttm_nopage(struct vm_area_struct *vma, unsigned long address, @@ -186,6 +188,17 @@ struct page *drm_vm_ttm_nopage(struct vm #ifdef DRM_ODD_MM_COMPAT +/* + * VM compatibility code for 2.6.15-2.6.19(?). This code implements a complicated + * workaround for a single BUG statement in do_no_page in these versions. The + * tricky thing is that we need to take the mmap_sem in exclusive mode for _all_ + * vmas mapping the ttm, before dev->struct_mutex is taken. The way we do this is to + * check first take the dev->struct_mutex, and then trylock all mmap_sems. If this + * fails for a single mmap_sem, we have to release all sems and the dev->struct_mutex, + * release the cpu and retry. We also need to keep track of all vmas mapping the ttm. + * phew. + */ + typedef struct p_mm_entry { struct list_head head; struct mm_struct *mm; diff --git a/linux-core/drm_compat.h b/linux-core/drm_compat.h index 5617fb7..a1a9439 100644 --- a/linux-core/drm_compat.h +++ b/linux-core/drm_compat.h @@ -231,7 +231,7 @@ static inline int remap_pfn_range(struct #include <linux/mm.h> #include <asm/page.h> -#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) && \ +#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))) #define DRM_ODD_MM_COMPAT #endif @@ -277,7 +277,18 @@ extern int drm_map_page_into_agp(struct #define unmap_page_from_agp drm_unmap_page_from_agp #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) +extern struct page *get_nopage_retry(void); +extern void free_nopage_retry(void); +struct fault_data; +extern struct page *drm_vm_ttm_fault(struct vm_area_struct *vma, + struct fault_data *data); + +#define NOPAGE_REFAULT get_nopage_retry() +#endif + + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) /* * Hopefully, real NOPAGE_RETRY functionality will be in 2.6.19. @@ -295,10 +306,6 @@ struct fault_data { int type; }; -extern struct page *get_nopage_retry(void); -extern void free_nopage_retry(void); - -#define NOPAGE_REFAULT get_nopage_retry() extern int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); @@ -307,9 +314,6 @@ extern struct page *drm_vm_ttm_nopage(st unsigned long address, int *type); -extern struct page *drm_vm_ttm_fault(struct vm_area_struct *vma, - struct fault_data *data); - #endif #ifdef DRM_ODD_MM_COMPAT diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 75c89c1..518e2aa 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -433,7 +433,7 @@ void drm_exit(struct drm_driver *driver) } } else pci_unregister_driver(&driver->pci_driver); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) free_nopage_retry(); #endif DRM_INFO("Module unloaded\n"); @@ -472,10 +472,14 @@ static void drm_free_mem_cache(kmem_cach { if (!cache) return; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) if (kmem_cache_destroy(cache)) { DRM_ERROR("Warning! DRM is leaking %s memory.\n", name); } +#else + kmem_cache_destroy(cache); +#endif } static void drm_free_memory_caches(void ) diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index ba4b145..fd6e89d 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -159,7 +159,9 @@ static __inline__ struct page *drm_do_vm } #endif /* __OS_HAS_AGP */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) static #endif struct page *drm_vm_ttm_fault(struct vm_area_struct *vma, @@ -244,7 +246,7 @@ struct page *drm_vm_ttm_fault(struct vm_ mutex_unlock(&dev->struct_mutex); return NULL; } - +#endif /** * \c nopage method for shared virtual memory. @@ -535,7 +537,7 @@ static struct vm_operations_struct drm_v .close = drm_vm_close, }; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) static struct vm_operations_struct drm_vm_ttm_ops = { .nopage = drm_vm_ttm_nopage, .open = drm_vm_ttm_open_wrapper, |
From: <th...@ke...> - 2006-10-21 12:20:42
|
linux-core/drm_agpsupport.c | 2 +- linux-core/drm_ttm.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) New commits: diff-tree 7ea059ae076c50f2012dee2ccbb8d41745705383 (from parents) Merge: 9ed4656799043f24f4d64615ebb8128bedc99799 a8909a0ebcc21ad6b92b93ffe87878ece4b56506 Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Sat Oct 21 14:20:28 2006 +0200 Merge branch 'master' of git+ssh://git.freedesktop.org/git/mesa/drm diff-tree 9ed4656799043f24f4d64615ebb8128bedc99799 (from 9321592149c031694c459bb05e7a31d1197fe5cb) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Sat Oct 21 14:17:51 2006 +0200 The CPU cache must be flushed _before_ we start modifying the kernel map ptes, otherwise data will be missing, which becomes apparent when the kernel evicts batch buffers which are likely to be written into in the evicted state, and then rebound to the AGP aperture. This means we cannot rely on the AGP module to flush the cache for us. diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 13a3ced..a5f1f9e 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -610,7 +610,7 @@ static int drm_agp_bind_ttm(drm_ttm_back DRM_DEBUG("drm_agp_bind_ttm\n"); DRM_MASK_VAL(backend->flags, DRM_BE_FLAG_BOUND_CACHED, (cached) ? DRM_BE_FLAG_BOUND_CACHED : 0); - mem->is_flushed = FALSE; + mem->is_flushed = TRUE; mem->type = (cached) ? agp_priv->cached_type : agp_priv->uncached_type; ret = drm_agp_bind_memory(mem, offset); if (ret) { diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index 599589f..7344acc 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -28,6 +28,18 @@ #include "drmP.h" +static void drm_ttm_ipi_handler(void *null) +{ + wbinvd(); +} + +static void drm_ttm_cache_flush(void) +{ + if (on_each_cpu(drm_ttm_ipi_handler, NULL, 1, 1) != 0) + DRM_ERROR("Timed out waiting for drm cache flush.\n"); +} + + /* * Use kmalloc if possible. Otherwise fall back to vmalloc. */ @@ -99,6 +111,9 @@ static int drm_set_caching(drm_ttm_t * t if ((ttm->page_flags & DRM_TTM_PAGE_UNCACHED) == noncached) return 0; + if (noncached) + drm_ttm_cache_flush(); + for (i = 0; i < ttm->num_pages; ++i) { cur_page = ttm->pages + i; if (*cur_page) { |
From: <ai...@ke...> - 2006-12-19 10:35:24
|
linux-core/drm_compat.h | 6 ------ linux-core/drm_os_linux.h | 3 --- linux-core/drm_sysfs.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) New commits: diff-tree aa07b2ab0e1c8a24fb1694ca3b13eb9ea4618fbe (from ff4b5ccdb4ef985c29e3f0d36e1c5094d02733e2) Author: Dave Airlie <ai...@li...> Date: Tue Dec 19 21:33:47 2006 +1100 remove drm pci from 2.5 days diff --git a/linux-core/drm_compat.h b/linux-core/drm_compat.h index 13a2ba8..fe010ef 100644 --- a/linux-core/drm_compat.h +++ b/linux-core/drm_compat.h @@ -86,12 +86,6 @@ pos = n, n = list_entry(n->member.next, typeof(*n), member)) #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -#define DRM_PCI_DEV(pdev) &pdev->dev -#else -#define DRM_PCI_DEV(pdev) NULL -#endif - #ifndef __user #define __user #endif diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c index e5dd053..ace0778 100644 --- a/linux-core/drm_sysfs.c +++ b/linux-core/drm_sysfs.c @@ -162,7 +162,7 @@ struct class_device *drm_sysfs_device_ad memset(s_dev, 0x00, sizeof(*s_dev)); s_dev->dev = MKDEV(DRM_MAJOR, head->minor); - s_dev->class_dev.dev = DRM_PCI_DEV(head->dev->pdev); + s_dev->class_dev.dev = &head->dev->pdev->dev; s_dev->class_dev.class = &cs->class; snprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, "card%d", head->minor); diff-tree ff4b5ccdb4ef985c29e3f0d36e1c5094d02733e2 (from 86ff2aeb9bfea357d5748b3587ab224e813b37b6) Author: Dave Airlie <ai...@li...> Date: Tue Dec 19 21:30:27 2006 +1100 remove legacy taskqueue code diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h index 78dd00e..816959e 100644 --- a/linux-core/drm_os_linux.h +++ b/linux-core/drm_os_linux.h @@ -93,9 +93,6 @@ static __inline__ int mtrr_del(int reg, #define MTRR_TYPE_WRCOMB 1 #endif -/** Task queue handler arguments */ -#define DRM_TASKQUEUE_ARGS void *arg - /** For data going into the kernel through the ioctl argument */ #define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \ if ( copy_from_user(&arg1, arg2, arg3) ) \ |
From: <th...@ke...> - 2006-12-19 22:54:39
|
linux-core/drm_bufs.c | 1 + linux-core/drm_compat.c | 2 ++ linux-core/drm_ttm.c | 2 ++ linux-core/drm_vm.c | 2 ++ 4 files changed, 7 insertions(+) New commits: diff-tree 3b8e6ccd2573a027aa30c10d08253de1756540c2 (from 72b5d1507a7e9c18fc0141c13819ea01c0813924) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Tue Dec 19 23:45:59 2006 +0100 Security fix. Zero pages before they are handed to user space. TTM pages were not cleared when allocated and handed to user space. Sensitive information may leak. diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index b466f8b..cde77ea 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -259,6 +259,8 @@ struct page *drm_vm_ttm_nopage(struct vm } ++bm->cur_pages; SetPageLocked(page); + clear_page(kmap(page)); + kunmap(page); } get_page(page); diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index 931972a..c32dfcf 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -235,6 +235,8 @@ static int drm_ttm_populate(drm_ttm_t * #else SetPageReserved(page); #endif + clear_page(kmap(page)); + kunmap(page); ttm->pages[i] = page; ++bm->cur_pages; } diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 2bf408e..f36218e 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -220,6 +220,8 @@ struct page *drm_vm_ttm_fault(struct vm_ #else SetPageReserved(page); #endif + clear_page(kmap(page)); + kunmap(page); } if (ttm->page_flags & DRM_TTM_PAGE_UNCACHED) { diff-tree 72b5d1507a7e9c18fc0141c13819ea01c0813924 (from 81251bf78f06dc26e26c3edb09639850371fe540) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Tue Dec 19 23:23:17 2006 +0100 Security fix. Zero pages before they are handed to user space. Shared memory areas were not cleared when they are allocated and handed to user space. Sensitive information may leak. diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index d6ebc8d..ef110c2 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -202,6 +202,7 @@ static int drm_addmap_core(drm_device_t drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -ENOMEM; } + memset(map->handle, 0, map->size); map->offset = (unsigned long)map->handle; if (map->flags & _DRM_CONTAINS_LOCK) { /* Prevent a 2nd X Server from creating a 2nd lock */ |
From: <th...@ke...> - 2006-12-21 09:49:33
|
linux-core/drm_mm.c | 13 ++++++------- linux-core/drm_proc.c | 10 +++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) New commits: diff-tree ae5822561370b34808603820a063fc6e8b17dbe2 (from a467d248293f9384092ab39a9214fbf725d21927) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Thu Dec 21 10:40:25 2006 +0100 Improve memory manager accounting printout formatting. diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index 863cacf..1c2c17f 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -452,19 +452,23 @@ static int drm__objects_info(char *buf, *start = &buf[offset]; *eof = 0; + DRM_PROC_PRINT("Object accounting:\n\n"); if (fm->initialized) { - DRM_PROC_PRINT("Number of active fence objects: %d.\n\n", + DRM_PROC_PRINT("Number of active fence objects: %d.\n", atomic_read(&fm->count)); } else { - DRM_PROC_PRINT("Fence objects are not supported by this driver\n\n"); + DRM_PROC_PRINT("Fence objects are not supported by this driver\n"); } if (bm->initialized) { DRM_PROC_PRINT("Number of active buffer objects: %d.\n\n", atomic_read(&bm->count)); + } + DRM_PROC_PRINT("Memory accounting:\n\n"); + if (bm->initialized) { DRM_PROC_PRINT("Number of locked GATT pages: %lu.\n", bm->cur_pages); } else { - DRM_PROC_PRINT("Buffer objects are not supported by this driver.\n\n"); + DRM_PROC_PRINT("Buffer objects are not supported by this driver.\n"); } drm_query_memctl(&used_mem, &low_mem, &high_mem); diff-tree a467d248293f9384092ab39a9214fbf725d21927 (from b7586ab539e5f8d16b473543ab829d0a4441f87c) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Thu Dec 21 10:32:13 2006 +0100 Fix buggy aligned allocations. diff --git a/linux-core/drm_mm.c b/linux-core/drm_mm.c index 0e54447..5889ee4 100644 --- a/linux-core/drm_mm.c +++ b/linux-core/drm_mm.c @@ -148,7 +148,7 @@ drm_mm_node_t *drm_mm_get_block(drm_mm_n unsigned tmp = 0; if (alignment) - tmp = size % alignment; + tmp = parent->start % alignment; if (tmp) { align_splitoff = drm_mm_split_at_start(parent, alignment - tmp); @@ -162,12 +162,8 @@ drm_mm_node_t *drm_mm_get_block(drm_mm_n return parent; } else { child = drm_mm_split_at_start(parent, size); - if (!child) { - if (align_splitoff) - drm_mm_put_block(align_splitoff); - return NULL; - } } + if (align_splitoff) drm_mm_put_block(align_splitoff); @@ -240,8 +236,11 @@ drm_mm_node_t *drm_mm_search_free(const entry = list_entry(list, drm_mm_node_t, fl_entry); wasted = 0; + if (entry->size < size) + continue; + if (alignment) { - register unsigned tmp = size % alignment; + register unsigned tmp = entry->start % alignment; if (tmp) wasted += alignment - tmp; } |
From: <ma...@ke...> - 2007-01-05 18:42:43
|
shared-core/nouveau_drv.h | 3 +++ shared-core/nouveau_fifo.c | 1 + shared-core/nouveau_irq.c | 37 ++++++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 13 deletions(-) New commits: diff-tree 0f95ddc42892abdbc1f111b6b105f2ef4ed2b05f (from parents) Merge: 9d167f1f4bc89b784248d22bc95dfc15a72d0244 f80659bc2967dbed4aed0d44a550bb4a9e4569b5 Author: Matthieu Castet <mat@mat-pc.(none)> Date: Fri Jan 5 19:41:12 2007 +0100 Merge branch 'master' of git+ssh://ma...@gi.../git/mesa/drm/ diff-tree 9d167f1f4bc89b784248d22bc95dfc15a72d0244 (from 4fe2858f53c6ea542cd81961ebdad118acfc8f32) Author: Matthieu Castet <mat@mat-pc.(none)> Date: Fri Jan 5 19:40:11 2007 +0100 Add basic pgraph context for nv10. It only fake a context switch : pgraph state are not save/restored. diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h index 6e998f3..44479d7 100644 --- a/shared-core/nouveau_drv.h +++ b/shared-core/nouveau_drv.h @@ -89,6 +89,9 @@ struct nouveau_fifo struct mem_block *ramin_grctx; /* objects belonging to this fifo */ struct nouveau_object *objs; + + /* XXX move this in PGRAPH struct */ + uint32_t pgraph_ctx_user; }; struct nouveau_config { diff --git a/shared-core/nouveau_fifo.c b/shared-core/nouveau_fifo.c index 9f8c740..e97e4a6 100644 --- a/shared-core/nouveau_fifo.c +++ b/shared-core/nouveau_fifo.c @@ -488,6 +488,7 @@ static int nouveau_fifo_alloc(drm_device init->channel = i; init->put_base = 0; dev_priv->cur_fifo = init->channel; + dev_priv->fifos[i].pgraph_ctx_user = i << 24; nouveau_wait_for_idle(dev); diff --git a/shared-core/nouveau_irq.c b/shared-core/nouveau_irq.c index 160016e..7a31fb0 100644 --- a/shared-core/nouveau_irq.c +++ b/shared-core/nouveau_irq.c @@ -240,21 +240,32 @@ static void nouveau_nv04_context_switch( static void nouveau_nv10_context_switch(drm_device_t *dev) { drm_nouveau_private_t *dev_priv = dev->dev_private; - int channel; + int channel, channel_old; channel=NV_READ(NV_PFIFO_CACH1_PSH1)&(nouveau_fifo_number(dev)-1); - /* 2-channel commute */ -// if (channel==0) -// channel=1; -// else -// channel=0; -// dev_priv->cur_fifo=channel; - -// NV_WRITE(NV_PGRAPH_CTX_CONTROL, 0x10000100); - NV_WRITE(NV_PGRAPH_CTX_USER, NV_READ(NV_PGRAPH_CTX_USER)|0x1F000000); -// NV_WRITE(NV_PGRAPH_FFINTFC_ST2, NV_READ(NV_PGRAPH_FFINTFC_ST2)&0xCFFFFFFF); - /* touch PGRAPH_CTX_SWITCH* here ? */ - NV_WRITE(NV_PGRAPH_CTX_CONTROL, 0x10000100); + channel_old = (NV_READ(NV_PGRAPH_CTX_USER) >> 24) & (nouveau_fifo_number(dev)-1); + + DRM_INFO("NV: PGRAPH context switch interrupt channel %x -> %x\n",channel_old, channel); + + NV_WRITE(NV_PGRAPH_FIFO,0x0); + NV_WRITE(NV_PFIFO_CACH1_PUL0, 0x00000000); + NV_WRITE(NV_PFIFO_CACH1_PUL1, 0x00000000); + NV_WRITE(NV_PFIFO_CACHES, 0x00000000); + + dev_priv->fifos[channel_old].pgraph_ctx_user = NV_READ(NV_PGRAPH_CTX_USER); + //XXX save PGRAPH context + NV_WRITE(NV_PGRAPH_CTX_CONTROL, 0x10000000); + NV_WRITE(NV_PGRAPH_CTX_USER, dev_priv->fifos[channel].pgraph_ctx_user); + //XXX restore PGRAPH context + printk("ctx_user %x %x\n", dev_priv->fifos[channel_old].pgraph_ctx_user, dev_priv->fifos[channel].pgraph_ctx_user); + + NV_WRITE(NV_PGRAPH_FFINTFC_ST2, NV_READ(NV_PGRAPH_FFINTFC_ST2)&0xCFFFFFFF); + NV_WRITE(NV_PGRAPH_CTX_CONTROL, 0x10010100); + + NV_WRITE(NV_PFIFO_CACH1_PUL0, 0x00000001); + NV_WRITE(NV_PFIFO_CACH1_PUL1, 0x00000001); + NV_WRITE(NV_PFIFO_CACHES, 0x00000001); + NV_WRITE(NV_PGRAPH_FIFO,0x1); } static void nouveau_pgraph_irq_handler(drm_device_t *dev) |
From: <ma...@ke...> - 2007-01-05 19:49:19
|
linux-core/nouveau_drv.c | 1 + shared-core/nouveau_drv.h | 4 ++++ shared-core/nouveau_state.c | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) New commits: diff-tree d99c7c27e2df1a7093f3d2f5c7d196f58bfe1647 (from parents) Merge: 025f281bbfe81960e8c60234f5eafd37cbe2d881 0f95ddc42892abdbc1f111b6b105f2ef4ed2b05f Author: Stephane Marchesin <mar...@ic...> Date: Fri Jan 5 20:50:46 2007 +0100 Merge branch 'master' of git+ssh://ma...@gi.../git/mesa/drm diff-tree 025f281bbfe81960e8c60234f5eafd37cbe2d881 (from f80659bc2967dbed4aed0d44a550bb4a9e4569b5) Author: Stephane Marchesin <mar...@ic...> Date: Fri Jan 5 20:49:34 2007 +0100 nouveau: Add an mtrr over the whole FB diff --git a/linux-core/nouveau_drv.c b/linux-core/nouveau_drv.c index 57b55ce..91de2b3 100644 --- a/linux-core/nouveau_drv.c +++ b/linux-core/nouveau_drv.c @@ -42,6 +42,7 @@ static struct drm_driver driver = { DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, .load = nouveau_load, .firstopen = nouveau_firstopen, + .lastclose = nouveau_lastclose, .unload = nouveau_unload, .preclose = nouveau_preclose, .irq_preinstall = nouveau_irq_preinstall, diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h index 6e998f3..7f012d6 100644 --- a/shared-core/nouveau_drv.h +++ b/shared-core/nouveau_drv.h @@ -129,6 +129,9 @@ typedef struct drm_nouveau_private { uint64_t fb_phys; uint64_t agp_phys; + /* the mtrr covering the FB */ + int fb_mtrr; + struct mem_block *agp_heap; struct mem_block *fb_heap; struct mem_block *fb_nomap_heap; @@ -142,6 +145,7 @@ drm_nouveau_private_t; extern void nouveau_preclose(drm_device_t * dev, DRMFILE filp); extern int nouveau_load(struct drm_device *dev, unsigned long flags); extern int nouveau_firstopen(struct drm_device *dev); +extern void nouveau_lastclose(struct drm_device *dev); extern int nouveau_unload(struct drm_device *dev); extern int nouveau_ioctl_getparam(DRM_IOCTL_ARGS); extern int nouveau_ioctl_setparam(DRM_IOCTL_ARGS); diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index c66ecd4..2d0f798 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -46,7 +46,7 @@ int nouveau_firstopen(struct drm_device /* resource 0 is mmio regs */ /* resource 1 is linear FB */ - /* resource 2 is ??? (mmio regs + 0x1000000) */ + /* resource 2 is RAMIN (mmio regs + 0x1000000) */ /* resource 6 is bios */ /* map the mmio regs */ @@ -71,6 +71,11 @@ int nouveau_firstopen(struct drm_device ret = nouveau_fifo_init(dev); if (ret) return ret; +#if __OS_HAS_MTRR + /* setup a mtrr over the FB */ + dev_priv->fb_mtrr=drm_mtrr_add(drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC); +#endif + /* FIXME: doesn't belong here, and have no idea what it's for.. */ if (dev_priv->card_type >= NV_40) nv40_graph_init(dev); @@ -98,6 +103,15 @@ int nouveau_load(struct drm_device *dev, return 0; } +void nouveau_lastclose(struct drm_device *dev) +{ +#if __OS_HAS_MTRR + drm_nouveau_private_t *dev_priv = dev->dev_private; + if(dev_priv->fb_mtrr>0) + drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC); +#endif +} + int nouveau_unload(struct drm_device *dev) { drm_free(dev->dev_private, sizeof(*dev->dev_private), DRM_MEM_DRIVER); |
From: <dar...@ke...> - 2007-01-06 07:19:08
|
shared-core/nouveau_reg.h | 1 shared-core/nv40_graph.c | 70 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 12 deletions(-) New commits: diff-tree 1f1714cf3dd24ea4109722ea2b47bcf4725f27ea (from dbb0d979cc6c4e1f444cdbbf6dc3571c3818ea39) Author: Ben Skeggs <dar...@ii...> Date: Sat Jan 6 18:05:21 2007 +1100 nouveau: get c51 doing glxgears without the binary driver's help. diff --git a/shared-core/nv40_graph.c b/shared-core/nv40_graph.c index 6a4f138..77af37f 100644 --- a/shared-core/nv40_graph.c +++ b/shared-core/nv40_graph.c @@ -285,8 +285,12 @@ nv40_graph_context_create(drm_device_t * /* Initialise default context values */ if (dev_priv->card_type == NV_40) nv40_graph_context_init(dev, chan->ramin_grctx); - else + else { + /*XXX: this context was pulled from a c51 card. no idea if it + * is usable on a "real" nv44... + */ nv44_graph_context_init(dev, chan->ramin_grctx); + } return 0; } @@ -379,14 +383,20 @@ nv40_graph_context_restore(drm_device_t /* Some voodoo that makes context switching work without the binary driver * initialising the card first. * - * My best guess is that this describes to the GPU how to save/restore the - * context between RAMIN and PGRAPH. But, this is just a hunch.. no actual - * evidence as of yet.. Though, it should be easily testable. + * It is possible to effect how the context is saved from PGRAPH into a block + * of instance memory by altering the values in these tables. This may mean + * that the context layout of each chipset is slightly different (at least + * NV40 and C51 are different). It would also be possible for chipsets to + * have an identical context layout, but pull the data from different PGRAPH + * registers. * - * If that hunch is correct, it's likely that this differs between cards. At - * least NV44 has a different grctx layout than NV40 does. + * TODO: decode the meaning of the magic values, may provide clues about the + * differences between the various NV40 chipsets. + * TODO: one we have a better idea of how each chipset differs, perhaps think + * about unifying these instead of providing a separate table for each + * chip. * - * mmio-trace dumps from other nv4x cards very welcome :) + * mmio-trace dumps from other nv4x/g7x/c5x cards very welcome :) */ static uint32_t nv40_ctx_voodoo[] = { 0x00400889, 0x00200000, 0x0060000a, 0x00200000, 0x00300000, 0x00800001, @@ -420,6 +430,40 @@ static uint32_t nv40_ctx_voodoo[] = { ~0 }; +static uint32_t c51_ctx_voodoo[] = { + 0x00400889, 0x00200000, 0x0060000a, 0x00200000, 0x00300000, 0x00800001, + 0x00700009, 0x0060000e, 0x00400d64, 0x00400d05, 0x00409565, 0x00409a06, + 0x0040a868, 0x00200000, 0x0060000a, 0x00700000, 0x00106000, 0x00700080, + 0x004014e6, 0x007000a0, 0x00401a84, 0x00700082, 0x00600001, 0x00500061, + 0x00600002, 0x00401b68, 0x00500060, 0x00200001, 0x0060000a, 0x0011814d, + 0x00110158, 0x00105401, 0x0020003a, 0x00100051, 0x001040c5, 0x0010c1c4, + 0x001041c9, 0x0010c1dc, 0x00150210, 0x0012c225, 0x00108238, 0x0010823e, + 0x001242c0, 0x00200040, 0x00100280, 0x00128100, 0x00128120, 0x00128143, + 0x0011415f, 0x0010815c, 0x0010c140, 0x00104029, 0x00110400, 0x00104d10, + 0x001046ec, 0x00500060, 0x00403a87, 0x0060000d, 0x00407ce6, 0x002000f1, + 0x0060000a, 0x00148653, 0x00104668, 0x0010c66d, 0x00120682, 0x0011068b, + 0x00168691, 0x001046ae, 0x001046b0, 0x001206b4, 0x001046c4, 0x001146c6, + 0x001646cc, 0x001186e6, 0x001046ed, 0x001246f0, 0x002000c0, 0x00100700, + 0x0010c3d7, 0x001043e1, 0x00500060, 0x00405800, 0x00405884, 0x00600003, + 0x00500067, 0x00600008, 0x00500060, 0x00700082, 0x00200232, 0x0060000a, + 0x00104800, 0x00108901, 0x00104910, 0x00124920, 0x0020001f, 0x00100940, + 0x00140965, 0x00148a00, 0x00108a14, 0x00140b00, 0x00134b2c, 0x0010cd00, + 0x0010cd04, 0x00104d08, 0x00104d80, 0x00104e00, 0x00105c00, 0x00104f06, + 0x002002b2, 0x0060000a, 0x00300000, 0x00200080, 0x00407200, 0x00200084, + 0x00800001, 0x002004fa, 0x0060000a, 0x00201320, 0x0040788a, 0xfffffb06, + 0x00800029, 0x00407c84, 0x00200b20, 0x00800002, 0x00408d00, 0x00600006, + 0x00700003, 0x004086e6, 0x00700080, 0x002002b2, 0x0060000a, 0x00200004, + 0x00800001, 0x00700000, 0x00200000, 0x0060000a, 0x00106002, 0x0040a884, + 0x00700002, 0x00600004, 0x0040a868, 0x00700000, 0x00200000, 0x0060000a, + 0x00106002, 0x00700080, 0x00400a84, 0x00700002, 0x00400a68, 0x00500060, + 0x00600007, 0x00409988, 0x0060000f, 0x00000000, 0x00500060, 0x00200000, + 0x0060000a, 0x00700000, 0x00106001, 0x00700083, 0x00910880, 0x00901ffe, + 0x01940000, 0x00200020, 0x0060000b, 0x00500069, 0x0060000c, 0x00401b68, + 0x0040aa06, 0x0040ab05, 0x00600009, 0x00700005, 0x00700006, 0x0060000e, + ~0 +}; + + int nv40_graph_init(drm_device_t *dev) { @@ -430,11 +474,10 @@ nv40_graph_init(drm_device_t *dev) int i, chipset; chipset = (NV_READ(NV_PMC_BOOT_0) & 0x0ff00000) >> 20; - DRM_DEBUG("chipset (from PMC_BOOT_0): NV0x%02X\n", chipset); + DRM_DEBUG("chipset (from PMC_BOOT_0): NV%02X\n", chipset); switch (chipset) { - case 0x40: - ctx_voodoo = nv40_ctx_voodoo; - break; + case 0x40: ctx_voodoo = nv40_ctx_voodoo; break; + case 0x4e: ctx_voodoo = c51_ctx_voodoo; break; default: DRM_ERROR("Unknown ctx_voodoo for chipset 0x%02x\n", chipset); ctx_voodoo = NULL; diff-tree dbb0d979cc6c4e1f444cdbbf6dc3571c3818ea39 (from 528ab8ce4038397c043b05a46f95c666a985f7a3) Author: Ben Skeggs <dar...@ii...> Date: Sat Jan 6 17:50:00 2007 +1100 nouveau: Use PMC_BOOT_0 to determine which ctx_voodoo to load. diff --git a/shared-core/nouveau_reg.h b/shared-core/nouveau_reg.h index 38a2206..23fce39 100644 --- a/shared-core/nouveau_reg.h +++ b/shared-core/nouveau_reg.h @@ -45,6 +45,7 @@ # define NV03_FIFO_REGS_DMAPUT(i) (NV03_FIFO_REGS(i)+0x40) # define NV03_FIFO_REGS_DMAGET(i) (NV03_FIFO_REGS(i)+0x44) +#define NV_PMC_BOOT_0 0x00000000 #define NV_PMC_INTSTAT 0x00000100 # define NV_PMC_INTSTAT_PFIFO_PENDING (1<< 8) # define NV_PMC_INTSTAT_PGRAPH_PENDING (1<<12) diff --git a/shared-core/nv40_graph.c b/shared-core/nv40_graph.c index 6e3ef2c..6a4f138 100644 --- a/shared-core/nv40_graph.c +++ b/shared-core/nv40_graph.c @@ -427,13 +427,16 @@ nv40_graph_init(drm_device_t *dev) (drm_nouveau_private_t *)dev->dev_private; uint32_t *ctx_voodoo; uint32_t pg0220_inst; - int i; + int i, chipset; - switch (dev_priv->card_type) { - case NV_40: + chipset = (NV_READ(NV_PMC_BOOT_0) & 0x0ff00000) >> 20; + DRM_DEBUG("chipset (from PMC_BOOT_0): NV0x%02X\n", chipset); + switch (chipset) { + case 0x40: ctx_voodoo = nv40_ctx_voodoo; break; default: + DRM_ERROR("Unknown ctx_voodoo for chipset 0x%02x\n", chipset); ctx_voodoo = NULL; break; } |
From: <dar...@ke...> - 2007-01-07 13:45:11
|
shared-core/nouveau_drv.h | 15 ++++++--- shared-core/nouveau_fifo.c | 12 ++----- shared-core/nouveau_mem.c | 70 ++++++++++++++++++++++++++++++++++++++++---- shared-core/nouveau_state.c | 15 +++++++++ 4 files changed, 94 insertions(+), 18 deletions(-) New commits: diff-tree faa46122993bc5970b3d67933bd81d863a3c4762 (from cd3711455e7e5e69448b4805bddc2adcd480c6d5) Author: Ben Skeggs <dar...@ii...> Date: Mon Jan 8 00:37:39 2007 +1100 nouveau: avoid allocating vram that's used as instance memory. diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h index 7b366f1..6b09046 100644 --- a/shared-core/nouveau_drv.h +++ b/shared-core/nouveau_drv.h @@ -120,7 +120,8 @@ typedef struct drm_nouveau_private { int fifo_alloc_count; struct nouveau_fifo fifos[NV_MAX_FIFO_NUMBER]; - /* RAMFC and RAMRO offsets */ + /* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */ + uint32_t ramin_size; uint32_t ramht_offset; uint32_t ramht_size; uint32_t ramht_bits; @@ -165,7 +166,7 @@ extern void nouveau_mem_fre extern int nouveau_mem_init(struct drm_device *dev); extern void nouveau_mem_close(struct drm_device *dev); extern int nouveau_instmem_init(struct drm_device *dev, - uint32_t offset, uint32_t size); + uint32_t offset); extern struct mem_block* nouveau_instmem_alloc(struct drm_device *dev, uint32_t size, uint32_t align); extern void nouveau_instmem_free(struct drm_device *dev, diff --git a/shared-core/nouveau_fifo.c b/shared-core/nouveau_fifo.c index 0e47da0..e5f825e 100644 --- a/shared-core/nouveau_fifo.c +++ b/shared-core/nouveau_fifo.c @@ -69,11 +69,10 @@ static int nouveau_fifo_ctx_size(drm_dev static int nouveau_fifo_instmem_configure(drm_device_t *dev) { drm_nouveau_private_t *dev_priv = dev->dev_private; - uint32_t obj_base, obj_size; int i; - /* Clear RAMIN */ - for (i=0x00710000; i<0x00800000; i++) + /* Clear start of RAMIN, enough to cover RAMFC/HT/RO basically */ + for (i=0x00710000; i<0x00730000; i++) NV_WRITE(i, 0x00000000); /* FIFO hash table (RAMHT) @@ -139,12 +138,9 @@ static int nouveau_fifo_instmem_configur dev_priv->ramfc_offset, dev_priv->ramfc_size); - obj_base = dev_priv->ramfc_offset + dev_priv->ramfc_size; - obj_size = (512*1024) - obj_base; /*XXX: probably wrong on some cards*/ - if (nouveau_instmem_init(dev, obj_base, obj_size)) + if (nouveau_instmem_init(dev, dev_priv->ramfc_offset + + dev_priv->ramfc_size)) return 1; - DRM_DEBUG("RAMIN object space: offset=0x%08x, size=%dKiB\n", - obj_base, obj_size>>10); return 0; } diff --git a/shared-core/nouveau_mem.c b/shared-core/nouveau_mem.c index df8641e..cd53d25 100644 --- a/shared-core/nouveau_mem.c +++ b/shared-core/nouveau_mem.c @@ -282,6 +282,7 @@ uint64_t nouveau_mem_fb_amount(struct dr int nouveau_mem_init(struct drm_device *dev) { drm_nouveau_private_t *dev_priv = dev->dev_private; + uint32_t fb_size; dev_priv->agp_phys=0; dev_priv->fb_phys=0; @@ -340,15 +341,22 @@ no_agp: /* Init FB */ dev_priv->fb_phys=drm_get_resource_start(dev,1); - if (nouveau_mem_fb_amount(dev)>256*1024*1024) { + fb_size = nouveau_mem_fb_amount(dev); + /* On at least NV40, RAMIN is actually at the end of vram. + * We don't want to allocate this... */ + if (dev_priv->card_type >= NV_40) + fb_size -= dev_priv->ramin_size; + DRM_DEBUG("Available VRAM: %dKiB\n", fb_size>>10); + + if (fb_size>256*1024*1024) { /* On cards with > 256Mb, you can't map everything. * So we create a second FB heap for that type of memory */ if (init_heap(&dev_priv->fb_heap, drm_get_resource_start(dev,1), 256*1024*1024)) return DRM_ERR(ENOMEM); - if (init_heap(&dev_priv->fb_nomap_heap, drm_get_resource_start(dev,1)+256*1024*1024, nouveau_mem_fb_amount(dev)-256*1024*1024)) + if (init_heap(&dev_priv->fb_nomap_heap, drm_get_resource_start(dev,1)+256*1024*1024, fb_size-256*1024*1024)) return DRM_ERR(ENOMEM); } else { - if (init_heap(&dev_priv->fb_heap, drm_get_resource_start(dev,1), nouveau_mem_fb_amount(dev))) + if (init_heap(&dev_priv->fb_heap, drm_get_resource_start(dev,1), fb_size)) return DRM_ERR(ENOMEM); dev_priv->fb_nomap_heap=NULL; } @@ -449,13 +457,31 @@ void nouveau_mem_free(struct drm_device* free_block(block); } -int nouveau_instmem_init(struct drm_device *dev, uint32_t offset, - uint32_t size) +int nouveau_instmem_init(struct drm_device *dev, uint32_t offset) { drm_nouveau_private_t *dev_priv = dev->dev_private; int ret; - ret = init_heap(&dev_priv->ramin_heap, offset, size); + if (dev_priv->card_type >= NV_40) + /* We'll want more instance memory than this on some NV4x cards. + * There's a 16MB aperture to play with that maps onto the end + * of vram. For now, only reserve a small piece until we know + * more about what each chipset requires. + */ + dev_priv->ramin_size = (1*1024* 1024); + else { + /*XXX: what *are* the limits on <NV40 cards?, and does RAMIN + * exist in vram on those cards as well? + */ + dev_priv->ramin_size = (512*1024); + } + DRM_DEBUG("RAMIN size: %dKiB\n", dev_priv->ramin_size>>10); + + /* Create a heap to manage RAMIN allocations, we don't allocate + * the space that was reserved for RAMHT/FC/RO. + */ + ret = init_heap(&dev_priv->ramin_heap, offset, + dev_priv->ramin_size - offset); if (ret) { dev_priv->ramin_heap = NULL; DRM_ERROR("Failed to init RAMIN heap\n"); diff-tree cd3711455e7e5e69448b4805bddc2adcd480c6d5 (from 31daf669624c35bdf686aaeea7d7844d0cb5141a) Author: Ben Skeggs <dar...@ii...> Date: Sun Jan 7 23:56:45 2007 +1100 nouveau: map pci resource 2 on >=nv40 diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h index 1cf13ef..7b366f1 100644 --- a/shared-core/nouveau_drv.h +++ b/shared-core/nouveau_drv.h @@ -108,6 +108,7 @@ typedef struct drm_nouveau_private { drm_local_map_t *mmio; drm_local_map_t *fb; + drm_local_map_t *ramin; /* NV40 onwards */ //TODO: Remove me, I'm bogus :) int cur_fifo; @@ -169,6 +170,11 @@ extern struct mem_block* nouveau_instmem uint32_t size, uint32_t align); extern void nouveau_instmem_free(struct drm_device *dev, struct mem_block *block); +extern uint32_t nouveau_instmem_r32(drm_nouveau_private_t *dev_priv, + struct mem_block *mem, int index); +extern void nouveau_instmem_w32(drm_nouveau_private_t *dev_priv, + struct mem_block *mem, int index, + uint32_t val); /* nouveau_fifo.c */ extern int nouveau_fifo_init(drm_device_t *dev); @@ -208,8 +214,8 @@ extern long nouveau_compat_ioctl(struct #define NV_WRITE(reg,val) DRM_WRITE32( dev_priv->mmio, (reg), (val) ) #endif -#define INSTANCE_WR(mem,ofs,val) NV_WRITE(NV_RAMIN+(uint32_t)(mem)->start+((ofs)<<2),(val)) -#define INSTANCE_RD(mem,ofs) NV_READ(NV_RAMIN+(uint32_t)(mem)->start+((ofs)<<2)) +#define INSTANCE_WR(mem,ofs,val) nouveau_instmem_w32(dev_priv,(mem),(ofs),(val)) +#define INSTANCE_RD(mem,ofs) nouveau_instmem_r32(dev_priv,(mem),(ofs)) #endif /* __NOUVEAU_DRV_H__ */ diff --git a/shared-core/nouveau_mem.c b/shared-core/nouveau_mem.c index 4d4100e..df8641e 100644 --- a/shared-core/nouveau_mem.c +++ b/shared-core/nouveau_mem.c @@ -492,6 +492,38 @@ void nouveau_instmem_free(struct drm_dev } } +uint32_t nouveau_instmem_r32(drm_nouveau_private_t *dev_priv, + struct mem_block *mem, int index) +{ + uint32_t ofs = (uint32_t)mem->start + (index<<2); + + if (dev_priv->ramin) { +#if defined(__powerpc__) + return in_be32((void __iomem *)(dev_priv->ramin)->handle + ofs); +#else + return DRM_READ32(dev_priv->ramin, ofs); +#endif + } else { + return NV_READ(NV_RAMIN+ofs); + } +} + +void nouveau_instmem_w32(drm_nouveau_private_t *dev_priv, + struct mem_block *mem, int index, uint32_t val) +{ + uint32_t ofs = (uint32_t)mem->start + (index<<2); + + if (dev_priv->ramin) { +#if defined(__powerpc__) + out_be32((void __iomem *)(dev_priv->ramin)->handle + ofs, val); +#else + DRM_WRITE32(dev_priv->ramin, ofs, val); +#endif + } else { + NV_WRITE(NV_RAMIN+ofs, val); + } +} + /* * Ioctls */ diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index 43f9c2a..951e21f 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -64,6 +64,21 @@ int nouveau_firstopen(struct drm_device DRM_INFO("%lld MB of video ram detected\n",nouveau_mem_fb_amount(dev)>>20); + /* map larger RAMIN aperture on NV40 cards */ + if (dev_priv->card_type >= NV_40) { + ret = drm_addmap(dev, drm_get_resource_start(dev, 2), + drm_get_resource_len(dev, 2), + _DRM_REGISTERS, + _DRM_READ_ONLY, + &dev_priv->ramin); + if (ret) { + DRM_ERROR("Failed to init RAMIN mapping, " + "limited instance memory available\n"); + dev_priv->ramin = NULL; + } + } else + dev_priv->ramin = NULL; + /* Clear RAMIN * Determine locations for RAMHT/FC/RO * Initialise PFIFO |
From: <ai...@ke...> - 2007-01-08 00:53:31
|
linux-core/drmP.h | 22 +----------- linux-core/drm_bufs.c | 8 +++- linux-core/drm_memory.c | 23 ++++++++++++ linux-core/drm_memory.h | 76 ------------------------------------------ linux-core/drm_memory_debug.c | 73 ---------------------------------------- linux-core/drm_memory_debug.h | 68 ------------------------------------- linux-core/drm_vm.c | 2 - linux-core/i810_dma.c | 34 ++++++++++++------ linux-core/i810_drv.h | 2 + linux-core/i830_dma.c | 32 +++++++++++------ linux-core/i830_drv.h | 2 + 11 files changed, 80 insertions(+), 262 deletions(-) New commits: diff-tree b147c3926352e4dcb9dbf53b8b12baae8ce34254 (from fe5770b89e57c669a946dea86a58b17387bf9cf4) Author: Christoph Hellwig <hc...@in...> Date: Mon Jan 8 10:55:49 2007 +1100 drm: remove drm_follow_page, and drm_ioremap and ioremapfree This comes from the Re: [patch] paravirt: isolate module ops on lkml It needs some testing, please report any regressions caused. Signed-off-by: Dave Airlie <ai...@li...> diff --git a/linux-core/drmP.h b/linux-core/drmP.h index ecb0318..af8a544 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -1457,26 +1457,8 @@ extern int drm_fence_buffer_objects(drm_ drm_fence_object_t *fence, drm_fence_object_t **used_fence); - -/* Inline replacements for DRM_IOREMAP macros */ -static __inline__ void drm_core_ioremap(struct drm_map *map, - struct drm_device *dev) -{ - map->handle = drm_ioremap(map->offset, map->size, dev); -} - -static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, - struct drm_device *dev) -{ - map->handle = drm_ioremap_nocache(map->offset, map->size, dev); -} - -static __inline__ void drm_core_ioremapfree(struct drm_map *map, - struct drm_device *dev) -{ - if (map->handle && map->size) - drm_ioremapfree(map->handle, map->size, dev); -} +extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev); +extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev); static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsigned int token) diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 1ff191a..8793ba0 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -179,7 +179,7 @@ static int drm_addmap_core(drm_device_t } } if (map->type == _DRM_REGISTERS) - map->handle = drm_ioremap(map->offset, map->size, dev); + map->handle = ioremap(map->offset, map->size); break; case _DRM_SHM: list = drm_find_matching_map(dev, map); @@ -279,6 +279,8 @@ static int drm_addmap_core(drm_device_t list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); if (!list) { + if (map->type == _DRM_REGISTERS) + iounmap(map->handle); drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } @@ -295,6 +297,8 @@ static int drm_addmap_core(drm_device_t ret = drm_map_handle(dev, &list->hash, user_token, 0); if (ret) { + if (map->type == _DRM_REGISTERS) + iounmap(map->handle); drm_free(map, sizeof(*map), DRM_MEM_MAPS); drm_free(list, sizeof(*list), DRM_MEM_MAPS); mutex_unlock(&dev->struct_mutex); @@ -402,7 +406,7 @@ int drm_rmmap_locked(drm_device_t *dev, switch (map->type) { case _DRM_REGISTERS: - drm_ioremapfree(map->handle, map->size, dev); + iounmap(map->handle); /* FALLTHROUGH */ case _DRM_FRAME_BUFFER: if (drm_core_has_MTRR(dev) && map->mtrr >= 0) { diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index 10f43f4..62f54b6 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -244,3 +244,26 @@ int drm_unbind_agp(DRM_AGP_MEM * handle) } #endif /* agp */ #endif /* debug_memory */ + +void drm_core_ioremap(struct drm_map *map, struct drm_device *dev) +{ + if (drm_core_has_AGP(dev) && + dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) + map->handle = agp_remap(map->offset, map->size, dev); + else + map->handle = ioremap(map->offset, map->size); +} +EXPORT_SYMBOL_GPL(drm_core_ioremap); + +void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev) +{ + if (!map->handle || !map->size) + return; + + if (drm_core_has_AGP(dev) && + dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) + vunmap(map->handle); + else + iounmap(map->handle); +} +EXPORT_SYMBOL_GPL(drm_core_ioremapfree); diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h index c299e25..32b89e5 100644 --- a/linux-core/drm_memory.h +++ b/linux-core/drm_memory.h @@ -122,19 +122,6 @@ static inline void *agp_remap(unsigned l return addr; } -static inline unsigned long drm_follow_page(void *vaddr) -{ - pgd_t *pgd = pgd_offset_k((unsigned long) vaddr); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,10) - pmd_t *pmd = pmd_offset(pgd, (unsigned long)vaddr); -#else - pud_t *pud = pud_offset(pgd, (unsigned long) vaddr); - pmd_t *pmd = pmd_offset(pud, (unsigned long) vaddr); -#endif - pte_t *ptep = pte_offset_kernel(pmd, (unsigned long) vaddr); - return pte_pfn(*ptep) << PAGE_SHIFT; -} - #else /* __OS_HAS_AGP */ static inline drm_map_t *drm_lookup_map(unsigned long offset, @@ -149,67 +136,4 @@ static inline void *agp_remap(unsigned l return NULL; } -static inline unsigned long drm_follow_page(void *vaddr) -{ - return 0; -} -#endif - -#ifndef DEBUG_MEMORY -static inline void *drm_ioremap(unsigned long offset, unsigned long size, - drm_device_t * dev) -{ - if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { - drm_map_t *map = drm_lookup_map(offset, size, dev); - - if (map && map->type == _DRM_AGP) - return agp_remap(offset, size, dev); - } - - return ioremap(offset, size); -} - -static inline void *drm_ioremap_nocache(unsigned long offset, - unsigned long size, drm_device_t * dev) -{ - if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { - drm_map_t *map = drm_lookup_map(offset, size, dev); - - if (map && map->type == _DRM_AGP) - return agp_remap(offset, size, dev); - } - - return ioremap_nocache(offset, size); -} - -static inline void drm_ioremapfree(void *pt, unsigned long size, - drm_device_t * dev) -{ - /* - * This is a bit ugly. It would be much cleaner if the DRM API would use separate - * routines for handling mappings in the AGP space. Hopefully this can be done in - * a future revision of the interface... - */ - if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture - && ((unsigned long)pt >= VMALLOC_START - && (unsigned long)pt < VMALLOC_END)) { - unsigned long offset; - drm_map_t *map; - - offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK); - map = drm_lookup_map(offset, size, dev); - if (map && map->type == _DRM_AGP) { - vunmap(pt); - return; - } - } - iounmap(pt); -} -#else -extern void *drm_ioremap(unsigned long offset, unsigned long size, - drm_device_t * dev); -extern void *drm_ioremap_nocache(unsigned long offset, - unsigned long size, drm_device_t * dev); -extern void drm_ioremapfree(void *pt, unsigned long size, - drm_device_t * dev); #endif diff --git a/linux-core/drm_memory_debug.c b/linux-core/drm_memory_debug.c index aa1b292..c124f8f 100644 --- a/linux-core/drm_memory_debug.c +++ b/linux-core/drm_memory_debug.c @@ -289,79 +289,6 @@ void drm_free_pages(unsigned long addres } } -void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t * dev) -{ - void *pt; - - if (!size) { - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Mapping 0 bytes at 0x%08lx\n", offset); - return NULL; - } - - if (!(pt = drm_ioremap(offset, size, dev))) { - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count; - spin_unlock(&drm_mem_lock); - return NULL; - } - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count; - drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size; - spin_unlock(&drm_mem_lock); - return pt; -} -EXPORT_SYMBOL(drm_ioremap); - -void *drm_ioremap_nocache(unsigned long offset, unsigned long size, - drm_device_t * dev) -{ - void *pt; - - if (!size) { - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Mapping 0 bytes at 0x%08lx\n", offset); - return NULL; - } - - if (!(pt = drm_ioremap_nocache(offset, size, dev))) { - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count; - spin_unlock(&drm_mem_lock); - return NULL; - } - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count; - drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size; - spin_unlock(&drm_mem_lock); - return pt; -} -EXPORT_SYMBOL(drm_ioremap_nocache); - -void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev) -{ - int alloc_count; - int free_count; - - if (!pt) - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Attempt to free NULL pointer\n"); - else - drm_ioremapfree(pt, size, dev); - - spin_lock(&drm_mem_lock); - drm_mem_stats[DRM_MEM_MAPPINGS].bytes_freed += size; - free_count = ++drm_mem_stats[DRM_MEM_MAPPINGS].free_count; - alloc_count = drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count; - spin_unlock(&drm_mem_lock); - if (free_count > alloc_count) { - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Excess frees: %d frees, %d allocs\n", - free_count, alloc_count); - } -} -EXPORT_SYMBOL(drm_ioremapfree); - #if __OS_HAS_AGP DRM_AGP_MEM *drm_alloc_agp(drm_device_t *dev, int pages, u32 type) diff --git a/linux-core/drm_memory_debug.h b/linux-core/drm_memory_debug.h index 1e0a63b..9d0dedf 100644 --- a/linux-core/drm_memory_debug.h +++ b/linux-core/drm_memory_debug.h @@ -275,74 +275,6 @@ void drm_free_pages (unsigned long addre } } -void *drm_ioremap (unsigned long offset, unsigned long size, - drm_device_t * dev) { - void *pt; - - if (!size) { - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Mapping 0 bytes at 0x%08lx\n", offset); - return NULL; - } - - if (!(pt = drm_ioremap(offset, size, dev))) { - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count; - spin_unlock(&drm_mem_lock); - return NULL; - } - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count; - drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size; - spin_unlock(&drm_mem_lock); - return pt; -} - -void *drm_ioremap_nocache (unsigned long offset, unsigned long size, - drm_device_t * dev) { - void *pt; - - if (!size) { - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Mapping 0 bytes at 0x%08lx\n", offset); - return NULL; - } - - if (!(pt = drm_ioremap_nocache(offset, size, dev))) { - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count; - spin_unlock(&drm_mem_lock); - return NULL; - } - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count; - drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size; - spin_unlock(&drm_mem_lock); - return pt; -} - -void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) { - int alloc_count; - int free_count; - - if (!pt) - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Attempt to free NULL pointer\n"); - else - drm_ioremapfree(pt, size, dev); - - spin_lock(&drm_mem_lock); - drm_mem_stats[DRM_MEM_MAPPINGS].bytes_freed += size; - free_count = ++drm_mem_stats[DRM_MEM_MAPPINGS].free_count; - alloc_count = drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count; - spin_unlock(&drm_mem_lock); - if (free_count > alloc_count) { - DRM_MEM_ERROR(DRM_MEM_MAPPINGS, - "Excess frees: %d frees, %d allocs\n", - free_count, alloc_count); - } -} - #if __OS_HAS_AGP DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) { diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 2413016..827a7bd 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -349,7 +349,7 @@ static void drm_vm_shm_close(struct vm_a map->size); DRM_DEBUG("mtrr_del = %d\n", retcode); } - drm_ioremapfree(map->handle, map->size, dev); + iounmap(map->handle); break; case _DRM_SHM: vfree(map->handle); diff-tree fe5770b89e57c669a946dea86a58b17387bf9cf4 (from faa46122993bc5970b3d67933bd81d863a3c4762) Author: Dave Airlie <ai...@i8...> Date: Mon Jan 8 22:27:11 2007 +1100 fixup i810/i830 to use drm_core_ioremap instead of drm_ioremap diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c index 3126796..ad4d2fc 100644 --- a/linux-core/i810_dma.c +++ b/linux-core/i810_dma.c @@ -238,8 +238,7 @@ static int i810_dma_cleanup(drm_device_t (drm_i810_private_t *) dev->dev_private; if (dev_priv->ring.virtual_start) { - drm_ioremapfree((void *)dev_priv->ring.virtual_start, - dev_priv->ring.Size, dev); + drm_core_ioremapfree(&dev_priv->ring.map, dev); } if (dev_priv->hw_status_page) { pci_free_consistent(dev->pdev, PAGE_SIZE, @@ -255,9 +254,9 @@ static int i810_dma_cleanup(drm_device_t for (i = 0; i < dma->buf_count; i++) { drm_buf_t *buf = dma->buflist[i]; drm_i810_buf_priv_t *buf_priv = buf->dev_private; + if (buf_priv->kernel_virtual && buf->total) - drm_ioremapfree(buf_priv->kernel_virtual, - buf->total, dev); + drm_core_ioremapfree(&buf_priv->map, dev); } } return 0; @@ -330,8 +329,15 @@ static int i810_freelist_init(drm_device *buf_priv->in_use = I810_BUF_FREE; - buf_priv->kernel_virtual = drm_ioremap(buf->bus_address, - buf->total, dev); + buf_priv->map.offset = buf->bus_address; + buf_priv->map.size = buf->total; + buf_priv->map.type = _DRM_AGP; + buf_priv->map.flags = 0; + buf_priv->map.mtrr = 0; + + drm_core_ioremap(&buf_priv->map, dev); + buf_priv->kernel_virtual = buf_priv->map.handle; + } return 0; } @@ -382,18 +388,24 @@ static int i810_dma_initialize(drm_devic dev_priv->ring.End = init->ring_end; dev_priv->ring.Size = init->ring_size; - dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base + - init->ring_start, - init->ring_size, dev); + dev_priv->ring.map.offset = dev->agp->base + init->ring_start; + dev_priv->ring.map.size = init->ring_size; + dev_priv->ring.map.type = _DRM_AGP; + dev_priv->ring.map.flags = 0; + dev_priv->ring.map.mtrr = 0; - if (dev_priv->ring.virtual_start == NULL) { + drm_core_ioremap(&dev_priv->ring.map, dev); + + if (dev_priv->ring.map.handle == NULL) { dev->dev_private = (void *)dev_priv; i810_dma_cleanup(dev); DRM_ERROR("can not ioremap virtual address for" " ring buffer\n"); - return -ENOMEM; + return DRM_ERR(ENOMEM); } + dev_priv->ring.virtual_start = dev_priv->ring.map.handle; + dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; dev_priv->w = init->w; diff --git a/linux-core/i810_drv.h b/linux-core/i810_drv.h index bb7358d..69d7949 100644 --- a/linux-core/i810_drv.h +++ b/linux-core/i810_drv.h @@ -61,6 +61,7 @@ typedef struct drm_i810_buf_priv { int currently_mapped; void *virtual; void *kernel_virtual; + drm_local_map_t map; } drm_i810_buf_priv_t; typedef struct _drm_i810_ring_buffer { @@ -72,6 +73,7 @@ typedef struct _drm_i810_ring_buffer { int head; int tail; int space; + drm_local_map_t map; } drm_i810_ring_buffer_t; typedef struct drm_i810_private { diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c index a1b7079..e35551b 100644 --- a/linux-core/i830_dma.c +++ b/linux-core/i830_dma.c @@ -226,8 +226,7 @@ static int i830_dma_cleanup(drm_device_t (drm_i830_private_t *) dev->dev_private; if (dev_priv->ring.virtual_start) { - drm_ioremapfree((void *)dev_priv->ring.virtual_start, - dev_priv->ring.Size, dev); + drm_core_ioremapfree(&dev_priv->ring.map, dev); } if (dev_priv->hw_status_page) { pci_free_consistent(dev->pdev, PAGE_SIZE, @@ -245,8 +244,7 @@ static int i830_dma_cleanup(drm_device_t drm_buf_t *buf = dma->buflist[i]; drm_i830_buf_priv_t *buf_priv = buf->dev_private; if (buf_priv->kernel_virtual && buf->total) - drm_ioremapfree(buf_priv->kernel_virtual, - buf->total, dev); + drm_core_ioremapfree(&buf_priv->map, dev); } } return 0; @@ -323,8 +321,14 @@ static int i830_freelist_init(drm_device *buf_priv->in_use = I830_BUF_FREE; - buf_priv->kernel_virtual = drm_ioremap(buf->bus_address, - buf->total, dev); + buf_priv->map.offset = buf->bus_address; + buf_priv->map.size = buf->total; + buf_priv->map.type = 0; + buf_priv->map.flags = 0; + buf_priv->map.mtrr = 0; + + drm_core_ioremap(&buf_priv->map, dev); + buf_priv->kernel_virtual = buf_priv->map.handle; } return 0; } @@ -376,18 +380,24 @@ static int i830_dma_initialize(drm_devic dev_priv->ring.End = init->ring_end; dev_priv->ring.Size = init->ring_size; - dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base + - init->ring_start, - init->ring_size, dev); + dev_priv->ring.map.offset = init->ring_start; + dev_priv->ring.map.size = init->ring_size; + dev_priv->ring.map.type = 0; + dev_priv->ring.map.flags = 0; + dev_priv->ring.map.mtrr = 0; + + drm_core_ioremap(&dev_priv->ring.map, dev); - if (dev_priv->ring.virtual_start == NULL) { + if (dev_priv->ring.map.handle == NULL) { dev->dev_private = (void *)dev_priv; i830_dma_cleanup(dev); DRM_ERROR("can not ioremap virtual address for" " ring buffer\n"); - return -ENOMEM; + return DRM_ERR(ENOMEM); } + dev_priv->ring.virtual_start = dev_priv->ring.map.handle; + dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; dev_priv->w = init->w; diff --git a/linux-core/i830_drv.h b/linux-core/i830_drv.h index 85bc5be..e91f94a 100644 --- a/linux-core/i830_drv.h +++ b/linux-core/i830_drv.h @@ -68,6 +68,7 @@ typedef struct drm_i830_buf_priv { int currently_mapped; void __user *virtual; void *kernel_virtual; + drm_local_map_t map; } drm_i830_buf_priv_t; typedef struct _drm_i830_ring_buffer { @@ -79,6 +80,7 @@ typedef struct _drm_i830_ring_buffer { int head; int tail; int space; + drm_local_map_t map; } drm_i830_ring_buffer_t; typedef struct drm_i830_private { |
From: <ma...@ke...> - 2007-01-08 02:48:47
|
shared-core/nouveau_state.c | 3 +++ 1 files changed, 3 insertions(+) New commits: diff-tree 6eaa1272b4159a547d6da21f14cbcc5b5d0f600c (from parents) Merge: 1f0f7d7a180af088d6c79d55da04402f0eff0416 5bf60c9d6c2e04a65085a0a332de24b06043fcb8 Author: Stephane Marchesin <mar...@ic...> Date: Mon Jan 8 03:50:34 2007 +0100 Merge branch 'master' of git+ssh://ma...@gi.../git/mesa/drm diff-tree 1f0f7d7a180af088d6c79d55da04402f0eff0416 (from faa46122993bc5970b3d67933bd81d863a3c4762) Author: Stephane Marchesin <mar...@ic...> Date: Mon Jan 8 00:11:39 2007 +0100 nouveau: fix a stupid bug from me. diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c index 951e21f..44f8c1a 100644 --- a/shared-core/nouveau_state.c +++ b/shared-core/nouveau_state.c @@ -120,7 +120,10 @@ void nouveau_lastclose(struct drm_device { drm_nouveau_private_t *dev_priv = dev->dev_private; if(dev_priv->fb_mtrr>0) + { drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC); + dev_priv->fb_mtrr=0; + } } int nouveau_unload(struct drm_device *dev) |
From: <jk...@ke...> - 2007-01-19 02:40:35
|
shared-core/nouveau_fifo.c | 5 ----- shared-core/nv30_graph.c | 1 - 2 files changed, 6 deletions(-) New commits: diff-tree a40de938fa5cf98f01d569e39fe3931d545c357a (from ab72a7714e4e9b87cc93887d1978f1c533255566) Author: Jeremy Kolb <jk...@br...> Date: Thu Jan 18 21:39:36 2007 -0500 nouveau: cleanup nv30_graph.c diff --git a/shared-core/nv30_graph.c b/shared-core/nv30_graph.c index 94f6b3e..a5f01ea 100644 --- a/shared-core/nv30_graph.c +++ b/shared-core/nv30_graph.c @@ -8,7 +8,6 @@ #include "nouveau_drm.h" /* - * TODO: In the dump start seems to be 7654b0 while end is 76ac28. * This is obviously not the correct size. */ #define NV30_GRCTX_SIZE (23840) diff-tree ab72a7714e4e9b87cc93887d1978f1c533255566 (from bd0418cb01232d7529ecb0f515aa9b6d6804a3ac) Author: Jeremy Kolb <jk...@br...> Date: Thu Jan 18 21:39:09 2007 -0500 nouveau: Remove write to CTX_SIZE. This gives us proper nv3x PGRAPH switching. diff --git a/shared-core/nouveau_fifo.c b/shared-core/nouveau_fifo.c index 8ea0564..e80ba76 100644 --- a/shared-core/nouveau_fifo.c +++ b/shared-core/nouveau_fifo.c @@ -368,12 +368,7 @@ static void nouveau_nv30_context_init(dr RAMFC_WR(ACQUIRE_TIMESTAMP, NV_READ(NV_PFIFO_CACH1_ACQUIRE_TIMESTAMP)); RAMFC_WR(ACQUIRE_TIMEOUT, NV_READ(NV_PFIFO_CACH1_ACQUIRE_TIMEOUT)); RAMFC_WR(SEMAPHORE, NV_READ(NV_PFIFO_CACH1_SEMAPHORE)); - NV_WRITE(NV_PGRAPH_CHANNEL_CTX_SIZE, grctx_inst); /* Misnomer. Really a ptr to the grctx */ - /* - * TODO: We need to put this somewhere... - */ - /*INSTANCE_WR(dev_priv->ctx_table, init->channel, grctx_inst);*/ RAMFC_WR(DMA_SUBROUTINE, init->put_base); } |
From: <dar...@ke...> - 2007-01-19 04:41:36
|
shared-core/drm_pciids.txt | 1 + shared-core/nouveau_drm.h | 1 + shared-core/nouveau_drv.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) New commits: diff-tree 19ba0749384994662e0d6167c70cc6fbd78eb0ff (from 4291df69bd03f71cbbe91b7b1ad82b580e1d362a) Author: Ben Skeggs <dar...@ii...> Date: Fri Jan 19 15:41:51 2007 +1100 nouveau: fix getparam from 32-bit client on 64-bit kernel diff --git a/shared-core/nouveau_drm.h b/shared-core/nouveau_drm.h index 3f36319..0f11c43 100644 --- a/shared-core/nouveau_drm.h +++ b/shared-core/nouveau_drm.h @@ -93,6 +93,7 @@ drm_nouveau_mem_free_t; #define NOUVEAU_GETPARAM_AGP_PHYSICAL 7 typedef struct drm_nouveau_getparam { unsigned int param; + unsigned int dummy; uint64_t value; } drm_nouveau_getparam_t; diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h index 4978c47..522a8cf 100644 --- a/shared-core/nouveau_drv.h +++ b/shared-core/nouveau_drv.h @@ -34,7 +34,7 @@ #define DRIVER_MAJOR 0 #define DRIVER_MINOR 0 -#define DRIVER_PATCHLEVEL 2 +#define DRIVER_PATCHLEVEL 3 #define NOUVEAU_FAMILY 0x0000FFFF #define NOUVEAU_FLAGS 0xFFFF0000 diff-tree 4291df69bd03f71cbbe91b7b1ad82b580e1d362a (from a40de938fa5cf98f01d569e39fe3931d545c357a) Author: Ben Skeggs <dar...@ii...> Date: Sun Jan 14 10:42:58 2007 +1100 nouveau: re-add 6150 Go pciid (0x0244) diff --git a/shared-core/drm_pciids.txt b/shared-core/drm_pciids.txt index 5483157..0d2639e 100644 --- a/shared-core/drm_pciids.txt +++ b/shared-core/drm_pciids.txt @@ -600,6 +600,7 @@ 0x10de 0x0221 NV_44 "GeForce 6200" 0x10de 0x0240 NV_44 "GeForce 6150" 0x10de 0x0242 NV_44 "GeForce 6100" +0x10de 0x0244 NV_44 "GeForce 6150 Go" 0x10de 0x0250 NV_25 "GeForce4 Ti 4600" 0x10de 0x0251 NV_25 "GeForce4 Ti 4400" 0x10de 0x0252 NV_25 "GeForce4 Ti" |
From: <pm...@ke...> - 2007-01-26 18:26:06
|
shared-core/nouveau_reg.h | 11 +++++++++++ shared-core/nv10_graph.c | 46 +++++++++++++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 15 deletions(-) New commits: diff-tree 05d3ed472e6ab5cfa7741e523bdb3992591ecc7e (from e7ba15a00369d85d3abeb42d95fe76dc40a544a8) Author: Patrice Mandin <pm...@ca...> Date: Fri Jan 26 19:25:49 2007 +0100 nouveau: only save/restore nv17 regs on nv17,18 hw diff --git a/shared-core/nv10_graph.c b/shared-core/nv10_graph.c index 038e09c..9a04bd8 100644 --- a/shared-core/nv10_graph.c +++ b/shared-core/nv10_graph.c @@ -354,21 +354,6 @@ NV_PGRAPH_BETA_PREMULT, 0x00400ea4, 0x00400ea8, 0x00400eac, -0x00400eb0, -0x00400eb4, -0x00400eb8, -0x00400ebc, -0x00400ec0, -0x00400ec4, -0x00400ec8, -0x00400ecc, -0x00400ed0, -0x00400ed4, -0x00400ed8, -0x00400edc, -0x00400ee0, -0x00400a00, -0x00400a04, 0x00400e90, 0x00400e94, 0x00400e98, @@ -525,6 +510,25 @@ NV_PGRAPH_VALID2, 0 }; +static int nv17_graph_ctx_regs [] = { +0x00400eb0, +0x00400eb4, +0x00400eb8, +0x00400ebc, +0x00400ec0, +0x00400ec4, +0x00400ec8, +0x00400ecc, +0x00400ed0, +0x00400ed4, +0x00400ed8, +0x00400edc, +0x00400ee0, +0x00400a00, +0x00400a04, +0 +}; + void nouveau_nv10_context_switch(drm_device_t *dev) { drm_nouveau_private_t *dev_priv = dev->dev_private; @@ -545,6 +549,12 @@ void nouveau_nv10_context_switch(drm_dev // save PGRAPH context for (i = 0; nv10_graph_ctx_regs[i]; i++) dev_priv->fifos[channel_old].nv10_pgraph_ctx[i] = NV_READ(nv10_graph_ctx_regs[i]); + if ((NV_READ(NV_PMC_BOOT_0) & 0x0ff00000)==0x01700000) + || (NV_READ(NV_PMC_BOOT_0) & 0x0ff00000)==0x01800000)) + { + for (; nv17_graph_ctx_regs[i]; i++) + dev_priv->fifos[channel_old].nv10_pgraph_ctx[i] = NV_READ(nv17_graph_ctx_regs[i]); + } nouveau_wait_for_idle(dev); @@ -557,6 +567,12 @@ void nouveau_nv10_context_switch(drm_dev #if 0 for (i = 0; nv10_graph_ctx_regs[i]; i++) NV_WRITE(nv10_graph_ctx_regs[i], dev_priv->fifos[channel].nv10_pgraph_ctx[i]); + if ((NV_READ(NV_PMC_BOOT_0) & 0x0ff00000)==0x01700000) + || (NV_READ(NV_PMC_BOOT_0) & 0x0ff00000)==0x01800000)) + { + for (; nv17_graph_ctx_regs[i]; i++) + NV_WRITE(nv17_graph_ctx_regs[i], dev_priv->fifos[channel].nv10_pgraph_ctx[i]); + } nouveau_wait_for_idle(dev); #endif diff-tree e7ba15a00369d85d3abeb42d95fe76dc40a544a8 (from d4c9f135b56eee826f0d5eaf41f2088a861da590) Author: Patrice Mandin <pm...@ca...> Date: Fri Jan 26 19:24:34 2007 +0100 nouveau: add extra pgraph registers diff --git a/shared-core/nouveau_reg.h b/shared-core/nouveau_reg.h index 543be69..f0345d1 100644 --- a/shared-core/nouveau_reg.h +++ b/shared-core/nouveau_reg.h @@ -73,6 +73,13 @@ #define NV_PGRAPH_CTX_SWITCH3 0x00400154 #define NV_PGRAPH_CTX_SWITCH4 0x00400158 #define NV_PGRAPH_CTX_SWITCH5 0x0040015C +#define NV_PGRAPH_CTX_CACHE1 0x00400160 +#define NV_PGRAPH_CTX_CACHE2 0x00400180 +#define NV_PGRAPH_CTX_CACHE3 0x004001A0 +#define NV_PGRAPH_CTX_CACHE4 0x004001C0 +#define NV_PGRAPH_CTX_CACHE5 0x004001E0 +#define NV_PGRAPH_ABS_X_RAM 0x00400400 +#define NV_PGRAPH_ABS_Y_RAM 0x00400480 #define NV_PGRAPH_X_MISC 0x00400500 #define NV_PGRAPH_Y_MISC 0x00400504 #define NV_PGRAPH_VALID1 0x00400508 @@ -151,9 +158,13 @@ #define NV_PGRAPH_CHANNEL_CTX_POINTER 0x00400788 #define NV_PGRAPH_PATT_COLOR0 0x00400800 #define NV_PGRAPH_PATT_COLOR1 0x00400804 +#define NV_PGRAPH_PATTERN 0x00400808 #define NV_PGRAPH_PATTERN_SHAPE 0x00400810 #define NV_PGRAPH_CHROMA 0x00400814 #define NV_PGRAPH_STORED_FMT 0x00400830 +#define NV_PGRAPH_PATT_COLORRAM 0x00400900 +#define NV_PGRAPH_WINDOWCLIP_HORIZONTAL 0x00400F00 +#define NV_PGRAPH_WINDOWCLIP_VERTICAL 0x00400F20 #define NV_PGRAPH_XFMODE0 0x00400F40 #define NV_PGRAPH_XFMODE1 0x00400F44 #define NV_PGRAPH_GLOBALSTATE0 0x00400F48 |
From: <th...@ke...> - 2007-01-31 10:06:44
|
linux-core/drm_bo.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 2 deletions(-) New commits: diff-tree 36d50687dd88e0e42cf2adfd8ff81a160765e12a (from d399fcf46f3b9eab0eb37aefc8e593f8a711d1ef) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Wed Jan 31 11:03:53 2007 +0100 Fix an error-path oops. diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 7439e27..2b960c7 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -373,11 +373,13 @@ static void drm_bo_base_deref_locked(drm static void drm_bo_usage_deref_unlocked(drm_buffer_object_t * bo) { + drm_device_t *dev = bo->dev; + if (atomic_dec_and_test(&bo->usage)) { - mutex_lock(&bo->dev->struct_mutex); + mutex_lock(&dev->struct_mutex); if (atomic_read(&bo->usage) == 0) drm_bo_destroy_locked(bo); - mutex_unlock(&bo->dev->struct_mutex); + mutex_unlock(&dev->struct_mutex); } } diff-tree d399fcf46f3b9eab0eb37aefc8e593f8a711d1ef (from 0932269656825397b4b9e1bfdfc75254f544c96f) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Tue Jan 30 16:20:23 2007 +0100 Add a buffer object transfer function. Creates a placeholder for the old buffer contents when it is transfered to / from static memory like VRAM. diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 74476d3..7439e27 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1346,6 +1346,49 @@ static int drm_bo_add_ttm(drm_file_t * p return ret; } +/* + * Transfer a buffer object's memory and LRU status to a newly + * created object. User-space references remains with the old + * object. Call bo->mutex locked. + */ + +int drm_buffer_object_transfer(drm_buffer_object_t *bo, + drm_buffer_object_t **new_obj) +{ + drm_buffer_object_t *fbo; + drm_device_t *dev = bo->dev; + drm_buffer_manager_t *bm = &dev->bm; + + fbo = drm_ctl_calloc(1, sizeof(*bo), DRM_MEM_BUFOBJ); + if (!fbo) + return -ENOMEM; + + *fbo = *bo; + mutex_init(&fbo->mutex); + mutex_lock(&fbo->mutex); + mutex_lock(&dev->struct_mutex); + + INIT_LIST_HEAD(&fbo->ddestroy); + INIT_LIST_HEAD(&fbo->lru); + list_splice_init(&bo->lru, &fbo->lru); + + bo->mm_node = NULL; + bo->ttm = NULL; + bo->ttm_object = NULL; + bo->fence = NULL; + bo->flags = 0; + + fbo->mm_node->private = (void *)fbo; + atomic_set(&fbo->usage, 1); + atomic_inc(&bm->count); + mutex_unlock(&dev->struct_mutex); + mutex_unlock(&fbo->mutex); + + *new_obj = fbo; + return 0; +} + + int drm_buffer_object_create(drm_file_t * priv, unsigned long size, drm_bo_type_t type, |
From: <th...@ke...> - 2007-02-02 08:24:13
|
shared-core/via_dma.c | 132 ++++++++++++++++++++------------------------------ shared-core/via_drm.h | 4 - shared-core/via_drv.h | 1 3 files changed, 58 insertions(+), 79 deletions(-) New commits: diff-tree 6c04185857694b2293046b7ea1d4515404a740c3 (from 70bba11bc7bbf0cfb028521c1b6676ed0962c317) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Fri Feb 2 09:15:44 2007 +0100 via: Try to improve command-buffer chaining. Bump driver date and patchlevel. diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c index a08d7d5..0915963 100644 --- a/shared-core/via_dma.c +++ b/shared-core/via_dma.c @@ -299,7 +299,7 @@ static int via_dispatch_cmdbuffer(drm_de cmd->size, dev, 1))) { return ret; } - + vb = via_check_dma(dev_priv, (cmd->size < 0x100) ? 0x102 : cmd->size); if (vb == NULL) { return DRM_ERR(EAGAIN); @@ -433,70 +433,46 @@ static inline uint32_t *via_get_dma(drm_ * modifying the pause address stored in the buffer itself. If * the regulator has already paused, restart it. */ + static int via_hook_segment(drm_via_private_t *dev_priv, uint32_t pause_addr_hi, uint32_t pause_addr_lo, int no_pci_fire) { int paused, count; volatile uint32_t *paused_at = dev_priv->last_pause_ptr; + uint32_t reader,ptr; + paused = 0; via_flush_write_combine(); - while(! *(via_get_dma(dev_priv)-1)); *dev_priv->last_pause_ptr = pause_addr_lo; via_flush_write_combine(); - - /* - * The below statement is inserted to really force the flush. - * Not sure it is needed. - */ - - while(! *dev_priv->last_pause_ptr); + reader = *(dev_priv->hw_addr_ptr); + ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + + dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1; - while(! *dev_priv->last_pause_ptr); - - paused = 0; - count = 20; - - while (!(paused = (VIA_READ(0x41c) & 0x80000000)) && count--); - if ((count <= 8) && (count >= 0)) { - uint32_t rgtr, ptr; - rgtr = *(dev_priv->hw_addr_ptr); - ptr = ((volatile char *)dev_priv->last_pause_ptr - - dev_priv->dma_ptr) + dev_priv->dma_offset + - (uint32_t) dev_priv->agpAddr + 4 - CMDBUF_ALIGNMENT_SIZE; - if (rgtr <= ptr) { - DRM_ERROR - ("Command regulator\npaused at count %d, address %x, " - "while current pause address is %x.\n" - "Please mail this message to " - "<uni...@li...>\n", count, - rgtr, ptr); - } + if ((ptr - reader) <= dev_priv->dma_diff ) { + count = 10000000; + while (!(paused = (VIA_READ(0x41c) & 0x80000000)) && count--); } - + if (paused && !no_pci_fire) { - uint32_t rgtr,ptr; - uint32_t ptr_low; + reader = *(dev_priv->hw_addr_ptr); + if ((ptr - reader) == dev_priv->dma_diff) { + + /* + * There is a concern that these writes may stall the PCI bus + * if the GPU is not idle. However, idling the GPU first + * doesn't make a difference. + */ - count = 1000000; - while ((VIA_READ(VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY) - && count--); - - rgtr = *(dev_priv->hw_addr_ptr); - ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + - dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; - - - ptr_low = (ptr > 3*CMDBUF_ALIGNMENT_SIZE) ? - ptr - 3*CMDBUF_ALIGNMENT_SIZE : 0; - if (rgtr <= ptr && rgtr >= ptr_low) { VIA_WRITE(VIA_REG_TRANSET, (HC_ParaType_PreCR << 16)); VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_hi); VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_lo); VIA_READ(VIA_REG_TRANSPACE); - } + } } + return paused; } @@ -505,6 +481,9 @@ static int via_hook_segment(drm_via_priv static int via_wait_idle(drm_via_private_t * dev_priv) { int count = 10000000; + + while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && count--); + while (count-- && (VIA_READ(VIA_REG_STATUS) & (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY))) ; @@ -551,7 +530,9 @@ static void via_cmdbuf_start(drm_via_pri uint32_t end_addr, end_addr_lo; uint32_t command; uint32_t agp_base; - + uint32_t ptr; + uint32_t reader; + int count; dev_priv->dma_low = 0; @@ -581,6 +562,24 @@ static void via_cmdbuf_start(drm_via_pri DRM_WRITEMEMORYBARRIER(); VIA_WRITE(VIA_REG_TRANSPACE, command | HC_HAGPCMNT_MASK); VIA_READ(VIA_REG_TRANSPACE); + + dev_priv->dma_diff = 0; + + count = 10000000; + while (!(VIA_READ(0x41c) & 0x80000000) && count--); + + reader = *(dev_priv->hw_addr_ptr); + ptr = ((volatile char *)dev_priv->last_pause_ptr - dev_priv->dma_ptr) + + dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; + + /* + * This is the difference between where we tell the + * command reader to pause and where it actually pauses. + * This differs between hw implementation so we need to + * detect it. + */ + + dev_priv->dma_diff = ptr - reader; } static void via_pad_cache(drm_via_private_t *dev_priv, int qwords) @@ -598,20 +597,18 @@ static inline void via_dummy_bitblt(drm_ uint32_t *vb = via_get_dma(dev_priv); SetReg2DAGP(0x0C, (0 | (0 << 16))); SetReg2DAGP(0x10, 0 | (0 << 16)); - SetReg2DAGP(0x0, 0x1 | 0x2000 | 0xAA000000); + SetReg2DAGP(0x0, 0x1 | 0x2000 | 0xAA000000); } - static void via_cmdbuf_jump(drm_via_private_t * dev_priv) { uint32_t agp_base; uint32_t pause_addr_lo, pause_addr_hi; uint32_t jump_addr_lo, jump_addr_hi; volatile uint32_t *last_pause_ptr; - uint32_t dma_low_save1, dma_low_save2; agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr; - via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi, + via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi, &jump_addr_lo, 0); dev_priv->dma_wrap = dev_priv->dma_low; @@ -627,38 +624,14 @@ static void via_cmdbuf_jump(drm_via_priv } via_dummy_bitblt(dev_priv); - via_dummy_bitblt(dev_priv); - - last_pause_ptr = - via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, - &pause_addr_lo, 0) -1; - via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, - &pause_addr_lo, 0); - - *last_pause_ptr = pause_addr_lo; - dma_low_save1 = dev_priv->dma_low; - - /* - * Now, set a trap that will pause the regulator if it tries to rerun the old - * command buffer. (Which may happen if via_hook_segment detecs a command regulator pause - * and reissues the jump command over PCI, while the regulator has already taken the jump - * and actually paused at the current buffer end). - * There appears to be no other way to detect this condition, since the hw_addr_pointer - * does not seem to get updated immediately when a jump occurs. - */ - - last_pause_ptr = - via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, + via_dummy_bitblt(dev_priv); + last_pause_ptr = via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, &pause_addr_lo, 0) -1; - via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, + via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi, &pause_addr_lo, 0); *last_pause_ptr = pause_addr_lo; - dma_low_save2 = dev_priv->dma_low; - dev_priv->dma_low = dma_low_save1; via_hook_segment( dev_priv, jump_addr_hi, jump_addr_lo, 0); - dev_priv->dma_low = dma_low_save2; - via_hook_segment( dev_priv, pause_addr_hi, pause_addr_lo, 0); } diff --git a/shared-core/via_drm.h b/shared-core/via_drm.h index 16421d7..88345bd 100644 --- a/shared-core/via_drm.h +++ b/shared-core/via_drm.h @@ -42,11 +42,11 @@ * backwards incompatibilities, (which should be avoided whenever possible). */ -#define VIA_DRM_DRIVER_DATE "20061227" +#define VIA_DRM_DRIVER_DATE "20070202" #define VIA_DRM_DRIVER_MAJOR 2 #define VIA_DRM_DRIVER_MINOR 11 -#define VIA_DRM_DRIVER_PATCHLEVEL 0 +#define VIA_DRM_DRIVER_PATCHLEVEL 1 #define VIA_DRM_DRIVER_VERSION (((VIA_DRM_DRIVER_MAJOR) << 16) | (VIA_DRM_DRIVER_MINOR)) #define VIA_NR_SAREA_CLIPRECTS 8 diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h index 7a8f2c3..42d0c74 100644 --- a/shared-core/via_drv.h +++ b/shared-core/via_drv.h @@ -102,6 +102,7 @@ typedef struct drm_via_private { #ifdef VIA_HAVE_DMABLIT drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES]; #endif + uint32_t dma_diff; } drm_via_private_t; enum via_family { diff-tree 70bba11bc7bbf0cfb028521c1b6676ed0962c317 (from 07fabc3fd8f00006e6117081f5183a826a6d2bbb) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Fri Feb 2 09:20:16 2007 +0100 Disable AGP DMA for chips with the new 3D engine. diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c index 90dbb6a..a08d7d5 100644 --- a/shared-core/via_dma.c +++ b/shared-core/via_dma.c @@ -192,6 +192,11 @@ static int via_initialize(drm_device_t * return DRM_ERR(EFAULT); } + if (dev_priv->chipset == VIA_DX9_0) { + DRM_ERROR("AGP DMA is not supported on this chip\n"); + return DRM_ERR(EINVAL); + } + dev_priv->ring.map.offset = dev->agp->base + init->offset; dev_priv->ring.map.size = init->size; dev_priv->ring.map.type = 0; |
From: <th...@ke...> - 2007-02-13 19:48:14
|
linux-core/drmP.h | 16 +++-- linux-core/drm_fops.c | 57 ++++++++++------- linux-core/drm_irq.c | 4 - linux-core/drm_lock.c | 160 ++++++++++++++++++++++++++++---------------------- linux-core/drm_stub.c | 1 linux-core/sis_drv.c | 2 shared-core/via_drv.c | 3 7 files changed, 143 insertions(+), 100 deletions(-) New commits: diff-tree 6b289db05496c5cc89c29817be16cb107a522722 (from e1460426b885ab656e3cda3fd3841d64260434c5) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Tue Feb 13 20:46:56 2007 +0100 Remove debug printout. diff --git a/linux-core/via_mm.c b/linux-core/via_mm.c index 67d212d..d97269f 100644 --- a/linux-core/via_mm.c +++ b/linux-core/via_mm.c @@ -204,7 +204,6 @@ void via_reclaim_buffers_locked(drm_devi if (dev->driver->dma_quiescent) { dev->driver->dma_quiescent(dev); } - DRM_ERROR("Lock status is %d\n", dev->lock.idle_has_lock); drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)priv); mutex_unlock(&dev->struct_mutex); diff-tree e1460426b885ab656e3cda3fd3841d64260434c5 (from 5bd13c5e15a14d34356f2363c55b1d4c7ca3269a) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Sun Feb 11 20:33:57 2007 +0100 Bugzilla Bug #9457 Add refcounting of user waiters to the DRM hardware lock, so that we can use the DRM_LOCK_CONT flag more conservatively. Also add a kernel waiter refcount that if nonzero transfers the lock for the kernel context, when it is released. This is useful when waiting for idle and can be used for very simple fence object driver implementations for the new memory manager. It also resolves the AIGLX startup deadlock for the sis and the via drivers. i810, i830 still require that the hardware lock is really taken so the deadlock remains for those two. I'm not sure about ffb. Anyone familiar with that code? diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 9c748e6..edc1557 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -458,6 +458,10 @@ typedef struct drm_lock_data { struct file *filp; /**< File descr of lock holder (0=kernel) */ wait_queue_head_t lock_queue; /**< Queue of blocked processes */ unsigned long lock_time; /**< Time of last lock in jiffies */ + spinlock_t spinlock; + uint32_t kernel_waiters; + uint32_t user_waiters; + int idle_has_lock; } drm_lock_data_t; /** @@ -712,6 +716,8 @@ struct drm_driver { void (*reclaim_buffers) (struct drm_device *dev, struct file * filp); void (*reclaim_buffers_locked) (struct drm_device *dev, struct file * filp); + void (*reclaim_buffers_idlelocked) (struct drm_device *dev, + struct file * filp); unsigned long (*get_map_ofs) (drm_map_t * map); unsigned long (*get_reg_ofs) (struct drm_device * dev); void (*set_version) (struct drm_device * dev, drm_set_version_t * sv); @@ -1193,12 +1199,14 @@ extern int drm_lock(struct inode *inode, unsigned int cmd, unsigned long arg); extern int drm_unlock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context); -extern int drm_lock_free(drm_device_t * dev, - __volatile__ unsigned int *lock, unsigned int context); +extern int drm_lock_take(drm_lock_data_t *lock_data, unsigned int context); +extern int drm_lock_free(drm_lock_data_t *lock_data, unsigned int context); +extern void drm_idlelock_take(drm_lock_data_t *lock_data); +extern void drm_idlelock_release(drm_lock_data_t *lock_data); + /* * These are exported to drivers so that they can implement fencing using - * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. + * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. */ extern int drm_i_have_hw_lock(struct file *filp); diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index 84e06c8..faf7672 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -427,38 +427,51 @@ int drm_release(struct inode *inode, str dev->open_count); if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { - unsigned long _end = jiffies + DRM_HZ*3; - - do { - retcode = drm_kernel_take_hw_lock(filp); - } while(retcode && !time_after_eq(jiffies,_end)); - - if (!retcode) { + if (drm_i_have_hw_lock(filp)) { dev->driver->reclaim_buffers_locked(dev, filp); - - drm_lock_free(dev, &dev->lock.hw_lock->lock, - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); } else { + unsigned long _end=jiffies + 3*DRM_HZ; + int locked = 0; + + drm_idlelock_take(&dev->lock); /* - * FIXME: This is not a good solution. We should perhaps associate the - * DRM lock with a process context, and check whether the current process - * holds the lock. Then we can run reclaim buffers locked anyway. + * Wait for a while. */ - DRM_ERROR("Reclaim buffers locked deadlock.\n" - "\tThis is probably a single thread having multiple\n" - "\tDRM file descriptors open either dying or" - " closing file descriptors\n" - "\twhile having the lock. I will not reclaim buffers.\n" - "\tLocking context is 0x%08x\n", - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + do{ + spin_lock(&dev->lock.spinlock); + locked = dev->lock.idle_has_lock; + spin_unlock(&dev->lock.spinlock); + if (locked) + break; + schedule(); + } while (!time_after_eq(jiffies, _end)); + + if (!locked) { + DRM_ERROR("reclaim_buffers_locked() deadlock. Please rework this\n" + "\tdriver to use reclaim_buffers_idlelocked() instead.\n" + "\tI will go on reclaiming the buffers anyway.\n"); + } + + dev->driver->reclaim_buffers_locked(dev, filp); + drm_idlelock_release(&dev->lock); } - } else if (drm_i_have_hw_lock(filp)) { + } + + if (dev->driver->reclaim_buffers_idlelocked && dev->lock.hw_lock) { + + drm_idlelock_take(&dev->lock); + dev->driver->reclaim_buffers_idlelocked(dev, filp); + drm_idlelock_release(&dev->lock); + + } + + if (drm_i_have_hw_lock(filp)) { DRM_DEBUG("File %p released, freeing lock for context %d\n", filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - drm_lock_free(dev, &dev->lock.hw_lock->lock, + drm_lock_free(&dev->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); } diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c index c365c08..92cf7f5 100644 --- a/linux-core/drm_irq.c +++ b/linux-core/drm_irq.c @@ -422,7 +422,7 @@ static void drm_locked_tasklet_func(unsi spin_lock_irqsave(&dev->tasklet_lock, irqflags); if (!dev->locked_tasklet_func || - !drm_lock_take(&dev->lock.hw_lock->lock, + !drm_lock_take(&dev->lock, DRM_KERNEL_CONTEXT)) { spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); return; @@ -433,7 +433,7 @@ static void drm_locked_tasklet_func(unsi dev->locked_tasklet_func(dev); - drm_lock_free(dev, &dev->lock.hw_lock->lock, + drm_lock_free(&dev->lock, DRM_KERNEL_CONTEXT); dev->locked_tasklet_func = NULL; diff --git a/linux-core/drm_lock.c b/linux-core/drm_lock.c index d11c570..a4b1a63 100644 --- a/linux-core/drm_lock.c +++ b/linux-core/drm_lock.c @@ -35,12 +35,6 @@ #include "drmP.h" -#if 0 -static int drm_lock_transfer(drm_device_t * dev, - __volatile__ unsigned int *lock, - unsigned int context); -#endif - static int drm_notifier(void *priv); /** @@ -83,6 +77,9 @@ int drm_lock(struct inode *inode, struct return -EINVAL; add_wait_queue(&dev->lock.lock_queue, &entry); + spin_lock(&dev->lock.spinlock); + dev->lock.user_waiters++; + spin_unlock(&dev->lock.spinlock); for (;;) { __set_current_state(TASK_INTERRUPTIBLE); if (!dev->lock.hw_lock) { @@ -90,7 +87,7 @@ int drm_lock(struct inode *inode, struct ret = -EINTR; break; } - if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) { + if (drm_lock_take(&dev->lock, lock.context)) { dev->lock.filp = filp; dev->lock.lock_time = jiffies; atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); @@ -104,6 +101,9 @@ int drm_lock(struct inode *inode, struct break; } } + spin_lock(&dev->lock.spinlock); + dev->lock.user_waiters--; + spin_unlock(&dev->lock.spinlock); __set_current_state(TASK_RUNNING); remove_wait_queue(&dev->lock.lock_queue, &entry); @@ -184,8 +184,7 @@ int drm_unlock(struct inode *inode, stru if (dev->driver->kernel_context_switch_unlock) dev->driver->kernel_context_switch_unlock(dev); else { - if (drm_lock_free(dev, &dev->lock.hw_lock->lock, - lock.context)) { + if (drm_lock_free(&dev->lock,lock.context)) { /* FIXME: Should really bail out here. */ } } @@ -203,20 +202,29 @@ int drm_unlock(struct inode *inode, stru * * Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction. */ -int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) +int drm_lock_take(drm_lock_data_t *lock_data, + unsigned int context) { unsigned int old, new, prev; + volatile unsigned int *lock = &lock_data->hw_lock->lock; + spin_lock(&lock_data->spinlock); do { old = *lock; if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT; - else - new = context | _DRM_LOCK_HELD | _DRM_LOCK_CONT; + else { + new = context | _DRM_LOCK_HELD | + ((lock_data->user_waiters + lock_data->kernel_waiters > 1) ? + _DRM_LOCK_CONT : 0); + } prev = cmpxchg(lock, old, new); } while (prev != old); + spin_unlock(&lock_data->spinlock); + if (_DRM_LOCKING_CONTEXT(old) == context) { if (old & _DRM_LOCK_HELD) { + spin_unlock(&lock_data->spinlock); if (context != DRM_KERNEL_CONTEXT) { DRM_ERROR("%d holds heavyweight lock\n", context); @@ -224,14 +232,17 @@ int drm_lock_take(__volatile__ unsigned return 0; } } - if (new == (context | _DRM_LOCK_HELD | _DRM_LOCK_CONT)) { + + if ((_DRM_LOCKING_CONTEXT(new)) == context && (new & _DRM_LOCK_HELD)) { /* Have lock */ + + spin_unlock(&lock_data->spinlock); return 1; } + spin_unlock(&lock_data->spinlock); return 0; } -#if 0 /** * This takes a lock forcibly and hands it to context. Should ONLY be used * inside *_unlock to give lock to kernel before calling *_dma_schedule. @@ -244,13 +255,13 @@ int drm_lock_take(__volatile__ unsigned * Resets the lock file pointer. * Marks the lock as held by the given context, via the \p cmpxchg instruction. */ -static int drm_lock_transfer(drm_device_t * dev, - __volatile__ unsigned int *lock, +static int drm_lock_transfer(drm_lock_data_t *lock_data, unsigned int context) { unsigned int old, new, prev; + volatile unsigned int *lock = &lock_data->hw_lock->lock; - dev->lock.filp = NULL; + lock_data->filp = NULL; do { old = *lock; new = context | _DRM_LOCK_HELD; @@ -258,7 +269,6 @@ static int drm_lock_transfer(drm_device_ } while (prev != old); return 1; } -#endif /** * Free lock. @@ -271,10 +281,19 @@ static int drm_lock_transfer(drm_device_ * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task * waiting on the lock queue. */ -int drm_lock_free(drm_device_t * dev, - __volatile__ unsigned int *lock, unsigned int context) +int drm_lock_free(drm_lock_data_t *lock_data, unsigned int context) { unsigned int old, new, prev; + volatile unsigned int *lock = &lock_data->hw_lock->lock; + + spin_lock(&lock_data->spinlock); + if (lock_data->kernel_waiters != 0) { + drm_lock_transfer(lock_data, 0); + lock_data->idle_has_lock = 1; + spin_unlock(&lock_data->spinlock); + return 1; + } + spin_unlock(&lock_data->spinlock); do { old = *lock; @@ -287,7 +306,7 @@ int drm_lock_free(drm_device_t * dev, context, _DRM_LOCKING_CONTEXT(old)); return 1; } - wake_up_interruptible(&dev->lock.lock_queue); + wake_up_interruptible(&lock_data->lock_queue); return 0; } @@ -322,65 +341,66 @@ static int drm_notifier(void *priv) return 0; } -/* - * Can be used by drivers to take the hardware lock if necessary. - * (Waiting for idle before reclaiming buffers etc.) +/** + * This function returns immediately and takes the hw lock + * with the kernel context if it is free, otherwise it gets the highest priority when and if + * it is eventually released. + * + * This guarantees that the kernel will _eventually_ have the lock _unless_ it is held + * by a blocked process. (In the latter case an explicit wait for the hardware lock would cause + * a deadlock, which is why the "idlelock" was invented). + * + * This should be sufficient to wait for GPU idle without + * having to worry about starvation. */ -int drm_i_have_hw_lock(struct file *filp) +void drm_idlelock_take(drm_lock_data_t *lock_data) { - DRM_DEVICE; + int ret = 0; - return (priv->lock_count && dev->lock.hw_lock && - _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && - dev->lock.filp == filp); -} + spin_lock(&lock_data->spinlock); + lock_data->kernel_waiters++; + if (!lock_data->idle_has_lock) { + + spin_unlock(&lock_data->spinlock); + ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT); + spin_lock(&lock_data->spinlock); -EXPORT_SYMBOL(drm_i_have_hw_lock); + if (ret == 1) + lock_data->idle_has_lock = 1; + } + spin_unlock(&lock_data->spinlock); +} +EXPORT_SYMBOL(drm_idlelock_take); -int drm_kernel_take_hw_lock(struct file *filp) +void drm_idlelock_release(drm_lock_data_t *lock_data) { - DRM_DEVICE; + unsigned int old, prev; + volatile unsigned int *lock = &lock_data->hw_lock->lock; - int ret = 0; - unsigned long _end = jiffies + 3*DRM_HZ; - - if (!drm_i_have_hw_lock(filp)) { - - DECLARE_WAITQUEUE(entry, current); - - add_wait_queue(&dev->lock.lock_queue, &entry); - for (;;) { - __set_current_state(TASK_INTERRUPTIBLE); - if (!dev->lock.hw_lock) { - /* Device has been unregistered */ - ret = -EINTR; - break; - } - if (drm_lock_take(&dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - dev->lock.filp = filp; - dev->lock.lock_time = jiffies; - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); - break; /* Got lock */ - } - /* Contention */ - if (time_after_eq(jiffies,_end)) { - ret = -EBUSY; - break; - } - - schedule_timeout(1); - if (signal_pending(current)) { - ret = -ERESTARTSYS; - break; - } + spin_lock(&lock_data->spinlock); + if (--lock_data->kernel_waiters == 0) { + if (lock_data->idle_has_lock) { + do { + old = *lock; + prev = cmpxchg(lock, old, DRM_KERNEL_CONTEXT); + } while (prev != old); + wake_up_interruptible(&lock_data->lock_queue); + lock_data->idle_has_lock = 0; } - __set_current_state(TASK_RUNNING); - remove_wait_queue(&dev->lock.lock_queue, &entry); } - return ret; + spin_unlock(&lock_data->spinlock); } +EXPORT_SYMBOL(drm_idlelock_release); + -EXPORT_SYMBOL(drm_kernel_take_hw_lock); +int drm_i_have_hw_lock(struct file *filp) +{ + DRM_DEVICE; + return (priv->lock_count && dev->lock.hw_lock && + _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && + dev->lock.filp == filp); +} + +EXPORT_SYMBOL(drm_i_have_hw_lock); diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index 60123cd..2dc95aa 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -63,6 +63,7 @@ static int drm_fill_in_dev(drm_device_t spin_lock_init(&dev->count_lock); spin_lock_init(&dev->drw_lock); spin_lock_init(&dev->tasklet_lock); + spin_lock_init(&dev->lock.spinlock); init_timer(&dev->timer); mutex_init(&dev->struct_mutex); mutex_init(&dev->ctxlist_mutex); diff --git a/linux-core/sis_drv.c b/linux-core/sis_drv.c index 9b0b983..114ec8f 100644 --- a/linux-core/sis_drv.c +++ b/linux-core/sis_drv.c @@ -74,7 +74,7 @@ static struct drm_driver driver = { .context_dtor = NULL, .dma_quiescent = sis_idle, .reclaim_buffers = NULL, - .reclaim_buffers_locked = sis_reclaim_buffers_locked, + .reclaim_buffers_idlelocked = sis_reclaim_buffers_locked, .lastclose = sis_lastclose, .get_map_ofs = drm_core_get_map_ofs, .get_reg_ofs = drm_core_get_reg_ofs, diff --git a/linux-core/via_mm.c b/linux-core/via_mm.c index d97269f..67d212d 100644 --- a/linux-core/via_mm.c +++ b/linux-core/via_mm.c @@ -204,6 +204,7 @@ void via_reclaim_buffers_locked(drm_devi if (dev->driver->dma_quiescent) { dev->driver->dma_quiescent(dev); } + DRM_ERROR("Lock status is %d\n", dev->lock.idle_has_lock); drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)priv); mutex_unlock(&dev->struct_mutex); diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c index 33b0a42..1446af2 100644 --- a/shared-core/via_drv.c +++ b/shared-core/via_drv.c @@ -57,8 +57,9 @@ static struct drm_driver driver = { .dma_quiescent = via_driver_dma_quiescent, .dri_library_name = dri_library_name, .reclaim_buffers = drm_core_reclaim_buffers, + .reclaim_buffers_locked = NULL, #ifdef VIA_HAVE_CORE_MM - .reclaim_buffers_locked = via_reclaim_buffers_locked, + .reclaim_buffers_idlelocked = via_reclaim_buffers_locked, .lastclose = via_lastclose, #endif .get_map_ofs = drm_core_get_map_ofs, |
From: <ma...@ke...> - 2007-02-13 23:06:30
|
shared-core/nouveau_fifo.c | 12 ++++++------ shared-core/nouveau_mem.c | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) New commits: diff-tree f524870184b29885c6207af21fcb45c47fbaa576 (from 59af900e4f62370457117b0659e3f28f89949499) Author: Stephane Marchesin <mar...@ic...> Date: Wed Feb 14 00:08:55 2007 +0100 nouveau: fix the build on big endian (thanks CyberFoxx) diff --git a/shared-core/nouveau_fifo.c b/shared-core/nouveau_fifo.c index 7f929c5..fd5455b 100644 --- a/shared-core/nouveau_fifo.c +++ b/shared-core/nouveau_fifo.c @@ -187,7 +187,7 @@ int nouveau_fifo_init(drm_device_t *dev) NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES | NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_4 | #ifdef __BIG_ENDIAN - NV_PFIFO_CACH1_BIG_ENDIAN | + NV_PFIFO_CACHE1_BIG_ENDIAN | #endif 0x00000000); @@ -293,7 +293,7 @@ static void nouveau_nv04_context_init(dr NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES | NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_4 | #ifdef __BIG_ENDIAN - NV_PFIFO_CACH1_BIG_ENDIAN | + NV_PFIFO_CACHE1_BIG_ENDIAN | #endif 0x00000000); } @@ -326,7 +326,7 @@ static void nouveau_nv10_context_init(dr NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES | NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_4 | #ifdef __BIG_ENDIAN - NV_PFIFO_CACH1_BIG_ENDIAN | + NV_PFIFO_CACHE1_BIG_ENDIAN | #endif 0x00000000); } @@ -357,7 +357,7 @@ static void nouveau_nv30_context_init(dr NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES | NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8 | #ifdef __BIG_ENDIAN - NV_PFIFO_CACH1_BIG_ENDIAN | + NV_PFIFO_CACHE1_BIG_ENDIAN | #endif 0x00000000); @@ -421,7 +421,7 @@ static void nouveau_nv40_context_init(dr NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES | NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8 | #ifdef __BIG_ENDIAN - NV_PFIFO_CACH1_BIG_ENDIAN | + NV_PFIFO_CACHE1_BIG_ENDIAN | #endif 0x30000000 /* no idea.. */); RAMFC_WR(DMA_SUBROUTINE, init->put_base); @@ -493,7 +493,7 @@ nouveau_fifo_context_restore(drm_device_ NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES | NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_4 | #ifdef __BIG_ENDIAN - NV_PFIFO_CACH1_BIG_ENDIAN | + NV_PFIFO_CACHE1_BIG_ENDIAN | #endif 0x00000000); } diff-tree 59af900e4f62370457117b0659e3f28f89949499 (from 6b289db05496c5cc89c29817be16cb107a522722) Author: B. Rathmann <koa...@us...> Date: Wed Feb 14 00:07:31 2007 +0100 nouveau: fix memory initialization with multiple cards. diff --git a/shared-core/nouveau_mem.c b/shared-core/nouveau_mem.c index cd53d25..3b1f443 100644 --- a/shared-core/nouveau_mem.c +++ b/shared-core/nouveau_mem.c @@ -35,7 +35,7 @@ #include "drm_sarea.h" #include "nouveau_drv.h" -static int meminit_ok=0; +//static int meminit_ok=0; static struct mem_block *split_block(struct mem_block *p, uint64_t start, uint64_t size, DRMFILE filp) @@ -373,10 +373,9 @@ struct mem_block* nouveau_mem_alloc(stru /* * Init memory if needed */ - if (meminit_ok==0) + if (dev_priv->fb_phys == 0) { nouveau_mem_init(dev); - meminit_ok=1; } /* @@ -446,8 +445,10 @@ alloc_ok: void nouveau_mem_free(struct drm_device* dev, struct mem_block* block) { + drm_nouveau_private_t *dev_priv = dev->dev_private; + DRM_INFO("freeing 0x%llx\n", block->start); - if (meminit_ok==0) + if (dev_priv->fb_phys == 0) { DRM_ERROR("%s called without init\n", __FUNCTION__); return; |
From: <th...@ke...> - 2007-02-16 19:26:38
|
libdrm/xf86drm.c | 3 linux-core/Makefile.kernel | 4 linux-core/drm_bo.c | 11 +- linux-core/drm_fence.c | 15 +- linux-core/drm_objects.h | 4 linux-core/i915_buffer.c | 8 - linux-core/i915_drv.c | 2 linux-core/via_buffer.c | 163 +++++++++++++++++++++++++++++++ linux-core/via_fence.c | 230 +++++++++++++++++++++++++++++++++++++++++++++ shared-core/i915_drv.h | 6 - shared-core/via_dma.c | 14 -- shared-core/via_drm.h | 14 -- shared-core/via_drv.c | 48 +++++++++ shared-core/via_drv.h | 51 +++++++++ shared-core/via_map.c | 17 +++ 15 files changed, 539 insertions(+), 51 deletions(-) New commits: diff-tree 6d8ed5aedda27ec238aac3d69fb9dfadc82bfa9a (from e0f53e59be4b96ed6eb28bd2df9f6a9d789d1734) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Fri Feb 16 20:25:26 2007 +0100 Leftover files from previous commit. diff --git a/linux-core/via_buffer.c b/linux-core/via_buffer.c new file mode 100644 index 0000000..f156ee6 --- /dev/null +++ b/linux-core/via_buffer.c @@ -0,0 +1,163 @@ +/************************************************************************** + * + * Copyright (c) 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> + */ + +#include "drmP.h" +#include "via_drm.h" +#include "via_drv.h" + +drm_ttm_backend_t *via_create_ttm_backend_entry(drm_device_t * dev) +{ + return drm_agp_init_ttm(dev, NULL); +} + +int via_fence_types(drm_buffer_object_t *bo, uint32_t * class, uint32_t * type) +{ + *class = 0; + *type = 3; + return 0; +} + +int via_invalidate_caches(drm_device_t * dev, uint32_t flags) +{ + /* + * FIXME: Invalidate texture caches here. + */ + + return 0; +} + + +static int via_vram_info(drm_device_t *dev, + unsigned long *offset, + unsigned long *size) +{ + struct pci_dev *pdev = dev->pdev; + unsigned long flags; + + int ret = DRM_ERR(EINVAL); + int i; + for (i=0; i<6; ++i) { + flags = pci_resource_flags(pdev, i); + if ((flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH)) == + (IORESOURCE_MEM | IORESOURCE_PREFETCH)) { + ret = 0; + break; + } + } + + if (ret) { + DRM_ERROR("Could not find VRAM PCI resource\n"); + return ret; + } + + *offset = pci_resource_start(pdev, i); + *size = pci_resource_end(pdev, i) - *offset + 1; + return 0; +} + +int via_init_mem_type(drm_device_t * dev, uint32_t type, + drm_mem_type_manager_t * man) +{ + switch (type) { + case DRM_BO_MEM_LOCAL: + /* System memory */ + + man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE | + _DRM_FLAG_MEMTYPE_CACHED; + man->drm_bus_maptype = 0; + break; + + case DRM_BO_MEM_TT: + /* Dynamic agpgart memory */ + + if (!(drm_core_has_AGP(dev) && dev->agp)) { + DRM_ERROR("AGP is not enabled for memory type %u\n", + (unsigned)type); + return -EINVAL; + } + man->io_offset = dev->agp->agp_info.aper_base; + man->io_size = dev->agp->agp_info.aper_size * 1024 * 1024; + man->io_addr = NULL; + man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE | _DRM_FLAG_NEEDS_IOREMAP; + + /* Only to get pte protection right. */ + + man->drm_bus_maptype = _DRM_AGP; + break; + + case DRM_BO_MEM_VRAM: + /* "On-card" video ram */ + + man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE | _DRM_FLAG_NEEDS_IOREMAP; + man->drm_bus_maptype = _DRM_FRAME_BUFFER; + man->io_addr = NULL; + return via_vram_info(dev, &man->io_offset, &man->io_size); + break; + + case DRM_BO_MEM_PRIV0: + /* Pre-bound agpgart memory */ + + if (!(drm_core_has_AGP(dev) && dev->agp)) { + DRM_ERROR("AGP is not enabled for memory type %u\n", + (unsigned)type); + return -EINVAL; + } + man->io_offset = dev->agp->agp_info.aper_base; + man->io_size = dev->agp->agp_info.aper_size * 1024 * 1024; + man->io_addr = NULL; + man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE | + _DRM_FLAG_MEMTYPE_FIXED | _DRM_FLAG_NEEDS_IOREMAP; + man->drm_bus_maptype = _DRM_AGP; + break; + + default: + DRM_ERROR("Unsupported memory type %u\n", (unsigned)type); + return -EINVAL; + } + return 0; +} + +uint32_t via_evict_mask(drm_buffer_object_t *bo) +{ + switch (bo->mem.mem_type) { + case DRM_BO_MEM_LOCAL: + case DRM_BO_MEM_TT: + return DRM_BO_FLAG_MEM_LOCAL; /* Evict TT to local */ + case DRM_BO_MEM_PRIV0: /* Evict pre-bound AGP to TT */ + return DRM_BO_MEM_TT; + case DRM_BO_MEM_VRAM: + if (bo->mem.num_pages > 128) + return DRM_BO_MEM_TT; + else + return DRM_BO_MEM_LOCAL; + default: + return DRM_BO_MEM_LOCAL; + } +} diff --git a/linux-core/via_fence.c b/linux-core/via_fence.c new file mode 100644 index 0000000..0224993 --- /dev/null +++ b/linux-core/via_fence.c @@ -0,0 +1,230 @@ +/************************************************************************** + * + * Copyright (c) 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 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 + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ +/* + * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> + */ + +#include "drmP.h" +#include "via_drm.h" +#include "via_drv.h" + +/* + * DRM_FENCE_TYPE_EXE guarantees that all command buffers can be evicted. + * DRM_VIA_FENCE_TYPE_ACCEL guarantees that all 2D & 3D rendering is complete. + */ + + +static uint32_t via_perform_flush(drm_device_t *dev, uint32_t class) +{ + drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; + drm_fence_class_manager_t *fc = &dev->fm.class[class]; + uint32_t pending_flush_types = 0; + uint32_t signaled_flush_types = 0; + uint32_t status; + + if (class != 0) + return 0; + + if (!dev_priv) + return 0; + + spin_lock(&dev_priv->fence_lock); + + pending_flush_types = fc->pending_flush | + ((fc->pending_exe_flush) ? DRM_FENCE_TYPE_EXE : 0); + + if (pending_flush_types) { + + /* + * Take the idlelock. This guarantees that the next time a client tries + * to grab the lock, it will stall until the idlelock is released. This + * guarantees that eventually, the GPU engines will be idle, but nothing + * else. It cannot be used to protect the hardware. + */ + + + if (!dev_priv->have_idlelock) { + drm_idlelock_take(&dev->lock); + dev_priv->have_idlelock = 1; + } + + /* + * Check if AGP command reader is idle. + */ + + if (pending_flush_types & DRM_FENCE_TYPE_EXE) + if (VIA_READ(0x41C) & 0x80000000) + signaled_flush_types |= DRM_FENCE_TYPE_EXE; + + /* + * Check VRAM command queue empty and 2D + 3D engines idle. + */ + + if (pending_flush_types & DRM_VIA_FENCE_TYPE_ACCEL) { + status = VIA_READ(VIA_REG_STATUS); + if ((status & VIA_VR_QUEUE_BUSY) && + !(status & (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY))) + signaled_flush_types |= DRM_VIA_FENCE_TYPE_ACCEL; + } + + if (signaled_flush_types) { + pending_flush_types &= ~signaled_flush_types; + if (!pending_flush_types && dev_priv->have_idlelock) { + drm_idlelock_release(&dev->lock); + dev_priv->have_idlelock = 0; + } + drm_fence_handler(dev, 0, dev_priv->emit_0_sequence, signaled_flush_types); + } + } + + spin_unlock(&dev_priv->fence_lock); + + return fc->pending_flush | + ((fc->pending_exe_flush) ? DRM_FENCE_TYPE_EXE : 0); +} + + +/** + * Emit a fence sequence. + */ + +int via_fence_emit_sequence(drm_device_t * dev, uint32_t class, uint32_t flags, + uint32_t * sequence, uint32_t * native_type) +{ + drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; + int ret = 0; + + if (!dev_priv) + return -EINVAL; + + switch(class) { + case 0: /* AGP command stream */ + + /* + * The sequence number isn't really used by the hardware yet. + */ + + spin_lock(&dev_priv->fence_lock); + *sequence = ++dev_priv->emit_0_sequence; + spin_unlock(&dev_priv->fence_lock); + + /* + * When drm_fence_handler() is called with flush type 0x01, and a + * sequence number, That means that the EXE flag is expired. + * Nothing else. No implicit flushing or other engines idle. + */ + + *native_type = DRM_FENCE_TYPE_EXE; + break; + default: + ret = DRM_ERR(EINVAL); + break; + } + return ret; +} + +/** + * Manual poll (from the fence manager). + */ + +void via_poke_flush(drm_device_t * dev, uint32_t class) +{ + drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; + drm_fence_manager_t *fm = &dev->fm; + unsigned long flags; + uint32_t pending_flush; + + if (!dev_priv) + return ; + + write_lock_irqsave(&fm->lock, flags); + pending_flush = via_perform_flush(dev, class); + if (pending_flush) + pending_flush = via_perform_flush(dev, class); + write_unlock_irqrestore(&fm->lock, flags); + + /* + * Kick the timer if there are more flushes pending. + */ + + if (pending_flush && !timer_pending(&dev_priv->fence_timer)) { + dev_priv->fence_timer.expires = jiffies + 1; + add_timer(&dev_priv->fence_timer); + } +} + +/** + * No irq fence expirations implemented yet. + * Although both the HQV engines and PCI dmablit engines signal + * idle with an IRQ, we haven't implemented this yet. + * This means that the drm fence manager will always poll for engine idle, + * unless the caller wanting to wait for a fence object has indicated a lazy wait. + */ + +int via_fence_has_irq(struct drm_device * dev, uint32_t class, + uint32_t flags) +{ + return 0; +} + +/** + * Regularly call the flush function. This enables lazy waits, so we can + * set lazy_capable. Lazy waits don't really care when the fence expires, + * so a timer tick delay should be fine. + */ + +void via_fence_timer(unsigned long data) +{ + drm_device_t *dev = (drm_device_t *) data; + drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; + drm_fence_manager_t *fm = &dev->fm; + uint32_t pending_flush; + drm_fence_class_manager_t *fc = &dev->fm.class[0]; + + if (!dev_priv) + return; + if (!fm->initialized) + goto out_unlock; + + via_poke_flush(dev, 0); + pending_flush = fc->pending_flush | + ((fc->pending_exe_flush) ? DRM_FENCE_TYPE_EXE : 0); + + /* + * disable timer if there are no more flushes pending. + */ + + if (!pending_flush && timer_pending(&dev_priv->fence_timer)) { + BUG_ON(dev_priv->have_idlelock); + del_timer(&dev_priv->fence_timer); + } + return; +out_unlock: + return; + +} diff-tree e0f53e59be4b96ed6eb28bd2df9f6a9d789d1734 (from 7766378d97323de375687285f2e125008b79045d) Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> Date: Fri Feb 16 20:22:24 2007 +0100 Simple fence object sample driver for via, based on idling the GPU. Buffer object driver for via. Some changes to buffer object driver callbacks. Improve fence flushing. diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 1a8edee..862772d 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -2271,8 +2271,9 @@ int drmFenceCreate(int fd, unsigned flag drmFence *fence) { drm_fence_arg_t arg; - + memset(&arg, 0, sizeof(arg)); + arg.flags = flags; arg.type = type; arg.class = class; arg.op = drm_fence_create; diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel index c2bfb67..08c0fb2 100644 --- a/linux-core/Makefile.kernel +++ b/linux-core/Makefile.kernel @@ -29,8 +29,8 @@ sis-objs := sis_drv.o sis_mm.o ffb-objs := ffb_drv.o ffb_context.o savage-objs := savage_drv.o savage_bci.o savage_state.o via-objs := via_irq.o via_drv.o via_map.o via_mm.o via_dma.o via_verifier.o \ - via_video.o via_dmablit.o -mach64-objs := mach64_drv.o mach64_dma.o mach64_irq.o mach64_state.o + via_video.o via_dmablit.o via_fence.o via_buffer.o +mach64-objs := mach64_drv.o mach64_dma.o mach64_irq.o mach64_state.o nv-objs := nv_drv.o ifeq ($(CONFIG_COMPAT),y) diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 8fc2a30..548ce14 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -641,7 +641,7 @@ static int drm_bo_evict(drm_buffer_objec } evict_mem = bo->mem; - evict_mem.mask = dev->driver->bo_driver->evict_flags(dev, mem_type); + evict_mem.mask = dev->driver->bo_driver->evict_mask(bo); ret = drm_bo_mem_space(bo, &evict_mem, no_wait); if (ret) { @@ -1351,7 +1351,7 @@ static int drm_buffer_object_validate(dr DRM_DEBUG("New flags 0x%08x, Old flags 0x%08x\n", bo->mem.mask, bo->mem.flags); ret = - driver->fence_type(bo->mem.mask, &bo->fence_class, &bo->fence_type); + driver->fence_type(bo, &bo->fence_class, &bo->fence_type); if (ret) { DRM_ERROR("Driver did not support given buffer permissions\n"); return ret; @@ -2001,9 +2001,9 @@ static int drm_bo_lock_mm(drm_device_t * return ret; } -static int drm_bo_init_mm(drm_device_t * dev, - unsigned type, - unsigned long p_offset, unsigned long p_size) +int drm_bo_init_mm(drm_device_t * dev, + unsigned type, + unsigned long p_offset, unsigned long p_size) { drm_buffer_manager_t *bm = &dev->bm; int ret = -EINVAL; @@ -2043,6 +2043,7 @@ static int drm_bo_init_mm(drm_device_t * return 0; } +EXPORT_SYMBOL(drm_bo_init_mm); /* * This is called from lastclose, so we don't need to bother about diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c index 634cf4f..3e17a16 100644 --- a/linux-core/drm_fence.c +++ b/linux-core/drm_fence.c @@ -91,6 +91,11 @@ void drm_fence_handler(drm_device_t * de } + fc->pending_flush &= ~type; + if (fc->pending_exe_flush && (type & DRM_FENCE_TYPE_EXE) && + ((sequence - fc->exe_flush_sequence) < driver->wrap_diff)) + fc->pending_exe_flush = 0; + if (wake) { DRM_WAKEUP(&fc->fence_queue); } @@ -180,7 +185,7 @@ static void drm_fence_flush_exe(drm_fenc */ list = &fc->ring; - if (list->next == &fc->ring) { + if (list_empty(list)) { return; } else { drm_fence_object_t *fence = @@ -279,7 +284,8 @@ EXPORT_SYMBOL(drm_fence_flush_old); static int drm_fence_lazy_wait(drm_device_t *dev, drm_fence_object_t *fence, - int ignore_signals, uint32_t mask) + int ignore_signals, + uint32_t mask) { drm_fence_manager_t *fm = &dev->fm; drm_fence_class_manager_t *fc = &fm->class[fence->class]; @@ -289,7 +295,7 @@ static int drm_fence_lazy_wait(drm_devic do { DRM_WAIT_ON(ret, fc->fence_queue, 3 * DRM_HZ, - fence_signaled(dev, fence, mask, 1)); + fence_signaled(dev, fence, mask, 0)); if (time_after_eq(jiffies, _end)) break; } while (ret == -EINTR && ignore_signals); @@ -352,10 +358,9 @@ int drm_fence_object_wait(drm_device_t * return ret; } } - if (fence_signaled(dev, fence, mask, 0)) + if (drm_fence_object_signaled(fence, mask)) return 0; - DRM_ERROR("Busy wait\n"); /* * Avoid kernel-space busy-waits. */ diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 547de6b..98228ad 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -411,11 +411,11 @@ typedef struct drm_bo_driver { uint32_t num_mem_busy_prio; drm_ttm_backend_t *(*create_ttm_backend_entry) (struct drm_device * dev); - int (*fence_type) (uint32_t flags, uint32_t * class, uint32_t * type); + int (*fence_type) (struct drm_buffer_object *bo, uint32_t * class, uint32_t * type); int (*invalidate_caches) (struct drm_device * dev, uint32_t flags); int (*init_mem_type) (struct drm_device * dev, uint32_t type, drm_mem_type_manager_t * man); - uint32_t(*evict_flags) (struct drm_device * dev, uint32_t type); + uint32_t(*evict_mask) (struct drm_buffer_object *bo); int (*move) (struct drm_buffer_object * bo, int evict, int no_wait, struct drm_bo_mem_reg * new_mem); } drm_bo_driver_t; diff --git a/linux-core/i915_buffer.c b/linux-core/i915_buffer.c index 2cb0dc5..8797de8 100644 --- a/linux-core/i915_buffer.c +++ b/linux-core/i915_buffer.c @@ -38,10 +38,10 @@ drm_ttm_backend_t *i915_create_ttm_backe return drm_agp_init_ttm(dev, NULL); } -int i915_fence_types(uint32_t buffer_flags, uint32_t * class, uint32_t * type) +int i915_fence_types(drm_buffer_object_t *bo, uint32_t * class, uint32_t * type) { *class = 0; - if (buffer_flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) + if (bo->mem.flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) *type = 3; else *type = 1; @@ -106,9 +106,9 @@ int i915_init_mem_type(drm_device_t * de return 0; } -uint32_t i915_evict_flags(drm_device_t * dev, uint32_t type) +uint32_t i915_evict_mask(drm_buffer_object_t *bo) { - switch (type) { + switch (bo->mem.mem_type) { case DRM_BO_MEM_LOCAL: case DRM_BO_MEM_TT: return DRM_BO_FLAG_MEM_LOCAL; diff --git a/linux-core/i915_drv.c b/linux-core/i915_drv.c index 33daf48..56e5998 100644 --- a/linux-core/i915_drv.c +++ b/linux-core/i915_drv.c @@ -64,7 +64,7 @@ static drm_bo_driver_t i915_bo_driver = .fence_type = i915_fence_types, .invalidate_caches = i915_invalidate_caches, .init_mem_type = i915_init_mem_type, - .evict_flags = i915_evict_flags, + .evict_mask = i915_evict_mask, .move = i915_move, }; #endif diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h index 34875db..3cb1a57 100644 --- a/shared-core/i915_drv.h +++ b/shared-core/i915_drv.h @@ -196,11 +196,11 @@ extern int i915_fence_has_irq(drm_device #ifdef I915_HAVE_BUFFER /* i915_buffer.c */ extern drm_ttm_backend_t *i915_create_ttm_backend_entry(drm_device_t *dev); -extern int i915_fence_types(uint32_t buffer_flags, uint32_t *class, uint32_t *type); +extern int i915_fence_types(drm_buffer_object_t *bo, uint32_t *class, uint32_t *type); extern int i915_invalidate_caches(drm_device_t *dev, uint32_t buffer_flags); -extern int i915_init_mem_type(drm_device_t *dev, uint32_t type, +extern int i915_init_mem_type(drm_device_t *dev, uint32_t type, drm_mem_type_manager_t *man); -extern uint32_t i915_evict_flags(drm_device_t *dev, uint32_t type); +extern uint32_t i915_evict_mask(drm_buffer_object_t *bo); extern int i915_move(drm_buffer_object_t *bo, int evict, int no_wait, drm_bo_mem_reg_t *new_mem); diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c index 0915963..8c5a5c6 100644 --- a/shared-core/via_dma.c +++ b/shared-core/via_dma.c @@ -40,20 +40,6 @@ #include "via_drv.h" #include "via_3d_reg.h" -#define CMDBUF_ALIGNMENT_SIZE (0x100) -#define CMDBUF_ALIGNMENT_MASK (0x0ff) - -/* defines for VIA 3D registers */ -#define VIA_REG_STATUS 0x400 -#define VIA_REG_TRANSET 0x43C -#define VIA_REG_TRANSPACE 0x440 - -/* VIA_REG_STATUS(0x400): Engine Status */ -#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */ -#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */ -#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */ -#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */ - #define SetReg2DAGP(nReg, nData) { \ *((uint32_t *)(vb)) = ((nReg) >> 2) | HALCYON_HEADER1; \ *((uint32_t *)(vb) + 1) = (nData); \ diff --git a/shared-core/via_drm.h b/shared-core/via_drm.h index 88345bd..635e463 100644 --- a/shared-core/via_drm.h +++ b/shared-core/via_drm.h @@ -58,21 +58,11 @@ (VIA_MAX_CACHELINE_SIZE - 1)) & \ ~(VIA_MAX_CACHELINE_SIZE - 1)) + \ VIA_MAX_CACHELINE_SIZE*(lockNo))) - -/* Each region is a minimum of 64k, and there are at most 64 of them. - */ #define VIA_NR_TEX_REGIONS 64 -#define VIA_LOG_MIN_TEX_REGION_SIZE 16 + #endif -#define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */ -#define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */ -#define VIA_UPLOAD_CTX 0x4 -#define VIA_UPLOAD_BUFFERS 0x8 -#define VIA_UPLOAD_TEX0 0x10 -#define VIA_UPLOAD_TEX1 0x20 -#define VIA_UPLOAD_CLIPRECTS 0x40 -#define VIA_UPLOAD_ALL 0xff +#define DRM_VIA_FENCE_TYPE_ACCEL 0x00000002 /* VIA specific ioctls */ #define DRM_VIA_ALLOCMEM 0x00 diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c index 1446af2..0a478fe 100644 --- a/shared-core/via_drv.c +++ b/shared-core/via_drv.c @@ -38,6 +38,47 @@ static struct pci_device_id pciidlist[] viadrv_PCI_IDS }; + +#ifdef VIA_HAVE_FENCE +static drm_fence_driver_t via_fence_driver = { + .num_classes = 1, + .wrap_diff = (1 << 30), + .flush_diff = (1 << 20), + .sequence_mask = 0xffffffffU, + .lazy_capable = 1, + .emit = via_fence_emit_sequence, + .poke_flush = via_poke_flush, + .has_irq = via_fence_has_irq, +}; +#endif +#ifdef VIA_HAVE_BUFFER + +/** + * If there's no thrashing. This is the preferred memory type order. + */ +static uint32_t via_mem_prios[] = {DRM_BO_MEM_PRIV0, DRM_BO_MEM_VRAM, DRM_BO_MEM_TT, DRM_BO_MEM_LOCAL}; + +/** + * If we have thrashing, most memory will be evicted to TT anyway, so we might as well + * just move the new buffer into TT from the start. + */ +static uint32_t via_busy_prios[] = {DRM_BO_MEM_TT, DRM_BO_MEM_PRIV0, DRM_BO_MEM_VRAM, DRM_BO_MEM_LOCAL}; + + +static drm_bo_driver_t via_bo_driver = { + .mem_type_prio = via_mem_prios, + .mem_busy_prio = via_busy_prios, + .num_mem_type_prio = ARRAY_SIZE(via_mem_prios), + .num_mem_busy_prio = ARRAY_SIZE(via_busy_prios), + .create_ttm_backend_entry = via_create_ttm_backend_entry, + .fence_type = via_fence_types, + .invalidate_caches = via_invalidate_caches, + .init_mem_type = via_init_mem_type, + .evict_mask = via_evict_mask, + .move = NULL, +}; +#endif + static int probe(struct pci_dev *pdev, const struct pci_device_id *ent); static struct drm_driver driver = { .driver_features = @@ -80,7 +121,12 @@ static struct drm_driver driver = { .probe = probe, .remove = __devexit_p(drm_cleanup_pci), }, - +#ifdef VIA_HAVE_FENCE + .fence_driver = &via_fence_driver, +#endif +#ifdef VIA_HAVE_BUFFER + .bo_driver = &via_bo_driver, +#endif .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = VIA_DRM_DRIVER_DATE, diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h index 42d0c74..baafbbf 100644 --- a/shared-core/via_drv.h +++ b/shared-core/via_drv.h @@ -32,6 +32,27 @@ #include "via_verifier.h" +/* + * Registers go here. + */ + + +#define CMDBUF_ALIGNMENT_SIZE (0x100) +#define CMDBUF_ALIGNMENT_MASK (0x0ff) + +/* defines for VIA 3D registers */ +#define VIA_REG_STATUS 0x400 +#define VIA_REG_TRANSET 0x43C +#define VIA_REG_TRANSPACE 0x440 + +/* VIA_REG_STATUS(0x400): Engine Status */ +#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */ +#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */ +#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */ +#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */ + + + #if defined(__linux__) #include "via_dmablit.h" @@ -41,6 +62,8 @@ */ #define VIA_HAVE_DMABLIT 1 #define VIA_HAVE_CORE_MM 1 +#define VIA_HAVE_FENCE 1 +#define VIA_HAVE_BUFFER 1 #endif #define VIA_PCI_BUF_SIZE 60000 @@ -103,6 +126,12 @@ typedef struct drm_via_private { drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES]; #endif uint32_t dma_diff; +#ifdef VIA_HAVE_FENCE + spinlock_t fence_lock; + uint32_t emit_0_sequence; + int have_idlelock; + struct timer_list fence_timer; +#endif } drm_via_private_t; enum via_family { @@ -163,4 +192,26 @@ extern void via_dmablit_handler(drm_devi extern void via_init_dmablit(drm_device_t *dev); #endif +#ifdef VIA_HAVE_FENCE +extern void via_fence_timer(unsigned long data); +extern void via_poke_flush(drm_device_t * dev, uint32_t class); +extern int via_fence_emit_sequence(drm_device_t * dev, uint32_t class, + uint32_t flags, + uint32_t * sequence, + uint32_t * native_type); +extern int via_fence_has_irq(struct drm_device * dev, uint32_t class, + uint32_t flags); +#endif + +#ifdef VIA_HAVE_BUFFER +extern drm_ttm_backend_t *via_create_ttm_backend_entry(drm_device_t *dev); +extern int via_fence_types(drm_buffer_object_t *bo, uint32_t *class, uint32_t *type); +extern int via_invalidate_caches(drm_device_t *dev, uint32_t buffer_flags); +extern int via_init_mem_type(drm_device_t *dev, uint32_t type, + drm_mem_type_manager_t *man); +extern uint32_t via_evict_mask(drm_buffer_object_t *bo); +extern int via_move(drm_buffer_object_t *bo, int evict, + int no_wait, drm_bo_mem_reg_t *new_mem); +#endif + #endif diff --git a/shared-core/via_map.c b/shared-core/via_map.c index a37f5fd..83324cf 100644 --- a/shared-core/via_map.c +++ b/shared-core/via_map.c @@ -28,6 +28,7 @@ static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) { drm_via_private_t *dev_priv = dev->dev_private; + int ret = 0; DRM_DEBUG("%s\n", __FUNCTION__); @@ -64,8 +65,22 @@ static int via_do_init_map(drm_device_t #ifdef VIA_HAVE_DMABLIT via_init_dmablit( dev ); #endif +#ifdef VIA_HAVE_FENCE + dev_priv->emit_0_sequence = 0; + dev_priv->have_idlelock = 0; + spin_lock_init(&dev_priv->fence_lock); + init_timer(&dev_priv->fence_timer); + dev_priv->fence_timer.function = &via_fence_timer; + dev_priv->fence_timer.data = (unsigned long) dev; +#endif /* VIA_HAVE_FENCE */ dev->dev_private = (void *)dev_priv; - return 0; +#ifdef VIA_HAVE_BUFFER + ret = drm_bo_driver_init(dev); + if (ret) + DRM_ERROR("Could not initialize buffer object driver.\n"); +#endif + return ret; + } int via_do_cleanup_map(drm_device_t * dev) |
From: <ai...@ke...> - 2007-03-18 10:45:37
|
linux-core/drm_memory.c | 43 +++++++++++++++++++++++++++++++ linux-core/drm_memory.h | 65 ------------------------------------------------ 2 files changed, 43 insertions(+), 65 deletions(-) New commits: diff-tree 27197d7836b913976f6b75005d1c0c926774825a (from c4808e206bcc5b3d3c0baa2e6e5130e67b78152b) Author: Dave Airlie <ai...@li...> Date: Sun Mar 18 21:45:07 2007 +1100 deinline agp_remap along lines of kernel diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index 9a53fa8..72e0f10 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -213,6 +213,49 @@ void drm_free_pages(unsigned long addres } #if __OS_HAS_AGP +static void *agp_remap(unsigned long offset, unsigned long size, + drm_device_t * dev) +{ + unsigned long *phys_addr_map, i, num_pages = + PAGE_ALIGN(size) / PAGE_SIZE; + struct drm_agp_mem *agpmem; + struct page **page_map; + void *addr; + + size = PAGE_ALIGN(size); + +#ifdef __alpha__ + offset -= dev->hose->mem_space->start; +#endif + + for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) + if (agpmem->bound <= offset + && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= + (offset + size)) + break; + if (!agpmem) + return NULL; + + /* + * OK, we're mapping AGP space on a chipset/platform on which memory accesses by + * the CPU do not get remapped by the GART. We fix this by using the kernel's + * page-table instead (that's probably faster anyhow...). + */ + /* note: use vmalloc() because num_pages could be large... */ + page_map = vmalloc(num_pages * sizeof(struct page *)); + if (!page_map) + return NULL; + + phys_addr_map = + agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; + for (i = 0; i < num_pages; ++i) + page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); + addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); + vfree(page_map); + + return addr; +} + /** Wrapper around agp_allocate_memory() */ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) DRM_AGP_MEM *drm_alloc_agp(drm_device_t *dev, int pages, u32 type) diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h index ab36b7d..03cb4d1 100644 --- a/linux-core/drm_memory.h +++ b/linux-core/drm_memory.h @@ -57,49 +57,6 @@ # endif #endif -static inline void *agp_remap(unsigned long offset, unsigned long size, - drm_device_t * dev) -{ - unsigned long *phys_addr_map, i, num_pages = - PAGE_ALIGN(size) / PAGE_SIZE; - struct drm_agp_mem *agpmem; - struct page **page_map; - void *addr; - - size = PAGE_ALIGN(size); - -#ifdef __alpha__ - offset -= dev->hose->mem_space->start; -#endif - - for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) - if (agpmem->bound <= offset - && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= - (offset + size)) - break; - if (!agpmem) - return NULL; - - /* - * OK, we're mapping AGP space on a chipset/platform on which memory accesses by - * the CPU do not get remapped by the GART. We fix this by using the kernel's - * page-table instead (that's probably faster anyhow...). - */ - /* note: use vmalloc() because num_pages could be large... */ - page_map = vmalloc(num_pages * sizeof(struct page *)); - if (!page_map) - return NULL; - - phys_addr_map = - agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; - for (i = 0; i < num_pages; ++i) - page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); - addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); - vfree(page_map); - - return addr; -} - #else /* __OS_HAS_AGP */ static inline drm_map_t *drm_lookup_map(unsigned long offset, diff-tree c4808e206bcc5b3d3c0baa2e6e5130e67b78152b (from 93f66af76a18357f7e3bfcb52c241962287c5caa) Author: Dave Airlie <ai...@li...> Date: Sun Mar 18 21:42:48 2007 +1100 remove drm_lookup_map unused now diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h index 32b89e5..ab36b7d 100644 --- a/linux-core/drm_memory.h +++ b/linux-core/drm_memory.h @@ -57,28 +57,6 @@ # endif #endif -/* - * Find the drm_map that covers the range [offset, offset+size). - */ -static inline drm_map_t *drm_lookup_map(unsigned long offset, - unsigned long size, drm_device_t * dev) -{ - struct list_head *list; - drm_map_list_t *r_list; - drm_map_t *map; - - list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *) list; - map = r_list->map; - if (!map) - continue; - if (map->offset <= offset - && (offset + size) <= (map->offset + map->size)) - return map; - } - return NULL; -} - static inline void *agp_remap(unsigned long offset, unsigned long size, drm_device_t * dev) { |
From: <ai...@ke...> - 2007-03-18 21:24:31
|
linux-core/drmP.h | 35 +++++++++++++++-------------------- linux-core/drm_agpsupport.c | 24 ++++++++++++------------ linux-core/drm_bo.c | 32 ++++++++++++++++---------------- linux-core/drm_fops.c | 30 +++++++++++------------------- linux-core/drm_memory.c | 6 ++++++ linux-core/drm_memory.h | 12 ------------ linux-core/drm_mm.c | 18 ++++++++---------- linux-core/drm_object.c | 12 ++++++------ linux-core/drm_objects.h | 18 +++++++++--------- linux-core/drm_ttm.c | 16 ++++++++-------- shared-core/drm.h | 6 +++--- 11 files changed, 94 insertions(+), 115 deletions(-) New commits: diff-tree 2463b03cb4d89cfcc5f2af6d6f09b28a491cb971 (from 6c4428d40c7531a28aa405e3db407461d20a0110) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:23:43 2007 +1100 whitespace cleanup pending a kernel merge diff --git a/linux-core/drmP.h b/linux-core/drmP.h index d1dbdc2..596a017 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -416,11 +416,11 @@ typedef struct drm_file { struct drm_head *head; int remove_auth_on_close; unsigned long lock_count; - + /* * The user object hash table is global and resides in the * drm_device structure. We protect the lists and hash tables with the - * device struct_mutex. A bit coarse-grained but probably the best + * device struct_mutex. A bit coarse-grained but probably the best * option. */ @@ -534,7 +534,7 @@ typedef struct drm_sigdata { } drm_sigdata_t; -/* +/* * Generic memory manager structs */ @@ -655,7 +655,7 @@ struct drm_driver { struct drm_fence_driver *fence_driver; struct drm_bo_driver *bo_driver; - + int major; int minor; int patchlevel; @@ -732,11 +732,11 @@ typedef struct drm_device { /*@{ */ drm_map_list_t *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 */ - drm_open_hash_t object_hash; /**< User token hash table for objects */ - struct address_space *dev_mapping; /**< For unmap_mapping_range() */ - struct page *ttm_dummy_page; + drm_open_hash_t map_hash; /**< User token hash table for maps */ + drm_mm_t offset_manager; /**< User token manager */ + drm_open_hash_t object_hash; /**< User token hash table for objects */ + struct address_space *dev_mapping; /**< For unmap_mapping_range() */ + struct page *ttm_dummy_page; /** \name Context handle management */ /*@{ */ @@ -818,7 +818,7 @@ typedef struct drm_device { drm_fence_manager_t fm; drm_buffer_manager_t bm; - + /** \name Drawable information */ /*@{ */ spinlock_t drw_lock; @@ -948,7 +948,7 @@ extern void drm_free_memctl(size_t size) extern int drm_alloc_memctl(size_t size); extern void drm_query_memctl(drm_u64_t *cur_used, drm_u64_t *low_threshold, - drm_u64_t *high_threshold); + drm_u64_t *high_threshold); extern void drm_init_memctl(size_t low_threshold, size_t high_threshold, size_t unit_size); @@ -1161,14 +1161,14 @@ extern struct class_device *drm_sysfs_de drm_head_t * head); extern void drm_sysfs_device_remove(struct class_device *class_dev); -/* - * Basic memory manager support (drm_mm.c) +/* + * Basic memory manager support (drm_mm.c) */ extern drm_mm_node_t * drm_mm_get_block(drm_mm_node_t * parent, unsigned long size, unsigned alignment); extern void drm_mm_put_block(drm_mm_node_t *cur); -extern drm_mm_node_t *drm_mm_search_free(const drm_mm_t *mm, unsigned long size, +extern drm_mm_node_t *drm_mm_search_free(const drm_mm_t *mm, unsigned long size, unsigned alignment, int best_match); extern int drm_mm_init(drm_mm_t *mm, unsigned long start, unsigned long size); extern void drm_mm_takedown(drm_mm_t *mm); @@ -1181,11 +1181,6 @@ static inline drm_mm_t *drm_get_mm(drm_m { return block->mm; } - - - - - extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev); extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev); @@ -1204,7 +1199,7 @@ static __inline__ int drm_device_is_agp( { if ( dev->driver->device_is_agp != NULL ) { int err = (*dev->driver->device_is_agp)( dev ); - + if (err != 2) { return err; } diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 6b93d24..0f7b1d2 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -567,7 +567,7 @@ static int drm_agp_needs_unbind_cache_ad } -static int drm_agp_populate(drm_ttm_backend_t *backend, unsigned long num_pages, +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; @@ -597,9 +597,9 @@ static int drm_agp_populate(drm_ttm_back return 0; } -static int drm_agp_bind_ttm(drm_ttm_backend_t *backend, +static int drm_agp_bind_ttm(drm_ttm_backend_t *backend, unsigned long offset, - int cached) + int cached) { drm_agp_ttm_priv *agp_priv = (drm_agp_ttm_priv *) backend->private; DRM_AGP_MEM *mem = agp_priv->mem; @@ -620,7 +620,7 @@ static int drm_agp_bind_ttm(drm_ttm_back static int drm_agp_unbind_ttm(drm_ttm_backend_t *backend) { drm_agp_ttm_priv *agp_priv = (drm_agp_ttm_priv *) backend->private; - + DRM_DEBUG("drm_agp_unbind_ttm\n"); if (agp_priv->mem->is_bound) return drm_agp_unbind_memory(agp_priv->mem); @@ -646,8 +646,8 @@ static void drm_agp_clear_ttm(drm_ttm_ba static void drm_agp_destroy_ttm(drm_ttm_backend_t *backend) { - drm_agp_ttm_priv *agp_priv; - + drm_agp_ttm_priv *agp_priv; + if (backend) { DRM_DEBUG("drm_agp_destroy_ttm\n"); agp_priv = (drm_agp_ttm_priv *) backend->private; @@ -659,11 +659,11 @@ static void drm_agp_destroy_ttm(drm_ttm_ backend->private = NULL; } if (backend->flags & DRM_BE_FLAG_NEEDS_FREE) { - drm_ctl_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS); + drm_ctl_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS); } } } - + drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev, drm_ttm_backend_t *backend) @@ -695,15 +695,15 @@ drm_ttm_backend_t *drm_agp_init_ttm(stru 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_priv->mem = NULL; agp_priv->alloc_type = AGP_USER_MEMORY; agp_priv->cached_type = AGP_USER_CACHED_MEMORY; diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 548ce14..d3e89af 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.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 @@ -14,15 +14,15 @@ * 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. - * + * **************************************************************************/ /* * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> @@ -35,7 +35,7 @@ * * The buffer usage atomic_t needs to be protected by dev->struct_mutex * when there is a chance that it can be zero before or after the operation. - * + * * dev->struct_mutex also protects all lists and list heads. Hash tables and hash * heads. * @@ -502,7 +502,7 @@ static void drm_bo_usage_deref_unlocked( } /* - * Note. The caller has to register (if applicable) + * Note. The caller has to register (if applicable) * and deregister fence object usage. */ @@ -546,7 +546,7 @@ int drm_fence_buffer_objects(drm_file_t /* * Transfer to a local list before we release the dev->struct_mutex; - * This is so we don't get any new unfenced objects while fencing + * This is so we don't get any new unfenced objects while fencing * the ones we already have.. */ @@ -604,7 +604,7 @@ int drm_fence_buffer_objects(drm_file_t EXPORT_SYMBOL(drm_fence_buffer_objects); /* - * bo->mutex locked + * bo->mutex locked */ static int drm_bo_evict(drm_buffer_object_t * bo, unsigned mem_type, @@ -1011,7 +1011,7 @@ static int drm_bo_check_unfenced(drm_buf * 1) validating * 2) submitting commands * 3) fencing - * Should really be an atomic operation. + * Should really be an atomic operation. * We now "solve" this problem by keeping * the buffer "unfenced" after validating, but before fencing. */ @@ -1053,7 +1053,7 @@ static int drm_bo_wait_unfenced(drm_buff /* * Fill in the ioctl reply argument with buffer info. - * Bo locked. + * Bo locked. */ static void drm_bo_fill_rep_arg(drm_buffer_object_t * bo, @@ -1078,8 +1078,8 @@ static void drm_bo_fill_rep_arg(drm_buff /* * Wait for buffer idle and register that we've mapped the buffer. - * Mapping is registered as a drm_ref_object with type _DRM_REF_TYPE1, - * so that if the client dies, the mapping is automatically + * Mapping is registered as a drm_ref_object with type _DRM_REF_TYPE1, + * so that if the client dies, the mapping is automatically * unregistered. */ @@ -1215,7 +1215,7 @@ static void drm_buffer_user_object_unmap } /* - * bo->mutex locked. + * bo->mutex locked. * Note that new_mem_flags are NOT transferred to the bo->mem.mask. */ @@ -2251,7 +2251,7 @@ EXPORT_SYMBOL(drm_mem_reg_is_pci); * \param bus_size On return the byte size of the buffer object or zero if * the buffer object memory is not accessible through a PCI region. * \return Failure indication. - * + * * Returns -EINVAL if the buffer object is currently not mappable. * Otherwise returns zero. */ diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index faf7672..3521c09 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -159,7 +159,7 @@ int drm_open(struct inode *inode, struct spin_unlock(&dev->count_lock); } mutex_lock(&dev->struct_mutex); - BUG_ON((dev->dev_mapping != NULL) && + BUG_ON((dev->dev_mapping != NULL) && (dev->dev_mapping != inode->i_mapping)); if (dev->dev_mapping == NULL) dev->dev_mapping = inode->i_mapping; @@ -355,42 +355,34 @@ static void drm_object_release(struct fi /* * Free leftover ref objects created by me. Note that we cannot use - * list_for_each() here, as the struct_mutex may be temporarily released + * list_for_each() here, as the struct_mutex may be temporarily released * by the remove_() functions, and thus the lists may be altered. * Also, a drm_remove_ref_object() will not remove it * from the list unless its refcount is 1. */ - head = &priv->refd_objects; + head = &priv->refd_objects; while (head->next != head) { ref_object = list_entry(head->next, drm_ref_object_t, list); - drm_remove_ref_object(priv, ref_object); - head = &priv->refd_objects; + drm_remove_ref_object(priv, ref_object); + head = &priv->refd_objects; } - + /* * Free leftover user objects created by me. */ - head = &priv->user_objects; + head = &priv->user_objects; while (head->next != head) { user_object = list_entry(head->next, drm_user_object_t, list); - drm_remove_user_object(priv, user_object); - head = &priv->user_objects; + drm_remove_user_object(priv, user_object); + head = &priv->user_objects; } - - - for(i=0; i<_DRM_NO_REF_TYPES; ++i) { drm_ht_remove(&priv->refd_object_hash[i]); } -} - - - - - +} /** * Release file. @@ -563,7 +555,7 @@ EXPORT_SYMBOL(drm_release); * to set a newer interface version to avoid breaking older Xservers. * Without fixing the Xserver you get: "WaitForSomething(): select: errno=22" * http://freedesktop.org/bugzilla/show_bug.cgi?id=1505 if you try - * to return the correct response. + * to return the correct response. */ unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait) { diff --git a/linux-core/drm_mm.c b/linux-core/drm_mm.c index 634a178..2caf596 100644 --- a/linux-core/drm_mm.c +++ b/linux-core/drm_mm.c @@ -53,7 +53,7 @@ unsigned long drm_mm_tail_space(drm_mm_t entry = list_entry(tail_node, drm_mm_node_t, ml_entry); if (!entry->free) return 0; - + return entry->size; } @@ -66,7 +66,7 @@ int drm_mm_remove_space_from_tail(drm_mm entry = list_entry(tail_node, drm_mm_node_t, ml_entry); if (!entry->free) return -ENOMEM; - + if (entry->size <= size) return -ENOMEM; @@ -80,7 +80,7 @@ static int drm_mm_create_tail_node(drm_m unsigned long size) { drm_mm_node_t *child; - + child = (drm_mm_node_t *) drm_ctl_alloc(sizeof(*child), DRM_MEM_MM); if (!child) @@ -96,7 +96,7 @@ static int drm_mm_create_tail_node(drm_m return 0; } - + int drm_mm_add_space_to_tail(drm_mm_t *mm, unsigned long size) { @@ -111,12 +111,12 @@ int drm_mm_add_space_to_tail(drm_mm_t *m entry->size += size; return 0; } - + static drm_mm_node_t *drm_mm_split_at_start(drm_mm_node_t *parent, unsigned long size) { drm_mm_node_t *child; - + child = (drm_mm_node_t *) drm_ctl_alloc(sizeof(*child), DRM_MEM_MM); if (!child) @@ -136,8 +136,6 @@ static drm_mm_node_t *drm_mm_split_at_st parent->start += size; return child; } - - drm_mm_node_t *drm_mm_get_block(drm_mm_node_t * parent, unsigned long size, unsigned alignment) @@ -149,13 +147,13 @@ drm_mm_node_t *drm_mm_get_block(drm_mm_n if (alignment) tmp = parent->start % alignment; - + if (tmp) { align_splitoff = drm_mm_split_at_start(parent, alignment - tmp); if (!align_splitoff) return NULL; } - + if (parent->size == size) { list_del_init(&parent->fl_entry); parent->free = 0; diff --git a/linux-core/drm_object.c b/linux-core/drm_object.c index 939cf0d..23412ed 100644 --- a/linux-core/drm_object.c +++ b/linux-core/drm_object.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 @@ -14,15 +14,15 @@ * 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. - * + * **************************************************************************/ /* * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h index 98228ad..b3155af 100644 --- a/linux-core/drm_objects.h +++ b/linux-core/drm_objects.h @@ -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,7 +10,7 @@ * 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. @@ -19,8 +19,8 @@ * 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. * **************************************************************************/ @@ -222,12 +222,12 @@ extern int drm_fence_ioctl(DRM_IOCTL_ARG * The ttm backend GTT interface. (In our case AGP). * Any similar type of device (PCIE?) * needs only to implement these functions to be usable with the "TTM" interface. - * The AGP backend implementation lives in drm_agpsupport.c + * The AGP backend implementation lives in drm_agpsupport.c * basically maps these calls to available functions in agpgart. * Each drm device driver gets an - * additional function pointer that creates these types, + * additional function pointer that creates these types, * so that the device can choose the correct aperture. - * (Multiple AGP apertures, etc.) + * (Multiple AGP apertures, etc.) * Most device drivers will let this point to the standard AGP implementation. */ @@ -275,7 +275,7 @@ extern void drm_ttm_fixup_caching(drm_tt extern struct page *drm_ttm_get_page(drm_ttm_t * ttm, int index); /* - * Destroy a ttm. The user normally calls drmRmMap or a similar IOCTL to do this, + * Destroy a ttm. The user normally calls drmRmMap or a similar IOCTL to do this, * which calls this function iff there are no vmas referencing it anymore. Otherwise it is called * when the last vma exits. */ diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index e67719e..2556634 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.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,19 +10,19 @@ * 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. - * + * **************************************************************************/ /* * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> @@ -101,7 +101,7 @@ static struct page *drm_ttm_alloc_page(v } /* - * Change caching policy for the linear kernel map + * Change caching policy for the linear kernel map * for range of pages in a ttm. */ diff --git a/shared-core/drm.h b/shared-core/drm.h index bcb3eed..3c59cd4 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -798,7 +798,7 @@ typedef enum { drm_bo_type_user, drm_bo_type_fake }drm_bo_type_t; - + typedef struct drm_bo_arg_request { unsigned handle; /* User space handle */ @@ -846,10 +846,10 @@ typedef struct drm_bo_arg_reply { unsigned page_alignment; unsigned expand_pad[4]; /*Future expansion */ }drm_bo_arg_reply_t; - + typedef struct drm_bo_arg{ - int handled; + int handled; drm_u64_t next; union { drm_bo_arg_request_t req; diff-tree 6c4428d40c7531a28aa405e3db407461d20a0110 (from 27197d7836b913976f6b75005d1c0c926774825a) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:09:21 2007 +1100 clean up more of inline functions agp_remap/drm_lookup_map diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index 72e0f10..f156fea 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -286,6 +286,12 @@ int drm_unbind_agp(DRM_AGP_MEM * handle) { return drm_agp_unbind_memory(handle); } + +static void *agp_remap(unsigned long offset, unsigned long size, + drm_device_t * dev) +{ + return NULL; +} #endif /* agp */ #endif /* debug_memory */ diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h index 03cb4d1..5590c49 100644 --- a/linux-core/drm_memory.h +++ b/linux-core/drm_memory.h @@ -59,16 +59,4 @@ #else /* __OS_HAS_AGP */ -static inline drm_map_t *drm_lookup_map(unsigned long offset, - unsigned long size, drm_device_t * dev) -{ - return NULL; -} - -static inline void *agp_remap(unsigned long offset, unsigned long size, - drm_device_t * dev) -{ - return NULL; -} - #endif |
From: <ai...@ke...> - 2007-03-18 21:36:08
|
linux-core/drm_drv.c | 2 +- linux-core/drm_proc.c | 2 +- linux-core/i810_dma.c | 2 +- linux-core/i830_dma.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) New commits: diff-tree bbb6fc9307c42891120faeaca5c57cf7884866ad (from 483f6a113d21b90821d091c4dae413703f9907e5) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:36:01 2007 +1100 make drm fops const from kernel diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index ff9b29e..fba59b9 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -442,7 +442,7 @@ void drm_exit(struct drm_driver *driver) EXPORT_SYMBOL(drm_exit); /** File operations structure */ -static struct file_operations drm_stub_fops = { +static const struct file_operations drm_stub_fops = { .owner = THIS_MODULE, .open = drm_stub_open }; diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c index 4146700..3f2dad3 100644 --- a/linux-core/i810_dma.c +++ b/linux-core/i810_dma.c @@ -131,7 +131,7 @@ static int i810_mmap_buffers(struct file return 0; } -static struct file_operations i810_buffer_fops = { +static const struct file_operations i810_buffer_fops = { .open = drm_open, .release = drm_release, .ioctl = drm_ioctl, diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c index 406a3ff..78bd623 100644 --- a/linux-core/i830_dma.c +++ b/linux-core/i830_dma.c @@ -117,7 +117,7 @@ static int i830_mmap_buffers(struct file return 0; } -static struct file_operations i830_buffer_fops = { +static const struct file_operations i830_buffer_fops = { .open = drm_open, .release = drm_release, .ioctl = drm_ioctl, diff-tree 483f6a113d21b90821d091c4dae413703f9907e5 (from 2d7ecb84221278a9b6a0328fb2f9a63ea6b8e2e2) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:32:25 2007 +1100 use ARRAY_SIZE diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index 1c2c17f..d6da86b 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -75,7 +75,7 @@ static struct drm_proc_list { #endif }; -#define DRM_PROC_ENTRIES (sizeof(drm_proc_list)/sizeof(drm_proc_list[0])) +#define DRM_PROC_ENTRIES ARRAY_SIZE(drm_proc_list) /** * Initialize the DRI proc filesystem for a device. |
From: <ai...@ke...> - 2007-03-18 21:46:59
|
linux-core/drm_drv.c | 13 ++++++------- linux-core/drm_memory.c | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) New commits: diff-tree c991f8e049d8f39cbbb74afb81097affdc110a29 (from a2e3bae8e23398b1db25ea79cf1086a1fa735946) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:46:39 2007 +1100 cleanup ioctl expansion code diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index fba59b9..bfa39ab 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -591,21 +591,20 @@ int drm_ioctl(struct inode *inode, struc current->pid, cmd, nr, (long)old_encode_dev(priv->head->device), priv->authenticated); - if (nr >= DRIVER_IOCTL_COUNT && - (nr < DRM_COMMAND_BASE || nr >= DRM_COMMAND_END)) + if ((nr >= DRIVER_IOCTL_COUNT) && + ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) 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]; - else if (nr >= DRM_COMMAND_END || nr < DRM_COMMAND_BASE) + else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) ioctl = &drm_ioctls[nr]; - else + else goto err_i1; - - func = ioctl->func; - if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl) /* Local override? */ + /* is there a local override? */ + if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl) func = dev->driver->dma_ioctl; if (!func) { diff-tree a2e3bae8e23398b1db25ea79cf1086a1fa735946 (from bbb6fc9307c42891120faeaca5c57cf7884866ad) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:46:25 2007 +1100 oops missing else diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index f156fea..a1aaa8f 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -287,12 +287,14 @@ int drm_unbind_agp(DRM_AGP_MEM * handle) return drm_agp_unbind_memory(handle); } +#else /* __OS_HAS_AGP*/ static void *agp_remap(unsigned long offset, unsigned long size, drm_device_t * dev) { return NULL; } #endif /* agp */ + #endif /* debug_memory */ void drm_core_ioremap(struct drm_map *map, struct drm_device *dev) |
From: <ai...@ke...> - 2007-03-18 22:12:20
|
linux-core/drm_ioctl.c | 4 ++-- shared-core/i915_drv.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) New commits: diff-tree 46fac1708242756d280128888bda7218fb224603 (from 26aba875e1094dcb3ba88ac4c41e943ef46df2c8) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 09:12:08 2007 +1100 fixup return values in drm ioctl diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c index 3dcc4bf..a924636 100644 --- a/linux-core/drm_ioctl.c +++ b/linux-core/drm_ioctl.c @@ -343,7 +343,7 @@ int drm_setversion(DRM_IOCTL_ARGS) if (sv.drm_di_major != -1) { if (sv.drm_di_major != DRM_IF_MAJOR || sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) - return EINVAL; + return -EINVAL; if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor); dev->if_version = max(if_version, dev->if_version); if (sv.drm_di_minor >= 1) { @@ -357,7 +357,7 @@ int drm_setversion(DRM_IOCTL_ARGS) if (sv.drm_dd_major != -1) { if (sv.drm_dd_major != dev->driver->major || sv.drm_dd_minor < 0 || sv.drm_dd_minor > dev->driver->minor) - return EINVAL; + return -EINVAL; if (dev->driver->set_version) dev->driver->set_version(dev, &sv); diff-tree 26aba875e1094dcb3ba88ac4c41e943ef46df2c8 (from c991f8e049d8f39cbbb74afb81097affdc110a29) Author: Dave Airlie <ai...@li...> Date: Mon Mar 19 08:56:24 2007 +1100 more whitespace issues diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h index a373616..662ffad 100644 --- a/shared-core/i915_drv.h +++ b/shared-core/i915_drv.h @@ -112,14 +112,14 @@ typedef struct drm_i915_private { struct mem_block *agp_heap; unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds; int vblank_pipe; - spinlock_t user_irq_lock; - int user_irq_refcount; - int fence_irq_on; - uint32_t irq_enable_reg; - int irq_enabled; + spinlock_t user_irq_lock; + int user_irq_refcount; + int fence_irq_on; + uint32_t irq_enable_reg; + int irq_enabled; #ifdef I915_HAVE_FENCE - uint32_t flush_sequence; + uint32_t flush_sequence; uint32_t flush_flags; uint32_t flush_pending; uint32_t saved_flush_status; |