aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/omap_gem.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-12-14 18:07:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-14 19:04:09 -0500
commit1a29d85eb0f19b7d8271923d8917d7b4f5540b3e (patch)
tree76bf90e637fb4b0c95a7a9eb81bc9aec71329a4e /drivers/gpu/drm/omapdrm/omap_gem.c
parent82b0f8c39a3869b6fd2a10e180a862248736ec6f (diff)
mm: use vmf->address instead of of vmf->virtual_address
Every single user of vmf->virtual_address typed that entry to unsigned long before doing anything with it so the type of virtual_address does not really provide us any additional safety. Just use masked vmf->address which already has the appropriate type. Link: http://lkml.kernel.org/r/1479460644-25076-3-git-send-email-jack@suse.cz Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_gem.c')
-rw-r--r--drivers/gpu/drm/omapdrm/omap_gem.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index d4e1e11466f8..4a90c690f09e 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -398,8 +398,7 @@ static int fault_1d(struct drm_gem_object *obj,
398 pgoff_t pgoff; 398 pgoff_t pgoff;
399 399
400 /* We don't use vmf->pgoff since that has the fake offset: */ 400 /* We don't use vmf->pgoff since that has the fake offset: */
401 pgoff = ((unsigned long)vmf->virtual_address - 401 pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
402 vma->vm_start) >> PAGE_SHIFT;
403 402
404 if (omap_obj->pages) { 403 if (omap_obj->pages) {
405 omap_gem_cpu_sync(obj, pgoff); 404 omap_gem_cpu_sync(obj, pgoff);
@@ -409,11 +408,10 @@ static int fault_1d(struct drm_gem_object *obj,
409 pfn = (omap_obj->paddr >> PAGE_SHIFT) + pgoff; 408 pfn = (omap_obj->paddr >> PAGE_SHIFT) + pgoff;
410 } 409 }
411 410
412 VERB("Inserting %p pfn %lx, pa %lx", vmf->virtual_address, 411 VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
413 pfn, pfn << PAGE_SHIFT); 412 pfn, pfn << PAGE_SHIFT);
414 413
415 return vm_insert_mixed(vma, (unsigned long)vmf->virtual_address, 414 return vm_insert_mixed(vma, vmf->address, __pfn_to_pfn_t(pfn, PFN_DEV));
416 __pfn_to_pfn_t(pfn, PFN_DEV));
417} 415}
418 416
419/* Special handling for the case of faulting in 2d tiled buffers */ 417/* Special handling for the case of faulting in 2d tiled buffers */
@@ -427,7 +425,7 @@ static int fault_2d(struct drm_gem_object *obj,
427 struct page *pages[64]; /* XXX is this too much to have on stack? */ 425 struct page *pages[64]; /* XXX is this too much to have on stack? */
428 unsigned long pfn; 426 unsigned long pfn;
429 pgoff_t pgoff, base_pgoff; 427 pgoff_t pgoff, base_pgoff;
430 void __user *vaddr; 428 unsigned long vaddr;
431 int i, ret, slots; 429 int i, ret, slots;
432 430
433 /* 431 /*
@@ -447,8 +445,7 @@ static int fault_2d(struct drm_gem_object *obj,
447 const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE); 445 const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
448 446
449 /* We don't use vmf->pgoff since that has the fake offset: */ 447 /* We don't use vmf->pgoff since that has the fake offset: */
450 pgoff = ((unsigned long)vmf->virtual_address - 448 pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
451 vma->vm_start) >> PAGE_SHIFT;
452 449
453 /* 450 /*
454 * Actual address we start mapping at is rounded down to previous slot 451 * Actual address we start mapping at is rounded down to previous slot
@@ -459,7 +456,7 @@ static int fault_2d(struct drm_gem_object *obj,
459 /* figure out buffer width in slots */ 456 /* figure out buffer width in slots */
460 slots = omap_obj->width >> priv->usergart[fmt].slot_shift; 457 slots = omap_obj->width >> priv->usergart[fmt].slot_shift;
461 458
462 vaddr = vmf->virtual_address - ((pgoff - base_pgoff) << PAGE_SHIFT); 459 vaddr = vmf->address - ((pgoff - base_pgoff) << PAGE_SHIFT);
463 460
464 entry = &priv->usergart[fmt].entry[priv->usergart[fmt].last]; 461 entry = &priv->usergart[fmt].entry[priv->usergart[fmt].last];
465 462
@@ -503,12 +500,11 @@ static int fault_2d(struct drm_gem_object *obj,
503 500
504 pfn = entry->paddr >> PAGE_SHIFT; 501 pfn = entry->paddr >> PAGE_SHIFT;
505 502
506 VERB("Inserting %p pfn %lx, pa %lx", vmf->virtual_address, 503 VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
507 pfn, pfn << PAGE_SHIFT); 504 pfn, pfn << PAGE_SHIFT);
508 505
509 for (i = n; i > 0; i--) { 506 for (i = n; i > 0; i--) {
510 vm_insert_mixed(vma, (unsigned long)vaddr, 507 vm_insert_mixed(vma, vaddr, __pfn_to_pfn_t(pfn, PFN_DEV));
511 __pfn_to_pfn_t(pfn, PFN_DEV));
512 pfn += priv->usergart[fmt].stride_pfn; 508 pfn += priv->usergart[fmt].stride_pfn;
513 vaddr += PAGE_SIZE * m; 509 vaddr += PAGE_SIZE * m;
514 } 510 }