summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2002-11-06 00:53:07 +0000
committerIan Romanick <idr@us.ibm.com>2002-11-06 00:53:07 +0000
commit1a57f218a7cd358e1b91e2cb43522808411a7f2b (patch)
tree060d9ca67de9ec9ee04cacac41b93d0d247c582c /linux
parent87ac0cdb2623711f92986859d54f18864d1ea215 (diff)
Merge from trunk.
Diffstat (limited to 'linux')
-rw-r--r--linux/Makefile.linux6
-rw-r--r--linux/drm_ioctl.h17
-rw-r--r--linux/drm_os_linux.h2
-rw-r--r--linux/drm_vm.h6
-rw-r--r--linux/i810_dma.c50
-rw-r--r--linux/i810_drv.h2
-rw-r--r--linux/i830_dma.c33
-rw-r--r--linux/i830_drv.h2
8 files changed, 41 insertions, 77 deletions
diff --git a/linux/Makefile.linux b/linux/Makefile.linux
index 7c3f1db9..4505e6c1 100644
--- a/linux/Makefile.linux
+++ b/linux/Makefile.linux
@@ -44,7 +44,7 @@ LIBS =
DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \
drm_drv.h drm_fops.h drm_init.h drm_ioctl.h drm_lists.h \
drm_lock.h drm_memory.h drm_proc.h drm_stub.h drm_vm.h
-DRMHEADERS = drm.h drmP.h
+DRMHEADERS = drm.h drmP.h drm_sarea.h
GAMMAOBJS = gamma_drv.o gamma_dma.o
GAMMAHEADERS = gamma_drv.h $(DRMHEADERS) $(DRMTEMPLATES)
@@ -52,7 +52,7 @@ GAMMAHEADERS = gamma_drv.h $(DRMHEADERS) $(DRMTEMPLATES)
TDFXOBJS = tdfx_drv.o
TDFXHEADERS = tdfx.h $(DRMHEADERS) $(DRMTEMPLATES)
-R128OBJS = r128_drv.o r128_cce.o r128_state.o
+R128OBJS = r128_drv.o r128_cce.o r128_state.o r128_irq.o
R128HEADERS = r128.h r128_drv.h r128_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
RADEONOBJS = radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o
@@ -158,7 +158,7 @@ MODS += i810.o
MODS += i830.o
endif
-MGAOBJS = mga_drv.o mga_dma.o mga_state.o mga_warp.o
+MGAOBJS = mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
MGAHEADERS = mga.h mga_drv.h mga_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
I810OBJS = i810_drv.o i810_dma.o
diff --git a/linux/drm_ioctl.h b/linux/drm_ioctl.h
index 0d8a1259..01604e75 100644
--- a/linux/drm_ioctl.h
+++ b/linux/drm_ioctl.h
@@ -32,6 +32,7 @@
#define __NO_VERSION__
#include "drmP.h"
+
int DRM(irq_busid)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
@@ -41,8 +42,20 @@ int DRM(irq_busid)(struct inode *inode, struct file *filp,
if (copy_from_user(&p, (drm_irq_busid_t *)arg, sizeof(p)))
return -EFAULT;
dev = pci_find_slot(p.busnum, PCI_DEVFN(p.devnum, p.funcnum));
- if (dev) p.irq = dev->irq;
- else p.irq = 0;
+ if (!dev) {
+ DRM_ERROR("pci_find_slot failed for %d:%d:%d\n",
+ p.busnum, p.devnum, p.funcnum);
+ p.irq = 0;
+ goto out;
+ }
+ if (pci_enable_device(dev) != 0) {
+ DRM_ERROR("pci_enable_device failed for %d:%d:%d\n",
+ p.busnum, p.devnum, p.funcnum);
+ p.irq = 0;
+ goto out;
+ }
+ p.irq = dev->irq;
+ out:
DRM_DEBUG("%d:%d:%d => IRQ %d\n",
p.busnum, p.devnum, p.funcnum, p.irq);
if (copy_to_user((drm_irq_busid_t *)arg, &p, sizeof(p)))
diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h
index cf003137..e9b24356 100644
--- a/linux/drm_os_linux.h
+++ b/linux/drm_os_linux.h
@@ -74,7 +74,7 @@ do { \
ret = -EBUSY; \
break; \
} \
- schedule_timeout(max(HZ/100,1)); \
+ schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
if (signal_pending(current)) { \
ret = -EINTR; \
break; \
diff --git a/linux/drm_vm.h b/linux/drm_vm.h
index 52dfd594..683c0857 100644
--- a/linux/drm_vm.h
+++ b/linux/drm_vm.h
@@ -71,7 +71,7 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
* Find the right map
*/
- if(!dev->agp->cant_use_aperture) goto vm_nopage_error;
+ if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list;
@@ -408,7 +408,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) {
vma->vm_flags &= VM_MAYWRITE;
-#if defined(__i386__)
+#if defined(__i386__) || defined(__x86_64__)
pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
#else
/* Ye gads this is ugly. With more thought
@@ -435,7 +435,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS:
if (VM_OFFSET(vma) >= __pa(high_memory)) {
-#if defined(__i386__)
+#if defined(__i386__) || defined(__x86_64__)
if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) {
pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
pgprot_val(vma->vm_page_prot) &= ~_PAGE_PWT;
diff --git a/linux/i810_dma.c b/linux/i810_dma.c
index 94379bb7..13f5f64f 100644
--- a/linux/i810_dma.c
+++ b/linux/i810_dma.c
@@ -26,7 +26,7 @@
*
* Authors: Rickard E. (Rik) Faith <faith@valinux.com>
* Jeff Hartmann <jhartmann@valinux.com>
- * Keith Whitwell <keith_whitwell@yahoo.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
*
*/
@@ -269,44 +269,6 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d,
return retcode;
}
-static unsigned long i810_alloc_page(drm_device_t *dev)
-{
- unsigned long address;
-
- address = __get_free_page(GFP_KERNEL);
- if(address == 0UL)
- return 0;
-
-#if LINUX_VERSION_CODE < 0x020409
- atomic_inc(&virt_to_page(address)->count);
- set_bit(PG_locked, &virt_to_page(address)->flags);
-#else
- get_page(virt_to_page(address));
-#if LINUX_VERSION_CODE < 0x020500
- LockPage(virt_to_page(address));
-#else
- SetPageLocked(virt_to_page(address));
-#endif
-#endif
- return address;
-}
-
-static void i810_free_page(drm_device_t *dev, unsigned long page)
-{
- if (page) {
-#if LINUX_VERSION_CODE < 0x020409
- atomic_dec(&virt_to_page(page)->count);
- clear_bit(PG_locked, &virt_to_page(page)->flags);
- wake_up(&virt_to_page(page)->wait);
-#else
- struct page *p = virt_to_page(page);
- put_page(p);
- unlock_page(p);
-#endif
- free_page(page);
- }
-}
-
static int i810_dma_cleanup(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
@@ -321,7 +283,9 @@ static int i810_dma_cleanup(drm_device_t *dev)
dev_priv->ring.Size);
}
if(dev_priv->hw_status_page != 0UL) {
- i810_free_page(dev, dev_priv->hw_status_page);
+ pci_free_consistent(dev->pdev, PAGE_SIZE,
+ (void *)dev_priv->hw_status_page,
+ dev_priv->dma_status_page);
/* Need to rewrite hardware status page */
I810_WRITE(0x02080, 0x1ffff000);
}
@@ -481,7 +445,9 @@ static int i810_dma_initialize(drm_device_t *dev,
dev_priv->zi1 = init->depth_offset | init->pitch_bits;
/* Program Hardware Status Page */
- dev_priv->hw_status_page = i810_alloc_page(dev);
+ dev_priv->hw_status_page =
+ (unsigned long) pci_alloc_consistent(dev->pdev, PAGE_SIZE,
+ &dev_priv->dma_status_page);
if(dev_priv->hw_status_page == 0UL) {
dev->dev_private = (void *)dev_priv;
i810_dma_cleanup(dev);
@@ -491,7 +457,7 @@ static int i810_dma_initialize(drm_device_t *dev,
memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE);
DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page);
- I810_WRITE(0x02080, virt_to_bus((void *)dev_priv->hw_status_page));
+ I810_WRITE(0x02080, dev_priv->dma_status_page);
DRM_DEBUG("Enabled hardware status page\n");
/* Now we need to init our freelist */
diff --git a/linux/i810_drv.h b/linux/i810_drv.h
index 99165cf8..106abf56 100644
--- a/linux/i810_drv.h
+++ b/linux/i810_drv.h
@@ -64,6 +64,8 @@ typedef struct drm_i810_private {
unsigned long hw_status_page;
unsigned long counter;
+ dma_addr_t dma_status_page;
+
drm_buf_t *mmap_buffer;
diff --git a/linux/i830_dma.c b/linux/i830_dma.c
index 70884373..d29e21cb 100644
--- a/linux/i830_dma.c
+++ b/linux/i830_dma.c
@@ -272,29 +272,6 @@ static int i830_dma_get_buffer(drm_device_t *dev, drm_i830_dma_t *d,
return retcode;
}
-static unsigned long i830_alloc_page(drm_device_t *dev)
-{
- unsigned long address;
-
- address = __get_free_page(GFP_KERNEL);
- if(address == 0UL)
- return 0;
-
- get_page(virt_to_page(address));
- LockPage(virt_to_page(address));
- return address;
-}
-
-static void i830_free_page(drm_device_t *dev, unsigned long page)
-{
- if (page) {
- struct page *p = virt_to_page(page);
- put_page(p);
- UnlockPage(p);
- free_page(page);
- }
-}
-
static int i830_dma_cleanup(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
@@ -309,7 +286,9 @@ static int i830_dma_cleanup(drm_device_t *dev)
dev_priv->ring.Size);
}
if(dev_priv->hw_status_page != 0UL) {
- i830_free_page(dev, dev_priv->hw_status_page);
+ pci_free_consistent(dev->pdev, PAGE_SIZE,
+ (void *)dev_priv->hw_status_page,
+ dev_priv->dma_status_page);
/* Need to rewrite hardware status page */
I830_WRITE(0x02080, 0x1ffff000);
}
@@ -483,7 +462,9 @@ static int i830_dma_initialize(drm_device_t *dev,
dev_priv->depth_pitch = init->depth_pitch;
/* Program Hardware Status Page */
- dev_priv->hw_status_page = i830_alloc_page(dev);
+ dev_priv->hw_status_page =
+ (unsigned long) pci_alloc_consistent(dev->pdev, PAGE_SIZE,
+ &dev_priv->dma_status_page);
if(dev_priv->hw_status_page == 0UL) {
dev->dev_private = (void *)dev_priv;
i830_dma_cleanup(dev);
@@ -493,7 +474,7 @@ static int i830_dma_initialize(drm_device_t *dev,
memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE);
DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page);
- I830_WRITE(0x02080, virt_to_bus((void *)dev_priv->hw_status_page));
+ I830_WRITE(0x02080, dev_priv->dma_status_page);
DRM_DEBUG("Enabled hardware status page\n");
/* Now we need to init our freelist */
diff --git a/linux/i830_drv.h b/linux/i830_drv.h
index 527d0ce3..eec640ca 100644
--- a/linux/i830_drv.h
+++ b/linux/i830_drv.h
@@ -64,6 +64,8 @@ typedef struct drm_i830_private {
unsigned long hw_status_page;
unsigned long counter;
+ dma_addr_t dma_status_page;
+
drm_buf_t *mmap_buffer;
u32 front_di1, back_di1, zi1;