summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Kuoppala <mika.kuoppala@linux.intel.com>2015-06-25 11:35:05 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-06-26 04:41:13 -0400
commitc44ef60e437019b8ca1dab8b4d2e8761fd4ce1e9 (patch)
tree15f16c7f8aa77f60f537d85014a3bd37479746cb
parenta05d80eec27460a2dca06676d489637e25f93caf (diff)
drm/i915/gtt: Allow >= 4GB sizes for vm.
We can have exactly 4GB sized ppgtt with 32bit system. size_t is inadequate for this. v2: Convert a lot more places (Daniel) Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com> Reviewed-by: Michel Thierry <michel.thierry@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/char/agp/intel-gtt.c4
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c42
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c6
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c22
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.h12
-rw-r--r--include/drm/intel-gtt.h4
6 files changed, 45 insertions, 45 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 0b4188b9af7c..4734d02ca899 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1408,8 +1408,8 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
1408} 1408}
1409EXPORT_SYMBOL(intel_gmch_probe); 1409EXPORT_SYMBOL(intel_gmch_probe);
1410 1410
1411void intel_gtt_get(size_t *gtt_total, size_t *stolen_size, 1411void intel_gtt_get(u64 *gtt_total, size_t *stolen_size,
1412 phys_addr_t *mappable_base, unsigned long *mappable_end) 1412 phys_addr_t *mappable_base, u64 *mappable_end)
1413{ 1413{
1414 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT; 1414 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
1415 *stolen_size = intel_private.stolen_size; 1415 *stolen_size = intel_private.stolen_size;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 495a6376cf39..bd0fbd6caac2 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -198,7 +198,7 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
198 struct drm_i915_private *dev_priv = dev->dev_private; 198 struct drm_i915_private *dev_priv = dev->dev_private;
199 struct i915_address_space *vm = &dev_priv->gtt.base; 199 struct i915_address_space *vm = &dev_priv->gtt.base;
200 struct i915_vma *vma; 200 struct i915_vma *vma;
201 size_t total_obj_size, total_gtt_size; 201 u64 total_obj_size, total_gtt_size;
202 int count, ret; 202 int count, ret;
203 203
204 ret = mutex_lock_interruptible(&dev->struct_mutex); 204 ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -231,7 +231,7 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
231 } 231 }
232 mutex_unlock(&dev->struct_mutex); 232 mutex_unlock(&dev->struct_mutex);
233 233
234 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", 234 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
235 count, total_obj_size, total_gtt_size); 235 count, total_obj_size, total_gtt_size);
236 return 0; 236 return 0;
237} 237}
@@ -253,7 +253,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
253 struct drm_device *dev = node->minor->dev; 253 struct drm_device *dev = node->minor->dev;
254 struct drm_i915_private *dev_priv = dev->dev_private; 254 struct drm_i915_private *dev_priv = dev->dev_private;
255 struct drm_i915_gem_object *obj; 255 struct drm_i915_gem_object *obj;
256 size_t total_obj_size, total_gtt_size; 256 u64 total_obj_size, total_gtt_size;
257 LIST_HEAD(stolen); 257 LIST_HEAD(stolen);
258 int count, ret; 258 int count, ret;
259 259
@@ -292,7 +292,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
292 } 292 }
293 mutex_unlock(&dev->struct_mutex); 293 mutex_unlock(&dev->struct_mutex);
294 294
295 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", 295 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
296 count, total_obj_size, total_gtt_size); 296 count, total_obj_size, total_gtt_size);
297 return 0; 297 return 0;
298} 298}
@@ -310,10 +310,10 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
310 310
311struct file_stats { 311struct file_stats {
312 struct drm_i915_file_private *file_priv; 312 struct drm_i915_file_private *file_priv;
313 int count; 313 unsigned long count;
314 size_t total, unbound; 314 u64 total, unbound;
315 size_t global, shared; 315 u64 global, shared;
316 size_t active, inactive; 316 u64 active, inactive;
317}; 317};
318 318
319static int per_file_stats(int id, void *ptr, void *data) 319static int per_file_stats(int id, void *ptr, void *data)
@@ -370,7 +370,7 @@ static int per_file_stats(int id, void *ptr, void *data)
370 370
371#define print_file_stats(m, name, stats) do { \ 371#define print_file_stats(m, name, stats) do { \
372 if (stats.count) \ 372 if (stats.count) \
373 seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", \ 373 seq_printf(m, "%s: %lu objects, %llu bytes (%llu active, %llu inactive, %llu global, %llu shared, %llu unbound)\n", \
374 name, \ 374 name, \
375 stats.count, \ 375 stats.count, \
376 stats.total, \ 376 stats.total, \
@@ -420,7 +420,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
420 struct drm_device *dev = node->minor->dev; 420 struct drm_device *dev = node->minor->dev;
421 struct drm_i915_private *dev_priv = dev->dev_private; 421 struct drm_i915_private *dev_priv = dev->dev_private;
422 u32 count, mappable_count, purgeable_count; 422 u32 count, mappable_count, purgeable_count;
423 size_t size, mappable_size, purgeable_size; 423 u64 size, mappable_size, purgeable_size;
424 struct drm_i915_gem_object *obj; 424 struct drm_i915_gem_object *obj;
425 struct i915_address_space *vm = &dev_priv->gtt.base; 425 struct i915_address_space *vm = &dev_priv->gtt.base;
426 struct drm_file *file; 426 struct drm_file *file;
@@ -437,17 +437,17 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
437 437
438 size = count = mappable_size = mappable_count = 0; 438 size = count = mappable_size = mappable_count = 0;
439 count_objects(&dev_priv->mm.bound_list, global_list); 439 count_objects(&dev_priv->mm.bound_list, global_list);
440 seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n", 440 seq_printf(m, "%u [%u] objects, %llu [%llu] bytes in gtt\n",
441 count, mappable_count, size, mappable_size); 441 count, mappable_count, size, mappable_size);
442 442
443 size = count = mappable_size = mappable_count = 0; 443 size = count = mappable_size = mappable_count = 0;
444 count_vmas(&vm->active_list, mm_list); 444 count_vmas(&vm->active_list, mm_list);
445 seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n", 445 seq_printf(m, " %u [%u] active objects, %llu [%llu] bytes\n",
446 count, mappable_count, size, mappable_size); 446 count, mappable_count, size, mappable_size);
447 447
448 size = count = mappable_size = mappable_count = 0; 448 size = count = mappable_size = mappable_count = 0;
449 count_vmas(&vm->inactive_list, mm_list); 449 count_vmas(&vm->inactive_list, mm_list);
450 seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n", 450 seq_printf(m, " %u [%u] inactive objects, %llu [%llu] bytes\n",
451 count, mappable_count, size, mappable_size); 451 count, mappable_count, size, mappable_size);
452 452
453 size = count = purgeable_size = purgeable_count = 0; 453 size = count = purgeable_size = purgeable_count = 0;
@@ -456,7 +456,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
456 if (obj->madv == I915_MADV_DONTNEED) 456 if (obj->madv == I915_MADV_DONTNEED)
457 purgeable_size += obj->base.size, ++purgeable_count; 457 purgeable_size += obj->base.size, ++purgeable_count;
458 } 458 }
459 seq_printf(m, "%u unbound objects, %zu bytes\n", count, size); 459 seq_printf(m, "%u unbound objects, %llu bytes\n", count, size);
460 460
461 size = count = mappable_size = mappable_count = 0; 461 size = count = mappable_size = mappable_count = 0;
462 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { 462 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
@@ -473,16 +473,16 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
473 ++purgeable_count; 473 ++purgeable_count;
474 } 474 }
475 } 475 }
476 seq_printf(m, "%u purgeable objects, %zu bytes\n", 476 seq_printf(m, "%u purgeable objects, %llu bytes\n",
477 purgeable_count, purgeable_size); 477 purgeable_count, purgeable_size);
478 seq_printf(m, "%u pinned mappable objects, %zu bytes\n", 478 seq_printf(m, "%u pinned mappable objects, %llu bytes\n",
479 mappable_count, mappable_size); 479 mappable_count, mappable_size);
480 seq_printf(m, "%u fault mappable objects, %zu bytes\n", 480 seq_printf(m, "%u fault mappable objects, %llu bytes\n",
481 count, size); 481 count, size);
482 482
483 seq_printf(m, "%zu [%lu] gtt total\n", 483 seq_printf(m, "%llu [%llu] gtt total\n",
484 dev_priv->gtt.base.total, 484 dev_priv->gtt.base.total,
485 dev_priv->gtt.mappable_end - dev_priv->gtt.base.start); 485 (u64)dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
486 486
487 seq_putc(m, '\n'); 487 seq_putc(m, '\n');
488 print_batch_pool_stats(m, dev_priv); 488 print_batch_pool_stats(m, dev_priv);
@@ -519,7 +519,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
519 uintptr_t list = (uintptr_t) node->info_ent->data; 519 uintptr_t list = (uintptr_t) node->info_ent->data;
520 struct drm_i915_private *dev_priv = dev->dev_private; 520 struct drm_i915_private *dev_priv = dev->dev_private;
521 struct drm_i915_gem_object *obj; 521 struct drm_i915_gem_object *obj;
522 size_t total_obj_size, total_gtt_size; 522 u64 total_obj_size, total_gtt_size;
523 int count, ret; 523 int count, ret;
524 524
525 ret = mutex_lock_interruptible(&dev->struct_mutex); 525 ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -541,7 +541,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
541 541
542 mutex_unlock(&dev->struct_mutex); 542 mutex_unlock(&dev->struct_mutex);
543 543
544 seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n", 544 seq_printf(m, "Total %d objects, %llu bytes, %llu GTT size\n",
545 count, total_obj_size, total_gtt_size); 545 count, total_obj_size, total_gtt_size);
546 546
547 return 0; 547 return 0;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f79ce9f22312..db1955fad005 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3712,9 +3712,9 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,
3712 struct drm_device *dev = obj->base.dev; 3712 struct drm_device *dev = obj->base.dev;
3713 struct drm_i915_private *dev_priv = dev->dev_private; 3713 struct drm_i915_private *dev_priv = dev->dev_private;
3714 u32 size, fence_size, fence_alignment, unfenced_alignment; 3714 u32 size, fence_size, fence_alignment, unfenced_alignment;
3715 unsigned long start = 3715 u64 start =
3716 flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0; 3716 flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0;
3717 unsigned long end = 3717 u64 end =
3718 flags & PIN_MAPPABLE ? dev_priv->gtt.mappable_end : vm->total; 3718 flags & PIN_MAPPABLE ? dev_priv->gtt.mappable_end : vm->total;
3719 struct i915_vma *vma; 3719 struct i915_vma *vma;
3720 int ret; 3720 int ret;
@@ -3770,7 +3770,7 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,
3770 * attempt to find space. 3770 * attempt to find space.
3771 */ 3771 */
3772 if (size > end) { 3772 if (size > end) {
3773 DRM_DEBUG("Attempting to bind an object (view type=%u) larger than the aperture: size=%u > %s aperture=%lu\n", 3773 DRM_DEBUG("Attempting to bind an object (view type=%u) larger than the aperture: size=%u > %s aperture=%llu\n",
3774 ggtt_view ? ggtt_view->type : 0, 3774 ggtt_view ? ggtt_view->type : 0,
3775 size, 3775 size,
3776 flags & PIN_MAPPABLE ? "mappable" : "total", 3776 flags & PIN_MAPPABLE ? "mappable" : "total",
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 68705e381ada..7a7789e18f38 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2112,7 +2112,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
2112void i915_gem_init_global_gtt(struct drm_device *dev) 2112void i915_gem_init_global_gtt(struct drm_device *dev)
2113{ 2113{
2114 struct drm_i915_private *dev_priv = dev->dev_private; 2114 struct drm_i915_private *dev_priv = dev->dev_private;
2115 unsigned long gtt_size, mappable_size; 2115 u64 gtt_size, mappable_size;
2116 2116
2117 gtt_size = dev_priv->gtt.base.total; 2117 gtt_size = dev_priv->gtt.base.total;
2118 mappable_size = dev_priv->gtt.mappable_end; 2118 mappable_size = dev_priv->gtt.mappable_end;
@@ -2369,13 +2369,13 @@ static void chv_setup_private_ppat(struct drm_i915_private *dev_priv)
2369} 2369}
2370 2370
2371static int gen8_gmch_probe(struct drm_device *dev, 2371static int gen8_gmch_probe(struct drm_device *dev,
2372 size_t *gtt_total, 2372 u64 *gtt_total,
2373 size_t *stolen, 2373 size_t *stolen,
2374 phys_addr_t *mappable_base, 2374 phys_addr_t *mappable_base,
2375 unsigned long *mappable_end) 2375 u64 *mappable_end)
2376{ 2376{
2377 struct drm_i915_private *dev_priv = dev->dev_private; 2377 struct drm_i915_private *dev_priv = dev->dev_private;
2378 unsigned int gtt_size; 2378 u64 gtt_size;
2379 u16 snb_gmch_ctl; 2379 u16 snb_gmch_ctl;
2380 int ret; 2380 int ret;
2381 2381
@@ -2417,10 +2417,10 @@ static int gen8_gmch_probe(struct drm_device *dev,
2417} 2417}
2418 2418
2419static int gen6_gmch_probe(struct drm_device *dev, 2419static int gen6_gmch_probe(struct drm_device *dev,
2420 size_t *gtt_total, 2420 u64 *gtt_total,
2421 size_t *stolen, 2421 size_t *stolen,
2422 phys_addr_t *mappable_base, 2422 phys_addr_t *mappable_base,
2423 unsigned long *mappable_end) 2423 u64 *mappable_end)
2424{ 2424{
2425 struct drm_i915_private *dev_priv = dev->dev_private; 2425 struct drm_i915_private *dev_priv = dev->dev_private;
2426 unsigned int gtt_size; 2426 unsigned int gtt_size;
@@ -2434,7 +2434,7 @@ static int gen6_gmch_probe(struct drm_device *dev,
2434 * a coarse sanity check. 2434 * a coarse sanity check.
2435 */ 2435 */
2436 if ((*mappable_end < (64<<20) || (*mappable_end > (512<<20)))) { 2436 if ((*mappable_end < (64<<20) || (*mappable_end > (512<<20)))) {
2437 DRM_ERROR("Unknown GMADR size (%lx)\n", 2437 DRM_ERROR("Unknown GMADR size (%llx)\n",
2438 dev_priv->gtt.mappable_end); 2438 dev_priv->gtt.mappable_end);
2439 return -ENXIO; 2439 return -ENXIO;
2440 } 2440 }
@@ -2468,10 +2468,10 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
2468} 2468}
2469 2469
2470static int i915_gmch_probe(struct drm_device *dev, 2470static int i915_gmch_probe(struct drm_device *dev,
2471 size_t *gtt_total, 2471 u64 *gtt_total,
2472 size_t *stolen, 2472 size_t *stolen,
2473 phys_addr_t *mappable_base, 2473 phys_addr_t *mappable_base,
2474 unsigned long *mappable_end) 2474 u64 *mappable_end)
2475{ 2475{
2476 struct drm_i915_private *dev_priv = dev->dev_private; 2476 struct drm_i915_private *dev_priv = dev->dev_private;
2477 int ret; 2477 int ret;
@@ -2536,9 +2536,9 @@ int i915_gem_gtt_init(struct drm_device *dev)
2536 gtt->base.dev = dev; 2536 gtt->base.dev = dev;
2537 2537
2538 /* GMADR is the PCI mmio aperture into the global GTT. */ 2538 /* GMADR is the PCI mmio aperture into the global GTT. */
2539 DRM_INFO("Memory usable by graphics device = %zdM\n", 2539 DRM_INFO("Memory usable by graphics device = %lluM\n",
2540 gtt->base.total >> 20); 2540 gtt->base.total >> 20);
2541 DRM_DEBUG_DRIVER("GMADR size = %ldM\n", gtt->mappable_end >> 20); 2541 DRM_DEBUG_DRIVER("GMADR size = %lldM\n", gtt->mappable_end >> 20);
2542 DRM_DEBUG_DRIVER("GTT stolen size = %zdM\n", gtt->stolen_size >> 20); 2542 DRM_DEBUG_DRIVER("GTT stolen size = %zdM\n", gtt->stolen_size >> 20);
2543#ifdef CONFIG_INTEL_IOMMU 2543#ifdef CONFIG_INTEL_IOMMU
2544 if (intel_iommu_gfx_mapped) 2544 if (intel_iommu_gfx_mapped)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 017ea308f8b4..600eec00a1f4 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -235,8 +235,8 @@ struct i915_address_space {
235 struct drm_mm mm; 235 struct drm_mm mm;
236 struct drm_device *dev; 236 struct drm_device *dev;
237 struct list_head global_link; 237 struct list_head global_link;
238 unsigned long start; /* Start offset always 0 for dri2 */ 238 u64 start; /* Start offset always 0 for dri2 */
239 size_t total; /* size addr space maps (ex. 2GB for ggtt) */ 239 u64 total; /* size addr space maps (ex. 2GB for ggtt) */
240 240
241 struct { 241 struct {
242 dma_addr_t addr; 242 dma_addr_t addr;
@@ -302,9 +302,9 @@ struct i915_address_space {
302 */ 302 */
303struct i915_gtt { 303struct i915_gtt {
304 struct i915_address_space base; 304 struct i915_address_space base;
305 size_t stolen_size; /* Total size of stolen memory */
306 305
307 unsigned long mappable_end; /* End offset that we can CPU map */ 306 size_t stolen_size; /* Total size of stolen memory */
307 u64 mappable_end; /* End offset that we can CPU map */
308 struct io_mapping *mappable; /* Mapping to our CPU mappable region */ 308 struct io_mapping *mappable; /* Mapping to our CPU mappable region */
309 phys_addr_t mappable_base; /* PA of our GMADR */ 309 phys_addr_t mappable_base; /* PA of our GMADR */
310 310
@@ -316,9 +316,9 @@ struct i915_gtt {
316 int mtrr; 316 int mtrr;
317 317
318 /* global gtt ops */ 318 /* global gtt ops */
319 int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total, 319 int (*gtt_probe)(struct drm_device *dev, u64 *gtt_total,
320 size_t *stolen, phys_addr_t *mappable_base, 320 size_t *stolen, phys_addr_t *mappable_base,
321 unsigned long *mappable_end); 321 u64 *mappable_end);
322}; 322};
323 323
324struct i915_hw_ppgtt { 324struct i915_hw_ppgtt {
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index b08bdade6002..9e9bddaa58a5 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -3,8 +3,8 @@
3#ifndef _DRM_INTEL_GTT_H 3#ifndef _DRM_INTEL_GTT_H
4#define _DRM_INTEL_GTT_H 4#define _DRM_INTEL_GTT_H
5 5
6void intel_gtt_get(size_t *gtt_total, size_t *stolen_size, 6void intel_gtt_get(u64 *gtt_total, size_t *stolen_size,
7 phys_addr_t *mappable_base, unsigned long *mappable_end); 7 phys_addr_t *mappable_base, u64 *mappable_end);
8 8
9int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, 9int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
10 struct agp_bridge_data *bridge); 10 struct agp_bridge_data *bridge);