aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-05-07 23:37:51 -0400
committerPaul Mackerras <paulus@samba.org>2007-05-07 23:37:51 -0400
commit02bbc0f09c90cefdb2837605c96a66c5ce4ba2e1 (patch)
tree04ef573cd4de095c500c9fc3477f4278c0b36300 /drivers/char/agp
parent7487a2245b8841c77ba9db406cf99a483b9334e9 (diff)
parent5b94f675f57e4ff16c8fda09088d7480a84dcd91 (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/char/agp')
-rw-r--r--drivers/char/agp/ali-agp.c2
-rw-r--r--drivers/char/agp/alpha-agp.c2
-rw-r--r--drivers/char/agp/amd64-agp.c13
-rw-r--r--drivers/char/agp/generic.c22
-rw-r--r--drivers/char/agp/intel-agp.c8
-rw-r--r--drivers/char/agp/nvidia-agp.c9
-rw-r--r--drivers/char/agp/parisc-agp.c2
-rw-r--r--drivers/char/agp/sgi-agp.c5
-rw-r--r--drivers/char/agp/sis-agp.c278
-rw-r--r--drivers/char/agp/sworks-agp.c23
10 files changed, 199 insertions, 165 deletions
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 5b684fddcc03..4941ddb78939 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -145,6 +145,7 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge)
145 void *addr = agp_generic_alloc_page(agp_bridge); 145 void *addr = agp_generic_alloc_page(agp_bridge);
146 u32 temp; 146 u32 temp;
147 147
148 global_flush_tlb();
148 if (!addr) 149 if (!addr)
149 return NULL; 150 return NULL;
150 151
@@ -160,6 +161,7 @@ static void ali_destroy_page(void * addr)
160 if (addr) { 161 if (addr) {
161 global_cache_flush(); /* is this really needed? --hch */ 162 global_cache_flush(); /* is this really needed? --hch */
162 agp_generic_destroy_page(addr); 163 agp_generic_destroy_page(addr);
164 global_flush_tlb();
163 } 165 }
164} 166}
165 167
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index b0acf41c0db9..aa8f3a39a704 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -173,7 +173,7 @@ alpha_core_agp_setup(void)
173 /* 173 /*
174 * Build a fake pci_dev struct 174 * Build a fake pci_dev struct
175 */ 175 */
176 pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 176 pdev = alloc_pci_dev();
177 if (!pdev) 177 if (!pdev)
178 return -ENOMEM; 178 return -ENOMEM;
179 pdev->vendor = 0xffff; 179 pdev->vendor = 0xffff;
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 485720486d60..c9f0f250d78f 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -14,6 +14,7 @@
14#include <linux/agp_backend.h> 14#include <linux/agp_backend.h>
15#include <linux/mmzone.h> 15#include <linux/mmzone.h>
16#include <asm/page.h> /* PAGE_SIZE */ 16#include <asm/page.h> /* PAGE_SIZE */
17#include <asm/e820.h>
17#include <asm/k8.h> 18#include <asm/k8.h>
18#include "agp.h" 19#include "agp.h"
19 20
@@ -259,7 +260,6 @@ static const struct agp_bridge_driver amd_8151_driver = {
259/* Some basic sanity checks for the aperture. */ 260/* Some basic sanity checks for the aperture. */
260static int __devinit aperture_valid(u64 aper, u32 size) 261static int __devinit aperture_valid(u64 aper, u32 size)
261{ 262{
262 u32 pfn, c;
263 if (aper == 0) { 263 if (aper == 0) {
264 printk(KERN_ERR PFX "No aperture\n"); 264 printk(KERN_ERR PFX "No aperture\n");
265 return 0; 265 return 0;
@@ -272,14 +272,9 @@ static int __devinit aperture_valid(u64 aper, u32 size)
272 printk(KERN_ERR PFX "Aperture out of bounds\n"); 272 printk(KERN_ERR PFX "Aperture out of bounds\n");
273 return 0; 273 return 0;
274 } 274 }
275 pfn = aper >> PAGE_SHIFT; 275 if (e820_any_mapped(aper, aper + size, E820_RAM)) {
276 for (c = 0; c < size/PAGE_SIZE; c++) { 276 printk(KERN_ERR PFX "Aperture pointing to RAM\n");
277 if (!pfn_valid(pfn + c)) 277 return 0;
278 break;
279 if (!PageReserved(pfn_to_page(pfn + c))) {
280 printk(KERN_ERR PFX "Aperture pointing to RAM\n");
281 return 0;
282 }
283 } 278 }
284 279
285 /* Request the Aperture. This catches cases when someone else 280 /* Request the Aperture. This catches cases when someone else
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index f902d71947ba..45aeb917ec63 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -51,28 +51,6 @@ int agp_memory_reserved;
51 */ 51 */
52EXPORT_SYMBOL_GPL(agp_memory_reserved); 52EXPORT_SYMBOL_GPL(agp_memory_reserved);
53 53
54#if defined(CONFIG_X86)
55int map_page_into_agp(struct page *page)
56{
57 int i;
58 i = change_page_attr(page, 1, PAGE_KERNEL_NOCACHE);
59 /* Caller's responsibility to call global_flush_tlb() for
60 * performance reasons */
61 return i;
62}
63EXPORT_SYMBOL_GPL(map_page_into_agp);
64
65int unmap_page_from_agp(struct page *page)
66{
67 int i;
68 i = change_page_attr(page, 1, PAGE_KERNEL);
69 /* Caller's responsibility to call global_flush_tlb() for
70 * performance reasons */
71 return i;
72}
73EXPORT_SYMBOL_GPL(unmap_page_from_agp);
74#endif
75
76/* 54/*
77 * Generic routines for handling agp_memory structures - 55 * Generic routines for handling agp_memory structures -
78 * They use the basic page allocation routines to do the brunt of the work. 56 * They use the basic page allocation routines to do the brunt of the work.
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 55392a45a14b..9c69f2e761f5 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -186,8 +186,9 @@ static void *i8xx_alloc_pages(void)
186 return NULL; 186 return NULL;
187 187
188 if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) { 188 if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) {
189 change_page_attr(page, 4, PAGE_KERNEL);
189 global_flush_tlb(); 190 global_flush_tlb();
190 __free_page(page); 191 __free_pages(page, 2);
191 return NULL; 192 return NULL;
192 } 193 }
193 global_flush_tlb(); 194 global_flush_tlb();
@@ -209,7 +210,7 @@ static void i8xx_destroy_pages(void *addr)
209 global_flush_tlb(); 210 global_flush_tlb();
210 put_page(page); 211 put_page(page);
211 unlock_page(page); 212 unlock_page(page);
212 free_pages((unsigned long)addr, 2); 213 __free_pages(page, 2);
213 atomic_dec(&agp_bridge->current_memory_agp); 214 atomic_dec(&agp_bridge->current_memory_agp);
214} 215}
215 216
@@ -315,9 +316,6 @@ static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
315 struct agp_memory *new; 316 struct agp_memory *new;
316 void *addr; 317 void *addr;
317 318
318 if (pg_count != 1 && pg_count != 4)
319 return NULL;
320
321 switch (pg_count) { 319 switch (pg_count) {
322 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge); 320 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge);
323 global_flush_tlb(); 321 global_flush_tlb();
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 0c9dab557c94..6cd7373dcdf4 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -320,11 +320,11 @@ static int __devinit agp_nvidia_probe(struct pci_dev *pdev,
320 u8 cap_ptr; 320 u8 cap_ptr;
321 321
322 nvidia_private.dev_1 = 322 nvidia_private.dev_1 =
323 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1)); 323 pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1));
324 nvidia_private.dev_2 = 324 nvidia_private.dev_2 =
325 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2)); 325 pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
326 nvidia_private.dev_3 = 326 nvidia_private.dev_3 =
327 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0)); 327 pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
328 328
329 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) { 329 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
330 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 " 330 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
@@ -443,6 +443,9 @@ static int __init agp_nvidia_init(void)
443static void __exit agp_nvidia_cleanup(void) 443static void __exit agp_nvidia_cleanup(void)
444{ 444{
445 pci_unregister_driver(&agp_nvidia_pci_driver); 445 pci_unregister_driver(&agp_nvidia_pci_driver);
446 pci_dev_put(nvidia_private.dev_1);
447 pci_dev_put(nvidia_private.dev_2);
448 pci_dev_put(nvidia_private.dev_3);
446} 449}
447 450
448module_init(agp_nvidia_init); 451module_init(agp_nvidia_init);
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 3d83b461ccad..f4562cc22343 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -329,7 +329,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
329 struct agp_bridge_data *bridge; 329 struct agp_bridge_data *bridge;
330 int error = 0; 330 int error = 0;
331 331
332 fake_bridge_dev = kmalloc(sizeof (struct pci_dev), GFP_KERNEL); 332 fake_bridge_dev = alloc_pci_dev();
333 if (!fake_bridge_dev) { 333 if (!fake_bridge_dev) {
334 error = -ENOMEM; 334 error = -ENOMEM;
335 goto fail; 335 goto fail;
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index ee8f50edde1b..cda608c42bea 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -47,9 +47,8 @@ static void *sgi_tioca_alloc_page(struct agp_bridge_data *bridge)
47 47
48 nid = info->ca_closest_node; 48 nid = info->ca_closest_node;
49 page = alloc_pages_node(nid, GFP_KERNEL, 0); 49 page = alloc_pages_node(nid, GFP_KERNEL, 0);
50 if (page == NULL) { 50 if (!page)
51 return 0; 51 return NULL;
52 }
53 52
54 get_page(page); 53 get_page(page);
55 SetPageLocked(page); 54 SetPageLocked(page);
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index 125f4282d955..eb1a1c738190 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -143,96 +143,6 @@ static struct agp_bridge_driver sis_driver = {
143 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 143 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
144}; 144};
145 145
146static struct agp_device_ids sis_agp_device_ids[] __devinitdata =
147{
148 {
149 .device_id = PCI_DEVICE_ID_SI_5591_AGP,
150 .chipset_name = "5591",
151 },
152 {
153 .device_id = PCI_DEVICE_ID_SI_530,
154 .chipset_name = "530",
155 },
156 {
157 .device_id = PCI_DEVICE_ID_SI_540,
158 .chipset_name = "540",
159 },
160 {
161 .device_id = PCI_DEVICE_ID_SI_550,
162 .chipset_name = "550",
163 },
164 {
165 .device_id = PCI_DEVICE_ID_SI_620,
166 .chipset_name = "620",
167 },
168 {
169 .device_id = PCI_DEVICE_ID_SI_630,
170 .chipset_name = "630",
171 },
172 {
173 .device_id = PCI_DEVICE_ID_SI_635,
174 .chipset_name = "635",
175 },
176 {
177 .device_id = PCI_DEVICE_ID_SI_645,
178 .chipset_name = "645",
179 },
180 {
181 .device_id = PCI_DEVICE_ID_SI_646,
182 .chipset_name = "646",
183 },
184 {
185 .device_id = PCI_DEVICE_ID_SI_648,
186 .chipset_name = "648",
187 },
188 {
189 .device_id = PCI_DEVICE_ID_SI_650,
190 .chipset_name = "650",
191 },
192 {
193 .device_id = PCI_DEVICE_ID_SI_651,
194 .chipset_name = "651",
195 },
196 {
197 .device_id = PCI_DEVICE_ID_SI_655,
198 .chipset_name = "655",
199 },
200 {
201 .device_id = PCI_DEVICE_ID_SI_661,
202 .chipset_name = "661",
203 },
204 {
205 .device_id = PCI_DEVICE_ID_SI_730,
206 .chipset_name = "730",
207 },
208 {
209 .device_id = PCI_DEVICE_ID_SI_735,
210 .chipset_name = "735",
211 },
212 {
213 .device_id = PCI_DEVICE_ID_SI_740,
214 .chipset_name = "740",
215 },
216 {
217 .device_id = PCI_DEVICE_ID_SI_741,
218 .chipset_name = "741",
219 },
220 {
221 .device_id = PCI_DEVICE_ID_SI_745,
222 .chipset_name = "745",
223 },
224 {
225 .device_id = PCI_DEVICE_ID_SI_746,
226 .chipset_name = "746",
227 },
228 {
229 .device_id = PCI_DEVICE_ID_SI_760,
230 .chipset_name = "760",
231 },
232 { }, /* dummy final entry, always present */
233};
234
235
236// chipsets that require the 'delay hack' 146// chipsets that require the 'delay hack'
237static int sis_broken_chipsets[] __devinitdata = { 147static int sis_broken_chipsets[] __devinitdata = {
238 PCI_DEVICE_ID_SI_648, 148 PCI_DEVICE_ID_SI_648,
@@ -269,29 +179,15 @@ static void __devinit sis_get_driver(struct agp_bridge_data *bridge)
269static int __devinit agp_sis_probe(struct pci_dev *pdev, 179static int __devinit agp_sis_probe(struct pci_dev *pdev,
270 const struct pci_device_id *ent) 180 const struct pci_device_id *ent)
271{ 181{
272 struct agp_device_ids *devs = sis_agp_device_ids;
273 struct agp_bridge_data *bridge; 182 struct agp_bridge_data *bridge;
274 u8 cap_ptr; 183 u8 cap_ptr;
275 int j;
276 184
277 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 185 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
278 if (!cap_ptr) 186 if (!cap_ptr)
279 return -ENODEV; 187 return -ENODEV;
280 188
281 /* probe for known chipsets */
282 for (j = 0; devs[j].chipset_name; j++) {
283 if (pdev->device == devs[j].device_id) {
284 printk(KERN_INFO PFX "Detected SiS %s chipset\n",
285 devs[j].chipset_name);
286 goto found;
287 }
288 }
289
290 printk(KERN_ERR PFX "Unsupported SiS chipset (device id: %04x)\n",
291 pdev->device);
292 return -ENODEV;
293 189
294found: 190 printk(KERN_INFO PFX "Detected SiS chipset - id:%i\n", pdev->device);
295 bridge = agp_alloc_bridge(); 191 bridge = agp_alloc_bridge();
296 if (!bridge) 192 if (!bridge)
297 return -ENOMEM; 193 return -ENOMEM;
@@ -320,12 +216,172 @@ static void __devexit agp_sis_remove(struct pci_dev *pdev)
320 216
321static struct pci_device_id agp_sis_pci_table[] = { 217static struct pci_device_id agp_sis_pci_table[] = {
322 { 218 {
323 .class = (PCI_CLASS_BRIDGE_HOST << 8), 219 .class = (PCI_CLASS_BRIDGE_HOST << 8),
324 .class_mask = ~0, 220 .class_mask = ~0,
325 .vendor = PCI_VENDOR_ID_SI, 221 .vendor = PCI_VENDOR_ID_SI,
326 .device = PCI_ANY_ID, 222 .device = PCI_DEVICE_ID_SI_5591_AGP,
327 .subvendor = PCI_ANY_ID, 223 .subvendor = PCI_ANY_ID,
328 .subdevice = PCI_ANY_ID, 224 .subdevice = PCI_ANY_ID,
225 },
226 {
227 .class = (PCI_CLASS_BRIDGE_HOST << 8),
228 .class_mask = ~0,
229 .vendor = PCI_VENDOR_ID_SI,
230 .device = PCI_DEVICE_ID_SI_530,
231 .subvendor = PCI_ANY_ID,
232 .subdevice = PCI_ANY_ID,
233 },
234 {
235 .class = (PCI_CLASS_BRIDGE_HOST << 8),
236 .class_mask = ~0,
237 .vendor = PCI_VENDOR_ID_SI,
238 .device = PCI_DEVICE_ID_SI_540,
239 .subvendor = PCI_ANY_ID,
240 .subdevice = PCI_ANY_ID,
241 },
242 {
243 .class = (PCI_CLASS_BRIDGE_HOST << 8),
244 .class_mask = ~0,
245 .vendor = PCI_VENDOR_ID_SI,
246 .device = PCI_DEVICE_ID_SI_550,
247 .subvendor = PCI_ANY_ID,
248 .subdevice = PCI_ANY_ID,
249 },
250 {
251 .class = (PCI_CLASS_BRIDGE_HOST << 8),
252 .class_mask = ~0,
253 .vendor = PCI_VENDOR_ID_SI,
254 .device = PCI_DEVICE_ID_SI_620,
255 .subvendor = PCI_ANY_ID,
256 .subdevice = PCI_ANY_ID,
257 },
258 {
259 .class = (PCI_CLASS_BRIDGE_HOST << 8),
260 .class_mask = ~0,
261 .vendor = PCI_VENDOR_ID_SI,
262 .device = PCI_DEVICE_ID_SI_630,
263 .subvendor = PCI_ANY_ID,
264 .subdevice = PCI_ANY_ID,
265 },
266 {
267 .class = (PCI_CLASS_BRIDGE_HOST << 8),
268 .class_mask = ~0,
269 .vendor = PCI_VENDOR_ID_SI,
270 .device = PCI_DEVICE_ID_SI_635,
271 .subvendor = PCI_ANY_ID,
272 .subdevice = PCI_ANY_ID,
273 },
274 {
275 .class = (PCI_CLASS_BRIDGE_HOST << 8),
276 .class_mask = ~0,
277 .vendor = PCI_VENDOR_ID_SI,
278 .device = PCI_DEVICE_ID_SI_645,
279 .subvendor = PCI_ANY_ID,
280 .subdevice = PCI_ANY_ID,
281 },
282 {
283 .class = (PCI_CLASS_BRIDGE_HOST << 8),
284 .class_mask = ~0,
285 .vendor = PCI_VENDOR_ID_SI,
286 .device = PCI_DEVICE_ID_SI_646,
287 .subvendor = PCI_ANY_ID,
288 .subdevice = PCI_ANY_ID,
289 },
290 {
291 .class = (PCI_CLASS_BRIDGE_HOST << 8),
292 .class_mask = ~0,
293 .vendor = PCI_VENDOR_ID_SI,
294 .device = PCI_DEVICE_ID_SI_648,
295 .subvendor = PCI_ANY_ID,
296 .subdevice = PCI_ANY_ID,
297 },
298 {
299 .class = (PCI_CLASS_BRIDGE_HOST << 8),
300 .class_mask = ~0,
301 .vendor = PCI_VENDOR_ID_SI,
302 .device = PCI_DEVICE_ID_SI_650,
303 .subvendor = PCI_ANY_ID,
304 .subdevice = PCI_ANY_ID,
305 },
306 {
307 .class = (PCI_CLASS_BRIDGE_HOST << 8),
308 .class_mask = ~0,
309 .vendor = PCI_VENDOR_ID_SI,
310 .device = PCI_DEVICE_ID_SI_651,
311 .subvendor = PCI_ANY_ID,
312 .subdevice = PCI_ANY_ID,
313 },
314 {
315 .class = (PCI_CLASS_BRIDGE_HOST << 8),
316 .class_mask = ~0,
317 .vendor = PCI_VENDOR_ID_SI,
318 .device = PCI_DEVICE_ID_SI_655,
319 .subvendor = PCI_ANY_ID,
320 .subdevice = PCI_ANY_ID,
321 },
322 {
323 .class = (PCI_CLASS_BRIDGE_HOST << 8),
324 .class_mask = ~0,
325 .vendor = PCI_VENDOR_ID_SI,
326 .device = PCI_DEVICE_ID_SI_661,
327 .subvendor = PCI_ANY_ID,
328 .subdevice = PCI_ANY_ID,
329 },
330 {
331 .class = (PCI_CLASS_BRIDGE_HOST << 8),
332 .class_mask = ~0,
333 .vendor = PCI_VENDOR_ID_SI,
334 .device = PCI_DEVICE_ID_SI_730,
335 .subvendor = PCI_ANY_ID,
336 .subdevice = PCI_ANY_ID,
337 },
338 {
339 .class = (PCI_CLASS_BRIDGE_HOST << 8),
340 .class_mask = ~0,
341 .vendor = PCI_VENDOR_ID_SI,
342 .device = PCI_DEVICE_ID_SI_735,
343 .subvendor = PCI_ANY_ID,
344 .subdevice = PCI_ANY_ID,
345 },
346 {
347 .class = (PCI_CLASS_BRIDGE_HOST << 8),
348 .class_mask = ~0,
349 .vendor = PCI_VENDOR_ID_SI,
350 .device = PCI_DEVICE_ID_SI_740,
351 .subvendor = PCI_ANY_ID,
352 .subdevice = PCI_ANY_ID,
353 },
354 {
355 .class = (PCI_CLASS_BRIDGE_HOST << 8),
356 .class_mask = ~0,
357 .vendor = PCI_VENDOR_ID_SI,
358 .device = PCI_DEVICE_ID_SI_741,
359 .subvendor = PCI_ANY_ID,
360 .subdevice = PCI_ANY_ID,
361 },
362 {
363 .class = (PCI_CLASS_BRIDGE_HOST << 8),
364 .class_mask = ~0,
365 .vendor = PCI_VENDOR_ID_SI,
366 .device = PCI_DEVICE_ID_SI_745,
367 .subvendor = PCI_ANY_ID,
368 .subdevice = PCI_ANY_ID,
369 },
370 {
371 .class = (PCI_CLASS_BRIDGE_HOST << 8),
372 .class_mask = ~0,
373 .vendor = PCI_VENDOR_ID_SI,
374 .device = PCI_DEVICE_ID_SI_746,
375 .subvendor = PCI_ANY_ID,
376 .subdevice = PCI_ANY_ID,
377 },
378 {
379 .class = (PCI_CLASS_BRIDGE_HOST << 8),
380 .class_mask = ~0,
381 .vendor = PCI_VENDOR_ID_SI,
382 .device = PCI_DEVICE_ID_SI_760,
383 .subvendor = PCI_ANY_ID,
384 .subdevice = PCI_ANY_ID,
329 }, 385 },
330 { } 386 { }
331}; 387};
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 55212a3811fd..551ef25063ef 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -455,15 +455,6 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
455 u32 temp, temp2; 455 u32 temp, temp2;
456 u8 cap_ptr = 0; 456 u8 cap_ptr = 0;
457 457
458 /* Everything is on func 1 here so we are hardcoding function one */
459 bridge_dev = pci_find_slot((unsigned int)pdev->bus->number,
460 PCI_DEVFN(0, 1));
461 if (!bridge_dev) {
462 printk(KERN_INFO PFX "Detected a Serverworks chipset "
463 "but could not find the secondary device.\n");
464 return -ENODEV;
465 }
466
467 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 458 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
468 459
469 switch (pdev->device) { 460 switch (pdev->device) {
@@ -483,6 +474,15 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
483 return -ENODEV; 474 return -ENODEV;
484 } 475 }
485 476
477 /* Everything is on func 1 here so we are hardcoding function one */
478 bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
479 PCI_DEVFN(0, 1));
480 if (!bridge_dev) {
481 printk(KERN_INFO PFX "Detected a Serverworks chipset "
482 "but could not find the secondary device.\n");
483 return -ENODEV;
484 }
485
486 serverworks_private.svrwrks_dev = bridge_dev; 486 serverworks_private.svrwrks_dev = bridge_dev;
487 serverworks_private.gart_addr_ofs = 0x10; 487 serverworks_private.gart_addr_ofs = 0x10;
488 488
@@ -515,7 +515,7 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev,
515 515
516 bridge->driver = &sworks_driver; 516 bridge->driver = &sworks_driver;
517 bridge->dev_private_data = &serverworks_private, 517 bridge->dev_private_data = &serverworks_private,
518 bridge->dev = pdev; 518 bridge->dev = pci_dev_get(pdev);
519 519
520 pci_set_drvdata(pdev, bridge); 520 pci_set_drvdata(pdev, bridge);
521 return agp_add_bridge(bridge); 521 return agp_add_bridge(bridge);
@@ -525,8 +525,11 @@ static void __devexit agp_serverworks_remove(struct pci_dev *pdev)
525{ 525{
526 struct agp_bridge_data *bridge = pci_get_drvdata(pdev); 526 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
527 527
528 pci_dev_put(bridge->dev);
528 agp_remove_bridge(bridge); 529 agp_remove_bridge(bridge);
529 agp_put_bridge(bridge); 530 agp_put_bridge(bridge);
531 pci_dev_put(serverworks_private.svrwrks_dev);
532 serverworks_private.svrwrks_dev = NULL;
530} 533}
531 534
532static struct pci_device_id agp_serverworks_pci_table[] = { 535static struct pci_device_id agp_serverworks_pci_table[] = {