aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 12:07:16 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 12:07:16 -0500
commitd31d29540915f21d3f2bcfdd6d135fde328038a0 (patch)
tree43af1c34adff65dcb316ac8a82f3f05d6de9edad /drivers/char
parent7a8c6ad918e9c598bf3b799f1a0d5ee4dee59ca3 (diff)
parent3d5e2c13b13468f5eb2ac9323690af7e17f195fe (diff)
Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (22 commits) drm: add initial r500 drm support radeon: setup the ring buffer fetcher to be less agressive. drm: fixup some of the ioctl function exit paths drm: the drm really should call pci_set_master.. i915: Add chipset id for Intel Integrated Graphics Device drm: cleanup DRM_DEBUG() parameters drm/i915: add support for E7221 chipset drm: don't cast a pointer to pointer of list_head mga_dma: return 'err' not just zero from mga_do_cleanup_dma() drm: add _DRM_DRIVER flag, and re-order unload. drm: enable udev node creation drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx. drm: move drm_mem_init to proper place in startup sequence drm: call driver load function after initialising AGP drm: Fix ioc32 compat layer drm: fd.o bug #11895: Only add the AGP base to map offset if the caller didn't. i915: add suspend/resume support drm: update DRM sysfs support drm: Initialize the AGP structure's base address at init rather than enable. drm: move two function extern into the correct block ...
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/drm/Kconfig9
-rw-r--r--drivers/char/drm/Makefile2
-rw-r--r--drivers/char/drm/README.drm1
-rw-r--r--drivers/char/drm/ati_pcigart.c6
-rw-r--r--drivers/char/drm/drm.h3
-rw-r--r--drivers/char/drm/drmP.h68
-rw-r--r--drivers/char/drm/drm_agpsupport.c3
-rw-r--r--drivers/char/drm/drm_bufs.c23
-rw-r--r--drivers/char/drm/drm_context.c2
-rw-r--r--drivers/char/drm/drm_drv.c39
-rw-r--r--drivers/char/drm/drm_hashtab.c5
-rw-r--r--drivers/char/drm/drm_hashtab.h1
-rw-r--r--drivers/char/drm/drm_ioc32.c6
-rw-r--r--drivers/char/drm/drm_ioctl.c25
-rw-r--r--drivers/char/drm/drm_irq.c4
-rw-r--r--drivers/char/drm/drm_memory.c1
-rw-r--r--drivers/char/drm/drm_mm.c1
-rw-r--r--drivers/char/drm/drm_os_linux.h4
-rw-r--r--drivers/char/drm/drm_pciids.h97
-rw-r--r--drivers/char/drm/drm_proc.c4
-rw-r--r--drivers/char/drm/drm_sarea.h2
-rw-r--r--drivers/char/drm/drm_scatter.c10
-rw-r--r--drivers/char/drm/drm_stub.c18
-rw-r--r--drivers/char/drm/drm_sysfs.c146
-rw-r--r--drivers/char/drm/drm_vm.c4
-rw-r--r--drivers/char/drm/i810_dma.c24
-rw-r--r--drivers/char/drm/i810_drv.h52
-rw-r--r--drivers/char/drm/i830_dma.c2
-rw-r--r--drivers/char/drm/i830_drm.h8
-rw-r--r--drivers/char/drm/i830_drv.h51
-rw-r--r--drivers/char/drm/i830_irq.c2
-rw-r--r--drivers/char/drm/i915_dma.c124
-rw-r--r--drivers/char/drm/i915_drv.c464
-rw-r--r--drivers/char/drm/i915_drv.h848
-rw-r--r--drivers/char/drm/i915_irq.c26
-rw-r--r--drivers/char/drm/i915_mem.c11
-rw-r--r--drivers/char/drm/mga_dma.c10
-rw-r--r--drivers/char/drm/mga_drv.h123
-rw-r--r--drivers/char/drm/mga_state.c24
-rw-r--r--drivers/char/drm/r128_cce.c6
-rw-r--r--drivers/char/drm/r128_drv.h5
-rw-r--r--drivers/char/drm/r128_state.c43
-rw-r--r--drivers/char/drm/r300_cmdbuf.c75
-rw-r--r--drivers/char/drm/r300_reg.h32
-rw-r--r--drivers/char/drm/radeon_cp.c166
-rw-r--r--drivers/char/drm/radeon_drm.h13
-rw-r--r--drivers/char/drm/radeon_drv.h91
-rw-r--r--drivers/char/drm/radeon_irq.c6
-rw-r--r--drivers/char/drm/radeon_mem.c6
-rw-r--r--drivers/char/drm/radeon_state.c18
-rw-r--r--drivers/char/drm/savage_state.c6
-rw-r--r--drivers/char/drm/sis_mm.c6
-rw-r--r--drivers/char/drm/via_dma.c20
-rw-r--r--drivers/char/drm/via_dmablit.c184
-rw-r--r--drivers/char/drm/via_dmablit.h84
-rw-r--r--drivers/char/drm/via_drm.h4
-rw-r--r--drivers/char/drm/via_drv.c2
-rw-r--r--drivers/char/drm/via_irq.c26
-rw-r--r--drivers/char/drm/via_map.c5
-rw-r--r--drivers/char/drm/via_mm.c6
-rw-r--r--drivers/char/drm/via_video.c4
61 files changed, 2291 insertions, 770 deletions
diff --git a/drivers/char/drm/Kconfig b/drivers/char/drm/Kconfig
index ba3058dd39a7..610d6fd5bb50 100644
--- a/drivers/char/drm/Kconfig
+++ b/drivers/char/drm/Kconfig
@@ -38,7 +38,7 @@ config DRM_RADEON
38 Choose this option if you have an ATI Radeon graphics card. There 38 Choose this option if you have an ATI Radeon graphics card. There
39 are both PCI and AGP versions. You don't need to choose this to 39 are both PCI and AGP versions. You don't need to choose this to
40 run the Radeon in plain VGA mode. 40 run the Radeon in plain VGA mode.
41 41
42 If M is selected, the module will be called radeon. 42 If M is selected, the module will be called radeon.
43 43
44config DRM_I810 44config DRM_I810
@@ -71,9 +71,9 @@ config DRM_I915
71 852GM, 855GM 865G or 915G integrated graphics. If M is selected, the 71 852GM, 855GM 865G or 915G integrated graphics. If M is selected, the
72 module will be called i915. AGP support is required for this driver 72 module will be called i915. AGP support is required for this driver
73 to work. This driver is used by the Intel driver in X.org 6.8 and 73 to work. This driver is used by the Intel driver in X.org 6.8 and
74 XFree86 4.4 and above. If unsure, build this and i830 as modules and 74 XFree86 4.4 and above. If unsure, build this and i830 as modules and
75 the X server will load the correct one. 75 the X server will load the correct one.
76 76
77endchoice 77endchoice
78 78
79config DRM_MGA 79config DRM_MGA
@@ -88,7 +88,7 @@ config DRM_SIS
88 tristate "SiS video cards" 88 tristate "SiS video cards"
89 depends on DRM && AGP 89 depends on DRM && AGP
90 help 90 help
91 Choose this option if you have a SiS 630 or compatible video 91 Choose this option if you have a SiS 630 or compatible video
92 chipset. If M is selected the module will be called sis. AGP 92 chipset. If M is selected the module will be called sis. AGP
93 support is required for this driver to work. 93 support is required for this driver to work.
94 94
@@ -105,4 +105,3 @@ config DRM_SAVAGE
105 help 105 help
106 Choose this option if you have a Savage3D/4/SuperSavage/Pro/Twister 106 Choose this option if you have a Savage3D/4/SuperSavage/Pro/Twister
107 chipset. If M is selected the module will be called savage. 107 chipset. If M is selected the module will be called savage.
108
diff --git a/drivers/char/drm/Makefile b/drivers/char/drm/Makefile
index 6915a0599dfb..1283ded88ead 100644
--- a/drivers/char/drm/Makefile
+++ b/drivers/char/drm/Makefile
@@ -38,5 +38,3 @@ obj-$(CONFIG_DRM_I915) += i915.o
38obj-$(CONFIG_DRM_SIS) += sis.o 38obj-$(CONFIG_DRM_SIS) += sis.o
39obj-$(CONFIG_DRM_SAVAGE)+= savage.o 39obj-$(CONFIG_DRM_SAVAGE)+= savage.o
40obj-$(CONFIG_DRM_VIA) +=via.o 40obj-$(CONFIG_DRM_VIA) +=via.o
41
42
diff --git a/drivers/char/drm/README.drm b/drivers/char/drm/README.drm
index af74cd79a279..b5b332722581 100644
--- a/drivers/char/drm/README.drm
+++ b/drivers/char/drm/README.drm
@@ -41,4 +41,3 @@ For specific information about kernel-level support, see:
41 41
42 A Security Analysis of the Direct Rendering Infrastructure 42 A Security Analysis of the Direct Rendering Infrastructure
43 http://dri.sourceforge.net/doc/security_low_level.html 43 http://dri.sourceforge.net/doc/security_low_level.html
44
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index 3345641ff904..d352dbb4ccf7 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -41,7 +41,7 @@ static void *drm_ati_alloc_pcigart_table(int order)
41 struct page *page; 41 struct page *page;
42 int i; 42 int i;
43 43
44 DRM_DEBUG("%s: alloc %d order\n", __FUNCTION__, order); 44 DRM_DEBUG("%d order\n", order);
45 45
46 address = __get_free_pages(GFP_KERNEL | __GFP_COMP, 46 address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
47 order); 47 order);
@@ -54,7 +54,7 @@ static void *drm_ati_alloc_pcigart_table(int order)
54 for (i = 0; i < order; i++, page++) 54 for (i = 0; i < order; i++, page++)
55 SetPageReserved(page); 55 SetPageReserved(page);
56 56
57 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); 57 DRM_DEBUG("returning 0x%08lx\n", address);
58 return (void *)address; 58 return (void *)address;
59} 59}
60 60
@@ -63,7 +63,7 @@ static void drm_ati_free_pcigart_table(void *address, int order)
63 struct page *page; 63 struct page *page;
64 int i; 64 int i;
65 int num_pages = 1 << order; 65 int num_pages = 1 << order;
66 DRM_DEBUG("%s\n", __FUNCTION__); 66 DRM_DEBUG("\n");
67 67
68 page = virt_to_page((unsigned long)address); 68 page = virt_to_page((unsigned long)address);
69 69
diff --git a/drivers/char/drm/drm.h b/drivers/char/drm/drm.h
index 82fb3d0d2785..3a05c6d5ebe1 100644
--- a/drivers/char/drm/drm.h
+++ b/drivers/char/drm/drm.h
@@ -202,7 +202,8 @@ enum drm_map_flags {
202 _DRM_KERNEL = 0x08, /**< kernel requires access */ 202 _DRM_KERNEL = 0x08, /**< kernel requires access */
203 _DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */ 203 _DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */
204 _DRM_CONTAINS_LOCK = 0x20, /**< SHM page that contains lock */ 204 _DRM_CONTAINS_LOCK = 0x20, /**< SHM page that contains lock */
205 _DRM_REMOVABLE = 0x40 /**< Removable mapping */ 205 _DRM_REMOVABLE = 0x40, /**< Removable mapping */
206 _DRM_DRIVER = 0x80 /**< Managed by driver */
206}; 207};
207 208
208struct drm_ctx_priv_map { 209struct drm_ctx_priv_map {
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index dde02a15fa59..19d3be5c4b2d 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -292,7 +292,6 @@ struct drm_magic_entry {
292 struct list_head head; 292 struct list_head head;
293 struct drm_hash_item hash_item; 293 struct drm_hash_item hash_item;
294 struct drm_file *priv; 294 struct drm_file *priv;
295 struct drm_magic_entry *next;
296}; 295};
297 296
298struct drm_vma_entry { 297struct drm_vma_entry {
@@ -388,8 +387,8 @@ struct drm_file {
388 struct drm_head *head; 387 struct drm_head *head;
389 int remove_auth_on_close; 388 int remove_auth_on_close;
390 unsigned long lock_count; 389 unsigned long lock_count;
391 void *driver_priv;
392 struct file *filp; 390 struct file *filp;
391 void *driver_priv;
393}; 392};
394 393
395/** Wait queue */ 394/** Wait queue */
@@ -401,11 +400,9 @@ struct drm_queue {
401 wait_queue_head_t read_queue; /**< Processes waiting on block_read */ 400 wait_queue_head_t read_queue; /**< Processes waiting on block_read */
402 atomic_t block_write; /**< Queue blocked for writes */ 401 atomic_t block_write; /**< Queue blocked for writes */
403 wait_queue_head_t write_queue; /**< Processes waiting on block_write */ 402 wait_queue_head_t write_queue; /**< Processes waiting on block_write */
404#if 1
405 atomic_t total_queued; /**< Total queued statistic */ 403 atomic_t total_queued; /**< Total queued statistic */
406 atomic_t total_flushed; /**< Total flushes statistic */ 404 atomic_t total_flushed; /**< Total flushes statistic */
407 atomic_t total_locks; /**< Total locks statistics */ 405 atomic_t total_locks; /**< Total locks statistics */
408#endif
409 enum drm_ctx_flags flags; /**< Context preserving and 2D-only */ 406 enum drm_ctx_flags flags; /**< Context preserving and 2D-only */
410 struct drm_waitlist waitlist; /**< Pending buffers */ 407 struct drm_waitlist waitlist; /**< Pending buffers */
411 wait_queue_head_t flush_queue; /**< Processes waiting until flush */ 408 wait_queue_head_t flush_queue; /**< Processes waiting until flush */
@@ -416,7 +413,8 @@ struct drm_queue {
416 */ 413 */
417struct drm_lock_data { 414struct drm_lock_data {
418 struct drm_hw_lock *hw_lock; /**< Hardware lock */ 415 struct drm_hw_lock *hw_lock; /**< Hardware lock */
419 struct drm_file *file_priv; /**< File descr of lock holder (0=kernel) */ 416 /** Private of lock holder's file (NULL=kernel) */
417 struct drm_file *file_priv;
420 wait_queue_head_t lock_queue; /**< Queue of blocked processes */ 418 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
421 unsigned long lock_time; /**< Time of last lock in jiffies */ 419 unsigned long lock_time; /**< Time of last lock in jiffies */
422 spinlock_t spinlock; 420 spinlock_t spinlock;
@@ -491,6 +489,27 @@ struct drm_sigdata {
491 struct drm_hw_lock *lock; 489 struct drm_hw_lock *lock;
492}; 490};
493 491
492
493/*
494 * Generic memory manager structs
495 */
496
497struct drm_mm_node {
498 struct list_head fl_entry;
499 struct list_head ml_entry;
500 int free;
501 unsigned long start;
502 unsigned long size;
503 struct drm_mm *mm;
504 void *private;
505};
506
507struct drm_mm {
508 struct list_head fl_entry;
509 struct list_head ml_entry;
510};
511
512
494/** 513/**
495 * Mappings list 514 * Mappings list
496 */ 515 */
@@ -498,7 +517,7 @@ struct drm_map_list {
498 struct list_head head; /**< list head */ 517 struct list_head head; /**< list head */
499 struct drm_hash_item hash; 518 struct drm_hash_item hash;
500 struct drm_map *map; /**< mapping */ 519 struct drm_map *map; /**< mapping */
501 unsigned int user_token; 520 uint64_t user_token;
502}; 521};
503 522
504typedef struct drm_map drm_local_map_t; 523typedef struct drm_map drm_local_map_t;
@@ -536,24 +555,6 @@ struct drm_ati_pcigart_info {
536 int table_size; 555 int table_size;
537}; 556};
538 557
539/*
540 * Generic memory manager structs
541 */
542struct drm_mm_node {
543 struct list_head fl_entry;
544 struct list_head ml_entry;
545 int free;
546 unsigned long start;
547 unsigned long size;
548 struct drm_mm *mm;
549 void *private;
550};
551
552struct drm_mm {
553 struct list_head fl_entry;
554 struct list_head ml_entry;
555};
556
557/** 558/**
558 * DRM driver structure. This structure represent the common code for 559 * DRM driver structure. This structure represent the common code for
559 * a family of cards. There will one drm_device for each card present 560 * a family of cards. There will one drm_device for each card present
@@ -567,6 +568,8 @@ struct drm_driver {
567 void (*postclose) (struct drm_device *, struct drm_file *); 568 void (*postclose) (struct drm_device *, struct drm_file *);
568 void (*lastclose) (struct drm_device *); 569 void (*lastclose) (struct drm_device *);
569 int (*unload) (struct drm_device *); 570 int (*unload) (struct drm_device *);
571 int (*suspend) (struct drm_device *);
572 int (*resume) (struct drm_device *);
570 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); 573 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
571 void (*dma_ready) (struct drm_device *); 574 void (*dma_ready) (struct drm_device *);
572 int (*dma_quiescent) (struct drm_device *); 575 int (*dma_quiescent) (struct drm_device *);
@@ -642,6 +645,7 @@ struct drm_head {
642 * may contain multiple heads. 645 * may contain multiple heads.
643 */ 646 */
644struct drm_device { 647struct drm_device {
648 struct device dev; /**< Linux device */
645 char *unique; /**< Unique identifier: e.g., busid */ 649 char *unique; /**< Unique identifier: e.g., busid */
646 int unique_len; /**< Length of unique field */ 650 int unique_len; /**< Length of unique field */
647 char *devname; /**< For /proc/interrupts */ 651 char *devname; /**< For /proc/interrupts */
@@ -750,7 +754,6 @@ struct drm_device {
750 struct pci_controller *hose; 754 struct pci_controller *hose;
751#endif 755#endif
752 struct drm_sg_mem *sg; /**< Scatter gather memory */ 756 struct drm_sg_mem *sg; /**< Scatter gather memory */
753 unsigned long *ctx_bitmap; /**< context bitmap */
754 void *dev_private; /**< device private data */ 757 void *dev_private; /**< device private data */
755 struct drm_sigdata sigdata; /**< For block_all_signals */ 758 struct drm_sigdata sigdata; /**< For block_all_signals */
756 sigset_t sigmask; 759 sigset_t sigmask;
@@ -847,6 +850,8 @@ extern int drm_release(struct inode *inode, struct file *filp);
847 850
848 /* Mapping support (drm_vm.h) */ 851 /* Mapping support (drm_vm.h) */
849extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); 852extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
853extern unsigned long drm_core_get_map_ofs(struct drm_map * map);
854extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
850extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 855extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
851 856
852 /* Memory management support (drm_memory.h) */ 857 /* Memory management support (drm_memory.h) */
@@ -1061,11 +1066,11 @@ extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1061extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); 1066extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
1062 1067
1063 /* sysfs support (drm_sysfs.c) */ 1068 /* sysfs support (drm_sysfs.c) */
1069struct drm_sysfs_class;
1064extern struct class *drm_sysfs_create(struct module *owner, char *name); 1070extern struct class *drm_sysfs_create(struct module *owner, char *name);
1065extern void drm_sysfs_destroy(struct class *cs); 1071extern void drm_sysfs_destroy(void);
1066extern struct class_device *drm_sysfs_device_add(struct class *cs, 1072extern int drm_sysfs_device_add(struct drm_device *dev, struct drm_head *head);
1067 struct drm_head *head); 1073extern void drm_sysfs_device_remove(struct drm_device *dev);
1068extern void drm_sysfs_device_remove(struct class_device *class_dev);
1069 1074
1070/* 1075/*
1071 * Basic memory manager support (drm_mm.c) 1076 * Basic memory manager support (drm_mm.c)
@@ -1073,7 +1078,7 @@ extern void drm_sysfs_device_remove(struct class_device *class_dev);
1073extern struct drm_mm_node *drm_mm_get_block(struct drm_mm_node * parent, 1078extern struct drm_mm_node *drm_mm_get_block(struct drm_mm_node * parent,
1074 unsigned long size, 1079 unsigned long size,
1075 unsigned alignment); 1080 unsigned alignment);
1076void drm_mm_put_block(struct drm_mm_node * cur); 1081extern void drm_mm_put_block(struct drm_mm_node * cur);
1077extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, unsigned long size, 1082extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, unsigned long size,
1078 unsigned alignment, int best_match); 1083 unsigned alignment, int best_match);
1079extern int drm_mm_init(struct drm_mm *mm, unsigned long start, unsigned long size); 1084extern int drm_mm_init(struct drm_mm *mm, unsigned long start, unsigned long size);
@@ -1144,8 +1149,5 @@ extern void *drm_calloc(size_t nmemb, size_t size, int area);
1144 1149
1145/*@}*/ 1150/*@}*/
1146 1151
1147extern unsigned long drm_core_get_map_ofs(struct drm_map * map);
1148extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
1149
1150#endif /* __KERNEL__ */ 1152#endif /* __KERNEL__ */
1151#endif 1153#endif
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c
index 214f4fbcba73..9468c7889ff1 100644
--- a/drivers/char/drm/drm_agpsupport.c
+++ b/drivers/char/drm/drm_agpsupport.c
@@ -166,7 +166,6 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode)
166 166
167 dev->agp->mode = mode.mode; 167 dev->agp->mode = mode.mode;
168 agp_enable(dev->agp->bridge, mode.mode); 168 agp_enable(dev->agp->bridge, mode.mode);
169 dev->agp->base = dev->agp->agp_info.aper_base;
170 dev->agp->enabled = 1; 169 dev->agp->enabled = 1;
171 return 0; 170 return 0;
172} 171}
@@ -417,7 +416,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
417 INIT_LIST_HEAD(&head->memory); 416 INIT_LIST_HEAD(&head->memory);
418 head->cant_use_aperture = head->agp_info.cant_use_aperture; 417 head->cant_use_aperture = head->agp_info.cant_use_aperture;
419 head->page_mask = head->agp_info.page_mask; 418 head->page_mask = head->agp_info.page_mask;
420 419 head->base = head->agp_info.aper_base;
421 return head; 420 return head;
422} 421}
423 422
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index d24a6c2c2c24..bde64b84166e 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -184,7 +184,7 @@ static int drm_addmap_core(struct drm_device * dev, unsigned int offset,
184 return -ENOMEM; 184 return -ENOMEM;
185 } 185 }
186 } 186 }
187 187
188 break; 188 break;
189 case _DRM_SHM: 189 case _DRM_SHM:
190 list = drm_find_matching_map(dev, map); 190 list = drm_find_matching_map(dev, map);
@@ -229,11 +229,17 @@ static int drm_addmap_core(struct drm_device * dev, unsigned int offset,
229#ifdef __alpha__ 229#ifdef __alpha__
230 map->offset += dev->hose->mem_space->start; 230 map->offset += dev->hose->mem_space->start;
231#endif 231#endif
232 /* Note: dev->agp->base may actually be 0 when the DRM 232 /* In some cases (i810 driver), user space may have already
233 * is not in control of AGP space. But if user space is 233 * added the AGP base itself, because dev->agp->base previously
234 * it should already have added the AGP base itself. 234 * only got set during AGP enable. So, only add the base
235 * address if the map's offset isn't already within the
236 * aperture.
235 */ 237 */
236 map->offset += dev->agp->base; 238 if (map->offset < dev->agp->base ||
239 map->offset > dev->agp->base +
240 dev->agp->agp_info.aper_size * 1024 * 1024 - 1) {
241 map->offset += dev->agp->base;
242 }
237 map->mtrr = dev->agp->agp_mtrr; /* for getmap */ 243 map->mtrr = dev->agp->agp_mtrr; /* for getmap */
238 244
239 /* This assumes the DRM is in total control of AGP space. 245 /* This assumes the DRM is in total control of AGP space.
@@ -429,6 +435,7 @@ int drm_rmmap(struct drm_device *dev, drm_local_map_t *map)
429 435
430 return ret; 436 return ret;
431} 437}
438EXPORT_SYMBOL(drm_rmmap);
432 439
433/* The rmmap ioctl appears to be unnecessary. All mappings are torn down on 440/* The rmmap ioctl appears to be unnecessary. All mappings are torn down on
434 * the last close of the device, and this is necessary for cleanup when things 441 * the last close of the device, and this is necessary for cleanup when things
@@ -814,9 +821,9 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
814 page_count = 0; 821 page_count = 0;
815 822
816 while (entry->buf_count < count) { 823 while (entry->buf_count < count) {
817 824
818 dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000, 0xfffffffful); 825 dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000, 0xfffffffful);
819 826
820 if (!dmah) { 827 if (!dmah) {
821 /* Set count correctly so we free the proper amount. */ 828 /* Set count correctly so we free the proper amount. */
822 entry->buf_count = count; 829 entry->buf_count = count;
@@ -1592,5 +1599,3 @@ int drm_order(unsigned long size)
1592 return order; 1599 return order;
1593} 1600}
1594EXPORT_SYMBOL(drm_order); 1601EXPORT_SYMBOL(drm_order);
1595
1596
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index 17fe69e7bfc1..d505f695421f 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -159,7 +159,7 @@ int drm_getsareactx(struct drm_device *dev, void *data,
159 request->handle = NULL; 159 request->handle = NULL;
160 list_for_each_entry(_entry, &dev->maplist, head) { 160 list_for_each_entry(_entry, &dev->maplist, head) {
161 if (_entry->map == map) { 161 if (_entry->map == map) {
162 request->handle = 162 request->handle =
163 (void *)(unsigned long)_entry->user_token; 163 (void *)(unsigned long)_entry->user_token;
164 break; 164 break;
165 } 165 }
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 44a46268b02b..0e7af53c87de 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -200,8 +200,10 @@ int drm_lastclose(struct drm_device * dev)
200 } 200 }
201 201
202 list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) { 202 list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
203 drm_rmmap_locked(dev, r_list->map); 203 if (!(r_list->map->flags & _DRM_DRIVER)) {
204 r_list = NULL; 204 drm_rmmap_locked(dev, r_list->map);
205 r_list = NULL;
206 }
205 } 207 }
206 208
207 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { 209 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
@@ -255,8 +257,6 @@ int drm_init(struct drm_driver *driver)
255 257
256 DRM_DEBUG("\n"); 258 DRM_DEBUG("\n");
257 259
258 drm_mem_init();
259
260 for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) { 260 for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
261 pid = (struct pci_device_id *)&driver->pci_driver.id_table[i]; 261 pid = (struct pci_device_id *)&driver->pci_driver.id_table[i];
262 262
@@ -293,10 +293,6 @@ static void drm_cleanup(struct drm_device * dev)
293 293
294 drm_lastclose(dev); 294 drm_lastclose(dev);
295 295
296 drm_ht_remove(&dev->map_hash);
297
298 drm_ctxbitmap_cleanup(dev);
299
300 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && 296 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
301 dev->agp && dev->agp->agp_mtrr >= 0) { 297 dev->agp && dev->agp->agp_mtrr >= 0) {
302 int retval; 298 int retval;
@@ -314,6 +310,9 @@ static void drm_cleanup(struct drm_device * dev)
314 if (dev->driver->unload) 310 if (dev->driver->unload)
315 dev->driver->unload(dev); 311 dev->driver->unload(dev);
316 312
313 drm_ht_remove(&dev->map_hash);
314 drm_ctxbitmap_cleanup(dev);
315
317 drm_put_head(&dev->primary); 316 drm_put_head(&dev->primary);
318 if (drm_put_dev(dev)) 317 if (drm_put_dev(dev))
319 DRM_ERROR("Cannot unload module\n"); 318 DRM_ERROR("Cannot unload module\n");
@@ -383,22 +382,24 @@ static int __init drm_core_init(void)
383 goto err_p3; 382 goto err_p3;
384 } 383 }
385 384
385 drm_mem_init();
386
386 DRM_INFO("Initialized %s %d.%d.%d %s\n", 387 DRM_INFO("Initialized %s %d.%d.%d %s\n",
387 CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); 388 CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
388 return 0; 389 return 0;
389 err_p3: 390err_p3:
390 drm_sysfs_destroy(drm_class); 391 drm_sysfs_destroy();
391 err_p2: 392err_p2:
392 unregister_chrdev(DRM_MAJOR, "drm"); 393 unregister_chrdev(DRM_MAJOR, "drm");
393 drm_free(drm_heads, sizeof(*drm_heads) * drm_cards_limit, DRM_MEM_STUB); 394 drm_free(drm_heads, sizeof(*drm_heads) * drm_cards_limit, DRM_MEM_STUB);
394 err_p1: 395err_p1:
395 return ret; 396 return ret;
396} 397}
397 398
398static void __exit drm_core_exit(void) 399static void __exit drm_core_exit(void)
399{ 400{
400 remove_proc_entry("dri", NULL); 401 remove_proc_entry("dri", NULL);
401 drm_sysfs_destroy(drm_class); 402 drm_sysfs_destroy();
402 403
403 unregister_chrdev(DRM_MAJOR, "drm"); 404 unregister_chrdev(DRM_MAJOR, "drm");
404 405
@@ -494,23 +495,25 @@ int drm_ioctl(struct inode *inode, struct file *filp,
494 } else { 495 } else {
495 if (cmd & (IOC_IN | IOC_OUT)) { 496 if (cmd & (IOC_IN | IOC_OUT)) {
496 kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL); 497 kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
497 if (!kdata) 498 if (!kdata) {
498 return -ENOMEM; 499 retcode = -ENOMEM;
500 goto err_i1;
501 }
499 } 502 }
500 503
501 if (cmd & IOC_IN) { 504 if (cmd & IOC_IN) {
502 if (copy_from_user(kdata, (void __user *)arg, 505 if (copy_from_user(kdata, (void __user *)arg,
503 _IOC_SIZE(cmd)) != 0) { 506 _IOC_SIZE(cmd)) != 0) {
504 retcode = -EACCES; 507 retcode = -EFAULT;
505 goto err_i1; 508 goto err_i1;
506 } 509 }
507 } 510 }
508 retcode = func(dev, kdata, file_priv); 511 retcode = func(dev, kdata, file_priv);
509 512
510 if (cmd & IOC_OUT) { 513 if ((retcode == 0) && (cmd & IOC_OUT)) {
511 if (copy_to_user((void __user *)arg, kdata, 514 if (copy_to_user((void __user *)arg, kdata,
512 _IOC_SIZE(cmd)) != 0) 515 _IOC_SIZE(cmd)) != 0)
513 retcode = -EACCES; 516 retcode = -EFAULT;
514 } 517 }
515 } 518 }
516 519
diff --git a/drivers/char/drm/drm_hashtab.c b/drivers/char/drm/drm_hashtab.c
index 4b8e7db5a232..33160673a7b7 100644
--- a/drivers/char/drm/drm_hashtab.c
+++ b/drivers/char/drm/drm_hashtab.c
@@ -80,7 +80,7 @@ void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key)
80 } 80 }
81} 81}
82 82
83static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht, 83static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht,
84 unsigned long key) 84 unsigned long key)
85{ 85{
86 struct drm_hash_item *entry; 86 struct drm_hash_item *entry;
@@ -129,7 +129,7 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item)
129} 129}
130 130
131/* 131/*
132 * Just insert an item and return any "bits" bit key that hasn't been 132 * Just insert an item and return any "bits" bit key that hasn't been
133 * used before. 133 * used before.
134 */ 134 */
135int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, 135int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
@@ -200,4 +200,3 @@ void drm_ht_remove(struct drm_open_hash *ht)
200 ht->table = NULL; 200 ht->table = NULL;
201 } 201 }
202} 202}
203
diff --git a/drivers/char/drm/drm_hashtab.h b/drivers/char/drm/drm_hashtab.h
index 573e333ac457..cd2b189e1be6 100644
--- a/drivers/char/drm/drm_hashtab.h
+++ b/drivers/char/drm/drm_hashtab.h
@@ -65,4 +65,3 @@ extern void drm_ht_remove(struct drm_open_hash *ht);
65 65
66 66
67#endif 67#endif
68
diff --git a/drivers/char/drm/drm_ioc32.c b/drivers/char/drm/drm_ioc32.c
index 2286f3312c5c..90f5a8d9bdcb 100644
--- a/drivers/char/drm/drm_ioc32.c
+++ b/drivers/char/drm/drm_ioc32.c
@@ -1051,8 +1051,12 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1051 drm_ioctl_compat_t *fn; 1051 drm_ioctl_compat_t *fn;
1052 int ret; 1052 int ret;
1053 1053
1054 /* Assume that ioctls without an explicit compat routine will just
1055 * work. This may not always be a good assumption, but it's better
1056 * than always failing.
1057 */
1054 if (nr >= ARRAY_SIZE(drm_compat_ioctls)) 1058 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
1055 return -ENOTTY; 1059 return drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
1056 1060
1057 fn = drm_compat_ioctls[nr]; 1061 fn = drm_compat_ioctls[nr];
1058 1062
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index 3cbebf868e68..16829fb3089d 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -234,26 +234,23 @@ int drm_getclient(struct drm_device *dev, void *data,
234 234
235 idx = client->idx; 235 idx = client->idx;
236 mutex_lock(&dev->struct_mutex); 236 mutex_lock(&dev->struct_mutex);
237
238 if (list_empty(&dev->filelist)) {
239 mutex_unlock(&dev->struct_mutex);
240 return -EINVAL;
241 }
242 237
243 i = 0; 238 i = 0;
244 list_for_each_entry(pt, &dev->filelist, lhead) { 239 list_for_each_entry(pt, &dev->filelist, lhead) {
245 if (i++ >= idx) 240 if (i++ >= idx) {
246 break; 241 client->auth = pt->authenticated;
242 client->pid = pt->pid;
243 client->uid = pt->uid;
244 client->magic = pt->magic;
245 client->iocs = pt->ioctl_count;
246 mutex_unlock(&dev->struct_mutex);
247
248 return 0;
249 }
247 } 250 }
248
249 client->auth = pt->authenticated;
250 client->pid = pt->pid;
251 client->uid = pt->uid;
252 client->magic = pt->magic;
253 client->iocs = pt->ioctl_count;
254 mutex_unlock(&dev->struct_mutex); 251 mutex_unlock(&dev->struct_mutex);
255 252
256 return 0; 253 return -EINVAL;
257} 254}
258 255
259/** 256/**
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index 05eae63f85ba..089c015c01d1 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -107,7 +107,7 @@ static int drm_irq_install(struct drm_device * dev)
107 dev->irq_enabled = 1; 107 dev->irq_enabled = 1;
108 mutex_unlock(&dev->struct_mutex); 108 mutex_unlock(&dev->struct_mutex);
109 109
110 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq); 110 DRM_DEBUG("irq=%d\n", dev->irq);
111 111
112 if (drm_core_check_feature(dev, DRIVER_IRQ_VBL)) { 112 if (drm_core_check_feature(dev, DRIVER_IRQ_VBL)) {
113 init_waitqueue_head(&dev->vbl_queue); 113 init_waitqueue_head(&dev->vbl_queue);
@@ -164,7 +164,7 @@ int drm_irq_uninstall(struct drm_device * dev)
164 if (!irq_enabled) 164 if (!irq_enabled)
165 return -EINVAL; 165 return -EINVAL;
166 166
167 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq); 167 DRM_DEBUG("irq=%d\n", dev->irq);
168 168
169 dev->driver->irq_uninstall(dev); 169 dev->driver->irq_uninstall(dev);
170 170
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c
index 93019901bd30..845081b44f63 100644
--- a/drivers/char/drm/drm_memory.c
+++ b/drivers/char/drm/drm_memory.c
@@ -179,4 +179,3 @@ void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
179 iounmap(map->handle); 179 iounmap(map->handle);
180} 180}
181EXPORT_SYMBOL(drm_core_ioremapfree); 181EXPORT_SYMBOL(drm_core_ioremapfree);
182
diff --git a/drivers/char/drm/drm_mm.c b/drivers/char/drm/drm_mm.c
index 86f4eb61a6a4..dcff9e9b52e3 100644
--- a/drivers/char/drm/drm_mm.c
+++ b/drivers/char/drm/drm_mm.c
@@ -293,4 +293,3 @@ void drm_mm_takedown(struct drm_mm * mm)
293 293
294 drm_free(entry, sizeof(*entry), DRM_MEM_MM); 294 drm_free(entry, sizeof(*entry), DRM_MEM_MM);
295} 295}
296
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h
index daa69c9d8977..8dbd2572b7c3 100644
--- a/drivers/char/drm/drm_os_linux.h
+++ b/drivers/char/drm/drm_os_linux.h
@@ -69,9 +69,9 @@ static __inline__ int mtrr_del(int reg, unsigned long base, unsigned long size)
69#define DRM_COPY_TO_USER(arg1, arg2, arg3) \ 69#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
70 copy_to_user(arg1, arg2, arg3) 70 copy_to_user(arg1, arg2, arg3)
71/* Macros for copyfrom user, but checking readability only once */ 71/* Macros for copyfrom user, but checking readability only once */
72#define DRM_VERIFYAREA_READ( uaddr, size ) \ 72#define DRM_VERIFYAREA_READ( uaddr, size ) \
73 (access_ok( VERIFY_READ, uaddr, size ) ? 0 : -EFAULT) 73 (access_ok( VERIFY_READ, uaddr, size ) ? 0 : -EFAULT)
74#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ 74#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
75 __copy_from_user(arg1, arg2, arg3) 75 __copy_from_user(arg1, arg2, arg3)
76#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ 76#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
77 __copy_to_user(arg1, arg2, arg3) 77 __copy_to_user(arg1, arg2, arg3)
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 43d3c42df360..f52468843678 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -139,6 +139,101 @@
139 {0x1002, 0x5e4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ 139 {0x1002, 0x5e4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
140 {0x1002, 0x5e4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ 140 {0x1002, 0x5e4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
141 {0x1002, 0x5e4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ 141 {0x1002, 0x5e4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
142 {0x1002, 0x7100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
143 {0x1002, 0x7101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
144 {0x1002, 0x7102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
145 {0x1002, 0x7103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
146 {0x1002, 0x7104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
147 {0x1002, 0x7105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
148 {0x1002, 0x7106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
149 {0x1002, 0x7108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
150 {0x1002, 0x7109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
151 {0x1002, 0x710A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
152 {0x1002, 0x710B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
153 {0x1002, 0x710C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
154 {0x1002, 0x710E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
155 {0x1002, 0x710F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \
156 {0x1002, 0x7140, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
157 {0x1002, 0x7141, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
158 {0x1002, 0x7142, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
159 {0x1002, 0x7143, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
160 {0x1002, 0x7144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
161 {0x1002, 0x7145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
162 {0x1002, 0x7146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
163 {0x1002, 0x7147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
164 {0x1002, 0x7149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
165 {0x1002, 0x714A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
166 {0x1002, 0x714B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
167 {0x1002, 0x714C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
168 {0x1002, 0x714D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
169 {0x1002, 0x714E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
170 {0x1002, 0x714F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
171 {0x1002, 0x7151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
172 {0x1002, 0x7152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
173 {0x1002, 0x7153, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
174 {0x1002, 0x715E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
175 {0x1002, 0x715F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
176 {0x1002, 0x7180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
177 {0x1002, 0x7181, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
178 {0x1002, 0x7183, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
179 {0x1002, 0x7186, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
180 {0x1002, 0x7187, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
181 {0x1002, 0x7188, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
182 {0x1002, 0x718A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
183 {0x1002, 0x718B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
184 {0x1002, 0x718C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
185 {0x1002, 0x718D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
186 {0x1002, 0x718F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
187 {0x1002, 0x7193, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
188 {0x1002, 0x7196, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
189 {0x1002, 0x719B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
190 {0x1002, 0x719F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
191 {0x1002, 0x71C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
192 {0x1002, 0x71C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
193 {0x1002, 0x71C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
194 {0x1002, 0x71C3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
195 {0x1002, 0x71C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
196 {0x1002, 0x71C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
197 {0x1002, 0x71C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
198 {0x1002, 0x71C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
199 {0x1002, 0x71CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
200 {0x1002, 0x71CE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
201 {0x1002, 0x71D2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
202 {0x1002, 0x71D4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
203 {0x1002, 0x71D5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
204 {0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
205 {0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
206 {0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
207 {0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
208 {0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
209 {0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
210 {0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
211 {0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
212 {0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x7245, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
214 {0x1002, 0x7246, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
215 {0x1002, 0x7247, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
216 {0x1002, 0x7248, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
217 {0x1002, 0x7249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
218 {0x1002, 0x724A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
219 {0x1002, 0x724B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
220 {0x1002, 0x724C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
221 {0x1002, 0x724D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
222 {0x1002, 0x724E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
223 {0x1002, 0x724F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
224 {0x1002, 0x7280, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
225 {0x1002, 0x7281, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
226 {0x1002, 0x7283, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
227 {0x1002, 0x7284, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
228 {0x1002, 0x7287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
229 {0x1002, 0x7288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
230 {0x1002, 0x7289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
231 {0x1002, 0x728B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
232 {0x1002, 0x728C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \
233 {0x1002, 0x7290, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
234 {0x1002, 0x7291, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
235 {0x1002, 0x7293, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
236 {0x1002, 0x7297, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \
142 {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ 237 {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
143 {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 238 {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
144 {0, 0, 0} 239 {0, 0, 0}
@@ -311,5 +406,5 @@
311 {0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 406 {0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
312 {0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 407 {0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
313 {0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 408 {0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
409 {0x8086, 0x2a42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
314 {0, 0, 0} 410 {0, 0, 0}
315
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 12dfea89c7f3..d9b560fe9bbe 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -236,11 +236,11 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
236 type = "??"; 236 type = "??";
237 else 237 else
238 type = types[map->type]; 238 type = types[map->type];
239 DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08x ", 239 DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ",
240 i, 240 i,
241 map->offset, 241 map->offset,
242 map->size, type, map->flags, 242 map->size, type, map->flags,
243 r_list->user_token); 243 (unsigned long) r_list->user_token);
244 if (map->mtrr < 0) { 244 if (map->mtrr < 0) {
245 DRM_PROC_PRINT("none\n"); 245 DRM_PROC_PRINT("none\n");
246 } else { 246 } else {
diff --git a/drivers/char/drm/drm_sarea.h b/drivers/char/drm/drm_sarea.h
index e040f47f369f..480037331e4e 100644
--- a/drivers/char/drm/drm_sarea.h
+++ b/drivers/char/drm/drm_sarea.h
@@ -45,7 +45,7 @@
45#endif 45#endif
46 46
47/** Maximum number of drawables in the SAREA */ 47/** Maximum number of drawables in the SAREA */
48#define SAREA_MAX_DRAWABLES 256 48#define SAREA_MAX_DRAWABLES 256
49 49
50#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000 50#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
51 51
diff --git a/drivers/char/drm/drm_scatter.c b/drivers/char/drm/drm_scatter.c
index eb7fa437355e..26d8f675ed5d 100644
--- a/drivers/char/drm/drm_scatter.c
+++ b/drivers/char/drm/drm_scatter.c
@@ -67,7 +67,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
67 struct drm_sg_mem *entry; 67 struct drm_sg_mem *entry;
68 unsigned long pages, i, j; 68 unsigned long pages, i, j;
69 69
70 DRM_DEBUG("%s\n", __FUNCTION__); 70 DRM_DEBUG("\n");
71 71
72 if (!drm_core_check_feature(dev, DRIVER_SG)) 72 if (!drm_core_check_feature(dev, DRIVER_SG))
73 return -EINVAL; 73 return -EINVAL;
@@ -81,7 +81,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
81 81
82 memset(entry, 0, sizeof(*entry)); 82 memset(entry, 0, sizeof(*entry));
83 pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; 83 pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
84 DRM_DEBUG("sg size=%ld pages=%ld\n", request->size, pages); 84 DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages);
85 85
86 entry->pages = pages; 86 entry->pages = pages;
87 entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist), 87 entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist),
@@ -122,8 +122,8 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
122 122
123 entry->handle = ScatterHandle((unsigned long)entry->virtual); 123 entry->handle = ScatterHandle((unsigned long)entry->virtual);
124 124
125 DRM_DEBUG("sg alloc handle = %08lx\n", entry->handle); 125 DRM_DEBUG("handle = %08lx\n", entry->handle);
126 DRM_DEBUG("sg alloc virtual = %p\n", entry->virtual); 126 DRM_DEBUG("virtual = %p\n", entry->virtual);
127 127
128 for (i = (unsigned long)entry->virtual, j = 0; j < pages; 128 for (i = (unsigned long)entry->virtual, j = 0; j < pages;
129 i += PAGE_SIZE, j++) { 129 i += PAGE_SIZE, j++) {
@@ -210,7 +210,7 @@ int drm_sg_free(struct drm_device *dev, void *data,
210 if (!entry || entry->handle != request->handle) 210 if (!entry || entry->handle != request->handle)
211 return -EINVAL; 211 return -EINVAL;
212 212
213 DRM_DEBUG("sg free virtual = %p\n", entry->virtual); 213 DRM_DEBUG("virtual = %p\n", entry->virtual);
214 214
215 drm_sg_cleanup(entry); 215 drm_sg_cleanup(entry);
216 216
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index ee83ff9efed6..d93a217f856a 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -98,10 +98,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
98 98
99 dev->driver = driver; 99 dev->driver = driver;
100 100
101 if (dev->driver->load)
102 if ((retcode = dev->driver->load(dev, ent->driver_data)))
103 goto error_out_unreg;
104
105 if (drm_core_has_AGP(dev)) { 101 if (drm_core_has_AGP(dev)) {
106 if (drm_device_is_agp(dev)) 102 if (drm_device_is_agp(dev))
107 dev->agp = drm_agp_init(dev); 103 dev->agp = drm_agp_init(dev);
@@ -120,6 +116,10 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
120 } 116 }
121 } 117 }
122 118
119 if (dev->driver->load)
120 if ((retcode = dev->driver->load(dev, ent->driver_data)))
121 goto error_out_unreg;
122
123 retcode = drm_ctxbitmap_init(dev); 123 retcode = drm_ctxbitmap_init(dev);
124 if (retcode) { 124 if (retcode) {
125 DRM_ERROR("Cannot allocate memory for context bitmap.\n"); 125 DRM_ERROR("Cannot allocate memory for context bitmap.\n");
@@ -168,11 +168,10 @@ static int drm_get_head(struct drm_device * dev, struct drm_head * head)
168 goto err_g1; 168 goto err_g1;
169 } 169 }
170 170
171 head->dev_class = drm_sysfs_device_add(drm_class, head); 171 ret = drm_sysfs_device_add(dev, head);
172 if (IS_ERR(head->dev_class)) { 172 if (ret) {
173 printk(KERN_ERR 173 printk(KERN_ERR
174 "DRM: Error sysfs_device_add.\n"); 174 "DRM: Error sysfs_device_add.\n");
175 ret = PTR_ERR(head->dev_class);
176 goto err_g2; 175 goto err_g2;
177 } 176 }
178 *heads = head; 177 *heads = head;
@@ -218,13 +217,14 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
218 if (ret) 217 if (ret)
219 goto err_g1; 218 goto err_g1;
220 219
220 pci_set_master(pdev);
221 if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) { 221 if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
222 printk(KERN_ERR "DRM: Fill_in_dev failed.\n"); 222 printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
223 goto err_g2; 223 goto err_g2;
224 } 224 }
225 if ((ret = drm_get_head(dev, &dev->primary))) 225 if ((ret = drm_get_head(dev, &dev->primary)))
226 goto err_g2; 226 goto err_g2;
227 227
228 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", 228 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
229 driver->name, driver->major, driver->minor, driver->patchlevel, 229 driver->name, driver->major, driver->minor, driver->patchlevel,
230 driver->date, dev->primary.minor); 230 driver->date, dev->primary.minor);
@@ -283,7 +283,7 @@ int drm_put_head(struct drm_head * head)
283 DRM_DEBUG("release secondary minor %d\n", minor); 283 DRM_DEBUG("release secondary minor %d\n", minor);
284 284
285 drm_proc_cleanup(minor, drm_proc_root, head->dev_root); 285 drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
286 drm_sysfs_device_remove(head->dev_class); 286 drm_sysfs_device_remove(head->dev);
287 287
288 *head = (struct drm_head) {.dev = NULL}; 288 *head = (struct drm_head) {.dev = NULL};
289 289
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c
index cf4349b00b07..fa36153619e8 100644
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -19,6 +19,45 @@
19#include "drm_core.h" 19#include "drm_core.h"
20#include "drmP.h" 20#include "drmP.h"
21 21
22#define to_drm_device(d) container_of(d, struct drm_device, dev)
23
24/**
25 * drm_sysfs_suspend - DRM class suspend hook
26 * @dev: Linux device to suspend
27 * @state: power state to enter
28 *
29 * Just figures out what the actual struct drm_device associated with
30 * @dev is and calls its suspend hook, if present.
31 */
32static int drm_sysfs_suspend(struct device *dev, pm_message_t state)
33{
34 struct drm_device *drm_dev = to_drm_device(dev);
35
36 printk(KERN_ERR "%s\n", __FUNCTION__);
37
38 if (drm_dev->driver->suspend)
39 return drm_dev->driver->suspend(drm_dev);
40
41 return 0;
42}
43
44/**
45 * drm_sysfs_resume - DRM class resume hook
46 * @dev: Linux device to resume
47 *
48 * Just figures out what the actual struct drm_device associated with
49 * @dev is and calls its resume hook, if present.
50 */
51static int drm_sysfs_resume(struct device *dev)
52{
53 struct drm_device *drm_dev = to_drm_device(dev);
54
55 if (drm_dev->driver->resume)
56 return drm_dev->driver->resume(drm_dev);
57
58 return 0;
59}
60
22/* Display the version of drm_core. This doesn't work right in current design */ 61/* Display the version of drm_core. This doesn't work right in current design */
23static ssize_t version_show(struct class *dev, char *buf) 62static ssize_t version_show(struct class *dev, char *buf)
24{ 63{
@@ -33,7 +72,7 @@ static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
33 * @owner: pointer to the module that is to "own" this struct drm_sysfs_class 72 * @owner: pointer to the module that is to "own" this struct drm_sysfs_class
34 * @name: pointer to a string for the name of this class. 73 * @name: pointer to a string for the name of this class.
35 * 74 *
36 * This is used to create a struct drm_sysfs_class pointer that can then be used 75 * This is used to create DRM class pointer that can then be used
37 * in calls to drm_sysfs_device_add(). 76 * in calls to drm_sysfs_device_add().
38 * 77 *
39 * Note, the pointer created here is to be destroyed when finished by making a 78 * Note, the pointer created here is to be destroyed when finished by making a
@@ -50,6 +89,9 @@ struct class *drm_sysfs_create(struct module *owner, char *name)
50 goto err_out; 89 goto err_out;
51 } 90 }
52 91
92 class->suspend = drm_sysfs_suspend;
93 class->resume = drm_sysfs_resume;
94
53 err = class_create_file(class, &class_attr_version); 95 err = class_create_file(class, &class_attr_version);
54 if (err) 96 if (err)
55 goto err_out_class; 97 goto err_out_class;
@@ -63,94 +105,100 @@ err_out:
63} 105}
64 106
65/** 107/**
66 * drm_sysfs_destroy - destroys a struct drm_sysfs_class structure 108 * drm_sysfs_destroy - destroys DRM class
67 * @cs: pointer to the struct drm_sysfs_class that is to be destroyed
68 * 109 *
69 * Note, the pointer to be destroyed must have been created with a call to 110 * Destroy the DRM device class.
70 * drm_sysfs_create().
71 */ 111 */
72void drm_sysfs_destroy(struct class *class) 112void drm_sysfs_destroy(void)
73{ 113{
74 if ((class == NULL) || (IS_ERR(class))) 114 if ((drm_class == NULL) || (IS_ERR(drm_class)))
75 return; 115 return;
76 116 class_remove_file(drm_class, &class_attr_version);
77 class_remove_file(class, &class_attr_version); 117 class_destroy(drm_class);
78 class_destroy(class);
79} 118}
80 119
81static ssize_t show_dri(struct class_device *class_device, char *buf) 120static ssize_t show_dri(struct device *device, struct device_attribute *attr,
121 char *buf)
82{ 122{
83 struct drm_device * dev = ((struct drm_head *)class_get_devdata(class_device))->dev; 123 struct drm_device *dev = to_drm_device(device);
84 if (dev->driver->dri_library_name) 124 if (dev->driver->dri_library_name)
85 return dev->driver->dri_library_name(dev, buf); 125 return dev->driver->dri_library_name(dev, buf);
86 return snprintf(buf, PAGE_SIZE, "%s\n", dev->driver->pci_driver.name); 126 return snprintf(buf, PAGE_SIZE, "%s\n", dev->driver->pci_driver.name);
87} 127}
88 128
89static struct class_device_attribute class_device_attrs[] = { 129static struct device_attribute device_attrs[] = {
90 __ATTR(dri_library_name, S_IRUGO, show_dri, NULL), 130 __ATTR(dri_library_name, S_IRUGO, show_dri, NULL),
91}; 131};
92 132
93/** 133/**
134 * drm_sysfs_device_release - do nothing
135 * @dev: Linux device
136 *
137 * Normally, this would free the DRM device associated with @dev, along
138 * with cleaning up any other stuff. But we do that in the DRM core, so
139 * this function can just return and hope that the core does its job.
140 */
141static void drm_sysfs_device_release(struct device *dev)
142{
143 return;
144}
145
146/**
94 * drm_sysfs_device_add - adds a class device to sysfs for a character driver 147 * drm_sysfs_device_add - adds a class device to sysfs for a character driver
95 * @cs: pointer to the struct class that this device should be registered to. 148 * @dev: DRM device to be added
96 * @dev: the dev_t for the device to be added. 149 * @head: DRM head in question
97 * @device: a pointer to a struct device that is assiociated with this class device.
98 * @fmt: string for the class device's name
99 * 150 *
100 * A struct class_device will be created in sysfs, registered to the specified 151 * Add a DRM device to the DRM's device model class. We use @dev's PCI device
101 * class. A "dev" file will be created, showing the dev_t for the device. The 152 * as the parent for the Linux device, and make sure it has a file containing
102 * pointer to the struct class_device will be returned from the call. Any further 153 * the driver we're using (for userspace compatibility).
103 * sysfs files that might be required can be created using this pointer.
104 * Note: the struct class passed to this function must have previously been
105 * created with a call to drm_sysfs_create().
106 */ 154 */
107struct class_device *drm_sysfs_device_add(struct class *cs, struct drm_head *head) 155int drm_sysfs_device_add(struct drm_device *dev, struct drm_head *head)
108{ 156{
109 struct class_device *class_dev; 157 int err;
110 int i, j, err; 158 int i, j;
111 159
112 class_dev = class_device_create(cs, NULL, 160 dev->dev.parent = &dev->pdev->dev;
113 MKDEV(DRM_MAJOR, head->minor), 161 dev->dev.class = drm_class;
114 &(head->dev->pdev)->dev, 162 dev->dev.release = drm_sysfs_device_release;
115 "card%d", head->minor); 163 dev->dev.devt = head->device;
116 if (IS_ERR(class_dev)) { 164 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "card%d", head->minor);
117 err = PTR_ERR(class_dev); 165
166 err = device_register(&dev->dev);
167 if (err) {
168 DRM_ERROR("device add failed: %d\n", err);
118 goto err_out; 169 goto err_out;
119 } 170 }
120 171
121 class_set_devdata(class_dev, head); 172 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
122 173 err = device_create_file(&dev->dev, &device_attrs[i]);
123 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
124 err = class_device_create_file(class_dev,
125 &class_device_attrs[i]);
126 if (err) 174 if (err)
127 goto err_out_files; 175 goto err_out_files;
128 } 176 }
129 177
130 return class_dev; 178 return 0;
131 179
132err_out_files: 180err_out_files:
133 if (i > 0) 181 if (i > 0)
134 for (j = 0; j < i; j++) 182 for (j = 0; j < i; j++)
135 class_device_remove_file(class_dev, 183 device_remove_file(&dev->dev, &device_attrs[i]);
136 &class_device_attrs[i]); 184 device_unregister(&dev->dev);
137 class_device_unregister(class_dev);
138err_out: 185err_out:
139 return ERR_PTR(err); 186
187 return err;
140} 188}
141 189
142/** 190/**
143 * drm_sysfs_device_remove - removes a class device that was created with drm_sysfs_device_add() 191 * drm_sysfs_device_remove - remove DRM device
144 * @dev: the dev_t of the device that was previously registered. 192 * @dev: DRM device to remove
145 * 193 *
146 * This call unregisters and cleans up a class device that was created with a 194 * This call unregisters and cleans up a class device that was created with a
147 * call to drm_sysfs_device_add() 195 * call to drm_sysfs_device_add()
148 */ 196 */
149void drm_sysfs_device_remove(struct class_device *class_dev) 197void drm_sysfs_device_remove(struct drm_device *dev)
150{ 198{
151 int i; 199 int i;
152 200
153 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 201 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
154 class_device_remove_file(class_dev, &class_device_attrs[i]); 202 device_remove_file(&dev->dev, &device_attrs[i]);
155 class_device_unregister(class_dev); 203 device_unregister(&dev->dev);
156} 204}
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index ef5e6b130c48..cea4105374b2 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -180,7 +180,7 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
180 return NOPAGE_SIGBUS; 180 return NOPAGE_SIGBUS;
181 get_page(page); 181 get_page(page);
182 182
183 DRM_DEBUG("shm_nopage 0x%lx\n", address); 183 DRM_DEBUG("0x%lx\n", address);
184 return page; 184 return page;
185} 185}
186 186
@@ -294,7 +294,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
294 294
295 get_page(page); 295 get_page(page);
296 296
297 DRM_DEBUG("dma_nopage 0x%lx (page %lu)\n", address, page_nr); 297 DRM_DEBUG("0x%lx (page %lu)\n", address, page_nr);
298 return page; 298 return page;
299} 299}
300 300
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index eb381a7c5bee..8d7ea81c4b66 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -40,7 +40,7 @@
40 40
41#define I810_BUF_FREE 2 41#define I810_BUF_FREE 2
42#define I810_BUF_CLIENT 1 42#define I810_BUF_CLIENT 1
43#define I810_BUF_HARDWARE 0 43#define I810_BUF_HARDWARE 0
44 44
45#define I810_BUF_UNMAPPED 0 45#define I810_BUF_UNMAPPED 0
46#define I810_BUF_MAPPED 1 46#define I810_BUF_MAPPED 1
@@ -570,7 +570,7 @@ static void i810EmitState(struct drm_device * dev)
570 drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; 570 drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv;
571 unsigned int dirty = sarea_priv->dirty; 571 unsigned int dirty = sarea_priv->dirty;
572 572
573 DRM_DEBUG("%s %x\n", __FUNCTION__, dirty); 573 DRM_DEBUG("%x\n", dirty);
574 574
575 if (dirty & I810_UPLOAD_BUFFERS) { 575 if (dirty & I810_UPLOAD_BUFFERS) {
576 i810EmitDestVerified(dev, sarea_priv->BufferState); 576 i810EmitDestVerified(dev, sarea_priv->BufferState);
@@ -802,8 +802,7 @@ static void i810_dma_dispatch_flip(struct drm_device * dev)
802 int pitch = dev_priv->pitch; 802 int pitch = dev_priv->pitch;
803 RING_LOCALS; 803 RING_LOCALS;
804 804
805 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", 805 DRM_DEBUG("page=%d pfCurrentPage=%d\n",
806 __FUNCTION__,
807 dev_priv->current_page, 806 dev_priv->current_page,
808 dev_priv->sarea_priv->pf_current_page); 807 dev_priv->sarea_priv->pf_current_page);
809 808
@@ -848,8 +847,6 @@ static void i810_dma_quiescent(struct drm_device * dev)
848 drm_i810_private_t *dev_priv = dev->dev_private; 847 drm_i810_private_t *dev_priv = dev->dev_private;
849 RING_LOCALS; 848 RING_LOCALS;
850 849
851/* printk("%s\n", __FUNCTION__); */
852
853 i810_kernel_lost_context(dev); 850 i810_kernel_lost_context(dev);
854 851
855 BEGIN_LP_RING(4); 852 BEGIN_LP_RING(4);
@@ -869,8 +866,6 @@ static int i810_flush_queue(struct drm_device * dev)
869 int i, ret = 0; 866 int i, ret = 0;
870 RING_LOCALS; 867 RING_LOCALS;
871 868
872/* printk("%s\n", __FUNCTION__); */
873
874 i810_kernel_lost_context(dev); 869 i810_kernel_lost_context(dev);
875 870
876 BEGIN_LP_RING(2); 871 BEGIN_LP_RING(2);
@@ -949,7 +944,7 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
949 944
950 LOCK_TEST_WITH_RETURN(dev, file_priv); 945 LOCK_TEST_WITH_RETURN(dev, file_priv);
951 946
952 DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", 947 DRM_DEBUG("idx %d used %d discard %d\n",
953 vertex->idx, vertex->used, vertex->discard); 948 vertex->idx, vertex->used, vertex->discard);
954 949
955 if (vertex->idx < 0 || vertex->idx > dma->buf_count) 950 if (vertex->idx < 0 || vertex->idx > dma->buf_count)
@@ -987,7 +982,7 @@ static int i810_clear_bufs(struct drm_device *dev, void *data,
987static int i810_swap_bufs(struct drm_device *dev, void *data, 982static int i810_swap_bufs(struct drm_device *dev, void *data,
988 struct drm_file *file_priv) 983 struct drm_file *file_priv)
989{ 984{
990 DRM_DEBUG("i810_swap_bufs\n"); 985 DRM_DEBUG("\n");
991 986
992 LOCK_TEST_WITH_RETURN(dev, file_priv); 987 LOCK_TEST_WITH_RETURN(dev, file_priv);
993 988
@@ -1068,11 +1063,10 @@ static void i810_dma_dispatch_mc(struct drm_device * dev, struct drm_buf * buf,
1068 1063
1069 sarea_priv->dirty = 0x7f; 1064 sarea_priv->dirty = 0x7f;
1070 1065
1071 DRM_DEBUG("dispatch mc addr 0x%lx, used 0x%x\n", address, used); 1066 DRM_DEBUG("addr 0x%lx, used 0x%x\n", address, used);
1072 1067
1073 dev_priv->counter++; 1068 dev_priv->counter++;
1074 DRM_DEBUG("dispatch counter : %ld\n", dev_priv->counter); 1069 DRM_DEBUG("dispatch counter : %ld\n", dev_priv->counter);
1075 DRM_DEBUG("i810_dma_dispatch_mc\n");
1076 DRM_DEBUG("start : %lx\n", start); 1070 DRM_DEBUG("start : %lx\n", start);
1077 DRM_DEBUG("used : %d\n", used); 1071 DRM_DEBUG("used : %d\n", used);
1078 DRM_DEBUG("start + used - 4 : %ld\n", start + used - 4); 1072 DRM_DEBUG("start + used - 4 : %ld\n", start + used - 4);
@@ -1179,7 +1173,7 @@ static void i810_do_init_pageflip(struct drm_device * dev)
1179{ 1173{
1180 drm_i810_private_t *dev_priv = dev->dev_private; 1174 drm_i810_private_t *dev_priv = dev->dev_private;
1181 1175
1182 DRM_DEBUG("%s\n", __FUNCTION__); 1176 DRM_DEBUG("\n");
1183 dev_priv->page_flipping = 1; 1177 dev_priv->page_flipping = 1;
1184 dev_priv->current_page = 0; 1178 dev_priv->current_page = 0;
1185 dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; 1179 dev_priv->sarea_priv->pf_current_page = dev_priv->current_page;
@@ -1189,7 +1183,7 @@ static int i810_do_cleanup_pageflip(struct drm_device * dev)
1189{ 1183{
1190 drm_i810_private_t *dev_priv = dev->dev_private; 1184 drm_i810_private_t *dev_priv = dev->dev_private;
1191 1185
1192 DRM_DEBUG("%s\n", __FUNCTION__); 1186 DRM_DEBUG("\n");
1193 if (dev_priv->current_page != 0) 1187 if (dev_priv->current_page != 0)
1194 i810_dma_dispatch_flip(dev); 1188 i810_dma_dispatch_flip(dev);
1195 1189
@@ -1202,7 +1196,7 @@ static int i810_flip_bufs(struct drm_device *dev, void *data,
1202{ 1196{
1203 drm_i810_private_t *dev_priv = dev->dev_private; 1197 drm_i810_private_t *dev_priv = dev->dev_private;
1204 1198
1205 DRM_DEBUG("%s\n", __FUNCTION__); 1199 DRM_DEBUG("\n");
1206 1200
1207 LOCK_TEST_WITH_RETURN(dev, file_priv); 1201 LOCK_TEST_WITH_RETURN(dev, file_priv);
1208 1202
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index 0af45872f67e..0118849a5672 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -25,7 +25,7 @@
25 * DEALINGS IN THE SOFTWARE. 25 * DEALINGS IN THE SOFTWARE.
26 * 26 *
27 * Authors: Rickard E. (Rik) Faith <faith@valinux.com> 27 * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
28 * Jeff Hartmann <jhartmann@valinux.com> 28 * Jeff Hartmann <jhartmann@valinux.com>
29 * 29 *
30 */ 30 */
31 31
@@ -134,7 +134,7 @@ extern int i810_max_ioctl;
134#define I810_ADDR(reg) (I810_BASE(reg) + reg) 134#define I810_ADDR(reg) (I810_BASE(reg) + reg)
135#define I810_DEREF(reg) *(__volatile__ int *)I810_ADDR(reg) 135#define I810_DEREF(reg) *(__volatile__ int *)I810_ADDR(reg)
136#define I810_READ(reg) I810_DEREF(reg) 136#define I810_READ(reg) I810_DEREF(reg)
137#define I810_WRITE(reg,val) do { I810_DEREF(reg) = val; } while (0) 137#define I810_WRITE(reg,val) do { I810_DEREF(reg) = val; } while (0)
138#define I810_DEREF16(reg) *(__volatile__ u16 *)I810_ADDR(reg) 138#define I810_DEREF16(reg) *(__volatile__ u16 *)I810_ADDR(reg)
139#define I810_READ16(reg) I810_DEREF16(reg) 139#define I810_READ16(reg) I810_DEREF16(reg)
140#define I810_WRITE16(reg,val) do { I810_DEREF16(reg) = val; } while (0) 140#define I810_WRITE16(reg,val) do { I810_DEREF16(reg) = val; } while (0)
@@ -145,7 +145,7 @@ extern int i810_max_ioctl;
145 145
146#define BEGIN_LP_RING(n) do { \ 146#define BEGIN_LP_RING(n) do { \
147 if (I810_VERBOSE) \ 147 if (I810_VERBOSE) \
148 DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", n, __FUNCTION__); \ 148 DRM_DEBUG("BEGIN_LP_RING(%d)\n", n); \
149 if (dev_priv->ring.space < n*4) \ 149 if (dev_priv->ring.space < n*4) \
150 i810_wait_ring(dev, n*4); \ 150 i810_wait_ring(dev, n*4); \
151 dev_priv->ring.space -= n*4; \ 151 dev_priv->ring.space -= n*4; \
@@ -155,19 +155,19 @@ extern int i810_max_ioctl;
155} while (0) 155} while (0)
156 156
157#define ADVANCE_LP_RING() do { \ 157#define ADVANCE_LP_RING() do { \
158 if (I810_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING\n"); \ 158 if (I810_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING\n"); \
159 dev_priv->ring.tail = outring; \ 159 dev_priv->ring.tail = outring; \
160 I810_WRITE(LP_RING + RING_TAIL, outring); \ 160 I810_WRITE(LP_RING + RING_TAIL, outring); \
161} while(0) 161} while(0)
162 162
163#define OUT_RING(n) do { \ 163#define OUT_RING(n) do { \
164 if (I810_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \ 164 if (I810_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
165 *(volatile unsigned int *)(virt + outring) = n; \ 165 *(volatile unsigned int *)(virt + outring) = n; \
166 outring += 4; \ 166 outring += 4; \
167 outring &= ringmask; \ 167 outring &= ringmask; \
168} while (0) 168} while (0)
169 169
170#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23)) 170#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
171#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23)) 171#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
172#define CMD_REPORT_HEAD (7<<23) 172#define CMD_REPORT_HEAD (7<<23)
173#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1) 173#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
@@ -184,28 +184,28 @@ extern int i810_max_ioctl;
184 184
185#define I810REG_HWSTAM 0x02098 185#define I810REG_HWSTAM 0x02098
186#define I810REG_INT_IDENTITY_R 0x020a4 186#define I810REG_INT_IDENTITY_R 0x020a4
187#define I810REG_INT_MASK_R 0x020a8 187#define I810REG_INT_MASK_R 0x020a8
188#define I810REG_INT_ENABLE_R 0x020a0 188#define I810REG_INT_ENABLE_R 0x020a0
189 189
190#define LP_RING 0x2030 190#define LP_RING 0x2030
191#define HP_RING 0x2040 191#define HP_RING 0x2040
192#define RING_TAIL 0x00 192#define RING_TAIL 0x00
193#define TAIL_ADDR 0x000FFFF8 193#define TAIL_ADDR 0x000FFFF8
194#define RING_HEAD 0x04 194#define RING_HEAD 0x04
195#define HEAD_WRAP_COUNT 0xFFE00000 195#define HEAD_WRAP_COUNT 0xFFE00000
196#define HEAD_WRAP_ONE 0x00200000 196#define HEAD_WRAP_ONE 0x00200000
197#define HEAD_ADDR 0x001FFFFC 197#define HEAD_ADDR 0x001FFFFC
198#define RING_START 0x08 198#define RING_START 0x08
199#define START_ADDR 0x00FFFFF8 199#define START_ADDR 0x00FFFFF8
200#define RING_LEN 0x0C 200#define RING_LEN 0x0C
201#define RING_NR_PAGES 0x000FF000 201#define RING_NR_PAGES 0x000FF000
202#define RING_REPORT_MASK 0x00000006 202#define RING_REPORT_MASK 0x00000006
203#define RING_REPORT_64K 0x00000002 203#define RING_REPORT_64K 0x00000002
204#define RING_REPORT_128K 0x00000004 204#define RING_REPORT_128K 0x00000004
205#define RING_NO_REPORT 0x00000000 205#define RING_NO_REPORT 0x00000000
206#define RING_VALID_MASK 0x00000001 206#define RING_VALID_MASK 0x00000001
207#define RING_VALID 0x00000001 207#define RING_VALID 0x00000001
208#define RING_INVALID 0x00000000 208#define RING_INVALID 0x00000000
209 209
210#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 210#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
211#define SC_UPDATE_SCISSOR (0x1<<1) 211#define SC_UPDATE_SCISSOR (0x1<<1)
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 69a363edb0d2..379cbdad4921 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -42,7 +42,7 @@
42 42
43#define I830_BUF_FREE 2 43#define I830_BUF_FREE 2
44#define I830_BUF_CLIENT 1 44#define I830_BUF_CLIENT 1
45#define I830_BUF_HARDWARE 0 45#define I830_BUF_HARDWARE 0
46 46
47#define I830_BUF_UNMAPPED 0 47#define I830_BUF_UNMAPPED 0
48#define I830_BUF_MAPPED 1 48#define I830_BUF_MAPPED 1
diff --git a/drivers/char/drm/i830_drm.h b/drivers/char/drm/i830_drm.h
index 968a6d9f9dcb..4b00d2dd4f68 100644
--- a/drivers/char/drm/i830_drm.h
+++ b/drivers/char/drm/i830_drm.h
@@ -12,9 +12,9 @@
12#define _I830_DEFINES_ 12#define _I830_DEFINES_
13 13
14#define I830_DMA_BUF_ORDER 12 14#define I830_DMA_BUF_ORDER 12
15#define I830_DMA_BUF_SZ (1<<I830_DMA_BUF_ORDER) 15#define I830_DMA_BUF_SZ (1<<I830_DMA_BUF_ORDER)
16#define I830_DMA_BUF_NR 256 16#define I830_DMA_BUF_NR 256
17#define I830_NR_SAREA_CLIPRECTS 8 17#define I830_NR_SAREA_CLIPRECTS 8
18 18
19/* Each region is a minimum of 64k, and there are at most 64 of them. 19/* Each region is a minimum of 64k, and there are at most 64 of them.
20 */ 20 */
@@ -58,7 +58,7 @@
58#define I830_UPLOAD_TEXBLEND_MASK 0xf00000 58#define I830_UPLOAD_TEXBLEND_MASK 0xf00000
59#define I830_UPLOAD_TEX_PALETTE_N(n) (0x1000000 << (n)) 59#define I830_UPLOAD_TEX_PALETTE_N(n) (0x1000000 << (n))
60#define I830_UPLOAD_TEX_PALETTE_SHARED 0x4000000 60#define I830_UPLOAD_TEX_PALETTE_SHARED 0x4000000
61#define I830_UPLOAD_STIPPLE 0x8000000 61#define I830_UPLOAD_STIPPLE 0x8000000
62 62
63/* Indices into buf.Setup where various bits of state are mirrored per 63/* Indices into buf.Setup where various bits of state are mirrored per
64 * context and per buffer. These can be fired at the card as a unit, 64 * context and per buffer. These can be fired at the card as a unit,
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index db3a9fa83960..4caba8c54455 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -25,7 +25,7 @@
25 * DEALINGS IN THE SOFTWARE. 25 * DEALINGS IN THE SOFTWARE.
26 * 26 *
27 * Authors: Rickard E. (Rik) Faith <faith@valinux.com> 27 * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
28 * Jeff Hartmann <jhartmann@valinux.com> 28 * Jeff Hartmann <jhartmann@valinux.com>
29 * 29 *
30 */ 30 */
31 31
@@ -156,8 +156,7 @@ extern int i830_driver_device_is_agp(struct drm_device * dev);
156 156
157#define BEGIN_LP_RING(n) do { \ 157#define BEGIN_LP_RING(n) do { \
158 if (I830_VERBOSE) \ 158 if (I830_VERBOSE) \
159 printk("BEGIN_LP_RING(%d) in %s\n", \ 159 printk("BEGIN_LP_RING(%d)\n", (n)); \
160 n, __FUNCTION__); \
161 if (dev_priv->ring.space < n*4) \ 160 if (dev_priv->ring.space < n*4) \
162 i830_wait_ring(dev, n*4, __FUNCTION__); \ 161 i830_wait_ring(dev, n*4, __FUNCTION__); \
163 outcount = 0; \ 162 outcount = 0; \
@@ -183,7 +182,7 @@ extern int i830_driver_device_is_agp(struct drm_device * dev);
183 182
184extern int i830_wait_ring(struct drm_device * dev, int n, const char *caller); 183extern int i830_wait_ring(struct drm_device * dev, int n, const char *caller);
185 184
186#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23)) 185#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
187#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23)) 186#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
188#define CMD_REPORT_HEAD (7<<23) 187#define CMD_REPORT_HEAD (7<<23)
189#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1) 188#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
@@ -203,30 +202,30 @@ extern int i830_wait_ring(struct drm_device * dev, int n, const char *caller);
203 202
204#define I830REG_HWSTAM 0x02098 203#define I830REG_HWSTAM 0x02098
205#define I830REG_INT_IDENTITY_R 0x020a4 204#define I830REG_INT_IDENTITY_R 0x020a4
206#define I830REG_INT_MASK_R 0x020a8 205#define I830REG_INT_MASK_R 0x020a8
207#define I830REG_INT_ENABLE_R 0x020a0 206#define I830REG_INT_ENABLE_R 0x020a0
208 207
209#define I830_IRQ_RESERVED ((1<<13)|(3<<2)) 208#define I830_IRQ_RESERVED ((1<<13)|(3<<2))
210 209
211#define LP_RING 0x2030 210#define LP_RING 0x2030
212#define HP_RING 0x2040 211#define HP_RING 0x2040
213#define RING_TAIL 0x00 212#define RING_TAIL 0x00
214#define TAIL_ADDR 0x001FFFF8 213#define TAIL_ADDR 0x001FFFF8
215#define RING_HEAD 0x04 214#define RING_HEAD 0x04
216#define HEAD_WRAP_COUNT 0xFFE00000 215#define HEAD_WRAP_COUNT 0xFFE00000
217#define HEAD_WRAP_ONE 0x00200000 216#define HEAD_WRAP_ONE 0x00200000
218#define HEAD_ADDR 0x001FFFFC 217#define HEAD_ADDR 0x001FFFFC
219#define RING_START 0x08 218#define RING_START 0x08
220#define START_ADDR 0x0xFFFFF000 219#define START_ADDR 0x0xFFFFF000
221#define RING_LEN 0x0C 220#define RING_LEN 0x0C
222#define RING_NR_PAGES 0x001FF000 221#define RING_NR_PAGES 0x001FF000
223#define RING_REPORT_MASK 0x00000006 222#define RING_REPORT_MASK 0x00000006
224#define RING_REPORT_64K 0x00000002 223#define RING_REPORT_64K 0x00000002
225#define RING_REPORT_128K 0x00000004 224#define RING_REPORT_128K 0x00000004
226#define RING_NO_REPORT 0x00000000 225#define RING_NO_REPORT 0x00000000
227#define RING_VALID_MASK 0x00000001 226#define RING_VALID_MASK 0x00000001
228#define RING_VALID 0x00000001 227#define RING_VALID 0x00000001
229#define RING_INVALID 0x00000000 228#define RING_INVALID 0x00000000
230 229
231#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 230#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
232#define SC_UPDATE_SCISSOR (0x1<<1) 231#define SC_UPDATE_SCISSOR (0x1<<1)
@@ -279,9 +278,9 @@ extern int i830_wait_ring(struct drm_device * dev, int n, const char *caller);
279#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21) 278#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
280#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20) 279#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
281 280
282#define MI_BATCH_BUFFER ((0x30<<23)|1) 281#define MI_BATCH_BUFFER ((0x30<<23)|1)
283#define MI_BATCH_BUFFER_START (0x31<<23) 282#define MI_BATCH_BUFFER_START (0x31<<23)
284#define MI_BATCH_BUFFER_END (0xA<<23) 283#define MI_BATCH_BUFFER_END (0xA<<23)
285#define MI_BATCH_NON_SECURE (1) 284#define MI_BATCH_NON_SECURE (1)
286 285
287#define MI_WAIT_FOR_EVENT ((0x3<<23)) 286#define MI_WAIT_FOR_EVENT ((0x3<<23))
diff --git a/drivers/char/drm/i830_irq.c b/drivers/char/drm/i830_irq.c
index 76403f4b6200..a33db5f0967f 100644
--- a/drivers/char/drm/i830_irq.c
+++ b/drivers/char/drm/i830_irq.c
@@ -144,7 +144,7 @@ int i830_irq_wait(struct drm_device *dev, void *data,
144 struct drm_file *file_priv) 144 struct drm_file *file_priv)
145{ 145{
146 drm_i830_private_t *dev_priv = dev->dev_private; 146 drm_i830_private_t *dev_priv = dev->dev_private;
147 drm_i830_irq_wait_t *irqwait = data; 147 drm_i830_irq_wait_t *irqwait = data;
148 148
149 if (!dev_priv) { 149 if (!dev_priv) {
150 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 150 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index e61a43e5b3ac..43986d81ae34 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -31,17 +31,6 @@
31#include "i915_drm.h" 31#include "i915_drm.h"
32#include "i915_drv.h" 32#include "i915_drv.h"
33 33
34#define IS_I965G(dev) (dev->pci_device == 0x2972 || \
35 dev->pci_device == 0x2982 || \
36 dev->pci_device == 0x2992 || \
37 dev->pci_device == 0x29A2 || \
38 dev->pci_device == 0x2A02 || \
39 dev->pci_device == 0x2A12)
40
41#define IS_G33(dev) (dev->pci_device == 0x29b2 || \
42 dev->pci_device == 0x29c2 || \
43 dev->pci_device == 0x29d2)
44
45/* Really want an OS-independent resettable timer. Would like to have 34/* Really want an OS-independent resettable timer. Would like to have
46 * this loop run for (eg) 3 sec, but have the timer reset every time 35 * this loop run for (eg) 3 sec, but have the timer reset every time
47 * the head pointer changes, so that EBUSY only happens if the ring 36 * the head pointer changes, so that EBUSY only happens if the ring
@@ -90,6 +79,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
90 79
91static int i915_dma_cleanup(struct drm_device * dev) 80static int i915_dma_cleanup(struct drm_device * dev)
92{ 81{
82 drm_i915_private_t *dev_priv = dev->dev_private;
93 /* Make sure interrupts are disabled here because the uninstall ioctl 83 /* Make sure interrupts are disabled here because the uninstall ioctl
94 * may not have been called from userspace and after dev_private 84 * may not have been called from userspace and after dev_private
95 * is freed, it's too late. 85 * is freed, it's too late.
@@ -97,52 +87,42 @@ static int i915_dma_cleanup(struct drm_device * dev)
97 if (dev->irq) 87 if (dev->irq)
98 drm_irq_uninstall(dev); 88 drm_irq_uninstall(dev);
99 89
100 if (dev->dev_private) { 90 if (dev_priv->ring.virtual_start) {
101 drm_i915_private_t *dev_priv = 91 drm_core_ioremapfree(&dev_priv->ring.map, dev);
102 (drm_i915_private_t *) dev->dev_private; 92 dev_priv->ring.virtual_start = 0;
103 93 dev_priv->ring.map.handle = 0;
104 if (dev_priv->ring.virtual_start) { 94 dev_priv->ring.map.size = 0;
105 drm_core_ioremapfree(&dev_priv->ring.map, dev); 95 }
106 }
107
108 if (dev_priv->status_page_dmah) {
109 drm_pci_free(dev, dev_priv->status_page_dmah);
110 /* Need to rewrite hardware status page */
111 I915_WRITE(0x02080, 0x1ffff000);
112 }
113
114 if (dev_priv->status_gfx_addr) {
115 dev_priv->status_gfx_addr = 0;
116 drm_core_ioremapfree(&dev_priv->hws_map, dev);
117 I915_WRITE(0x2080, 0x1ffff000);
118 }
119 96
120 drm_free(dev->dev_private, sizeof(drm_i915_private_t), 97 if (dev_priv->status_page_dmah) {
121 DRM_MEM_DRIVER); 98 drm_pci_free(dev, dev_priv->status_page_dmah);
99 dev_priv->status_page_dmah = NULL;
100 /* Need to rewrite hardware status page */
101 I915_WRITE(0x02080, 0x1ffff000);
102 }
122 103
123 dev->dev_private = NULL; 104 if (dev_priv->status_gfx_addr) {
105 dev_priv->status_gfx_addr = 0;
106 drm_core_ioremapfree(&dev_priv->hws_map, dev);
107 I915_WRITE(0x2080, 0x1ffff000);
124 } 108 }
125 109
126 return 0; 110 return 0;
127} 111}
128 112
129static int i915_initialize(struct drm_device * dev, 113static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
130 drm_i915_private_t * dev_priv,
131 drm_i915_init_t * init)
132{ 114{
133 memset(dev_priv, 0, sizeof(drm_i915_private_t)); 115 drm_i915_private_t *dev_priv = dev->dev_private;
134 116
135 dev_priv->sarea = drm_getsarea(dev); 117 dev_priv->sarea = drm_getsarea(dev);
136 if (!dev_priv->sarea) { 118 if (!dev_priv->sarea) {
137 DRM_ERROR("can not find sarea!\n"); 119 DRM_ERROR("can not find sarea!\n");
138 dev->dev_private = (void *)dev_priv;
139 i915_dma_cleanup(dev); 120 i915_dma_cleanup(dev);
140 return -EINVAL; 121 return -EINVAL;
141 } 122 }
142 123
143 dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset); 124 dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset);
144 if (!dev_priv->mmio_map) { 125 if (!dev_priv->mmio_map) {
145 dev->dev_private = (void *)dev_priv;
146 i915_dma_cleanup(dev); 126 i915_dma_cleanup(dev);
147 DRM_ERROR("can not find mmio map!\n"); 127 DRM_ERROR("can not find mmio map!\n");
148 return -EINVAL; 128 return -EINVAL;
@@ -165,7 +145,6 @@ static int i915_initialize(struct drm_device * dev,
165 drm_core_ioremap(&dev_priv->ring.map, dev); 145 drm_core_ioremap(&dev_priv->ring.map, dev);
166 146
167 if (dev_priv->ring.map.handle == NULL) { 147 if (dev_priv->ring.map.handle == NULL) {
168 dev->dev_private = (void *)dev_priv;
169 i915_dma_cleanup(dev); 148 i915_dma_cleanup(dev);
170 DRM_ERROR("can not ioremap virtual address for" 149 DRM_ERROR("can not ioremap virtual address for"
171 " ring buffer\n"); 150 " ring buffer\n");
@@ -197,7 +176,6 @@ static int i915_initialize(struct drm_device * dev,
197 drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); 176 drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff);
198 177
199 if (!dev_priv->status_page_dmah) { 178 if (!dev_priv->status_page_dmah) {
200 dev->dev_private = (void *)dev_priv;
201 i915_dma_cleanup(dev); 179 i915_dma_cleanup(dev);
202 DRM_ERROR("Can not allocate hardware status page\n"); 180 DRM_ERROR("Can not allocate hardware status page\n");
203 return -ENOMEM; 181 return -ENOMEM;
@@ -209,7 +187,6 @@ static int i915_initialize(struct drm_device * dev,
209 I915_WRITE(0x02080, dev_priv->dma_status_page); 187 I915_WRITE(0x02080, dev_priv->dma_status_page);
210 } 188 }
211 DRM_DEBUG("Enabled hardware status page\n"); 189 DRM_DEBUG("Enabled hardware status page\n");
212 dev->dev_private = (void *)dev_priv;
213 return 0; 190 return 0;
214} 191}
215 192
@@ -254,17 +231,12 @@ static int i915_dma_resume(struct drm_device * dev)
254static int i915_dma_init(struct drm_device *dev, void *data, 231static int i915_dma_init(struct drm_device *dev, void *data,
255 struct drm_file *file_priv) 232 struct drm_file *file_priv)
256{ 233{
257 drm_i915_private_t *dev_priv;
258 drm_i915_init_t *init = data; 234 drm_i915_init_t *init = data;
259 int retcode = 0; 235 int retcode = 0;
260 236
261 switch (init->func) { 237 switch (init->func) {
262 case I915_INIT_DMA: 238 case I915_INIT_DMA:
263 dev_priv = drm_alloc(sizeof(drm_i915_private_t), 239 retcode = i915_initialize(dev, init);
264 DRM_MEM_DRIVER);
265 if (dev_priv == NULL)
266 return -ENOMEM;
267 retcode = i915_initialize(dev, dev_priv, init);
268 break; 240 break;
269 case I915_CLEANUP_DMA: 241 case I915_CLEANUP_DMA:
270 retcode = i915_dma_cleanup(dev); 242 retcode = i915_dma_cleanup(dev);
@@ -351,7 +323,7 @@ static int validate_cmd(int cmd)
351{ 323{
352 int ret = do_validate_cmd(cmd); 324 int ret = do_validate_cmd(cmd);
353 325
354/* printk("validate_cmd( %x ): %d\n", cmd, ret); */ 326/* printk("validate_cmd( %x ): %d\n", cmd, ret); */
355 327
356 return ret; 328 return ret;
357} 329}
@@ -685,7 +657,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
685 int value; 657 int value;
686 658
687 if (!dev_priv) { 659 if (!dev_priv) {
688 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 660 DRM_ERROR("called with no initialization\n");
689 return -EINVAL; 661 return -EINVAL;
690 } 662 }
691 663
@@ -719,7 +691,7 @@ static int i915_setparam(struct drm_device *dev, void *data,
719 drm_i915_setparam_t *param = data; 691 drm_i915_setparam_t *param = data;
720 692
721 if (!dev_priv) { 693 if (!dev_priv) {
722 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 694 DRM_ERROR("called with no initialization\n");
723 return -EINVAL; 695 return -EINVAL;
724 } 696 }
725 697
@@ -749,7 +721,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
749 drm_i915_hws_addr_t *hws = data; 721 drm_i915_hws_addr_t *hws = data;
750 722
751 if (!dev_priv) { 723 if (!dev_priv) {
752 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 724 DRM_ERROR("called with no initialization\n");
753 return -EINVAL; 725 return -EINVAL;
754 } 726 }
755 727
@@ -757,7 +729,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
757 729
758 dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12); 730 dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12);
759 731
760 dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws->addr; 732 dev_priv->hws_map.offset = dev->agp->base + hws->addr;
761 dev_priv->hws_map.size = 4*1024; 733 dev_priv->hws_map.size = 4*1024;
762 dev_priv->hws_map.type = 0; 734 dev_priv->hws_map.type = 0;
763 dev_priv->hws_map.flags = 0; 735 dev_priv->hws_map.flags = 0;
@@ -765,7 +737,6 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
765 737
766 drm_core_ioremap(&dev_priv->hws_map, dev); 738 drm_core_ioremap(&dev_priv->hws_map, dev);
767 if (dev_priv->hws_map.handle == NULL) { 739 if (dev_priv->hws_map.handle == NULL) {
768 dev->dev_private = (void *)dev_priv;
769 i915_dma_cleanup(dev); 740 i915_dma_cleanup(dev);
770 dev_priv->status_gfx_addr = 0; 741 dev_priv->status_gfx_addr = 0;
771 DRM_ERROR("can not ioremap virtual address for" 742 DRM_ERROR("can not ioremap virtual address for"
@@ -784,6 +755,10 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
784 755
785int i915_driver_load(struct drm_device *dev, unsigned long flags) 756int i915_driver_load(struct drm_device *dev, unsigned long flags)
786{ 757{
758 struct drm_i915_private *dev_priv = dev->dev_private;
759 unsigned long base, size;
760 int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1;
761
787 /* i915 has 4 more counters */ 762 /* i915 has 4 more counters */
788 dev->counters += 4; 763 dev->counters += 4;
789 dev->types[6] = _DRM_STAT_IRQ; 764 dev->types[6] = _DRM_STAT_IRQ;
@@ -791,24 +766,51 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
791 dev->types[8] = _DRM_STAT_SECONDARY; 766 dev->types[8] = _DRM_STAT_SECONDARY;
792 dev->types[9] = _DRM_STAT_DMA; 767 dev->types[9] = _DRM_STAT_DMA;
793 768
769 dev_priv = drm_alloc(sizeof(drm_i915_private_t), DRM_MEM_DRIVER);
770 if (dev_priv == NULL)
771 return -ENOMEM;
772
773 memset(dev_priv, 0, sizeof(drm_i915_private_t));
774
775 dev->dev_private = (void *)dev_priv;
776
777 /* Add register map (needed for suspend/resume) */
778 base = drm_get_resource_start(dev, mmio_bar);
779 size = drm_get_resource_len(dev, mmio_bar);
780
781 ret = drm_addmap(dev, base, size, _DRM_REGISTERS,
782 _DRM_KERNEL | _DRM_DRIVER,
783 &dev_priv->mmio_map);
784 return ret;
785}
786
787int i915_driver_unload(struct drm_device *dev)
788{
789 struct drm_i915_private *dev_priv = dev->dev_private;
790
791 if (dev_priv->mmio_map)
792 drm_rmmap(dev, dev_priv->mmio_map);
793
794 drm_free(dev->dev_private, sizeof(drm_i915_private_t),
795 DRM_MEM_DRIVER);
796
794 return 0; 797 return 0;
795} 798}
796 799
797void i915_driver_lastclose(struct drm_device * dev) 800void i915_driver_lastclose(struct drm_device * dev)
798{ 801{
799 if (dev->dev_private) { 802 drm_i915_private_t *dev_priv = dev->dev_private;
800 drm_i915_private_t *dev_priv = dev->dev_private; 803
804 if (dev_priv->agp_heap)
801 i915_mem_takedown(&(dev_priv->agp_heap)); 805 i915_mem_takedown(&(dev_priv->agp_heap));
802 } 806
803 i915_dma_cleanup(dev); 807 i915_dma_cleanup(dev);
804} 808}
805 809
806void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) 810void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
807{ 811{
808 if (dev->dev_private) { 812 drm_i915_private_t *dev_priv = dev->dev_private;
809 drm_i915_private_t *dev_priv = dev->dev_private; 813 i915_mem_release(dev, file_priv, dev_priv->agp_heap);
810 i915_mem_release(dev, file_priv, dev_priv->agp_heap);
811 }
812} 814}
813 815
814struct drm_ioctl_desc i915_ioctls[] = { 816struct drm_ioctl_desc i915_ioctls[] = {
diff --git a/drivers/char/drm/i915_drv.c b/drivers/char/drm/i915_drv.c
index 85bcc276f804..52e51033d32c 100644
--- a/drivers/char/drm/i915_drv.c
+++ b/drivers/char/drm/i915_drv.c
@@ -38,6 +38,465 @@ static struct pci_device_id pciidlist[] = {
38 i915_PCI_IDS 38 i915_PCI_IDS
39}; 39};
40 40
41enum pipe {
42 PIPE_A = 0,
43 PIPE_B,
44};
45
46static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe)
47{
48 struct drm_i915_private *dev_priv = dev->dev_private;
49
50 if (pipe == PIPE_A)
51 return (I915_READ(DPLL_A) & DPLL_VCO_ENABLE);
52 else
53 return (I915_READ(DPLL_B) & DPLL_VCO_ENABLE);
54}
55
56static void i915_save_palette(struct drm_device *dev, enum pipe pipe)
57{
58 struct drm_i915_private *dev_priv = dev->dev_private;
59 unsigned long reg = (pipe == PIPE_A ? PALETTE_A : PALETTE_B);
60 u32 *array;
61 int i;
62
63 if (!i915_pipe_enabled(dev, pipe))
64 return;
65
66 if (pipe == PIPE_A)
67 array = dev_priv->save_palette_a;
68 else
69 array = dev_priv->save_palette_b;
70
71 for(i = 0; i < 256; i++)
72 array[i] = I915_READ(reg + (i << 2));
73}
74
75static void i915_restore_palette(struct drm_device *dev, enum pipe pipe)
76{
77 struct drm_i915_private *dev_priv = dev->dev_private;
78 unsigned long reg = (pipe == PIPE_A ? PALETTE_A : PALETTE_B);
79 u32 *array;
80 int i;
81
82 if (!i915_pipe_enabled(dev, pipe))
83 return;
84
85 if (pipe == PIPE_A)
86 array = dev_priv->save_palette_a;
87 else
88 array = dev_priv->save_palette_b;
89
90 for(i = 0; i < 256; i++)
91 I915_WRITE(reg + (i << 2), array[i]);
92}
93
94static u8 i915_read_indexed(u16 index_port, u16 data_port, u8 reg)
95{
96 outb(reg, index_port);
97 return inb(data_port);
98}
99
100static u8 i915_read_ar(u16 st01, u8 reg, u16 palette_enable)
101{
102 inb(st01);
103 outb(palette_enable | reg, VGA_AR_INDEX);
104 return inb(VGA_AR_DATA_READ);
105}
106
107static void i915_write_ar(u8 st01, u8 reg, u8 val, u16 palette_enable)
108{
109 inb(st01);
110 outb(palette_enable | reg, VGA_AR_INDEX);
111 outb(val, VGA_AR_DATA_WRITE);
112}
113
114static void i915_write_indexed(u16 index_port, u16 data_port, u8 reg, u8 val)
115{
116 outb(reg, index_port);
117 outb(val, data_port);
118}
119
120static void i915_save_vga(struct drm_device *dev)
121{
122 struct drm_i915_private *dev_priv = dev->dev_private;
123 int i;
124 u16 cr_index, cr_data, st01;
125
126 /* VGA color palette registers */
127 dev_priv->saveDACMASK = inb(VGA_DACMASK);
128 /* DACCRX automatically increments during read */
129 outb(0, VGA_DACRX);
130 /* Read 3 bytes of color data from each index */
131 for (i = 0; i < 256 * 3; i++)
132 dev_priv->saveDACDATA[i] = inb(VGA_DACDATA);
133
134 /* MSR bits */
135 dev_priv->saveMSR = inb(VGA_MSR_READ);
136 if (dev_priv->saveMSR & VGA_MSR_CGA_MODE) {
137 cr_index = VGA_CR_INDEX_CGA;
138 cr_data = VGA_CR_DATA_CGA;
139 st01 = VGA_ST01_CGA;
140 } else {
141 cr_index = VGA_CR_INDEX_MDA;
142 cr_data = VGA_CR_DATA_MDA;
143 st01 = VGA_ST01_MDA;
144 }
145
146 /* CRT controller regs */
147 i915_write_indexed(cr_index, cr_data, 0x11,
148 i915_read_indexed(cr_index, cr_data, 0x11) &
149 (~0x80));
150 for (i = 0; i < 0x24; i++)
151 dev_priv->saveCR[i] =
152 i915_read_indexed(cr_index, cr_data, i);
153 /* Make sure we don't turn off CR group 0 writes */
154 dev_priv->saveCR[0x11] &= ~0x80;
155
156 /* Attribute controller registers */
157 inb(st01);
158 dev_priv->saveAR_INDEX = inb(VGA_AR_INDEX);
159 for (i = 0; i < 20; i++)
160 dev_priv->saveAR[i] = i915_read_ar(st01, i, 0);
161 inb(st01);
162 outb(dev_priv->saveAR_INDEX, VGA_AR_INDEX);
163
164 /* Graphics controller registers */
165 for (i = 0; i < 9; i++)
166 dev_priv->saveGR[i] =
167 i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, i);
168
169 dev_priv->saveGR[0x10] =
170 i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x10);
171 dev_priv->saveGR[0x11] =
172 i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x11);
173 dev_priv->saveGR[0x18] =
174 i915_read_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x18);
175
176 /* Sequencer registers */
177 for (i = 0; i < 8; i++)
178 dev_priv->saveSR[i] =
179 i915_read_indexed(VGA_SR_INDEX, VGA_SR_DATA, i);
180}
181
182static void i915_restore_vga(struct drm_device *dev)
183{
184 struct drm_i915_private *dev_priv = dev->dev_private;
185 int i;
186 u16 cr_index, cr_data, st01;
187
188 /* MSR bits */
189 outb(dev_priv->saveMSR, VGA_MSR_WRITE);
190 if (dev_priv->saveMSR & VGA_MSR_CGA_MODE) {
191 cr_index = VGA_CR_INDEX_CGA;
192 cr_data = VGA_CR_DATA_CGA;
193 st01 = VGA_ST01_CGA;
194 } else {
195 cr_index = VGA_CR_INDEX_MDA;
196 cr_data = VGA_CR_DATA_MDA;
197 st01 = VGA_ST01_MDA;
198 }
199
200 /* Sequencer registers, don't write SR07 */
201 for (i = 0; i < 7; i++)
202 i915_write_indexed(VGA_SR_INDEX, VGA_SR_DATA, i,
203 dev_priv->saveSR[i]);
204
205 /* CRT controller regs */
206 /* Enable CR group 0 writes */
207 i915_write_indexed(cr_index, cr_data, 0x11, dev_priv->saveCR[0x11]);
208 for (i = 0; i < 0x24; i++)
209 i915_write_indexed(cr_index, cr_data, i, dev_priv->saveCR[i]);
210
211 /* Graphics controller regs */
212 for (i = 0; i < 9; i++)
213 i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, i,
214 dev_priv->saveGR[i]);
215
216 i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x10,
217 dev_priv->saveGR[0x10]);
218 i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x11,
219 dev_priv->saveGR[0x11]);
220 i915_write_indexed(VGA_GR_INDEX, VGA_GR_DATA, 0x18,
221 dev_priv->saveGR[0x18]);
222
223 /* Attribute controller registers */
224 for (i = 0; i < 20; i++)
225 i915_write_ar(st01, i, dev_priv->saveAR[i], 0);
226 inb(st01); /* switch back to index mode */
227 outb(dev_priv->saveAR_INDEX | 0x20, VGA_AR_INDEX);
228
229 /* VGA color palette registers */
230 outb(dev_priv->saveDACMASK, VGA_DACMASK);
231 /* DACCRX automatically increments during read */
232 outb(0, VGA_DACWX);
233 /* Read 3 bytes of color data from each index */
234 for (i = 0; i < 256 * 3; i++)
235 outb(dev_priv->saveDACDATA[i], VGA_DACDATA);
236
237}
238
239static int i915_suspend(struct drm_device *dev)
240{
241 struct drm_i915_private *dev_priv = dev->dev_private;
242 int i;
243
244 if (!dev || !dev_priv) {
245 printk(KERN_ERR "dev: %p, dev_priv: %p\n", dev, dev_priv);
246 printk(KERN_ERR "DRM not initialized, aborting suspend.\n");
247 return -ENODEV;
248 }
249
250 pci_save_state(dev->pdev);
251 pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB);
252
253 /* Pipe & plane A info */
254 dev_priv->savePIPEACONF = I915_READ(PIPEACONF);
255 dev_priv->savePIPEASRC = I915_READ(PIPEASRC);
256 dev_priv->saveFPA0 = I915_READ(FPA0);
257 dev_priv->saveFPA1 = I915_READ(FPA1);
258 dev_priv->saveDPLL_A = I915_READ(DPLL_A);
259 if (IS_I965G(dev))
260 dev_priv->saveDPLL_A_MD = I915_READ(DPLL_A_MD);
261 dev_priv->saveHTOTAL_A = I915_READ(HTOTAL_A);
262 dev_priv->saveHBLANK_A = I915_READ(HBLANK_A);
263 dev_priv->saveHSYNC_A = I915_READ(HSYNC_A);
264 dev_priv->saveVTOTAL_A = I915_READ(VTOTAL_A);
265 dev_priv->saveVBLANK_A = I915_READ(VBLANK_A);
266 dev_priv->saveVSYNC_A = I915_READ(VSYNC_A);
267 dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A);
268
269 dev_priv->saveDSPACNTR = I915_READ(DSPACNTR);
270 dev_priv->saveDSPASTRIDE = I915_READ(DSPASTRIDE);
271 dev_priv->saveDSPASIZE = I915_READ(DSPASIZE);
272 dev_priv->saveDSPAPOS = I915_READ(DSPAPOS);
273 dev_priv->saveDSPABASE = I915_READ(DSPABASE);
274 if (IS_I965G(dev)) {
275 dev_priv->saveDSPASURF = I915_READ(DSPASURF);
276 dev_priv->saveDSPATILEOFF = I915_READ(DSPATILEOFF);
277 }
278 i915_save_palette(dev, PIPE_A);
279
280 /* Pipe & plane B info */
281 dev_priv->savePIPEBCONF = I915_READ(PIPEBCONF);
282 dev_priv->savePIPEBSRC = I915_READ(PIPEBSRC);
283 dev_priv->saveFPB0 = I915_READ(FPB0);
284 dev_priv->saveFPB1 = I915_READ(FPB1);
285 dev_priv->saveDPLL_B = I915_READ(DPLL_B);
286 if (IS_I965G(dev))
287 dev_priv->saveDPLL_B_MD = I915_READ(DPLL_B_MD);
288 dev_priv->saveHTOTAL_B = I915_READ(HTOTAL_B);
289 dev_priv->saveHBLANK_B = I915_READ(HBLANK_B);
290 dev_priv->saveHSYNC_B = I915_READ(HSYNC_B);
291 dev_priv->saveVTOTAL_B = I915_READ(VTOTAL_B);
292 dev_priv->saveVBLANK_B = I915_READ(VBLANK_B);
293 dev_priv->saveVSYNC_B = I915_READ(VSYNC_B);
294 dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A);
295
296 dev_priv->saveDSPBCNTR = I915_READ(DSPBCNTR);
297 dev_priv->saveDSPBSTRIDE = I915_READ(DSPBSTRIDE);
298 dev_priv->saveDSPBSIZE = I915_READ(DSPBSIZE);
299 dev_priv->saveDSPBPOS = I915_READ(DSPBPOS);
300 dev_priv->saveDSPBBASE = I915_READ(DSPBBASE);
301 if (IS_I965GM(dev) || IS_IGD_GM(dev)) {
302 dev_priv->saveDSPBSURF = I915_READ(DSPBSURF);
303 dev_priv->saveDSPBTILEOFF = I915_READ(DSPBTILEOFF);
304 }
305 i915_save_palette(dev, PIPE_B);
306
307 /* CRT state */
308 dev_priv->saveADPA = I915_READ(ADPA);
309
310 /* LVDS state */
311 dev_priv->savePP_CONTROL = I915_READ(PP_CONTROL);
312 dev_priv->savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS);
313 dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL);
314 if (IS_I965G(dev))
315 dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2);
316 if (IS_MOBILE(dev) && !IS_I830(dev))
317 dev_priv->saveLVDS = I915_READ(LVDS);
318 if (!IS_I830(dev) && !IS_845G(dev))
319 dev_priv->savePFIT_CONTROL = I915_READ(PFIT_CONTROL);
320 dev_priv->saveLVDSPP_ON = I915_READ(LVDSPP_ON);
321 dev_priv->saveLVDSPP_OFF = I915_READ(LVDSPP_OFF);
322 dev_priv->savePP_CYCLE = I915_READ(PP_CYCLE);
323
324 /* FIXME: save TV & SDVO state */
325
326 /* FBC state */
327 dev_priv->saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE);
328 dev_priv->saveFBC_LL_BASE = I915_READ(FBC_LL_BASE);
329 dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2);
330 dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL);
331
332 /* VGA state */
333 dev_priv->saveVCLK_DIVISOR_VGA0 = I915_READ(VCLK_DIVISOR_VGA0);
334 dev_priv->saveVCLK_DIVISOR_VGA1 = I915_READ(VCLK_DIVISOR_VGA1);
335 dev_priv->saveVCLK_POST_DIV = I915_READ(VCLK_POST_DIV);
336 dev_priv->saveVGACNTRL = I915_READ(VGACNTRL);
337
338 /* Scratch space */
339 for (i = 0; i < 16; i++) {
340 dev_priv->saveSWF0[i] = I915_READ(SWF0 + (i << 2));
341 dev_priv->saveSWF1[i] = I915_READ(SWF10 + (i << 2));
342 }
343 for (i = 0; i < 3; i++)
344 dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2));
345
346 i915_save_vga(dev);
347
348 /* Shut down the device */
349 pci_disable_device(dev->pdev);
350 pci_set_power_state(dev->pdev, PCI_D3hot);
351
352 return 0;
353}
354
355static int i915_resume(struct drm_device *dev)
356{
357 struct drm_i915_private *dev_priv = dev->dev_private;
358 int i;
359
360 pci_set_power_state(dev->pdev, PCI_D0);
361 pci_restore_state(dev->pdev);
362 if (pci_enable_device(dev->pdev))
363 return -1;
364
365 pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB);
366
367 /* Pipe & plane A info */
368 /* Prime the clock */
369 if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) {
370 I915_WRITE(DPLL_A, dev_priv->saveDPLL_A &
371 ~DPLL_VCO_ENABLE);
372 udelay(150);
373 }
374 I915_WRITE(FPA0, dev_priv->saveFPA0);
375 I915_WRITE(FPA1, dev_priv->saveFPA1);
376 /* Actually enable it */
377 I915_WRITE(DPLL_A, dev_priv->saveDPLL_A);
378 udelay(150);
379 if (IS_I965G(dev))
380 I915_WRITE(DPLL_A_MD, dev_priv->saveDPLL_A_MD);
381 udelay(150);
382
383 /* Restore mode */
384 I915_WRITE(HTOTAL_A, dev_priv->saveHTOTAL_A);
385 I915_WRITE(HBLANK_A, dev_priv->saveHBLANK_A);
386 I915_WRITE(HSYNC_A, dev_priv->saveHSYNC_A);
387 I915_WRITE(VTOTAL_A, dev_priv->saveVTOTAL_A);
388 I915_WRITE(VBLANK_A, dev_priv->saveVBLANK_A);
389 I915_WRITE(VSYNC_A, dev_priv->saveVSYNC_A);
390 I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A);
391
392 /* Restore plane info */
393 I915_WRITE(DSPASIZE, dev_priv->saveDSPASIZE);
394 I915_WRITE(DSPAPOS, dev_priv->saveDSPAPOS);
395 I915_WRITE(PIPEASRC, dev_priv->savePIPEASRC);
396 I915_WRITE(DSPABASE, dev_priv->saveDSPABASE);
397 I915_WRITE(DSPASTRIDE, dev_priv->saveDSPASTRIDE);
398 if (IS_I965G(dev)) {
399 I915_WRITE(DSPASURF, dev_priv->saveDSPASURF);
400 I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF);
401 }
402
403 if ((dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) &&
404 (dev_priv->saveDPLL_A & DPLL_VGA_MODE_DIS))
405 I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF);
406
407 i915_restore_palette(dev, PIPE_A);
408 /* Enable the plane */
409 I915_WRITE(DSPACNTR, dev_priv->saveDSPACNTR);
410 I915_WRITE(DSPABASE, I915_READ(DSPABASE));
411
412 /* Pipe & plane B info */
413 if (dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) {
414 I915_WRITE(DPLL_B, dev_priv->saveDPLL_B &
415 ~DPLL_VCO_ENABLE);
416 udelay(150);
417 }
418 I915_WRITE(FPB0, dev_priv->saveFPB0);
419 I915_WRITE(FPB1, dev_priv->saveFPB1);
420 /* Actually enable it */
421 I915_WRITE(DPLL_B, dev_priv->saveDPLL_B);
422 udelay(150);
423 if (IS_I965G(dev))
424 I915_WRITE(DPLL_B_MD, dev_priv->saveDPLL_B_MD);
425 udelay(150);
426
427 /* Restore mode */
428 I915_WRITE(HTOTAL_B, dev_priv->saveHTOTAL_B);
429 I915_WRITE(HBLANK_B, dev_priv->saveHBLANK_B);
430 I915_WRITE(HSYNC_B, dev_priv->saveHSYNC_B);
431 I915_WRITE(VTOTAL_B, dev_priv->saveVTOTAL_B);
432 I915_WRITE(VBLANK_B, dev_priv->saveVBLANK_B);
433 I915_WRITE(VSYNC_B, dev_priv->saveVSYNC_B);
434 I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B);
435
436 /* Restore plane info */
437 I915_WRITE(DSPBSIZE, dev_priv->saveDSPBSIZE);
438 I915_WRITE(DSPBPOS, dev_priv->saveDSPBPOS);
439 I915_WRITE(PIPEBSRC, dev_priv->savePIPEBSRC);
440 I915_WRITE(DSPBBASE, dev_priv->saveDSPBBASE);
441 I915_WRITE(DSPBSTRIDE, dev_priv->saveDSPBSTRIDE);
442 if (IS_I965G(dev)) {
443 I915_WRITE(DSPBSURF, dev_priv->saveDSPBSURF);
444 I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF);
445 }
446
447 if ((dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) &&
448 (dev_priv->saveDPLL_B & DPLL_VGA_MODE_DIS))
449 I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF);
450 i915_restore_palette(dev, PIPE_A);
451 /* Enable the plane */
452 I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR);
453 I915_WRITE(DSPBBASE, I915_READ(DSPBBASE));
454
455 /* CRT state */
456 I915_WRITE(ADPA, dev_priv->saveADPA);
457
458 /* LVDS state */
459 if (IS_I965G(dev))
460 I915_WRITE(BLC_PWM_CTL2, dev_priv->saveBLC_PWM_CTL2);
461 if (IS_MOBILE(dev) && !IS_I830(dev))
462 I915_WRITE(LVDS, dev_priv->saveLVDS);
463 if (!IS_I830(dev) && !IS_845G(dev))
464 I915_WRITE(PFIT_CONTROL, dev_priv->savePFIT_CONTROL);
465
466 I915_WRITE(PFIT_PGM_RATIOS, dev_priv->savePFIT_PGM_RATIOS);
467 I915_WRITE(BLC_PWM_CTL, dev_priv->saveBLC_PWM_CTL);
468 I915_WRITE(LVDSPP_ON, dev_priv->saveLVDSPP_ON);
469 I915_WRITE(LVDSPP_OFF, dev_priv->saveLVDSPP_OFF);
470 I915_WRITE(PP_CYCLE, dev_priv->savePP_CYCLE);
471 I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL);
472
473 /* FIXME: restore TV & SDVO state */
474
475 /* FBC info */
476 I915_WRITE(FBC_CFB_BASE, dev_priv->saveFBC_CFB_BASE);
477 I915_WRITE(FBC_LL_BASE, dev_priv->saveFBC_LL_BASE);
478 I915_WRITE(FBC_CONTROL2, dev_priv->saveFBC_CONTROL2);
479 I915_WRITE(FBC_CONTROL, dev_priv->saveFBC_CONTROL);
480
481 /* VGA state */
482 I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL);
483 I915_WRITE(VCLK_DIVISOR_VGA0, dev_priv->saveVCLK_DIVISOR_VGA0);
484 I915_WRITE(VCLK_DIVISOR_VGA1, dev_priv->saveVCLK_DIVISOR_VGA1);
485 I915_WRITE(VCLK_POST_DIV, dev_priv->saveVCLK_POST_DIV);
486 udelay(150);
487
488 for (i = 0; i < 16; i++) {
489 I915_WRITE(SWF0 + (i << 2), dev_priv->saveSWF0[i]);
490 I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i+7]);
491 }
492 for (i = 0; i < 3; i++)
493 I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]);
494
495 i915_restore_vga(dev);
496
497 return 0;
498}
499
41static struct drm_driver driver = { 500static struct drm_driver driver = {
42 /* don't use mtrr's here, the Xserver or user space app should 501 /* don't use mtrr's here, the Xserver or user space app should
43 * deal with them for intel hardware. 502 * deal with them for intel hardware.
@@ -47,8 +506,11 @@ static struct drm_driver driver = {
47 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL | 506 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL |
48 DRIVER_IRQ_VBL2, 507 DRIVER_IRQ_VBL2,
49 .load = i915_driver_load, 508 .load = i915_driver_load,
509 .unload = i915_driver_unload,
50 .lastclose = i915_driver_lastclose, 510 .lastclose = i915_driver_lastclose,
51 .preclose = i915_driver_preclose, 511 .preclose = i915_driver_preclose,
512 .suspend = i915_suspend,
513 .resume = i915_resume,
52 .device_is_agp = i915_driver_device_is_agp, 514 .device_is_agp = i915_driver_device_is_agp,
53 .vblank_wait = i915_driver_vblank_wait, 515 .vblank_wait = i915_driver_vblank_wait,
54 .vblank_wait2 = i915_driver_vblank_wait2, 516 .vblank_wait2 = i915_driver_vblank_wait2,
@@ -77,7 +539,7 @@ static struct drm_driver driver = {
77 .name = DRIVER_NAME, 539 .name = DRIVER_NAME,
78 .id_table = pciidlist, 540 .id_table = pciidlist,
79 }, 541 },
80 542
81 .name = DRIVER_NAME, 543 .name = DRIVER_NAME,
82 .desc = DRIVER_DESC, 544 .desc = DRIVER_DESC,
83 .date = DRIVER_DATE, 545 .date = DRIVER_DATE,
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index e064292e703a..37bbf6729b4e 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -114,6 +114,85 @@ typedef struct drm_i915_private {
114 spinlock_t swaps_lock; 114 spinlock_t swaps_lock;
115 drm_i915_vbl_swap_t vbl_swaps; 115 drm_i915_vbl_swap_t vbl_swaps;
116 unsigned int swaps_pending; 116 unsigned int swaps_pending;
117
118 /* Register state */
119 u8 saveLBB;
120 u32 saveDSPACNTR;
121 u32 saveDSPBCNTR;
122 u32 savePIPEACONF;
123 u32 savePIPEBCONF;
124 u32 savePIPEASRC;
125 u32 savePIPEBSRC;
126 u32 saveFPA0;
127 u32 saveFPA1;
128 u32 saveDPLL_A;
129 u32 saveDPLL_A_MD;
130 u32 saveHTOTAL_A;
131 u32 saveHBLANK_A;
132 u32 saveHSYNC_A;
133 u32 saveVTOTAL_A;
134 u32 saveVBLANK_A;
135 u32 saveVSYNC_A;
136 u32 saveBCLRPAT_A;
137 u32 saveDSPASTRIDE;
138 u32 saveDSPASIZE;
139 u32 saveDSPAPOS;
140 u32 saveDSPABASE;
141 u32 saveDSPASURF;
142 u32 saveDSPATILEOFF;
143 u32 savePFIT_PGM_RATIOS;
144 u32 saveBLC_PWM_CTL;
145 u32 saveBLC_PWM_CTL2;
146 u32 saveFPB0;
147 u32 saveFPB1;
148 u32 saveDPLL_B;
149 u32 saveDPLL_B_MD;
150 u32 saveHTOTAL_B;
151 u32 saveHBLANK_B;
152 u32 saveHSYNC_B;
153 u32 saveVTOTAL_B;
154 u32 saveVBLANK_B;
155 u32 saveVSYNC_B;
156 u32 saveBCLRPAT_B;
157 u32 saveDSPBSTRIDE;
158 u32 saveDSPBSIZE;
159 u32 saveDSPBPOS;
160 u32 saveDSPBBASE;
161 u32 saveDSPBSURF;
162 u32 saveDSPBTILEOFF;
163 u32 saveVCLK_DIVISOR_VGA0;
164 u32 saveVCLK_DIVISOR_VGA1;
165 u32 saveVCLK_POST_DIV;
166 u32 saveVGACNTRL;
167 u32 saveADPA;
168 u32 saveLVDS;
169 u32 saveLVDSPP_ON;
170 u32 saveLVDSPP_OFF;
171 u32 saveDVOA;
172 u32 saveDVOB;
173 u32 saveDVOC;
174 u32 savePP_ON;
175 u32 savePP_OFF;
176 u32 savePP_CONTROL;
177 u32 savePP_CYCLE;
178 u32 savePFIT_CONTROL;
179 u32 save_palette_a[256];
180 u32 save_palette_b[256];
181 u32 saveFBC_CFB_BASE;
182 u32 saveFBC_LL_BASE;
183 u32 saveFBC_CONTROL;
184 u32 saveFBC_CONTROL2;
185 u32 saveSWF0[16];
186 u32 saveSWF1[16];
187 u32 saveSWF2[3];
188 u8 saveMSR;
189 u8 saveSR[8];
190 u8 saveGR[24];
191 u8 saveAR_INDEX;
192 u8 saveAR[20];
193 u8 saveDACMASK;
194 u8 saveDACDATA[256*3]; /* 256 3-byte colors */
195 u8 saveCR[36];
117} drm_i915_private_t; 196} drm_i915_private_t;
118 197
119extern struct drm_ioctl_desc i915_ioctls[]; 198extern struct drm_ioctl_desc i915_ioctls[];
@@ -122,6 +201,7 @@ extern int i915_max_ioctl;
122 /* i915_dma.c */ 201 /* i915_dma.c */
123extern void i915_kernel_lost_context(struct drm_device * dev); 202extern void i915_kernel_lost_context(struct drm_device * dev);
124extern int i915_driver_load(struct drm_device *, unsigned long flags); 203extern int i915_driver_load(struct drm_device *, unsigned long flags);
204extern int i915_driver_unload(struct drm_device *);
125extern void i915_driver_lastclose(struct drm_device * dev); 205extern void i915_driver_lastclose(struct drm_device * dev);
126extern void i915_driver_preclose(struct drm_device *dev, 206extern void i915_driver_preclose(struct drm_device *dev,
127 struct drm_file *file_priv); 207 struct drm_file *file_priv);
@@ -163,7 +243,7 @@ extern void i915_mem_release(struct drm_device * dev,
163 243
164#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg)) 244#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
165#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val)) 245#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
166#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg)) 246#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
167#define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val)) 247#define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
168 248
169#define I915_VERBOSE 0 249#define I915_VERBOSE 0
@@ -173,9 +253,8 @@ extern void i915_mem_release(struct drm_device * dev,
173 253
174#define BEGIN_LP_RING(n) do { \ 254#define BEGIN_LP_RING(n) do { \
175 if (I915_VERBOSE) \ 255 if (I915_VERBOSE) \
176 DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", \ 256 DRM_DEBUG("BEGIN_LP_RING(%d)\n", (n)); \
177 (n), __FUNCTION__); \ 257 if (dev_priv->ring.space < (n)*4) \
178 if (dev_priv->ring.space < (n)*4) \
179 i915_wait_ring(dev, (n)*4, __FUNCTION__); \ 258 i915_wait_ring(dev, (n)*4, __FUNCTION__); \
180 outcount = 0; \ 259 outcount = 0; \
181 outring = dev_priv->ring.tail; \ 260 outring = dev_priv->ring.tail; \
@@ -200,7 +279,51 @@ extern void i915_mem_release(struct drm_device * dev,
200 279
201extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller); 280extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
202 281
203#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23)) 282/* Extended config space */
283#define LBB 0xf4
284
285/* VGA stuff */
286
287#define VGA_ST01_MDA 0x3ba
288#define VGA_ST01_CGA 0x3da
289
290#define VGA_MSR_WRITE 0x3c2
291#define VGA_MSR_READ 0x3cc
292#define VGA_MSR_MEM_EN (1<<1)
293#define VGA_MSR_CGA_MODE (1<<0)
294
295#define VGA_SR_INDEX 0x3c4
296#define VGA_SR_DATA 0x3c5
297
298#define VGA_AR_INDEX 0x3c0
299#define VGA_AR_VID_EN (1<<5)
300#define VGA_AR_DATA_WRITE 0x3c0
301#define VGA_AR_DATA_READ 0x3c1
302
303#define VGA_GR_INDEX 0x3ce
304#define VGA_GR_DATA 0x3cf
305/* GR05 */
306#define VGA_GR_MEM_READ_MODE_SHIFT 3
307#define VGA_GR_MEM_READ_MODE_PLANE 1
308/* GR06 */
309#define VGA_GR_MEM_MODE_MASK 0xc
310#define VGA_GR_MEM_MODE_SHIFT 2
311#define VGA_GR_MEM_A0000_AFFFF 0
312#define VGA_GR_MEM_A0000_BFFFF 1
313#define VGA_GR_MEM_B0000_B7FFF 2
314#define VGA_GR_MEM_B0000_BFFFF 3
315
316#define VGA_DACMASK 0x3c6
317#define VGA_DACRX 0x3c7
318#define VGA_DACWX 0x3c8
319#define VGA_DACDATA 0x3c9
320
321#define VGA_CR_INDEX_MDA 0x3b4
322#define VGA_CR_DATA_MDA 0x3b5
323#define VGA_CR_INDEX_CGA 0x3d4
324#define VGA_CR_DATA_CGA 0x3d5
325
326#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
204#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23)) 327#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
205#define CMD_REPORT_HEAD (7<<23) 328#define CMD_REPORT_HEAD (7<<23)
206#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1) 329#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
@@ -215,9 +338,47 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
215#define BB1_UNPROTECTED (0<<0) 338#define BB1_UNPROTECTED (0<<0)
216#define BB2_END_ADDR_MASK (~0x7) 339#define BB2_END_ADDR_MASK (~0x7)
217 340
341/* Framebuffer compression */
342#define FBC_CFB_BASE 0x03200 /* 4k page aligned */
343#define FBC_LL_BASE 0x03204 /* 4k page aligned */
344#define FBC_CONTROL 0x03208
345#define FBC_CTL_EN (1<<31)
346#define FBC_CTL_PERIODIC (1<<30)
347#define FBC_CTL_INTERVAL_SHIFT (16)
348#define FBC_CTL_UNCOMPRESSIBLE (1<<14)
349#define FBC_CTL_STRIDE_SHIFT (5)
350#define FBC_CTL_FENCENO (1<<0)
351#define FBC_COMMAND 0x0320c
352#define FBC_CMD_COMPRESS (1<<0)
353#define FBC_STATUS 0x03210
354#define FBC_STAT_COMPRESSING (1<<31)
355#define FBC_STAT_COMPRESSED (1<<30)
356#define FBC_STAT_MODIFIED (1<<29)
357#define FBC_STAT_CURRENT_LINE (1<<0)
358#define FBC_CONTROL2 0x03214
359#define FBC_CTL_FENCE_DBL (0<<4)
360#define FBC_CTL_IDLE_IMM (0<<2)
361#define FBC_CTL_IDLE_FULL (1<<2)
362#define FBC_CTL_IDLE_LINE (2<<2)
363#define FBC_CTL_IDLE_DEBUG (3<<2)
364#define FBC_CTL_CPU_FENCE (1<<1)
365#define FBC_CTL_PLANEA (0<<0)
366#define FBC_CTL_PLANEB (1<<0)
367#define FBC_FENCE_OFF 0x0321b
368
369#define FBC_LL_SIZE (1536)
370#define FBC_LL_PAD (32)
371
372/* Interrupt bits:
373 */
374#define USER_INT_FLAG (1<<1)
375#define VSYNC_PIPEB_FLAG (1<<5)
376#define VSYNC_PIPEA_FLAG (1<<7)
377#define HWB_OOM_FLAG (1<<13) /* binner out of memory */
378
218#define I915REG_HWSTAM 0x02098 379#define I915REG_HWSTAM 0x02098
219#define I915REG_INT_IDENTITY_R 0x020a4 380#define I915REG_INT_IDENTITY_R 0x020a4
220#define I915REG_INT_MASK_R 0x020a8 381#define I915REG_INT_MASK_R 0x020a8
221#define I915REG_INT_ENABLE_R 0x020a0 382#define I915REG_INT_ENABLE_R 0x020a0
222 383
223#define I915REG_PIPEASTAT 0x70024 384#define I915REG_PIPEASTAT 0x70024
@@ -229,7 +390,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
229#define SRX_INDEX 0x3c4 390#define SRX_INDEX 0x3c4
230#define SRX_DATA 0x3c5 391#define SRX_DATA 0x3c5
231#define SR01 1 392#define SR01 1
232#define SR01_SCREEN_OFF (1<<5) 393#define SR01_SCREEN_OFF (1<<5)
233 394
234#define PPCR 0x61204 395#define PPCR 0x61204
235#define PPCR_ON (1<<0) 396#define PPCR_ON (1<<0)
@@ -249,31 +410,129 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
249#define ADPA_DPMS_OFF (3<<10) 410#define ADPA_DPMS_OFF (3<<10)
250 411
251#define NOPID 0x2094 412#define NOPID 0x2094
252#define LP_RING 0x2030 413#define LP_RING 0x2030
253#define HP_RING 0x2040 414#define HP_RING 0x2040
254#define RING_TAIL 0x00 415/* The binner has its own ring buffer:
416 */
417#define HWB_RING 0x2400
418
419#define RING_TAIL 0x00
255#define TAIL_ADDR 0x001FFFF8 420#define TAIL_ADDR 0x001FFFF8
256#define RING_HEAD 0x04 421#define RING_HEAD 0x04
257#define HEAD_WRAP_COUNT 0xFFE00000 422#define HEAD_WRAP_COUNT 0xFFE00000
258#define HEAD_WRAP_ONE 0x00200000 423#define HEAD_WRAP_ONE 0x00200000
259#define HEAD_ADDR 0x001FFFFC 424#define HEAD_ADDR 0x001FFFFC
260#define RING_START 0x08 425#define RING_START 0x08
261#define START_ADDR 0x0xFFFFF000 426#define START_ADDR 0x0xFFFFF000
262#define RING_LEN 0x0C 427#define RING_LEN 0x0C
263#define RING_NR_PAGES 0x001FF000 428#define RING_NR_PAGES 0x001FF000
264#define RING_REPORT_MASK 0x00000006 429#define RING_REPORT_MASK 0x00000006
265#define RING_REPORT_64K 0x00000002 430#define RING_REPORT_64K 0x00000002
266#define RING_REPORT_128K 0x00000004 431#define RING_REPORT_128K 0x00000004
267#define RING_NO_REPORT 0x00000000 432#define RING_NO_REPORT 0x00000000
268#define RING_VALID_MASK 0x00000001 433#define RING_VALID_MASK 0x00000001
269#define RING_VALID 0x00000001 434#define RING_VALID 0x00000001
270#define RING_INVALID 0x00000000 435#define RING_INVALID 0x00000000
436
437/* Instruction parser error reg:
438 */
439#define IPEIR 0x2088
440
441/* Scratch pad debug 0 reg:
442 */
443#define SCPD0 0x209c
444
445/* Error status reg:
446 */
447#define ESR 0x20b8
448
449/* Secondary DMA fetch address debug reg:
450 */
451#define DMA_FADD_S 0x20d4
452
453/* Cache mode 0 reg.
454 * - Manipulating render cache behaviour is central
455 * to the concept of zone rendering, tuning this reg can help avoid
456 * unnecessary render cache reads and even writes (for z/stencil)
457 * at beginning and end of scene.
458 *
459 * - To change a bit, write to this reg with a mask bit set and the
460 * bit of interest either set or cleared. EG: (BIT<<16) | BIT to set.
461 */
462#define Cache_Mode_0 0x2120
463#define CM0_MASK_SHIFT 16
464#define CM0_IZ_OPT_DISABLE (1<<6)
465#define CM0_ZR_OPT_DISABLE (1<<5)
466#define CM0_DEPTH_EVICT_DISABLE (1<<4)
467#define CM0_COLOR_EVICT_DISABLE (1<<3)
468#define CM0_DEPTH_WRITE_DISABLE (1<<1)
469#define CM0_RC_OP_FLUSH_DISABLE (1<<0)
470
471
472/* Graphics flush control. A CPU write flushes the GWB of all writes.
473 * The data is discarded.
474 */
475#define GFX_FLSH_CNTL 0x2170
476
477/* Binner control. Defines the location of the bin pointer list:
478 */
479#define BINCTL 0x2420
480#define BC_MASK (1 << 9)
481
482/* Binned scene info.
483 */
484#define BINSCENE 0x2428
485#define BS_OP_LOAD (1 << 8)
486#define BS_MASK (1 << 22)
487
488/* Bin command parser debug reg:
489 */
490#define BCPD 0x2480
491
492/* Bin memory control debug reg:
493 */
494#define BMCD 0x2484
495
496/* Bin data cache debug reg:
497 */
498#define BDCD 0x2488
499
500/* Binner pointer cache debug reg:
501 */
502#define BPCD 0x248c
503
504/* Binner scratch pad debug reg:
505 */
506#define BINSKPD 0x24f0
507
508/* HWB scratch pad debug reg:
509 */
510#define HWBSKPD 0x24f4
511
512/* Binner memory pool reg:
513 */
514#define BMP_BUFFER 0x2430
515#define BMP_PAGE_SIZE_4K (0 << 10)
516#define BMP_BUFFER_SIZE_SHIFT 1
517#define BMP_ENABLE (1 << 0)
518
519/* Get/put memory from the binner memory pool:
520 */
521#define BMP_GET 0x2438
522#define BMP_PUT 0x2440
523#define BMP_OFFSET_SHIFT 5
524
525/* 3D state packets:
526 */
527#define GFX_OP_RASTER_RULES ((0x3<<29)|(0x7<<24))
271 528
272#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) 529#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
273#define SC_UPDATE_SCISSOR (0x1<<1) 530#define SC_UPDATE_SCISSOR (0x1<<1)
274#define SC_ENABLE_MASK (0x1<<0) 531#define SC_ENABLE_MASK (0x1<<0)
275#define SC_ENABLE (0x1<<0) 532#define SC_ENABLE (0x1<<0)
276 533
534#define GFX_OP_LOAD_INDIRECT ((0x3<<29)|(0x1d<<24)|(0x7<<16))
535
277#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1)) 536#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
278#define SCI_YMIN_MASK (0xffff<<16) 537#define SCI_YMIN_MASK (0xffff<<16)
279#define SCI_XMIN_MASK (0xffff<<0) 538#define SCI_XMIN_MASK (0xffff<<0)
@@ -290,17 +549,19 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
290 549
291#define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2) 550#define GFX_OP_DRAWRECT_INFO_I965 ((0x7900<<16)|0x2)
292 551
552#define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|4)
293#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) 553#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
294#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21) 554#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
295#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20) 555#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
296 556
297#define MI_BATCH_BUFFER ((0x30<<23)|1) 557#define MI_BATCH_BUFFER ((0x30<<23)|1)
298#define MI_BATCH_BUFFER_START (0x31<<23) 558#define MI_BATCH_BUFFER_START (0x31<<23)
299#define MI_BATCH_BUFFER_END (0xA<<23) 559#define MI_BATCH_BUFFER_END (0xA<<23)
300#define MI_BATCH_NON_SECURE (1) 560#define MI_BATCH_NON_SECURE (1)
301#define MI_BATCH_NON_SECURE_I965 (1<<8) 561#define MI_BATCH_NON_SECURE_I965 (1<<8)
302 562
303#define MI_WAIT_FOR_EVENT ((0x3<<23)) 563#define MI_WAIT_FOR_EVENT ((0x3<<23))
564#define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
304#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2) 565#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
305#define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1) 566#define MI_WAIT_FOR_PLANE_A_SCANLINES (1<<1)
306 567
@@ -308,9 +569,538 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
308 569
309#define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2) 570#define CMD_OP_DISPLAYBUFFER_INFO ((0x0<<29)|(0x14<<23)|2)
310#define ASYNC_FLIP (1<<22) 571#define ASYNC_FLIP (1<<22)
572#define DISPLAY_PLANE_A (0<<20)
573#define DISPLAY_PLANE_B (1<<20)
574
575/* Display regs */
576#define DSPACNTR 0x70180
577#define DSPBCNTR 0x71180
578#define DISPPLANE_SEL_PIPE_MASK (1<<24)
579
580/* Define the region of interest for the binner:
581 */
582#define CMD_OP_BIN_CONTROL ((0x3<<29)|(0x1d<<24)|(0x84<<16)|4)
311 583
312#define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1) 584#define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
313 585
314#define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5]) 586#define CMD_MI_FLUSH (0x04 << 23)
587#define MI_NO_WRITE_FLUSH (1 << 2)
588#define MI_READ_FLUSH (1 << 0)
589#define MI_EXE_FLUSH (1 << 1)
590#define MI_END_SCENE (1 << 4) /* flush binner and incr scene count */
591#define MI_SCENE_COUNT (1 << 3) /* just increment scene count */
592
593#define BREADCRUMB_BITS 31
594#define BREADCRUMB_MASK ((1U << BREADCRUMB_BITS) - 1)
595
596#define READ_BREADCRUMB(dev_priv) (((volatile u32*)(dev_priv->hw_status_page))[5])
597#define READ_HWSP(dev_priv, reg) (((volatile u32*)(dev_priv->hw_status_page))[reg])
598
599#define BLC_PWM_CTL 0x61254
600#define BACKLIGHT_MODULATION_FREQ_SHIFT (17)
601
602#define BLC_PWM_CTL2 0x61250
603/**
604 * This is the most significant 15 bits of the number of backlight cycles in a
605 * complete cycle of the modulated backlight control.
606 *
607 * The actual value is this field multiplied by two.
608 */
609#define BACKLIGHT_MODULATION_FREQ_MASK (0x7fff << 17)
610#define BLM_LEGACY_MODE (1 << 16)
611/**
612 * This is the number of cycles out of the backlight modulation cycle for which
613 * the backlight is on.
614 *
615 * This field must be no greater than the number of cycles in the complete
616 * backlight modulation cycle.
617 */
618#define BACKLIGHT_DUTY_CYCLE_SHIFT (0)
619#define BACKLIGHT_DUTY_CYCLE_MASK (0xffff)
620
621#define I915_GCFGC 0xf0
622#define I915_LOW_FREQUENCY_ENABLE (1 << 7)
623#define I915_DISPLAY_CLOCK_190_200_MHZ (0 << 4)
624#define I915_DISPLAY_CLOCK_333_MHZ (4 << 4)
625#define I915_DISPLAY_CLOCK_MASK (7 << 4)
626
627#define I855_HPLLCC 0xc0
628#define I855_CLOCK_CONTROL_MASK (3 << 0)
629#define I855_CLOCK_133_200 (0 << 0)
630#define I855_CLOCK_100_200 (1 << 0)
631#define I855_CLOCK_100_133 (2 << 0)
632#define I855_CLOCK_166_250 (3 << 0)
633
634/* p317, 319
635 */
636#define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */
637#define VCLK2_VCO_N 0x600a
638#define VCLK2_VCO_DIV_SEL 0x6012
639
640#define VCLK_DIVISOR_VGA0 0x6000
641#define VCLK_DIVISOR_VGA1 0x6004
642#define VCLK_POST_DIV 0x6010
643/** Selects a post divisor of 4 instead of 2. */
644# define VGA1_PD_P2_DIV_4 (1 << 15)
645/** Overrides the p2 post divisor field */
646# define VGA1_PD_P1_DIV_2 (1 << 13)
647# define VGA1_PD_P1_SHIFT 8
648/** P1 value is 2 greater than this field */
649# define VGA1_PD_P1_MASK (0x1f << 8)
650/** Selects a post divisor of 4 instead of 2. */
651# define VGA0_PD_P2_DIV_4 (1 << 7)
652/** Overrides the p2 post divisor field */
653# define VGA0_PD_P1_DIV_2 (1 << 5)
654# define VGA0_PD_P1_SHIFT 0
655/** P1 value is 2 greater than this field */
656# define VGA0_PD_P1_MASK (0x1f << 0)
657
658/* I830 CRTC registers */
659#define HTOTAL_A 0x60000
660#define HBLANK_A 0x60004
661#define HSYNC_A 0x60008
662#define VTOTAL_A 0x6000c
663#define VBLANK_A 0x60010
664#define VSYNC_A 0x60014
665#define PIPEASRC 0x6001c
666#define BCLRPAT_A 0x60020
667#define VSYNCSHIFT_A 0x60028
668
669#define HTOTAL_B 0x61000
670#define HBLANK_B 0x61004
671#define HSYNC_B 0x61008
672#define VTOTAL_B 0x6100c
673#define VBLANK_B 0x61010
674#define VSYNC_B 0x61014
675#define PIPEBSRC 0x6101c
676#define BCLRPAT_B 0x61020
677#define VSYNCSHIFT_B 0x61028
678
679#define PP_STATUS 0x61200
680# define PP_ON (1 << 31)
681/**
682 * Indicates that all dependencies of the panel are on:
683 *
684 * - PLL enabled
685 * - pipe enabled
686 * - LVDS/DVOB/DVOC on
687 */
688# define PP_READY (1 << 30)
689# define PP_SEQUENCE_NONE (0 << 28)
690# define PP_SEQUENCE_ON (1 << 28)
691# define PP_SEQUENCE_OFF (2 << 28)
692# define PP_SEQUENCE_MASK 0x30000000
693#define PP_CONTROL 0x61204
694# define POWER_TARGET_ON (1 << 0)
695
696#define LVDSPP_ON 0x61208
697#define LVDSPP_OFF 0x6120c
698#define PP_CYCLE 0x61210
699
700#define PFIT_CONTROL 0x61230
701# define PFIT_ENABLE (1 << 31)
702# define PFIT_PIPE_MASK (3 << 29)
703# define PFIT_PIPE_SHIFT 29
704# define VERT_INTERP_DISABLE (0 << 10)
705# define VERT_INTERP_BILINEAR (1 << 10)
706# define VERT_INTERP_MASK (3 << 10)
707# define VERT_AUTO_SCALE (1 << 9)
708# define HORIZ_INTERP_DISABLE (0 << 6)
709# define HORIZ_INTERP_BILINEAR (1 << 6)
710# define HORIZ_INTERP_MASK (3 << 6)
711# define HORIZ_AUTO_SCALE (1 << 5)
712# define PANEL_8TO6_DITHER_ENABLE (1 << 3)
713
714#define PFIT_PGM_RATIOS 0x61234
715# define PFIT_VERT_SCALE_MASK 0xfff00000
716# define PFIT_HORIZ_SCALE_MASK 0x0000fff0
717
718#define PFIT_AUTO_RATIOS 0x61238
719
720
721#define DPLL_A 0x06014
722#define DPLL_B 0x06018
723# define DPLL_VCO_ENABLE (1 << 31)
724# define DPLL_DVO_HIGH_SPEED (1 << 30)
725# define DPLL_SYNCLOCK_ENABLE (1 << 29)
726# define DPLL_VGA_MODE_DIS (1 << 28)
727# define DPLLB_MODE_DAC_SERIAL (1 << 26) /* i915 */
728# define DPLLB_MODE_LVDS (2 << 26) /* i915 */
729# define DPLL_MODE_MASK (3 << 26)
730# define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10 (0 << 24) /* i915 */
731# define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 (1 << 24) /* i915 */
732# define DPLLB_LVDS_P2_CLOCK_DIV_14 (0 << 24) /* i915 */
733# define DPLLB_LVDS_P2_CLOCK_DIV_7 (1 << 24) /* i915 */
734# define DPLL_P2_CLOCK_DIV_MASK 0x03000000 /* i915 */
735# define DPLL_FPA01_P1_POST_DIV_MASK 0x00ff0000 /* i915 */
736/**
737 * The i830 generation, in DAC/serial mode, defines p1 as two plus this
738 * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
739 */
740# define DPLL_FPA01_P1_POST_DIV_MASK_I830 0x001f0000
741/**
742 * The i830 generation, in LVDS mode, defines P1 as the bit number set within
743 * this field (only one bit may be set).
744 */
745# define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS 0x003f0000
746# define DPLL_FPA01_P1_POST_DIV_SHIFT 16
747# define PLL_P2_DIVIDE_BY_4 (1 << 23) /* i830, required in DVO non-gang */
748# define PLL_P1_DIVIDE_BY_TWO (1 << 21) /* i830 */
749# define PLL_REF_INPUT_DREFCLK (0 << 13)
750# define PLL_REF_INPUT_TVCLKINA (1 << 13) /* i830 */
751# define PLL_REF_INPUT_TVCLKINBC (2 << 13) /* SDVO TVCLKIN */
752# define PLLB_REF_INPUT_SPREADSPECTRUMIN (3 << 13)
753# define PLL_REF_INPUT_MASK (3 << 13)
754# define PLL_LOAD_PULSE_PHASE_SHIFT 9
755/*
756 * Parallel to Serial Load Pulse phase selection.
757 * Selects the phase for the 10X DPLL clock for the PCIe
758 * digital display port. The range is 4 to 13; 10 or more
759 * is just a flip delay. The default is 6
760 */
761# define PLL_LOAD_PULSE_PHASE_MASK (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
762# define DISPLAY_RATE_SELECT_FPA1 (1 << 8)
763
764/**
765 * SDVO multiplier for 945G/GM. Not used on 965.
766 *
767 * \sa DPLL_MD_UDI_MULTIPLIER_MASK
768 */
769# define SDVO_MULTIPLIER_MASK 0x000000ff
770# define SDVO_MULTIPLIER_SHIFT_HIRES 4
771# define SDVO_MULTIPLIER_SHIFT_VGA 0
772
773/** @defgroup DPLL_MD
774 * @{
775 */
776/** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
777#define DPLL_A_MD 0x0601c
778/** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
779#define DPLL_B_MD 0x06020
780/**
781 * UDI pixel divider, controlling how many pixels are stuffed into a packet.
782 *
783 * Value is pixels minus 1. Must be set to 1 pixel for SDVO.
784 */
785# define DPLL_MD_UDI_DIVIDER_MASK 0x3f000000
786# define DPLL_MD_UDI_DIVIDER_SHIFT 24
787/** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
788# define DPLL_MD_VGA_UDI_DIVIDER_MASK 0x003f0000
789# define DPLL_MD_VGA_UDI_DIVIDER_SHIFT 16
790/**
791 * SDVO/UDI pixel multiplier.
792 *
793 * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
794 * clock rate is 10 times the DPLL clock. At low resolution/refresh rate
795 * modes, the bus rate would be below the limits, so SDVO allows for stuffing
796 * dummy bytes in the datastream at an increased clock rate, with both sides of
797 * the link knowing how many bytes are fill.
798 *
799 * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
800 * rate to 130Mhz to get a bus rate of 1.30Ghz. The DPLL clock rate would be
801 * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
802 * through an SDVO command.
803 *
804 * This register field has values of multiplication factor minus 1, with
805 * a maximum multiplier of 5 for SDVO.
806 */
807# define DPLL_MD_UDI_MULTIPLIER_MASK 0x00003f00
808# define DPLL_MD_UDI_MULTIPLIER_SHIFT 8
809/** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
810 * This best be set to the default value (3) or the CRT won't work. No,
811 * I don't entirely understand what this does...
812 */
813# define DPLL_MD_VGA_UDI_MULTIPLIER_MASK 0x0000003f
814# define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT 0
815/** @} */
816
817#define DPLL_TEST 0x606c
818# define DPLLB_TEST_SDVO_DIV_1 (0 << 22)
819# define DPLLB_TEST_SDVO_DIV_2 (1 << 22)
820# define DPLLB_TEST_SDVO_DIV_4 (2 << 22)
821# define DPLLB_TEST_SDVO_DIV_MASK (3 << 22)
822# define DPLLB_TEST_N_BYPASS (1 << 19)
823# define DPLLB_TEST_M_BYPASS (1 << 18)
824# define DPLLB_INPUT_BUFFER_ENABLE (1 << 16)
825# define DPLLA_TEST_N_BYPASS (1 << 3)
826# define DPLLA_TEST_M_BYPASS (1 << 2)
827# define DPLLA_INPUT_BUFFER_ENABLE (1 << 0)
828
829#define ADPA 0x61100
830#define ADPA_DAC_ENABLE (1<<31)
831#define ADPA_DAC_DISABLE 0
832#define ADPA_PIPE_SELECT_MASK (1<<30)
833#define ADPA_PIPE_A_SELECT 0
834#define ADPA_PIPE_B_SELECT (1<<30)
835#define ADPA_USE_VGA_HVPOLARITY (1<<15)
836#define ADPA_SETS_HVPOLARITY 0
837#define ADPA_VSYNC_CNTL_DISABLE (1<<11)
838#define ADPA_VSYNC_CNTL_ENABLE 0
839#define ADPA_HSYNC_CNTL_DISABLE (1<<10)
840#define ADPA_HSYNC_CNTL_ENABLE 0
841#define ADPA_VSYNC_ACTIVE_HIGH (1<<4)
842#define ADPA_VSYNC_ACTIVE_LOW 0
843#define ADPA_HSYNC_ACTIVE_HIGH (1<<3)
844#define ADPA_HSYNC_ACTIVE_LOW 0
845
846#define FPA0 0x06040
847#define FPA1 0x06044
848#define FPB0 0x06048
849#define FPB1 0x0604c
850# define FP_N_DIV_MASK 0x003f0000
851# define FP_N_DIV_SHIFT 16
852# define FP_M1_DIV_MASK 0x00003f00
853# define FP_M1_DIV_SHIFT 8
854# define FP_M2_DIV_MASK 0x0000003f
855# define FP_M2_DIV_SHIFT 0
856
857
858#define PORT_HOTPLUG_EN 0x61110
859# define SDVOB_HOTPLUG_INT_EN (1 << 26)
860# define SDVOC_HOTPLUG_INT_EN (1 << 25)
861# define TV_HOTPLUG_INT_EN (1 << 18)
862# define CRT_HOTPLUG_INT_EN (1 << 9)
863# define CRT_HOTPLUG_FORCE_DETECT (1 << 3)
864
865#define PORT_HOTPLUG_STAT 0x61114
866# define CRT_HOTPLUG_INT_STATUS (1 << 11)
867# define TV_HOTPLUG_INT_STATUS (1 << 10)
868# define CRT_HOTPLUG_MONITOR_MASK (3 << 8)
869# define CRT_HOTPLUG_MONITOR_COLOR (3 << 8)
870# define CRT_HOTPLUG_MONITOR_MONO (2 << 8)
871# define CRT_HOTPLUG_MONITOR_NONE (0 << 8)
872# define SDVOC_HOTPLUG_INT_STATUS (1 << 7)
873# define SDVOB_HOTPLUG_INT_STATUS (1 << 6)
874
875#define SDVOB 0x61140
876#define SDVOC 0x61160
877#define SDVO_ENABLE (1 << 31)
878#define SDVO_PIPE_B_SELECT (1 << 30)
879#define SDVO_STALL_SELECT (1 << 29)
880#define SDVO_INTERRUPT_ENABLE (1 << 26)
881/**
882 * 915G/GM SDVO pixel multiplier.
883 *
884 * Programmed value is multiplier - 1, up to 5x.
885 *
886 * \sa DPLL_MD_UDI_MULTIPLIER_MASK
887 */
888#define SDVO_PORT_MULTIPLY_MASK (7 << 23)
889#define SDVO_PORT_MULTIPLY_SHIFT 23
890#define SDVO_PHASE_SELECT_MASK (15 << 19)
891#define SDVO_PHASE_SELECT_DEFAULT (6 << 19)
892#define SDVO_CLOCK_OUTPUT_INVERT (1 << 18)
893#define SDVOC_GANG_MODE (1 << 16)
894#define SDVO_BORDER_ENABLE (1 << 7)
895#define SDVOB_PCIE_CONCURRENCY (1 << 3)
896#define SDVO_DETECTED (1 << 2)
897/* Bits to be preserved when writing */
898#define SDVOB_PRESERVE_MASK ((1 << 17) | (1 << 16) | (1 << 14))
899#define SDVOC_PRESERVE_MASK (1 << 17)
900
901/** @defgroup LVDS
902 * @{
903 */
904/**
905 * This register controls the LVDS output enable, pipe selection, and data
906 * format selection.
907 *
908 * All of the clock/data pairs are force powered down by power sequencing.
909 */
910#define LVDS 0x61180
911/**
912 * Enables the LVDS port. This bit must be set before DPLLs are enabled, as
913 * the DPLL semantics change when the LVDS is assigned to that pipe.
914 */
915# define LVDS_PORT_EN (1 << 31)
916/** Selects pipe B for LVDS data. Must be set on pre-965. */
917# define LVDS_PIPEB_SELECT (1 << 30)
918
919/**
920 * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
921 * pixel.
922 */
923# define LVDS_A0A2_CLKA_POWER_MASK (3 << 8)
924# define LVDS_A0A2_CLKA_POWER_DOWN (0 << 8)
925# define LVDS_A0A2_CLKA_POWER_UP (3 << 8)
926/**
927 * Controls the A3 data pair, which contains the additional LSBs for 24 bit
928 * mode. Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
929 * on.
930 */
931# define LVDS_A3_POWER_MASK (3 << 6)
932# define LVDS_A3_POWER_DOWN (0 << 6)
933# define LVDS_A3_POWER_UP (3 << 6)
934/**
935 * Controls the CLKB pair. This should only be set when LVDS_B0B3_POWER_UP
936 * is set.
937 */
938# define LVDS_CLKB_POWER_MASK (3 << 4)
939# define LVDS_CLKB_POWER_DOWN (0 << 4)
940# define LVDS_CLKB_POWER_UP (3 << 4)
941
942/**
943 * Controls the B0-B3 data pairs. This must be set to match the DPLL p2
944 * setting for whether we are in dual-channel mode. The B3 pair will
945 * additionally only be powered up when LVDS_A3_POWER_UP is set.
946 */
947# define LVDS_B0B3_POWER_MASK (3 << 2)
948# define LVDS_B0B3_POWER_DOWN (0 << 2)
949# define LVDS_B0B3_POWER_UP (3 << 2)
950
951#define PIPEACONF 0x70008
952#define PIPEACONF_ENABLE (1<<31)
953#define PIPEACONF_DISABLE 0
954#define PIPEACONF_DOUBLE_WIDE (1<<30)
955#define I965_PIPECONF_ACTIVE (1<<30)
956#define PIPEACONF_SINGLE_WIDE 0
957#define PIPEACONF_PIPE_UNLOCKED 0
958#define PIPEACONF_PIPE_LOCKED (1<<25)
959#define PIPEACONF_PALETTE 0
960#define PIPEACONF_GAMMA (1<<24)
961#define PIPECONF_FORCE_BORDER (1<<25)
962#define PIPECONF_PROGRESSIVE (0 << 21)
963#define PIPECONF_INTERLACE_W_FIELD_INDICATION (6 << 21)
964#define PIPECONF_INTERLACE_FIELD_0_ONLY (7 << 21)
965
966#define PIPEBCONF 0x71008
967#define PIPEBCONF_ENABLE (1<<31)
968#define PIPEBCONF_DISABLE 0
969#define PIPEBCONF_DOUBLE_WIDE (1<<30)
970#define PIPEBCONF_DISABLE 0
971#define PIPEBCONF_GAMMA (1<<24)
972#define PIPEBCONF_PALETTE 0
973
974#define PIPEBGCMAXRED 0x71010
975#define PIPEBGCMAXGREEN 0x71014
976#define PIPEBGCMAXBLUE 0x71018
977#define PIPEBSTAT 0x71024
978#define PIPEBFRAMEHIGH 0x71040
979#define PIPEBFRAMEPIXEL 0x71044
980
981#define DSPACNTR 0x70180
982#define DSPBCNTR 0x71180
983#define DISPLAY_PLANE_ENABLE (1<<31)
984#define DISPLAY_PLANE_DISABLE 0
985#define DISPPLANE_GAMMA_ENABLE (1<<30)
986#define DISPPLANE_GAMMA_DISABLE 0
987#define DISPPLANE_PIXFORMAT_MASK (0xf<<26)
988#define DISPPLANE_8BPP (0x2<<26)
989#define DISPPLANE_15_16BPP (0x4<<26)
990#define DISPPLANE_16BPP (0x5<<26)
991#define DISPPLANE_32BPP_NO_ALPHA (0x6<<26)
992#define DISPPLANE_32BPP (0x7<<26)
993#define DISPPLANE_STEREO_ENABLE (1<<25)
994#define DISPPLANE_STEREO_DISABLE 0
995#define DISPPLANE_SEL_PIPE_MASK (1<<24)
996#define DISPPLANE_SEL_PIPE_A 0
997#define DISPPLANE_SEL_PIPE_B (1<<24)
998#define DISPPLANE_SRC_KEY_ENABLE (1<<22)
999#define DISPPLANE_SRC_KEY_DISABLE 0
1000#define DISPPLANE_LINE_DOUBLE (1<<20)
1001#define DISPPLANE_NO_LINE_DOUBLE 0
1002#define DISPPLANE_STEREO_POLARITY_FIRST 0
1003#define DISPPLANE_STEREO_POLARITY_SECOND (1<<18)
1004/* plane B only */
1005#define DISPPLANE_ALPHA_TRANS_ENABLE (1<<15)
1006#define DISPPLANE_ALPHA_TRANS_DISABLE 0
1007#define DISPPLANE_SPRITE_ABOVE_DISPLAYA 0
1008#define DISPPLANE_SPRITE_ABOVE_OVERLAY (1)
1009
1010#define DSPABASE 0x70184
1011#define DSPASTRIDE 0x70188
1012
1013#define DSPBBASE 0x71184
1014#define DSPBADDR DSPBBASE
1015#define DSPBSTRIDE 0x71188
1016
1017#define DSPAKEYVAL 0x70194
1018#define DSPAKEYMASK 0x70198
1019
1020#define DSPAPOS 0x7018C /* reserved */
1021#define DSPASIZE 0x70190
1022#define DSPBPOS 0x7118C
1023#define DSPBSIZE 0x71190
1024
1025#define DSPASURF 0x7019C
1026#define DSPATILEOFF 0x701A4
1027
1028#define DSPBSURF 0x7119C
1029#define DSPBTILEOFF 0x711A4
1030
1031#define VGACNTRL 0x71400
1032# define VGA_DISP_DISABLE (1 << 31)
1033# define VGA_2X_MODE (1 << 30)
1034# define VGA_PIPE_B_SELECT (1 << 29)
1035
1036/*
1037 * Some BIOS scratch area registers. The 845 (and 830?) store the amount
1038 * of video memory available to the BIOS in SWF1.
1039 */
1040
1041#define SWF0 0x71410
1042
1043/*
1044 * 855 scratch registers.
1045 */
1046#define SWF10 0x70410
1047
1048#define SWF30 0x72414
1049
1050/*
1051 * Overlay registers. These are overlay registers accessed via MMIO.
1052 * Those loaded via the overlay register page are defined in i830_video.c.
1053 */
1054#define OVADD 0x30000
1055
1056#define DOVSTA 0x30008
1057#define OC_BUF (0x3<<20)
1058
1059#define OGAMC5 0x30010
1060#define OGAMC4 0x30014
1061#define OGAMC3 0x30018
1062#define OGAMC2 0x3001c
1063#define OGAMC1 0x30020
1064#define OGAMC0 0x30024
1065/*
1066 * Palette registers
1067 */
1068#define PALETTE_A 0x0a000
1069#define PALETTE_B 0x0a800
1070
1071#define IS_I830(dev) ((dev)->pci_device == 0x3577)
1072#define IS_845G(dev) ((dev)->pci_device == 0x2562)
1073#define IS_I85X(dev) ((dev)->pci_device == 0x3582)
1074#define IS_I855(dev) ((dev)->pci_device == 0x3582)
1075#define IS_I865G(dev) ((dev)->pci_device == 0x2572)
1076
1077#define IS_I915G(dev) ((dev)->pci_device == 0x2582 || (dev)->pci_device == 0x258a)
1078#define IS_I915GM(dev) ((dev)->pci_device == 0x2592)
1079#define IS_I945G(dev) ((dev)->pci_device == 0x2772)
1080#define IS_I945GM(dev) ((dev)->pci_device == 0x27A2)
1081
1082#define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
1083 (dev)->pci_device == 0x2982 || \
1084 (dev)->pci_device == 0x2992 || \
1085 (dev)->pci_device == 0x29A2 || \
1086 (dev)->pci_device == 0x2A02 || \
1087 (dev)->pci_device == 0x2A12 || \
1088 (dev)->pci_device == 0x2A42)
1089
1090#define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
1091
1092#define IS_IGD_GM(dev) ((dev)->pci_device == 0x2A42)
1093
1094#define IS_G33(dev) ((dev)->pci_device == 0x29C2 || \
1095 (dev)->pci_device == 0x29B2 || \
1096 (dev)->pci_device == 0x29D2)
1097
1098#define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
1099 IS_I945GM(dev) || IS_I965G(dev) || IS_G33(dev))
1100
1101#define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
1102 IS_I945GM(dev) || IS_I965GM(dev) || IS_IGD_GM(dev))
1103
1104#define PRIMARY_RINGBUFFER_SIZE (128*1024)
315 1105
316#endif 1106#endif
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index a443f4a202e3..92653b38e64c 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -276,7 +276,7 @@ static int i915_emit_irq(struct drm_device * dev)
276 276
277 i915_kernel_lost_context(dev); 277 i915_kernel_lost_context(dev);
278 278
279 DRM_DEBUG("%s\n", __FUNCTION__); 279 DRM_DEBUG("\n");
280 280
281 dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter; 281 dev_priv->sarea_priv->last_enqueue = ++dev_priv->counter;
282 282
@@ -291,7 +291,7 @@ static int i915_emit_irq(struct drm_device * dev)
291 OUT_RING(0); 291 OUT_RING(0);
292 OUT_RING(GFX_OP_USER_INTERRUPT); 292 OUT_RING(GFX_OP_USER_INTERRUPT);
293 ADVANCE_LP_RING(); 293 ADVANCE_LP_RING();
294 294
295 return dev_priv->counter; 295 return dev_priv->counter;
296} 296}
297 297
@@ -300,7 +300,7 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
300 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 300 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
301 int ret = 0; 301 int ret = 0;
302 302
303 DRM_DEBUG("%s irq_nr=%d breadcrumb=%d\n", __FUNCTION__, irq_nr, 303 DRM_DEBUG("irq_nr=%d breadcrumb=%d\n", irq_nr,
304 READ_BREADCRUMB(dev_priv)); 304 READ_BREADCRUMB(dev_priv));
305 305
306 if (READ_BREADCRUMB(dev_priv) >= irq_nr) 306 if (READ_BREADCRUMB(dev_priv) >= irq_nr)
@@ -312,8 +312,7 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
312 READ_BREADCRUMB(dev_priv) >= irq_nr); 312 READ_BREADCRUMB(dev_priv) >= irq_nr);
313 313
314 if (ret == -EBUSY) { 314 if (ret == -EBUSY) {
315 DRM_ERROR("%s: EBUSY -- rec: %d emitted: %d\n", 315 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
316 __FUNCTION__,
317 READ_BREADCRUMB(dev_priv), (int)dev_priv->counter); 316 READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
318 } 317 }
319 318
@@ -329,14 +328,14 @@ static int i915_driver_vblank_do_wait(struct drm_device *dev, unsigned int *sequ
329 int ret = 0; 328 int ret = 0;
330 329
331 if (!dev_priv) { 330 if (!dev_priv) {
332 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 331 DRM_ERROR("called with no initialization\n");
333 return -EINVAL; 332 return -EINVAL;
334 } 333 }
335 334
336 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ, 335 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
337 (((cur_vblank = atomic_read(counter)) 336 (((cur_vblank = atomic_read(counter))
338 - *sequence) <= (1<<23))); 337 - *sequence) <= (1<<23)));
339 338
340 *sequence = cur_vblank; 339 *sequence = cur_vblank;
341 340
342 return ret; 341 return ret;
@@ -365,7 +364,7 @@ int i915_irq_emit(struct drm_device *dev, void *data,
365 LOCK_TEST_WITH_RETURN(dev, file_priv); 364 LOCK_TEST_WITH_RETURN(dev, file_priv);
366 365
367 if (!dev_priv) { 366 if (!dev_priv) {
368 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 367 DRM_ERROR("called with no initialization\n");
369 return -EINVAL; 368 return -EINVAL;
370 } 369 }
371 370
@@ -388,7 +387,7 @@ int i915_irq_wait(struct drm_device *dev, void *data,
388 drm_i915_irq_wait_t *irqwait = data; 387 drm_i915_irq_wait_t *irqwait = data;
389 388
390 if (!dev_priv) { 389 if (!dev_priv) {
391 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 390 DRM_ERROR("called with no initialization\n");
392 return -EINVAL; 391 return -EINVAL;
393 } 392 }
394 393
@@ -418,13 +417,12 @@ int i915_vblank_pipe_set(struct drm_device *dev, void *data,
418 drm_i915_vblank_pipe_t *pipe = data; 417 drm_i915_vblank_pipe_t *pipe = data;
419 418
420 if (!dev_priv) { 419 if (!dev_priv) {
421 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 420 DRM_ERROR("called with no initialization\n");
422 return -EINVAL; 421 return -EINVAL;
423 } 422 }
424 423
425 if (pipe->pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { 424 if (pipe->pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) {
426 DRM_ERROR("%s called with invalid pipe 0x%x\n", 425 DRM_ERROR("called with invalid pipe 0x%x\n", pipe->pipe);
427 __FUNCTION__, pipe->pipe);
428 return -EINVAL; 426 return -EINVAL;
429 } 427 }
430 428
@@ -443,7 +441,7 @@ int i915_vblank_pipe_get(struct drm_device *dev, void *data,
443 u16 flag; 441 u16 flag;
444 442
445 if (!dev_priv) { 443 if (!dev_priv) {
446 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 444 DRM_ERROR("called with no initialization\n");
447 return -EINVAL; 445 return -EINVAL;
448 } 446 }
449 447
@@ -555,7 +553,7 @@ int i915_vblank_swap(struct drm_device *dev, void *data,
555 553
556 spin_lock_irqsave(&dev_priv->swaps_lock, irqflags); 554 spin_lock_irqsave(&dev_priv->swaps_lock, irqflags);
557 555
558 list_add_tail((struct list_head *)vbl_swap, &dev_priv->vbl_swaps.head); 556 list_add_tail(&vbl_swap->head, &dev_priv->vbl_swaps.head);
559 dev_priv->swaps_pending++; 557 dev_priv->swaps_pending++;
560 558
561 spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); 559 spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c
index 56fb9b30a5d7..6126a60dc9cb 100644
--- a/drivers/char/drm/i915_mem.c
+++ b/drivers/char/drm/i915_mem.c
@@ -276,7 +276,7 @@ int i915_mem_alloc(struct drm_device *dev, void *data,
276 struct mem_block *block, **heap; 276 struct mem_block *block, **heap;
277 277
278 if (!dev_priv) { 278 if (!dev_priv) {
279 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 279 DRM_ERROR("called with no initialization\n");
280 return -EINVAL; 280 return -EINVAL;
281 } 281 }
282 282
@@ -314,7 +314,7 @@ int i915_mem_free(struct drm_device *dev, void *data,
314 struct mem_block *block, **heap; 314 struct mem_block *block, **heap;
315 315
316 if (!dev_priv) { 316 if (!dev_priv) {
317 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 317 DRM_ERROR("called with no initialization\n");
318 return -EINVAL; 318 return -EINVAL;
319 } 319 }
320 320
@@ -342,7 +342,7 @@ int i915_mem_init_heap(struct drm_device *dev, void *data,
342 struct mem_block **heap; 342 struct mem_block **heap;
343 343
344 if (!dev_priv) { 344 if (!dev_priv) {
345 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 345 DRM_ERROR("called with no initialization\n");
346 return -EINVAL; 346 return -EINVAL;
347 } 347 }
348 348
@@ -366,7 +366,7 @@ int i915_mem_destroy_heap( struct drm_device *dev, void *data,
366 struct mem_block **heap; 366 struct mem_block **heap;
367 367
368 if ( !dev_priv ) { 368 if ( !dev_priv ) {
369 DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ ); 369 DRM_ERROR( "called with no initialization\n" );
370 return -EINVAL; 370 return -EINVAL;
371 } 371 }
372 372
@@ -375,7 +375,7 @@ int i915_mem_destroy_heap( struct drm_device *dev, void *data,
375 DRM_ERROR("get_heap failed"); 375 DRM_ERROR("get_heap failed");
376 return -EFAULT; 376 return -EFAULT;
377 } 377 }
378 378
379 if (!*heap) { 379 if (!*heap) {
380 DRM_ERROR("heap not initialized?"); 380 DRM_ERROR("heap not initialized?");
381 return -EFAULT; 381 return -EFAULT;
@@ -384,4 +384,3 @@ int i915_mem_destroy_heap( struct drm_device *dev, void *data,
384 i915_mem_takedown( heap ); 384 i915_mem_takedown( heap );
385 return 0; 385 return 0;
386} 386}
387
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c
index c567c34cda78..c1d12dbfa8d8 100644
--- a/drivers/char/drm/mga_dma.c
+++ b/drivers/char/drm/mga_dma.c
@@ -493,7 +493,7 @@ static int mga_do_agp_dma_bootstrap(struct drm_device * dev,
493 dma_bs->agp_size); 493 dma_bs->agp_size);
494 return err; 494 return err;
495 } 495 }
496 496
497 dev_priv->agp_size = agp_size; 497 dev_priv->agp_size = agp_size;
498 dev_priv->agp_handle = agp_req.handle; 498 dev_priv->agp_handle = agp_req.handle;
499 499
@@ -550,7 +550,7 @@ static int mga_do_agp_dma_bootstrap(struct drm_device * dev,
550 { 550 {
551 struct drm_map_list *_entry; 551 struct drm_map_list *_entry;
552 unsigned long agp_token = 0; 552 unsigned long agp_token = 0;
553 553
554 list_for_each_entry(_entry, &dev->maplist, head) { 554 list_for_each_entry(_entry, &dev->maplist, head) {
555 if (_entry->map == dev->agp_buffer_map) 555 if (_entry->map == dev->agp_buffer_map)
556 agp_token = _entry->user_token; 556 agp_token = _entry->user_token;
@@ -964,7 +964,7 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup)
964 964
965 free_req.handle = dev_priv->agp_handle; 965 free_req.handle = dev_priv->agp_handle;
966 drm_agp_free(dev, &free_req); 966 drm_agp_free(dev, &free_req);
967 967
968 dev_priv->agp_textures = NULL; 968 dev_priv->agp_textures = NULL;
969 dev_priv->agp_size = 0; 969 dev_priv->agp_size = 0;
970 dev_priv->agp_handle = 0; 970 dev_priv->agp_handle = 0;
@@ -998,7 +998,7 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup)
998 } 998 }
999 } 999 }
1000 1000
1001 return 0; 1001 return err;
1002} 1002}
1003 1003
1004int mga_dma_init(struct drm_device *dev, void *data, 1004int mga_dma_init(struct drm_device *dev, void *data,
@@ -1050,7 +1050,7 @@ int mga_dma_flush(struct drm_device *dev, void *data,
1050#if MGA_DMA_DEBUG 1050#if MGA_DMA_DEBUG
1051 int ret = mga_do_wait_for_idle(dev_priv); 1051 int ret = mga_do_wait_for_idle(dev_priv);
1052 if (ret < 0) 1052 if (ret < 0)
1053 DRM_INFO("%s: -EBUSY\n", __FUNCTION__); 1053 DRM_INFO("-EBUSY\n");
1054 return ret; 1054 return ret;
1055#else 1055#else
1056 return mga_do_wait_for_idle(dev_priv); 1056 return mga_do_wait_for_idle(dev_priv);
diff --git a/drivers/char/drm/mga_drv.h b/drivers/char/drm/mga_drv.h
index cd94c04e31c0..f6ebd24bd587 100644
--- a/drivers/char/drm/mga_drv.h
+++ b/drivers/char/drm/mga_drv.h
@@ -216,8 +216,8 @@ static inline u32 _MGA_READ(u32 * addr)
216#define MGA_WRITE( reg, val ) DRM_WRITE32(dev_priv->mmio, (reg), (val)) 216#define MGA_WRITE( reg, val ) DRM_WRITE32(dev_priv->mmio, (reg), (val))
217#endif 217#endif
218 218
219#define DWGREG0 0x1c00 219#define DWGREG0 0x1c00
220#define DWGREG0_END 0x1dff 220#define DWGREG0_END 0x1dff
221#define DWGREG1 0x2c00 221#define DWGREG1 0x2c00
222#define DWGREG1_END 0x2dff 222#define DWGREG1_END 0x2dff
223 223
@@ -249,7 +249,7 @@ do { \
249 } else if ( dev_priv->prim.space < \ 249 } else if ( dev_priv->prim.space < \
250 dev_priv->prim.high_mark ) { \ 250 dev_priv->prim.high_mark ) { \
251 if ( MGA_DMA_DEBUG ) \ 251 if ( MGA_DMA_DEBUG ) \
252 DRM_INFO( "%s: wrap...\n", __FUNCTION__ ); \ 252 DRM_INFO( "wrap...\n"); \
253 return -EBUSY; \ 253 return -EBUSY; \
254 } \ 254 } \
255 } \ 255 } \
@@ -260,7 +260,7 @@ do { \
260 if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \ 260 if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \
261 if ( mga_do_wait_for_idle( dev_priv ) < 0 ) { \ 261 if ( mga_do_wait_for_idle( dev_priv ) < 0 ) { \
262 if ( MGA_DMA_DEBUG ) \ 262 if ( MGA_DMA_DEBUG ) \
263 DRM_INFO( "%s: wrap...\n", __FUNCTION__ ); \ 263 DRM_INFO( "wrap...\n"); \
264 return -EBUSY; \ 264 return -EBUSY; \
265 } \ 265 } \
266 mga_do_dma_wrap_end( dev_priv ); \ 266 mga_do_dma_wrap_end( dev_priv ); \
@@ -280,8 +280,7 @@ do { \
280#define BEGIN_DMA( n ) \ 280#define BEGIN_DMA( n ) \
281do { \ 281do { \
282 if ( MGA_VERBOSE ) { \ 282 if ( MGA_VERBOSE ) { \
283 DRM_INFO( "BEGIN_DMA( %d ) in %s\n", \ 283 DRM_INFO( "BEGIN_DMA( %d )\n", (n) ); \
284 (n), __FUNCTION__ ); \
285 DRM_INFO( " space=0x%x req=0x%Zx\n", \ 284 DRM_INFO( " space=0x%x req=0x%Zx\n", \
286 dev_priv->prim.space, (n) * DMA_BLOCK_SIZE ); \ 285 dev_priv->prim.space, (n) * DMA_BLOCK_SIZE ); \
287 } \ 286 } \
@@ -292,7 +291,7 @@ do { \
292#define BEGIN_DMA_WRAP() \ 291#define BEGIN_DMA_WRAP() \
293do { \ 292do { \
294 if ( MGA_VERBOSE ) { \ 293 if ( MGA_VERBOSE ) { \
295 DRM_INFO( "BEGIN_DMA() in %s\n", __FUNCTION__ ); \ 294 DRM_INFO( "BEGIN_DMA()\n" ); \
296 DRM_INFO( " space=0x%x\n", dev_priv->prim.space ); \ 295 DRM_INFO( " space=0x%x\n", dev_priv->prim.space ); \
297 } \ 296 } \
298 prim = dev_priv->prim.start; \ 297 prim = dev_priv->prim.start; \
@@ -311,7 +310,7 @@ do { \
311#define FLUSH_DMA() \ 310#define FLUSH_DMA() \
312do { \ 311do { \
313 if ( 0 ) { \ 312 if ( 0 ) { \
314 DRM_INFO( "%s:\n", __FUNCTION__ ); \ 313 DRM_INFO( "\n" ); \
315 DRM_INFO( " tail=0x%06x head=0x%06lx\n", \ 314 DRM_INFO( " tail=0x%06x head=0x%06lx\n", \
316 dev_priv->prim.tail, \ 315 dev_priv->prim.tail, \
317 MGA_READ( MGA_PRIMADDRESS ) - \ 316 MGA_READ( MGA_PRIMADDRESS ) - \
@@ -394,22 +393,22 @@ do { \
394#define MGA_VINTCLR (1 << 4) 393#define MGA_VINTCLR (1 << 4)
395#define MGA_VINTEN (1 << 5) 394#define MGA_VINTEN (1 << 5)
396 395
397#define MGA_ALPHACTRL 0x2c7c 396#define MGA_ALPHACTRL 0x2c7c
398#define MGA_AR0 0x1c60 397#define MGA_AR0 0x1c60
399#define MGA_AR1 0x1c64 398#define MGA_AR1 0x1c64
400#define MGA_AR2 0x1c68 399#define MGA_AR2 0x1c68
401#define MGA_AR3 0x1c6c 400#define MGA_AR3 0x1c6c
402#define MGA_AR4 0x1c70 401#define MGA_AR4 0x1c70
403#define MGA_AR5 0x1c74 402#define MGA_AR5 0x1c74
404#define MGA_AR6 0x1c78 403#define MGA_AR6 0x1c78
405 404
406#define MGA_CXBNDRY 0x1c80 405#define MGA_CXBNDRY 0x1c80
407#define MGA_CXLEFT 0x1ca0 406#define MGA_CXLEFT 0x1ca0
408#define MGA_CXRIGHT 0x1ca4 407#define MGA_CXRIGHT 0x1ca4
409 408
410#define MGA_DMAPAD 0x1c54 409#define MGA_DMAPAD 0x1c54
411#define MGA_DSTORG 0x2cb8 410#define MGA_DSTORG 0x2cb8
412#define MGA_DWGCTL 0x1c00 411#define MGA_DWGCTL 0x1c00
413# define MGA_OPCOD_MASK (15 << 0) 412# define MGA_OPCOD_MASK (15 << 0)
414# define MGA_OPCOD_TRAP (4 << 0) 413# define MGA_OPCOD_TRAP (4 << 0)
415# define MGA_OPCOD_TEXTURE_TRAP (6 << 0) 414# define MGA_OPCOD_TEXTURE_TRAP (6 << 0)
@@ -455,27 +454,27 @@ do { \
455# define MGA_CLIPDIS (1 << 31) 454# define MGA_CLIPDIS (1 << 31)
456#define MGA_DWGSYNC 0x2c4c 455#define MGA_DWGSYNC 0x2c4c
457 456
458#define MGA_FCOL 0x1c24 457#define MGA_FCOL 0x1c24
459#define MGA_FIFOSTATUS 0x1e10 458#define MGA_FIFOSTATUS 0x1e10
460#define MGA_FOGCOL 0x1cf4 459#define MGA_FOGCOL 0x1cf4
461#define MGA_FXBNDRY 0x1c84 460#define MGA_FXBNDRY 0x1c84
462#define MGA_FXLEFT 0x1ca8 461#define MGA_FXLEFT 0x1ca8
463#define MGA_FXRIGHT 0x1cac 462#define MGA_FXRIGHT 0x1cac
464 463
465#define MGA_ICLEAR 0x1e18 464#define MGA_ICLEAR 0x1e18
466# define MGA_SOFTRAPICLR (1 << 0) 465# define MGA_SOFTRAPICLR (1 << 0)
467# define MGA_VLINEICLR (1 << 5) 466# define MGA_VLINEICLR (1 << 5)
468#define MGA_IEN 0x1e1c 467#define MGA_IEN 0x1e1c
469# define MGA_SOFTRAPIEN (1 << 0) 468# define MGA_SOFTRAPIEN (1 << 0)
470# define MGA_VLINEIEN (1 << 5) 469# define MGA_VLINEIEN (1 << 5)
471 470
472#define MGA_LEN 0x1c5c 471#define MGA_LEN 0x1c5c
473 472
474#define MGA_MACCESS 0x1c04 473#define MGA_MACCESS 0x1c04
475 474
476#define MGA_PITCH 0x1c8c 475#define MGA_PITCH 0x1c8c
477#define MGA_PLNWT 0x1c1c 476#define MGA_PLNWT 0x1c1c
478#define MGA_PRIMADDRESS 0x1e58 477#define MGA_PRIMADDRESS 0x1e58
479# define MGA_DMA_GENERAL (0 << 0) 478# define MGA_DMA_GENERAL (0 << 0)
480# define MGA_DMA_BLIT (1 << 0) 479# define MGA_DMA_BLIT (1 << 0)
481# define MGA_DMA_VECTOR (2 << 0) 480# define MGA_DMA_VECTOR (2 << 0)
@@ -487,43 +486,43 @@ do { \
487# define MGA_PRIMPTREN0 (1 << 0) 486# define MGA_PRIMPTREN0 (1 << 0)
488# define MGA_PRIMPTREN1 (1 << 1) 487# define MGA_PRIMPTREN1 (1 << 1)
489 488
490#define MGA_RST 0x1e40 489#define MGA_RST 0x1e40
491# define MGA_SOFTRESET (1 << 0) 490# define MGA_SOFTRESET (1 << 0)
492# define MGA_SOFTEXTRST (1 << 1) 491# define MGA_SOFTEXTRST (1 << 1)
493 492
494#define MGA_SECADDRESS 0x2c40 493#define MGA_SECADDRESS 0x2c40
495#define MGA_SECEND 0x2c44 494#define MGA_SECEND 0x2c44
496#define MGA_SETUPADDRESS 0x2cd0 495#define MGA_SETUPADDRESS 0x2cd0
497#define MGA_SETUPEND 0x2cd4 496#define MGA_SETUPEND 0x2cd4
498#define MGA_SGN 0x1c58 497#define MGA_SGN 0x1c58
499#define MGA_SOFTRAP 0x2c48 498#define MGA_SOFTRAP 0x2c48
500#define MGA_SRCORG 0x2cb4 499#define MGA_SRCORG 0x2cb4
501# define MGA_SRMMAP_MASK (1 << 0) 500# define MGA_SRMMAP_MASK (1 << 0)
502# define MGA_SRCMAP_FB (0 << 0) 501# define MGA_SRCMAP_FB (0 << 0)
503# define MGA_SRCMAP_SYSMEM (1 << 0) 502# define MGA_SRCMAP_SYSMEM (1 << 0)
504# define MGA_SRCACC_MASK (1 << 1) 503# define MGA_SRCACC_MASK (1 << 1)
505# define MGA_SRCACC_PCI (0 << 1) 504# define MGA_SRCACC_PCI (0 << 1)
506# define MGA_SRCACC_AGP (1 << 1) 505# define MGA_SRCACC_AGP (1 << 1)
507#define MGA_STATUS 0x1e14 506#define MGA_STATUS 0x1e14
508# define MGA_SOFTRAPEN (1 << 0) 507# define MGA_SOFTRAPEN (1 << 0)
509# define MGA_VSYNCPEN (1 << 4) 508# define MGA_VSYNCPEN (1 << 4)
510# define MGA_VLINEPEN (1 << 5) 509# define MGA_VLINEPEN (1 << 5)
511# define MGA_DWGENGSTS (1 << 16) 510# define MGA_DWGENGSTS (1 << 16)
512# define MGA_ENDPRDMASTS (1 << 17) 511# define MGA_ENDPRDMASTS (1 << 17)
513#define MGA_STENCIL 0x2cc8 512#define MGA_STENCIL 0x2cc8
514#define MGA_STENCILCTL 0x2ccc 513#define MGA_STENCILCTL 0x2ccc
515 514
516#define MGA_TDUALSTAGE0 0x2cf8 515#define MGA_TDUALSTAGE0 0x2cf8
517#define MGA_TDUALSTAGE1 0x2cfc 516#define MGA_TDUALSTAGE1 0x2cfc
518#define MGA_TEXBORDERCOL 0x2c5c 517#define MGA_TEXBORDERCOL 0x2c5c
519#define MGA_TEXCTL 0x2c30 518#define MGA_TEXCTL 0x2c30
520#define MGA_TEXCTL2 0x2c3c 519#define MGA_TEXCTL2 0x2c3c
521# define MGA_DUALTEX (1 << 7) 520# define MGA_DUALTEX (1 << 7)
522# define MGA_G400_TC2_MAGIC (1 << 15) 521# define MGA_G400_TC2_MAGIC (1 << 15)
523# define MGA_MAP1_ENABLE (1 << 31) 522# define MGA_MAP1_ENABLE (1 << 31)
524#define MGA_TEXFILTER 0x2c58 523#define MGA_TEXFILTER 0x2c58
525#define MGA_TEXHEIGHT 0x2c2c 524#define MGA_TEXHEIGHT 0x2c2c
526#define MGA_TEXORG 0x2c24 525#define MGA_TEXORG 0x2c24
527# define MGA_TEXORGMAP_MASK (1 << 0) 526# define MGA_TEXORGMAP_MASK (1 << 0)
528# define MGA_TEXORGMAP_FB (0 << 0) 527# define MGA_TEXORGMAP_FB (0 << 0)
529# define MGA_TEXORGMAP_SYSMEM (1 << 0) 528# define MGA_TEXORGMAP_SYSMEM (1 << 0)
@@ -534,45 +533,45 @@ do { \
534#define MGA_TEXORG2 0x2ca8 533#define MGA_TEXORG2 0x2ca8
535#define MGA_TEXORG3 0x2cac 534#define MGA_TEXORG3 0x2cac
536#define MGA_TEXORG4 0x2cb0 535#define MGA_TEXORG4 0x2cb0
537#define MGA_TEXTRANS 0x2c34 536#define MGA_TEXTRANS 0x2c34
538#define MGA_TEXTRANSHIGH 0x2c38 537#define MGA_TEXTRANSHIGH 0x2c38
539#define MGA_TEXWIDTH 0x2c28 538#define MGA_TEXWIDTH 0x2c28
540 539
541#define MGA_WACCEPTSEQ 0x1dd4 540#define MGA_WACCEPTSEQ 0x1dd4
542#define MGA_WCODEADDR 0x1e6c 541#define MGA_WCODEADDR 0x1e6c
543#define MGA_WFLAG 0x1dc4 542#define MGA_WFLAG 0x1dc4
544#define MGA_WFLAG1 0x1de0 543#define MGA_WFLAG1 0x1de0
545#define MGA_WFLAGNB 0x1e64 544#define MGA_WFLAGNB 0x1e64
546#define MGA_WFLAGNB1 0x1e08 545#define MGA_WFLAGNB1 0x1e08
547#define MGA_WGETMSB 0x1dc8 546#define MGA_WGETMSB 0x1dc8
548#define MGA_WIADDR 0x1dc0 547#define MGA_WIADDR 0x1dc0
549#define MGA_WIADDR2 0x1dd8 548#define MGA_WIADDR2 0x1dd8
550# define MGA_WMODE_SUSPEND (0 << 0) 549# define MGA_WMODE_SUSPEND (0 << 0)
551# define MGA_WMODE_RESUME (1 << 0) 550# define MGA_WMODE_RESUME (1 << 0)
552# define MGA_WMODE_JUMP (2 << 0) 551# define MGA_WMODE_JUMP (2 << 0)
553# define MGA_WMODE_START (3 << 0) 552# define MGA_WMODE_START (3 << 0)
554# define MGA_WAGP_ENABLE (1 << 2) 553# define MGA_WAGP_ENABLE (1 << 2)
555#define MGA_WMISC 0x1e70 554#define MGA_WMISC 0x1e70
556# define MGA_WUCODECACHE_ENABLE (1 << 0) 555# define MGA_WUCODECACHE_ENABLE (1 << 0)
557# define MGA_WMASTER_ENABLE (1 << 1) 556# define MGA_WMASTER_ENABLE (1 << 1)
558# define MGA_WCACHEFLUSH_ENABLE (1 << 3) 557# define MGA_WCACHEFLUSH_ENABLE (1 << 3)
559#define MGA_WVRTXSZ 0x1dcc 558#define MGA_WVRTXSZ 0x1dcc
560 559
561#define MGA_YBOT 0x1c9c 560#define MGA_YBOT 0x1c9c
562#define MGA_YDST 0x1c90 561#define MGA_YDST 0x1c90
563#define MGA_YDSTLEN 0x1c88 562#define MGA_YDSTLEN 0x1c88
564#define MGA_YDSTORG 0x1c94 563#define MGA_YDSTORG 0x1c94
565#define MGA_YTOP 0x1c98 564#define MGA_YTOP 0x1c98
566 565
567#define MGA_ZORG 0x1c0c 566#define MGA_ZORG 0x1c0c
568 567
569/* This finishes the current batch of commands 568/* This finishes the current batch of commands
570 */ 569 */
571#define MGA_EXEC 0x0100 570#define MGA_EXEC 0x0100
572 571
573/* AGP PLL encoding (for G200 only). 572/* AGP PLL encoding (for G200 only).
574 */ 573 */
575#define MGA_AGP_PLL 0x1e4c 574#define MGA_AGP_PLL 0x1e4c
576# define MGA_AGP2XPLL_DISABLE (0 << 0) 575# define MGA_AGP2XPLL_DISABLE (0 << 0)
577# define MGA_AGP2XPLL_ENABLE (1 << 0) 576# define MGA_AGP2XPLL_ENABLE (1 << 0)
578 577
diff --git a/drivers/char/drm/mga_state.c b/drivers/char/drm/mga_state.c
index 5ec8b61c5d45..d3f8aade07b3 100644
--- a/drivers/char/drm/mga_state.c
+++ b/drivers/char/drm/mga_state.c
@@ -150,8 +150,8 @@ static __inline__ void mga_g400_emit_tex0(drm_mga_private_t * dev_priv)
150 drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[0]; 150 drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[0];
151 DMA_LOCALS; 151 DMA_LOCALS;
152 152
153/* printk("mga_g400_emit_tex0 %x %x %x\n", tex->texorg, */ 153/* printk("mga_g400_emit_tex0 %x %x %x\n", tex->texorg, */
154/* tex->texctl, tex->texctl2); */ 154/* tex->texctl, tex->texctl2); */
155 155
156 BEGIN_DMA(6); 156 BEGIN_DMA(6);
157 157
@@ -190,8 +190,8 @@ static __inline__ void mga_g400_emit_tex1(drm_mga_private_t * dev_priv)
190 drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[1]; 190 drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[1];
191 DMA_LOCALS; 191 DMA_LOCALS;
192 192
193/* printk("mga_g400_emit_tex1 %x %x %x\n", tex->texorg, */ 193/* printk("mga_g400_emit_tex1 %x %x %x\n", tex->texorg, */
194/* tex->texctl, tex->texctl2); */ 194/* tex->texctl, tex->texctl2); */
195 195
196 BEGIN_DMA(5); 196 BEGIN_DMA(5);
197 197
@@ -256,7 +256,7 @@ static __inline__ void mga_g400_emit_pipe(drm_mga_private_t * dev_priv)
256 unsigned int pipe = sarea_priv->warp_pipe; 256 unsigned int pipe = sarea_priv->warp_pipe;
257 DMA_LOCALS; 257 DMA_LOCALS;
258 258
259/* printk("mga_g400_emit_pipe %x\n", pipe); */ 259/* printk("mga_g400_emit_pipe %x\n", pipe); */
260 260
261 BEGIN_DMA(10); 261 BEGIN_DMA(10);
262 262
@@ -619,7 +619,7 @@ static void mga_dma_dispatch_swap(struct drm_device * dev)
619 619
620 FLUSH_DMA(); 620 FLUSH_DMA();
621 621
622 DRM_DEBUG("%s... done.\n", __FUNCTION__); 622 DRM_DEBUG("... done.\n");
623} 623}
624 624
625static void mga_dma_dispatch_vertex(struct drm_device * dev, struct drm_buf * buf) 625static void mga_dma_dispatch_vertex(struct drm_device * dev, struct drm_buf * buf)
@@ -631,7 +631,7 @@ static void mga_dma_dispatch_vertex(struct drm_device * dev, struct drm_buf * bu
631 u32 length = (u32) buf->used; 631 u32 length = (u32) buf->used;
632 int i = 0; 632 int i = 0;
633 DMA_LOCALS; 633 DMA_LOCALS;
634 DRM_DEBUG("vertex: buf=%d used=%d\n", buf->idx, buf->used); 634 DRM_DEBUG("buf=%d used=%d\n", buf->idx, buf->used);
635 635
636 if (buf->used) { 636 if (buf->used) {
637 buf_priv->dispatched = 1; 637 buf_priv->dispatched = 1;
@@ -678,7 +678,7 @@ static void mga_dma_dispatch_indices(struct drm_device * dev, struct drm_buf * b
678 u32 address = (u32) buf->bus_address; 678 u32 address = (u32) buf->bus_address;
679 int i = 0; 679 int i = 0;
680 DMA_LOCALS; 680 DMA_LOCALS;
681 DRM_DEBUG("indices: buf=%d start=%d end=%d\n", buf->idx, start, end); 681 DRM_DEBUG("buf=%d start=%d end=%d\n", buf->idx, start, end);
682 682
683 if (start != end) { 683 if (start != end) {
684 buf_priv->dispatched = 1; 684 buf_priv->dispatched = 1;
@@ -955,7 +955,7 @@ static int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *fi
955#if 0 955#if 0
956 if (mga_do_wait_for_idle(dev_priv) < 0) { 956 if (mga_do_wait_for_idle(dev_priv) < 0) {
957 if (MGA_DMA_DEBUG) 957 if (MGA_DMA_DEBUG)
958 DRM_INFO("%s: -EBUSY\n", __FUNCTION__); 958 DRM_INFO("-EBUSY\n");
959 return -EBUSY; 959 return -EBUSY;
960 } 960 }
961#endif 961#endif
@@ -1014,7 +1014,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil
1014 int value; 1014 int value;
1015 1015
1016 if (!dev_priv) { 1016 if (!dev_priv) {
1017 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1017 DRM_ERROR("called with no initialization\n");
1018 return -EINVAL; 1018 return -EINVAL;
1019 } 1019 }
1020 1020
@@ -1046,7 +1046,7 @@ static int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *fi
1046 DMA_LOCALS; 1046 DMA_LOCALS;
1047 1047
1048 if (!dev_priv) { 1048 if (!dev_priv) {
1049 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1049 DRM_ERROR("called with no initialization\n");
1050 return -EINVAL; 1050 return -EINVAL;
1051 } 1051 }
1052 1052
@@ -1075,7 +1075,7 @@ file_priv)
1075 u32 *fence = data; 1075 u32 *fence = data;
1076 1076
1077 if (!dev_priv) { 1077 if (!dev_priv) {
1078 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1078 DRM_ERROR("called with no initialization\n");
1079 return -EINVAL; 1079 return -EINVAL;
1080 } 1080 }
1081 1081
diff --git a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c
index 7d550aba165e..892e0a589846 100644
--- a/drivers/char/drm/r128_cce.c
+++ b/drivers/char/drm/r128_cce.c
@@ -1,4 +1,4 @@
1/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*- 1/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*-
2 * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com 2 * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
3 */ 3 */
4/* 4/*
@@ -651,7 +651,7 @@ int r128_cce_start(struct drm_device *dev, void *data, struct drm_file *file_pri
651 LOCK_TEST_WITH_RETURN(dev, file_priv); 651 LOCK_TEST_WITH_RETURN(dev, file_priv);
652 652
653 if (dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4) { 653 if (dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4) {
654 DRM_DEBUG("%s while CCE running\n", __FUNCTION__); 654 DRM_DEBUG("while CCE running\n");
655 return 0; 655 return 0;
656 } 656 }
657 657
@@ -710,7 +710,7 @@ int r128_cce_reset(struct drm_device *dev, void *data, struct drm_file *file_pri
710 LOCK_TEST_WITH_RETURN(dev, file_priv); 710 LOCK_TEST_WITH_RETURN(dev, file_priv);
711 711
712 if (!dev_priv) { 712 if (!dev_priv) {
713 DRM_DEBUG("%s called before init done\n", __FUNCTION__); 713 DRM_DEBUG("called before init done\n");
714 return -EINVAL; 714 return -EINVAL;
715 } 715 }
716 716
diff --git a/drivers/char/drm/r128_drv.h b/drivers/char/drm/r128_drv.h
index 5041bd8dbed8..011105e51ac6 100644
--- a/drivers/char/drm/r128_drv.h
+++ b/drivers/char/drm/r128_drv.h
@@ -462,8 +462,7 @@ do { \
462 462
463#define BEGIN_RING( n ) do { \ 463#define BEGIN_RING( n ) do { \
464 if ( R128_VERBOSE ) { \ 464 if ( R128_VERBOSE ) { \
465 DRM_INFO( "BEGIN_RING( %d ) in %s\n", \ 465 DRM_INFO( "BEGIN_RING( %d )\n", (n)); \
466 (n), __FUNCTION__ ); \
467 } \ 466 } \
468 if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \ 467 if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
469 COMMIT_RING(); \ 468 COMMIT_RING(); \
@@ -493,7 +492,7 @@ do { \
493 write * sizeof(u32) ); \ 492 write * sizeof(u32) ); \
494 } \ 493 } \
495 if (((dev_priv->ring.tail + _nr) & tail_mask) != write) { \ 494 if (((dev_priv->ring.tail + _nr) & tail_mask) != write) { \
496 DRM_ERROR( \ 495 DRM_ERROR( \
497 "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \ 496 "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \
498 ((dev_priv->ring.tail + _nr) & tail_mask), \ 497 ((dev_priv->ring.tail + _nr) & tail_mask), \
499 write, __LINE__); \ 498 write, __LINE__); \
diff --git a/drivers/char/drm/r128_state.c b/drivers/char/drm/r128_state.c
index b7f483cac6d4..51a9afce7b9b 100644
--- a/drivers/char/drm/r128_state.c
+++ b/drivers/char/drm/r128_state.c
@@ -42,7 +42,7 @@ static void r128_emit_clip_rects(drm_r128_private_t * dev_priv,
42{ 42{
43 u32 aux_sc_cntl = 0x00000000; 43 u32 aux_sc_cntl = 0x00000000;
44 RING_LOCALS; 44 RING_LOCALS;
45 DRM_DEBUG(" %s\n", __FUNCTION__); 45 DRM_DEBUG("\n");
46 46
47 BEGIN_RING((count < 3 ? count : 3) * 5 + 2); 47 BEGIN_RING((count < 3 ? count : 3) * 5 + 2);
48 48
@@ -85,7 +85,7 @@ static __inline__ void r128_emit_core(drm_r128_private_t * dev_priv)
85 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 85 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
86 drm_r128_context_regs_t *ctx = &sarea_priv->context_state; 86 drm_r128_context_regs_t *ctx = &sarea_priv->context_state;
87 RING_LOCALS; 87 RING_LOCALS;
88 DRM_DEBUG(" %s\n", __FUNCTION__); 88 DRM_DEBUG("\n");
89 89
90 BEGIN_RING(2); 90 BEGIN_RING(2);
91 91
@@ -100,7 +100,7 @@ static __inline__ void r128_emit_context(drm_r128_private_t * dev_priv)
100 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 100 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
101 drm_r128_context_regs_t *ctx = &sarea_priv->context_state; 101 drm_r128_context_regs_t *ctx = &sarea_priv->context_state;
102 RING_LOCALS; 102 RING_LOCALS;
103 DRM_DEBUG(" %s\n", __FUNCTION__); 103 DRM_DEBUG("\n");
104 104
105 BEGIN_RING(13); 105 BEGIN_RING(13);
106 106
@@ -126,7 +126,7 @@ static __inline__ void r128_emit_setup(drm_r128_private_t * dev_priv)
126 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 126 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
127 drm_r128_context_regs_t *ctx = &sarea_priv->context_state; 127 drm_r128_context_regs_t *ctx = &sarea_priv->context_state;
128 RING_LOCALS; 128 RING_LOCALS;
129 DRM_DEBUG(" %s\n", __FUNCTION__); 129 DRM_DEBUG("\n");
130 130
131 BEGIN_RING(3); 131 BEGIN_RING(3);
132 132
@@ -142,7 +142,7 @@ static __inline__ void r128_emit_masks(drm_r128_private_t * dev_priv)
142 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 142 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
143 drm_r128_context_regs_t *ctx = &sarea_priv->context_state; 143 drm_r128_context_regs_t *ctx = &sarea_priv->context_state;
144 RING_LOCALS; 144 RING_LOCALS;
145 DRM_DEBUG(" %s\n", __FUNCTION__); 145 DRM_DEBUG("\n");
146 146
147 BEGIN_RING(5); 147 BEGIN_RING(5);
148 148
@@ -161,7 +161,7 @@ static __inline__ void r128_emit_window(drm_r128_private_t * dev_priv)
161 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 161 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
162 drm_r128_context_regs_t *ctx = &sarea_priv->context_state; 162 drm_r128_context_regs_t *ctx = &sarea_priv->context_state;
163 RING_LOCALS; 163 RING_LOCALS;
164 DRM_DEBUG(" %s\n", __FUNCTION__); 164 DRM_DEBUG("\n");
165 165
166 BEGIN_RING(2); 166 BEGIN_RING(2);
167 167
@@ -178,7 +178,7 @@ static __inline__ void r128_emit_tex0(drm_r128_private_t * dev_priv)
178 drm_r128_texture_regs_t *tex = &sarea_priv->tex_state[0]; 178 drm_r128_texture_regs_t *tex = &sarea_priv->tex_state[0];
179 int i; 179 int i;
180 RING_LOCALS; 180 RING_LOCALS;
181 DRM_DEBUG(" %s\n", __FUNCTION__); 181 DRM_DEBUG("\n");
182 182
183 BEGIN_RING(7 + R128_MAX_TEXTURE_LEVELS); 183 BEGIN_RING(7 + R128_MAX_TEXTURE_LEVELS);
184 184
@@ -204,7 +204,7 @@ static __inline__ void r128_emit_tex1(drm_r128_private_t * dev_priv)
204 drm_r128_texture_regs_t *tex = &sarea_priv->tex_state[1]; 204 drm_r128_texture_regs_t *tex = &sarea_priv->tex_state[1];
205 int i; 205 int i;
206 RING_LOCALS; 206 RING_LOCALS;
207 DRM_DEBUG(" %s\n", __FUNCTION__); 207 DRM_DEBUG("\n");
208 208
209 BEGIN_RING(5 + R128_MAX_TEXTURE_LEVELS); 209 BEGIN_RING(5 + R128_MAX_TEXTURE_LEVELS);
210 210
@@ -226,7 +226,7 @@ static void r128_emit_state(drm_r128_private_t * dev_priv)
226 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 226 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
227 unsigned int dirty = sarea_priv->dirty; 227 unsigned int dirty = sarea_priv->dirty;
228 228
229 DRM_DEBUG("%s: dirty=0x%08x\n", __FUNCTION__, dirty); 229 DRM_DEBUG("dirty=0x%08x\n", dirty);
230 230
231 if (dirty & R128_UPLOAD_CORE) { 231 if (dirty & R128_UPLOAD_CORE) {
232 r128_emit_core(dev_priv); 232 r128_emit_core(dev_priv);
@@ -362,7 +362,7 @@ static void r128_cce_dispatch_clear(struct drm_device * dev,
362 unsigned int flags = clear->flags; 362 unsigned int flags = clear->flags;
363 int i; 363 int i;
364 RING_LOCALS; 364 RING_LOCALS;
365 DRM_DEBUG("%s\n", __FUNCTION__); 365 DRM_DEBUG("\n");
366 366
367 if (dev_priv->page_flipping && dev_priv->current_page == 1) { 367 if (dev_priv->page_flipping && dev_priv->current_page == 1) {
368 unsigned int tmp = flags; 368 unsigned int tmp = flags;
@@ -466,7 +466,7 @@ static void r128_cce_dispatch_swap(struct drm_device * dev)
466 struct drm_clip_rect *pbox = sarea_priv->boxes; 466 struct drm_clip_rect *pbox = sarea_priv->boxes;
467 int i; 467 int i;
468 RING_LOCALS; 468 RING_LOCALS;
469 DRM_DEBUG("%s\n", __FUNCTION__); 469 DRM_DEBUG("\n");
470 470
471#if R128_PERFORMANCE_BOXES 471#if R128_PERFORMANCE_BOXES
472 /* Do some trivial performance monitoring... 472 /* Do some trivial performance monitoring...
@@ -528,8 +528,7 @@ static void r128_cce_dispatch_flip(struct drm_device * dev)
528{ 528{
529 drm_r128_private_t *dev_priv = dev->dev_private; 529 drm_r128_private_t *dev_priv = dev->dev_private;
530 RING_LOCALS; 530 RING_LOCALS;
531 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", 531 DRM_DEBUG("page=%d pfCurrentPage=%d\n",
532 __FUNCTION__,
533 dev_priv->current_page, dev_priv->sarea_priv->pfCurrentPage); 532 dev_priv->current_page, dev_priv->sarea_priv->pfCurrentPage);
534 533
535#if R128_PERFORMANCE_BOXES 534#if R128_PERFORMANCE_BOXES
@@ -1156,7 +1155,7 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
1156 int count, *x, *y; 1155 int count, *x, *y;
1157 int i, xbuf_size, ybuf_size; 1156 int i, xbuf_size, ybuf_size;
1158 RING_LOCALS; 1157 RING_LOCALS;
1159 DRM_DEBUG("%s\n", __FUNCTION__); 1158 DRM_DEBUG("\n");
1160 1159
1161 count = depth->n; 1160 count = depth->n;
1162 if (count > 4096 || count <= 0) 1161 if (count > 4096 || count <= 0)
@@ -1226,7 +1225,7 @@ static void r128_cce_dispatch_stipple(struct drm_device * dev, u32 * stipple)
1226 drm_r128_private_t *dev_priv = dev->dev_private; 1225 drm_r128_private_t *dev_priv = dev->dev_private;
1227 int i; 1226 int i;
1228 RING_LOCALS; 1227 RING_LOCALS;
1229 DRM_DEBUG("%s\n", __FUNCTION__); 1228 DRM_DEBUG("\n");
1230 1229
1231 BEGIN_RING(33); 1230 BEGIN_RING(33);
1232 1231
@@ -1309,7 +1308,7 @@ static int r128_do_cleanup_pageflip(struct drm_device * dev)
1309static int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv) 1308static int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv)
1310{ 1309{
1311 drm_r128_private_t *dev_priv = dev->dev_private; 1310 drm_r128_private_t *dev_priv = dev->dev_private;
1312 DRM_DEBUG("%s\n", __FUNCTION__); 1311 DRM_DEBUG("\n");
1313 1312
1314 LOCK_TEST_WITH_RETURN(dev, file_priv); 1313 LOCK_TEST_WITH_RETURN(dev, file_priv);
1315 1314
@@ -1328,7 +1327,7 @@ static int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *fi
1328{ 1327{
1329 drm_r128_private_t *dev_priv = dev->dev_private; 1328 drm_r128_private_t *dev_priv = dev->dev_private;
1330 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; 1329 drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
1331 DRM_DEBUG("%s\n", __FUNCTION__); 1330 DRM_DEBUG("\n");
1332 1331
1333 LOCK_TEST_WITH_RETURN(dev, file_priv); 1332 LOCK_TEST_WITH_RETURN(dev, file_priv);
1334 1333
@@ -1356,7 +1355,7 @@ static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *
1356 LOCK_TEST_WITH_RETURN(dev, file_priv); 1355 LOCK_TEST_WITH_RETURN(dev, file_priv);
1357 1356
1358 if (!dev_priv) { 1357 if (!dev_priv) {
1359 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1358 DRM_ERROR("called with no initialization\n");
1360 return -EINVAL; 1359 return -EINVAL;
1361 } 1360 }
1362 1361
@@ -1412,7 +1411,7 @@ static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file
1412 LOCK_TEST_WITH_RETURN(dev, file_priv); 1411 LOCK_TEST_WITH_RETURN(dev, file_priv);
1413 1412
1414 if (!dev_priv) { 1413 if (!dev_priv) {
1415 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1414 DRM_ERROR("called with no initialization\n");
1416 return -EINVAL; 1415 return -EINVAL;
1417 } 1416 }
1418 1417
@@ -1557,11 +1556,11 @@ static int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file
1557 LOCK_TEST_WITH_RETURN(dev, file_priv); 1556 LOCK_TEST_WITH_RETURN(dev, file_priv);
1558 1557
1559 if (!dev_priv) { 1558 if (!dev_priv) {
1560 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1559 DRM_ERROR("called with no initialization\n");
1561 return -EINVAL; 1560 return -EINVAL;
1562 } 1561 }
1563 1562
1564 DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n", 1563 DRM_DEBUG("idx=%d s=%d e=%d d=%d\n",
1565 indirect->idx, indirect->start, indirect->end, 1564 indirect->idx, indirect->start, indirect->end,
1566 indirect->discard); 1565 indirect->discard);
1567 1566
@@ -1622,7 +1621,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fi
1622 int value; 1621 int value;
1623 1622
1624 if (!dev_priv) { 1623 if (!dev_priv) {
1625 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1624 DRM_ERROR("called with no initialization\n");
1626 return -EINVAL; 1625 return -EINVAL;
1627 } 1626 }
1628 1627
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 59b2944811c5..0f4afc44245c 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -77,23 +77,31 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
77 return -EFAULT; 77 return -EFAULT;
78 } 78 }
79 79
80 box.x1 = 80 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) {
81 (box.x1 + 81 box.x1 = (box.x1) &
82 R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK; 82 R300_CLIPRECT_MASK;
83 box.y1 = 83 box.y1 = (box.y1) &
84 (box.y1 + 84 R300_CLIPRECT_MASK;
85 R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK; 85 box.x2 = (box.x2) &
86 box.x2 = 86 R300_CLIPRECT_MASK;
87 (box.x2 + 87 box.y2 = (box.y2) &
88 R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK; 88 R300_CLIPRECT_MASK;
89 box.y2 = 89 } else {
90 (box.y2 + 90 box.x1 = (box.x1 + R300_CLIPRECT_OFFSET) &
91 R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK; 91 R300_CLIPRECT_MASK;
92 box.y1 = (box.y1 + R300_CLIPRECT_OFFSET) &
93 R300_CLIPRECT_MASK;
94 box.x2 = (box.x2 + R300_CLIPRECT_OFFSET) &
95 R300_CLIPRECT_MASK;
96 box.y2 = (box.y2 + R300_CLIPRECT_OFFSET) &
97 R300_CLIPRECT_MASK;
92 98
99 }
93 OUT_RING((box.x1 << R300_CLIPRECT_X_SHIFT) | 100 OUT_RING((box.x1 << R300_CLIPRECT_X_SHIFT) |
94 (box.y1 << R300_CLIPRECT_Y_SHIFT)); 101 (box.y1 << R300_CLIPRECT_Y_SHIFT));
95 OUT_RING((box.x2 << R300_CLIPRECT_X_SHIFT) | 102 OUT_RING((box.x2 << R300_CLIPRECT_X_SHIFT) |
96 (box.y2 << R300_CLIPRECT_Y_SHIFT)); 103 (box.y2 << R300_CLIPRECT_Y_SHIFT));
104
97 } 105 }
98 106
99 OUT_RING_REG(R300_RE_CLIPRECT_CNTL, r300_cliprect_cntl[nr - 1]); 107 OUT_RING_REG(R300_RE_CLIPRECT_CNTL, r300_cliprect_cntl[nr - 1]);
@@ -133,9 +141,11 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
133 141
134static u8 r300_reg_flags[0x10000 >> 2]; 142static u8 r300_reg_flags[0x10000 >> 2];
135 143
136void r300_init_reg_flags(void) 144void r300_init_reg_flags(struct drm_device *dev)
137{ 145{
138 int i; 146 int i;
147 drm_radeon_private_t *dev_priv = dev->dev_private;
148
139 memset(r300_reg_flags, 0, 0x10000 >> 2); 149 memset(r300_reg_flags, 0, 0x10000 >> 2);
140#define ADD_RANGE_MARK(reg, count,mark) \ 150#define ADD_RANGE_MARK(reg, count,mark) \
141 for(i=((reg)>>2);i<((reg)>>2)+(count);i++)\ 151 for(i=((reg)>>2);i<((reg)>>2)+(count);i++)\
@@ -230,6 +240,9 @@ void r300_init_reg_flags(void)
230 ADD_RANGE(R300_VAP_INPUT_ROUTE_0_0, 8); 240 ADD_RANGE(R300_VAP_INPUT_ROUTE_0_0, 8);
231 ADD_RANGE(R300_VAP_INPUT_ROUTE_1_0, 8); 241 ADD_RANGE(R300_VAP_INPUT_ROUTE_1_0, 8);
232 242
243 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) {
244 ADD_RANGE(0x4074, 16);
245 }
233} 246}
234 247
235static __inline__ int r300_check_range(unsigned reg, int count) 248static __inline__ int r300_check_range(unsigned reg, int count)
@@ -486,7 +499,7 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
486 if (cmd[0] & 0x8000) { 499 if (cmd[0] & 0x8000) {
487 u32 offset; 500 u32 offset;
488 501
489 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL 502 if (cmd[1] & (RADEON_GMC_SRC_PITCH_OFFSET_CNTL
490 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) { 503 | RADEON_GMC_DST_PITCH_OFFSET_CNTL)) {
491 offset = cmd[2] << 10; 504 offset = cmd[2] << 10;
492 ret = !radeon_check_offset(dev_priv, offset); 505 ret = !radeon_check_offset(dev_priv, offset);
@@ -504,7 +517,7 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
504 DRM_ERROR("Invalid bitblt second offset is %08X\n", offset); 517 DRM_ERROR("Invalid bitblt second offset is %08X\n", offset);
505 return -EINVAL; 518 return -EINVAL;
506 } 519 }
507 520
508 } 521 }
509 } 522 }
510 523
@@ -723,54 +736,54 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
723 u32 *ref_age_base; 736 u32 *ref_age_base;
724 u32 i, buf_idx, h_pending; 737 u32 i, buf_idx, h_pending;
725 RING_LOCALS; 738 RING_LOCALS;
726 739
727 if (cmdbuf->bufsz < 740 if (cmdbuf->bufsz <
728 (sizeof(u64) + header.scratch.n_bufs * sizeof(buf_idx))) { 741 (sizeof(u64) + header.scratch.n_bufs * sizeof(buf_idx))) {
729 return -EINVAL; 742 return -EINVAL;
730 } 743 }
731 744
732 if (header.scratch.reg >= 5) { 745 if (header.scratch.reg >= 5) {
733 return -EINVAL; 746 return -EINVAL;
734 } 747 }
735 748
736 dev_priv->scratch_ages[header.scratch.reg]++; 749 dev_priv->scratch_ages[header.scratch.reg]++;
737 750
738 ref_age_base = (u32 *)(unsigned long)*((uint64_t *)cmdbuf->buf); 751 ref_age_base = (u32 *)(unsigned long)*((uint64_t *)cmdbuf->buf);
739 752
740 cmdbuf->buf += sizeof(u64); 753 cmdbuf->buf += sizeof(u64);
741 cmdbuf->bufsz -= sizeof(u64); 754 cmdbuf->bufsz -= sizeof(u64);
742 755
743 for (i=0; i < header.scratch.n_bufs; i++) { 756 for (i=0; i < header.scratch.n_bufs; i++) {
744 buf_idx = *(u32 *)cmdbuf->buf; 757 buf_idx = *(u32 *)cmdbuf->buf;
745 buf_idx *= 2; /* 8 bytes per buf */ 758 buf_idx *= 2; /* 8 bytes per buf */
746 759
747 if (DRM_COPY_TO_USER(ref_age_base + buf_idx, &dev_priv->scratch_ages[header.scratch.reg], sizeof(u32))) { 760 if (DRM_COPY_TO_USER(ref_age_base + buf_idx, &dev_priv->scratch_ages[header.scratch.reg], sizeof(u32))) {
748 return -EINVAL; 761 return -EINVAL;
749 } 762 }
750 763
751 if (DRM_COPY_FROM_USER(&h_pending, ref_age_base + buf_idx + 1, sizeof(u32))) { 764 if (DRM_COPY_FROM_USER(&h_pending, ref_age_base + buf_idx + 1, sizeof(u32))) {
752 return -EINVAL; 765 return -EINVAL;
753 } 766 }
754 767
755 if (h_pending == 0) { 768 if (h_pending == 0) {
756 return -EINVAL; 769 return -EINVAL;
757 } 770 }
758 771
759 h_pending--; 772 h_pending--;
760 773
761 if (DRM_COPY_TO_USER(ref_age_base + buf_idx + 1, &h_pending, sizeof(u32))) { 774 if (DRM_COPY_TO_USER(ref_age_base + buf_idx + 1, &h_pending, sizeof(u32))) {
762 return -EINVAL; 775 return -EINVAL;
763 } 776 }
764 777
765 cmdbuf->buf += sizeof(buf_idx); 778 cmdbuf->buf += sizeof(buf_idx);
766 cmdbuf->bufsz -= sizeof(buf_idx); 779 cmdbuf->bufsz -= sizeof(buf_idx);
767 } 780 }
768 781
769 BEGIN_RING(2); 782 BEGIN_RING(2);
770 OUT_RING( CP_PACKET0( RADEON_SCRATCH_REG0 + header.scratch.reg * 4, 0 ) ); 783 OUT_RING( CP_PACKET0( RADEON_SCRATCH_REG0 + header.scratch.reg * 4, 0 ) );
771 OUT_RING( dev_priv->scratch_ages[header.scratch.reg] ); 784 OUT_RING( dev_priv->scratch_ages[header.scratch.reg] );
772 ADVANCE_RING(); 785 ADVANCE_RING();
773 786
774 return 0; 787 return 0;
775} 788}
776 789
@@ -919,7 +932,7 @@ int r300_do_cp_cmdbuf(struct drm_device *dev,
919 goto cleanup; 932 goto cleanup;
920 } 933 }
921 break; 934 break;
922 935
923 default: 936 default:
924 DRM_ERROR("bad cmd_type %i at %p\n", 937 DRM_ERROR("bad cmd_type %i at %p\n",
925 header.header.cmd_type, 938 header.header.cmd_type,
diff --git a/drivers/char/drm/r300_reg.h b/drivers/char/drm/r300_reg.h
index fa194a46c1e4..8f664af9c4a4 100644
--- a/drivers/char/drm/r300_reg.h
+++ b/drivers/char/drm/r300_reg.h
@@ -853,13 +853,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
853# define R300_TX_FORMAT_W8Z8Y8X8 0xC 853# define R300_TX_FORMAT_W8Z8Y8X8 0xC
854# define R300_TX_FORMAT_W2Z10Y10X10 0xD 854# define R300_TX_FORMAT_W2Z10Y10X10 0xD
855# define R300_TX_FORMAT_W16Z16Y16X16 0xE 855# define R300_TX_FORMAT_W16Z16Y16X16 0xE
856# define R300_TX_FORMAT_DXT1 0xF 856# define R300_TX_FORMAT_DXT1 0xF
857# define R300_TX_FORMAT_DXT3 0x10 857# define R300_TX_FORMAT_DXT3 0x10
858# define R300_TX_FORMAT_DXT5 0x11 858# define R300_TX_FORMAT_DXT5 0x11
859# define R300_TX_FORMAT_D3DMFT_CxV8U8 0x12 /* no swizzle */ 859# define R300_TX_FORMAT_D3DMFT_CxV8U8 0x12 /* no swizzle */
860# define R300_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */ 860# define R300_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */
861# define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */ 861# define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */
862# define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */ 862# define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */
863 /* 0x16 - some 16 bit green format.. ?? */ 863 /* 0x16 - some 16 bit green format.. ?? */
864# define R300_TX_FORMAT_UNK25 (1 << 25) /* no swizzle */ 864# define R300_TX_FORMAT_UNK25 (1 << 25) /* no swizzle */
865# define R300_TX_FORMAT_CUBIC_MAP (1 << 26) 865# define R300_TX_FORMAT_CUBIC_MAP (1 << 26)
@@ -867,19 +867,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
867 /* gap */ 867 /* gap */
868 /* Floating point formats */ 868 /* Floating point formats */
869 /* Note - hardware supports both 16 and 32 bit floating point */ 869 /* Note - hardware supports both 16 and 32 bit floating point */
870# define R300_TX_FORMAT_FL_I16 0x18 870# define R300_TX_FORMAT_FL_I16 0x18
871# define R300_TX_FORMAT_FL_I16A16 0x19 871# define R300_TX_FORMAT_FL_I16A16 0x19
872# define R300_TX_FORMAT_FL_R16G16B16A16 0x1A 872# define R300_TX_FORMAT_FL_R16G16B16A16 0x1A
873# define R300_TX_FORMAT_FL_I32 0x1B 873# define R300_TX_FORMAT_FL_I32 0x1B
874# define R300_TX_FORMAT_FL_I32A32 0x1C 874# define R300_TX_FORMAT_FL_I32A32 0x1C
875# define R300_TX_FORMAT_FL_R32G32B32A32 0x1D 875# define R300_TX_FORMAT_FL_R32G32B32A32 0x1D
876 /* alpha modes, convenience mostly */ 876 /* alpha modes, convenience mostly */
877 /* if you have alpha, pick constant appropriate to the 877 /* if you have alpha, pick constant appropriate to the
878 number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */ 878 number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
879# define R300_TX_FORMAT_ALPHA_1CH 0x000 879# define R300_TX_FORMAT_ALPHA_1CH 0x000
880# define R300_TX_FORMAT_ALPHA_2CH 0x200 880# define R300_TX_FORMAT_ALPHA_2CH 0x200
881# define R300_TX_FORMAT_ALPHA_4CH 0x600 881# define R300_TX_FORMAT_ALPHA_4CH 0x600
882# define R300_TX_FORMAT_ALPHA_NONE 0xA00 882# define R300_TX_FORMAT_ALPHA_NONE 0xA00
883 /* Swizzling */ 883 /* Swizzling */
884 /* constants */ 884 /* constants */
885# define R300_TX_FORMAT_X 0 885# define R300_TX_FORMAT_X 0
@@ -1360,11 +1360,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
1360# define R300_RB3D_Z_DISABLED_2 0x00000014 1360# define R300_RB3D_Z_DISABLED_2 0x00000014
1361# define R300_RB3D_Z_TEST 0x00000012 1361# define R300_RB3D_Z_TEST 0x00000012
1362# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016 1362# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016
1363# define R300_RB3D_Z_WRITE_ONLY 0x00000006 1363# define R300_RB3D_Z_WRITE_ONLY 0x00000006
1364 1364
1365# define R300_RB3D_Z_TEST 0x00000012 1365# define R300_RB3D_Z_TEST 0x00000012
1366# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016 1366# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016
1367# define R300_RB3D_Z_WRITE_ONLY 0x00000006 1367# define R300_RB3D_Z_WRITE_ONLY 0x00000006
1368# define R300_RB3D_STENCIL_ENABLE 0x00000001 1368# define R300_RB3D_STENCIL_ENABLE 0x00000001
1369 1369
1370#define R300_RB3D_ZSTENCIL_CNTL_1 0x4F04 1370#define R300_RB3D_ZSTENCIL_CNTL_1 0x4F04
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 24fca8ec1379..5dc799ab86b8 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -816,6 +816,46 @@ static const u32 R300_cp_microcode[][2] = {
816 {0000000000, 0000000000}, 816 {0000000000, 0000000000},
817}; 817};
818 818
819static u32 RADEON_READ_MCIND(drm_radeon_private_t *dev_priv, int addr)
820{
821 u32 ret;
822 RADEON_WRITE(R520_MC_IND_INDEX, 0x7f0000 | (addr & 0xff));
823 ret = RADEON_READ(R520_MC_IND_DATA);
824 RADEON_WRITE(R520_MC_IND_INDEX, 0);
825 return ret;
826}
827
828u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv)
829{
830
831 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515)
832 return RADEON_READ_MCIND(dev_priv, RV515_MC_FB_LOCATION);
833 else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515)
834 return RADEON_READ_MCIND(dev_priv, R520_MC_FB_LOCATION);
835 else
836 return RADEON_READ(RADEON_MC_FB_LOCATION);
837}
838
839static void radeon_write_fb_location(drm_radeon_private_t *dev_priv, u32 fb_loc)
840{
841 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515)
842 RADEON_WRITE_MCIND(RV515_MC_FB_LOCATION, fb_loc);
843 else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515)
844 RADEON_WRITE_MCIND(R520_MC_FB_LOCATION, fb_loc);
845 else
846 RADEON_WRITE(RADEON_MC_FB_LOCATION, fb_loc);
847}
848
849static void radeon_write_agp_location(drm_radeon_private_t *dev_priv, u32 agp_loc)
850{
851 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515)
852 RADEON_WRITE_MCIND(RV515_MC_AGP_LOCATION, agp_loc);
853 else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515)
854 RADEON_WRITE_MCIND(R520_MC_AGP_LOCATION, agp_loc);
855 else
856 RADEON_WRITE(RADEON_MC_AGP_LOCATION, agp_loc);
857}
858
819static int RADEON_READ_PLL(struct drm_device * dev, int addr) 859static int RADEON_READ_PLL(struct drm_device * dev, int addr)
820{ 860{
821 drm_radeon_private_t *dev_priv = dev->dev_private; 861 drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -824,7 +864,7 @@ static int RADEON_READ_PLL(struct drm_device * dev, int addr)
824 return RADEON_READ(RADEON_CLOCK_CNTL_DATA); 864 return RADEON_READ(RADEON_CLOCK_CNTL_DATA);
825} 865}
826 866
827static int RADEON_READ_PCIE(drm_radeon_private_t *dev_priv, int addr) 867static u32 RADEON_READ_PCIE(drm_radeon_private_t *dev_priv, int addr)
828{ 868{
829 RADEON_WRITE8(RADEON_PCIE_INDEX, addr & 0xff); 869 RADEON_WRITE8(RADEON_PCIE_INDEX, addr & 0xff);
830 return RADEON_READ(RADEON_PCIE_DATA); 870 return RADEON_READ(RADEON_PCIE_DATA);
@@ -1074,41 +1114,43 @@ static int radeon_do_engine_reset(struct drm_device * dev)
1074 1114
1075 radeon_do_pixcache_flush(dev_priv); 1115 radeon_do_pixcache_flush(dev_priv);
1076 1116
1077 clock_cntl_index = RADEON_READ(RADEON_CLOCK_CNTL_INDEX); 1117 if ((dev_priv->flags & RADEON_FAMILY_MASK) < CHIP_RV515) {
1078 mclk_cntl = RADEON_READ_PLL(dev, RADEON_MCLK_CNTL); 1118 clock_cntl_index = RADEON_READ(RADEON_CLOCK_CNTL_INDEX);
1079 1119 mclk_cntl = RADEON_READ_PLL(dev, RADEON_MCLK_CNTL);
1080 RADEON_WRITE_PLL(RADEON_MCLK_CNTL, (mclk_cntl | 1120
1081 RADEON_FORCEON_MCLKA | 1121 RADEON_WRITE_PLL(RADEON_MCLK_CNTL, (mclk_cntl |
1082 RADEON_FORCEON_MCLKB | 1122 RADEON_FORCEON_MCLKA |
1083 RADEON_FORCEON_YCLKA | 1123 RADEON_FORCEON_MCLKB |
1084 RADEON_FORCEON_YCLKB | 1124 RADEON_FORCEON_YCLKA |
1085 RADEON_FORCEON_MC | 1125 RADEON_FORCEON_YCLKB |
1086 RADEON_FORCEON_AIC)); 1126 RADEON_FORCEON_MC |
1087 1127 RADEON_FORCEON_AIC));
1088 rbbm_soft_reset = RADEON_READ(RADEON_RBBM_SOFT_RESET); 1128
1089 1129 rbbm_soft_reset = RADEON_READ(RADEON_RBBM_SOFT_RESET);
1090 RADEON_WRITE(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset | 1130
1091 RADEON_SOFT_RESET_CP | 1131 RADEON_WRITE(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset |
1092 RADEON_SOFT_RESET_HI | 1132 RADEON_SOFT_RESET_CP |
1093 RADEON_SOFT_RESET_SE | 1133 RADEON_SOFT_RESET_HI |
1094 RADEON_SOFT_RESET_RE | 1134 RADEON_SOFT_RESET_SE |
1095 RADEON_SOFT_RESET_PP | 1135 RADEON_SOFT_RESET_RE |
1096 RADEON_SOFT_RESET_E2 | 1136 RADEON_SOFT_RESET_PP |
1097 RADEON_SOFT_RESET_RB)); 1137 RADEON_SOFT_RESET_E2 |
1098 RADEON_READ(RADEON_RBBM_SOFT_RESET); 1138 RADEON_SOFT_RESET_RB));
1099 RADEON_WRITE(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset & 1139 RADEON_READ(RADEON_RBBM_SOFT_RESET);
1100 ~(RADEON_SOFT_RESET_CP | 1140 RADEON_WRITE(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset &
1101 RADEON_SOFT_RESET_HI | 1141 ~(RADEON_SOFT_RESET_CP |
1102 RADEON_SOFT_RESET_SE | 1142 RADEON_SOFT_RESET_HI |
1103 RADEON_SOFT_RESET_RE | 1143 RADEON_SOFT_RESET_SE |
1104 RADEON_SOFT_RESET_PP | 1144 RADEON_SOFT_RESET_RE |
1105 RADEON_SOFT_RESET_E2 | 1145 RADEON_SOFT_RESET_PP |
1106 RADEON_SOFT_RESET_RB))); 1146 RADEON_SOFT_RESET_E2 |
1107 RADEON_READ(RADEON_RBBM_SOFT_RESET); 1147 RADEON_SOFT_RESET_RB)));
1108 1148 RADEON_READ(RADEON_RBBM_SOFT_RESET);
1109 RADEON_WRITE_PLL(RADEON_MCLK_CNTL, mclk_cntl); 1149
1110 RADEON_WRITE(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); 1150 RADEON_WRITE_PLL(RADEON_MCLK_CNTL, mclk_cntl);
1111 RADEON_WRITE(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); 1151 RADEON_WRITE(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index);
1152 RADEON_WRITE(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset);
1153 }
1112 1154
1113 /* Reset the CP ring */ 1155 /* Reset the CP ring */
1114 radeon_do_cp_reset(dev_priv); 1156 radeon_do_cp_reset(dev_priv);
@@ -1127,21 +1169,21 @@ static void radeon_cp_init_ring_buffer(struct drm_device * dev,
1127{ 1169{
1128 u32 ring_start, cur_read_ptr; 1170 u32 ring_start, cur_read_ptr;
1129 u32 tmp; 1171 u32 tmp;
1130 1172
1131 /* Initialize the memory controller. With new memory map, the fb location 1173 /* Initialize the memory controller. With new memory map, the fb location
1132 * is not changed, it should have been properly initialized already. Part 1174 * is not changed, it should have been properly initialized already. Part
1133 * of the problem is that the code below is bogus, assuming the GART is 1175 * of the problem is that the code below is bogus, assuming the GART is
1134 * always appended to the fb which is not necessarily the case 1176 * always appended to the fb which is not necessarily the case
1135 */ 1177 */
1136 if (!dev_priv->new_memmap) 1178 if (!dev_priv->new_memmap)
1137 RADEON_WRITE(RADEON_MC_FB_LOCATION, 1179 radeon_write_fb_location(dev_priv,
1138 ((dev_priv->gart_vm_start - 1) & 0xffff0000) 1180 ((dev_priv->gart_vm_start - 1) & 0xffff0000)
1139 | (dev_priv->fb_location >> 16)); 1181 | (dev_priv->fb_location >> 16));
1140 1182
1141#if __OS_HAS_AGP 1183#if __OS_HAS_AGP
1142 if (dev_priv->flags & RADEON_IS_AGP) { 1184 if (dev_priv->flags & RADEON_IS_AGP) {
1143 RADEON_WRITE(RADEON_AGP_BASE, (unsigned int)dev->agp->base); 1185 RADEON_WRITE(RADEON_AGP_BASE, (unsigned int)dev->agp->base);
1144 RADEON_WRITE(RADEON_MC_AGP_LOCATION, 1186 radeon_write_agp_location(dev_priv,
1145 (((dev_priv->gart_vm_start - 1 + 1187 (((dev_priv->gart_vm_start - 1 +
1146 dev_priv->gart_size) & 0xffff0000) | 1188 dev_priv->gart_size) & 0xffff0000) |
1147 (dev_priv->gart_vm_start >> 16))); 1189 (dev_priv->gart_vm_start >> 16)));
@@ -1190,9 +1232,15 @@ static void radeon_cp_init_ring_buffer(struct drm_device * dev,
1190 /* Set ring buffer size */ 1232 /* Set ring buffer size */
1191#ifdef __BIG_ENDIAN 1233#ifdef __BIG_ENDIAN
1192 RADEON_WRITE(RADEON_CP_RB_CNTL, 1234 RADEON_WRITE(RADEON_CP_RB_CNTL,
1193 dev_priv->ring.size_l2qw | RADEON_BUF_SWAP_32BIT); 1235 RADEON_BUF_SWAP_32BIT |
1236 (dev_priv->ring.fetch_size_l2ow << 18) |
1237 (dev_priv->ring.rptr_update_l2qw << 8) |
1238 dev_priv->ring.size_l2qw);
1194#else 1239#else
1195 RADEON_WRITE(RADEON_CP_RB_CNTL, dev_priv->ring.size_l2qw); 1240 RADEON_WRITE(RADEON_CP_RB_CNTL,
1241 (dev_priv->ring.fetch_size_l2ow << 18) |
1242 (dev_priv->ring.rptr_update_l2qw << 8) |
1243 dev_priv->ring.size_l2qw);
1196#endif 1244#endif
1197 1245
1198 /* Start with assuming that writeback doesn't work */ 1246 /* Start with assuming that writeback doesn't work */
@@ -1299,7 +1347,7 @@ static void radeon_set_igpgart(drm_radeon_private_t * dev_priv, int on)
1299 1347
1300 RADEON_WRITE(RADEON_AGP_BASE, (unsigned int)dev_priv->gart_vm_start); 1348 RADEON_WRITE(RADEON_AGP_BASE, (unsigned int)dev_priv->gart_vm_start);
1301 dev_priv->gart_size = 32*1024*1024; 1349 dev_priv->gart_size = 32*1024*1024;
1302 RADEON_WRITE(RADEON_MC_AGP_LOCATION, 1350 radeon_write_agp_location(dev_priv,
1303 (((dev_priv->gart_vm_start - 1 + 1351 (((dev_priv->gart_vm_start - 1 +
1304 dev_priv->gart_size) & 0xffff0000) | 1352 dev_priv->gart_size) & 0xffff0000) |
1305 (dev_priv->gart_vm_start >> 16))); 1353 (dev_priv->gart_vm_start >> 16)));
@@ -1333,7 +1381,7 @@ static void radeon_set_pciegart(drm_radeon_private_t * dev_priv, int on)
1333 dev_priv->gart_vm_start + 1381 dev_priv->gart_vm_start +
1334 dev_priv->gart_size - 1); 1382 dev_priv->gart_size - 1);
1335 1383
1336 RADEON_WRITE(RADEON_MC_AGP_LOCATION, 0xffffffc0); /* ?? */ 1384 radeon_write_agp_location(dev_priv, 0xffffffc0); /* ?? */
1337 1385
1338 RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_CNTL, 1386 RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_CNTL,
1339 RADEON_PCIE_TX_GART_EN); 1387 RADEON_PCIE_TX_GART_EN);
@@ -1358,7 +1406,7 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on)
1358 return; 1406 return;
1359 } 1407 }
1360 1408
1361 tmp = RADEON_READ(RADEON_AIC_CNTL); 1409 tmp = RADEON_READ(RADEON_AIC_CNTL);
1362 1410
1363 if (on) { 1411 if (on) {
1364 RADEON_WRITE(RADEON_AIC_CNTL, 1412 RADEON_WRITE(RADEON_AIC_CNTL,
@@ -1376,7 +1424,7 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on)
1376 1424
1377 /* Turn off AGP aperture -- is this required for PCI GART? 1425 /* Turn off AGP aperture -- is this required for PCI GART?
1378 */ 1426 */
1379 RADEON_WRITE(RADEON_MC_AGP_LOCATION, 0xffffffc0); /* ?? */ 1427 radeon_write_agp_location(dev_priv, 0xffffffc0);
1380 RADEON_WRITE(RADEON_AGP_COMMAND, 0); /* clear AGP_COMMAND */ 1428 RADEON_WRITE(RADEON_AGP_COMMAND, 0); /* clear AGP_COMMAND */
1381 } else { 1429 } else {
1382 RADEON_WRITE(RADEON_AIC_CNTL, 1430 RADEON_WRITE(RADEON_AIC_CNTL,
@@ -1581,10 +1629,9 @@ static int radeon_do_init_cp(struct drm_device * dev, drm_radeon_init_t * init)
1581 dev->agp_buffer_map->handle); 1629 dev->agp_buffer_map->handle);
1582 } 1630 }
1583 1631
1584 dev_priv->fb_location = (RADEON_READ(RADEON_MC_FB_LOCATION) 1632 dev_priv->fb_location = (radeon_read_fb_location(dev_priv) & 0xffff) << 16;
1585 & 0xffff) << 16; 1633 dev_priv->fb_size =
1586 dev_priv->fb_size = 1634 ((radeon_read_fb_location(dev_priv) & 0xffff0000u) + 0x10000)
1587 ((RADEON_READ(RADEON_MC_FB_LOCATION) & 0xffff0000u) + 0x10000)
1588 - dev_priv->fb_location; 1635 - dev_priv->fb_location;
1589 1636
1590 dev_priv->front_pitch_offset = (((dev_priv->front_pitch / 64) << 22) | 1637 dev_priv->front_pitch_offset = (((dev_priv->front_pitch / 64) << 22) |
@@ -1630,7 +1677,7 @@ static int radeon_do_init_cp(struct drm_device * dev, drm_radeon_init_t * init)
1630 ((base + dev_priv->gart_size) & 0xfffffffful) < base) 1677 ((base + dev_priv->gart_size) & 0xfffffffful) < base)
1631 base = dev_priv->fb_location 1678 base = dev_priv->fb_location
1632 - dev_priv->gart_size; 1679 - dev_priv->gart_size;
1633 } 1680 }
1634 dev_priv->gart_vm_start = base & 0xffc00000u; 1681 dev_priv->gart_vm_start = base & 0xffc00000u;
1635 if (dev_priv->gart_vm_start != base) 1682 if (dev_priv->gart_vm_start != base)
1636 DRM_INFO("GART aligned down from 0x%08x to 0x%08x\n", 1683 DRM_INFO("GART aligned down from 0x%08x to 0x%08x\n",
@@ -1663,6 +1710,11 @@ static int radeon_do_init_cp(struct drm_device * dev, drm_radeon_init_t * init)
1663 dev_priv->ring.size = init->ring_size; 1710 dev_priv->ring.size = init->ring_size;
1664 dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8); 1711 dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8);
1665 1712
1713 dev_priv->ring.rptr_update = /* init->rptr_update */ 4096;
1714 dev_priv->ring.rptr_update_l2qw = drm_order( /* init->rptr_update */ 4096 / 8);
1715
1716 dev_priv->ring.fetch_size = /* init->fetch_size */ 32;
1717 dev_priv->ring.fetch_size_l2ow = drm_order( /* init->fetch_size */ 32 / 16);
1666 dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1; 1718 dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1;
1667 1719
1668 dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK; 1720 dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
@@ -1830,7 +1882,7 @@ int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_pri
1830 LOCK_TEST_WITH_RETURN(dev, file_priv); 1882 LOCK_TEST_WITH_RETURN(dev, file_priv);
1831 1883
1832 if (init->func == RADEON_INIT_R300_CP) 1884 if (init->func == RADEON_INIT_R300_CP)
1833 r300_init_reg_flags(); 1885 r300_init_reg_flags(dev);
1834 1886
1835 switch (init->func) { 1887 switch (init->func) {
1836 case RADEON_INIT_CP: 1888 case RADEON_INIT_CP:
@@ -1852,12 +1904,12 @@ int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_pr
1852 LOCK_TEST_WITH_RETURN(dev, file_priv); 1904 LOCK_TEST_WITH_RETURN(dev, file_priv);
1853 1905
1854 if (dev_priv->cp_running) { 1906 if (dev_priv->cp_running) {
1855 DRM_DEBUG("%s while CP running\n", __FUNCTION__); 1907 DRM_DEBUG("while CP running\n");
1856 return 0; 1908 return 0;
1857 } 1909 }
1858 if (dev_priv->cp_mode == RADEON_CSQ_PRIDIS_INDDIS) { 1910 if (dev_priv->cp_mode == RADEON_CSQ_PRIDIS_INDDIS) {
1859 DRM_DEBUG("%s called with bogus CP mode (%d)\n", 1911 DRM_DEBUG("called with bogus CP mode (%d)\n",
1860 __FUNCTION__, dev_priv->cp_mode); 1912 dev_priv->cp_mode);
1861 return 0; 1913 return 0;
1862 } 1914 }
1863 1915
@@ -1962,7 +2014,7 @@ int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_pr
1962 LOCK_TEST_WITH_RETURN(dev, file_priv); 2014 LOCK_TEST_WITH_RETURN(dev, file_priv);
1963 2015
1964 if (!dev_priv) { 2016 if (!dev_priv) {
1965 DRM_DEBUG("%s called before init done\n", __FUNCTION__); 2017 DRM_DEBUG("called before init done\n");
1966 return -EINVAL; 2018 return -EINVAL;
1967 } 2019 }
1968 2020
@@ -2239,6 +2291,10 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
2239 case CHIP_R350: 2291 case CHIP_R350:
2240 case CHIP_R420: 2292 case CHIP_R420:
2241 case CHIP_RV410: 2293 case CHIP_RV410:
2294 case CHIP_RV515:
2295 case CHIP_R520:
2296 case CHIP_RV570:
2297 case CHIP_R580:
2242 dev_priv->flags |= RADEON_HAS_HIERZ; 2298 dev_priv->flags |= RADEON_HAS_HIERZ;
2243 break; 2299 break;
2244 default: 2300 default:
diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h
index 5a8e23f916fc..71e5b21fad2c 100644
--- a/drivers/char/drm/radeon_drm.h
+++ b/drivers/char/drm/radeon_drm.h
@@ -223,10 +223,10 @@ typedef union {
223#define R300_CMD_CP_DELAY 5 223#define R300_CMD_CP_DELAY 5
224#define R300_CMD_DMA_DISCARD 6 224#define R300_CMD_DMA_DISCARD 6
225#define R300_CMD_WAIT 7 225#define R300_CMD_WAIT 7
226# define R300_WAIT_2D 0x1 226# define R300_WAIT_2D 0x1
227# define R300_WAIT_3D 0x2 227# define R300_WAIT_3D 0x2
228# define R300_WAIT_2D_CLEAN 0x3 228# define R300_WAIT_2D_CLEAN 0x3
229# define R300_WAIT_3D_CLEAN 0x4 229# define R300_WAIT_3D_CLEAN 0x4
230#define R300_CMD_SCRATCH 8 230#define R300_CMD_SCRATCH 8
231 231
232typedef union { 232typedef union {
@@ -656,6 +656,7 @@ typedef struct drm_radeon_indirect {
656#define RADEON_PARAM_SCRATCH_OFFSET 11 656#define RADEON_PARAM_SCRATCH_OFFSET 11
657#define RADEON_PARAM_CARD_TYPE 12 657#define RADEON_PARAM_CARD_TYPE 12
658#define RADEON_PARAM_VBLANK_CRTC 13 /* VBLANK CRTC */ 658#define RADEON_PARAM_VBLANK_CRTC 13 /* VBLANK CRTC */
659#define RADEON_PARAM_FB_LOCATION 14 /* FB location */
659 660
660typedef struct drm_radeon_getparam { 661typedef struct drm_radeon_getparam {
661 int param; 662 int param;
@@ -722,7 +723,7 @@ typedef struct drm_radeon_surface_free {
722 unsigned int address; 723 unsigned int address;
723} drm_radeon_surface_free_t; 724} drm_radeon_surface_free_t;
724 725
725#define DRM_RADEON_VBLANK_CRTC1 1 726#define DRM_RADEON_VBLANK_CRTC1 1
726#define DRM_RADEON_VBLANK_CRTC2 2 727#define DRM_RADEON_VBLANK_CRTC2 2
727 728
728#endif 729#endif
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index bfbb60a9298c..4434332c79bc 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -123,6 +123,12 @@ enum radeon_family {
123 CHIP_R420, 123 CHIP_R420,
124 CHIP_RV410, 124 CHIP_RV410,
125 CHIP_RS400, 125 CHIP_RS400,
126 CHIP_RV515,
127 CHIP_R520,
128 CHIP_RV530,
129 CHIP_RV560,
130 CHIP_RV570,
131 CHIP_R580,
126 CHIP_LAST, 132 CHIP_LAST,
127}; 133};
128 134
@@ -166,6 +172,12 @@ typedef struct drm_radeon_ring_buffer {
166 int size; 172 int size;
167 int size_l2qw; 173 int size_l2qw;
168 174
175 int rptr_update; /* Double Words */
176 int rptr_update_l2qw; /* log2 Quad Words */
177
178 int fetch_size; /* Double Words */
179 int fetch_size_l2ow; /* log2 Oct Words */
180
169 u32 tail; 181 u32 tail;
170 u32 tail_mask; 182 u32 tail_mask;
171 int space; 183 int space;
@@ -336,6 +348,7 @@ extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file
336extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); 348extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
337extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv); 349extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
338extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); 350extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
351extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv);
339 352
340extern void radeon_freelist_reset(struct drm_device * dev); 353extern void radeon_freelist_reset(struct drm_device * dev);
341extern struct drm_buf *radeon_freelist_get(struct drm_device * dev); 354extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
@@ -382,7 +395,7 @@ extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
382 unsigned long arg); 395 unsigned long arg);
383 396
384/* r300_cmdbuf.c */ 397/* r300_cmdbuf.c */
385extern void r300_init_reg_flags(void); 398extern void r300_init_reg_flags(struct drm_device *dev);
386 399
387extern int r300_do_cp_cmdbuf(struct drm_device * dev, 400extern int r300_do_cp_cmdbuf(struct drm_device * dev,
388 struct drm_file *file_priv, 401 struct drm_file *file_priv,
@@ -429,7 +442,7 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev,
429#define RADEON_PCIE_INDEX 0x0030 442#define RADEON_PCIE_INDEX 0x0030
430#define RADEON_PCIE_DATA 0x0034 443#define RADEON_PCIE_DATA 0x0034
431#define RADEON_PCIE_TX_GART_CNTL 0x10 444#define RADEON_PCIE_TX_GART_CNTL 0x10
432# define RADEON_PCIE_TX_GART_EN (1 << 0) 445# define RADEON_PCIE_TX_GART_EN (1 << 0)
433# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0<<1) 446# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0<<1)
434# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1<<1) 447# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1<<1)
435# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3<<1) 448# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3<<1)
@@ -439,7 +452,7 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev,
439# define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1<<8) 452# define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1<<8)
440#define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11 453#define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11
441#define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12 454#define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12
442#define RADEON_PCIE_TX_GART_BASE 0x13 455#define RADEON_PCIE_TX_GART_BASE 0x13
443#define RADEON_PCIE_TX_GART_START_LO 0x14 456#define RADEON_PCIE_TX_GART_START_LO 0x14
444#define RADEON_PCIE_TX_GART_START_HI 0x15 457#define RADEON_PCIE_TX_GART_START_HI 0x15
445#define RADEON_PCIE_TX_GART_END_LO 0x16 458#define RADEON_PCIE_TX_GART_END_LO 0x16
@@ -454,6 +467,16 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev,
454#define RADEON_IGPGART_ENABLE 0x38 467#define RADEON_IGPGART_ENABLE 0x38
455#define RADEON_IGPGART_UNK_39 0x39 468#define RADEON_IGPGART_UNK_39 0x39
456 469
470#define R520_MC_IND_INDEX 0x70
471#define R520_MC_IND_WR_EN (1<<24)
472#define R520_MC_IND_DATA 0x74
473
474#define RV515_MC_FB_LOCATION 0x01
475#define RV515_MC_AGP_LOCATION 0x02
476
477#define R520_MC_FB_LOCATION 0x04
478#define R520_MC_AGP_LOCATION 0x05
479
457#define RADEON_MPP_TB_CONFIG 0x01c0 480#define RADEON_MPP_TB_CONFIG 0x01c0
458#define RADEON_MEM_CNTL 0x0140 481#define RADEON_MEM_CNTL 0x0140
459#define RADEON_MEM_SDRAM_MODE_REG 0x0158 482#define RADEON_MEM_SDRAM_MODE_REG 0x0158
@@ -512,12 +535,12 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev,
512 535
513#define RADEON_GEN_INT_STATUS 0x0044 536#define RADEON_GEN_INT_STATUS 0x0044
514# define RADEON_CRTC_VBLANK_STAT (1 << 0) 537# define RADEON_CRTC_VBLANK_STAT (1 << 0)
515# define RADEON_CRTC_VBLANK_STAT_ACK (1 << 0) 538# define RADEON_CRTC_VBLANK_STAT_ACK (1 << 0)
516# define RADEON_CRTC2_VBLANK_STAT (1 << 9) 539# define RADEON_CRTC2_VBLANK_STAT (1 << 9)
517# define RADEON_CRTC2_VBLANK_STAT_ACK (1 << 9) 540# define RADEON_CRTC2_VBLANK_STAT_ACK (1 << 9)
518# define RADEON_GUI_IDLE_INT_TEST_ACK (1 << 19) 541# define RADEON_GUI_IDLE_INT_TEST_ACK (1 << 19)
519# define RADEON_SW_INT_TEST (1 << 25) 542# define RADEON_SW_INT_TEST (1 << 25)
520# define RADEON_SW_INT_TEST_ACK (1 << 25) 543# define RADEON_SW_INT_TEST_ACK (1 << 25)
521# define RADEON_SW_INT_FIRE (1 << 26) 544# define RADEON_SW_INT_FIRE (1 << 26)
522 545
523#define RADEON_HOST_PATH_CNTL 0x0130 546#define RADEON_HOST_PATH_CNTL 0x0130
@@ -615,9 +638,51 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev,
615# define RADEON_SOFT_RESET_E2 (1 << 5) 638# define RADEON_SOFT_RESET_E2 (1 << 5)
616# define RADEON_SOFT_RESET_RB (1 << 6) 639# define RADEON_SOFT_RESET_RB (1 << 6)
617# define RADEON_SOFT_RESET_HDP (1 << 7) 640# define RADEON_SOFT_RESET_HDP (1 << 7)
641/*
642 * 6:0 Available slots in the FIFO
643 * 8 Host Interface active
644 * 9 CP request active
645 * 10 FIFO request active
646 * 11 Host Interface retry active
647 * 12 CP retry active
648 * 13 FIFO retry active
649 * 14 FIFO pipeline busy
650 * 15 Event engine busy
651 * 16 CP command stream busy
652 * 17 2D engine busy
653 * 18 2D portion of render backend busy
654 * 20 3D setup engine busy
655 * 26 GA engine busy
656 * 27 CBA 2D engine busy
657 * 31 2D engine busy or 3D engine busy or FIFO not empty or CP busy or
658 * command stream queue not empty or Ring Buffer not empty
659 */
618#define RADEON_RBBM_STATUS 0x0e40 660#define RADEON_RBBM_STATUS 0x0e40
661/* Same as the previous RADEON_RBBM_STATUS; this is a mirror of that register. */
662/* #define RADEON_RBBM_STATUS 0x1740 */
663/* bits 6:0 are dword slots available in the cmd fifo */
619# define RADEON_RBBM_FIFOCNT_MASK 0x007f 664# define RADEON_RBBM_FIFOCNT_MASK 0x007f
620# define RADEON_RBBM_ACTIVE (1 << 31) 665# define RADEON_HIRQ_ON_RBB (1 << 8)
666# define RADEON_CPRQ_ON_RBB (1 << 9)
667# define RADEON_CFRQ_ON_RBB (1 << 10)
668# define RADEON_HIRQ_IN_RTBUF (1 << 11)
669# define RADEON_CPRQ_IN_RTBUF (1 << 12)
670# define RADEON_CFRQ_IN_RTBUF (1 << 13)
671# define RADEON_PIPE_BUSY (1 << 14)
672# define RADEON_ENG_EV_BUSY (1 << 15)
673# define RADEON_CP_CMDSTRM_BUSY (1 << 16)
674# define RADEON_E2_BUSY (1 << 17)
675# define RADEON_RB2D_BUSY (1 << 18)
676# define RADEON_RB3D_BUSY (1 << 19) /* not used on r300 */
677# define RADEON_VAP_BUSY (1 << 20)
678# define RADEON_RE_BUSY (1 << 21) /* not used on r300 */
679# define RADEON_TAM_BUSY (1 << 22) /* not used on r300 */
680# define RADEON_TDM_BUSY (1 << 23) /* not used on r300 */
681# define RADEON_PB_BUSY (1 << 24) /* not used on r300 */
682# define RADEON_TIM_BUSY (1 << 25) /* not used on r300 */
683# define RADEON_GA_BUSY (1 << 26)
684# define RADEON_CBA2D_BUSY (1 << 27)
685# define RADEON_RBBM_ACTIVE (1 << 31)
621#define RADEON_RE_LINE_PATTERN 0x1cd0 686#define RADEON_RE_LINE_PATTERN 0x1cd0
622#define RADEON_RE_MISC 0x26c4 687#define RADEON_RE_MISC 0x26c4
623#define RADEON_RE_TOP_LEFT 0x26c0 688#define RADEON_RE_TOP_LEFT 0x26c0
@@ -1004,6 +1069,13 @@ do { \
1004 RADEON_WRITE( RADEON_PCIE_DATA, (val) ); \ 1069 RADEON_WRITE( RADEON_PCIE_DATA, (val) ); \
1005} while (0) 1070} while (0)
1006 1071
1072#define RADEON_WRITE_MCIND( addr, val ) \
1073 do { \
1074 RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff)); \
1075 RADEON_WRITE(R520_MC_IND_DATA, (val)); \
1076 RADEON_WRITE(R520_MC_IND_INDEX, 0); \
1077 } while (0)
1078
1007#define CP_PACKET0( reg, n ) \ 1079#define CP_PACKET0( reg, n ) \
1008 (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) 1080 (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
1009#define CP_PACKET0_TABLE( reg, n ) \ 1081#define CP_PACKET0_TABLE( reg, n ) \
@@ -1114,8 +1186,7 @@ do { \
1114 1186
1115#define BEGIN_RING( n ) do { \ 1187#define BEGIN_RING( n ) do { \
1116 if ( RADEON_VERBOSE ) { \ 1188 if ( RADEON_VERBOSE ) { \
1117 DRM_INFO( "BEGIN_RING( %d ) in %s\n", \ 1189 DRM_INFO( "BEGIN_RING( %d )\n", (n)); \
1118 n, __FUNCTION__ ); \
1119 } \ 1190 } \
1120 if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \ 1191 if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
1121 COMMIT_RING(); \ 1192 COMMIT_RING(); \
@@ -1133,7 +1204,7 @@ do { \
1133 write, dev_priv->ring.tail ); \ 1204 write, dev_priv->ring.tail ); \
1134 } \ 1205 } \
1135 if (((dev_priv->ring.tail + _nr) & mask) != write) { \ 1206 if (((dev_priv->ring.tail + _nr) & mask) != write) { \
1136 DRM_ERROR( \ 1207 DRM_ERROR( \
1137 "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \ 1208 "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \
1138 ((dev_priv->ring.tail + _nr) & mask), \ 1209 ((dev_priv->ring.tail + _nr) & mask), \
1139 write, __LINE__); \ 1210 write, __LINE__); \
diff --git a/drivers/char/drm/radeon_irq.c b/drivers/char/drm/radeon_irq.c
index 84f5bc36252b..009af3814b6f 100644
--- a/drivers/char/drm/radeon_irq.c
+++ b/drivers/char/drm/radeon_irq.c
@@ -154,7 +154,7 @@ static int radeon_driver_vblank_do_wait(struct drm_device * dev,
154 int ack = 0; 154 int ack = 0;
155 atomic_t *counter; 155 atomic_t *counter;
156 if (!dev_priv) { 156 if (!dev_priv) {
157 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 157 DRM_ERROR("called with no initialization\n");
158 return -EINVAL; 158 return -EINVAL;
159 } 159 }
160 160
@@ -205,7 +205,7 @@ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_pr
205 LOCK_TEST_WITH_RETURN(dev, file_priv); 205 LOCK_TEST_WITH_RETURN(dev, file_priv);
206 206
207 if (!dev_priv) { 207 if (!dev_priv) {
208 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 208 DRM_ERROR("called with no initialization\n");
209 return -EINVAL; 209 return -EINVAL;
210 } 210 }
211 211
@@ -227,7 +227,7 @@ int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_pr
227 drm_radeon_irq_wait_t *irqwait = data; 227 drm_radeon_irq_wait_t *irqwait = data;
228 228
229 if (!dev_priv) { 229 if (!dev_priv) {
230 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 230 DRM_ERROR("called with no initialization\n");
231 return -EINVAL; 231 return -EINVAL;
232 } 232 }
233 233
diff --git a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c
index a29acfe2f973..78b34fa7c89a 100644
--- a/drivers/char/drm/radeon_mem.c
+++ b/drivers/char/drm/radeon_mem.c
@@ -224,7 +224,7 @@ int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_p
224 struct mem_block *block, **heap; 224 struct mem_block *block, **heap;
225 225
226 if (!dev_priv) { 226 if (!dev_priv) {
227 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 227 DRM_ERROR("called with no initialization\n");
228 return -EINVAL; 228 return -EINVAL;
229 } 229 }
230 230
@@ -259,7 +259,7 @@ int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_pr
259 struct mem_block *block, **heap; 259 struct mem_block *block, **heap;
260 260
261 if (!dev_priv) { 261 if (!dev_priv) {
262 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 262 DRM_ERROR("called with no initialization\n");
263 return -EINVAL; 263 return -EINVAL;
264 } 264 }
265 265
@@ -285,7 +285,7 @@ int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *fi
285 struct mem_block **heap; 285 struct mem_block **heap;
286 286
287 if (!dev_priv) { 287 if (!dev_priv) {
288 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 288 DRM_ERROR("called with no initialization\n");
289 return -EINVAL; 289 return -EINVAL;
290 } 290 }
291 291
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index f824f2f5fdc2..6f75512f591e 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -898,7 +898,7 @@ static void radeon_cp_dispatch_clear(struct drm_device * dev,
898 int w = pbox[i].x2 - x; 898 int w = pbox[i].x2 - x;
899 int h = pbox[i].y2 - y; 899 int h = pbox[i].y2 - y;
900 900
901 DRM_DEBUG("dispatch clear %d,%d-%d,%d flags 0x%x\n", 901 DRM_DEBUG("%d,%d-%d,%d flags 0x%x\n",
902 x, y, w, h, flags); 902 x, y, w, h, flags);
903 903
904 if (flags & RADEON_FRONT) { 904 if (flags & RADEON_FRONT) {
@@ -1368,7 +1368,7 @@ static void radeon_cp_dispatch_swap(struct drm_device * dev)
1368 int w = pbox[i].x2 - x; 1368 int w = pbox[i].x2 - x;
1369 int h = pbox[i].y2 - y; 1369 int h = pbox[i].y2 - y;
1370 1370
1371 DRM_DEBUG("dispatch swap %d,%d-%d,%d\n", x, y, w, h); 1371 DRM_DEBUG("%d,%d-%d,%d\n", x, y, w, h);
1372 1372
1373 BEGIN_RING(9); 1373 BEGIN_RING(9);
1374 1374
@@ -1422,8 +1422,7 @@ static void radeon_cp_dispatch_flip(struct drm_device * dev)
1422 int offset = (dev_priv->sarea_priv->pfCurrentPage == 1) 1422 int offset = (dev_priv->sarea_priv->pfCurrentPage == 1)
1423 ? dev_priv->front_offset : dev_priv->back_offset; 1423 ? dev_priv->front_offset : dev_priv->back_offset;
1424 RING_LOCALS; 1424 RING_LOCALS;
1425 DRM_DEBUG("%s: pfCurrentPage=%d\n", 1425 DRM_DEBUG("pfCurrentPage=%d\n",
1426 __FUNCTION__,
1427 dev_priv->sarea_priv->pfCurrentPage); 1426 dev_priv->sarea_priv->pfCurrentPage);
1428 1427
1429 /* Do some trivial performance monitoring... 1428 /* Do some trivial performance monitoring...
@@ -1562,7 +1561,7 @@ static void radeon_cp_dispatch_indirect(struct drm_device * dev,
1562{ 1561{
1563 drm_radeon_private_t *dev_priv = dev->dev_private; 1562 drm_radeon_private_t *dev_priv = dev->dev_private;
1564 RING_LOCALS; 1563 RING_LOCALS;
1565 DRM_DEBUG("indirect: buf=%d s=0x%x e=0x%x\n", buf->idx, start, end); 1564 DRM_DEBUG("buf=%d s=0x%x e=0x%x\n", buf->idx, start, end);
1566 1565
1567 if (start != end) { 1566 if (start != end) {
1568 int offset = (dev_priv->gart_buffers_offset 1567 int offset = (dev_priv->gart_buffers_offset
@@ -1758,7 +1757,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
1758 buf = radeon_freelist_get(dev); 1757 buf = radeon_freelist_get(dev);
1759 } 1758 }
1760 if (!buf) { 1759 if (!buf) {
1761 DRM_DEBUG("radeon_cp_dispatch_texture: EAGAIN\n"); 1760 DRM_DEBUG("EAGAIN\n");
1762 if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image))) 1761 if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image)))
1763 return -EFAULT; 1762 return -EFAULT;
1764 return -EAGAIN; 1763 return -EAGAIN;
@@ -2413,7 +2412,7 @@ static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_fil
2413 2412
2414 LOCK_TEST_WITH_RETURN(dev, file_priv); 2413 LOCK_TEST_WITH_RETURN(dev, file_priv);
2415 2414
2416 DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n", 2415 DRM_DEBUG("idx=%d s=%d e=%d d=%d\n",
2417 indirect->idx, indirect->start, indirect->end, 2416 indirect->idx, indirect->start, indirect->end,
2418 indirect->discard); 2417 indirect->discard);
2419 2418
@@ -2779,7 +2778,7 @@ static int radeon_emit_wait(struct drm_device * dev, int flags)
2779 drm_radeon_private_t *dev_priv = dev->dev_private; 2778 drm_radeon_private_t *dev_priv = dev->dev_private;
2780 RING_LOCALS; 2779 RING_LOCALS;
2781 2780
2782 DRM_DEBUG("%s: %x\n", __FUNCTION__, flags); 2781 DRM_DEBUG("%x\n", flags);
2783 switch (flags) { 2782 switch (flags) {
2784 case RADEON_WAIT_2D: 2783 case RADEON_WAIT_2D:
2785 BEGIN_RING(2); 2784 BEGIN_RING(2);
@@ -3035,6 +3034,9 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
3035 case RADEON_PARAM_VBLANK_CRTC: 3034 case RADEON_PARAM_VBLANK_CRTC:
3036 value = radeon_vblank_crtc_get(dev); 3035 value = radeon_vblank_crtc_get(dev);
3037 break; 3036 break;
3037 case RADEON_PARAM_FB_LOCATION:
3038 value = radeon_read_fb_location(dev_priv);
3039 break;
3038 default: 3040 default:
3039 DRM_DEBUG("Invalid parameter %d\n", param->param); 3041 DRM_DEBUG("Invalid parameter %d\n", param->param);
3040 return -EINVAL; 3042 return -EINVAL;
diff --git a/drivers/char/drm/savage_state.c b/drivers/char/drm/savage_state.c
index bf8e0e10fe21..5f6238fdf1fa 100644
--- a/drivers/char/drm/savage_state.c
+++ b/drivers/char/drm/savage_state.c
@@ -512,7 +512,7 @@ static int savage_dispatch_vb_prim(drm_savage_private_t * dev_priv,
512 DMA_DRAW_PRIMITIVE(count, prim, skip); 512 DMA_DRAW_PRIMITIVE(count, prim, skip);
513 513
514 if (vb_stride == vtx_size) { 514 if (vb_stride == vtx_size) {
515 DMA_COPY(&vtxbuf[vb_stride * start], 515 DMA_COPY(&vtxbuf[vb_stride * start],
516 vtx_size * count); 516 vtx_size * count);
517 } else { 517 } else {
518 for (i = start; i < start + count; ++i) { 518 for (i = start; i < start + count; ++i) {
@@ -742,7 +742,7 @@ static int savage_dispatch_vb_idx(drm_savage_private_t * dev_priv,
742 while (n != 0) { 742 while (n != 0) {
743 /* Can emit up to 255 vertices (85 triangles) at once. */ 743 /* Can emit up to 255 vertices (85 triangles) at once. */
744 unsigned int count = n > 255 ? 255 : n; 744 unsigned int count = n > 255 ? 255 : n;
745 745
746 /* Check indices */ 746 /* Check indices */
747 for (i = 0; i < count; ++i) { 747 for (i = 0; i < count; ++i) {
748 if (idx[i] > vb_size / (vb_stride * 4)) { 748 if (idx[i] > vb_size / (vb_stride * 4)) {
@@ -933,7 +933,7 @@ static int savage_dispatch_draw(drm_savage_private_t * dev_priv,
933 /* j was check in savage_bci_cmdbuf */ 933 /* j was check in savage_bci_cmdbuf */
934 ret = savage_dispatch_vb_idx(dev_priv, 934 ret = savage_dispatch_vb_idx(dev_priv,
935 &cmd_header, (const uint16_t *)cmdbuf, 935 &cmd_header, (const uint16_t *)cmdbuf,
936 (const uint32_t *)vtxbuf, vb_size, 936 (const uint32_t *)vtxbuf, vb_size,
937 vb_stride); 937 vb_stride);
938 cmdbuf += j; 938 cmdbuf += j;
939 break; 939 break;
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c
index a6b7ccdaf73d..b3878770fce1 100644
--- a/drivers/char/drm/sis_mm.c
+++ b/drivers/char/drm/sis_mm.c
@@ -115,7 +115,7 @@ static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file
115 dev_priv->vram_offset = fb->offset; 115 dev_priv->vram_offset = fb->offset;
116 116
117 mutex_unlock(&dev->struct_mutex); 117 mutex_unlock(&dev->struct_mutex);
118 DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size); 118 DRM_DEBUG("offset = %u, size = %u\n", fb->offset, fb->size);
119 119
120 return 0; 120 return 0;
121} 121}
@@ -205,7 +205,7 @@ static int sis_ioctl_agp_init(struct drm_device *dev, void *data,
205 dev_priv->agp_offset = agp->offset; 205 dev_priv->agp_offset = agp->offset;
206 mutex_unlock(&dev->struct_mutex); 206 mutex_unlock(&dev->struct_mutex);
207 207
208 DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size); 208 DRM_DEBUG("offset = %u, size = %u\n", agp->offset, agp->size);
209 return 0; 209 return 0;
210} 210}
211 211
@@ -249,7 +249,7 @@ int sis_idle(struct drm_device *dev)
249 return 0; 249 return 0;
250 } 250 }
251 } 251 }
252 252
253 /* 253 /*
254 * Implement a device switch here if needed 254 * Implement a device switch here if needed
255 */ 255 */
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 7009dbddac43..94baec692b57 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -179,14 +179,12 @@ static int via_initialize(struct drm_device * dev,
179 } 179 }
180 180
181 if (dev_priv->ring.virtual_start != NULL) { 181 if (dev_priv->ring.virtual_start != NULL) {
182 DRM_ERROR("%s called again without calling cleanup\n", 182 DRM_ERROR("called again without calling cleanup\n");
183 __FUNCTION__);
184 return -EFAULT; 183 return -EFAULT;
185 } 184 }
186 185
187 if (!dev->agp || !dev->agp->base) { 186 if (!dev->agp || !dev->agp->base) {
188 DRM_ERROR("%s called with no agp memory available\n", 187 DRM_ERROR("called with no agp memory available\n");
189 __FUNCTION__);
190 return -EFAULT; 188 return -EFAULT;
191 } 189 }
192 190
@@ -267,8 +265,7 @@ static int via_dispatch_cmdbuffer(struct drm_device * dev, drm_via_cmdbuffer_t *
267 dev_priv = (drm_via_private_t *) dev->dev_private; 265 dev_priv = (drm_via_private_t *) dev->dev_private;
268 266
269 if (dev_priv->ring.virtual_start == NULL) { 267 if (dev_priv->ring.virtual_start == NULL) {
270 DRM_ERROR("%s called without initializing AGP ring buffer.\n", 268 DRM_ERROR("called without initializing AGP ring buffer.\n");
271 __FUNCTION__);
272 return -EFAULT; 269 return -EFAULT;
273 } 270 }
274 271
@@ -337,8 +334,7 @@ static int via_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *fi
337 334
338 LOCK_TEST_WITH_RETURN(dev, file_priv); 335 LOCK_TEST_WITH_RETURN(dev, file_priv);
339 336
340 DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf->buf, 337 DRM_DEBUG("buf %p size %lu\n", cmdbuf->buf, cmdbuf->size);
341 cmdbuf->size);
342 338
343 ret = via_dispatch_cmdbuffer(dev, cmdbuf); 339 ret = via_dispatch_cmdbuffer(dev, cmdbuf);
344 if (ret) { 340 if (ret) {
@@ -379,8 +375,7 @@ static int via_pci_cmdbuffer(struct drm_device *dev, void *data, struct drm_file
379 375
380 LOCK_TEST_WITH_RETURN(dev, file_priv); 376 LOCK_TEST_WITH_RETURN(dev, file_priv);
381 377
382 DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf->buf, 378 DRM_DEBUG("buf %p size %lu\n", cmdbuf->buf, cmdbuf->size);
383 cmdbuf->size);
384 379
385 ret = via_dispatch_pci_cmdbuffer(dev, cmdbuf); 380 ret = via_dispatch_pci_cmdbuffer(dev, cmdbuf);
386 if (ret) { 381 if (ret) {
@@ -648,14 +643,13 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
648 uint32_t tmp_size, count; 643 uint32_t tmp_size, count;
649 drm_via_private_t *dev_priv; 644 drm_via_private_t *dev_priv;
650 645
651 DRM_DEBUG("via cmdbuf_size\n"); 646 DRM_DEBUG("\n");
652 LOCK_TEST_WITH_RETURN(dev, file_priv); 647 LOCK_TEST_WITH_RETURN(dev, file_priv);
653 648
654 dev_priv = (drm_via_private_t *) dev->dev_private; 649 dev_priv = (drm_via_private_t *) dev->dev_private;
655 650
656 if (dev_priv->ring.virtual_start == NULL) { 651 if (dev_priv->ring.virtual_start == NULL) {
657 DRM_ERROR("%s called without initializing AGP ring buffer.\n", 652 DRM_ERROR("called without initializing AGP ring buffer.\n");
658 __FUNCTION__);
659 return -EFAULT; 653 return -EFAULT;
660 } 654 }
661 655
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index c6fd16f3cb43..33c5197b73c4 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -1,5 +1,5 @@
1/* via_dmablit.c -- PCI DMA BitBlt support for the VIA Unichrome/Pro 1/* via_dmablit.c -- PCI DMA BitBlt support for the VIA Unichrome/Pro
2 * 2 *
3 * Copyright (C) 2005 Thomas Hellstrom, All Rights Reserved. 3 * Copyright (C) 2005 Thomas Hellstrom, All Rights Reserved.
4 * 4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a 5 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -16,22 +16,22 @@
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 19 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * 23 *
24 * Authors: 24 * Authors:
25 * Thomas Hellstrom. 25 * Thomas Hellstrom.
26 * Partially based on code obtained from Digeo Inc. 26 * Partially based on code obtained from Digeo Inc.
27 */ 27 */
28 28
29 29
30/* 30/*
31 * Unmaps the DMA mappings. 31 * Unmaps the DMA mappings.
32 * FIXME: Is this a NoOp on x86? Also 32 * FIXME: Is this a NoOp on x86? Also
33 * FIXME: What happens if this one is called and a pending blit has previously done 33 * FIXME: What happens if this one is called and a pending blit has previously done
34 * the same DMA mappings? 34 * the same DMA mappings?
35 */ 35 */
36 36
37#include "drmP.h" 37#include "drmP.h"
@@ -65,7 +65,7 @@ via_unmap_blit_from_device(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
65 int num_desc = vsg->num_desc; 65 int num_desc = vsg->num_desc;
66 unsigned cur_descriptor_page = num_desc / vsg->descriptors_per_page; 66 unsigned cur_descriptor_page = num_desc / vsg->descriptors_per_page;
67 unsigned descriptor_this_page = num_desc % vsg->descriptors_per_page; 67 unsigned descriptor_this_page = num_desc % vsg->descriptors_per_page;
68 drm_via_descriptor_t *desc_ptr = vsg->desc_pages[cur_descriptor_page] + 68 drm_via_descriptor_t *desc_ptr = vsg->desc_pages[cur_descriptor_page] +
69 descriptor_this_page; 69 descriptor_this_page;
70 dma_addr_t next = vsg->chain_start; 70 dma_addr_t next = vsg->chain_start;
71 71
@@ -73,7 +73,7 @@ via_unmap_blit_from_device(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
73 if (descriptor_this_page-- == 0) { 73 if (descriptor_this_page-- == 0) {
74 cur_descriptor_page--; 74 cur_descriptor_page--;
75 descriptor_this_page = vsg->descriptors_per_page - 1; 75 descriptor_this_page = vsg->descriptors_per_page - 1;
76 desc_ptr = vsg->desc_pages[cur_descriptor_page] + 76 desc_ptr = vsg->desc_pages[cur_descriptor_page] +
77 descriptor_this_page; 77 descriptor_this_page;
78 } 78 }
79 dma_unmap_single(&pdev->dev, next, sizeof(*desc_ptr), DMA_TO_DEVICE); 79 dma_unmap_single(&pdev->dev, next, sizeof(*desc_ptr), DMA_TO_DEVICE);
@@ -93,7 +93,7 @@ via_unmap_blit_from_device(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
93static void 93static void
94via_map_blit_for_device(struct pci_dev *pdev, 94via_map_blit_for_device(struct pci_dev *pdev,
95 const drm_via_dmablit_t *xfer, 95 const drm_via_dmablit_t *xfer,
96 drm_via_sg_info_t *vsg, 96 drm_via_sg_info_t *vsg,
97 int mode) 97 int mode)
98{ 98{
99 unsigned cur_descriptor_page = 0; 99 unsigned cur_descriptor_page = 0;
@@ -110,7 +110,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
110 dma_addr_t next = 0 | VIA_DMA_DPR_EC; 110 dma_addr_t next = 0 | VIA_DMA_DPR_EC;
111 drm_via_descriptor_t *desc_ptr = NULL; 111 drm_via_descriptor_t *desc_ptr = NULL;
112 112
113 if (mode == 1) 113 if (mode == 1)
114 desc_ptr = vsg->desc_pages[cur_descriptor_page]; 114 desc_ptr = vsg->desc_pages[cur_descriptor_page];
115 115
116 for (cur_line = 0; cur_line < xfer->num_lines; ++cur_line) { 116 for (cur_line = 0; cur_line < xfer->num_lines; ++cur_line) {
@@ -118,24 +118,24 @@ via_map_blit_for_device(struct pci_dev *pdev,
118 line_len = xfer->line_length; 118 line_len = xfer->line_length;
119 cur_fb = fb_addr; 119 cur_fb = fb_addr;
120 cur_mem = mem_addr; 120 cur_mem = mem_addr;
121 121
122 while (line_len > 0) { 122 while (line_len > 0) {
123 123
124 remaining_len = min(PAGE_SIZE-VIA_PGOFF(cur_mem), line_len); 124 remaining_len = min(PAGE_SIZE-VIA_PGOFF(cur_mem), line_len);
125 line_len -= remaining_len; 125 line_len -= remaining_len;
126 126
127 if (mode == 1) { 127 if (mode == 1) {
128 desc_ptr->mem_addr = 128 desc_ptr->mem_addr =
129 dma_map_page(&pdev->dev, 129 dma_map_page(&pdev->dev,
130 vsg->pages[VIA_PFN(cur_mem) - 130 vsg->pages[VIA_PFN(cur_mem) -
131 VIA_PFN(first_addr)], 131 VIA_PFN(first_addr)],
132 VIA_PGOFF(cur_mem), remaining_len, 132 VIA_PGOFF(cur_mem), remaining_len,
133 vsg->direction); 133 vsg->direction);
134 desc_ptr->dev_addr = cur_fb; 134 desc_ptr->dev_addr = cur_fb;
135 135
136 desc_ptr->size = remaining_len; 136 desc_ptr->size = remaining_len;
137 desc_ptr->next = (uint32_t) next; 137 desc_ptr->next = (uint32_t) next;
138 next = dma_map_single(&pdev->dev, desc_ptr, sizeof(*desc_ptr), 138 next = dma_map_single(&pdev->dev, desc_ptr, sizeof(*desc_ptr),
139 DMA_TO_DEVICE); 139 DMA_TO_DEVICE);
140 desc_ptr++; 140 desc_ptr++;
141 if (++num_descriptors_this_page >= vsg->descriptors_per_page) { 141 if (++num_descriptors_this_page >= vsg->descriptors_per_page) {
@@ -143,12 +143,12 @@ via_map_blit_for_device(struct pci_dev *pdev,
143 desc_ptr = vsg->desc_pages[++cur_descriptor_page]; 143 desc_ptr = vsg->desc_pages[++cur_descriptor_page];
144 } 144 }
145 } 145 }
146 146
147 num_desc++; 147 num_desc++;
148 cur_mem += remaining_len; 148 cur_mem += remaining_len;
149 cur_fb += remaining_len; 149 cur_fb += remaining_len;
150 } 150 }
151 151
152 mem_addr += xfer->mem_stride; 152 mem_addr += xfer->mem_stride;
153 fb_addr += xfer->fb_stride; 153 fb_addr += xfer->fb_stride;
154 } 154 }
@@ -161,14 +161,14 @@ via_map_blit_for_device(struct pci_dev *pdev,
161} 161}
162 162
163/* 163/*
164 * Function that frees up all resources for a blit. It is usable even if the 164 * Function that frees up all resources for a blit. It is usable even if the
165 * blit info has only been partially built as long as the status enum is consistent 165 * blit info has only been partially built as long as the status enum is consistent
166 * with the actual status of the used resources. 166 * with the actual status of the used resources.
167 */ 167 */
168 168
169 169
170static void 170static void
171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) 171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
172{ 172{
173 struct page *page; 173 struct page *page;
174 int i; 174 int i;
@@ -185,7 +185,7 @@ via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
185 case dr_via_pages_locked: 185 case dr_via_pages_locked:
186 for (i=0; i<vsg->num_pages; ++i) { 186 for (i=0; i<vsg->num_pages; ++i) {
187 if ( NULL != (page = vsg->pages[i])) { 187 if ( NULL != (page = vsg->pages[i])) {
188 if (! PageReserved(page) && (DMA_FROM_DEVICE == vsg->direction)) 188 if (! PageReserved(page) && (DMA_FROM_DEVICE == vsg->direction))
189 SetPageDirty(page); 189 SetPageDirty(page);
190 page_cache_release(page); 190 page_cache_release(page);
191 } 191 }
@@ -200,7 +200,7 @@ via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
200 vsg->bounce_buffer = NULL; 200 vsg->bounce_buffer = NULL;
201 } 201 }
202 vsg->free_on_sequence = 0; 202 vsg->free_on_sequence = 0;
203} 203}
204 204
205/* 205/*
206 * Fire a blit engine. 206 * Fire a blit engine.
@@ -213,7 +213,7 @@ via_fire_dmablit(struct drm_device *dev, drm_via_sg_info_t *vsg, int engine)
213 213
214 VIA_WRITE(VIA_PCI_DMA_MAR0 + engine*0x10, 0); 214 VIA_WRITE(VIA_PCI_DMA_MAR0 + engine*0x10, 0);
215 VIA_WRITE(VIA_PCI_DMA_DAR0 + engine*0x10, 0); 215 VIA_WRITE(VIA_PCI_DMA_DAR0 + engine*0x10, 0);
216 VIA_WRITE(VIA_PCI_DMA_CSR0 + engine*0x04, VIA_DMA_CSR_DD | VIA_DMA_CSR_TD | 216 VIA_WRITE(VIA_PCI_DMA_CSR0 + engine*0x04, VIA_DMA_CSR_DD | VIA_DMA_CSR_TD |
217 VIA_DMA_CSR_DE); 217 VIA_DMA_CSR_DE);
218 VIA_WRITE(VIA_PCI_DMA_MR0 + engine*0x04, VIA_DMA_MR_CM | VIA_DMA_MR_TDIE); 218 VIA_WRITE(VIA_PCI_DMA_MR0 + engine*0x04, VIA_DMA_MR_CM | VIA_DMA_MR_TDIE);
219 VIA_WRITE(VIA_PCI_DMA_BCR0 + engine*0x10, 0); 219 VIA_WRITE(VIA_PCI_DMA_BCR0 + engine*0x10, 0);
@@ -233,9 +233,9 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
233{ 233{
234 int ret; 234 int ret;
235 unsigned long first_pfn = VIA_PFN(xfer->mem_addr); 235 unsigned long first_pfn = VIA_PFN(xfer->mem_addr);
236 vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride -1)) - 236 vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride -1)) -
237 first_pfn + 1; 237 first_pfn + 1;
238 238
239 if (NULL == (vsg->pages = vmalloc(sizeof(struct page *) * vsg->num_pages))) 239 if (NULL == (vsg->pages = vmalloc(sizeof(struct page *) * vsg->num_pages)))
240 return -ENOMEM; 240 return -ENOMEM;
241 memset(vsg->pages, 0, sizeof(struct page *) * vsg->num_pages); 241 memset(vsg->pages, 0, sizeof(struct page *) * vsg->num_pages);
@@ -248,7 +248,7 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
248 248
249 up_read(&current->mm->mmap_sem); 249 up_read(&current->mm->mmap_sem);
250 if (ret != vsg->num_pages) { 250 if (ret != vsg->num_pages) {
251 if (ret < 0) 251 if (ret < 0)
252 return ret; 252 return ret;
253 vsg->state = dr_via_pages_locked; 253 vsg->state = dr_via_pages_locked;
254 return -EINVAL; 254 return -EINVAL;
@@ -264,21 +264,21 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
264 * quite large for some blits, and pages don't need to be contingous. 264 * quite large for some blits, and pages don't need to be contingous.
265 */ 265 */
266 266
267static int 267static int
268via_alloc_desc_pages(drm_via_sg_info_t *vsg) 268via_alloc_desc_pages(drm_via_sg_info_t *vsg)
269{ 269{
270 int i; 270 int i;
271 271
272 vsg->descriptors_per_page = PAGE_SIZE / sizeof( drm_via_descriptor_t); 272 vsg->descriptors_per_page = PAGE_SIZE / sizeof( drm_via_descriptor_t);
273 vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) / 273 vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) /
274 vsg->descriptors_per_page; 274 vsg->descriptors_per_page;
275 275
276 if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, sizeof(void *), GFP_KERNEL))) 276 if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, sizeof(void *), GFP_KERNEL)))
277 return -ENOMEM; 277 return -ENOMEM;
278 278
279 vsg->state = dr_via_desc_pages_alloc; 279 vsg->state = dr_via_desc_pages_alloc;
280 for (i=0; i<vsg->num_desc_pages; ++i) { 280 for (i=0; i<vsg->num_desc_pages; ++i) {
281 if (NULL == (vsg->desc_pages[i] = 281 if (NULL == (vsg->desc_pages[i] =
282 (drm_via_descriptor_t *) __get_free_page(GFP_KERNEL))) 282 (drm_via_descriptor_t *) __get_free_page(GFP_KERNEL)))
283 return -ENOMEM; 283 return -ENOMEM;
284 } 284 }
@@ -286,7 +286,7 @@ via_alloc_desc_pages(drm_via_sg_info_t *vsg)
286 vsg->num_desc); 286 vsg->num_desc);
287 return 0; 287 return 0;
288} 288}
289 289
290static void 290static void
291via_abort_dmablit(struct drm_device *dev, int engine) 291via_abort_dmablit(struct drm_device *dev, int engine)
292{ 292{
@@ -300,7 +300,7 @@ via_dmablit_engine_off(struct drm_device *dev, int engine)
300{ 300{
301 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private; 301 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private;
302 302
303 VIA_WRITE(VIA_PCI_DMA_CSR0 + engine*0x04, VIA_DMA_CSR_TD | VIA_DMA_CSR_DD); 303 VIA_WRITE(VIA_PCI_DMA_CSR0 + engine*0x04, VIA_DMA_CSR_TD | VIA_DMA_CSR_DD);
304} 304}
305 305
306 306
@@ -311,7 +311,7 @@ via_dmablit_engine_off(struct drm_device *dev, int engine)
311 * task. Basically the task of the interrupt handler is to submit a new blit to the engine, while 311 * task. Basically the task of the interrupt handler is to submit a new blit to the engine, while
312 * the workqueue task takes care of processing associated with the old blit. 312 * the workqueue task takes care of processing associated with the old blit.
313 */ 313 */
314 314
315void 315void
316via_dmablit_handler(struct drm_device *dev, int engine, int from_irq) 316via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
317{ 317{
@@ -331,19 +331,19 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
331 spin_lock_irqsave(&blitq->blit_lock, irqsave); 331 spin_lock_irqsave(&blitq->blit_lock, irqsave);
332 } 332 }
333 333
334 done_transfer = blitq->is_active && 334 done_transfer = blitq->is_active &&
335 (( status = VIA_READ(VIA_PCI_DMA_CSR0 + engine*0x04)) & VIA_DMA_CSR_TD); 335 (( status = VIA_READ(VIA_PCI_DMA_CSR0 + engine*0x04)) & VIA_DMA_CSR_TD);
336 done_transfer = done_transfer || ( blitq->aborting && !(status & VIA_DMA_CSR_DE)); 336 done_transfer = done_transfer || ( blitq->aborting && !(status & VIA_DMA_CSR_DE));
337 337
338 cur = blitq->cur; 338 cur = blitq->cur;
339 if (done_transfer) { 339 if (done_transfer) {
340 340
341 blitq->blits[cur]->aborted = blitq->aborting; 341 blitq->blits[cur]->aborted = blitq->aborting;
342 blitq->done_blit_handle++; 342 blitq->done_blit_handle++;
343 DRM_WAKEUP(blitq->blit_queue + cur); 343 DRM_WAKEUP(blitq->blit_queue + cur);
344 344
345 cur++; 345 cur++;
346 if (cur >= VIA_NUM_BLIT_SLOTS) 346 if (cur >= VIA_NUM_BLIT_SLOTS)
347 cur = 0; 347 cur = 0;
348 blitq->cur = cur; 348 blitq->cur = cur;
349 349
@@ -355,7 +355,7 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
355 355
356 blitq->is_active = 0; 356 blitq->is_active = 0;
357 blitq->aborting = 0; 357 blitq->aborting = 0;
358 schedule_work(&blitq->wq); 358 schedule_work(&blitq->wq);
359 359
360 } else if (blitq->is_active && time_after_eq(jiffies, blitq->end)) { 360 } else if (blitq->is_active && time_after_eq(jiffies, blitq->end)) {
361 361
@@ -367,7 +367,7 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
367 blitq->aborting = 1; 367 blitq->aborting = 1;
368 blitq->end = jiffies + DRM_HZ; 368 blitq->end = jiffies + DRM_HZ;
369 } 369 }
370 370
371 if (!blitq->is_active) { 371 if (!blitq->is_active) {
372 if (blitq->num_outstanding) { 372 if (blitq->num_outstanding) {
373 via_fire_dmablit(dev, blitq->blits[cur], engine); 373 via_fire_dmablit(dev, blitq->blits[cur], engine);
@@ -383,14 +383,14 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
383 } 383 }
384 via_dmablit_engine_off(dev, engine); 384 via_dmablit_engine_off(dev, engine);
385 } 385 }
386 } 386 }
387 387
388 if (from_irq) { 388 if (from_irq) {
389 spin_unlock(&blitq->blit_lock); 389 spin_unlock(&blitq->blit_lock);
390 } else { 390 } else {
391 spin_unlock_irqrestore(&blitq->blit_lock, irqsave); 391 spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
392 } 392 }
393} 393}
394 394
395 395
396 396
@@ -426,13 +426,13 @@ via_dmablit_active(drm_via_blitq_t *blitq, int engine, uint32_t handle, wait_que
426 426
427 return active; 427 return active;
428} 428}
429 429
430/* 430/*
431 * Sync. Wait for at least three seconds for the blit to be performed. 431 * Sync. Wait for at least three seconds for the blit to be performed.
432 */ 432 */
433 433
434static int 434static int
435via_dmablit_sync(struct drm_device *dev, uint32_t handle, int engine) 435via_dmablit_sync(struct drm_device *dev, uint32_t handle, int engine)
436{ 436{
437 437
438 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private; 438 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private;
@@ -441,12 +441,12 @@ via_dmablit_sync(struct drm_device *dev, uint32_t handle, int engine)
441 int ret = 0; 441 int ret = 0;
442 442
443 if (via_dmablit_active(blitq, engine, handle, &queue)) { 443 if (via_dmablit_active(blitq, engine, handle, &queue)) {
444 DRM_WAIT_ON(ret, *queue, 3 * DRM_HZ, 444 DRM_WAIT_ON(ret, *queue, 3 * DRM_HZ,
445 !via_dmablit_active(blitq, engine, handle, NULL)); 445 !via_dmablit_active(blitq, engine, handle, NULL));
446 } 446 }
447 DRM_DEBUG("DMA blit sync handle 0x%x engine %d returned %d\n", 447 DRM_DEBUG("DMA blit sync handle 0x%x engine %d returned %d\n",
448 handle, engine, ret); 448 handle, engine, ret);
449 449
450 return ret; 450 return ret;
451} 451}
452 452
@@ -468,12 +468,12 @@ via_dmablit_timer(unsigned long data)
468 struct drm_device *dev = blitq->dev; 468 struct drm_device *dev = blitq->dev;
469 int engine = (int) 469 int engine = (int)
470 (blitq - ((drm_via_private_t *)dev->dev_private)->blit_queues); 470 (blitq - ((drm_via_private_t *)dev->dev_private)->blit_queues);
471 471
472 DRM_DEBUG("Polling timer called for engine %d, jiffies %lu\n", engine, 472 DRM_DEBUG("Polling timer called for engine %d, jiffies %lu\n", engine,
473 (unsigned long) jiffies); 473 (unsigned long) jiffies);
474 474
475 via_dmablit_handler(dev, engine, 0); 475 via_dmablit_handler(dev, engine, 0);
476 476
477 if (!timer_pending(&blitq->poll_timer)) { 477 if (!timer_pending(&blitq->poll_timer)) {
478 mod_timer(&blitq->poll_timer, jiffies + 1); 478 mod_timer(&blitq->poll_timer, jiffies + 1);
479 479
@@ -497,7 +497,7 @@ via_dmablit_timer(unsigned long data)
497 */ 497 */
498 498
499 499
500static void 500static void
501via_dmablit_workqueue(struct work_struct *work) 501via_dmablit_workqueue(struct work_struct *work)
502{ 502{
503 drm_via_blitq_t *blitq = container_of(work, drm_via_blitq_t, wq); 503 drm_via_blitq_t *blitq = container_of(work, drm_via_blitq_t, wq);
@@ -505,38 +505,38 @@ via_dmablit_workqueue(struct work_struct *work)
505 unsigned long irqsave; 505 unsigned long irqsave;
506 drm_via_sg_info_t *cur_sg; 506 drm_via_sg_info_t *cur_sg;
507 int cur_released; 507 int cur_released;
508 508
509 509
510 DRM_DEBUG("Workqueue task called for blit engine %ld\n",(unsigned long) 510 DRM_DEBUG("Workqueue task called for blit engine %ld\n",(unsigned long)
511 (blitq - ((drm_via_private_t *)dev->dev_private)->blit_queues)); 511 (blitq - ((drm_via_private_t *)dev->dev_private)->blit_queues));
512 512
513 spin_lock_irqsave(&blitq->blit_lock, irqsave); 513 spin_lock_irqsave(&blitq->blit_lock, irqsave);
514 514
515 while(blitq->serviced != blitq->cur) { 515 while(blitq->serviced != blitq->cur) {
516 516
517 cur_released = blitq->serviced++; 517 cur_released = blitq->serviced++;
518 518
519 DRM_DEBUG("Releasing blit slot %d\n", cur_released); 519 DRM_DEBUG("Releasing blit slot %d\n", cur_released);
520 520
521 if (blitq->serviced >= VIA_NUM_BLIT_SLOTS) 521 if (blitq->serviced >= VIA_NUM_BLIT_SLOTS)
522 blitq->serviced = 0; 522 blitq->serviced = 0;
523 523
524 cur_sg = blitq->blits[cur_released]; 524 cur_sg = blitq->blits[cur_released];
525 blitq->num_free++; 525 blitq->num_free++;
526 526
527 spin_unlock_irqrestore(&blitq->blit_lock, irqsave); 527 spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
528 528
529 DRM_WAKEUP(&blitq->busy_queue); 529 DRM_WAKEUP(&blitq->busy_queue);
530 530
531 via_free_sg_info(dev->pdev, cur_sg); 531 via_free_sg_info(dev->pdev, cur_sg);
532 kfree(cur_sg); 532 kfree(cur_sg);
533 533
534 spin_lock_irqsave(&blitq->blit_lock, irqsave); 534 spin_lock_irqsave(&blitq->blit_lock, irqsave);
535 } 535 }
536 536
537 spin_unlock_irqrestore(&blitq->blit_lock, irqsave); 537 spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
538} 538}
539 539
540 540
541/* 541/*
542 * Init all blit engines. Currently we use two, but some hardware have 4. 542 * Init all blit engines. Currently we use two, but some hardware have 4.
@@ -550,8 +550,8 @@ via_init_dmablit(struct drm_device *dev)
550 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private; 550 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private;
551 drm_via_blitq_t *blitq; 551 drm_via_blitq_t *blitq;
552 552
553 pci_set_master(dev->pdev); 553 pci_set_master(dev->pdev);
554 554
555 for (i=0; i< VIA_NUM_BLIT_ENGINES; ++i) { 555 for (i=0; i< VIA_NUM_BLIT_ENGINES; ++i) {
556 blitq = dev_priv->blit_queues + i; 556 blitq = dev_priv->blit_queues + i;
557 blitq->dev = dev; 557 blitq->dev = dev;
@@ -572,20 +572,20 @@ via_init_dmablit(struct drm_device *dev)
572 INIT_WORK(&blitq->wq, via_dmablit_workqueue); 572 INIT_WORK(&blitq->wq, via_dmablit_workqueue);
573 setup_timer(&blitq->poll_timer, via_dmablit_timer, 573 setup_timer(&blitq->poll_timer, via_dmablit_timer,
574 (unsigned long)blitq); 574 (unsigned long)blitq);
575 } 575 }
576} 576}
577 577
578/* 578/*
579 * Build all info and do all mappings required for a blit. 579 * Build all info and do all mappings required for a blit.
580 */ 580 */
581 581
582 582
583static int 583static int
584via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer) 584via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
585{ 585{
586 int draw = xfer->to_fb; 586 int draw = xfer->to_fb;
587 int ret = 0; 587 int ret = 0;
588 588
589 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 589 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
590 vsg->bounce_buffer = NULL; 590 vsg->bounce_buffer = NULL;
591 591
@@ -599,7 +599,7 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
599 /* 599 /*
600 * Below check is a driver limitation, not a hardware one. We 600 * Below check is a driver limitation, not a hardware one. We
601 * don't want to lock unused pages, and don't want to incoporate the 601 * don't want to lock unused pages, and don't want to incoporate the
602 * extra logic of avoiding them. Make sure there are no. 602 * extra logic of avoiding them. Make sure there are no.
603 * (Not a big limitation anyway.) 603 * (Not a big limitation anyway.)
604 */ 604 */
605 605
@@ -625,11 +625,11 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
625 if (xfer->num_lines > 2048 || (xfer->num_lines*xfer->mem_stride > (2048*2048*4))) { 625 if (xfer->num_lines > 2048 || (xfer->num_lines*xfer->mem_stride > (2048*2048*4))) {
626 DRM_ERROR("Too large PCI DMA bitblt.\n"); 626 DRM_ERROR("Too large PCI DMA bitblt.\n");
627 return -EINVAL; 627 return -EINVAL;
628 } 628 }
629 629
630 /* 630 /*
631 * we allow a negative fb stride to allow flipping of images in 631 * we allow a negative fb stride to allow flipping of images in
632 * transfer. 632 * transfer.
633 */ 633 */
634 634
635 if (xfer->mem_stride < xfer->line_length || 635 if (xfer->mem_stride < xfer->line_length ||
@@ -653,11 +653,11 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
653#else 653#else
654 if ((((unsigned long)xfer->mem_addr & 15) || 654 if ((((unsigned long)xfer->mem_addr & 15) ||
655 ((unsigned long)xfer->fb_addr & 3)) || 655 ((unsigned long)xfer->fb_addr & 3)) ||
656 ((xfer->num_lines > 1) && 656 ((xfer->num_lines > 1) &&
657 ((xfer->mem_stride & 15) || (xfer->fb_stride & 3)))) { 657 ((xfer->mem_stride & 15) || (xfer->fb_stride & 3)))) {
658 DRM_ERROR("Invalid DRM bitblt alignment.\n"); 658 DRM_ERROR("Invalid DRM bitblt alignment.\n");
659 return -EINVAL; 659 return -EINVAL;
660 } 660 }
661#endif 661#endif
662 662
663 if (0 != (ret = via_lock_all_dma_pages(vsg, xfer))) { 663 if (0 != (ret = via_lock_all_dma_pages(vsg, xfer))) {
@@ -673,17 +673,17 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
673 return ret; 673 return ret;
674 } 674 }
675 via_map_blit_for_device(dev->pdev, xfer, vsg, 1); 675 via_map_blit_for_device(dev->pdev, xfer, vsg, 1);
676 676
677 return 0; 677 return 0;
678} 678}
679 679
680 680
681/* 681/*
682 * Reserve one free slot in the blit queue. Will wait for one second for one 682 * Reserve one free slot in the blit queue. Will wait for one second for one
683 * to become available. Otherwise -EBUSY is returned. 683 * to become available. Otherwise -EBUSY is returned.
684 */ 684 */
685 685
686static int 686static int
687via_dmablit_grab_slot(drm_via_blitq_t *blitq, int engine) 687via_dmablit_grab_slot(drm_via_blitq_t *blitq, int engine)
688{ 688{
689 int ret=0; 689 int ret=0;
@@ -698,10 +698,10 @@ via_dmablit_grab_slot(drm_via_blitq_t *blitq, int engine)
698 if (ret) { 698 if (ret) {
699 return (-EINTR == ret) ? -EAGAIN : ret; 699 return (-EINTR == ret) ? -EAGAIN : ret;
700 } 700 }
701 701
702 spin_lock_irqsave(&blitq->blit_lock, irqsave); 702 spin_lock_irqsave(&blitq->blit_lock, irqsave);
703 } 703 }
704 704
705 blitq->num_free--; 705 blitq->num_free--;
706 spin_unlock_irqrestore(&blitq->blit_lock, irqsave); 706 spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
707 707
@@ -712,7 +712,7 @@ via_dmablit_grab_slot(drm_via_blitq_t *blitq, int engine)
712 * Hand back a free slot if we changed our mind. 712 * Hand back a free slot if we changed our mind.
713 */ 713 */
714 714
715static void 715static void
716via_dmablit_release_slot(drm_via_blitq_t *blitq) 716via_dmablit_release_slot(drm_via_blitq_t *blitq)
717{ 717{
718 unsigned long irqsave; 718 unsigned long irqsave;
@@ -728,8 +728,8 @@ via_dmablit_release_slot(drm_via_blitq_t *blitq)
728 */ 728 */
729 729
730 730
731static int 731static int
732via_dmablit(struct drm_device *dev, drm_via_dmablit_t *xfer) 732via_dmablit(struct drm_device *dev, drm_via_dmablit_t *xfer)
733{ 733{
734 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private; 734 drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private;
735 drm_via_sg_info_t *vsg; 735 drm_via_sg_info_t *vsg;
@@ -760,15 +760,15 @@ via_dmablit(struct drm_device *dev, drm_via_dmablit_t *xfer)
760 spin_lock_irqsave(&blitq->blit_lock, irqsave); 760 spin_lock_irqsave(&blitq->blit_lock, irqsave);
761 761
762 blitq->blits[blitq->head++] = vsg; 762 blitq->blits[blitq->head++] = vsg;
763 if (blitq->head >= VIA_NUM_BLIT_SLOTS) 763 if (blitq->head >= VIA_NUM_BLIT_SLOTS)
764 blitq->head = 0; 764 blitq->head = 0;
765 blitq->num_outstanding++; 765 blitq->num_outstanding++;
766 xfer->sync.sync_handle = ++blitq->cur_blit_handle; 766 xfer->sync.sync_handle = ++blitq->cur_blit_handle;
767 767
768 spin_unlock_irqrestore(&blitq->blit_lock, irqsave); 768 spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
769 xfer->sync.engine = engine; 769 xfer->sync.engine = engine;
770 770
771 via_dmablit_handler(dev, engine, 0); 771 via_dmablit_handler(dev, engine, 0);
772 772
773 return 0; 773 return 0;
774} 774}
@@ -776,7 +776,7 @@ via_dmablit(struct drm_device *dev, drm_via_dmablit_t *xfer)
776/* 776/*
777 * Sync on a previously submitted blit. Note that the X server use signals extensively, and 777 * Sync on a previously submitted blit. Note that the X server use signals extensively, and
778 * that there is a very big probability that this IOCTL will be interrupted by a signal. In that 778 * that there is a very big probability that this IOCTL will be interrupted by a signal. In that
779 * case it returns with -EAGAIN for the signal to be delivered. 779 * case it returns with -EAGAIN for the signal to be delivered.
780 * The caller should then reissue the IOCTL. This is similar to what is being done for drmGetLock(). 780 * The caller should then reissue the IOCTL. This is similar to what is being done for drmGetLock().
781 */ 781 */
782 782
@@ -786,7 +786,7 @@ via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_pri
786 drm_via_blitsync_t *sync = data; 786 drm_via_blitsync_t *sync = data;
787 int err; 787 int err;
788 788
789 if (sync->engine >= VIA_NUM_BLIT_ENGINES) 789 if (sync->engine >= VIA_NUM_BLIT_ENGINES)
790 return -EINVAL; 790 return -EINVAL;
791 791
792 err = via_dmablit_sync(dev, sync->sync_handle, sync->engine); 792 err = via_dmablit_sync(dev, sync->sync_handle, sync->engine);
@@ -796,15 +796,15 @@ via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_pri
796 796
797 return err; 797 return err;
798} 798}
799 799
800 800
801/* 801/*
802 * Queue a blit and hand back a handle to be used for sync. This IOCTL may be interrupted by a signal 802 * Queue a blit and hand back a handle to be used for sync. This IOCTL may be interrupted by a signal
803 * while waiting for a free slot in the blit queue. In that case it returns with -EAGAIN and should 803 * while waiting for a free slot in the blit queue. In that case it returns with -EAGAIN and should
804 * be reissued. See the above IOCTL code. 804 * be reissued. See the above IOCTL code.
805 */ 805 */
806 806
807int 807int
808via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv ) 808via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv )
809{ 809{
810 drm_via_dmablit_t *xfer = data; 810 drm_via_dmablit_t *xfer = data;
diff --git a/drivers/char/drm/via_dmablit.h b/drivers/char/drm/via_dmablit.h
index 6f6a513d5147..7408a547a036 100644
--- a/drivers/char/drm/via_dmablit.h
+++ b/drivers/char/drm/via_dmablit.h
@@ -1,5 +1,5 @@
1/* via_dmablit.h -- PCI DMA BitBlt support for the VIA Unichrome/Pro 1/* via_dmablit.h -- PCI DMA BitBlt support for the VIA Unichrome/Pro
2 * 2 *
3 * Copyright 2005 Thomas Hellstrom. 3 * Copyright 2005 Thomas Hellstrom.
4 * All Rights Reserved. 4 * All Rights Reserved.
5 * 5 *
@@ -17,12 +17,12 @@
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 20 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * 24 *
25 * Authors: 25 * Authors:
26 * Thomas Hellstrom. 26 * Thomas Hellstrom.
27 * Register info from Digeo Inc. 27 * Register info from Digeo Inc.
28 */ 28 */
@@ -67,7 +67,7 @@ typedef struct _drm_via_blitq {
67 unsigned cur; 67 unsigned cur;
68 unsigned num_free; 68 unsigned num_free;
69 unsigned num_outstanding; 69 unsigned num_outstanding;
70 unsigned long end; 70 unsigned long end;
71 int aborting; 71 int aborting;
72 int is_active; 72 int is_active;
73 drm_via_sg_info_t *blits[VIA_NUM_BLIT_SLOTS]; 73 drm_via_sg_info_t *blits[VIA_NUM_BLIT_SLOTS];
@@ -77,46 +77,46 @@ typedef struct _drm_via_blitq {
77 struct work_struct wq; 77 struct work_struct wq;
78 struct timer_list poll_timer; 78 struct timer_list poll_timer;
79} drm_via_blitq_t; 79} drm_via_blitq_t;
80
81 80
82/* 81
82/*
83 * PCI DMA Registers 83 * PCI DMA Registers
84 * Channels 2 & 3 don't seem to be implemented in hardware. 84 * Channels 2 & 3 don't seem to be implemented in hardware.
85 */ 85 */
86 86
87#define VIA_PCI_DMA_MAR0 0xE40 /* Memory Address Register of Channel 0 */ 87#define VIA_PCI_DMA_MAR0 0xE40 /* Memory Address Register of Channel 0 */
88#define VIA_PCI_DMA_DAR0 0xE44 /* Device Address Register of Channel 0 */ 88#define VIA_PCI_DMA_DAR0 0xE44 /* Device Address Register of Channel 0 */
89#define VIA_PCI_DMA_BCR0 0xE48 /* Byte Count Register of Channel 0 */ 89#define VIA_PCI_DMA_BCR0 0xE48 /* Byte Count Register of Channel 0 */
90#define VIA_PCI_DMA_DPR0 0xE4C /* Descriptor Pointer Register of Channel 0 */ 90#define VIA_PCI_DMA_DPR0 0xE4C /* Descriptor Pointer Register of Channel 0 */
91 91
92#define VIA_PCI_DMA_MAR1 0xE50 /* Memory Address Register of Channel 1 */ 92#define VIA_PCI_DMA_MAR1 0xE50 /* Memory Address Register of Channel 1 */
93#define VIA_PCI_DMA_DAR1 0xE54 /* Device Address Register of Channel 1 */ 93#define VIA_PCI_DMA_DAR1 0xE54 /* Device Address Register of Channel 1 */
94#define VIA_PCI_DMA_BCR1 0xE58 /* Byte Count Register of Channel 1 */ 94#define VIA_PCI_DMA_BCR1 0xE58 /* Byte Count Register of Channel 1 */
95#define VIA_PCI_DMA_DPR1 0xE5C /* Descriptor Pointer Register of Channel 1 */ 95#define VIA_PCI_DMA_DPR1 0xE5C /* Descriptor Pointer Register of Channel 1 */
96 96
97#define VIA_PCI_DMA_MAR2 0xE60 /* Memory Address Register of Channel 2 */ 97#define VIA_PCI_DMA_MAR2 0xE60 /* Memory Address Register of Channel 2 */
98#define VIA_PCI_DMA_DAR2 0xE64 /* Device Address Register of Channel 2 */ 98#define VIA_PCI_DMA_DAR2 0xE64 /* Device Address Register of Channel 2 */
99#define VIA_PCI_DMA_BCR2 0xE68 /* Byte Count Register of Channel 2 */ 99#define VIA_PCI_DMA_BCR2 0xE68 /* Byte Count Register of Channel 2 */
100#define VIA_PCI_DMA_DPR2 0xE6C /* Descriptor Pointer Register of Channel 2 */ 100#define VIA_PCI_DMA_DPR2 0xE6C /* Descriptor Pointer Register of Channel 2 */
101 101
102#define VIA_PCI_DMA_MAR3 0xE70 /* Memory Address Register of Channel 3 */ 102#define VIA_PCI_DMA_MAR3 0xE70 /* Memory Address Register of Channel 3 */
103#define VIA_PCI_DMA_DAR3 0xE74 /* Device Address Register of Channel 3 */ 103#define VIA_PCI_DMA_DAR3 0xE74 /* Device Address Register of Channel 3 */
104#define VIA_PCI_DMA_BCR3 0xE78 /* Byte Count Register of Channel 3 */ 104#define VIA_PCI_DMA_BCR3 0xE78 /* Byte Count Register of Channel 3 */
105#define VIA_PCI_DMA_DPR3 0xE7C /* Descriptor Pointer Register of Channel 3 */ 105#define VIA_PCI_DMA_DPR3 0xE7C /* Descriptor Pointer Register of Channel 3 */
106 106
107#define VIA_PCI_DMA_MR0 0xE80 /* Mode Register of Channel 0 */ 107#define VIA_PCI_DMA_MR0 0xE80 /* Mode Register of Channel 0 */
108#define VIA_PCI_DMA_MR1 0xE84 /* Mode Register of Channel 1 */ 108#define VIA_PCI_DMA_MR1 0xE84 /* Mode Register of Channel 1 */
109#define VIA_PCI_DMA_MR2 0xE88 /* Mode Register of Channel 2 */ 109#define VIA_PCI_DMA_MR2 0xE88 /* Mode Register of Channel 2 */
110#define VIA_PCI_DMA_MR3 0xE8C /* Mode Register of Channel 3 */ 110#define VIA_PCI_DMA_MR3 0xE8C /* Mode Register of Channel 3 */
111 111
112#define VIA_PCI_DMA_CSR0 0xE90 /* Command/Status Register of Channel 0 */ 112#define VIA_PCI_DMA_CSR0 0xE90 /* Command/Status Register of Channel 0 */
113#define VIA_PCI_DMA_CSR1 0xE94 /* Command/Status Register of Channel 1 */ 113#define VIA_PCI_DMA_CSR1 0xE94 /* Command/Status Register of Channel 1 */
114#define VIA_PCI_DMA_CSR2 0xE98 /* Command/Status Register of Channel 2 */ 114#define VIA_PCI_DMA_CSR2 0xE98 /* Command/Status Register of Channel 2 */
115#define VIA_PCI_DMA_CSR3 0xE9C /* Command/Status Register of Channel 3 */ 115#define VIA_PCI_DMA_CSR3 0xE9C /* Command/Status Register of Channel 3 */
116 116
117#define VIA_PCI_DMA_PTR 0xEA0 /* Priority Type Register */ 117#define VIA_PCI_DMA_PTR 0xEA0 /* Priority Type Register */
118 118
119/* Define for DMA engine */ 119/* Define for DMA engine */
120/* DPR */ 120/* DPR */
121#define VIA_DMA_DPR_EC (1<<1) /* end of chain */ 121#define VIA_DMA_DPR_EC (1<<1) /* end of chain */
122#define VIA_DMA_DPR_DDIE (1<<2) /* descriptor done interrupt enable */ 122#define VIA_DMA_DPR_DDIE (1<<2) /* descriptor done interrupt enable */
diff --git a/drivers/char/drm/via_drm.h b/drivers/char/drm/via_drm.h
index 8f53c76062e9..a3b5c102b067 100644
--- a/drivers/char/drm/via_drm.h
+++ b/drivers/char/drm/via_drm.h
@@ -35,7 +35,7 @@
35#include "via_drmclient.h" 35#include "via_drmclient.h"
36#endif 36#endif
37 37
38#define VIA_NR_SAREA_CLIPRECTS 8 38#define VIA_NR_SAREA_CLIPRECTS 8
39#define VIA_NR_XVMC_PORTS 10 39#define VIA_NR_XVMC_PORTS 10
40#define VIA_NR_XVMC_LOCKS 5 40#define VIA_NR_XVMC_LOCKS 5
41#define VIA_MAX_CACHELINE_SIZE 64 41#define VIA_MAX_CACHELINE_SIZE 64
@@ -259,7 +259,7 @@ typedef struct drm_via_blitsync {
259typedef struct drm_via_dmablit { 259typedef struct drm_via_dmablit {
260 uint32_t num_lines; 260 uint32_t num_lines;
261 uint32_t line_length; 261 uint32_t line_length;
262 262
263 uint32_t fb_addr; 263 uint32_t fb_addr;
264 uint32_t fb_stride; 264 uint32_t fb_stride;
265 265
diff --git a/drivers/char/drm/via_drv.c b/drivers/char/drm/via_drv.c
index 2d4957ab256a..80c01cdfa37d 100644
--- a/drivers/char/drm/via_drv.c
+++ b/drivers/char/drm/via_drv.c
@@ -71,7 +71,7 @@ static struct drm_driver driver = {
71 .name = DRIVER_NAME, 71 .name = DRIVER_NAME,
72 .id_table = pciidlist, 72 .id_table = pciidlist,
73 }, 73 },
74 74
75 .name = DRIVER_NAME, 75 .name = DRIVER_NAME,
76 .desc = DRIVER_DESC, 76 .desc = DRIVER_DESC,
77 .date = DRIVER_DATE, 77 .date = DRIVER_DATE,
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
index 9c1d52bc92d7..c6bb978a1106 100644
--- a/drivers/char/drm/via_irq.c
+++ b/drivers/char/drm/via_irq.c
@@ -169,9 +169,9 @@ int via_driver_vblank_wait(struct drm_device * dev, unsigned int *sequence)
169 unsigned int cur_vblank; 169 unsigned int cur_vblank;
170 int ret = 0; 170 int ret = 0;
171 171
172 DRM_DEBUG("viadrv_vblank_wait\n"); 172 DRM_DEBUG("\n");
173 if (!dev_priv) { 173 if (!dev_priv) {
174 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 174 DRM_ERROR("called with no initialization\n");
175 return -EINVAL; 175 return -EINVAL;
176 } 176 }
177 177
@@ -201,24 +201,23 @@ via_driver_irq_wait(struct drm_device * dev, unsigned int irq, int force_sequenc
201 maskarray_t *masks; 201 maskarray_t *masks;
202 int real_irq; 202 int real_irq;
203 203
204 DRM_DEBUG("%s\n", __FUNCTION__); 204 DRM_DEBUG("\n");
205 205
206 if (!dev_priv) { 206 if (!dev_priv) {
207 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 207 DRM_ERROR("called with no initialization\n");
208 return -EINVAL; 208 return -EINVAL;
209 } 209 }
210 210
211 if (irq >= drm_via_irq_num) { 211 if (irq >= drm_via_irq_num) {
212 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, 212 DRM_ERROR("Trying to wait on unknown irq %d\n", irq);
213 irq);
214 return -EINVAL; 213 return -EINVAL;
215 } 214 }
216 215
217 real_irq = dev_priv->irq_map[irq]; 216 real_irq = dev_priv->irq_map[irq];
218 217
219 if (real_irq < 0) { 218 if (real_irq < 0) {
220 DRM_ERROR("%s Video IRQ %d not available on this hardware.\n", 219 DRM_ERROR("Video IRQ %d not available on this hardware.\n",
221 __FUNCTION__, irq); 220 irq);
222 return -EINVAL; 221 return -EINVAL;
223 } 222 }
224 223
@@ -251,7 +250,7 @@ void via_driver_irq_preinstall(struct drm_device * dev)
251 drm_via_irq_t *cur_irq; 250 drm_via_irq_t *cur_irq;
252 int i; 251 int i;
253 252
254 DRM_DEBUG("driver_irq_preinstall: dev_priv: %p\n", dev_priv); 253 DRM_DEBUG("dev_priv: %p\n", dev_priv);
255 if (dev_priv) { 254 if (dev_priv) {
256 cur_irq = dev_priv->via_irqs; 255 cur_irq = dev_priv->via_irqs;
257 256
@@ -298,7 +297,7 @@ void via_driver_irq_postinstall(struct drm_device * dev)
298 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 297 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
299 u32 status; 298 u32 status;
300 299
301 DRM_DEBUG("via_driver_irq_postinstall\n"); 300 DRM_DEBUG("\n");
302 if (dev_priv) { 301 if (dev_priv) {
303 status = VIA_READ(VIA_REG_INTERRUPT); 302 status = VIA_READ(VIA_REG_INTERRUPT);
304 VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL 303 VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL
@@ -317,7 +316,7 @@ void via_driver_irq_uninstall(struct drm_device * dev)
317 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 316 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
318 u32 status; 317 u32 status;
319 318
320 DRM_DEBUG("driver_irq_uninstall)\n"); 319 DRM_DEBUG("\n");
321 if (dev_priv) { 320 if (dev_priv) {
322 321
323 /* Some more magic, oh for some data sheets ! */ 322 /* Some more magic, oh for some data sheets ! */
@@ -344,7 +343,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
344 return -EINVAL; 343 return -EINVAL;
345 344
346 if (irqwait->request.irq >= dev_priv->num_irqs) { 345 if (irqwait->request.irq >= dev_priv->num_irqs) {
347 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, 346 DRM_ERROR("Trying to wait on unknown irq %d\n",
348 irqwait->request.irq); 347 irqwait->request.irq);
349 return -EINVAL; 348 return -EINVAL;
350 } 349 }
@@ -362,8 +361,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
362 } 361 }
363 362
364 if (irqwait->request.type & VIA_IRQ_SIGNAL) { 363 if (irqwait->request.type & VIA_IRQ_SIGNAL) {
365 DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n", 364 DRM_ERROR("Signals on Via IRQs not implemented yet.\n");
366 __FUNCTION__);
367 return -EINVAL; 365 return -EINVAL;
368 } 366 }
369 367
diff --git a/drivers/char/drm/via_map.c b/drivers/char/drm/via_map.c
index 10091507a0dc..a967556be014 100644
--- a/drivers/char/drm/via_map.c
+++ b/drivers/char/drm/via_map.c
@@ -29,7 +29,7 @@ static int via_do_init_map(struct drm_device * dev, drm_via_init_t * init)
29{ 29{
30 drm_via_private_t *dev_priv = dev->dev_private; 30 drm_via_private_t *dev_priv = dev->dev_private;
31 31
32 DRM_DEBUG("%s\n", __FUNCTION__); 32 DRM_DEBUG("\n");
33 33
34 dev_priv->sarea = drm_getsarea(dev); 34 dev_priv->sarea = drm_getsarea(dev);
35 if (!dev_priv->sarea) { 35 if (!dev_priv->sarea) {
@@ -79,7 +79,7 @@ int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
79{ 79{
80 drm_via_init_t *init = data; 80 drm_via_init_t *init = data;
81 81
82 DRM_DEBUG("%s\n", __FUNCTION__); 82 DRM_DEBUG("\n");
83 83
84 switch (init->func) { 84 switch (init->func) {
85 case VIA_INIT_MAP: 85 case VIA_INIT_MAP:
@@ -121,4 +121,3 @@ int via_driver_unload(struct drm_device *dev)
121 121
122 return 0; 122 return 0;
123} 123}
124
diff --git a/drivers/char/drm/via_mm.c b/drivers/char/drm/via_mm.c
index 3ffbf8649833..e64094916e4f 100644
--- a/drivers/char/drm/via_mm.c
+++ b/drivers/char/drm/via_mm.c
@@ -53,7 +53,7 @@ int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
53 dev_priv->agp_offset = agp->offset; 53 dev_priv->agp_offset = agp->offset;
54 mutex_unlock(&dev->struct_mutex); 54 mutex_unlock(&dev->struct_mutex);
55 55
56 DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size); 56 DRM_DEBUG("offset = %u, size = %u\n", agp->offset, agp->size);
57 return 0; 57 return 0;
58} 58}
59 59
@@ -77,7 +77,7 @@ int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
77 dev_priv->vram_offset = fb->offset; 77 dev_priv->vram_offset = fb->offset;
78 78
79 mutex_unlock(&dev->struct_mutex); 79 mutex_unlock(&dev->struct_mutex);
80 DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size); 80 DRM_DEBUG("offset = %u, size = %u\n", fb->offset, fb->size);
81 81
82 return 0; 82 return 0;
83 83
@@ -113,7 +113,7 @@ void via_lastclose(struct drm_device *dev)
113 dev_priv->vram_initialized = 0; 113 dev_priv->vram_initialized = 0;
114 dev_priv->agp_initialized = 0; 114 dev_priv->agp_initialized = 0;
115 mutex_unlock(&dev->struct_mutex); 115 mutex_unlock(&dev->struct_mutex);
116} 116}
117 117
118int via_mem_alloc(struct drm_device *dev, void *data, 118int via_mem_alloc(struct drm_device *dev, void *data,
119 struct drm_file *file_priv) 119 struct drm_file *file_priv)
diff --git a/drivers/char/drm/via_video.c b/drivers/char/drm/via_video.c
index c15e75b54cb1..6ec04ac12459 100644
--- a/drivers/char/drm/via_video.c
+++ b/drivers/char/drm/via_video.c
@@ -33,7 +33,7 @@ void via_init_futex(drm_via_private_t * dev_priv)
33{ 33{
34 unsigned int i; 34 unsigned int i;
35 35
36 DRM_DEBUG("%s\n", __FUNCTION__); 36 DRM_DEBUG("\n");
37 37
38 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) { 38 for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
39 DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i])); 39 DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
@@ -73,7 +73,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_
73 drm_via_sarea_t *sAPriv = dev_priv->sarea_priv; 73 drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
74 int ret = 0; 74 int ret = 0;
75 75
76 DRM_DEBUG("%s\n", __FUNCTION__); 76 DRM_DEBUG("\n");
77 77
78 if (fx->lock > VIA_NR_XVMC_LOCKS) 78 if (fx->lock > VIA_NR_XVMC_LOCKS)
79 return -EFAULT; 79 return -EFAULT;