aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 16:08:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 16:08:22 -0400
commitbe53bfdb8088e9d1924199cc1a96e113756b1075 (patch)
tree8c65eb9d82ca4c0f11c17cfdc44d5263820b415b /drivers/gpu/drm/ttm
parentb2094ef840697bc8ca5d17a83b7e30fad5f1e9fa (diff)
parent5466c7b1683a23dbbcfb7ee4a71c4f23886001c7 (diff)
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm main changes from Dave Airlie: "This is the main drm pull request, I'm probably going to send two more smaller ones, will explain below. This contains a patch that is also in the fbdev tree, but it should be the same patch, it added an API for hot unplugging framebuffer devices, and I need that API for a new driver. It also contains some changes to the i2c tree which Jean has acked, and one change to moorestown platform stuff in x86. Highlights: - new drivers: UDL driver for USB displaylink devices, kms only, should support correct hotplug operations. - core: i2c speedups + better hotplug support, EDID overriding via firmware interface - allows user to load a firmware for a broken monitor/kvm from userspace, it even has documentation for it. - exynos: new HDMI audio + hdmi 1.4 + virtual output driver - gma500: code cleanup - radeon: cleanups, CS optimisations, streamout support and pageflip fix - nouveau: NVD9 displayport support + more reclocking work - i915: re-enabling GMBUS, finish gpu patch (might help hibernation who knows), missed irq fixes, stencil tiling fixes, interlaced support, aliasesd PPGTT support for SNB/IVB, swizzling for SNB/IVB, semaphore fixes As well as the usual bunch of cleanups and fixes all over the place. I've got two things I'd like to merge a bit later: a) AMD support for all their new radeonhd 7000 series GPU and APUs. AMD dropped this a bit late due to insane internal review processes, (please AMD just follow Intel and let open source guys ship stuff early) however I don't want to penalise people who own this hardware (since its been on sale for 3-4 months and GPU hw doesn't exactly have a lifetime in years) and consign them to using closed drivers for longer than necessary. The changes are well contained and just plug into the driver new gpu functionality so they should be fairly regression proof. I just want to give them a bit of a run on the hw AMD kindly sent me. b) drm prime/dma-buf interface code. This is just infrastructure code to expose the dma-buf stuff to drm drivers and to userspace. I'm not planning on pushing any driver support in this cycle (except maybe exynos), but I'd like to get the infrastructure code in so for the next cycle I can start getting the driver support into the individual drivers. We have started driver support for i915, nouveau and udl along with I think exynos and omap in staging. However this code relies on the dma-buf tree being pulled into your tree first since it needs the latest interfaces from that tree. I'll push to get that tree sent asap. (oh and any warnings you see in i915 are gcc's fault from what anyone can see)." Fix up trivial conflicts in arch/x86/platform/mrst/mrst.c due to the new msic_thermal_platform_data() thermal function being added next to the tc35876x_platform_data() i2c device function.. * 'drm-next' of git://people.freedesktop.org/~airlied/linux: (326 commits) drm/i915: use DDC_ADDR instead of hard-coding it drm/radeon: use DDC_ADDR instead of hard-coding it drm: remove unneeded redefinition of DDC_ADDR drm/exynos: added virtual display driver. drm: allow loading an EDID as firmware to override broken monitor drm/exynos: enable hdmi audio feature drm/exynos: add default pixel format for plane drm/exynos: cleanup exynos_hdmi.h drm/exynos: add is_local member in exynos_drm_subdrv struct drm/exynos: add subdrv open/close functions drm/exynos: remove module of exynos drm subdrv drm/exynos: release pending pageflip events when closed drm/exynos: added new funtion to get/put dma address. drm/exynos: update gem and buffer framework. drm/exynos: added mode_fixup feature and code clean. drm/exynos: add HDMI version 1.4 support drm/exynos: remove exynos_mixer.h gma500: Fix mmap frambuffer drm/radeon: Drop radeon_gem_object_(un)pin. drm/radeon: Restrict offset for legacy display engine. ...
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_agp_backend.c4
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c72
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_vm.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_memory.c12
-rw-r--r--drivers/gpu/drm/ttm/ttm_object.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c55
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc_dma.c60
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c8
8 files changed, 96 insertions, 125 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c
index 747c1413fc9..4a872829136 100644
--- a/drivers/gpu/drm/ttm/ttm_agp_backend.c
+++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c
@@ -29,6 +29,8 @@
29 * Keith Packard. 29 * Keith Packard.
30 */ 30 */
31 31
32#define pr_fmt(fmt) "[TTM] " fmt
33
32#include "ttm/ttm_module.h" 34#include "ttm/ttm_module.h"
33#include "ttm/ttm_bo_driver.h" 35#include "ttm/ttm_bo_driver.h"
34#include "ttm/ttm_page_alloc.h" 36#include "ttm/ttm_page_alloc.h"
@@ -74,7 +76,7 @@ static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
74 76
75 ret = agp_bind_memory(mem, node->start); 77 ret = agp_bind_memory(mem, node->start);
76 if (ret) 78 if (ret)
77 printk(KERN_ERR TTM_PFX "AGP Bind memory failed.\n"); 79 pr_err("AGP Bind memory failed\n");
78 80
79 return ret; 81 return ret;
80} 82}
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 7c3a57de818..1f5c67c579c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -28,6 +28,8 @@
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> 28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */ 29 */
30 30
31#define pr_fmt(fmt) "[TTM] " fmt
32
31#include "ttm/ttm_module.h" 33#include "ttm/ttm_module.h"
32#include "ttm/ttm_bo_driver.h" 34#include "ttm/ttm_bo_driver.h"
33#include "ttm/ttm_placement.h" 35#include "ttm/ttm_placement.h"
@@ -68,15 +70,13 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)
68{ 70{
69 struct ttm_mem_type_manager *man = &bdev->man[mem_type]; 71 struct ttm_mem_type_manager *man = &bdev->man[mem_type];
70 72
71 printk(KERN_ERR TTM_PFX " has_type: %d\n", man->has_type); 73 pr_err(" has_type: %d\n", man->has_type);
72 printk(KERN_ERR TTM_PFX " use_type: %d\n", man->use_type); 74 pr_err(" use_type: %d\n", man->use_type);
73 printk(KERN_ERR TTM_PFX " flags: 0x%08X\n", man->flags); 75 pr_err(" flags: 0x%08X\n", man->flags);
74 printk(KERN_ERR TTM_PFX " gpu_offset: 0x%08lX\n", man->gpu_offset); 76 pr_err(" gpu_offset: 0x%08lX\n", man->gpu_offset);
75 printk(KERN_ERR TTM_PFX " size: %llu\n", man->size); 77 pr_err(" size: %llu\n", man->size);
76 printk(KERN_ERR TTM_PFX " available_caching: 0x%08X\n", 78 pr_err(" available_caching: 0x%08X\n", man->available_caching);
77 man->available_caching); 79 pr_err(" default_caching: 0x%08X\n", man->default_caching);
78 printk(KERN_ERR TTM_PFX " default_caching: 0x%08X\n",
79 man->default_caching);
80 if (mem_type != TTM_PL_SYSTEM) 80 if (mem_type != TTM_PL_SYSTEM)
81 (*man->func->debug)(man, TTM_PFX); 81 (*man->func->debug)(man, TTM_PFX);
82} 82}
@@ -86,16 +86,16 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
86{ 86{
87 int i, ret, mem_type; 87 int i, ret, mem_type;
88 88
89 printk(KERN_ERR TTM_PFX "No space for %p (%lu pages, %luK, %luM)\n", 89 pr_err("No space for %p (%lu pages, %luK, %luM)\n",
90 bo, bo->mem.num_pages, bo->mem.size >> 10, 90 bo, bo->mem.num_pages, bo->mem.size >> 10,
91 bo->mem.size >> 20); 91 bo->mem.size >> 20);
92 for (i = 0; i < placement->num_placement; i++) { 92 for (i = 0; i < placement->num_placement; i++) {
93 ret = ttm_mem_type_from_flags(placement->placement[i], 93 ret = ttm_mem_type_from_flags(placement->placement[i],
94 &mem_type); 94 &mem_type);
95 if (ret) 95 if (ret)
96 return; 96 return;
97 printk(KERN_ERR TTM_PFX " placement[%d]=0x%08X (%d)\n", 97 pr_err(" placement[%d]=0x%08X (%d)\n",
98 i, placement->placement[i], mem_type); 98 i, placement->placement[i], mem_type);
99 ttm_mem_type_debug(bo->bdev, mem_type); 99 ttm_mem_type_debug(bo->bdev, mem_type);
100 } 100 }
101} 101}
@@ -344,7 +344,7 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
344 ret = -ENOMEM; 344 ret = -ENOMEM;
345 break; 345 break;
346 default: 346 default:
347 printk(KERN_ERR TTM_PFX "Illegal buffer object type\n"); 347 pr_err("Illegal buffer object type\n");
348 ret = -EINVAL; 348 ret = -EINVAL;
349 break; 349 break;
350 } 350 }
@@ -432,7 +432,7 @@ moved:
432 if (bo->evicted) { 432 if (bo->evicted) {
433 ret = bdev->driver->invalidate_caches(bdev, bo->mem.placement); 433 ret = bdev->driver->invalidate_caches(bdev, bo->mem.placement);
434 if (ret) 434 if (ret)
435 printk(KERN_ERR TTM_PFX "Can not flush read caches\n"); 435 pr_err("Can not flush read caches\n");
436 bo->evicted = false; 436 bo->evicted = false;
437 } 437 }
438 438
@@ -734,9 +734,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
734 734
735 if (unlikely(ret != 0)) { 735 if (unlikely(ret != 0)) {
736 if (ret != -ERESTARTSYS) { 736 if (ret != -ERESTARTSYS) {
737 printk(KERN_ERR TTM_PFX 737 pr_err("Failed to expire sync object before buffer eviction\n");
738 "Failed to expire sync object before "
739 "buffer eviction.\n");
740 } 738 }
741 goto out; 739 goto out;
742 } 740 }
@@ -757,9 +755,8 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
757 no_wait_reserve, no_wait_gpu); 755 no_wait_reserve, no_wait_gpu);
758 if (ret) { 756 if (ret) {
759 if (ret != -ERESTARTSYS) { 757 if (ret != -ERESTARTSYS) {
760 printk(KERN_ERR TTM_PFX 758 pr_err("Failed to find memory space for buffer 0x%p eviction\n",
761 "Failed to find memory space for " 759 bo);
762 "buffer 0x%p eviction.\n", bo);
763 ttm_bo_mem_space_debug(bo, &placement); 760 ttm_bo_mem_space_debug(bo, &placement);
764 } 761 }
765 goto out; 762 goto out;
@@ -769,7 +766,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
769 no_wait_reserve, no_wait_gpu); 766 no_wait_reserve, no_wait_gpu);
770 if (ret) { 767 if (ret) {
771 if (ret != -ERESTARTSYS) 768 if (ret != -ERESTARTSYS)
772 printk(KERN_ERR TTM_PFX "Buffer eviction failed\n"); 769 pr_err("Buffer eviction failed\n");
773 ttm_bo_mem_put(bo, &evict_mem); 770 ttm_bo_mem_put(bo, &evict_mem);
774 goto out; 771 goto out;
775 } 772 }
@@ -1180,7 +1177,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1180 1177
1181 ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false); 1178 ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
1182 if (ret) { 1179 if (ret) {
1183 printk(KERN_ERR TTM_PFX "Out of kernel memory.\n"); 1180 pr_err("Out of kernel memory\n");
1184 if (destroy) 1181 if (destroy)
1185 (*destroy)(bo); 1182 (*destroy)(bo);
1186 else 1183 else
@@ -1191,7 +1188,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1191 size += buffer_start & ~PAGE_MASK; 1188 size += buffer_start & ~PAGE_MASK;
1192 num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 1189 num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
1193 if (num_pages == 0) { 1190 if (num_pages == 0) {
1194 printk(KERN_ERR TTM_PFX "Illegal buffer object size.\n"); 1191 pr_err("Illegal buffer object size\n");
1195 if (destroy) 1192 if (destroy)
1196 (*destroy)(bo); 1193 (*destroy)(bo);
1197 else 1194 else
@@ -1342,8 +1339,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
1342 if (allow_errors) { 1339 if (allow_errors) {
1343 return ret; 1340 return ret;
1344 } else { 1341 } else {
1345 printk(KERN_ERR TTM_PFX 1342 pr_err("Cleanup eviction failed\n");
1346 "Cleanup eviction failed\n");
1347 } 1343 }
1348 } 1344 }
1349 spin_lock(&glob->lru_lock); 1345 spin_lock(&glob->lru_lock);
@@ -1358,14 +1354,14 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
1358 int ret = -EINVAL; 1354 int ret = -EINVAL;
1359 1355
1360 if (mem_type >= TTM_NUM_MEM_TYPES) { 1356 if (mem_type >= TTM_NUM_MEM_TYPES) {
1361 printk(KERN_ERR TTM_PFX "Illegal memory type %d\n", mem_type); 1357 pr_err("Illegal memory type %d\n", mem_type);
1362 return ret; 1358 return ret;
1363 } 1359 }
1364 man = &bdev->man[mem_type]; 1360 man = &bdev->man[mem_type];
1365 1361
1366 if (!man->has_type) { 1362 if (!man->has_type) {
1367 printk(KERN_ERR TTM_PFX "Trying to take down uninitialized " 1363 pr_err("Trying to take down uninitialized memory manager type %u\n",
1368 "memory manager type %u\n", mem_type); 1364 mem_type);
1369 return ret; 1365 return ret;
1370 } 1366 }
1371 1367
@@ -1388,16 +1384,12 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)
1388 struct ttm_mem_type_manager *man = &bdev->man[mem_type]; 1384 struct ttm_mem_type_manager *man = &bdev->man[mem_type];
1389 1385
1390 if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) { 1386 if (mem_type == 0 || mem_type >= TTM_NUM_MEM_TYPES) {
1391 printk(KERN_ERR TTM_PFX 1387 pr_err("Illegal memory manager memory type %u\n", mem_type);
1392 "Illegal memory manager memory type %u.\n",
1393 mem_type);
1394 return -EINVAL; 1388 return -EINVAL;
1395 } 1389 }
1396 1390
1397 if (!man->has_type) { 1391 if (!man->has_type) {
1398 printk(KERN_ERR TTM_PFX 1392 pr_err("Memory type %u has not been initialized\n", mem_type);
1399 "Memory type %u has not been initialized.\n",
1400 mem_type);
1401 return 0; 1393 return 0;
1402 } 1394 }
1403 1395
@@ -1482,8 +1474,7 @@ int ttm_bo_global_init(struct drm_global_reference *ref)
1482 ttm_mem_init_shrink(&glob->shrink, ttm_bo_swapout); 1474 ttm_mem_init_shrink(&glob->shrink, ttm_bo_swapout);
1483 ret = ttm_mem_register_shrink(glob->mem_glob, &glob->shrink); 1475 ret = ttm_mem_register_shrink(glob->mem_glob, &glob->shrink);
1484 if (unlikely(ret != 0)) { 1476 if (unlikely(ret != 0)) {
1485 printk(KERN_ERR TTM_PFX 1477 pr_err("Could not register buffer object swapout\n");
1486 "Could not register buffer object swapout.\n");
1487 goto out_no_shrink; 1478 goto out_no_shrink;
1488 } 1479 }
1489 1480
@@ -1516,9 +1507,8 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
1516 man->use_type = false; 1507 man->use_type = false;
1517 if ((i != TTM_PL_SYSTEM) && ttm_bo_clean_mm(bdev, i)) { 1508 if ((i != TTM_PL_SYSTEM) && ttm_bo_clean_mm(bdev, i)) {
1518 ret = -EBUSY; 1509 ret = -EBUSY;
1519 printk(KERN_ERR TTM_PFX 1510 pr_err("DRM memory manager type %d is not clean\n",
1520 "DRM memory manager type %d " 1511 i);
1521 "is not clean.\n", i);
1522 } 1512 }
1523 man->has_type = false; 1513 man->has_type = false;
1524 } 1514 }
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 54412848de8..a877813571a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -28,6 +28,8 @@
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> 28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */ 29 */
30 30
31#define pr_fmt(fmt) "[TTM] " fmt
32
31#include <ttm/ttm_module.h> 33#include <ttm/ttm_module.h>
32#include <ttm/ttm_bo_driver.h> 34#include <ttm/ttm_bo_driver.h>
33#include <ttm/ttm_placement.h> 35#include <ttm/ttm_placement.h>
@@ -262,8 +264,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
262 read_unlock(&bdev->vm_lock); 264 read_unlock(&bdev->vm_lock);
263 265
264 if (unlikely(bo == NULL)) { 266 if (unlikely(bo == NULL)) {
265 printk(KERN_ERR TTM_PFX 267 pr_err("Could not find buffer object to map\n");
266 "Could not find buffer object to map.\n");
267 return -EINVAL; 268 return -EINVAL;
268 } 269 }
269 270
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 9eba8e9a4e9..23d2ecbaed5 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -25,6 +25,8 @@
25 * 25 *
26 **************************************************************************/ 26 **************************************************************************/
27 27
28#define pr_fmt(fmt) "[TTM] " fmt
29
28#include "ttm/ttm_memory.h" 30#include "ttm/ttm_memory.h"
29#include "ttm/ttm_module.h" 31#include "ttm/ttm_module.h"
30#include "ttm/ttm_page_alloc.h" 32#include "ttm/ttm_page_alloc.h"
@@ -74,9 +76,8 @@ static void ttm_mem_zone_kobj_release(struct kobject *kobj)
74 struct ttm_mem_zone *zone = 76 struct ttm_mem_zone *zone =
75 container_of(kobj, struct ttm_mem_zone, kobj); 77 container_of(kobj, struct ttm_mem_zone, kobj);
76 78
77 printk(KERN_INFO TTM_PFX 79 pr_info("Zone %7s: Used memory at exit: %llu kiB\n",
78 "Zone %7s: Used memory at exit: %llu kiB.\n", 80 zone->name, (unsigned long long)zone->used_mem >> 10);
79 zone->name, (unsigned long long) zone->used_mem >> 10);
80 kfree(zone); 81 kfree(zone);
81} 82}
82 83
@@ -390,9 +391,8 @@ int ttm_mem_global_init(struct ttm_mem_global *glob)
390#endif 391#endif
391 for (i = 0; i < glob->num_zones; ++i) { 392 for (i = 0; i < glob->num_zones; ++i) {
392 zone = glob->zones[i]; 393 zone = glob->zones[i];
393 printk(KERN_INFO TTM_PFX 394 pr_info("Zone %7s: Available graphics memory: %llu kiB\n",
394 "Zone %7s: Available graphics memory: %llu kiB.\n", 395 zone->name, (unsigned long long)zone->max_mem >> 10);
395 zone->name, (unsigned long long) zone->max_mem >> 10);
396 } 396 }
397 ttm_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); 397 ttm_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE));
398 ttm_dma_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); 398 ttm_dma_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE));
diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c
index 93577f2e295..68daca412cb 100644
--- a/drivers/gpu/drm/ttm/ttm_object.c
+++ b/drivers/gpu/drm/ttm/ttm_object.c
@@ -49,6 +49,8 @@
49 * for fast lookup of ref objects given a base object. 49 * for fast lookup of ref objects given a base object.
50 */ 50 */
51 51
52#define pr_fmt(fmt) "[TTM] " fmt
53
52#include "ttm/ttm_object.h" 54#include "ttm/ttm_object.h"
53#include "ttm/ttm_module.h" 55#include "ttm/ttm_module.h"
54#include <linux/list.h> 56#include <linux/list.h>
@@ -232,8 +234,7 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile,
232 return NULL; 234 return NULL;
233 235
234 if (tfile != base->tfile && !base->shareable) { 236 if (tfile != base->tfile && !base->shareable) {
235 printk(KERN_ERR TTM_PFX 237 pr_err("Attempted access of non-shareable object\n");
236 "Attempted access of non-shareable object.\n");
237 ttm_base_object_unref(&base); 238 ttm_base_object_unref(&base);
238 return NULL; 239 return NULL;
239 } 240 }
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 499debda791..ebc6fac96e3 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -30,6 +30,9 @@
30 * - Use page->lru to keep a free list 30 * - Use page->lru to keep a free list
31 * - doesn't track currently in use pages 31 * - doesn't track currently in use pages
32 */ 32 */
33
34#define pr_fmt(fmt) "[TTM] " fmt
35
33#include <linux/list.h> 36#include <linux/list.h>
34#include <linux/spinlock.h> 37#include <linux/spinlock.h>
35#include <linux/highmem.h> 38#include <linux/highmem.h>
@@ -167,18 +170,13 @@ static ssize_t ttm_pool_store(struct kobject *kobj,
167 m->options.small = val; 170 m->options.small = val;
168 else if (attr == &ttm_page_pool_alloc_size) { 171 else if (attr == &ttm_page_pool_alloc_size) {
169 if (val > NUM_PAGES_TO_ALLOC*8) { 172 if (val > NUM_PAGES_TO_ALLOC*8) {
170 printk(KERN_ERR TTM_PFX 173 pr_err("Setting allocation size to %lu is not allowed. Recommended size is %lu\n",
171 "Setting allocation size to %lu "
172 "is not allowed. Recommended size is "
173 "%lu\n",
174 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7), 174 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7),
175 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10)); 175 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
176 return size; 176 return size;
177 } else if (val > NUM_PAGES_TO_ALLOC) { 177 } else if (val > NUM_PAGES_TO_ALLOC) {
178 printk(KERN_WARNING TTM_PFX 178 pr_warn("Setting allocation size to larger than %lu is not recommended\n",
179 "Setting allocation size to " 179 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
180 "larger than %lu is not recommended.\n",
181 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
182 } 180 }
183 m->options.alloc_size = val; 181 m->options.alloc_size = val;
184 } 182 }
@@ -279,8 +277,7 @@ static void ttm_pages_put(struct page *pages[], unsigned npages)
279{ 277{
280 unsigned i; 278 unsigned i;
281 if (set_pages_array_wb(pages, npages)) 279 if (set_pages_array_wb(pages, npages))
282 printk(KERN_ERR TTM_PFX "Failed to set %d pages to wb!\n", 280 pr_err("Failed to set %d pages to wb!\n", npages);
283 npages);
284 for (i = 0; i < npages; ++i) 281 for (i = 0; i < npages; ++i)
285 __free_page(pages[i]); 282 __free_page(pages[i]);
286} 283}
@@ -315,8 +312,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free)
315 pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), 312 pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
316 GFP_KERNEL); 313 GFP_KERNEL);
317 if (!pages_to_free) { 314 if (!pages_to_free) {
318 printk(KERN_ERR TTM_PFX 315 pr_err("Failed to allocate memory for pool free operation\n");
319 "Failed to allocate memory for pool free operation.\n");
320 return 0; 316 return 0;
321 } 317 }
322 318
@@ -438,16 +434,12 @@ static int ttm_set_pages_caching(struct page **pages,
438 case tt_uncached: 434 case tt_uncached:
439 r = set_pages_array_uc(pages, cpages); 435 r = set_pages_array_uc(pages, cpages);
440 if (r) 436 if (r)
441 printk(KERN_ERR TTM_PFX 437 pr_err("Failed to set %d pages to uc!\n", cpages);
442 "Failed to set %d pages to uc!\n",
443 cpages);
444 break; 438 break;
445 case tt_wc: 439 case tt_wc:
446 r = set_pages_array_wc(pages, cpages); 440 r = set_pages_array_wc(pages, cpages);
447 if (r) 441 if (r)
448 printk(KERN_ERR TTM_PFX 442 pr_err("Failed to set %d pages to wc!\n", cpages);
449 "Failed to set %d pages to wc!\n",
450 cpages);
451 break; 443 break;
452 default: 444 default:
453 break; 445 break;
@@ -492,8 +484,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
492 caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); 484 caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
493 485
494 if (!caching_array) { 486 if (!caching_array) {
495 printk(KERN_ERR TTM_PFX 487 pr_err("Unable to allocate table for new pages\n");
496 "Unable to allocate table for new pages.");
497 return -ENOMEM; 488 return -ENOMEM;
498 } 489 }
499 490
@@ -501,7 +492,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
501 p = alloc_page(gfp_flags); 492 p = alloc_page(gfp_flags);
502 493
503 if (!p) { 494 if (!p) {
504 printk(KERN_ERR TTM_PFX "Unable to get page %u.\n", i); 495 pr_err("Unable to get page %u\n", i);
505 496
506 /* store already allocated pages in the pool after 497 /* store already allocated pages in the pool after
507 * setting the caching state */ 498 * setting the caching state */
@@ -599,8 +590,7 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
599 ++pool->nrefills; 590 ++pool->nrefills;
600 pool->npages += alloc_size; 591 pool->npages += alloc_size;
601 } else { 592 } else {
602 printk(KERN_ERR TTM_PFX 593 pr_err("Failed to fill pool (%p)\n", pool);
603 "Failed to fill pool (%p).", pool);
604 /* If we have any pages left put them to the pool. */ 594 /* If we have any pages left put them to the pool. */
605 list_for_each_entry(p, &pool->list, lru) { 595 list_for_each_entry(p, &pool->list, lru) {
606 ++cpages; 596 ++cpages;
@@ -675,9 +665,7 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
675 for (i = 0; i < npages; i++) { 665 for (i = 0; i < npages; i++) {
676 if (pages[i]) { 666 if (pages[i]) {
677 if (page_count(pages[i]) != 1) 667 if (page_count(pages[i]) != 1)
678 printk(KERN_ERR TTM_PFX 668 pr_err("Erroneous page count. Leaking pages.\n");
679 "Erroneous page count. "
680 "Leaking pages.\n");
681 __free_page(pages[i]); 669 __free_page(pages[i]);
682 pages[i] = NULL; 670 pages[i] = NULL;
683 } 671 }
@@ -689,9 +677,7 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
689 for (i = 0; i < npages; i++) { 677 for (i = 0; i < npages; i++) {
690 if (pages[i]) { 678 if (pages[i]) {
691 if (page_count(pages[i]) != 1) 679 if (page_count(pages[i]) != 1)
692 printk(KERN_ERR TTM_PFX 680 pr_err("Erroneous page count. Leaking pages.\n");
693 "Erroneous page count. "
694 "Leaking pages.\n");
695 list_add_tail(&pages[i]->lru, &pool->list); 681 list_add_tail(&pages[i]->lru, &pool->list);
696 pages[i] = NULL; 682 pages[i] = NULL;
697 pool->npages++; 683 pool->npages++;
@@ -740,8 +726,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
740 p = alloc_page(gfp_flags); 726 p = alloc_page(gfp_flags);
741 if (!p) { 727 if (!p) {
742 728
743 printk(KERN_ERR TTM_PFX 729 pr_err("Unable to allocate page\n");
744 "Unable to allocate page.");
745 return -ENOMEM; 730 return -ENOMEM;
746 } 731 }
747 732
@@ -781,9 +766,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
781 if (r) { 766 if (r) {
782 /* If there is any pages in the list put them back to 767 /* If there is any pages in the list put them back to
783 * the pool. */ 768 * the pool. */
784 printk(KERN_ERR TTM_PFX 769 pr_err("Failed to allocate extra pages for large request\n");
785 "Failed to allocate extra pages "
786 "for large request.");
787 ttm_put_pages(pages, count, flags, cstate); 770 ttm_put_pages(pages, count, flags, cstate);
788 return r; 771 return r;
789 } 772 }
@@ -809,7 +792,7 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
809 792
810 WARN_ON(_manager); 793 WARN_ON(_manager);
811 794
812 printk(KERN_INFO TTM_PFX "Initializing pool allocator.\n"); 795 pr_info("Initializing pool allocator\n");
813 796
814 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); 797 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
815 798
@@ -844,7 +827,7 @@ void ttm_page_alloc_fini(void)
844{ 827{
845 int i; 828 int i;
846 829
847 printk(KERN_INFO TTM_PFX "Finalizing pool allocator.\n"); 830 pr_info("Finalizing pool allocator\n");
848 ttm_pool_mm_shrink_fini(_manager); 831 ttm_pool_mm_shrink_fini(_manager);
849 832
850 for (i = 0; i < NUM_POOLS; ++i) 833 for (i = 0; i < NUM_POOLS; ++i)
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 0c46d8cdc6e..4f9e548b2ee 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -33,6 +33,8 @@
33 * when freed). 33 * when freed).
34 */ 34 */
35 35
36#define pr_fmt(fmt) "[TTM] " fmt
37
36#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
37#include <linux/list.h> 39#include <linux/list.h>
38#include <linux/seq_file.h> /* for seq_printf */ 40#include <linux/seq_file.h> /* for seq_printf */
@@ -221,18 +223,13 @@ static ssize_t ttm_pool_store(struct kobject *kobj, struct attribute *attr,
221 m->options.small = val; 223 m->options.small = val;
222 else if (attr == &ttm_page_pool_alloc_size) { 224 else if (attr == &ttm_page_pool_alloc_size) {
223 if (val > NUM_PAGES_TO_ALLOC*8) { 225 if (val > NUM_PAGES_TO_ALLOC*8) {
224 printk(KERN_ERR TTM_PFX 226 pr_err("Setting allocation size to %lu is not allowed. Recommended size is %lu\n",
225 "Setting allocation size to %lu "
226 "is not allowed. Recommended size is "
227 "%lu\n",
228 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7), 227 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7),
229 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10)); 228 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
230 return size; 229 return size;
231 } else if (val > NUM_PAGES_TO_ALLOC) { 230 } else if (val > NUM_PAGES_TO_ALLOC) {
232 printk(KERN_WARNING TTM_PFX 231 pr_warn("Setting allocation size to larger than %lu is not recommended\n",
233 "Setting allocation size to " 232 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
234 "larger than %lu is not recommended.\n",
235 NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 10));
236 } 233 }
237 m->options.alloc_size = val; 234 m->options.alloc_size = val;
238 } 235 }
@@ -313,15 +310,13 @@ static int ttm_set_pages_caching(struct dma_pool *pool,
313 if (pool->type & IS_UC) { 310 if (pool->type & IS_UC) {
314 r = set_pages_array_uc(pages, cpages); 311 r = set_pages_array_uc(pages, cpages);
315 if (r) 312 if (r)
316 pr_err(TTM_PFX 313 pr_err("%s: Failed to set %d pages to uc!\n",
317 "%s: Failed to set %d pages to uc!\n",
318 pool->dev_name, cpages); 314 pool->dev_name, cpages);
319 } 315 }
320 if (pool->type & IS_WC) { 316 if (pool->type & IS_WC) {
321 r = set_pages_array_wc(pages, cpages); 317 r = set_pages_array_wc(pages, cpages);
322 if (r) 318 if (r)
323 pr_err(TTM_PFX 319 pr_err("%s: Failed to set %d pages to wc!\n",
324 "%s: Failed to set %d pages to wc!\n",
325 pool->dev_name, cpages); 320 pool->dev_name, cpages);
326 } 321 }
327 return r; 322 return r;
@@ -387,8 +382,8 @@ static void ttm_dma_pages_put(struct dma_pool *pool, struct list_head *d_pages,
387 /* Don't set WB on WB page pool. */ 382 /* Don't set WB on WB page pool. */
388 if (npages && !(pool->type & IS_CACHED) && 383 if (npages && !(pool->type & IS_CACHED) &&
389 set_pages_array_wb(pages, npages)) 384 set_pages_array_wb(pages, npages))
390 pr_err(TTM_PFX "%s: Failed to set %d pages to wb!\n", 385 pr_err("%s: Failed to set %d pages to wb!\n",
391 pool->dev_name, npages); 386 pool->dev_name, npages);
392 387
393 list_for_each_entry_safe(d_page, tmp, d_pages, page_list) { 388 list_for_each_entry_safe(d_page, tmp, d_pages, page_list) {
394 list_del(&d_page->page_list); 389 list_del(&d_page->page_list);
@@ -400,8 +395,8 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
400{ 395{
401 /* Don't set WB on WB page pool. */ 396 /* Don't set WB on WB page pool. */
402 if (!(pool->type & IS_CACHED) && set_pages_array_wb(&d_page->p, 1)) 397 if (!(pool->type & IS_CACHED) && set_pages_array_wb(&d_page->p, 1))
403 pr_err(TTM_PFX "%s: Failed to set %d pages to wb!\n", 398 pr_err("%s: Failed to set %d pages to wb!\n",
404 pool->dev_name, 1); 399 pool->dev_name, 1);
405 400
406 list_del(&d_page->page_list); 401 list_del(&d_page->page_list);
407 __ttm_dma_free_page(pool, d_page); 402 __ttm_dma_free_page(pool, d_page);
@@ -430,17 +425,16 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free)
430#if 0 425#if 0
431 if (nr_free > 1) { 426 if (nr_free > 1) {
432 pr_debug("%s: (%s:%d) Attempting to free %d (%d) pages\n", 427 pr_debug("%s: (%s:%d) Attempting to free %d (%d) pages\n",
433 pool->dev_name, pool->name, current->pid, 428 pool->dev_name, pool->name, current->pid,
434 npages_to_free, nr_free); 429 npages_to_free, nr_free);
435 } 430 }
436#endif 431#endif
437 pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), 432 pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
438 GFP_KERNEL); 433 GFP_KERNEL);
439 434
440 if (!pages_to_free) { 435 if (!pages_to_free) {
441 pr_err(TTM_PFX 436 pr_err("%s: Failed to allocate memory for pool free operation\n",
442 "%s: Failed to allocate memory for pool free operation.\n", 437 pool->dev_name);
443 pool->dev_name);
444 return 0; 438 return 0;
445 } 439 }
446 INIT_LIST_HEAD(&d_pages); 440 INIT_LIST_HEAD(&d_pages);
@@ -723,23 +717,21 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
723 caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); 717 caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
724 718
725 if (!caching_array) { 719 if (!caching_array) {
726 pr_err(TTM_PFX 720 pr_err("%s: Unable to allocate table for new pages\n",
727 "%s: Unable to allocate table for new pages.", 721 pool->dev_name);
728 pool->dev_name);
729 return -ENOMEM; 722 return -ENOMEM;
730 } 723 }
731 724
732 if (count > 1) { 725 if (count > 1) {
733 pr_debug("%s: (%s:%d) Getting %d pages\n", 726 pr_debug("%s: (%s:%d) Getting %d pages\n",
734 pool->dev_name, pool->name, current->pid, 727 pool->dev_name, pool->name, current->pid, count);
735 count);
736 } 728 }
737 729
738 for (i = 0, cpages = 0; i < count; ++i) { 730 for (i = 0, cpages = 0; i < count; ++i) {
739 dma_p = __ttm_dma_alloc_page(pool); 731 dma_p = __ttm_dma_alloc_page(pool);
740 if (!dma_p) { 732 if (!dma_p) {
741 pr_err(TTM_PFX "%s: Unable to get page %u.\n", 733 pr_err("%s: Unable to get page %u\n",
742 pool->dev_name, i); 734 pool->dev_name, i);
743 735
744 /* store already allocated pages in the pool after 736 /* store already allocated pages in the pool after
745 * setting the caching state */ 737 * setting the caching state */
@@ -821,8 +813,8 @@ static int ttm_dma_page_pool_fill_locked(struct dma_pool *pool,
821 struct dma_page *d_page; 813 struct dma_page *d_page;
822 unsigned cpages = 0; 814 unsigned cpages = 0;
823 815
824 pr_err(TTM_PFX "%s: Failed to fill %s pool (r:%d)!\n", 816 pr_err("%s: Failed to fill %s pool (r:%d)!\n",
825 pool->dev_name, pool->name, r); 817 pool->dev_name, pool->name, r);
826 818
827 list_for_each_entry(d_page, &d_pages, page_list) { 819 list_for_each_entry(d_page, &d_pages, page_list) {
828 cpages++; 820 cpages++;
@@ -1038,8 +1030,8 @@ static int ttm_dma_pool_mm_shrink(struct shrinker *shrink,
1038 nr_free = shrink_pages; 1030 nr_free = shrink_pages;
1039 shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free); 1031 shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free);
1040 pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n", 1032 pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n",
1041 p->pool->dev_name, p->pool->name, current->pid, nr_free, 1033 p->pool->dev_name, p->pool->name, current->pid,
1042 shrink_pages); 1034 nr_free, shrink_pages);
1043 } 1035 }
1044 mutex_unlock(&_manager->lock); 1036 mutex_unlock(&_manager->lock);
1045 /* return estimated number of unused pages in pool */ 1037 /* return estimated number of unused pages in pool */
@@ -1064,7 +1056,7 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
1064 1056
1065 WARN_ON(_manager); 1057 WARN_ON(_manager);
1066 1058
1067 printk(KERN_INFO TTM_PFX "Initializing DMA pool allocator.\n"); 1059 pr_info("Initializing DMA pool allocator\n");
1068 1060
1069 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); 1061 _manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
1070 if (!_manager) 1062 if (!_manager)
@@ -1097,7 +1089,7 @@ void ttm_dma_page_alloc_fini(void)
1097{ 1089{
1098 struct device_pools *p, *t; 1090 struct device_pools *p, *t;
1099 1091
1100 printk(KERN_INFO TTM_PFX "Finalizing DMA pool allocator.\n"); 1092 pr_info("Finalizing DMA pool allocator\n");
1101 ttm_dma_pool_mm_shrink_fini(_manager); 1093 ttm_dma_pool_mm_shrink_fini(_manager);
1102 1094
1103 list_for_each_entry_safe_reverse(p, t, &_manager->pools, pools) { 1095 list_for_each_entry_safe_reverse(p, t, &_manager->pools, pools) {
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index c10cf5e2443..fa09daf9a50 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -28,6 +28,8 @@
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> 28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */ 29 */
30 30
31#define pr_fmt(fmt) "[TTM] " fmt
32
31#include <linux/sched.h> 33#include <linux/sched.h>
32#include <linux/highmem.h> 34#include <linux/highmem.h>
33#include <linux/pagemap.h> 35#include <linux/pagemap.h>
@@ -196,7 +198,7 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev,
196 ttm_tt_alloc_page_directory(ttm); 198 ttm_tt_alloc_page_directory(ttm);
197 if (!ttm->pages) { 199 if (!ttm->pages) {
198 ttm_tt_destroy(ttm); 200 ttm_tt_destroy(ttm);
199 printk(KERN_ERR TTM_PFX "Failed allocating page table\n"); 201 pr_err("Failed allocating page table\n");
200 return -ENOMEM; 202 return -ENOMEM;
201 } 203 }
202 return 0; 204 return 0;
@@ -229,7 +231,7 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev,
229 ttm_dma_tt_alloc_page_directory(ttm_dma); 231 ttm_dma_tt_alloc_page_directory(ttm_dma);
230 if (!ttm->pages || !ttm_dma->dma_address) { 232 if (!ttm->pages || !ttm_dma->dma_address) {
231 ttm_tt_destroy(ttm); 233 ttm_tt_destroy(ttm);
232 printk(KERN_ERR TTM_PFX "Failed allocating page table\n"); 234 pr_err("Failed allocating page table\n");
233 return -ENOMEM; 235 return -ENOMEM;
234 } 236 }
235 return 0; 237 return 0;
@@ -347,7 +349,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
347 ttm->num_pages << PAGE_SHIFT, 349 ttm->num_pages << PAGE_SHIFT,
348 0); 350 0);
349 if (unlikely(IS_ERR(swap_storage))) { 351 if (unlikely(IS_ERR(swap_storage))) {
350 printk(KERN_ERR "Failed allocating swap storage.\n"); 352 pr_err("Failed allocating swap storage\n");
351 return PTR_ERR(swap_storage); 353 return PTR_ERR(swap_storage);
352 } 354 }
353 } else 355 } else