Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/ttm drm/ttm: Cast to potentially large...



details:   https://anonhg.NetBSD.org/src/rev/52d8eb4423f2
branches:  trunk
changeset: 368599:52d8eb4423f2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Jul 21 08:07:56 2022 +0000

description:
drm/ttm: Cast to potentially larger types before << PAGE_SHIFT.

Not sure if this is a problem but it might affect, e.g., i386pae.
Can't hurt, in any case, to cast to what the type will be after the
shift anyway.

diffstat:

 sys/external/bsd/drm2/ttm/ttm_bo_vm.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (53 lines):

diff -r 020962e99321 -r 52d8eb4423f2 sys/external/bsd/drm2/ttm/ttm_bo_vm.c
--- a/sys/external/bsd/drm2/ttm/ttm_bo_vm.c     Thu Jul 21 07:53:28 2022 +0000
+++ b/sys/external/bsd/drm2/ttm/ttm_bo_vm.c     Thu Jul 21 08:07:56 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttm_bo_vm.c,v 1.21 2022/07/20 01:12:14 riastradh Exp $ */
+/*     $NetBSD: ttm_bo_vm.c,v 1.22 2022/07/21 08:07:56 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,v 1.21 2022/07/20 01:12:14 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo_vm.c,v 1.22 2022/07/21 08:07:56 riastradh Exp $");
 
 #include <sys/types.h>
 
@@ -163,7 +163,7 @@
                        .flags = TTM_OPT_FLAG_FORCE_ALLOC,
                };
                u.ttm = bo->ttm;
-               size = (bo->ttm->num_pages << PAGE_SHIFT);
+               size = (size_t)bo->ttm->num_pages << PAGE_SHIFT;
                if (ISSET(bo->mem.placement, TTM_PL_FLAG_CACHED))
                        pgprot = vm_prot;
                else
@@ -195,12 +195,12 @@
                if (!bo->mem.bus.is_iomem) {
                        paddr = page_to_phys(u.ttm->pages[startpage + i]);
                } else if (bdev->driver->io_mem_pfn) {
-                       paddr = (*bdev->driver->io_mem_pfn)(bo, startpage + i)
-                           << PAGE_SHIFT;
+                       paddr = (paddr_t)(*bdev->driver->io_mem_pfn)(bo,
+                           startpage + i) << PAGE_SHIFT;
                } else {
                        const paddr_t cookie = bus_space_mmap(bdev->memt,
-                           u.base, ((startpage + i) << PAGE_SHIFT), vm_prot,
-                           0);
+                           u.base, (off_t)(startpage + i) << PAGE_SHIFT,
+                           vm_prot, 0);
 
                        paddr = pmap_phys_address(cookie);
                }
@@ -292,7 +292,7 @@
        /* Success!  */
        *uobjp = &bo->uvmobj;
        *uoffsetp = (offset -
-           (drm_vma_node_start(&bo->base.vma_node) << PAGE_SHIFT));
+           ((off_t)drm_vma_node_start(&bo->base.vma_node) << PAGE_SHIFT));
        return 0;
 
 fail1: ttm_bo_put(bo);



Home | Main Index | Thread Index | Old Index