diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-09-12 06:34:44 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-21 06:37:18 -0400 |
commit | bdd30729b68d708c970125aab363931134698f2d (patch) | |
tree | e7db7e5d4ebfdee40687f038e67d64e14e4cc563 /drivers/char/agp | |
parent | 90cb149e1a85f8296daa1989c055db18fbf4ea88 (diff) |
intel-gtt: kill mask_memory functions
That indirection mess can now go. Add a dummy i81x gtt_driver to
avoid a NULL pointer check.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char/agp')
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 105 |
1 files changed, 13 insertions, 92 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 44722c6790b2..bb222d5f322b 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -69,20 +69,6 @@ static struct gatt_mask intel_i810_masks[] = | |||
69 | #define INTEL_AGP_CACHED_MEMORY_LLC_MLC 3 | 69 | #define INTEL_AGP_CACHED_MEMORY_LLC_MLC 3 |
70 | #define INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT 4 | 70 | #define INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT 4 |
71 | 71 | ||
72 | static struct gatt_mask intel_gen6_masks[] = | ||
73 | { | ||
74 | {.mask = I810_PTE_VALID | GEN6_PTE_UNCACHED, | ||
75 | .type = INTEL_AGP_UNCACHED_MEMORY }, | ||
76 | {.mask = I810_PTE_VALID | GEN6_PTE_LLC, | ||
77 | .type = INTEL_AGP_CACHED_MEMORY_LLC }, | ||
78 | {.mask = I810_PTE_VALID | GEN6_PTE_LLC | GEN6_PTE_GFDT, | ||
79 | .type = INTEL_AGP_CACHED_MEMORY_LLC_GFDT }, | ||
80 | {.mask = I810_PTE_VALID | GEN6_PTE_LLC_MLC, | ||
81 | .type = INTEL_AGP_CACHED_MEMORY_LLC_MLC }, | ||
82 | {.mask = I810_PTE_VALID | GEN6_PTE_LLC_MLC | GEN6_PTE_GFDT, | ||
83 | .type = INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT }, | ||
84 | }; | ||
85 | |||
86 | struct intel_gtt_driver { | 72 | struct intel_gtt_driver { |
87 | unsigned int gen : 8; | 73 | unsigned int gen : 8; |
88 | unsigned int is_g33 : 1; | 74 | unsigned int is_g33 : 1; |
@@ -287,34 +273,6 @@ static void i8xx_destroy_pages(struct page *page) | |||
287 | atomic_dec(&agp_bridge->current_memory_agp); | 273 | atomic_dec(&agp_bridge->current_memory_agp); |
288 | } | 274 | } |
289 | 275 | ||
290 | static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge, | ||
291 | int type) | ||
292 | { | ||
293 | if (type < AGP_USER_TYPES) | ||
294 | return type; | ||
295 | else if (type == AGP_USER_CACHED_MEMORY) | ||
296 | return INTEL_AGP_CACHED_MEMORY; | ||
297 | else | ||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | static int intel_gen6_type_to_mask_type(struct agp_bridge_data *bridge, | ||
302 | int type) | ||
303 | { | ||
304 | unsigned int type_mask = type & ~AGP_USER_CACHED_MEMORY_GFDT; | ||
305 | unsigned int gfdt = type & AGP_USER_CACHED_MEMORY_GFDT; | ||
306 | |||
307 | if (type_mask == AGP_USER_UNCACHED_MEMORY) | ||
308 | return INTEL_AGP_UNCACHED_MEMORY; | ||
309 | else if (type_mask == AGP_USER_CACHED_MEMORY_LLC_MLC) | ||
310 | return gfdt ? INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT : | ||
311 | INTEL_AGP_CACHED_MEMORY_LLC_MLC; | ||
312 | else /* set 'normal'/'cached' to LLC by default */ | ||
313 | return gfdt ? INTEL_AGP_CACHED_MEMORY_LLC_GFDT : | ||
314 | INTEL_AGP_CACHED_MEMORY_LLC; | ||
315 | } | ||
316 | |||
317 | |||
318 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, | 276 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, |
319 | int type) | 277 | int type) |
320 | { | 278 | { |
@@ -1290,35 +1248,6 @@ static int i9xx_setup(void) | |||
1290 | return 0; | 1248 | return 0; |
1291 | } | 1249 | } |
1292 | 1250 | ||
1293 | /* | ||
1294 | * The i965 supports 36-bit physical addresses, but to keep | ||
1295 | * the format of the GTT the same, the bits that don't fit | ||
1296 | * in a 32-bit word are shifted down to bits 4..7. | ||
1297 | * | ||
1298 | * Gcc is smart enough to notice that "(addr >> 28) & 0xf0" | ||
1299 | * is always zero on 32-bit architectures, so no need to make | ||
1300 | * this conditional. | ||
1301 | */ | ||
1302 | static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, | ||
1303 | dma_addr_t addr, int type) | ||
1304 | { | ||
1305 | /* Shift high bits down */ | ||
1306 | addr |= (addr >> 28) & 0xf0; | ||
1307 | |||
1308 | /* Type checking must be done elsewhere */ | ||
1309 | return addr | bridge->driver->masks[type].mask; | ||
1310 | } | ||
1311 | |||
1312 | static unsigned long intel_gen6_mask_memory(struct agp_bridge_data *bridge, | ||
1313 | dma_addr_t addr, int type) | ||
1314 | { | ||
1315 | /* gen6 has bit11-4 for physical addr bit39-32 */ | ||
1316 | addr |= (addr >> 28) & 0xff0; | ||
1317 | |||
1318 | /* Type checking must be done elsewhere */ | ||
1319 | return addr | bridge->driver->masks[type].mask; | ||
1320 | } | ||
1321 | |||
1322 | static const struct agp_bridge_driver intel_810_driver = { | 1251 | static const struct agp_bridge_driver intel_810_driver = { |
1323 | .owner = THIS_MODULE, | 1252 | .owner = THIS_MODULE, |
1324 | .aperture_sizes = intel_i810_sizes, | 1253 | .aperture_sizes = intel_i810_sizes, |
@@ -1353,8 +1282,6 @@ static const struct agp_bridge_driver intel_830_driver = { | |||
1353 | .configure = intel_fake_agp_configure, | 1282 | .configure = intel_fake_agp_configure, |
1354 | .fetch_size = intel_fake_agp_fetch_size, | 1283 | .fetch_size = intel_fake_agp_fetch_size, |
1355 | .cleanup = intel_gtt_cleanup, | 1284 | .cleanup = intel_gtt_cleanup, |
1356 | .mask_memory = intel_i810_mask_memory, | ||
1357 | .masks = intel_i810_masks, | ||
1358 | .agp_enable = intel_fake_agp_enable, | 1285 | .agp_enable = intel_fake_agp_enable, |
1359 | .cache_flush = global_cache_flush, | 1286 | .cache_flush = global_cache_flush, |
1360 | .create_gatt_table = intel_fake_agp_create_gatt_table, | 1287 | .create_gatt_table = intel_fake_agp_create_gatt_table, |
@@ -1367,7 +1294,6 @@ static const struct agp_bridge_driver intel_830_driver = { | |||
1367 | .agp_alloc_pages = agp_generic_alloc_pages, | 1294 | .agp_alloc_pages = agp_generic_alloc_pages, |
1368 | .agp_destroy_page = agp_generic_destroy_page, | 1295 | .agp_destroy_page = agp_generic_destroy_page, |
1369 | .agp_destroy_pages = agp_generic_destroy_pages, | 1296 | .agp_destroy_pages = agp_generic_destroy_pages, |
1370 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1371 | .chipset_flush = intel_i830_chipset_flush, | 1297 | .chipset_flush = intel_i830_chipset_flush, |
1372 | }; | 1298 | }; |
1373 | 1299 | ||
@@ -1379,8 +1305,6 @@ static const struct agp_bridge_driver intel_915_driver = { | |||
1379 | .configure = intel_fake_agp_configure, | 1305 | .configure = intel_fake_agp_configure, |
1380 | .fetch_size = intel_fake_agp_fetch_size, | 1306 | .fetch_size = intel_fake_agp_fetch_size, |
1381 | .cleanup = intel_gtt_cleanup, | 1307 | .cleanup = intel_gtt_cleanup, |
1382 | .mask_memory = intel_i810_mask_memory, | ||
1383 | .masks = intel_i810_masks, | ||
1384 | .agp_enable = intel_fake_agp_enable, | 1308 | .agp_enable = intel_fake_agp_enable, |
1385 | .cache_flush = global_cache_flush, | 1309 | .cache_flush = global_cache_flush, |
1386 | .create_gatt_table = intel_fake_agp_create_gatt_table, | 1310 | .create_gatt_table = intel_fake_agp_create_gatt_table, |
@@ -1393,7 +1317,6 @@ static const struct agp_bridge_driver intel_915_driver = { | |||
1393 | .agp_alloc_pages = agp_generic_alloc_pages, | 1317 | .agp_alloc_pages = agp_generic_alloc_pages, |
1394 | .agp_destroy_page = agp_generic_destroy_page, | 1318 | .agp_destroy_page = agp_generic_destroy_page, |
1395 | .agp_destroy_pages = agp_generic_destroy_pages, | 1319 | .agp_destroy_pages = agp_generic_destroy_pages, |
1396 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1397 | .chipset_flush = intel_i915_chipset_flush, | 1320 | .chipset_flush = intel_i915_chipset_flush, |
1398 | }; | 1321 | }; |
1399 | 1322 | ||
@@ -1405,8 +1328,6 @@ static const struct agp_bridge_driver intel_i965_driver = { | |||
1405 | .configure = intel_fake_agp_configure, | 1328 | .configure = intel_fake_agp_configure, |
1406 | .fetch_size = intel_fake_agp_fetch_size, | 1329 | .fetch_size = intel_fake_agp_fetch_size, |
1407 | .cleanup = intel_gtt_cleanup, | 1330 | .cleanup = intel_gtt_cleanup, |
1408 | .mask_memory = intel_i965_mask_memory, | ||
1409 | .masks = intel_i810_masks, | ||
1410 | .agp_enable = intel_fake_agp_enable, | 1331 | .agp_enable = intel_fake_agp_enable, |
1411 | .cache_flush = global_cache_flush, | 1332 | .cache_flush = global_cache_flush, |
1412 | .create_gatt_table = intel_fake_agp_create_gatt_table, | 1333 | .create_gatt_table = intel_fake_agp_create_gatt_table, |
@@ -1419,7 +1340,6 @@ static const struct agp_bridge_driver intel_i965_driver = { | |||
1419 | .agp_alloc_pages = agp_generic_alloc_pages, | 1340 | .agp_alloc_pages = agp_generic_alloc_pages, |
1420 | .agp_destroy_page = agp_generic_destroy_page, | 1341 | .agp_destroy_page = agp_generic_destroy_page, |
1421 | .agp_destroy_pages = agp_generic_destroy_pages, | 1342 | .agp_destroy_pages = agp_generic_destroy_pages, |
1422 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1423 | .chipset_flush = intel_i915_chipset_flush, | 1343 | .chipset_flush = intel_i915_chipset_flush, |
1424 | }; | 1344 | }; |
1425 | 1345 | ||
@@ -1431,8 +1351,6 @@ static const struct agp_bridge_driver intel_gen6_driver = { | |||
1431 | .configure = intel_fake_agp_configure, | 1351 | .configure = intel_fake_agp_configure, |
1432 | .fetch_size = intel_fake_agp_fetch_size, | 1352 | .fetch_size = intel_fake_agp_fetch_size, |
1433 | .cleanup = intel_gtt_cleanup, | 1353 | .cleanup = intel_gtt_cleanup, |
1434 | .mask_memory = intel_gen6_mask_memory, | ||
1435 | .masks = intel_gen6_masks, | ||
1436 | .agp_enable = intel_fake_agp_enable, | 1354 | .agp_enable = intel_fake_agp_enable, |
1437 | .cache_flush = global_cache_flush, | 1355 | .cache_flush = global_cache_flush, |
1438 | .create_gatt_table = intel_fake_agp_create_gatt_table, | 1356 | .create_gatt_table = intel_fake_agp_create_gatt_table, |
@@ -1445,7 +1363,6 @@ static const struct agp_bridge_driver intel_gen6_driver = { | |||
1445 | .agp_alloc_pages = agp_generic_alloc_pages, | 1363 | .agp_alloc_pages = agp_generic_alloc_pages, |
1446 | .agp_destroy_page = agp_generic_destroy_page, | 1364 | .agp_destroy_page = agp_generic_destroy_page, |
1447 | .agp_destroy_pages = agp_generic_destroy_pages, | 1365 | .agp_destroy_pages = agp_generic_destroy_pages, |
1448 | .agp_type_to_mask_type = intel_gen6_type_to_mask_type, | ||
1449 | .chipset_flush = intel_i915_chipset_flush, | 1366 | .chipset_flush = intel_i915_chipset_flush, |
1450 | }; | 1367 | }; |
1451 | 1368 | ||
@@ -1457,8 +1374,6 @@ static const struct agp_bridge_driver intel_g33_driver = { | |||
1457 | .configure = intel_fake_agp_configure, | 1374 | .configure = intel_fake_agp_configure, |
1458 | .fetch_size = intel_fake_agp_fetch_size, | 1375 | .fetch_size = intel_fake_agp_fetch_size, |
1459 | .cleanup = intel_gtt_cleanup, | 1376 | .cleanup = intel_gtt_cleanup, |
1460 | .mask_memory = intel_i965_mask_memory, | ||
1461 | .masks = intel_i810_masks, | ||
1462 | .agp_enable = intel_fake_agp_enable, | 1377 | .agp_enable = intel_fake_agp_enable, |
1463 | .cache_flush = global_cache_flush, | 1378 | .cache_flush = global_cache_flush, |
1464 | .create_gatt_table = intel_fake_agp_create_gatt_table, | 1379 | .create_gatt_table = intel_fake_agp_create_gatt_table, |
@@ -1471,10 +1386,12 @@ static const struct agp_bridge_driver intel_g33_driver = { | |||
1471 | .agp_alloc_pages = agp_generic_alloc_pages, | 1386 | .agp_alloc_pages = agp_generic_alloc_pages, |
1472 | .agp_destroy_page = agp_generic_destroy_page, | 1387 | .agp_destroy_page = agp_generic_destroy_page, |
1473 | .agp_destroy_pages = agp_generic_destroy_pages, | 1388 | .agp_destroy_pages = agp_generic_destroy_pages, |
1474 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1475 | .chipset_flush = intel_i915_chipset_flush, | 1389 | .chipset_flush = intel_i915_chipset_flush, |
1476 | }; | 1390 | }; |
1477 | 1391 | ||
1392 | static const struct intel_gtt_driver i81x_gtt_driver = { | ||
1393 | .gen = 1, | ||
1394 | }; | ||
1478 | static const struct intel_gtt_driver i8xx_gtt_driver = { | 1395 | static const struct intel_gtt_driver i8xx_gtt_driver = { |
1479 | .gen = 2, | 1396 | .gen = 2, |
1480 | .setup = i830_setup, | 1397 | .setup = i830_setup, |
@@ -1538,10 +1455,14 @@ static const struct intel_gtt_driver_description { | |||
1538 | const struct agp_bridge_driver *gmch_driver; | 1455 | const struct agp_bridge_driver *gmch_driver; |
1539 | const struct intel_gtt_driver *gtt_driver; | 1456 | const struct intel_gtt_driver *gtt_driver; |
1540 | } intel_gtt_chipsets[] = { | 1457 | } intel_gtt_chipsets[] = { |
1541 | { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver , NULL}, | 1458 | { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver, |
1542 | { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver , NULL}, | 1459 | &i81x_gtt_driver}, |
1543 | { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver , NULL}, | 1460 | { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver, |
1544 | { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver , NULL}, | 1461 | &i81x_gtt_driver}, |
1462 | { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver, | ||
1463 | &i81x_gtt_driver}, | ||
1464 | { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver, | ||
1465 | &i81x_gtt_driver}, | ||
1545 | { PCI_DEVICE_ID_INTEL_82830_CGC, "830M", | 1466 | { PCI_DEVICE_ID_INTEL_82830_CGC, "830M", |
1546 | &intel_830_driver , &i8xx_gtt_driver}, | 1467 | &intel_830_driver , &i8xx_gtt_driver}, |
1547 | { PCI_DEVICE_ID_INTEL_82845G_IG, "830M", | 1468 | { PCI_DEVICE_ID_INTEL_82845G_IG, "830M", |
@@ -1664,9 +1585,9 @@ int intel_gmch_probe(struct pci_dev *pdev, | |||
1664 | 1585 | ||
1665 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name); | 1586 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name); |
1666 | 1587 | ||
1667 | if (bridge->driver->mask_memory == intel_gen6_mask_memory) | 1588 | if (intel_private.driver->write_entry == gen6_write_entry) |
1668 | mask = 40; | 1589 | mask = 40; |
1669 | else if (bridge->driver->mask_memory == intel_i965_mask_memory) | 1590 | else if (intel_private.driver->write_entry == i965_write_entry) |
1670 | mask = 36; | 1591 | mask = 36; |
1671 | else | 1592 | else |
1672 | mask = 32; | 1593 | mask = 32; |