aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i810
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/gpu/drm/i810
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/gpu/drm/i810')
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c40
-rw-r--r--drivers/gpu/drm/i810/i810_drv.c38
-rw-r--r--drivers/gpu/drm/i810/i810_drv.h6
3 files changed, 40 insertions, 44 deletions
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 004ecdfe1b5..8f371e8d630 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -30,8 +30,9 @@
30 * 30 *
31 */ 31 */
32 32
33#include <drm/drmP.h> 33#include "drmP.h"
34#include <drm/i810_drm.h> 34#include "drm.h"
35#include "i810_drm.h"
35#include "i810_drv.h" 36#include "i810_drv.h"
36#include <linux/interrupt.h> /* For task queue support */ 37#include <linux/interrupt.h> /* For task queue support */
37#include <linux/delay.h> 38#include <linux/delay.h>
@@ -98,6 +99,7 @@ static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
98 buf_priv = buf->dev_private; 99 buf_priv = buf->dev_private;
99 100
100 vma->vm_flags |= (VM_IO | VM_DONTCOPY); 101 vma->vm_flags |= (VM_IO | VM_DONTCOPY);
102 vma->vm_file = filp;
101 103
102 buf_priv->currently_mapped = I810_BUF_MAPPED; 104 buf_priv->currently_mapped = I810_BUF_MAPPED;
103 105
@@ -114,9 +116,6 @@ static const struct file_operations i810_buffer_fops = {
114 .unlocked_ioctl = drm_ioctl, 116 .unlocked_ioctl = drm_ioctl,
115 .mmap = i810_mmap_buffers, 117 .mmap = i810_mmap_buffers,
116 .fasync = drm_fasync, 118 .fasync = drm_fasync,
117#ifdef CONFIG_COMPAT
118 .compat_ioctl = drm_compat_ioctl,
119#endif
120 .llseek = noop_llseek, 119 .llseek = noop_llseek,
121}; 120};
122 121
@@ -131,11 +130,11 @@ static int i810_map_buffer(struct drm_buf *buf, struct drm_file *file_priv)
131 if (buf_priv->currently_mapped == I810_BUF_MAPPED) 130 if (buf_priv->currently_mapped == I810_BUF_MAPPED)
132 return -EINVAL; 131 return -EINVAL;
133 132
134 /* This is all entirely broken */ 133 down_write(&current->mm->mmap_sem);
135 old_fops = file_priv->filp->f_op; 134 old_fops = file_priv->filp->f_op;
136 file_priv->filp->f_op = &i810_buffer_fops; 135 file_priv->filp->f_op = &i810_buffer_fops;
137 dev_priv->mmap_buffer = buf; 136 dev_priv->mmap_buffer = buf;
138 buf_priv->virtual = (void *)vm_mmap(file_priv->filp, 0, buf->total, 137 buf_priv->virtual = (void *)do_mmap(file_priv->filp, 0, buf->total,
139 PROT_READ | PROT_WRITE, 138 PROT_READ | PROT_WRITE,
140 MAP_SHARED, buf->bus_address); 139 MAP_SHARED, buf->bus_address);
141 dev_priv->mmap_buffer = NULL; 140 dev_priv->mmap_buffer = NULL;
@@ -146,6 +145,7 @@ static int i810_map_buffer(struct drm_buf *buf, struct drm_file *file_priv)
146 retcode = PTR_ERR(buf_priv->virtual); 145 retcode = PTR_ERR(buf_priv->virtual);
147 buf_priv->virtual = NULL; 146 buf_priv->virtual = NULL;
148 } 147 }
148 up_write(&current->mm->mmap_sem);
149 149
150 return retcode; 150 return retcode;
151} 151}
@@ -158,8 +158,11 @@ static int i810_unmap_buffer(struct drm_buf *buf)
158 if (buf_priv->currently_mapped != I810_BUF_MAPPED) 158 if (buf_priv->currently_mapped != I810_BUF_MAPPED)
159 return -EINVAL; 159 return -EINVAL;
160 160
161 retcode = vm_munmap((unsigned long)buf_priv->virtual, 161 down_write(&current->mm->mmap_sem);
162 retcode = do_munmap(current->mm,
163 (unsigned long)buf_priv->virtual,
162 (size_t) buf->total); 164 (size_t) buf->total);
165 up_write(&current->mm->mmap_sem);
163 166
164 buf_priv->currently_mapped = I810_BUF_UNMAPPED; 167 buf_priv->currently_mapped = I810_BUF_UNMAPPED;
165 buf_priv->virtual = NULL; 168 buf_priv->virtual = NULL;
@@ -219,6 +222,8 @@ static int i810_dma_cleanup(struct drm_device *dev)
219 pci_free_consistent(dev->pdev, PAGE_SIZE, 222 pci_free_consistent(dev->pdev, PAGE_SIZE,
220 dev_priv->hw_status_page, 223 dev_priv->hw_status_page,
221 dev_priv->dma_status_page); 224 dev_priv->dma_status_page);
225 /* Need to rewrite hardware status page */
226 I810_WRITE(0x02080, 0x1ffff000);
222 } 227 }
223 kfree(dev->dev_private); 228 kfree(dev->dev_private);
224 dev->dev_private = NULL; 229 dev->dev_private = NULL;
@@ -883,7 +888,7 @@ static int i810_flush_queue(struct drm_device *dev)
883} 888}
884 889
885/* Must be called with the lock held */ 890/* Must be called with the lock held */
886void i810_driver_reclaim_buffers(struct drm_device *dev, 891static void i810_reclaim_buffers(struct drm_device *dev,
887 struct drm_file *file_priv) 892 struct drm_file *file_priv)
888{ 893{
889 struct drm_device_dma *dma = dev->dma; 894 struct drm_device_dma *dma = dev->dma;
@@ -1205,8 +1210,6 @@ int i810_driver_load(struct drm_device *dev, unsigned long flags)
1205 dev->types[8] = _DRM_STAT_SECONDARY; 1210 dev->types[8] = _DRM_STAT_SECONDARY;
1206 dev->types[9] = _DRM_STAT_DMA; 1211 dev->types[9] = _DRM_STAT_DMA;
1207 1212
1208 pci_set_master(dev->pdev);
1209
1210 return 0; 1213 return 0;
1211} 1214}
1212 1215
@@ -1222,17 +1225,12 @@ void i810_driver_preclose(struct drm_device *dev, struct drm_file *file_priv)
1222 if (dev_priv->page_flipping) 1225 if (dev_priv->page_flipping)
1223 i810_do_cleanup_pageflip(dev); 1226 i810_do_cleanup_pageflip(dev);
1224 } 1227 }
1228}
1225 1229
1226 if (file_priv->master && file_priv->master->lock.hw_lock) { 1230void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
1227 drm_idlelock_take(&file_priv->master->lock); 1231 struct drm_file *file_priv)
1228 i810_driver_reclaim_buffers(dev, file_priv); 1232{
1229 drm_idlelock_release(&file_priv->master->lock); 1233 i810_reclaim_buffers(dev, file_priv);
1230 } else {
1231 /* master disappeared, clean up stuff anyway and hope nothing
1232 * goes wrong */
1233 i810_driver_reclaim_buffers(dev, file_priv);
1234 }
1235
1236} 1234}
1237 1235
1238int i810_driver_dma_quiescent(struct drm_device *dev) 1236int i810_driver_dma_quiescent(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 2e91fc3580b..6f98d059f68 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -30,44 +30,40 @@
30 * Gareth Hughes <gareth@valinux.com> 30 * Gareth Hughes <gareth@valinux.com>
31 */ 31 */
32 32
33#include <linux/module.h> 33#include "drmP.h"
34 34#include "drm.h"
35#include <drm/drmP.h> 35#include "i810_drm.h"
36#include <drm/i810_drm.h>
37#include "i810_drv.h" 36#include "i810_drv.h"
38 37
39#include <drm/drm_pciids.h> 38#include "drm_pciids.h"
40 39
41static struct pci_device_id pciidlist[] = { 40static struct pci_device_id pciidlist[] = {
42 i810_PCI_IDS 41 i810_PCI_IDS
43}; 42};
44 43
45static const struct file_operations i810_driver_fops = {
46 .owner = THIS_MODULE,
47 .open = drm_open,
48 .release = drm_release,
49 .unlocked_ioctl = drm_ioctl,
50 .mmap = drm_mmap,
51 .poll = drm_poll,
52 .fasync = drm_fasync,
53#ifdef CONFIG_COMPAT
54 .compat_ioctl = drm_compat_ioctl,
55#endif
56 .llseek = noop_llseek,
57};
58
59static struct drm_driver driver = { 44static struct drm_driver driver = {
60 .driver_features = 45 .driver_features =
61 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | 46 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
62 DRIVER_HAVE_DMA, 47 DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE,
63 .dev_priv_size = sizeof(drm_i810_buf_priv_t), 48 .dev_priv_size = sizeof(drm_i810_buf_priv_t),
64 .load = i810_driver_load, 49 .load = i810_driver_load,
65 .lastclose = i810_driver_lastclose, 50 .lastclose = i810_driver_lastclose,
66 .preclose = i810_driver_preclose, 51 .preclose = i810_driver_preclose,
67 .device_is_agp = i810_driver_device_is_agp, 52 .device_is_agp = i810_driver_device_is_agp,
53 .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
68 .dma_quiescent = i810_driver_dma_quiescent, 54 .dma_quiescent = i810_driver_dma_quiescent,
69 .ioctls = i810_ioctls, 55 .ioctls = i810_ioctls,
70 .fops = &i810_driver_fops, 56 .fops = {
57 .owner = THIS_MODULE,
58 .open = drm_open,
59 .release = drm_release,
60 .unlocked_ioctl = drm_ioctl,
61 .mmap = drm_mmap,
62 .poll = drm_poll,
63 .fasync = drm_fasync,
64 .llseek = noop_llseek,
65 },
66
71 .name = DRIVER_NAME, 67 .name = DRIVER_NAME,
72 .desc = DRIVER_DESC, 68 .desc = DRIVER_DESC,
73 .date = DRIVER_DATE, 69 .date = DRIVER_DATE,
diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
index 6e0acad9e0f..c9339f48179 100644
--- a/drivers/gpu/drm/i810/i810_drv.h
+++ b/drivers/gpu/drm/i810/i810_drv.h
@@ -116,12 +116,14 @@ typedef struct drm_i810_private {
116 116
117 /* i810_dma.c */ 117 /* i810_dma.c */
118extern int i810_driver_dma_quiescent(struct drm_device *dev); 118extern int i810_driver_dma_quiescent(struct drm_device *dev);
119void i810_driver_reclaim_buffers(struct drm_device *dev, 119extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
120 struct drm_file *file_priv); 120 struct drm_file *file_priv);
121extern int i810_driver_load(struct drm_device *, unsigned long flags); 121extern int i810_driver_load(struct drm_device *, unsigned long flags);
122extern void i810_driver_lastclose(struct drm_device *dev); 122extern void i810_driver_lastclose(struct drm_device *dev);
123extern void i810_driver_preclose(struct drm_device *dev, 123extern void i810_driver_preclose(struct drm_device *dev,
124 struct drm_file *file_priv); 124 struct drm_file *file_priv);
125extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
126 struct drm_file *file_priv);
125extern int i810_driver_device_is_agp(struct drm_device *dev); 127extern int i810_driver_device_is_agp(struct drm_device *dev);
126 128
127extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 129extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg);