summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2005-11-15Loosen via dmablit alignment checks somewhat. Adapt stride check to maximumThomas Hellstrom
sceen size for EXA.
2005-11-15Fix compiling and reenable build of i915 driver.Eric Anholt
2005-11-15Fix Savage DRI without ShadowStatus NO by allowing the shadow area to beEric Anholt
mapped.
2005-11-11enable i915 32/64 bit ioctlsDave Airlie
2005-11-11RV200 < R200Dave Airlie
2005-11-11i810 should be fine with i810.. no idea what this crack is ..Dave Airlie
2005-11-11fix up radeon whitespaceDave Airlie
2005-11-11Fix breakage from the move of driver ioctl externs to header files.Eric Anholt
2005-11-11whitespace align with kernelDave Airlie
2005-11-11mixing breaks in r128 driver.. fixed in kernelDave Airlie
2005-11-11copy correct KconfigDave Airlie
2005-11-11realign whitespace with kernelDave Airlie
2005-11-11remove extra spacesDave Airlie
2005-11-11A bunch of create_proc_dir_entry() calls creating directories had crept inDave Airlie
since the last sweep; converted to proc_mkdir(). From: Al Viro (via kernel)
2005-11-11convert to use __set_current_state, align some header includesDave Airlie
2005-11-11whitespace align closer with kernelDave Airlie
2005-11-11cleanup ioctl/max_ioctl to use header file for extern symbolsDave Airlie
2005-11-10Fix cpu_to_le32 same as kernel not sure it is correct for ppcDave Airlie
2005-11-10cleanup / whitespace align with kernelDave Airlie
2005-11-08Correct a LOR issue on FreeBSD by allocating temporary space and doing aEric Anholt
single DRM_COPY_FROM_USER rather than DRM_VERIFYAREA_READ followed by tons of DRM_COPY_FROM_USER_UNCHECKED. I don't like the look of the temporary space allocation, but I like the simplification in the rest of the file. Tested with glxgears, tuxracer, and q3 on a savage4.
2005-11-08Correct another LOR issue with resource allocation. This leaves theEric Anholt
drm_get_resource_* resource allocation a little racy, but they're getting called at either X Server startup or driver load, so it's serialized anyway.
2005-11-08Initial port of savage to FreeBSD for the AGP and !ShadowStatus case. AddsEric Anholt
drm_mtrr_{add,del} for handling the MTRR setup. Still has a LOR issue with DRM_VERIFYAREA_READ/DRM_COPY_FROM_USER_UNCHECKED in savage_bci.c -- this won't work with the fine-grained locking in use, and just doing a single copyin to a temporary will probably work fine. Also note that the module leaks approximately 4 kb on unload.
2005-11-08Correct a LOR on FreeBSD by allocating a temporary buffer and doing aEric Anholt
single COPY_FROM_USER into it, rather than VERIFYAREA followed by many COPY_FROM_USER_UNCHECKEDs.
2005-11-08Correct a LOR related to the PCI resource allocations by simply moving theEric Anholt
uninit to unload time rather than lastclose.
2005-11-08Fix FreeBSD DRM for latest MGA changes to agp support, which cleans thingsEric Anholt
up a good bit, I think. Also, remove the agp_uninit() function which has lain around as a noop for years now. The FreeBSD DRM is now all compiling, with the exception of via. One known sleeping-with-lock-held issue remains.
2005-11-08Catch FreeBSD up to the pcie gart changes. Required minor modification toEric Anholt
radeon_cp.c to use a drm_local_map_t-type mapping (drm_core_ioremap rather than drm_ioremap), which contains private device mapping information on BSD. I also changed the ati_pcigart interface to use "void *" for pointers to kva rather than "unsigned long". While PCIGART support appears to be broken on FreeBSD currently, I think this is not new, and BusType PCI remains working on my r100 in Linux.
2005-11-08Correct a recursion on non-recursive mutex in drm_addmap from radeon'sEric Anholt
firstopen, by making drm_addmap require the drm device lock to be held. Also, make matching of kernel maps match linux by requiring shm matches to have the contains_lock flag set if the offset doesn't match.
2005-11-07Fix bug #4908 for now. Alternative is highlighted in this bug report as theAlan Hourihane
better future direction.
2005-11-06Re-disable the via driver while it's broken on BSD.Eric Anholt
2005-11-03Converts the remaining drm_agp_foo functions to be a drm_agp_foo andIan Romanick
drm_agp_foo_ioctl pair. Modifies the MGA DRM to use the drm_agp_foo functions instead of the drm_foo_agp functions. The drm_foo_agp functions are no longer exported by drm.ko. Ensures that dma->seg_count and dma->page_count are properly set in drm_addbufs_{agp,sg,fb}. drm_addbufs_pci was already correct. Ensures that mga_do_agp_dma_bootstrap correctly sets agp_buffer_token. At this point PCI DMA is still broken. Xorg bug: #4797 Reviewed by: Dave Airlie, Eric Anholt Signed-off-by: Ian Romanick <idr@us.ibm.com>
2005-10-31Bump to 1.0.5 for new via headerAdam Jackson
2005-10-23we don't use this stuff anymore .. remove 1k buffer from driver ..Dave Airlie
2005-10-22via: Sync via_drm.h with 3D driver. Bump via patchlevel and date.Thomas Hellstrom
2005-10-22Bug #328: Silence read-from-uninitialized warnings in DRM_CAS on Alpha.Adam Jackson
(David Dawes)
2005-10-21Don't set MTRR's for intel hardwareAlan Hourihane
2005-10-20fix G550 cardsDave Airlie
2005-10-20Bump to 1.0.4.Adam Jackson
2005-10-20Remove the remaining references to Xlib. libdrm is totally independent now.Adam Jackson
2005-10-20via and r300 still need installed reg headers.Adam Jackson
2005-10-20via: PCI DMA bugfixes and DOS due to too many mapped pages checks.Thomas Hellstrom
2005-10-20Remove bogus Xlib dependency.Adam Jackson
2005-10-20dma access also needs some workDave Airlie
2005-10-20the old init path needs to set WAGP_ENABLE by defaultDave Airlie
2005-10-14Doig a full clean up from mga_do_dma_bootstrap whenIan Romanick
mga_do_agp_dma_bootstrap fails causes problems if mga_do_pci_dma_bootstrap succeeds. This commit makes it possible to do a "minimal" clean up instead. I'm still trying to figure out what is causing the failures in mga_do_agp_dma_bootstrap... Signed-off-by: Ian Romanick <idr@us.ibm.com>
2005-10-14Fixed a cut-and-paste bug that could cause an oops in mga_do_cleanup_dmaIan Romanick
when mga_do_init_dma fails. Still trying to determine why mga_do_init_dma is failing. Signed-off-by: Ian Romanick <idr@us.ibm.com>
2005-10-13Better pkgconfig-fu: -ldrm in Libs:Adam Jackson
2005-10-13Add X300 RV370Dave Airlie
2005-10-11The Linux 2.6.9 (and earlier) fops structure does not contain aIan Romanick
.compat_ioctl field. This change makes the DRM build on those kernels. Signed-off-by: Ian Romanick <idr@us.ibm.com>
2005-10-06Skeleton nv drm driver, to enable DMA in EXA. (Lars Knoll, minor updates byAdam Jackson
me)
2005-10-06remove version not used anymoreDave Airlie
l ppc">#else #define __REALLY_HAVE_MTRR 0 #endif #define __REALLY_HAVE_SG (__HAVE_SG) #if __REALLY_HAVE_AGP #include <pci/agpvar.h> #include <sys/agpio.h> #endif #include <opt_drm.h> #if DRM_DEBUG #undef DRM_DEBUG_CODE #define DRM_DEBUG_CODE 2 #endif #undef DRM_DEBUG #if DRM_LINUX #include <sys/file.h> #include <sys/proc.h> #include <machine/../linux/linux.h> #include <machine/../linux/linux_proto.h> #endif #define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */ #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) #define DRM_DEV_UID 0 #define DRM_DEV_GID 0 #define CDEV_MAJOR 145 #if __FreeBSD_version >= 500000 #define DRM_CURPROC curthread #define DRM_STRUCTPROC struct thread #define DRM_SPINTYPE struct mtx #define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF) #define DRM_SPINUNINIT(l) mtx_destroy(&l) #define DRM_SPINLOCK(l) mtx_lock(l) #define DRM_SPINUNLOCK(u) mtx_unlock(u); #define DRM_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED) #define DRM_CURRENTPID curthread->td_proc->p_pid #define DRM_LOCK() mtx_lock(&dev->dev_lock) #define DRM_UNLOCK() mtx_unlock(&dev->dev_lock) #else /* There is no need for locking on FreeBSD 4.x. Synchronization is handled by * the fact that there is no reentrancy of the kernel except for interrupt * handlers, and the interrupt handler synchronization is managed by spls. */ #define DRM_CURPROC curproc #define DRM_STRUCTPROC struct proc #define DRM_SPINTYPE #define DRM_SPININIT(l,name) #define DRM_SPINUNINIT(l) #define DRM_SPINLOCK(l) #define DRM_SPINUNLOCK(u) #define DRM_SPINLOCK_ASSERT(l) #define DRM_CURRENTPID curproc->p_pid #define DRM_LOCK() #define DRM_UNLOCK() #endif /* Currently our DRMFILE (filp) is a void * which is actually the pid * of the current process. It should be a per-open unique pointer, but * code for that is not yet written */ #define DRMFILE void * #define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p, DRMFILE filp #define DRM_SUSER(p) suser(p) #define DRM_TASKQUEUE_ARGS void *arg, int pending #define DRM_IRQ_ARGS void *arg typedef void irqreturn_t; #define IRQ_HANDLED /* nothing */ #define IRQ_NONE /* nothing */ #define DRM_DEVICE drm_device_t *dev = kdev->si_drv1 #define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) #define DRM_FREE(pt,size) free( pt, DRM(M_DRM) ) /* Read/write from bus space, with byteswapping to le if necessary */ #define DRM_READ8(map, offset) *(volatile u_int8_t *) (((unsigned long)(map)->handle) + (offset)) #define DRM_READ32(map, offset) *(volatile u_int32_t *)(((unsigned long)(map)->handle) + (offset)) #define DRM_WRITE8(map, offset, val) *(volatile u_int8_t *) (((unsigned long)(map)->handle) + (offset)) = val #define DRM_WRITE32(map, offset, val) *(volatile u_int32_t *)(((unsigned long)(map)->handle) + (offset)) = val /* #define DRM_READ8(map, offset) bus_space_read_1( (map)->iot, (map)->ioh, (offset) ) #define DRM_READ32(map, offset) bus_space_read_4( (map)->iot, (map)->ioh, (offset) ) #define DRM_WRITE8(map, offset, val) bus_space_write_1( (map)->iot, (map)->ioh, (offset), (val) ) #define DRM_WRITE32(map, offset, val) bus_space_write_4( (map)->iot, (map)->ioh, (offset), (val) ) */ #define DRM_AGP_FIND_DEVICE() agp_find_device() #define DRM_ERR(v) v #define DRM_MTRR_WC MDF_WRITECOMBINE #define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \ do { \ if (_filp != (DRMFILE)DRM_CURRENTPID) { \ DRM_ERROR("filp doesn't match curproc\n"); \ return EINVAL; \ } \ DRM_LOCK(); \ _priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \ DRM_UNLOCK(); \ if (_priv == NULL) { \ DRM_ERROR("can't find authenticator\n"); \ return EINVAL; \ } \ } while (0) #define LOCK_TEST_WITH_RETURN(dev, filp) \ do { \ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \ dev->lock.filp != filp) { \ DRM_ERROR("%s called without lock held\n", \ __FUNCTION__); \ return EINVAL; \ } \ } while (0) #define DRM_UDELAY( udelay ) \ do { \ struct timeval tv1, tv2; \ microtime(&tv1); \ do { \ microtime(&tv2); \ } \ while (((tv2.tv_sec-tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec) < udelay ); \ } while (0) #define DRM_GETSAREA() \ do { \ drm_map_list_entry_t *listentry; \ TAILQ_FOREACH(listentry, dev->maplist, link) { \ drm_local_map_t *map = listentry->map; \ if (map->type == _DRM_SHM && \ map->flags & _DRM_CONTAINS_LOCK) { \ dev_priv->sarea = map; \ break; \ } \ } \ } while (0) #define DRM_HZ hz #if defined(__FreeBSD__) && __FreeBSD_version > 500000 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ mtx_lock(&dev->irq_lock); \ if (!(condition)) \ ret = msleep(&(queue), &dev->irq_lock, \ PZERO | PCATCH, "drmwtq", (timeout)); \ mtx_unlock(&dev->irq_lock); \ } #else #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ int s = spldrm(); \ if (!(condition)) \ ret = tsleep( &(queue), PZERO | PCATCH, \ "drmwtq", (timeout) ); \ splx(s); \ } #endif #define DRM_WAKEUP( queue ) wakeup( queue ) #define DRM_WAKEUP_INT( queue ) wakeup( queue ) #define DRM_INIT_WAITQUEUE( queue ) do {} while (0) #define DRM_COPY_TO_USER_IOCTL(user, kern, size) \ if ( IOCPARM_LEN(cmd) != size) \ return EINVAL; \ *user = kern; #define DRM_COPY_FROM_USER_IOCTL(kern, user, size) \ if ( IOCPARM_LEN(cmd) != size) \ return EINVAL; \ kern = *user; #define DRM_COPY_TO_USER(user, kern, size) \ copyout(kern, user, size) #define DRM_COPY_FROM_USER(kern, user, size) \ copyin(user, kern, size) /* Macros for userspace access with checking readability once */ /* FIXME: can't find equivalent functionality for nocheck yet. * It'll be slower than linux, but should be correct. */ #define DRM_VERIFYAREA_READ( uaddr, size ) \ (!useracc((caddr_t)uaddr, size, VM_PROT_READ)) #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ copyin(arg2, arg1, arg3) #define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ copyout(arg2, arg1, arg3) #define DRM_GET_USER_UNCHECKED(val, uaddr) \ ((val) = fuword(uaddr), 0) #define DRM_PUT_USER_UNCHECKED(uaddr, val) \ suword(uaddr, val) /* DRM_READMEMORYBARRIER() prevents reordering of reads. * DRM_WRITEMEMORYBARRIER() prevents reordering of writes. * DRM_MEMORYBARRIER() prevents reordering of reads and writes. */ #if defined(__i386__) #define DRM_READMEMORYBARRIER() __asm __volatile( \ "lock; addl $0,0(%%esp)" : : : "memory"); #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); #define DRM_MEMORYBARRIER() __asm __volatile( \ "lock; addl $0,0(%%esp)" : : : "memory"); #elif defined(__alpha__) #define DRM_READMEMORYBARRIER() alpha_mb(); #define DRM_WRITEMEMORYBARRIER() alpha_wmb(); #define DRM_MEMORYBARRIER() alpha_mb(); #endif #define PAGE_ALIGN(addr) round_page(addr) #ifndef M_WAITOK /* M_WAITOK (=0) name removed in -current */ #define M_WAITOK 0 #endif #define malloctype DRM(M_DRM) /* The macros conflicted in the MALLOC_DEFINE */ MALLOC_DECLARE(malloctype); #undef malloctype #if __FreeBSD_version >= 480000 #define cpu_to_le32(x) htole32(x) #define le32_to_cpu(x) le32toh(x) #else #define cpu_to_le32(x) (x) #define le32_to_cpu(x) (x) #endif typedef unsigned long dma_addr_t; typedef u_int32_t atomic_t; typedef u_int32_t u32; typedef u_int16_t u16; typedef u_int8_t u8; #define atomic_set(p, v) (*(p) = (v)) #define atomic_read(p) (*(p)) #define atomic_inc(p) atomic_add_int(p, 1) #define atomic_dec(p) atomic_subtract_int(p, 1) #define atomic_add(n, p) atomic_add_int(p, n) #define atomic_sub(n, p) atomic_subtract_int(p, n) /* Fake this */ #if __FreeBSD_version < 500000 /* The extra atomic functions from 5.0 haven't been merged to 4.x */ static __inline int atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src) { int res = exp; __asm __volatile ( " lock ; " " cmpxchgl %1,%2 ; " " setz %%al ; " " movzbl %%al,%0 ; " "1: " "# atomic_cmpset_int" : "+a" (res) /* 0 (result) */ : "r" (src), /* 1 */ "m" (*(dst)) /* 2 */ : "memory"); return (res); } #endif static __inline atomic_t test_and_set_bit(int b, volatile void *p) { int s = splhigh(); unsigned int m = 1<<b; unsigned int r = *(volatile int *)p & m; *(volatile int *)p |= m; splx(s); return r; } static __inline void clear_bit(int b, volatile void *p) { atomic_clear_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f)); } static __inline void set_bit(int b, volatile void *p) { atomic_set_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f)); } static __inline int test_bit(int b, volatile void *p) { return ((volatile int *)p)[b >> 5] & (1 << (b & 0x1f)); } static __inline int find_first_zero_bit(volatile void *p, int max) { int b; for (b = 0; b < max; b += 32) { if (((volatile int *)p)[b >> 5] != ~0) { for (;;) { if ((((volatile int *)p)[b >> 5] & (1 << (b & 0x1f))) == 0) return b; b++; } } } return max; } #define spldrm() spltty() /* * Fake out the module macros for versions of FreeBSD where they don't * exist. */ #if (__FreeBSD_version < 500002 && __FreeBSD_version > 500000) || __FreeBSD_version < 420000 #define MODULE_VERSION(a,b) struct __hack #define MODULE_DEPEND(a,b,c,d,e) struct __hack #endif /* Redefinitions to make templating easy */ #define wait_queue_head_t atomic_t #define agp_memory void #define jiffies ticks /* Macros to make printf easier */ #define DRM_ERROR(fmt, arg...) \ printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \ DRM_CURRENTPID, __func__ , ## arg) #define DRM_MEM_ERROR(area, fmt, arg...) \ printf("error: [" DRM_NAME ":pid%d:%s:%s] *ERROR* " fmt, \ DRM_CURRENTPID , __func__, DRM(mem_stats)[area].name , ##arg) #define DRM_INFO(fmt, arg...) printf("info: [" DRM_NAME "] " fmt , ## arg) #if DRM_DEBUG_CODE #define DRM_DEBUG(fmt, arg...) \ do { \ if (DRM(flags) & DRM_FLAG_DEBUG) \ printf("[" DRM_NAME ":pid%d:%s] " fmt, \ DRM_CURRENTPID, __func__ , ## arg); \ } while (0) #else #define DRM_DEBUG(fmt, arg...) do { } while (0) #endif #if (__FreeBSD_version >= 500000) || ((__FreeBSD_version < 500000) && (__FreeBSD_version >= 410002)) #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS) #else #define DRM_SYSCTL_HANDLER_ARGS SYSCTL_HANDLER_ARGS #endif #define DRM_FIND_MAP(dest, o) \ do { \ drm_map_list_entry_t *listentry; \ TAILQ_FOREACH(listentry, dev->maplist, link) { \ if ( listentry->map->offset == o ) { \ dest = listentry->map; \ break; \ } \ } \ } while (0) /* Internal functions */ /* drm_drv.h */ extern d_ioctl_t DRM(ioctl); extern d_open_t DRM(open); extern d_close_t DRM(close); extern d_read_t DRM(read); extern d_poll_t DRM(poll); extern d_mmap_t DRM(mmap); extern int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, drm_device_t *dev); extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p); /* sysctl support (drm_sysctl.h) */ extern int DRM(sysctl_init)(drm_device_t *dev); extern int DRM(sysctl_cleanup)(drm_device_t *dev); /* Memory info sysctl (drm_memory_debug.h) */ #ifdef DEBUG_MEMORY extern int DRM(mem_info) DRM_SYSCTL_HANDLER_ARGS; #endif