aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-11-05 10:43:35 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-11-23 15:14:43 -0500
commitff26860fb53f2dcfaaaf1bf017b09dbdfddff5ee (patch)
tree2e441a68f636f52f9c158febe23766e6841d1a75 /drivers/char/agp
parent820647b97a9cbdd976c7177f1b6047fc1f6dd5c0 (diff)
intel-gtt: fold i81x-only dcache support into the generic driver
Now the intel-gtt.c rewrite is complete! 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.c150
1 files changed, 61 insertions, 89 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 4b79a7b47522..72267c801637 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -86,9 +86,6 @@ static struct _intel_private {
86 dma_addr_t scratch_page_dma; 86 dma_addr_t scratch_page_dma;
87} intel_private; 87} intel_private;
88 88
89static int intel_fake_agp_insert_entries(struct agp_memory *mem,
90 off_t pg_start, int type);
91
92#define INTEL_GTT_GEN intel_private.driver->gen 89#define INTEL_GTT_GEN intel_private.driver->gen
93#define IS_G33 intel_private.driver->is_g33 90#define IS_G33 intel_private.driver->is_g33
94#define IS_PINEVIEW intel_private.driver->is_pineview 91#define IS_PINEVIEW intel_private.driver->is_pineview
@@ -223,30 +220,26 @@ static void i810_cleanup(void)
223 free_gatt_pages(intel_private.i81x_gtt_table, I810_GTT_ORDER); 220 free_gatt_pages(intel_private.i81x_gtt_table, I810_GTT_ORDER);
224} 221}
225 222
226static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, 223static int i810_insert_dcache_entries(struct agp_memory *mem, off_t pg_start,
227 int type) 224 int type)
228{ 225{
229 int i; 226 int i;
230 227
231 if (type == AGP_DCACHE_MEMORY) { 228 if ((pg_start + mem->page_count)
232 if ((pg_start + mem->page_count) 229 > intel_private.num_dcache_entries)
233 > intel_private.num_dcache_entries) 230 return -EINVAL;
234 return -EINVAL;
235
236 if (!mem->is_flushed)
237 global_cache_flush();
238 231
239 for (i = pg_start; i < (pg_start + mem->page_count); i++) { 232 if (!mem->is_flushed)
240 dma_addr_t addr = i << PAGE_SHIFT; 233 global_cache_flush();
241 intel_private.driver->write_entry(addr,
242 i, type);
243 }
244 readl(intel_private.gtt+i-1);
245 234
246 return 0; 235 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
236 dma_addr_t addr = i << PAGE_SHIFT;
237 intel_private.driver->write_entry(addr,
238 i, type);
247 } 239 }
240 readl(intel_private.gtt+i-1);
248 241
249 return intel_fake_agp_insert_entries(mem, pg_start, type); 242 return 0;
250} 243}
251 244
252/* 245/*
@@ -935,6 +928,9 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
935 int i, j; 928 int i, j;
936 int ret = -EINVAL; 929 int ret = -EINVAL;
937 930
931 if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY)
932 return i810_insert_dcache_entries(mem, pg_start, type);
933
938 if (mem->page_count == 0) 934 if (mem->page_count == 0)
939 goto out; 935 goto out;
940 936
@@ -1211,28 +1207,6 @@ static int i9xx_setup(void)
1211 return 0; 1207 return 0;
1212} 1208}
1213 1209
1214static const struct agp_bridge_driver intel_810_driver = {
1215 .owner = THIS_MODULE,
1216 .size_type = FIXED_APER_SIZE,
1217 .aperture_sizes = intel_fake_agp_sizes,
1218 .num_aperture_sizes = ARRAY_SIZE(intel_fake_agp_sizes),
1219 .configure = intel_fake_agp_configure,
1220 .fetch_size = intel_fake_agp_fetch_size,
1221 .cleanup = intel_gtt_cleanup,
1222 .agp_enable = intel_fake_agp_enable,
1223 .cache_flush = global_cache_flush,
1224 .create_gatt_table = intel_fake_agp_create_gatt_table,
1225 .free_gatt_table = intel_fake_agp_free_gatt_table,
1226 .insert_memory = intel_i810_insert_entries,
1227 .remove_memory = intel_fake_agp_remove_entries,
1228 .alloc_by_type = intel_fake_agp_alloc_by_type,
1229 .free_by_type = intel_i810_free_by_type,
1230 .agp_alloc_page = agp_generic_alloc_page,
1231 .agp_alloc_pages = agp_generic_alloc_pages,
1232 .agp_destroy_page = agp_generic_destroy_page,
1233 .agp_destroy_pages = agp_generic_destroy_pages,
1234};
1235
1236static const struct agp_bridge_driver intel_fake_agp_driver = { 1210static const struct agp_bridge_driver intel_fake_agp_driver = {
1237 .owner = THIS_MODULE, 1211 .owner = THIS_MODULE,
1238 .size_type = FIXED_APER_SIZE, 1212 .size_type = FIXED_APER_SIZE,
@@ -1352,93 +1326,92 @@ static const struct intel_gtt_driver sandybridge_gtt_driver = {
1352static const struct intel_gtt_driver_description { 1326static const struct intel_gtt_driver_description {
1353 unsigned int gmch_chip_id; 1327 unsigned int gmch_chip_id;
1354 char *name; 1328 char *name;
1355 const struct agp_bridge_driver *gmch_driver;
1356 const struct intel_gtt_driver *gtt_driver; 1329 const struct intel_gtt_driver *gtt_driver;
1357} intel_gtt_chipsets[] = { 1330} intel_gtt_chipsets[] = {
1358 { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver, 1331 { PCI_DEVICE_ID_INTEL_82810_IG1, "i810",
1359 &i81x_gtt_driver}, 1332 &i81x_gtt_driver},
1360 { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver, 1333 { PCI_DEVICE_ID_INTEL_82810_IG3, "i810",
1361 &i81x_gtt_driver}, 1334 &i81x_gtt_driver},
1362 { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver, 1335 { PCI_DEVICE_ID_INTEL_82810E_IG, "i810",
1363 &i81x_gtt_driver}, 1336 &i81x_gtt_driver},
1364 { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver, 1337 { PCI_DEVICE_ID_INTEL_82815_CGC, "i815",
1365 &i81x_gtt_driver}, 1338 &i81x_gtt_driver},
1366 { PCI_DEVICE_ID_INTEL_82830_CGC, "830M", 1339 { PCI_DEVICE_ID_INTEL_82830_CGC, "830M",
1367 &intel_fake_agp_driver, &i8xx_gtt_driver}, 1340 &i8xx_gtt_driver},
1368 { PCI_DEVICE_ID_INTEL_82845G_IG, "830M", 1341 { PCI_DEVICE_ID_INTEL_82845G_IG, "830M",
1369 &intel_fake_agp_driver, &i8xx_gtt_driver}, 1342 &i8xx_gtt_driver},
1370 { PCI_DEVICE_ID_INTEL_82854_IG, "854", 1343 { PCI_DEVICE_ID_INTEL_82854_IG, "854",
1371 &intel_fake_agp_driver, &i8xx_gtt_driver}, 1344 &i8xx_gtt_driver},
1372 { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM", 1345 { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM",
1373 &intel_fake_agp_driver, &i8xx_gtt_driver}, 1346 &i8xx_gtt_driver},
1374 { PCI_DEVICE_ID_INTEL_82865_IG, "865", 1347 { PCI_DEVICE_ID_INTEL_82865_IG, "865",
1375 &intel_fake_agp_driver, &i8xx_gtt_driver}, 1348 &i8xx_gtt_driver},
1376 { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)", 1349 { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)",
1377 &intel_fake_agp_driver, &i915_gtt_driver }, 1350 &i915_gtt_driver },
1378 { PCI_DEVICE_ID_INTEL_82915G_IG, "915G", 1351 { PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
1379 &intel_fake_agp_driver, &i915_gtt_driver }, 1352 &i915_gtt_driver },
1380 { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM", 1353 { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
1381 &intel_fake_agp_driver, &i915_gtt_driver }, 1354 &i915_gtt_driver },
1382 { PCI_DEVICE_ID_INTEL_82945G_IG, "945G", 1355 { PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
1383 &intel_fake_agp_driver, &i915_gtt_driver }, 1356 &i915_gtt_driver },
1384 { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM", 1357 { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
1385 &intel_fake_agp_driver, &i915_gtt_driver }, 1358 &i915_gtt_driver },
1386 { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME", 1359 { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
1387 &intel_fake_agp_driver, &i915_gtt_driver }, 1360 &i915_gtt_driver },
1388 { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ", 1361 { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
1389 &intel_fake_agp_driver, &i965_gtt_driver }, 1362 &i965_gtt_driver },
1390 { PCI_DEVICE_ID_INTEL_82G35_IG, "G35", 1363 { PCI_DEVICE_ID_INTEL_82G35_IG, "G35",
1391 &intel_fake_agp_driver, &i965_gtt_driver }, 1364 &i965_gtt_driver },
1392 { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q", 1365 { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
1393 &intel_fake_agp_driver, &i965_gtt_driver }, 1366 &i965_gtt_driver },
1394 { PCI_DEVICE_ID_INTEL_82965G_IG, "965G", 1367 { PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
1395 &intel_fake_agp_driver, &i965_gtt_driver }, 1368 &i965_gtt_driver },
1396 { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM", 1369 { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
1397 &intel_fake_agp_driver, &i965_gtt_driver }, 1370 &i965_gtt_driver },
1398 { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE", 1371 { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
1399 &intel_fake_agp_driver, &i965_gtt_driver }, 1372 &i965_gtt_driver },
1400 { PCI_DEVICE_ID_INTEL_G33_IG, "G33", 1373 { PCI_DEVICE_ID_INTEL_G33_IG, "G33",
1401 &intel_fake_agp_driver, &g33_gtt_driver }, 1374 &g33_gtt_driver },
1402 { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35", 1375 { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
1403 &intel_fake_agp_driver, &g33_gtt_driver }, 1376 &g33_gtt_driver },
1404 { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33", 1377 { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
1405 &intel_fake_agp_driver, &g33_gtt_driver }, 1378 &g33_gtt_driver },
1406 { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150", 1379 { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150",
1407 &intel_fake_agp_driver, &pineview_gtt_driver }, 1380 &pineview_gtt_driver },
1408 { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150", 1381 { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150",
1409 &intel_fake_agp_driver, &pineview_gtt_driver }, 1382 &pineview_gtt_driver },
1410 { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45", 1383 { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45",
1411 &intel_fake_agp_driver, &g4x_gtt_driver }, 1384 &g4x_gtt_driver },
1412 { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake", 1385 { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake",
1413 &intel_fake_agp_driver, &g4x_gtt_driver }, 1386 &g4x_gtt_driver },
1414 { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43", 1387 { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43",
1415 &intel_fake_agp_driver, &g4x_gtt_driver }, 1388 &g4x_gtt_driver },
1416 { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43", 1389 { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43",
1417 &intel_fake_agp_driver, &g4x_gtt_driver }, 1390 &g4x_gtt_driver },
1418 { PCI_DEVICE_ID_INTEL_B43_IG, "B43", 1391 { PCI_DEVICE_ID_INTEL_B43_IG, "B43",
1419 &intel_fake_agp_driver, &g4x_gtt_driver }, 1392 &g4x_gtt_driver },
1420 { PCI_DEVICE_ID_INTEL_B43_1_IG, "B43", 1393 { PCI_DEVICE_ID_INTEL_B43_1_IG, "B43",
1421 &intel_fake_agp_driver, &g4x_gtt_driver }, 1394 &g4x_gtt_driver },
1422 { PCI_DEVICE_ID_INTEL_G41_IG, "G41", 1395 { PCI_DEVICE_ID_INTEL_G41_IG, "G41",
1423 &intel_fake_agp_driver, &g4x_gtt_driver }, 1396 &g4x_gtt_driver },
1424 { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG, 1397 { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG,
1425 "HD Graphics", &intel_fake_agp_driver, &ironlake_gtt_driver }, 1398 "HD Graphics", &ironlake_gtt_driver },
1426 { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 1399 { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG,
1427 "HD Graphics", &intel_fake_agp_driver, &ironlake_gtt_driver }, 1400 "HD Graphics", &ironlake_gtt_driver },
1428 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG, 1401 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG,
1429 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1402 "Sandybridge", &sandybridge_gtt_driver },
1430 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG, 1403 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG,
1431 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1404 "Sandybridge", &sandybridge_gtt_driver },
1432 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG, 1405 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG,
1433 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1406 "Sandybridge", &sandybridge_gtt_driver },
1434 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG, 1407 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG,
1435 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1408 "Sandybridge", &sandybridge_gtt_driver },
1436 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG, 1409 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG,
1437 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1410 "Sandybridge", &sandybridge_gtt_driver },
1438 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG, 1411 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG,
1439 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1412 "Sandybridge", &sandybridge_gtt_driver },
1440 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG, 1413 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG,
1441 "Sandybridge", &intel_fake_agp_driver, &sandybridge_gtt_driver }, 1414 "Sandybridge", &sandybridge_gtt_driver },
1442 { 0, NULL, NULL } 1415 { 0, NULL, NULL }
1443}; 1416};
1444 1417
@@ -1463,21 +1436,20 @@ int intel_gmch_probe(struct pci_dev *pdev,
1463 struct agp_bridge_data *bridge) 1436 struct agp_bridge_data *bridge)
1464{ 1437{
1465 int i, mask; 1438 int i, mask;
1466 bridge->driver = NULL; 1439 intel_private.driver = NULL;
1467 1440
1468 for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) { 1441 for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) {
1469 if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) { 1442 if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) {
1470 bridge->driver =
1471 intel_gtt_chipsets[i].gmch_driver;
1472 intel_private.driver = 1443 intel_private.driver =
1473 intel_gtt_chipsets[i].gtt_driver; 1444 intel_gtt_chipsets[i].gtt_driver;
1474 break; 1445 break;
1475 } 1446 }
1476 } 1447 }
1477 1448
1478 if (!bridge->driver) 1449 if (!intel_private.driver)
1479 return 0; 1450 return 0;
1480 1451
1452 bridge->driver = &intel_fake_agp_driver;
1481 bridge->dev_private_data = &intel_private; 1453 bridge->dev_private_data = &intel_private;
1482 bridge->dev = pdev; 1454 bridge->dev = pdev;
1483 1455