aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/drm/ati_pcigart.c91
-rw-r--r--drivers/char/drm/drmP.h3
-rw-r--r--drivers/char/drm/drm_fops.c7
-rw-r--r--drivers/char/drm/drm_lock.c35
-rw-r--r--drivers/char/drm/drm_pciids.h7
-rw-r--r--drivers/char/drm/r128_cce.c1
-rw-r--r--drivers/char/drm/radeon_cp.c1
-rw-r--r--drivers/char/drm/via_dma.c59
-rw-r--r--drivers/char/drm/via_dmablit.c2
-rw-r--r--drivers/char/nozomi.c61
-rw-r--r--drivers/char/riscom8.c8
11 files changed, 154 insertions, 121 deletions
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index d352dbb4ccf7..e5a0e97cfdda 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -35,42 +35,23 @@
35 35
36# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ 36# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
37 37
38static void *drm_ati_alloc_pcigart_table(int order) 38static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
39 struct drm_ati_pcigart_info *gart_info)
39{ 40{
40 unsigned long address; 41 gart_info->table_handle = drm_pci_alloc(dev, gart_info->table_size,
41 struct page *page; 42 PAGE_SIZE,
42 int i; 43 gart_info->table_mask);
43 44 if (gart_info->table_handle == NULL)
44 DRM_DEBUG("%d order\n", order); 45 return -ENOMEM;
45
46 address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
47 order);
48 if (address == 0UL) {
49 return NULL;
50 }
51
52 page = virt_to_page(address);
53 46
54 for (i = 0; i < order; i++, page++) 47 return 0;
55 SetPageReserved(page);
56
57 DRM_DEBUG("returning 0x%08lx\n", address);
58 return (void *)address;
59} 48}
60 49
61static void drm_ati_free_pcigart_table(void *address, int order) 50static void drm_ati_free_pcigart_table(struct drm_device *dev,
51 struct drm_ati_pcigart_info *gart_info)
62{ 52{
63 struct page *page; 53 drm_pci_free(dev, gart_info->table_handle);
64 int i; 54 gart_info->table_handle = NULL;
65 int num_pages = 1 << order;
66 DRM_DEBUG("\n");
67
68 page = virt_to_page((unsigned long)address);
69
70 for (i = 0; i < num_pages; i++, page++)
71 ClearPageReserved(page);
72
73 free_pages((unsigned long)address, order);
74} 55}
75 56
76int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) 57int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
@@ -78,8 +59,7 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
78 struct drm_sg_mem *entry = dev->sg; 59 struct drm_sg_mem *entry = dev->sg;
79 unsigned long pages; 60 unsigned long pages;
80 int i; 61 int i;
81 int order; 62 int max_pages;
82 int num_pages, max_pages;
83 63
84 /* we need to support large memory configurations */ 64 /* we need to support large memory configurations */
85 if (!entry) { 65 if (!entry) {
@@ -87,15 +67,7 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
87 return 0; 67 return 0;
88 } 68 }
89 69
90 order = drm_order((gart_info->table_size + (PAGE_SIZE-1)) / PAGE_SIZE);
91 num_pages = 1 << order;
92
93 if (gart_info->bus_addr) { 70 if (gart_info->bus_addr) {
94 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
95 pci_unmap_single(dev->pdev, gart_info->bus_addr,
96 num_pages * PAGE_SIZE,
97 PCI_DMA_TODEVICE);
98 }
99 71
100 max_pages = (gart_info->table_size / sizeof(u32)); 72 max_pages = (gart_info->table_size / sizeof(u32));
101 pages = (entry->pages <= max_pages) 73 pages = (entry->pages <= max_pages)
@@ -112,10 +84,9 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
112 gart_info->bus_addr = 0; 84 gart_info->bus_addr = 0;
113 } 85 }
114 86
115 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN 87 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN &&
116 && gart_info->addr) { 88 gart_info->table_handle) {
117 drm_ati_free_pcigart_table(gart_info->addr, order); 89 drm_ati_free_pcigart_table(dev, gart_info);
118 gart_info->addr = NULL;
119 } 90 }
120 91
121 return 1; 92 return 1;
@@ -127,11 +98,10 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
127 struct drm_sg_mem *entry = dev->sg; 98 struct drm_sg_mem *entry = dev->sg;
128 void *address = NULL; 99 void *address = NULL;
129 unsigned long pages; 100 unsigned long pages;
130 u32 *pci_gart, page_base, bus_address = 0; 101 u32 *pci_gart, page_base;
102 dma_addr_t bus_address = 0;
131 int i, j, ret = 0; 103 int i, j, ret = 0;
132 int order;
133 int max_pages; 104 int max_pages;
134 int num_pages;
135 105
136 if (!entry) { 106 if (!entry) {
137 DRM_ERROR("no scatter/gather memory!\n"); 107 DRM_ERROR("no scatter/gather memory!\n");
@@ -141,31 +111,14 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
141 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { 111 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
142 DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n"); 112 DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n");
143 113
144 order = drm_order((gart_info->table_size + 114 ret = drm_ati_alloc_pcigart_table(dev, gart_info);
145 (PAGE_SIZE-1)) / PAGE_SIZE); 115 if (ret) {
146 num_pages = 1 << order;
147 address = drm_ati_alloc_pcigart_table(order);
148 if (!address) {
149 DRM_ERROR("cannot allocate PCI GART page!\n"); 116 DRM_ERROR("cannot allocate PCI GART page!\n");
150 goto done; 117 goto done;
151 } 118 }
152 119
153 if (!dev->pdev) { 120 address = gart_info->table_handle->vaddr;
154 DRM_ERROR("PCI device unknown!\n"); 121 bus_address = gart_info->table_handle->busaddr;
155 goto done;
156 }
157
158 bus_address = pci_map_single(dev->pdev, address,
159 num_pages * PAGE_SIZE,
160 PCI_DMA_TODEVICE);
161 if (bus_address == 0) {
162 DRM_ERROR("unable to map PCIGART pages!\n");
163 order = drm_order((gart_info->table_size +
164 (PAGE_SIZE-1)) / PAGE_SIZE);
165 drm_ati_free_pcigart_table(address, order);
166 address = NULL;
167 goto done;
168 }
169 } else { 122 } else {
170 address = gart_info->addr; 123 address = gart_info->addr;
171 bus_address = gart_info->bus_addr; 124 bus_address = gart_info->bus_addr;
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index a6789f25009b..8ea9dd1717a9 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -54,6 +54,7 @@
54#include <linux/pci.h> 54#include <linux/pci.h>
55#include <linux/jiffies.h> 55#include <linux/jiffies.h>
56#include <linux/smp_lock.h> /* For (un)lock_kernel */ 56#include <linux/smp_lock.h> /* For (un)lock_kernel */
57#include <linux/dma-mapping.h>
57#include <linux/mm.h> 58#include <linux/mm.h>
58#include <linux/cdev.h> 59#include <linux/cdev.h>
59#include <linux/mutex.h> 60#include <linux/mutex.h>
@@ -551,6 +552,8 @@ struct drm_ati_pcigart_info {
551 int gart_reg_if; 552 int gart_reg_if;
552 void *addr; 553 void *addr;
553 dma_addr_t bus_addr; 554 dma_addr_t bus_addr;
555 dma_addr_t table_mask;
556 struct drm_dma_handle *table_handle;
554 drm_local_map_t mapping; 557 drm_local_map_t mapping;
555 int table_size; 558 int table_size;
556}; 559};
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 3992f73299cc..f09d4b5002b0 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -326,6 +326,7 @@ int drm_release(struct inode *inode, struct file *filp)
326 struct drm_file *file_priv = filp->private_data; 326 struct drm_file *file_priv = filp->private_data;
327 struct drm_device *dev = file_priv->head->dev; 327 struct drm_device *dev = file_priv->head->dev;
328 int retcode = 0; 328 int retcode = 0;
329 unsigned long irqflags;
329 330
330 lock_kernel(); 331 lock_kernel();
331 332
@@ -357,9 +358,11 @@ int drm_release(struct inode *inode, struct file *filp)
357 */ 358 */
358 359
359 do{ 360 do{
360 spin_lock(&dev->lock.spinlock); 361 spin_lock_irqsave(&dev->lock.spinlock,
362 irqflags);
361 locked = dev->lock.idle_has_lock; 363 locked = dev->lock.idle_has_lock;
362 spin_unlock(&dev->lock.spinlock); 364 spin_unlock_irqrestore(&dev->lock.spinlock,
365 irqflags);
363 if (locked) 366 if (locked)
364 break; 367 break;
365 schedule(); 368 schedule();
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index bea2a7d5b2b2..12dcdd1832f0 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -53,6 +53,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
53 DECLARE_WAITQUEUE(entry, current); 53 DECLARE_WAITQUEUE(entry, current);
54 struct drm_lock *lock = data; 54 struct drm_lock *lock = data;
55 int ret = 0; 55 int ret = 0;
56 unsigned long irqflags;
56 57
57 ++file_priv->lock_count; 58 ++file_priv->lock_count;
58 59
@@ -71,9 +72,9 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
71 return -EINVAL; 72 return -EINVAL;
72 73
73 add_wait_queue(&dev->lock.lock_queue, &entry); 74 add_wait_queue(&dev->lock.lock_queue, &entry);
74 spin_lock(&dev->lock.spinlock); 75 spin_lock_irqsave(&dev->lock.spinlock, irqflags);
75 dev->lock.user_waiters++; 76 dev->lock.user_waiters++;
76 spin_unlock(&dev->lock.spinlock); 77 spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
77 for (;;) { 78 for (;;) {
78 __set_current_state(TASK_INTERRUPTIBLE); 79 __set_current_state(TASK_INTERRUPTIBLE);
79 if (!dev->lock.hw_lock) { 80 if (!dev->lock.hw_lock) {
@@ -95,9 +96,9 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
95 break; 96 break;
96 } 97 }
97 } 98 }
98 spin_lock(&dev->lock.spinlock); 99 spin_lock_irqsave(&dev->lock.spinlock, irqflags);
99 dev->lock.user_waiters--; 100 dev->lock.user_waiters--;
100 spin_unlock(&dev->lock.spinlock); 101 spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
101 __set_current_state(TASK_RUNNING); 102 __set_current_state(TASK_RUNNING);
102 remove_wait_queue(&dev->lock.lock_queue, &entry); 103 remove_wait_queue(&dev->lock.lock_queue, &entry);
103 104
@@ -198,8 +199,9 @@ int drm_lock_take(struct drm_lock_data *lock_data,
198{ 199{
199 unsigned int old, new, prev; 200 unsigned int old, new, prev;
200 volatile unsigned int *lock = &lock_data->hw_lock->lock; 201 volatile unsigned int *lock = &lock_data->hw_lock->lock;
202 unsigned long irqflags;
201 203
202 spin_lock(&lock_data->spinlock); 204 spin_lock_irqsave(&lock_data->spinlock, irqflags);
203 do { 205 do {
204 old = *lock; 206 old = *lock;
205 if (old & _DRM_LOCK_HELD) 207 if (old & _DRM_LOCK_HELD)
@@ -211,7 +213,7 @@ int drm_lock_take(struct drm_lock_data *lock_data,
211 } 213 }
212 prev = cmpxchg(lock, old, new); 214 prev = cmpxchg(lock, old, new);
213 } while (prev != old); 215 } while (prev != old);
214 spin_unlock(&lock_data->spinlock); 216 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
215 217
216 if (_DRM_LOCKING_CONTEXT(old) == context) { 218 if (_DRM_LOCKING_CONTEXT(old) == context) {
217 if (old & _DRM_LOCK_HELD) { 219 if (old & _DRM_LOCK_HELD) {
@@ -272,15 +274,16 @@ int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
272{ 274{
273 unsigned int old, new, prev; 275 unsigned int old, new, prev;
274 volatile unsigned int *lock = &lock_data->hw_lock->lock; 276 volatile unsigned int *lock = &lock_data->hw_lock->lock;
277 unsigned long irqflags;
275 278
276 spin_lock(&lock_data->spinlock); 279 spin_lock_irqsave(&lock_data->spinlock, irqflags);
277 if (lock_data->kernel_waiters != 0) { 280 if (lock_data->kernel_waiters != 0) {
278 drm_lock_transfer(lock_data, 0); 281 drm_lock_transfer(lock_data, 0);
279 lock_data->idle_has_lock = 1; 282 lock_data->idle_has_lock = 1;
280 spin_unlock(&lock_data->spinlock); 283 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
281 return 1; 284 return 1;
282 } 285 }
283 spin_unlock(&lock_data->spinlock); 286 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
284 287
285 do { 288 do {
286 old = *lock; 289 old = *lock;
@@ -344,19 +347,20 @@ static int drm_notifier(void *priv)
344void drm_idlelock_take(struct drm_lock_data *lock_data) 347void drm_idlelock_take(struct drm_lock_data *lock_data)
345{ 348{
346 int ret = 0; 349 int ret = 0;
350 unsigned long irqflags;
347 351
348 spin_lock(&lock_data->spinlock); 352 spin_lock_irqsave(&lock_data->spinlock, irqflags);
349 lock_data->kernel_waiters++; 353 lock_data->kernel_waiters++;
350 if (!lock_data->idle_has_lock) { 354 if (!lock_data->idle_has_lock) {
351 355
352 spin_unlock(&lock_data->spinlock); 356 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
353 ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT); 357 ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT);
354 spin_lock(&lock_data->spinlock); 358 spin_lock_irqsave(&lock_data->spinlock, irqflags);
355 359
356 if (ret == 1) 360 if (ret == 1)
357 lock_data->idle_has_lock = 1; 361 lock_data->idle_has_lock = 1;
358 } 362 }
359 spin_unlock(&lock_data->spinlock); 363 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
360} 364}
361EXPORT_SYMBOL(drm_idlelock_take); 365EXPORT_SYMBOL(drm_idlelock_take);
362 366
@@ -364,8 +368,9 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
364{ 368{
365 unsigned int old, prev; 369 unsigned int old, prev;
366 volatile unsigned int *lock = &lock_data->hw_lock->lock; 370 volatile unsigned int *lock = &lock_data->hw_lock->lock;
371 unsigned long irqflags;
367 372
368 spin_lock(&lock_data->spinlock); 373 spin_lock_irqsave(&lock_data->spinlock, irqflags);
369 if (--lock_data->kernel_waiters == 0) { 374 if (--lock_data->kernel_waiters == 0) {
370 if (lock_data->idle_has_lock) { 375 if (lock_data->idle_has_lock) {
371 do { 376 do {
@@ -376,7 +381,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
376 lock_data->idle_has_lock = 0; 381 lock_data->idle_has_lock = 0;
377 } 382 }
378 } 383 }
379 spin_unlock(&lock_data->spinlock); 384 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
380} 385}
381EXPORT_SYMBOL(drm_idlelock_release); 386EXPORT_SYMBOL(drm_idlelock_release);
382 387
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 715b361f0c2b..a6a499f97e22 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -205,9 +205,9 @@
205 {0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 205 {0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
206 {0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ 206 {0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
207 {0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 207 {0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
208 {0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ 208 {0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
209 {0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 209 {0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
210 {0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 210 {0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
211 {0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ 211 {0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
212 {0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ 212 {0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ 213 {0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
@@ -238,6 +238,7 @@
238 {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ 238 {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
239 {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 239 {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
240 {0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ 240 {0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
241 {0x1002, 0x791f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
241 {0, 0, 0} 242 {0, 0, 0}
242 243
243#define r128_PCI_IDS \ 244#define r128_PCI_IDS \
diff --git a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c
index 892e0a589846..f36adbd3aaf5 100644
--- a/drivers/char/drm/r128_cce.c
+++ b/drivers/char/drm/r128_cce.c
@@ -558,6 +558,7 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
558#if __OS_HAS_AGP 558#if __OS_HAS_AGP
559 if (dev_priv->is_pci) { 559 if (dev_priv->is_pci) {
560#endif 560#endif
561 dev_priv->gart_info.table_mask = DMA_BIT_MASK(32);
561 dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; 562 dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN;
562 dev_priv->gart_info.table_size = R128_PCIGART_TABLE_SIZE; 563 dev_priv->gart_info.table_size = R128_PCIGART_TABLE_SIZE;
563 dev_priv->gart_info.addr = NULL; 564 dev_priv->gart_info.addr = NULL;
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 833abc7e55fb..9072e4a1894e 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1807,6 +1807,7 @@ static int radeon_do_init_cp(struct drm_device * dev, drm_radeon_init_t * init)
1807 } else 1807 } else
1808#endif 1808#endif
1809 { 1809 {
1810 dev_priv->gart_info.table_mask = DMA_BIT_MASK(32);
1810 /* if we have an offset set from userspace */ 1811 /* if we have an offset set from userspace */
1811 if (dev_priv->pcigart_offset_set) { 1812 if (dev_priv->pcigart_offset_set) {
1812 dev_priv->gart_info.bus_addr = 1813 dev_priv->gart_info.bus_addr =
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 94baec692b57..7a339dba6a69 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -126,6 +126,8 @@ via_cmdbuf_wait(drm_via_private_t * dev_priv, unsigned int size)
126 hw_addr, cur_addr, next_addr); 126 hw_addr, cur_addr, next_addr);
127 return -1; 127 return -1;
128 } 128 }
129 if ((cur_addr < hw_addr) && (next_addr >= hw_addr))
130 msleep(1);
129 } while ((cur_addr < hw_addr) && (next_addr >= hw_addr)); 131 } while ((cur_addr < hw_addr) && (next_addr >= hw_addr));
130 return 0; 132 return 0;
131} 133}
@@ -416,27 +418,50 @@ static int via_hook_segment(drm_via_private_t * dev_priv,
416 int paused, count; 418 int paused, count;
417 volatile uint32_t *paused_at = dev_priv->last_pause_ptr; 419 volatile uint32_t *paused_at = dev_priv->last_pause_ptr;
418 uint32_t reader,ptr; 420 uint32_t reader,ptr;
421 uint32_t diff;
419 422
420 paused = 0; 423 paused = 0;
421 via_flush_write_combine(); 424 via_flush_write_combine();
422 (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1); 425 (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1);
426
423 *paused_at = pause_addr_lo; 427 *paused_at = pause_addr_lo;
424 via_flush_write_combine(); 428 via_flush_write_combine();
425 (void) *paused_at; 429 (void) *paused_at;
430
426 reader = *(dev_priv->hw_addr_ptr); 431 reader = *(dev_priv->hw_addr_ptr);
427 ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + 432 ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) +
428 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; 433 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
434
429 dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1; 435 dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1;
430 436
431 if ((ptr - reader) <= dev_priv->dma_diff ) { 437 /*
432 count = 10000000; 438 * If there is a possibility that the command reader will
433 while (!(paused = (VIA_READ(0x41c) & 0x80000000)) && count--); 439 * miss the new pause address and pause on the old one,
440 * In that case we need to program the new start address
441 * using PCI.
442 */
443
444 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
445 count = 10000000;
446 while(diff == 0 && count--) {
447 paused = (VIA_READ(0x41c) & 0x80000000);
448 if (paused)
449 break;
450 reader = *(dev_priv->hw_addr_ptr);
451 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
434 } 452 }
435 453
454 paused = VIA_READ(0x41c) & 0x80000000;
455
436 if (paused && !no_pci_fire) { 456 if (paused && !no_pci_fire) {
437 reader = *(dev_priv->hw_addr_ptr); 457 reader = *(dev_priv->hw_addr_ptr);
438 if ((ptr - reader) == dev_priv->dma_diff) { 458 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
439 459 diff &= (dev_priv->dma_high - 1);
460 if (diff != 0 && diff < (dev_priv->dma_high >> 1)) {
461 DRM_ERROR("Paused at incorrect address. "
462 "0x%08x, 0x%08x 0x%08x\n",
463 ptr, reader, dev_priv->dma_diff);
464 } else if (diff == 0) {
440 /* 465 /*
441 * There is a concern that these writes may stall the PCI bus 466 * There is a concern that these writes may stall the PCI bus
442 * if the GPU is not idle. However, idling the GPU first 467 * if the GPU is not idle. However, idling the GPU first
@@ -577,6 +602,7 @@ static void via_cmdbuf_jump(drm_via_private_t * dev_priv)
577 uint32_t pause_addr_lo, pause_addr_hi; 602 uint32_t pause_addr_lo, pause_addr_hi;
578 uint32_t jump_addr_lo, jump_addr_hi; 603 uint32_t jump_addr_lo, jump_addr_hi;
579 volatile uint32_t *last_pause_ptr; 604 volatile uint32_t *last_pause_ptr;
605 uint32_t dma_low_save1, dma_low_save2;
580 606
581 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr; 607 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
582 via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi, 608 via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi,
@@ -603,8 +629,29 @@ static void via_cmdbuf_jump(drm_via_private_t * dev_priv)
603 &pause_addr_lo, 0); 629 &pause_addr_lo, 0);
604 630
605 *last_pause_ptr = pause_addr_lo; 631 *last_pause_ptr = pause_addr_lo;
632 dma_low_save1 = dev_priv->dma_low;
606 633
607 via_hook_segment( dev_priv, jump_addr_hi, jump_addr_lo, 0); 634 /*
635 * Now, set a trap that will pause the regulator if it tries to rerun the old
636 * command buffer. (Which may happen if via_hook_segment detecs a command regulator pause
637 * and reissues the jump command over PCI, while the regulator has already taken the jump
638 * and actually paused at the current buffer end).
639 * There appears to be no other way to detect this condition, since the hw_addr_pointer
640 * does not seem to get updated immediately when a jump occurs.
641 */
642
643 last_pause_ptr =
644 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
645 &pause_addr_lo, 0) - 1;
646 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
647 &pause_addr_lo, 0);
648 *last_pause_ptr = pause_addr_lo;
649
650 dma_low_save2 = dev_priv->dma_low;
651 dev_priv->dma_low = dma_low_save1;
652 via_hook_segment(dev_priv, jump_addr_hi, jump_addr_lo, 0);
653 dev_priv->dma_low = dma_low_save2;
654 via_hook_segment(dev_priv, pause_addr_hi, pause_addr_lo, 0);
608} 655}
609 656
610 657
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 33c5197b73c4..409e00afdd07 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -603,7 +603,7 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
603 * (Not a big limitation anyway.) 603 * (Not a big limitation anyway.)
604 */ 604 */
605 605
606 if ((xfer->mem_stride - xfer->line_length) >= PAGE_SIZE) { 606 if ((xfer->mem_stride - xfer->line_length) > 2*PAGE_SIZE) {
607 DRM_ERROR("Too large system memory stride. Stride: %d, " 607 DRM_ERROR("Too large system memory stride. Stride: %d, "
608 "Length: %d\n", xfer->mem_stride, xfer->line_length); 608 "Length: %d\n", xfer->mem_stride, xfer->line_length);
609 return -EINVAL; 609 return -EINVAL;
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index dfaab2322de3..6d0dc5f9b6bb 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -190,6 +190,14 @@ enum card_type {
190 F32_8 = 8192, /* 3072 bytes downl. + 1024 bytes uplink * 2 -> 8192 */ 190 F32_8 = 8192, /* 3072 bytes downl. + 1024 bytes uplink * 2 -> 8192 */
191}; 191};
192 192
193/* Initialization states a card can be in */
194enum card_state {
195 NOZOMI_STATE_UKNOWN = 0,
196 NOZOMI_STATE_ENABLED = 1, /* pci device enabled */
197 NOZOMI_STATE_ALLOCATED = 2, /* config setup done */
198 NOZOMI_STATE_READY = 3, /* flowcontrols received */
199};
200
193/* Two different toggle channels exist */ 201/* Two different toggle channels exist */
194enum channel_type { 202enum channel_type {
195 CH_A = 0, 203 CH_A = 0,
@@ -385,6 +393,7 @@ struct nozomi {
385 spinlock_t spin_mutex; /* secures access to registers and tty */ 393 spinlock_t spin_mutex; /* secures access to registers and tty */
386 394
387 unsigned int index_start; 395 unsigned int index_start;
396 enum card_state state;
388 u32 open_ttys; 397 u32 open_ttys;
389}; 398};
390 399
@@ -686,6 +695,7 @@ static int nozomi_read_config_table(struct nozomi *dc)
686 dc->last_ier = dc->last_ier | CTRL_DL; 695 dc->last_ier = dc->last_ier | CTRL_DL;
687 writew(dc->last_ier, dc->reg_ier); 696 writew(dc->last_ier, dc->reg_ier);
688 697
698 dc->state = NOZOMI_STATE_ALLOCATED;
689 dev_info(&dc->pdev->dev, "Initialization OK!\n"); 699 dev_info(&dc->pdev->dev, "Initialization OK!\n");
690 return 1; 700 return 1;
691 } 701 }
@@ -944,6 +954,14 @@ static int receive_flow_control(struct nozomi *dc)
944 case CTRL_APP2: 954 case CTRL_APP2:
945 port = PORT_APP2; 955 port = PORT_APP2;
946 enable_ier = APP2_DL; 956 enable_ier = APP2_DL;
957 if (dc->state == NOZOMI_STATE_ALLOCATED) {
958 /*
959 * After card initialization the flow control
960 * received for APP2 is always the last
961 */
962 dc->state = NOZOMI_STATE_READY;
963 dev_info(&dc->pdev->dev, "Device READY!\n");
964 }
947 break; 965 break;
948 default: 966 default:
949 dev_err(&dc->pdev->dev, 967 dev_err(&dc->pdev->dev,
@@ -1366,22 +1384,12 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1366 1384
1367 dc->pdev = pdev; 1385 dc->pdev = pdev;
1368 1386
1369 /* Find out what card type it is */
1370 nozomi_get_card_type(dc);
1371
1372 ret = pci_enable_device(dc->pdev); 1387 ret = pci_enable_device(dc->pdev);
1373 if (ret) { 1388 if (ret) {
1374 dev_err(&pdev->dev, "Failed to enable PCI Device\n"); 1389 dev_err(&pdev->dev, "Failed to enable PCI Device\n");
1375 goto err_free; 1390 goto err_free;
1376 } 1391 }
1377 1392
1378 start = pci_resource_start(dc->pdev, 0);
1379 if (start == 0) {
1380 dev_err(&pdev->dev, "No I/O address for card detected\n");
1381 ret = -ENODEV;
1382 goto err_disable_device;
1383 }
1384
1385 ret = pci_request_regions(dc->pdev, NOZOMI_NAME); 1393 ret = pci_request_regions(dc->pdev, NOZOMI_NAME);
1386 if (ret) { 1394 if (ret) {
1387 dev_err(&pdev->dev, "I/O address 0x%04x already in use\n", 1395 dev_err(&pdev->dev, "I/O address 0x%04x already in use\n",
@@ -1389,6 +1397,16 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1389 goto err_disable_device; 1397 goto err_disable_device;
1390 } 1398 }
1391 1399
1400 start = pci_resource_start(dc->pdev, 0);
1401 if (start == 0) {
1402 dev_err(&pdev->dev, "No I/O address for card detected\n");
1403 ret = -ENODEV;
1404 goto err_rel_regs;
1405 }
1406
1407 /* Find out what card type it is */
1408 nozomi_get_card_type(dc);
1409
1392 dc->base_addr = ioremap(start, dc->card_type); 1410 dc->base_addr = ioremap(start, dc->card_type);
1393 if (!dc->base_addr) { 1411 if (!dc->base_addr) {
1394 dev_err(&pdev->dev, "Unable to map card MMIO\n"); 1412 dev_err(&pdev->dev, "Unable to map card MMIO\n");
@@ -1425,6 +1443,14 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1425 dc->index_start = ndev_idx * MAX_PORT; 1443 dc->index_start = ndev_idx * MAX_PORT;
1426 ndevs[ndev_idx] = dc; 1444 ndevs[ndev_idx] = dc;
1427 1445
1446 pci_set_drvdata(pdev, dc);
1447
1448 /* Enable RESET interrupt */
1449 dc->last_ier = RESET;
1450 iowrite16(dc->last_ier, dc->reg_ier);
1451
1452 dc->state = NOZOMI_STATE_ENABLED;
1453
1428 for (i = 0; i < MAX_PORT; i++) { 1454 for (i = 0; i < MAX_PORT; i++) {
1429 mutex_init(&dc->port[i].tty_sem); 1455 mutex_init(&dc->port[i].tty_sem);
1430 dc->port[i].tty_open_count = 0; 1456 dc->port[i].tty_open_count = 0;
@@ -1433,12 +1459,6 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1433 &pdev->dev); 1459 &pdev->dev);
1434 } 1460 }
1435 1461
1436 /* Enable RESET interrupt. */
1437 dc->last_ier = RESET;
1438 writew(dc->last_ier, dc->reg_ier);
1439
1440 pci_set_drvdata(pdev, dc);
1441
1442 return 0; 1462 return 0;
1443 1463
1444err_free_sbuf: 1464err_free_sbuf:
@@ -1553,7 +1573,7 @@ static int ntty_open(struct tty_struct *tty, struct file *file)
1553 struct nozomi *dc = get_dc_by_tty(tty); 1573 struct nozomi *dc = get_dc_by_tty(tty);
1554 unsigned long flags; 1574 unsigned long flags;
1555 1575
1556 if (!port || !dc) 1576 if (!port || !dc || dc->state != NOZOMI_STATE_READY)
1557 return -ENODEV; 1577 return -ENODEV;
1558 1578
1559 if (mutex_lock_interruptible(&port->tty_sem)) 1579 if (mutex_lock_interruptible(&port->tty_sem))
@@ -1716,6 +1736,10 @@ static int ntty_tiocmget(struct tty_struct *tty, struct file *file)
1716static int ntty_tiocmset(struct tty_struct *tty, struct file *file, 1736static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
1717 unsigned int set, unsigned int clear) 1737 unsigned int set, unsigned int clear)
1718{ 1738{
1739 struct nozomi *dc = get_dc_by_tty(tty);
1740 unsigned long flags;
1741
1742 spin_lock_irqsave(&dc->spin_mutex, flags);
1719 if (set & TIOCM_RTS) 1743 if (set & TIOCM_RTS)
1720 set_rts(tty, 1); 1744 set_rts(tty, 1);
1721 else if (clear & TIOCM_RTS) 1745 else if (clear & TIOCM_RTS)
@@ -1725,6 +1749,7 @@ static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
1725 set_dtr(tty, 1); 1749 set_dtr(tty, 1);
1726 else if (clear & TIOCM_DTR) 1750 else if (clear & TIOCM_DTR)
1727 set_dtr(tty, 0); 1751 set_dtr(tty, 0);
1752 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1728 1753
1729 return 0; 1754 return 0;
1730} 1755}
@@ -1762,7 +1787,7 @@ static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp)
1762 icount.brk = cnow.brk; 1787 icount.brk = cnow.brk;
1763 icount.buf_overrun = cnow.buf_overrun; 1788 icount.buf_overrun = cnow.buf_overrun;
1764 1789
1765 return copy_to_user(argp, &icount, sizeof(icount)); 1790 return copy_to_user(argp, &icount, sizeof(icount)) ? -EFAULT : 0;
1766} 1791}
1767 1792
1768static int ntty_ioctl(struct tty_struct *tty, struct file *file, 1793static int ntty_ioctl(struct tty_struct *tty, struct file *file,
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 8fc4fe4e38f1..3f9d0a9ac36d 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1620,14 +1620,8 @@ static int __init rc_init_drivers(void)
1620 1620
1621static void rc_release_drivers(void) 1621static void rc_release_drivers(void)
1622{ 1622{
1623 unsigned long flags;
1624
1625 spin_lock_irqsave(&riscom_lock, flags);
1626
1627 tty_unregister_driver(riscom_driver); 1623 tty_unregister_driver(riscom_driver);
1628 put_tty_driver(riscom_driver); 1624 put_tty_driver(riscom_driver);
1629
1630 spin_unlock_irqrestore(&riscom_lock, flags);
1631} 1625}
1632 1626
1633#ifndef MODULE 1627#ifndef MODULE
@@ -1715,7 +1709,7 @@ static int __init riscom8_init_module (void)
1715 1709
1716 if (iobase || iobase1 || iobase2 || iobase3) { 1710 if (iobase || iobase1 || iobase2 || iobase3) {
1717 for(i = 0; i < RC_NBOARD; i++) 1711 for(i = 0; i < RC_NBOARD; i++)
1718 rc_board[0].base = 0; 1712 rc_board[i].base = 0;
1719 } 1713 }
1720 1714
1721 if (iobase) 1715 if (iobase)