some more

This commit is contained in:
Alan Hourihane 2001-04-30 17:11:39 +00:00
parent d8e2b6fdc9
commit 74c759d20b
15 changed files with 145 additions and 28 deletions

View file

@ -28,6 +28,8 @@
#include <pci/agpvar.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
@ -235,6 +237,9 @@ extern d_ioctl_t DRM(finish);
extern d_ioctl_t DRM(addmap);
extern d_ioctl_t DRM(rmmap);
#if __HAVE_DMA
extern d_ioctl_t DRM(addbufs_agp);
extern d_ioctl_t DRM(addbufs_pci);
extern d_ioctl_t DRM(addbufs_sg);
extern d_ioctl_t DRM(addbufs);
extern d_ioctl_t DRM(infobufs);
extern d_ioctl_t DRM(markbufs);

View file

@ -28,6 +28,8 @@
#include <pci/agpvar.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
@ -235,6 +237,9 @@ extern d_ioctl_t DRM(finish);
extern d_ioctl_t DRM(addmap);
extern d_ioctl_t DRM(rmmap);
#if __HAVE_DMA
extern d_ioctl_t DRM(addbufs_agp);
extern d_ioctl_t DRM(addbufs_pci);
extern d_ioctl_t DRM(addbufs_sg);
extern d_ioctl_t DRM(addbufs);
extern d_ioctl_t DRM(infobufs);
extern d_ioctl_t DRM(markbufs);

View file

@ -82,7 +82,6 @@
#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
#define DRM_LOOPING_LIMIT 5000000
#define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
#define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
#define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
#define DRM_FLAG_DEBUG 0x01

View file

@ -33,6 +33,14 @@
#ifdef __linux__
#include <linux/vmalloc.h>
#endif
#ifdef __FreeBSD__
#include <machine/param.h>
#include <sys/mman.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
#endif
#include "drmP.h"
#ifndef __HAVE_PCI_DMA
@ -998,8 +1006,12 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
drm_device_dma_t *dma = dev->dma;
int retcode = 0;
const int zero = 0;
unsigned long virtual;
unsigned long address;
#ifdef __linux__
unsigned long virtual, address;
#endif
#ifdef __FreeBSD__
vm_offset_t virtual, address;
#endif
drm_buf_map_t request;
int i;
@ -1021,7 +1033,7 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
drm_map_t *map = DRIVER_AGP_BUFFERS_MAP( dev );
if ( !map ) {
retcode = -EINVAL;
retcode = EINVAL;
goto done;
}
@ -1030,19 +1042,27 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
down( &current->mm->mmap_sem );
#else
down_write( &current->mm->mmap_sem );
#endif
#endif
virtual = do_mmap( filp, 0, map->size,
PROT_READ | PROT_WRITE,
MAP_SHARED,
(unsigned long)map->offset );
#ifdef __linux__
#if LINUX_VERSION_CODE <= 0x020402
up( &current->mm->mmap_sem );
#else
up_write( &current->mm->mmap_sem );
#endif
#endif
#ifdef __FreeBSD__
retcode = vm_mmap(&p->p_vmspace->vm_map,
&virtual,
round_page(dma->byte_count),
PROT_READ|PROT_WRITE, VM_PROT_ALL,
MAP_SHARED,
SLIST_FIRST(&kdev->si_hlist),
(unsigned long)map->offset );
#endif
} else {
#ifdef __linux__
@ -1050,25 +1070,38 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
down( &current->mm->mmap_sem );
#else
down_write( &current->mm->mmap_sem );
#endif
#endif
virtual = do_mmap( filp, 0, dma->byte_count,
PROT_READ | PROT_WRITE,
MAP_SHARED, 0 );
#ifdef __linux__
#if LINUX_VERSION_CODE <= 0x020402
up( &current->mm->mmap_sem );
#else
up_write( &current->mm->mmap_sem );
#endif
#endif
#ifdef __FreeBSD__
retcode = vm_mmap(&p->p_vmspace->vm_map,
&virtual,
round_page(dma->byte_count),
PROT_READ|PROT_WRITE, VM_PROT_ALL,
MAP_SHARED,
SLIST_FIRST(&kdev->si_hlist),
0);
#endif
}
#ifdef __linux__
if ( virtual > -1024UL ) {
/* Real error */
retcode = (signed long)virtual;
goto done;
}
#endif
#ifdef __FreeBSD__
if (retcode)
goto done;
#endif
request.virtual = (void *)virtual;
for ( i = 0 ; i < dma->buf_count ; i++ ) {

View file

@ -468,7 +468,12 @@ int DRM(context_switch_complete)(drm_device_t *dev, int new)
#endif
clear_bit(0, &dev->context_flag);
#ifdef __linux__
wake_up_interruptible(&dev->context_wait);
#endif
#ifdef __FreeBSD__
wakeup( &dev->context_wait );
#endif
return 0;
}
@ -480,10 +485,10 @@ static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
if (atomic_read(&q->use_count) != 1
|| atomic_read(&q->finalization)
|| atomic_read(&q->block_count)) {
DRM_ERROR("New queue is already in use: u%d f%d b%d\n",
atomic_read(&q->use_count),
atomic_read(&q->finalization),
atomic_read(&q->block_count));
DRM_ERROR("New queue is already in use: u%ld f%ld b%ld\n",
(unsigned long)atomic_read(&q->use_count),
(unsigned long)atomic_read(&q->finalization),
(unsigned long)atomic_read(&q->block_count));
}
atomic_set(&q->finalization, 0);
@ -494,9 +499,16 @@ static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
atomic_set(&q->total_flushed, 0);
atomic_set(&q->total_locks, 0);
#ifdef __linux__
init_waitqueue_head(&q->write_queue);
init_waitqueue_head(&q->read_queue);
init_waitqueue_head(&q->flush_queue);
#endif
#ifdef __FreeBSD__
q->write_queue = 0;
q->read_queue = 0;
q->flush_queue = 0;
#endif
q->flags = ctx->flags;

View file

@ -188,9 +188,17 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->time_completed = get_cycles();
#endif
#ifdef __linux__
if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait);
}
#endif
#ifdef __FreeBSD__
if ( buf->dma_wait ) {
wakeup( &buf->dma_wait );
buf->dma_wait = 0;
}
#endif
#if __HAVE_DMA_FREELIST
else {
drm_device_dma_t *dma = dev->dma;

View file

@ -310,7 +310,7 @@ unsigned long DRM(alloc_pages)(int order, int area)
#ifdef __linux__
unsigned long address;
#endif
#ifdef __FreeBSD_
#ifdef __FreeBSD__
vm_offset_t address;
#endif
unsigned long bytes = PAGE_SIZE << order;

View file

@ -40,6 +40,8 @@
#endif
#include <asm/pgalloc.h>
#define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
/* Wait queue declarations changed in 2.3.1 */
#ifndef DECLARE_WAITQUEUE
#define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }

View file

@ -82,7 +82,6 @@
#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
#define DRM_LOOPING_LIMIT 5000000
#define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
#define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
#define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
#define DRM_FLAG_DEBUG 0x01

View file

@ -33,6 +33,14 @@
#ifdef __linux__
#include <linux/vmalloc.h>
#endif
#ifdef __FreeBSD__
#include <machine/param.h>
#include <sys/mman.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
#endif
#include "drmP.h"
#ifndef __HAVE_PCI_DMA
@ -998,8 +1006,12 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
drm_device_dma_t *dma = dev->dma;
int retcode = 0;
const int zero = 0;
unsigned long virtual;
unsigned long address;
#ifdef __linux__
unsigned long virtual, address;
#endif
#ifdef __FreeBSD__
vm_offset_t virtual, address;
#endif
drm_buf_map_t request;
int i;
@ -1021,7 +1033,7 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
drm_map_t *map = DRIVER_AGP_BUFFERS_MAP( dev );
if ( !map ) {
retcode = -EINVAL;
retcode = EINVAL;
goto done;
}
@ -1030,19 +1042,27 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
down( &current->mm->mmap_sem );
#else
down_write( &current->mm->mmap_sem );
#endif
#endif
virtual = do_mmap( filp, 0, map->size,
PROT_READ | PROT_WRITE,
MAP_SHARED,
(unsigned long)map->offset );
#ifdef __linux__
#if LINUX_VERSION_CODE <= 0x020402
up( &current->mm->mmap_sem );
#else
up_write( &current->mm->mmap_sem );
#endif
#endif
#ifdef __FreeBSD__
retcode = vm_mmap(&p->p_vmspace->vm_map,
&virtual,
round_page(dma->byte_count),
PROT_READ|PROT_WRITE, VM_PROT_ALL,
MAP_SHARED,
SLIST_FIRST(&kdev->si_hlist),
(unsigned long)map->offset );
#endif
} else {
#ifdef __linux__
@ -1050,25 +1070,38 @@ int DRM(mapbufs)( DRM_OS_IOCTL )
down( &current->mm->mmap_sem );
#else
down_write( &current->mm->mmap_sem );
#endif
#endif
virtual = do_mmap( filp, 0, dma->byte_count,
PROT_READ | PROT_WRITE,
MAP_SHARED, 0 );
#ifdef __linux__
#if LINUX_VERSION_CODE <= 0x020402
up( &current->mm->mmap_sem );
#else
up_write( &current->mm->mmap_sem );
#endif
#endif
#ifdef __FreeBSD__
retcode = vm_mmap(&p->p_vmspace->vm_map,
&virtual,
round_page(dma->byte_count),
PROT_READ|PROT_WRITE, VM_PROT_ALL,
MAP_SHARED,
SLIST_FIRST(&kdev->si_hlist),
0);
#endif
}
#ifdef __linux__
if ( virtual > -1024UL ) {
/* Real error */
retcode = (signed long)virtual;
goto done;
}
#endif
#ifdef __FreeBSD__
if (retcode)
goto done;
#endif
request.virtual = (void *)virtual;
for ( i = 0 ; i < dma->buf_count ; i++ ) {

View file

@ -468,7 +468,12 @@ int DRM(context_switch_complete)(drm_device_t *dev, int new)
#endif
clear_bit(0, &dev->context_flag);
#ifdef __linux__
wake_up_interruptible(&dev->context_wait);
#endif
#ifdef __FreeBSD__
wakeup( &dev->context_wait );
#endif
return 0;
}
@ -480,10 +485,10 @@ static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
if (atomic_read(&q->use_count) != 1
|| atomic_read(&q->finalization)
|| atomic_read(&q->block_count)) {
DRM_ERROR("New queue is already in use: u%d f%d b%d\n",
atomic_read(&q->use_count),
atomic_read(&q->finalization),
atomic_read(&q->block_count));
DRM_ERROR("New queue is already in use: u%ld f%ld b%ld\n",
(unsigned long)atomic_read(&q->use_count),
(unsigned long)atomic_read(&q->finalization),
(unsigned long)atomic_read(&q->block_count));
}
atomic_set(&q->finalization, 0);
@ -494,9 +499,16 @@ static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
atomic_set(&q->total_flushed, 0);
atomic_set(&q->total_locks, 0);
#ifdef __linux__
init_waitqueue_head(&q->write_queue);
init_waitqueue_head(&q->read_queue);
init_waitqueue_head(&q->flush_queue);
#endif
#ifdef __FreeBSD__
q->write_queue = 0;
q->read_queue = 0;
q->flush_queue = 0;
#endif
q->flags = ctx->flags;

View file

@ -188,9 +188,17 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->time_completed = get_cycles();
#endif
#ifdef __linux__
if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait);
}
#endif
#ifdef __FreeBSD__
if ( buf->dma_wait ) {
wakeup( &buf->dma_wait );
buf->dma_wait = 0;
}
#endif
#if __HAVE_DMA_FREELIST
else {
drm_device_dma_t *dma = dev->dma;

View file

@ -310,7 +310,7 @@ unsigned long DRM(alloc_pages)(int order, int area)
#ifdef __linux__
unsigned long address;
#endif
#ifdef __FreeBSD_
#ifdef __FreeBSD__
vm_offset_t address;
#endif
unsigned long bytes = PAGE_SIZE << order;

View file

@ -40,6 +40,8 @@
#endif
#include <asm/pgalloc.h>
#define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
/* Wait queue declarations changed in 2.3.1 */
#ifndef DECLARE_WAITQUEUE
#define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }

View file

@ -58,8 +58,7 @@ extern void gamma_dma_quiescent_dual(drm_device_t *dev);
/* gamma_dma.c */
extern int gamma_dma_schedule(drm_device_t *dev, int locked);
extern int gamma_dma(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int gamma_dma( DRM_OS_IOCTL );
extern int gamma_find_devices(void);
extern int gamma_found(void);