diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 20:11:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 20:11:39 -0500 |
commit | 5b2eef966cb2ae307aa4ef1767f7307774bc96ca (patch) | |
tree | 095a251e145903598dd8d90d5b2eb880f0d6ff93 /drivers/char/agp | |
parent | 8adbf8d46718a8f110de55ec82c40d04d0c362cc (diff) | |
parent | 56bec7c009872ef33fe452ea75fecba481351b44 (diff) |
Merge branch 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (390 commits)
drm/radeon/kms: disable underscan by default
drm/radeon/kms: only enable hdmi features if the monitor supports audio
drm: Restore the old_fb upon modeset failure
drm/nouveau: fix hwmon device binding
radeon: consolidate asic-specific function decls for pre-r600
vga_switcheroo: comparing too few characters in strncmp()
drm/radeon/kms: add NI pci ids
drm/radeon/kms: don't enable pcie gen2 on NI yet
drm/radeon/kms: add radeon_asic struct for NI asics
drm/radeon/kms/ni: load default sclk/mclk/vddc at pm init
drm/radeon/kms: add ucode loader for NI
drm/radeon/kms: add support for DCE5 display LUTs
drm/radeon/kms: add ni_reg.h
drm/radeon/kms: add bo blit support for NI
drm/radeon/kms: always use writeback/events for fences on NI
drm/radeon/kms: adjust default clock/vddc tracking for pm on DCE5
drm/radeon/kms: add backend map workaround for barts
drm/radeon/kms: fill gpu init for NI asics
drm/radeon/kms: add disabled vbios accessor for NI asics
drm/radeon/kms: handle NI thermal controller
...
Diffstat (limited to 'drivers/char/agp')
-rw-r--r-- | drivers/char/agp/agp.h | 1 | ||||
-rw-r--r-- | drivers/char/agp/compat_ioctl.c | 1 | ||||
-rw-r--r-- | drivers/char/agp/compat_ioctl.h | 1 | ||||
-rw-r--r-- | drivers/char/agp/frontend.c | 8 | ||||
-rw-r--r-- | drivers/char/agp/generic.c | 27 | ||||
-rw-r--r-- | drivers/char/agp/intel-agp.c | 5 | ||||
-rw-r--r-- | drivers/char/agp/intel-agp.h | 14 | ||||
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 778 |
8 files changed, 363 insertions, 472 deletions
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 5259065f3c79..3e67ddde9e16 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h | |||
@@ -120,7 +120,6 @@ struct agp_bridge_driver { | |||
120 | void (*agp_destroy_page)(struct page *, int flags); | 120 | void (*agp_destroy_page)(struct page *, int flags); |
121 | void (*agp_destroy_pages)(struct agp_memory *); | 121 | void (*agp_destroy_pages)(struct agp_memory *); |
122 | int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); | 122 | int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); |
123 | void (*chipset_flush)(struct agp_bridge_data *); | ||
124 | }; | 123 | }; |
125 | 124 | ||
126 | struct agp_bridge_data { | 125 | struct agp_bridge_data { |
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c index 9d2c97a69cdd..a48e05b31593 100644 --- a/drivers/char/agp/compat_ioctl.c +++ b/drivers/char/agp/compat_ioctl.c | |||
@@ -276,7 +276,6 @@ long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
276 | break; | 276 | break; |
277 | 277 | ||
278 | case AGPIOC_CHIPSET_FLUSH32: | 278 | case AGPIOC_CHIPSET_FLUSH32: |
279 | ret_val = agpioc_chipset_flush_wrap(curr_priv); | ||
280 | break; | 279 | break; |
281 | } | 280 | } |
282 | 281 | ||
diff --git a/drivers/char/agp/compat_ioctl.h b/drivers/char/agp/compat_ioctl.h index 0c9678ac0371..f30e0fd97963 100644 --- a/drivers/char/agp/compat_ioctl.h +++ b/drivers/char/agp/compat_ioctl.h | |||
@@ -102,6 +102,5 @@ void agp_free_memory_wrap(struct agp_memory *memory); | |||
102 | struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type); | 102 | struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type); |
103 | struct agp_memory *agp_find_mem_by_key(int key); | 103 | struct agp_memory *agp_find_mem_by_key(int key); |
104 | struct agp_client *agp_find_client_by_pid(pid_t id); | 104 | struct agp_client *agp_find_client_by_pid(pid_t id); |
105 | int agpioc_chipset_flush_wrap(struct agp_file_private *priv); | ||
106 | 105 | ||
107 | #endif /* _AGP_COMPAT_H */ | 106 | #endif /* _AGP_COMPAT_H */ |
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index 3cb4539a98b2..2e044338753c 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c | |||
@@ -957,13 +957,6 @@ static int agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg) | |||
957 | return agp_unbind_memory(memory); | 957 | return agp_unbind_memory(memory); |
958 | } | 958 | } |
959 | 959 | ||
960 | int agpioc_chipset_flush_wrap(struct agp_file_private *priv) | ||
961 | { | ||
962 | DBG(""); | ||
963 | agp_flush_chipset(agp_bridge); | ||
964 | return 0; | ||
965 | } | ||
966 | |||
967 | static long agp_ioctl(struct file *file, | 960 | static long agp_ioctl(struct file *file, |
968 | unsigned int cmd, unsigned long arg) | 961 | unsigned int cmd, unsigned long arg) |
969 | { | 962 | { |
@@ -1039,7 +1032,6 @@ static long agp_ioctl(struct file *file, | |||
1039 | break; | 1032 | break; |
1040 | 1033 | ||
1041 | case AGPIOC_CHIPSET_FLUSH: | 1034 | case AGPIOC_CHIPSET_FLUSH: |
1042 | ret_val = agpioc_chipset_flush_wrap(curr_priv); | ||
1043 | break; | 1035 | break; |
1044 | } | 1036 | } |
1045 | 1037 | ||
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 4956f1c8f9d5..012cba0d6d96 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -81,13 +81,6 @@ static int agp_get_key(void) | |||
81 | return -1; | 81 | return -1; |
82 | } | 82 | } |
83 | 83 | ||
84 | void agp_flush_chipset(struct agp_bridge_data *bridge) | ||
85 | { | ||
86 | if (bridge->driver->chipset_flush) | ||
87 | bridge->driver->chipset_flush(bridge); | ||
88 | } | ||
89 | EXPORT_SYMBOL(agp_flush_chipset); | ||
90 | |||
91 | /* | 84 | /* |
92 | * Use kmalloc if possible for the page list. Otherwise fall back to | 85 | * Use kmalloc if possible for the page list. Otherwise fall back to |
93 | * vmalloc. This speeds things up and also saves memory for small AGP | 86 | * vmalloc. This speeds things up and also saves memory for small AGP |
@@ -487,26 +480,6 @@ int agp_unbind_memory(struct agp_memory *curr) | |||
487 | } | 480 | } |
488 | EXPORT_SYMBOL(agp_unbind_memory); | 481 | EXPORT_SYMBOL(agp_unbind_memory); |
489 | 482 | ||
490 | /** | ||
491 | * agp_rebind_emmory - Rewrite the entire GATT, useful on resume | ||
492 | */ | ||
493 | int agp_rebind_memory(void) | ||
494 | { | ||
495 | struct agp_memory *curr; | ||
496 | int ret_val = 0; | ||
497 | |||
498 | spin_lock(&agp_bridge->mapped_lock); | ||
499 | list_for_each_entry(curr, &agp_bridge->mapped_list, mapped_list) { | ||
500 | ret_val = curr->bridge->driver->insert_memory(curr, | ||
501 | curr->pg_start, | ||
502 | curr->type); | ||
503 | if (ret_val != 0) | ||
504 | break; | ||
505 | } | ||
506 | spin_unlock(&agp_bridge->mapped_lock); | ||
507 | return ret_val; | ||
508 | } | ||
509 | EXPORT_SYMBOL(agp_rebind_memory); | ||
510 | 483 | ||
511 | /* End - Routines for handling swapping of agp_memory into the GATT */ | 484 | /* End - Routines for handling swapping of agp_memory into the GATT */ |
512 | 485 | ||
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index e72f49d52202..07e9796fead7 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -828,14 +828,9 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev) | |||
828 | static int agp_intel_resume(struct pci_dev *pdev) | 828 | static int agp_intel_resume(struct pci_dev *pdev) |
829 | { | 829 | { |
830 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); | 830 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
831 | int ret_val; | ||
832 | 831 | ||
833 | bridge->driver->configure(); | 832 | bridge->driver->configure(); |
834 | 833 | ||
835 | ret_val = agp_rebind_memory(); | ||
836 | if (ret_val != 0) | ||
837 | return ret_val; | ||
838 | |||
839 | return 0; | 834 | return 0; |
840 | } | 835 | } |
841 | #endif | 836 | #endif |
diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h index 90539df02504..010e3defd6c3 100644 --- a/drivers/char/agp/intel-agp.h +++ b/drivers/char/agp/intel-agp.h | |||
@@ -75,6 +75,8 @@ | |||
75 | #define I810_GMS_DISABLE 0x00000000 | 75 | #define I810_GMS_DISABLE 0x00000000 |
76 | #define I810_PGETBL_CTL 0x2020 | 76 | #define I810_PGETBL_CTL 0x2020 |
77 | #define I810_PGETBL_ENABLED 0x00000001 | 77 | #define I810_PGETBL_ENABLED 0x00000001 |
78 | /* Note: PGETBL_CTL2 has a different offset on G33. */ | ||
79 | #define I965_PGETBL_CTL2 0x20c4 | ||
78 | #define I965_PGETBL_SIZE_MASK 0x0000000e | 80 | #define I965_PGETBL_SIZE_MASK 0x0000000e |
79 | #define I965_PGETBL_SIZE_512KB (0 << 1) | 81 | #define I965_PGETBL_SIZE_512KB (0 << 1) |
80 | #define I965_PGETBL_SIZE_256KB (1 << 1) | 82 | #define I965_PGETBL_SIZE_256KB (1 << 1) |
@@ -82,9 +84,15 @@ | |||
82 | #define I965_PGETBL_SIZE_1MB (3 << 1) | 84 | #define I965_PGETBL_SIZE_1MB (3 << 1) |
83 | #define I965_PGETBL_SIZE_2MB (4 << 1) | 85 | #define I965_PGETBL_SIZE_2MB (4 << 1) |
84 | #define I965_PGETBL_SIZE_1_5MB (5 << 1) | 86 | #define I965_PGETBL_SIZE_1_5MB (5 << 1) |
85 | #define G33_PGETBL_SIZE_MASK (3 << 8) | 87 | #define G33_GMCH_SIZE_MASK (3 << 8) |
86 | #define G33_PGETBL_SIZE_1M (1 << 8) | 88 | #define G33_GMCH_SIZE_1M (1 << 8) |
87 | #define G33_PGETBL_SIZE_2M (2 << 8) | 89 | #define G33_GMCH_SIZE_2M (2 << 8) |
90 | #define G4x_GMCH_SIZE_MASK (0xf << 8) | ||
91 | #define G4x_GMCH_SIZE_1M (0x1 << 8) | ||
92 | #define G4x_GMCH_SIZE_2M (0x3 << 8) | ||
93 | #define G4x_GMCH_SIZE_VT_1M (0x9 << 8) | ||
94 | #define G4x_GMCH_SIZE_VT_1_5M (0xa << 8) | ||
95 | #define G4x_GMCH_SIZE_VT_2M (0xc << 8) | ||
88 | 96 | ||
89 | #define I810_DRAM_CTL 0x3000 | 97 | #define I810_DRAM_CTL 0x3000 |
90 | #define I810_DRAM_ROW_0 0x00000001 | 98 | #define I810_DRAM_ROW_0 0x00000001 |
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 29ac6d499fa6..356f73e0d17e 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <asm/smp.h> | 24 | #include <asm/smp.h> |
25 | #include "agp.h" | 25 | #include "agp.h" |
26 | #include "intel-agp.h" | 26 | #include "intel-agp.h" |
27 | #include <linux/intel-gtt.h> | ||
28 | #include <drm/intel-gtt.h> | 27 | #include <drm/intel-gtt.h> |
29 | 28 | ||
30 | /* | 29 | /* |
@@ -39,40 +38,12 @@ | |||
39 | #define USE_PCI_DMA_API 0 | 38 | #define USE_PCI_DMA_API 0 |
40 | #endif | 39 | #endif |
41 | 40 | ||
42 | /* Max amount of stolen space, anything above will be returned to Linux */ | ||
43 | int intel_max_stolen = 32 * 1024 * 1024; | ||
44 | |||
45 | static const struct aper_size_info_fixed intel_i810_sizes[] = | ||
46 | { | ||
47 | {64, 16384, 4}, | ||
48 | /* The 32M mode still requires a 64k gatt */ | ||
49 | {32, 8192, 4} | ||
50 | }; | ||
51 | |||
52 | #define AGP_DCACHE_MEMORY 1 | ||
53 | #define AGP_PHYS_MEMORY 2 | ||
54 | #define INTEL_AGP_CACHED_MEMORY 3 | ||
55 | |||
56 | static struct gatt_mask intel_i810_masks[] = | ||
57 | { | ||
58 | {.mask = I810_PTE_VALID, .type = 0}, | ||
59 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, | ||
60 | {.mask = I810_PTE_VALID, .type = 0}, | ||
61 | {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED, | ||
62 | .type = INTEL_AGP_CACHED_MEMORY} | ||
63 | }; | ||
64 | |||
65 | #define INTEL_AGP_UNCACHED_MEMORY 0 | ||
66 | #define INTEL_AGP_CACHED_MEMORY_LLC 1 | ||
67 | #define INTEL_AGP_CACHED_MEMORY_LLC_GFDT 2 | ||
68 | #define INTEL_AGP_CACHED_MEMORY_LLC_MLC 3 | ||
69 | #define INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT 4 | ||
70 | |||
71 | struct intel_gtt_driver { | 41 | struct intel_gtt_driver { |
72 | unsigned int gen : 8; | 42 | unsigned int gen : 8; |
73 | unsigned int is_g33 : 1; | 43 | unsigned int is_g33 : 1; |
74 | unsigned int is_pineview : 1; | 44 | unsigned int is_pineview : 1; |
75 | unsigned int is_ironlake : 1; | 45 | unsigned int is_ironlake : 1; |
46 | unsigned int has_pgtbl_enable : 1; | ||
76 | unsigned int dma_mask_size : 8; | 47 | unsigned int dma_mask_size : 8; |
77 | /* Chipset specific GTT setup */ | 48 | /* Chipset specific GTT setup */ |
78 | int (*setup)(void); | 49 | int (*setup)(void); |
@@ -95,13 +66,14 @@ static struct _intel_private { | |||
95 | u8 __iomem *registers; | 66 | u8 __iomem *registers; |
96 | phys_addr_t gtt_bus_addr; | 67 | phys_addr_t gtt_bus_addr; |
97 | phys_addr_t gma_bus_addr; | 68 | phys_addr_t gma_bus_addr; |
98 | phys_addr_t pte_bus_addr; | 69 | u32 PGETBL_save; |
99 | u32 __iomem *gtt; /* I915G */ | 70 | u32 __iomem *gtt; /* I915G */ |
100 | int num_dcache_entries; | 71 | int num_dcache_entries; |
101 | union { | 72 | union { |
102 | void __iomem *i9xx_flush_page; | 73 | void __iomem *i9xx_flush_page; |
103 | void *i8xx_flush_page; | 74 | void *i8xx_flush_page; |
104 | }; | 75 | }; |
76 | char *i81x_gtt_table; | ||
105 | struct page *i8xx_page; | 77 | struct page *i8xx_page; |
106 | struct resource ifp_resource; | 78 | struct resource ifp_resource; |
107 | int resource_valid; | 79 | int resource_valid; |
@@ -113,42 +85,31 @@ static struct _intel_private { | |||
113 | #define IS_G33 intel_private.driver->is_g33 | 85 | #define IS_G33 intel_private.driver->is_g33 |
114 | #define IS_PINEVIEW intel_private.driver->is_pineview | 86 | #define IS_PINEVIEW intel_private.driver->is_pineview |
115 | #define IS_IRONLAKE intel_private.driver->is_ironlake | 87 | #define IS_IRONLAKE intel_private.driver->is_ironlake |
88 | #define HAS_PGTBL_EN intel_private.driver->has_pgtbl_enable | ||
116 | 89 | ||
117 | static void intel_agp_free_sglist(struct agp_memory *mem) | 90 | int intel_gtt_map_memory(struct page **pages, unsigned int num_entries, |
118 | { | 91 | struct scatterlist **sg_list, int *num_sg) |
119 | struct sg_table st; | ||
120 | |||
121 | st.sgl = mem->sg_list; | ||
122 | st.orig_nents = st.nents = mem->page_count; | ||
123 | |||
124 | sg_free_table(&st); | ||
125 | |||
126 | mem->sg_list = NULL; | ||
127 | mem->num_sg = 0; | ||
128 | } | ||
129 | |||
130 | static int intel_agp_map_memory(struct agp_memory *mem) | ||
131 | { | 92 | { |
132 | struct sg_table st; | 93 | struct sg_table st; |
133 | struct scatterlist *sg; | 94 | struct scatterlist *sg; |
134 | int i; | 95 | int i; |
135 | 96 | ||
136 | if (mem->sg_list) | 97 | if (*sg_list) |
137 | return 0; /* already mapped (for e.g. resume */ | 98 | return 0; /* already mapped (for e.g. resume */ |
138 | 99 | ||
139 | DBG("try mapping %lu pages\n", (unsigned long)mem->page_count); | 100 | DBG("try mapping %lu pages\n", (unsigned long)num_entries); |
140 | 101 | ||
141 | if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL)) | 102 | if (sg_alloc_table(&st, num_entries, GFP_KERNEL)) |
142 | goto err; | 103 | goto err; |
143 | 104 | ||
144 | mem->sg_list = sg = st.sgl; | 105 | *sg_list = sg = st.sgl; |
145 | 106 | ||
146 | for (i = 0 ; i < mem->page_count; i++, sg = sg_next(sg)) | 107 | for (i = 0 ; i < num_entries; i++, sg = sg_next(sg)) |
147 | sg_set_page(sg, mem->pages[i], PAGE_SIZE, 0); | 108 | sg_set_page(sg, pages[i], PAGE_SIZE, 0); |
148 | 109 | ||
149 | mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, | 110 | *num_sg = pci_map_sg(intel_private.pcidev, *sg_list, |
150 | mem->page_count, PCI_DMA_BIDIRECTIONAL); | 111 | num_entries, PCI_DMA_BIDIRECTIONAL); |
151 | if (unlikely(!mem->num_sg)) | 112 | if (unlikely(!*num_sg)) |
152 | goto err; | 113 | goto err; |
153 | 114 | ||
154 | return 0; | 115 | return 0; |
@@ -157,90 +118,22 @@ err: | |||
157 | sg_free_table(&st); | 118 | sg_free_table(&st); |
158 | return -ENOMEM; | 119 | return -ENOMEM; |
159 | } | 120 | } |
121 | EXPORT_SYMBOL(intel_gtt_map_memory); | ||
160 | 122 | ||
161 | static void intel_agp_unmap_memory(struct agp_memory *mem) | 123 | void intel_gtt_unmap_memory(struct scatterlist *sg_list, int num_sg) |
162 | { | 124 | { |
125 | struct sg_table st; | ||
163 | DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count); | 126 | DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count); |
164 | 127 | ||
165 | pci_unmap_sg(intel_private.pcidev, mem->sg_list, | 128 | pci_unmap_sg(intel_private.pcidev, sg_list, |
166 | mem->page_count, PCI_DMA_BIDIRECTIONAL); | 129 | num_sg, PCI_DMA_BIDIRECTIONAL); |
167 | intel_agp_free_sglist(mem); | ||
168 | } | ||
169 | |||
170 | static int intel_i810_fetch_size(void) | ||
171 | { | ||
172 | u32 smram_miscc; | ||
173 | struct aper_size_info_fixed *values; | ||
174 | |||
175 | pci_read_config_dword(intel_private.bridge_dev, | ||
176 | I810_SMRAM_MISCC, &smram_miscc); | ||
177 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); | ||
178 | |||
179 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { | ||
180 | dev_warn(&intel_private.bridge_dev->dev, "i810 is disabled\n"); | ||
181 | return 0; | ||
182 | } | ||
183 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { | ||
184 | agp_bridge->current_size = (void *) (values + 1); | ||
185 | agp_bridge->aperture_size_idx = 1; | ||
186 | return values[1].size; | ||
187 | } else { | ||
188 | agp_bridge->current_size = (void *) (values); | ||
189 | agp_bridge->aperture_size_idx = 0; | ||
190 | return values[0].size; | ||
191 | } | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static int intel_i810_configure(void) | ||
197 | { | ||
198 | struct aper_size_info_fixed *current_size; | ||
199 | u32 temp; | ||
200 | int i; | ||
201 | |||
202 | current_size = A_SIZE_FIX(agp_bridge->current_size); | ||
203 | 130 | ||
204 | if (!intel_private.registers) { | 131 | st.sgl = sg_list; |
205 | pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp); | 132 | st.orig_nents = st.nents = num_sg; |
206 | temp &= 0xfff80000; | ||
207 | 133 | ||
208 | intel_private.registers = ioremap(temp, 128 * 4096); | 134 | sg_free_table(&st); |
209 | if (!intel_private.registers) { | ||
210 | dev_err(&intel_private.pcidev->dev, | ||
211 | "can't remap memory\n"); | ||
212 | return -ENOMEM; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | if ((readl(intel_private.registers+I810_DRAM_CTL) | ||
217 | & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { | ||
218 | /* This will need to be dynamically assigned */ | ||
219 | dev_info(&intel_private.pcidev->dev, | ||
220 | "detected 4MB dedicated video ram\n"); | ||
221 | intel_private.num_dcache_entries = 1024; | ||
222 | } | ||
223 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); | ||
224 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); | ||
225 | writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); | ||
226 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ | ||
227 | |||
228 | if (agp_bridge->driver->needs_scratch_page) { | ||
229 | for (i = 0; i < current_size->num_entries; i++) { | ||
230 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); | ||
231 | } | ||
232 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI posting. */ | ||
233 | } | ||
234 | global_cache_flush(); | ||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static void intel_i810_cleanup(void) | ||
239 | { | ||
240 | writel(0, intel_private.registers+I810_PGETBL_CTL); | ||
241 | readl(intel_private.registers); /* PCI Posting. */ | ||
242 | iounmap(intel_private.registers); | ||
243 | } | 135 | } |
136 | EXPORT_SYMBOL(intel_gtt_unmap_memory); | ||
244 | 137 | ||
245 | static void intel_fake_agp_enable(struct agp_bridge_data *bridge, u32 mode) | 138 | static void intel_fake_agp_enable(struct agp_bridge_data *bridge, u32 mode) |
246 | { | 139 | { |
@@ -277,80 +170,64 @@ static void i8xx_destroy_pages(struct page *page) | |||
277 | atomic_dec(&agp_bridge->current_memory_agp); | 170 | atomic_dec(&agp_bridge->current_memory_agp); |
278 | } | 171 | } |
279 | 172 | ||
280 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, | 173 | #define I810_GTT_ORDER 4 |
281 | int type) | 174 | static int i810_setup(void) |
282 | { | 175 | { |
283 | int i, j, num_entries; | 176 | u32 reg_addr; |
284 | void *temp; | 177 | char *gtt_table; |
285 | int ret = -EINVAL; | ||
286 | int mask_type; | ||
287 | |||
288 | if (mem->page_count == 0) | ||
289 | goto out; | ||
290 | |||
291 | temp = agp_bridge->current_size; | ||
292 | num_entries = A_SIZE_FIX(temp)->num_entries; | ||
293 | 178 | ||
294 | if ((pg_start + mem->page_count) > num_entries) | 179 | /* i81x does not preallocate the gtt. It's always 64kb in size. */ |
295 | goto out_err; | 180 | gtt_table = alloc_gatt_pages(I810_GTT_ORDER); |
181 | if (gtt_table == NULL) | ||
182 | return -ENOMEM; | ||
183 | intel_private.i81x_gtt_table = gtt_table; | ||
296 | 184 | ||
185 | pci_read_config_dword(intel_private.pcidev, I810_MMADDR, ®_addr); | ||
186 | reg_addr &= 0xfff80000; | ||
297 | 187 | ||
298 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { | 188 | intel_private.registers = ioremap(reg_addr, KB(64)); |
299 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) { | 189 | if (!intel_private.registers) |
300 | ret = -EBUSY; | 190 | return -ENOMEM; |
301 | goto out_err; | ||
302 | } | ||
303 | } | ||
304 | 191 | ||
305 | if (type != mem->type) | 192 | writel(virt_to_phys(gtt_table) | I810_PGETBL_ENABLED, |
306 | goto out_err; | 193 | intel_private.registers+I810_PGETBL_CTL); |
307 | 194 | ||
308 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | 195 | intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE; |
309 | 196 | ||
310 | switch (mask_type) { | 197 | if ((readl(intel_private.registers+I810_DRAM_CTL) |
311 | case AGP_DCACHE_MEMORY: | 198 | & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { |
312 | if (!mem->is_flushed) | 199 | dev_info(&intel_private.pcidev->dev, |
313 | global_cache_flush(); | 200 | "detected 4MB dedicated video ram\n"); |
314 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { | 201 | intel_private.num_dcache_entries = 1024; |
315 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, | ||
316 | intel_private.registers+I810_PTE_BASE+(i*4)); | ||
317 | } | ||
318 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); | ||
319 | break; | ||
320 | case AGP_PHYS_MEMORY: | ||
321 | case AGP_NORMAL_MEMORY: | ||
322 | if (!mem->is_flushed) | ||
323 | global_cache_flush(); | ||
324 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | ||
325 | writel(agp_bridge->driver->mask_memory(agp_bridge, | ||
326 | page_to_phys(mem->pages[i]), mask_type), | ||
327 | intel_private.registers+I810_PTE_BASE+(j*4)); | ||
328 | } | ||
329 | readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); | ||
330 | break; | ||
331 | default: | ||
332 | goto out_err; | ||
333 | } | 202 | } |
334 | 203 | ||
335 | out: | 204 | return 0; |
336 | ret = 0; | ||
337 | out_err: | ||
338 | mem->is_flushed = true; | ||
339 | return ret; | ||
340 | } | 205 | } |
341 | 206 | ||
342 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, | 207 | static void i810_cleanup(void) |
343 | int type) | 208 | { |
209 | writel(0, intel_private.registers+I810_PGETBL_CTL); | ||
210 | free_gatt_pages(intel_private.i81x_gtt_table, I810_GTT_ORDER); | ||
211 | } | ||
212 | |||
213 | static int i810_insert_dcache_entries(struct agp_memory *mem, off_t pg_start, | ||
214 | int type) | ||
344 | { | 215 | { |
345 | int i; | 216 | int i; |
346 | 217 | ||
347 | if (mem->page_count == 0) | 218 | if ((pg_start + mem->page_count) |
348 | return 0; | 219 | > intel_private.num_dcache_entries) |
220 | return -EINVAL; | ||
221 | |||
222 | if (!mem->is_flushed) | ||
223 | global_cache_flush(); | ||
349 | 224 | ||
350 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { | 225 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { |
351 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); | 226 | dma_addr_t addr = i << PAGE_SHIFT; |
227 | intel_private.driver->write_entry(addr, | ||
228 | i, type); | ||
352 | } | 229 | } |
353 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); | 230 | readl(intel_private.gtt+i-1); |
354 | 231 | ||
355 | return 0; | 232 | return 0; |
356 | } | 233 | } |
@@ -397,29 +274,6 @@ static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type) | |||
397 | return new; | 274 | return new; |
398 | } | 275 | } |
399 | 276 | ||
400 | static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type) | ||
401 | { | ||
402 | struct agp_memory *new; | ||
403 | |||
404 | if (type == AGP_DCACHE_MEMORY) { | ||
405 | if (pg_count != intel_private.num_dcache_entries) | ||
406 | return NULL; | ||
407 | |||
408 | new = agp_create_memory(1); | ||
409 | if (new == NULL) | ||
410 | return NULL; | ||
411 | |||
412 | new->type = AGP_DCACHE_MEMORY; | ||
413 | new->page_count = pg_count; | ||
414 | new->num_scratch_pages = 0; | ||
415 | agp_free_page_array(new); | ||
416 | return new; | ||
417 | } | ||
418 | if (type == AGP_PHYS_MEMORY) | ||
419 | return alloc_agpphysmem_i8xx(pg_count, type); | ||
420 | return NULL; | ||
421 | } | ||
422 | |||
423 | static void intel_i810_free_by_type(struct agp_memory *curr) | 277 | static void intel_i810_free_by_type(struct agp_memory *curr) |
424 | { | 278 | { |
425 | agp_free_key(curr->key); | 279 | agp_free_key(curr->key); |
@@ -437,13 +291,6 @@ static void intel_i810_free_by_type(struct agp_memory *curr) | |||
437 | kfree(curr); | 291 | kfree(curr); |
438 | } | 292 | } |
439 | 293 | ||
440 | static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge, | ||
441 | dma_addr_t addr, int type) | ||
442 | { | ||
443 | /* Type checking must be done elsewhere */ | ||
444 | return addr | bridge->driver->masks[type].mask; | ||
445 | } | ||
446 | |||
447 | static int intel_gtt_setup_scratch_page(void) | 294 | static int intel_gtt_setup_scratch_page(void) |
448 | { | 295 | { |
449 | struct page *page; | 296 | struct page *page; |
@@ -455,7 +302,7 @@ static int intel_gtt_setup_scratch_page(void) | |||
455 | get_page(page); | 302 | get_page(page); |
456 | set_pages_uc(page, 1); | 303 | set_pages_uc(page, 1); |
457 | 304 | ||
458 | if (USE_PCI_DMA_API && INTEL_GTT_GEN > 2) { | 305 | if (intel_private.base.needs_dmar) { |
459 | dma_addr = pci_map_page(intel_private.pcidev, page, 0, | 306 | dma_addr = pci_map_page(intel_private.pcidev, page, 0, |
460 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | 307 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); |
461 | if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) | 308 | if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) |
@@ -470,34 +317,45 @@ static int intel_gtt_setup_scratch_page(void) | |||
470 | return 0; | 317 | return 0; |
471 | } | 318 | } |
472 | 319 | ||
473 | static const struct aper_size_info_fixed const intel_fake_agp_sizes[] = { | 320 | static void i810_write_entry(dma_addr_t addr, unsigned int entry, |
321 | unsigned int flags) | ||
322 | { | ||
323 | u32 pte_flags = I810_PTE_VALID; | ||
324 | |||
325 | switch (flags) { | ||
326 | case AGP_DCACHE_MEMORY: | ||
327 | pte_flags |= I810_PTE_LOCAL; | ||
328 | break; | ||
329 | case AGP_USER_CACHED_MEMORY: | ||
330 | pte_flags |= I830_PTE_SYSTEM_CACHED; | ||
331 | break; | ||
332 | } | ||
333 | |||
334 | writel(addr | pte_flags, intel_private.gtt + entry); | ||
335 | } | ||
336 | |||
337 | static const struct aper_size_info_fixed intel_fake_agp_sizes[] = { | ||
338 | {32, 8192, 3}, | ||
339 | {64, 16384, 4}, | ||
474 | {128, 32768, 5}, | 340 | {128, 32768, 5}, |
475 | /* The 64M mode still requires a 128k gatt */ | ||
476 | {64, 16384, 5}, | ||
477 | {256, 65536, 6}, | 341 | {256, 65536, 6}, |
478 | {512, 131072, 7}, | 342 | {512, 131072, 7}, |
479 | }; | 343 | }; |
480 | 344 | ||
481 | static unsigned int intel_gtt_stolen_entries(void) | 345 | static unsigned int intel_gtt_stolen_size(void) |
482 | { | 346 | { |
483 | u16 gmch_ctrl; | 347 | u16 gmch_ctrl; |
484 | u8 rdct; | 348 | u8 rdct; |
485 | int local = 0; | 349 | int local = 0; |
486 | static const int ddt[4] = { 0, 16, 32, 64 }; | 350 | static const int ddt[4] = { 0, 16, 32, 64 }; |
487 | unsigned int overhead_entries, stolen_entries; | ||
488 | unsigned int stolen_size = 0; | 351 | unsigned int stolen_size = 0; |
489 | 352 | ||
353 | if (INTEL_GTT_GEN == 1) | ||
354 | return 0; /* no stolen mem on i81x */ | ||
355 | |||
490 | pci_read_config_word(intel_private.bridge_dev, | 356 | pci_read_config_word(intel_private.bridge_dev, |
491 | I830_GMCH_CTRL, &gmch_ctrl); | 357 | I830_GMCH_CTRL, &gmch_ctrl); |
492 | 358 | ||
493 | if (INTEL_GTT_GEN > 4 || IS_PINEVIEW) | ||
494 | overhead_entries = 0; | ||
495 | else | ||
496 | overhead_entries = intel_private.base.gtt_mappable_entries | ||
497 | / 1024; | ||
498 | |||
499 | overhead_entries += 1; /* BIOS popup */ | ||
500 | |||
501 | if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || | 359 | if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || |
502 | intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { | 360 | intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { |
503 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { | 361 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { |
@@ -623,12 +481,7 @@ static unsigned int intel_gtt_stolen_entries(void) | |||
623 | } | 481 | } |
624 | } | 482 | } |
625 | 483 | ||
626 | if (!local && stolen_size > intel_max_stolen) { | 484 | if (stolen_size > 0) { |
627 | dev_info(&intel_private.bridge_dev->dev, | ||
628 | "detected %dK stolen memory, trimming to %dK\n", | ||
629 | stolen_size / KB(1), intel_max_stolen / KB(1)); | ||
630 | stolen_size = intel_max_stolen; | ||
631 | } else if (stolen_size > 0) { | ||
632 | dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n", | 485 | dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n", |
633 | stolen_size / KB(1), local ? "local" : "stolen"); | 486 | stolen_size / KB(1), local ? "local" : "stolen"); |
634 | } else { | 487 | } else { |
@@ -637,46 +490,88 @@ static unsigned int intel_gtt_stolen_entries(void) | |||
637 | stolen_size = 0; | 490 | stolen_size = 0; |
638 | } | 491 | } |
639 | 492 | ||
640 | stolen_entries = stolen_size/KB(4) - overhead_entries; | 493 | return stolen_size; |
494 | } | ||
641 | 495 | ||
642 | return stolen_entries; | 496 | static void i965_adjust_pgetbl_size(unsigned int size_flag) |
497 | { | ||
498 | u32 pgetbl_ctl, pgetbl_ctl2; | ||
499 | |||
500 | /* ensure that ppgtt is disabled */ | ||
501 | pgetbl_ctl2 = readl(intel_private.registers+I965_PGETBL_CTL2); | ||
502 | pgetbl_ctl2 &= ~I810_PGETBL_ENABLED; | ||
503 | writel(pgetbl_ctl2, intel_private.registers+I965_PGETBL_CTL2); | ||
504 | |||
505 | /* write the new ggtt size */ | ||
506 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); | ||
507 | pgetbl_ctl &= ~I965_PGETBL_SIZE_MASK; | ||
508 | pgetbl_ctl |= size_flag; | ||
509 | writel(pgetbl_ctl, intel_private.registers+I810_PGETBL_CTL); | ||
643 | } | 510 | } |
644 | 511 | ||
645 | static unsigned int intel_gtt_total_entries(void) | 512 | static unsigned int i965_gtt_total_entries(void) |
646 | { | 513 | { |
647 | int size; | 514 | int size; |
515 | u32 pgetbl_ctl; | ||
516 | u16 gmch_ctl; | ||
648 | 517 | ||
649 | if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5) { | 518 | pci_read_config_word(intel_private.bridge_dev, |
650 | u32 pgetbl_ctl; | 519 | I830_GMCH_CTRL, &gmch_ctl); |
651 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); | ||
652 | 520 | ||
653 | switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) { | 521 | if (INTEL_GTT_GEN == 5) { |
654 | case I965_PGETBL_SIZE_128KB: | 522 | switch (gmch_ctl & G4x_GMCH_SIZE_MASK) { |
655 | size = KB(128); | 523 | case G4x_GMCH_SIZE_1M: |
656 | break; | 524 | case G4x_GMCH_SIZE_VT_1M: |
657 | case I965_PGETBL_SIZE_256KB: | 525 | i965_adjust_pgetbl_size(I965_PGETBL_SIZE_1MB); |
658 | size = KB(256); | ||
659 | break; | ||
660 | case I965_PGETBL_SIZE_512KB: | ||
661 | size = KB(512); | ||
662 | break; | ||
663 | case I965_PGETBL_SIZE_1MB: | ||
664 | size = KB(1024); | ||
665 | break; | 526 | break; |
666 | case I965_PGETBL_SIZE_2MB: | 527 | case G4x_GMCH_SIZE_VT_1_5M: |
667 | size = KB(2048); | 528 | i965_adjust_pgetbl_size(I965_PGETBL_SIZE_1_5MB); |
668 | break; | 529 | break; |
669 | case I965_PGETBL_SIZE_1_5MB: | 530 | case G4x_GMCH_SIZE_2M: |
670 | size = KB(1024 + 512); | 531 | case G4x_GMCH_SIZE_VT_2M: |
532 | i965_adjust_pgetbl_size(I965_PGETBL_SIZE_2MB); | ||
671 | break; | 533 | break; |
672 | default: | ||
673 | dev_info(&intel_private.pcidev->dev, | ||
674 | "unknown page table size, assuming 512KB\n"); | ||
675 | size = KB(512); | ||
676 | } | 534 | } |
535 | } | ||
677 | 536 | ||
678 | return size/4; | 537 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); |
679 | } else if (INTEL_GTT_GEN == 6) { | 538 | |
539 | switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) { | ||
540 | case I965_PGETBL_SIZE_128KB: | ||
541 | size = KB(128); | ||
542 | break; | ||
543 | case I965_PGETBL_SIZE_256KB: | ||
544 | size = KB(256); | ||
545 | break; | ||
546 | case I965_PGETBL_SIZE_512KB: | ||
547 | size = KB(512); | ||
548 | break; | ||
549 | /* GTT pagetable sizes bigger than 512KB are not possible on G33! */ | ||
550 | case I965_PGETBL_SIZE_1MB: | ||
551 | size = KB(1024); | ||
552 | break; | ||
553 | case I965_PGETBL_SIZE_2MB: | ||
554 | size = KB(2048); | ||
555 | break; | ||
556 | case I965_PGETBL_SIZE_1_5MB: | ||
557 | size = KB(1024 + 512); | ||
558 | break; | ||
559 | default: | ||
560 | dev_info(&intel_private.pcidev->dev, | ||
561 | "unknown page table size, assuming 512KB\n"); | ||
562 | size = KB(512); | ||
563 | } | ||
564 | |||
565 | return size/4; | ||
566 | } | ||
567 | |||
568 | static unsigned int intel_gtt_total_entries(void) | ||
569 | { | ||
570 | int size; | ||
571 | |||
572 | if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5) | ||
573 | return i965_gtt_total_entries(); | ||
574 | else if (INTEL_GTT_GEN == 6) { | ||
680 | u16 snb_gmch_ctl; | 575 | u16 snb_gmch_ctl; |
681 | 576 | ||
682 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); | 577 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); |
@@ -706,7 +601,18 @@ static unsigned int intel_gtt_mappable_entries(void) | |||
706 | { | 601 | { |
707 | unsigned int aperture_size; | 602 | unsigned int aperture_size; |
708 | 603 | ||
709 | if (INTEL_GTT_GEN == 2) { | 604 | if (INTEL_GTT_GEN == 1) { |
605 | u32 smram_miscc; | ||
606 | |||
607 | pci_read_config_dword(intel_private.bridge_dev, | ||
608 | I810_SMRAM_MISCC, &smram_miscc); | ||
609 | |||
610 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) | ||
611 | == I810_GFX_MEM_WIN_32M) | ||
612 | aperture_size = MB(32); | ||
613 | else | ||
614 | aperture_size = MB(64); | ||
615 | } else if (INTEL_GTT_GEN == 2) { | ||
710 | u16 gmch_ctrl; | 616 | u16 gmch_ctrl; |
711 | 617 | ||
712 | pci_read_config_word(intel_private.bridge_dev, | 618 | pci_read_config_word(intel_private.bridge_dev, |
@@ -739,7 +645,7 @@ static void intel_gtt_cleanup(void) | |||
739 | 645 | ||
740 | iounmap(intel_private.gtt); | 646 | iounmap(intel_private.gtt); |
741 | iounmap(intel_private.registers); | 647 | iounmap(intel_private.registers); |
742 | 648 | ||
743 | intel_gtt_teardown_scratch_page(); | 649 | intel_gtt_teardown_scratch_page(); |
744 | } | 650 | } |
745 | 651 | ||
@@ -755,6 +661,14 @@ static int intel_gtt_init(void) | |||
755 | intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries(); | 661 | intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries(); |
756 | intel_private.base.gtt_total_entries = intel_gtt_total_entries(); | 662 | intel_private.base.gtt_total_entries = intel_gtt_total_entries(); |
757 | 663 | ||
664 | /* save the PGETBL reg for resume */ | ||
665 | intel_private.PGETBL_save = | ||
666 | readl(intel_private.registers+I810_PGETBL_CTL) | ||
667 | & ~I810_PGETBL_ENABLED; | ||
668 | /* we only ever restore the register when enabling the PGTBL... */ | ||
669 | if (HAS_PGTBL_EN) | ||
670 | intel_private.PGETBL_save |= I810_PGETBL_ENABLED; | ||
671 | |||
758 | dev_info(&intel_private.bridge_dev->dev, | 672 | dev_info(&intel_private.bridge_dev->dev, |
759 | "detected gtt size: %dK total, %dK mappable\n", | 673 | "detected gtt size: %dK total, %dK mappable\n", |
760 | intel_private.base.gtt_total_entries * 4, | 674 | intel_private.base.gtt_total_entries * 4, |
@@ -772,14 +686,7 @@ static int intel_gtt_init(void) | |||
772 | 686 | ||
773 | global_cache_flush(); /* FIXME: ? */ | 687 | global_cache_flush(); /* FIXME: ? */ |
774 | 688 | ||
775 | /* we have to call this as early as possible after the MMIO base address is known */ | 689 | intel_private.base.stolen_size = intel_gtt_stolen_size(); |
776 | intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); | ||
777 | if (intel_private.base.gtt_stolen_entries == 0) { | ||
778 | intel_private.driver->cleanup(); | ||
779 | iounmap(intel_private.registers); | ||
780 | iounmap(intel_private.gtt); | ||
781 | return -ENOMEM; | ||
782 | } | ||
783 | 690 | ||
784 | ret = intel_gtt_setup_scratch_page(); | 691 | ret = intel_gtt_setup_scratch_page(); |
785 | if (ret != 0) { | 692 | if (ret != 0) { |
@@ -787,6 +694,8 @@ static int intel_gtt_init(void) | |||
787 | return ret; | 694 | return ret; |
788 | } | 695 | } |
789 | 696 | ||
697 | intel_private.base.needs_dmar = USE_PCI_DMA_API && INTEL_GTT_GEN > 2; | ||
698 | |||
790 | return 0; | 699 | return 0; |
791 | } | 700 | } |
792 | 701 | ||
@@ -862,25 +771,19 @@ static void i830_write_entry(dma_addr_t addr, unsigned int entry, | |||
862 | unsigned int flags) | 771 | unsigned int flags) |
863 | { | 772 | { |
864 | u32 pte_flags = I810_PTE_VALID; | 773 | u32 pte_flags = I810_PTE_VALID; |
865 | 774 | ||
866 | switch (flags) { | 775 | if (flags == AGP_USER_CACHED_MEMORY) |
867 | case AGP_DCACHE_MEMORY: | ||
868 | pte_flags |= I810_PTE_LOCAL; | ||
869 | break; | ||
870 | case AGP_USER_CACHED_MEMORY: | ||
871 | pte_flags |= I830_PTE_SYSTEM_CACHED; | 776 | pte_flags |= I830_PTE_SYSTEM_CACHED; |
872 | break; | ||
873 | } | ||
874 | 777 | ||
875 | writel(addr | pte_flags, intel_private.gtt + entry); | 778 | writel(addr | pte_flags, intel_private.gtt + entry); |
876 | } | 779 | } |
877 | 780 | ||
878 | static void intel_enable_gtt(void) | 781 | static bool intel_enable_gtt(void) |
879 | { | 782 | { |
880 | u32 gma_addr; | 783 | u32 gma_addr; |
881 | u16 gmch_ctrl; | 784 | u8 __iomem *reg; |
882 | 785 | ||
883 | if (INTEL_GTT_GEN == 2) | 786 | if (INTEL_GTT_GEN <= 2) |
884 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, | 787 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, |
885 | &gma_addr); | 788 | &gma_addr); |
886 | else | 789 | else |
@@ -889,13 +792,38 @@ static void intel_enable_gtt(void) | |||
889 | 792 | ||
890 | intel_private.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK); | 793 | intel_private.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK); |
891 | 794 | ||
892 | pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl); | 795 | if (INTEL_GTT_GEN >= 6) |
893 | gmch_ctrl |= I830_GMCH_ENABLED; | 796 | return true; |
894 | pci_write_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, gmch_ctrl); | ||
895 | 797 | ||
896 | writel(intel_private.pte_bus_addr|I810_PGETBL_ENABLED, | 798 | if (INTEL_GTT_GEN == 2) { |
897 | intel_private.registers+I810_PGETBL_CTL); | 799 | u16 gmch_ctrl; |
898 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ | 800 | |
801 | pci_read_config_word(intel_private.bridge_dev, | ||
802 | I830_GMCH_CTRL, &gmch_ctrl); | ||
803 | gmch_ctrl |= I830_GMCH_ENABLED; | ||
804 | pci_write_config_word(intel_private.bridge_dev, | ||
805 | I830_GMCH_CTRL, gmch_ctrl); | ||
806 | |||
807 | pci_read_config_word(intel_private.bridge_dev, | ||
808 | I830_GMCH_CTRL, &gmch_ctrl); | ||
809 | if ((gmch_ctrl & I830_GMCH_ENABLED) == 0) { | ||
810 | dev_err(&intel_private.pcidev->dev, | ||
811 | "failed to enable the GTT: GMCH_CTRL=%x\n", | ||
812 | gmch_ctrl); | ||
813 | return false; | ||
814 | } | ||
815 | } | ||
816 | |||
817 | reg = intel_private.registers+I810_PGETBL_CTL; | ||
818 | writel(intel_private.PGETBL_save, reg); | ||
819 | if (HAS_PGTBL_EN && (readl(reg) & I810_PGETBL_ENABLED) == 0) { | ||
820 | dev_err(&intel_private.pcidev->dev, | ||
821 | "failed to enable the GTT: PGETBL=%x [expected %x]\n", | ||
822 | readl(reg), intel_private.PGETBL_save); | ||
823 | return false; | ||
824 | } | ||
825 | |||
826 | return true; | ||
899 | } | 827 | } |
900 | 828 | ||
901 | static int i830_setup(void) | 829 | static int i830_setup(void) |
@@ -910,8 +838,6 @@ static int i830_setup(void) | |||
910 | return -ENOMEM; | 838 | return -ENOMEM; |
911 | 839 | ||
912 | intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE; | 840 | intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE; |
913 | intel_private.pte_bus_addr = | ||
914 | readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; | ||
915 | 841 | ||
916 | intel_i830_setup_flush(); | 842 | intel_i830_setup_flush(); |
917 | 843 | ||
@@ -936,12 +862,12 @@ static int intel_fake_agp_configure(void) | |||
936 | { | 862 | { |
937 | int i; | 863 | int i; |
938 | 864 | ||
939 | intel_enable_gtt(); | 865 | if (!intel_enable_gtt()) |
866 | return -EIO; | ||
940 | 867 | ||
941 | agp_bridge->gart_bus_addr = intel_private.gma_bus_addr; | 868 | agp_bridge->gart_bus_addr = intel_private.gma_bus_addr; |
942 | 869 | ||
943 | for (i = intel_private.base.gtt_stolen_entries; | 870 | for (i = 0; i < intel_private.base.gtt_total_entries; i++) { |
944 | i < intel_private.base.gtt_total_entries; i++) { | ||
945 | intel_private.driver->write_entry(intel_private.scratch_page_dma, | 871 | intel_private.driver->write_entry(intel_private.scratch_page_dma, |
946 | i, 0); | 872 | i, 0); |
947 | } | 873 | } |
@@ -965,10 +891,10 @@ static bool i830_check_flags(unsigned int flags) | |||
965 | return false; | 891 | return false; |
966 | } | 892 | } |
967 | 893 | ||
968 | static void intel_gtt_insert_sg_entries(struct scatterlist *sg_list, | 894 | void intel_gtt_insert_sg_entries(struct scatterlist *sg_list, |
969 | unsigned int sg_len, | 895 | unsigned int sg_len, |
970 | unsigned int pg_start, | 896 | unsigned int pg_start, |
971 | unsigned int flags) | 897 | unsigned int flags) |
972 | { | 898 | { |
973 | struct scatterlist *sg; | 899 | struct scatterlist *sg; |
974 | unsigned int len, m; | 900 | unsigned int len, m; |
@@ -989,27 +915,34 @@ static void intel_gtt_insert_sg_entries(struct scatterlist *sg_list, | |||
989 | } | 915 | } |
990 | readl(intel_private.gtt+j-1); | 916 | readl(intel_private.gtt+j-1); |
991 | } | 917 | } |
918 | EXPORT_SYMBOL(intel_gtt_insert_sg_entries); | ||
919 | |||
920 | void intel_gtt_insert_pages(unsigned int first_entry, unsigned int num_entries, | ||
921 | struct page **pages, unsigned int flags) | ||
922 | { | ||
923 | int i, j; | ||
924 | |||
925 | for (i = 0, j = first_entry; i < num_entries; i++, j++) { | ||
926 | dma_addr_t addr = page_to_phys(pages[i]); | ||
927 | intel_private.driver->write_entry(addr, | ||
928 | j, flags); | ||
929 | } | ||
930 | readl(intel_private.gtt+j-1); | ||
931 | } | ||
932 | EXPORT_SYMBOL(intel_gtt_insert_pages); | ||
992 | 933 | ||
993 | static int intel_fake_agp_insert_entries(struct agp_memory *mem, | 934 | static int intel_fake_agp_insert_entries(struct agp_memory *mem, |
994 | off_t pg_start, int type) | 935 | off_t pg_start, int type) |
995 | { | 936 | { |
996 | int i, j; | ||
997 | int ret = -EINVAL; | 937 | int ret = -EINVAL; |
998 | 938 | ||
939 | if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY) | ||
940 | return i810_insert_dcache_entries(mem, pg_start, type); | ||
941 | |||
999 | if (mem->page_count == 0) | 942 | if (mem->page_count == 0) |
1000 | goto out; | 943 | goto out; |
1001 | 944 | ||
1002 | if (pg_start < intel_private.base.gtt_stolen_entries) { | 945 | if (pg_start + mem->page_count > intel_private.base.gtt_total_entries) |
1003 | dev_printk(KERN_DEBUG, &intel_private.pcidev->dev, | ||
1004 | "pg_start == 0x%.8lx, gtt_stolen_entries == 0x%.8x\n", | ||
1005 | pg_start, intel_private.base.gtt_stolen_entries); | ||
1006 | |||
1007 | dev_info(&intel_private.pcidev->dev, | ||
1008 | "trying to insert into local/stolen memory\n"); | ||
1009 | goto out_err; | ||
1010 | } | ||
1011 | |||
1012 | if ((pg_start + mem->page_count) > intel_private.base.gtt_total_entries) | ||
1013 | goto out_err; | 946 | goto out_err; |
1014 | 947 | ||
1015 | if (type != mem->type) | 948 | if (type != mem->type) |
@@ -1021,21 +954,17 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem, | |||
1021 | if (!mem->is_flushed) | 954 | if (!mem->is_flushed) |
1022 | global_cache_flush(); | 955 | global_cache_flush(); |
1023 | 956 | ||
1024 | if (USE_PCI_DMA_API && INTEL_GTT_GEN > 2) { | 957 | if (intel_private.base.needs_dmar) { |
1025 | ret = intel_agp_map_memory(mem); | 958 | ret = intel_gtt_map_memory(mem->pages, mem->page_count, |
959 | &mem->sg_list, &mem->num_sg); | ||
1026 | if (ret != 0) | 960 | if (ret != 0) |
1027 | return ret; | 961 | return ret; |
1028 | 962 | ||
1029 | intel_gtt_insert_sg_entries(mem->sg_list, mem->num_sg, | 963 | intel_gtt_insert_sg_entries(mem->sg_list, mem->num_sg, |
1030 | pg_start, type); | 964 | pg_start, type); |
1031 | } else { | 965 | } else |
1032 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 966 | intel_gtt_insert_pages(pg_start, mem->page_count, mem->pages, |
1033 | dma_addr_t addr = page_to_phys(mem->pages[i]); | 967 | type); |
1034 | intel_private.driver->write_entry(addr, | ||
1035 | j, type); | ||
1036 | } | ||
1037 | readl(intel_private.gtt+j-1); | ||
1038 | } | ||
1039 | 968 | ||
1040 | out: | 969 | out: |
1041 | ret = 0; | 970 | ret = 0; |
@@ -1044,40 +973,54 @@ out_err: | |||
1044 | return ret; | 973 | return ret; |
1045 | } | 974 | } |
1046 | 975 | ||
976 | void intel_gtt_clear_range(unsigned int first_entry, unsigned int num_entries) | ||
977 | { | ||
978 | unsigned int i; | ||
979 | |||
980 | for (i = first_entry; i < (first_entry + num_entries); i++) { | ||
981 | intel_private.driver->write_entry(intel_private.scratch_page_dma, | ||
982 | i, 0); | ||
983 | } | ||
984 | readl(intel_private.gtt+i-1); | ||
985 | } | ||
986 | EXPORT_SYMBOL(intel_gtt_clear_range); | ||
987 | |||
1047 | static int intel_fake_agp_remove_entries(struct agp_memory *mem, | 988 | static int intel_fake_agp_remove_entries(struct agp_memory *mem, |
1048 | off_t pg_start, int type) | 989 | off_t pg_start, int type) |
1049 | { | 990 | { |
1050 | int i; | ||
1051 | |||
1052 | if (mem->page_count == 0) | 991 | if (mem->page_count == 0) |
1053 | return 0; | 992 | return 0; |
1054 | 993 | ||
1055 | if (pg_start < intel_private.base.gtt_stolen_entries) { | 994 | if (intel_private.base.needs_dmar) { |
1056 | dev_info(&intel_private.pcidev->dev, | 995 | intel_gtt_unmap_memory(mem->sg_list, mem->num_sg); |
1057 | "trying to disable local/stolen memory\n"); | 996 | mem->sg_list = NULL; |
1058 | return -EINVAL; | 997 | mem->num_sg = 0; |
1059 | } | 998 | } |
1060 | 999 | ||
1061 | if (USE_PCI_DMA_API && INTEL_GTT_GEN > 2) | 1000 | intel_gtt_clear_range(pg_start, mem->page_count); |
1062 | intel_agp_unmap_memory(mem); | ||
1063 | |||
1064 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { | ||
1065 | intel_private.driver->write_entry(intel_private.scratch_page_dma, | ||
1066 | i, 0); | ||
1067 | } | ||
1068 | readl(intel_private.gtt+i-1); | ||
1069 | 1001 | ||
1070 | return 0; | 1002 | return 0; |
1071 | } | 1003 | } |
1072 | 1004 | ||
1073 | static void intel_fake_agp_chipset_flush(struct agp_bridge_data *bridge) | ||
1074 | { | ||
1075 | intel_private.driver->chipset_flush(); | ||
1076 | } | ||
1077 | |||
1078 | static struct agp_memory *intel_fake_agp_alloc_by_type(size_t pg_count, | 1005 | static struct agp_memory *intel_fake_agp_alloc_by_type(size_t pg_count, |
1079 | int type) | 1006 | int type) |
1080 | { | 1007 | { |
1008 | struct agp_memory *new; | ||
1009 | |||
1010 | if (type == AGP_DCACHE_MEMORY && INTEL_GTT_GEN == 1) { | ||
1011 | if (pg_count != intel_private.num_dcache_entries) | ||
1012 | return NULL; | ||
1013 | |||
1014 | new = agp_create_memory(1); | ||
1015 | if (new == NULL) | ||
1016 | return NULL; | ||
1017 | |||
1018 | new->type = AGP_DCACHE_MEMORY; | ||
1019 | new->page_count = pg_count; | ||
1020 | new->num_scratch_pages = 0; | ||
1021 | agp_free_page_array(new); | ||
1022 | return new; | ||
1023 | } | ||
1081 | if (type == AGP_PHYS_MEMORY) | 1024 | if (type == AGP_PHYS_MEMORY) |
1082 | return alloc_agpphysmem_i8xx(pg_count, type); | 1025 | return alloc_agpphysmem_i8xx(pg_count, type); |
1083 | /* always return NULL for other allocation types for now */ | 1026 | /* always return NULL for other allocation types for now */ |
@@ -1274,40 +1217,11 @@ static int i9xx_setup(void) | |||
1274 | intel_private.gtt_bus_addr = reg_addr + gtt_offset; | 1217 | intel_private.gtt_bus_addr = reg_addr + gtt_offset; |
1275 | } | 1218 | } |
1276 | 1219 | ||
1277 | intel_private.pte_bus_addr = | ||
1278 | readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; | ||
1279 | |||
1280 | intel_i9xx_setup_flush(); | 1220 | intel_i9xx_setup_flush(); |
1281 | 1221 | ||
1282 | return 0; | 1222 | return 0; |
1283 | } | 1223 | } |
1284 | 1224 | ||
1285 | static const struct agp_bridge_driver intel_810_driver = { | ||
1286 | .owner = THIS_MODULE, | ||
1287 | .aperture_sizes = intel_i810_sizes, | ||
1288 | .size_type = FIXED_APER_SIZE, | ||
1289 | .num_aperture_sizes = 2, | ||
1290 | .needs_scratch_page = true, | ||
1291 | .configure = intel_i810_configure, | ||
1292 | .fetch_size = intel_i810_fetch_size, | ||
1293 | .cleanup = intel_i810_cleanup, | ||
1294 | .mask_memory = intel_i810_mask_memory, | ||
1295 | .masks = intel_i810_masks, | ||
1296 | .agp_enable = intel_fake_agp_enable, | ||
1297 | .cache_flush = global_cache_flush, | ||
1298 | .create_gatt_table = agp_generic_create_gatt_table, | ||
1299 | .free_gatt_table = agp_generic_free_gatt_table, | ||
1300 | .insert_memory = intel_i810_insert_entries, | ||
1301 | .remove_memory = intel_i810_remove_entries, | ||
1302 | .alloc_by_type = intel_i810_alloc_by_type, | ||
1303 | .free_by_type = intel_i810_free_by_type, | ||
1304 | .agp_alloc_page = agp_generic_alloc_page, | ||
1305 | .agp_alloc_pages = agp_generic_alloc_pages, | ||
1306 | .agp_destroy_page = agp_generic_destroy_page, | ||
1307 | .agp_destroy_pages = agp_generic_destroy_pages, | ||
1308 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1309 | }; | ||
1310 | |||
1311 | static const struct agp_bridge_driver intel_fake_agp_driver = { | 1225 | static const struct agp_bridge_driver intel_fake_agp_driver = { |
1312 | .owner = THIS_MODULE, | 1226 | .owner = THIS_MODULE, |
1313 | .size_type = FIXED_APER_SIZE, | 1227 | .size_type = FIXED_APER_SIZE, |
@@ -1328,15 +1242,20 @@ static const struct agp_bridge_driver intel_fake_agp_driver = { | |||
1328 | .agp_alloc_pages = agp_generic_alloc_pages, | 1242 | .agp_alloc_pages = agp_generic_alloc_pages, |
1329 | .agp_destroy_page = agp_generic_destroy_page, | 1243 | .agp_destroy_page = agp_generic_destroy_page, |
1330 | .agp_destroy_pages = agp_generic_destroy_pages, | 1244 | .agp_destroy_pages = agp_generic_destroy_pages, |
1331 | .chipset_flush = intel_fake_agp_chipset_flush, | ||
1332 | }; | 1245 | }; |
1333 | 1246 | ||
1334 | static const struct intel_gtt_driver i81x_gtt_driver = { | 1247 | static const struct intel_gtt_driver i81x_gtt_driver = { |
1335 | .gen = 1, | 1248 | .gen = 1, |
1249 | .has_pgtbl_enable = 1, | ||
1336 | .dma_mask_size = 32, | 1250 | .dma_mask_size = 32, |
1251 | .setup = i810_setup, | ||
1252 | .cleanup = i810_cleanup, | ||
1253 | .check_flags = i830_check_flags, | ||
1254 | .write_entry = i810_write_entry, | ||
1337 | }; | 1255 | }; |
1338 | static const struct intel_gtt_driver i8xx_gtt_driver = { | 1256 | static const struct intel_gtt_driver i8xx_gtt_driver = { |
1339 | .gen = 2, | 1257 | .gen = 2, |
1258 | .has_pgtbl_enable = 1, | ||
1340 | .setup = i830_setup, | 1259 | .setup = i830_setup, |
1341 | .cleanup = i830_cleanup, | 1260 | .cleanup = i830_cleanup, |
1342 | .write_entry = i830_write_entry, | 1261 | .write_entry = i830_write_entry, |
@@ -1346,10 +1265,11 @@ static const struct intel_gtt_driver i8xx_gtt_driver = { | |||
1346 | }; | 1265 | }; |
1347 | static const struct intel_gtt_driver i915_gtt_driver = { | 1266 | static const struct intel_gtt_driver i915_gtt_driver = { |
1348 | .gen = 3, | 1267 | .gen = 3, |
1268 | .has_pgtbl_enable = 1, | ||
1349 | .setup = i9xx_setup, | 1269 | .setup = i9xx_setup, |
1350 | .cleanup = i9xx_cleanup, | 1270 | .cleanup = i9xx_cleanup, |
1351 | /* i945 is the last gpu to need phys mem (for overlay and cursors). */ | 1271 | /* i945 is the last gpu to need phys mem (for overlay and cursors). */ |
1352 | .write_entry = i830_write_entry, | 1272 | .write_entry = i830_write_entry, |
1353 | .dma_mask_size = 32, | 1273 | .dma_mask_size = 32, |
1354 | .check_flags = i830_check_flags, | 1274 | .check_flags = i830_check_flags, |
1355 | .chipset_flush = i9xx_chipset_flush, | 1275 | .chipset_flush = i9xx_chipset_flush, |
@@ -1376,6 +1296,7 @@ static const struct intel_gtt_driver pineview_gtt_driver = { | |||
1376 | }; | 1296 | }; |
1377 | static const struct intel_gtt_driver i965_gtt_driver = { | 1297 | static const struct intel_gtt_driver i965_gtt_driver = { |
1378 | .gen = 4, | 1298 | .gen = 4, |
1299 | .has_pgtbl_enable = 1, | ||
1379 | .setup = i9xx_setup, | 1300 | .setup = i9xx_setup, |
1380 | .cleanup = i9xx_cleanup, | 1301 | .cleanup = i9xx_cleanup, |
1381 | .write_entry = i965_write_entry, | 1302 | .write_entry = i965_write_entry, |
@@ -1419,93 +1340,92 @@ static const struct intel_gtt_driver sandybridge_gtt_driver = { | |||
1419 | static const struct intel_gtt_driver_description { | 1340 | static const struct intel_gtt_driver_description { |
1420 | unsigned int gmch_chip_id; | 1341 | unsigned int gmch_chip_id; |
1421 | char *name; | 1342 | char *name; |
1422 | const struct agp_bridge_driver *gmch_driver; | ||
1423 | const struct intel_gtt_driver *gtt_driver; | 1343 | const struct intel_gtt_driver *gtt_driver; |
1424 | } intel_gtt_chipsets[] = { | 1344 | } intel_gtt_chipsets[] = { |
1425 | { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver, | 1345 | { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", |
1426 | &i81x_gtt_driver}, | 1346 | &i81x_gtt_driver}, |
1427 | { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver, | 1347 | { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", |
1428 | &i81x_gtt_driver}, | 1348 | &i81x_gtt_driver}, |
1429 | { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver, | 1349 | { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", |
1430 | &i81x_gtt_driver}, | 1350 | &i81x_gtt_driver}, |
1431 | { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver, | 1351 | { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", |
1432 | &i81x_gtt_driver}, | 1352 | &i81x_gtt_driver}, |
1433 | { PCI_DEVICE_ID_INTEL_82830_CGC, "830M", | 1353 | { PCI_DEVICE_ID_INTEL_82830_CGC, "830M", |
1434 | &intel_fake_agp_driver, &i8xx_gtt_driver}, | 1354 | &i8xx_gtt_driver}, |
1435 | { PCI_DEVICE_ID_INTEL_82845G_IG, "830M", | 1355 | { PCI_DEVICE_ID_INTEL_82845G_IG, "830M", |
1436 | &intel_fake_agp_driver, &i8xx_gtt_driver}, | 1356 | &i8xx_gtt_driver}, |
1437 | { PCI_DEVICE_ID_INTEL_82854_IG, "854", | 1357 | { PCI_DEVICE_ID_INTEL_82854_IG, "854", |
1438 | &intel_fake_agp_driver, &i8xx_gtt_driver}, | 1358 | &i8xx_gtt_driver}, |
1439 | { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM", | 1359 | { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM", |
1440 | &intel_fake_agp_driver, &i8xx_gtt_driver}, | 1360 | &i8xx_gtt_driver}, |
1441 | { PCI_DEVICE_ID_INTEL_82865_IG, "865", | 1361 | { PCI_DEVICE_ID_INTEL_82865_IG, "865", |
1442 | &intel_fake_agp_driver, &i8xx_gtt_driver}, | 1362 | &i8xx_gtt_driver}, |
1443 | { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)", | 1363 | { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)", |
1444 | &intel_fake_agp_driver, &i915_gtt_driver }, | 1364 | &i915_gtt_driver }, |
1445 | { PCI_DEVICE_ID_INTEL_82915G_IG, "915G", | 1365 | { PCI_DEVICE_ID_INTEL_82915G_IG, "915G", |
1446 | &intel_fake_agp_driver, &i915_gtt_driver }, | 1366 | &i915_gtt_driver }, |
1447 | { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM", | 1367 | { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM", |
1448 | &intel_fake_agp_driver, &i915_gtt_driver }, | 1368 | &i915_gtt_driver }, |
1449 | { PCI_DEVICE_ID_INTEL_82945G_IG, "945G", | 1369 | { PCI_DEVICE_ID_INTEL_82945G_IG, "945G", |
1450 | &intel_fake_agp_driver, &i915_gtt_driver }, | 1370 | &i915_gtt_driver }, |
1451 | { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM", | 1371 | { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM", |
1452 | &intel_fake_agp_driver, &i915_gtt_driver }, | 1372 | &i915_gtt_driver }, |
1453 | { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME", | 1373 | { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME", |
1454 | &intel_fake_agp_driver, &i915_gtt_driver }, | 1374 | &i915_gtt_driver }, |
1455 | { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ", | 1375 | { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ", |
1456 | &intel_fake_agp_driver, &i965_gtt_driver }, | 1376 | &i965_gtt_driver }, |
1457 | { PCI_DEVICE_ID_INTEL_82G35_IG, "G35", | 1377 | { PCI_DEVICE_ID_INTEL_82G35_IG, "G35", |
1458 | &intel_fake_agp_driver, &i965_gtt_driver }, | 1378 | &i965_gtt_driver }, |
1459 | { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q", | 1379 | { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q", |
1460 | &intel_fake_agp_driver, &i965_gtt_driver }, | 1380 | &i965_gtt_driver }, |
1461 | { PCI_DEVICE_ID_INTEL_82965G_IG, "965G", | 1381 | { PCI_DEVICE_ID_INTEL_82965G_IG, "965G", |
1462 | &intel_fake_agp_driver, &i965_gtt_driver }, | 1382 | &i965_gtt_driver }, |
1463 | { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM", | 1383 | { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM", |
1464 | &intel_fake_agp_driver, &i965_gtt_driver }, | 1384 | &i965_gtt_driver }, |
1465 | { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE", | 1385 | { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE", |
1466 | &intel_fake_agp_driver, &i965_gtt_driver }, | 1386 | &i965_gtt_driver }, |
1467 | { PCI_DEVICE_ID_INTEL_G33_IG, "G33", | 1387 | { PCI_DEVICE_ID_INTEL_G33_IG, "G33", |
1468 | &intel_fake_agp_driver, &g33_gtt_driver }, | 1388 | &g33_gtt_driver }, |
1469 | { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35", | 1389 | { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35", |
1470 | &intel_fake_agp_driver, &g33_gtt_driver }, | 1390 | &g33_gtt_driver }, |
1471 | { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33", | 1391 | { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33", |
1472 | &intel_fake_agp_driver, &g33_gtt_driver }, | 1392 | &g33_gtt_driver }, |
1473 | { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150", | 1393 | { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150", |
1474 | &intel_fake_agp_driver, &pineview_gtt_driver }, | 1394 | &pineview_gtt_driver }, |
1475 | { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150", | 1395 | { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150", |
1476 | &intel_fake_agp_driver, &pineview_gtt_driver }, | 1396 | &pineview_gtt_driver }, |
1477 | { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45", | 1397 | { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45", |
1478 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1398 | &g4x_gtt_driver }, |
1479 | { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake", | 1399 | { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake", |
1480 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1400 | &g4x_gtt_driver }, |
1481 | { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43", | 1401 | { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43", |
1482 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1402 | &g4x_gtt_driver }, |
1483 | { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43", | 1403 | { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43", |
1484 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1404 | &g4x_gtt_driver }, |
1485 | { PCI_DEVICE_ID_INTEL_B43_IG, "B43", | 1405 | { PCI_DEVICE_ID_INTEL_B43_IG, "B43", |
1486 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1406 | &g4x_gtt_driver }, |
1487 | { PCI_DEVICE_ID_INTEL_B43_1_IG, "B43", | 1407 | { PCI_DEVICE_ID_INTEL_B43_1_IG, "B43", |
1488 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1408 | &g4x_gtt_driver }, |
1489 | { PCI_DEVICE_ID_INTEL_G41_IG, "G41", | 1409 | { PCI_DEVICE_ID_INTEL_G41_IG, "G41", |
1490 | &intel_fake_agp_driver, &g4x_gtt_driver }, | 1410 | &g4x_gtt_driver }, |
1491 | { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG, | 1411 | { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG, |
1492 | "HD Graphics", &intel_fake_agp_driver, &ironlake_gtt_driver }, | 1412 | "HD Graphics", &ironlake_gtt_driver }, |
1493 | { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, | 1413 | { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, |
1494 | "HD Graphics", &intel_fake_agp_driver, &ironlake_gtt_driver }, | 1414 | "HD Graphics", &ironlake_gtt_driver }, |
1495 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG, | 1415 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG, |
1496 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1416 | "Sandybridge", &sandybridge_gtt_driver }, |
1497 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG, | 1417 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG, |
1498 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1418 | "Sandybridge", &sandybridge_gtt_driver }, |
1499 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG, | 1419 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG, |
1500 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1420 | "Sandybridge", &sandybridge_gtt_driver }, |
1501 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG, | 1421 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG, |
1502 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1422 | "Sandybridge", &sandybridge_gtt_driver }, |
1503 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG, | 1423 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG, |
1504 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1424 | "Sandybridge", &sandybridge_gtt_driver }, |
1505 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG, | 1425 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG, |
1506 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1426 | "Sandybridge", &sandybridge_gtt_driver }, |
1507 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG, | 1427 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG, |
1508 | "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, | 1428 | "Sandybridge", &sandybridge_gtt_driver }, |
1509 | { 0, NULL, NULL } | 1429 | { 0, NULL, NULL } |
1510 | }; | 1430 | }; |
1511 | 1431 | ||
@@ -1530,21 +1450,20 @@ int intel_gmch_probe(struct pci_dev *pdev, | |||
1530 | struct agp_bridge_data *bridge) | 1450 | struct agp_bridge_data *bridge) |
1531 | { | 1451 | { |
1532 | int i, mask; | 1452 | int i, mask; |
1533 | bridge->driver = NULL; | 1453 | intel_private.driver = NULL; |
1534 | 1454 | ||
1535 | for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) { | 1455 | for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) { |
1536 | if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) { | 1456 | if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) { |
1537 | bridge->driver = | 1457 | intel_private.driver = |
1538 | intel_gtt_chipsets[i].gmch_driver; | ||
1539 | intel_private.driver = | ||
1540 | intel_gtt_chipsets[i].gtt_driver; | 1458 | intel_gtt_chipsets[i].gtt_driver; |
1541 | break; | 1459 | break; |
1542 | } | 1460 | } |
1543 | } | 1461 | } |
1544 | 1462 | ||
1545 | if (!bridge->driver) | 1463 | if (!intel_private.driver) |
1546 | return 0; | 1464 | return 0; |
1547 | 1465 | ||
1466 | bridge->driver = &intel_fake_agp_driver; | ||
1548 | bridge->dev_private_data = &intel_private; | 1467 | bridge->dev_private_data = &intel_private; |
1549 | bridge->dev = pdev; | 1468 | bridge->dev = pdev; |
1550 | 1469 | ||
@@ -1560,8 +1479,8 @@ int intel_gmch_probe(struct pci_dev *pdev, | |||
1560 | pci_set_consistent_dma_mask(intel_private.pcidev, | 1479 | pci_set_consistent_dma_mask(intel_private.pcidev, |
1561 | DMA_BIT_MASK(mask)); | 1480 | DMA_BIT_MASK(mask)); |
1562 | 1481 | ||
1563 | if (bridge->driver == &intel_810_driver) | 1482 | /*if (bridge->driver == &intel_810_driver) |
1564 | return 1; | 1483 | return 1;*/ |
1565 | 1484 | ||
1566 | if (intel_gtt_init() != 0) | 1485 | if (intel_gtt_init() != 0) |
1567 | return 0; | 1486 | return 0; |
@@ -1570,12 +1489,19 @@ int intel_gmch_probe(struct pci_dev *pdev, | |||
1570 | } | 1489 | } |
1571 | EXPORT_SYMBOL(intel_gmch_probe); | 1490 | EXPORT_SYMBOL(intel_gmch_probe); |
1572 | 1491 | ||
1573 | struct intel_gtt *intel_gtt_get(void) | 1492 | const struct intel_gtt *intel_gtt_get(void) |
1574 | { | 1493 | { |
1575 | return &intel_private.base; | 1494 | return &intel_private.base; |
1576 | } | 1495 | } |
1577 | EXPORT_SYMBOL(intel_gtt_get); | 1496 | EXPORT_SYMBOL(intel_gtt_get); |
1578 | 1497 | ||
1498 | void intel_gtt_chipset_flush(void) | ||
1499 | { | ||
1500 | if (intel_private.driver->chipset_flush) | ||
1501 | intel_private.driver->chipset_flush(); | ||
1502 | } | ||
1503 | EXPORT_SYMBOL(intel_gtt_chipset_flush); | ||
1504 | |||
1579 | void intel_gmch_remove(struct pci_dev *pdev) | 1505 | void intel_gmch_remove(struct pci_dev *pdev) |
1580 | { | 1506 | { |
1581 | if (intel_private.pcidev) | 1507 | if (intel_private.pcidev) |