diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-09-12 11:11:15 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-21 06:40:41 -0400 |
commit | ae83dd5c7d80e0f9063739a18e270da7207a91e3 (patch) | |
tree | 2d5e0f7538350998479957d16f4b735fa8a83a3a /drivers/char/agp/intel-gtt.c | |
parent | 22533b494ff6a812b3e97248cc6c062858396182 (diff) |
intel-gtt add a cleanup function for chipset specific stuff
The old code didn't clean up the i830 chipset flush page. And it
looks nicer.
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/intel-gtt.c')
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index f82a2a688bcc..9a03815483c7 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -76,6 +76,9 @@ struct intel_gtt_driver { | |||
76 | unsigned int dma_mask_size : 8; | 76 | unsigned int dma_mask_size : 8; |
77 | /* Chipset specific GTT setup */ | 77 | /* Chipset specific GTT setup */ |
78 | int (*setup)(void); | 78 | int (*setup)(void); |
79 | /* This should undo anything done in ->setup() save the unmapping | ||
80 | * of the mmio register file, that's done in the generic code. */ | ||
81 | void (*cleanup)(void); | ||
79 | void (*write_entry)(dma_addr_t addr, unsigned int entry, unsigned int flags); | 82 | void (*write_entry)(dma_addr_t addr, unsigned int entry, unsigned int flags); |
80 | /* Flags is a more or less chipset specific opaque value. | 83 | /* Flags is a more or less chipset specific opaque value. |
81 | * For chipsets that need to support old ums (non-gem) code, this | 84 | * For chipsets that need to support old ums (non-gem) code, this |
@@ -732,12 +735,8 @@ static void intel_gtt_teardown_scratch_page(void) | |||
732 | 735 | ||
733 | static void intel_gtt_cleanup(void) | 736 | static void intel_gtt_cleanup(void) |
734 | { | 737 | { |
735 | if (intel_private.i9xx_flush_page) | 738 | intel_private.driver->cleanup(); |
736 | iounmap(intel_private.i9xx_flush_page); | 739 | |
737 | if (intel_private.resource_valid) | ||
738 | release_resource(&intel_private.ifp_resource); | ||
739 | intel_private.ifp_resource.start = 0; | ||
740 | intel_private.resource_valid = 0; | ||
741 | iounmap(intel_private.gtt); | 740 | iounmap(intel_private.gtt); |
742 | iounmap(intel_private.registers); | 741 | iounmap(intel_private.registers); |
743 | 742 | ||
@@ -766,6 +765,7 @@ static int intel_gtt_init(void) | |||
766 | intel_private.gtt = ioremap(intel_private.gtt_bus_addr, | 765 | intel_private.gtt = ioremap(intel_private.gtt_bus_addr, |
767 | gtt_map_size); | 766 | gtt_map_size); |
768 | if (!intel_private.gtt) { | 767 | if (!intel_private.gtt) { |
768 | intel_private.driver->cleanup(); | ||
769 | iounmap(intel_private.registers); | 769 | iounmap(intel_private.registers); |
770 | return -ENOMEM; | 770 | return -ENOMEM; |
771 | } | 771 | } |
@@ -775,6 +775,7 @@ static int intel_gtt_init(void) | |||
775 | /* we have to call this as early as possible after the MMIO base address is known */ | 775 | /* we have to call this as early as possible after the MMIO base address is known */ |
776 | intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); | 776 | intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries(); |
777 | if (intel_private.base.gtt_stolen_entries == 0) { | 777 | if (intel_private.base.gtt_stolen_entries == 0) { |
778 | intel_private.driver->cleanup(); | ||
778 | iounmap(intel_private.registers); | 779 | iounmap(intel_private.registers); |
779 | iounmap(intel_private.gtt); | 780 | iounmap(intel_private.gtt); |
780 | return -ENOMEM; | 781 | return -ENOMEM; |
@@ -809,7 +810,7 @@ static int intel_fake_agp_fetch_size(void) | |||
809 | return 0; | 810 | return 0; |
810 | } | 811 | } |
811 | 812 | ||
812 | static void intel_i830_fini_flush(void) | 813 | static void i830_cleanup(void) |
813 | { | 814 | { |
814 | kunmap(intel_private.i8xx_page); | 815 | kunmap(intel_private.i8xx_page); |
815 | intel_private.i8xx_flush_page = NULL; | 816 | intel_private.i8xx_flush_page = NULL; |
@@ -831,7 +832,7 @@ static void intel_i830_setup_flush(void) | |||
831 | 832 | ||
832 | intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page); | 833 | intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page); |
833 | if (!intel_private.i8xx_flush_page) | 834 | if (!intel_private.i8xx_flush_page) |
834 | intel_i830_fini_flush(); | 835 | i830_cleanup(); |
835 | } | 836 | } |
836 | 837 | ||
837 | /* The chipset_flush interface needs to get data that has already been | 838 | /* The chipset_flush interface needs to get data that has already been |
@@ -1174,6 +1175,16 @@ static void intel_i9xx_setup_flush(void) | |||
1174 | "can't ioremap flush page - no chipset flushing\n"); | 1175 | "can't ioremap flush page - no chipset flushing\n"); |
1175 | } | 1176 | } |
1176 | 1177 | ||
1178 | static void i9xx_cleanup(void) | ||
1179 | { | ||
1180 | if (intel_private.i9xx_flush_page) | ||
1181 | iounmap(intel_private.i9xx_flush_page); | ||
1182 | if (intel_private.resource_valid) | ||
1183 | release_resource(&intel_private.ifp_resource); | ||
1184 | intel_private.ifp_resource.start = 0; | ||
1185 | intel_private.resource_valid = 0; | ||
1186 | } | ||
1187 | |||
1177 | static void i9xx_chipset_flush(void) | 1188 | static void i9xx_chipset_flush(void) |
1178 | { | 1189 | { |
1179 | if (intel_private.i9xx_flush_page) | 1190 | if (intel_private.i9xx_flush_page) |
@@ -1217,6 +1228,10 @@ static void gen6_write_entry(dma_addr_t addr, unsigned int entry, | |||
1217 | writel(addr | pte_flags, intel_private.gtt + entry); | 1228 | writel(addr | pte_flags, intel_private.gtt + entry); |
1218 | } | 1229 | } |
1219 | 1230 | ||
1231 | static void gen6_cleanup(void) | ||
1232 | { | ||
1233 | } | ||
1234 | |||
1220 | static int i9xx_setup(void) | 1235 | static int i9xx_setup(void) |
1221 | { | 1236 | { |
1222 | u32 reg_addr; | 1237 | u32 reg_addr; |
@@ -1315,6 +1330,7 @@ static const struct intel_gtt_driver i81x_gtt_driver = { | |||
1315 | static const struct intel_gtt_driver i8xx_gtt_driver = { | 1330 | static const struct intel_gtt_driver i8xx_gtt_driver = { |
1316 | .gen = 2, | 1331 | .gen = 2, |
1317 | .setup = i830_setup, | 1332 | .setup = i830_setup, |
1333 | .cleanup = i830_cleanup, | ||
1318 | .write_entry = i830_write_entry, | 1334 | .write_entry = i830_write_entry, |
1319 | .dma_mask_size = 32, | 1335 | .dma_mask_size = 32, |
1320 | .check_flags = i830_check_flags, | 1336 | .check_flags = i830_check_flags, |
@@ -1323,6 +1339,7 @@ static const struct intel_gtt_driver i8xx_gtt_driver = { | |||
1323 | static const struct intel_gtt_driver i915_gtt_driver = { | 1339 | static const struct intel_gtt_driver i915_gtt_driver = { |
1324 | .gen = 3, | 1340 | .gen = 3, |
1325 | .setup = i9xx_setup, | 1341 | .setup = i9xx_setup, |
1342 | .cleanup = i9xx_cleanup, | ||
1326 | /* i945 is the last gpu to need phys mem (for overlay and cursors). */ | 1343 | /* i945 is the last gpu to need phys mem (for overlay and cursors). */ |
1327 | .write_entry = i830_write_entry, | 1344 | .write_entry = i830_write_entry, |
1328 | .dma_mask_size = 32, | 1345 | .dma_mask_size = 32, |
@@ -1333,6 +1350,7 @@ static const struct intel_gtt_driver g33_gtt_driver = { | |||
1333 | .gen = 3, | 1350 | .gen = 3, |
1334 | .is_g33 = 1, | 1351 | .is_g33 = 1, |
1335 | .setup = i9xx_setup, | 1352 | .setup = i9xx_setup, |
1353 | .cleanup = i9xx_cleanup, | ||
1336 | .write_entry = i965_write_entry, | 1354 | .write_entry = i965_write_entry, |
1337 | .dma_mask_size = 36, | 1355 | .dma_mask_size = 36, |
1338 | .check_flags = i830_check_flags, | 1356 | .check_flags = i830_check_flags, |
@@ -1342,6 +1360,7 @@ static const struct intel_gtt_driver pineview_gtt_driver = { | |||
1342 | .gen = 3, | 1360 | .gen = 3, |
1343 | .is_pineview = 1, .is_g33 = 1, | 1361 | .is_pineview = 1, .is_g33 = 1, |
1344 | .setup = i9xx_setup, | 1362 | .setup = i9xx_setup, |
1363 | .cleanup = i9xx_cleanup, | ||
1345 | .write_entry = i965_write_entry, | 1364 | .write_entry = i965_write_entry, |
1346 | .dma_mask_size = 36, | 1365 | .dma_mask_size = 36, |
1347 | .check_flags = i830_check_flags, | 1366 | .check_flags = i830_check_flags, |
@@ -1350,6 +1369,7 @@ static const struct intel_gtt_driver pineview_gtt_driver = { | |||
1350 | static const struct intel_gtt_driver i965_gtt_driver = { | 1369 | static const struct intel_gtt_driver i965_gtt_driver = { |
1351 | .gen = 4, | 1370 | .gen = 4, |
1352 | .setup = i9xx_setup, | 1371 | .setup = i9xx_setup, |
1372 | .cleanup = i9xx_cleanup, | ||
1353 | .write_entry = i965_write_entry, | 1373 | .write_entry = i965_write_entry, |
1354 | .dma_mask_size = 36, | 1374 | .dma_mask_size = 36, |
1355 | .check_flags = i830_check_flags, | 1375 | .check_flags = i830_check_flags, |
@@ -1358,6 +1378,7 @@ static const struct intel_gtt_driver i965_gtt_driver = { | |||
1358 | static const struct intel_gtt_driver g4x_gtt_driver = { | 1378 | static const struct intel_gtt_driver g4x_gtt_driver = { |
1359 | .gen = 5, | 1379 | .gen = 5, |
1360 | .setup = i9xx_setup, | 1380 | .setup = i9xx_setup, |
1381 | .cleanup = i9xx_cleanup, | ||
1361 | .write_entry = i965_write_entry, | 1382 | .write_entry = i965_write_entry, |
1362 | .dma_mask_size = 36, | 1383 | .dma_mask_size = 36, |
1363 | .check_flags = i830_check_flags, | 1384 | .check_flags = i830_check_flags, |
@@ -1367,6 +1388,7 @@ static const struct intel_gtt_driver ironlake_gtt_driver = { | |||
1367 | .gen = 5, | 1388 | .gen = 5, |
1368 | .is_ironlake = 1, | 1389 | .is_ironlake = 1, |
1369 | .setup = i9xx_setup, | 1390 | .setup = i9xx_setup, |
1391 | .cleanup = i9xx_cleanup, | ||
1370 | .write_entry = i965_write_entry, | 1392 | .write_entry = i965_write_entry, |
1371 | .dma_mask_size = 36, | 1393 | .dma_mask_size = 36, |
1372 | .check_flags = i830_check_flags, | 1394 | .check_flags = i830_check_flags, |
@@ -1375,6 +1397,7 @@ static const struct intel_gtt_driver ironlake_gtt_driver = { | |||
1375 | static const struct intel_gtt_driver sandybridge_gtt_driver = { | 1397 | static const struct intel_gtt_driver sandybridge_gtt_driver = { |
1376 | .gen = 6, | 1398 | .gen = 6, |
1377 | .setup = i9xx_setup, | 1399 | .setup = i9xx_setup, |
1400 | .cleanup = gen6_cleanup, | ||
1378 | .write_entry = gen6_write_entry, | 1401 | .write_entry = gen6_write_entry, |
1379 | .dma_mask_size = 40, | 1402 | .dma_mask_size = 40, |
1380 | .check_flags = gen6_check_flags, | 1403 | .check_flags = gen6_check_flags, |